2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
55 #if defined(__cplusplus) || defined(c_plusplus)
59 #define PERL_NO_GET_CONTEXT
64 #include <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 33
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(sv,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", { {"geometry", StringReference},
245 {"width", IntegerReference},{"height", IntegerReference},
246 {"channel", MagickChannelOptions} } },
248 { "OilPaint", { {"radius", RealReference} } },
249 { "ReduceNoise", { {"geometry", StringReference},
250 {"width", IntegerReference},{"height", IntegerReference},
251 {"channel", MagickChannelOptions} } },
252 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
253 {"y", IntegerReference} } },
254 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
255 {"color", StringReference}, {"background", StringReference} } },
256 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
257 {"height", IntegerReference} } },
258 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
259 {"height", IntegerReference} } },
260 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
261 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
262 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
263 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
264 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
265 {"y", RealReference}, { "fill", StringReference},
266 {"color", StringReference} } },
267 { "Spread", { {"radius", RealReference} } },
268 { "Swirl", { {"degrees", RealReference},
269 {"interpolate", MagickInterpolateOptions} } },
270 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
271 {"height", IntegerReference}, {"filter", MagickFilterOptions},
272 {"support", StringReference }, {"blur", RealReference } } },
273 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
274 {"height", IntegerReference}, {"filter", MagickFilterOptions},
275 {"support", RealReference }, {"blur", RealReference } } },
276 { "Annotate", { {"text", StringReference}, {"font", StringReference},
277 {"pointsize", RealReference}, {"density", StringReference},
278 {"undercolor", StringReference}, {"stroke", StringReference},
279 {"fill", StringReference}, {"geometry", StringReference},
280 {"pen", StringReference}, {"x", RealReference},
281 {"y", RealReference}, {"gravity", MagickGravityOptions},
282 {"translate", StringReference}, {"scale", StringReference},
283 {"rotate", RealReference}, {"skewX", RealReference},
284 {"skewY", RealReference}, {"strokewidth", RealReference},
285 {"antialias", MagickBooleanOptions}, {"family", StringReference},
286 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
287 {"weight", IntegerReference}, {"align", MagickAlignOptions},
288 {"encoding", StringReference}, {"affine", ArrayReference},
289 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
290 {"tile", ImageReference}, {"kerning", RealReference},
291 {"interline-spacing", RealReference},
292 {"interword-spacing", RealReference},
293 {"direction", MagickDirectionOptions} } },
294 { "ColorFloodfill", { {"geometry", StringReference},
295 {"x", IntegerReference}, {"y", IntegerReference},
296 {"fill", StringReference}, {"bordercolor", StringReference},
297 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
298 { "Composite", { {"image", ImageReference},
299 {"compose", MagickComposeOptions}, {"geometry", StringReference},
300 {"x", IntegerReference}, {"y", IntegerReference},
301 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
302 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
303 {"color", StringReference}, {"mask", ImageReference},
304 {"channel", MagickChannelOptions},
305 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
306 {"blend", StringReference} } },
307 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
308 { "CycleColormap", { {"display", IntegerReference} } },
309 { "Draw", { {"primitive", MagickPrimitiveOptions},
310 {"points", StringReference}, {"method", MagickMethodOptions},
311 {"stroke", StringReference}, {"fill", StringReference},
312 {"strokewidth", RealReference}, {"font", StringReference},
313 {"bordercolor", StringReference}, {"x", RealReference},
314 {"y", RealReference}, {"translate", StringReference},
315 {"scale", StringReference}, {"rotate", RealReference},
316 {"skewX", RealReference}, {"skewY", RealReference},
317 {"tile", ImageReference}, {"pointsize", RealReference},
318 {"antialias", MagickBooleanOptions}, {"density", StringReference},
319 {"linewidth", RealReference}, {"affine", ArrayReference},
320 {"stroke-dashoffset", RealReference},
321 {"stroke-dasharray", ArrayReference},
322 {"interpolate", MagickInterpolateOptions},
323 {"origin", StringReference}, {"text", StringReference},
324 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
325 {"vector-graphics", StringReference}, {"kerning", RealReference},
326 {"interline-spacing", RealReference},
327 {"interword-spacing", RealReference},
328 {"direction", MagickDirectionOptions} } },
329 { "Equalize", { {"channel", MagickChannelOptions} } },
330 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
331 {"red", RealReference}, {"green", RealReference},
332 {"blue", RealReference} } },
333 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
334 {"dither-method", MagickDitherOptions} } },
335 { "MatteFloodfill", { {"geometry", StringReference},
336 {"x", IntegerReference}, {"y", IntegerReference},
337 {"opacity", StringReference}, {"bordercolor", StringReference},
338 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
339 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
340 {"saturation", RealReference}, {"whiteness", RealReference},
341 {"brightness", RealReference}, {"lightness", RealReference},
342 {"blackness", RealReference} } },
343 { "Negate", { {"gray", MagickBooleanOptions},
344 {"channel", MagickChannelOptions} } },
345 { "Normalize", { {"channel", MagickChannelOptions} } },
347 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
348 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
349 {"invert", MagickBooleanOptions} } },
350 { "Quantize", { {"colors", IntegerReference},
351 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
352 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
353 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
354 {"dither-method", MagickDitherOptions} } },
355 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
356 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
357 { "Segment", { {"geometry", StringReference},
358 {"cluster-threshold", RealReference},
359 {"smoothing-threshold", RealReference},
360 {"colorspace", MagickColorspaceOptions},
361 {"verbose", MagickBooleanOptions} } },
363 { "Solarize", { {"geometry", StringReference},
364 {"threshold", StringReference} } },
366 { "Texture", { {"texture", ImageReference} } },
367 { "Evaluate", { {"value", RealReference},
368 {"operator", MagickEvaluateOptions},
369 {"channel", MagickChannelOptions} } },
370 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
371 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
372 { "Threshold", { {"threshold", StringReference},
373 {"channel", MagickChannelOptions} } },
374 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
375 {"sigma", RealReference} } },
376 { "Trim", { {"fuzz", StringReference} } },
377 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
378 {"wavelength", RealReference},
379 {"interpolate", MagickInterpolateOptions} } },
380 { "Separate", { {"channel", MagickChannelOptions} } },
382 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
383 {"y", IntegerReference} } },
384 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
386 { "GaussianBlur", { {"geometry", StringReference},
387 {"radius", RealReference}, {"sigma", RealReference},
388 {"channel", MagickChannelOptions} } },
389 { "Convolve", { {"coefficients", ArrayReference},
390 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
391 { "Profile", { {"name", StringReference}, {"profile", StringReference},
392 { "rendering-intent", MagickIntentOptions},
393 { "black-point-compensation", MagickBooleanOptions} } },
394 { "UnsharpMask", { {"geometry", StringReference},
395 {"radius", RealReference}, {"sigma", RealReference},
396 {"amount", RealReference}, {"threshold", RealReference},
397 {"channel", MagickChannelOptions} } },
398 { "MotionBlur", { {"geometry", StringReference},
399 {"radius", RealReference}, {"sigma", RealReference},
400 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
401 { "OrderedDither", { {"threshold", StringReference},
402 {"channel", MagickChannelOptions} } },
403 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
404 {"height", IntegerReference} } },
405 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
406 {"white-point", RealReference}, {"gamma", RealReference},
407 {"channel", MagickChannelOptions}, {"level", StringReference} } },
408 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
409 { "AffineTransform", { {"affine", ArrayReference},
410 {"translate", StringReference}, {"scale", StringReference},
411 {"rotate", RealReference}, {"skewX", RealReference},
412 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
413 {"background", StringReference} } },
414 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
415 { "AdaptiveThreshold", { {"geometry", StringReference},
416 {"width", IntegerReference}, {"height", IntegerReference},
417 {"offset", IntegerReference} } },
418 { "Resample", { {"density", StringReference}, {"x", RealReference},
419 {"y", RealReference}, {"filter", MagickFilterOptions},
420 {"support", RealReference }, {"blur", RealReference } } },
421 { "Describe", { {"file", FileReference} } },
422 { "BlackThreshold", { {"threshold", StringReference},
423 {"channel", MagickChannelOptions} } },
424 { "WhiteThreshold", { {"threshold", StringReference},
425 {"channel", MagickChannelOptions} } },
426 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
427 {"channel", MagickChannelOptions} } },
428 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference} } },
431 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
440 {"sigma", RealReference}, {"x", IntegerReference},
441 {"y", IntegerReference} } },
442 { "Identify", { {"file", FileReference}, {"features", StringReference},
443 {"unique", MagickBooleanOptions} } },
444 { "SepiaTone", { {"threshold", RealReference} } },
445 { "SigmoidalContrast", { {"geometry", StringReference},
446 {"contrast", RealReference}, {"mid-point", RealReference},
447 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
448 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
449 {"height", IntegerReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"fuzz", StringReference},
451 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
452 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
453 {"sigma", RealReference}, {"x", IntegerReference},
454 {"y", IntegerReference}, {"background", StringReference} } },
455 { "ContrastStretch", { {"levels", StringReference},
456 {"black-point", RealReference},{"white-point", RealReference},
457 {"channel", MagickChannelOptions} } },
460 { "AdaptiveSharpen", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"channel", MagickChannelOptions} } },
466 { "AdaptiveBlur", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"channel", MagickChannelOptions} } },
469 { "Sketch", { {"geometry", StringReference},
470 {"radius", RealReference}, {"sigma", RealReference},
471 {"angle", RealReference} } },
473 { "AdaptiveResize", { {"geometry", StringReference},
474 {"width", IntegerReference}, {"height", IntegerReference},
475 {"filter", MagickFilterOptions}, {"support", StringReference },
476 {"blur", RealReference } } },
477 { "ClipMask", { {"mask", ImageReference} } },
478 { "LinearStretch", { {"levels", StringReference},
479 {"black-point", RealReference},{"white-point", RealReference} } },
480 { "Recolor", { {"matrix", ArrayReference} } },
481 { "Mask", { {"mask", ImageReference} } },
482 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
483 {"font", StringReference}, {"stroke", StringReference},
484 {"fill", StringReference}, {"strokewidth", RealReference},
485 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
486 {"background", StringReference} } },
487 { "FloodfillPaint", { {"geometry", StringReference},
488 {"x", IntegerReference}, {"y", IntegerReference},
489 {"fill", StringReference}, {"bordercolor", StringReference},
490 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
491 {"invert", MagickBooleanOptions} } },
492 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
493 {"virtual-pixel", MagickVirtualPixelOptions},
494 {"best-fit", MagickBooleanOptions} } },
495 { "Clut", { {"image", ImageReference},
496 {"channel", MagickChannelOptions} } },
497 { "LiquidRescale", { {"geometry", StringReference},
498 {"width", IntegerReference}, {"height", IntegerReference},
499 {"delta-x", RealReference}, {"rigidity", RealReference } } },
500 { "Encipher", { {"passphrase", StringReference} } },
501 { "Decipher", { {"passphrase", StringReference} } },
502 { "Deskew", { {"geometry", StringReference},
503 {"threshold", StringReference} } },
504 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
505 {"dither-method", MagickDitherOptions} } },
506 { "SparseColor", { {"points", ArrayReference},
507 {"method", MagickSparseColorOptions},
508 {"virtual-pixel", MagickVirtualPixelOptions},
509 {"channel", MagickChannelOptions} } },
510 { "Function", { {"parameters", ArrayReference},
511 {"function", MagickFunctionOptions},
512 {"virtual-pixel", MagickVirtualPixelOptions} } },
513 { "SelectiveBlur", { {"geometry", StringReference},
514 {"radius", RealReference}, {"sigma", RealReference},
515 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
516 { "HaldClut", { {"image", ImageReference},
517 {"channel", MagickChannelOptions} } },
518 { "BlueShift", { {"factor", StringReference} } },
519 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
521 { "ColorDecisionList", {
522 {"color-correction-collection", StringReference} } },
523 { "AutoGamma", { {"channel", MagickChannelOptions} } },
524 { "AutoLevel", { {"channel", MagickChannelOptions} } },
525 { "LevelColors", { {"invert", MagickBooleanOptions},
526 {"black-point", StringReference}, {"white-point", StringReference},
527 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
528 { "Clamp", { {"channel", MagickChannelOptions} } },
529 { "Filter", { {"kernel", StringReference},
530 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
531 { "BrightnessContrast", { {"levels", StringReference},
532 {"brightness", RealReference},{"contrast", RealReference},
533 {"channel", MagickChannelOptions} } },
534 { "Morphology", { {"kernel", StringReference},
535 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
536 {"iterations", IntegerReference} } },
537 { "ColorMatrix", { {"matrix", ArrayReference} } },
538 { "Color", { {"color", StringReference} } },
539 { "Mode", { {"geometry", StringReference},
540 {"width", IntegerReference},{"height", IntegerReference},
541 {"channel", MagickChannelOptions} } },
542 { "Statistic", { {"geometry", StringReference},
543 {"width", IntegerReference},{"height", IntegerReference},
544 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
548 *magick_registry = (SplayTreeInfo *) NULL;
551 Forward declarations.
554 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
557 strEQcase(const char *,const char *);
560 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 % C l o n e P a c k a g e I n f o %
568 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
570 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
573 % The format of the ClonePackageInfo routine is:
575 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
578 % A description of each parameter follows:
580 % o info: a structure of type info.
582 % o exception: Return any errors or warnings in this structure.
585 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
586 ExceptionInfo *exception)
591 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
592 if (clone_info == (struct PackageInfo *) NULL)
594 ThrowPerlException(exception,ResourceLimitError,
595 "UnableToClonePackageInfo",PackageName);
596 return((struct PackageInfo *) NULL);
598 if (info == (struct PackageInfo *) NULL)
600 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
604 clone_info->image_info=CloneImageInfo(info->image_info);
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 % constant() returns a double value for the specified name.
621 % The format of the constant routine is:
623 % double constant(char *name,ssize_t sans)
625 % A description of each parameter follows:
627 % o value: Method constant returns a double value for the specified name.
629 % o name: The name of the constant.
631 % o sans: This integer value is not used.
634 static double constant(char *name,ssize_t sans)
642 if (strEQ(name,"BlobError"))
644 if (strEQ(name,"BlobWarning"))
650 if (strEQ(name,"CacheError"))
652 if (strEQ(name,"CacheWarning"))
653 return(CacheWarning);
654 if (strEQ(name,"CoderError"))
656 if (strEQ(name,"CoderWarning"))
657 return(CoderWarning);
658 if (strEQ(name,"ConfigureError"))
659 return(ConfigureError);
660 if (strEQ(name,"ConfigureWarning"))
661 return(ConfigureWarning);
662 if (strEQ(name,"CorruptImageError"))
663 return(CorruptImageError);
664 if (strEQ(name,"CorruptImageWarning"))
665 return(CorruptImageWarning);
670 if (strEQ(name,"DelegateError"))
671 return(DelegateError);
672 if (strEQ(name,"DelegateWarning"))
673 return(DelegateWarning);
674 if (strEQ(name,"DrawError"))
676 if (strEQ(name,"DrawWarning"))
682 if (strEQ(name,"ErrorException"))
683 return(ErrorException);
684 if (strEQ(name,"ExceptionError"))
686 if (strEQ(name,"ExceptionWarning"))
687 return(CoderWarning);
692 if (strEQ(name,"FatalErrorException"))
693 return(FatalErrorException);
694 if (strEQ(name,"FileOpenError"))
695 return(FileOpenError);
696 if (strEQ(name,"FileOpenWarning"))
697 return(FileOpenWarning);
702 if (strEQ(name,"ImageError"))
704 if (strEQ(name,"ImageWarning"))
705 return(ImageWarning);
710 if (strEQ(name,"MaxRGB"))
711 return(QuantumRange);
712 if (strEQ(name,"MissingDelegateError"))
713 return(MissingDelegateError);
714 if (strEQ(name,"MissingDelegateWarning"))
715 return(MissingDelegateWarning);
716 if (strEQ(name,"ModuleError"))
718 if (strEQ(name,"ModuleWarning"))
719 return(ModuleWarning);
724 if (strEQ(name,"Opaque"))
725 return(OpaqueOpacity);
726 if (strEQ(name,"OptionError"))
728 if (strEQ(name,"OptionWarning"))
729 return(OptionWarning);
734 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
735 return(MAGICKCORE_QUANTUM_DEPTH);
736 if (strEQ(name,"QuantumDepth"))
737 return(QuantumDepth);
738 if (strEQ(name,"QuantumRange"))
739 return(QuantumRange);
744 if (strEQ(name,"ResourceLimitError"))
745 return(ResourceLimitError);
746 if (strEQ(name,"ResourceLimitWarning"))
747 return(ResourceLimitWarning);
748 if (strEQ(name,"RegistryError"))
749 return(RegistryError);
750 if (strEQ(name,"RegistryWarning"))
751 return(RegistryWarning);
756 if (strEQ(name,"StreamError"))
758 if (strEQ(name,"StreamWarning"))
759 return(StreamWarning);
760 if (strEQ(name,"Success"))
766 if (strEQ(name,"Transparent"))
767 return(TransparentOpacity);
768 if (strEQ(name,"TypeError"))
770 if (strEQ(name,"TypeWarning"))
776 if (strEQ(name,"WarningException"))
777 return(WarningException);
782 if (strEQ(name,"XServerError"))
783 return(XServerError);
784 if (strEQ(name,"XServerWarning"))
785 return(XServerWarning);
794 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798 % D e s t r o y P a c k a g e I n f o %
802 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
804 % Method DestroyPackageInfo frees a previously created info structure.
806 % The format of the DestroyPackageInfo routine is:
808 % DestroyPackageInfo(struct PackageInfo *info)
810 % A description of each parameter follows:
812 % o info: a structure of type info.
815 static void DestroyPackageInfo(struct PackageInfo *info)
817 info->image_info=DestroyImageInfo(info->image_info);
818 info=(struct PackageInfo *) RelinquishMagickMemory(info);
822 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % Method GetList is recursively called by SetupList to traverse the
833 % Image__Magick reference. If building an reference_vector (see SetupList),
834 % *current is the current position in *reference_vector and *last is the final
835 % entry in *reference_vector.
837 % The format of the GetList routine is:
841 % A description of each parameter follows:
843 % o info: a structure of type info.
846 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,ssize_t *current,
847 ssize_t *last,ExceptionInfo *exception)
852 if (reference == (SV *) NULL)
854 switch (SvTYPE(reference))
874 previous=(Image *) NULL;
878 for (i=0; i <= n; i++)
884 if (rv && *rv && sv_isobject(*rv))
886 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
888 if (image == (Image *) NULL)
890 if (image == previous)
892 image=CloneImage(image,0,0,MagickTrue,exception);
893 if (image == (Image *) NULL)
896 image->previous=previous;
897 *(previous ? &previous->next : &head)=image;
898 for (previous=image; previous->next; previous=previous->next) ;
906 Blessed scalar, one image.
908 image=(Image *) SvIV(reference);
909 if (image == (Image *) NULL)
911 image->previous=(Image *) NULL;
912 image->next=(Image *) NULL;
913 if (reference_vector)
915 if (*current == *last)
918 if (*reference_vector == (SV **) NULL)
919 *reference_vector=(SV **) AcquireQuantumMemory(*last,
920 sizeof(*reference_vector));
922 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
923 *last,sizeof(*reference_vector));
925 if (*reference_vector == (SV **) NULL)
927 ThrowPerlException(exception,ResourceLimitError,
928 "MemoryAllocationFailed",PackageName);
929 return((Image *) NULL);
931 (*reference_vector)[*current]=reference;
932 (*reference_vector)[++(*current)]=NULL;
939 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
940 (double) SvTYPE(reference));
941 return((Image *) NULL);
945 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
949 % G e t P a c k a g e I n f o %
953 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
955 % Method GetPackageInfo looks up or creates an info structure for the given
956 % Image__Magick reference. If it does create a new one, the information in
957 % package_info is used to initialize it.
959 % The format of the GetPackageInfo routine is:
961 % struct PackageInfo *GetPackageInfo(void *reference,
962 % struct PackageInfo *package_info,ExceptionInfo *exception)
964 % A description of each parameter follows:
966 % o info: a structure of type info.
968 % o exception: Return any errors or warnings in this structure.
971 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
972 struct PackageInfo *package_info,ExceptionInfo *exception)
975 message[MaxTextExtent];
983 (void) FormatMagickString(message,MaxTextExtent,"%s::package%s%p",
984 PackageName,XS_VERSION,reference);
985 sv=perl_get_sv(message,(TRUE | 0x02));
986 if (sv == (SV *) NULL)
988 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
990 return(package_info);
992 if (SvREFCNT(sv) == 0)
993 (void) SvREFCNT_inc(sv);
994 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
996 clone_info=ClonePackageInfo(package_info,exception);
997 sv_setiv(sv,(IV) clone_info);
1002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 % S e t A t t r i b u t e %
1010 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012 % SetAttribute() sets the attribute to the value in sval. This can change
1013 % either or both of image or info.
1015 % The format of the SetAttribute routine is:
1017 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1018 % SV *sval,ExceptionInfo *exception)
1020 % A description of each parameter follows:
1022 % o list: a list of strings.
1024 % o string: a character string.
1028 static inline double SiPrefixToDouble(const char *string,const double interval)
1037 value=strtod(string,&q);
1039 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1041 switch (tolower((int) ((unsigned char) *q)))
1043 case '%': value*=pow(scale,0)*interval/100.0; break;
1044 case 'k': value*=pow(scale,1); break;
1045 case 'm': value*=pow(scale,2); break;
1046 case 'g': value*=pow(scale,3); break;
1047 case 't': value*=pow(scale,4); break;
1048 case 'p': value*=pow(scale,5); break;
1049 case 'e': value*=pow(scale,6); break;
1050 case 'z': value*=pow(scale,7); break;
1051 case 'y': value*=pow(scale,8); break;
1057 static inline double StringToDouble(const char *value)
1059 return(strtod(value,(char **) NULL));
1062 static inline ssize_t StringToLong(const char *value)
1064 return(strtol(value,(char **) NULL,10));
1067 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1068 const char *attribute,SV *sval,ExceptionInfo *exception)
1095 if (LocaleCompare(attribute,"adjoin") == 0)
1097 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1098 SvPV(sval,na)) : SvIV(sval);
1101 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1106 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1109 if (LocaleCompare(attribute,"alpha") == 0)
1111 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1112 SvPV(sval,na)) : SvIV(sval);
1115 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1119 for ( ; image; image=image->next)
1120 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1123 if (LocaleCompare(attribute,"antialias") == 0)
1125 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1126 SvPV(sval,na)) : SvIV(sval);
1129 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1134 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1137 if (LocaleCompare(attribute,"area-limit") == 0)
1142 limit=MagickResourceInfinity;
1143 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1144 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1145 (void) SetMagickResourceLimit(AreaResource,limit);
1148 if (LocaleCompare(attribute,"attenuate") == 0)
1151 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1154 if (LocaleCompare(attribute,"authenticate") == 0)
1157 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1161 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1162 for ( ; image; image=image->next)
1163 SetImageProperty(image,attribute,SvPV(sval,na));
1169 if (LocaleCompare(attribute,"background") == 0)
1171 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1173 info->image_info->background_color=target_color;
1174 for ( ; image; image=image->next)
1175 image->background_color=target_color;
1178 if (LocaleCompare(attribute,"bias") == 0)
1180 for ( ; image; image=image->next)
1181 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1184 if (LocaleCompare(attribute,"blue-primary") == 0)
1186 for ( ; image; image=image->next)
1188 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1189 image->chromaticity.blue_primary.x=geometry_info.rho;
1190 image->chromaticity.blue_primary.y=geometry_info.sigma;
1191 if ((flags & SigmaValue) == 0)
1192 image->chromaticity.blue_primary.y=
1193 image->chromaticity.blue_primary.x;
1197 if (LocaleCompare(attribute,"bordercolor") == 0)
1199 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1201 info->image_info->border_color=target_color;
1202 for ( ; image; image=image->next)
1203 image->border_color=target_color;
1207 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1208 for ( ; image; image=image->next)
1209 SetImageProperty(image,attribute,SvPV(sval,na));
1215 if (LocaleCompare(attribute,"cache-threshold") == 0)
1217 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1218 SiPrefixToDouble(SvPV(sval,na),100.0));
1219 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1220 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1223 if (LocaleCompare(attribute,"clip-mask") == 0)
1228 clip_mask=(Image *) NULL;
1230 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1231 for ( ; image; image=image->next)
1232 SetImageClipMask(image,clip_mask);
1235 if (LocaleNCompare(attribute,"colormap",8) == 0)
1237 for ( ; image; image=image->next)
1245 if (image->storage_class == DirectClass)
1248 items=sscanf(attribute,"%*[^[][%ld",&i);
1249 if (i > (ssize_t) image->colors)
1251 if ((strchr(SvPV(sval,na),',') == 0) ||
1252 (strchr(SvPV(sval,na),')') != 0))
1253 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1256 color=image->colormap+i;
1257 pixel.red=color->red;
1258 pixel.green=color->green;
1259 pixel.blue=color->blue;
1260 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1261 pixel.red=geometry_info.rho;
1262 pixel.green=geometry_info.sigma;
1263 pixel.blue=geometry_info.xi;
1264 color->red=ClampToQuantum(pixel.red);
1265 color->green=ClampToQuantum(pixel.green);
1266 color->blue=ClampToQuantum(pixel.blue);
1271 if (LocaleCompare(attribute,"colorspace") == 0)
1273 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1274 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1277 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1281 for ( ; image; image=image->next)
1282 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1285 if (LocaleCompare(attribute,"comment") == 0)
1287 for ( ; image; image=image->next)
1288 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1289 info ? info->image_info : (ImageInfo *) NULL,image,
1293 if (LocaleCompare(attribute,"compression") == 0)
1295 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1296 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1299 ThrowPerlException(exception,OptionError,
1300 "UnrecognizedImageCompression",SvPV(sval,na));
1304 info->image_info->compression=(CompressionType) sp;
1305 for ( ; image; image=image->next)
1306 image->compression=(CompressionType) sp;
1310 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1311 for ( ; image; image=image->next)
1312 SetImageProperty(image,attribute,SvPV(sval,na));
1318 if (LocaleCompare(attribute,"debug") == 0)
1320 SetLogEventMask(SvPV(sval,na));
1323 if (LocaleCompare(attribute,"delay") == 0)
1325 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1326 for ( ; image; image=image->next)
1328 image->delay=(size_t) floor(geometry_info.rho+0.5);
1329 if ((flags & SigmaValue) != 0)
1330 image->ticks_per_second=(ssize_t)
1331 floor(geometry_info.sigma+0.5);
1335 if (LocaleCompare(attribute,"disk-limit") == 0)
1340 limit=MagickResourceInfinity;
1341 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1342 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1343 (void) SetMagickResourceLimit(DiskResource,limit);
1346 if (LocaleCompare(attribute,"density") == 0)
1348 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1350 ThrowPerlException(exception,OptionError,"MissingGeometry",
1355 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1356 for ( ; image; image=image->next)
1358 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1359 image->x_resolution=geometry_info.rho;
1360 image->y_resolution=geometry_info.sigma;
1361 if ((flags & SigmaValue) == 0)
1362 image->y_resolution=image->x_resolution;
1366 if (LocaleCompare(attribute,"depth") == 0)
1369 info->image_info->depth=SvIV(sval);
1370 for ( ; image; image=image->next)
1371 (void) SetImageDepth(image,SvIV(sval));
1374 if (LocaleCompare(attribute,"dispose") == 0)
1376 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1377 SvPV(sval,na)) : SvIV(sval);
1380 ThrowPerlException(exception,OptionError,
1381 "UnrecognizedDisposeMethod",SvPV(sval,na));
1384 for ( ; image; image=image->next)
1385 image->dispose=(DisposeType) sp;
1388 if (LocaleCompare(attribute,"dither") == 0)
1392 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1393 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1396 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1400 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1404 if (LocaleCompare(attribute,"display") == 0)
1408 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1412 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1413 for ( ; image; image=image->next)
1414 SetImageProperty(image,attribute,SvPV(sval,na));
1420 if (LocaleCompare(attribute,"endian") == 0)
1422 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1423 SvPV(sval,na)) : SvIV(sval);
1426 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1431 info->image_info->endian=(EndianType) sp;
1432 for ( ; image; image=image->next)
1433 image->endian=(EndianType) sp;
1436 if (LocaleCompare(attribute,"extract") == 0)
1439 Set image extract geometry.
1441 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1445 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1446 for ( ; image; image=image->next)
1447 SetImageProperty(image,attribute,SvPV(sval,na));
1453 if (LocaleCompare(attribute,"filename") == 0)
1456 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1458 for ( ; image; image=image->next)
1459 (void) CopyMagickString(image->filename,SvPV(sval,na),
1463 if (LocaleCompare(attribute,"file") == 0)
1471 if (info == (struct PackageInfo *) NULL)
1473 io_info=IoIFP(sv_2io(sval));
1474 if (io_info == (PerlIO *) NULL)
1476 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1480 file=PerlIO_findFILE(io_info);
1481 if (file == (FILE *) NULL)
1483 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1487 SetImageInfoFile(info->image_info,file);
1490 if (LocaleCompare(attribute,"fill") == 0)
1493 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1496 if (LocaleCompare(attribute,"font") == 0)
1499 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1502 if (LocaleCompare(attribute,"foreground") == 0)
1504 if (LocaleCompare(attribute,"fuzz") == 0)
1507 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1508 for ( ; image; image=image->next)
1509 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1513 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1514 for ( ; image; image=image->next)
1515 SetImageProperty(image,attribute,SvPV(sval,na));
1521 if (LocaleCompare(attribute,"gamma") == 0)
1523 for ( ; image; image=image->next)
1524 image->gamma=SvNV(sval);
1527 if (LocaleCompare(attribute,"gravity") == 0)
1529 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1530 SvPV(sval,na)) : SvIV(sval);
1533 ThrowPerlException(exception,OptionError,
1534 "UnrecognizedGravityType",SvPV(sval,na));
1538 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1539 for ( ; image; image=image->next)
1540 image->gravity=(GravityType) sp;
1543 if (LocaleCompare(attribute,"green-primary") == 0)
1545 for ( ; image; image=image->next)
1547 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1548 image->chromaticity.green_primary.x=geometry_info.rho;
1549 image->chromaticity.green_primary.y=geometry_info.sigma;
1550 if ((flags & SigmaValue) == 0)
1551 image->chromaticity.green_primary.y=
1552 image->chromaticity.green_primary.x;
1557 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1558 for ( ; image; image=image->next)
1559 SetImageProperty(image,attribute,SvPV(sval,na));
1565 if (LocaleNCompare(attribute,"index",5) == 0)
1576 register PixelPacket
1582 for ( ; image; image=image->next)
1584 if (image->storage_class != PseudoClass)
1588 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1589 image_view=AcquireCacheView(image);
1590 p=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1591 if (p != (PixelPacket *) NULL)
1593 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1594 items=sscanf(SvPV(sval,na),"%ld",&index);
1595 if ((index >= 0) && (index < (ssize_t) image->colors))
1596 SetIndexPixelComponent(indexes,index);
1597 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1599 image_view=DestroyCacheView(image_view);
1603 if (LocaleCompare(attribute,"iterations") == 0)
1606 for ( ; image; image=image->next)
1607 image->iterations=SvIV(sval);
1610 if (LocaleCompare(attribute,"interlace") == 0)
1612 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1613 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1616 ThrowPerlException(exception,OptionError,
1617 "UnrecognizedInterlaceType",SvPV(sval,na));
1621 info->image_info->interlace=(InterlaceType) sp;
1622 for ( ; image; image=image->next)
1623 image->interlace=(InterlaceType) sp;
1627 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1628 for ( ; image; image=image->next)
1629 SetImageProperty(image,attribute,SvPV(sval,na));
1635 if (LocaleCompare(attribute,"label") == 0)
1637 for ( ; image; image=image->next)
1638 (void) SetImageProperty(image,"label",InterpretImageProperties(
1639 info ? info->image_info : (ImageInfo *) NULL,image,
1643 if (LocaleCompare(attribute,"loop") == 0)
1646 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1647 for ( ; image; image=image->next)
1648 SetImageProperty(image,attribute,SvPV(sval,na));
1654 if (LocaleCompare(attribute,"magick") == 0)
1657 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
1658 "%s:",SvPV(sval,na));
1659 for ( ; image; image=image->next)
1660 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1663 if (LocaleCompare(attribute,"map-limit") == 0)
1668 limit=MagickResourceInfinity;
1669 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1670 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1671 (void) SetMagickResourceLimit(MapResource,limit);
1674 if (LocaleCompare(attribute,"mask") == 0)
1679 mask=(Image *) NULL;
1681 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1682 for ( ; image; image=image->next)
1683 SetImageMask(image,mask);
1686 if (LocaleCompare(attribute,"mattecolor") == 0)
1688 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1690 info->image_info->matte_color=target_color;
1691 for ( ; image; image=image->next)
1692 image->matte_color=target_color;
1695 if (LocaleCompare(attribute,"matte") == 0)
1697 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1698 SvPV(sval,na)) : SvIV(sval);
1701 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1705 for ( ; image; image=image->next)
1706 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1709 if (LocaleCompare(attribute,"memory-limit") == 0)
1714 limit=MagickResourceInfinity;
1715 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1716 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1717 (void) SetMagickResourceLimit(MemoryResource,limit);
1720 if (LocaleCompare(attribute,"monochrome") == 0)
1722 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1723 SvPV(sval,na)) : SvIV(sval);
1726 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1731 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1732 for ( ; image; image=image->next)
1733 (void) SetImageType(image,BilevelType);
1737 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1738 for ( ; image; image=image->next)
1739 SetImageProperty(image,attribute,SvPV(sval,na));
1745 if (LocaleCompare(attribute,"option") == 0)
1748 DefineImageOption(info->image_info,SvPV(sval,na));
1751 if (LocaleCompare(attribute,"orientation") == 0)
1753 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1754 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1757 ThrowPerlException(exception,OptionError,
1758 "UnrecognizedOrientationType",SvPV(sval,na));
1762 info->image_info->orientation=(OrientationType) sp;
1763 for ( ; image; image=image->next)
1764 image->orientation=(OrientationType) sp;
1768 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1769 for ( ; image; image=image->next)
1770 SetImageProperty(image,attribute,SvPV(sval,na));
1776 if (LocaleCompare(attribute,"page") == 0)
1781 geometry=GetPageGeometry(SvPV(sval,na));
1783 (void) CloneString(&info->image_info->page,geometry);
1784 for ( ; image; image=image->next)
1785 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1786 geometry=(char *) RelinquishMagickMemory(geometry);
1789 if (LocaleCompare(attribute,"pen") == 0)
1792 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1795 if (LocaleNCompare(attribute,"pixel",5) == 0)
1803 register IndexPacket
1806 register PixelPacket
1812 for ( ; image; image=image->next)
1814 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1818 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1819 image_view=AcquireCacheView(image);
1820 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1821 indexes=GetCacheViewAuthenticIndexQueue(image_view);
1822 if (q != (PixelPacket *) NULL)
1824 if ((strchr(SvPV(sval,na),',') == 0) ||
1825 (strchr(SvPV(sval,na),')') != 0))
1826 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1829 GetMagickPixelPacket(image,&pixel);
1830 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1831 pixel.red=geometry_info.rho;
1832 if ((flags & SigmaValue) != 0)
1833 pixel.green=geometry_info.sigma;
1834 if ((flags & XiValue) != 0)
1835 pixel.blue=geometry_info.xi;
1836 if ((flags & PsiValue) != 0)
1837 pixel.opacity=geometry_info.psi;
1838 if ((flags & ChiValue) != 0)
1839 pixel.index=geometry_info.chi;
1841 SetRedPixelComponent(q,ClampToQuantum(pixel.red));
1842 SetGreenPixelComponent(q,ClampToQuantum(pixel.green));
1843 SetBluePixelComponent(q,ClampToQuantum(pixel.blue));
1844 SetOpacityPixelComponent(q,ClampToQuantum(pixel.opacity));
1845 if (((image->colorspace == CMYKColorspace) ||
1846 (image->storage_class == PseudoClass)) &&
1847 (indexes != (IndexPacket *) NULL))
1848 SetIndexPixelComponent(indexes,ClampToQuantum(pixel.index));
1849 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1851 image_view=DestroyCacheView(image_view);
1855 if (LocaleCompare(attribute,"pointsize") == 0)
1859 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1860 info->image_info->pointsize=geometry_info.rho;
1864 if (LocaleCompare(attribute,"preview") == 0)
1866 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1867 SvPV(sval,na)) : SvIV(sval);
1870 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1875 info->image_info->preview_type=(PreviewType) sp;
1879 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1880 for ( ; image; image=image->next)
1881 SetImageProperty(image,attribute,SvPV(sval,na));
1887 if (LocaleCompare(attribute,"quality") == 0)
1890 info->image_info->quality=SvIV(sval);
1891 for ( ; image; image=image->next)
1892 image->quality=SvIV(sval);
1896 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1897 for ( ; image; image=image->next)
1898 SetImageProperty(image,attribute,SvPV(sval,na));
1904 if (LocaleCompare(attribute,"red-primary") == 0)
1906 for ( ; image; image=image->next)
1908 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1909 image->chromaticity.red_primary.x=geometry_info.rho;
1910 image->chromaticity.red_primary.y=geometry_info.sigma;
1911 if ((flags & SigmaValue) == 0)
1912 image->chromaticity.red_primary.y=
1913 image->chromaticity.red_primary.x;
1917 if (LocaleCompare(attribute,"render") == 0)
1919 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1920 SvPV(sval,na)) : SvIV(sval);
1923 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1927 for ( ; image; image=image->next)
1928 image->rendering_intent=(RenderingIntent) sp;
1931 if (LocaleCompare(attribute,"repage") == 0)
1936 for ( ; image; image=image->next)
1938 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1939 if ((flags & WidthValue) != 0)
1941 if ((flags & HeightValue) == 0)
1942 geometry.height=geometry.width;
1943 image->page.width=geometry.width;
1944 image->page.height=geometry.height;
1946 if ((flags & AspectValue) != 0)
1948 if ((flags & XValue) != 0)
1949 image->page.x+=geometry.x;
1950 if ((flags & YValue) != 0)
1951 image->page.y+=geometry.y;
1955 if ((flags & XValue) != 0)
1957 image->page.x=geometry.x;
1958 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1959 image->page.width=image->columns+geometry.x;
1961 if ((flags & YValue) != 0)
1963 image->page.y=geometry.y;
1964 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1965 image->page.height=image->rows+geometry.y;
1972 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1973 for ( ; image; image=image->next)
1974 SetImageProperty(image,attribute,SvPV(sval,na));
1980 if (LocaleCompare(attribute,"sampling-factor") == 0)
1982 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1984 ThrowPerlException(exception,OptionError,"MissingGeometry",
1989 (void) CloneString(&info->image_info->sampling_factor,
1993 if (LocaleCompare(attribute,"scene") == 0)
1995 for ( ; image; image=image->next)
1996 image->scene=SvIV(sval);
1999 if (LocaleCompare(attribute,"subimage") == 0)
2002 info->image_info->subimage=SvIV(sval);
2005 if (LocaleCompare(attribute,"subrange") == 0)
2008 info->image_info->subrange=SvIV(sval);
2011 if (LocaleCompare(attribute,"server") == 0)
2013 if (LocaleCompare(attribute,"size") == 0)
2017 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2019 ThrowPerlException(exception,OptionError,"MissingGeometry",
2023 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2027 if (LocaleCompare(attribute,"stroke") == 0)
2030 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2034 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2035 for ( ; image; image=image->next)
2036 SetImageProperty(image,attribute,SvPV(sval,na));
2042 if (LocaleCompare(attribute,"texture") == 0)
2045 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2048 if (LocaleCompare(attribute,"thread-limit") == 0)
2053 limit=MagickResourceInfinity;
2054 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2055 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2056 (void) SetMagickResourceLimit(ThreadResource,limit);
2059 if (LocaleCompare(attribute,"tile") == 0)
2062 (void) CloneString(&info->image_info->tile,SvPV(sval,na));
2065 if (LocaleCompare(attribute,"tile-offset") == 0)
2070 geometry=GetPageGeometry(SvPV(sval,na));
2072 (void) CloneString(&info->image_info->page,geometry);
2073 for ( ; image; image=image->next)
2074 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2076 geometry=(char *) RelinquishMagickMemory(geometry);
2079 if (LocaleCompare(attribute,"time-limit") == 0)
2084 limit=MagickResourceInfinity;
2085 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2086 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2087 (void) SetMagickResourceLimit(TimeResource,limit);
2090 if (LocaleCompare(attribute,"transparent-color") == 0)
2092 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2094 info->image_info->transparent_color=target_color;
2095 for ( ; image; image=image->next)
2096 image->transparent_color=target_color;
2099 if (LocaleCompare(attribute,"type") == 0)
2101 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2102 SvPV(sval,na)) : SvIV(sval);
2105 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2110 info->image_info->type=(ImageType) sp;
2111 for ( ; image; image=image->next)
2112 SetImageType(image,(ImageType) sp);
2116 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2117 for ( ; image; image=image->next)
2118 SetImageProperty(image,attribute,SvPV(sval,na));
2124 if (LocaleCompare(attribute,"units") == 0)
2126 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2127 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2130 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2135 info->image_info->units=(ResolutionType) sp;
2136 for ( ; image; image=image->next)
2141 units=(ResolutionType) sp;
2142 if (image->units != units)
2143 switch (image->units)
2145 case UndefinedResolution:
2146 case PixelsPerInchResolution:
2148 if (units == PixelsPerCentimeterResolution)
2150 image->x_resolution*=2.54;
2151 image->y_resolution*=2.54;
2155 case PixelsPerCentimeterResolution:
2157 if (units == PixelsPerInchResolution)
2159 image->x_resolution/=2.54;
2160 image->y_resolution/=2.54;
2170 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2171 for ( ; image; image=image->next)
2172 SetImageProperty(image,attribute,SvPV(sval,na));
2178 if (LocaleCompare(attribute,"verbose") == 0)
2180 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2181 SvPV(sval,na)) : SvIV(sval);
2184 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2189 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2192 if (LocaleCompare(attribute,"view") == 0)
2195 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2198 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2200 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2201 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2204 ThrowPerlException(exception,OptionError,
2205 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2209 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2210 for ( ; image; image=image->next)
2211 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2215 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2216 for ( ; image; image=image->next)
2217 SetImageProperty(image,attribute,SvPV(sval,na));
2223 if (LocaleCompare(attribute,"white-point") == 0)
2225 for ( ; image; image=image->next)
2227 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2228 image->chromaticity.white_point.x=geometry_info.rho;
2229 image->chromaticity.white_point.y=geometry_info.sigma;
2230 if ((flags & SigmaValue) == 0)
2231 image->chromaticity.white_point.y=
2232 image->chromaticity.white_point.x;
2237 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2238 for ( ; image; image=image->next)
2239 SetImageProperty(image,attribute,SvPV(sval,na));
2245 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2246 for ( ; image; image=image->next)
2247 SetImageProperty(image,attribute,SvPV(sval,na));
2254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2258 % S e t u p L i s t %
2262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2264 % Method SetupList returns the list of all the images linked by their
2265 % image->next and image->previous link lists for use with ImageMagick. If
2266 % info is non-NULL, an info structure is returned in *info. If
2267 % reference_vector is non-NULL,an array of SV* are returned in
2268 % *reference_vector. Reference_vector is used when the images are going to be
2269 % replaced with new Image*'s.
2271 % The format of the SetupList routine is:
2273 % Image *SetupList(SV *reference,struct PackageInfo **info,
2274 % SV ***reference_vector,ExceptionInfo *exception)
2276 % A description of each parameter follows:
2278 % o list: a list of strings.
2280 % o string: a character string.
2282 % o exception: Return any errors or warnings in this structure.
2285 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2286 SV ***reference_vector,ExceptionInfo *exception)
2295 if (reference_vector)
2296 *reference_vector=NULL;
2301 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2302 if (info && (SvTYPE(reference) == SVt_PVAV))
2303 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2313 % s t r E Q c a s e %
2317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2319 % strEQcase() compares two strings and returns 0 if they are the
2320 % same or if the second string runs out first. The comparison is case
2323 % The format of the strEQcase routine is:
2325 % ssize_t strEQcase(const char *p,const char *q)
2327 % A description of each parameter follows:
2329 % o p: a character string.
2331 % o q: a character string.
2335 static ssize_t strEQcase(const char *p,const char *q)
2343 for (i=0 ; (c=(*q)) != 0; i++)
2345 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2346 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2351 return(((*q == 0) && (*p == 0)) ? i : 0);
2355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2359 % I m a g e : : M a g i c k %
2363 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2367 MODULE = Image::Magick PACKAGE = Image::Magick
2372 MagickCoreGenesis("PerlMagick",MagickFalse);
2373 SetWarningHandler(NULL);
2374 SetErrorHandler(NULL);
2375 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2376 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2382 if (magick_registry != (SplayTreeInfo *) NULL)
2383 magick_registry=DestroySplayTree(magick_registry);
2384 MagickCoreTerminus();
2388 constant(name,argument)
2393 ###############################################################################
2401 ###############################################################################
2406 Image::Magick ref=NO_INIT
2430 PERL_UNUSED_VAR(ref);
2431 PERL_UNUSED_VAR(ix);
2432 exception=AcquireExceptionInfo();
2433 perl_exception=newSVpv("",0);
2434 package_info=(struct PackageInfo *) NULL;
2435 if (sv_isobject(ST(0)) == 0)
2437 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2441 reference=SvRV(ST(0));
2442 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2443 if (image == (Image *) NULL)
2445 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2449 package_info=ClonePackageInfo(info,exception);
2451 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2454 for (i=2; i < items; i+=2)
2455 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2457 (void) AnimateImages(package_info->image_info,image);
2458 (void) CatchImageException(image);
2459 InheritException(exception,&image->exception);
2462 if (package_info != (struct PackageInfo *) NULL)
2463 DestroyPackageInfo(package_info);
2464 InheritPerlException(exception,perl_exception);
2465 exception=DestroyExceptionInfo(exception);
2466 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2467 SvPOK_on(perl_exception);
2468 ST(0)=sv_2mortal(perl_exception);
2473 ###############################################################################
2481 ###############################################################################
2486 Image::Magick ref=NO_INIT
2524 PERL_UNUSED_VAR(ref);
2525 PERL_UNUSED_VAR(ix);
2526 exception=AcquireExceptionInfo();
2527 perl_exception=newSVpv("",0);
2531 if (sv_isobject(ST(0)) == 0)
2533 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2537 reference=SvRV(ST(0));
2538 hv=SvSTASH(reference);
2540 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2542 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2543 if (image == (Image *) NULL)
2545 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2549 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2554 for (i=2; i < items; i+=2)
2556 attribute=(char *) SvPV(ST(i-1),na);
2562 if (LocaleCompare(attribute,"stack") == 0)
2564 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2568 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2574 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2580 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2586 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2587 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2589 for ( ; image; image=image->next)
2591 AddImageToRegistry(sv,image);
2593 av_push(av,sv_bless(rv,hv));
2596 exception=DestroyExceptionInfo(exception);
2598 SvREFCNT_dec(perl_exception);
2602 InheritPerlException(exception,perl_exception);
2603 exception=DestroyExceptionInfo(exception);
2604 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2605 SvPOK_on(perl_exception);
2606 ST(0)=sv_2mortal(perl_exception);
2611 ###############################################################################
2619 ###############################################################################
2624 Image::Magick ref=NO_INIT
2655 PERL_UNUSED_VAR(ref);
2656 PERL_UNUSED_VAR(ix);
2657 exception=AcquireExceptionInfo();
2658 perl_exception=newSVpv("",0);
2660 if (sv_isobject(ST(0)) == 0)
2662 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2666 reference=SvRV(ST(0));
2667 hv=SvSTASH(reference);
2668 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2669 if (image == (Image *) NULL)
2671 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2675 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2676 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2679 Create blessed Perl array for the returned image.
2682 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2684 AddImageToRegistry(sv,image);
2686 av_push(av,sv_bless(rv,hv));
2688 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2689 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
2690 "average-%.*s",(int) (MaxTextExtent-9),
2691 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2692 (void) CopyMagickString(image->filename,info->image_info->filename,
2694 SetImageInfo(info->image_info,0,exception);
2695 exception=DestroyExceptionInfo(exception);
2696 SvREFCNT_dec(perl_exception);
2700 InheritPerlException(exception,perl_exception);
2701 exception=DestroyExceptionInfo(exception);
2702 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2703 SvPOK_on(perl_exception);
2704 ST(0)=sv_2mortal(perl_exception);
2709 ###############################################################################
2713 # B l o b T o I m a g e #
2717 ###############################################################################
2721 BlobToImage(ref,...)
2722 Image::Magick ref=NO_INIT
2768 PERL_UNUSED_VAR(ref);
2769 PERL_UNUSED_VAR(ix);
2770 exception=AcquireExceptionInfo();
2771 perl_exception=newSVpv("",0);
2774 ac=(items < 2) ? 1 : items-1;
2775 length=(STRLEN *) NULL;
2776 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2777 if (list == (char **) NULL)
2779 ThrowPerlException(exception,ResourceLimitError,
2780 "MemoryAllocationFailed",PackageName);
2783 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2784 if (length == (STRLEN *) NULL)
2786 ThrowPerlException(exception,ResourceLimitError,
2787 "MemoryAllocationFailed",PackageName);
2790 if (sv_isobject(ST(0)) == 0)
2792 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2796 reference=SvRV(ST(0));
2797 hv=SvSTASH(reference);
2798 if (SvTYPE(reference) != SVt_PVAV)
2800 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2804 av=(AV *) reference;
2805 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2810 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2813 for (n=0, i=0; i < ac; i++)
2815 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2816 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2818 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2823 list[n]=(char *) NULL;
2825 for (i=number_images=0; i < n; i++)
2827 image=BlobToImage(info->image_info,list[i],length[i],exception);
2828 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2830 for ( ; image; image=image->next)
2832 AddImageToRegistry(sv,image);
2834 av_push(av,sv_bless(rv,hv));
2842 for (i=0; i < n; i++)
2843 if (list[i] != (char *) NULL)
2844 for (p=keep; list[i] != *p++; )
2845 if (*p == (char *) NULL)
2847 list[i]=(char *) RelinquishMagickMemory(list[i]);
2853 list=(char **) RelinquishMagickMemory(list);
2855 length=(STRLEN *) RelinquishMagickMemory(length);
2856 InheritPerlException(exception,perl_exception);
2857 exception=DestroyExceptionInfo(exception);
2858 sv_setiv(perl_exception,(IV) number_images);
2859 SvPOK_on(perl_exception);
2860 ST(0)=sv_2mortal(perl_exception);
2865 ###############################################################################
2873 ###############################################################################
2878 Image::Magick ref=NO_INIT
2911 PERL_UNUSED_VAR(ref);
2912 PERL_UNUSED_VAR(ix);
2913 exception=AcquireExceptionInfo();
2914 perl_exception=newSVpv("",0);
2916 if (sv_isobject(ST(0)) == 0)
2918 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2922 reference=SvRV(ST(0));
2923 hv=SvSTASH(reference);
2924 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2925 if (image == (Image *) NULL)
2927 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2932 Create blessed Perl array for the returned image.
2935 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2937 for ( ; image; image=image->next)
2939 clone=CloneImage(image,0,0,MagickTrue,exception);
2940 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2942 AddImageToRegistry(sv,clone);
2944 av_push(av,sv_bless(rv,hv));
2947 exception=DestroyExceptionInfo(exception);
2948 SvREFCNT_dec(perl_exception);
2952 InheritPerlException(exception,perl_exception);
2953 exception=DestroyExceptionInfo(exception);
2954 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2955 SvPOK_on(perl_exception);
2956 ST(0)=sv_2mortal(perl_exception);
2961 ###############################################################################
2969 ###############################################################################
2977 PERL_UNUSED_VAR(ref);
2978 if (magick_registry != (SplayTreeInfo *) NULL)
2983 ResetSplayTreeIterator(magick_registry);
2984 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2985 while (p != (Image *) NULL)
2988 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2994 ###############################################################################
3002 ###############################################################################
3007 Image::Magick ref=NO_INIT
3036 PERL_UNUSED_VAR(ref);
3037 PERL_UNUSED_VAR(ix);
3038 exception=AcquireExceptionInfo();
3039 perl_exception=newSVpv("",0);
3041 if (sv_isobject(ST(0)) == 0)
3043 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3047 reference=SvRV(ST(0));
3048 hv=SvSTASH(reference);
3050 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3052 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3053 if (image == (Image *) NULL)
3055 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3059 image=CoalesceImages(image,exception);
3060 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3062 for ( ; image; image=image->next)
3064 AddImageToRegistry(sv,image);
3066 av_push(av,sv_bless(rv,hv));
3069 exception=DestroyExceptionInfo(exception);
3071 SvREFCNT_dec(perl_exception);
3075 InheritPerlException(exception,perl_exception);
3076 exception=DestroyExceptionInfo(exception);
3077 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3078 SvPOK_on(perl_exception);
3079 ST(0)=sv_2mortal(perl_exception);
3084 ###############################################################################
3092 ###############################################################################
3097 Image::Magick ref=NO_INIT
3146 PERL_UNUSED_VAR(ref);
3147 PERL_UNUSED_VAR(ix);
3148 exception=AcquireExceptionInfo();
3149 perl_exception=newSVpv("",0);
3153 if (sv_isobject(ST(0)) == 0)
3155 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3159 reference=SvRV(ST(0));
3160 hv=SvSTASH(reference);
3162 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3164 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3165 if (image == (Image *) NULL)
3167 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3171 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3175 channel=DefaultChannels;
3176 reconstruct_image=image;
3177 metric=RootMeanSquaredErrorMetric;
3178 for (i=2; i < items; i+=2)
3180 attribute=(char *) SvPV(ST(i-1),na);
3186 if (LocaleCompare(attribute,"channel") == 0)
3191 option=ParseChannelOption(SvPV(ST(i),na));
3194 ThrowPerlException(exception,OptionError,
3195 "UnrecognizedType",SvPV(ST(i),na));
3198 channel=(ChannelType) option;
3201 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3208 if (LocaleCompare(attribute,"fuzz") == 0)
3210 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3213 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3220 if (LocaleCompare(attribute,"image") == 0)
3222 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3223 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3226 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3233 if (LocaleCompare(attribute,"metric") == 0)
3235 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3239 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3243 metric=(MetricType) option;
3246 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3252 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3258 difference_image=CompareImageChannels(image,reconstruct_image,channel,
3259 metric,&distortion,exception);
3260 if (difference_image != (Image *) NULL)
3262 difference_image->error.mean_error_per_pixel=distortion;
3263 AddImageToRegistry(sv,difference_image);
3265 av_push(av,sv_bless(rv,hv));
3268 exception=DestroyExceptionInfo(exception);
3270 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3274 InheritPerlException(exception,perl_exception);
3275 exception=DestroyExceptionInfo(exception);
3276 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3277 SvPOK_on(perl_exception);
3278 ST(0)=sv_2mortal(perl_exception);
3283 ###############################################################################
3287 # C o m p a r e L a y e r s #
3291 ###############################################################################
3296 Image::Magick ref=NO_INIT
3298 CompareImageLayers = 1
3300 compareimagelayers = 3
3337 PERL_UNUSED_VAR(ref);
3338 PERL_UNUSED_VAR(ix);
3339 exception=AcquireExceptionInfo();
3340 perl_exception=newSVpv("",0);
3342 if (sv_isobject(ST(0)) == 0)
3344 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3348 reference=SvRV(ST(0));
3349 hv=SvSTASH(reference);
3351 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3353 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3354 if (image == (Image *) NULL)
3356 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3360 method=CompareAnyLayer;
3361 for (i=2; i < items; i+=2)
3363 attribute=(char *) SvPV(ST(i-1),na);
3369 if (LocaleCompare(attribute,"method") == 0)
3371 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3375 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3379 method=(ImageLayerMethod) option;
3382 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3394 image=CompareImageLayers(image,method,exception);
3395 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3397 for ( ; image; image=image->next)
3399 AddImageToRegistry(sv,image);
3401 av_push(av,sv_bless(rv,hv));
3404 exception=DestroyExceptionInfo(exception);
3406 SvREFCNT_dec(perl_exception);
3410 InheritPerlException(exception,perl_exception);
3411 exception=DestroyExceptionInfo(exception);
3412 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3413 SvPOK_on(perl_exception);
3414 ST(0)=sv_2mortal(perl_exception);
3419 ###############################################################################
3427 ###############################################################################
3432 Image::Magick ref=NO_INIT
3438 PERL_UNUSED_VAR(ref);
3439 if (sv_isobject(ST(0)) == 0)
3440 croak("ReferenceIsNotMyType");
3441 reference=SvRV(ST(0));
3442 switch (SvTYPE(reference))
3447 message[MaxTextExtent];
3465 Array (AV *) reference
3467 (void) FormatMagickString(message,MaxTextExtent,"package%s%p",
3468 XS_VERSION,reference);
3469 hv=gv_stashpv(PackageName, FALSE);
3472 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3476 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3478 info=(struct PackageInfo *) SvIV(sv);
3479 DestroyPackageInfo(info);
3481 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3490 Blessed scalar = (Image *) SvIV(reference)
3492 image=(Image *) SvIV(reference);
3493 if (image != (Image *) NULL)
3494 DeleteImageFromRegistry(reference,image);
3503 ###############################################################################
3511 ###############################################################################
3516 Image::Magick ref=NO_INIT
3540 PERL_UNUSED_VAR(ref);
3541 PERL_UNUSED_VAR(ix);
3542 exception=AcquireExceptionInfo();
3543 perl_exception=newSVpv("",0);
3544 package_info=(struct PackageInfo *) NULL;
3545 if (sv_isobject(ST(0)) == 0)
3547 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3551 reference=SvRV(ST(0));
3552 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3553 if (image == (Image *) NULL)
3555 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3559 package_info=ClonePackageInfo(info,exception);
3561 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3564 for (i=2; i < items; i+=2)
3565 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3567 (void) DisplayImages(package_info->image_info,image);
3568 (void) CatchImageException(image);
3569 InheritException(exception,&image->exception);
3572 if (package_info != (struct PackageInfo *) NULL)
3573 DestroyPackageInfo(package_info);
3574 InheritPerlException(exception,perl_exception);
3575 exception=DestroyExceptionInfo(exception);
3576 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3577 SvPOK_on(perl_exception);
3578 ST(0)=sv_2mortal(perl_exception);
3583 ###############################################################################
3587 # E v a l u a t e I m a g e s #
3591 ###############################################################################
3596 Image::Magick ref=NO_INIT
3618 MagickEvaluateOperator
3633 PERL_UNUSED_VAR(ref);
3634 PERL_UNUSED_VAR(ix);
3635 exception=AcquireExceptionInfo();
3636 perl_exception=newSVpv("",0);
3638 if (sv_isobject(ST(0)) == 0)
3640 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3644 reference=SvRV(ST(0));
3645 hv=SvSTASH(reference);
3646 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3647 if (image == (Image *) NULL)
3649 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3653 op=MeanEvaluateOperator;
3659 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3663 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3667 op=(MagickEvaluateOperator) in;
3670 for (i=2; i < items; i+=2)
3672 attribute=(char *) SvPV(ST(i-1),na);
3678 if (LocaleCompare(attribute,"operator") == 0)
3683 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3684 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3687 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3691 op=(MagickEvaluateOperator) in;
3694 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3706 image=EvaluateImages(image,op,exception);
3707 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3710 Create blessed Perl array for the returned image.
3713 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3715 AddImageToRegistry(sv,image);
3717 av_push(av,sv_bless(rv,hv));
3719 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3720 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
3721 "evaluate-%.*s",(int) (MaxTextExtent-9),
3722 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3723 (void) CopyMagickString(image->filename,info->image_info->filename,
3725 SetImageInfo(info->image_info,0,exception);
3726 exception=DestroyExceptionInfo(exception);
3727 SvREFCNT_dec(perl_exception);
3731 InheritPerlException(exception,perl_exception);
3732 exception=DestroyExceptionInfo(exception);
3733 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3734 SvPOK_on(perl_exception);
3735 ST(0)=sv_2mortal(perl_exception);
3740 ###############################################################################
3748 ###############################################################################
3753 Image::Magick ref=NO_INIT
3760 #define ChannelFeatures(channel,direction) \
3762 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3763 channel_features[channel].angular_second_moment[direction]); \
3764 PUSHs(sv_2mortal(newSVpv(message,0))); \
3765 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3766 channel_features[channel].contrast[direction]); \
3767 PUSHs(sv_2mortal(newSVpv(message,0))); \
3768 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3769 channel_features[channel].contrast[direction]); \
3770 PUSHs(sv_2mortal(newSVpv(message,0))); \
3771 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3772 channel_features[channel].variance_sum_of_squares[direction]); \
3773 PUSHs(sv_2mortal(newSVpv(message,0))); \
3774 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3775 channel_features[channel].inverse_difference_moment[direction]); \
3776 PUSHs(sv_2mortal(newSVpv(message,0))); \
3777 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3778 channel_features[channel].sum_average[direction]); \
3779 PUSHs(sv_2mortal(newSVpv(message,0))); \
3780 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3781 channel_features[channel].sum_variance[direction]); \
3782 PUSHs(sv_2mortal(newSVpv(message,0))); \
3783 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3784 channel_features[channel].sum_entropy[direction]); \
3785 PUSHs(sv_2mortal(newSVpv(message,0))); \
3786 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3787 channel_features[channel].entropy[direction]); \
3788 PUSHs(sv_2mortal(newSVpv(message,0))); \
3789 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3790 channel_features[channel].difference_variance[direction]); \
3791 PUSHs(sv_2mortal(newSVpv(message,0))); \
3792 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3793 channel_features[channel].difference_entropy[direction]); \
3794 PUSHs(sv_2mortal(newSVpv(message,0))); \
3795 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3796 channel_features[channel].measure_of_correlation_1[direction]); \
3797 PUSHs(sv_2mortal(newSVpv(message,0))); \
3798 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3799 channel_features[channel].measure_of_correlation_2[direction]); \
3800 PUSHs(sv_2mortal(newSVpv(message,0))); \
3801 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
3802 channel_features[channel].maximum_correlation_coefficient[direction]); \
3803 PUSHs(sv_2mortal(newSVpv(message,0))); \
3811 message[MaxTextExtent];
3842 PERL_UNUSED_VAR(ref);
3843 PERL_UNUSED_VAR(ix);
3844 exception=AcquireExceptionInfo();
3845 perl_exception=newSVpv("",0);
3847 if (sv_isobject(ST(0)) == 0)
3849 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3853 reference=SvRV(ST(0));
3854 hv=SvSTASH(reference);
3856 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3858 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3859 if (image == (Image *) NULL)
3861 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3865 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3867 for (i=2; i < items; i+=2)
3869 attribute=(char *) SvPV(ST(i-1),na);
3875 if (LocaleCompare(attribute,"distance") == 0)
3877 distance=StringToLong((char *) SvPV(ST(1),na));
3880 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3886 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3893 for ( ; image; image=image->next)
3895 channel_features=GetImageChannelFeatures(image,distance,
3897 if (channel_features == (ChannelFeatures *) NULL)
3900 EXTEND(sp,75*count);
3901 for (i=0; i < 4; i++)
3903 ChannelFeatures(RedChannel,i);
3904 ChannelFeatures(GreenChannel,i);
3905 ChannelFeatures(BlueChannel,i);
3906 if (image->colorspace == CMYKColorspace)
3907 ChannelFeatures(IndexChannel,i);
3908 if (image->matte != MagickFalse)
3909 ChannelFeatures(OpacityChannel,i);
3911 channel_features=(ChannelFeatures *)
3912 RelinquishMagickMemory(channel_features);
3916 InheritPerlException(exception,perl_exception);
3917 exception=DestroyExceptionInfo(exception);
3918 SvREFCNT_dec(perl_exception);
3922 ###############################################################################
3930 ###############################################################################
3935 Image::Magick ref=NO_INIT
3973 PERL_UNUSED_VAR(ref);
3974 PERL_UNUSED_VAR(ix);
3975 exception=AcquireExceptionInfo();
3976 perl_exception=newSVpv("",0);
3978 if (sv_isobject(ST(0)) == 0)
3980 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3984 reference=SvRV(ST(0));
3985 hv=SvSTASH(reference);
3986 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3987 if (image == (Image *) NULL)
3989 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3993 background_color=image->background_color;
3995 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3998 for (i=2; i < items; i+=2)
4000 attribute=(char *) SvPV(ST(i-1),na);
4006 if (LocaleCompare(attribute,"background") == 0)
4008 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
4009 &background_color,exception);
4012 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4018 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4024 image->background_color=background_color;
4025 image=MergeImageLayers(image,FlattenLayer,exception);
4026 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4029 Create blessed Perl array for the returned image.
4032 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4034 AddImageToRegistry(sv,image);
4036 av_push(av,sv_bless(rv,hv));
4038 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4039 (void) FormatMagickString(info->image_info->filename,MaxTextExtent,
4040 "flatten-%.*s",(int) (MaxTextExtent-9),
4041 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4042 (void) CopyMagickString(image->filename,info->image_info->filename,
4044 SetImageInfo(info->image_info,0,exception);
4045 exception=DestroyExceptionInfo(exception);
4046 SvREFCNT_dec(perl_exception);
4050 InheritPerlException(exception,perl_exception);
4051 exception=DestroyExceptionInfo(exception);
4052 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4053 SvPOK_on(perl_exception); /* return messages in string context */
4054 ST(0)=sv_2mortal(perl_exception);
4059 ###############################################################################
4067 ###############################################################################
4072 Image::Magick ref=NO_INIT
4084 expression[MaxTextExtent];
4111 PERL_UNUSED_VAR(ref);
4112 PERL_UNUSED_VAR(ix);
4113 exception=AcquireExceptionInfo();
4114 perl_exception=newSVpv("",0);
4118 if (sv_isobject(ST(0)) == 0)
4120 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4124 reference=SvRV(ST(0));
4125 hv=SvSTASH(reference);
4127 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4129 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4130 if (image == (Image *) NULL)
4132 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4136 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4140 channel=DefaultChannels;
4141 (void) CopyMagickString(expression,"u",MaxTextExtent);
4143 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4145 for (i=2; i < items; i+=2)
4147 attribute=(char *) SvPV(ST(i-1),na);
4153 if (LocaleCompare(attribute,"channel") == 0)
4158 option=ParseChannelOption(SvPV(ST(i),na));
4161 ThrowPerlException(exception,OptionError,
4162 "UnrecognizedType",SvPV(ST(i),na));
4165 channel=(ChannelType) option;
4168 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4175 if (LocaleCompare(attribute,"expression") == 0)
4177 (void) CopyMagickString(expression,SvPV(ST(i),na),
4181 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4187 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4193 image=FxImageChannel(image,channel,expression,exception);
4194 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4196 for ( ; image; image=image->next)
4198 AddImageToRegistry(sv,image);
4200 av_push(av,sv_bless(rv,hv));
4203 exception=DestroyExceptionInfo(exception);
4205 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4209 InheritPerlException(exception,perl_exception);
4210 exception=DestroyExceptionInfo(exception);
4211 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4212 SvPOK_on(perl_exception);
4213 ST(0)=sv_2mortal(perl_exception);
4218 ###############################################################################
4226 ###############################################################################
4231 Image::Magick ref=NO_INIT
4242 color[MaxTextExtent];
4267 PERL_UNUSED_VAR(ref);
4268 PERL_UNUSED_VAR(ix);
4269 exception=AcquireExceptionInfo();
4270 perl_exception=newSVpv("",0);
4271 if (sv_isobject(ST(0)) == 0)
4273 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4277 reference=SvRV(ST(0));
4278 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4279 if (image == (Image *) NULL && !info)
4282 for (i=1; i < items; i++)
4284 attribute=(char *) SvPV(ST(i),na);
4291 if (LocaleCompare(attribute,"adjoin") == 0)
4294 s=newSViv((ssize_t) info->image_info->adjoin);
4295 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4298 if (LocaleCompare(attribute,"antialias") == 0)
4301 s=newSViv((ssize_t) info->image_info->antialias);
4302 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4305 if (LocaleCompare(attribute,"area") == 0)
4307 s=newSViv(GetMagickResource(AreaResource));
4308 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4311 if (LocaleCompare(attribute,"attenuate") == 0)
4316 value=GetImageProperty(image,attribute);
4317 if (value != (const char *) NULL)
4319 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4322 if (LocaleCompare(attribute,"authenticate") == 0)
4325 s=newSVpv(info->image_info->authenticate,0);
4326 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4329 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4336 if (LocaleCompare(attribute,"background") == 0)
4338 if (image == (Image *) NULL)
4340 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4341 QuantumFormat "," QuantumFormat "," QuantumFormat,
4342 image->background_color.red,image->background_color.green,
4343 image->background_color.blue,image->background_color.opacity);
4345 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4348 if (LocaleCompare(attribute,"base-columns") == 0)
4350 if (image != (Image *) NULL)
4351 s=newSViv((ssize_t) image->magick_columns);
4352 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4355 if (LocaleCompare(attribute,"base-filename") == 0)
4357 if (image != (Image *) NULL)
4358 s=newSVpv(image->magick_filename,0);
4359 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4362 if (LocaleCompare(attribute,"base-height") == 0)
4364 if (image != (Image *) NULL)
4365 s=newSViv((ssize_t) image->magick_rows);
4366 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4369 if (LocaleCompare(attribute,"base-rows") == 0)
4371 if (image != (Image *) NULL)
4372 s=newSViv((ssize_t) image->magick_rows);
4373 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4376 if (LocaleCompare(attribute,"base-width") == 0)
4378 if (image != (Image *) NULL)
4379 s=newSViv((ssize_t) image->magick_columns);
4380 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4383 if (LocaleCompare(attribute,"bias") == 0)
4385 if (image != (Image *) NULL)
4386 s=newSVnv(image->bias);
4387 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4390 if (LocaleCompare(attribute,"blue-primary") == 0)
4392 if (image == (Image *) NULL)
4394 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
4395 image->chromaticity.blue_primary.x,
4396 image->chromaticity.blue_primary.y);
4398 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4401 if (LocaleCompare(attribute,"bordercolor") == 0)
4403 if (image == (Image *) NULL)
4405 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4406 QuantumFormat "," QuantumFormat "," QuantumFormat,
4407 image->border_color.red,image->border_color.green,
4408 image->border_color.blue,image->border_color.opacity);
4410 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4413 if (LocaleCompare(attribute,"bounding-box") == 0)
4416 geometry[MaxTextExtent];
4421 if (image == (Image *) NULL)
4423 page=GetImageBoundingBox(image,&image->exception);
4424 (void) FormatMagickString(geometry,MaxTextExtent,
4425 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4426 page.height,(double) page.x,(double) page.y);
4427 s=newSVpv(geometry,0);
4428 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4431 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4438 if (LocaleCompare(attribute,"class") == 0)
4440 if (image == (Image *) NULL)
4442 s=newSViv(image->storage_class);
4443 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4444 image->storage_class));
4446 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4449 if (LocaleCompare(attribute,"clip-mask") == 0)
4451 if (image != (Image *) NULL)
4457 if (image->mask == (Image *) NULL)
4459 if (image->mask != (Image *) NULL)
4461 AddImageToRegistry(sv,image->mask);
4462 s=sv_bless(newRV(sv),SvSTASH(reference));
4465 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4468 if (LocaleCompare(attribute,"clip-path") == 0)
4470 if (image != (Image *) NULL)
4476 if (image->clip_mask == (Image *) NULL)
4478 if (image->clip_mask != (Image *) NULL)
4480 AddImageToRegistry(sv,image->clip_mask);
4481 s=sv_bless(newRV(sv),SvSTASH(reference));
4484 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4487 if (LocaleCompare(attribute,"compression") == 0)
4489 j=info ? info->image_info->compression : image ?
4490 image->compression : UndefinedCompression;
4492 if (info->image_info->compression == UndefinedCompression)
4493 j=image->compression;
4495 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4498 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4501 if (LocaleCompare(attribute,"colorspace") == 0)
4503 j=image ? image->colorspace : RGBColorspace;
4505 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4508 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4511 if (LocaleCompare(attribute,"colors") == 0)
4513 if (image != (Image *) NULL)
4514 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4515 &image->exception));
4516 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4519 if (LocaleNCompare(attribute,"colormap",8) == 0)
4524 if (image == (Image *) NULL || !image->colormap)
4527 items=sscanf(attribute,"%*[^[][%ld",&j);
4528 if (j > (ssize_t) image->colors)
4530 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
4531 QuantumFormat "," QuantumFormat "," QuantumFormat,
4532 image->colormap[j].red,image->colormap[j].green,
4533 image->colormap[j].blue,image->colormap[j].opacity);
4535 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4538 if (LocaleCompare(attribute,"columns") == 0)
4540 if (image != (Image *) NULL)
4541 s=newSViv((ssize_t) image->columns);
4542 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4545 if (LocaleCompare(attribute,"comment") == 0)
4550 value=GetImageProperty(image,attribute);
4551 if (value != (const char *) NULL)
4553 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4556 if (LocaleCompare(attribute,"copyright") == 0)
4558 s=newSVpv(GetMagickCopyright(),0);
4559 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4569 if (LocaleCompare(attribute,"density") == 0)
4572 geometry[MaxTextExtent];
4574 if (image == (Image *) NULL)
4576 (void) FormatMagickString(geometry,MaxTextExtent,"%.15gx%.15g",
4577 image->x_resolution,image->y_resolution);
4578 s=newSVpv(geometry,0);
4579 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4582 if (LocaleCompare(attribute,"delay") == 0)
4584 if (image != (Image *) NULL)
4585 s=newSViv((ssize_t) image->delay);
4586 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4589 if (LocaleCompare(attribute,"depth") == 0)
4591 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4592 if (image != (Image *) NULL)
4593 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4594 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4597 if (LocaleCompare(attribute,"directory") == 0)
4599 if (image && image->directory)
4600 s=newSVpv(image->directory,0);
4601 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4604 if (LocaleCompare(attribute,"dispose") == 0)
4606 if (image == (Image *) NULL)
4609 s=newSViv(image->dispose);
4611 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4613 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4616 if (LocaleCompare(attribute,"disk") == 0)
4618 s=newSViv(GetMagickResource(DiskResource));
4619 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4622 if (LocaleCompare(attribute,"dither") == 0)
4625 s=newSViv((ssize_t) info->image_info->dither);
4626 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4629 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4631 if (info && info->image_info->server_name)
4632 s=newSVpv(info->image_info->server_name,0);
4633 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4636 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4643 if (LocaleCompare(attribute,"elapsed-time") == 0)
4645 if (image != (Image *) NULL)
4646 s=newSVnv(GetElapsedTime(&image->timer));
4647 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4650 if (LocaleCompare(attribute,"endian") == 0)
4652 j=info ? info->image_info->endian : image ? image->endian :
4655 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4657 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4660 if (LocaleCompare(attribute,"error") == 0)
4662 if (image != (Image *) NULL)
4663 s=newSVnv(image->error.mean_error_per_pixel);
4664 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4667 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4674 if (LocaleCompare(attribute,"filesize") == 0)
4676 if (image != (Image *) NULL)
4677 s=newSViv((ssize_t) GetBlobSize(image));
4678 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4681 if (LocaleCompare(attribute,"filename") == 0)
4683 if (info && info->image_info->filename &&
4684 *info->image_info->filename)
4685 s=newSVpv(info->image_info->filename,0);
4686 if (image != (Image *) NULL)
4687 s=newSVpv(image->filename,0);
4688 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4691 if (LocaleCompare(attribute,"filter") == 0)
4693 s=image ? newSViv(image->filter) : newSViv(0);
4694 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4700 if (LocaleCompare(attribute,"font") == 0)
4702 if (info && info->image_info->font)
4703 s=newSVpv(info->image_info->font,0);
4704 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4707 if (LocaleCompare(attribute,"foreground") == 0)
4709 if (LocaleCompare(attribute,"format") == 0)
4714 magick_info=(const MagickInfo *) NULL;
4715 if (info && (*info->image_info->magick != '\0'))
4716 magick_info=GetMagickInfo(info->image_info->magick,exception);
4717 if (image != (Image *) NULL)
4718 magick_info=GetMagickInfo(image->magick,&image->exception);
4719 if ((magick_info != (const MagickInfo *) NULL) &&
4720 (*magick_info->description != '\0'))
4721 s=newSVpv((char *) magick_info->description,0);
4722 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4725 if (LocaleCompare(attribute,"fuzz") == 0)
4728 s=newSVnv(info->image_info->fuzz);
4729 if (image != (Image *) NULL)
4730 s=newSVnv(image->fuzz);
4731 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4734 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4741 if (LocaleCompare(attribute,"gamma") == 0)
4743 if (image != (Image *) NULL)
4744 s=newSVnv(image->gamma);
4745 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4748 if (LocaleCompare(attribute,"geometry") == 0)
4750 if (image && image->geometry)
4751 s=newSVpv(image->geometry,0);
4752 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4755 if (LocaleCompare(attribute,"gravity") == 0)
4757 s=image ? newSViv(image->gravity) : newSViv(0);
4758 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4761 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4764 if (LocaleCompare(attribute,"green-primary") == 0)
4766 if (image == (Image *) NULL)
4768 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
4769 image->chromaticity.green_primary.x,
4770 image->chromaticity.green_primary.y);
4772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4775 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4782 if (LocaleCompare(attribute,"height") == 0)
4784 if (image != (Image *) NULL)
4785 s=newSViv((ssize_t) image->rows);
4786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4789 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4796 if (LocaleCompare(attribute,"icc") == 0)
4798 if (image != (Image *) NULL)
4803 profile=GetImageProfile(image,"icc");
4804 if (profile != (StringInfo *) NULL)
4805 s=newSVpv((const char *) GetStringInfoDatum(profile),
4806 GetStringInfoLength(profile));
4808 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4811 if (LocaleCompare(attribute,"icm") == 0)
4813 if (image != (Image *) NULL)
4818 profile=GetImageProfile(image,"icm");
4819 if (profile != (const StringInfo *) NULL)
4820 s=newSVpv((const char *) GetStringInfoDatum(profile),
4821 GetStringInfoLength(profile));
4823 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4826 if (LocaleCompare(attribute,"id") == 0)
4828 if (image != (Image *) NULL)
4839 (void) FormatMagickString(key,MaxTextExtent,"%.20g\n",(double)
4841 status=SetImageRegistry(ImageRegistryType,key,image,
4845 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4848 if (LocaleNCompare(attribute,"index",5) == 0)
4851 name[MaxTextExtent];
4860 register const IndexPacket
4863 register const PixelPacket
4869 if (image == (Image *) NULL)
4871 if (image->storage_class != PseudoClass)
4875 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4876 image_view=AcquireCacheView(image);
4877 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4878 if (p != (const PixelPacket *) NULL)
4880 indexes=GetCacheViewVirtualIndexQueue(image_view);
4881 (void) FormatMagickString(name,MaxTextExtent,QuantumFormat,
4882 GetIndexPixelComponent(indexes));
4884 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4886 image_view=DestroyCacheView(image_view);
4889 if (LocaleCompare(attribute,"iptc") == 0)
4891 if (image != (Image *) NULL)
4896 profile=GetImageProfile(image,"iptc");
4897 if (profile != (const StringInfo *) NULL)
4898 s=newSVpv((const char *) GetStringInfoDatum(profile),
4899 GetStringInfoLength(profile));
4901 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4904 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4906 if (image != (Image *) NULL)
4907 s=newSViv((ssize_t) image->iterations);
4908 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4911 if (LocaleCompare(attribute,"interlace") == 0)
4913 j=info ? info->image_info->interlace : image ? image->interlace :
4916 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4919 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4922 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4929 if (LocaleCompare(attribute,"label") == 0)
4934 if (image == (Image *) NULL)
4936 value=GetImageProperty(image,"Label");
4937 if (value != (const char *) NULL)
4939 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4942 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4944 if (image != (Image *) NULL)
4945 s=newSViv((ssize_t) image->iterations);
4946 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4949 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4956 if (LocaleCompare(attribute,"magick") == 0)
4958 if (info && *info->image_info->magick)
4959 s=newSVpv(info->image_info->magick,0);
4960 if (image != (Image *) NULL)
4961 s=newSVpv(image->magick,0);
4962 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4965 if (LocaleCompare(attribute,"map") == 0)
4967 s=newSViv(GetMagickResource(MapResource));
4968 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4971 if (LocaleCompare(attribute,"maximum-error") == 0)
4973 if (image != (Image *) NULL)
4974 s=newSVnv(image->error.normalized_maximum_error);
4975 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4978 if (LocaleCompare(attribute,"memory") == 0)
4980 s=newSViv(GetMagickResource(MemoryResource));
4981 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4984 if (LocaleCompare(attribute,"mean-error") == 0)
4986 if (image != (Image *) NULL)
4987 s=newSVnv(image->error.normalized_mean_error);
4988 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4991 if (LocaleCompare(attribute,"mime") == 0)
4993 if (info && *info->image_info->magick)
4994 s=newSVpv(MagickToMime(info->image_info->magick),0);
4995 if (image != (Image *) NULL)
4996 s=newSVpv(MagickToMime(image->magick),0);
4997 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5000 if (LocaleCompare(attribute,"mattecolor") == 0)
5002 if (image == (Image *) NULL)
5004 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
5005 QuantumFormat "," QuantumFormat "," QuantumFormat,
5006 image->matte_color.red,image->matte_color.green,
5007 image->matte_color.blue,image->matte_color.opacity);
5009 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5012 if (LocaleCompare(attribute,"matte") == 0)
5014 if (image != (Image *) NULL)
5015 s=newSViv((ssize_t) image->matte);
5016 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5019 if (LocaleCompare(attribute,"mime") == 0)
5025 if (info && *info->image_info->magick)
5026 magick=info->image_info->magick;
5027 if (image != (Image *) NULL)
5028 magick=image->magick;
5034 mime=MagickToMime(magick);
5036 mime=(char *) RelinquishMagickMemory(mime);
5038 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5041 if (LocaleCompare(attribute,"monochrome") == 0)
5043 if (image == (Image *) NULL)
5045 j=info ? info->image_info->monochrome :
5046 IsMonochromeImage(image,&image->exception);
5048 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5051 if (LocaleCompare(attribute,"montage") == 0)
5053 if (image && image->montage)
5054 s=newSVpv(image->montage,0);
5055 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5058 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5065 if (LocaleCompare(attribute,"orientation") == 0)
5067 j=info ? info->image_info->orientation : image ?
5068 image->orientation : UndefinedOrientation;
5070 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5073 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5076 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5083 if (LocaleCompare(attribute,"page") == 0)
5085 if (info && info->image_info->page)
5086 s=newSVpv(info->image_info->page,0);
5087 if (image != (Image *) NULL)
5090 geometry[MaxTextExtent];
5092 (void) FormatMagickString(geometry,MaxTextExtent,
5093 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5094 (double) image->page.height,(double) image->page.x,(double)
5096 s=newSVpv(geometry,0);
5098 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5101 if (LocaleCompare(attribute,"page.x") == 0)
5103 if (image != (Image *) NULL)
5104 s=newSViv((ssize_t) image->page.x);
5105 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5108 if (LocaleCompare(attribute,"page.y") == 0)
5110 if (image != (Image *) NULL)
5111 s=newSViv((ssize_t) image->page.y);
5112 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5115 if (LocaleNCompare(attribute,"pixel",5) == 0)
5118 tuple[MaxTextExtent];
5127 register const PixelPacket
5130 register const IndexPacket
5133 if (image == (Image *) NULL)
5137 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5138 p=GetVirtualPixels(image,x,y,1,1,exception);
5139 indexes=GetVirtualIndexQueue(image);
5140 if (image->colorspace != CMYKColorspace)
5141 (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
5142 QuantumFormat "," QuantumFormat "," QuantumFormat,
5143 GetRedPixelComponent(p),GetGreenPixelComponent(p),
5144 GetBluePixelComponent(p),GetOpacityPixelComponent(p));
5146 (void) FormatMagickString(tuple,MaxTextExtent,QuantumFormat ","
5147 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5148 QuantumFormat,GetRedPixelComponent(p),
5149 GetGreenPixelComponent(p),GetBluePixelComponent(p),
5150 GetIndexPixelComponent(indexes),GetOpacityPixelComponent(p));
5152 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5155 if (LocaleCompare(attribute,"pointsize") == 0)
5158 s=newSViv((ssize_t) info->image_info->pointsize);
5159 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5162 if (LocaleCompare(attribute,"preview") == 0)
5164 s=newSViv(info->image_info->preview_type);
5165 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5166 info->image_info->preview_type));
5168 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5171 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5178 if (LocaleCompare(attribute,"quality") == 0)
5181 s=newSViv((ssize_t) info->image_info->quality);
5182 if (image != (Image *) NULL)
5183 s=newSViv((ssize_t) image->quality);
5184 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5187 if (LocaleCompare(attribute,"quantum") == 0)
5190 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5191 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5194 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5201 if (LocaleCompare(attribute,"rendering-intent") == 0)
5203 s=newSViv(image->rendering_intent);
5204 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5205 image->rendering_intent));
5207 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5210 if (LocaleCompare(attribute,"red-primary") == 0)
5212 if (image == (Image *) NULL)
5214 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
5215 image->chromaticity.red_primary.x,
5216 image->chromaticity.red_primary.y);
5218 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5221 if (LocaleCompare(attribute,"rows") == 0)
5223 if (image != (Image *) NULL)
5224 s=newSViv((ssize_t) image->rows);
5225 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5228 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5235 if (LocaleCompare(attribute,"sampling-factor") == 0)
5237 if (info && info->image_info->sampling_factor)
5238 s=newSVpv(info->image_info->sampling_factor,0);
5239 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5242 if (LocaleCompare(attribute,"subimage") == 0)
5245 s=newSViv((ssize_t) info->image_info->subimage);
5246 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5249 if (LocaleCompare(attribute,"subrange") == 0)
5252 s=newSViv((ssize_t) info->image_info->subrange);
5253 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5256 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5258 if (info && info->image_info->server_name)
5259 s=newSVpv(info->image_info->server_name,0);
5260 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5263 if (LocaleCompare(attribute,"size") == 0)
5265 if (info && info->image_info->size)
5266 s=newSVpv(info->image_info->size,0);
5267 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5270 if (LocaleCompare(attribute,"scene") == 0)
5272 if (image != (Image *) NULL)
5273 s=newSViv((ssize_t) image->scene);
5274 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5277 if (LocaleCompare(attribute,"scenes") == 0)
5279 if (image != (Image *) NULL)
5280 s=newSViv((ssize_t) info->image_info->number_scenes);
5281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5284 if (LocaleCompare(attribute,"signature") == 0)
5289 if (image == (Image *) NULL)
5291 (void) SignatureImage(image);
5292 value=GetImageProperty(image,"Signature");
5293 if (value != (const char *) NULL)
5295 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5298 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5305 if (LocaleCompare(attribute,"taint") == 0)
5307 if (image != (Image *) NULL)
5308 s=newSViv((ssize_t) IsTaintImage(image));
5309 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5312 if (LocaleCompare(attribute,"tile") == 0)
5314 if (info && info->image_info->tile)
5315 s=newSVpv(info->image_info->tile,0);
5316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5319 if (LocaleCompare(attribute,"texture") == 0)
5321 if (info && info->image_info->texture)
5322 s=newSVpv(info->image_info->texture,0);
5323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5326 if (LocaleCompare(attribute,"total-ink-density") == 0)
5328 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5329 if (image != (Image *) NULL)
5330 s=newSVnv(GetImageTotalInkDensity(image));
5331 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5334 if (LocaleCompare(attribute,"transparent-color") == 0)
5336 if (image == (Image *) NULL)
5338 (void) FormatMagickString(color,MaxTextExtent,QuantumFormat ","
5339 QuantumFormat "," QuantumFormat "," QuantumFormat,
5340 image->transparent_color.red,image->transparent_color.green,
5341 image->transparent_color.blue,image->transparent_color.opacity);
5343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5346 if (LocaleCompare(attribute,"type") == 0)
5348 if (image == (Image *) NULL)
5350 j=(ssize_t) GetImageType(image,&image->exception);
5352 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5354 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5357 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5364 if (LocaleCompare(attribute,"units") == 0)
5366 j=info ? info->image_info->units : image ? image->units :
5367 UndefinedResolution;
5368 if (info && (info->image_info->units == UndefinedResolution))
5371 if (j == UndefinedResolution)
5372 s=newSVpv("undefined units",0);
5374 if (j == PixelsPerInchResolution)
5375 s=newSVpv("pixels / inch",0);
5377 s=newSVpv("pixels / centimeter",0);
5378 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5381 if (LocaleCompare(attribute,"user-time") == 0)
5383 if (image != (Image *) NULL)
5384 s=newSVnv(GetUserTime(&image->timer));
5385 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5395 if (LocaleCompare(attribute,"verbose") == 0)
5398 s=newSViv((ssize_t) info->image_info->verbose);
5399 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5402 if (LocaleCompare(attribute,"version") == 0)
5404 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5405 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5408 if (LocaleCompare(attribute,"view") == 0)
5410 if (info && info->image_info->view)
5411 s=newSVpv(info->image_info->view,0);
5412 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5415 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5417 if (image == (Image *) NULL)
5419 j=(ssize_t) GetImageVirtualPixelMethod(image);
5421 (void) sv_setpv(s,CommandOptionToMnemonic(
5422 MagickVirtualPixelOptions,j));
5424 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5427 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5434 if (LocaleCompare(attribute,"white-point") == 0)
5436 if (image == (Image *) NULL)
5438 (void) FormatMagickString(color,MaxTextExtent,"%.15g,%.15g",
5439 image->chromaticity.white_point.x,
5440 image->chromaticity.white_point.y);
5442 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5445 if (LocaleCompare(attribute,"width") == 0)
5447 if (image != (Image *) NULL)
5448 s=newSViv((ssize_t) image->columns);
5449 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5452 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5459 if (LocaleCompare(attribute,"x-resolution") == 0)
5461 if (image != (Image *) NULL)
5462 s=newSVnv(image->x_resolution);
5463 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5473 if (LocaleCompare(attribute,"y-resolution") == 0)
5475 if (image != (Image *) NULL)
5476 s=newSVnv(image->y_resolution);
5477 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5480 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5487 if (image == (Image *) NULL)
5488 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5492 value=GetImageProperty(image,attribute);
5493 if (value != (const char *) NULL)
5496 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5499 if (*attribute != '%')
5500 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5507 meta=InterpretImageProperties(info ? info->image_info :
5508 (ImageInfo *) NULL,image,attribute);
5510 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5511 meta=(char *) RelinquishMagickMemory(meta);
5515 exception=DestroyExceptionInfo(exception);
5516 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5520 ###############################################################################
5524 # G e t A u t h e n t i c P i x e l s #
5528 ###############################################################################
5532 GetAuthenticPixels(ref,...)
5533 Image::Magick ref = NO_INIT
5535 getauthenticpixels = 1
5565 PERL_UNUSED_VAR(ref);
5566 PERL_UNUSED_VAR(ix);
5567 exception=AcquireExceptionInfo();
5568 perl_exception=newSVpv("",0);
5569 if (sv_isobject(ST(0)) == 0)
5571 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5575 reference=SvRV(ST(0));
5577 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5578 if (image == (Image *) NULL)
5580 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5587 region.width=image->columns;
5590 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5591 for (i=2; i < items; i+=2)
5593 attribute=(char *) SvPV(ST(i-1),na);
5599 if (LocaleCompare(attribute,"geometry") == 0)
5601 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5604 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5611 if (LocaleCompare(attribute,"height") == 0)
5613 region.height=SvIV(ST(i));
5616 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5623 if (LocaleCompare(attribute,"x") == 0)
5625 region.x=SvIV(ST(i));
5628 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5635 if (LocaleCompare(attribute,"y") == 0)
5637 region.y=SvIV(ST(i));
5640 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5647 if (LocaleCompare(attribute,"width") == 0)
5649 region.width=SvIV(ST(i));
5652 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5658 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5659 region.height,exception);
5660 if (blob != (void *) NULL)
5664 InheritPerlException(exception,perl_exception);
5665 exception=DestroyExceptionInfo(exception);
5666 SvREFCNT_dec(perl_exception); /* throw away all errors */
5675 ###############################################################################
5679 # G e t V i r t u a l P i x e l s #
5683 ###############################################################################
5687 GetVirtualPixels(ref,...)
5688 Image::Magick ref = NO_INIT
5690 getvirtualpixels = 1
5691 AcquireImagePixels = 2
5692 acquireimagepixels = 3
5720 PERL_UNUSED_VAR(ref);
5721 PERL_UNUSED_VAR(ix);
5722 exception=AcquireExceptionInfo();
5723 perl_exception=newSVpv("",0);
5724 if (sv_isobject(ST(0)) == 0)
5726 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5730 reference=SvRV(ST(0));
5732 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5733 if (image == (Image *) NULL)
5735 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5742 region.width=image->columns;
5745 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5746 for (i=2; i < items; i+=2)
5748 attribute=(char *) SvPV(ST(i-1),na);
5754 if (LocaleCompare(attribute,"geometry") == 0)
5756 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5759 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5766 if (LocaleCompare(attribute,"height") == 0)
5768 region.height=SvIV(ST(i));
5771 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5778 if (LocaleCompare(attribute,"x") == 0)
5780 region.x=SvIV(ST(i));
5783 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5790 if (LocaleCompare(attribute,"y") == 0)
5792 region.y=SvIV(ST(i));
5795 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5802 if (LocaleCompare(attribute,"width") == 0)
5804 region.width=SvIV(ST(i));
5807 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5813 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5814 region.height,exception);
5815 if (blob != (void *) NULL)
5819 InheritPerlException(exception,perl_exception);
5820 exception=DestroyExceptionInfo(exception);
5821 SvREFCNT_dec(perl_exception); /* throw away all errors */
5824 RETVAL = (void *) blob;
5830 ###############################################################################
5834 # G e t A u t h e n t i c I n d e x Q u e u e #
5838 ###############################################################################
5842 GetAuthenticIndexQueue(ref,...)
5843 Image::Magick ref = NO_INIT
5845 getauthenticindexqueue = 1
5866 PERL_UNUSED_VAR(ref);
5867 PERL_UNUSED_VAR(ix);
5868 exception=AcquireExceptionInfo();
5869 perl_exception=newSVpv("",0);
5870 if (sv_isobject(ST(0)) == 0)
5872 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5876 reference=SvRV(ST(0));
5878 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5879 if (image == (Image *) NULL)
5881 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5886 blob=(void *) GetAuthenticIndexQueue(image);
5887 if (blob != (void *) NULL)
5891 InheritPerlException(exception,perl_exception);
5892 exception=DestroyExceptionInfo(exception);
5893 SvREFCNT_dec(perl_exception); /* throw away all errors */
5902 ###############################################################################
5906 # G e t V i r t u a l I n d e x Q u e u e #
5910 ###############################################################################
5914 GetVirtualIndexQueue(ref,...)
5915 Image::Magick ref = NO_INIT
5917 getvirtualindexqueue = 1
5936 PERL_UNUSED_VAR(ref);
5937 PERL_UNUSED_VAR(ix);
5938 exception=AcquireExceptionInfo();
5939 perl_exception=newSVpv("",0);
5940 if (sv_isobject(ST(0)) == 0)
5942 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5946 reference=SvRV(ST(0));
5948 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5949 if (image == (Image *) NULL)
5951 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5956 blob=(void *) GetVirtualIndexQueue(image);
5957 if (blob != (void *) NULL)
5961 InheritPerlException(exception,perl_exception);
5962 exception=DestroyExceptionInfo(exception);
5963 SvREFCNT_dec(perl_exception); /* throw away all errors */
5972 ###############################################################################
5976 # H i s t o g r a m #
5980 ###############################################################################
5985 Image::Magick ref=NO_INIT
5996 message[MaxTextExtent];
6027 PERL_UNUSED_VAR(ref);
6028 PERL_UNUSED_VAR(ix);
6029 exception=AcquireExceptionInfo();
6030 perl_exception=newSVpv("",0);
6032 if (sv_isobject(ST(0)) == 0)
6034 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6038 reference=SvRV(ST(0));
6039 hv=SvSTASH(reference);
6041 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6043 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6044 if (image == (Image *) NULL)
6046 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6050 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6052 for ( ; image; image=image->next)
6054 histogram=GetImageHistogram(image,&number_colors,&image->exception);
6055 if (histogram == (ColorPacket *) NULL)
6057 count+=(ssize_t) number_colors;
6059 for (i=0; i < (ssize_t) number_colors; i++)
6061 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
6062 histogram[i].pixel.red);
6063 PUSHs(sv_2mortal(newSVpv(message,0)));
6064 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
6065 histogram[i].pixel.green);
6066 PUSHs(sv_2mortal(newSVpv(message,0)));
6067 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
6068 histogram[i].pixel.blue);
6069 PUSHs(sv_2mortal(newSVpv(message,0)));
6070 if (image->colorspace == CMYKColorspace)
6072 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
6073 histogram[i].index);
6074 PUSHs(sv_2mortal(newSVpv(message,0)));
6076 (void) FormatMagickString(message,MaxTextExtent,QuantumFormat,
6077 histogram[i].pixel.opacity);
6078 PUSHs(sv_2mortal(newSVpv(message,0)));
6079 (void) FormatMagickString(message,MaxTextExtent,"%.20g",(double)
6080 histogram[i].count);
6081 PUSHs(sv_2mortal(newSVpv(message,0)));
6083 histogram=(ColorPacket *) RelinquishMagickMemory(histogram);
6087 InheritPerlException(exception,perl_exception);
6088 exception=DestroyExceptionInfo(exception);
6089 SvREFCNT_dec(perl_exception);
6093 ###############################################################################
6101 ###############################################################################
6106 Image::Magick ref=NO_INIT
6133 register const IndexPacket
6136 register const PixelPacket
6150 *reference; /* reference is the SV* of ref=SvIV(reference) */
6152 PERL_UNUSED_VAR(ref);
6153 PERL_UNUSED_VAR(ix);
6154 exception=AcquireExceptionInfo();
6155 perl_exception=newSVpv("",0);
6156 reference=SvRV(ST(0));
6157 av=(AV *) reference;
6158 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6160 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6161 if (image == (Image *) NULL)
6163 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6167 channel=DefaultChannels;
6168 normalize=MagickTrue;
6171 region.width=image->columns;
6174 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6175 for (i=2; i < items; i+=2)
6177 attribute=(char *) SvPV(ST(i-1),na);
6183 if (LocaleCompare(attribute,"channel") == 0)
6188 option=ParseChannelOption(SvPV(ST(i),na));
6191 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6195 channel=(ChannelType) option;
6198 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6205 if (LocaleCompare(attribute,"geometry") == 0)
6207 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6210 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6217 if (LocaleCompare(attribute,"normalize") == 0)
6219 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6223 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6227 normalize=option != 0 ? MagickTrue : MagickFalse;
6230 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6237 if (LocaleCompare(attribute,"x") == 0)
6239 region.x=SvIV(ST(i));
6242 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6249 if (LocaleCompare(attribute,"y") == 0)
6251 region.y=SvIV(ST(i));
6254 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6266 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6267 if (p == (const PixelPacket *) NULL)
6274 indexes=GetVirtualIndexQueue(image);
6276 if (normalize != MagickFalse)
6277 scale=1.0/QuantumRange;
6278 if ((channel & RedChannel) != 0)
6279 PUSHs(sv_2mortal(newSVnv(scale*GetRedPixelComponent(p))));
6280 if ((channel & GreenChannel) != 0)
6281 PUSHs(sv_2mortal(newSVnv(scale*GetGreenPixelComponent(p))));
6282 if ((channel & BlueChannel) != 0)
6283 PUSHs(sv_2mortal(newSVnv(scale*GetBluePixelComponent(p))));
6284 if (((channel & IndexChannel) != 0) &&
6285 (image->colorspace == CMYKColorspace))
6286 PUSHs(sv_2mortal(newSVnv(scale*GetIndexPixelComponent(indexes))));
6287 if ((channel & OpacityChannel) != 0)
6288 PUSHs(sv_2mortal(newSVnv(scale*GetOpacityPixelComponent(p))));
6292 InheritPerlException(exception,perl_exception);
6293 exception=DestroyExceptionInfo(exception);
6294 SvREFCNT_dec(perl_exception);
6298 ###############################################################################
6302 # G e t P i x e l s #
6306 ###############################################################################
6311 Image::Magick ref=NO_INIT
6350 *reference; /* reference is the SV* of ref=SvIV(reference) */
6352 PERL_UNUSED_VAR(ref);
6353 PERL_UNUSED_VAR(ix);
6354 exception=AcquireExceptionInfo();
6355 perl_exception=newSVpv("",0);
6356 reference=SvRV(ST(0));
6357 av=(AV *) reference;
6358 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6360 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6361 if (image == (Image *) NULL)
6363 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6368 if (image->matte != MagickFalse)
6370 if (image->colorspace == CMYKColorspace)
6373 if (image->matte != MagickFalse)
6376 normalize=MagickFalse;
6379 region.width=image->columns;
6382 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6383 for (i=2; i < items; i+=2)
6385 attribute=(char *) SvPV(ST(i-1),na);
6391 if (LocaleCompare(attribute,"geometry") == 0)
6393 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6396 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6403 if (LocaleCompare(attribute,"height") == 0)
6405 region.height=SvIV(ST(i));
6408 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6415 if (LocaleCompare(attribute,"map") == 0)
6420 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6427 if (LocaleCompare(attribute,"normalize") == 0)
6429 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6433 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6437 normalize=option != 0 ? MagickTrue : MagickFalse;
6440 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6447 if (LocaleCompare(attribute,"width") == 0)
6449 region.width=SvIV(ST(i));
6452 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6459 if (LocaleCompare(attribute,"x") == 0)
6461 region.x=SvIV(ST(i));
6464 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6471 if (LocaleCompare(attribute,"y") == 0)
6473 region.y=SvIV(ST(i));
6476 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6482 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6488 if (normalize != MagickFalse)
6493 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6494 region.height*sizeof(*pixels));
6495 if (pixels == (float *) NULL)
6497 ThrowPerlException(exception,ResourceLimitError,
6498 "MemoryAllocationFailed",PackageName);
6501 status=ExportImagePixels(image,region.x,region.y,region.width,
6502 region.height,map,FloatPixel,pixels,exception);
6503 if (status == MagickFalse)
6507 EXTEND(sp,strlen(map)*region.width*region.height);
6508 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6509 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6511 pixels=(float *) RelinquishMagickMemory(pixels);
6518 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6519 region.height*sizeof(*pixels));
6520 if (pixels == (Quantum *) NULL)
6522 ThrowPerlException(exception,ResourceLimitError,
6523 "MemoryAllocationFailed",PackageName);
6526 status=ExportImagePixels(image,region.x,region.y,region.width,
6527 region.height,map,QuantumPixel,pixels,exception);
6528 if (status == MagickFalse)
6532 EXTEND(sp,strlen(map)*region.width*region.height);
6533 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6534 PUSHs(sv_2mortal(newSViv(pixels[i])));
6536 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6540 InheritPerlException(exception,perl_exception);
6541 exception=DestroyExceptionInfo(exception);
6542 SvREFCNT_dec(perl_exception);
6546 ###############################################################################
6550 # I m a g e T o B l o b #
6554 ###############################################################################
6558 ImageToBlob(ref,...)
6559 Image::Magick ref=NO_INIT
6568 filename[MaxTextExtent];
6597 PERL_UNUSED_VAR(ref);
6598 PERL_UNUSED_VAR(ix);
6599 exception=AcquireExceptionInfo();
6600 perl_exception=newSVpv("",0);
6601 package_info=(struct PackageInfo *) NULL;
6602 if (sv_isobject(ST(0)) == 0)
6604 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6608 reference=SvRV(ST(0));
6609 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6610 if (image == (Image *) NULL)
6612 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6616 package_info=ClonePackageInfo(info,exception);
6617 for (i=2; i < items; i+=2)
6618 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6619 (void) CopyMagickString(filename,package_info->image_info->filename,
6622 for (next=image; next; next=next->next)
6624 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6625 next->scene=scene++;
6627 SetImageInfo(package_info->image_info,(unsigned int)
6628 GetImageListLength(image),&image->exception);
6629 EXTEND(sp,(ssize_t) GetImageListLength(image));
6630 for ( ; image; image=image->next)
6633 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6634 if (blob != (char *) NULL)
6636 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6637 blob=(unsigned char *) RelinquishMagickMemory(blob);
6639 if (package_info->image_info->adjoin)
6644 if (package_info != (struct PackageInfo *) NULL)
6645 DestroyPackageInfo(package_info);
6646 InheritPerlException(exception,perl_exception);
6647 exception=DestroyExceptionInfo(exception);
6648 SvREFCNT_dec(perl_exception); /* throw away all errors */
6652 ###############################################################################
6660 ###############################################################################
6665 Image::Magick ref=NO_INIT
6669 OptimizeImageLayers = 3
6671 optimizeimagelayers = 5
6716 PERL_UNUSED_VAR(ref);
6717 PERL_UNUSED_VAR(ix);
6718 exception=AcquireExceptionInfo();
6719 perl_exception=newSVpv("",0);
6721 if (sv_isobject(ST(0)) == 0)
6723 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6727 reference=SvRV(ST(0));
6728 hv=SvSTASH(reference);
6730 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6732 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6733 if (image == (Image *) NULL)
6735 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6739 compose=image->compose;
6741 method=OptimizeLayer;
6742 for (i=2; i < items; i+=2)
6744 attribute=(char *) SvPV(ST(i-1),na);
6750 if (LocaleCompare(attribute,"compose") == 0)
6752 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6753 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6756 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6760 compose=(CompositeOperator) sp;
6763 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6770 if (LocaleCompare(attribute,"dither") == 0)
6772 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6773 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
6776 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6780 dither=(MagickBooleanType) sp;
6783 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6790 if (LocaleCompare(attribute,"method") == 0)
6792 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6796 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6800 method=(ImageLayerMethod) option;
6803 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6809 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6815 layers=(Image *) NULL;
6818 case CompareAnyLayer:
6819 case CompareClearLayer:
6820 case CompareOverlayLayer:
6823 layers=CompareImageLayers(image,method,exception);
6830 layers=MergeImageLayers(image,method,exception);
6835 layers=DisposeImages(image,exception);
6838 case OptimizeImageLayer:
6840 layers=OptimizeImageLayers(image,exception);
6843 case OptimizePlusLayer:
6845 layers=OptimizePlusImageLayers(image,exception);
6848 case OptimizeTransLayer:
6850 OptimizeImageTransparency(image,exception);
6851 InheritException(&(image->exception),exception);
6854 case RemoveDupsLayer:
6856 RemoveDuplicateLayers(&image,exception);
6857 InheritException(&(image->exception),exception);
6860 case RemoveZeroLayer:
6862 RemoveZeroDelayLayers(&image,exception);
6863 InheritException(&(image->exception),exception);
6872 General Purpose, GIF Animation Optimizer.
6874 layers=CoalesceImages(image,exception);
6875 if (layers == (Image *) NULL)
6877 InheritException(&(layers->exception),exception);
6879 layers=OptimizeImageLayers(image,exception);
6880 if (layers == (Image *) NULL)
6882 InheritException(&(layers->exception),exception);
6883 image=DestroyImageList(image);
6885 layers=(Image *) NULL;
6886 OptimizeImageTransparency(image,exception);
6887 InheritException(&(image->exception),exception);
6888 quantize_info=AcquireQuantizeInfo(info->image_info);
6889 (void) RemapImages(quantize_info,image,(Image *) NULL);
6890 quantize_info=DestroyQuantizeInfo(quantize_info);
6893 case CompositeLayer:
6902 Split image sequence at the first 'NULL:' image.
6905 while (source != (Image *) NULL)
6907 source=GetNextImageInList(source);
6908 if ((source != (Image *) NULL) &&
6909 (LocaleCompare(source->magick,"NULL") == 0))
6912 if (source != (Image *) NULL)
6914 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6915 (GetNextImageInList(source) == (Image *) NULL))
6916 source=(Image *) NULL;
6920 Separate the two lists, junk the null: image.
6922 source=SplitImageList(source->previous);
6923 DeleteImageFromList(&source);
6926 if (source == (Image *) NULL)
6928 (void) ThrowMagickException(exception,GetMagickModule(),
6929 OptionError,"MissingNullSeparator","layers Composite");
6933 Adjust offset with gravity and virtual canvas.
6935 SetGeometry(image,&geometry);
6936 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6937 geometry.width=source->page.width != 0 ? source->page.width :
6939 geometry.height=source->page.height != 0 ? source->page.height :
6941 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6942 image->columns,image->page.height != 0 ? image->page.height :
6943 image->rows,image->gravity,&geometry);
6944 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6945 source=DestroyImageList(source);
6946 InheritException(&(image->exception),exception);
6950 if (layers != (Image *) NULL)
6952 InheritException(&(layers->exception),exception);
6955 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6957 for ( ; image; image=image->next)
6959 AddImageToRegistry(sv,image);
6961 av_push(av,sv_bless(rv,hv));
6964 exception=DestroyExceptionInfo(exception);
6966 SvREFCNT_dec(perl_exception);
6970 InheritPerlException(exception,perl_exception);
6971 exception=DestroyExceptionInfo(exception);
6972 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6973 SvPOK_on(perl_exception);
6974 ST(0)=sv_2mortal(perl_exception);
6979 ###############################################################################
6983 # M a g i c k T o M i m e #
6987 ###############################################################################
6991 MagickToMime(ref,name)
6992 Image::Magick ref=NO_INIT
7001 PERL_UNUSED_VAR(ref);
7002 PERL_UNUSED_VAR(ix);
7003 mime=MagickToMime(name);
7004 RETVAL=newSVpv(mime,0);
7005 mime=(char *) RelinquishMagickMemory(mime);
7011 ###############################################################################
7019 ###############################################################################
7024 Image::Magick ref=NO_INIT
7061 MedianFilterImage = 36
7067 ReduceNoiseImage = 42
7093 ColorFloodfillImage= 68
7099 CycleColormapImage = 74
7109 MatteFloodfillImage= 84
7117 NumberColorsImage = 92
7127 SignatureImage = 102
7137 TransparentImage = 112
7139 ThresholdImage = 114
7153 DeconstructImage = 130
7155 GaussianBlurImage = 132
7161 UnsharpMaskImage = 138
7163 MotionBlurImage = 140
7165 OrderedDitherImage = 142
7172 AffineTransform = 149
7173 AffineTransformImage = 150
7175 DifferenceImage = 152
7176 AdaptiveThreshold = 153
7177 AdaptiveThresholdImage = 154
7182 BlackThreshold = 159
7183 BlackThresholdImage= 160
7184 WhiteThreshold = 161
7185 WhiteThresholdImage= 162
7187 RadialBlurImage = 164
7189 ThumbnailImage = 166
7199 PosterizeImage = 176
7205 SepiaToneImage = 182
7206 SigmoidalContrast = 183
7207 SigmoidalContrastImage = 184
7212 ContrastStretch = 189
7213 ContrastStretchImage = 190
7218 AdaptiveSharpen = 195
7219 AdaptiveSharpenImage = 196
7221 TransposeImage = 198
7223 TransverseImage = 200
7225 AutoOrientImage = 202
7227 AdaptiveBlurImage = 204
7231 UniqueColorsImage = 208
7232 AdaptiveResize = 209
7233 AdaptiveResizeImage= 210
7237 LinearStretchImage = 214
7244 FloodfillPaint = 221
7245 FloodfillPaintImage= 222
7251 LiquidRescaleImage = 228
7261 SparseColorImage = 238
7265 SelectiveBlurImage = 242
7269 BlueShiftImage = 246
7270 ForwardFourierTransform = 247
7271 ForwardFourierTransformImage = 248
7272 InverseFourierTransform = 249
7273 InverseFourierTransformImage = 250
7274 ColorDecisionList = 251
7275 ColorDecisionListImage = 252
7277 AutoGammaImage = 254
7279 AutoLevelImage = 256
7281 LevelColorsImage = 258
7286 BrightnessContrast = 263
7287 BrightnessContrastImage = 264
7289 MorphologyImage = 266
7291 ColorMatrixImage = 268
7297 StatisticImage = 274
7306 attribute_flag[MaxArguments],
7307 message[MaxTextExtent];
7367 argument_list[MaxArguments];
7369 PERL_UNUSED_VAR(ref);
7370 PERL_UNUSED_VAR(ix);
7371 exception=AcquireExceptionInfo();
7372 perl_exception=newSVpv("",0);
7373 reference_vector=NULL;
7377 if (sv_isobject(ST(0)) == 0)
7379 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7383 reference=SvRV(ST(0));
7384 region_info.width=0;
7385 region_info.height=0;
7388 region_image=(Image *) NULL;
7389 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7390 if (ix && (ix != 666))
7393 Called as Method(...)
7396 rp=(&Methods[ix-1]);
7402 Called as Mogrify("Method",...)
7404 attribute=(char *) SvPV(ST(1),na);
7407 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7408 attribute=(char *) SvPV(ST(2),na);
7411 for (rp=Methods; ; rp++)
7413 if (rp >= EndOf(Methods))
7415 ThrowPerlException(exception,OptionError,
7416 "UnrecognizedPerlMagickMethod",attribute);
7419 if (strEQcase(attribute,rp->name))
7425 if (image == (Image *) NULL)
7427 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7430 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7431 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7432 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7449 pp=(Arguments *) NULL;
7457 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7459 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7461 if (strEQcase(attribute,qq->method) > ssize_test)
7464 ssize_test=strEQcase(attribute,qq->method);
7467 if (pp == (Arguments *) NULL)
7469 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7471 goto continue_outer_loop;
7473 al=(&argument_list[pp-rp->arguments]);
7476 case ArrayReference:
7478 if (SvTYPE(sv) != SVt_RV)
7480 (void) FormatMagickString(message,MaxTextExtent,
7481 "invalid %.60s value",pp->method);
7482 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7483 goto continue_outer_loop;
7485 al->array_reference=SvRV(sv);
7490 al->real_reference=SvNV(sv);
7495 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7498 case ImageReference:
7500 if (!sv_isobject(sv) ||
7501 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7502 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7504 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7510 case IntegerReference:
7512 al->integer_reference=SvIV(sv);
7515 case StringReference:
7517 al->string_reference=(char *) SvPV(sv,al->length);
7518 if (sv_isobject(sv))
7519 al->image_reference=SetupList(aTHX_ SvRV(sv),
7520 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7526 Is a string; look up name.
7528 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7530 al->string_reference=(char *) SvPV(sv,al->length);
7531 al->integer_reference=(-1);
7534 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7535 MagickFalse,SvPV(sv,na));
7536 if (pp->type == MagickChannelOptions)
7537 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7538 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7540 (void) FormatMagickString(message,MaxTextExtent,
7541 "invalid %.60s value",pp->method);
7542 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7543 goto continue_outer_loop;
7548 attribute_flag[pp-rp->arguments]++;
7549 continue_outer_loop: ;
7551 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7552 pv=reference_vector;
7553 SetGeometryInfo(&geometry_info);
7554 channel=DefaultChannels;
7555 for (next=image; next; next=next->next)
7558 SetGeometry(image,&geometry);
7559 if ((region_info.width*region_info.height) != 0)
7562 image=CropImage(image,®ion_info,exception);
7568 (void) FormatMagickString(message,MaxTextExtent,"%.20g",(double) ix);
7569 ThrowPerlException(exception,OptionError,
7570 "UnrecognizedPerlMagickMethod",message);
7573 case 1: /* Comment */
7575 if (attribute_flag[0] == 0)
7576 argument_list[0].string_reference=(char *) NULL;
7577 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7578 info ? info->image_info : (ImageInfo *) NULL,image,
7579 argument_list[0].string_reference));
7584 if (attribute_flag[0] == 0)
7585 argument_list[0].string_reference=(char *) NULL;
7586 (void) SetImageProperty(image,"label",InterpretImageProperties(
7587 info ? info->image_info : (ImageInfo *) NULL,image,
7588 argument_list[0].string_reference));
7591 case 3: /* AddNoise */
7593 if (attribute_flag[0] == 0)
7594 argument_list[0].integer_reference=UniformNoise;
7595 if (attribute_flag[1] != 0)
7596 channel=(ChannelType) argument_list[1].integer_reference;
7597 image=AddNoiseImageChannel(image,channel,(NoiseType)
7598 argument_list[0].integer_reference,exception);
7601 case 4: /* Colorize */
7606 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7607 if (attribute_flag[0] != 0)
7608 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7610 if (attribute_flag[1] == 0)
7611 argument_list[1].string_reference="100%";
7612 image=ColorizeImage(image,argument_list[1].string_reference,target,
7616 case 5: /* Border */
7620 if (attribute_flag[0] != 0)
7622 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7623 &geometry,exception);
7624 if ((flags & HeightValue) == 0)
7625 geometry.height=geometry.width;
7627 if (attribute_flag[1] != 0)
7628 geometry.width=argument_list[1].integer_reference;
7629 if (attribute_flag[2] != 0)
7630 geometry.height=argument_list[2].integer_reference;
7631 if (attribute_flag[3] != 0)
7632 QueryColorDatabase(argument_list[3].string_reference,
7633 &image->border_color,exception);
7634 if (attribute_flag[4] != 0)
7635 QueryColorDatabase(argument_list[4].string_reference,
7636 &image->border_color,exception);
7637 if (attribute_flag[5] != 0)
7638 QueryColorDatabase(argument_list[5].string_reference,
7639 &image->border_color,exception);
7640 if (attribute_flag[6] != 0)
7641 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7642 image=BorderImage(image,&geometry,exception);
7647 if (attribute_flag[0] != 0)
7649 flags=ParseGeometry(argument_list[0].string_reference,
7651 if ((flags & SigmaValue) == 0)
7652 geometry_info.sigma=1.0;
7654 if (attribute_flag[1] != 0)
7655 geometry_info.rho=argument_list[1].real_reference;
7656 if (attribute_flag[2] != 0)
7657 geometry_info.sigma=argument_list[2].real_reference;
7658 if (attribute_flag[3] != 0)
7659 channel=(ChannelType) argument_list[3].integer_reference;
7660 image=BlurImageChannel(image,channel,geometry_info.rho,
7661 geometry_info.sigma,exception);
7666 if (attribute_flag[0] != 0)
7667 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7668 &geometry,exception);
7669 if (attribute_flag[1] != 0)
7670 geometry.width=argument_list[1].integer_reference;
7671 if (attribute_flag[2] != 0)
7672 geometry.height=argument_list[2].integer_reference;
7673 if (attribute_flag[3] != 0)
7674 geometry.x=argument_list[3].integer_reference;
7675 if (attribute_flag[4] != 0)
7676 geometry.y=argument_list[4].integer_reference;
7677 image=ChopImage(image,&geometry,exception);
7682 if (attribute_flag[6] != 0)
7683 image->gravity=(GravityType) argument_list[6].integer_reference;
7684 if (attribute_flag[0] != 0)
7685 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7686 &geometry,exception);
7687 if (attribute_flag[1] != 0)
7688 geometry.width=argument_list[1].integer_reference;
7689 if (attribute_flag[2] != 0)
7690 geometry.height=argument_list[2].integer_reference;
7691 if (attribute_flag[3] != 0)
7692 geometry.x=argument_list[3].integer_reference;
7693 if (attribute_flag[4] != 0)
7694 geometry.y=argument_list[4].integer_reference;
7695 if (attribute_flag[5] != 0)
7697 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7698 image=CropImage(image,&geometry,exception);
7701 case 9: /* Despeckle */
7703 image=DespeckleImage(image,exception);
7708 if (attribute_flag[0] != 0)
7709 geometry_info.rho=argument_list[0].real_reference;
7710 image=EdgeImage(image,geometry_info.rho,exception);
7713 case 11: /* Emboss */
7715 if (attribute_flag[0] != 0)
7717 flags=ParseGeometry(argument_list[0].string_reference,
7719 if ((flags & SigmaValue) == 0)
7720 geometry_info.sigma=1.0;
7722 if (attribute_flag[1] != 0)
7723 geometry_info.rho=argument_list[1].real_reference;
7724 if (attribute_flag[2] != 0)
7725 geometry_info.sigma=argument_list[2].real_reference;
7726 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7730 case 12: /* Enhance */
7732 image=EnhanceImage(image,exception);
7737 image=FlipImage(image,exception);
7742 image=FlopImage(image,exception);
7745 case 15: /* Frame */
7750 if (attribute_flag[0] != 0)
7752 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7753 &geometry,exception);
7754 if ((flags & HeightValue) == 0)
7755 geometry.height=geometry.width;
7756 frame_info.width=geometry.width;
7757 frame_info.height=geometry.height;
7758 frame_info.outer_bevel=geometry.x;
7759 frame_info.inner_bevel=geometry.y;
7761 if (attribute_flag[1] != 0)
7762 frame_info.width=argument_list[1].integer_reference;
7763 if (attribute_flag[2] != 0)
7764 frame_info.height=argument_list[2].integer_reference;
7765 if (attribute_flag[3] != 0)
7766 frame_info.inner_bevel=argument_list[3].integer_reference;
7767 if (attribute_flag[4] != 0)
7768 frame_info.outer_bevel=argument_list[4].integer_reference;
7769 if (attribute_flag[5] != 0)
7770 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7772 if (attribute_flag[6] != 0)
7773 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7775 frame_info.x=(ssize_t) frame_info.width;
7776 frame_info.y=(ssize_t) frame_info.height;
7777 frame_info.width=image->columns+2*frame_info.x;
7778 frame_info.height=image->rows+2*frame_info.y;
7779 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7780 image->matte_color=fill_color;
7781 if (attribute_flag[7] != 0)
7782 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7783 image=FrameImage(image,&frame_info,exception);
7786 case 16: /* Implode */
7788 if (attribute_flag[0] == 0)
7789 argument_list[0].real_reference=0.5;
7790 if (attribute_flag[1] != 0)
7791 image->interpolate=(InterpolatePixelMethod)
7792 argument_list[1].integer_reference;
7793 image=ImplodeImage(image,argument_list[0].real_reference,
7797 case 17: /* Magnify */
7799 image=MagnifyImage(image,exception);
7802 case 18: /* MedianFilter */
7804 if (attribute_flag[0] != 0)
7806 flags=ParseGeometry(argument_list[0].string_reference,
7808 if ((flags & SigmaValue) == 0)
7809 geometry_info.sigma=1.0;
7811 if (attribute_flag[1] != 0)
7812 geometry_info.rho=argument_list[1].real_reference;
7813 if (attribute_flag[2] != 0)
7814 geometry_info.sigma=argument_list[2].real_reference;
7815 if (attribute_flag[3] != 0)
7816 channel=(ChannelType) argument_list[3].integer_reference;
7817 image=StatisticImageChannel(image,channel,MedianStatistic,
7818 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7821 case 19: /* Minify */
7823 image=MinifyImage(image,exception);
7826 case 20: /* OilPaint */
7828 if (attribute_flag[0] == 0)
7829 argument_list[0].real_reference=0.0;
7830 image=OilPaintImage(image,argument_list[0].real_reference,
7834 case 21: /* ReduceNoise */
7836 if (attribute_flag[0] != 0)
7838 flags=ParseGeometry(argument_list[0].string_reference,
7840 if ((flags & SigmaValue) == 0)
7841 geometry_info.sigma=1.0;
7843 if (attribute_flag[1] != 0)
7844 geometry_info.rho=argument_list[1].real_reference;
7845 if (attribute_flag[2] != 0)
7846 geometry_info.sigma=argument_list[2].real_reference;
7847 if (attribute_flag[3] != 0)
7848 channel=(ChannelType) argument_list[3].integer_reference;
7849 image=StatisticImageChannel(image,channel,NonpeakStatistic,
7850 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
7855 if (attribute_flag[0] != 0)
7856 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7857 &geometry,exception);
7858 if (attribute_flag[1] != 0)
7859 geometry.x=argument_list[1].integer_reference;
7860 if (attribute_flag[2] != 0)
7861 geometry.y=argument_list[2].integer_reference;
7862 image=RollImage(image,geometry.x,geometry.y,exception);
7865 case 23: /* Rotate */
7867 if (attribute_flag[0] == 0)
7868 argument_list[0].real_reference=90.0;
7869 if (attribute_flag[1] != 0)
7870 QueryColorDatabase(argument_list[1].string_reference,
7871 &image->background_color,exception);
7872 if (attribute_flag[2] != 0)
7873 QueryColorDatabase(argument_list[2].string_reference,
7874 &image->background_color,exception);
7875 if (attribute_flag[3] != 0)
7876 QueryColorDatabase(argument_list[3].string_reference,
7877 &image->background_color,exception);
7878 image=RotateImage(image,argument_list[0].real_reference,exception);
7881 case 24: /* Sample */
7883 if (attribute_flag[0] != 0)
7884 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7885 &geometry,exception);
7886 if (attribute_flag[1] != 0)
7887 geometry.width=argument_list[1].integer_reference;
7888 if (attribute_flag[2] != 0)
7889 geometry.height=argument_list[2].integer_reference;
7890 image=SampleImage(image,geometry.width,geometry.height,exception);
7893 case 25: /* Scale */
7895 if (attribute_flag[0] != 0)
7896 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7897 &geometry,exception);
7898 if (attribute_flag[1] != 0)
7899 geometry.width=argument_list[1].integer_reference;
7900 if (attribute_flag[2] != 0)
7901 geometry.height=argument_list[2].integer_reference;
7902 image=ScaleImage(image,geometry.width,geometry.height,exception);
7905 case 26: /* Shade */
7907 if (attribute_flag[0] != 0)
7909 flags=ParseGeometry(argument_list[0].string_reference,
7911 if ((flags & SigmaValue) == 0)
7912 geometry_info.sigma=0.0;
7914 if (attribute_flag[1] != 0)
7915 geometry_info.rho=argument_list[1].real_reference;
7916 if (attribute_flag[2] != 0)
7917 geometry_info.sigma=argument_list[2].real_reference;
7918 image=ShadeImage(image,
7919 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7920 geometry_info.rho,geometry_info.sigma,exception);
7923 case 27: /* Sharpen */
7925 if (attribute_flag[0] != 0)
7927 flags=ParseGeometry(argument_list[0].string_reference,
7929 if ((flags & SigmaValue) == 0)
7930 geometry_info.sigma=1.0;
7932 if (attribute_flag[1] != 0)
7933 geometry_info.rho=argument_list[1].real_reference;
7934 if (attribute_flag[2] != 0)
7935 geometry_info.sigma=argument_list[2].real_reference;
7936 if (attribute_flag[3] != 0)
7937 channel=(ChannelType) argument_list[3].integer_reference;
7938 image=SharpenImageChannel(image,channel,geometry_info.rho,
7939 geometry_info.sigma,exception);
7942 case 28: /* Shear */
7944 if (attribute_flag[0] != 0)
7946 flags=ParseGeometry(argument_list[0].string_reference,
7948 if ((flags & SigmaValue) == 0)
7949 geometry_info.sigma=geometry_info.rho;
7951 if (attribute_flag[1] != 0)
7952 geometry_info.rho=argument_list[1].real_reference;
7953 if (attribute_flag[2] != 0)
7954 geometry_info.sigma=argument_list[2].real_reference;
7955 if (attribute_flag[3] != 0)
7956 QueryColorDatabase(argument_list[3].string_reference,
7957 &image->background_color,exception);
7958 if (attribute_flag[4] != 0)
7959 QueryColorDatabase(argument_list[4].string_reference,
7960 &image->background_color,exception);
7961 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7965 case 29: /* Spread */
7967 if (attribute_flag[0] == 0)
7968 argument_list[0].real_reference=1.0;
7969 image=SpreadImage(image,argument_list[0].real_reference,exception);
7972 case 30: /* Swirl */
7974 if (attribute_flag[0] == 0)
7975 argument_list[0].real_reference=50.0;
7976 if (attribute_flag[1] != 0)
7977 image->interpolate=(InterpolatePixelMethod)
7978 argument_list[1].integer_reference;
7979 image=SwirlImage(image,argument_list[0].real_reference,exception);
7982 case 31: /* Resize */
7985 if (attribute_flag[0] != 0)
7986 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7987 &geometry,exception);
7988 if (attribute_flag[1] != 0)
7989 geometry.width=argument_list[1].integer_reference;
7990 if (attribute_flag[2] != 0)
7991 geometry.height=argument_list[2].integer_reference;
7992 if (attribute_flag[3] == 0)
7993 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7994 if (attribute_flag[4] != 0)
7995 SetImageArtifact(image,"filter:support",
7996 argument_list[4].string_reference);
7997 if (attribute_flag[5] == 0)
7998 argument_list[5].real_reference=1.0;
7999 image=ResizeImage(image,geometry.width,geometry.height,
8000 (FilterTypes) argument_list[3].integer_reference,
8001 argument_list[5].real_reference,exception);
8004 case 33: /* Annotate */
8009 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8011 if (attribute_flag[0] != 0)
8016 text=InterpretImageProperties(info ? info->image_info :
8017 (ImageInfo *) NULL,image,argument_list[0].string_reference);
8018 (void) CloneString(&draw_info->text,text);
8019 text=DestroyString(text);
8021 if (attribute_flag[1] != 0)
8022 (void) CloneString(&draw_info->font,
8023 argument_list[1].string_reference);
8024 if (attribute_flag[2] != 0)
8025 draw_info->pointsize=argument_list[2].real_reference;
8026 if (attribute_flag[3] != 0)
8027 (void) CloneString(&draw_info->density,
8028 argument_list[3].string_reference);
8029 if (attribute_flag[4] != 0)
8030 (void) QueryColorDatabase(argument_list[4].string_reference,
8031 &draw_info->undercolor,exception);
8032 if (attribute_flag[5] != 0)
8034 (void) QueryColorDatabase(argument_list[5].string_reference,
8035 &draw_info->stroke,exception);
8036 if (argument_list[5].image_reference != (Image *) NULL)
8037 draw_info->stroke_pattern=CloneImage(
8038 argument_list[5].image_reference,0,0,MagickTrue,exception);
8040 if (attribute_flag[6] != 0)
8042 (void) QueryColorDatabase(argument_list[6].string_reference,
8043 &draw_info->fill,exception);
8044 if (argument_list[6].image_reference != (Image *) NULL)
8045 draw_info->fill_pattern=CloneImage(
8046 argument_list[6].image_reference,0,0,MagickTrue,exception);
8048 if (attribute_flag[7] != 0)
8050 (void) CloneString(&draw_info->geometry,
8051 argument_list[7].string_reference);
8052 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8053 &geometry,exception);
8054 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8055 geometry_info.sigma=geometry_info.xi;
8057 if (attribute_flag[8] != 0)
8058 (void) QueryColorDatabase(argument_list[8].string_reference,
8059 &draw_info->fill,exception);
8060 if (attribute_flag[11] != 0)
8061 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
8062 if (attribute_flag[25] != 0)
8067 av=(AV *) argument_list[25].array_reference;
8068 if ((av_len(av) != 3) && (av_len(av) != 5))
8070 ThrowPerlException(exception,OptionError,
8071 "affine matrix must have 4 or 6 elements",PackageName);
8074 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8075 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8076 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8077 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8078 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8079 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8081 ThrowPerlException(exception,OptionError,
8082 "affine matrix is singular",PackageName);
8085 if (av_len(av) == 5)
8087 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8088 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8091 for (j=12; j < 17; j++)
8093 if (attribute_flag[j] == 0)
8095 value=argument_list[j].string_reference;
8096 angle=argument_list[j].real_reference;
8097 current=draw_info->affine;
8098 GetAffineMatrix(&affine);
8106 flags=ParseGeometry(value,&geometry_info);
8107 affine.tx=geometry_info.xi;
8108 affine.ty=geometry_info.psi;
8109 if ((flags & PsiValue) == 0)
8110 affine.ty=affine.tx;
8118 flags=ParseGeometry(value,&geometry_info);
8119 affine.sx=geometry_info.rho;
8120 affine.sy=geometry_info.sigma;
8121 if ((flags & SigmaValue) == 0)
8122 affine.sy=affine.sx;
8132 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8133 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8134 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8135 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8143 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8151 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8155 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8156 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8157 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8158 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8159 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8161 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8164 if (attribute_flag[9] == 0)
8165 argument_list[9].real_reference=0.0;
8166 if (attribute_flag[10] == 0)
8167 argument_list[10].real_reference=0.0;
8168 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8171 geometry[MaxTextExtent];
8173 (void) FormatMagickString(geometry,MaxTextExtent,"%+f%+f",
8174 (double) argument_list[9].real_reference+draw_info->affine.tx,
8175 (double) argument_list[10].real_reference+draw_info->affine.ty);
8176 (void) CloneString(&draw_info->geometry,geometry);
8178 if (attribute_flag[17] != 0)
8179 draw_info->stroke_width=argument_list[17].real_reference;
8180 if (attribute_flag[18] != 0)
8182 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8183 MagickTrue : MagickFalse;
8184 draw_info->stroke_antialias=draw_info->text_antialias;
8186 if (attribute_flag[19] != 0)
8187 (void) CloneString(&draw_info->family,
8188 argument_list[19].string_reference);
8189 if (attribute_flag[20] != 0)
8190 draw_info->style=(StyleType) argument_list[20].integer_reference;
8191 if (attribute_flag[21] != 0)
8192 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8193 if (attribute_flag[22] != 0)
8194 draw_info->weight=argument_list[22].integer_reference;
8195 if (attribute_flag[23] != 0)
8196 draw_info->align=(AlignType) argument_list[23].integer_reference;
8197 if (attribute_flag[24] != 0)
8198 (void) CloneString(&draw_info->encoding,
8199 argument_list[24].string_reference);
8200 if (attribute_flag[25] != 0)
8201 draw_info->fill_pattern=CloneImage(
8202 argument_list[25].image_reference,0,0,MagickTrue,exception);
8203 if (attribute_flag[26] != 0)
8204 draw_info->fill_pattern=CloneImage(
8205 argument_list[26].image_reference,0,0,MagickTrue,exception);
8206 if (attribute_flag[27] != 0)
8207 draw_info->stroke_pattern=CloneImage(
8208 argument_list[27].image_reference,0,0,MagickTrue,exception);
8209 if (attribute_flag[29] != 0)
8210 draw_info->kerning=argument_list[29].real_reference;
8211 if (attribute_flag[30] != 0)
8212 draw_info->interline_spacing=argument_list[30].real_reference;
8213 if (attribute_flag[31] != 0)
8214 draw_info->interword_spacing=argument_list[31].real_reference;
8215 if (attribute_flag[32] != 0)
8216 draw_info->direction=(DirectionType)
8217 argument_list[32].integer_reference;
8218 (void) AnnotateImage(image,draw_info);
8219 draw_info=DestroyDrawInfo(draw_info);
8222 case 34: /* ColorFloodfill */
8233 draw_info=CloneDrawInfo(info ? info->image_info :
8234 (ImageInfo *) NULL,(DrawInfo *) NULL);
8235 if (attribute_flag[0] != 0)
8236 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8237 &geometry,exception);
8238 if (attribute_flag[1] != 0)
8239 geometry.x=argument_list[1].integer_reference;
8240 if (attribute_flag[2] != 0)
8241 geometry.y=argument_list[2].integer_reference;
8242 if (attribute_flag[3] != 0)
8243 (void) QueryColorDatabase(argument_list[3].string_reference,
8244 &draw_info->fill,exception);
8245 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8248 if (attribute_flag[4] != 0)
8250 QueryMagickColor(argument_list[4].string_reference,&target,
8254 if (attribute_flag[5] != 0)
8255 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8257 if (attribute_flag[6] != 0)
8258 invert=(MagickBooleanType) argument_list[6].integer_reference;
8259 (void) FloodfillPaintImage(image,DefaultChannels,draw_info,&target,
8260 geometry.x,geometry.y,invert);
8261 draw_info=DestroyDrawInfo(draw_info);
8264 case 35: /* Composite */
8267 composite_geometry[MaxTextExtent];
8273 compose=OverCompositeOp;
8274 if (attribute_flag[0] != 0)
8275 composite_image=argument_list[0].image_reference;
8278 ThrowPerlException(exception,OptionError,
8279 "CompositeImageRequired",PackageName);
8283 Parameter Handling used for BOTH normal and tiled composition.
8285 if (attribute_flag[1] != 0) /* compose */
8286 compose=(CompositeOperator) argument_list[1].integer_reference;
8287 if (attribute_flag[6] != 0) /* opacity */
8289 if (compose != DissolveCompositeOp)
8290 (void) SetImageOpacity(composite_image,(Quantum) (QuantumRange-
8291 SiPrefixToDouble(argument_list[6].string_reference,
8307 register PixelPacket
8314 Handle dissolve composite operator (patch by
8317 (void) CloneString(&image->geometry,
8318 argument_list[6].string_reference);
8319 opacity=(Quantum) (QuantumRange-SiPrefixToDouble(
8320 argument_list[6].string_reference,QuantumRange));
8321 if (composite_image->matte != MagickTrue)
8322 (void) SetImageOpacity(composite_image,OpaqueOpacity);
8323 composite_view=AcquireCacheView(composite_image);
8324 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8326 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8327 composite_image->columns,1,exception);
8328 for (x=0; x < (ssize_t) composite_image->columns; x++)
8330 if (q->opacity == OpaqueOpacity)
8331 q->opacity=ClampToQuantum(opacity);
8334 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8335 if (sync == MagickFalse)
8338 composite_view=DestroyCacheView(composite_view);
8341 if (attribute_flag[9] != 0) /* "color=>" */
8342 QueryColorDatabase(argument_list[9].string_reference,
8343 &composite_image->background_color,exception);
8344 if (attribute_flag[12] != 0) /* "interpolate=>" */
8345 image->interpolate=(InterpolatePixelMethod)
8346 argument_list[12].integer_reference;
8347 if (attribute_flag[13] != 0) /* "args=>" */
8348 (void) SetImageArtifact(composite_image,"compose:args",
8349 argument_list[13].string_reference);
8350 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8351 (void) SetImageArtifact(composite_image,"compose:args",
8352 argument_list[14].string_reference);
8354 Tiling Composition (with orthogonal rotate).
8356 rotate_image=(Image *) NULL;
8357 if (attribute_flag[8] != 0) /* "rotate=>" */
8362 rotate_image=RotateImage(composite_image,
8363 argument_list[8].real_reference,exception);
8364 if (rotate_image == (Image *) NULL)
8367 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8374 Tile the composite image.
8376 if (attribute_flag[8] != 0) /* "tile=>" */
8377 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8380 (void) SetImageArtifact(composite_image,
8381 "compose:outside-overlay","false");
8382 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8383 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8385 if (attribute_flag[8] != 0) /* rotate */
8386 (void) CompositeImage(image,compose,rotate_image,x,y);
8388 (void) CompositeImage(image,compose,composite_image,x,y);
8390 if (attribute_flag[8] != 0) /* rotate */
8391 rotate_image=DestroyImage(rotate_image);
8395 Parameter Handling used used ONLY for normal composition.
8397 if (attribute_flag[5] != 0) /* gravity */
8398 image->gravity=(GravityType) argument_list[5].integer_reference;
8399 if (attribute_flag[2] != 0) /* geometry offset */
8401 SetGeometry(image,&geometry);
8402 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8404 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8407 if (attribute_flag[3] != 0) /* x offset */
8408 geometry.x=argument_list[3].integer_reference;
8409 if (attribute_flag[4] != 0) /* y offset */
8410 geometry.y=argument_list[4].integer_reference;
8411 if (attribute_flag[10] != 0) /* mask */
8413 if ((image->compose == DisplaceCompositeOp) ||
8414 (image->compose == DistortCompositeOp))
8417 Merge Y displacement into X displacement image.
8419 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8421 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8422 argument_list[10].image_reference,0,0);
8427 Set a blending mask for the composition.
8429 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8430 MagickTrue,&image->exception);
8431 (void) NegateImage(image->mask,MagickFalse);
8434 if (attribute_flag[11] != 0) /* channel */
8435 channel=(ChannelType) argument_list[11].integer_reference;
8437 Composite two images (normal composition).
8439 (void) FormatMagickString(composite_geometry,MaxTextExtent,
8440 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8441 (double) composite_image->rows,(double) geometry.x,(double)
8443 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8445 if (attribute_flag[8] == 0) /* no rotate */
8446 CompositeImageChannel(image,channel,compose,composite_image,
8447 geometry.x,geometry.y);
8451 Position adjust rotated image then composite.
8453 geometry.x-=(ssize_t) (rotate_image->columns-
8454 composite_image->columns)/2;
8455 geometry.y-=(ssize_t) (rotate_image->rows-
8456 composite_image->rows)/2;
8457 CompositeImageChannel(image,channel,compose,rotate_image,
8458 geometry.x,geometry.y);
8459 rotate_image=DestroyImage(rotate_image);
8461 if (attribute_flag[10] != 0) /* mask */
8463 if ((image->compose == DisplaceCompositeOp) ||
8464 (image->compose == DistortCompositeOp))
8465 composite_image=DestroyImage(composite_image);
8467 image->mask=DestroyImage(image->mask);
8471 case 36: /* Contrast */
8473 if (attribute_flag[0] == 0)
8474 argument_list[0].integer_reference=0;
8475 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8476 MagickTrue : MagickFalse);
8479 case 37: /* CycleColormap */
8481 if (attribute_flag[0] == 0)
8482 argument_list[0].integer_reference=6;
8483 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8491 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8493 (void) CloneString(&draw_info->primitive,"point");
8494 if (attribute_flag[0] != 0)
8496 if (argument_list[0].integer_reference < 0)
8497 (void) CloneString(&draw_info->primitive,
8498 argument_list[0].string_reference);
8500 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8501 MagickPrimitiveOptions,argument_list[0].integer_reference));
8503 if (attribute_flag[1] != 0)
8505 if (LocaleCompare(draw_info->primitive,"path") == 0)
8507 (void) ConcatenateString(&draw_info->primitive," '");
8508 ConcatenateString(&draw_info->primitive,
8509 argument_list[1].string_reference);
8510 (void) ConcatenateString(&draw_info->primitive,"'");
8514 (void) ConcatenateString(&draw_info->primitive," ");
8515 ConcatenateString(&draw_info->primitive,
8516 argument_list[1].string_reference);
8519 if (attribute_flag[2] != 0)
8521 (void) ConcatenateString(&draw_info->primitive," ");
8522 (void) ConcatenateString(&draw_info->primitive,
8523 CommandOptionToMnemonic(MagickMethodOptions,
8524 argument_list[2].integer_reference));
8526 if (attribute_flag[3] != 0)
8528 (void) QueryColorDatabase(argument_list[3].string_reference,
8529 &draw_info->stroke,exception);
8530 if (argument_list[3].image_reference != (Image *) NULL)
8531 draw_info->stroke_pattern=CloneImage(
8532 argument_list[3].image_reference,0,0,MagickTrue,exception);
8534 if (attribute_flag[4] != 0)
8536 (void) QueryColorDatabase(argument_list[4].string_reference,
8537 &draw_info->fill,exception);
8538 if (argument_list[4].image_reference != (Image *) NULL)
8539 draw_info->fill_pattern=CloneImage(
8540 argument_list[4].image_reference,0,0,MagickTrue,exception);
8542 if (attribute_flag[5] != 0)
8543 draw_info->stroke_width=argument_list[5].real_reference;
8544 if (attribute_flag[6] != 0)
8545 (void) CloneString(&draw_info->font,
8546 argument_list[6].string_reference);
8547 if (attribute_flag[7] != 0)
8548 (void) QueryColorDatabase(argument_list[7].string_reference,
8549 &draw_info->border_color,exception);
8550 if (attribute_flag[8] != 0)
8551 draw_info->affine.tx=argument_list[8].real_reference;
8552 if (attribute_flag[9] != 0)
8553 draw_info->affine.ty=argument_list[9].real_reference;
8554 if (attribute_flag[20] != 0)
8559 av=(AV *) argument_list[20].array_reference;
8560 if ((av_len(av) != 3) && (av_len(av) != 5))
8562 ThrowPerlException(exception,OptionError,
8563 "affine matrix must have 4 or 6 elements",PackageName);
8566 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8567 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8568 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8569 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8570 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8571 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8573 ThrowPerlException(exception,OptionError,
8574 "affine matrix is singular",PackageName);
8577 if (av_len(av) == 5)
8579 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8580 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8583 for (j=10; j < 15; j++)
8585 if (attribute_flag[j] == 0)
8587 value=argument_list[j].string_reference;
8588 angle=argument_list[j].real_reference;
8589 current=draw_info->affine;
8590 GetAffineMatrix(&affine);
8598 flags=ParseGeometry(value,&geometry_info);
8599 affine.tx=geometry_info.xi;
8600 affine.ty=geometry_info.psi;
8601 if ((flags & PsiValue) == 0)
8602 affine.ty=affine.tx;
8610 flags=ParseGeometry(value,&geometry_info);
8611 affine.sx=geometry_info.rho;
8612 affine.sy=geometry_info.sigma;
8613 if ((flags & SigmaValue) == 0)
8614 affine.sy=affine.sx;
8624 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8625 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8626 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8627 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8635 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8643 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8647 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8648 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8649 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8650 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8651 draw_info->affine.tx=
8652 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8653 draw_info->affine.ty=
8654 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8656 if (attribute_flag[15] != 0)
8657 draw_info->fill_pattern=CloneImage(
8658 argument_list[15].image_reference,0,0,MagickTrue,exception);
8659 if (attribute_flag[16] != 0)
8660 draw_info->pointsize=argument_list[16].real_reference;
8661 if (attribute_flag[17] != 0)
8663 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8664 ? MagickTrue : MagickFalse;
8665 draw_info->text_antialias=draw_info->stroke_antialias;
8667 if (attribute_flag[18] != 0)
8668 (void) CloneString(&draw_info->density,
8669 argument_list[18].string_reference);
8670 if (attribute_flag[19] != 0)
8671 draw_info->stroke_width=argument_list[19].real_reference;
8672 if (attribute_flag[21] != 0)
8673 draw_info->dash_offset=argument_list[21].real_reference;
8674 if (attribute_flag[22] != 0)
8679 av=(AV *) argument_list[22].array_reference;
8680 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8681 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8682 if (draw_info->dash_pattern != (double *) NULL)
8684 for (i=0; i <= av_len(av); i++)
8685 draw_info->dash_pattern[i]=(double)
8686 SvNV(*(av_fetch(av,i,0)));
8687 draw_info->dash_pattern[i]=0.0;
8690 if (attribute_flag[23] != 0)
8691 image->interpolate=(InterpolatePixelMethod)
8692 argument_list[23].integer_reference;
8693 if ((attribute_flag[24] != 0) &&
8694 (draw_info->fill_pattern != (Image *) NULL))
8695 flags=ParsePageGeometry(draw_info->fill_pattern,
8696 argument_list[24].string_reference,
8697 &draw_info->fill_pattern->tile_offset,exception);
8698 if (attribute_flag[25] != 0)
8700 (void) ConcatenateString(&draw_info->primitive," '");
8701 (void) ConcatenateString(&draw_info->primitive,
8702 argument_list[25].string_reference);
8703 (void) ConcatenateString(&draw_info->primitive,"'");
8705 if (attribute_flag[26] != 0)
8706 draw_info->fill_pattern=CloneImage(
8707 argument_list[26].image_reference,0,0,MagickTrue,exception);
8708 if (attribute_flag[27] != 0)
8709 draw_info->stroke_pattern=CloneImage(
8710 argument_list[27].image_reference,0,0,MagickTrue,exception);
8711 if (attribute_flag[28] != 0)
8712 (void) CloneString(&draw_info->primitive,
8713 argument_list[28].string_reference);
8714 if (attribute_flag[29] != 0)
8715 draw_info->kerning=argument_list[29].real_reference;
8716 if (attribute_flag[30] != 0)
8717 draw_info->interline_spacing=argument_list[30].real_reference;
8718 if (attribute_flag[31] != 0)
8719 draw_info->interword_spacing=argument_list[31].real_reference;
8720 if (attribute_flag[32] != 0)
8721 draw_info->direction=(DirectionType)
8722 argument_list[32].integer_reference;
8723 DrawImage(image,draw_info);
8724 draw_info=DestroyDrawInfo(draw_info);
8727 case 39: /* Equalize */
8729 if (attribute_flag[0] != 0)
8730 channel=(ChannelType) argument_list[0].integer_reference;
8731 EqualizeImageChannel(image,channel);
8734 case 40: /* Gamma */
8736 if (attribute_flag[1] != 0)
8737 channel=(ChannelType) argument_list[1].integer_reference;
8738 if (attribute_flag[2] == 0)
8739 argument_list[2].real_reference=1.0;
8740 if (attribute_flag[3] == 0)
8741 argument_list[3].real_reference=1.0;
8742 if (attribute_flag[4] == 0)
8743 argument_list[4].real_reference=1.0;
8744 if (attribute_flag[0] == 0)
8746 (void) FormatMagickString(message,MaxTextExtent,
8747 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8748 (double) argument_list[3].real_reference,
8749 (double) argument_list[4].real_reference);
8750 argument_list[0].string_reference=message;
8752 if (strchr(argument_list[0].string_reference,',') != (char *) NULL)
8753 (void) GammaImage(image,argument_list[0].string_reference);
8755 (void) GammaImageChannel(image,channel,
8756 StringToDouble(argument_list[0].string_reference));
8764 if (attribute_flag[0] == 0)
8766 ThrowPerlException(exception,OptionError,"MapImageRequired",
8770 quantize_info=AcquireQuantizeInfo(info->image_info);
8771 if (attribute_flag[1] != 0)
8772 quantize_info->dither=(MagickBooleanType)
8773 argument_list[1].integer_reference;
8774 if (attribute_flag[2] != 0)
8775 quantize_info->dither_method=(DitherMethod)
8776 argument_list[2].integer_reference;
8777 (void) RemapImages(quantize_info,image,
8778 argument_list[0].image_reference);
8779 quantize_info=DestroyQuantizeInfo(quantize_info);
8782 case 42: /* MatteFloodfill */
8793 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8795 if (attribute_flag[0] != 0)
8796 if (attribute_flag[0] != 0)
8797 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8798 &geometry,exception);
8799 if (attribute_flag[1] != 0)
8800 geometry.x=argument_list[1].integer_reference;
8801 if (attribute_flag[2] != 0)
8802 geometry.y=argument_list[2].integer_reference;
8803 if (image->matte == MagickFalse)
8804 (void) SetImageOpacity(image,OpaqueOpacity);
8805 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8807 if (attribute_flag[4] != 0)
8808 QueryMagickColor(argument_list[4].string_reference,&target,
8810 if (attribute_flag[3] != 0)
8811 target.opacity=SiPrefixToDouble(argument_list[3].string_reference,
8813 if (attribute_flag[5] != 0)
8814 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8817 if (attribute_flag[6] != 0)
8818 invert=(MagickBooleanType) argument_list[6].integer_reference;
8819 (void) FloodfillPaintImage(image,OpacityChannel,draw_info,&target,
8820 geometry.x,geometry.y,invert);
8821 draw_info=DestroyDrawInfo(draw_info);
8824 case 43: /* Modulate */
8827 modulate[MaxTextExtent];
8832 colorspace=image->colorspace;
8833 geometry_info.rho=100.0;
8834 geometry_info.sigma=100.0;
8835 geometry_info.xi=100.0;
8836 if (attribute_flag[0] != 0)
8837 (void)ParseGeometry(argument_list[0].string_reference,
8839 if (attribute_flag[1] != 0)
8840 geometry_info.xi=argument_list[1].real_reference;
8841 if (attribute_flag[2] != 0)
8842 geometry_info.sigma=argument_list[2].real_reference;
8843 if (attribute_flag[3] != 0)
8845 (void) SetImageColorspace(image,HWBColorspace);
8846 geometry_info.sigma=argument_list[3].real_reference;
8848 if (attribute_flag[4] != 0)
8849 geometry_info.rho=argument_list[4].real_reference;
8850 if (attribute_flag[5] != 0)
8852 (void) SetImageColorspace(image,HSLColorspace);
8853 geometry_info.sigma=argument_list[5].real_reference;
8855 if (attribute_flag[6] != 0)
8857 (void) SetImageColorspace(image,HWBColorspace);
8858 geometry_info.rho=argument_list[6].real_reference;
8860 (void) FormatMagickString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8861 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8862 (void) ModulateImage(image,modulate);
8863 (void) SetImageColorspace(image,colorspace);
8866 case 44: /* Negate */
8868 if (attribute_flag[0] == 0)
8869 argument_list[0].integer_reference=0;
8870 if (attribute_flag[1] != 0)
8871 channel=(ChannelType) argument_list[1].integer_reference;
8872 (void) NegateImageChannel(image,channel,
8873 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
8876 case 45: /* Normalize */
8878 if (attribute_flag[0] != 0)
8879 channel=(ChannelType) argument_list[0].integer_reference;
8880 NormalizeImageChannel(image,channel);
8883 case 46: /* NumberColors */
8885 case 47: /* Opaque */
8894 (void) QueryMagickColor("none",&target,exception);
8895 (void) QueryMagickColor("none",&fill_color,exception);
8896 if (attribute_flag[0] != 0)
8897 (void) QueryMagickColor(argument_list[0].string_reference,
8899 if (attribute_flag[1] != 0)
8900 (void) QueryMagickColor(argument_list[1].string_reference,
8901 &fill_color,exception);
8902 if (attribute_flag[2] != 0)
8903 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8905 if (attribute_flag[3] != 0)
8906 channel=(ChannelType) argument_list[3].integer_reference;
8908 if (attribute_flag[4] != 0)
8909 invert=(MagickBooleanType) argument_list[4].integer_reference;
8910 (void) OpaquePaintImageChannel(image,channel,&target,&fill_color,
8914 case 48: /* Quantize */
8919 quantize_info=AcquireQuantizeInfo(info->image_info);
8920 if (attribute_flag[0] != 0)
8921 quantize_info->number_colors=(size_t)
8922 argument_list[0].integer_reference;
8923 if (attribute_flag[1] != 0)
8924 quantize_info->tree_depth=(size_t)
8925 argument_list[1].integer_reference;
8926 if (attribute_flag[2] != 0)
8927 quantize_info->colorspace=(ColorspaceType)
8928 argument_list[2].integer_reference;
8929 if (attribute_flag[3] != 0)
8930 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8931 MagickTrue : MagickFalse;
8932 if (attribute_flag[4] != 0)
8933 quantize_info->measure_error=
8934 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8935 if (attribute_flag[5] != 0)
8936 (void) QueryColorDatabase(argument_list[5].string_reference,
8937 &image->transparent_color,exception);
8938 if (attribute_flag[5] && argument_list[5].integer_reference)
8940 (void) QuantizeImages(quantize_info,image);
8943 if (attribute_flag[6] != 0)
8944 quantize_info->dither_method=(DitherMethod)
8945 argument_list[6].integer_reference;
8946 if ((image->storage_class == DirectClass) ||
8947 (image->colors > quantize_info->number_colors) ||
8948 (quantize_info->colorspace == GRAYColorspace))
8949 (void) QuantizeImage(quantize_info,image);
8951 CompressImageColormap(image);
8952 quantize_info=DestroyQuantizeInfo(quantize_info);
8955 case 49: /* Raise */
8957 if (attribute_flag[0] != 0)
8958 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8959 &geometry,exception);
8960 if (attribute_flag[1] != 0)
8961 geometry.width=argument_list[1].integer_reference;
8962 if (attribute_flag[2] != 0)
8963 geometry.height=argument_list[2].integer_reference;
8964 if (attribute_flag[3] == 0)
8965 argument_list[3].integer_reference=1;
8966 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8967 0 ? MagickTrue : MagickFalse);
8970 case 50: /* Segment */
8977 smoothing_threshold;
8982 cluster_threshold=1.0;
8983 smoothing_threshold=1.5;
8984 colorspace=RGBColorspace;
8985 verbose=MagickFalse;
8986 if (attribute_flag[0] != 0)
8988 flags=ParseGeometry(argument_list[0].string_reference,
8990 cluster_threshold=geometry_info.rho;
8991 if (flags & SigmaValue)
8992 smoothing_threshold=geometry_info.sigma;
8994 if (attribute_flag[1] != 0)
8995 cluster_threshold=argument_list[1].real_reference;
8996 if (attribute_flag[2] != 0)
8997 smoothing_threshold=argument_list[2].real_reference;
8998 if (attribute_flag[3] != 0)
8999 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9000 if (attribute_flag[4] != 0)
9001 verbose=argument_list[4].integer_reference != 0 ?
9002 MagickTrue : MagickFalse;
9003 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9004 smoothing_threshold);
9007 case 51: /* Signature */
9009 (void) SignatureImage(image);
9012 case 52: /* Solarize */
9014 geometry_info.rho=QuantumRange/2.0;
9015 if (attribute_flag[0] != 0)
9016 flags=ParseGeometry(argument_list[0].string_reference,
9018 if (attribute_flag[1] != 0)
9019 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
9021 (void) SolarizeImage(image,geometry_info.rho);
9026 (void) SyncImage(image);
9029 case 54: /* Texture */
9031 if (attribute_flag[0] == 0)
9033 TextureImage(image,argument_list[0].image_reference);
9036 case 55: /* Evalute */
9038 MagickEvaluateOperator
9041 op=SetEvaluateOperator;
9042 if (attribute_flag[0] == MagickFalse)
9043 argument_list[0].real_reference=0.0;
9044 if (attribute_flag[1] != MagickFalse)
9045 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9046 if (attribute_flag[2] != MagickFalse)
9047 channel=(ChannelType) argument_list[2].integer_reference;
9048 (void) EvaluateImageChannel(image,channel,op,
9049 argument_list[0].real_reference,exception);
9052 case 56: /* Transparent */
9063 (void) QueryMagickColor("none",&target,exception);
9064 if (attribute_flag[0] != 0)
9065 (void) QueryMagickColor(argument_list[0].string_reference,&target,
9067 opacity=TransparentOpacity;
9068 if (attribute_flag[1] != 0)
9069 opacity=SiPrefixToDouble(argument_list[1].string_reference,
9071 if (attribute_flag[2] != 0)
9072 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
9074 if (attribute_flag[3] == 0)
9075 argument_list[3].integer_reference=0;
9077 if (attribute_flag[3] != 0)
9078 invert=(MagickBooleanType) argument_list[3].integer_reference;
9079 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9083 case 57: /* Threshold */
9088 if (attribute_flag[0] == 0)
9089 argument_list[0].string_reference="50%";
9090 if (attribute_flag[1] != 0)
9091 channel=(ChannelType) argument_list[1].integer_reference;
9092 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9094 (void) BilevelImageChannel(image,channel,threshold);
9097 case 58: /* Charcoal */
9099 if (attribute_flag[0] != 0)
9101 flags=ParseGeometry(argument_list[0].string_reference,
9103 if ((flags & SigmaValue) == 0)
9104 geometry_info.sigma=1.0;
9106 if (attribute_flag[1] != 0)
9107 geometry_info.rho=argument_list[1].real_reference;
9108 if (attribute_flag[2] != 0)
9109 geometry_info.sigma=argument_list[2].real_reference;
9110 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9116 if (attribute_flag[0] != 0)
9117 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9119 image=TrimImage(image,exception);
9124 if (attribute_flag[0] != 0)
9126 flags=ParseGeometry(argument_list[0].string_reference,
9128 if ((flags & SigmaValue) == 0)
9129 geometry_info.sigma=1.0;
9131 if (attribute_flag[1] != 0)
9132 geometry_info.rho=argument_list[1].real_reference;
9133 if (attribute_flag[2] != 0)
9134 geometry_info.sigma=argument_list[2].real_reference;
9135 if (attribute_flag[3] != 0)
9136 image->interpolate=(InterpolatePixelMethod)
9137 argument_list[3].integer_reference;
9138 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9142 case 61: /* Separate */
9144 if (attribute_flag[0] != 0)
9145 channel=(ChannelType) argument_list[0].integer_reference;
9146 (void) SeparateImageChannel(image,channel);
9149 case 63: /* Stereo */
9151 if (attribute_flag[0] == 0)
9153 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9157 if (attribute_flag[1] != 0)
9158 geometry.x=argument_list[1].integer_reference;
9159 if (attribute_flag[2] != 0)
9160 geometry.y=argument_list[2].integer_reference;
9161 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9162 geometry.x,geometry.y,exception);
9165 case 64: /* Stegano */
9167 if (attribute_flag[0] == 0)
9169 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9173 if (attribute_flag[1] == 0)
9174 argument_list[1].integer_reference=0;
9175 image->offset=argument_list[1].integer_reference;
9176 image=SteganoImage(image,argument_list[0].image_reference,exception);
9179 case 65: /* Deconstruct */
9181 image=DeconstructImages(image,exception);
9184 case 66: /* GaussianBlur */
9186 if (attribute_flag[0] != 0)
9188 flags=ParseGeometry(argument_list[0].string_reference,
9190 if ((flags & SigmaValue) == 0)
9191 geometry_info.sigma=1.0;
9193 if (attribute_flag[1] != 0)
9194 geometry_info.rho=argument_list[1].real_reference;
9195 if (attribute_flag[2] != 0)
9196 geometry_info.sigma=argument_list[2].real_reference;
9197 if (attribute_flag[3] != 0)
9198 channel=(ChannelType) argument_list[3].integer_reference;
9199 image=GaussianBlurImageChannel(image,channel,geometry_info.rho,
9200 geometry_info.sigma,exception);
9203 case 67: /* Convolve */
9214 if (attribute_flag[0] == 0)
9216 if (attribute_flag[1] != 0)
9217 channel=(ChannelType) argument_list[1].integer_reference;
9218 if (attribute_flag[2] != 0)
9219 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9221 av=(AV *) argument_list[0].array_reference;
9222 order=(size_t) sqrt(av_len(av)+1);
9223 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9224 if (kernel == (double *) NULL)
9226 ThrowPerlException(exception,ResourceLimitFatalError,
9227 "MemoryAllocationFailed",PackageName);
9230 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9231 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9232 for ( ; j < (ssize_t) (order*order); j++)
9234 image=ConvolveImageChannel(image,channel,order,kernel,exception);
9235 kernel=(double *) RelinquishMagickMemory(kernel);
9238 case 68: /* Profile */
9253 if (attribute_flag[0] != 0)
9254 name=argument_list[0].string_reference;
9255 if (attribute_flag[2] != 0)
9256 image->rendering_intent=(RenderingIntent)
9257 argument_list[2].integer_reference;
9258 if (attribute_flag[3] != 0)
9259 image->black_point_compensation=
9260 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9261 if (attribute_flag[1] != 0)
9263 if (argument_list[1].length == 0)
9266 Remove a profile from the image.
9268 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9273 Associate user supplied profile with the image.
9275 profile=AcquireStringInfo(argument_list[1].length);
9276 SetStringInfoDatum(profile,(const unsigned char *)
9277 argument_list[1].string_reference);
9278 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9279 (size_t) GetStringInfoLength(profile),MagickFalse);
9280 profile=DestroyStringInfo(profile);
9284 Associate a profile with the image.
9287 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9288 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9289 profile_image=ReadImages(profile_info,&image->exception);
9290 if (profile_image == (Image *) NULL)
9292 ResetImageProfileIterator(profile_image);
9293 name=GetNextImageProfile(profile_image);
9294 while (name != (const char *) NULL)
9299 profile=GetImageProfile(profile_image,name);
9300 if (profile != (const StringInfo *) NULL)
9301 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9302 (size_t) GetStringInfoLength(profile),MagickFalse);
9303 name=GetNextImageProfile(profile_image);
9305 profile_image=DestroyImage(profile_image);
9306 profile_info=DestroyImageInfo(profile_info);
9309 case 69: /* UnsharpMask */
9311 if (attribute_flag[0] != 0)
9313 flags=ParseGeometry(argument_list[0].string_reference,
9315 if ((flags & SigmaValue) == 0)
9316 geometry_info.sigma=1.0;
9317 if ((flags & XiValue) == 0)
9318 geometry_info.xi=1.0;
9319 if ((flags & PsiValue) == 0)
9320 geometry_info.psi=0.5;
9322 if (attribute_flag[1] != 0)
9323 geometry_info.rho=argument_list[1].real_reference;
9324 if (attribute_flag[2] != 0)
9325 geometry_info.sigma=argument_list[2].real_reference;
9326 if (attribute_flag[3] != 0)
9327 geometry_info.xi=argument_list[3].real_reference;
9328 if (attribute_flag[4] != 0)
9329 geometry_info.psi=argument_list[4].real_reference;
9330 if (attribute_flag[5] != 0)
9331 channel=(ChannelType) argument_list[5].integer_reference;
9332 image=UnsharpMaskImageChannel(image,channel,geometry_info.rho,
9333 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
9336 case 70: /* MotionBlur */
9338 if (attribute_flag[0] != 0)
9340 flags=ParseGeometry(argument_list[0].string_reference,
9342 if ((flags & SigmaValue) == 0)
9343 geometry_info.sigma=1.0;
9344 if ((flags & XiValue) == 0)
9345 geometry_info.xi=1.0;
9347 if (attribute_flag[1] != 0)
9348 geometry_info.rho=argument_list[1].real_reference;
9349 if (attribute_flag[2] != 0)
9350 geometry_info.sigma=argument_list[2].real_reference;
9351 if (attribute_flag[3] != 0)
9352 geometry_info.xi=argument_list[3].real_reference;
9353 if (attribute_flag[4] != 0)
9354 channel=(ChannelType) argument_list[4].integer_reference;
9355 image=MotionBlurImageChannel(image,channel,geometry_info.rho,
9356 geometry_info.sigma,geometry_info.xi,exception);
9359 case 71: /* OrderedDither */
9361 if (attribute_flag[0] == 0)
9362 argument_list[0].string_reference="o8x8";
9363 if (attribute_flag[1] != 0)
9364 channel=(ChannelType) argument_list[1].integer_reference;
9365 (void) OrderedPosterizeImageChannel(image,channel,
9366 argument_list[0].string_reference,exception);
9369 case 72: /* Shave */
9371 if (attribute_flag[0] != 0)
9372 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9373 &geometry,exception);
9374 if (attribute_flag[1] != 0)
9375 geometry.width=argument_list[1].integer_reference;
9376 if (attribute_flag[2] != 0)
9377 geometry.height=argument_list[2].integer_reference;
9378 image=ShaveImage(image,&geometry,exception);
9381 case 73: /* Level */
9389 white_point=(MagickRealType) image->columns*image->rows;
9391 if (attribute_flag[0] != 0)
9393 flags=ParseGeometry(argument_list[0].string_reference,
9395 black_point=geometry_info.rho;
9396 if ((flags & SigmaValue) != 0)
9397 white_point=geometry_info.sigma;
9398 if ((flags & XiValue) != 0)
9399 gamma=geometry_info.xi;
9400 if ((flags & PercentValue) != 0)
9402 black_point*=(double) (QuantumRange/100.0);
9403 white_point*=(double) (QuantumRange/100.0);
9405 if ((flags & SigmaValue) == 0)
9406 white_point=(double) QuantumRange-black_point;
9408 if (attribute_flag[1] != 0)
9409 black_point=argument_list[1].real_reference;
9410 if (attribute_flag[2] != 0)
9411 white_point=argument_list[2].real_reference;
9412 if (attribute_flag[3] != 0)
9413 gamma=argument_list[3].real_reference;
9414 if (attribute_flag[4] != 0)
9415 channel=(ChannelType) argument_list[4].integer_reference;
9416 if (attribute_flag[5] != 0)
9418 argument_list[0].real_reference=argument_list[5].real_reference;
9419 attribute_flag[0]=attribute_flag[5];
9421 (void) LevelImageChannel(image,channel,black_point,white_point,gamma);
9426 if (attribute_flag[0] == 0)
9427 argument_list[0].string_reference="#1";
9428 if (attribute_flag[1] == 0)
9429 argument_list[1].integer_reference=MagickTrue;
9430 (void) ClipImagePath(image,argument_list[0].string_reference,
9431 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9434 case 75: /* AffineTransform */
9439 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9441 if (attribute_flag[0] != 0)
9446 av=(AV *) argument_list[0].array_reference;
9447 if ((av_len(av) != 3) && (av_len(av) != 5))
9449 ThrowPerlException(exception,OptionError,
9450 "affine matrix must have 4 or 6 elements",PackageName);
9453 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9454 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9455 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9456 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9457 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9458 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9460 ThrowPerlException(exception,OptionError,
9461 "affine matrix is singular",PackageName);
9464 if (av_len(av) == 5)
9466 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9467 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9470 for (j=1; j < 6; j++)
9472 if (attribute_flag[j] == 0)
9474 value=argument_list[j].string_reference;
9475 angle=argument_list[j].real_reference;
9476 current=draw_info->affine;
9477 GetAffineMatrix(&affine);
9485 flags=ParseGeometry(value,&geometry_info);
9486 affine.tx=geometry_info.xi;
9487 affine.ty=geometry_info.psi;
9488 if ((flags & PsiValue) == 0)
9489 affine.ty=affine.tx;
9497 flags=ParseGeometry(value,&geometry_info);
9498 affine.sx=geometry_info.rho;
9499 affine.sy=geometry_info.sigma;
9500 if ((flags & SigmaValue) == 0)
9501 affine.sy=affine.sx;
9511 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9512 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9513 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9514 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9522 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9530 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9534 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9535 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9536 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9537 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9538 draw_info->affine.tx=
9539 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9540 draw_info->affine.ty=
9541 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9543 if (attribute_flag[6] != 0)
9544 image->interpolate=(InterpolatePixelMethod)
9545 argument_list[6].integer_reference;
9546 if (attribute_flag[7] != 0)
9547 QueryColorDatabase(argument_list[7].string_reference,
9548 &image->background_color,exception);
9549 image=AffineTransformImage(image,&draw_info->affine,exception);
9550 draw_info=DestroyDrawInfo(draw_info);
9553 case 76: /* Difference */
9555 if (attribute_flag[0] == 0)
9557 ThrowPerlException(exception,OptionError,
9558 "ReferenceImageRequired",PackageName);
9561 if (attribute_flag[1] != 0)
9562 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9564 (void) IsImagesEqual(image,argument_list[0].image_reference);
9567 case 77: /* AdaptiveThreshold */
9569 if (attribute_flag[0] != 0)
9571 flags=ParseGeometry(argument_list[0].string_reference,
9573 if ((flags & PercentValue) != 0)
9574 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9576 if (attribute_flag[1] != 0)
9577 geometry_info.rho=argument_list[1].integer_reference;
9578 if (attribute_flag[2] != 0)
9579 geometry_info.sigma=argument_list[2].integer_reference;
9580 if (attribute_flag[3] != 0)
9581 geometry_info.xi=argument_list[3].integer_reference;;
9582 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9583 (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9587 case 78: /* Resample */
9593 if (attribute_flag[0] != 0)
9595 flags=ParseGeometry(argument_list[0].string_reference,
9597 if ((flags & SigmaValue) == 0)
9598 geometry_info.sigma=geometry_info.rho;
9600 if (attribute_flag[1] != 0)
9601 geometry_info.rho=argument_list[1].real_reference;
9602 if (attribute_flag[2] != 0)
9603 geometry_info.sigma=argument_list[2].real_reference;
9604 if (attribute_flag[3] == 0)
9605 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9606 if (attribute_flag[4] == 0)
9607 SetImageArtifact(image,"filter:support",
9608 argument_list[4].string_reference);
9609 if (attribute_flag[5] != 0)
9610 argument_list[5].real_reference=1.0;
9611 width=(size_t) (geometry_info.rho*image->columns/
9612 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9613 height=(size_t) (geometry_info.sigma*image->rows/
9614 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9615 image=ResizeImage(image,width,height,(FilterTypes)
9616 argument_list[3].integer_reference,argument_list[5].real_reference,
9618 if (image != (Image *) NULL)
9620 image->x_resolution=geometry_info.rho;
9621 image->y_resolution=geometry_info.sigma;
9625 case 79: /* Describe */
9627 if (attribute_flag[0] == 0)
9628 argument_list[0].file_reference=(FILE *) NULL;
9629 if (attribute_flag[1] != 0)
9630 (void) SetImageArtifact(image,"identify:features",
9631 argument_list[1].string_reference);
9632 (void) IdentifyImage(image,argument_list[0].file_reference,
9636 case 80: /* BlackThreshold */
9638 if (attribute_flag[0] == 0)
9639 argument_list[0].string_reference="50%";
9640 if (attribute_flag[2] != 0)
9641 channel=(ChannelType) argument_list[2].integer_reference;
9642 BlackThresholdImageChannel(image,channel,
9643 argument_list[0].string_reference,exception);
9646 case 81: /* WhiteThreshold */
9648 if (attribute_flag[0] == 0)
9649 argument_list[0].string_reference="50%";
9650 if (attribute_flag[2] != 0)
9651 channel=(ChannelType) argument_list[2].integer_reference;
9652 WhiteThresholdImageChannel(image,channel,
9653 argument_list[0].string_reference,exception);
9656 case 82: /* RadialBlur */
9658 if (attribute_flag[0] != 0)
9660 flags=ParseGeometry(argument_list[0].string_reference,
9662 if ((flags & SigmaValue) == 0)
9663 geometry_info.sigma=1.0;
9665 if (attribute_flag[1] != 0)
9666 geometry_info.rho=argument_list[1].real_reference;
9667 if (attribute_flag[2] != 0)
9668 channel=(ChannelType) argument_list[2].integer_reference;
9669 image=RadialBlurImageChannel(image,channel,geometry_info.rho,
9673 case 83: /* Thumbnail */
9675 if (attribute_flag[0] != 0)
9676 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9677 &geometry,exception);
9678 if (attribute_flag[1] != 0)
9679 geometry.width=argument_list[1].integer_reference;
9680 if (attribute_flag[2] != 0)
9681 geometry.height=argument_list[2].integer_reference;
9682 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9685 case 84: /* Strip */
9687 (void) StripImage(image);
9695 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9696 if (attribute_flag[0] != 0)
9697 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9699 if (attribute_flag[1] == 0)
9700 argument_list[1].string_reference="100";
9701 image=TintImage(image,argument_list[1].string_reference,target,
9705 case 86: /* Channel */
9707 if (attribute_flag[0] != 0)
9708 channel=(ChannelType) argument_list[0].integer_reference;
9709 (void) SeparateImageChannel(image,channel);
9712 case 87: /* Splice */
9714 if (attribute_flag[0] != 0)
9715 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9716 &geometry,exception);
9717 if (attribute_flag[1] != 0)
9718 geometry.width=argument_list[1].integer_reference;
9719 if (attribute_flag[2] != 0)
9720 geometry.height=argument_list[2].integer_reference;
9721 if (attribute_flag[3] != 0)
9722 geometry.x=argument_list[3].integer_reference;
9723 if (attribute_flag[4] != 0)
9724 geometry.y=argument_list[4].integer_reference;
9725 if (attribute_flag[5] != 0)
9726 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9728 if (attribute_flag[6] != 0)
9729 (void) QueryColorDatabase(argument_list[6].string_reference,
9730 &image->background_color,exception);
9731 if (attribute_flag[7] != 0)
9732 image->gravity=(GravityType) argument_list[7].integer_reference;
9733 image=SpliceImage(image,&geometry,exception);
9736 case 88: /* Posterize */
9738 if (attribute_flag[0] == 0)
9739 argument_list[0].integer_reference=3;
9740 if (attribute_flag[1] == 0)
9741 argument_list[1].integer_reference=0;
9742 (void) PosterizeImage(image,argument_list[0].integer_reference,
9743 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9746 case 89: /* Shadow */
9748 if (attribute_flag[0] != 0)
9750 flags=ParseGeometry(argument_list[0].string_reference,
9752 if ((flags & SigmaValue) == 0)
9753 geometry_info.sigma=1.0;
9754 if ((flags & XiValue) == 0)
9755 geometry_info.xi=4.0;
9756 if ((flags & PsiValue) == 0)
9757 geometry_info.psi=4.0;
9759 if (attribute_flag[1] != 0)
9760 geometry_info.rho=argument_list[1].real_reference;
9761 if (attribute_flag[2] != 0)
9762 geometry_info.sigma=argument_list[2].real_reference;
9763 if (attribute_flag[3] != 0)
9764 geometry_info.xi=argument_list[3].integer_reference;
9765 if (attribute_flag[4] != 0)
9766 geometry_info.psi=argument_list[4].integer_reference;
9767 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9768 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9772 case 90: /* Identify */
9774 if (attribute_flag[0] == 0)
9775 argument_list[0].file_reference=(FILE *) NULL;
9776 if (attribute_flag[1] != 0)
9777 (void) SetImageArtifact(image,"identify:features",
9778 argument_list[1].string_reference);
9779 if ((attribute_flag[2] != 0) &&
9780 (argument_list[2].integer_reference != 0))
9781 (void) SetImageArtifact(image,"identify:unique","true");
9782 (void) IdentifyImage(image,argument_list[0].file_reference,
9786 case 91: /* SepiaTone */
9788 if (attribute_flag[0] == 0)
9789 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9790 image=SepiaToneImage(image,argument_list[0].real_reference,
9794 case 92: /* SigmoidalContrast */
9799 if (attribute_flag[0] != 0)
9801 flags=ParseGeometry(argument_list[0].string_reference,
9803 if ((flags & SigmaValue) == 0)
9804 geometry_info.sigma=QuantumRange/2.0;
9805 if ((flags & PercentValue) != 0)
9806 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9808 if (attribute_flag[1] != 0)
9809 geometry_info.rho=argument_list[1].real_reference;
9810 if (attribute_flag[2] != 0)
9811 geometry_info.sigma=argument_list[2].real_reference;
9812 if (attribute_flag[3] != 0)
9813 channel=(ChannelType) argument_list[3].integer_reference;
9815 if (attribute_flag[4] != 0)
9816 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9818 (void) SigmoidalContrastImageChannel(image,channel,sharpen,
9819 geometry_info.rho,geometry_info.sigma);
9822 case 93: /* Extent */
9824 if (attribute_flag[7] != 0)
9825 image->gravity=(GravityType) argument_list[7].integer_reference;
9826 if (attribute_flag[0] != 0)
9831 flags=ParseGravityGeometry(image,
9832 argument_list[0].string_reference,&geometry,exception);
9833 if (geometry.width == 0)
9834 geometry.width=image->columns;
9835 if (geometry.height == 0)
9836 geometry.height=image->rows;
9838 if (attribute_flag[1] != 0)
9839 geometry.width=argument_list[1].integer_reference;
9840 if (attribute_flag[2] != 0)
9841 geometry.height=argument_list[2].integer_reference;
9842 if (attribute_flag[3] != 0)
9843 geometry.x=argument_list[3].integer_reference;
9844 if (attribute_flag[4] != 0)
9845 geometry.y=argument_list[4].integer_reference;
9846 if (attribute_flag[5] != 0)
9847 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9849 if (attribute_flag[6] != 0)
9850 (void) QueryColorDatabase(argument_list[6].string_reference,
9851 &image->background_color,exception);
9852 image=ExtentImage(image,&geometry,exception);
9855 case 94: /* Vignette */
9857 if (attribute_flag[0] != 0)
9859 flags=ParseGeometry(argument_list[0].string_reference,
9861 if ((flags & SigmaValue) == 0)
9862 geometry_info.sigma=1.0;
9863 if ((flags & XiValue) == 0)
9864 geometry_info.xi=0.1*image->columns;
9865 if ((flags & PsiValue) == 0)
9866 geometry_info.psi=0.1*image->rows;
9868 if (attribute_flag[1] != 0)
9869 geometry_info.rho=argument_list[1].real_reference;
9870 if (attribute_flag[2] != 0)
9871 geometry_info.sigma=argument_list[2].real_reference;
9872 if (attribute_flag[3] != 0)
9873 geometry_info.xi=argument_list[3].integer_reference;
9874 if (attribute_flag[4] != 0)
9875 geometry_info.psi=argument_list[4].integer_reference;
9876 if (attribute_flag[5] != 0)
9877 (void) QueryColorDatabase(argument_list[5].string_reference,
9878 &image->background_color,exception);
9879 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9880 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9884 case 95: /* ContrastStretch */
9891 white_point=(MagickRealType) image->columns*image->rows;
9892 if (attribute_flag[0] != 0)
9894 flags=ParseGeometry(argument_list[0].string_reference,
9896 black_point=geometry_info.rho;
9897 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9899 if ((flags & PercentValue) != 0)
9901 black_point*=(double) image->columns*image->rows/100.0;
9902 white_point*=(double) image->columns*image->rows/100.0;
9904 white_point=(MagickRealType) image->columns*image->rows-
9907 if (attribute_flag[1] != 0)
9908 black_point=argument_list[1].real_reference;
9909 if (attribute_flag[2] != 0)
9910 white_point=argument_list[2].real_reference;
9911 if (attribute_flag[4] != 0)
9912 channel=(ChannelType) argument_list[4].integer_reference;
9913 (void) ContrastStretchImageChannel(image,channel,black_point,
9917 case 96: /* Sans0 */
9921 case 97: /* Sans1 */
9925 case 98: /* AdaptiveSharpen */
9927 if (attribute_flag[0] != 0)
9929 flags=ParseGeometry(argument_list[0].string_reference,
9931 if ((flags & SigmaValue) == 0)
9932 geometry_info.sigma=1.0;
9934 if (attribute_flag[1] != 0)
9935 geometry_info.rho=argument_list[1].real_reference;
9936 if (attribute_flag[2] != 0)
9937 geometry_info.sigma=argument_list[2].real_reference;
9938 if (attribute_flag[3] != 0)
9939 channel=(ChannelType) argument_list[3].integer_reference;
9940 image=AdaptiveSharpenImageChannel(image,channel,geometry_info.rho,
9941 geometry_info.sigma,exception);
9944 case 99: /* Transpose */
9946 image=TransposeImage(image,exception);
9949 case 100: /* Tranverse */
9951 image=TransverseImage(image,exception);
9954 case 101: /* AutoOrient */
9956 switch (image->orientation)
9958 case TopRightOrientation:
9960 image=FlopImage(image,exception);
9963 case BottomRightOrientation:
9965 image=RotateImage(image,180.0,exception);
9968 case BottomLeftOrientation:
9970 image=FlipImage(image,exception);
9973 case LeftTopOrientation:
9975 image=TransposeImage(image,exception);
9978 case RightTopOrientation:
9980 image=RotateImage(image,90.0,exception);
9983 case RightBottomOrientation:
9985 image=TransverseImage(image,exception);
9988 case LeftBottomOrientation:
9990 image=RotateImage(image,270.0,exception);
9998 case 102: /* AdaptiveBlur */
10000 if (attribute_flag[0] != 0)
10002 flags=ParseGeometry(argument_list[0].string_reference,
10004 if ((flags & SigmaValue) == 0)
10005 geometry_info.sigma=1.0;
10007 if (attribute_flag[1] != 0)
10008 geometry_info.rho=argument_list[1].real_reference;
10009 if (attribute_flag[2] != 0)
10010 geometry_info.sigma=argument_list[2].real_reference;
10011 if (attribute_flag[3] != 0)
10012 channel=(ChannelType) argument_list[3].integer_reference;
10013 image=AdaptiveBlurImageChannel(image,channel,geometry_info.rho,
10014 geometry_info.sigma,exception);
10017 case 103: /* Sketch */
10019 if (attribute_flag[0] != 0)
10021 flags=ParseGeometry(argument_list[0].string_reference,
10023 if ((flags & SigmaValue) == 0)
10024 geometry_info.sigma=1.0;
10025 if ((flags & XiValue) == 0)
10026 geometry_info.xi=1.0;
10028 if (attribute_flag[1] != 0)
10029 geometry_info.rho=argument_list[1].real_reference;
10030 if (attribute_flag[2] != 0)
10031 geometry_info.sigma=argument_list[2].real_reference;
10032 if (attribute_flag[3] != 0)
10033 geometry_info.xi=argument_list[3].real_reference;
10034 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10035 geometry_info.xi,exception);
10038 case 104: /* UniqueColors */
10040 image=UniqueImageColors(image,exception);
10043 case 105: /* AdaptiveResize */
10045 if (attribute_flag[0] != 0)
10046 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10047 &geometry,exception);
10048 if (attribute_flag[1] != 0)
10049 geometry.width=argument_list[1].integer_reference;
10050 if (attribute_flag[2] != 0)
10051 geometry.height=argument_list[2].integer_reference;
10052 if (attribute_flag[3] != 0)
10053 image->filter=(FilterTypes) argument_list[4].integer_reference;
10054 if (attribute_flag[4] != 0)
10055 SetImageArtifact(image,"filter:support",
10056 argument_list[4].string_reference);
10057 if (attribute_flag[5] != 0)
10058 image->blur=argument_list[5].real_reference;
10059 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10063 case 106: /* ClipMask */
10065 if (attribute_flag[0] == 0)
10067 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10069 goto PerlException;
10071 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10072 MagickTrue,exception);
10073 (void) NegateImage(image->clip_mask,MagickFalse);
10076 case 107: /* LinearStretch */
10083 white_point=(MagickRealType) image->columns*image->rows;
10084 if (attribute_flag[0] != 0)
10086 flags=ParseGeometry(argument_list[0].string_reference,
10088 if ((flags & SigmaValue) != 0)
10089 white_point=geometry_info.sigma;
10090 if ((flags & PercentValue) != 0)
10092 black_point*=(double) image->columns*image->rows/100.0;
10093 white_point*=(double) image->columns*image->rows/100.0;
10095 if ((flags & SigmaValue) == 0)
10096 white_point=(double) image->columns*image->rows-black_point;
10098 if (attribute_flag[1] != 0)
10099 black_point=argument_list[1].real_reference;
10100 if (attribute_flag[2] != 0)
10101 white_point=argument_list[2].real_reference;
10102 (void) LinearStretchImage(image,black_point,white_point);
10105 case 109: /* Mask */
10107 if (attribute_flag[0] == 0)
10109 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10111 goto PerlException;
10113 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10114 MagickTrue,exception);
10115 (void) NegateImage(image->mask,MagickFalse);
10118 case 110: /* Polaroid */
10126 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10127 (DrawInfo *) NULL);
10128 if (attribute_flag[0] != 0)
10129 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10130 info ? info->image_info : (ImageInfo *) NULL,image,
10131 argument_list[0].string_reference));
10133 if (attribute_flag[1] != 0)
10134 angle=argument_list[1].real_reference;
10135 if (attribute_flag[2] != 0)
10136 (void) CloneString(&draw_info->font,
10137 argument_list[2].string_reference);
10138 if (attribute_flag[3] != 0)
10139 (void) QueryColorDatabase(argument_list[3].string_reference,
10140 &draw_info->stroke,exception);
10141 if (attribute_flag[4] != 0)
10142 (void) QueryColorDatabase(argument_list[4].string_reference,
10143 &draw_info->fill,exception);
10144 if (attribute_flag[5] != 0)
10145 draw_info->stroke_width=argument_list[5].real_reference;
10146 if (attribute_flag[6] != 0)
10147 draw_info->pointsize=argument_list[6].real_reference;
10148 if (attribute_flag[7] != 0)
10149 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10150 if (attribute_flag[8] != 0)
10151 (void) QueryColorDatabase(argument_list[8].string_reference,
10152 &image->background_color,exception);
10153 image=PolaroidImage(image,draw_info,angle,exception);
10154 draw_info=DestroyDrawInfo(draw_info);
10157 case 111: /* FloodfillPaint */
10168 draw_info=CloneDrawInfo(info ? info->image_info :
10169 (ImageInfo *) NULL,(DrawInfo *) NULL);
10170 if (attribute_flag[0] != 0)
10171 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10172 &geometry,exception);
10173 if (attribute_flag[1] != 0)
10174 geometry.x=argument_list[1].integer_reference;
10175 if (attribute_flag[2] != 0)
10176 geometry.y=argument_list[2].integer_reference;
10177 if (attribute_flag[3] != 0)
10178 (void) QueryColorDatabase(argument_list[3].string_reference,
10179 &draw_info->fill,exception);
10180 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10182 if (attribute_flag[4] != 0)
10183 QueryMagickColor(argument_list[4].string_reference,&target,
10185 if (attribute_flag[5] != 0)
10186 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10188 if (attribute_flag[6] != 0)
10189 channel=(ChannelType) argument_list[6].integer_reference;
10190 invert=MagickFalse;
10191 if (attribute_flag[7] != 0)
10192 invert=(MagickBooleanType) argument_list[7].integer_reference;
10193 (void) FloodfillPaintImage(image,channel,draw_info,&target,geometry.x,
10194 geometry.y,invert);
10195 draw_info=DestroyDrawInfo(draw_info);
10198 case 112: /* Distort */
10210 number_coordinates;
10215 if (attribute_flag[0] == 0)
10217 method=UndefinedDistortion;
10218 if (attribute_flag[1] != 0)
10219 method=(DistortImageMethod) argument_list[1].integer_reference;
10220 av=(AV *) argument_list[0].array_reference;
10221 number_coordinates=(size_t) av_len(av)+1;
10222 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10223 sizeof(*coordinates));
10224 if (coordinates == (double *) NULL)
10226 ThrowPerlException(exception,ResourceLimitFatalError,
10227 "MemoryAllocationFailed",PackageName);
10228 goto PerlException;
10230 for (j=0; j < (ssize_t) number_coordinates; j++)
10231 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10232 virtual_pixel=UndefinedVirtualPixelMethod;
10233 if (attribute_flag[2] != 0)
10234 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10235 argument_list[2].integer_reference);
10236 image=DistortImage(image,method,number_coordinates,coordinates,
10237 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10239 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10240 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10241 coordinates=(double *) RelinquishMagickMemory(coordinates);
10244 case 113: /* Clut */
10246 if (attribute_flag[0] == 0)
10248 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10250 goto PerlException;
10252 if (attribute_flag[1] != 0)
10253 channel=(ChannelType) argument_list[1].integer_reference;
10254 (void) ClutImageChannel(image,channel,
10255 argument_list[0].image_reference);
10258 case 114: /* LiquidRescale */
10260 if (attribute_flag[0] != 0)
10261 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10262 &geometry,exception);
10263 if (attribute_flag[1] != 0)
10264 geometry.width=argument_list[1].integer_reference;
10265 if (attribute_flag[2] != 0)
10266 geometry.height=argument_list[2].integer_reference;
10267 if (attribute_flag[3] == 0)
10268 argument_list[3].real_reference=1.0;
10269 if (attribute_flag[4] == 0)
10270 argument_list[4].real_reference=0.0;
10271 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10272 argument_list[3].real_reference,argument_list[4].real_reference,
10276 case 115: /* EncipherImage */
10278 (void) EncipherImage(image,argument_list[0].string_reference,
10282 case 116: /* DecipherImage */
10284 (void) DecipherImage(image,argument_list[0].string_reference,
10288 case 117: /* Deskew */
10290 geometry_info.rho=QuantumRange/2.0;
10291 if (attribute_flag[0] != 0)
10292 flags=ParseGeometry(argument_list[0].string_reference,
10294 if (attribute_flag[1] != 0)
10295 geometry_info.rho=SiPrefixToDouble(
10296 argument_list[1].string_reference,QuantumRange);
10297 image=DeskewImage(image,geometry_info.rho,exception);
10300 case 118: /* Remap */
10305 if (attribute_flag[0] == 0)
10307 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10309 goto PerlException;
10311 quantize_info=AcquireQuantizeInfo(info->image_info);
10312 if (attribute_flag[1] != 0)
10313 quantize_info->dither=(MagickBooleanType)
10314 argument_list[1].integer_reference;
10315 if (attribute_flag[2] != 0)
10316 quantize_info->dither_method=(DitherMethod)
10317 argument_list[2].integer_reference;
10318 (void) RemapImages(quantize_info,image,
10319 argument_list[0].image_reference);
10320 quantize_info=DestroyQuantizeInfo(quantize_info);
10323 case 119: /* SparseColor */
10335 number_coordinates;
10340 if (attribute_flag[0] == 0)
10342 method=UndefinedColorInterpolate;
10343 if (attribute_flag[1] != 0)
10344 method=(SparseColorMethod) argument_list[1].integer_reference;
10345 av=(AV *) argument_list[0].array_reference;
10346 number_coordinates=(size_t) av_len(av)+1;
10347 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10348 sizeof(*coordinates));
10349 if (coordinates == (double *) NULL)
10351 ThrowPerlException(exception,ResourceLimitFatalError,
10352 "MemoryAllocationFailed",PackageName);
10353 goto PerlException;
10355 for (j=0; j < (ssize_t) number_coordinates; j++)
10356 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10357 virtual_pixel=UndefinedVirtualPixelMethod;
10358 if (attribute_flag[2] != 0)
10359 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10360 argument_list[2].integer_reference);
10361 if (attribute_flag[3] != 0)
10362 channel=(ChannelType) argument_list[3].integer_reference;
10363 image=SparseColorImage(image,channel,method,number_coordinates,
10364 coordinates,exception);
10365 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10366 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10367 coordinates=(double *) RelinquishMagickMemory(coordinates);
10370 case 120: /* Function */
10387 if (attribute_flag[0] == 0)
10389 function=UndefinedFunction;
10390 if (attribute_flag[1] != 0)
10391 function=(MagickFunction) argument_list[1].integer_reference;
10392 av=(AV *) argument_list[0].array_reference;
10393 number_parameters=(size_t) av_len(av)+1;
10394 parameters=(double *) AcquireQuantumMemory(number_parameters,
10395 sizeof(*parameters));
10396 if (parameters == (double *) NULL)
10398 ThrowPerlException(exception,ResourceLimitFatalError,
10399 "MemoryAllocationFailed",PackageName);
10400 goto PerlException;
10402 for (j=0; j < (ssize_t) number_parameters; j++)
10403 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10404 virtual_pixel=UndefinedVirtualPixelMethod;
10405 if (attribute_flag[2] != 0)
10406 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10407 argument_list[2].integer_reference);
10408 (void) FunctionImage(image,function,number_parameters,parameters,
10410 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10411 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10412 parameters=(double *) RelinquishMagickMemory(parameters);
10415 case 121: /* SelectiveBlur */
10417 if (attribute_flag[0] != 0)
10419 flags=ParseGeometry(argument_list[0].string_reference,
10421 if ((flags & SigmaValue) == 0)
10422 geometry_info.sigma=1.0;
10423 if ((flags & PercentValue) != 0)
10424 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10426 if (attribute_flag[1] != 0)
10427 geometry_info.rho=argument_list[1].real_reference;
10428 if (attribute_flag[2] != 0)
10429 geometry_info.sigma=argument_list[2].real_reference;
10430 if (attribute_flag[3] != 0)
10431 geometry_info.xi=argument_list[3].integer_reference;;
10432 if (attribute_flag[4] != 0)
10433 channel=(ChannelType) argument_list[4].integer_reference;
10434 image=SelectiveBlurImageChannel(image,channel,geometry_info.rho,
10435 geometry_info.sigma,geometry_info.xi,exception);
10438 case 122: /* HaldClut */
10440 if (attribute_flag[0] == 0)
10442 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10444 goto PerlException;
10446 if (attribute_flag[1] != 0)
10447 channel=(ChannelType) argument_list[1].integer_reference;
10448 (void) HaldClutImageChannel(image,channel,
10449 argument_list[0].image_reference);
10452 case 123: /* BlueShift */
10454 if (attribute_flag[0] != 0)
10455 (void) ParseGeometry(argument_list[0].string_reference,
10457 image=BlueShiftImage(image,geometry_info.rho,exception);
10460 case 124: /* ForwardFourierTransformImage */
10462 image=ForwardFourierTransformImage(image,
10463 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10467 case 125: /* InverseFourierTransformImage */
10469 image=InverseFourierTransformImage(image,image->next,
10470 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10474 case 126: /* ColorDecisionList */
10476 if (attribute_flag[0] == 0)
10477 argument_list[0].string_reference=(char *) NULL;
10478 (void) ColorDecisionListImage(image,
10479 argument_list[0].string_reference);
10482 case 127: /* AutoGamma */
10484 if (attribute_flag[0] != 0)
10485 channel=(ChannelType) argument_list[0].integer_reference;
10486 (void) AutoGammaImageChannel(image,channel);
10489 case 128: /* AutoLevel */
10491 if (attribute_flag[0] != 0)
10492 channel=(ChannelType) argument_list[0].integer_reference;
10493 (void) AutoLevelImageChannel(image,channel);
10496 case 129: /* LevelColors */
10502 (void) QueryMagickColor("#000000",&black_point,exception);
10503 (void) QueryMagickColor("#ffffff",&white_point,exception);
10504 if (attribute_flag[1] != 0)
10505 (void) QueryMagickColor(argument_list[1].string_reference,
10506 &black_point,exception);
10507 if (attribute_flag[2] != 0)
10508 (void) QueryMagickColor(argument_list[2].string_reference,
10509 &white_point,exception);
10510 if (attribute_flag[3] != 0)
10511 channel=(ChannelType) argument_list[3].integer_reference;
10512 (void) LevelColorsImageChannel(image,channel,&black_point,
10513 &white_point,argument_list[0].integer_reference != 0 ? MagickTrue :
10517 case 130: /* Clamp */
10519 if (attribute_flag[0] != 0)
10520 channel=(ChannelType) argument_list[0].integer_reference;
10521 (void) ClampImageChannel(image,channel);
10524 case 131: /* Filter */
10529 if (attribute_flag[0] == 0)
10531 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10532 if (kernel == (KernelInfo *) NULL)
10534 if (attribute_flag[1] != 0)
10535 channel=(ChannelType) argument_list[1].integer_reference;
10536 if (attribute_flag[2] != 0)
10537 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10539 image=FilterImageChannel(image,channel,kernel,exception);
10540 kernel=DestroyKernelInfo(kernel);
10543 case 132: /* BrightnessContrast */
10551 if (attribute_flag[0] != 0)
10553 flags=ParseGeometry(argument_list[0].string_reference,
10555 brightness=geometry_info.rho;
10556 if ((flags & SigmaValue) == 0)
10557 contrast=geometry_info.sigma;
10559 if (attribute_flag[1] != 0)
10560 brightness=argument_list[1].real_reference;
10561 if (attribute_flag[2] != 0)
10562 contrast=argument_list[2].real_reference;
10563 if (attribute_flag[4] != 0)
10564 channel=(ChannelType) argument_list[4].integer_reference;
10565 (void) BrightnessContrastImageChannel(image,channel,brightness,
10569 case 133: /* Morphology */
10580 if (attribute_flag[0] == 0)
10582 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10583 if (kernel == (KernelInfo *) NULL)
10585 if (attribute_flag[1] != 0)
10586 channel=(ChannelType) argument_list[1].integer_reference;
10587 method=UndefinedMorphology;
10588 if (attribute_flag[2] != 0)
10589 method=argument_list[2].integer_reference;
10591 if (attribute_flag[3] != 0)
10592 iterations=argument_list[4].integer_reference;
10593 image=MorphologyImageChannel(image,channel,method,iterations,kernel,
10595 kernel=DestroyKernelInfo(kernel);
10598 case 108: /* Recolor */
10599 case 134: /* ColorMatrix */
10613 if (attribute_flag[0] == 0)
10615 av=(AV *) argument_list[0].array_reference;
10616 order=(size_t) sqrt(av_len(av)+1);
10617 color_matrix=(double *) AcquireQuantumMemory(order,order*
10618 sizeof(*color_matrix));
10619 if (color_matrix == (double *) NULL)
10621 ThrowPerlException(exception,ResourceLimitFatalError,
10622 "MemoryAllocationFailed",PackageName);
10623 goto PerlException;
10625 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10626 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10627 for ( ; j < (ssize_t) (order*order); j++)
10628 color_matrix[j]=0.0;
10629 kernel_info=AcquireKernelInfo("1");
10630 if (kernel_info == (KernelInfo *) NULL)
10632 kernel_info->width=order;
10633 kernel_info->height=order;
10634 kernel_info->values=color_matrix;
10635 image=ColorMatrixImage(image,kernel_info,exception);
10636 kernel_info->values=(double *) NULL;
10637 kernel_info=DestroyKernelInfo(kernel_info);
10638 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10641 case 135: /* Color */
10646 (void) QueryMagickColor("none",&color,exception);
10647 if (attribute_flag[0] != 0)
10648 (void) QueryMagickColor(argument_list[0].string_reference,
10650 (void) SetImageColor(image,&color);
10653 case 136: /* Mode */
10655 if (attribute_flag[0] != 0)
10657 flags=ParseGeometry(argument_list[0].string_reference,
10659 if ((flags & SigmaValue) == 0)
10660 geometry_info.sigma=1.0;
10662 if (attribute_flag[1] != 0)
10663 geometry_info.rho=argument_list[1].real_reference;
10664 if (attribute_flag[2] != 0)
10665 geometry_info.sigma=argument_list[2].real_reference;
10666 if (attribute_flag[3] != 0)
10667 channel=(ChannelType) argument_list[3].integer_reference;
10668 image=StatisticImageChannel(image,channel,ModeStatistic,
10669 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10672 case 137: /* Statistic */
10677 statistic=UndefinedStatistic;
10678 if (attribute_flag[0] != 0)
10680 flags=ParseGeometry(argument_list[0].string_reference,
10682 if ((flags & SigmaValue) == 0)
10683 geometry_info.sigma=1.0;
10685 if (attribute_flag[1] != 0)
10686 geometry_info.rho=argument_list[1].real_reference;
10687 if (attribute_flag[2] != 0)
10688 geometry_info.sigma=argument_list[2].real_reference;
10689 if (attribute_flag[3] != 0)
10690 channel=(ChannelType) argument_list[3].integer_reference;
10691 if (attribute_flag[4] != 0)
10692 statistic=(StatisticType) argument_list[4].integer_reference;
10693 image=StatisticImageChannel(image,channel,statistic,
10694 (size_t) geometry_info.rho,(size_t) geometry_info.sigma,exception);
10698 if (next != (Image *) NULL)
10699 (void) CatchImageException(next);
10700 if (region_image != (Image *) NULL)
10705 status=CompositeImage(region_image,CopyCompositeOp,image,
10706 region_info.x,region_info.y);
10707 (void) CatchImageException(region_image);
10708 image=DestroyImage(image);
10709 image=region_image;
10711 if (image != (Image *) NULL)
10714 if (next && (next != image))
10716 image->next=next->next;
10717 DeleteImageFromRegistry(*pv,next);
10719 sv_setiv(*pv,(IV) image);
10727 if (reference_vector)
10728 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10729 InheritPerlException(exception,perl_exception);
10730 exception=DestroyExceptionInfo(exception);
10731 sv_setiv(perl_exception,(IV) number_images);
10732 SvPOK_on(perl_exception);
10733 ST(0)=sv_2mortal(perl_exception);
10738 ###############################################################################
10746 ###############################################################################
10751 Image::Magick ref=NO_INIT
10796 PERL_UNUSED_VAR(ref);
10797 PERL_UNUSED_VAR(ix);
10798 exception=AcquireExceptionInfo();
10799 perl_exception=newSVpv("",0);
10802 if (sv_isobject(ST(0)) == 0)
10804 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10806 goto PerlException;
10808 reference=SvRV(ST(0));
10809 hv=SvSTASH(reference);
10811 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10813 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10814 if (image == (Image *) NULL)
10816 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10818 goto PerlException;
10823 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10824 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10825 (void) QueryMagickColor("none",&transparent_color,exception);
10826 for (i=2; i < items; i+=2)
10828 attribute=(char *) SvPV(ST(i-1),na);
10829 switch (*attribute)
10834 if (LocaleCompare(attribute,"background") == 0)
10836 (void) QueryColorDatabase(SvPV(ST(i),na),
10837 &montage_info->background_color,exception);
10838 for (next=image; next; next=next->next)
10839 next->background_color=montage_info->background_color;
10842 if (LocaleCompare(attribute,"border") == 0)
10844 montage_info->border_width=SvIV(ST(i));
10847 if (LocaleCompare(attribute,"bordercolor") == 0)
10849 (void) QueryColorDatabase(SvPV(ST(i),na),
10850 &montage_info->border_color,exception);
10851 for (next=image; next; next=next->next)
10852 next->border_color=montage_info->border_color;
10855 if (LocaleCompare(attribute,"borderwidth") == 0)
10857 montage_info->border_width=SvIV(ST(i));
10860 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10867 if (LocaleCompare(attribute,"compose") == 0)
10869 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10870 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10873 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10877 for (next=image; next; next=next->next)
10878 next->compose=(CompositeOperator) sp;
10881 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10888 if (LocaleCompare(attribute,"fill") == 0)
10890 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10894 if (LocaleCompare(attribute,"font") == 0)
10896 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10899 if (LocaleCompare(attribute,"frame") == 0)
10905 if (IsGeometry(p) == MagickFalse)
10907 ThrowPerlException(exception,OptionError,"MissingGeometry",
10911 (void) CloneString(&montage_info->frame,p);
10913 montage_info->frame=(char *) NULL;
10916 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10923 if (LocaleCompare(attribute,"geometry") == 0)
10929 if (IsGeometry(p) == MagickFalse)
10931 ThrowPerlException(exception,OptionError,"MissingGeometry",
10935 (void) CloneString(&montage_info->geometry,p);
10937 montage_info->geometry=(char *) NULL;
10940 if (LocaleCompare(attribute,"gravity") == 0)
10945 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10946 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10949 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10953 montage_info->gravity=(GravityType) in;
10954 for (next=image; next; next=next->next)
10955 next->gravity=(GravityType) in;
10958 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10965 if (LocaleCompare(attribute,"label") == 0)
10967 for (next=image; next; next=next->next)
10968 (void) SetImageProperty(next,"label",InterpretImageProperties(
10969 info ? info->image_info : (ImageInfo *) NULL,next,
10973 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10980 if (LocaleCompare(attribute,"mattecolor") == 0)
10982 (void) QueryColorDatabase(SvPV(ST(i),na),
10983 &montage_info->matte_color,exception);
10984 for (next=image; next; next=next->next)
10985 next->matte_color=montage_info->matte_color;
10988 if (LocaleCompare(attribute,"mode") == 0)
10993 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10994 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10999 ThrowPerlException(exception,OptionError,
11000 "UnrecognizedModeType",SvPV(ST(i),na));
11005 (void) CloneString(&montage_info->frame,"15x15+3+3");
11006 montage_info->shadow=MagickTrue;
11011 montage_info->frame=(char *) NULL;
11012 montage_info->shadow=MagickFalse;
11013 montage_info->border_width=0;
11016 case ConcatenateMode:
11018 montage_info->frame=(char *) NULL;
11019 montage_info->shadow=MagickFalse;
11020 (void) CloneString(&montage_info->geometry,"+0+0");
11021 montage_info->border_width=0;
11026 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11033 if (LocaleCompare(attribute,"pointsize") == 0)
11035 montage_info->pointsize=SvIV(ST(i));
11038 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11045 if (LocaleCompare(attribute,"shadow") == 0)
11047 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11048 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11051 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11055 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11058 if (LocaleCompare(attribute,"stroke") == 0)
11060 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11064 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11071 if (LocaleCompare(attribute,"texture") == 0)
11073 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11076 if (LocaleCompare(attribute,"tile") == 0)
11078 char *p=SvPV(ST(i),na);
11079 if (IsGeometry(p) == MagickFalse)
11081 ThrowPerlException(exception,OptionError,"MissingGeometry",
11085 (void) CloneString(&montage_info->tile,p);
11087 montage_info->tile=(char *) NULL;
11090 if (LocaleCompare(attribute,"title") == 0)
11092 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11095 if (LocaleCompare(attribute,"transparent") == 0)
11100 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11101 for (next=image; next; next=next->next)
11102 (void) TransparentPaintImage(next,&transparent_color,
11103 TransparentOpacity,MagickFalse);
11106 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11112 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11118 image=MontageImageList(info->image_info,montage_info,image,exception);
11119 montage_info=DestroyMontageInfo(montage_info);
11120 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11121 goto PerlException;
11122 if (transparent_color.opacity != TransparentOpacity)
11123 for (next=image; next; next=next->next)
11124 (void) TransparentPaintImage(next,&transparent_color,
11125 TransparentOpacity,MagickFalse);
11126 for ( ; image; image=image->next)
11128 AddImageToRegistry(sv,image);
11130 av_push(av,sv_bless(rv,hv));
11133 exception=DestroyExceptionInfo(exception);
11134 ST(0)=av_reference;
11135 SvREFCNT_dec(perl_exception);
11139 InheritPerlException(exception,perl_exception);
11140 exception=DestroyExceptionInfo(exception);
11141 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11142 SvPOK_on(perl_exception);
11143 ST(0)=sv_2mortal(perl_exception);
11148 ###############################################################################
11156 ###############################################################################
11161 Image::Magick ref=NO_INIT
11199 PERL_UNUSED_VAR(ref);
11200 PERL_UNUSED_VAR(ix);
11201 exception=AcquireExceptionInfo();
11202 perl_exception=newSVpv("",0);
11206 if (sv_isobject(ST(0)) == 0)
11208 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11210 goto PerlException;
11212 reference=SvRV(ST(0));
11213 hv=SvSTASH(reference);
11215 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11217 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11218 if (image == (Image *) NULL)
11220 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11222 goto PerlException;
11224 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11229 for (i=2; i < items; i+=2)
11231 attribute=(char *) SvPV(ST(i-1),na);
11232 switch (*attribute)
11237 if (LocaleCompare(attribute,"frames") == 0)
11239 number_frames=SvIV(ST(i));
11242 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11248 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11254 image=MorphImages(image,number_frames,exception);
11255 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11256 goto PerlException;
11257 for ( ; image; image=image->next)
11259 AddImageToRegistry(sv,image);
11261 av_push(av,sv_bless(rv,hv));
11264 exception=DestroyExceptionInfo(exception);
11265 ST(0)=av_reference;
11266 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11270 InheritPerlException(exception,perl_exception);
11271 exception=DestroyExceptionInfo(exception);
11272 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11273 SvPOK_on(perl_exception);
11274 ST(0)=sv_2mortal(perl_exception);
11279 ###############################################################################
11287 ###############################################################################
11292 Image::Magick ref=NO_INIT
11320 PERL_UNUSED_VAR(ref);
11321 PERL_UNUSED_VAR(ix);
11322 exception=AcquireExceptionInfo();
11323 perl_exception=newSVpv("",0);
11325 if (sv_isobject(ST(0)) == 0)
11327 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11329 goto PerlException;
11331 reference=SvRV(ST(0));
11332 hv=SvSTASH(reference);
11333 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11334 if (image == (Image *) NULL)
11336 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11338 goto PerlException;
11340 image=MergeImageLayers(image,MosaicLayer,exception);
11342 Create blessed Perl array for the returned image.
11345 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11347 AddImageToRegistry(sv,image);
11349 av_push(av,sv_bless(rv,hv));
11351 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11352 (void) CopyMagickString(image->filename,info->image_info->filename,
11354 SetImageInfo(info->image_info,0,&image->exception);
11355 exception=DestroyExceptionInfo(exception);
11356 SvREFCNT_dec(perl_exception);
11360 InheritPerlException(exception,perl_exception);
11361 exception=DestroyExceptionInfo(exception);
11362 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11363 SvPOK_on(perl_exception); /* return messages in string context */
11364 ST(0)=sv_2mortal(perl_exception);
11369 ###############################################################################
11377 ###############################################################################
11382 Image::Magick ref=NO_INIT
11435 PERL_UNUSED_VAR(ref);
11436 PERL_UNUSED_VAR(ix);
11437 exception=AcquireExceptionInfo();
11438 perl_exception=newSVpv("",0);
11439 package_info=(struct PackageInfo *) NULL;
11440 ac=(items < 2) ? 1 : items-1;
11441 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11443 length=(STRLEN *) NULL;
11444 if (list == (char **) NULL)
11446 ThrowPerlException(exception,ResourceLimitError,
11447 "MemoryAllocationFailed",PackageName);
11448 goto PerlException;
11451 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11452 if (length == (STRLEN *) NULL)
11454 ThrowPerlException(exception,ResourceLimitError,
11455 "MemoryAllocationFailed",PackageName);
11456 goto PerlException;
11458 if (sv_isobject(ST(0)) == 0)
11460 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11462 goto PerlException;
11464 reference=SvRV(ST(0));
11465 hv=SvSTASH(reference);
11466 if (SvTYPE(reference) != SVt_PVAV)
11468 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11470 goto PerlException;
11472 av=(AV *) reference;
11473 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11475 package_info=ClonePackageInfo(info,exception);
11478 *list=(char *) (*package_info->image_info->filename ?
11479 package_info->image_info->filename : "XC:black");
11481 for (n=0, i=0; i < ac; i++)
11483 list[n]=(char *) SvPV(ST(i+1),length[n]);
11484 if ((items >= 3) && strEQcase(list[n],"blob"))
11490 blob=(void *) (SvPV(ST(i+1),length[n]));
11491 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11493 if ((items >= 3) && strEQcase(list[n],"filename"))
11495 if ((items >= 3) && strEQcase(list[n],"file"))
11504 io_info=IoIFP(sv_2io(ST(i+1)));
11505 if (io_info == (PerlIO *) NULL)
11507 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11511 file=PerlIO_findFILE(io_info);
11512 if (file == (FILE *) NULL)
11514 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11518 SetImageInfoFile(package_info->image_info,file);
11520 if ((items >= 3) && strEQcase(list[n],"magick"))
11524 list[n]=(char *) NULL;
11526 status=ExpandFilenames(&n,&list);
11527 if (status == MagickFalse)
11529 ThrowPerlException(exception,ResourceLimitError,
11530 "MemoryAllocationFailed",PackageName);
11531 goto PerlException;
11534 for (i=0; i < n; i++)
11536 (void) CopyMagickString(package_info->image_info->filename,list[i],
11538 image=PingImage(package_info->image_info,exception);
11539 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11541 if ((package_info->image_info->file != (FILE *) NULL) ||
11542 (package_info->image_info->blob != (void *) NULL))
11543 DisassociateImageStream(image);
11544 count+=GetImageListLength(image);
11545 EXTEND(sp,4*count);
11546 for (next=image; next; next=next->next)
11548 PUSHs(sv_2mortal(newSViv(next->columns)));
11549 PUSHs(sv_2mortal(newSViv(next->rows)));
11550 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11551 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11553 image=DestroyImageList(image);
11558 for (i=0; i < n; i++)
11559 if (list[i] != (char *) NULL)
11560 for (p=keep; list[i] != *p++; )
11563 list[i]=(char *) RelinquishMagickMemory(list[i]);
11568 if (package_info != (struct PackageInfo *) NULL)
11569 DestroyPackageInfo(package_info);
11570 if (list && (list != keep))
11571 list=(char **) RelinquishMagickMemory(list);
11573 keep=(char **) RelinquishMagickMemory(keep);
11575 length=(STRLEN *) RelinquishMagickMemory(length);
11576 InheritPerlException(exception,perl_exception);
11577 exception=DestroyExceptionInfo(exception);
11578 SvREFCNT_dec(perl_exception); /* throw away all errors */
11582 ###############################################################################
11590 ###############################################################################
11595 Image::Magick ref=NO_INIT
11628 PERL_UNUSED_VAR(ref);
11629 PERL_UNUSED_VAR(ix);
11630 exception=AcquireExceptionInfo();
11631 perl_exception=newSVpv("",0);
11634 if (sv_isobject(ST(0)) == 0)
11636 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11638 goto PerlException;
11640 reference=SvRV(ST(0));
11641 hv=SvSTASH(reference);
11643 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11645 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11646 if (image == (Image *) NULL)
11648 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11650 goto PerlException;
11652 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11653 preview_type=GammaPreview;
11655 preview_type=(PreviewType)
11656 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11657 for ( ; image; image=image->next)
11659 preview_image=PreviewImage(image,preview_type,exception);
11660 if (preview_image == (Image *) NULL)
11661 goto PerlException;
11662 AddImageToRegistry(sv,preview_image);
11664 av_push(av,sv_bless(rv,hv));
11667 exception=DestroyExceptionInfo(exception);
11668 ST(0)=av_reference;
11669 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11673 InheritPerlException(exception,perl_exception);
11674 exception=DestroyExceptionInfo(exception);
11675 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11676 SvPOK_on(perl_exception);
11677 ST(0)=sv_2mortal(perl_exception);
11682 ###############################################################################
11686 # Q u e r y C o l o r #
11690 ###############################################################################
11694 QueryColor(ref,...)
11695 Image::Magick ref=NO_INIT
11715 PERL_UNUSED_VAR(ref);
11716 PERL_UNUSED_VAR(ix);
11717 exception=AcquireExceptionInfo();
11718 perl_exception=newSVpv("",0);
11727 colorlist=GetColorInfoList("*",&colors,exception);
11729 for (i=0; i < (ssize_t) colors; i++)
11731 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11733 colorlist=(const ColorInfo **)
11734 RelinquishMagickMemory((ColorInfo **) colorlist);
11735 goto PerlException;
11737 EXTEND(sp,5*items);
11738 for (i=1; i < items; i++)
11740 name=(char *) SvPV(ST(i),na);
11741 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11746 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11747 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11748 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11749 if (color.matte != MagickFalse)
11750 PUSHs(sv_2mortal(newSViv((size_t) floor(color.opacity+0.5))));
11751 if (color.colorspace == CMYKColorspace)
11752 PUSHs(sv_2mortal(newSViv((size_t) floor(color.index+0.5))));
11756 InheritPerlException(exception,perl_exception);
11757 exception=DestroyExceptionInfo(exception);
11758 SvREFCNT_dec(perl_exception);
11762 ###############################################################################
11766 # Q u e r y C o l o r N a m e #
11770 ###############################################################################
11774 QueryColorname(ref,...)
11775 Image::Magick ref=NO_INIT
11784 message[MaxTextExtent];
11803 *reference; /* reference is the SV* of ref=SvIV(reference) */
11805 PERL_UNUSED_VAR(ref);
11806 PERL_UNUSED_VAR(ix);
11807 exception=AcquireExceptionInfo();
11808 perl_exception=newSVpv("",0);
11809 reference=SvRV(ST(0));
11810 av=(AV *) reference;
11811 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11813 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11814 if (image == (Image *) NULL)
11816 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11818 goto PerlException;
11821 for (i=1; i < items; i++)
11823 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11824 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11826 PUSHs(sv_2mortal(newSVpv(message,0)));
11830 InheritPerlException(exception,perl_exception);
11831 exception=DestroyExceptionInfo(exception);
11832 SvREFCNT_dec(perl_exception);
11836 ###############################################################################
11840 # Q u e r y F o n t #
11844 ###############################################################################
11849 Image::Magick ref=NO_INIT
11856 message[MaxTextExtent];
11867 volatile const TypeInfo
11870 PERL_UNUSED_VAR(ref);
11871 PERL_UNUSED_VAR(ix);
11872 exception=AcquireExceptionInfo();
11873 perl_exception=newSVpv("",0);
11882 typelist=GetTypeInfoList("*",&types,exception);
11884 for (i=0; i < (ssize_t) types; i++)
11886 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11888 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11890 goto PerlException;
11892 EXTEND(sp,10*items);
11893 for (i=1; i < items; i++)
11895 name=(char *) SvPV(ST(i),na);
11896 type_info=GetTypeInfo(name,exception);
11897 if (type_info == (TypeInfo *) NULL)
11902 if (type_info->name == (char *) NULL)
11905 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11906 if (type_info->description == (char *) NULL)
11909 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11910 if (type_info->family == (char *) NULL)
11913 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11914 if (type_info->style == UndefinedStyle)
11917 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11918 type_info->style),0)));
11919 if (type_info->stretch == UndefinedStretch)
11922 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11923 type_info->stretch),0)));
11924 (void) FormatMagickString(message,MaxTextExtent,"%.20g",(double)
11925 type_info->weight);
11926 PUSHs(sv_2mortal(newSVpv(message,0)));
11927 if (type_info->encoding == (char *) NULL)
11930 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11931 if (type_info->foundry == (char *) NULL)
11934 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11935 if (type_info->format == (char *) NULL)
11938 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11939 if (type_info->metrics == (char *) NULL)
11942 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11943 if (type_info->glyphs == (char *) NULL)
11946 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11950 InheritPerlException(exception,perl_exception);
11951 exception=DestroyExceptionInfo(exception);
11952 SvREFCNT_dec(perl_exception);
11956 ###############################################################################
11960 # Q u e r y F o n t M e t r i c s #
11964 ###############################################################################
11968 QueryFontMetrics(ref,...)
11969 Image::Magick ref=NO_INIT
11971 queryfontmetrics = 1
12018 *reference; /* reference is the SV* of ref=SvIV(reference) */
12023 PERL_UNUSED_VAR(ref);
12024 PERL_UNUSED_VAR(ix);
12025 exception=AcquireExceptionInfo();
12026 package_info=(struct PackageInfo *) NULL;
12027 perl_exception=newSVpv("",0);
12028 reference=SvRV(ST(0));
12029 av=(AV *) reference;
12030 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12032 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12033 if (image == (Image *) NULL)
12035 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12037 goto PerlException;
12039 package_info=ClonePackageInfo(info,exception);
12040 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12041 CloneString(&draw_info->text,"");
12042 current=draw_info->affine;
12043 GetAffineMatrix(&affine);
12046 EXTEND(sp,7*items);
12047 for (i=2; i < items; i+=2)
12049 attribute=(char *) SvPV(ST(i-1),na);
12050 switch (*attribute)
12055 if (LocaleCompare(attribute,"antialias") == 0)
12057 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12061 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12065 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12068 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12075 if (LocaleCompare(attribute,"density") == 0)
12077 CloneString(&draw_info->density,SvPV(ST(i),na));
12080 if (LocaleCompare(attribute,"direction") == 0)
12082 draw_info->direction=(DirectionType) ParseCommandOption(
12083 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12086 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12093 if (LocaleCompare(attribute,"encoding") == 0)
12095 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12098 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12105 if (LocaleCompare(attribute,"family") == 0)
12107 CloneString(&draw_info->family,SvPV(ST(i),na));
12110 if (LocaleCompare(attribute,"fill") == 0)
12113 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12114 &image->exception);
12117 if (LocaleCompare(attribute,"font") == 0)
12119 CloneString(&draw_info->font,SvPV(ST(i),na));
12122 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12129 if (LocaleCompare(attribute,"geometry") == 0)
12131 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12134 if (LocaleCompare(attribute,"gravity") == 0)
12136 draw_info->gravity=(GravityType) ParseCommandOption(
12137 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12140 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12147 if (LocaleCompare(attribute,"interline-spacing") == 0)
12149 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12150 draw_info->interline_spacing=geometry_info.rho;
12153 if (LocaleCompare(attribute,"interword-spacing") == 0)
12155 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12156 draw_info->interword_spacing=geometry_info.rho;
12159 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12166 if (LocaleCompare(attribute,"kerning") == 0)
12168 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12169 draw_info->kerning=geometry_info.rho;
12172 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12179 if (LocaleCompare(attribute,"pointsize") == 0)
12181 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12182 draw_info->pointsize=geometry_info.rho;
12185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12192 if (LocaleCompare(attribute,"rotate") == 0)
12194 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12195 affine.rx=geometry_info.rho;
12196 affine.ry=geometry_info.sigma;
12197 if ((flags & SigmaValue) == 0)
12198 affine.ry=affine.rx;
12201 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12208 if (LocaleCompare(attribute,"scale") == 0)
12210 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12211 affine.sx=geometry_info.rho;
12212 affine.sy=geometry_info.sigma;
12213 if ((flags & SigmaValue) == 0)
12214 affine.sy=affine.sx;
12217 if (LocaleCompare(attribute,"skew") == 0)
12223 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12224 x_angle=geometry_info.rho;
12225 y_angle=geometry_info.sigma;
12226 if ((flags & SigmaValue) == 0)
12228 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12229 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12232 if (LocaleCompare(attribute,"stroke") == 0)
12235 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12236 &image->exception);
12239 if (LocaleCompare(attribute,"style") == 0)
12241 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12245 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12249 draw_info->style=(StyleType) type;
12252 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12259 if (LocaleCompare(attribute,"text") == 0)
12261 CloneString(&draw_info->text,SvPV(ST(i),na));
12264 if (LocaleCompare(attribute,"translate") == 0)
12266 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12267 affine.tx=geometry_info.rho;
12268 affine.ty=geometry_info.sigma;
12269 if ((flags & SigmaValue) == 0)
12270 affine.ty=affine.tx;
12273 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12280 if (LocaleCompare(attribute,"weight") == 0)
12282 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12283 draw_info->weight=(size_t) geometry_info.rho;
12286 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12293 if (LocaleCompare(attribute,"x") == 0)
12295 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12296 x=geometry_info.rho;
12299 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12306 if (LocaleCompare(attribute,"y") == 0)
12308 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12309 y=geometry_info.rho;
12312 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12318 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12324 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12325 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12326 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12327 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12328 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12329 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12330 if (draw_info->geometry == (char *) NULL)
12332 draw_info->geometry=AcquireString((char *) NULL);
12333 (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
12334 "%.15g,%.15g",x,y);
12336 status=GetTypeMetrics(image,draw_info,&metrics);
12337 (void) CatchImageException(image);
12338 if (status == MagickFalse)
12342 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12343 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12344 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12345 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12346 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12347 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12348 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12349 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12350 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12351 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12352 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12353 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12354 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12356 draw_info=DestroyDrawInfo(draw_info);
12359 if (package_info != (struct PackageInfo *) NULL)
12360 DestroyPackageInfo(package_info);
12361 InheritPerlException(exception,perl_exception);
12362 exception=DestroyExceptionInfo(exception);
12363 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12367 ###############################################################################
12371 # 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 #
12375 ###############################################################################
12379 QueryMultilineFontMetrics(ref,...)
12380 Image::Magick ref=NO_INIT
12382 querymultilinefontmetrics = 1
12429 *reference; /* reference is the SV* of ref=SvIV(reference) */
12434 PERL_UNUSED_VAR(ref);
12435 PERL_UNUSED_VAR(ix);
12436 exception=AcquireExceptionInfo();
12437 package_info=(struct PackageInfo *) NULL;
12438 perl_exception=newSVpv("",0);
12439 reference=SvRV(ST(0));
12440 av=(AV *) reference;
12441 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12443 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12444 if (image == (Image *) NULL)
12446 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12448 goto PerlException;
12450 package_info=ClonePackageInfo(info,exception);
12451 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12452 CloneString(&draw_info->text,"");
12453 current=draw_info->affine;
12454 GetAffineMatrix(&affine);
12457 EXTEND(sp,7*items);
12458 for (i=2; i < items; i+=2)
12460 attribute=(char *) SvPV(ST(i-1),na);
12461 switch (*attribute)
12466 if (LocaleCompare(attribute,"antialias") == 0)
12468 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12472 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12476 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12479 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12486 if (LocaleCompare(attribute,"density") == 0)
12488 CloneString(&draw_info->density,SvPV(ST(i),na));
12491 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12498 if (LocaleCompare(attribute,"encoding") == 0)
12500 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12503 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12510 if (LocaleCompare(attribute,"family") == 0)
12512 CloneString(&draw_info->family,SvPV(ST(i),na));
12515 if (LocaleCompare(attribute,"fill") == 0)
12518 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12519 &image->exception);
12522 if (LocaleCompare(attribute,"font") == 0)
12524 CloneString(&draw_info->font,SvPV(ST(i),na));
12527 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12534 if (LocaleCompare(attribute,"geometry") == 0)
12536 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12539 if (LocaleCompare(attribute,"gravity") == 0)
12541 draw_info->gravity=(GravityType) ParseCommandOption(
12542 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12545 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12552 if (LocaleCompare(attribute,"pointsize") == 0)
12554 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12555 draw_info->pointsize=geometry_info.rho;
12558 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12565 if (LocaleCompare(attribute,"rotate") == 0)
12567 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12568 affine.rx=geometry_info.rho;
12569 affine.ry=geometry_info.sigma;
12570 if ((flags & SigmaValue) == 0)
12571 affine.ry=affine.rx;
12574 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12581 if (LocaleCompare(attribute,"scale") == 0)
12583 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12584 affine.sx=geometry_info.rho;
12585 affine.sy=geometry_info.sigma;
12586 if ((flags & SigmaValue) == 0)
12587 affine.sy=affine.sx;
12590 if (LocaleCompare(attribute,"skew") == 0)
12596 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12597 x_angle=geometry_info.rho;
12598 y_angle=geometry_info.sigma;
12599 if ((flags & SigmaValue) == 0)
12601 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12602 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12605 if (LocaleCompare(attribute,"stroke") == 0)
12608 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12609 &image->exception);
12612 if (LocaleCompare(attribute,"style") == 0)
12614 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12618 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12622 draw_info->style=(StyleType) type;
12625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12632 if (LocaleCompare(attribute,"text") == 0)
12634 CloneString(&draw_info->text,SvPV(ST(i),na));
12637 if (LocaleCompare(attribute,"translate") == 0)
12639 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12640 affine.tx=geometry_info.rho;
12641 affine.ty=geometry_info.sigma;
12642 if ((flags & SigmaValue) == 0)
12643 affine.ty=affine.tx;
12646 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12653 if (LocaleCompare(attribute,"weight") == 0)
12655 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12656 draw_info->weight=(size_t) geometry_info.rho;
12659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12666 if (LocaleCompare(attribute,"x") == 0)
12668 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12669 x=geometry_info.rho;
12672 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12679 if (LocaleCompare(attribute,"y") == 0)
12681 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12682 y=geometry_info.rho;
12685 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12691 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12697 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12698 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12699 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12700 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12701 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12702 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12703 if (draw_info->geometry == (char *) NULL)
12705 draw_info->geometry=AcquireString((char *) NULL);
12706 (void) FormatMagickString(draw_info->geometry,MaxTextExtent,
12707 "%.15g,%.15g",x,y);
12709 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12710 (void) CatchImageException(image);
12711 if (status == MagickFalse)
12715 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12716 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12717 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12718 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12719 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12720 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12721 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12722 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12723 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12724 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12725 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12726 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12727 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12729 draw_info=DestroyDrawInfo(draw_info);
12732 if (package_info != (struct PackageInfo *) NULL)
12733 DestroyPackageInfo(package_info);
12734 InheritPerlException(exception,perl_exception);
12735 exception=DestroyExceptionInfo(exception);
12736 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12740 ###############################################################################
12744 # Q u e r y F o r m a t #
12748 ###############################################################################
12752 QueryFormat(ref,...)
12753 Image::Magick ref=NO_INIT
12770 volatile const MagickInfo
12773 PERL_UNUSED_VAR(ref);
12774 PERL_UNUSED_VAR(ix);
12775 exception=AcquireExceptionInfo();
12776 perl_exception=newSVpv("",0);
12780 format[MaxTextExtent];
12788 format_list=GetMagickInfoList("*",&types,exception);
12790 for (i=0; i < (ssize_t) types; i++)
12792 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12793 LocaleLower(format);
12794 PUSHs(sv_2mortal(newSVpv(format,0)));
12796 format_list=(const MagickInfo **)
12797 RelinquishMagickMemory((MagickInfo *) format_list);
12798 goto PerlException;
12800 EXTEND(sp,8*items);
12801 for (i=1; i < items; i++)
12803 name=(char *) SvPV(ST(i),na);
12804 magick_info=GetMagickInfo(name,exception);
12805 if (magick_info == (const MagickInfo *) NULL)
12810 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12811 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12812 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12813 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12814 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12815 if (magick_info->description == (char *) NULL)
12818 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12819 if (magick_info->module == (char *) NULL)
12822 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12826 InheritPerlException(exception,perl_exception);
12827 exception=DestroyExceptionInfo(exception);
12828 SvREFCNT_dec(perl_exception);
12832 ###############################################################################
12836 # Q u e r y O p t i o n #
12840 ###############################################################################
12844 QueryOption(ref,...)
12845 Image::Magick ref=NO_INIT
12866 PERL_UNUSED_VAR(ref);
12867 PERL_UNUSED_VAR(ix);
12868 exception=AcquireExceptionInfo();
12869 perl_exception=newSVpv("",0);
12870 EXTEND(sp,8*items);
12871 for (i=1; i < items; i++)
12873 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12875 options=GetCommandOptions((CommandOption) option);
12876 if (options == (char **) NULL)
12880 for (j=0; options[j] != (char *) NULL; j++)
12881 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12882 options=DestroyStringList(options);
12886 InheritPerlException(exception,perl_exception);
12887 exception=DestroyExceptionInfo(exception);
12888 SvREFCNT_dec(perl_exception);
12892 ###############################################################################
12900 ###############################################################################
12905 Image::Magick ref=NO_INIT
12952 *perl_exception, /* Perl variable for storing messages */
12957 PERL_UNUSED_VAR(ref);
12958 PERL_UNUSED_VAR(ix);
12959 exception=AcquireExceptionInfo();
12960 perl_exception=newSVpv("",0);
12962 package_info=(struct PackageInfo *) NULL;
12964 ac=(items < 2) ? 1 : items-1;
12965 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12967 length=(STRLEN *) NULL;
12968 if (list == (char **) NULL)
12970 ThrowPerlException(exception,ResourceLimitError,
12971 "MemoryAllocationFailed",PackageName);
12972 goto PerlException;
12974 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12975 if (length == (STRLEN *) NULL)
12977 ThrowPerlException(exception,ResourceLimitError,
12978 "MemoryAllocationFailed",PackageName);
12979 goto PerlException;
12981 if (sv_isobject(ST(0)) == 0)
12983 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12985 goto PerlException;
12987 reference=SvRV(ST(0));
12988 hv=SvSTASH(reference);
12989 if (SvTYPE(reference) != SVt_PVAV)
12991 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12993 goto PerlException;
12995 av=(AV *) reference;
12996 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12998 package_info=ClonePackageInfo(info,exception);
13001 *list=(char *) (*package_info->image_info->filename ?
13002 package_info->image_info->filename : "XC:black");
13004 for (n=0, i=0; i < ac; i++)
13006 list[n]=(char *) SvPV(ST(i+1),length[n]);
13007 if ((items >= 3) && strEQcase(list[n],"blob"))
13013 blob=(void *) (SvPV(ST(i+1),length[n]));
13014 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13016 if ((items >= 3) && strEQcase(list[n],"filename"))
13018 if ((items >= 3) && strEQcase(list[n],"file"))
13027 io_info=IoIFP(sv_2io(ST(i+1)));
13028 if (io_info == (PerlIO *) NULL)
13030 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13034 file=PerlIO_findFILE(io_info);
13035 if (file == (FILE *) NULL)
13037 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13041 SetImageInfoFile(package_info->image_info,file);
13043 if ((items >= 3) && strEQcase(list[n],"magick"))
13047 list[n]=(char *) NULL;
13049 status=ExpandFilenames(&n,&list);
13050 if (status == MagickFalse)
13052 ThrowPerlException(exception,ResourceLimitError,
13053 "MemoryAllocationFailed",PackageName);
13054 goto PerlException;
13057 for (i=0; i < n; i++)
13059 if ((package_info->image_info->file != (FILE *) NULL) ||
13060 (package_info->image_info->blob != (void *) NULL))
13062 image=ReadImages(package_info->image_info,exception);
13063 if (image != (Image *) NULL)
13064 DisassociateImageStream(image);
13068 (void) CopyMagickString(package_info->image_info->filename,list[i],
13070 image=ReadImages(package_info->image_info,exception);
13072 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13074 for ( ; image; image=image->next)
13076 AddImageToRegistry(sv,image);
13078 av_push(av,sv_bless(rv,hv));
13086 for (i=0; i < n; i++)
13087 if (list[i] != (char *) NULL)
13088 for (p=keep; list[i] != *p++; )
13089 if (*p == (char *) NULL)
13091 list[i]=(char *) RelinquishMagickMemory(list[i]);
13096 if (package_info != (struct PackageInfo *) NULL)
13097 DestroyPackageInfo(package_info);
13098 if (list && (list != keep))
13099 list=(char **) RelinquishMagickMemory(list);
13101 keep=(char **) RelinquishMagickMemory(keep);
13103 length=(STRLEN *) RelinquishMagickMemory(length);
13104 InheritPerlException(exception,perl_exception);
13105 exception=DestroyExceptionInfo(exception);
13106 sv_setiv(perl_exception,(IV) number_images);
13107 SvPOK_on(perl_exception);
13108 ST(0)=sv_2mortal(perl_exception);
13113 ###############################################################################
13121 ###############################################################################
13126 Image::Magick ref=NO_INIT
13149 PERL_UNUSED_VAR(ref);
13150 PERL_UNUSED_VAR(ix);
13151 exception=AcquireExceptionInfo();
13152 perl_exception=newSVpv("",0);
13153 reference=SvRV(ST(0));
13154 av=(AV *) reference;
13155 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13157 for (i=1; i < items; i++)
13158 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13159 SvPV(ST(i),na),exception);
13160 InheritPerlException(exception,perl_exception);
13161 exception=DestroyExceptionInfo(exception);
13162 SvREFCNT_dec(perl_exception); /* throw away all errors */
13166 ###############################################################################
13174 ###############################################################################
13179 Image::Magick ref=NO_INIT
13202 *reference; /* reference is the SV* of ref=SvIV(reference) */
13204 PERL_UNUSED_VAR(ref);
13205 PERL_UNUSED_VAR(ix);
13206 exception=AcquireExceptionInfo();
13207 perl_exception=newSVpv("",0);
13208 if (sv_isobject(ST(0)) == 0)
13210 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13212 goto PerlException;
13214 reference=SvRV(ST(0));
13215 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13217 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13219 for (i=2; i < items; i+=2)
13220 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13223 InheritPerlException(exception,perl_exception);
13224 exception=DestroyExceptionInfo(exception);
13225 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13226 SvPOK_on(perl_exception);
13227 ST(0)=sv_2mortal(perl_exception);
13232 ###############################################################################
13236 # S e t P i x e l #
13240 ###############################################################################
13245 Image::Magick ref=NO_INIT
13272 register IndexPacket
13278 register PixelPacket
13289 *reference; /* reference is the SV* of ref=SvIV(reference) */
13291 PERL_UNUSED_VAR(ref);
13292 PERL_UNUSED_VAR(ix);
13293 exception=AcquireExceptionInfo();
13294 perl_exception=newSVpv("",0);
13295 reference=SvRV(ST(0));
13296 av=(AV *) reference;
13297 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13299 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13300 if (image == (Image *) NULL)
13302 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13304 goto PerlException;
13307 channel=DefaultChannels;
13308 normalize=MagickTrue;
13311 region.width=image->columns;
13314 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13315 for (i=2; i < items; i+=2)
13317 attribute=(char *) SvPV(ST(i-1),na);
13318 switch (*attribute)
13323 if (LocaleCompare(attribute,"channel") == 0)
13328 option=ParseChannelOption(SvPV(ST(i),na));
13331 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13335 channel=(ChannelType) option;
13338 if (LocaleCompare(attribute,"color") == 0)
13340 if (SvTYPE(ST(i)) != SVt_RV)
13343 message[MaxTextExtent];
13345 (void) FormatMagickString(message,MaxTextExtent,
13346 "invalid %.60s value",attribute);
13347 ThrowPerlException(exception,OptionError,message,
13350 av=(AV *) SvRV(ST(i));
13353 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13360 if (LocaleCompare(attribute,"geometry") == 0)
13362 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13365 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13372 if (LocaleCompare(attribute,"normalize") == 0)
13374 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13378 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13382 normalize=option != 0 ? MagickTrue : MagickFalse;
13385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13392 if (LocaleCompare(attribute,"x") == 0)
13394 region.x=SvIV(ST(i));
13397 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13404 if (LocaleCompare(attribute,"y") == 0)
13406 region.y=SvIV(ST(i));
13409 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13415 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13421 (void) SetImageStorageClass(image,DirectClass);
13422 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13423 if ((q == (PixelPacket *) NULL) || (av == (AV *) NULL) ||
13424 (SvTYPE(av) != SVt_PVAV))
13435 indexes=GetAuthenticIndexQueue(image);
13437 if (normalize != MagickFalse)
13438 scale=QuantumRange;
13439 if (((channel & RedChannel) != 0) && (i <= av_len(av)))
13441 SetRedPixelComponent(q,ClampToQuantum(QuantumRange*SvNV(*(
13442 av_fetch(av,i,0)))));
13445 if (((channel & GreenChannel) != 0) && (i <= av_len(av)))
13447 SetGreenPixelComponent(q,ClampToQuantum(QuantumRange*SvNV(*(
13448 av_fetch(av,i,0)))));
13451 if (((channel & BlueChannel) != 0) && (i <= av_len(av)))
13453 SetBluePixelComponent(q,ClampToQuantum(QuantumRange*SvNV(*(
13454 av_fetch(av,i,0)))));
13457 if ((((channel & IndexChannel) != 0) &&
13458 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13460 SetIndexPixelComponent(indexes,ClampToQuantum(QuantumRange*
13461 SvNV(*(av_fetch(av,i,0)))));
13464 if (((channel & OpacityChannel) != 0) && (i <= av_len(av)))
13466 SetOpacityPixelComponent(q,ClampToQuantum(QuantumRange*
13467 SvNV(*(av_fetch(av,i,0)))));
13470 (void) SyncAuthenticPixels(image,exception);
13474 InheritPerlException(exception,perl_exception);
13475 exception=DestroyExceptionInfo(exception);
13476 SvREFCNT_dec(perl_exception);
13480 ###############################################################################
13488 ###############################################################################
13493 Image::Magick ref=NO_INIT
13532 PERL_UNUSED_VAR(ref);
13533 PERL_UNUSED_VAR(ix);
13534 exception=AcquireExceptionInfo();
13535 perl_exception=newSVpv("",0);
13539 if (sv_isobject(ST(0)) == 0)
13541 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13543 goto PerlException;
13545 reference=SvRV(ST(0));
13546 hv=SvSTASH(reference);
13548 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13550 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13551 if (image == (Image *) NULL)
13553 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13555 goto PerlException;
13557 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13563 for (i=2; i < items; i+=2)
13565 attribute=(char *) SvPV(ST(i-1),na);
13566 switch (*attribute)
13571 if (LocaleCompare(attribute,"offset") == 0)
13573 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13576 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13583 if (LocaleCompare(attribute,"stack") == 0)
13585 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13589 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13595 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13607 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13609 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13610 goto PerlException;
13611 for ( ; image; image=image->next)
13613 AddImageToRegistry(sv,image);
13615 av_push(av,sv_bless(rv,hv));
13618 exception=DestroyExceptionInfo(exception);
13619 ST(0)=av_reference;
13620 SvREFCNT_dec(perl_exception);
13624 InheritPerlException(exception,perl_exception);
13625 exception=DestroyExceptionInfo(exception);
13626 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13627 SvPOK_on(perl_exception);
13628 ST(0)=sv_2mortal(perl_exception);
13633 ###############################################################################
13637 # S t a t i s t i c s #
13641 ###############################################################################
13645 Statistics(ref,...)
13646 Image::Magick ref=NO_INIT
13648 StatisticsImage = 1
13650 statisticsimage = 3
13653 #define ChannelStatistics(channel) \
13655 (void) FormatMagickString(message,MaxTextExtent,"%.20g", \
13656 (double) channel_statistics[channel].depth); \
13657 PUSHs(sv_2mortal(newSVpv(message,0))); \
13658 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13659 channel_statistics[channel].minima/scale); \
13660 PUSHs(sv_2mortal(newSVpv(message,0))); \
13661 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13662 channel_statistics[channel].maxima/scale); \
13663 PUSHs(sv_2mortal(newSVpv(message,0))); \
13664 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13665 channel_statistics[channel].mean/scale); \
13666 PUSHs(sv_2mortal(newSVpv(message,0))); \
13667 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13668 channel_statistics[channel].standard_deviation/scale); \
13669 PUSHs(sv_2mortal(newSVpv(message,0))); \
13670 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13671 channel_statistics[channel].kurtosis); \
13672 PUSHs(sv_2mortal(newSVpv(message,0))); \
13673 (void) FormatMagickString(message,MaxTextExtent,"%.15g", \
13674 channel_statistics[channel].skewness); \
13675 PUSHs(sv_2mortal(newSVpv(message,0))); \
13682 message[MaxTextExtent];
13685 *channel_statistics;
13710 PERL_UNUSED_VAR(ref);
13711 PERL_UNUSED_VAR(ix);
13712 exception=AcquireExceptionInfo();
13713 perl_exception=newSVpv("",0);
13715 if (sv_isobject(ST(0)) == 0)
13717 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13719 goto PerlException;
13721 reference=SvRV(ST(0));
13722 hv=SvSTASH(reference);
13724 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13726 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13727 if (image == (Image *) NULL)
13729 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13731 goto PerlException;
13733 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13735 for ( ; image; image=image->next)
13737 channel_statistics=GetImageChannelStatistics(image,&image->exception);
13738 if (channel_statistics == (ChannelStatistics *) NULL)
13741 EXTEND(sp,35*count);
13742 scale=(double) QuantumRange;
13743 ChannelStatistics(RedChannel);
13744 ChannelStatistics(GreenChannel);
13745 ChannelStatistics(BlueChannel);
13746 if (image->colorspace == CMYKColorspace)
13747 ChannelStatistics(IndexChannel);
13748 if (image->matte != MagickFalse)
13749 ChannelStatistics(OpacityChannel);
13750 channel_statistics=(ChannelStatistics *)
13751 RelinquishMagickMemory(channel_statistics);
13755 InheritPerlException(exception,perl_exception);
13756 exception=DestroyExceptionInfo(exception);
13757 SvREFCNT_dec(perl_exception);
13761 ###############################################################################
13765 # S y n c A u t h e n t i c P i x e l s #
13769 ###############################################################################
13773 SyncAuthenticPixels(ref,...)
13774 Image::Magick ref = NO_INIT
13776 Syncauthenticpixels = 1
13777 SyncImagePixels = 2
13778 syncimagepixels = 3
13797 PERL_UNUSED_VAR(ref);
13798 PERL_UNUSED_VAR(ix);
13799 exception=AcquireExceptionInfo();
13800 perl_exception=newSVpv("",0);
13801 if (sv_isobject(ST(0)) == 0)
13803 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13805 goto PerlException;
13808 reference=SvRV(ST(0));
13809 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13810 if (image == (Image *) NULL)
13812 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13814 goto PerlException;
13817 status=SyncAuthenticPixels(image,exception);
13818 if (status != MagickFalse)
13820 InheritException(exception,&image->exception);
13823 InheritPerlException(exception,perl_exception);
13824 exception=DestroyExceptionInfo(exception);
13825 SvREFCNT_dec(perl_exception); /* throw away all errors */
13829 ###############################################################################
13833 # T r a n s f o r m #
13837 ###############################################################################
13842 Image::Magick ref=NO_INIT
13880 PERL_UNUSED_VAR(ref);
13881 PERL_UNUSED_VAR(ix);
13882 exception=AcquireExceptionInfo();
13883 perl_exception=newSVpv("",0);
13887 if (sv_isobject(ST(0)) == 0)
13889 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13891 goto PerlException;
13893 reference=SvRV(ST(0));
13894 hv=SvSTASH(reference);
13896 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13898 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13899 if (image == (Image *) NULL)
13901 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13903 goto PerlException;
13905 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13909 crop_geometry=(char *) NULL;
13910 geometry=(char *) NULL;
13911 for (i=2; i < items; i+=2)
13913 attribute=(char *) SvPV(ST(i-1),na);
13914 switch (*attribute)
13919 if (LocaleCompare(attribute,"crop") == 0)
13921 crop_geometry=SvPV(ST(i),na);
13924 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13931 if (LocaleCompare(attribute,"geometry") == 0)
13933 geometry=SvPV(ST(i),na);
13936 if (LocaleCompare(attribute,"gravity") == 0)
13944 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13945 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13948 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13952 for (next=image; next; next=next->next)
13953 next->gravity=(GravityType) in;
13956 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13962 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13968 for ( ; image; image=image->next)
13970 clone=CloneImage(image,0,0,MagickTrue,exception);
13971 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13972 goto PerlException;
13973 TransformImage(&clone,crop_geometry,geometry);
13974 for ( ; clone; clone=clone->next)
13976 AddImageToRegistry(sv,clone);
13978 av_push(av,sv_bless(rv,hv));
13982 exception=DestroyExceptionInfo(exception);
13983 ST(0)=av_reference;
13984 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13988 InheritPerlException(exception,perl_exception);
13989 exception=DestroyExceptionInfo(exception);
13990 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13991 SvPOK_on(perl_exception);
13992 ST(0)=sv_2mortal(perl_exception);
13997 ###############################################################################
14005 ###############################################################################
14010 Image::Magick ref=NO_INIT
14018 filename[MaxTextExtent];
14042 PERL_UNUSED_VAR(ref);
14043 PERL_UNUSED_VAR(ix);
14044 exception=AcquireExceptionInfo();
14045 perl_exception=newSVpv("",0);
14047 package_info=(struct PackageInfo *) NULL;
14048 if (sv_isobject(ST(0)) == 0)
14050 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14052 goto PerlException;
14054 reference=SvRV(ST(0));
14055 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14056 if (image == (Image *) NULL)
14058 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14060 goto PerlException;
14062 package_info=ClonePackageInfo(info,exception);
14064 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14067 for (i=2; i < items; i+=2)
14068 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14070 (void) CopyMagickString(filename,package_info->image_info->filename,
14073 for (next=image; next; next=next->next)
14075 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14076 next->scene=scene++;
14078 SetImageInfo(package_info->image_info,(unsigned int)
14079 GetImageListLength(image),&image->exception);
14080 for (next=image; next; next=next->next)
14082 (void) WriteImage(package_info->image_info,next);
14083 if (next->exception.severity >= ErrorException)
14084 InheritException(exception,&next->exception);
14085 GetImageException(next,exception);
14087 if (package_info->image_info->adjoin)
14092 if (package_info != (struct PackageInfo *) NULL)
14093 DestroyPackageInfo(package_info);
14094 InheritPerlException(exception,perl_exception);
14095 exception=DestroyExceptionInfo(exception);
14096 sv_setiv(perl_exception,(IV) number_images);
14097 SvPOK_on(perl_exception);
14098 ST(0)=sv_2mortal(perl_exception);