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 {"direction", MagickDirectionOptions} } },
290 { "ColorFloodfill", { {"geometry", StringReference},
291 {"x", IntegerReference}, {"y", IntegerReference},
292 {"fill", StringReference}, {"bordercolor", StringReference},
293 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
294 { "Composite", { {"image", ImageReference},
295 {"compose", MagickComposeOptions}, {"geometry", StringReference},
296 {"x", IntegerReference}, {"y", IntegerReference},
297 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
298 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
299 {"color", StringReference}, {"mask", ImageReference},
300 {"channel", MagickChannelOptions},
301 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
302 {"blend", StringReference} } },
303 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
304 { "CycleColormap", { {"display", IntegerReference} } },
305 { "Draw", { {"primitive", MagickPrimitiveOptions},
306 {"points", StringReference}, {"method", MagickMethodOptions},
307 {"stroke", StringReference}, {"fill", StringReference},
308 {"strokewidth", RealReference}, {"font", StringReference},
309 {"bordercolor", StringReference}, {"x", RealReference},
310 {"y", RealReference}, {"translate", StringReference},
311 {"scale", StringReference}, {"rotate", RealReference},
312 {"skewX", RealReference}, {"skewY", RealReference},
313 {"tile", ImageReference}, {"pointsize", RealReference},
314 {"antialias", MagickBooleanOptions}, {"density", StringReference},
315 {"linewidth", RealReference}, {"affine", ArrayReference},
316 {"stroke-dashoffset", RealReference},
317 {"stroke-dasharray", ArrayReference},
318 {"interpolate", MagickInterpolateOptions},
319 {"origin", StringReference}, {"text", StringReference},
320 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
321 {"vector-graphics", StringReference}, {"kerning", RealReference},
322 {"interline-spacing", RealReference},
323 {"interword-spacing", RealReference} } },
324 { "Equalize", { {"channel", MagickChannelOptions} } },
325 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
326 {"red", RealReference}, {"green", RealReference},
327 {"blue", RealReference} } },
328 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
329 {"dither-method", MagickDitherOptions} } },
330 { "MatteFloodfill", { {"geometry", StringReference},
331 {"x", IntegerReference}, {"y", IntegerReference},
332 {"opacity", StringReference}, {"bordercolor", StringReference},
333 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
334 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
335 {"saturation", RealReference}, {"whiteness", RealReference},
336 {"brightness", RealReference}, {"lightness", RealReference},
337 {"blackness", RealReference} } },
338 { "Negate", { {"gray", MagickBooleanOptions},
339 {"channel", MagickChannelOptions} } },
340 { "Normalize", { {"channel", MagickChannelOptions} } },
342 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
343 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
344 {"invert", MagickBooleanOptions} } },
345 { "Quantize", { {"colors", IntegerReference},
346 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
347 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
348 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
349 {"dither-method", MagickDitherOptions} } },
350 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
351 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
352 { "Segment", { {"geometry", StringReference},
353 {"cluster-threshold", RealReference},
354 {"smoothing-threshold", RealReference},
355 {"colorspace", MagickColorspaceOptions},
356 {"verbose", MagickBooleanOptions} } },
358 { "Solarize", { {"geometry", StringReference},
359 {"threshold", StringReference} } },
361 { "Texture", { {"texture", ImageReference} } },
362 { "Evaluate", { {"value", RealReference},
363 {"operator", MagickEvaluateOptions},
364 {"channel", MagickChannelOptions} } },
365 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
366 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
367 { "Threshold", { {"threshold", StringReference},
368 {"channel", MagickChannelOptions} } },
369 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
370 {"sigma", RealReference} } },
371 { "Trim", { {"fuzz", StringReference} } },
372 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
373 {"wavelength", RealReference},
374 {"interpolate", MagickInterpolateOptions} } },
375 { "Separate", { {"channel", MagickChannelOptions} } },
377 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
378 {"y", IntegerReference} } },
379 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
381 { "GaussianBlur", { {"geometry", StringReference},
382 {"radius", RealReference}, {"sigma", RealReference},
383 {"channel", MagickChannelOptions} } },
384 { "Convolve", { {"coefficients", ArrayReference},
385 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
386 { "Profile", { {"name", StringReference}, {"profile", StringReference},
387 { "rendering-intent", MagickIntentOptions},
388 { "black-point-compensation", MagickBooleanOptions} } },
389 { "UnsharpMask", { {"geometry", StringReference},
390 {"radius", RealReference}, {"sigma", RealReference},
391 {"amount", RealReference}, {"threshold", RealReference},
392 {"channel", MagickChannelOptions} } },
393 { "MotionBlur", { {"geometry", StringReference},
394 {"radius", RealReference}, {"sigma", RealReference},
395 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
396 { "OrderedDither", { {"threshold", StringReference},
397 {"channel", MagickChannelOptions} } },
398 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
399 {"height", IntegerReference} } },
400 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
401 {"white-point", RealReference}, {"gamma", RealReference},
402 {"channel", MagickChannelOptions}, {"level", StringReference} } },
403 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
404 { "AffineTransform", { {"affine", ArrayReference},
405 {"translate", StringReference}, {"scale", StringReference},
406 {"rotate", RealReference}, {"skewX", RealReference},
407 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
408 {"background", StringReference} } },
409 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
410 { "AdaptiveThreshold", { {"geometry", StringReference},
411 {"width", IntegerReference}, {"height", IntegerReference},
412 {"offset", IntegerReference} } },
413 { "Resample", { {"density", StringReference}, {"x", RealReference},
414 {"y", RealReference}, {"filter", MagickFilterOptions},
415 {"support", RealReference }, {"blur", RealReference } } },
416 { "Describe", { {"file", FileReference} } },
417 { "BlackThreshold", { {"threshold", StringReference},
418 {"channel", MagickChannelOptions} } },
419 { "WhiteThreshold", { {"threshold", StringReference},
420 {"channel", MagickChannelOptions} } },
421 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
422 {"channel", MagickChannelOptions} } },
423 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
424 {"height", IntegerReference} } },
426 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
427 { "Channel", { {"channel", MagickChannelOptions} } },
428 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference}, {"x", IntegerReference},
430 {"y", IntegerReference}, {"fuzz", StringReference},
431 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
432 { "Posterize", { {"levels", IntegerReference},
433 {"dither", MagickBooleanOptions} } },
434 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
435 {"sigma", RealReference}, {"x", IntegerReference},
436 {"y", IntegerReference} } },
437 { "Identify", { {"file", FileReference}, {"features", StringReference},
438 {"unique", MagickBooleanOptions} } },
439 { "SepiaTone", { {"threshold", RealReference} } },
440 { "SigmoidalContrast", { {"geometry", StringReference},
441 {"contrast", RealReference}, {"mid-point", RealReference},
442 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
443 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
444 {"height", IntegerReference}, {"x", IntegerReference},
445 {"y", IntegerReference}, {"fuzz", StringReference},
446 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
447 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
448 {"sigma", RealReference}, {"x", IntegerReference},
449 {"y", IntegerReference}, {"background", StringReference} } },
450 { "ContrastStretch", { {"levels", StringReference},
451 {"black-point", RealReference},{"white-point", RealReference},
452 {"channel", MagickChannelOptions} } },
455 { "AdaptiveSharpen", { {"geometry", StringReference},
456 {"radius", RealReference}, {"sigma", RealReference},
457 {"channel", MagickChannelOptions} } },
461 { "AdaptiveBlur", { {"geometry", StringReference},
462 {"radius", RealReference}, {"sigma", RealReference},
463 {"channel", MagickChannelOptions} } },
464 { "Sketch", { {"geometry", StringReference},
465 {"radius", RealReference}, {"sigma", RealReference},
466 {"angle", RealReference} } },
468 { "AdaptiveResize", { {"geometry", StringReference},
469 {"width", IntegerReference}, {"height", IntegerReference},
470 {"filter", MagickFilterOptions}, {"support", StringReference },
471 {"blur", RealReference } } },
472 { "ClipMask", { {"mask", ImageReference} } },
473 { "LinearStretch", { {"levels", StringReference},
474 {"black-point", RealReference},{"white-point", RealReference} } },
475 { "Recolor", { {"matrix", ArrayReference} } },
476 { "Mask", { {"mask", ImageReference} } },
477 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
478 {"font", StringReference}, {"stroke", StringReference},
479 {"fill", StringReference}, {"strokewidth", RealReference},
480 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
481 {"background", StringReference} } },
482 { "FloodfillPaint", { {"geometry", StringReference},
483 {"x", IntegerReference}, {"y", IntegerReference},
484 {"fill", StringReference}, {"bordercolor", StringReference},
485 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
486 {"invert", MagickBooleanOptions} } },
487 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
488 {"virtual-pixel", MagickVirtualPixelOptions},
489 {"best-fit", MagickBooleanOptions} } },
490 { "Clut", { {"image", ImageReference},
491 {"channel", MagickChannelOptions} } },
492 { "LiquidRescale", { {"geometry", StringReference},
493 {"width", IntegerReference}, {"height", IntegerReference},
494 {"delta-x", RealReference}, {"rigidity", RealReference } } },
495 { "Encipher", { {"passphrase", StringReference} } },
496 { "Decipher", { {"passphrase", StringReference} } },
497 { "Deskew", { {"geometry", StringReference},
498 {"threshold", StringReference} } },
499 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
500 {"dither-method", MagickDitherOptions} } },
501 { "SparseColor", { {"points", ArrayReference},
502 {"method", MagickSparseColorOptions},
503 {"virtual-pixel", MagickVirtualPixelOptions},
504 {"channel", MagickChannelOptions} } },
505 { "Function", { {"parameters", ArrayReference},
506 {"function", MagickFunctionOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions} } },
508 { "SelectiveBlur", { {"geometry", StringReference},
509 {"radius", RealReference}, {"sigma", RealReference},
510 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
511 { "HaldClut", { {"image", ImageReference},
512 {"channel", MagickChannelOptions} } },
513 { "BlueShift", { {"factor", StringReference} } },
514 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
515 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
516 { "ColorDecisionList", {
517 {"color-correction-collection", StringReference} } },
518 { "AutoGamma", { {"channel", MagickChannelOptions} } },
519 { "AutoLevel", { {"channel", MagickChannelOptions} } },
520 { "LevelColors", { {"invert", MagickBooleanOptions},
521 {"black-point", RealReference}, {"white-point", RealReference},
522 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
523 { "Clamp", { {"channel", MagickChannelOptions} } },
524 { "Filter", { {"kernel", StringReference},
525 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
526 { "BrightnessContrast", { {"levels", StringReference},
527 {"brightness", RealReference},{"contrast", RealReference},
528 {"channel", MagickChannelOptions} } },
529 { "Morphology", { {"kernel", StringReference},
530 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
531 {"iterations", IntegerReference} } },
532 { "ColorMatrix", { {"matrix", ArrayReference} } },
536 *magick_registry = (SplayTreeInfo *) NULL;
539 Forward declarations.
542 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
545 strEQcase(const char *,const char *);
548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
552 % C l o n e P a c k a g e I n f o %
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
558 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
561 % The format of the ClonePackageInfo routine is:
563 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
566 % A description of each parameter follows:
568 % o info: a structure of type info.
570 % o exception: Return any errors or warnings in this structure.
573 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
574 ExceptionInfo *exception)
579 clone_info=(struct PackageInfo *) AcquireAlignedMemory(1,sizeof(*clone_info));
580 if (clone_info == (struct PackageInfo *) NULL)
582 ThrowPerlException(exception,ResourceLimitError,
583 "UnableToClonePackageInfo",PackageName);
584 return((struct PackageInfo *) NULL);
586 if (info == (struct PackageInfo *) NULL)
588 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
592 clone_info->image_info=CloneImageInfo(info->image_info);
597 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
605 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
607 % constant() returns a double value for the specified name.
609 % The format of the constant routine is:
611 % double constant(char *name,long sans)
613 % A description of each parameter follows:
615 % o value: Method constant returns a double value for the specified name.
617 % o name: The name of the constant.
619 % o sans: This integer value is not used.
622 static double constant(char *name,long sans)
630 if (strEQ(name,"BlobError"))
632 if (strEQ(name,"BlobWarning"))
638 if (strEQ(name,"CacheError"))
640 if (strEQ(name,"CacheWarning"))
641 return(CacheWarning);
642 if (strEQ(name,"CoderError"))
644 if (strEQ(name,"CoderWarning"))
645 return(CoderWarning);
646 if (strEQ(name,"ConfigureError"))
647 return(ConfigureError);
648 if (strEQ(name,"ConfigureWarning"))
649 return(ConfigureWarning);
650 if (strEQ(name,"CorruptImageError"))
651 return(CorruptImageError);
652 if (strEQ(name,"CorruptImageWarning"))
653 return(CorruptImageWarning);
658 if (strEQ(name,"DelegateError"))
659 return(DelegateError);
660 if (strEQ(name,"DelegateWarning"))
661 return(DelegateWarning);
662 if (strEQ(name,"DrawError"))
664 if (strEQ(name,"DrawWarning"))
670 if (strEQ(name,"ErrorException"))
671 return(ErrorException);
672 if (strEQ(name,"ExceptionError"))
674 if (strEQ(name,"ExceptionWarning"))
675 return(CoderWarning);
680 if (strEQ(name,"FatalErrorException"))
681 return(FatalErrorException);
682 if (strEQ(name,"FileOpenError"))
683 return(FileOpenError);
684 if (strEQ(name,"FileOpenWarning"))
685 return(FileOpenWarning);
690 if (strEQ(name,"ImageError"))
692 if (strEQ(name,"ImageWarning"))
693 return(ImageWarning);
698 if (strEQ(name,"MaxRGB"))
699 return(QuantumRange);
700 if (strEQ(name,"MissingDelegateError"))
701 return(MissingDelegateError);
702 if (strEQ(name,"MissingDelegateWarning"))
703 return(MissingDelegateWarning);
704 if (strEQ(name,"ModuleError"))
706 if (strEQ(name,"ModuleWarning"))
707 return(ModuleWarning);
712 if (strEQ(name,"Opaque"))
713 return(OpaqueOpacity);
714 if (strEQ(name,"OptionError"))
716 if (strEQ(name,"OptionWarning"))
717 return(OptionWarning);
722 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
723 return(MAGICKCORE_QUANTUM_DEPTH);
724 if (strEQ(name,"QuantumDepth"))
725 return(QuantumDepth);
726 if (strEQ(name,"QuantumRange"))
727 return(QuantumRange);
732 if (strEQ(name,"ResourceLimitError"))
733 return(ResourceLimitError);
734 if (strEQ(name,"ResourceLimitWarning"))
735 return(ResourceLimitWarning);
736 if (strEQ(name,"RegistryError"))
737 return(RegistryError);
738 if (strEQ(name,"RegistryWarning"))
739 return(RegistryWarning);
744 if (strEQ(name,"StreamError"))
746 if (strEQ(name,"StreamWarning"))
747 return(StreamWarning);
748 if (strEQ(name,"Success"))
754 if (strEQ(name,"Transparent"))
755 return(TransparentOpacity);
756 if (strEQ(name,"TypeError"))
758 if (strEQ(name,"TypeWarning"))
764 if (strEQ(name,"WarningException"))
765 return(WarningException);
770 if (strEQ(name,"XServerError"))
771 return(XServerError);
772 if (strEQ(name,"XServerWarning"))
773 return(XServerWarning);
782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
786 % D e s t r o y P a c k a g e I n f o %
790 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
792 % Method DestroyPackageInfo frees a previously created info structure.
794 % The format of the DestroyPackageInfo routine is:
796 % DestroyPackageInfo(struct PackageInfo *info)
798 % A description of each parameter follows:
800 % o info: a structure of type info.
803 static void DestroyPackageInfo(struct PackageInfo *info)
805 info->image_info=DestroyImageInfo(info->image_info);
806 info=(struct PackageInfo *) RelinquishMagickMemory(info);
810 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
818 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
820 % Method GetList is recursively called by SetupList to traverse the
821 % Image__Magick reference. If building an reference_vector (see SetupList),
822 % *current is the current position in *reference_vector and *last is the final
823 % entry in *reference_vector.
825 % The format of the GetList routine is:
829 % A description of each parameter follows:
831 % o info: a structure of type info.
834 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,long *current,
835 long *last,ExceptionInfo *exception)
840 if (reference == (SV *) NULL)
842 switch (SvTYPE(reference))
862 previous=(Image *) NULL;
866 for (i=0; i <= n; i++)
872 if (rv && *rv && sv_isobject(*rv))
874 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
876 if (image == (Image *) NULL)
878 if (image == previous)
880 image=CloneImage(image,0,0,MagickTrue,exception);
881 if (image == (Image *) NULL)
884 image->previous=previous;
885 *(previous ? &previous->next : &head)=image;
886 for (previous=image; previous->next; previous=previous->next) ;
894 Blessed scalar, one image.
896 image=(Image *) SvIV(reference);
897 if (image == (Image *) NULL)
899 image->previous=(Image *) NULL;
900 image->next=(Image *) NULL;
901 if (reference_vector)
903 if (*current == *last)
906 if (*reference_vector == (SV **) NULL)
907 *reference_vector=(SV **) AcquireQuantumMemory(*last,
908 sizeof(*reference_vector));
910 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
911 *last,sizeof(*reference_vector));
913 if (*reference_vector == (SV **) NULL)
915 ThrowPerlException(exception,ResourceLimitError,
916 "MemoryAllocationFailed",PackageName);
917 return((Image *) NULL);
919 (*reference_vector)[*current]=reference;
920 (*reference_vector)[++(*current)]=NULL;
927 (void) fprintf(stderr,"GetList: UnrecognizedType %ld\n",
928 (long) SvTYPE(reference));
929 return((Image *) NULL);
933 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
937 % G e t P a c k a g e I n f o %
941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
943 % Method GetPackageInfo looks up or creates an info structure for the given
944 % Image__Magick reference. If it does create a new one, the information in
945 % package_info is used to initialize it.
947 % The format of the GetPackageInfo routine is:
949 % struct PackageInfo *GetPackageInfo(void *reference,
950 % struct PackageInfo *package_info,ExceptionInfo *exception)
952 % A description of each parameter follows:
954 % o info: a structure of type info.
956 % o exception: Return any errors or warnings in this structure.
959 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
960 struct PackageInfo *package_info,ExceptionInfo *exception)
963 message[MaxTextExtent];
971 (void) FormatMagickString(message,MaxTextExtent,"%s::package%s%lx",
972 PackageName,XS_VERSION,(long) reference);
973 sv=perl_get_sv(message,(TRUE | 0x02));
974 if (sv == (SV *) NULL)
976 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
978 return(package_info);
980 if (SvREFCNT(sv) == 0)
981 (void) SvREFCNT_inc(sv);
982 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
984 clone_info=ClonePackageInfo(package_info,exception);
985 sv_setiv(sv,(IV) clone_info);
990 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
994 % S e t A t t r i b u t e %
998 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1000 % SetAttribute() sets the attribute to the value in sval. This can change
1001 % either or both of image or info.
1003 % The format of the SetAttribute routine is:
1005 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1006 % SV *sval,ExceptionInfo *exception)
1008 % A description of each parameter follows:
1010 % o list: a list of strings.
1012 % o string: a character string.
1016 static inline double SiPrefixToDouble(const char *string,const double interval)
1025 value=strtod(string,&q);
1027 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1029 switch (tolower((int) ((unsigned char) *q)))
1031 case '%': value*=pow(scale,0)*interval/100.0; break;
1032 case 'k': value*=pow(scale,1); break;
1033 case 'm': value*=pow(scale,2); break;
1034 case 'g': value*=pow(scale,3); break;
1035 case 't': value*=pow(scale,4); break;
1036 case 'p': value*=pow(scale,5); break;
1037 case 'e': value*=pow(scale,6); break;
1038 case 'z': value*=pow(scale,7); break;
1039 case 'y': value*=pow(scale,8); break;
1045 static inline double StringToDouble(const char *value)
1047 return(strtod(value,(char **) NULL));
1050 static inline long StringToLong(const char *value)
1052 return(strtol(value,(char **) NULL,10));
1055 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1056 const char *attribute,SV *sval,ExceptionInfo *exception)
1083 if (LocaleCompare(attribute,"adjoin") == 0)
1085 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1086 SvPV(sval,na)) : SvIV(sval);
1089 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1094 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1097 if (LocaleCompare(attribute,"alpha") == 0)
1099 sp=SvPOK(sval) ? ParseMagickOption(MagickAlphaOptions,MagickFalse,
1100 SvPV(sval,na)) : SvIV(sval);
1103 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1107 for ( ; image; image=image->next)
1108 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1111 if (LocaleCompare(attribute,"antialias") == 0)
1113 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1114 SvPV(sval,na)) : SvIV(sval);
1117 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1122 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1125 if (LocaleCompare(attribute,"area-limit") == 0)
1130 limit=MagickResourceInfinity;
1131 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1132 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1133 (void) SetMagickResourceLimit(AreaResource,limit);
1136 if (LocaleCompare(attribute,"attenuate") == 0)
1139 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1142 if (LocaleCompare(attribute,"authenticate") == 0)
1145 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1149 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1150 for ( ; image; image=image->next)
1151 SetImageProperty(image,attribute,SvPV(sval,na));
1157 if (LocaleCompare(attribute,"background") == 0)
1159 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1161 info->image_info->background_color=target_color;
1162 for ( ; image; image=image->next)
1163 image->background_color=target_color;
1166 if (LocaleCompare(attribute,"bias") == 0)
1168 for ( ; image; image=image->next)
1169 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1172 if (LocaleCompare(attribute,"blue-primary") == 0)
1174 for ( ; image; image=image->next)
1176 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1177 image->chromaticity.blue_primary.x=geometry_info.rho;
1178 image->chromaticity.blue_primary.y=geometry_info.sigma;
1179 if ((flags & SigmaValue) == 0)
1180 image->chromaticity.blue_primary.y=
1181 image->chromaticity.blue_primary.x;
1185 if (LocaleCompare(attribute,"bordercolor") == 0)
1187 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1189 info->image_info->border_color=target_color;
1190 for ( ; image; image=image->next)
1191 image->border_color=target_color;
1195 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1196 for ( ; image; image=image->next)
1197 SetImageProperty(image,attribute,SvPV(sval,na));
1203 if (LocaleCompare(attribute,"cache-threshold") == 0)
1205 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1206 SiPrefixToDouble(SvPV(sval,na),100.0));
1207 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1208 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1211 if (LocaleCompare(attribute,"clip-mask") == 0)
1216 clip_mask=(Image *) NULL;
1218 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1219 for ( ; image; image=image->next)
1220 SetImageClipMask(image,clip_mask);
1223 if (LocaleNCompare(attribute,"colormap",8) == 0)
1225 for ( ; image; image=image->next)
1233 if (image->storage_class == DirectClass)
1236 items=sscanf(attribute,"%*[^[][%ld",&i);
1237 if (i > (long) image->colors)
1239 if ((strchr(SvPV(sval,na),',') == 0) ||
1240 (strchr(SvPV(sval,na),')') != 0))
1241 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1244 color=image->colormap+i;
1245 pixel.red=color->red;
1246 pixel.green=color->green;
1247 pixel.blue=color->blue;
1248 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1249 pixel.red=geometry_info.rho;
1250 pixel.green=geometry_info.sigma;
1251 pixel.blue=geometry_info.xi;
1252 color->red=ClampToQuantum(pixel.red);
1253 color->green=ClampToQuantum(pixel.green);
1254 color->blue=ClampToQuantum(pixel.blue);
1259 if (LocaleCompare(attribute,"colorspace") == 0)
1261 sp=SvPOK(sval) ? ParseMagickOption(MagickColorspaceOptions,
1262 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1265 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1269 for ( ; image; image=image->next)
1270 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1273 if (LocaleCompare(attribute,"comment") == 0)
1275 for ( ; image; image=image->next)
1276 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1277 info ? info->image_info : (ImageInfo *) NULL,image,
1281 if (LocaleCompare(attribute,"compression") == 0)
1283 sp=SvPOK(sval) ? ParseMagickOption(MagickCompressOptions,
1284 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1287 ThrowPerlException(exception,OptionError,
1288 "UnrecognizedImageCompression",SvPV(sval,na));
1292 info->image_info->compression=(CompressionType) sp;
1293 for ( ; image; image=image->next)
1294 image->compression=(CompressionType) sp;
1298 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1299 for ( ; image; image=image->next)
1300 SetImageProperty(image,attribute,SvPV(sval,na));
1306 if (LocaleCompare(attribute,"debug") == 0)
1308 SetLogEventMask(SvPV(sval,na));
1311 if (LocaleCompare(attribute,"delay") == 0)
1313 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1314 for ( ; image; image=image->next)
1316 image->delay=(unsigned long) floor(geometry_info.rho+0.5);
1317 if ((flags & SigmaValue) != 0)
1318 image->ticks_per_second=(unsigned long)
1319 floor(geometry_info.sigma+0.5);
1323 if (LocaleCompare(attribute,"disk-limit") == 0)
1328 limit=MagickResourceInfinity;
1329 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1330 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1331 (void) SetMagickResourceLimit(DiskResource,limit);
1334 if (LocaleCompare(attribute,"density") == 0)
1336 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1338 ThrowPerlException(exception,OptionError,"MissingGeometry",
1343 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1344 for ( ; image; image=image->next)
1346 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1347 image->x_resolution=geometry_info.rho;
1348 image->y_resolution=geometry_info.sigma;
1349 if ((flags & SigmaValue) == 0)
1350 image->y_resolution=image->x_resolution;
1354 if (LocaleCompare(attribute,"depth") == 0)
1357 info->image_info->depth=SvIV(sval);
1358 for ( ; image; image=image->next)
1359 (void) SetImageDepth(image,SvIV(sval));
1362 if (LocaleCompare(attribute,"dispose") == 0)
1364 sp=SvPOK(sval) ? ParseMagickOption(MagickDisposeOptions,MagickFalse,
1365 SvPV(sval,na)) : SvIV(sval);
1368 ThrowPerlException(exception,OptionError,
1369 "UnrecognizedDisposeMethod",SvPV(sval,na));
1372 for ( ; image; image=image->next)
1373 image->dispose=(DisposeType) sp;
1376 if (LocaleCompare(attribute,"dither") == 0)
1380 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,
1381 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1384 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1388 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1392 if (LocaleCompare(attribute,"display") == 0)
1396 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1400 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1401 for ( ; image; image=image->next)
1402 SetImageProperty(image,attribute,SvPV(sval,na));
1408 if (LocaleCompare(attribute,"endian") == 0)
1410 sp=SvPOK(sval) ? ParseMagickOption(MagickEndianOptions,MagickFalse,
1411 SvPV(sval,na)) : SvIV(sval);
1414 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1419 info->image_info->endian=(EndianType) sp;
1420 for ( ; image; image=image->next)
1421 image->endian=(EndianType) sp;
1424 if (LocaleCompare(attribute,"extract") == 0)
1427 Set image extract geometry.
1429 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1433 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1434 for ( ; image; image=image->next)
1435 SetImageProperty(image,attribute,SvPV(sval,na));
1441 if (LocaleCompare(attribute,"filename") == 0)
1444 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1446 for ( ; image; image=image->next)
1447 (void) CopyMagickString(image->filename,SvPV(sval,na),
1451 if (LocaleCompare(attribute,"file") == 0)
1459 if (info == (struct PackageInfo *) NULL)
1461 io_info=IoIFP(sv_2io(sval));
1462 if (io_info == (PerlIO *) NULL)
1464 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1468 file=PerlIO_findFILE(io_info);
1469 if (file == (FILE *) NULL)
1471 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1475 SetImageInfoFile(info->image_info,file);
1478 if (LocaleCompare(attribute,"fill") == 0)
1481 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1484 if (LocaleCompare(attribute,"font") == 0)
1487 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1490 if (LocaleCompare(attribute,"foreground") == 0)
1492 if (LocaleCompare(attribute,"fuzz") == 0)
1495 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1496 for ( ; image; image=image->next)
1497 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1501 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1502 for ( ; image; image=image->next)
1503 SetImageProperty(image,attribute,SvPV(sval,na));
1509 if (LocaleCompare(attribute,"gamma") == 0)
1511 for ( ; image; image=image->next)
1512 image->gamma=SvNV(sval);
1515 if (LocaleCompare(attribute,"gravity") == 0)
1517 sp=SvPOK(sval) ? ParseMagickOption(MagickGravityOptions,MagickFalse,
1518 SvPV(sval,na)) : SvIV(sval);
1521 ThrowPerlException(exception,OptionError,
1522 "UnrecognizedGravityType",SvPV(sval,na));
1525 for ( ; image; image=image->next)
1526 image->gravity=(GravityType) sp;
1529 if (LocaleCompare(attribute,"green-primary") == 0)
1531 for ( ; image; image=image->next)
1533 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1534 image->chromaticity.green_primary.x=geometry_info.rho;
1535 image->chromaticity.green_primary.y=geometry_info.sigma;
1536 if ((flags & SigmaValue) == 0)
1537 image->chromaticity.green_primary.y=
1538 image->chromaticity.green_primary.x;
1543 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1544 for ( ; image; image=image->next)
1545 SetImageProperty(image,attribute,SvPV(sval,na));
1551 if (LocaleNCompare(attribute,"index",5) == 0)
1562 register PixelPacket
1568 for ( ; image; image=image->next)
1570 if (image->storage_class != PseudoClass)
1574 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1575 image_view=AcquireCacheView(image);
1576 p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1577 if (p != (PixelPacket *) NULL)
1579 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1580 items=sscanf(SvPV(sval,na),"%ld",&index);
1581 if ((index >= 0) && (index < (long) image->colors))
1582 *indexes=(IndexPacket) index;
1583 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1585 image_view=DestroyCacheView(image_view);
1589 if (LocaleCompare(attribute,"iterations") == 0)
1592 for ( ; image; image=image->next)
1593 image->iterations=SvIV(sval);
1596 if (LocaleCompare(attribute,"interlace") == 0)
1598 sp=SvPOK(sval) ? ParseMagickOption(MagickInterlaceOptions,MagickFalse,
1599 SvPV(sval,na)) : SvIV(sval);
1602 ThrowPerlException(exception,OptionError,
1603 "UnrecognizedInterlaceType",SvPV(sval,na));
1607 info->image_info->interlace=(InterlaceType) sp;
1608 for ( ; image; image=image->next)
1609 image->interlace=(InterlaceType) sp;
1613 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1614 for ( ; image; image=image->next)
1615 SetImageProperty(image,attribute,SvPV(sval,na));
1621 if (LocaleCompare(attribute,"label") == 0)
1623 for ( ; image; image=image->next)
1624 (void) SetImageProperty(image,"label",InterpretImageProperties(
1625 info ? info->image_info : (ImageInfo *) NULL,image,
1629 if (LocaleCompare(attribute,"loop") == 0)
1632 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1633 for ( ; image; image=image->next)
1634 SetImageProperty(image,attribute,SvPV(sval,na));
1640 if (LocaleCompare(attribute,"magick") == 0)
1643 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
1644 "%.1024s:",SvPV(sval,na));
1645 for ( ; image; image=image->next)
1646 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1649 if (LocaleCompare(attribute,"map-limit") == 0)
1654 limit=MagickResourceInfinity;
1655 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1656 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1657 (void) SetMagickResourceLimit(MapResource,limit);
1660 if (LocaleCompare(attribute,"mask") == 0)
1665 mask=(Image *) NULL;
1667 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1668 for ( ; image; image=image->next)
1669 SetImageMask(image,mask);
1672 if (LocaleCompare(attribute,"mattecolor") == 0)
1674 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1676 info->image_info->matte_color=target_color;
1677 for ( ; image; image=image->next)
1678 image->matte_color=target_color;
1681 if (LocaleCompare(attribute,"matte") == 0)
1683 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1684 SvPV(sval,na)) : SvIV(sval);
1687 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1691 for ( ; image; image=image->next)
1692 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1695 if (LocaleCompare(attribute,"memory-limit") == 0)
1700 limit=MagickResourceInfinity;
1701 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1702 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1703 (void) SetMagickResourceLimit(MemoryResource,limit);
1706 if (LocaleCompare(attribute,"monochrome") == 0)
1708 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
1709 SvPV(sval,na)) : SvIV(sval);
1712 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1717 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1718 for ( ; image; image=image->next)
1719 (void) SetImageType(image,BilevelType);
1723 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1724 for ( ; image; image=image->next)
1725 SetImageProperty(image,attribute,SvPV(sval,na));
1731 if (LocaleCompare(attribute,"option") == 0)
1734 DefineImageOption(info->image_info,SvPV(sval,na));
1737 if (LocaleCompare(attribute,"orientation") == 0)
1739 sp=SvPOK(sval) ? ParseMagickOption(MagickOrientationOptions,
1740 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1743 ThrowPerlException(exception,OptionError,
1744 "UnrecognizedOrientationType",SvPV(sval,na));
1748 info->image_info->orientation=(OrientationType) sp;
1749 for ( ; image; image=image->next)
1750 image->orientation=(OrientationType) sp;
1754 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1755 for ( ; image; image=image->next)
1756 SetImageProperty(image,attribute,SvPV(sval,na));
1762 if (LocaleCompare(attribute,"page") == 0)
1767 geometry=GetPageGeometry(SvPV(sval,na));
1769 (void) CloneString(&info->image_info->page,geometry);
1770 for ( ; image; image=image->next)
1771 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1772 geometry=(char *) RelinquishMagickMemory(geometry);
1775 if (LocaleCompare(attribute,"pen") == 0)
1778 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1781 if (LocaleNCompare(attribute,"pixel",5) == 0)
1789 register IndexPacket
1792 register PixelPacket
1798 for ( ; image; image=image->next)
1800 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1804 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1805 image_view=AcquireCacheView(image);
1806 p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1807 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1808 if (p != (PixelPacket *) NULL)
1810 if ((strchr(SvPV(sval,na),',') == 0) ||
1811 (strchr(SvPV(sval,na),')') != 0))
1812 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1815 GetMagickPixelPacket(image,&pixel);
1816 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1817 pixel.red=geometry_info.rho;
1818 if ((flags & SigmaValue) != 0)
1819 pixel.green=geometry_info.sigma;
1820 if ((flags & XiValue) != 0)
1821 pixel.blue=geometry_info.xi;
1822 if ((flags & PsiValue) != 0)
1823 pixel.opacity=geometry_info.psi;
1824 if ((flags & ChiValue) != 0)
1825 pixel.index=geometry_info.chi;
1827 p->red=ClampToQuantum(pixel.red);
1828 p->green=ClampToQuantum(pixel.green);
1829 p->blue=ClampToQuantum(pixel.blue);
1830 p->opacity=ClampToQuantum(pixel.opacity);
1831 if (((image->colorspace == CMYKColorspace) ||
1832 (image->storage_class == PseudoClass)) &&
1833 (indexes != (IndexPacket *) NULL))
1834 *indexes=ClampToQuantum(pixel.index);
1835 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1837 image_view=DestroyCacheView(image_view);
1841 if (LocaleCompare(attribute,"pointsize") == 0)
1845 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1846 info->image_info->pointsize=geometry_info.rho;
1850 if (LocaleCompare(attribute,"preview") == 0)
1852 sp=SvPOK(sval) ? ParseMagickOption(MagickPreviewOptions,MagickFalse,
1853 SvPV(sval,na)) : SvIV(sval);
1856 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1861 info->image_info->preview_type=(PreviewType) sp;
1865 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1866 for ( ; image; image=image->next)
1867 SetImageProperty(image,attribute,SvPV(sval,na));
1873 if (LocaleCompare(attribute,"quality") == 0)
1876 info->image_info->quality=SvIV(sval);
1877 for ( ; image; image=image->next)
1878 image->quality=SvIV(sval);
1882 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1883 for ( ; image; image=image->next)
1884 SetImageProperty(image,attribute,SvPV(sval,na));
1890 if (LocaleCompare(attribute,"red-primary") == 0)
1892 for ( ; image; image=image->next)
1894 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1895 image->chromaticity.red_primary.x=geometry_info.rho;
1896 image->chromaticity.red_primary.y=geometry_info.sigma;
1897 if ((flags & SigmaValue) == 0)
1898 image->chromaticity.red_primary.y=
1899 image->chromaticity.red_primary.x;
1903 if (LocaleCompare(attribute,"render") == 0)
1905 sp=SvPOK(sval) ? ParseMagickOption(MagickIntentOptions,MagickFalse,
1906 SvPV(sval,na)) : SvIV(sval);
1909 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1913 for ( ; image; image=image->next)
1914 image->rendering_intent=(RenderingIntent) sp;
1917 if (LocaleCompare(attribute,"repage") == 0)
1922 for ( ; image; image=image->next)
1924 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1925 if ((flags & WidthValue) != 0)
1927 if ((flags & HeightValue) == 0)
1928 geometry.height=geometry.width;
1929 image->page.width=geometry.width;
1930 image->page.height=geometry.height;
1932 if ((flags & AspectValue) != 0)
1934 if ((flags & XValue) != 0)
1935 image->page.x+=geometry.x;
1936 if ((flags & YValue) != 0)
1937 image->page.y+=geometry.y;
1941 if ((flags & XValue) != 0)
1943 image->page.x=geometry.x;
1944 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1945 image->page.width=image->columns+geometry.x;
1947 if ((flags & YValue) != 0)
1949 image->page.y=geometry.y;
1950 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1951 image->page.height=image->rows+geometry.y;
1958 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1959 for ( ; image; image=image->next)
1960 SetImageProperty(image,attribute,SvPV(sval,na));
1966 if (LocaleCompare(attribute,"sampling-factor") == 0)
1968 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1970 ThrowPerlException(exception,OptionError,"MissingGeometry",
1975 (void) CloneString(&info->image_info->sampling_factor,
1979 if (LocaleCompare(attribute,"scene") == 0)
1981 for ( ; image; image=image->next)
1982 image->scene=SvIV(sval);
1985 if (LocaleCompare(attribute,"subimage") == 0)
1988 info->image_info->subimage=SvIV(sval);
1991 if (LocaleCompare(attribute,"subrange") == 0)
1994 info->image_info->subrange=SvIV(sval);
1997 if (LocaleCompare(attribute,"server") == 0)
1999 if (LocaleCompare(attribute,"size") == 0)
2003 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2005 ThrowPerlException(exception,OptionError,"MissingGeometry",
2009 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2013 if (LocaleCompare(attribute,"stroke") == 0)
2016 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2020 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2021 for ( ; image; image=image->next)
2022 SetImageProperty(image,attribute,SvPV(sval,na));
2028 if (LocaleCompare(attribute,"tile") == 0)
2031 (void) CloneString(&info->image_info->tile,SvPV(sval,na));
2034 if (LocaleCompare(attribute,"texture") == 0)
2037 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2040 if (LocaleCompare(attribute,"tile-offset") == 0)
2045 geometry=GetPageGeometry(SvPV(sval,na));
2047 (void) CloneString(&info->image_info->page,geometry);
2048 for ( ; image; image=image->next)
2049 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2051 geometry=(char *) RelinquishMagickMemory(geometry);
2054 if (LocaleCompare(attribute,"time-limit") == 0)
2059 limit=MagickResourceInfinity;
2060 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2061 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2062 (void) SetMagickResourceLimit(TimeResource,limit);
2065 if (LocaleCompare(attribute,"transparent-color") == 0)
2067 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2069 info->image_info->transparent_color=target_color;
2070 for ( ; image; image=image->next)
2071 image->transparent_color=target_color;
2074 if (LocaleCompare(attribute,"type") == 0)
2076 sp=SvPOK(sval) ? ParseMagickOption(MagickTypeOptions,MagickFalse,
2077 SvPV(sval,na)) : SvIV(sval);
2080 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2085 info->image_info->type=(ImageType) sp;
2086 for ( ; image; image=image->next)
2087 SetImageType(image,(ImageType) sp);
2091 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2092 for ( ; image; image=image->next)
2093 SetImageProperty(image,attribute,SvPV(sval,na));
2099 if (LocaleCompare(attribute,"units") == 0)
2101 sp=SvPOK(sval) ? ParseMagickOption(MagickResolutionOptions,
2102 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2105 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2110 info->image_info->units=(ResolutionType) sp;
2111 for ( ; image; image=image->next)
2116 units=(ResolutionType) sp;
2117 if (image->units != units)
2118 switch (image->units)
2120 case UndefinedResolution:
2121 case PixelsPerInchResolution:
2123 if (units == PixelsPerCentimeterResolution)
2125 image->x_resolution*=2.54;
2126 image->y_resolution*=2.54;
2130 case PixelsPerCentimeterResolution:
2132 if (units == PixelsPerInchResolution)
2134 image->x_resolution/=2.54;
2135 image->y_resolution/=2.54;
2145 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2146 for ( ; image; image=image->next)
2147 SetImageProperty(image,attribute,SvPV(sval,na));
2153 if (LocaleCompare(attribute,"verbose") == 0)
2155 sp=SvPOK(sval) ? ParseMagickOption(MagickBooleanOptions,MagickFalse,
2156 SvPV(sval,na)) : SvIV(sval);
2159 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2164 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2167 if (LocaleCompare(attribute,"view") == 0)
2170 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2173 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2175 sp=SvPOK(sval) ? ParseMagickOption(MagickVirtualPixelOptions,
2176 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2179 ThrowPerlException(exception,OptionError,
2180 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2184 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2185 for ( ; image; image=image->next)
2186 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2190 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2191 for ( ; image; image=image->next)
2192 SetImageProperty(image,attribute,SvPV(sval,na));
2198 if (LocaleCompare(attribute,"white-point") == 0)
2200 for ( ; image; image=image->next)
2202 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2203 image->chromaticity.white_point.x=geometry_info.rho;
2204 image->chromaticity.white_point.y=geometry_info.sigma;
2205 if ((flags & SigmaValue) == 0)
2206 image->chromaticity.white_point.y=
2207 image->chromaticity.white_point.x;
2212 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2213 for ( ; image; image=image->next)
2214 SetImageProperty(image,attribute,SvPV(sval,na));
2220 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2221 for ( ; image; image=image->next)
2222 SetImageProperty(image,attribute,SvPV(sval,na));
2229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2233 % S e t u p L i s t %
2237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2239 % Method SetupList returns the list of all the images linked by their
2240 % image->next and image->previous link lists for use with ImageMagick. If
2241 % info is non-NULL, an info structure is returned in *info. If
2242 % reference_vector is non-NULL,an array of SV* are returned in
2243 % *reference_vector. Reference_vector is used when the images are going to be
2244 % replaced with new Image*'s.
2246 % The format of the SetupList routine is:
2248 % Image *SetupList(SV *reference,struct PackageInfo **info,
2249 % SV ***reference_vector,ExceptionInfo *exception)
2251 % A description of each parameter follows:
2253 % o list: a list of strings.
2255 % o string: a character string.
2257 % o exception: Return any errors or warnings in this structure.
2260 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2261 SV ***reference_vector,ExceptionInfo *exception)
2270 if (reference_vector)
2271 *reference_vector=NULL;
2276 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2277 if (info && (SvTYPE(reference) == SVt_PVAV))
2278 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2288 % s t r E Q c a s e %
2292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2294 % strEQcase() compares two strings and returns 0 if they are the
2295 % same or if the second string runs out first. The comparison is case
2298 % The format of the strEQcase routine is:
2300 % long strEQcase(const char *p,const char *q)
2302 % A description of each parameter follows:
2304 % o p: a character string.
2306 % o q: a character string.
2310 static long strEQcase(const char *p,const char *q)
2318 for (i=0 ; (c=(*q)) != 0; i++)
2320 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2321 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2326 return(((*q == 0) && (*p == 0)) ? i : 0);
2330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2334 % I m a g e : : M a g i c k %
2338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2342 MODULE = Image::Magick PACKAGE = Image::Magick
2347 MagickCoreGenesis("PerlMagick",MagickFalse);
2348 SetWarningHandler(NULL);
2349 SetErrorHandler(NULL);
2350 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2351 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2357 if (magick_registry != (SplayTreeInfo *) NULL)
2358 magick_registry=DestroySplayTree(magick_registry);
2359 MagickCoreTerminus();
2363 constant(name,argument)
2368 ###############################################################################
2376 ###############################################################################
2381 Image::Magick ref=NO_INIT
2405 exception=AcquireExceptionInfo();
2406 perl_exception=newSVpv("",0);
2407 package_info=(struct PackageInfo *) NULL;
2408 if (sv_isobject(ST(0)) == 0)
2410 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2414 reference=SvRV(ST(0));
2415 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2416 if (image == (Image *) NULL)
2418 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2422 package_info=ClonePackageInfo(info,exception);
2424 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2427 for (i=2; i < items; i+=2)
2428 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2430 (void) AnimateImages(package_info->image_info,image);
2431 (void) CatchImageException(image);
2432 InheritException(exception,&image->exception);
2435 if (package_info != (struct PackageInfo *) NULL)
2436 DestroyPackageInfo(package_info);
2437 InheritPerlException(exception,perl_exception);
2438 exception=DestroyExceptionInfo(exception);
2439 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2440 SvPOK_on(perl_exception);
2441 ST(0)=sv_2mortal(perl_exception);
2446 ###############################################################################
2454 ###############################################################################
2459 Image::Magick ref=NO_INIT
2497 exception=AcquireExceptionInfo();
2498 perl_exception=newSVpv("",0);
2501 if (sv_isobject(ST(0)) == 0)
2503 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2507 reference=SvRV(ST(0));
2508 hv=SvSTASH(reference);
2510 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2512 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2513 if (image == (Image *) NULL)
2515 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2519 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2524 for (i=2; i < items; i+=2)
2526 attribute=(char *) SvPV(ST(i-1),na);
2532 if (LocaleCompare(attribute,"stack") == 0)
2534 stack=ParseMagickOption(MagickBooleanOptions,MagickFalse,
2538 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2556 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2557 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2559 for ( ; image; image=image->next)
2561 AddImageToRegistry(image);
2563 av_push(av,sv_bless(rv,hv));
2566 exception=DestroyExceptionInfo(exception);
2568 SvREFCNT_dec(perl_exception);
2572 InheritPerlException(exception,perl_exception);
2573 exception=DestroyExceptionInfo(exception);
2574 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2575 SvPOK_on(perl_exception);
2576 ST(0)=sv_2mortal(perl_exception);
2581 ###############################################################################
2589 ###############################################################################
2594 Image::Magick ref=NO_INIT
2625 exception=AcquireExceptionInfo();
2626 perl_exception=newSVpv("",0);
2627 if (sv_isobject(ST(0)) == 0)
2629 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2633 reference=SvRV(ST(0));
2634 hv=SvSTASH(reference);
2635 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2636 if (image == (Image *) NULL)
2638 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2642 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2643 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2646 Create blessed Perl array for the returned image.
2649 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2651 AddImageToRegistry(image);
2653 av_push(av,sv_bless(rv,hv));
2655 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2656 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
2657 "average-%.*s",(int) (MaxTextExtent-9),
2658 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2659 (void) CopyMagickString(image->filename,info->image_info->filename,
2661 SetImageInfo(info->image_info,0,exception);
2662 exception=DestroyExceptionInfo(exception);
2663 SvREFCNT_dec(perl_exception);
2667 InheritPerlException(exception,perl_exception);
2668 exception=DestroyExceptionInfo(exception);
2669 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2670 SvPOK_on(perl_exception);
2671 ST(0)=sv_2mortal(perl_exception);
2676 ###############################################################################
2680 # B l o b T o I m a g e #
2684 ###############################################################################
2688 BlobToImage(ref,...)
2689 Image::Magick ref=NO_INIT
2735 exception=AcquireExceptionInfo();
2736 perl_exception=newSVpv("",0);
2738 ac=(items < 2) ? 1 : items-1;
2739 length=(STRLEN *) NULL;
2740 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2741 if (list == (char **) NULL)
2743 ThrowPerlException(exception,ResourceLimitError,
2744 "MemoryAllocationFailed",PackageName);
2747 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2748 if (length == (STRLEN *) NULL)
2750 ThrowPerlException(exception,ResourceLimitError,
2751 "MemoryAllocationFailed",PackageName);
2754 if (sv_isobject(ST(0)) == 0)
2756 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2760 reference=SvRV(ST(0));
2761 hv=SvSTASH(reference);
2762 if (SvTYPE(reference) != SVt_PVAV)
2764 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2768 av=(AV *) reference;
2769 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2774 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2777 for (n=0, i=0; i < ac; i++)
2779 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2780 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2782 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2787 list[n]=(char *) NULL;
2789 for (i=number_images=0; i < n; i++)
2791 image=BlobToImage(info->image_info,list[i],length[i],exception);
2792 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2794 for ( ; image; image=image->next)
2796 AddImageToRegistry(image);
2798 av_push(av,sv_bless(rv,hv));
2806 for (i=0; i < n; i++)
2807 if (list[i] != (char *) NULL)
2808 for (p=keep; list[i] != *p++; )
2809 if (*p == (char *) NULL)
2811 list[i]=(char *) RelinquishMagickMemory(list[i]);
2817 list=(char **) RelinquishMagickMemory(list);
2819 length=(STRLEN *) RelinquishMagickMemory(length);
2820 InheritPerlException(exception,perl_exception);
2821 exception=DestroyExceptionInfo(exception);
2822 sv_setiv(perl_exception,(IV) number_images);
2823 SvPOK_on(perl_exception);
2824 ST(0)=sv_2mortal(perl_exception);
2829 ###############################################################################
2837 ###############################################################################
2842 Image::Magick ref=NO_INIT
2875 exception=AcquireExceptionInfo();
2876 perl_exception=newSVpv("",0);
2877 if (sv_isobject(ST(0)) == 0)
2879 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2883 reference=SvRV(ST(0));
2884 hv=SvSTASH(reference);
2885 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2886 if (image == (Image *) NULL)
2888 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2893 Create blessed Perl array for the returned image.
2896 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2898 for ( ; image; image=image->next)
2900 clone=CloneImage(image,0,0,MagickTrue,exception);
2901 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2903 AddImageToRegistry(clone);
2905 av_push(av,sv_bless(rv,hv));
2908 exception=DestroyExceptionInfo(exception);
2909 SvREFCNT_dec(perl_exception);
2913 InheritPerlException(exception,perl_exception);
2914 exception=DestroyExceptionInfo(exception);
2915 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2916 SvPOK_on(perl_exception);
2917 ST(0)=sv_2mortal(perl_exception);
2922 ###############################################################################
2930 ###############################################################################
2938 if (magick_registry != (SplayTreeInfo *) NULL)
2943 ResetSplayTreeIterator(magick_registry);
2944 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2945 while (p != (Image *) NULL)
2948 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2954 ###############################################################################
2962 ###############################################################################
2967 Image::Magick ref=NO_INIT
2996 exception=AcquireExceptionInfo();
2997 perl_exception=newSVpv("",0);
2998 if (sv_isobject(ST(0)) == 0)
3000 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3004 reference=SvRV(ST(0));
3005 hv=SvSTASH(reference);
3007 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3009 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3010 if (image == (Image *) NULL)
3012 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3016 image=CoalesceImages(image,exception);
3017 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3019 for ( ; image; image=image->next)
3021 AddImageToRegistry(image);
3023 av_push(av,sv_bless(rv,hv));
3026 exception=DestroyExceptionInfo(exception);
3028 SvREFCNT_dec(perl_exception);
3032 InheritPerlException(exception,perl_exception);
3033 exception=DestroyExceptionInfo(exception);
3034 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3035 SvPOK_on(perl_exception);
3036 ST(0)=sv_2mortal(perl_exception);
3041 ###############################################################################
3049 ###############################################################################
3054 Image::Magick ref=NO_INIT
3103 exception=AcquireExceptionInfo();
3104 perl_exception=newSVpv("",0);
3107 if (sv_isobject(ST(0)) == 0)
3109 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3113 reference=SvRV(ST(0));
3114 hv=SvSTASH(reference);
3116 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3118 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3119 if (image == (Image *) NULL)
3121 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3125 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3129 channel=DefaultChannels;
3130 reconstruct_image=image;
3131 metric=RootMeanSquaredErrorMetric;
3132 for (i=2; i < items; i+=2)
3134 attribute=(char *) SvPV(ST(i-1),na);
3140 if (LocaleCompare(attribute,"channel") == 0)
3145 option=ParseChannelOption(SvPV(ST(i),na));
3148 ThrowPerlException(exception,OptionError,
3149 "UnrecognizedType",SvPV(ST(i),na));
3152 channel=(ChannelType) option;
3155 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3162 if (LocaleCompare(attribute,"fuzz") == 0)
3164 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3174 if (LocaleCompare(attribute,"image") == 0)
3176 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3177 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3179 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3186 if (LocaleCompare(attribute,"metric") == 0)
3188 option=ParseMagickOption(MagickMetricOptions,MagickFalse,
3192 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3196 metric=(MetricType) option;
3199 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3205 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3211 difference_image=CompareImageChannels(image,reconstruct_image,channel,
3212 metric,&distortion,exception);
3213 if (difference_image != (Image *) NULL)
3215 difference_image->error.mean_error_per_pixel=distortion;
3216 AddImageToRegistry(difference_image);
3218 av_push(av,sv_bless(rv,hv));
3221 exception=DestroyExceptionInfo(exception);
3223 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3227 InheritPerlException(exception,perl_exception);
3228 exception=DestroyExceptionInfo(exception);
3229 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3230 SvPOK_on(perl_exception);
3231 ST(0)=sv_2mortal(perl_exception);
3236 ###############################################################################
3240 # C o m p a r e L a y e r s #
3244 ###############################################################################
3249 Image::Magick ref=NO_INIT
3251 CompareImageLayers = 1
3253 compareimagelayers = 3
3290 exception=AcquireExceptionInfo();
3291 perl_exception=newSVpv("",0);
3292 if (sv_isobject(ST(0)) == 0)
3294 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3298 reference=SvRV(ST(0));
3299 hv=SvSTASH(reference);
3301 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3303 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3304 if (image == (Image *) NULL)
3306 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3310 method=CompareAnyLayer;
3311 for (i=2; i < items; i+=2)
3313 attribute=(char *) SvPV(ST(i-1),na);
3319 if (LocaleCompare(attribute,"method") == 0)
3321 option=ParseMagickOption(MagickLayerOptions,MagickFalse,
3325 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3329 method=(ImageLayerMethod) option;
3332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3344 image=CompareImageLayers(image,method,exception);
3345 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3347 for ( ; image; image=image->next)
3349 AddImageToRegistry(image);
3351 av_push(av,sv_bless(rv,hv));
3354 exception=DestroyExceptionInfo(exception);
3356 SvREFCNT_dec(perl_exception);
3360 InheritPerlException(exception,perl_exception);
3361 exception=DestroyExceptionInfo(exception);
3362 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3363 SvPOK_on(perl_exception);
3364 ST(0)=sv_2mortal(perl_exception);
3369 ###############################################################################
3377 ###############################################################################
3382 Image::Magick ref=NO_INIT
3388 if (sv_isobject(ST(0)) == 0)
3389 croak("ReferenceIsNotMyType");
3390 reference=SvRV(ST(0));
3391 switch (SvTYPE(reference))
3396 message[MaxTextExtent];
3411 Array (AV *) reference
3413 (void) FormatMagickString(message,MaxTextExtent,"package%s%lx",
3414 XS_VERSION,(long) reference);
3415 hv=gv_stashpv(PackageName, FALSE);
3418 gvp=(GV **) hv_fetch(hv,message,strlen(message),FALSE);
3422 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3424 info=(struct PackageInfo *) SvIV(sv);
3425 DestroyPackageInfo(info);
3427 hv_delete(hv,message,strlen(message),G_DISCARD);
3436 Blessed scalar = (Image *) SvIV(reference)
3438 image=(Image *) SvIV(reference);
3439 if (image != (Image *) NULL)
3440 DeleteImageFromRegistry(reference,image);
3449 ###############################################################################
3457 ###############################################################################
3462 Image::Magick ref=NO_INIT
3486 exception=AcquireExceptionInfo();
3487 perl_exception=newSVpv("",0);
3488 package_info=(struct PackageInfo *) NULL;
3489 if (sv_isobject(ST(0)) == 0)
3491 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3495 reference=SvRV(ST(0));
3496 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3497 if (image == (Image *) NULL)
3499 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3503 package_info=ClonePackageInfo(info,exception);
3505 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3508 for (i=2; i < items; i+=2)
3509 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3511 (void) DisplayImages(package_info->image_info,image);
3512 (void) CatchImageException(image);
3513 InheritException(exception,&image->exception);
3516 if (package_info != (struct PackageInfo *) NULL)
3517 DestroyPackageInfo(package_info);
3518 InheritPerlException(exception,perl_exception);
3519 exception=DestroyExceptionInfo(exception);
3520 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3521 SvPOK_on(perl_exception);
3522 ST(0)=sv_2mortal(perl_exception);
3527 ###############################################################################
3531 # E v a l u a t e I m a g e s #
3535 ###############################################################################
3540 Image::Magick ref=NO_INIT
3562 MagickEvaluateOperator
3577 exception=AcquireExceptionInfo();
3578 perl_exception=newSVpv("",0);
3579 if (sv_isobject(ST(0)) == 0)
3581 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3585 reference=SvRV(ST(0));
3586 hv=SvSTASH(reference);
3587 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3588 if (image == (Image *) NULL)
3590 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3594 op=MeanEvaluateOperator;
3600 in=ParseMagickOption(MagickEvaluateOptions,MagickFalse,(char *)
3604 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3608 op=(MagickEvaluateOperator) in;
3611 for (i=2; i < items; i+=2)
3613 attribute=(char *) SvPV(ST(i-1),na);
3619 if (LocaleCompare(attribute,"operator") == 0)
3624 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
3625 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3628 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3632 op=(MagickEvaluateOperator) in;
3635 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3641 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3647 image=EvaluateImages(image,op,exception);
3648 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3651 Create blessed Perl array for the returned image.
3654 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3656 AddImageToRegistry(image);
3658 av_push(av,sv_bless(rv,hv));
3660 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3661 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
3662 "evaluate-%.*s",(int) (MaxTextExtent-9),
3663 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3664 (void) CopyMagickString(image->filename,info->image_info->filename,
3666 SetImageInfo(info->image_info,0,exception);
3667 exception=DestroyExceptionInfo(exception);
3668 SvREFCNT_dec(perl_exception);
3672 InheritPerlException(exception,perl_exception);
3673 exception=DestroyExceptionInfo(exception);
3674 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3675 SvPOK_on(perl_exception);
3676 ST(0)=sv_2mortal(perl_exception);
3681 ###############################################################################
3689 ###############################################################################
3694 Image::Magick ref=NO_INIT
3701 #define ChannelFeatures(channel,direction) \
3703 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3704 channel_features[channel].angular_second_moment[direction]); \
3705 PUSHs(sv_2mortal(newSVpv(message,0))); \
3706 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3707 channel_features[channel].contrast[direction]); \
3708 PUSHs(sv_2mortal(newSVpv(message,0))); \
3709 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3710 channel_features[channel].contrast[direction]); \
3711 PUSHs(sv_2mortal(newSVpv(message,0))); \
3712 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3713 channel_features[channel].variance_sum_of_squares[direction]); \
3714 PUSHs(sv_2mortal(newSVpv(message,0))); \
3715 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3716 channel_features[channel].inverse_difference_moment[direction]); \
3717 PUSHs(sv_2mortal(newSVpv(message,0))); \
3718 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3719 channel_features[channel].sum_average[direction]); \
3720 PUSHs(sv_2mortal(newSVpv(message,0))); \
3721 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3722 channel_features[channel].sum_variance[direction]); \
3723 PUSHs(sv_2mortal(newSVpv(message,0))); \
3724 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3725 channel_features[channel].sum_entropy[direction]); \
3726 PUSHs(sv_2mortal(newSVpv(message,0))); \
3727 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3728 channel_features[channel].entropy[direction]); \
3729 PUSHs(sv_2mortal(newSVpv(message,0))); \
3730 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3731 channel_features[channel].difference_variance[direction]); \
3732 PUSHs(sv_2mortal(newSVpv(message,0))); \
3733 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3734 channel_features[channel].difference_entropy[direction]); \
3735 PUSHs(sv_2mortal(newSVpv(message,0))); \
3736 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3737 channel_features[channel].measure_of_correlation_1[direction]); \
3738 PUSHs(sv_2mortal(newSVpv(message,0))); \
3739 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3740 channel_features[channel].measure_of_correlation_2[direction]); \
3741 PUSHs(sv_2mortal(newSVpv(message,0))); \
3742 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3743 channel_features[channel].maximum_correlation_coefficient[direction]); \
3744 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 message[MaxTextExtent];
3783 exception=AcquireExceptionInfo();
3784 perl_exception=newSVpv("",0);
3786 if (sv_isobject(ST(0)) == 0)
3788 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3792 reference=SvRV(ST(0));
3793 hv=SvSTASH(reference);
3795 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3797 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3798 if (image == (Image *) NULL)
3800 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3804 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3806 for (i=2; i < items; i+=2)
3808 attribute=(char *) SvPV(ST(i-1),na);
3814 if (LocaleCompare(attribute,"distance") == 0)
3816 distance=StringToLong((char *) SvPV(ST(1),na));
3819 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3825 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3832 for ( ; image; image=image->next)
3834 channel_features=GetImageChannelFeatures(image,distance,
3836 if (channel_features == (ChannelFeatures *) NULL)
3839 EXTEND(sp,75*count);
3840 for (i=0; i < 4; i++)
3842 ChannelFeatures(RedChannel,i);
3843 ChannelFeatures(GreenChannel,i);
3844 ChannelFeatures(BlueChannel,i);
3845 if (image->colorspace == CMYKColorspace)
3846 ChannelFeatures(IndexChannel,i);
3847 if (image->matte != MagickFalse)
3848 ChannelFeatures(OpacityChannel,i);
3850 channel_features=(ChannelFeatures *)
3851 RelinquishMagickMemory(channel_features);
3855 InheritPerlException(exception,perl_exception);
3856 exception=DestroyExceptionInfo(exception);
3857 SvREFCNT_dec(perl_exception);
3861 ###############################################################################
3869 ###############################################################################
3874 Image::Magick ref=NO_INIT
3912 exception=AcquireExceptionInfo();
3913 perl_exception=newSVpv("",0);
3914 if (sv_isobject(ST(0)) == 0)
3916 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3920 reference=SvRV(ST(0));
3921 hv=SvSTASH(reference);
3922 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3923 if (image == (Image *) NULL)
3925 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3929 background_color=image->background_color;
3931 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3934 for (i=2; i < items; i+=2)
3936 attribute=(char *) SvPV(ST(i-1),na);
3942 if (LocaleCompare(attribute,"background") == 0)
3944 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3945 &background_color,exception);
3948 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3954 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3960 image->background_color=background_color;
3961 image=MergeImageLayers(image,FlattenLayer,exception);
3962 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3965 Create blessed Perl array for the returned image.
3968 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3970 AddImageToRegistry(image);
3972 av_push(av,sv_bless(rv,hv));
3974 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3975 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
3976 "flatten-%.*s",(int) (MaxTextExtent-9),
3977 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3978 (void) CopyMagickString(image->filename,info->image_info->filename,
3980 SetImageInfo(info->image_info,0,exception);
3981 exception=DestroyExceptionInfo(exception);
3982 SvREFCNT_dec(perl_exception);
3986 InheritPerlException(exception,perl_exception);
3987 exception=DestroyExceptionInfo(exception);
3988 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3989 SvPOK_on(perl_exception); /* return messages in string context */
3990 ST(0)=sv_2mortal(perl_exception);
3995 ###############################################################################
4003 ###############################################################################
4008 Image::Magick ref=NO_INIT
4020 expression[MaxTextExtent];
4047 exception=AcquireExceptionInfo();
4048 perl_exception=newSVpv("",0);
4051 if (sv_isobject(ST(0)) == 0)
4053 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4057 reference=SvRV(ST(0));
4058 hv=SvSTASH(reference);
4060 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4062 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4063 if (image == (Image *) NULL)
4065 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4069 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4073 channel=DefaultChannels;
4074 (void) CopyMagickString(expression,"u",MaxTextExtent);
4076 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4078 for (i=2; i < items; i+=2)
4080 attribute=(char *) SvPV(ST(i-1),na);
4086 if (LocaleCompare(attribute,"channel") == 0)
4091 option=ParseChannelOption(SvPV(ST(i),na));
4094 ThrowPerlException(exception,OptionError,
4095 "UnrecognizedType",SvPV(ST(i),na));
4098 channel=(ChannelType) option;
4101 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4108 if (LocaleCompare(attribute,"expression") == 0)
4110 (void) CopyMagickString(expression,SvPV(ST(i),na),
4114 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4120 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4126 image=FxImageChannel(image,channel,expression,exception);
4127 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4129 for ( ; image; image=image->next)
4131 AddImageToRegistry(image);
4133 av_push(av,sv_bless(rv,hv));
4136 exception=DestroyExceptionInfo(exception);
4138 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4142 InheritPerlException(exception,perl_exception);
4143 exception=DestroyExceptionInfo(exception);
4144 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4145 SvPOK_on(perl_exception);
4146 ST(0)=sv_2mortal(perl_exception);
4151 ###############################################################################
4159 ###############################################################################
4164 Image::Magick ref=NO_INIT
4175 color[MaxTextExtent];
4200 exception=AcquireExceptionInfo();
4201 perl_exception=newSVpv("",0);
4202 if (sv_isobject(ST(0)) == 0)
4204 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4208 reference=SvRV(ST(0));
4209 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4210 if (image == (Image *) NULL && !info)
4213 for (i=1; i < items; i++)
4215 attribute=(char *) SvPV(ST(i),na);
4222 if (LocaleCompare(attribute,"adjoin") == 0)
4225 s=newSViv((long) info->image_info->adjoin);
4226 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4229 if (LocaleCompare(attribute,"antialias") == 0)
4232 s=newSViv((long) info->image_info->antialias);
4233 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4236 if (LocaleCompare(attribute,"area") == 0)
4238 s=newSViv(GetMagickResource(AreaResource));
4239 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4242 if (LocaleCompare(attribute,"attenuate") == 0)
4247 value=GetImageProperty(image,attribute);
4248 if (value != (const char *) NULL)
4250 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4253 if (LocaleCompare(attribute,"authenticate") == 0)
4256 s=newSVpv(info->image_info->authenticate,0);
4257 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4267 if (LocaleCompare(attribute,"background") == 0)
4269 if (image == (Image *) NULL)
4271 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4272 QuantumFormat "," QuantumFormat "," QuantumFormat,
4273 image->background_color.red,image->background_color.green,
4274 image->background_color.blue,image->background_color.opacity);
4276 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4279 if (LocaleCompare(attribute,"base-columns") == 0)
4281 if (image != (Image *) NULL)
4282 s=newSViv((long) image->magick_columns);
4283 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4286 if (LocaleCompare(attribute,"base-filename") == 0)
4288 if (image != (Image *) NULL)
4289 s=newSVpv(image->magick_filename,0);
4290 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4293 if (LocaleCompare(attribute,"base-height") == 0)
4295 if (image != (Image *) NULL)
4296 s=newSViv((long) image->magick_rows);
4297 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4300 if (LocaleCompare(attribute,"base-rows") == 0)
4302 if (image != (Image *) NULL)
4303 s=newSViv((long) image->magick_rows);
4304 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4307 if (LocaleCompare(attribute,"base-width") == 0)
4309 if (image != (Image *) NULL)
4310 s=newSViv((long) image->magick_columns);
4311 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4314 if (LocaleCompare(attribute,"bias") == 0)
4316 if (image != (Image *) NULL)
4317 s=newSVnv(image->bias);
4318 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4321 if (LocaleCompare(attribute,"blue-primary") == 0)
4323 if (image == (Image *) NULL)
4325 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
4326 image->chromaticity.blue_primary.x,
4327 image->chromaticity.blue_primary.y);
4329 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4332 if (LocaleCompare(attribute,"bordercolor") == 0)
4334 if (image == (Image *) NULL)
4336 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4337 QuantumFormat "," QuantumFormat "," QuantumFormat,
4338 image->border_color.red,image->border_color.green,
4339 image->border_color.blue,image->border_color.opacity);
4341 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4344 if (LocaleCompare(attribute,"bounding-box") == 0)
4347 geometry[MaxTextExtent];
4352 if (image == (Image *) NULL)
4354 page=GetImageBoundingBox(image,&image->exception);
4355 (void) FormatMagickString(geometry,MaxTextExtent,
4356 "%lux%lu%+ld%+ld",page.width,page.height,page.x,page.y);
4357 s=newSVpv(geometry,0);
4358 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4368 if (LocaleCompare(attribute,"class") == 0)
4370 if (image == (Image *) NULL)
4372 s=newSViv(image->storage_class);
4373 (void) sv_setpv(s,MagickOptionToMnemonic(MagickClassOptions,
4374 image->storage_class));
4376 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4379 if (LocaleCompare(attribute,"clip-mask") == 0)
4381 if (image != (Image *) NULL)
4386 if (image->mask == (Image *) NULL)
4388 if (image->mask != (Image *) NULL)
4390 AddImageToRegistry(image->mask);
4391 s=sv_bless(newRV(sv),SvSTASH(reference));
4394 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4397 if (LocaleCompare(attribute,"clip-path") == 0)
4399 if (image != (Image *) NULL)
4404 if (image->clip_mask == (Image *) NULL)
4406 if (image->clip_mask != (Image *) NULL)
4408 AddImageToRegistry(image->clip_mask);
4409 s=sv_bless(newRV(sv),SvSTASH(reference));
4412 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4415 if (LocaleCompare(attribute,"compression") == 0)
4417 j=info ? info->image_info->compression : image->compression;
4419 if (info->image_info->compression == UndefinedCompression)
4420 j=image->compression;
4422 (void) sv_setpv(s,MagickOptionToMnemonic(MagickCompressOptions,
4425 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4428 if (LocaleCompare(attribute,"colorspace") == 0)
4430 j=image ? image->colorspace : RGBColorspace;
4432 (void) sv_setpv(s,MagickOptionToMnemonic(MagickColorspaceOptions,
4435 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4438 if (LocaleCompare(attribute,"colors") == 0)
4440 if (image != (Image *) NULL)
4441 s=newSViv((long) GetNumberColors(image,(FILE *) NULL,
4442 &image->exception));
4443 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4446 if (LocaleNCompare(attribute,"colormap",8) == 0)
4451 if (image == (Image *) NULL || !image->colormap)
4454 items=sscanf(attribute,"%*[^[][%ld",&j);
4455 if (j > (long) image->colors)
4457 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4458 QuantumFormat "," QuantumFormat "," QuantumFormat,
4459 image->colormap[j].red,image->colormap[j].green,
4460 image->colormap[j].blue,image->colormap[j].opacity);
4462 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4465 if (LocaleCompare(attribute,"columns") == 0)
4467 if (image != (Image *) NULL)
4468 s=newSViv((long) image->columns);
4469 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4472 if (LocaleCompare(attribute,"comment") == 0)
4477 value=GetImageProperty(image,attribute);
4478 if (value != (const char *) NULL)
4480 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4483 if (LocaleCompare(attribute,"copyright") == 0)
4485 s=newSVpv(GetMagickCopyright(),0);
4486 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4489 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4496 if (LocaleCompare(attribute,"density") == 0)
4499 geometry[MaxTextExtent];
4501 if (image == (Image *) NULL)
4503 (void) FormatMagickString(geometry,MaxTextExtent,"%.15gx%.15g",
4504 image->x_resolution,image->y_resolution);
4505 s=newSVpv(geometry,0);
4506 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4509 if (LocaleCompare(attribute,"delay") == 0)
4511 if (image != (Image *) NULL)
4512 s=newSViv((long) image->delay);
4513 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4516 if (LocaleCompare(attribute,"depth") == 0)
4518 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4519 if (image != (Image *) NULL)
4520 s=newSViv((long) GetImageDepth(image,&image->exception));
4521 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4524 if (LocaleCompare(attribute,"directory") == 0)
4526 if (image && image->directory)
4527 s=newSVpv(image->directory,0);
4528 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4531 if (LocaleCompare(attribute,"dispose") == 0)
4533 if (image == (Image *) NULL)
4536 s=newSViv(image->dispose);
4538 MagickOptionToMnemonic(MagickDisposeOptions,image->dispose));
4540 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4543 if (LocaleCompare(attribute,"disk") == 0)
4545 s=newSViv(GetMagickResource(DiskResource));
4546 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4549 if (LocaleCompare(attribute,"dither") == 0)
4552 s=newSViv((long) info->image_info->dither);
4553 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4556 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4558 if (info && info->image_info->server_name)
4559 s=newSVpv(info->image_info->server_name,0);
4560 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4563 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4570 if (LocaleCompare(attribute,"elapsed-time") == 0)
4572 if (image != (Image *) NULL)
4573 s=newSVnv(GetElapsedTime(&image->timer));
4574 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4577 if (LocaleCompare(attribute,"endian") == 0)
4579 j=info ? info->image_info->endian : image->endian;
4581 (void) sv_setpv(s,MagickOptionToMnemonic(MagickEndianOptions,j));
4583 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4586 if (LocaleCompare(attribute,"error") == 0)
4588 if (image != (Image *) NULL)
4589 s=newSVnv(image->error.mean_error_per_pixel);
4590 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4593 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4600 if (LocaleCompare(attribute,"filesize") == 0)
4602 if (image != (Image *) NULL)
4603 s=newSViv((long) GetBlobSize(image));
4604 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4607 if (LocaleCompare(attribute,"filename") == 0)
4609 if (info && info->image_info->filename &&
4610 *info->image_info->filename)
4611 s=newSVpv(info->image_info->filename,0);
4612 if (image != (Image *) NULL)
4613 s=newSVpv(image->filename,0);
4614 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4617 if (LocaleCompare(attribute,"filter") == 0)
4619 s=newSViv(image->filter);
4620 (void) sv_setpv(s,MagickOptionToMnemonic(MagickFilterOptions,
4623 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4626 if (LocaleCompare(attribute,"font") == 0)
4628 if (info && info->image_info->font)
4629 s=newSVpv(info->image_info->font,0);
4630 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4633 if (LocaleCompare(attribute,"foreground") == 0)
4635 if (LocaleCompare(attribute,"format") == 0)
4640 magick_info=(const MagickInfo *) NULL;
4641 if (info && (*info->image_info->magick != '\0'))
4642 magick_info=GetMagickInfo(info->image_info->magick,exception);
4643 if (image != (Image *) NULL)
4644 magick_info=GetMagickInfo(image->magick,&image->exception);
4645 if ((magick_info != (const MagickInfo *) NULL) &&
4646 (*magick_info->description != '\0'))
4647 s=newSVpv((char *) magick_info->description,0);
4648 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4651 if (LocaleCompare(attribute,"fuzz") == 0)
4654 s=newSVnv(info->image_info->fuzz);
4655 if (image != (Image *) NULL)
4656 s=newSVnv(image->fuzz);
4657 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4660 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4667 if (LocaleCompare(attribute,"gamma") == 0)
4669 if (image != (Image *) NULL)
4670 s=newSVnv(image->gamma);
4671 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4674 if (LocaleCompare(attribute,"geometry") == 0)
4676 if (image && image->geometry)
4677 s=newSVpv(image->geometry,0);
4678 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4681 if (LocaleCompare(attribute,"gravity") == 0)
4683 s=newSViv(image->gravity);
4685 MagickOptionToMnemonic(MagickGravityOptions,image->gravity));
4687 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4690 if (LocaleCompare(attribute,"green-primary") == 0)
4692 if (image == (Image *) NULL)
4694 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
4695 image->chromaticity.green_primary.x,
4696 image->chromaticity.green_primary.y);
4698 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4708 if (LocaleCompare(attribute,"height") == 0)
4710 if (image != (Image *) NULL)
4711 s=newSViv((long) image->rows);
4712 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4715 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4722 if (LocaleCompare(attribute,"icc") == 0)
4724 if (image != (Image *) NULL)
4729 profile=GetImageProfile(image,"icc");
4730 if (profile != (StringInfo *) NULL)
4731 s=newSVpv((const char *) GetStringInfoDatum(profile),
4732 GetStringInfoLength(profile));
4734 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4737 if (LocaleCompare(attribute,"icm") == 0)
4739 if (image != (Image *) NULL)
4744 profile=GetImageProfile(image,"icm");
4745 if (profile != (const StringInfo *) NULL)
4746 s=newSVpv((const char *) GetStringInfoDatum(profile),
4747 GetStringInfoLength(profile));
4749 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4752 if (LocaleCompare(attribute,"id") == 0)
4754 if (image != (Image *) NULL)
4765 (void) FormatMagickString(key,MaxTextExtent,"%ld\n",id);
4766 status=SetImageRegistry(ImageRegistryType,key,image,
4770 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4773 if (LocaleNCompare(attribute,"index",5) == 0)
4776 name[MaxTextExtent];
4785 register const IndexPacket
4788 register const PixelPacket
4794 if (image == (Image *) NULL)
4796 if (image->storage_class != PseudoClass)
4800 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4801 image_view=AcquireCacheView(image);
4802 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4803 if (p != (const PixelPacket *) NULL)
4805 indexes=GetCacheViewVirtualIndexQueue(image_view);
4806 (void) FormatMagickString(name,MaxTextExtent,QuantumFormat,
4809 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4811 image_view=DestroyCacheView(image_view);
4814 if (LocaleCompare(attribute,"iptc") == 0)
4816 if (image != (Image *) NULL)
4821 profile=GetImageProfile(image,"iptc");
4822 if (profile != (const StringInfo *) NULL)
4823 s=newSVpv((const char *) GetStringInfoDatum(profile),
4824 GetStringInfoLength(profile));
4826 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4829 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4831 if (image != (Image *) NULL)
4832 s=newSViv((long) image->iterations);
4833 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4836 if (LocaleCompare(attribute,"interlace") == 0)
4838 j=info ? info->image_info->interlace : image->interlace;
4840 (void) sv_setpv(s,MagickOptionToMnemonic(MagickInterlaceOptions,
4843 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4846 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4853 if (LocaleCompare(attribute,"label") == 0)
4858 if (image == (Image *) NULL)
4860 value=GetImageProperty(image,"Label");
4861 if (value != (const char *) NULL)
4863 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4866 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4868 if (image != (Image *) NULL)
4869 s=newSViv((long) image->iterations);
4870 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4873 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4880 if (LocaleCompare(attribute,"magick") == 0)
4882 if (info && *info->image_info->magick)
4883 s=newSVpv(info->image_info->magick,0);
4884 if (image != (Image *) NULL)
4885 s=newSVpv(image->magick,0);
4886 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4889 if (LocaleCompare(attribute,"map") == 0)
4891 s=newSViv(GetMagickResource(MapResource));
4892 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4895 if (LocaleCompare(attribute,"maximum-error") == 0)
4897 if (image != (Image *) NULL)
4898 s=newSVnv(image->error.normalized_maximum_error);
4899 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4902 if (LocaleCompare(attribute,"memory") == 0)
4904 s=newSViv(GetMagickResource(MemoryResource));
4905 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4908 if (LocaleCompare(attribute,"mean-error") == 0)
4910 if (image != (Image *) NULL)
4911 s=newSVnv(image->error.normalized_mean_error);
4912 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4915 if (LocaleCompare(attribute,"mime") == 0)
4917 if (info && *info->image_info->magick)
4918 s=newSVpv(MagickToMime(info->image_info->magick),0);
4919 if (image != (Image *) NULL)
4920 s=newSVpv(MagickToMime(image->magick),0);
4921 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4924 if (LocaleCompare(attribute,"mattecolor") == 0)
4926 if (image == (Image *) NULL)
4928 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4929 QuantumFormat "," QuantumFormat "," QuantumFormat,
4930 image->matte_color.red,image->matte_color.green,
4931 image->matte_color.blue,image->matte_color.opacity);
4933 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4936 if (LocaleCompare(attribute,"matte") == 0)
4938 if (image != (Image *) NULL)
4939 s=newSViv((long) image->matte);
4940 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4943 if (LocaleCompare(attribute,"mime") == 0)
4949 if (info && *info->image_info->magick)
4950 magick=info->image_info->magick;
4951 if (image != (Image *) NULL)
4952 magick=image->magick;
4958 mime=MagickToMime(magick);
4960 mime=(char *) RelinquishMagickMemory(mime);
4962 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4965 if (LocaleCompare(attribute,"monochrome") == 0)
4967 if (image == (Image *) NULL)
4969 j=info ? info->image_info->monochrome :
4970 IsMonochromeImage(image,&image->exception);
4972 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4975 if (LocaleCompare(attribute,"montage") == 0)
4977 if (image && image->montage)
4978 s=newSVpv(image->montage,0);
4979 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4982 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4989 if (LocaleCompare(attribute,"orientation") == 0)
4991 j=info ? info->image_info->orientation : image->orientation;
4993 (void) sv_setpv(s,MagickOptionToMnemonic(MagickOrientationOptions,
4996 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4999 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5006 if (LocaleCompare(attribute,"page") == 0)
5008 if (info && info->image_info->page)
5009 s=newSVpv(info->image_info->page,0);
5010 if (image != (Image *) NULL)
5013 geometry[MaxTextExtent];
5015 (void) FormatMagickString(geometry,MaxTextExtent,
5016 "%lux%lu%+ld%+ld",image->page.width,image->page.height,
5017 image->page.x,image->page.y);
5018 s=newSVpv(geometry,0);
5020 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5023 if (LocaleCompare(attribute,"page.x") == 0)
5025 if (image != (Image *) NULL)
5026 s=newSViv((long) image->page.x);
5027 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5030 if (LocaleCompare(attribute,"page.y") == 0)
5032 if (image != (Image *) NULL)
5033 s=newSViv((long) image->page.y);
5034 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5037 if (LocaleNCompare(attribute,"pixel",5) == 0)
5040 tuple[MaxTextExtent];
5049 register const PixelPacket
5052 register const IndexPacket
5055 if (image == (Image *) NULL)
5059 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5060 p=GetVirtualPixels(image,x,y,1,1,exception);
5061 indexes=GetVirtualIndexQueue(image);
5062 if (image->colorspace != CMYKColorspace)
5063 (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
5064 QuantumFormat "," QuantumFormat "," QuantumFormat,
5065 p->red,p->green,p->blue,p->opacity);
5067 (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
5068 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5069 QuantumFormat,p->red,p->green,p->blue,*indexes,p->opacity);
5071 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5074 if (LocaleCompare(attribute,"pointsize") == 0)
5077 s=newSViv((long) info->image_info->pointsize);
5078 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5081 if (LocaleCompare(attribute,"preview") == 0)
5083 s=newSViv(info->image_info->preview_type);
5084 (void) sv_setpv(s,MagickOptionToMnemonic(MagickPreviewOptions,
5085 info->image_info->preview_type));
5087 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5090 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5097 if (LocaleCompare(attribute,"quality") == 0)
5100 s=newSViv((long) info->image_info->quality);
5101 if (image != (Image *) NULL)
5102 s=newSViv((long) image->quality);
5103 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5106 if (LocaleCompare(attribute,"quantum") == 0)
5109 s=newSViv((long) MAGICKCORE_QUANTUM_DEPTH);
5110 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5113 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5120 if (LocaleCompare(attribute,"rendering-intent") == 0)
5122 s=newSViv(image->rendering_intent);
5123 (void) sv_setpv(s,MagickOptionToMnemonic(MagickIntentOptions,
5124 image->rendering_intent));
5126 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5129 if (LocaleCompare(attribute,"red-primary") == 0)
5131 if (image == (Image *) NULL)
5133 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
5134 image->chromaticity.red_primary.x,
5135 image->chromaticity.red_primary.y);
5137 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5140 if (LocaleCompare(attribute,"rows") == 0)
5142 if (image != (Image *) NULL)
5143 s=newSViv((long) image->rows);
5144 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5154 if (LocaleCompare(attribute,"sampling-factor") == 0)
5156 if (info && info->image_info->sampling_factor)
5157 s=newSVpv(info->image_info->sampling_factor,0);
5158 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5161 if (LocaleCompare(attribute,"subimage") == 0)
5164 s=newSViv((long) info->image_info->subimage);
5165 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5168 if (LocaleCompare(attribute,"subrange") == 0)
5171 s=newSViv((long) info->image_info->subrange);
5172 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5175 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5177 if (info && info->image_info->server_name)
5178 s=newSVpv(info->image_info->server_name,0);
5179 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5182 if (LocaleCompare(attribute,"size") == 0)
5184 if (info && info->image_info->size)
5185 s=newSVpv(info->image_info->size,0);
5186 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5189 if (LocaleCompare(attribute,"scene") == 0)
5191 if (image != (Image *) NULL)
5192 s=newSViv((long) image->scene);
5193 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5196 if (LocaleCompare(attribute,"scenes") == 0)
5198 if (image != (Image *) NULL)
5199 s=newSViv((long) info->image_info->number_scenes);
5200 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5203 if (LocaleCompare(attribute,"signature") == 0)
5208 if (image == (Image *) NULL)
5210 (void) SignatureImage(image);
5211 value=GetImageProperty(image,"Signature");
5212 if (value != (const char *) NULL)
5214 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5217 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5224 if (LocaleCompare(attribute,"taint") == 0)
5226 if (image != (Image *) NULL)
5227 s=newSViv((long) IsTaintImage(image));
5228 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5231 if (LocaleCompare(attribute,"tile") == 0)
5233 if (info && info->image_info->tile)
5234 s=newSVpv(info->image_info->tile,0);
5235 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5238 if (LocaleCompare(attribute,"texture") == 0)
5240 if (info && info->image_info->texture)
5241 s=newSVpv(info->image_info->texture,0);
5242 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5245 if (LocaleCompare(attribute,"total-ink-density") == 0)
5247 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5248 if (image != (Image *) NULL)
5249 s=newSVnv(GetImageTotalInkDensity(image));
5250 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5253 if (LocaleCompare(attribute,"transparent-color") == 0)
5255 if (image == (Image *) NULL)
5257 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
5258 QuantumFormat "," QuantumFormat "," QuantumFormat,
5259 image->transparent_color.red,image->transparent_color.green,
5260 image->transparent_color.blue,image->transparent_color.opacity);
5262 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5265 if (LocaleCompare(attribute,"type") == 0)
5267 if (image == (Image *) NULL)
5269 j=(long) GetImageType(image,&image->exception);
5271 (void) sv_setpv(s,MagickOptionToMnemonic(MagickTypeOptions,j));
5273 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5276 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5283 if (LocaleCompare(attribute,"units") == 0)
5285 j=info ? info->image_info->units : image->units;
5287 if (info->image_info->units == UndefinedResolution)
5289 if (j == UndefinedResolution)
5290 s=newSVpv("undefined units",0);
5292 if (j == PixelsPerInchResolution)
5293 s=newSVpv("pixels / inch",0);
5295 s=newSVpv("pixels / centimeter",0);
5296 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5299 if (LocaleCompare(attribute,"user-time") == 0)
5301 if (image != (Image *) NULL)
5302 s=newSVnv(GetUserTime(&image->timer));
5303 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5306 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5313 if (LocaleCompare(attribute,"verbose") == 0)
5316 s=newSViv((long) info->image_info->verbose);
5317 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5320 if (LocaleCompare(attribute,"version") == 0)
5322 s=newSVpv(GetMagickVersion((unsigned long *) NULL),0);
5323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5326 if (LocaleCompare(attribute,"view") == 0)
5328 if (info && info->image_info->view)
5329 s=newSVpv(info->image_info->view,0);
5330 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5333 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5335 if (image == (Image *) NULL)
5337 j=(long) GetImageVirtualPixelMethod(image);
5339 (void) sv_setpv(s,MagickOptionToMnemonic(
5340 MagickVirtualPixelOptions,j));
5342 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5345 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5352 if (LocaleCompare(attribute,"white-point") == 0)
5354 if (image == (Image *) NULL)
5356 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
5357 image->chromaticity.white_point.x,
5358 image->chromaticity.white_point.y);
5360 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5363 if (LocaleCompare(attribute,"width") == 0)
5365 if (image != (Image *) NULL)
5366 s=newSViv((long) image->columns);
5367 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5370 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5377 if (LocaleCompare(attribute,"x-resolution") == 0)
5379 if (image != (Image *) NULL)
5380 s=newSVnv(image->x_resolution);
5381 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5384 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5391 if (LocaleCompare(attribute,"y-resolution") == 0)
5393 if (image != (Image *) NULL)
5394 s=newSVnv(image->y_resolution);
5395 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5398 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5405 if (image == (Image *) NULL)
5406 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5410 value=GetImageProperty(image,attribute);
5411 if (value != (const char *) NULL)
5414 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5417 if (*attribute != '%')
5418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5425 meta=InterpretImageProperties(info ? info->image_info :
5426 (ImageInfo *) NULL,image,attribute);
5428 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5429 meta=(char *) RelinquishMagickMemory(meta);
5433 exception=DestroyExceptionInfo(exception);
5434 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5438 ###############################################################################
5442 # G e t A u t h e n t i c P i x e l s #
5446 ###############################################################################
5450 GetAuthenticPixels(ref,...)
5451 Image::Magick ref = NO_INIT
5453 getauthenticpixels = 1
5483 exception=AcquireExceptionInfo();
5484 perl_exception=newSVpv("",0);
5485 if (sv_isobject(ST(0)) == 0)
5487 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5491 reference=SvRV(ST(0));
5493 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5494 if (image == (Image *) NULL)
5496 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5503 region.width=image->columns;
5506 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5507 for (i=2; i < items; i+=2)
5509 attribute=(char *) SvPV(ST(i-1),na);
5515 if (LocaleCompare(attribute,"geometry") == 0)
5517 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5520 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5527 if (LocaleCompare(attribute,"height") == 0)
5529 region.height=SvIV(ST(i));
5532 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5539 if (LocaleCompare(attribute,"x") == 0)
5541 region.x=SvIV(ST(i));
5544 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5551 if (LocaleCompare(attribute,"y") == 0)
5553 region.y=SvIV(ST(i));
5556 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5563 if (LocaleCompare(attribute,"width") == 0)
5565 region.width=SvIV(ST(i));
5568 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5574 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5575 region.height,exception);
5576 if (blob != (void *) NULL)
5580 InheritPerlException(exception,perl_exception);
5581 exception=DestroyExceptionInfo(exception);
5582 SvREFCNT_dec(perl_exception); /* throw away all errors */
5591 ###############################################################################
5595 # G e t V i r t u a l P i x e l s #
5599 ###############################################################################
5603 GetVirtualPixels(ref,...)
5604 Image::Magick ref = NO_INIT
5606 getvirtualpixels = 1
5607 AcquireImagePixels = 2
5608 acquireimagepixels = 3
5636 exception=AcquireExceptionInfo();
5637 perl_exception=newSVpv("",0);
5638 if (sv_isobject(ST(0)) == 0)
5640 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5644 reference=SvRV(ST(0));
5646 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5647 if (image == (Image *) NULL)
5649 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5656 region.width=image->columns;
5659 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5660 for (i=2; i < items; i+=2)
5662 attribute=(char *) SvPV(ST(i-1),na);
5668 if (LocaleCompare(attribute,"geometry") == 0)
5670 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5673 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5680 if (LocaleCompare(attribute,"height") == 0)
5682 region.height=SvIV(ST(i));
5685 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5692 if (LocaleCompare(attribute,"x") == 0)
5694 region.x=SvIV(ST(i));
5697 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5704 if (LocaleCompare(attribute,"y") == 0)
5706 region.y=SvIV(ST(i));
5709 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5716 if (LocaleCompare(attribute,"width") == 0)
5718 region.width=SvIV(ST(i));
5721 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5727 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5728 region.height,exception);
5729 if (blob != (void *) NULL)
5733 InheritPerlException(exception,perl_exception);
5734 exception=DestroyExceptionInfo(exception);
5735 SvREFCNT_dec(perl_exception); /* throw away all errors */
5738 RETVAL = (void *) blob;
5744 ###############################################################################
5748 # G e t A u t h e n t i c I n d e x Q u e u e #
5752 ###############################################################################
5756 GetAuthenticIndexQueue(ref,...)
5757 Image::Magick ref = NO_INIT
5759 getauthenticindexqueue = 1
5780 exception=AcquireExceptionInfo();
5781 perl_exception=newSVpv("",0);
5782 if (sv_isobject(ST(0)) == 0)
5784 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5788 reference=SvRV(ST(0));
5790 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5791 if (image == (Image *) NULL)
5793 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5798 blob=(void *) GetAuthenticIndexQueue(image);
5799 if (blob != (void *) NULL)
5803 InheritPerlException(exception,perl_exception);
5804 exception=DestroyExceptionInfo(exception);
5805 SvREFCNT_dec(perl_exception); /* throw away all errors */
5814 ###############################################################################
5818 # G e t V i r t u a l I n d e x Q u e u e #
5822 ###############################################################################
5826 GetVirtualIndexQueue(ref,...)
5827 Image::Magick ref = NO_INIT
5829 getvirtualindexqueue = 1
5848 exception=AcquireExceptionInfo();
5849 perl_exception=newSVpv("",0);
5850 if (sv_isobject(ST(0)) == 0)
5852 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5856 reference=SvRV(ST(0));
5858 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5859 if (image == (Image *) NULL)
5861 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5866 blob=(void *) GetVirtualIndexQueue(image);
5867 if (blob != (void *) NULL)
5871 InheritPerlException(exception,perl_exception);
5872 exception=DestroyExceptionInfo(exception);
5873 SvREFCNT_dec(perl_exception); /* throw away all errors */
5882 ###############################################################################
5886 # H i s t o g r a m #
5890 ###############################################################################
5895 Image::Magick ref=NO_INIT
5906 message[MaxTextExtent];
5937 exception=AcquireExceptionInfo();
5938 perl_exception=newSVpv("",0);
5940 if (sv_isobject(ST(0)) == 0)
5942 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5946 reference=SvRV(ST(0));
5947 hv=SvSTASH(reference);
5949 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
5951 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5952 if (image == (Image *) NULL)
5954 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5958 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5960 for ( ; image; image=image->next)
5962 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5963 if (histogram == (ColorPacket *) NULL)
5965 count+=number_colors;
5967 for (i=0; i < (long) number_colors; i++)
5969 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5970 histogram[i].pixel.red);
5971 PUSHs(sv_2mortal(newSVpv(message,0)));
5972 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5973 histogram[i].pixel.green);
5974 PUSHs(sv_2mortal(newSVpv(message,0)));
5975 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5976 histogram[i].pixel.blue);
5977 PUSHs(sv_2mortal(newSVpv(message,0)));
5978 if (image->colorspace == CMYKColorspace)
5980 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5981 histogram[i].index);
5982 PUSHs(sv_2mortal(newSVpv(message,0)));
5984 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
5985 histogram[i].pixel.opacity);
5986 PUSHs(sv_2mortal(newSVpv(message,0)));
5987 (void) FormatMagickString(message,MaxTextExtent,"%lu",
5988 (unsigned long) histogram[i].count);
5989 PUSHs(sv_2mortal(newSVpv(message,0)));
5991 histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
5995 InheritPerlException(exception,perl_exception);
5996 exception=DestroyExceptionInfo(exception);
5997 SvREFCNT_dec(perl_exception);
6001 ###############################################################################
6009 ###############################################################################
6014 Image::Magick ref=NO_INIT
6044 register const IndexPacket
6047 register const PixelPacket
6058 *reference; /* reference is the SV* of ref=SvIV(reference) */
6060 exception=AcquireExceptionInfo();
6061 perl_exception=newSVpv("",0);
6062 reference=SvRV(ST(0));
6063 av=(AV *) reference;
6064 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6066 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6067 if (image == (Image *) NULL)
6069 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6073 channel=DefaultChannels;
6074 normalize=MagickTrue;
6077 region.width=image->columns;
6080 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6081 for (i=2; i < items; i+=2)
6083 attribute=(char *) SvPV(ST(i-1),na);
6089 if (LocaleCompare(attribute,"channel") == 0)
6094 option=ParseChannelOption(SvPV(ST(i),na));
6097 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6101 channel=(ChannelType) option;
6104 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6111 if (LocaleCompare(attribute,"geometry") == 0)
6113 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6116 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6123 if (LocaleCompare(attribute,"normalize") == 0)
6125 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6129 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6133 normalize=option != 0 ? MagickTrue : MagickFalse;
6136 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6143 if (LocaleCompare(attribute,"x") == 0)
6145 region.x=SvIV(ST(i));
6148 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6155 if (LocaleCompare(attribute,"y") == 0)
6157 region.y=SvIV(ST(i));
6160 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6172 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6173 if (p == (const PixelPacket *) NULL)
6180 indexes=GetVirtualIndexQueue(image);
6182 if (normalize != MagickFalse)
6183 scale=1.0/QuantumRange;
6184 if ((channel & RedChannel) != 0)
6185 PUSHs(sv_2mortal(newSVnv(scale*p->red)));
6186 if ((channel & GreenChannel) != 0)
6187 PUSHs(sv_2mortal(newSVnv(scale*p->green)));
6188 if ((channel & BlueChannel) != 0)
6189 PUSHs(sv_2mortal(newSVnv(scale*p->blue)));
6190 if (((channel & IndexChannel) != 0) &&
6191 (image->colorspace == CMYKColorspace))
6192 PUSHs(sv_2mortal(newSVnv(scale*(*indexes))));
6193 if ((channel & OpacityChannel) != 0)
6194 PUSHs(sv_2mortal(newSVnv(scale*p->opacity)));
6198 InheritPerlException(exception,perl_exception);
6199 exception=DestroyExceptionInfo(exception);
6200 SvREFCNT_dec(perl_exception);
6204 ###############################################################################
6208 # G e t P i x e l s #
6212 ###############################################################################
6217 Image::Magick ref=NO_INIT
6256 *reference; /* reference is the SV* of ref=SvIV(reference) */
6258 exception=AcquireExceptionInfo();
6259 perl_exception=newSVpv("",0);
6260 reference=SvRV(ST(0));
6261 av=(AV *) reference;
6262 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6264 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6265 if (image == (Image *) NULL)
6267 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6272 if (image->matte != MagickFalse)
6274 if (image->colorspace == CMYKColorspace)
6277 if (image->matte != MagickFalse)
6280 normalize=MagickFalse;
6283 region.width=image->columns;
6286 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6287 for (i=2; i < items; i+=2)
6289 attribute=(char *) SvPV(ST(i-1),na);
6295 if (LocaleCompare(attribute,"geometry") == 0)
6297 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6300 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6307 if (LocaleCompare(attribute,"height") == 0)
6309 region.height=SvIV(ST(i));
6312 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6319 if (LocaleCompare(attribute,"map") == 0)
6324 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6331 if (LocaleCompare(attribute,"normalize") == 0)
6333 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
6337 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6341 normalize=option != 0 ? MagickTrue : MagickFalse;
6344 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6351 if (LocaleCompare(attribute,"width") == 0)
6353 region.width=SvIV(ST(i));
6356 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6363 if (LocaleCompare(attribute,"x") == 0)
6365 region.x=SvIV(ST(i));
6368 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6375 if (LocaleCompare(attribute,"y") == 0)
6377 region.y=SvIV(ST(i));
6380 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6386 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6392 if (normalize != MagickFalse)
6397 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6398 region.height*sizeof(*pixels));
6399 if (pixels == (float *) NULL)
6401 ThrowPerlException(exception,ResourceLimitError,
6402 "MemoryAllocationFailed",PackageName);
6405 status=ExportImagePixels(image,region.x,region.y,region.width,
6406 region.height,map,FloatPixel,pixels,exception);
6407 if (status == MagickFalse)
6411 EXTEND(sp,strlen(map)*region.width*region.height);
6412 for (i=0; i < (long) (strlen(map)*region.width*region.height); i++)
6413 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6415 pixels=(float *) RelinquishMagickMemory(pixels);
6422 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6423 region.height*sizeof(*pixels));
6424 if (pixels == (Quantum *) NULL)
6426 ThrowPerlException(exception,ResourceLimitError,
6427 "MemoryAllocationFailed",PackageName);
6430 status=ExportImagePixels(image,region.x,region.y,region.width,
6431 region.height,map,QuantumPixel,pixels,exception);
6432 if (status == MagickFalse)
6436 EXTEND(sp,strlen(map)*region.width*region.height);
6437 for (i=0; i < (long) (strlen(map)*region.width*region.height); i++)
6438 PUSHs(sv_2mortal(newSViv(pixels[i])));
6440 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6444 InheritPerlException(exception,perl_exception);
6445 exception=DestroyExceptionInfo(exception);
6446 SvREFCNT_dec(perl_exception);
6450 ###############################################################################
6454 # I m a g e T o B l o b #
6458 ###############################################################################
6462 ImageToBlob(ref,...)
6463 Image::Magick ref=NO_INIT
6472 filename[MaxTextExtent];
6501 exception=AcquireExceptionInfo();
6502 perl_exception=newSVpv("",0);
6503 package_info=(struct PackageInfo *) NULL;
6504 if (sv_isobject(ST(0)) == 0)
6506 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6510 reference=SvRV(ST(0));
6511 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6512 if (image == (Image *) NULL)
6514 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6518 package_info=ClonePackageInfo(info,exception);
6519 for (i=2; i < items; i+=2)
6520 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6521 (void) CopyMagickString(filename,package_info->image_info->filename,
6524 for (next=image; next; next=next->next)
6526 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6527 next->scene=scene++;
6529 SetImageInfo(package_info->image_info,(unsigned int)
6530 GetImageListLength(image),&image->exception);
6531 EXTEND(sp,(long) GetImageListLength(image));
6532 for ( ; image; image=image->next)
6535 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6536 if (blob != (char *) NULL)
6538 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6539 blob=(unsigned char *) RelinquishMagickMemory(blob);
6541 if (package_info->image_info->adjoin)
6546 if (package_info != (struct PackageInfo *) NULL)
6547 DestroyPackageInfo(package_info);
6548 InheritPerlException(exception,perl_exception);
6549 exception=DestroyExceptionInfo(exception);
6550 SvREFCNT_dec(perl_exception); /* throw away all errors */
6554 ###############################################################################
6562 ###############################################################################
6567 Image::Magick ref=NO_INIT
6571 OptimizeImageLayers = 3
6573 optimizeimagelayers = 5
6618 exception=AcquireExceptionInfo();
6619 perl_exception=newSVpv("",0);
6620 if (sv_isobject(ST(0)) == 0)
6622 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6626 reference=SvRV(ST(0));
6627 hv=SvSTASH(reference);
6629 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6631 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6632 if (image == (Image *) NULL)
6634 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6638 compose=image->compose;
6640 method=OptimizeLayer;
6641 for (i=2; i < items; i+=2)
6643 attribute=(char *) SvPV(ST(i-1),na);
6649 if (LocaleCompare(attribute,"compose") == 0)
6651 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
6652 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6655 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6659 compose=(CompositeOperator) sp;
6662 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6669 if (LocaleCompare(attribute,"dither") == 0)
6671 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
6672 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
6675 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6679 dither=(MagickBooleanType) sp;
6682 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6689 if (LocaleCompare(attribute,"method") == 0)
6691 option=ParseMagickOption(MagickLayerOptions,MagickFalse,
6695 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6699 method=(ImageLayerMethod) option;
6702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6708 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6714 layers=(Image *) NULL;
6717 case CompareAnyLayer:
6718 case CompareClearLayer:
6719 case CompareOverlayLayer:
6722 layers=CompareImageLayers(image,method,exception);
6729 layers=MergeImageLayers(image,method,exception);
6734 layers=DisposeImages(image,exception);
6737 case OptimizeImageLayer:
6739 layers=OptimizeImageLayers(image,exception);
6742 case OptimizePlusLayer:
6744 layers=OptimizePlusImageLayers(image,exception);
6747 case OptimizeTransLayer:
6749 OptimizeImageTransparency(image,exception);
6750 InheritException(&(image->exception),exception);
6753 case RemoveDupsLayer:
6755 RemoveDuplicateLayers(&image,exception);
6756 InheritException(&(image->exception),exception);
6759 case RemoveZeroLayer:
6761 RemoveZeroDelayLayers(&image,exception);
6762 InheritException(&(image->exception),exception);
6771 General Purpose, GIF Animation Optimizer.
6773 layers=CoalesceImages(image,exception);
6774 if (layers == (Image *) NULL)
6776 InheritException(&(layers->exception),exception);
6778 layers=OptimizeImageLayers(image,exception);
6779 if (layers == (Image *) NULL)
6781 InheritException(&(layers->exception),exception);
6782 image=DestroyImageList(image);
6784 layers=(Image *) NULL;
6785 OptimizeImageTransparency(image,exception);
6786 InheritException(&(image->exception),exception);
6787 quantize_info=AcquireQuantizeInfo(info->image_info);
6788 (void) RemapImages(quantize_info,image,(Image *) NULL);
6789 quantize_info=DestroyQuantizeInfo(quantize_info);
6792 case CompositeLayer:
6801 Split image sequence at the first 'NULL:' image.
6804 while (source != (Image *) NULL)
6806 source=GetNextImageInList(source);
6807 if ((source != (Image *) NULL) &&
6808 (LocaleCompare(source->magick,"NULL") == 0))
6811 if (source != (Image *) NULL)
6813 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6814 (GetNextImageInList(source) == (Image *) NULL))
6815 source=(Image *) NULL;
6819 Separate the two lists, junk the null: image.
6821 source=SplitImageList(source->previous);
6822 DeleteImageFromList(&source);
6825 if (source == (Image *) NULL)
6827 (void) ThrowMagickException(exception,GetMagickModule(),
6828 OptionError,"MissingNullSeparator","layers Composite");
6832 Adjust offset with gravity and virtual canvas.
6834 SetGeometry(image,&geometry);
6835 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6836 geometry.width=source->page.width != 0 ? source->page.width :
6838 geometry.height=source->page.height != 0 ? source->page.height :
6840 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6841 image->columns,image->page.height != 0 ? image->page.height :
6842 image->rows,image->gravity,&geometry);
6843 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6844 source=DestroyImageList(source);
6845 InheritException(&(image->exception),exception);
6849 if (layers != (Image *) NULL)
6851 InheritException(&(layers->exception),exception);
6854 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6856 for ( ; image; image=image->next)
6858 AddImageToRegistry(image);
6860 av_push(av,sv_bless(rv,hv));
6863 exception=DestroyExceptionInfo(exception);
6865 SvREFCNT_dec(perl_exception);
6869 InheritPerlException(exception,perl_exception);
6870 exception=DestroyExceptionInfo(exception);
6871 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6872 SvPOK_on(perl_exception);
6873 ST(0)=sv_2mortal(perl_exception);
6878 ###############################################################################
6882 # M a g i c k T o M i m e #
6886 ###############################################################################
6890 MagickToMime(ref,name)
6891 Image::Magick ref=NO_INIT
6900 mime=MagickToMime(name);
6901 RETVAL=newSVpv(mime,0);
6902 mime=(char *) RelinquishMagickMemory(mime);
6908 ###############################################################################
6916 ###############################################################################
6921 Image::Magick ref=NO_INIT
6958 MedianFilterImage = 36
6964 ReduceNoiseImage = 42
6990 ColorFloodfillImage= 68
6996 CycleColormapImage = 74
7006 MatteFloodfillImage= 84
7014 NumberColorsImage = 92
7024 SignatureImage = 102
7034 TransparentImage = 112
7036 ThresholdImage = 114
7050 DeconstructImage = 130
7052 GaussianBlurImage = 132
7058 UnsharpMaskImage = 138
7060 MotionBlurImage = 140
7062 OrderedDitherImage = 142
7069 AffineTransform = 149
7070 AffineTransformImage = 150
7072 DifferenceImage = 152
7073 AdaptiveThreshold = 153
7074 AdaptiveThresholdImage = 154
7079 BlackThreshold = 159
7080 BlackThresholdImage= 160
7081 WhiteThreshold = 161
7082 WhiteThresholdImage= 162
7084 RadialBlurImage = 164
7086 ThumbnailImage = 166
7096 PosterizeImage = 176
7102 SepiaToneImage = 182
7103 SigmoidalContrast = 183
7104 SigmoidalContrastImage = 184
7109 ContrastStretch = 189
7110 ContrastStretchImage = 190
7115 AdaptiveSharpen = 195
7116 AdaptiveSharpenImage = 196
7118 TransposeImage = 198
7120 TransverseImage = 200
7122 AutoOrientImage = 202
7124 AdaptiveBlurImage = 204
7128 UniqueColorsImage = 208
7129 AdaptiveResize = 209
7130 AdaptiveResizeImage= 210
7134 LinearStretchImage = 214
7141 FloodfillPaint = 221
7142 FloodfillPaintImage= 222
7148 LiquidRescaleImage = 228
7158 SparseColorImage = 238
7162 SelectiveBlurImage = 242
7166 BlueShiftImage = 246
7167 ForwardFourierTransform = 247
7168 ForwardFourierTransformImage = 248
7169 InverseFourierTransform = 249
7170 InverseFourierTransformImage = 250
7171 ColorDecisionList = 251
7172 ColorDecisionListImage = 252
7174 AutoGammaImage = 254
7176 AutoLevelImage = 256
7178 LevelColorsImage = 258
7183 BrightnessContrast = 263
7184 BrightnessContrastImage = 264
7186 MorphologyImage = 266
7188 ColorMatrixImage = 268
7197 attribute_flag[MaxArguments],
7198 message[MaxTextExtent];
7258 argument_list[MaxArguments];
7260 exception=AcquireExceptionInfo();
7261 perl_exception=newSVpv("",0);
7262 reference_vector=NULL;
7266 if (sv_isobject(ST(0)) == 0)
7268 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7272 reference=SvRV(ST(0));
7273 region_info.width=0;
7274 region_info.height=0;
7277 region_image=(Image *) NULL;
7278 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7279 if (ix && (ix != 666))
7282 Called as Method(...)
7285 rp=(&Methods[ix-1]);
7291 Called as Mogrify("Method",...)
7293 attribute=(char *) SvPV(ST(1),na);
7296 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7297 attribute=(char *) SvPV(ST(2),na);
7300 for (rp=Methods; ; rp++)
7302 if (rp >= EndOf(Methods))
7304 ThrowPerlException(exception,OptionError,
7305 "UnrecognizedPerlMagickMethod",attribute);
7308 if (strEQcase(attribute,rp->name))
7314 if (image == (Image *) NULL)
7316 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7319 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7320 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7321 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7337 pp=(Arguments *) NULL;
7345 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7347 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7349 if (strEQcase(attribute,qq->method) > longest)
7352 longest=strEQcase(attribute,qq->method);
7355 if (pp == (Arguments *) NULL)
7357 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7359 goto continue_outer_loop;
7361 al=(&argument_list[pp-rp->arguments]);
7364 case ArrayReference:
7366 if (SvTYPE(sv) != SVt_RV)
7368 (void) FormatMagickString(message,MaxTextExtent,
7369 "invalid %.60s value",pp->method);
7370 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7371 goto continue_outer_loop;
7373 al->array_reference=SvRV(sv);
7378 al->real_reference=SvNV(sv);
7383 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7386 case ImageReference:
7388 if (!sv_isobject(sv) ||
7389 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7390 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7392 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7398 case IntegerReference:
7400 al->long_reference=SvIV(sv);
7403 case StringReference:
7405 al->string_reference=(char *) SvPV(sv,al->length);
7406 if (sv_isobject(sv))
7407 al->image_reference=SetupList(aTHX_ SvRV(sv),
7408 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7414 Is a string; look up name.
7416 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7418 al->string_reference=(char *) SvPV(sv,al->length);
7419 al->long_reference=(-1);
7422 al->long_reference=ParseMagickOption((MagickOption) pp->type,
7423 MagickFalse,SvPV(sv,na));
7424 if (pp->type == MagickChannelOptions)
7425 al->long_reference=ParseChannelOption(SvPV(sv,na));
7426 if ((al->long_reference < 0) && ((al->long_reference=SvIV(sv)) <= 0))
7428 (void) FormatMagickString(message,MaxTextExtent,
7429 "invalid %.60s value",pp->method);
7430 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7431 goto continue_outer_loop;
7436 attribute_flag[pp-rp->arguments]++;
7437 continue_outer_loop: ;
7439 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7440 pv=reference_vector;
7441 SetGeometryInfo(&geometry_info);
7442 channel=DefaultChannels;
7443 for (next=image; next; next=next->next)
7446 SetGeometry(image,&geometry);
7447 if ((region_info.width*region_info.height) != 0)
7450 image=CropImage(image,®ion_info,exception);
7456 (void) FormatMagickString(message,MaxTextExtent,"%ld",(long) ix);
7457 ThrowPerlException(exception,OptionError,
7458 "UnrecognizedPerlMagickMethod",message);
7461 case 1: /* Comment */
7463 if (attribute_flag[0] == 0)
7464 argument_list[0].string_reference=(char *) NULL;
7465 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7466 info ? info->image_info : (ImageInfo *) NULL,image,
7467 argument_list[0].string_reference));
7472 if (attribute_flag[0] == 0)
7473 argument_list[0].string_reference=(char *) NULL;
7474 (void) SetImageProperty(image,"label",InterpretImageProperties(
7475 info ? info->image_info : (ImageInfo *) NULL,image,
7476 argument_list[0].string_reference));
7479 case 3: /* AddNoise */
7481 if (attribute_flag[0] == 0)
7482 argument_list[0].long_reference=UniformNoise;
7483 if (attribute_flag[1] != 0)
7484 channel=(ChannelType) argument_list[1].long_reference;
7485 image=AddNoiseImageChannel(image,channel,(NoiseType)
7486 argument_list[0].long_reference,exception);
7489 case 4: /* Colorize */
7494 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7495 if (attribute_flag[0] != 0)
7496 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7498 if (attribute_flag[1] == 0)
7499 argument_list[1].string_reference="100%";
7500 image=ColorizeImage(image,argument_list[1].string_reference,target,
7504 case 5: /* Border */
7508 if (attribute_flag[0] != 0)
7510 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7511 &geometry,exception);
7512 if ((flags & HeightValue) == 0)
7513 geometry.height=geometry.width;
7515 if (attribute_flag[1] != 0)
7516 geometry.width=argument_list[1].long_reference;
7517 if (attribute_flag[2] != 0)
7518 geometry.height=argument_list[2].long_reference;
7519 if (attribute_flag[3] != 0)
7520 QueryColorDatabase(argument_list[3].string_reference,
7521 &image->border_color,exception);
7522 if (attribute_flag[4] != 0)
7523 QueryColorDatabase(argument_list[4].string_reference,
7524 &image->border_color,exception);
7525 if (attribute_flag[5] != 0)
7526 QueryColorDatabase(argument_list[5].string_reference,
7527 &image->border_color,exception);
7528 if (attribute_flag[6] != 0)
7529 image->compose=(CompositeOperator) argument_list[6].long_reference;
7530 image=BorderImage(image,&geometry,exception);
7535 if (attribute_flag[0] != 0)
7537 flags=ParseGeometry(argument_list[0].string_reference,
7539 if ((flags & SigmaValue) == 0)
7540 geometry_info.sigma=1.0;
7542 if (attribute_flag[1] != 0)
7543 geometry_info.rho=argument_list[1].real_reference;
7544 if (attribute_flag[2] != 0)
7545 geometry_info.sigma=argument_list[2].real_reference;
7546 if (attribute_flag[3] != 0)
7547 channel=(ChannelType) argument_list[3].long_reference;
7548 image=BlurImageChannel(image,channel,geometry_info.rho,
7549 geometry_info.sigma,exception);
7554 if (attribute_flag[0] != 0)
7555 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7556 &geometry,exception);
7557 if (attribute_flag[1] != 0)
7558 geometry.width=argument_list[1].long_reference;
7559 if (attribute_flag[2] != 0)
7560 geometry.height=argument_list[2].long_reference;
7561 if (attribute_flag[3] != 0)
7562 geometry.x=argument_list[3].long_reference;
7563 if (attribute_flag[4] != 0)
7564 geometry.y=argument_list[4].long_reference;
7565 image=ChopImage(image,&geometry,exception);
7570 if (attribute_flag[6] != 0)
7571 image->gravity=(GravityType) argument_list[6].long_reference;
7572 if (attribute_flag[0] != 0)
7573 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7574 &geometry,exception);
7575 if (attribute_flag[1] != 0)
7576 geometry.width=argument_list[1].long_reference;
7577 if (attribute_flag[2] != 0)
7578 geometry.height=argument_list[2].long_reference;
7579 if (attribute_flag[3] != 0)
7580 geometry.x=argument_list[3].long_reference;
7581 if (attribute_flag[4] != 0)
7582 geometry.y=argument_list[4].long_reference;
7583 if (attribute_flag[5] != 0)
7585 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7586 image=CropImage(image,&geometry,exception);
7589 case 9: /* Despeckle */
7591 image=DespeckleImage(image,exception);
7596 if (attribute_flag[0] != 0)
7597 geometry_info.rho=argument_list[0].real_reference;
7598 image=EdgeImage(image,geometry_info.rho,exception);
7601 case 11: /* Emboss */
7603 if (attribute_flag[0] != 0)
7605 flags=ParseGeometry(argument_list[0].string_reference,
7607 if ((flags & SigmaValue) == 0)
7608 geometry_info.sigma=1.0;
7610 if (attribute_flag[1] != 0)
7611 geometry_info.rho=argument_list[1].real_reference;
7612 if (attribute_flag[2] != 0)
7613 geometry_info.sigma=argument_list[2].real_reference;
7614 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7618 case 12: /* Enhance */
7620 image=EnhanceImage(image,exception);
7625 image=FlipImage(image,exception);
7630 image=FlopImage(image,exception);
7633 case 15: /* Frame */
7638 if (attribute_flag[0] != 0)
7640 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7641 &geometry,exception);
7642 if ((flags & HeightValue) == 0)
7643 geometry.height=geometry.width;
7644 frame_info.width=geometry.width;
7645 frame_info.height=geometry.height;
7646 frame_info.outer_bevel=geometry.x;
7647 frame_info.inner_bevel=geometry.y;
7649 if (attribute_flag[1] != 0)
7650 frame_info.width=argument_list[1].long_reference;
7651 if (attribute_flag[2] != 0)
7652 frame_info.height=argument_list[2].long_reference;
7653 if (attribute_flag[3] != 0)
7654 frame_info.inner_bevel=argument_list[3].long_reference;
7655 if (attribute_flag[4] != 0)
7656 frame_info.outer_bevel=argument_list[4].long_reference;
7657 if (attribute_flag[5] != 0)
7658 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7660 if (attribute_flag[6] != 0)
7661 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7663 frame_info.x=(long) frame_info.width;
7664 frame_info.y=(long) frame_info.height;
7665 frame_info.width=image->columns+2*frame_info.x;
7666 frame_info.height=image->rows+2*frame_info.y;
7667 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7668 image->matte_color=fill_color;
7669 if (attribute_flag[7] != 0)
7670 image->compose=(CompositeOperator) argument_list[7].long_reference;
7671 image=FrameImage(image,&frame_info,exception);
7674 case 16: /* Implode */
7676 if (attribute_flag[0] == 0)
7677 argument_list[0].real_reference=0.5;
7678 if (attribute_flag[1] != 0)
7679 image->interpolate=(InterpolatePixelMethod)
7680 argument_list[1].long_reference;
7681 image=ImplodeImage(image,argument_list[0].real_reference,
7685 case 17: /* Magnify */
7687 image=MagnifyImage(image,exception);
7690 case 18: /* MedianFilter */
7692 if (attribute_flag[0] == 0)
7693 argument_list[0].real_reference=0.0;
7694 image=MedianFilterImage(image,argument_list[0].real_reference,
7698 case 19: /* Minify */
7700 image=MinifyImage(image,exception);
7703 case 20: /* OilPaint */
7705 if (attribute_flag[0] == 0)
7706 argument_list[0].real_reference=0.0;
7707 image=OilPaintImage(image,argument_list[0].real_reference,
7711 case 21: /* ReduceNoise */
7713 if (attribute_flag[0] == 0)
7714 argument_list[0].real_reference=0.0;
7715 image=ReduceNoiseImage(image,argument_list[0].real_reference,
7721 if (attribute_flag[0] != 0)
7722 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7723 &geometry,exception);
7724 if (attribute_flag[1] != 0)
7725 geometry.x=argument_list[1].long_reference;
7726 if (attribute_flag[2] != 0)
7727 geometry.y=argument_list[2].long_reference;
7728 image=RollImage(image,geometry.x,geometry.y,exception);
7731 case 23: /* Rotate */
7733 if (attribute_flag[0] == 0)
7734 argument_list[0].real_reference=90.0;
7735 if (attribute_flag[1] != 0)
7736 QueryColorDatabase(argument_list[1].string_reference,
7737 &image->background_color,exception);
7738 if (attribute_flag[2] != 0)
7739 QueryColorDatabase(argument_list[2].string_reference,
7740 &image->background_color,exception);
7741 if (attribute_flag[3] != 0)
7742 QueryColorDatabase(argument_list[3].string_reference,
7743 &image->background_color,exception);
7744 image=RotateImage(image,argument_list[0].real_reference,exception);
7747 case 24: /* Sample */
7749 if (attribute_flag[0] != 0)
7750 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7751 &geometry,exception);
7752 if (attribute_flag[1] != 0)
7753 geometry.width=argument_list[1].long_reference;
7754 if (attribute_flag[2] != 0)
7755 geometry.height=argument_list[2].long_reference;
7756 image=SampleImage(image,geometry.width,geometry.height,exception);
7759 case 25: /* Scale */
7761 if (attribute_flag[0] != 0)
7762 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7763 &geometry,exception);
7764 if (attribute_flag[1] != 0)
7765 geometry.width=argument_list[1].long_reference;
7766 if (attribute_flag[2] != 0)
7767 geometry.height=argument_list[2].long_reference;
7768 image=ScaleImage(image,geometry.width,geometry.height,exception);
7771 case 26: /* Shade */
7773 if (attribute_flag[0] != 0)
7775 flags=ParseGeometry(argument_list[0].string_reference,
7777 if ((flags & SigmaValue) == 0)
7778 geometry_info.sigma=0.0;
7780 if (attribute_flag[1] != 0)
7781 geometry_info.rho=argument_list[1].real_reference;
7782 if (attribute_flag[2] != 0)
7783 geometry_info.sigma=argument_list[2].real_reference;
7784 image=ShadeImage(image,
7785 argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse,
7786 geometry_info.rho,geometry_info.sigma,exception);
7789 case 27: /* Sharpen */
7791 if (attribute_flag[0] != 0)
7793 flags=ParseGeometry(argument_list[0].string_reference,
7795 if ((flags & SigmaValue) == 0)
7796 geometry_info.sigma=1.0;
7798 if (attribute_flag[1] != 0)
7799 geometry_info.rho=argument_list[1].real_reference;
7800 if (attribute_flag[2] != 0)
7801 geometry_info.sigma=argument_list[2].real_reference;
7802 if (attribute_flag[3] != 0)
7803 channel=(ChannelType) argument_list[3].long_reference;
7804 image=SharpenImageChannel(image,channel,geometry_info.rho,
7805 geometry_info.sigma,exception);
7808 case 28: /* Shear */
7810 if (attribute_flag[0] != 0)
7812 flags=ParseGeometry(argument_list[0].string_reference,
7814 if ((flags & SigmaValue) == 0)
7815 geometry_info.sigma=geometry_info.rho;
7817 if (attribute_flag[1] != 0)
7818 geometry_info.rho=argument_list[1].real_reference;
7819 if (attribute_flag[2] != 0)
7820 geometry_info.sigma=argument_list[2].real_reference;
7821 if (attribute_flag[3] != 0)
7822 QueryColorDatabase(argument_list[3].string_reference,
7823 &image->background_color,exception);
7824 if (attribute_flag[4] != 0)
7825 QueryColorDatabase(argument_list[4].string_reference,
7826 &image->background_color,exception);
7827 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7831 case 29: /* Spread */
7833 if (attribute_flag[0] == 0)
7834 argument_list[0].real_reference=1.0;
7835 image=SpreadImage(image,argument_list[0].real_reference,exception);
7838 case 30: /* Swirl */
7840 if (attribute_flag[0] == 0)
7841 argument_list[0].real_reference=50.0;
7842 if (attribute_flag[1] != 0)
7843 image->interpolate=(InterpolatePixelMethod)
7844 argument_list[1].long_reference;
7845 image=SwirlImage(image,argument_list[0].real_reference,exception);
7848 case 31: /* Resize */
7851 if (attribute_flag[0] != 0)
7852 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7853 &geometry,exception);
7854 if (attribute_flag[1] != 0)
7855 geometry.width=argument_list[1].long_reference;
7856 if (attribute_flag[2] != 0)
7857 geometry.height=argument_list[2].long_reference;
7858 if (attribute_flag[3] == 0)
7859 argument_list[3].long_reference=(long) UndefinedFilter;
7860 if (attribute_flag[4] != 0)
7861 SetImageArtifact(image,"filter:support",
7862 argument_list[4].string_reference);
7863 if (attribute_flag[5] == 0)
7864 argument_list[5].real_reference=1.0;
7865 image=ResizeImage(image,geometry.width,geometry.height,
7866 (FilterTypes) argument_list[3].long_reference,
7867 argument_list[5].real_reference,exception);
7870 case 33: /* Annotate */
7875 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7877 if (attribute_flag[0] != 0)
7882 text=InterpretImageProperties(info ? info->image_info :
7883 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7884 (void) CloneString(&draw_info->text,text);
7885 text=DestroyString(text);
7887 if (attribute_flag[1] != 0)
7888 (void) CloneString(&draw_info->font,
7889 argument_list[1].string_reference);
7890 if (attribute_flag[2] != 0)
7891 draw_info->pointsize=argument_list[2].real_reference;
7892 if (attribute_flag[3] != 0)
7893 (void) CloneString(&draw_info->density,
7894 argument_list[3].string_reference);
7895 if (attribute_flag[4] != 0)
7896 (void) QueryColorDatabase(argument_list[4].string_reference,
7897 &draw_info->undercolor,exception);
7898 if (attribute_flag[5] != 0)
7900 (void) QueryColorDatabase(argument_list[5].string_reference,
7901 &draw_info->stroke,exception);
7902 if (argument_list[5].image_reference != (Image *) NULL)
7903 draw_info->stroke_pattern=CloneImage(
7904 argument_list[5].image_reference,0,0,MagickTrue,exception);
7906 if (attribute_flag[6] != 0)
7908 (void) QueryColorDatabase(argument_list[6].string_reference,
7909 &draw_info->fill,exception);
7910 if (argument_list[6].image_reference != (Image *) NULL)
7911 draw_info->fill_pattern=CloneImage(
7912 argument_list[6].image_reference,0,0,MagickTrue,exception);
7914 if (attribute_flag[7] != 0)
7916 (void) CloneString(&draw_info->geometry,
7917 argument_list[7].string_reference);
7918 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7919 &geometry,exception);
7920 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7921 geometry_info.sigma=geometry_info.xi;
7923 if (attribute_flag[8] != 0)
7924 (void) QueryColorDatabase(argument_list[8].string_reference,
7925 &draw_info->fill,exception);
7926 if (attribute_flag[11] != 0)
7927 draw_info->gravity=(GravityType) argument_list[11].long_reference;
7928 if (attribute_flag[25] != 0)
7933 av=(AV *) argument_list[25].array_reference;
7934 if ((av_len(av) != 3) && (av_len(av) != 5))
7936 ThrowPerlException(exception,OptionError,
7937 "affine matrix must have 4 or 6 elements",PackageName);
7940 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7941 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7942 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7943 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7944 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7945 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7947 ThrowPerlException(exception,OptionError,
7948 "affine matrix is singular",PackageName);
7951 if (av_len(av) == 5)
7953 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
7954 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
7957 for (j=12; j < 17; j++)
7959 if (attribute_flag[j] == 0)
7961 value=argument_list[j].string_reference;
7962 angle=argument_list[j].real_reference;
7963 current=draw_info->affine;
7964 GetAffineMatrix(&affine);
7972 flags=ParseGeometry(value,&geometry_info);
7973 affine.tx=geometry_info.xi;
7974 affine.ty=geometry_info.psi;
7975 if ((flags & PsiValue) == 0)
7976 affine.ty=affine.tx;
7984 flags=ParseGeometry(value,&geometry_info);
7985 affine.sx=geometry_info.rho;
7986 affine.sy=geometry_info.sigma;
7987 if ((flags & SigmaValue) == 0)
7988 affine.sy=affine.sx;
7998 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
7999 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8000 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8001 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8009 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8017 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8021 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8022 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8023 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8024 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8025 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8027 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8030 if (attribute_flag[9] == 0)
8031 argument_list[9].real_reference=0.0;
8032 if (attribute_flag[10] == 0)
8033 argument_list[10].real_reference=0.0;
8034 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8037 geometry[MaxTextExtent];
8039 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
8040 (double) argument_list[9].real_reference+draw_info->affine.tx,
8041 (double) argument_list[10].real_reference+draw_info->affine.ty);
8042 (void) CloneString(&draw_info->geometry,geometry);
8044 if (attribute_flag[17] != 0)
8045 draw_info->stroke_width=argument_list[17].real_reference;
8046 if (attribute_flag[18] != 0)
8048 draw_info->text_antialias=argument_list[18].long_reference != 0 ?
8049 MagickTrue : MagickFalse;
8050 draw_info->stroke_antialias=draw_info->text_antialias;
8052 if (attribute_flag[19] != 0)
8053 (void) CloneString(&draw_info->family,
8054 argument_list[19].string_reference);
8055 if (attribute_flag[20] != 0)
8056 draw_info->style=(StyleType) argument_list[20].long_reference;
8057 if (attribute_flag[21] != 0)
8058 draw_info->stretch=(StretchType) argument_list[21].long_reference;
8059 if (attribute_flag[22] != 0)
8060 draw_info->weight=argument_list[22].long_reference;
8061 if (attribute_flag[23] != 0)
8062 draw_info->align=(AlignType) argument_list[23].long_reference;
8063 if (attribute_flag[24] != 0)
8064 (void) CloneString(&draw_info->encoding,
8065 argument_list[24].string_reference);
8066 if (attribute_flag[25] != 0)
8067 draw_info->fill_pattern=CloneImage(
8068 argument_list[25].image_reference,0,0,MagickTrue,exception);
8069 if (attribute_flag[26] != 0)
8070 draw_info->fill_pattern=CloneImage(
8071 argument_list[26].image_reference,0,0,MagickTrue,exception);
8072 if (attribute_flag[27] != 0)
8073 draw_info->stroke_pattern=CloneImage(
8074 argument_list[27].image_reference,0,0,MagickTrue,exception);
8075 if (attribute_flag[29] != 0)
8076 draw_info->kerning=argument_list[29].real_reference;
8077 if (attribute_flag[30] != 0)
8078 draw_info->interline_spacing=argument_list[30].real_reference;
8079 if (attribute_flag[31] != 0)
8080 draw_info->interword_spacing=argument_list[31].real_reference;
8081 if (attribute_flag[32] != 0)
8082 draw_info->direction=(DirectionType)
8083 argument_list[32].long_reference;
8084 (void) AnnotateImage(image,draw_info);
8085 draw_info=DestroyDrawInfo(draw_info);
8088 case 34: /* ColorFloodfill */
8099 draw_info=CloneDrawInfo(info ? info->image_info :
8100 (ImageInfo *) NULL,(DrawInfo *) NULL);
8101 if (attribute_flag[0] != 0)
8102 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8103 &geometry,exception);
8104 if (attribute_flag[1] != 0)
8105 geometry.x=argument_list[1].long_reference;
8106 if (attribute_flag[2] != 0)
8107 geometry.y=argument_list[2].long_reference;
8108 if (attribute_flag[3] != 0)
8109 (void) QueryColorDatabase(argument_list[3].string_reference,
8110 &draw_info->fill,exception);
8111 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8114 if (attribute_flag[4] != 0)
8116 QueryMagickColor(argument_list[4].string_reference,&target,
8120 if (attribute_flag[5] != 0)
8121 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8123 if (attribute_flag[6] != 0)
8124 invert=(MagickBooleanType) argument_list[6].long_reference;
8125 (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
8126 geometry.x,geometry.y,invert);
8127 draw_info=DestroyDrawInfo(draw_info);
8130 case 35: /* Composite */
8133 composite_geometry[MaxTextExtent];
8139 compose=OverCompositeOp;
8140 if (attribute_flag[0] != 0)
8141 composite_image=argument_list[0].image_reference;
8144 ThrowPerlException(exception,OptionError,
8145 "CompositeImageRequired",PackageName);
8149 Parameter Handling used for BOTH normal and tiled composition.
8151 if (attribute_flag[1] != 0) /* compose */
8152 compose=(CompositeOperator) argument_list[1].long_reference;
8153 if (attribute_flag[6] != 0) /* opacity */
8155 if (compose != DissolveCompositeOp)
8156 (void) SetImageOpacity(composite_image,(Quantum) (QuantumRange-
8157 SiPrefixToDouble(argument_list[6].string_reference,
8173 register PixelPacket
8180 Handle dissolve composite operator (patch by
8183 (void) CloneString(&image->geometry,
8184 argument_list[6].string_reference);
8185 opacity=(Quantum) (QuantumRange-SiPrefixToDouble(
8186 argument_list[6].string_reference,QuantumRange));
8187 if (composite_image->matte != MagickTrue)
8188 (void) SetImageOpacity(composite_image,OpaqueOpacity);
8189 composite_view=AcquireCacheView(composite_image);
8190 for (y=0; y < (long) composite_image->rows ; y++)
8192 q=GetCacheViewAuthenticPixels(composite_view,0,y,(long)
8193 composite_image->columns,1,exception);
8194 for (x=0; x < (long) composite_image->columns; x++)
8196 if (q->opacity == OpaqueOpacity)
8197 q->opacity=ClampToQuantum(opacity);
8200 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8201 if (sync == MagickFalse)
8204 composite_view=DestroyCacheView(composite_view);
8207 if (attribute_flag[9] != 0) /* "color=>" */
8208 QueryColorDatabase(argument_list[9].string_reference,
8209 &composite_image->background_color,exception);
8210 if (attribute_flag[12] != 0) /* "interpolate=>" */
8211 image->interpolate=(InterpolatePixelMethod)
8212 argument_list[12].long_reference;
8213 if (attribute_flag[13] != 0) /* "args=>" */
8214 (void) SetImageArtifact(composite_image,"compose:args",
8215 argument_list[13].string_reference);
8216 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8217 (void) SetImageArtifact(composite_image,"compose:args",
8218 argument_list[14].string_reference);
8220 Tiling Composition (with orthogonal rotate).
8222 rotate_image=(Image *) NULL;
8223 if (attribute_flag[8] != 0) /* "rotate=>" */
8228 rotate_image=RotateImage(composite_image,
8229 argument_list[8].real_reference,exception);
8230 if (rotate_image == (Image *) NULL)
8233 if (attribute_flag[7] && argument_list[7].long_reference) /* tile */
8240 Tile the composite image.
8242 if (attribute_flag[8] != 0) /* "tile=>" */
8243 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8246 (void) SetImageArtifact(composite_image,
8247 "compose:outside-overlay","false");
8248 for (y=0; y < (long) image->rows; y+=composite_image->rows)
8249 for (x=0; x < (long) image->columns; x+=composite_image->columns)
8251 if (attribute_flag[8] != 0) /* rotate */
8252 (void) CompositeImage(image,compose,rotate_image,x,y);
8254 (void) CompositeImage(image,compose,composite_image,x,y);
8256 if (attribute_flag[8] != 0) /* rotate */
8257 rotate_image=DestroyImage(rotate_image);
8261 Parameter Handling used used ONLY for normal composition.
8263 if (attribute_flag[5] != 0) /* gravity */
8264 image->gravity=(GravityType) argument_list[5].long_reference;
8265 if (attribute_flag[2] != 0) /* geometry offset */
8267 SetGeometry(image,&geometry);
8268 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8270 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8273 if (attribute_flag[3] != 0) /* x offset */
8274 geometry.x=argument_list[3].long_reference;
8275 if (attribute_flag[4] != 0) /* y offset */
8276 geometry.y=argument_list[4].long_reference;
8277 if (attribute_flag[10] != 0) /* mask */
8279 if ((image->compose == DisplaceCompositeOp) ||
8280 (image->compose == DistortCompositeOp))
8283 Merge Y displacement into X displacement image.
8285 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8287 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8288 argument_list[10].image_reference,0,0);
8293 Set a blending mask for the composition.
8295 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8296 MagickTrue,&image->exception);
8297 (void) NegateImage(image->mask,MagickFalse);
8300 if (attribute_flag[11] != 0) /* channel */
8301 channel=(ChannelType) argument_list[11].long_reference;
8303 Composite two images (normal composition).
8305 (void) FormatMagickString(composite_geometry,MaxTextExtent,
8306 "%lux%lu%+ld%+ld",composite_image->columns,composite_image->rows,
8307 geometry.x,geometry.y);
8308 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8310 if (attribute_flag[8] == 0) /* no rotate */
8311 CompositeImageChannel(image,channel,compose,composite_image,
8312 geometry.x,geometry.y);
8316 Position adjust rotated image then composite.
8318 geometry.x-=(long) (rotate_image->columns-
8319 composite_image->columns)/2;
8320 geometry.y-=(long) (rotate_image->rows-composite_image->rows)/2;
8321 CompositeImageChannel(image,channel,compose,rotate_image,
8322 geometry.x,geometry.y);
8323 rotate_image=DestroyImage(rotate_image);
8325 if (attribute_flag[10] != 0) /* mask */
8327 if ((image->compose == DisplaceCompositeOp) ||
8328 (image->compose == DistortCompositeOp))
8329 composite_image=DestroyImage(composite_image);
8331 image->mask=DestroyImage(image->mask);
8335 case 36: /* Contrast */
8337 if (attribute_flag[0] == 0)
8338 argument_list[0].long_reference=0;
8339 (void) ContrastImage(image,argument_list[0].long_reference != 0 ?
8340 MagickTrue : MagickFalse);
8343 case 37: /* CycleColormap */
8345 if (attribute_flag[0] == 0)
8346 argument_list[0].long_reference=6;
8347 (void) CycleColormapImage(image,argument_list[0].long_reference);
8355 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8357 (void) CloneString(&draw_info->primitive,"point");
8358 if (attribute_flag[0] != 0)
8360 if (argument_list[0].long_reference < 0)
8361 (void) CloneString(&draw_info->primitive,
8362 argument_list[0].string_reference);
8364 (void) CloneString(&draw_info->primitive,MagickOptionToMnemonic(
8365 MagickPrimitiveOptions,argument_list[0].long_reference));
8367 if (attribute_flag[1] != 0)
8369 if (LocaleCompare(draw_info->primitive,"path") == 0)
8371 (void) ConcatenateString(&draw_info->primitive," '");
8372 ConcatenateString(&draw_info->primitive,
8373 argument_list[1].string_reference);
8374 (void) ConcatenateString(&draw_info->primitive,"'");
8378 (void) ConcatenateString(&draw_info->primitive," ");
8379 ConcatenateString(&draw_info->primitive,
8380 argument_list[1].string_reference);
8383 if (attribute_flag[2] != 0)
8385 (void) ConcatenateString(&draw_info->primitive," ");
8386 (void) ConcatenateString(&draw_info->primitive,
8387 MagickOptionToMnemonic(MagickMethodOptions,
8388 argument_list[2].long_reference));
8390 if (attribute_flag[3] != 0)
8392 (void) QueryColorDatabase(argument_list[3].string_reference,
8393 &draw_info->stroke,exception);
8394 if (argument_list[3].image_reference != (Image *) NULL)
8395 draw_info->stroke_pattern=CloneImage(
8396 argument_list[3].image_reference,0,0,MagickTrue,exception);
8398 if (attribute_flag[4] != 0)
8400 (void) QueryColorDatabase(argument_list[4].string_reference,
8401 &draw_info->fill,exception);
8402 if (argument_list[4].image_reference != (Image *) NULL)
8403 draw_info->fill_pattern=CloneImage(
8404 argument_list[4].image_reference,0,0,MagickTrue,exception);
8406 if (attribute_flag[5] != 0)
8407 draw_info->stroke_width=argument_list[5].real_reference;
8408 if (attribute_flag[6] != 0)
8409 (void) CloneString(&draw_info->font,
8410 argument_list[6].string_reference);
8411 if (attribute_flag[7] != 0)
8412 (void) QueryColorDatabase(argument_list[7].string_reference,
8413 &draw_info->border_color,exception);
8414 if (attribute_flag[8] != 0)
8415 draw_info->affine.tx=argument_list[8].real_reference;
8416 if (attribute_flag[9] != 0)
8417 draw_info->affine.ty=argument_list[9].real_reference;
8418 if (attribute_flag[20] != 0)
8423 av=(AV *) argument_list[20].array_reference;
8424 if ((av_len(av) != 3) && (av_len(av) != 5))
8426 ThrowPerlException(exception,OptionError,
8427 "affine matrix must have 4 or 6 elements",PackageName);
8430 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8431 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8432 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8433 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8434 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8435 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8437 ThrowPerlException(exception,OptionError,
8438 "affine matrix is singular",PackageName);
8441 if (av_len(av) == 5)
8443 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8444 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8447 for (j=10; j < 15; j++)
8449 if (attribute_flag[j] == 0)
8451 value=argument_list[j].string_reference;
8452 angle=argument_list[j].real_reference;
8453 current=draw_info->affine;
8454 GetAffineMatrix(&affine);
8462 flags=ParseGeometry(value,&geometry_info);
8463 affine.tx=geometry_info.xi;
8464 affine.ty=geometry_info.psi;
8465 if ((flags & PsiValue) == 0)
8466 affine.ty=affine.tx;
8474 flags=ParseGeometry(value,&geometry_info);
8475 affine.sx=geometry_info.rho;
8476 affine.sy=geometry_info.sigma;
8477 if ((flags & SigmaValue) == 0)
8478 affine.sy=affine.sx;
8488 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8489 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8490 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8491 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8499 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8507 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8511 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8512 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8513 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8514 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8515 draw_info->affine.tx=
8516 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8517 draw_info->affine.ty=
8518 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8520 if (attribute_flag[15] != 0)
8521 draw_info->fill_pattern=CloneImage(
8522 argument_list[15].image_reference,0,0,MagickTrue,exception);
8523 if (attribute_flag[16] != 0)
8524 draw_info->pointsize=argument_list[16].real_reference;
8525 if (attribute_flag[17] != 0)
8527 draw_info->stroke_antialias=argument_list[17].long_reference != 0
8528 ? MagickTrue : MagickFalse;
8529 draw_info->text_antialias=draw_info->stroke_antialias;
8531 if (attribute_flag[18] != 0)
8532 (void) CloneString(&draw_info->density,
8533 argument_list[18].string_reference);
8534 if (attribute_flag[19] != 0)
8535 draw_info->stroke_width=argument_list[19].real_reference;
8536 if (attribute_flag[21] != 0)
8537 draw_info->dash_offset=argument_list[21].real_reference;
8538 if (attribute_flag[22] != 0)
8543 av=(AV *) argument_list[22].array_reference;
8544 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8545 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8546 if (draw_info->dash_pattern != (double *) NULL)
8548 for (i=0; i <= av_len(av); i++)
8549 draw_info->dash_pattern[i]=(double)
8550 SvNV(*(av_fetch(av,i,0)));
8551 draw_info->dash_pattern[i]=0.0;
8554 if (attribute_flag[23] != 0)
8555 image->interpolate=(InterpolatePixelMethod)
8556 argument_list[23].long_reference;
8557 if ((attribute_flag[24] != 0) &&
8558 (draw_info->fill_pattern != (Image *) NULL))
8559 flags=ParsePageGeometry(draw_info->fill_pattern,
8560 argument_list[24].string_reference,
8561 &draw_info->fill_pattern->tile_offset,exception);
8562 if (attribute_flag[25] != 0)
8564 (void) ConcatenateString(&draw_info->primitive," '");
8565 (void) ConcatenateString(&draw_info->primitive,
8566 argument_list[25].string_reference);
8567 (void) ConcatenateString(&draw_info->primitive,"'");
8569 if (attribute_flag[26] != 0)
8570 draw_info->fill_pattern=CloneImage(
8571 argument_list[26].image_reference,0,0,MagickTrue,exception);
8572 if (attribute_flag[27] != 0)
8573 draw_info->stroke_pattern=CloneImage(
8574 argument_list[27].image_reference,0,0,MagickTrue,exception);
8575 if (attribute_flag[28] != 0)
8576 (void) CloneString(&draw_info->primitive,
8577 argument_list[28].string_reference);
8578 if (attribute_flag[29] != 0)
8579 draw_info->kerning=argument_list[29].real_reference;
8580 if (attribute_flag[30] != 0)
8581 draw_info->interline_spacing=argument_list[30].real_reference;
8582 if (attribute_flag[31] != 0)
8583 draw_info->interword_spacing=argument_list[31].real_reference;
8584 DrawImage(image,draw_info);
8585 draw_info=DestroyDrawInfo(draw_info);
8588 case 39: /* Equalize */
8590 if (attribute_flag[0] != 0)
8591 channel=(ChannelType) argument_list[0].long_reference;
8592 EqualizeImageChannel(image,channel);
8595 case 40: /* Gamma */
8597 if (attribute_flag[1] != 0)
8598 channel=(ChannelType) argument_list[1].long_reference;
8599 if (attribute_flag[2] == 0)
8600 argument_list[2].real_reference=1.0;
8601 if (attribute_flag[3] == 0)
8602 argument_list[3].real_reference=1.0;
8603 if (attribute_flag[4] == 0)
8604 argument_list[4].real_reference=1.0;
8605 if (attribute_flag[0] == 0)
8607 (void) FormatMagickString(message,MaxTextExtent,
8608 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8609 (double) argument_list[3].real_reference,
8610 (double) argument_list[4].real_reference);
8611 argument_list[0].string_reference=message;
8613 if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
8614 (void) GammaImage(image,argument_list[0].string_reference);
8616 (void) GammaImageChannel(image,channel,
8617 StringToDouble(argument_list[0].string_reference));
8625 if (attribute_flag[0] == 0)
8627 ThrowPerlException(exception,OptionError,"MapImageRequired",
8631 quantize_info=AcquireQuantizeInfo(info->image_info);
8632 if (attribute_flag[1] != 0)
8633 quantize_info->dither=(MagickBooleanType)
8634 argument_list[1].long_reference;
8635 if (attribute_flag[2] != 0)
8636 quantize_info->dither_method=(DitherMethod)
8637 argument_list[2].long_reference;
8638 (void) RemapImages(quantize_info,image,
8639 argument_list[0].image_reference);
8640 quantize_info=DestroyQuantizeInfo(quantize_info);
8643 case 42: /* MatteFloodfill */
8654 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8656 if (attribute_flag[0] != 0)
8657 if (attribute_flag[0] != 0)
8658 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8659 &geometry,exception);
8660 if (attribute_flag[1] != 0)
8661 geometry.x=argument_list[1].long_reference;
8662 if (attribute_flag[2] != 0)
8663 geometry.y=argument_list[2].long_reference;
8664 if (image->matte == MagickFalse)
8665 (void) SetImageOpacity(image,OpaqueOpacity);
8666 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8668 if (attribute_flag[4] != 0)
8669 QueryMagickColor(argument_list[4].string_reference,&target,
8671 if (attribute_flag[3] != 0)
8672 target.opacity=SiPrefixToDouble(argument_list[3].string_reference,
8674 if (attribute_flag[5] != 0)
8675 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8678 if (attribute_flag[6] != 0)
8679 invert=(MagickBooleanType) argument_list[6].long_reference;
8680 (void) FloodfillPaintImage(image,OpacityChannel,draw_info,&target,
8681 geometry.x,geometry.y,invert);
8682 draw_info=DestroyDrawInfo(draw_info);
8685 case 43: /* Modulate */
8688 modulate[MaxTextExtent];
8693 colorspace=image->colorspace;
8694 geometry_info.rho=100.0;
8695 geometry_info.sigma=100.0;
8696 geometry_info.xi=100.0;
8697 if (attribute_flag[0] != 0)
8698 (void)ParseGeometry(argument_list[0].string_reference,
8700 if (attribute_flag[1] != 0)
8701 geometry_info.xi=argument_list[1].real_reference;
8702 if (attribute_flag[2] != 0)
8703 geometry_info.sigma=argument_list[2].real_reference;
8704 if (attribute_flag[3] != 0)
8706 (void) SetImageColorspace(image,HWBColorspace);
8707 geometry_info.sigma=argument_list[3].real_reference;
8709 if (attribute_flag[4] != 0)
8710 geometry_info.rho=argument_list[4].real_reference;
8711 if (attribute_flag[5] != 0)
8713 (void) SetImageColorspace(image,HSLColorspace);
8714 geometry_info.sigma=argument_list[5].real_reference;
8716 if (attribute_flag[6] != 0)
8718 (void) SetImageColorspace(image,HWBColorspace);
8719 geometry_info.rho=argument_list[6].real_reference;
8721 (void) FormatMagickString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8722 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8723 (void) ModulateImage(image,modulate);
8724 (void) SetImageColorspace(image,colorspace);
8727 case 44: /* Negate */
8729 if (attribute_flag[0] == 0)
8730 argument_list[0].long_reference=0;
8731 if (attribute_flag[1] != 0)
8732 channel=(ChannelType) argument_list[1].long_reference;
8733 (void) NegateImageChannel(image,channel,
8734 argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse);
8737 case 45: /* Normalize */
8739 if (attribute_flag[0] != 0)
8740 channel=(ChannelType) argument_list[0].long_reference;
8741 NormalizeImageChannel(image,channel);
8744 case 46: /* NumberColors */
8746 case 47: /* Opaque */
8755 (void) QueryMagickColor("none",&target,exception);
8756 (void) QueryMagickColor("none",&fill_color,exception);
8757 if (attribute_flag[0] != 0)
8758 (void) QueryMagickColor(argument_list[0].string_reference,
8760 if (attribute_flag[1] != 0)
8761 (void) QueryMagickColor(argument_list[1].string_reference,
8762 &fill_color,exception);
8763 if (attribute_flag[2] != 0)
8764 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8766 if (attribute_flag[3] != 0)
8767 channel=(ChannelType) argument_list[3].long_reference;
8769 if (attribute_flag[4] != 0)
8770 invert=(MagickBooleanType) argument_list[4].long_reference;
8771 (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
8775 case 48: /* Quantize */
8780 quantize_info=AcquireQuantizeInfo(info->image_info);
8781 if (attribute_flag[0] != 0)
8782 quantize_info->number_colors=(unsigned long)
8783 argument_list[0].long_reference;
8784 if (attribute_flag[1] != 0)
8785 quantize_info->tree_depth=(unsigned long)
8786 argument_list[1].long_reference;
8787 if (attribute_flag[2] != 0)
8788 quantize_info->colorspace=(ColorspaceType)
8789 argument_list[2].long_reference;
8790 if (attribute_flag[3] != 0)
8791 quantize_info->dither=argument_list[3].long_reference != 0 ?
8792 MagickTrue : MagickFalse;
8793 if (attribute_flag[4] != 0)
8794 quantize_info->measure_error=
8795 argument_list[4].long_reference != 0 ? MagickTrue : MagickFalse;
8796 if (attribute_flag[5] != 0)
8797 (void) QueryColorDatabase(argument_list[5].string_reference,
8798 &image->transparent_color,exception);
8799 if (attribute_flag[5] && argument_list[5].long_reference)
8801 (void) QuantizeImages(quantize_info,image);
8804 if (attribute_flag[6] != 0)
8805 quantize_info->dither_method=(DitherMethod)
8806 argument_list[6].long_reference;
8807 if ((image->storage_class == DirectClass) ||
8808 (image->colors > quantize_info->number_colors) ||
8809 (quantize_info->colorspace == GRAYColorspace))
8810 (void) QuantizeImage(quantize_info,image);
8812 CompressImageColormap(image);
8813 quantize_info=DestroyQuantizeInfo(quantize_info);
8816 case 49: /* Raise */
8818 if (attribute_flag[0] != 0)
8819 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8820 &geometry,exception);
8821 if (attribute_flag[1] != 0)
8822 geometry.width=argument_list[1].long_reference;
8823 if (attribute_flag[2] != 0)
8824 geometry.height=argument_list[2].long_reference;
8825 if (attribute_flag[3] == 0)
8826 argument_list[3].long_reference=1;
8827 (void) RaiseImage(image,&geometry,argument_list[3].long_reference !=
8828 0 ? MagickTrue : MagickFalse);
8831 case 50: /* Segment */
8838 smoothing_threshold;
8843 cluster_threshold=1.0;
8844 smoothing_threshold=1.5;
8845 colorspace=RGBColorspace;
8846 verbose=MagickFalse;
8847 if (attribute_flag[0] != 0)
8849 flags=ParseGeometry(argument_list[0].string_reference,
8851 cluster_threshold=geometry_info.rho;
8852 if (flags & SigmaValue)
8853 smoothing_threshold=geometry_info.sigma;
8855 if (attribute_flag[1] != 0)
8856 cluster_threshold=argument_list[1].real_reference;
8857 if (attribute_flag[2] != 0)
8858 smoothing_threshold=argument_list[2].real_reference;
8859 if (attribute_flag[3] != 0)
8860 colorspace=(ColorspaceType) argument_list[3].long_reference;
8861 if (attribute_flag[4] != 0)
8862 verbose=argument_list[4].long_reference != 0 ?
8863 MagickTrue : MagickFalse;
8864 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8865 smoothing_threshold);
8868 case 51: /* Signature */
8870 (void) SignatureImage(image);
8873 case 52: /* Solarize */
8875 geometry_info.rho=QuantumRange/2.0;
8876 if (attribute_flag[0] != 0)
8877 flags=ParseGeometry(argument_list[0].string_reference,
8879 if (attribute_flag[1] != 0)
8880 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8882 (void) SolarizeImage(image,geometry_info.rho);
8887 (void) SyncImage(image);
8890 case 54: /* Texture */
8892 if (attribute_flag[0] == 0)
8894 TextureImage(image,argument_list[0].image_reference);
8897 case 55: /* Evalute */
8899 MagickEvaluateOperator
8902 op=SetEvaluateOperator;
8903 if (attribute_flag[0] == MagickFalse)
8904 argument_list[0].real_reference=0.0;
8905 if (attribute_flag[1] != MagickFalse)
8906 op=(MagickEvaluateOperator) argument_list[1].long_reference;
8907 if (attribute_flag[2] != MagickFalse)
8908 channel=(ChannelType) argument_list[2].long_reference;
8909 (void) EvaluateImageChannel(image,channel,op,
8910 argument_list[0].real_reference,exception);
8913 case 56: /* Transparent */
8924 (void) QueryMagickColor("none",&target,exception);
8925 if (attribute_flag[0] != 0)
8926 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8928 opacity=TransparentOpacity;
8929 if (attribute_flag[1] != 0)
8930 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8932 if (attribute_flag[2] != 0)
8933 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8935 if (attribute_flag[3] == 0)
8936 argument_list[3].long_reference=0;
8938 if (attribute_flag[3] != 0)
8939 invert=(MagickBooleanType) argument_list[3].long_reference;
8940 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
8944 case 57: /* Threshold */
8949 if (attribute_flag[0] == 0)
8950 argument_list[0].string_reference="50%";
8951 if (attribute_flag[1] != 0)
8952 channel=(ChannelType) argument_list[1].long_reference;
8953 threshold=SiPrefixToDouble(argument_list[0].string_reference,
8955 (void) BilevelImageChannel(image,channel,threshold);
8958 case 58: /* Charcoal */
8960 if (attribute_flag[0] != 0)
8962 flags=ParseGeometry(argument_list[0].string_reference,
8964 if ((flags & SigmaValue) == 0)
8965 geometry_info.sigma=1.0;
8967 if (attribute_flag[1] != 0)
8968 geometry_info.rho=argument_list[1].real_reference;
8969 if (attribute_flag[2] != 0)
8970 geometry_info.sigma=argument_list[2].real_reference;
8971 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
8977 if (attribute_flag[0] != 0)
8978 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
8980 image=TrimImage(image,exception);
8985 if (attribute_flag[0] != 0)
8987 flags=ParseGeometry(argument_list[0].string_reference,
8989 if ((flags & SigmaValue) == 0)
8990 geometry_info.sigma=1.0;
8992 if (attribute_flag[1] != 0)
8993 geometry_info.rho=argument_list[1].real_reference;
8994 if (attribute_flag[2] != 0)
8995 geometry_info.sigma=argument_list[2].real_reference;
8996 if (attribute_flag[3] != 0)
8997 image->interpolate=(InterpolatePixelMethod)
8998 argument_list[3].long_reference;
8999 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9003 case 61: /* Separate */
9005 if (attribute_flag[0] != 0)
9006 channel=(ChannelType) argument_list[0].long_reference;
9007 (void) SeparateImageChannel(image,channel);
9010 case 63: /* Stereo */
9012 if (attribute_flag[0] == 0)
9014 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9018 if (attribute_flag[1] != 0)
9019 geometry.x=argument_list[1].long_reference;
9020 if (attribute_flag[2] != 0)
9021 geometry.y=argument_list[2].long_reference;
9022 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9023 geometry.x,geometry.y,exception);
9026 case 64: /* Stegano */
9028 if (attribute_flag[0] == 0)
9030 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9034 if (attribute_flag[1] == 0)
9035 argument_list[1].long_reference=0;
9036 image->offset=argument_list[1].long_reference;
9037 image=SteganoImage(image,argument_list[0].image_reference,exception);
9040 case 65: /* Deconstruct */
9042 image=DeconstructImages(image,exception);
9045 case 66: /* GaussianBlur */
9047 if (attribute_flag[0] != 0)
9049 flags=ParseGeometry(argument_list[0].string_reference,
9051 if ((flags & SigmaValue) == 0)
9052 geometry_info.sigma=1.0;
9054 if (attribute_flag[1] != 0)
9055 geometry_info.rho=argument_list[1].real_reference;
9056 if (attribute_flag[2] != 0)
9057 geometry_info.sigma=argument_list[2].real_reference;
9058 if (attribute_flag[3] != 0)
9059 channel=(ChannelType) argument_list[3].long_reference;
9060 image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
9061 geometry_info.sigma,exception);
9064 case 67: /* Convolve */
9075 if (attribute_flag[0] == 0)
9077 if (attribute_flag[1] != 0)
9078 channel=(ChannelType) argument_list[1].long_reference;
9079 if (attribute_flag[2] != 0)
9080 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9082 av=(AV *) argument_list[0].array_reference;
9083 order=(unsigned long) sqrt(av_len(av)+1);
9084 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9085 if (kernel == (double *) NULL)
9087 ThrowPerlException(exception,ResourceLimitFatalError,
9088 "MemoryAllocationFailed",PackageName);
9091 for (j=0; (j < (long) (order*order)) && (j < (av_len(av)+1)); j++)
9092 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9093 for ( ; j < (long) (order*order); j++)
9095 image=ConvolveImageChannel(image,channel,order,kernel,exception);
9096 kernel=(double *) RelinquishMagickMemory(kernel);
9099 case 68: /* Profile */
9114 if (attribute_flag[0] != 0)
9115 name=argument_list[0].string_reference;
9116 if (attribute_flag[2] != 0)
9117 image->rendering_intent=(RenderingIntent)
9118 argument_list[2].long_reference;
9119 if (attribute_flag[3] != 0)
9120 image->black_point_compensation=
9121 argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse;
9122 if (attribute_flag[1] != 0)
9124 if (argument_list[1].length == 0)
9127 Remove a profile from the image.
9129 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9134 Associate user supplied profile with the image.
9136 profile=AcquireStringInfo(argument_list[1].length);
9137 SetStringInfoDatum(profile,(const unsigned char *)
9138 argument_list[1].string_reference);
9139 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9140 (unsigned long) GetStringInfoLength(profile),MagickFalse);
9141 profile=DestroyStringInfo(profile);
9145 Associate a profile with the image.
9148 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9149 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9150 profile_image=ReadImages(profile_info,&image->exception);
9151 if (profile_image == (Image *) NULL)
9153 ResetImageProfileIterator(profile_image);
9154 name=GetNextImageProfile(profile_image);
9155 while (name != (const char *) NULL)
9160 profile=GetImageProfile(profile_image,name);
9161 if (profile != (const StringInfo *) NULL)
9162 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9163 (unsigned long) GetStringInfoLength(profile),MagickFalse);
9164 name=GetNextImageProfile(profile_image);
9166 profile_image=DestroyImage(profile_image);
9167 profile_info=DestroyImageInfo(profile_info);
9170 case 69: /* UnsharpMask */
9172 if (attribute_flag[0] != 0)
9174 flags=ParseGeometry(argument_list[0].string_reference,
9176 if ((flags & SigmaValue) == 0)
9177 geometry_info.sigma=1.0;
9178 if ((flags & XiValue) == 0)
9179 geometry_info.xi=1.0;
9180 if ((flags & PsiValue) == 0)
9181 geometry_info.psi=0.5;
9183 if (attribute_flag[1] != 0)
9184 geometry_info.rho=argument_list[1].real_reference;
9185 if (attribute_flag[2] != 0)
9186 geometry_info.sigma=argument_list[2].real_reference;
9187 if (attribute_flag[3] != 0)
9188 geometry_info.xi=argument_list[3].real_reference;
9189 if (attribute_flag[4] != 0)
9190 geometry_info.psi=argument_list[4].real_reference;
9191 if (attribute_flag[5] != 0)
9192 channel=(ChannelType) argument_list[5].long_reference;
9193 image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9194 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9197 case 70: /* MotionBlur */
9199 if (attribute_flag[0] != 0)
9201 flags=ParseGeometry(argument_list[0].string_reference,
9203 if ((flags & SigmaValue) == 0)
9204 geometry_info.sigma=1.0;
9205 if ((flags & XiValue) == 0)
9206 geometry_info.xi=1.0;
9208 if (attribute_flag[1] != 0)
9209 geometry_info.rho=argument_list[1].real_reference;
9210 if (attribute_flag[2] != 0)
9211 geometry_info.sigma=argument_list[2].real_reference;
9212 if (attribute_flag[3] != 0)
9213 geometry_info.xi=argument_list[3].real_reference;
9214 if (attribute_flag[4] != 0)
9215 channel=(ChannelType) argument_list[4].long_reference;
9216 image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9217 geometry_info.sigma,geometry_info.xi,exception);
9220 case 71: /* OrderedDither */
9222 if (attribute_flag[0] == 0)
9223 argument_list[0].string_reference="o8x8";
9224 if (attribute_flag[1] != 0)
9225 channel=(ChannelType) argument_list[1].long_reference;
9226 (void) OrderedPosterizeImageChannel(image,channel,
9227 argument_list[0].string_reference,exception);
9230 case 72: /* Shave */
9232 if (attribute_flag[0] != 0)
9233 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9234 &geometry,exception);
9235 if (attribute_flag[1] != 0)
9236 geometry.width=argument_list[1].long_reference;
9237 if (attribute_flag[2] != 0)
9238 geometry.height=argument_list[2].long_reference;
9239 image=ShaveImage(image,&geometry,exception);
9242 case 73: /* Level */
9250 white_point=(MagickRealType) image->columns*image->rows;
9252 if (attribute_flag[0] != 0)
9254 flags=ParseGeometry(argument_list[0].string_reference,
9256 black_point=geometry_info.rho;
9257 if ((flags & SigmaValue) != 0)
9258 white_point=geometry_info.sigma;
9259 if ((flags & XiValue) != 0)
9260 gamma=geometry_info.xi;
9261 if ((flags & PercentValue) != 0)
9263 black_point*=(double) (QuantumRange/100.0);
9264 white_point*=(double) (QuantumRange/100.0);
9266 if ((flags & SigmaValue) == 0)
9267 white_point=(double) QuantumRange-black_point;
9269 if (attribute_flag[1] != 0)
9270 black_point=argument_list[1].real_reference;
9271 if (attribute_flag[2] != 0)
9272 white_point=argument_list[2].real_reference;
9273 if (attribute_flag[3] != 0)
9274 gamma=argument_list[3].real_reference;
9275 if (attribute_flag[4] != 0)
9276 channel=(ChannelType) argument_list[4].long_reference;
9277 if (attribute_flag[5] != 0)
9279 argument_list[0].real_reference=argument_list[5].real_reference;
9280 attribute_flag[0]=attribute_flag[5];
9282 (void) LevelImageChannel(image,channel,black_point,white_point,gamma);
9287 if (attribute_flag[0] == 0)
9288 argument_list[0].string_reference="#1";
9289 if (attribute_flag[1] == 0)
9290 argument_list[1].long_reference=MagickTrue;
9291 (void) ClipImagePath(image,argument_list[0].string_reference,
9292 argument_list[1].long_reference != 0 ? MagickTrue : MagickFalse);
9295 case 75: /* AffineTransform */
9300 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9302 if (attribute_flag[0] != 0)
9307 av=(AV *) argument_list[0].array_reference;
9308 if ((av_len(av) != 3) && (av_len(av) != 5))
9310 ThrowPerlException(exception,OptionError,
9311 "affine matrix must have 4 or 6 elements",PackageName);
9314 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9315 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9316 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9317 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9318 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9319 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9321 ThrowPerlException(exception,OptionError,
9322 "affine matrix is singular",PackageName);
9325 if (av_len(av) == 5)
9327 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9328 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9331 for (j=1; j < 6; j++)
9333 if (attribute_flag[j] == 0)
9335 value=argument_list[j].string_reference;
9336 angle=argument_list[j].real_reference;
9337 current=draw_info->affine;
9338 GetAffineMatrix(&affine);
9346 flags=ParseGeometry(value,&geometry_info);
9347 affine.tx=geometry_info.xi;
9348 affine.ty=geometry_info.psi;
9349 if ((flags & PsiValue) == 0)
9350 affine.ty=affine.tx;
9358 flags=ParseGeometry(value,&geometry_info);
9359 affine.sx=geometry_info.rho;
9360 affine.sy=geometry_info.sigma;
9361 if ((flags & SigmaValue) == 0)
9362 affine.sy=affine.sx;
9372 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9373 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9374 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9375 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9383 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9391 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9395 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9396 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9397 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9398 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9399 draw_info->affine.tx=
9400 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9401 draw_info->affine.ty=
9402 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9404 if (attribute_flag[6] != 0)
9405 image->interpolate=(InterpolatePixelMethod)
9406 argument_list[6].long_reference;
9407 if (attribute_flag[7] != 0)
9408 QueryColorDatabase(argument_list[7].string_reference,
9409 &image->background_color,exception);
9410 image=AffineTransformImage(image,&draw_info->affine,exception);
9411 draw_info=DestroyDrawInfo(draw_info);
9414 case 76: /* Difference */
9416 if (attribute_flag[0] == 0)
9418 ThrowPerlException(exception,OptionError,
9419 "ReferenceImageRequired",PackageName);
9422 if (attribute_flag[1] != 0)
9423 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9425 (void) IsImagesEqual(image,argument_list[0].image_reference);
9428 case 77: /* AdaptiveThreshold */
9430 if (attribute_flag[0] != 0)
9432 flags=ParseGeometry(argument_list[0].string_reference,
9434 if ((flags & PercentValue) != 0)
9435 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9437 if (attribute_flag[1] != 0)
9438 geometry_info.rho=argument_list[1].long_reference;
9439 if (attribute_flag[2] != 0)
9440 geometry_info.sigma=argument_list[2].long_reference;
9441 if (attribute_flag[3] != 0)
9442 geometry_info.xi=argument_list[3].long_reference;;
9443 image=AdaptiveThresholdImage(image,(unsigned long) geometry_info.rho,
9444 (unsigned long) geometry_info.sigma,(long) geometry_info.xi,
9448 case 78: /* Resample */
9454 if (attribute_flag[0] != 0)
9456 flags=ParseGeometry(argument_list[0].string_reference,
9458 if ((flags & SigmaValue) == 0)
9459 geometry_info.sigma=geometry_info.rho;
9461 if (attribute_flag[1] != 0)
9462 geometry_info.rho=argument_list[1].real_reference;
9463 if (attribute_flag[2] != 0)
9464 geometry_info.sigma=argument_list[2].real_reference;
9465 if (attribute_flag[3] == 0)
9466 argument_list[3].long_reference=(long) UndefinedFilter;
9467 if (attribute_flag[4] == 0)
9468 SetImageArtifact(image,"filter:support",
9469 argument_list[4].string_reference);
9470 if (attribute_flag[5] != 0)
9471 argument_list[5].real_reference=1.0;
9472 width=(unsigned long) (geometry_info.rho*image->columns/
9473 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9474 height=(unsigned long) (geometry_info.sigma*image->rows/
9475 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9476 image=ResizeImage(image,width,height,(FilterTypes)
9477 argument_list[3].long_reference,argument_list[5].real_reference,
9479 if (image != (Image *) NULL)
9481 image->x_resolution=geometry_info.rho;
9482 image->y_resolution=geometry_info.sigma;
9486 case 79: /* Describe */
9488 if (attribute_flag[0] == 0)
9489 argument_list[0].file_reference=(FILE *) NULL;
9490 if (attribute_flag[1] != 0)
9491 (void) SetImageArtifact(image,"identify:features",
9492 argument_list[1].string_reference);
9493 (void) IdentifyImage(image,argument_list[0].file_reference,
9497 case 80: /* BlackThreshold */
9499 if (attribute_flag[0] == 0)
9500 argument_list[0].string_reference="50%";
9501 if (attribute_flag[2] != 0)
9502 channel=(ChannelType) argument_list[2].long_reference;
9503 BlackThresholdImageChannel(image,channel,
9504 argument_list[0].string_reference,exception);
9507 case 81: /* WhiteThreshold */
9509 if (attribute_flag[0] == 0)
9510 argument_list[0].string_reference="50%";
9511 if (attribute_flag[2] != 0)
9512 channel=(ChannelType) argument_list[2].long_reference;
9513 WhiteThresholdImageChannel(image,channel,
9514 argument_list[0].string_reference,exception);
9517 case 82: /* RadialBlur */
9519 if (attribute_flag[0] != 0)
9521 flags=ParseGeometry(argument_list[0].string_reference,
9523 if ((flags & SigmaValue) == 0)
9524 geometry_info.sigma=1.0;
9526 if (attribute_flag[1] != 0)
9527 geometry_info.rho=argument_list[1].real_reference;
9528 if (attribute_flag[2] != 0)
9529 channel=(ChannelType) argument_list[2].long_reference;
9530 image=RadialBlurImageChannel(image,channel,geometry_info.rho,
9534 case 83: /* Thumbnail */
9536 if (attribute_flag[0] != 0)
9537 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9538 &geometry,exception);
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 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9546 case 84: /* Strip */
9548 (void) StripImage(image);
9556 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9557 if (attribute_flag[0] != 0)
9558 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9560 if (attribute_flag[1] == 0)
9561 argument_list[1].string_reference="100";
9562 image=TintImage(image,argument_list[1].string_reference,target,
9566 case 86: /* Channel */
9568 if (attribute_flag[0] != 0)
9569 channel=(ChannelType) argument_list[0].long_reference;
9570 (void) SeparateImageChannel(image,channel);
9573 case 87: /* Splice */
9575 if (attribute_flag[0] != 0)
9576 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9577 &geometry,exception);
9578 if (attribute_flag[1] != 0)
9579 geometry.width=argument_list[1].long_reference;
9580 if (attribute_flag[2] != 0)
9581 geometry.height=argument_list[2].long_reference;
9582 if (attribute_flag[3] != 0)
9583 geometry.x=argument_list[3].long_reference;
9584 if (attribute_flag[4] != 0)
9585 geometry.y=argument_list[4].long_reference;
9586 if (attribute_flag[5] != 0)
9587 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9589 if (attribute_flag[6] != 0)
9590 (void) QueryColorDatabase(argument_list[6].string_reference,
9591 &image->background_color,exception);
9592 if (attribute_flag[7] != 0)
9593 image->gravity=(GravityType) argument_list[7].long_reference;
9594 image=SpliceImage(image,&geometry,exception);
9597 case 88: /* Posterize */
9599 if (attribute_flag[0] == 0)
9600 argument_list[0].long_reference=3;
9601 if (attribute_flag[1] == 0)
9602 argument_list[1].long_reference=0;
9603 (void) PosterizeImage(image,argument_list[0].long_reference,
9604 argument_list[1].long_reference ? MagickTrue : MagickFalse);
9607 case 89: /* Shadow */
9609 if (attribute_flag[0] != 0)
9611 flags=ParseGeometry(argument_list[0].string_reference,
9613 if ((flags & SigmaValue) == 0)
9614 geometry_info.sigma=1.0;
9615 if ((flags & XiValue) == 0)
9616 geometry_info.xi=4.0;
9617 if ((flags & PsiValue) == 0)
9618 geometry_info.psi=4.0;
9620 if (attribute_flag[1] != 0)
9621 geometry_info.rho=argument_list[1].real_reference;
9622 if (attribute_flag[2] != 0)
9623 geometry_info.sigma=argument_list[2].real_reference;
9624 if (attribute_flag[3] != 0)
9625 geometry_info.xi=argument_list[3].long_reference;
9626 if (attribute_flag[4] != 0)
9627 geometry_info.psi=argument_list[4].long_reference;
9628 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9629 (long) ceil(geometry_info.xi-0.5),(long) ceil(geometry_info.psi-
9633 case 90: /* Identify */
9635 if (attribute_flag[0] == 0)
9636 argument_list[0].file_reference=(FILE *) NULL;
9637 if (attribute_flag[1] != 0)
9638 (void) SetImageArtifact(image,"identify:features",
9639 argument_list[1].string_reference);
9640 if ((attribute_flag[2] != 0) &&
9641 (argument_list[2].long_reference != 0))
9642 (void) SetImageArtifact(image,"identify:unique","true");
9643 (void) IdentifyImage(image,argument_list[0].file_reference,
9647 case 91: /* SepiaTone */
9649 if (attribute_flag[0] == 0)
9650 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9651 image=SepiaToneImage(image,argument_list[0].real_reference,
9655 case 92: /* SigmoidalContrast */
9660 if (attribute_flag[0] != 0)
9662 flags=ParseGeometry(argument_list[0].string_reference,
9664 if ((flags & SigmaValue) == 0)
9665 geometry_info.sigma=QuantumRange/2.0;
9666 if ((flags & PercentValue) != 0)
9667 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9669 if (attribute_flag[1] != 0)
9670 geometry_info.rho=argument_list[1].real_reference;
9671 if (attribute_flag[2] != 0)
9672 geometry_info.sigma=argument_list[2].real_reference;
9673 if (attribute_flag[3] != 0)
9674 channel=(ChannelType) argument_list[3].long_reference;
9676 if (attribute_flag[4] != 0)
9677 sharpen=argument_list[4].long_reference != 0 ? MagickTrue :
9679 (void) SigmoidalContrastImageChannel(image,channel,sharpen,
9680 geometry_info.rho,geometry_info.sigma);
9683 case 93: /* Extent */
9685 if (attribute_flag[7] != 0)
9686 image->gravity=(GravityType) argument_list[7].long_reference;
9687 if (attribute_flag[0] != 0)
9692 flags=ParseGravityGeometry(image,
9693 argument_list[0].string_reference,&geometry,exception);
9694 if (geometry.width == 0)
9695 geometry.width=image->columns;
9696 if (geometry.height == 0)
9697 geometry.height=image->rows;
9698 geometry.x=(-geometry.x);
9699 geometry.y=(-geometry.y);
9701 if (attribute_flag[1] != 0)
9702 geometry.width=argument_list[1].long_reference;
9703 if (attribute_flag[2] != 0)
9704 geometry.height=argument_list[2].long_reference;
9705 if (attribute_flag[3] != 0)
9706 geometry.x=argument_list[3].long_reference;
9707 if (attribute_flag[4] != 0)
9708 geometry.y=argument_list[4].long_reference;
9709 if (attribute_flag[5] != 0)
9710 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9712 if (attribute_flag[6] != 0)
9713 (void) QueryColorDatabase(argument_list[6].string_reference,
9714 &image->background_color,exception);
9715 image=ExtentImage(image,&geometry,exception);
9718 case 94: /* Vignette */
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=0.1*image->columns;
9728 if ((flags & PsiValue) == 0)
9729 geometry_info.psi=0.1*image->rows;
9731 if (attribute_flag[1] != 0)
9732 geometry_info.rho=argument_list[1].real_reference;
9733 if (attribute_flag[2] != 0)
9734 geometry_info.sigma=argument_list[2].real_reference;
9735 if (attribute_flag[3] != 0)
9736 geometry_info.xi=argument_list[3].long_reference;
9737 if (attribute_flag[4] != 0)
9738 geometry_info.psi=argument_list[4].long_reference;
9739 if (attribute_flag[5] != 0)
9740 (void) QueryColorDatabase(argument_list[5].string_reference,
9741 &image->background_color,exception);
9742 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9743 (long) ceil(geometry_info.xi-0.5),(long) ceil(geometry_info.psi-
9747 case 95: /* ContrastStretch */
9754 white_point=(MagickRealType) image->columns*image->rows;
9755 if (attribute_flag[0] != 0)
9757 flags=ParseGeometry(argument_list[0].string_reference,
9759 black_point=geometry_info.rho;
9760 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9762 if ((flags & PercentValue) != 0)
9764 black_point*=(double) image->columns*image->rows/100.0;
9765 white_point*=(double) image->columns*image->rows/100.0;
9767 white_point=(MagickRealType) image->columns*image->rows-
9770 if (attribute_flag[1] != 0)
9771 black_point=argument_list[1].real_reference;
9772 if (attribute_flag[2] != 0)
9773 white_point=argument_list[2].real_reference;
9774 if (attribute_flag[4] != 0)
9775 channel=(ChannelType) argument_list[4].long_reference;
9776 (void) ContrastStretchImageChannel(image,channel,black_point,
9780 case 96: /* Sans0 */
9784 case 97: /* Sans1 */
9788 case 98: /* AdaptiveSharpen */
9790 if (attribute_flag[0] != 0)
9792 flags=ParseGeometry(argument_list[0].string_reference,
9794 if ((flags & SigmaValue) == 0)
9795 geometry_info.sigma=1.0;
9797 if (attribute_flag[1] != 0)
9798 geometry_info.rho=argument_list[1].real_reference;
9799 if (attribute_flag[2] != 0)
9800 geometry_info.sigma=argument_list[2].real_reference;
9801 if (attribute_flag[3] != 0)
9802 channel=(ChannelType) argument_list[3].long_reference;
9803 image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
9804 geometry_info.sigma,exception);
9807 case 99: /* Transpose */
9809 image=TransposeImage(image,exception);
9812 case 100: /* Tranverse */
9814 image=TransverseImage(image,exception);
9817 case 101: /* AutoOrient */
9819 switch (image->orientation)
9821 case TopRightOrientation:
9823 image=FlopImage(image,exception);
9826 case BottomRightOrientation:
9828 image=RotateImage(image,180.0,exception);
9831 case BottomLeftOrientation:
9833 image=FlipImage(image,exception);
9836 case LeftTopOrientation:
9838 image=TransposeImage(image,exception);
9841 case RightTopOrientation:
9843 image=RotateImage(image,90.0,exception);
9846 case RightBottomOrientation:
9848 image=TransverseImage(image,exception);
9851 case LeftBottomOrientation:
9853 image=RotateImage(image,270.0,exception);
9861 case 102: /* AdaptiveBlur */
9863 if (attribute_flag[0] != 0)
9865 flags=ParseGeometry(argument_list[0].string_reference,
9867 if ((flags & SigmaValue) == 0)
9868 geometry_info.sigma=1.0;
9870 if (attribute_flag[1] != 0)
9871 geometry_info.rho=argument_list[1].real_reference;
9872 if (attribute_flag[2] != 0)
9873 geometry_info.sigma=argument_list[2].real_reference;
9874 if (attribute_flag[3] != 0)
9875 channel=(ChannelType) argument_list[3].long_reference;
9876 image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
9877 geometry_info.sigma,exception);
9880 case 103: /* Sketch */
9882 if (attribute_flag[0] != 0)
9884 flags=ParseGeometry(argument_list[0].string_reference,
9886 if ((flags & SigmaValue) == 0)
9887 geometry_info.sigma=1.0;
9888 if ((flags & XiValue) == 0)
9889 geometry_info.xi=1.0;
9891 if (attribute_flag[1] != 0)
9892 geometry_info.rho=argument_list[1].real_reference;
9893 if (attribute_flag[2] != 0)
9894 geometry_info.sigma=argument_list[2].real_reference;
9895 if (attribute_flag[3] != 0)
9896 geometry_info.xi=argument_list[3].real_reference;
9897 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
9898 geometry_info.xi,exception);
9901 case 104: /* UniqueColors */
9903 image=UniqueImageColors(image,exception);
9906 case 105: /* AdaptiveResize */
9908 if (attribute_flag[0] != 0)
9909 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9910 &geometry,exception);
9911 if (attribute_flag[1] != 0)
9912 geometry.width=argument_list[1].long_reference;
9913 if (attribute_flag[2] != 0)
9914 geometry.height=argument_list[2].long_reference;
9915 if (attribute_flag[3] != 0)
9916 image->filter=(FilterTypes) argument_list[4].long_reference;
9917 if (attribute_flag[4] != 0)
9918 SetImageArtifact(image,"filter:support",
9919 argument_list[4].string_reference);
9920 if (attribute_flag[5] != 0)
9921 image->blur=argument_list[5].real_reference;
9922 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
9926 case 106: /* ClipMask */
9928 if (attribute_flag[0] == 0)
9930 ThrowPerlException(exception,OptionError,"MaskImageRequired",
9934 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
9935 MagickTrue,exception);
9936 (void) NegateImage(image->clip_mask,MagickFalse);
9939 case 107: /* LinearStretch */
9946 white_point=(MagickRealType) image->columns*image->rows;
9947 if (attribute_flag[0] != 0)
9949 flags=ParseGeometry(argument_list[0].string_reference,
9951 if ((flags & SigmaValue) != 0)
9952 white_point=geometry_info.sigma;
9953 if ((flags & PercentValue) != 0)
9955 black_point*=(double) image->columns*image->rows/100.0;
9956 white_point*=(double) image->columns*image->rows/100.0;
9958 if ((flags & SigmaValue) == 0)
9959 white_point=(double) image->columns*image->rows-black_point;
9961 if (attribute_flag[1] != 0)
9962 black_point=argument_list[1].real_reference;
9963 if (attribute_flag[2] != 0)
9964 white_point=argument_list[2].real_reference;
9965 (void) LinearStretchImage(image,black_point,white_point);
9968 case 109: /* Mask */
9970 if (attribute_flag[0] == 0)
9972 ThrowPerlException(exception,OptionError,"MaskImageRequired",
9976 image->mask=CloneImage(argument_list[0].image_reference,0,0,
9977 MagickTrue,exception);
9978 (void) NegateImage(image->mask,MagickFalse);
9981 case 110: /* Polaroid */
9989 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9991 if (attribute_flag[0] != 0)
9992 (void) SetImageProperty(image,"caption",InterpretImageProperties(
9993 info ? info->image_info : (ImageInfo *) NULL,image,
9994 argument_list[0].string_reference));
9996 if (attribute_flag[1] != 0)
9997 angle=argument_list[1].real_reference;
9998 if (attribute_flag[2] != 0)
9999 (void) CloneString(&draw_info->font,
10000 argument_list[2].string_reference);
10001 if (attribute_flag[3] != 0)
10002 (void) QueryColorDatabase(argument_list[3].string_reference,
10003 &draw_info->stroke,exception);
10004 if (attribute_flag[4] != 0)
10005 (void) QueryColorDatabase(argument_list[4].string_reference,
10006 &draw_info->fill,exception);
10007 if (attribute_flag[5] != 0)
10008 draw_info->stroke_width=argument_list[5].real_reference;
10009 if (attribute_flag[6] != 0)
10010 draw_info->pointsize=argument_list[6].real_reference;
10011 if (attribute_flag[7] != 0)
10012 draw_info->gravity=(GravityType) argument_list[7].long_reference;
10013 if (attribute_flag[8] != 0)
10014 (void) QueryColorDatabase(argument_list[8].string_reference,
10015 &image->background_color,exception);
10016 image=PolaroidImage(image,draw_info,angle,exception);
10017 draw_info=DestroyDrawInfo(draw_info);
10020 case 111: /* FloodfillPaint */
10031 draw_info=CloneDrawInfo(info ? info->image_info :
10032 (ImageInfo *) NULL,(DrawInfo *) NULL);
10033 if (attribute_flag[0] != 0)
10034 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10035 &geometry,exception);
10036 if (attribute_flag[1] != 0)
10037 geometry.x=argument_list[1].long_reference;
10038 if (attribute_flag[2] != 0)
10039 geometry.y=argument_list[2].long_reference;
10040 if (attribute_flag[3] != 0)
10041 (void) QueryColorDatabase(argument_list[3].string_reference,
10042 &draw_info->fill,exception);
10043 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10045 if (attribute_flag[4] != 0)
10046 QueryMagickColor(argument_list[4].string_reference,&target,
10048 if (attribute_flag[5] != 0)
10049 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10051 if (attribute_flag[6] != 0)
10052 channel=(ChannelType) argument_list[6].long_reference;
10053 invert=MagickFalse;
10054 if (attribute_flag[7] != 0)
10055 invert=(MagickBooleanType) argument_list[7].long_reference;
10056 (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
10057 geometry.y,invert);
10058 draw_info=DestroyDrawInfo(draw_info);
10061 case 112: /* Distort */
10073 number_coordinates;
10078 if (attribute_flag[0] == 0)
10080 method=UndefinedDistortion;
10081 if (attribute_flag[1] != 0)
10082 method=(DistortImageMethod) argument_list[1].long_reference;
10083 av=(AV *) argument_list[0].array_reference;
10084 number_coordinates=(unsigned long) av_len(av)+1;
10085 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10086 sizeof(*coordinates));
10087 if (coordinates == (double *) NULL)
10089 ThrowPerlException(exception,ResourceLimitFatalError,
10090 "MemoryAllocationFailed",PackageName);
10091 goto PerlException;
10093 for (j=0; j < (long) number_coordinates; j++)
10094 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10095 virtual_pixel=UndefinedVirtualPixelMethod;
10096 if (attribute_flag[2] != 0)
10097 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10098 argument_list[2].long_reference);
10099 image=DistortImage(image,method,number_coordinates,coordinates,
10100 argument_list[3].long_reference != 0 ? MagickTrue : MagickFalse,
10102 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10103 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10104 coordinates=(double *) RelinquishMagickMemory(coordinates);
10107 case 113: /* Clut */
10109 if (attribute_flag[0] == 0)
10111 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10113 goto PerlException;
10115 if (attribute_flag[1] != 0)
10116 channel=(ChannelType) argument_list[1].long_reference;
10117 (void) ClutImageChannel(image,channel,
10118 argument_list[0].image_reference);
10121 case 114: /* LiquidRescale */
10123 if (attribute_flag[0] != 0)
10124 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10125 &geometry,exception);
10126 if (attribute_flag[1] != 0)
10127 geometry.width=argument_list[1].long_reference;
10128 if (attribute_flag[2] != 0)
10129 geometry.height=argument_list[2].long_reference;
10130 if (attribute_flag[3] == 0)
10131 argument_list[3].real_reference=1.0;
10132 if (attribute_flag[4] == 0)
10133 argument_list[4].real_reference=0.0;
10134 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10135 argument_list[3].real_reference,argument_list[4].real_reference,
10139 case 115: /* EncipherImage */
10141 (void) EncipherImage(image,argument_list[0].string_reference,
10145 case 116: /* DecipherImage */
10147 (void) DecipherImage(image,argument_list[0].string_reference,
10151 case 117: /* Deskew */
10153 geometry_info.rho=QuantumRange/2.0;
10154 if (attribute_flag[0] != 0)
10155 flags=ParseGeometry(argument_list[0].string_reference,
10157 if (attribute_flag[1] != 0)
10158 geometry_info.rho=SiPrefixToDouble(
10159 argument_list[1].string_reference,QuantumRange);
10160 image=DeskewImage(image,geometry_info.rho,exception);
10163 case 118: /* Remap */
10168 if (attribute_flag[0] == 0)
10170 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10172 goto PerlException;
10174 quantize_info=AcquireQuantizeInfo(info->image_info);
10175 if (attribute_flag[1] != 0)
10176 quantize_info->dither=(MagickBooleanType)
10177 argument_list[1].long_reference;
10178 if (attribute_flag[2] != 0)
10179 quantize_info->dither_method=(DitherMethod)
10180 argument_list[2].long_reference;
10181 (void) RemapImages(quantize_info,image,
10182 argument_list[0].image_reference);
10183 quantize_info=DestroyQuantizeInfo(quantize_info);
10186 case 119: /* SparseColor */
10198 number_coordinates;
10203 if (attribute_flag[0] == 0)
10205 method=UndefinedColorInterpolate;
10206 if (attribute_flag[1] != 0)
10207 method=(SparseColorMethod) argument_list[1].long_reference;
10208 av=(AV *) argument_list[0].array_reference;
10209 number_coordinates=(unsigned long) av_len(av)+1;
10210 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10211 sizeof(*coordinates));
10212 if (coordinates == (double *) NULL)
10214 ThrowPerlException(exception,ResourceLimitFatalError,
10215 "MemoryAllocationFailed",PackageName);
10216 goto PerlException;
10218 for (j=0; j < (long) number_coordinates; j++)
10219 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10220 virtual_pixel=UndefinedVirtualPixelMethod;
10221 if (attribute_flag[2] != 0)
10222 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10223 argument_list[2].long_reference);
10224 if (attribute_flag[3] != 0)
10225 channel=(ChannelType) argument_list[3].long_reference;
10226 image=SparseColorImage(image,channel,method,number_coordinates,
10227 coordinates,exception);
10228 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10229 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10230 coordinates=(double *) RelinquishMagickMemory(coordinates);
10233 case 120: /* Function */
10250 if (attribute_flag[0] == 0)
10252 function=UndefinedFunction;
10253 if (attribute_flag[1] != 0)
10254 function=(MagickFunction) argument_list[1].long_reference;
10255 av=(AV *) argument_list[0].array_reference;
10256 number_parameters=(unsigned long) av_len(av)+1;
10257 parameters=(double *) AcquireQuantumMemory(number_parameters,
10258 sizeof(*parameters));
10259 if (parameters == (double *) NULL)
10261 ThrowPerlException(exception,ResourceLimitFatalError,
10262 "MemoryAllocationFailed",PackageName);
10263 goto PerlException;
10265 for (j=0; j < (long) number_parameters; j++)
10266 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10267 virtual_pixel=UndefinedVirtualPixelMethod;
10268 if (attribute_flag[2] != 0)
10269 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10270 argument_list[2].long_reference);
10271 (void) FunctionImage(image,function,number_parameters,parameters,
10273 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10274 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10275 parameters=(double *) RelinquishMagickMemory(parameters);
10278 case 121: /* SelectiveBlur */
10280 if (attribute_flag[0] != 0)
10282 flags=ParseGeometry(argument_list[0].string_reference,
10284 if ((flags & SigmaValue) == 0)
10285 geometry_info.sigma=1.0;
10286 if ((flags & PercentValue) != 0)
10287 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10289 if (attribute_flag[1] != 0)
10290 geometry_info.rho=argument_list[1].real_reference;
10291 if (attribute_flag[2] != 0)
10292 geometry_info.sigma=argument_list[2].real_reference;
10293 if (attribute_flag[3] != 0)
10294 geometry_info.xi=argument_list[3].long_reference;;
10295 if (attribute_flag[4] != 0)
10296 channel=(ChannelType) argument_list[4].long_reference;
10297 image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10298 geometry_info.sigma,geometry_info.xi,exception);
10301 case 122: /* HaldClut */
10303 if (attribute_flag[0] == 0)
10305 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10307 goto PerlException;
10309 if (attribute_flag[1] != 0)
10310 channel=(ChannelType) argument_list[1].long_reference;
10311 (void) HaldClutImageChannel(image,channel,
10312 argument_list[0].image_reference);
10315 case 123: /* BlueShift */
10317 if (attribute_flag[0] != 0)
10318 (void) ParseGeometry(argument_list[0].string_reference,
10320 image=BlueShiftImage(image,geometry_info.rho,exception);
10323 case 124: /* ForwardFourierTransformImage */
10325 image=ForwardFourierTransformImage(image,
10326 argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse,
10330 case 125: /* InverseFourierTransformImage */
10332 image=InverseFourierTransformImage(image,image->next,
10333 argument_list[0].long_reference != 0 ? MagickTrue : MagickFalse,
10337 case 126: /* ColorDecisionList */
10339 if (attribute_flag[0] == 0)
10340 argument_list[0].string_reference=(char *) NULL;
10341 (void) ColorDecisionListImage(image,
10342 argument_list[0].string_reference);
10345 case 127: /* AutoGamma */
10347 if (attribute_flag[0] != 0)
10348 channel=(ChannelType) argument_list[0].long_reference;
10349 (void) AutoGammaImageChannel(image,channel);
10352 case 128: /* AutoLevel */
10354 if (attribute_flag[0] != 0)
10355 channel=(ChannelType) argument_list[0].long_reference;
10356 (void) AutoLevelImageChannel(image,channel);
10359 case 129: /* LevelColors */
10365 (void) QueryMagickColor("#000000",&black_point,exception);
10366 (void) QueryMagickColor("#ffffff",&black_point,exception);
10367 if (attribute_flag[1] != 0)
10368 (void) QueryMagickColor(argument_list[1].string_reference,
10369 &black_point,exception);
10370 if (attribute_flag[2] != 0)
10371 (void) QueryMagickColor(argument_list[2].string_reference,
10372 &white_point,exception);
10373 if (attribute_flag[3] != 0)
10374 channel=(ChannelType) argument_list[3].long_reference;
10375 (void) LevelColorsImageChannel(image,channel,&black_point,
10376 &white_point,argument_list[0].long_reference != 0 ? MagickTrue :
10380 case 130: /* Clamp */
10382 if (attribute_flag[0] != 0)
10383 channel=(ChannelType) argument_list[0].long_reference;
10384 (void) ClampImageChannel(image,channel);
10387 case 131: /* Filter */
10392 if (attribute_flag[0] == 0)
10394 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10395 if (kernel == (KernelInfo *) NULL)
10397 if (attribute_flag[1] != 0)
10398 channel=(ChannelType) argument_list[1].long_reference;
10399 if (attribute_flag[2] != 0)
10400 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10402 image=FilterImageChannel(image,channel,kernel,exception);
10403 kernel=DestroyKernelInfo(kernel);
10406 case 132: /* BrightnessContrast */
10414 if (attribute_flag[0] != 0)
10416 flags=ParseGeometry(argument_list[0].string_reference,
10418 brightness=geometry_info.rho;
10419 if ((flags & SigmaValue) == 0)
10420 contrast=geometry_info.sigma;
10422 if (attribute_flag[1] != 0)
10423 brightness=argument_list[1].real_reference;
10424 if (attribute_flag[2] != 0)
10425 contrast=argument_list[2].real_reference;
10426 if (attribute_flag[4] != 0)
10427 channel=(ChannelType) argument_list[4].long_reference;
10428 (void) BrightnessContrastImageChannel(image,channel,brightness,
10432 case 133: /* Morphology */
10443 if (attribute_flag[0] == 0)
10445 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10446 if (kernel == (KernelInfo *) NULL)
10448 if (attribute_flag[1] != 0)
10449 channel=(ChannelType) argument_list[1].long_reference;
10450 method=UndefinedMorphology;
10451 if (attribute_flag[2] != 0)
10452 method=argument_list[2].long_reference;
10454 if (attribute_flag[3] != 0)
10455 iterations=argument_list[4].long_reference;
10456 image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10458 kernel=DestroyKernelInfo(kernel);
10461 case 108: /* Recolor */
10462 case 134: /* ColorMatrix */
10476 if (attribute_flag[0] == 0)
10478 av=(AV *) argument_list[0].array_reference;
10479 order=(unsigned long) sqrt(av_len(av)+1);
10480 color_matrix=(double *) AcquireQuantumMemory(order,order*
10481 sizeof(*color_matrix));
10482 if (color_matrix == (double *) NULL)
10484 ThrowPerlException(exception,ResourceLimitFatalError,
10485 "MemoryAllocationFailed",PackageName);
10486 goto PerlException;
10488 for (j=0; (j < (long) (order*order)) && (j < (av_len(av)+1)); j++)
10489 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10490 for ( ; j < (long) (order*order); j++)
10491 color_matrix[j]=0.0;
10492 kernel_info=AcquireKernelInfo((const char *) NULL);
10493 kernel_info->width=order;
10494 kernel_info->height=order;
10495 kernel_info->values=color_matrix;
10496 image=ColorMatrixImage(image,kernel_info,exception);
10497 kernel_info->values=(double *) NULL;
10498 kernel_info=DestroyKernelInfo(kernel_info);
10499 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10503 if (next != (Image *) NULL)
10504 (void) CatchImageException(next);
10505 if (region_image != (Image *) NULL)
10510 status=CompositeImage(region_image,CopyCompositeOp,image,
10511 region_info.x,region_info.y);
10512 (void) CatchImageException(region_image);
10513 image=DestroyImage(image);
10514 image=region_image;
10516 if (image != (Image *) NULL)
10519 if (next && (next != image))
10521 image->next=next->next;
10522 DeleteImageFromRegistry(*pv,next);
10524 sv_setiv(*pv,(IV) image);
10532 if (reference_vector)
10533 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10534 InheritPerlException(exception,perl_exception);
10535 exception=DestroyExceptionInfo(exception);
10536 sv_setiv(perl_exception,(IV) number_images);
10537 SvPOK_on(perl_exception);
10538 ST(0)=sv_2mortal(perl_exception);
10543 ###############################################################################
10551 ###############################################################################
10556 Image::Magick ref=NO_INIT
10601 exception=AcquireExceptionInfo();
10602 perl_exception=newSVpv("",0);
10604 if (sv_isobject(ST(0)) == 0)
10606 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10608 goto PerlException;
10610 reference=SvRV(ST(0));
10611 hv=SvSTASH(reference);
10613 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10615 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10616 if (image == (Image *) NULL)
10618 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10620 goto PerlException;
10625 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10626 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10627 (void) QueryMagickColor("none",&transparent_color,exception);
10628 for (i=2; i < items; i+=2)
10630 attribute=(char *) SvPV(ST(i-1),na);
10631 switch (*attribute)
10636 if (LocaleCompare(attribute,"background") == 0)
10638 (void) QueryColorDatabase(SvPV(ST(i),na),
10639 &montage_info->background_color,exception);
10640 for (next=image; next; next=next->next)
10641 next->background_color=montage_info->background_color;
10644 if (LocaleCompare(attribute,"border") == 0)
10646 montage_info->border_width=SvIV(ST(i));
10649 if (LocaleCompare(attribute,"bordercolor") == 0)
10651 (void) QueryColorDatabase(SvPV(ST(i),na),
10652 &montage_info->border_color,exception);
10653 for (next=image; next; next=next->next)
10654 next->border_color=montage_info->border_color;
10657 if (LocaleCompare(attribute,"borderwidth") == 0)
10659 montage_info->border_width=SvIV(ST(i));
10662 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10669 if (LocaleCompare(attribute,"compose") == 0)
10671 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
10672 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10675 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10679 for (next=image; next; next=next->next)
10680 next->compose=(CompositeOperator) sp;
10683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10690 if (LocaleCompare(attribute,"fill") == 0)
10692 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10696 if (LocaleCompare(attribute,"font") == 0)
10698 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10701 if (LocaleCompare(attribute,"frame") == 0)
10707 if (IsGeometry(p) == MagickFalse)
10709 ThrowPerlException(exception,OptionError,"MissingGeometry",
10713 (void) CloneString(&montage_info->frame,p);
10715 montage_info->frame=(char *) NULL;
10718 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10725 if (LocaleCompare(attribute,"geometry") == 0)
10731 if (IsGeometry(p) == MagickFalse)
10733 ThrowPerlException(exception,OptionError,"MissingGeometry",
10737 (void) CloneString(&montage_info->geometry,p);
10739 montage_info->geometry=(char *) NULL;
10742 if (LocaleCompare(attribute,"gravity") == 0)
10747 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
10748 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10751 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10755 montage_info->gravity=(GravityType) in;
10756 for (next=image; next; next=next->next)
10757 next->gravity=(GravityType) in;
10760 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10767 if (LocaleCompare(attribute,"label") == 0)
10769 for (next=image; next; next=next->next)
10770 (void) SetImageProperty(next,"label",InterpretImageProperties(
10771 info ? info->image_info : (ImageInfo *) NULL,next,
10775 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10782 if (LocaleCompare(attribute,"mattecolor") == 0)
10784 (void) QueryColorDatabase(SvPV(ST(i),na),
10785 &montage_info->matte_color,exception);
10786 for (next=image; next; next=next->next)
10787 next->matte_color=montage_info->matte_color;
10790 if (LocaleCompare(attribute,"mode") == 0)
10795 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10796 ParseMagickOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10801 ThrowPerlException(exception,OptionError,
10802 "UnrecognizedModeType",SvPV(ST(i),na));
10807 (void) CloneString(&montage_info->frame,"15x15+3+3");
10808 montage_info->shadow=MagickTrue;
10813 montage_info->frame=(char *) NULL;
10814 montage_info->shadow=MagickFalse;
10815 montage_info->border_width=0;
10818 case ConcatenateMode:
10820 montage_info->frame=(char *) NULL;
10821 montage_info->shadow=MagickFalse;
10822 (void) CloneString(&montage_info->geometry,"+0+0");
10823 montage_info->border_width=0;
10828 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10835 if (LocaleCompare(attribute,"pointsize") == 0)
10837 montage_info->pointsize=SvIV(ST(i));
10840 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10847 if (LocaleCompare(attribute,"shadow") == 0)
10849 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
10850 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
10853 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10857 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
10860 if (LocaleCompare(attribute,"stroke") == 0)
10862 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
10866 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10873 if (LocaleCompare(attribute,"texture") == 0)
10875 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
10878 if (LocaleCompare(attribute,"tile") == 0)
10880 char *p=SvPV(ST(i),na);
10881 if (IsGeometry(p) == MagickFalse)
10883 ThrowPerlException(exception,OptionError,"MissingGeometry",
10887 (void) CloneString(&montage_info->tile,p);
10889 montage_info->tile=(char *) NULL;
10892 if (LocaleCompare(attribute,"title") == 0)
10894 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
10897 if (LocaleCompare(attribute,"transparent") == 0)
10902 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
10903 for (next=image; next; next=next->next)
10904 (void) TransparentPaintImage(next,&transparent_color,
10905 TransparentOpacity,MagickFalse);
10908 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10914 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10920 image=MontageImageList(info->image_info,montage_info,image,exception);
10921 montage_info=DestroyMontageInfo(montage_info);
10922 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
10923 goto PerlException;
10924 if (transparent_color.opacity != TransparentOpacity)
10925 for (next=image; next; next=next->next)
10926 (void) TransparentPaintImage(next,&transparent_color,
10927 TransparentOpacity,MagickFalse);
10928 for ( ; image; image=image->next)
10930 AddImageToRegistry(image);
10932 av_push(av,sv_bless(rv,hv));
10935 exception=DestroyExceptionInfo(exception);
10936 ST(0)=av_reference;
10937 SvREFCNT_dec(perl_exception);
10941 InheritPerlException(exception,perl_exception);
10942 exception=DestroyExceptionInfo(exception);
10943 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
10944 SvPOK_on(perl_exception);
10945 ST(0)=sv_2mortal(perl_exception);
10950 ###############################################################################
10958 ###############################################################################
10963 Image::Magick ref=NO_INIT
11001 exception=AcquireExceptionInfo();
11002 perl_exception=newSVpv("",0);
11005 if (sv_isobject(ST(0)) == 0)
11007 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11009 goto PerlException;
11011 reference=SvRV(ST(0));
11012 hv=SvSTASH(reference);
11014 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11016 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11017 if (image == (Image *) NULL)
11019 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11021 goto PerlException;
11023 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11028 for (i=2; i < items; i+=2)
11030 attribute=(char *) SvPV(ST(i-1),na);
11031 switch (*attribute)
11036 if (LocaleCompare(attribute,"frames") == 0)
11038 number_frames=SvIV(ST(i));
11041 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11047 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11053 image=MorphImages(image,number_frames,exception);
11054 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11055 goto PerlException;
11056 for ( ; image; image=image->next)
11058 AddImageToRegistry(image);
11060 av_push(av,sv_bless(rv,hv));
11063 exception=DestroyExceptionInfo(exception);
11064 ST(0)=av_reference;
11065 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11069 InheritPerlException(exception,perl_exception);
11070 exception=DestroyExceptionInfo(exception);
11071 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11072 SvPOK_on(perl_exception);
11073 ST(0)=sv_2mortal(perl_exception);
11078 ###############################################################################
11086 ###############################################################################
11091 Image::Magick ref=NO_INIT
11119 exception=AcquireExceptionInfo();
11120 perl_exception=newSVpv("",0);
11121 if (sv_isobject(ST(0)) == 0)
11123 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11125 goto PerlException;
11127 reference=SvRV(ST(0));
11128 hv=SvSTASH(reference);
11129 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11130 if (image == (Image *) NULL)
11132 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11134 goto PerlException;
11136 image=MergeImageLayers(image,MosaicLayer,exception);
11138 Create blessed Perl array for the returned image.
11141 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11143 AddImageToRegistry(image);
11145 av_push(av,sv_bless(rv,hv));
11147 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11148 (void) CopyMagickString(image->filename,info->image_info->filename,
11150 SetImageInfo(info->image_info,0,&image->exception);
11151 exception=DestroyExceptionInfo(exception);
11152 SvREFCNT_dec(perl_exception);
11156 InheritPerlException(exception,perl_exception);
11157 exception=DestroyExceptionInfo(exception);
11158 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11159 SvPOK_on(perl_exception); /* return messages in string context */
11160 ST(0)=sv_2mortal(perl_exception);
11165 ###############################################################################
11173 ###############################################################################
11178 Image::Magick ref=NO_INIT
11231 exception=AcquireExceptionInfo();
11232 perl_exception=newSVpv("",0);
11233 package_info=(struct PackageInfo *) NULL;
11234 ac=(items < 2) ? 1 : items-1;
11235 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11237 length=(STRLEN *) NULL;
11238 if (list == (char **) NULL)
11240 ThrowPerlException(exception,ResourceLimitError,
11241 "MemoryAllocationFailed",PackageName);
11242 goto PerlException;
11245 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11246 if (length == (STRLEN *) NULL)
11248 ThrowPerlException(exception,ResourceLimitError,
11249 "MemoryAllocationFailed",PackageName);
11250 goto PerlException;
11252 if (sv_isobject(ST(0)) == 0)
11254 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11256 goto PerlException;
11258 reference=SvRV(ST(0));
11259 hv=SvSTASH(reference);
11260 if (SvTYPE(reference) != SVt_PVAV)
11262 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11264 goto PerlException;
11266 av=(AV *) reference;
11267 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11269 package_info=ClonePackageInfo(info,exception);
11272 *list=(char *) (*package_info->image_info->filename ?
11273 package_info->image_info->filename : "XC:black");
11275 for (n=0, i=0; i < ac; i++)
11277 list[n]=(char *) SvPV(ST(i+1),length[n]);
11278 if ((items >= 3) && strEQcase(list[n],"blob"))
11284 blob=(void *) (SvPV(ST(i+1),length[n]));
11285 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11287 if ((items >= 3) && strEQcase(list[n],"filename"))
11289 if ((items >= 3) && strEQcase(list[n],"file"))
11298 io_info=IoIFP(sv_2io(ST(i+1)));
11299 if (io_info == (PerlIO *) NULL)
11301 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11305 file=PerlIO_findFILE(io_info);
11306 if (file == (FILE *) NULL)
11308 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11312 SetImageInfoFile(package_info->image_info,file);
11314 if ((items >= 3) && strEQcase(list[n],"magick"))
11318 list[n]=(char *) NULL;
11320 status=ExpandFilenames(&n,&list);
11321 if (status == MagickFalse)
11323 ThrowPerlException(exception,ResourceLimitError,
11324 "MemoryAllocationFailed",PackageName);
11325 goto PerlException;
11328 for (i=0; i < n; i++)
11330 (void) CopyMagickString(package_info->image_info->filename,list[i],
11332 image=PingImage(package_info->image_info,exception);
11333 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11335 if ((package_info->image_info->file != (FILE *) NULL) ||
11336 (package_info->image_info->blob != (void *) NULL))
11337 DisassociateImageStream(image);
11338 count+=GetImageListLength(image);
11339 EXTEND(sp,4*count);
11340 for (next=image; next; next=next->next)
11342 PUSHs(sv_2mortal(newSViv(next->columns)));
11343 PUSHs(sv_2mortal(newSViv(next->rows)));
11344 PUSHs(sv_2mortal(newSViv((unsigned long) GetBlobSize(next))));
11345 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11347 image=DestroyImageList(image);
11352 for (i=0; i < n; i++)
11353 if (list[i] != (char *) NULL)
11354 for (p=keep; list[i] != *p++; )
11357 list[i]=(char *) RelinquishMagickMemory(list[i]);
11362 if (package_info != (struct PackageInfo *) NULL)
11363 DestroyPackageInfo(package_info);
11364 if (list && (list != keep))
11365 list=(char **) RelinquishMagickMemory(list);
11367 keep=(char **) RelinquishMagickMemory(keep);
11369 length=(STRLEN *) RelinquishMagickMemory(length);
11370 InheritPerlException(exception,perl_exception);
11371 exception=DestroyExceptionInfo(exception);
11372 SvREFCNT_dec(perl_exception); /* throw away all errors */
11376 ###############################################################################
11384 ###############################################################################
11389 Image::Magick ref=NO_INIT
11422 exception=AcquireExceptionInfo();
11423 perl_exception=newSVpv("",0);
11425 if (sv_isobject(ST(0)) == 0)
11427 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11429 goto PerlException;
11431 reference=SvRV(ST(0));
11432 hv=SvSTASH(reference);
11434 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11436 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11437 if (image == (Image *) NULL)
11439 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11441 goto PerlException;
11443 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11444 preview_type=GammaPreview;
11446 preview_type=(PreviewType)
11447 ParseMagickOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11448 for ( ; image; image=image->next)
11450 preview_image=PreviewImage(image,preview_type,exception);
11451 if (preview_image == (Image *) NULL)
11452 goto PerlException;
11453 AddImageToRegistry(preview_image);
11455 av_push(av,sv_bless(rv,hv));
11458 exception=DestroyExceptionInfo(exception);
11459 ST(0)=av_reference;
11460 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11464 InheritPerlException(exception,perl_exception);
11465 exception=DestroyExceptionInfo(exception);
11466 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11467 SvPOK_on(perl_exception);
11468 ST(0)=sv_2mortal(perl_exception);
11473 ###############################################################################
11477 # Q u e r y C o l o r #
11481 ###############################################################################
11485 QueryColor(ref,...)
11486 Image::Magick ref=NO_INIT
11506 exception=AcquireExceptionInfo();
11507 perl_exception=newSVpv("",0);
11516 colorlist=GetColorInfoList("*",&colors,exception);
11518 for (i=0; i < (long) colors; i++)
11520 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11522 colorlist=(const ColorInfo **)
11523 RelinquishMagickMemory((ColorInfo **) colorlist);
11524 goto PerlException;
11526 EXTEND(sp,5*items);
11527 for (i=1; i < items; i++)
11529 name=(char *) SvPV(ST(i),na);
11530 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11535 PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.red+0.5))));
11536 PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.green+0.5))));
11537 PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.blue+0.5))));
11538 if (color.matte != MagickFalse)
11539 PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.opacity+0.5))));
11540 if (color.colorspace == CMYKColorspace)
11541 PUSHs(sv_2mortal(newSViv((unsigned long) floor(color.index+0.5))));
11545 InheritPerlException(exception,perl_exception);
11546 exception=DestroyExceptionInfo(exception);
11547 SvREFCNT_dec(perl_exception);
11551 ###############################################################################
11555 # Q u e r y C o l o r N a m e #
11559 ###############################################################################
11563 QueryColorname(ref,...)
11564 Image::Magick ref=NO_INIT
11573 message[MaxTextExtent];
11592 *reference; /* reference is the SV* of ref=SvIV(reference) */
11594 exception=AcquireExceptionInfo();
11595 perl_exception=newSVpv("",0);
11596 reference=SvRV(ST(0));
11597 av=(AV *) reference;
11598 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11600 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11601 if (image == (Image *) NULL)
11603 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11605 goto PerlException;
11608 for (i=1; i < items; i++)
11610 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11611 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11613 PUSHs(sv_2mortal(newSVpv(message,0)));
11617 InheritPerlException(exception,perl_exception);
11618 exception=DestroyExceptionInfo(exception);
11619 SvREFCNT_dec(perl_exception);
11623 ###############################################################################
11627 # Q u e r y F o n t #
11631 ###############################################################################
11636 Image::Magick ref=NO_INIT
11643 message[MaxTextExtent];
11654 volatile const TypeInfo
11657 exception=AcquireExceptionInfo();
11658 perl_exception=newSVpv("",0);
11667 typelist=GetTypeInfoList("*",&types,exception);
11669 for (i=0; i < (long) types; i++)
11671 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11673 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11675 goto PerlException;
11677 EXTEND(sp,10*items);
11678 for (i=1; i < items; i++)
11680 name=(char *) SvPV(ST(i),na);
11681 type_info=GetTypeInfo(name,exception);
11682 if (type_info == (TypeInfo *) NULL)
11687 if (type_info->name == (char *) NULL)
11690 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11691 if (type_info->description == (char *) NULL)
11694 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11695 if (type_info->family == (char *) NULL)
11698 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11699 if (type_info->style == UndefinedStyle)
11702 PUSHs(sv_2mortal(newSVpv(MagickOptionToMnemonic(MagickStyleOptions,
11703 type_info->style),0)));
11704 if (type_info->stretch == UndefinedStretch)
11707 PUSHs(sv_2mortal(newSVpv(MagickOptionToMnemonic(MagickStretchOptions,
11708 type_info->stretch),0)));
11709 (void) FormatMagickString(message,MaxTextExtent,"%lu",type_info->weight);
11710 PUSHs(sv_2mortal(newSVpv(message,0)));
11711 if (type_info->encoding == (char *) NULL)
11714 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11715 if (type_info->foundry == (char *) NULL)
11718 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11719 if (type_info->format == (char *) NULL)
11722 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11723 if (type_info->metrics == (char *) NULL)
11726 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11727 if (type_info->glyphs == (char *) NULL)
11730 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11734 InheritPerlException(exception,perl_exception);
11735 exception=DestroyExceptionInfo(exception);
11736 SvREFCNT_dec(perl_exception);
11740 ###############################################################################
11744 # Q u e r y F o n t M e t r i c s #
11748 ###############################################################################
11752 QueryFontMetrics(ref,...)
11753 Image::Magick ref=NO_INIT
11755 queryfontmetrics = 1
11802 *reference; /* reference is the SV* of ref=SvIV(reference) */
11807 exception=AcquireExceptionInfo();
11808 package_info=(struct PackageInfo *) NULL;
11809 perl_exception=newSVpv("",0);
11810 reference=SvRV(ST(0));
11811 av=(AV *) reference;
11812 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11814 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11815 if (image == (Image *) NULL)
11817 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11819 goto PerlException;
11821 package_info=ClonePackageInfo(info,exception);
11822 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
11823 CloneString(&draw_info->text,"");
11824 current=draw_info->affine;
11825 GetAffineMatrix(&affine);
11828 EXTEND(sp,7*items);
11829 for (i=2; i < items; i+=2)
11831 attribute=(char *) SvPV(ST(i-1),na);
11832 switch (*attribute)
11837 if (LocaleCompare(attribute,"antialias") == 0)
11839 type=ParseMagickOption(MagickBooleanOptions,MagickFalse,
11843 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11847 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
11850 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11857 if (LocaleCompare(attribute,"density") == 0)
11859 CloneString(&draw_info->density,SvPV(ST(i),na));
11862 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11869 if (LocaleCompare(attribute,"encoding") == 0)
11871 CloneString(&draw_info->encoding,SvPV(ST(i),na));
11874 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11881 if (LocaleCompare(attribute,"family") == 0)
11883 CloneString(&draw_info->family,SvPV(ST(i),na));
11886 if (LocaleCompare(attribute,"fill") == 0)
11889 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
11890 &image->exception);
11893 if (LocaleCompare(attribute,"font") == 0)
11895 CloneString(&draw_info->font,SvPV(ST(i),na));
11898 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11905 if (LocaleCompare(attribute,"geometry") == 0)
11907 CloneString(&draw_info->geometry,SvPV(ST(i),na));
11910 if (LocaleCompare(attribute,"gravity") == 0)
11912 draw_info->gravity=(GravityType) ParseMagickOption(
11913 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11916 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11923 if (LocaleCompare(attribute,"interline-spacing") == 0)
11925 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11926 draw_info->interline_spacing=geometry_info.rho;
11929 if (LocaleCompare(attribute,"interword-spacing") == 0)
11931 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11932 draw_info->interword_spacing=geometry_info.rho;
11935 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11942 if (LocaleCompare(attribute,"kerning") == 0)
11944 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11945 draw_info->kerning=geometry_info.rho;
11948 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11955 if (LocaleCompare(attribute,"pointsize") == 0)
11957 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11958 draw_info->pointsize=geometry_info.rho;
11961 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11968 if (LocaleCompare(attribute,"rotate") == 0)
11970 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11971 affine.rx=geometry_info.rho;
11972 affine.ry=geometry_info.sigma;
11973 if ((flags & SigmaValue) == 0)
11974 affine.ry=affine.rx;
11977 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11984 if (LocaleCompare(attribute,"scale") == 0)
11986 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
11987 affine.sx=geometry_info.rho;
11988 affine.sy=geometry_info.sigma;
11989 if ((flags & SigmaValue) == 0)
11990 affine.sy=affine.sx;
11993 if (LocaleCompare(attribute,"skew") == 0)
11999 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12000 x_angle=geometry_info.rho;
12001 y_angle=geometry_info.sigma;
12002 if ((flags & SigmaValue) == 0)
12004 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12005 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12008 if (LocaleCompare(attribute,"stroke") == 0)
12011 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12012 &image->exception);
12015 if (LocaleCompare(attribute,"style") == 0)
12017 type=ParseMagickOption(MagickStyleOptions,MagickFalse,
12021 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12025 draw_info->style=(StyleType) type;
12028 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12035 if (LocaleCompare(attribute,"text") == 0)
12037 CloneString(&draw_info->text,SvPV(ST(i),na));
12040 if (LocaleCompare(attribute,"translate") == 0)
12042 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12043 affine.tx=geometry_info.rho;
12044 affine.ty=geometry_info.sigma;
12045 if ((flags & SigmaValue) == 0)
12046 affine.ty=affine.tx;
12049 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12056 if (LocaleCompare(attribute,"weight") == 0)
12058 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12059 draw_info->weight=(unsigned long) geometry_info.rho;
12062 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12069 if (LocaleCompare(attribute,"x") == 0)
12071 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12072 x=geometry_info.rho;
12075 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12082 if (LocaleCompare(attribute,"y") == 0)
12084 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12085 y=geometry_info.rho;
12088 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12094 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12100 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12101 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12102 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12103 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12104 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12105 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12106 if (draw_info->geometry == (char *) NULL)
12108 draw_info->geometry=AcquireString((char *) NULL);
12109 (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
12110 "%.15g,%.15g",x,y);
12112 status=GetTypeMetrics(image,draw_info,&metrics);
12113 (void) CatchImageException(image);
12114 if (status == MagickFalse)
12118 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12119 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12120 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12121 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12122 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12123 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12124 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12125 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12126 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12127 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12128 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12129 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12130 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12132 draw_info=DestroyDrawInfo(draw_info);
12135 if (package_info != (struct PackageInfo *) NULL)
12136 DestroyPackageInfo(package_info);
12137 InheritPerlException(exception,perl_exception);
12138 exception=DestroyExceptionInfo(exception);
12139 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12143 ###############################################################################
12147 # 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 #
12151 ###############################################################################
12155 QueryMultilineFontMetrics(ref,...)
12156 Image::Magick ref=NO_INIT
12158 querymultilinefontmetrics = 1
12205 *reference; /* reference is the SV* of ref=SvIV(reference) */
12210 exception=AcquireExceptionInfo();
12211 package_info=(struct PackageInfo *) NULL;
12212 perl_exception=newSVpv("",0);
12213 reference=SvRV(ST(0));
12214 av=(AV *) reference;
12215 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12217 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12218 if (image == (Image *) NULL)
12220 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12222 goto PerlException;
12224 package_info=ClonePackageInfo(info,exception);
12225 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12226 CloneString(&draw_info->text,"");
12227 current=draw_info->affine;
12228 GetAffineMatrix(&affine);
12231 EXTEND(sp,7*items);
12232 for (i=2; i < items; i+=2)
12234 attribute=(char *) SvPV(ST(i-1),na);
12235 switch (*attribute)
12240 if (LocaleCompare(attribute,"antialias") == 0)
12242 type=ParseMagickOption(MagickBooleanOptions,MagickFalse,
12246 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12250 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12253 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12260 if (LocaleCompare(attribute,"density") == 0)
12262 CloneString(&draw_info->density,SvPV(ST(i),na));
12265 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12272 if (LocaleCompare(attribute,"encoding") == 0)
12274 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12277 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12284 if (LocaleCompare(attribute,"family") == 0)
12286 CloneString(&draw_info->family,SvPV(ST(i),na));
12289 if (LocaleCompare(attribute,"fill") == 0)
12292 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12293 &image->exception);
12296 if (LocaleCompare(attribute,"font") == 0)
12298 CloneString(&draw_info->font,SvPV(ST(i),na));
12301 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12308 if (LocaleCompare(attribute,"geometry") == 0)
12310 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12313 if (LocaleCompare(attribute,"gravity") == 0)
12315 draw_info->gravity=(GravityType) ParseMagickOption(
12316 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12319 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12326 if (LocaleCompare(attribute,"pointsize") == 0)
12328 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12329 draw_info->pointsize=geometry_info.rho;
12332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12339 if (LocaleCompare(attribute,"rotate") == 0)
12341 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12342 affine.rx=geometry_info.rho;
12343 affine.ry=geometry_info.sigma;
12344 if ((flags & SigmaValue) == 0)
12345 affine.ry=affine.rx;
12348 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12355 if (LocaleCompare(attribute,"scale") == 0)
12357 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12358 affine.sx=geometry_info.rho;
12359 affine.sy=geometry_info.sigma;
12360 if ((flags & SigmaValue) == 0)
12361 affine.sy=affine.sx;
12364 if (LocaleCompare(attribute,"skew") == 0)
12370 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12371 x_angle=geometry_info.rho;
12372 y_angle=geometry_info.sigma;
12373 if ((flags & SigmaValue) == 0)
12375 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12376 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12379 if (LocaleCompare(attribute,"stroke") == 0)
12382 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12383 &image->exception);
12386 if (LocaleCompare(attribute,"style") == 0)
12388 type=ParseMagickOption(MagickStyleOptions,MagickFalse,
12392 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12396 draw_info->style=(StyleType) type;
12399 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12406 if (LocaleCompare(attribute,"text") == 0)
12408 CloneString(&draw_info->text,SvPV(ST(i),na));
12411 if (LocaleCompare(attribute,"translate") == 0)
12413 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12414 affine.tx=geometry_info.rho;
12415 affine.ty=geometry_info.sigma;
12416 if ((flags & SigmaValue) == 0)
12417 affine.ty=affine.tx;
12420 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12427 if (LocaleCompare(attribute,"weight") == 0)
12429 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12430 draw_info->weight=(unsigned long) geometry_info.rho;
12433 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12440 if (LocaleCompare(attribute,"x") == 0)
12442 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12443 x=geometry_info.rho;
12446 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12453 if (LocaleCompare(attribute,"y") == 0)
12455 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12456 y=geometry_info.rho;
12459 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12465 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12471 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12472 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12473 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12474 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12475 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12476 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12477 if (draw_info->geometry == (char *) NULL)
12479 draw_info->geometry=AcquireString((char *) NULL);
12480 (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
12481 "%.15g,%.15g",x,y);
12483 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12484 (void) CatchImageException(image);
12485 if (status == MagickFalse)
12489 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12490 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12491 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12492 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12493 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12494 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12495 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12496 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12497 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12498 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12499 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12500 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12501 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12503 draw_info=DestroyDrawInfo(draw_info);
12506 if (package_info != (struct PackageInfo *) NULL)
12507 DestroyPackageInfo(package_info);
12508 InheritPerlException(exception,perl_exception);
12509 exception=DestroyExceptionInfo(exception);
12510 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12514 ###############################################################################
12518 # Q u e r y F o r m a t #
12522 ###############################################################################
12526 QueryFormat(ref,...)
12527 Image::Magick ref=NO_INIT
12544 volatile const MagickInfo
12547 exception=AcquireExceptionInfo();
12548 perl_exception=newSVpv("",0);
12552 format[MaxTextExtent];
12560 format_list=GetMagickInfoList("*",&types,exception);
12562 for (i=0; i < (long) types; i++)
12564 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12565 LocaleLower(format);
12566 PUSHs(sv_2mortal(newSVpv(format,0)));
12568 format_list=(const MagickInfo **)
12569 RelinquishMagickMemory((MagickInfo *) format_list);
12570 goto PerlException;
12572 EXTEND(sp,8*items);
12573 for (i=1; i < items; i++)
12575 name=(char *) SvPV(ST(i),na);
12576 magick_info=GetMagickInfo(name,exception);
12577 if (magick_info == (const MagickInfo *) NULL)
12582 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12583 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12584 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12585 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12586 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12587 if (magick_info->description == (char *) NULL)
12590 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12591 if (magick_info->module == (char *) NULL)
12594 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12598 InheritPerlException(exception,perl_exception);
12599 exception=DestroyExceptionInfo(exception);
12600 SvREFCNT_dec(perl_exception);
12604 ###############################################################################
12608 # Q u e r y O p t i o n #
12612 ###############################################################################
12616 QueryOption(ref,...)
12617 Image::Magick ref=NO_INIT
12638 exception=AcquireExceptionInfo();
12639 perl_exception=newSVpv("",0);
12640 EXTEND(sp,8*items);
12641 for (i=1; i < items; i++)
12643 option=ParseMagickOption(MagickListOptions,MagickFalse,(char *)
12645 options=GetMagickOptions((MagickOption) option);
12646 if (options == (char **) NULL)
12650 for (j=0; options[j] != (char *) NULL; j++)
12651 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12652 options=DestroyStringList(options);
12657 InheritPerlException(exception,perl_exception);
12658 exception=DestroyExceptionInfo(exception);
12659 SvREFCNT_dec(perl_exception);
12663 ###############################################################################
12671 ###############################################################################
12676 Image::Magick ref=NO_INIT
12723 *perl_exception, /* Perl variable for storing messages */
12728 exception=AcquireExceptionInfo();
12729 perl_exception=newSVpv("",0);
12730 package_info=(struct PackageInfo *) NULL;
12732 ac=(items < 2) ? 1 : items-1;
12733 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12735 length=(STRLEN *) NULL;
12736 if (list == (char **) NULL)
12738 ThrowPerlException(exception,ResourceLimitError,
12739 "MemoryAllocationFailed",PackageName);
12740 goto PerlException;
12742 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12743 if (length == (STRLEN *) NULL)
12745 ThrowPerlException(exception,ResourceLimitError,
12746 "MemoryAllocationFailed",PackageName);
12747 goto PerlException;
12749 if (sv_isobject(ST(0)) == 0)
12751 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12753 goto PerlException;
12755 reference=SvRV(ST(0));
12756 hv=SvSTASH(reference);
12757 if (SvTYPE(reference) != SVt_PVAV)
12759 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12761 goto PerlException;
12763 av=(AV *) reference;
12764 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12766 package_info=ClonePackageInfo(info,exception);
12769 *list=(char *) (*package_info->image_info->filename ?
12770 package_info->image_info->filename : "XC:black");
12772 for (n=0, i=0; i < ac; i++)
12774 list[n]=(char *) SvPV(ST(i+1),length[n]);
12775 if ((items >= 3) && strEQcase(list[n],"blob"))
12781 blob=(void *) (SvPV(ST(i+1),length[n]));
12782 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12784 if ((items >= 3) && strEQcase(list[n],"filename"))
12786 if ((items >= 3) && strEQcase(list[n],"file"))
12795 io_info=IoIFP(sv_2io(ST(i+1)));
12796 if (io_info == (PerlIO *) NULL)
12798 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12802 file=PerlIO_findFILE(io_info);
12803 if (file == (FILE *) NULL)
12805 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12809 SetImageInfoFile(package_info->image_info,file);
12811 if ((items >= 3) && strEQcase(list[n],"magick"))
12815 list[n]=(char *) NULL;
12817 status=ExpandFilenames(&n,&list);
12818 if (status == MagickFalse)
12820 ThrowPerlException(exception,ResourceLimitError,
12821 "MemoryAllocationFailed",PackageName);
12822 goto PerlException;
12825 for (i=0; i < n; i++)
12827 if ((package_info->image_info->file != (FILE *) NULL) ||
12828 (package_info->image_info->blob != (void *) NULL))
12830 image=ReadImages(package_info->image_info,exception);
12831 if (image != (Image *) NULL)
12832 DisassociateImageStream(image);
12836 (void) CopyMagickString(package_info->image_info->filename,list[i],
12838 image=ReadImages(package_info->image_info,exception);
12840 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
12842 for ( ; image; image=image->next)
12844 AddImageToRegistry(image);
12846 av_push(av,sv_bless(rv,hv));
12854 for (i=0; i < n; i++)
12855 if (list[i] != (char *) NULL)
12856 for (p=keep; list[i] != *p++; )
12857 if (*p == (char *) NULL)
12859 list[i]=(char *) RelinquishMagickMemory(list[i]);
12864 if (package_info != (struct PackageInfo *) NULL)
12865 DestroyPackageInfo(package_info);
12866 if (list && (list != keep))
12867 list=(char **) RelinquishMagickMemory(list);
12869 keep=(char **) RelinquishMagickMemory(keep);
12871 length=(STRLEN *) RelinquishMagickMemory(length);
12872 InheritPerlException(exception,perl_exception);
12873 exception=DestroyExceptionInfo(exception);
12874 sv_setiv(perl_exception,(IV) number_images);
12875 SvPOK_on(perl_exception);
12876 ST(0)=sv_2mortal(perl_exception);
12881 ###############################################################################
12889 ###############################################################################
12894 Image::Magick ref=NO_INIT
12917 exception=AcquireExceptionInfo();
12918 perl_exception=newSVpv("",0);
12919 reference=SvRV(ST(0));
12920 av=(AV *) reference;
12921 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12923 for (i=1; i < items; i++)
12924 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
12925 SvPV(ST(i),na),exception);
12926 InheritPerlException(exception,perl_exception);
12927 exception=DestroyExceptionInfo(exception);
12928 SvREFCNT_dec(perl_exception); /* throw away all errors */
12932 ###############################################################################
12940 ###############################################################################
12945 Image::Magick ref=NO_INIT
12968 *reference; /* reference is the SV* of ref=SvIV(reference) */
12970 exception=AcquireExceptionInfo();
12971 perl_exception=newSVpv("",0);
12972 if (sv_isobject(ST(0)) == 0)
12974 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12976 goto PerlException;
12978 reference=SvRV(ST(0));
12979 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12981 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
12983 for (i=2; i < items; i+=2)
12984 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
12987 InheritPerlException(exception,perl_exception);
12988 exception=DestroyExceptionInfo(exception);
12989 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
12990 SvPOK_on(perl_exception);
12991 ST(0)=sv_2mortal(perl_exception);
12996 ###############################################################################
13000 # S e t P i x e l #
13004 ###############################################################################
13009 Image::Magick ref=NO_INIT
13039 register IndexPacket
13045 register PixelPacket
13053 *reference; /* reference is the SV* of ref=SvIV(reference) */
13055 exception=AcquireExceptionInfo();
13056 perl_exception=newSVpv("",0);
13057 reference=SvRV(ST(0));
13058 av=(AV *) reference;
13059 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13061 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13062 if (image == (Image *) NULL)
13064 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13066 goto PerlException;
13069 channel=DefaultChannels;
13070 normalize=MagickTrue;
13073 region.width=image->columns;
13076 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13077 for (i=2; i < items; i+=2)
13079 attribute=(char *) SvPV(ST(i-1),na);
13080 switch (*attribute)
13085 if (LocaleCompare(attribute,"channel") == 0)
13090 option=ParseChannelOption(SvPV(ST(i),na));
13093 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13097 channel=(ChannelType) option;
13100 if (LocaleCompare(attribute,"color") == 0)
13102 if (SvTYPE(ST(i)) != SVt_RV)
13105 message[MaxTextExtent];
13107 (void) FormatMagickString(message,MaxTextExtent,
13108 "invalid %.60s value",attribute);
13109 ThrowPerlException(exception,OptionError,message,
13112 av=(AV *) SvRV(ST(i));
13115 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13122 if (LocaleCompare(attribute,"geometry") == 0)
13124 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13127 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13134 if (LocaleCompare(attribute,"normalize") == 0)
13136 option=ParseMagickOption(MagickBooleanOptions,MagickFalse,
13140 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13144 normalize=option != 0 ? MagickTrue : MagickFalse;
13147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13154 if (LocaleCompare(attribute,"x") == 0)
13156 region.x=SvIV(ST(i));
13159 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13166 if (LocaleCompare(attribute,"y") == 0)
13168 region.y=SvIV(ST(i));
13171 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13177 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13183 (void) SetImageStorageClass(image,DirectClass);
13184 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13185 if ((q == (PixelPacket *) NULL) || (av == (AV *) NULL))
13196 indexes=GetAuthenticIndexQueue(image);
13198 if (normalize != MagickFalse)
13199 scale=QuantumRange;
13200 if (((channel & RedChannel) != 0) && (i <= av_len(av)))
13202 q->red=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13205 if (((channel & GreenChannel) != 0) && (i <= av_len(av)))
13207 q->green=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13210 if (((channel & BlueChannel) != 0) && (i <= av_len(av)))
13212 q->blue=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13215 if ((((channel & IndexChannel) != 0) &&
13216 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13218 *indexes=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13221 if (((channel & OpacityChannel) != 0) && (i <= av_len(av)))
13223 q->opacity=ClampToQuantum(QuantumRange*SvNV(*(av_fetch(av,i,0))));
13226 (void) SyncAuthenticPixels(image,exception);
13230 InheritPerlException(exception,perl_exception);
13231 exception=DestroyExceptionInfo(exception);
13232 SvREFCNT_dec(perl_exception);
13236 ###############################################################################
13240 # S t a t i s t i c s #
13244 ###############################################################################
13248 Statistics(ref,...)
13249 Image::Magick ref=NO_INIT
13251 StatisticsImage = 1
13253 statisticsimage = 3
13256 #define ChannelStatistics(channel) \
13258 (void) FormatMagickString(message,MaxTextExtent,"%lu", \
13259 channel_statistics[channel].depth); \
13260 PUSHs(sv_2mortal(newSVpv(message,0))); \
13261 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13262 channel_statistics[channel].minima/scale); \
13263 PUSHs(sv_2mortal(newSVpv(message,0))); \
13264 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13265 channel_statistics[channel].maxima/scale); \
13266 PUSHs(sv_2mortal(newSVpv(message,0))); \
13267 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13268 channel_statistics[channel].mean/scale); \
13269 PUSHs(sv_2mortal(newSVpv(message,0))); \
13270 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13271 channel_statistics[channel].standard_deviation/scale); \
13272 PUSHs(sv_2mortal(newSVpv(message,0))); \
13273 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13274 channel_statistics[channel].kurtosis); \
13275 PUSHs(sv_2mortal(newSVpv(message,0))); \
13276 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13277 channel_statistics[channel].skewness); \
13278 PUSHs(sv_2mortal(newSVpv(message,0))); \
13285 message[MaxTextExtent];
13288 *channel_statistics;
13313 exception=AcquireExceptionInfo();
13314 perl_exception=newSVpv("",0);
13316 if (sv_isobject(ST(0)) == 0)
13318 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13320 goto PerlException;
13322 reference=SvRV(ST(0));
13323 hv=SvSTASH(reference);
13325 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13327 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13328 if (image == (Image *) NULL)
13330 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13332 goto PerlException;
13334 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13336 for ( ; image; image=image->next)
13338 channel_statistics=GetImageChannelStatistics(image,&image->exception);
13339 if (channel_statistics == (ChannelStatistics *) NULL)
13342 EXTEND(sp,35*count);
13343 scale=(double) QuantumRange;
13344 ChannelStatistics(RedChannel);
13345 ChannelStatistics(GreenChannel);
13346 ChannelStatistics(BlueChannel);
13347 if (image->colorspace == CMYKColorspace)
13348 ChannelStatistics(IndexChannel);
13349 if (image->matte != MagickFalse)
13350 ChannelStatistics(OpacityChannel);
13351 channel_statistics=(ChannelStatistics *)
13352 RelinquishMagickMemory(channel_statistics);
13356 InheritPerlException(exception,perl_exception);
13357 exception=DestroyExceptionInfo(exception);
13358 SvREFCNT_dec(perl_exception);
13362 ###############################################################################
13366 # S y n c A u t h e n t i c P i x e l s #
13370 ###############################################################################
13374 SyncAuthenticPixels(ref,...)
13375 Image::Magick ref = NO_INIT
13377 Syncauthenticpixels = 1
13378 SyncImagePixels = 2
13379 syncimagepixels = 3
13398 exception=AcquireExceptionInfo();
13399 perl_exception=newSVpv("",0);
13401 if (sv_isobject(ST(0)) == 0)
13403 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13405 goto PerlException;
13408 reference=SvRV(ST(0));
13409 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13410 if (image == (Image *) NULL)
13412 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13414 goto PerlException;
13417 status=SyncAuthenticPixels(image,exception);
13418 if (status != MagickFalse)
13420 InheritException(exception,&image->exception);
13423 InheritPerlException(exception,perl_exception);
13424 exception=DestroyExceptionInfo(exception);
13425 SvREFCNT_dec(perl_exception); /* throw away all errors */
13429 ###############################################################################
13433 # T r a n s f o r m #
13437 ###############################################################################
13442 Image::Magick ref=NO_INIT
13480 exception=AcquireExceptionInfo();
13481 perl_exception=newSVpv("",0);
13484 if (sv_isobject(ST(0)) == 0)
13486 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13488 goto PerlException;
13490 reference=SvRV(ST(0));
13491 hv=SvSTASH(reference);
13493 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13495 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13496 if (image == (Image *) NULL)
13498 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13500 goto PerlException;
13502 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13506 crop_geometry=(char *) NULL;
13507 geometry=(char *) NULL;
13508 for (i=2; i < items; i+=2)
13510 attribute=(char *) SvPV(ST(i-1),na);
13511 switch (*attribute)
13516 if (LocaleCompare(attribute,"crop") == 0)
13518 crop_geometry=SvPV(ST(i),na);
13521 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13528 if (LocaleCompare(attribute,"geometry") == 0)
13530 geometry=SvPV(ST(i),na);
13533 if (LocaleCompare(attribute,"gravity") == 0)
13541 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseMagickOption(
13542 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13545 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13549 for (next=image; next; next=next->next)
13550 next->gravity=(GravityType) in;
13553 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13565 for ( ; image; image=image->next)
13567 clone=CloneImage(image,0,0,MagickTrue,exception);
13568 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13569 goto PerlException;
13570 TransformImage(&clone,crop_geometry,geometry);
13571 for ( ; clone; clone=clone->next)
13573 AddImageToRegistry(clone);
13575 av_push(av,sv_bless(rv,hv));
13579 exception=DestroyExceptionInfo(exception);
13580 ST(0)=av_reference;
13581 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13585 InheritPerlException(exception,perl_exception);
13586 exception=DestroyExceptionInfo(exception);
13587 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13588 SvPOK_on(perl_exception);
13589 ST(0)=sv_2mortal(perl_exception);
13594 ###############################################################################
13602 ###############################################################################
13607 Image::Magick ref=NO_INIT
13615 filename[MaxTextExtent];
13639 exception=AcquireExceptionInfo();
13640 perl_exception=newSVpv("",0);
13642 package_info=(struct PackageInfo *) NULL;
13643 if (sv_isobject(ST(0)) == 0)
13645 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13647 goto PerlException;
13649 reference=SvRV(ST(0));
13650 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13651 if (image == (Image *) NULL)
13653 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13655 goto PerlException;
13657 package_info=ClonePackageInfo(info,exception);
13659 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
13662 for (i=2; i < items; i+=2)
13663 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
13665 (void) CopyMagickString(filename,package_info->image_info->filename,
13668 for (next=image; next; next=next->next)
13670 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
13671 next->scene=scene++;
13673 SetImageInfo(package_info->image_info,(unsigned int)
13674 GetImageListLength(image),&image->exception);
13675 for (next=image; next; next=next->next)
13677 (void) WriteImage(package_info->image_info,next);
13678 if (next->exception.severity >= ErrorException)
13679 InheritException(exception,&next->exception);
13680 GetImageException(next,exception);
13682 if (package_info->image_info->adjoin)
13687 if (package_info != (struct PackageInfo *) NULL)
13688 DestroyPackageInfo(package_info);
13689 InheritPerlException(exception,perl_exception);
13690 exception=DestroyExceptionInfo(exception);
13691 sv_setiv(perl_exception,(IV) number_images);
13692 SvPOK_on(perl_exception);
13693 ST(0)=sv_2mortal(perl_exception);