2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
55 #if defined(__cplusplus) || defined(c_plusplus)
59 #define PERL_NO_GET_CONTEXT
64 #include <MagickCore/MagickCore.h>
67 #if defined(__cplusplus) || defined(c_plusplus)
79 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
80 #define EndOf(array) (&array[NumberOf(array)])
81 #define MaxArguments 33
85 #define NumberOf(array) (sizeof(array)/sizeof(*array))
86 #define PackageName "Image::Magick"
89 #define PerlIO_importFILE(f, fl) (f)
90 #define PerlIO_findFILE(f) NULL
93 #define sv_undef PL_sv_undef
96 #define AddImageToRegistry(sv,image) \
98 if (magick_registry != (SplayTreeInfo *) NULL) \
100 (void) AddValueToSplayTree(magick_registry,image,image); \
101 (sv)=newSViv((IV) image); \
105 #define DeleteImageFromRegistry(reference,image) \
107 if (magick_registry != (SplayTreeInfo *) NULL) \
109 if (GetImageReferenceCount(image) == 1) \
110 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
111 image=DestroyImage(image); \
112 sv_setiv(reference,0); \
116 #define InheritPerlException(exception,perl_exception) \
119 message[MaxTextExtent]; \
121 if ((exception)->severity != UndefinedException) \
123 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
124 (exception)->severity, (exception)->reason ? \
125 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
126 "Unknown", (exception)->description ? " (" : "", \
127 (exception)->description ? GetLocaleExceptionMessage( \
128 (exception)->severity,(exception)->description) : "", \
129 (exception)->description ? ")" : ""); \
130 if ((perl_exception) != (SV *) NULL) \
132 if (SvCUR(perl_exception)) \
133 sv_catpv(perl_exception,"\n"); \
134 sv_catpv(perl_exception,message); \
139 #define ThrowPerlException(exception,severity,tag,reason) \
140 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
141 tag,"`%s'",reason); \
144 Typedef and structure declarations.
148 ArrayReference = (~0),
149 RealReference = (~0)-1,
150 FileReference = (~0)-2,
151 ImageReference = (~0)-3,
152 IntegerReference = (~0)-4,
153 StringReference = (~0)-5
156 typedef struct _Arguments
196 *Image__Magick; /* data type for the Image::Magick package */
208 arguments[MaxArguments];
211 { "Comment", { {"comment", StringReference} } },
212 { "Label", { {"label", StringReference} } },
213 { "AddNoise", { {"noise", MagickNoiseOptions},
214 {"channel", MagickChannelOptions} } },
215 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
216 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
217 {"height", IntegerReference}, {"fill", StringReference},
218 {"bordercolor", StringReference}, {"color", StringReference},
219 {"compose", MagickComposeOptions} } },
220 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
221 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
222 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference} } },
225 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
226 {"height", IntegerReference}, {"x", IntegerReference},
227 {"y", IntegerReference}, {"fuzz", StringReference},
228 {"gravity", MagickGravityOptions} } },
230 { "Edge", { {"radius", RealReference} } },
231 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
232 {"sigma", RealReference} } },
236 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
237 {"height", IntegerReference}, {"inner", IntegerReference},
238 {"outer", IntegerReference}, {"fill", StringReference},
239 {"color", StringReference}, {"compose", MagickComposeOptions} } },
240 { "Implode", { {"amount", RealReference},
241 {"interpolate", MagickInterpolateOptions} } },
243 { "MedianFilter", { {"geometry", StringReference},
244 {"width", IntegerReference},{"height", IntegerReference},
245 {"channel", MagickChannelOptions} } },
247 { "OilPaint", { {"radius", RealReference} } },
248 { "ReduceNoise", { {"geometry", StringReference},
249 {"width", IntegerReference},{"height", IntegerReference},
250 {"channel", MagickChannelOptions} } },
251 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
252 {"y", IntegerReference} } },
253 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
254 {"color", StringReference}, {"background", StringReference} } },
255 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
256 {"height", IntegerReference} } },
257 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
258 {"height", IntegerReference} } },
259 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
260 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
261 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
262 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
263 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
264 {"y", RealReference}, { "fill", StringReference},
265 {"color", StringReference} } },
266 { "Spread", { {"radius", RealReference} } },
267 { "Swirl", { {"degrees", RealReference},
268 {"interpolate", MagickInterpolateOptions} } },
269 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", StringReference }, {"blur", RealReference } } },
272 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
273 {"height", IntegerReference}, {"filter", MagickFilterOptions},
274 {"support", RealReference }, {"blur", RealReference } } },
275 { "Annotate", { {"text", StringReference}, {"font", StringReference},
276 {"pointsize", RealReference}, {"density", StringReference},
277 {"undercolor", StringReference}, {"stroke", StringReference},
278 {"fill", StringReference}, {"geometry", StringReference},
279 {"pen", StringReference}, {"x", RealReference},
280 {"y", RealReference}, {"gravity", MagickGravityOptions},
281 {"translate", StringReference}, {"scale", StringReference},
282 {"rotate", RealReference}, {"skewX", RealReference},
283 {"skewY", RealReference}, {"strokewidth", RealReference},
284 {"antialias", MagickBooleanOptions}, {"family", StringReference},
285 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
286 {"weight", IntegerReference}, {"align", MagickAlignOptions},
287 {"encoding", StringReference}, {"affine", ArrayReference},
288 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
289 {"tile", ImageReference}, {"kerning", RealReference},
290 {"interline-spacing", RealReference},
291 {"interword-spacing", RealReference},
292 {"direction", MagickDirectionOptions} } },
293 { "ColorFloodfill", { {"geometry", StringReference},
294 {"x", IntegerReference}, {"y", IntegerReference},
295 {"fill", StringReference}, {"bordercolor", StringReference},
296 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
297 { "Composite", { {"image", ImageReference},
298 {"compose", MagickComposeOptions}, {"geometry", StringReference},
299 {"x", IntegerReference}, {"y", IntegerReference},
300 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
301 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
302 {"color", StringReference}, {"mask", ImageReference},
303 {"channel", MagickChannelOptions},
304 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
305 {"blend", StringReference} } },
306 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
307 { "CycleColormap", { {"display", IntegerReference} } },
308 { "Draw", { {"primitive", MagickPrimitiveOptions},
309 {"points", StringReference}, {"method", MagickMethodOptions},
310 {"stroke", StringReference}, {"fill", StringReference},
311 {"strokewidth", RealReference}, {"font", StringReference},
312 {"bordercolor", StringReference}, {"x", RealReference},
313 {"y", RealReference}, {"translate", StringReference},
314 {"scale", StringReference}, {"rotate", RealReference},
315 {"skewX", RealReference}, {"skewY", RealReference},
316 {"tile", ImageReference}, {"pointsize", RealReference},
317 {"antialias", MagickBooleanOptions}, {"density", StringReference},
318 {"linewidth", RealReference}, {"affine", ArrayReference},
319 {"stroke-dashoffset", RealReference},
320 {"stroke-dasharray", ArrayReference},
321 {"interpolate", MagickInterpolateOptions},
322 {"origin", StringReference}, {"text", StringReference},
323 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
324 {"vector-graphics", StringReference}, {"kerning", RealReference},
325 {"interline-spacing", RealReference},
326 {"interword-spacing", RealReference},
327 {"direction", MagickDirectionOptions} } },
328 { "Equalize", { {"channel", MagickChannelOptions} } },
329 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
330 {"red", RealReference}, {"green", RealReference},
331 {"blue", RealReference} } },
332 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
333 {"dither-method", MagickDitherOptions} } },
334 { "MatteFloodfill", { {"geometry", StringReference},
335 {"x", IntegerReference}, {"y", IntegerReference},
336 {"opacity", StringReference}, {"bordercolor", StringReference},
337 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
338 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
339 {"saturation", RealReference}, {"whiteness", RealReference},
340 {"brightness", RealReference}, {"lightness", RealReference},
341 {"blackness", RealReference} } },
342 { "Negate", { {"gray", MagickBooleanOptions},
343 {"channel", MagickChannelOptions} } },
344 { "Normalize", { {"channel", MagickChannelOptions} } },
346 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
347 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
348 {"invert", MagickBooleanOptions} } },
349 { "Quantize", { {"colors", IntegerReference},
350 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
351 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
352 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
353 {"dither-method", MagickDitherOptions} } },
354 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
355 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
356 { "Segment", { {"geometry", StringReference},
357 {"cluster-threshold", RealReference},
358 {"smoothing-threshold", RealReference},
359 {"colorspace", MagickColorspaceOptions},
360 {"verbose", MagickBooleanOptions} } },
362 { "Solarize", { {"geometry", StringReference},
363 {"threshold", StringReference} } },
365 { "Texture", { {"texture", ImageReference} } },
366 { "Evaluate", { {"value", RealReference},
367 {"operator", MagickEvaluateOptions},
368 {"channel", MagickChannelOptions} } },
369 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
370 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
371 { "Threshold", { {"threshold", StringReference},
372 {"channel", MagickChannelOptions} } },
373 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
374 {"sigma", RealReference} } },
375 { "Trim", { {"fuzz", StringReference} } },
376 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
377 {"wavelength", RealReference},
378 {"interpolate", MagickInterpolateOptions} } },
379 { "Separate", { {"channel", MagickChannelOptions} } },
381 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
382 {"y", IntegerReference} } },
383 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
385 { "GaussianBlur", { {"geometry", StringReference},
386 {"radius", RealReference}, {"sigma", RealReference},
387 {"channel", MagickChannelOptions} } },
388 { "Convolve", { {"coefficients", ArrayReference},
389 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
390 { "Profile", { {"name", StringReference}, {"profile", StringReference},
391 { "rendering-intent", MagickIntentOptions},
392 { "black-point-compensation", MagickBooleanOptions} } },
393 { "UnsharpMask", { {"geometry", StringReference},
394 {"radius", RealReference}, {"sigma", RealReference},
395 {"amount", RealReference}, {"threshold", RealReference},
396 {"channel", MagickChannelOptions} } },
397 { "MotionBlur", { {"geometry", StringReference},
398 {"radius", RealReference}, {"sigma", RealReference},
399 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
400 { "OrderedDither", { {"threshold", StringReference},
401 {"channel", MagickChannelOptions} } },
402 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
403 {"height", IntegerReference} } },
404 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
405 {"white-point", RealReference}, {"gamma", RealReference},
406 {"channel", MagickChannelOptions}, {"level", StringReference} } },
407 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
408 { "AffineTransform", { {"affine", ArrayReference},
409 {"translate", StringReference}, {"scale", StringReference},
410 {"rotate", RealReference}, {"skewX", RealReference},
411 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
412 {"background", StringReference} } },
413 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
414 { "AdaptiveThreshold", { {"geometry", StringReference},
415 {"width", IntegerReference}, {"height", IntegerReference},
416 {"offset", IntegerReference} } },
417 { "Resample", { {"density", StringReference}, {"x", RealReference},
418 {"y", RealReference}, {"filter", MagickFilterOptions},
419 {"support", RealReference }, {"blur", RealReference } } },
420 { "Describe", { {"file", FileReference} } },
421 { "BlackThreshold", { {"threshold", StringReference},
422 {"channel", MagickChannelOptions} } },
423 { "WhiteThreshold", { {"threshold", StringReference},
424 {"channel", MagickChannelOptions} } },
425 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
426 {"channel", MagickChannelOptions} } },
427 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
428 {"height", IntegerReference} } },
430 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
431 { "Channel", { {"channel", MagickChannelOptions} } },
432 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
433 {"height", IntegerReference}, {"x", IntegerReference},
434 {"y", IntegerReference}, {"fuzz", StringReference},
435 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
436 { "Posterize", { {"levels", IntegerReference},
437 {"dither", MagickBooleanOptions} } },
438 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
439 {"sigma", RealReference}, {"x", IntegerReference},
440 {"y", IntegerReference} } },
441 { "Identify", { {"file", FileReference}, {"features", StringReference},
442 {"unique", MagickBooleanOptions} } },
443 { "SepiaTone", { {"threshold", RealReference} } },
444 { "SigmoidalContrast", { {"geometry", StringReference},
445 {"contrast", RealReference}, {"mid-point", RealReference},
446 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
447 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
448 {"height", IntegerReference}, {"x", IntegerReference},
449 {"y", IntegerReference}, {"fuzz", StringReference},
450 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
451 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
452 {"sigma", RealReference}, {"x", IntegerReference},
453 {"y", IntegerReference}, {"background", StringReference} } },
454 { "ContrastStretch", { {"levels", StringReference},
455 {"black-point", RealReference},{"white-point", RealReference},
456 {"channel", MagickChannelOptions} } },
459 { "AdaptiveSharpen", { {"geometry", StringReference},
460 {"radius", RealReference}, {"sigma", RealReference},
461 {"channel", MagickChannelOptions} } },
465 { "AdaptiveBlur", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"channel", MagickChannelOptions} } },
468 { "Sketch", { {"geometry", StringReference},
469 {"radius", RealReference}, {"sigma", RealReference},
470 {"angle", RealReference} } },
472 { "AdaptiveResize", { {"geometry", StringReference},
473 {"width", IntegerReference}, {"height", IntegerReference},
474 {"filter", MagickFilterOptions}, {"support", StringReference },
475 {"blur", RealReference } } },
476 { "ClipMask", { {"mask", ImageReference} } },
477 { "LinearStretch", { {"levels", StringReference},
478 {"black-point", RealReference},{"white-point", RealReference} } },
479 { "Recolor", { {"matrix", ArrayReference} } },
480 { "Mask", { {"mask", ImageReference} } },
481 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
482 {"font", StringReference}, {"stroke", StringReference},
483 {"fill", StringReference}, {"strokewidth", RealReference},
484 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
485 {"background", StringReference} } },
486 { "FloodfillPaint", { {"geometry", StringReference},
487 {"x", IntegerReference}, {"y", IntegerReference},
488 {"fill", StringReference}, {"bordercolor", StringReference},
489 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
490 {"invert", MagickBooleanOptions} } },
491 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
492 {"virtual-pixel", MagickVirtualPixelOptions},
493 {"best-fit", MagickBooleanOptions} } },
494 { "Clut", { {"image", ImageReference},
495 {"channel", MagickChannelOptions} } },
496 { "LiquidRescale", { {"geometry", StringReference},
497 {"width", IntegerReference}, {"height", IntegerReference},
498 {"delta-x", RealReference}, {"rigidity", RealReference } } },
499 { "Encipher", { {"passphrase", StringReference} } },
500 { "Decipher", { {"passphrase", StringReference} } },
501 { "Deskew", { {"geometry", StringReference},
502 {"threshold", StringReference} } },
503 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
504 {"dither-method", MagickDitherOptions} } },
505 { "SparseColor", { {"points", ArrayReference},
506 {"method", MagickSparseColorOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions},
508 {"channel", MagickChannelOptions} } },
509 { "Function", { {"parameters", ArrayReference},
510 {"function", MagickFunctionOptions},
511 {"virtual-pixel", MagickVirtualPixelOptions} } },
512 { "SelectiveBlur", { {"geometry", StringReference},
513 {"radius", RealReference}, {"sigma", RealReference},
514 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
515 { "HaldClut", { {"image", ImageReference},
516 {"channel", MagickChannelOptions} } },
517 { "BlueShift", { {"factor", StringReference} } },
518 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "ColorDecisionList", {
521 {"color-correction-collection", StringReference} } },
522 { "AutoGamma", { {"channel", MagickChannelOptions} } },
523 { "AutoLevel", { {"channel", MagickChannelOptions} } },
524 { "LevelColors", { {"invert", MagickBooleanOptions},
525 {"black-point", StringReference}, {"white-point", StringReference},
526 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
527 { "Clamp", { {"channel", MagickChannelOptions} } },
528 { "Filter", { {"kernel", StringReference},
529 {"channel", MagickChannelOptions}, {"bias", StringReference} } },
530 { "BrightnessContrast", { {"levels", StringReference},
531 {"brightness", RealReference},{"contrast", RealReference},
532 {"channel", MagickChannelOptions} } },
533 { "Morphology", { {"kernel", StringReference},
534 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
535 {"iterations", IntegerReference} } },
536 { "ColorMatrix", { {"matrix", ArrayReference} } },
537 { "Color", { {"color", StringReference} } },
538 { "Mode", { {"geometry", StringReference},
539 {"width", IntegerReference},{"height", IntegerReference},
540 {"channel", MagickChannelOptions} } },
541 { "Statistic", { {"geometry", StringReference},
542 {"width", IntegerReference},{"height", IntegerReference},
543 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
547 *magick_registry = (SplayTreeInfo *) NULL;
550 Forward declarations.
553 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
556 strEQcase(const char *,const char *);
559 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563 % C l o n e P a c k a g e I n f o %
567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
572 % The format of the ClonePackageInfo routine is:
574 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
577 % A description of each parameter follows:
579 % o info: a structure of type info.
581 % o exception: Return any errors or warnings in this structure.
584 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
585 ExceptionInfo *exception)
590 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
591 if (clone_info == (struct PackageInfo *) NULL)
593 ThrowPerlException(exception,ResourceLimitError,
594 "UnableToClonePackageInfo",PackageName);
595 return((struct PackageInfo *) NULL);
597 if (info == (struct PackageInfo *) NULL)
599 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
603 clone_info->image_info=CloneImageInfo(info->image_info);
608 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618 % constant() returns a double value for the specified name.
620 % The format of the constant routine is:
622 % double constant(char *name,ssize_t sans)
624 % A description of each parameter follows:
626 % o value: Method constant returns a double value for the specified name.
628 % o name: The name of the constant.
630 % o sans: This integer value is not used.
633 static double constant(char *name,ssize_t sans)
641 if (strEQ(name,"BlobError"))
643 if (strEQ(name,"BlobWarning"))
649 if (strEQ(name,"CacheError"))
651 if (strEQ(name,"CacheWarning"))
652 return(CacheWarning);
653 if (strEQ(name,"CoderError"))
655 if (strEQ(name,"CoderWarning"))
656 return(CoderWarning);
657 if (strEQ(name,"ConfigureError"))
658 return(ConfigureError);
659 if (strEQ(name,"ConfigureWarning"))
660 return(ConfigureWarning);
661 if (strEQ(name,"CorruptImageError"))
662 return(CorruptImageError);
663 if (strEQ(name,"CorruptImageWarning"))
664 return(CorruptImageWarning);
669 if (strEQ(name,"DelegateError"))
670 return(DelegateError);
671 if (strEQ(name,"DelegateWarning"))
672 return(DelegateWarning);
673 if (strEQ(name,"DrawError"))
675 if (strEQ(name,"DrawWarning"))
681 if (strEQ(name,"ErrorException"))
682 return(ErrorException);
683 if (strEQ(name,"ExceptionError"))
685 if (strEQ(name,"ExceptionWarning"))
686 return(CoderWarning);
691 if (strEQ(name,"FatalErrorException"))
692 return(FatalErrorException);
693 if (strEQ(name,"FileOpenError"))
694 return(FileOpenError);
695 if (strEQ(name,"FileOpenWarning"))
696 return(FileOpenWarning);
701 if (strEQ(name,"ImageError"))
703 if (strEQ(name,"ImageWarning"))
704 return(ImageWarning);
709 if (strEQ(name,"MaxRGB"))
710 return(QuantumRange);
711 if (strEQ(name,"MissingDelegateError"))
712 return(MissingDelegateError);
713 if (strEQ(name,"MissingDelegateWarning"))
714 return(MissingDelegateWarning);
715 if (strEQ(name,"ModuleError"))
717 if (strEQ(name,"ModuleWarning"))
718 return(ModuleWarning);
723 if (strEQ(name,"Opaque"))
725 if (strEQ(name,"OptionError"))
727 if (strEQ(name,"OptionWarning"))
728 return(OptionWarning);
733 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
734 return(MAGICKCORE_QUANTUM_DEPTH);
735 if (strEQ(name,"QuantumDepth"))
736 return(MAGICKCORE_QUANTUM_DEPTH);
737 if (strEQ(name,"QuantumRange"))
738 return(QuantumRange);
743 if (strEQ(name,"ResourceLimitError"))
744 return(ResourceLimitError);
745 if (strEQ(name,"ResourceLimitWarning"))
746 return(ResourceLimitWarning);
747 if (strEQ(name,"RegistryError"))
748 return(RegistryError);
749 if (strEQ(name,"RegistryWarning"))
750 return(RegistryWarning);
755 if (strEQ(name,"StreamError"))
757 if (strEQ(name,"StreamWarning"))
758 return(StreamWarning);
759 if (strEQ(name,"Success"))
765 if (strEQ(name,"Transparent"))
766 return(TransparentAlpha);
767 if (strEQ(name,"TypeError"))
769 if (strEQ(name,"TypeWarning"))
775 if (strEQ(name,"WarningException"))
776 return(WarningException);
781 if (strEQ(name,"XServerError"))
782 return(XServerError);
783 if (strEQ(name,"XServerWarning"))
784 return(XServerWarning);
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 % D e s t r o y P a c k a g e I n f o %
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % Method DestroyPackageInfo frees a previously created info structure.
805 % The format of the DestroyPackageInfo routine is:
807 % DestroyPackageInfo(struct PackageInfo *info)
809 % A description of each parameter follows:
811 % o info: a structure of type info.
814 static void DestroyPackageInfo(struct PackageInfo *info)
816 info->image_info=DestroyImageInfo(info->image_info);
817 info=(struct PackageInfo *) RelinquishMagickMemory(info);
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
831 % Method GetList is recursively called by SetupList to traverse the
832 % Image__Magick reference. If building an reference_vector (see SetupList),
833 % *current is the current position in *reference_vector and *last is the final
834 % entry in *reference_vector.
836 % The format of the GetList routine is:
840 % A description of each parameter follows:
842 % o info: a structure of type info.
845 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
846 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
851 if (reference == (SV *) NULL)
853 switch (SvTYPE(reference))
873 previous=(Image *) NULL;
877 for (i=0; i <= n; i++)
883 if (rv && *rv && sv_isobject(*rv))
885 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
887 if (image == (Image *) NULL)
889 if (image == previous)
891 image=CloneImage(image,0,0,MagickTrue,exception);
892 if (image == (Image *) NULL)
895 image->previous=previous;
896 *(previous ? &previous->next : &head)=image;
897 for (previous=image; previous->next; previous=previous->next) ;
905 Blessed scalar, one image.
907 image=(Image *) SvIV(reference);
908 if (image == (Image *) NULL)
910 image->previous=(Image *) NULL;
911 image->next=(Image *) NULL;
912 if (reference_vector)
914 if (*current == *last)
917 if (*reference_vector == (SV **) NULL)
918 *reference_vector=(SV **) AcquireQuantumMemory(*last,
919 sizeof(*reference_vector));
921 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
922 *last,sizeof(*reference_vector));
924 if (*reference_vector == (SV **) NULL)
926 ThrowPerlException(exception,ResourceLimitError,
927 "MemoryAllocationFailed",PackageName);
928 return((Image *) NULL);
930 (*reference_vector)[*current]=reference;
931 (*reference_vector)[++(*current)]=NULL;
938 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
939 (double) SvTYPE(reference));
940 return((Image *) NULL);
944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948 % G e t P a c k a g e I n f o %
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954 % Method GetPackageInfo looks up or creates an info structure for the given
955 % Image__Magick reference. If it does create a new one, the information in
956 % package_info is used to initialize it.
958 % The format of the GetPackageInfo routine is:
960 % struct PackageInfo *GetPackageInfo(void *reference,
961 % struct PackageInfo *package_info,ExceptionInfo *exception)
963 % A description of each parameter follows:
965 % o info: a structure of type info.
967 % o exception: Return any errors or warnings in this structure.
970 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
971 struct PackageInfo *package_info,ExceptionInfo *exception)
974 message[MaxTextExtent];
982 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
983 PackageName,XS_VERSION,reference);
984 sv=perl_get_sv(message,(TRUE | 0x02));
985 if (sv == (SV *) NULL)
987 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
989 return(package_info);
991 if (SvREFCNT(sv) == 0)
992 (void) SvREFCNT_inc(sv);
993 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
995 clone_info=ClonePackageInfo(package_info,exception);
996 sv_setiv(sv,(IV) clone_info);
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1005 % S e t A t t r i b u t e %
1009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1011 % SetAttribute() sets the attribute to the value in sval. This can change
1012 % either or both of image or info.
1014 % The format of the SetAttribute routine is:
1016 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1017 % SV *sval,ExceptionInfo *exception)
1019 % A description of each parameter follows:
1021 % o list: a list of strings.
1023 % o string: a character string.
1027 static double SiPrefixToDouble(const char *string,const double interval)
1036 value=InterpretLocaleValue(string,&q);
1038 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1040 switch (tolower((int) ((unsigned char) *q)))
1042 case '%': value*=pow(scale,0)*interval/100.0; break;
1043 case 'k': value*=pow(scale,1); break;
1044 case 'm': value*=pow(scale,2); break;
1045 case 'g': value*=pow(scale,3); break;
1046 case 't': value*=pow(scale,4); break;
1047 case 'p': value*=pow(scale,5); break;
1048 case 'e': value*=pow(scale,6); break;
1049 case 'z': value*=pow(scale,7); break;
1050 case 'y': value*=pow(scale,8); break;
1056 static inline ssize_t StringToLong(const char *value)
1058 return(strtol(value,(char **) NULL,10));
1061 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1062 const char *attribute,SV *sval,ExceptionInfo *exception)
1089 if (LocaleCompare(attribute,"adjoin") == 0)
1091 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1092 SvPV(sval,na)) : SvIV(sval);
1095 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1100 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1103 if (LocaleCompare(attribute,"alpha") == 0)
1105 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1106 SvPV(sval,na)) : SvIV(sval);
1109 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1113 for ( ; image; image=image->next)
1114 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp);
1117 if (LocaleCompare(attribute,"antialias") == 0)
1119 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1120 SvPV(sval,na)) : SvIV(sval);
1123 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1128 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1131 if (LocaleCompare(attribute,"area-limit") == 0)
1136 limit=MagickResourceInfinity;
1137 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1138 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1139 (void) SetMagickResourceLimit(AreaResource,limit);
1142 if (LocaleCompare(attribute,"attenuate") == 0)
1145 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1148 if (LocaleCompare(attribute,"authenticate") == 0)
1151 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1155 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1156 for ( ; image; image=image->next)
1157 SetImageProperty(image,attribute,SvPV(sval,na));
1163 if (LocaleCompare(attribute,"background") == 0)
1165 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1167 info->image_info->background_color=target_color;
1168 for ( ; image; image=image->next)
1169 image->background_color=target_color;
1172 if (LocaleCompare(attribute,"bias") == 0)
1174 for ( ; image; image=image->next)
1175 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1178 if (LocaleCompare(attribute,"blue-primary") == 0)
1180 for ( ; image; image=image->next)
1182 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1183 image->chromaticity.blue_primary.x=geometry_info.rho;
1184 image->chromaticity.blue_primary.y=geometry_info.sigma;
1185 if ((flags & SigmaValue) == 0)
1186 image->chromaticity.blue_primary.y=
1187 image->chromaticity.blue_primary.x;
1191 if (LocaleCompare(attribute,"bordercolor") == 0)
1193 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1195 info->image_info->border_color=target_color;
1196 for ( ; image; image=image->next)
1197 image->border_color=target_color;
1201 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1202 for ( ; image; image=image->next)
1203 SetImageProperty(image,attribute,SvPV(sval,na));
1209 if (LocaleCompare(attribute,"cache-threshold") == 0)
1211 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1212 SiPrefixToDouble(SvPV(sval,na),100.0));
1213 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1214 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1217 if (LocaleCompare(attribute,"clip-mask") == 0)
1222 clip_mask=(Image *) NULL;
1224 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1225 for ( ; image; image=image->next)
1226 SetImageClipMask(image,clip_mask);
1229 if (LocaleNCompare(attribute,"colormap",8) == 0)
1231 for ( ; image; image=image->next)
1239 if (image->storage_class == DirectClass)
1242 items=sscanf(attribute,"%*[^[][%ld",&i);
1244 if (i > (ssize_t) image->colors)
1246 if ((strchr(SvPV(sval,na),',') == 0) ||
1247 (strchr(SvPV(sval,na),')') != 0))
1248 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1251 color=image->colormap+i;
1252 pixel.red=color->red;
1253 pixel.green=color->green;
1254 pixel.blue=color->blue;
1255 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1256 pixel.red=geometry_info.rho;
1257 pixel.green=geometry_info.sigma;
1258 pixel.blue=geometry_info.xi;
1259 color->red=ClampToQuantum(pixel.red);
1260 color->green=ClampToQuantum(pixel.green);
1261 color->blue=ClampToQuantum(pixel.blue);
1266 if (LocaleCompare(attribute,"colorspace") == 0)
1268 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1269 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1272 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1276 for ( ; image; image=image->next)
1277 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1280 if (LocaleCompare(attribute,"comment") == 0)
1282 for ( ; image; image=image->next)
1283 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1284 info ? info->image_info : (ImageInfo *) NULL,image,
1288 if (LocaleCompare(attribute,"compression") == 0)
1290 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1291 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1294 ThrowPerlException(exception,OptionError,
1295 "UnrecognizedImageCompression",SvPV(sval,na));
1299 info->image_info->compression=(CompressionType) sp;
1300 for ( ; image; image=image->next)
1301 image->compression=(CompressionType) sp;
1305 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1306 for ( ; image; image=image->next)
1307 SetImageProperty(image,attribute,SvPV(sval,na));
1313 if (LocaleCompare(attribute,"debug") == 0)
1315 SetLogEventMask(SvPV(sval,na));
1318 if (LocaleCompare(attribute,"delay") == 0)
1320 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1321 for ( ; image; image=image->next)
1323 image->delay=(size_t) floor(geometry_info.rho+0.5);
1324 if ((flags & SigmaValue) != 0)
1325 image->ticks_per_second=(ssize_t)
1326 floor(geometry_info.sigma+0.5);
1330 if (LocaleCompare(attribute,"disk-limit") == 0)
1335 limit=MagickResourceInfinity;
1336 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1337 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1338 (void) SetMagickResourceLimit(DiskResource,limit);
1341 if (LocaleCompare(attribute,"density") == 0)
1343 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1345 ThrowPerlException(exception,OptionError,"MissingGeometry",
1350 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1351 for ( ; image; image=image->next)
1353 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1354 image->x_resolution=geometry_info.rho;
1355 image->y_resolution=geometry_info.sigma;
1356 if ((flags & SigmaValue) == 0)
1357 image->y_resolution=image->x_resolution;
1361 if (LocaleCompare(attribute,"depth") == 0)
1364 info->image_info->depth=SvIV(sval);
1365 for ( ; image; image=image->next)
1366 (void) SetImageDepth(image,SvIV(sval));
1369 if (LocaleCompare(attribute,"dispose") == 0)
1371 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1372 SvPV(sval,na)) : SvIV(sval);
1375 ThrowPerlException(exception,OptionError,
1376 "UnrecognizedDisposeMethod",SvPV(sval,na));
1379 for ( ; image; image=image->next)
1380 image->dispose=(DisposeType) sp;
1383 if (LocaleCompare(attribute,"dither") == 0)
1387 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1388 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1391 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1395 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1399 if (LocaleCompare(attribute,"display") == 0)
1403 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1407 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1408 for ( ; image; image=image->next)
1409 SetImageProperty(image,attribute,SvPV(sval,na));
1415 if (LocaleCompare(attribute,"endian") == 0)
1417 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1418 SvPV(sval,na)) : SvIV(sval);
1421 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1426 info->image_info->endian=(EndianType) sp;
1427 for ( ; image; image=image->next)
1428 image->endian=(EndianType) sp;
1431 if (LocaleCompare(attribute,"extract") == 0)
1434 Set image extract geometry.
1436 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1440 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1441 for ( ; image; image=image->next)
1442 SetImageProperty(image,attribute,SvPV(sval,na));
1448 if (LocaleCompare(attribute,"filename") == 0)
1451 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1453 for ( ; image; image=image->next)
1454 (void) CopyMagickString(image->filename,SvPV(sval,na),
1458 if (LocaleCompare(attribute,"file") == 0)
1466 if (info == (struct PackageInfo *) NULL)
1468 io_info=IoIFP(sv_2io(sval));
1469 if (io_info == (PerlIO *) NULL)
1471 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1475 file=PerlIO_findFILE(io_info);
1476 if (file == (FILE *) NULL)
1478 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1482 SetImageInfoFile(info->image_info,file);
1485 if (LocaleCompare(attribute,"fill") == 0)
1488 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1491 if (LocaleCompare(attribute,"font") == 0)
1494 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1497 if (LocaleCompare(attribute,"foreground") == 0)
1499 if (LocaleCompare(attribute,"fuzz") == 0)
1502 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1503 for ( ; image; image=image->next)
1504 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1508 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1509 for ( ; image; image=image->next)
1510 SetImageProperty(image,attribute,SvPV(sval,na));
1516 if (LocaleCompare(attribute,"gamma") == 0)
1518 for ( ; image; image=image->next)
1519 image->gamma=SvNV(sval);
1522 if (LocaleCompare(attribute,"gravity") == 0)
1524 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1525 SvPV(sval,na)) : SvIV(sval);
1528 ThrowPerlException(exception,OptionError,
1529 "UnrecognizedGravityType",SvPV(sval,na));
1533 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1534 for ( ; image; image=image->next)
1535 image->gravity=(GravityType) sp;
1538 if (LocaleCompare(attribute,"green-primary") == 0)
1540 for ( ; image; image=image->next)
1542 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1543 image->chromaticity.green_primary.x=geometry_info.rho;
1544 image->chromaticity.green_primary.y=geometry_info.sigma;
1545 if ((flags & SigmaValue) == 0)
1546 image->chromaticity.green_primary.y=
1547 image->chromaticity.green_primary.x;
1552 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1553 for ( ; image; image=image->next)
1554 SetImageProperty(image,attribute,SvPV(sval,na));
1560 if (LocaleNCompare(attribute,"index",5) == 0)
1574 for ( ; image; image=image->next)
1576 if (image->storage_class != PseudoClass)
1580 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1582 image_view=AcquireCacheView(image);
1583 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1584 if (q != (Quantum *) NULL)
1586 items=sscanf(SvPV(sval,na),"%ld",&index);
1587 if ((index >= 0) && (index < (ssize_t) image->colors))
1588 SetPixelIndex(image,index,q);
1589 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1591 image_view=DestroyCacheView(image_view);
1595 if (LocaleCompare(attribute,"iterations") == 0)
1598 for ( ; image; image=image->next)
1599 image->iterations=SvIV(sval);
1602 if (LocaleCompare(attribute,"interlace") == 0)
1604 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1605 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1608 ThrowPerlException(exception,OptionError,
1609 "UnrecognizedInterlaceType",SvPV(sval,na));
1613 info->image_info->interlace=(InterlaceType) sp;
1614 for ( ; image; image=image->next)
1615 image->interlace=(InterlaceType) sp;
1619 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1620 for ( ; image; image=image->next)
1621 SetImageProperty(image,attribute,SvPV(sval,na));
1627 if (LocaleCompare(attribute,"label") == 0)
1629 for ( ; image; image=image->next)
1630 (void) SetImageProperty(image,"label",InterpretImageProperties(
1631 info ? info->image_info : (ImageInfo *) NULL,image,
1635 if (LocaleCompare(attribute,"loop") == 0)
1638 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1639 for ( ; image; image=image->next)
1640 SetImageProperty(image,attribute,SvPV(sval,na));
1646 if (LocaleCompare(attribute,"magick") == 0)
1649 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1650 "%s:",SvPV(sval,na));
1651 for ( ; image; image=image->next)
1652 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1655 if (LocaleCompare(attribute,"map-limit") == 0)
1660 limit=MagickResourceInfinity;
1661 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1662 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1663 (void) SetMagickResourceLimit(MapResource,limit);
1666 if (LocaleCompare(attribute,"mask") == 0)
1671 mask=(Image *) NULL;
1673 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1674 for ( ; image; image=image->next)
1675 SetImageMask(image,mask);
1678 if (LocaleCompare(attribute,"mattecolor") == 0)
1680 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1682 info->image_info->matte_color=target_color;
1683 for ( ; image; image=image->next)
1684 image->matte_color=target_color;
1687 if (LocaleCompare(attribute,"matte") == 0)
1689 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1690 SvPV(sval,na)) : SvIV(sval);
1693 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1697 for ( ; image; image=image->next)
1698 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1701 if (LocaleCompare(attribute,"memory-limit") == 0)
1706 limit=MagickResourceInfinity;
1707 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1708 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1709 (void) SetMagickResourceLimit(MemoryResource,limit);
1712 if (LocaleCompare(attribute,"monochrome") == 0)
1714 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1715 SvPV(sval,na)) : SvIV(sval);
1718 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1723 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1724 for ( ; image; image=image->next)
1725 (void) SetImageType(image,BilevelType);
1729 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1730 for ( ; image; image=image->next)
1731 SetImageProperty(image,attribute,SvPV(sval,na));
1737 if (LocaleCompare(attribute,"option") == 0)
1740 DefineImageOption(info->image_info,SvPV(sval,na));
1743 if (LocaleCompare(attribute,"orientation") == 0)
1745 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1746 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1749 ThrowPerlException(exception,OptionError,
1750 "UnrecognizedOrientationType",SvPV(sval,na));
1754 info->image_info->orientation=(OrientationType) sp;
1755 for ( ; image; image=image->next)
1756 image->orientation=(OrientationType) sp;
1760 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1761 for ( ; image; image=image->next)
1762 SetImageProperty(image,attribute,SvPV(sval,na));
1768 if (LocaleCompare(attribute,"page") == 0)
1773 geometry=GetPageGeometry(SvPV(sval,na));
1775 (void) CloneString(&info->image_info->page,geometry);
1776 for ( ; image; image=image->next)
1777 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1778 geometry=(char *) RelinquishMagickMemory(geometry);
1781 if (LocaleCompare(attribute,"pen") == 0)
1784 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1787 if (LocaleNCompare(attribute,"pixel",5) == 0)
1801 for ( ; image; image=image->next)
1803 if (SetImageStorageClass(image,DirectClass) == MagickFalse)
1807 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1809 image_view=AcquireCacheView(image);
1810 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1811 if (q != (Quantum *) NULL)
1813 if ((strchr(SvPV(sval,na),',') == 0) ||
1814 (strchr(SvPV(sval,na),')') != 0))
1815 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1818 GetPixelInfo(image,&pixel);
1819 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1820 pixel.red=geometry_info.rho;
1821 if ((flags & SigmaValue) != 0)
1822 pixel.green=geometry_info.sigma;
1823 if ((flags & XiValue) != 0)
1824 pixel.blue=geometry_info.xi;
1825 if ((flags & PsiValue) != 0)
1826 pixel.alpha=geometry_info.psi;
1827 if ((flags & ChiValue) != 0)
1828 pixel.black=geometry_info.chi;
1830 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1831 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1832 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1833 if (image->colorspace == CMYKColorspace)
1834 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1835 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1836 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1838 image_view=DestroyCacheView(image_view);
1842 if (LocaleCompare(attribute,"pointsize") == 0)
1846 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1847 info->image_info->pointsize=geometry_info.rho;
1851 if (LocaleCompare(attribute,"preview") == 0)
1853 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1854 SvPV(sval,na)) : SvIV(sval);
1857 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1862 info->image_info->preview_type=(PreviewType) sp;
1866 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1867 for ( ; image; image=image->next)
1868 SetImageProperty(image,attribute,SvPV(sval,na));
1874 if (LocaleCompare(attribute,"quality") == 0)
1877 info->image_info->quality=SvIV(sval);
1878 for ( ; image; image=image->next)
1879 image->quality=SvIV(sval);
1883 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1884 for ( ; image; image=image->next)
1885 SetImageProperty(image,attribute,SvPV(sval,na));
1891 if (LocaleCompare(attribute,"red-primary") == 0)
1893 for ( ; image; image=image->next)
1895 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1896 image->chromaticity.red_primary.x=geometry_info.rho;
1897 image->chromaticity.red_primary.y=geometry_info.sigma;
1898 if ((flags & SigmaValue) == 0)
1899 image->chromaticity.red_primary.y=
1900 image->chromaticity.red_primary.x;
1904 if (LocaleCompare(attribute,"render") == 0)
1906 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1907 SvPV(sval,na)) : SvIV(sval);
1910 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1914 for ( ; image; image=image->next)
1915 image->rendering_intent=(RenderingIntent) sp;
1918 if (LocaleCompare(attribute,"repage") == 0)
1923 for ( ; image; image=image->next)
1925 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1926 if ((flags & WidthValue) != 0)
1928 if ((flags & HeightValue) == 0)
1929 geometry.height=geometry.width;
1930 image->page.width=geometry.width;
1931 image->page.height=geometry.height;
1933 if ((flags & AspectValue) != 0)
1935 if ((flags & XValue) != 0)
1936 image->page.x+=geometry.x;
1937 if ((flags & YValue) != 0)
1938 image->page.y+=geometry.y;
1942 if ((flags & XValue) != 0)
1944 image->page.x=geometry.x;
1945 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1946 image->page.width=image->columns+geometry.x;
1948 if ((flags & YValue) != 0)
1950 image->page.y=geometry.y;
1951 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1952 image->page.height=image->rows+geometry.y;
1959 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1960 for ( ; image; image=image->next)
1961 SetImageProperty(image,attribute,SvPV(sval,na));
1967 if (LocaleCompare(attribute,"sampling-factor") == 0)
1969 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1971 ThrowPerlException(exception,OptionError,"MissingGeometry",
1976 (void) CloneString(&info->image_info->sampling_factor,
1980 if (LocaleCompare(attribute,"scene") == 0)
1982 for ( ; image; image=image->next)
1983 image->scene=SvIV(sval);
1986 if (LocaleCompare(attribute,"server") == 0)
1988 if (LocaleCompare(attribute,"size") == 0)
1992 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1994 ThrowPerlException(exception,OptionError,"MissingGeometry",
1998 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2002 if (LocaleCompare(attribute,"stroke") == 0)
2005 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2009 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2010 for ( ; image; image=image->next)
2011 SetImageProperty(image,attribute,SvPV(sval,na));
2017 if (LocaleCompare(attribute,"texture") == 0)
2020 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2023 if (LocaleCompare(attribute,"thread-limit") == 0)
2028 limit=MagickResourceInfinity;
2029 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2030 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2031 (void) SetMagickResourceLimit(ThreadResource,limit);
2034 if (LocaleCompare(attribute,"tile-offset") == 0)
2039 geometry=GetPageGeometry(SvPV(sval,na));
2041 (void) CloneString(&info->image_info->page,geometry);
2042 for ( ; image; image=image->next)
2043 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2045 geometry=(char *) RelinquishMagickMemory(geometry);
2048 if (LocaleCompare(attribute,"time-limit") == 0)
2053 limit=MagickResourceInfinity;
2054 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2055 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2056 (void) SetMagickResourceLimit(TimeResource,limit);
2059 if (LocaleCompare(attribute,"transparent-color") == 0)
2061 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2063 info->image_info->transparent_color=target_color;
2064 for ( ; image; image=image->next)
2065 image->transparent_color=target_color;
2068 if (LocaleCompare(attribute,"type") == 0)
2070 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2071 SvPV(sval,na)) : SvIV(sval);
2074 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2079 info->image_info->type=(ImageType) sp;
2080 for ( ; image; image=image->next)
2081 SetImageType(image,(ImageType) sp);
2085 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2086 for ( ; image; image=image->next)
2087 SetImageProperty(image,attribute,SvPV(sval,na));
2093 if (LocaleCompare(attribute,"units") == 0)
2095 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2096 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2099 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2104 info->image_info->units=(ResolutionType) sp;
2105 for ( ; image; image=image->next)
2110 units=(ResolutionType) sp;
2111 if (image->units != units)
2112 switch (image->units)
2114 case UndefinedResolution:
2115 case PixelsPerInchResolution:
2117 if (units == PixelsPerCentimeterResolution)
2119 image->x_resolution*=2.54;
2120 image->y_resolution*=2.54;
2124 case PixelsPerCentimeterResolution:
2126 if (units == PixelsPerInchResolution)
2128 image->x_resolution/=2.54;
2129 image->y_resolution/=2.54;
2139 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2140 for ( ; image; image=image->next)
2141 SetImageProperty(image,attribute,SvPV(sval,na));
2147 if (LocaleCompare(attribute,"verbose") == 0)
2149 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2150 SvPV(sval,na)) : SvIV(sval);
2153 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2158 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2161 if (LocaleCompare(attribute,"view") == 0)
2164 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2167 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2169 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2170 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2173 ThrowPerlException(exception,OptionError,
2174 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2178 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2179 for ( ; image; image=image->next)
2180 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2184 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2185 for ( ; image; image=image->next)
2186 SetImageProperty(image,attribute,SvPV(sval,na));
2192 if (LocaleCompare(attribute,"white-point") == 0)
2194 for ( ; image; image=image->next)
2196 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2197 image->chromaticity.white_point.x=geometry_info.rho;
2198 image->chromaticity.white_point.y=geometry_info.sigma;
2199 if ((flags & SigmaValue) == 0)
2200 image->chromaticity.white_point.y=
2201 image->chromaticity.white_point.x;
2206 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2207 for ( ; image; image=image->next)
2208 SetImageProperty(image,attribute,SvPV(sval,na));
2214 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2215 for ( ; image; image=image->next)
2216 SetImageProperty(image,attribute,SvPV(sval,na));
2223 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2227 % S e t u p L i s t %
2231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2233 % Method SetupList returns the list of all the images linked by their
2234 % image->next and image->previous link lists for use with ImageMagick. If
2235 % info is non-NULL, an info structure is returned in *info. If
2236 % reference_vector is non-NULL,an array of SV* are returned in
2237 % *reference_vector. Reference_vector is used when the images are going to be
2238 % replaced with new Image*'s.
2240 % The format of the SetupList routine is:
2242 % Image *SetupList(SV *reference,struct PackageInfo **info,
2243 % SV ***reference_vector,ExceptionInfo *exception)
2245 % A description of each parameter follows:
2247 % o list: a list of strings.
2249 % o string: a character string.
2251 % o exception: Return any errors or warnings in this structure.
2254 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2255 SV ***reference_vector,ExceptionInfo *exception)
2264 if (reference_vector)
2265 *reference_vector=NULL;
2270 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2271 if (info && (SvTYPE(reference) == SVt_PVAV))
2272 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2278 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2282 % s t r E Q c a s e %
2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2288 % strEQcase() compares two strings and returns 0 if they are the
2289 % same or if the second string runs out first. The comparison is case
2292 % The format of the strEQcase routine is:
2294 % ssize_t strEQcase(const char *p,const char *q)
2296 % A description of each parameter follows:
2298 % o p: a character string.
2300 % o q: a character string.
2304 static ssize_t strEQcase(const char *p,const char *q)
2312 for (i=0 ; (c=(*q)) != 0; i++)
2314 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2315 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2320 return(((*q == 0) && (*p == 0)) ? i : 0);
2324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2328 % I m a g e : : M a g i c k %
2332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2336 MODULE = Image::Magick PACKAGE = Image::Magick
2341 MagickCoreGenesis("PerlMagick",MagickFalse);
2342 SetWarningHandler(NULL);
2343 SetErrorHandler(NULL);
2344 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2345 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2351 if (magick_registry != (SplayTreeInfo *) NULL)
2352 magick_registry=DestroySplayTree(magick_registry);
2353 MagickCoreTerminus();
2357 constant(name,argument)
2362 ###############################################################################
2370 ###############################################################################
2375 Image::Magick ref=NO_INIT
2399 PERL_UNUSED_VAR(ref);
2400 PERL_UNUSED_VAR(ix);
2401 exception=AcquireExceptionInfo();
2402 perl_exception=newSVpv("",0);
2403 package_info=(struct PackageInfo *) NULL;
2404 if (sv_isobject(ST(0)) == 0)
2406 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2410 reference=SvRV(ST(0));
2411 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2412 if (image == (Image *) NULL)
2414 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2418 package_info=ClonePackageInfo(info,exception);
2420 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2423 for (i=2; i < items; i+=2)
2424 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2426 (void) AnimateImages(package_info->image_info,image);
2427 (void) CatchImageException(image);
2428 InheritException(exception,&image->exception);
2431 if (package_info != (struct PackageInfo *) NULL)
2432 DestroyPackageInfo(package_info);
2433 InheritPerlException(exception,perl_exception);
2434 exception=DestroyExceptionInfo(exception);
2435 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2436 SvPOK_on(perl_exception);
2437 ST(0)=sv_2mortal(perl_exception);
2442 ###############################################################################
2450 ###############################################################################
2455 Image::Magick ref=NO_INIT
2493 PERL_UNUSED_VAR(ref);
2494 PERL_UNUSED_VAR(ix);
2495 exception=AcquireExceptionInfo();
2496 perl_exception=newSVpv("",0);
2500 if (sv_isobject(ST(0)) == 0)
2502 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2506 reference=SvRV(ST(0));
2507 hv=SvSTASH(reference);
2509 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2511 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2512 if (image == (Image *) NULL)
2514 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2518 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2523 for (i=2; i < items; i+=2)
2525 attribute=(char *) SvPV(ST(i-1),na);
2531 if (LocaleCompare(attribute,"stack") == 0)
2533 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2537 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2555 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2556 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2558 for ( ; image; image=image->next)
2560 AddImageToRegistry(sv,image);
2562 av_push(av,sv_bless(rv,hv));
2565 exception=DestroyExceptionInfo(exception);
2567 SvREFCNT_dec(perl_exception);
2571 InheritPerlException(exception,perl_exception);
2572 exception=DestroyExceptionInfo(exception);
2573 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2574 SvPOK_on(perl_exception);
2575 ST(0)=sv_2mortal(perl_exception);
2580 ###############################################################################
2588 ###############################################################################
2593 Image::Magick ref=NO_INIT
2624 PERL_UNUSED_VAR(ref);
2625 PERL_UNUSED_VAR(ix);
2626 exception=AcquireExceptionInfo();
2627 perl_exception=newSVpv("",0);
2629 if (sv_isobject(ST(0)) == 0)
2631 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2635 reference=SvRV(ST(0));
2636 hv=SvSTASH(reference);
2637 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2638 if (image == (Image *) NULL)
2640 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2644 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2645 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2648 Create blessed Perl array for the returned image.
2651 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2653 AddImageToRegistry(sv,image);
2655 av_push(av,sv_bless(rv,hv));
2657 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2658 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2659 "average-%.*s",(int) (MaxTextExtent-9),
2660 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2661 (void) CopyMagickString(image->filename,info->image_info->filename,
2663 SetImageInfo(info->image_info,0,exception);
2664 exception=DestroyExceptionInfo(exception);
2665 SvREFCNT_dec(perl_exception);
2669 InheritPerlException(exception,perl_exception);
2670 exception=DestroyExceptionInfo(exception);
2671 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2672 SvPOK_on(perl_exception);
2673 ST(0)=sv_2mortal(perl_exception);
2678 ###############################################################################
2682 # B l o b T o I m a g e #
2686 ###############################################################################
2690 BlobToImage(ref,...)
2691 Image::Magick ref=NO_INIT
2737 PERL_UNUSED_VAR(ref);
2738 PERL_UNUSED_VAR(ix);
2739 exception=AcquireExceptionInfo();
2740 perl_exception=newSVpv("",0);
2743 ac=(items < 2) ? 1 : items-1;
2744 length=(STRLEN *) NULL;
2745 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2746 if (list == (char **) NULL)
2748 ThrowPerlException(exception,ResourceLimitError,
2749 "MemoryAllocationFailed",PackageName);
2752 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2753 if (length == (STRLEN *) NULL)
2755 ThrowPerlException(exception,ResourceLimitError,
2756 "MemoryAllocationFailed",PackageName);
2759 if (sv_isobject(ST(0)) == 0)
2761 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2765 reference=SvRV(ST(0));
2766 hv=SvSTASH(reference);
2767 if (SvTYPE(reference) != SVt_PVAV)
2769 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2773 av=(AV *) reference;
2774 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2779 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2782 for (n=0, i=0; i < ac; i++)
2784 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2785 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2787 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2792 list[n]=(char *) NULL;
2794 for (i=number_images=0; i < n; i++)
2796 image=BlobToImage(info->image_info,list[i],length[i],exception);
2797 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2799 for ( ; image; image=image->next)
2801 AddImageToRegistry(sv,image);
2803 av_push(av,sv_bless(rv,hv));
2811 for (i=0; i < n; i++)
2812 if (list[i] != (char *) NULL)
2813 for (p=keep; list[i] != *p++; )
2814 if (*p == (char *) NULL)
2816 list[i]=(char *) RelinquishMagickMemory(list[i]);
2822 list=(char **) RelinquishMagickMemory(list);
2824 length=(STRLEN *) RelinquishMagickMemory(length);
2825 InheritPerlException(exception,perl_exception);
2826 exception=DestroyExceptionInfo(exception);
2827 sv_setiv(perl_exception,(IV) number_images);
2828 SvPOK_on(perl_exception);
2829 ST(0)=sv_2mortal(perl_exception);
2834 ###############################################################################
2842 ###############################################################################
2847 Image::Magick ref=NO_INIT
2880 PERL_UNUSED_VAR(ref);
2881 PERL_UNUSED_VAR(ix);
2882 exception=AcquireExceptionInfo();
2883 perl_exception=newSVpv("",0);
2885 if (sv_isobject(ST(0)) == 0)
2887 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2891 reference=SvRV(ST(0));
2892 hv=SvSTASH(reference);
2893 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2894 if (image == (Image *) NULL)
2896 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2901 Create blessed Perl array for the returned image.
2904 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2906 for ( ; image; image=image->next)
2908 clone=CloneImage(image,0,0,MagickTrue,exception);
2909 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2911 AddImageToRegistry(sv,clone);
2913 av_push(av,sv_bless(rv,hv));
2916 exception=DestroyExceptionInfo(exception);
2917 SvREFCNT_dec(perl_exception);
2921 InheritPerlException(exception,perl_exception);
2922 exception=DestroyExceptionInfo(exception);
2923 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2924 SvPOK_on(perl_exception);
2925 ST(0)=sv_2mortal(perl_exception);
2930 ###############################################################################
2938 ###############################################################################
2946 PERL_UNUSED_VAR(ref);
2947 if (magick_registry != (SplayTreeInfo *) NULL)
2952 ResetSplayTreeIterator(magick_registry);
2953 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2954 while (p != (Image *) NULL)
2957 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2963 ###############################################################################
2971 ###############################################################################
2976 Image::Magick ref=NO_INIT
3005 PERL_UNUSED_VAR(ref);
3006 PERL_UNUSED_VAR(ix);
3007 exception=AcquireExceptionInfo();
3008 perl_exception=newSVpv("",0);
3010 if (sv_isobject(ST(0)) == 0)
3012 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3016 reference=SvRV(ST(0));
3017 hv=SvSTASH(reference);
3019 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3021 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3022 if (image == (Image *) NULL)
3024 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3028 image=CoalesceImages(image,exception);
3029 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3031 for ( ; image; image=image->next)
3033 AddImageToRegistry(sv,image);
3035 av_push(av,sv_bless(rv,hv));
3038 exception=DestroyExceptionInfo(exception);
3040 SvREFCNT_dec(perl_exception);
3044 InheritPerlException(exception,perl_exception);
3045 exception=DestroyExceptionInfo(exception);
3046 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3047 SvPOK_on(perl_exception);
3048 ST(0)=sv_2mortal(perl_exception);
3053 ###############################################################################
3061 ###############################################################################
3066 Image::Magick ref=NO_INIT
3112 PERL_UNUSED_VAR(ref);
3113 PERL_UNUSED_VAR(ix);
3114 exception=AcquireExceptionInfo();
3115 perl_exception=newSVpv("",0);
3119 if (sv_isobject(ST(0)) == 0)
3121 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3125 reference=SvRV(ST(0));
3126 hv=SvSTASH(reference);
3128 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3130 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3131 if (image == (Image *) NULL)
3133 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3137 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3141 reconstruct_image=image;
3142 metric=RootMeanSquaredErrorMetric;
3143 for (i=2; i < items; i+=2)
3145 attribute=(char *) SvPV(ST(i-1),na);
3151 if (LocaleCompare(attribute,"channel") == 0)
3156 option=ParseChannelOption(SvPV(ST(i),na));
3159 ThrowPerlException(exception,OptionError,
3160 "UnrecognizedType",SvPV(ST(i),na));
3163 SetPixelComponentMap(image,(ChannelType) option);
3166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3173 if (LocaleCompare(attribute,"fuzz") == 0)
3175 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3185 if (LocaleCompare(attribute,"image") == 0)
3187 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3188 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3191 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3198 if (LocaleCompare(attribute,"metric") == 0)
3200 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3204 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3208 metric=(MetricType) option;
3211 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3217 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3223 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3225 if (difference_image != (Image *) NULL)
3227 difference_image->error.mean_error_per_pixel=distortion;
3228 AddImageToRegistry(sv,difference_image);
3230 av_push(av,sv_bless(rv,hv));
3233 exception=DestroyExceptionInfo(exception);
3235 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3239 InheritPerlException(exception,perl_exception);
3240 exception=DestroyExceptionInfo(exception);
3241 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3242 SvPOK_on(perl_exception);
3243 ST(0)=sv_2mortal(perl_exception);
3248 ###############################################################################
3252 # C o m p a r e L a y e r s #
3256 ###############################################################################
3261 Image::Magick ref=NO_INIT
3263 CompareImagesLayers = 1
3265 compareimagelayers = 3
3302 PERL_UNUSED_VAR(ref);
3303 PERL_UNUSED_VAR(ix);
3304 exception=AcquireExceptionInfo();
3305 perl_exception=newSVpv("",0);
3307 if (sv_isobject(ST(0)) == 0)
3309 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3313 reference=SvRV(ST(0));
3314 hv=SvSTASH(reference);
3316 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3318 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3319 if (image == (Image *) NULL)
3321 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3325 method=CompareAnyLayer;
3326 for (i=2; i < items; i+=2)
3328 attribute=(char *) SvPV(ST(i-1),na);
3334 if (LocaleCompare(attribute,"method") == 0)
3336 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3340 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3344 method=(ImageLayerMethod) option;
3347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3353 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3359 image=CompareImagesLayers(image,method,exception);
3360 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3362 for ( ; image; image=image->next)
3364 AddImageToRegistry(sv,image);
3366 av_push(av,sv_bless(rv,hv));
3369 exception=DestroyExceptionInfo(exception);
3371 SvREFCNT_dec(perl_exception);
3375 InheritPerlException(exception,perl_exception);
3376 exception=DestroyExceptionInfo(exception);
3377 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3378 SvPOK_on(perl_exception);
3379 ST(0)=sv_2mortal(perl_exception);
3384 ###############################################################################
3392 ###############################################################################
3397 Image::Magick ref=NO_INIT
3403 PERL_UNUSED_VAR(ref);
3404 if (sv_isobject(ST(0)) == 0)
3405 croak("ReferenceIsNotMyType");
3406 reference=SvRV(ST(0));
3407 switch (SvTYPE(reference))
3412 message[MaxTextExtent];
3430 Array (AV *) reference
3432 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3433 XS_VERSION,reference);
3434 hv=gv_stashpv(PackageName, FALSE);
3437 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3441 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3443 info=(struct PackageInfo *) SvIV(sv);
3444 DestroyPackageInfo(info);
3446 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3456 Blessed scalar = (Image *) SvIV(reference)
3458 image=(Image *) SvIV(reference);
3459 if (image != (Image *) NULL)
3460 DeleteImageFromRegistry(reference,image);
3469 ###############################################################################
3477 ###############################################################################
3482 Image::Magick ref=NO_INIT
3506 PERL_UNUSED_VAR(ref);
3507 PERL_UNUSED_VAR(ix);
3508 exception=AcquireExceptionInfo();
3509 perl_exception=newSVpv("",0);
3510 package_info=(struct PackageInfo *) NULL;
3511 if (sv_isobject(ST(0)) == 0)
3513 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3517 reference=SvRV(ST(0));
3518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3519 if (image == (Image *) NULL)
3521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3525 package_info=ClonePackageInfo(info,exception);
3527 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3530 for (i=2; i < items; i+=2)
3531 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3533 (void) DisplayImages(package_info->image_info,image);
3534 (void) CatchImageException(image);
3535 InheritException(exception,&image->exception);
3538 if (package_info != (struct PackageInfo *) NULL)
3539 DestroyPackageInfo(package_info);
3540 InheritPerlException(exception,perl_exception);
3541 exception=DestroyExceptionInfo(exception);
3542 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3543 SvPOK_on(perl_exception);
3544 ST(0)=sv_2mortal(perl_exception);
3549 ###############################################################################
3553 # E v a l u a t e I m a g e s #
3557 ###############################################################################
3562 Image::Magick ref=NO_INIT
3584 MagickEvaluateOperator
3599 PERL_UNUSED_VAR(ref);
3600 PERL_UNUSED_VAR(ix);
3601 exception=AcquireExceptionInfo();
3602 perl_exception=newSVpv("",0);
3604 if (sv_isobject(ST(0)) == 0)
3606 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3610 reference=SvRV(ST(0));
3611 hv=SvSTASH(reference);
3612 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3613 if (image == (Image *) NULL)
3615 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3619 op=MeanEvaluateOperator;
3625 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3629 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3633 op=(MagickEvaluateOperator) in;
3636 for (i=2; i < items; i+=2)
3638 attribute=(char *) SvPV(ST(i-1),na);
3644 if (LocaleCompare(attribute,"operator") == 0)
3649 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3650 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3653 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3657 op=(MagickEvaluateOperator) in;
3660 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3666 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3672 image=EvaluateImages(image,op,exception);
3673 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3676 Create blessed Perl array for the returned image.
3679 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3681 AddImageToRegistry(sv,image);
3683 av_push(av,sv_bless(rv,hv));
3685 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3686 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3687 "evaluate-%.*s",(int) (MaxTextExtent-9),
3688 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3689 (void) CopyMagickString(image->filename,info->image_info->filename,
3691 SetImageInfo(info->image_info,0,exception);
3692 exception=DestroyExceptionInfo(exception);
3693 SvREFCNT_dec(perl_exception);
3697 InheritPerlException(exception,perl_exception);
3698 exception=DestroyExceptionInfo(exception);
3699 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3700 SvPOK_on(perl_exception);
3701 ST(0)=sv_2mortal(perl_exception);
3706 ###############################################################################
3714 ###############################################################################
3719 Image::Magick ref=NO_INIT
3726 #define ChannelFeatures(channel,direction) \
3728 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3729 channel_features[channel].angular_second_moment[direction]); \
3730 PUSHs(sv_2mortal(newSVpv(message,0))); \
3731 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3732 channel_features[channel].contrast[direction]); \
3733 PUSHs(sv_2mortal(newSVpv(message,0))); \
3734 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3735 channel_features[channel].contrast[direction]); \
3736 PUSHs(sv_2mortal(newSVpv(message,0))); \
3737 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3738 channel_features[channel].variance_sum_of_squares[direction]); \
3739 PUSHs(sv_2mortal(newSVpv(message,0))); \
3740 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3741 channel_features[channel].inverse_difference_moment[direction]); \
3742 PUSHs(sv_2mortal(newSVpv(message,0))); \
3743 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3744 channel_features[channel].sum_average[direction]); \
3745 PUSHs(sv_2mortal(newSVpv(message,0))); \
3746 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3747 channel_features[channel].sum_variance[direction]); \
3748 PUSHs(sv_2mortal(newSVpv(message,0))); \
3749 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3750 channel_features[channel].sum_entropy[direction]); \
3751 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3753 channel_features[channel].entropy[direction]); \
3754 PUSHs(sv_2mortal(newSVpv(message,0))); \
3755 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3756 channel_features[channel].difference_variance[direction]); \
3757 PUSHs(sv_2mortal(newSVpv(message,0))); \
3758 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3759 channel_features[channel].difference_entropy[direction]); \
3760 PUSHs(sv_2mortal(newSVpv(message,0))); \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].measure_of_correlation_1[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].measure_of_correlation_2[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3767 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3768 channel_features[channel].maximum_correlation_coefficient[direction]); \
3769 PUSHs(sv_2mortal(newSVpv(message,0))); \
3777 message[MaxTextExtent];
3804 PERL_UNUSED_VAR(ref);
3805 PERL_UNUSED_VAR(ix);
3806 exception=AcquireExceptionInfo();
3807 perl_exception=newSVpv("",0);
3809 if (sv_isobject(ST(0)) == 0)
3811 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3815 reference=SvRV(ST(0));
3818 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3819 if (image == (Image *) NULL)
3821 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3825 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3827 for (i=2; i < items; i+=2)
3829 attribute=(char *) SvPV(ST(i-1),na);
3835 if (LocaleCompare(attribute,"distance") == 0)
3837 distance=StringToLong((char *) SvPV(ST(1),na));
3840 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3846 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3853 for ( ; image; image=image->next)
3855 channel_features=GetImageFeatures(image,distance,
3857 if (channel_features == (ChannelFeatures *) NULL)
3860 EXTEND(sp,75*count);
3861 for (i=0; i < 4; i++)
3863 ChannelFeatures(RedChannel,i);
3864 ChannelFeatures(GreenChannel,i);
3865 ChannelFeatures(BlueChannel,i);
3866 if (image->colorspace == CMYKColorspace)
3867 ChannelFeatures(BlackChannel,i);
3868 if (image->matte != MagickFalse)
3869 ChannelFeatures(AlphaChannel,i);
3871 channel_features=(ChannelFeatures *)
3872 RelinquishMagickMemory(channel_features);
3876 InheritPerlException(exception,perl_exception);
3877 exception=DestroyExceptionInfo(exception);
3878 SvREFCNT_dec(perl_exception);
3882 ###############################################################################
3890 ###############################################################################
3895 Image::Magick ref=NO_INIT
3933 PERL_UNUSED_VAR(ref);
3934 PERL_UNUSED_VAR(ix);
3935 exception=AcquireExceptionInfo();
3936 perl_exception=newSVpv("",0);
3938 if (sv_isobject(ST(0)) == 0)
3940 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3944 reference=SvRV(ST(0));
3945 hv=SvSTASH(reference);
3946 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3947 if (image == (Image *) NULL)
3949 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3953 background_color=image->background_color;
3955 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3958 for (i=2; i < items; i+=2)
3960 attribute=(char *) SvPV(ST(i-1),na);
3966 if (LocaleCompare(attribute,"background") == 0)
3968 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3969 &background_color,exception);
3972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3984 image->background_color=background_color;
3985 image=MergeImageLayers(image,FlattenLayer,exception);
3986 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3989 Create blessed Perl array for the returned image.
3992 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3994 AddImageToRegistry(sv,image);
3996 av_push(av,sv_bless(rv,hv));
3998 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3999 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4000 "flatten-%.*s",(int) (MaxTextExtent-9),
4001 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4002 (void) CopyMagickString(image->filename,info->image_info->filename,
4004 SetImageInfo(info->image_info,0,exception);
4005 exception=DestroyExceptionInfo(exception);
4006 SvREFCNT_dec(perl_exception);
4010 InheritPerlException(exception,perl_exception);
4011 exception=DestroyExceptionInfo(exception);
4012 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4013 SvPOK_on(perl_exception); /* return messages in string context */
4014 ST(0)=sv_2mortal(perl_exception);
4019 ###############################################################################
4027 ###############################################################################
4032 Image::Magick ref=NO_INIT
4044 expression[MaxTextExtent];
4071 PERL_UNUSED_VAR(ref);
4072 PERL_UNUSED_VAR(ix);
4073 exception=AcquireExceptionInfo();
4074 perl_exception=newSVpv("",0);
4078 if (sv_isobject(ST(0)) == 0)
4080 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4084 reference=SvRV(ST(0));
4085 hv=SvSTASH(reference);
4087 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4089 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4090 if (image == (Image *) NULL)
4092 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4096 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4100 channel=DefaultChannels;
4101 (void) CopyMagickString(expression,"u",MaxTextExtent);
4103 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4105 for (i=2; i < items; i+=2)
4107 attribute=(char *) SvPV(ST(i-1),na);
4113 if (LocaleCompare(attribute,"channel") == 0)
4118 option=ParseChannelOption(SvPV(ST(i),na));
4121 ThrowPerlException(exception,OptionError,
4122 "UnrecognizedType",SvPV(ST(i),na));
4125 channel=(ChannelType) option;
4128 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4135 if (LocaleCompare(attribute,"expression") == 0)
4137 (void) CopyMagickString(expression,SvPV(ST(i),na),
4141 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4153 PushPixelComponentMap(image,channel);
4154 image=FxImage(image,expression,exception);
4155 if (image != (Image *) NULL)
4156 PopPixelComponentMap(image);
4157 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4159 for ( ; image; image=image->next)
4161 AddImageToRegistry(sv,image);
4163 av_push(av,sv_bless(rv,hv));
4166 exception=DestroyExceptionInfo(exception);
4168 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4172 InheritPerlException(exception,perl_exception);
4173 exception=DestroyExceptionInfo(exception);
4174 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4175 SvPOK_on(perl_exception);
4176 ST(0)=sv_2mortal(perl_exception);
4181 ###############################################################################
4189 ###############################################################################
4194 Image::Magick ref=NO_INIT
4205 color[MaxTextExtent];
4230 PERL_UNUSED_VAR(ref);
4231 PERL_UNUSED_VAR(ix);
4232 exception=AcquireExceptionInfo();
4233 perl_exception=newSVpv("",0);
4234 if (sv_isobject(ST(0)) == 0)
4236 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4240 reference=SvRV(ST(0));
4241 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4242 if (image == (Image *) NULL && !info)
4245 for (i=1; i < items; i++)
4247 attribute=(char *) SvPV(ST(i),na);
4254 if (LocaleCompare(attribute,"adjoin") == 0)
4257 s=newSViv((ssize_t) info->image_info->adjoin);
4258 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4261 if (LocaleCompare(attribute,"antialias") == 0)
4264 s=newSViv((ssize_t) info->image_info->antialias);
4265 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4268 if (LocaleCompare(attribute,"area") == 0)
4270 s=newSViv(GetMagickResource(AreaResource));
4271 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4274 if (LocaleCompare(attribute,"attenuate") == 0)
4279 value=GetImageProperty(image,attribute);
4280 if (value != (const char *) NULL)
4282 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4285 if (LocaleCompare(attribute,"authenticate") == 0)
4288 s=newSVpv(info->image_info->authenticate,0);
4289 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4292 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4299 if (LocaleCompare(attribute,"background") == 0)
4301 if (image == (Image *) NULL)
4303 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4304 QuantumFormat "," QuantumFormat "," QuantumFormat,
4305 image->background_color.red,image->background_color.green,
4306 image->background_color.blue,image->background_color.alpha);
4308 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4311 if (LocaleCompare(attribute,"base-columns") == 0)
4313 if (image != (Image *) NULL)
4314 s=newSViv((ssize_t) image->magick_columns);
4315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4318 if (LocaleCompare(attribute,"base-filename") == 0)
4320 if (image != (Image *) NULL)
4321 s=newSVpv(image->magick_filename,0);
4322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4325 if (LocaleCompare(attribute,"base-height") == 0)
4327 if (image != (Image *) NULL)
4328 s=newSViv((ssize_t) image->magick_rows);
4329 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4332 if (LocaleCompare(attribute,"base-rows") == 0)
4334 if (image != (Image *) NULL)
4335 s=newSViv((ssize_t) image->magick_rows);
4336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4339 if (LocaleCompare(attribute,"base-width") == 0)
4341 if (image != (Image *) NULL)
4342 s=newSViv((ssize_t) image->magick_columns);
4343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4346 if (LocaleCompare(attribute,"bias") == 0)
4348 if (image != (Image *) NULL)
4349 s=newSVnv(image->bias);
4350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4353 if (LocaleCompare(attribute,"blue-primary") == 0)
4355 if (image == (Image *) NULL)
4357 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4358 image->chromaticity.blue_primary.x,
4359 image->chromaticity.blue_primary.y);
4361 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4364 if (LocaleCompare(attribute,"bordercolor") == 0)
4366 if (image == (Image *) NULL)
4368 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4369 QuantumFormat "," QuantumFormat "," QuantumFormat,
4370 image->border_color.red,image->border_color.green,
4371 image->border_color.blue,image->border_color.alpha);
4373 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4376 if (LocaleCompare(attribute,"bounding-box") == 0)
4379 geometry[MaxTextExtent];
4384 if (image == (Image *) NULL)
4386 page=GetImageBoundingBox(image,&image->exception);
4387 (void) FormatLocaleString(geometry,MaxTextExtent,
4388 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4389 page.height,(double) page.x,(double) page.y);
4390 s=newSVpv(geometry,0);
4391 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4401 if (LocaleCompare(attribute,"class") == 0)
4403 if (image == (Image *) NULL)
4405 s=newSViv(image->storage_class);
4406 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4407 image->storage_class));
4409 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4412 if (LocaleCompare(attribute,"clip-mask") == 0)
4414 if (image != (Image *) NULL)
4420 if (image->mask == (Image *) NULL)
4422 if (image->mask != (Image *) NULL)
4424 AddImageToRegistry(sv,image->mask);
4425 s=sv_bless(newRV(sv),SvSTASH(reference));
4428 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4431 if (LocaleCompare(attribute,"clip-path") == 0)
4433 if (image != (Image *) NULL)
4439 if (image->clip_mask == (Image *) NULL)
4441 if (image->clip_mask != (Image *) NULL)
4443 AddImageToRegistry(sv,image->clip_mask);
4444 s=sv_bless(newRV(sv),SvSTASH(reference));
4447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4450 if (LocaleCompare(attribute,"compression") == 0)
4452 j=info ? info->image_info->compression : image ?
4453 image->compression : UndefinedCompression;
4455 if (info->image_info->compression == UndefinedCompression)
4456 j=image->compression;
4458 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4461 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4464 if (LocaleCompare(attribute,"colorspace") == 0)
4466 j=image ? image->colorspace : RGBColorspace;
4468 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4471 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4474 if (LocaleCompare(attribute,"colors") == 0)
4476 if (image != (Image *) NULL)
4477 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4478 &image->exception));
4479 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4482 if (LocaleNCompare(attribute,"colormap",8) == 0)
4487 if (image == (Image *) NULL || !image->colormap)
4490 items=sscanf(attribute,"%*[^[][%ld",&j);
4492 if (j > (ssize_t) image->colors)
4494 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4495 QuantumFormat "," QuantumFormat "," QuantumFormat,
4496 image->colormap[j].red,image->colormap[j].green,
4497 image->colormap[j].blue,image->colormap[j].alpha);
4499 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4502 if (LocaleCompare(attribute,"columns") == 0)
4504 if (image != (Image *) NULL)
4505 s=newSViv((ssize_t) image->columns);
4506 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4509 if (LocaleCompare(attribute,"comment") == 0)
4514 value=GetImageProperty(image,attribute);
4515 if (value != (const char *) NULL)
4517 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4520 if (LocaleCompare(attribute,"copyright") == 0)
4522 s=newSVpv(GetMagickCopyright(),0);
4523 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4526 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4533 if (LocaleCompare(attribute,"density") == 0)
4536 geometry[MaxTextExtent];
4538 if (image == (Image *) NULL)
4540 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4541 image->x_resolution,image->y_resolution);
4542 s=newSVpv(geometry,0);
4543 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4546 if (LocaleCompare(attribute,"delay") == 0)
4548 if (image != (Image *) NULL)
4549 s=newSViv((ssize_t) image->delay);
4550 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4553 if (LocaleCompare(attribute,"depth") == 0)
4555 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4556 if (image != (Image *) NULL)
4557 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4558 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4561 if (LocaleCompare(attribute,"directory") == 0)
4563 if (image && image->directory)
4564 s=newSVpv(image->directory,0);
4565 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4568 if (LocaleCompare(attribute,"dispose") == 0)
4570 if (image == (Image *) NULL)
4573 s=newSViv(image->dispose);
4575 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4577 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4580 if (LocaleCompare(attribute,"disk") == 0)
4582 s=newSViv(GetMagickResource(DiskResource));
4583 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4586 if (LocaleCompare(attribute,"dither") == 0)
4589 s=newSViv((ssize_t) info->image_info->dither);
4590 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4593 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4595 if (info && info->image_info->server_name)
4596 s=newSVpv(info->image_info->server_name,0);
4597 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4600 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4607 if (LocaleCompare(attribute,"elapsed-time") == 0)
4609 if (image != (Image *) NULL)
4610 s=newSVnv(GetElapsedTime(&image->timer));
4611 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4614 if (LocaleCompare(attribute,"endian") == 0)
4616 j=info ? info->image_info->endian : image ? image->endian :
4619 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4621 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4624 if (LocaleCompare(attribute,"error") == 0)
4626 if (image != (Image *) NULL)
4627 s=newSVnv(image->error.mean_error_per_pixel);
4628 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4631 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4638 if (LocaleCompare(attribute,"filesize") == 0)
4640 if (image != (Image *) NULL)
4641 s=newSViv((ssize_t) GetBlobSize(image));
4642 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4645 if (LocaleCompare(attribute,"filename") == 0)
4647 if (info && info->image_info->filename &&
4648 *info->image_info->filename)
4649 s=newSVpv(info->image_info->filename,0);
4650 if (image != (Image *) NULL)
4651 s=newSVpv(image->filename,0);
4652 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4655 if (LocaleCompare(attribute,"filter") == 0)
4657 s=image ? newSViv(image->filter) : newSViv(0);
4658 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4661 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4664 if (LocaleCompare(attribute,"font") == 0)
4666 if (info && info->image_info->font)
4667 s=newSVpv(info->image_info->font,0);
4668 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4671 if (LocaleCompare(attribute,"foreground") == 0)
4673 if (LocaleCompare(attribute,"format") == 0)
4678 magick_info=(const MagickInfo *) NULL;
4679 if (info && (*info->image_info->magick != '\0'))
4680 magick_info=GetMagickInfo(info->image_info->magick,exception);
4681 if (image != (Image *) NULL)
4682 magick_info=GetMagickInfo(image->magick,&image->exception);
4683 if ((magick_info != (const MagickInfo *) NULL) &&
4684 (*magick_info->description != '\0'))
4685 s=newSVpv((char *) magick_info->description,0);
4686 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4689 if (LocaleCompare(attribute,"fuzz") == 0)
4692 s=newSVnv(info->image_info->fuzz);
4693 if (image != (Image *) NULL)
4694 s=newSVnv(image->fuzz);
4695 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4705 if (LocaleCompare(attribute,"gamma") == 0)
4707 if (image != (Image *) NULL)
4708 s=newSVnv(image->gamma);
4709 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4712 if (LocaleCompare(attribute,"geometry") == 0)
4714 if (image && image->geometry)
4715 s=newSVpv(image->geometry,0);
4716 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4719 if (LocaleCompare(attribute,"gravity") == 0)
4721 s=image ? newSViv(image->gravity) : newSViv(0);
4722 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4725 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4728 if (LocaleCompare(attribute,"green-primary") == 0)
4730 if (image == (Image *) NULL)
4732 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4733 image->chromaticity.green_primary.x,
4734 image->chromaticity.green_primary.y);
4736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4746 if (LocaleCompare(attribute,"height") == 0)
4748 if (image != (Image *) NULL)
4749 s=newSViv((ssize_t) image->rows);
4750 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4753 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4760 if (LocaleCompare(attribute,"icc") == 0)
4762 if (image != (Image *) NULL)
4767 profile=GetImageProfile(image,"icc");
4768 if (profile != (StringInfo *) NULL)
4769 s=newSVpv((const char *) GetStringInfoDatum(profile),
4770 GetStringInfoLength(profile));
4772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4775 if (LocaleCompare(attribute,"icm") == 0)
4777 if (image != (Image *) NULL)
4782 profile=GetImageProfile(image,"icm");
4783 if (profile != (const StringInfo *) NULL)
4784 s=newSVpv((const char *) GetStringInfoDatum(profile),
4785 GetStringInfoLength(profile));
4787 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4790 if (LocaleCompare(attribute,"id") == 0)
4792 if (image != (Image *) NULL)
4803 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4805 status=SetImageRegistry(ImageRegistryType,key,image,
4810 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4813 if (LocaleNCompare(attribute,"index",5) == 0)
4816 name[MaxTextExtent];
4825 register const Quantum
4831 if (image == (Image *) NULL)
4833 if (image->storage_class != PseudoClass)
4837 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4839 image_view=AcquireCacheView(image);
4840 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4841 if (p != (const Quantum *) NULL)
4843 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4844 GetPixelIndex(image,p));
4846 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4848 image_view=DestroyCacheView(image_view);
4851 if (LocaleCompare(attribute,"iptc") == 0)
4853 if (image != (Image *) NULL)
4858 profile=GetImageProfile(image,"iptc");
4859 if (profile != (const StringInfo *) NULL)
4860 s=newSVpv((const char *) GetStringInfoDatum(profile),
4861 GetStringInfoLength(profile));
4863 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4866 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4868 if (image != (Image *) NULL)
4869 s=newSViv((ssize_t) image->iterations);
4870 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4873 if (LocaleCompare(attribute,"interlace") == 0)
4875 j=info ? info->image_info->interlace : image ? image->interlace :
4878 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4881 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4884 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4891 if (LocaleCompare(attribute,"label") == 0)
4896 if (image == (Image *) NULL)
4898 value=GetImageProperty(image,"Label");
4899 if (value != (const char *) NULL)
4901 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4904 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4906 if (image != (Image *) NULL)
4907 s=newSViv((ssize_t) image->iterations);
4908 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4911 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4918 if (LocaleCompare(attribute,"magick") == 0)
4920 if (info && *info->image_info->magick)
4921 s=newSVpv(info->image_info->magick,0);
4922 if (image != (Image *) NULL)
4923 s=newSVpv(image->magick,0);
4924 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4927 if (LocaleCompare(attribute,"map") == 0)
4929 s=newSViv(GetMagickResource(MapResource));
4930 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4933 if (LocaleCompare(attribute,"maximum-error") == 0)
4935 if (image != (Image *) NULL)
4936 s=newSVnv(image->error.normalized_maximum_error);
4937 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4940 if (LocaleCompare(attribute,"memory") == 0)
4942 s=newSViv(GetMagickResource(MemoryResource));
4943 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4946 if (LocaleCompare(attribute,"mean-error") == 0)
4948 if (image != (Image *) NULL)
4949 s=newSVnv(image->error.normalized_mean_error);
4950 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4953 if (LocaleCompare(attribute,"mime") == 0)
4955 if (info && *info->image_info->magick)
4956 s=newSVpv(MagickToMime(info->image_info->magick),0);
4957 if (image != (Image *) NULL)
4958 s=newSVpv(MagickToMime(image->magick),0);
4959 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4962 if (LocaleCompare(attribute,"mattecolor") == 0)
4964 if (image == (Image *) NULL)
4966 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4967 QuantumFormat "," QuantumFormat "," QuantumFormat,
4968 image->matte_color.red,image->matte_color.green,
4969 image->matte_color.blue,image->matte_color.alpha);
4971 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4974 if (LocaleCompare(attribute,"matte") == 0)
4976 if (image != (Image *) NULL)
4977 s=newSViv((ssize_t) image->matte);
4978 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4981 if (LocaleCompare(attribute,"mime") == 0)
4987 if (info && *info->image_info->magick)
4988 magick=info->image_info->magick;
4989 if (image != (Image *) NULL)
4990 magick=image->magick;
4996 mime=MagickToMime(magick);
4998 mime=(char *) RelinquishMagickMemory(mime);
5000 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5003 if (LocaleCompare(attribute,"monochrome") == 0)
5005 if (image == (Image *) NULL)
5007 j=info ? info->image_info->monochrome :
5008 IsImageMonochrome(image,&image->exception);
5010 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5013 if (LocaleCompare(attribute,"montage") == 0)
5015 if (image && image->montage)
5016 s=newSVpv(image->montage,0);
5017 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5020 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5027 if (LocaleCompare(attribute,"orientation") == 0)
5029 j=info ? info->image_info->orientation : image ?
5030 image->orientation : UndefinedOrientation;
5032 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5035 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5038 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5045 if (LocaleCompare(attribute,"page") == 0)
5047 if (info && info->image_info->page)
5048 s=newSVpv(info->image_info->page,0);
5049 if (image != (Image *) NULL)
5052 geometry[MaxTextExtent];
5054 (void) FormatLocaleString(geometry,MaxTextExtent,
5055 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5056 (double) image->page.height,(double) image->page.x,(double)
5058 s=newSVpv(geometry,0);
5060 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5063 if (LocaleCompare(attribute,"page.x") == 0)
5065 if (image != (Image *) NULL)
5066 s=newSViv((ssize_t) image->page.x);
5067 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5070 if (LocaleCompare(attribute,"page.y") == 0)
5072 if (image != (Image *) NULL)
5073 s=newSViv((ssize_t) image->page.y);
5074 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5077 if (LocaleNCompare(attribute,"pixel",5) == 0)
5080 tuple[MaxTextExtent];
5089 register const Quantum
5092 if (image == (Image *) NULL)
5096 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5098 p=GetVirtualPixels(image,x,y,1,1,exception);
5099 if (image->colorspace != CMYKColorspace)
5100 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5101 QuantumFormat "," QuantumFormat "," QuantumFormat,
5102 GetPixelRed(image,p),GetPixelGreen(image,p),
5103 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5105 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5106 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5107 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5108 GetPixelBlue(image,p),GetPixelBlack(image,p),
5109 GetPixelAlpha(image,p));
5111 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5114 if (LocaleCompare(attribute,"pointsize") == 0)
5117 s=newSViv((ssize_t) info->image_info->pointsize);
5118 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5121 if (LocaleCompare(attribute,"preview") == 0)
5123 s=newSViv(info->image_info->preview_type);
5124 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5125 info->image_info->preview_type));
5127 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5130 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5137 if (LocaleCompare(attribute,"quality") == 0)
5140 s=newSViv((ssize_t) info->image_info->quality);
5141 if (image != (Image *) NULL)
5142 s=newSViv((ssize_t) image->quality);
5143 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5146 if (LocaleCompare(attribute,"quantum") == 0)
5149 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5150 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5153 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5160 if (LocaleCompare(attribute,"rendering-intent") == 0)
5162 s=newSViv(image->rendering_intent);
5163 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5164 image->rendering_intent));
5166 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5169 if (LocaleCompare(attribute,"red-primary") == 0)
5171 if (image == (Image *) NULL)
5173 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5174 image->chromaticity.red_primary.x,
5175 image->chromaticity.red_primary.y);
5177 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5180 if (LocaleCompare(attribute,"rows") == 0)
5182 if (image != (Image *) NULL)
5183 s=newSViv((ssize_t) image->rows);
5184 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5187 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5194 if (LocaleCompare(attribute,"sampling-factor") == 0)
5196 if (info && info->image_info->sampling_factor)
5197 s=newSVpv(info->image_info->sampling_factor,0);
5198 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5201 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5203 if (info && info->image_info->server_name)
5204 s=newSVpv(info->image_info->server_name,0);
5205 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5208 if (LocaleCompare(attribute,"size") == 0)
5210 if (info && info->image_info->size)
5211 s=newSVpv(info->image_info->size,0);
5212 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5215 if (LocaleCompare(attribute,"scene") == 0)
5217 if (image != (Image *) NULL)
5218 s=newSViv((ssize_t) image->scene);
5219 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5222 if (LocaleCompare(attribute,"scenes") == 0)
5224 if (image != (Image *) NULL)
5225 s=newSViv((ssize_t) info->image_info->number_scenes);
5226 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5229 if (LocaleCompare(attribute,"signature") == 0)
5234 if (image == (Image *) NULL)
5236 (void) SignatureImage(image);
5237 value=GetImageProperty(image,"Signature");
5238 if (value != (const char *) NULL)
5240 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5243 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5250 if (LocaleCompare(attribute,"taint") == 0)
5252 if (image != (Image *) NULL)
5253 s=newSViv((ssize_t) IsTaintImage(image));
5254 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5257 if (LocaleCompare(attribute,"texture") == 0)
5259 if (info && info->image_info->texture)
5260 s=newSVpv(info->image_info->texture,0);
5261 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5264 if (LocaleCompare(attribute,"total-ink-density") == 0)
5266 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5267 if (image != (Image *) NULL)
5268 s=newSVnv(GetImageTotalInkDensity(image));
5269 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5272 if (LocaleCompare(attribute,"transparent-color") == 0)
5274 if (image == (Image *) NULL)
5276 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5277 QuantumFormat "," QuantumFormat "," QuantumFormat,
5278 image->transparent_color.red,image->transparent_color.green,
5279 image->transparent_color.blue,image->transparent_color.alpha);
5281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5284 if (LocaleCompare(attribute,"type") == 0)
5286 if (image == (Image *) NULL)
5288 j=(ssize_t) GetImageType(image,&image->exception);
5290 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5292 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5302 if (LocaleCompare(attribute,"units") == 0)
5304 j=info ? info->image_info->units : image ? image->units :
5305 UndefinedResolution;
5306 if (info && (info->image_info->units == UndefinedResolution))
5309 if (j == UndefinedResolution)
5310 s=newSVpv("undefined units",0);
5312 if (j == PixelsPerInchResolution)
5313 s=newSVpv("pixels / inch",0);
5315 s=newSVpv("pixels / centimeter",0);
5316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5319 if (LocaleCompare(attribute,"user-time") == 0)
5321 if (image != (Image *) NULL)
5322 s=newSVnv(GetUserTime(&image->timer));
5323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5326 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5333 if (LocaleCompare(attribute,"verbose") == 0)
5336 s=newSViv((ssize_t) info->image_info->verbose);
5337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5340 if (LocaleCompare(attribute,"version") == 0)
5342 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5346 if (LocaleCompare(attribute,"view") == 0)
5348 if (info && info->image_info->view)
5349 s=newSVpv(info->image_info->view,0);
5350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5353 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5355 if (image == (Image *) NULL)
5357 j=(ssize_t) GetImageVirtualPixelMethod(image);
5359 (void) sv_setpv(s,CommandOptionToMnemonic(
5360 MagickVirtualPixelOptions,j));
5362 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5365 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5372 if (LocaleCompare(attribute,"white-point") == 0)
5374 if (image == (Image *) NULL)
5376 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5377 image->chromaticity.white_point.x,
5378 image->chromaticity.white_point.y);
5380 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5383 if (LocaleCompare(attribute,"width") == 0)
5385 if (image != (Image *) NULL)
5386 s=newSViv((ssize_t) image->columns);
5387 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5390 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5397 if (LocaleCompare(attribute,"x-resolution") == 0)
5399 if (image != (Image *) NULL)
5400 s=newSVnv(image->x_resolution);
5401 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5411 if (LocaleCompare(attribute,"y-resolution") == 0)
5413 if (image != (Image *) NULL)
5414 s=newSVnv(image->y_resolution);
5415 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5425 if (image == (Image *) NULL)
5426 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5430 value=GetImageProperty(image,attribute);
5431 if (value != (const char *) NULL)
5434 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5437 if (*attribute != '%')
5438 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5445 meta=InterpretImageProperties(info ? info->image_info :
5446 (ImageInfo *) NULL,image,attribute);
5448 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5449 meta=(char *) RelinquishMagickMemory(meta);
5453 exception=DestroyExceptionInfo(exception);
5454 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5458 ###############################################################################
5462 # G e t A u t h e n t i c P i x e l s #
5466 ###############################################################################
5470 GetAuthenticPixels(ref,...)
5471 Image::Magick ref = NO_INIT
5473 getauthenticpixels = 1
5503 PERL_UNUSED_VAR(ref);
5504 PERL_UNUSED_VAR(ix);
5505 exception=AcquireExceptionInfo();
5506 perl_exception=newSVpv("",0);
5507 if (sv_isobject(ST(0)) == 0)
5509 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5513 reference=SvRV(ST(0));
5515 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5516 if (image == (Image *) NULL)
5518 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5525 region.width=image->columns;
5528 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5529 for (i=2; i < items; i+=2)
5531 attribute=(char *) SvPV(ST(i-1),na);
5537 if (LocaleCompare(attribute,"geometry") == 0)
5539 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5542 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5549 if (LocaleCompare(attribute,"height") == 0)
5551 region.height=SvIV(ST(i));
5554 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5561 if (LocaleCompare(attribute,"x") == 0)
5563 region.x=SvIV(ST(i));
5566 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5573 if (LocaleCompare(attribute,"y") == 0)
5575 region.y=SvIV(ST(i));
5578 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5585 if (LocaleCompare(attribute,"width") == 0)
5587 region.width=SvIV(ST(i));
5590 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5596 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5597 region.height,exception);
5598 if (blob != (void *) NULL)
5602 InheritPerlException(exception,perl_exception);
5603 exception=DestroyExceptionInfo(exception);
5604 SvREFCNT_dec(perl_exception); /* throw away all errors */
5613 ###############################################################################
5617 # G e t V i r t u a l P i x e l s #
5621 ###############################################################################
5625 GetVirtualPixels(ref,...)
5626 Image::Magick ref = NO_INIT
5628 getvirtualpixels = 1
5629 AcquireImagePixels = 2
5630 acquireimagepixels = 3
5658 PERL_UNUSED_VAR(ref);
5659 PERL_UNUSED_VAR(ix);
5660 exception=AcquireExceptionInfo();
5661 perl_exception=newSVpv("",0);
5662 if (sv_isobject(ST(0)) == 0)
5664 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5668 reference=SvRV(ST(0));
5670 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5671 if (image == (Image *) NULL)
5673 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5680 region.width=image->columns;
5683 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5684 for (i=2; i < items; i+=2)
5686 attribute=(char *) SvPV(ST(i-1),na);
5692 if (LocaleCompare(attribute,"geometry") == 0)
5694 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5704 if (LocaleCompare(attribute,"height") == 0)
5706 region.height=SvIV(ST(i));
5709 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5716 if (LocaleCompare(attribute,"x") == 0)
5718 region.x=SvIV(ST(i));
5721 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5728 if (LocaleCompare(attribute,"y") == 0)
5730 region.y=SvIV(ST(i));
5733 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5740 if (LocaleCompare(attribute,"width") == 0)
5742 region.width=SvIV(ST(i));
5745 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5751 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5752 region.height,exception);
5753 if (blob != (void *) NULL)
5757 InheritPerlException(exception,perl_exception);
5758 exception=DestroyExceptionInfo(exception);
5759 SvREFCNT_dec(perl_exception); /* throw away all errors */
5762 RETVAL = (void *) blob;
5768 ###############################################################################
5772 # G e t A u t h e n t i c M e t a c o n t e n t #
5776 ###############################################################################
5780 GetAuthenticMetacontent(ref,...)
5781 Image::Magick ref = NO_INIT
5783 getauthenticmetacontent = 1
5804 PERL_UNUSED_VAR(ref);
5805 PERL_UNUSED_VAR(ix);
5806 exception=AcquireExceptionInfo();
5807 perl_exception=newSVpv("",0);
5808 if (sv_isobject(ST(0)) == 0)
5810 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5814 reference=SvRV(ST(0));
5816 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5817 if (image == (Image *) NULL)
5819 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5824 blob=(void *) GetAuthenticMetacontent(image);
5825 if (blob != (void *) NULL)
5829 InheritPerlException(exception,perl_exception);
5830 exception=DestroyExceptionInfo(exception);
5831 SvREFCNT_dec(perl_exception); /* throw away all errors */
5840 ###############################################################################
5844 # G e t V i r t u a l M e t a c o n t e n t #
5848 ###############################################################################
5852 GetVirtualMetacontent(ref,...)
5853 Image::Magick ref = NO_INIT
5855 getvirtualmetacontent = 1
5874 PERL_UNUSED_VAR(ref);
5875 PERL_UNUSED_VAR(ix);
5876 exception=AcquireExceptionInfo();
5877 perl_exception=newSVpv("",0);
5878 if (sv_isobject(ST(0)) == 0)
5880 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5884 reference=SvRV(ST(0));
5886 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5887 if (image == (Image *) NULL)
5889 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5894 blob=(void *) GetVirtualMetacontent(image);
5895 if (blob != (void *) NULL)
5899 InheritPerlException(exception,perl_exception);
5900 exception=DestroyExceptionInfo(exception);
5901 SvREFCNT_dec(perl_exception); /* throw away all errors */
5910 ###############################################################################
5914 # H i s t o g r a m #
5918 ###############################################################################
5923 Image::Magick ref=NO_INIT
5934 message[MaxTextExtent];
5961 PERL_UNUSED_VAR(ref);
5962 PERL_UNUSED_VAR(ix);
5963 exception=AcquireExceptionInfo();
5964 perl_exception=newSVpv("",0);
5966 if (sv_isobject(ST(0)) == 0)
5968 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5972 reference=SvRV(ST(0));
5975 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5976 if (image == (Image *) NULL)
5978 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5982 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5984 for ( ; image; image=image->next)
5986 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5987 if (histogram == (PixelPacket *) NULL)
5989 count+=(ssize_t) number_colors;
5991 for (i=0; i < (ssize_t) number_colors; i++)
5993 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5995 PUSHs(sv_2mortal(newSVpv(message,0)));
5996 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5997 histogram[i].green);
5998 PUSHs(sv_2mortal(newSVpv(message,0)));
5999 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6001 PUSHs(sv_2mortal(newSVpv(message,0)));
6002 if (image->colorspace == CMYKColorspace)
6004 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6005 histogram[i].black);
6006 PUSHs(sv_2mortal(newSVpv(message,0)));
6008 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6009 histogram[i].alpha);
6010 PUSHs(sv_2mortal(newSVpv(message,0)));
6011 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6012 histogram[i].count);
6013 PUSHs(sv_2mortal(newSVpv(message,0)));
6015 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6019 InheritPerlException(exception,perl_exception);
6020 exception=DestroyExceptionInfo(exception);
6021 SvREFCNT_dec(perl_exception);
6025 ###############################################################################
6033 ###############################################################################
6038 Image::Magick ref=NO_INIT
6062 register const Quantum
6076 *reference; /* reference is the SV* of ref=SvIV(reference) */
6078 PERL_UNUSED_VAR(ref);
6079 PERL_UNUSED_VAR(ix);
6080 exception=AcquireExceptionInfo();
6081 perl_exception=newSVpv("",0);
6082 reference=SvRV(ST(0));
6083 av=(AV *) reference;
6084 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6086 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6087 if (image == (Image *) NULL)
6089 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6093 normalize=MagickTrue;
6096 region.width=image->columns;
6099 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6100 for (i=2; i < items; i+=2)
6102 attribute=(char *) SvPV(ST(i-1),na);
6108 if (LocaleCompare(attribute,"channel") == 0)
6113 option=ParseChannelOption(SvPV(ST(i),na));
6116 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6120 SetPixelComponentMap(image,(ChannelType) option);
6123 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6130 if (LocaleCompare(attribute,"geometry") == 0)
6132 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6135 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6142 if (LocaleCompare(attribute,"normalize") == 0)
6144 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6148 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6152 normalize=option != 0 ? MagickTrue : MagickFalse;
6155 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6162 if (LocaleCompare(attribute,"x") == 0)
6164 region.x=SvIV(ST(i));
6167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6174 if (LocaleCompare(attribute,"y") == 0)
6176 region.y=SvIV(ST(i));
6179 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6191 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6192 if (p == (const Quantum *) NULL)
6200 if (normalize != MagickFalse)
6201 scale=1.0/QuantumRange;
6202 if ((GetPixelRedTraits(image) & ActivePixelTrait) != 0)
6203 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6204 if ((GetPixelGreenTraits(image) & ActivePixelTrait) != 0)
6205 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6206 if ((GetPixelBlueTraits(image) & ActivePixelTrait) != 0)
6207 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6208 if (((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
6209 (image->colorspace == CMYKColorspace))
6210 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6211 if ((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0)
6212 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6216 InheritPerlException(exception,perl_exception);
6217 exception=DestroyExceptionInfo(exception);
6218 SvREFCNT_dec(perl_exception);
6222 ###############################################################################
6226 # G e t P i x e l s #
6230 ###############################################################################
6235 Image::Magick ref=NO_INIT
6274 *reference; /* reference is the SV* of ref=SvIV(reference) */
6276 PERL_UNUSED_VAR(ref);
6277 PERL_UNUSED_VAR(ix);
6278 exception=AcquireExceptionInfo();
6279 perl_exception=newSVpv("",0);
6280 reference=SvRV(ST(0));
6281 av=(AV *) reference;
6282 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6284 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6285 if (image == (Image *) NULL)
6287 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6292 if (image->matte != MagickFalse)
6294 if (image->colorspace == CMYKColorspace)
6297 if (image->matte != MagickFalse)
6300 normalize=MagickFalse;
6303 region.width=image->columns;
6306 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6307 for (i=2; i < items; i+=2)
6309 attribute=(char *) SvPV(ST(i-1),na);
6315 if (LocaleCompare(attribute,"geometry") == 0)
6317 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6320 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6327 if (LocaleCompare(attribute,"height") == 0)
6329 region.height=SvIV(ST(i));
6332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6339 if (LocaleCompare(attribute,"map") == 0)
6344 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6351 if (LocaleCompare(attribute,"normalize") == 0)
6353 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6357 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6361 normalize=option != 0 ? MagickTrue : MagickFalse;
6364 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6371 if (LocaleCompare(attribute,"width") == 0)
6373 region.width=SvIV(ST(i));
6376 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6383 if (LocaleCompare(attribute,"x") == 0)
6385 region.x=SvIV(ST(i));
6388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6395 if (LocaleCompare(attribute,"y") == 0)
6397 region.y=SvIV(ST(i));
6400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6406 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6412 if (normalize != MagickFalse)
6417 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6418 region.height*sizeof(*pixels));
6419 if (pixels == (float *) NULL)
6421 ThrowPerlException(exception,ResourceLimitError,
6422 "MemoryAllocationFailed",PackageName);
6425 status=ExportImagePixels(image,region.x,region.y,region.width,
6426 region.height,map,FloatPixel,pixels,exception);
6427 if (status == MagickFalse)
6431 EXTEND(sp,strlen(map)*region.width*region.height);
6432 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6433 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6435 pixels=(float *) RelinquishMagickMemory(pixels);
6442 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6443 region.height*sizeof(*pixels));
6444 if (pixels == (Quantum *) NULL)
6446 ThrowPerlException(exception,ResourceLimitError,
6447 "MemoryAllocationFailed",PackageName);
6450 status=ExportImagePixels(image,region.x,region.y,region.width,
6451 region.height,map,QuantumPixel,pixels,exception);
6452 if (status == MagickFalse)
6456 EXTEND(sp,strlen(map)*region.width*region.height);
6457 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6458 PUSHs(sv_2mortal(newSViv(pixels[i])));
6460 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6464 InheritPerlException(exception,perl_exception);
6465 exception=DestroyExceptionInfo(exception);
6466 SvREFCNT_dec(perl_exception);
6470 ###############################################################################
6474 # I m a g e T o B l o b #
6478 ###############################################################################
6482 ImageToBlob(ref,...)
6483 Image::Magick ref=NO_INIT
6492 filename[MaxTextExtent];
6521 PERL_UNUSED_VAR(ref);
6522 PERL_UNUSED_VAR(ix);
6523 exception=AcquireExceptionInfo();
6524 perl_exception=newSVpv("",0);
6525 package_info=(struct PackageInfo *) NULL;
6526 if (sv_isobject(ST(0)) == 0)
6528 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6532 reference=SvRV(ST(0));
6533 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6534 if (image == (Image *) NULL)
6536 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6540 package_info=ClonePackageInfo(info,exception);
6541 for (i=2; i < items; i+=2)
6542 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6543 (void) CopyMagickString(filename,package_info->image_info->filename,
6546 for (next=image; next; next=next->next)
6548 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6549 next->scene=scene++;
6551 SetImageInfo(package_info->image_info,(unsigned int)
6552 GetImageListLength(image),&image->exception);
6553 EXTEND(sp,(ssize_t) GetImageListLength(image));
6554 for ( ; image; image=image->next)
6557 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6558 if (blob != (char *) NULL)
6560 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6561 blob=(unsigned char *) RelinquishMagickMemory(blob);
6563 if (package_info->image_info->adjoin)
6568 if (package_info != (struct PackageInfo *) NULL)
6569 DestroyPackageInfo(package_info);
6570 InheritPerlException(exception,perl_exception);
6571 exception=DestroyExceptionInfo(exception);
6572 SvREFCNT_dec(perl_exception); /* throw away all errors */
6576 ###############################################################################
6584 ###############################################################################
6589 Image::Magick ref=NO_INIT
6593 OptimizeImageLayers = 3
6595 optimizeimagelayers = 5
6637 PERL_UNUSED_VAR(ref);
6638 PERL_UNUSED_VAR(ix);
6639 exception=AcquireExceptionInfo();
6640 perl_exception=newSVpv("",0);
6642 if (sv_isobject(ST(0)) == 0)
6644 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6648 reference=SvRV(ST(0));
6649 hv=SvSTASH(reference);
6651 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6653 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6654 if (image == (Image *) NULL)
6656 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6660 compose=image->compose;
6661 method=OptimizeLayer;
6662 for (i=2; i < items; i+=2)
6664 attribute=(char *) SvPV(ST(i-1),na);
6670 if (LocaleCompare(attribute,"compose") == 0)
6672 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6673 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6676 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6680 compose=(CompositeOperator) sp;
6683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6690 if (LocaleCompare(attribute,"method") == 0)
6692 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6696 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6700 method=(ImageLayerMethod) option;
6703 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6709 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6715 layers=(Image *) NULL;
6718 case CompareAnyLayer:
6719 case CompareClearLayer:
6720 case CompareOverlayLayer:
6723 layers=CompareImagesLayers(image,method,exception);
6730 layers=MergeImageLayers(image,method,exception);
6735 layers=DisposeImages(image,exception);
6738 case OptimizeImageLayer:
6740 layers=OptimizeImageLayers(image,exception);
6743 case OptimizePlusLayer:
6745 layers=OptimizePlusImageLayers(image,exception);
6748 case OptimizeTransLayer:
6750 OptimizeImageTransparency(image,exception);
6751 InheritException(&(image->exception),exception);
6754 case RemoveDupsLayer:
6756 RemoveDuplicateLayers(&image,exception);
6757 InheritException(&(image->exception),exception);
6760 case RemoveZeroLayer:
6762 RemoveZeroDelayLayers(&image,exception);
6763 InheritException(&(image->exception),exception);
6772 General Purpose, GIF Animation Optimizer.
6774 layers=CoalesceImages(image,exception);
6775 if (layers == (Image *) NULL)
6777 InheritException(&(layers->exception),exception);
6779 layers=OptimizeImageLayers(image,exception);
6780 if (layers == (Image *) NULL)
6782 InheritException(&(layers->exception),exception);
6783 image=DestroyImageList(image);
6785 layers=(Image *) NULL;
6786 OptimizeImageTransparency(image,exception);
6787 InheritException(&(image->exception),exception);
6788 quantize_info=AcquireQuantizeInfo(info->image_info);
6789 (void) RemapImages(quantize_info,image,(Image *) NULL);
6790 quantize_info=DestroyQuantizeInfo(quantize_info);
6793 case CompositeLayer:
6802 Split image sequence at the first 'NULL:' image.
6805 while (source != (Image *) NULL)
6807 source=GetNextImageInList(source);
6808 if ((source != (Image *) NULL) &&
6809 (LocaleCompare(source->magick,"NULL") == 0))
6812 if (source != (Image *) NULL)
6814 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6815 (GetNextImageInList(source) == (Image *) NULL))
6816 source=(Image *) NULL;
6820 Separate the two lists, junk the null: image.
6822 source=SplitImageList(source->previous);
6823 DeleteImageFromList(&source);
6826 if (source == (Image *) NULL)
6828 (void) ThrowMagickException(exception,GetMagickModule(),
6829 OptionError,"MissingNullSeparator","layers Composite");
6833 Adjust offset with gravity and virtual canvas.
6835 SetGeometry(image,&geometry);
6836 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6837 geometry.width=source->page.width != 0 ? source->page.width :
6839 geometry.height=source->page.height != 0 ? source->page.height :
6841 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6842 image->columns,image->page.height != 0 ? image->page.height :
6843 image->rows,image->gravity,&geometry);
6844 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6845 source=DestroyImageList(source);
6846 InheritException(&(image->exception),exception);
6850 if (layers != (Image *) NULL)
6852 InheritException(&(layers->exception),exception);
6855 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6857 for ( ; image; image=image->next)
6859 AddImageToRegistry(sv,image);
6861 av_push(av,sv_bless(rv,hv));
6864 exception=DestroyExceptionInfo(exception);
6866 SvREFCNT_dec(perl_exception);
6870 InheritPerlException(exception,perl_exception);
6871 exception=DestroyExceptionInfo(exception);
6872 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6873 SvPOK_on(perl_exception);
6874 ST(0)=sv_2mortal(perl_exception);
6879 ###############################################################################
6883 # M a g i c k T o M i m e #
6887 ###############################################################################
6891 MagickToMime(ref,name)
6892 Image::Magick ref=NO_INIT
6901 PERL_UNUSED_VAR(ref);
6902 PERL_UNUSED_VAR(ix);
6903 mime=MagickToMime(name);
6904 RETVAL=newSVpv(mime,0);
6905 mime=(char *) RelinquishMagickMemory(mime);
6911 ###############################################################################
6919 ###############################################################################
6924 Image::Magick ref=NO_INIT
6961 MedianFilterImage = 36
6967 ReduceNoiseImage = 42
6993 ColorFloodfillImage= 68
6999 CycleColormapImage = 74
7009 MatteFloodfillImage= 84
7017 NumberColorsImage = 92
7027 SignatureImage = 102
7037 TransparentImage = 112
7039 ThresholdImage = 114
7053 DeconstructImage = 130
7055 GaussianBlurImage = 132
7061 UnsharpMaskImage = 138
7063 MotionBlurImage = 140
7065 OrderedDitherImage = 142
7072 AffineTransform = 149
7073 AffineTransformImage = 150
7075 DifferenceImage = 152
7076 AdaptiveThreshold = 153
7077 AdaptiveThresholdImage = 154
7082 BlackThreshold = 159
7083 BlackThresholdImage= 160
7084 WhiteThreshold = 161
7085 WhiteThresholdImage= 162
7087 RadialBlurImage = 164
7089 ThumbnailImage = 166
7099 PosterizeImage = 176
7105 SepiaToneImage = 182
7106 SigmoidalContrast = 183
7107 SigmoidalContrastImage = 184
7112 ContrastStretch = 189
7113 ContrastStretchImage = 190
7118 AdaptiveSharpen = 195
7119 AdaptiveSharpenImage = 196
7121 TransposeImage = 198
7123 TransverseImage = 200
7125 AutoOrientImage = 202
7127 AdaptiveBlurImage = 204
7131 UniqueColorsImage = 208
7132 AdaptiveResize = 209
7133 AdaptiveResizeImage= 210
7137 LinearStretchImage = 214
7144 FloodfillPaint = 221
7145 FloodfillPaintImage= 222
7151 LiquidRescaleImage = 228
7161 SparseColorImage = 238
7165 SelectiveBlurImage = 242
7169 BlueShiftImage = 246
7170 ForwardFourierTransform = 247
7171 ForwardFourierTransformImage = 248
7172 InverseFourierTransform = 249
7173 InverseFourierTransformImage = 250
7174 ColorDecisionList = 251
7175 ColorDecisionListImage = 252
7177 AutoGammaImage = 254
7179 AutoLevelImage = 256
7181 LevelImageColors = 258
7186 BrightnessContrast = 263
7187 BrightnessContrastImage = 264
7189 MorphologyImage = 266
7191 ColorMatrixImage = 268
7197 StatisticImage = 274
7206 attribute_flag[MaxArguments],
7207 message[MaxTextExtent];
7267 argument_list[MaxArguments];
7269 PERL_UNUSED_VAR(ref);
7270 PERL_UNUSED_VAR(ix);
7271 exception=AcquireExceptionInfo();
7272 perl_exception=newSVpv("",0);
7273 reference_vector=NULL;
7277 if (sv_isobject(ST(0)) == 0)
7279 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7283 reference=SvRV(ST(0));
7284 region_info.width=0;
7285 region_info.height=0;
7288 region_image=(Image *) NULL;
7289 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7290 if (ix && (ix != 666))
7293 Called as Method(...)
7296 rp=(&Methods[ix-1]);
7302 Called as Mogrify("Method",...)
7304 attribute=(char *) SvPV(ST(1),na);
7307 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7308 attribute=(char *) SvPV(ST(2),na);
7311 for (rp=Methods; ; rp++)
7313 if (rp >= EndOf(Methods))
7315 ThrowPerlException(exception,OptionError,
7316 "UnrecognizedPerlMagickMethod",attribute);
7319 if (strEQcase(attribute,rp->name))
7325 if (image == (Image *) NULL)
7327 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7330 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7331 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7332 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7349 pp=(Arguments *) NULL;
7357 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7359 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7361 if (strEQcase(attribute,qq->method) > ssize_test)
7364 ssize_test=strEQcase(attribute,qq->method);
7367 if (pp == (Arguments *) NULL)
7369 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7371 goto continue_outer_loop;
7373 al=(&argument_list[pp-rp->arguments]);
7376 case ArrayReference:
7378 if (SvTYPE(sv) != SVt_RV)
7380 (void) FormatLocaleString(message,MaxTextExtent,
7381 "invalid %.60s value",pp->method);
7382 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7383 goto continue_outer_loop;
7385 al->array_reference=SvRV(sv);
7390 al->real_reference=SvNV(sv);
7395 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7398 case ImageReference:
7400 if (!sv_isobject(sv) ||
7401 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7402 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7404 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7410 case IntegerReference:
7412 al->integer_reference=SvIV(sv);
7415 case StringReference:
7417 al->string_reference=(char *) SvPV(sv,al->length);
7418 if (sv_isobject(sv))
7419 al->image_reference=SetupList(aTHX_ SvRV(sv),
7420 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7426 Is a string; look up name.
7428 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7430 al->string_reference=(char *) SvPV(sv,al->length);
7431 al->integer_reference=(-1);
7434 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7435 MagickFalse,SvPV(sv,na));
7436 if (pp->type == MagickChannelOptions)
7437 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7438 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7440 (void) FormatLocaleString(message,MaxTextExtent,
7441 "invalid %.60s value",pp->method);
7442 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7443 goto continue_outer_loop;
7448 attribute_flag[pp-rp->arguments]++;
7449 continue_outer_loop: ;
7451 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7452 pv=reference_vector;
7453 SetGeometryInfo(&geometry_info);
7454 channel=DefaultChannels;
7455 for (next=image; next; next=next->next)
7458 SetGeometry(image,&geometry);
7459 if ((region_info.width*region_info.height) != 0)
7462 image=CropImage(image,®ion_info,exception);
7468 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7469 ThrowPerlException(exception,OptionError,
7470 "UnrecognizedPerlMagickMethod",message);
7473 case 1: /* Comment */
7475 if (attribute_flag[0] == 0)
7476 argument_list[0].string_reference=(char *) NULL;
7477 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7478 info ? info->image_info : (ImageInfo *) NULL,image,
7479 argument_list[0].string_reference));
7484 if (attribute_flag[0] == 0)
7485 argument_list[0].string_reference=(char *) NULL;
7486 (void) SetImageProperty(image,"label",InterpretImageProperties(
7487 info ? info->image_info : (ImageInfo *) NULL,image,
7488 argument_list[0].string_reference));
7491 case 3: /* AddNoise */
7493 if (attribute_flag[0] == 0)
7494 argument_list[0].integer_reference=UniformNoise;
7495 if (attribute_flag[1] != 0)
7496 channel=(ChannelType) argument_list[1].integer_reference;
7497 PushPixelComponentMap(image,channel);
7498 image=AddNoiseImage(image,(NoiseType)
7499 argument_list[0].integer_reference,exception);
7500 if (image != (Image *) NULL)
7501 PopPixelComponentMap(image);
7504 case 4: /* Colorize */
7509 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7510 if (attribute_flag[0] != 0)
7511 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7513 if (attribute_flag[1] == 0)
7514 argument_list[1].string_reference="100%";
7515 image=ColorizeImage(image,argument_list[1].string_reference,target,
7519 case 5: /* Border */
7523 if (attribute_flag[0] != 0)
7525 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7526 &geometry,exception);
7527 if ((flags & HeightValue) == 0)
7528 geometry.height=geometry.width;
7530 if (attribute_flag[1] != 0)
7531 geometry.width=argument_list[1].integer_reference;
7532 if (attribute_flag[2] != 0)
7533 geometry.height=argument_list[2].integer_reference;
7534 if (attribute_flag[3] != 0)
7535 QueryColorDatabase(argument_list[3].string_reference,
7536 &image->border_color,exception);
7537 if (attribute_flag[4] != 0)
7538 QueryColorDatabase(argument_list[4].string_reference,
7539 &image->border_color,exception);
7540 if (attribute_flag[5] != 0)
7541 QueryColorDatabase(argument_list[5].string_reference,
7542 &image->border_color,exception);
7543 if (attribute_flag[6] != 0)
7544 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7545 image=BorderImage(image,&geometry,exception);
7550 if (attribute_flag[0] != 0)
7552 flags=ParseGeometry(argument_list[0].string_reference,
7554 if ((flags & SigmaValue) == 0)
7555 geometry_info.sigma=1.0;
7557 if (attribute_flag[1] != 0)
7558 geometry_info.rho=argument_list[1].real_reference;
7559 if (attribute_flag[2] != 0)
7560 geometry_info.sigma=argument_list[2].real_reference;
7561 if (attribute_flag[3] != 0)
7562 channel=(ChannelType) argument_list[3].integer_reference;
7563 PushPixelComponentMap(image,channel);
7564 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7566 if (image != (Image *) NULL)
7567 PopPixelComponentMap(image);
7572 if (attribute_flag[0] != 0)
7573 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7574 &geometry,exception);
7575 if (attribute_flag[1] != 0)
7576 geometry.width=argument_list[1].integer_reference;
7577 if (attribute_flag[2] != 0)
7578 geometry.height=argument_list[2].integer_reference;
7579 if (attribute_flag[3] != 0)
7580 geometry.x=argument_list[3].integer_reference;
7581 if (attribute_flag[4] != 0)
7582 geometry.y=argument_list[4].integer_reference;
7583 image=ChopImage(image,&geometry,exception);
7588 if (attribute_flag[6] != 0)
7589 image->gravity=(GravityType) argument_list[6].integer_reference;
7590 if (attribute_flag[0] != 0)
7591 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7592 &geometry,exception);
7593 if (attribute_flag[1] != 0)
7594 geometry.width=argument_list[1].integer_reference;
7595 if (attribute_flag[2] != 0)
7596 geometry.height=argument_list[2].integer_reference;
7597 if (attribute_flag[3] != 0)
7598 geometry.x=argument_list[3].integer_reference;
7599 if (attribute_flag[4] != 0)
7600 geometry.y=argument_list[4].integer_reference;
7601 if (attribute_flag[5] != 0)
7603 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7604 image=CropImage(image,&geometry,exception);
7607 case 9: /* Despeckle */
7609 image=DespeckleImage(image,exception);
7614 if (attribute_flag[0] != 0)
7615 geometry_info.rho=argument_list[0].real_reference;
7616 image=EdgeImage(image,geometry_info.rho,exception);
7619 case 11: /* Emboss */
7621 if (attribute_flag[0] != 0)
7623 flags=ParseGeometry(argument_list[0].string_reference,
7625 if ((flags & SigmaValue) == 0)
7626 geometry_info.sigma=1.0;
7628 if (attribute_flag[1] != 0)
7629 geometry_info.rho=argument_list[1].real_reference;
7630 if (attribute_flag[2] != 0)
7631 geometry_info.sigma=argument_list[2].real_reference;
7632 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7636 case 12: /* Enhance */
7638 image=EnhanceImage(image,exception);
7643 image=FlipImage(image,exception);
7648 image=FlopImage(image,exception);
7651 case 15: /* Frame */
7656 if (attribute_flag[0] != 0)
7658 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7659 &geometry,exception);
7660 if ((flags & HeightValue) == 0)
7661 geometry.height=geometry.width;
7662 frame_info.width=geometry.width;
7663 frame_info.height=geometry.height;
7664 frame_info.outer_bevel=geometry.x;
7665 frame_info.inner_bevel=geometry.y;
7667 if (attribute_flag[1] != 0)
7668 frame_info.width=argument_list[1].integer_reference;
7669 if (attribute_flag[2] != 0)
7670 frame_info.height=argument_list[2].integer_reference;
7671 if (attribute_flag[3] != 0)
7672 frame_info.inner_bevel=argument_list[3].integer_reference;
7673 if (attribute_flag[4] != 0)
7674 frame_info.outer_bevel=argument_list[4].integer_reference;
7675 if (attribute_flag[5] != 0)
7676 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7678 if (attribute_flag[6] != 0)
7679 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7681 frame_info.x=(ssize_t) frame_info.width;
7682 frame_info.y=(ssize_t) frame_info.height;
7683 frame_info.width=image->columns+2*frame_info.x;
7684 frame_info.height=image->rows+2*frame_info.y;
7685 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7686 image->matte_color=fill_color;
7687 if (attribute_flag[7] != 0)
7688 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7689 image=FrameImage(image,&frame_info,exception);
7692 case 16: /* Implode */
7694 if (attribute_flag[0] == 0)
7695 argument_list[0].real_reference=0.5;
7696 if (attribute_flag[1] != 0)
7697 image->interpolate=(InterpolatePixelMethod)
7698 argument_list[1].integer_reference;
7699 image=ImplodeImage(image,argument_list[0].real_reference,
7703 case 17: /* Magnify */
7705 image=MagnifyImage(image,exception);
7708 case 18: /* MedianFilter */
7710 if (attribute_flag[0] != 0)
7712 flags=ParseGeometry(argument_list[0].string_reference,
7714 if ((flags & SigmaValue) == 0)
7715 geometry_info.sigma=1.0;
7717 if (attribute_flag[1] != 0)
7718 geometry_info.rho=argument_list[1].real_reference;
7719 if (attribute_flag[2] != 0)
7720 geometry_info.sigma=argument_list[2].real_reference;
7721 if (attribute_flag[3] != 0)
7722 channel=(ChannelType) argument_list[3].integer_reference;
7723 PushPixelComponentMap(image,channel);
7724 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7725 (size_t) geometry_info.sigma,exception);
7726 if (image != (Image *) NULL)
7727 PopPixelComponentMap(image);
7730 case 19: /* Minify */
7732 image=MinifyImage(image,exception);
7735 case 20: /* OilPaint */
7737 if (attribute_flag[0] == 0)
7738 argument_list[0].real_reference=0.0;
7739 image=OilPaintImage(image,argument_list[0].real_reference,
7743 case 21: /* ReduceNoise */
7745 if (attribute_flag[0] != 0)
7747 flags=ParseGeometry(argument_list[0].string_reference,
7749 if ((flags & SigmaValue) == 0)
7750 geometry_info.sigma=1.0;
7752 if (attribute_flag[1] != 0)
7753 geometry_info.rho=argument_list[1].real_reference;
7754 if (attribute_flag[2] != 0)
7755 geometry_info.sigma=argument_list[2].real_reference;
7756 if (attribute_flag[3] != 0)
7757 channel=(ChannelType) argument_list[3].integer_reference;
7758 PushPixelComponentMap(image,channel);
7759 image=StatisticImage(image,NonpeakStatistic,(size_t)
7760 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7761 if (image != (Image *) NULL)
7762 PopPixelComponentMap(image);
7767 if (attribute_flag[0] != 0)
7768 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7769 &geometry,exception);
7770 if (attribute_flag[1] != 0)
7771 geometry.x=argument_list[1].integer_reference;
7772 if (attribute_flag[2] != 0)
7773 geometry.y=argument_list[2].integer_reference;
7774 image=RollImage(image,geometry.x,geometry.y,exception);
7777 case 23: /* Rotate */
7779 if (attribute_flag[0] == 0)
7780 argument_list[0].real_reference=90.0;
7781 if (attribute_flag[1] != 0)
7782 QueryColorDatabase(argument_list[1].string_reference,
7783 &image->background_color,exception);
7784 if (attribute_flag[2] != 0)
7785 QueryColorDatabase(argument_list[2].string_reference,
7786 &image->background_color,exception);
7787 if (attribute_flag[3] != 0)
7788 QueryColorDatabase(argument_list[3].string_reference,
7789 &image->background_color,exception);
7790 image=RotateImage(image,argument_list[0].real_reference,exception);
7793 case 24: /* Sample */
7795 if (attribute_flag[0] != 0)
7796 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7797 &geometry,exception);
7798 if (attribute_flag[1] != 0)
7799 geometry.width=argument_list[1].integer_reference;
7800 if (attribute_flag[2] != 0)
7801 geometry.height=argument_list[2].integer_reference;
7802 image=SampleImage(image,geometry.width,geometry.height,exception);
7805 case 25: /* Scale */
7807 if (attribute_flag[0] != 0)
7808 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7809 &geometry,exception);
7810 if (attribute_flag[1] != 0)
7811 geometry.width=argument_list[1].integer_reference;
7812 if (attribute_flag[2] != 0)
7813 geometry.height=argument_list[2].integer_reference;
7814 image=ScaleImage(image,geometry.width,geometry.height,exception);
7817 case 26: /* Shade */
7819 if (attribute_flag[0] != 0)
7821 flags=ParseGeometry(argument_list[0].string_reference,
7823 if ((flags & SigmaValue) == 0)
7824 geometry_info.sigma=0.0;
7826 if (attribute_flag[1] != 0)
7827 geometry_info.rho=argument_list[1].real_reference;
7828 if (attribute_flag[2] != 0)
7829 geometry_info.sigma=argument_list[2].real_reference;
7830 image=ShadeImage(image,
7831 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7832 geometry_info.rho,geometry_info.sigma,exception);
7835 case 27: /* Sharpen */
7837 if (attribute_flag[0] != 0)
7839 flags=ParseGeometry(argument_list[0].string_reference,
7841 if ((flags & SigmaValue) == 0)
7842 geometry_info.sigma=1.0;
7844 if (attribute_flag[1] != 0)
7845 geometry_info.rho=argument_list[1].real_reference;
7846 if (attribute_flag[2] != 0)
7847 geometry_info.sigma=argument_list[2].real_reference;
7848 if (attribute_flag[3] != 0)
7849 channel=(ChannelType) argument_list[3].integer_reference;
7850 PushPixelComponentMap(image,channel);
7851 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7853 if (image != (Image *) NULL)
7854 PopPixelComponentMap(image);
7857 case 28: /* Shear */
7859 if (attribute_flag[0] != 0)
7861 flags=ParseGeometry(argument_list[0].string_reference,
7863 if ((flags & SigmaValue) == 0)
7864 geometry_info.sigma=geometry_info.rho;
7866 if (attribute_flag[1] != 0)
7867 geometry_info.rho=argument_list[1].real_reference;
7868 if (attribute_flag[2] != 0)
7869 geometry_info.sigma=argument_list[2].real_reference;
7870 if (attribute_flag[3] != 0)
7871 QueryColorDatabase(argument_list[3].string_reference,
7872 &image->background_color,exception);
7873 if (attribute_flag[4] != 0)
7874 QueryColorDatabase(argument_list[4].string_reference,
7875 &image->background_color,exception);
7876 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7880 case 29: /* Spread */
7882 if (attribute_flag[0] == 0)
7883 argument_list[0].real_reference=1.0;
7884 image=SpreadImage(image,argument_list[0].real_reference,exception);
7887 case 30: /* Swirl */
7889 if (attribute_flag[0] == 0)
7890 argument_list[0].real_reference=50.0;
7891 if (attribute_flag[1] != 0)
7892 image->interpolate=(InterpolatePixelMethod)
7893 argument_list[1].integer_reference;
7894 image=SwirlImage(image,argument_list[0].real_reference,exception);
7897 case 31: /* Resize */
7900 if (attribute_flag[0] != 0)
7901 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7902 &geometry,exception);
7903 if (attribute_flag[1] != 0)
7904 geometry.width=argument_list[1].integer_reference;
7905 if (attribute_flag[2] != 0)
7906 geometry.height=argument_list[2].integer_reference;
7907 if (attribute_flag[3] == 0)
7908 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7909 if (attribute_flag[4] != 0)
7910 SetImageArtifact(image,"filter:support",
7911 argument_list[4].string_reference);
7912 if (attribute_flag[5] == 0)
7913 argument_list[5].real_reference=1.0;
7914 image=ResizeImage(image,geometry.width,geometry.height,
7915 (FilterTypes) argument_list[3].integer_reference,
7916 argument_list[5].real_reference,exception);
7919 case 33: /* Annotate */
7924 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7926 if (attribute_flag[0] != 0)
7931 text=InterpretImageProperties(info ? info->image_info :
7932 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7933 (void) CloneString(&draw_info->text,text);
7934 text=DestroyString(text);
7936 if (attribute_flag[1] != 0)
7937 (void) CloneString(&draw_info->font,
7938 argument_list[1].string_reference);
7939 if (attribute_flag[2] != 0)
7940 draw_info->pointsize=argument_list[2].real_reference;
7941 if (attribute_flag[3] != 0)
7942 (void) CloneString(&draw_info->density,
7943 argument_list[3].string_reference);
7944 if (attribute_flag[4] != 0)
7945 (void) QueryColorDatabase(argument_list[4].string_reference,
7946 &draw_info->undercolor,exception);
7947 if (attribute_flag[5] != 0)
7949 (void) QueryColorDatabase(argument_list[5].string_reference,
7950 &draw_info->stroke,exception);
7951 if (argument_list[5].image_reference != (Image *) NULL)
7952 draw_info->stroke_pattern=CloneImage(
7953 argument_list[5].image_reference,0,0,MagickTrue,exception);
7955 if (attribute_flag[6] != 0)
7957 (void) QueryColorDatabase(argument_list[6].string_reference,
7958 &draw_info->fill,exception);
7959 if (argument_list[6].image_reference != (Image *) NULL)
7960 draw_info->fill_pattern=CloneImage(
7961 argument_list[6].image_reference,0,0,MagickTrue,exception);
7963 if (attribute_flag[7] != 0)
7965 (void) CloneString(&draw_info->geometry,
7966 argument_list[7].string_reference);
7967 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7968 &geometry,exception);
7969 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7970 geometry_info.sigma=geometry_info.xi;
7972 if (attribute_flag[8] != 0)
7973 (void) QueryColorDatabase(argument_list[8].string_reference,
7974 &draw_info->fill,exception);
7975 if (attribute_flag[11] != 0)
7976 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7977 if (attribute_flag[25] != 0)
7982 av=(AV *) argument_list[25].array_reference;
7983 if ((av_len(av) != 3) && (av_len(av) != 5))
7985 ThrowPerlException(exception,OptionError,
7986 "affine matrix must have 4 or 6 elements",PackageName);
7989 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7990 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7991 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7992 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7993 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7994 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7996 ThrowPerlException(exception,OptionError,
7997 "affine matrix is singular",PackageName);
8000 if (av_len(av) == 5)
8002 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8003 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8006 for (j=12; j < 17; j++)
8008 if (attribute_flag[j] == 0)
8010 value=argument_list[j].string_reference;
8011 angle=argument_list[j].real_reference;
8012 current=draw_info->affine;
8013 GetAffineMatrix(&affine);
8021 flags=ParseGeometry(value,&geometry_info);
8022 affine.tx=geometry_info.xi;
8023 affine.ty=geometry_info.psi;
8024 if ((flags & PsiValue) == 0)
8025 affine.ty=affine.tx;
8033 flags=ParseGeometry(value,&geometry_info);
8034 affine.sx=geometry_info.rho;
8035 affine.sy=geometry_info.sigma;
8036 if ((flags & SigmaValue) == 0)
8037 affine.sy=affine.sx;
8047 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8048 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8049 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8050 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8058 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8066 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8070 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8071 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8072 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8073 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8074 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8076 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8079 if (attribute_flag[9] == 0)
8080 argument_list[9].real_reference=0.0;
8081 if (attribute_flag[10] == 0)
8082 argument_list[10].real_reference=0.0;
8083 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8086 geometry[MaxTextExtent];
8088 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8089 (double) argument_list[9].real_reference+draw_info->affine.tx,
8090 (double) argument_list[10].real_reference+draw_info->affine.ty);
8091 (void) CloneString(&draw_info->geometry,geometry);
8093 if (attribute_flag[17] != 0)
8094 draw_info->stroke_width=argument_list[17].real_reference;
8095 if (attribute_flag[18] != 0)
8097 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8098 MagickTrue : MagickFalse;
8099 draw_info->stroke_antialias=draw_info->text_antialias;
8101 if (attribute_flag[19] != 0)
8102 (void) CloneString(&draw_info->family,
8103 argument_list[19].string_reference);
8104 if (attribute_flag[20] != 0)
8105 draw_info->style=(StyleType) argument_list[20].integer_reference;
8106 if (attribute_flag[21] != 0)
8107 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8108 if (attribute_flag[22] != 0)
8109 draw_info->weight=argument_list[22].integer_reference;
8110 if (attribute_flag[23] != 0)
8111 draw_info->align=(AlignType) argument_list[23].integer_reference;
8112 if (attribute_flag[24] != 0)
8113 (void) CloneString(&draw_info->encoding,
8114 argument_list[24].string_reference);
8115 if (attribute_flag[25] != 0)
8116 draw_info->fill_pattern=CloneImage(
8117 argument_list[25].image_reference,0,0,MagickTrue,exception);
8118 if (attribute_flag[26] != 0)
8119 draw_info->fill_pattern=CloneImage(
8120 argument_list[26].image_reference,0,0,MagickTrue,exception);
8121 if (attribute_flag[27] != 0)
8122 draw_info->stroke_pattern=CloneImage(
8123 argument_list[27].image_reference,0,0,MagickTrue,exception);
8124 if (attribute_flag[29] != 0)
8125 draw_info->kerning=argument_list[29].real_reference;
8126 if (attribute_flag[30] != 0)
8127 draw_info->interline_spacing=argument_list[30].real_reference;
8128 if (attribute_flag[31] != 0)
8129 draw_info->interword_spacing=argument_list[31].real_reference;
8130 if (attribute_flag[32] != 0)
8131 draw_info->direction=(DirectionType)
8132 argument_list[32].integer_reference;
8133 (void) AnnotateImage(image,draw_info);
8134 draw_info=DestroyDrawInfo(draw_info);
8137 case 34: /* ColorFloodfill */
8148 draw_info=CloneDrawInfo(info ? info->image_info :
8149 (ImageInfo *) NULL,(DrawInfo *) NULL);
8150 if (attribute_flag[0] != 0)
8151 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8152 &geometry,exception);
8153 if (attribute_flag[1] != 0)
8154 geometry.x=argument_list[1].integer_reference;
8155 if (attribute_flag[2] != 0)
8156 geometry.y=argument_list[2].integer_reference;
8157 if (attribute_flag[3] != 0)
8158 (void) QueryColorDatabase(argument_list[3].string_reference,
8159 &draw_info->fill,exception);
8160 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8163 if (attribute_flag[4] != 0)
8165 QueryMagickColor(argument_list[4].string_reference,&target,
8169 if (attribute_flag[5] != 0)
8170 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8172 if (attribute_flag[6] != 0)
8173 invert=(MagickBooleanType) argument_list[6].integer_reference;
8174 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8176 draw_info=DestroyDrawInfo(draw_info);
8179 case 35: /* Composite */
8182 composite_geometry[MaxTextExtent];
8188 compose=OverCompositeOp;
8189 if (attribute_flag[0] != 0)
8190 composite_image=argument_list[0].image_reference;
8193 ThrowPerlException(exception,OptionError,
8194 "CompositeImageRequired",PackageName);
8198 Parameter Handling used for BOTH normal and tiled composition.
8200 if (attribute_flag[1] != 0) /* compose */
8201 compose=(CompositeOperator) argument_list[1].integer_reference;
8202 if (attribute_flag[6] != 0) /* opacity */
8204 if (compose != DissolveCompositeOp)
8205 (void) SetImageOpacity(composite_image,(Quantum)
8206 SiPrefixToDouble(argument_list[6].string_reference,
8229 Handle dissolve composite operator (patch by
8232 (void) CloneString(&image->geometry,
8233 argument_list[6].string_reference);
8234 opacity=(Quantum) SiPrefixToDouble(
8235 argument_list[6].string_reference,QuantumRange);
8236 if (composite_image->matte != MagickTrue)
8237 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8238 composite_view=AcquireCacheView(composite_image);
8239 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8241 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8242 composite_image->columns,1,exception);
8243 for (x=0; x < (ssize_t) composite_image->columns; x++)
8245 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8246 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8247 q+=GetPixelComponents(composite_image);
8249 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8250 if (sync == MagickFalse)
8253 composite_view=DestroyCacheView(composite_view);
8256 if (attribute_flag[9] != 0) /* "color=>" */
8257 QueryColorDatabase(argument_list[9].string_reference,
8258 &composite_image->background_color,exception);
8259 if (attribute_flag[12] != 0) /* "interpolate=>" */
8260 image->interpolate=(InterpolatePixelMethod)
8261 argument_list[12].integer_reference;
8262 if (attribute_flag[13] != 0) /* "args=>" */
8263 (void) SetImageArtifact(composite_image,"compose:args",
8264 argument_list[13].string_reference);
8265 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8266 (void) SetImageArtifact(composite_image,"compose:args",
8267 argument_list[14].string_reference);
8269 Tiling Composition (with orthogonal rotate).
8271 rotate_image=(Image *) NULL;
8272 if (attribute_flag[8] != 0) /* "rotate=>" */
8277 rotate_image=RotateImage(composite_image,
8278 argument_list[8].real_reference,exception);
8279 if (rotate_image == (Image *) NULL)
8282 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8289 Tile the composite image.
8291 if (attribute_flag[8] != 0) /* "tile=>" */
8292 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8295 (void) SetImageArtifact(composite_image,
8296 "compose:outside-overlay","false");
8297 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8298 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8300 if (attribute_flag[8] != 0) /* rotate */
8301 (void) CompositeImage(image,compose,rotate_image,x,y);
8303 (void) CompositeImage(image,compose,composite_image,x,y);
8305 if (attribute_flag[8] != 0) /* rotate */
8306 rotate_image=DestroyImage(rotate_image);
8310 Parameter Handling used used ONLY for normal composition.
8312 if (attribute_flag[5] != 0) /* gravity */
8313 image->gravity=(GravityType) argument_list[5].integer_reference;
8314 if (attribute_flag[2] != 0) /* geometry offset */
8316 SetGeometry(image,&geometry);
8317 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8319 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8322 if (attribute_flag[3] != 0) /* x offset */
8323 geometry.x=argument_list[3].integer_reference;
8324 if (attribute_flag[4] != 0) /* y offset */
8325 geometry.y=argument_list[4].integer_reference;
8326 if (attribute_flag[10] != 0) /* mask */
8328 if ((image->compose == DisplaceCompositeOp) ||
8329 (image->compose == DistortCompositeOp))
8332 Merge Y displacement into X displacement image.
8334 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8336 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8337 argument_list[10].image_reference,0,0);
8342 Set a blending mask for the composition.
8344 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8345 MagickTrue,&image->exception);
8346 (void) NegateImage(image->mask,MagickFalse);
8349 if (attribute_flag[11] != 0) /* channel */
8350 channel=(ChannelType) argument_list[11].integer_reference;
8352 Composite two images (normal composition).
8354 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8355 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8356 (double) composite_image->rows,(double) geometry.x,(double)
8358 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8360 PushPixelComponentMap(image,channel);
8361 if (attribute_flag[8] == 0) /* no rotate */
8362 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8366 Position adjust rotated image then composite.
8368 geometry.x-=(ssize_t) (rotate_image->columns-
8369 composite_image->columns)/2;
8370 geometry.y-=(ssize_t) (rotate_image->rows-
8371 composite_image->rows)/2;
8372 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8373 rotate_image=DestroyImage(rotate_image);
8375 if (attribute_flag[10] != 0) /* mask */
8377 if ((image->compose == DisplaceCompositeOp) ||
8378 (image->compose == DistortCompositeOp))
8379 composite_image=DestroyImage(composite_image);
8381 image->mask=DestroyImage(image->mask);
8383 PopPixelComponentMap(image);
8386 case 36: /* Contrast */
8388 if (attribute_flag[0] == 0)
8389 argument_list[0].integer_reference=0;
8390 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8391 MagickTrue : MagickFalse);
8394 case 37: /* CycleColormap */
8396 if (attribute_flag[0] == 0)
8397 argument_list[0].integer_reference=6;
8398 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8406 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8408 (void) CloneString(&draw_info->primitive,"point");
8409 if (attribute_flag[0] != 0)
8411 if (argument_list[0].integer_reference < 0)
8412 (void) CloneString(&draw_info->primitive,
8413 argument_list[0].string_reference);
8415 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8416 MagickPrimitiveOptions,argument_list[0].integer_reference));
8418 if (attribute_flag[1] != 0)
8420 if (LocaleCompare(draw_info->primitive,"path") == 0)
8422 (void) ConcatenateString(&draw_info->primitive," '");
8423 ConcatenateString(&draw_info->primitive,
8424 argument_list[1].string_reference);
8425 (void) ConcatenateString(&draw_info->primitive,"'");
8429 (void) ConcatenateString(&draw_info->primitive," ");
8430 ConcatenateString(&draw_info->primitive,
8431 argument_list[1].string_reference);
8434 if (attribute_flag[2] != 0)
8436 (void) ConcatenateString(&draw_info->primitive," ");
8437 (void) ConcatenateString(&draw_info->primitive,
8438 CommandOptionToMnemonic(MagickMethodOptions,
8439 argument_list[2].integer_reference));
8441 if (attribute_flag[3] != 0)
8443 (void) QueryColorDatabase(argument_list[3].string_reference,
8444 &draw_info->stroke,exception);
8445 if (argument_list[3].image_reference != (Image *) NULL)
8446 draw_info->stroke_pattern=CloneImage(
8447 argument_list[3].image_reference,0,0,MagickTrue,exception);
8449 if (attribute_flag[4] != 0)
8451 (void) QueryColorDatabase(argument_list[4].string_reference,
8452 &draw_info->fill,exception);
8453 if (argument_list[4].image_reference != (Image *) NULL)
8454 draw_info->fill_pattern=CloneImage(
8455 argument_list[4].image_reference,0,0,MagickTrue,exception);
8457 if (attribute_flag[5] != 0)
8458 draw_info->stroke_width=argument_list[5].real_reference;
8459 if (attribute_flag[6] != 0)
8460 (void) CloneString(&draw_info->font,
8461 argument_list[6].string_reference);
8462 if (attribute_flag[7] != 0)
8463 (void) QueryColorDatabase(argument_list[7].string_reference,
8464 &draw_info->border_color,exception);
8465 if (attribute_flag[8] != 0)
8466 draw_info->affine.tx=argument_list[8].real_reference;
8467 if (attribute_flag[9] != 0)
8468 draw_info->affine.ty=argument_list[9].real_reference;
8469 if (attribute_flag[20] != 0)
8474 av=(AV *) argument_list[20].array_reference;
8475 if ((av_len(av) != 3) && (av_len(av) != 5))
8477 ThrowPerlException(exception,OptionError,
8478 "affine matrix must have 4 or 6 elements",PackageName);
8481 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8482 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8483 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8484 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8485 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8486 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8488 ThrowPerlException(exception,OptionError,
8489 "affine matrix is singular",PackageName);
8492 if (av_len(av) == 5)
8494 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8495 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8498 for (j=10; j < 15; j++)
8500 if (attribute_flag[j] == 0)
8502 value=argument_list[j].string_reference;
8503 angle=argument_list[j].real_reference;
8504 current=draw_info->affine;
8505 GetAffineMatrix(&affine);
8513 flags=ParseGeometry(value,&geometry_info);
8514 affine.tx=geometry_info.xi;
8515 affine.ty=geometry_info.psi;
8516 if ((flags & PsiValue) == 0)
8517 affine.ty=affine.tx;
8525 flags=ParseGeometry(value,&geometry_info);
8526 affine.sx=geometry_info.rho;
8527 affine.sy=geometry_info.sigma;
8528 if ((flags & SigmaValue) == 0)
8529 affine.sy=affine.sx;
8539 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8540 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8541 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8542 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8550 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8558 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8562 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8563 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8564 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8565 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8566 draw_info->affine.tx=
8567 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8568 draw_info->affine.ty=
8569 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8571 if (attribute_flag[15] != 0)
8572 draw_info->fill_pattern=CloneImage(
8573 argument_list[15].image_reference,0,0,MagickTrue,exception);
8574 if (attribute_flag[16] != 0)
8575 draw_info->pointsize=argument_list[16].real_reference;
8576 if (attribute_flag[17] != 0)
8578 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8579 ? MagickTrue : MagickFalse;
8580 draw_info->text_antialias=draw_info->stroke_antialias;
8582 if (attribute_flag[18] != 0)
8583 (void) CloneString(&draw_info->density,
8584 argument_list[18].string_reference);
8585 if (attribute_flag[19] != 0)
8586 draw_info->stroke_width=argument_list[19].real_reference;
8587 if (attribute_flag[21] != 0)
8588 draw_info->dash_offset=argument_list[21].real_reference;
8589 if (attribute_flag[22] != 0)
8594 av=(AV *) argument_list[22].array_reference;
8595 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8596 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8597 if (draw_info->dash_pattern != (double *) NULL)
8599 for (i=0; i <= av_len(av); i++)
8600 draw_info->dash_pattern[i]=(double)
8601 SvNV(*(av_fetch(av,i,0)));
8602 draw_info->dash_pattern[i]=0.0;
8605 if (attribute_flag[23] != 0)
8606 image->interpolate=(InterpolatePixelMethod)
8607 argument_list[23].integer_reference;
8608 if ((attribute_flag[24] != 0) &&
8609 (draw_info->fill_pattern != (Image *) NULL))
8610 flags=ParsePageGeometry(draw_info->fill_pattern,
8611 argument_list[24].string_reference,
8612 &draw_info->fill_pattern->tile_offset,exception);
8613 if (attribute_flag[25] != 0)
8615 (void) ConcatenateString(&draw_info->primitive," '");
8616 (void) ConcatenateString(&draw_info->primitive,
8617 argument_list[25].string_reference);
8618 (void) ConcatenateString(&draw_info->primitive,"'");
8620 if (attribute_flag[26] != 0)
8621 draw_info->fill_pattern=CloneImage(
8622 argument_list[26].image_reference,0,0,MagickTrue,exception);
8623 if (attribute_flag[27] != 0)
8624 draw_info->stroke_pattern=CloneImage(
8625 argument_list[27].image_reference,0,0,MagickTrue,exception);
8626 if (attribute_flag[28] != 0)
8627 (void) CloneString(&draw_info->primitive,
8628 argument_list[28].string_reference);
8629 if (attribute_flag[29] != 0)
8630 draw_info->kerning=argument_list[29].real_reference;
8631 if (attribute_flag[30] != 0)
8632 draw_info->interline_spacing=argument_list[30].real_reference;
8633 if (attribute_flag[31] != 0)
8634 draw_info->interword_spacing=argument_list[31].real_reference;
8635 if (attribute_flag[32] != 0)
8636 draw_info->direction=(DirectionType)
8637 argument_list[32].integer_reference;
8638 DrawImage(image,draw_info);
8639 draw_info=DestroyDrawInfo(draw_info);
8642 case 39: /* Equalize */
8644 if (attribute_flag[0] != 0)
8645 channel=(ChannelType) argument_list[0].integer_reference;
8646 PushPixelComponentMap(image,channel);
8647 EqualizeImage(image);
8648 PopPixelComponentMap(image);
8651 case 40: /* Gamma */
8653 if (attribute_flag[1] != 0)
8654 channel=(ChannelType) argument_list[1].integer_reference;
8655 if (attribute_flag[2] == 0)
8656 argument_list[2].real_reference=1.0;
8657 if (attribute_flag[3] == 0)
8658 argument_list[3].real_reference=1.0;
8659 if (attribute_flag[4] == 0)
8660 argument_list[4].real_reference=1.0;
8661 if (attribute_flag[0] == 0)
8663 (void) FormatLocaleString(message,MaxTextExtent,
8664 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8665 (double) argument_list[3].real_reference,
8666 (double) argument_list[4].real_reference);
8667 argument_list[0].string_reference=message;
8669 (void) GammaImage(image,InterpretLocaleValue(
8670 argument_list[0].string_reference,(char **) NULL));
8678 if (attribute_flag[0] == 0)
8680 ThrowPerlException(exception,OptionError,"MapImageRequired",
8684 quantize_info=AcquireQuantizeInfo(info->image_info);
8685 if (attribute_flag[1] != 0)
8686 quantize_info->dither=(MagickBooleanType)
8687 argument_list[1].integer_reference;
8688 if (attribute_flag[2] != 0)
8689 quantize_info->dither_method=(DitherMethod)
8690 argument_list[2].integer_reference;
8691 (void) RemapImages(quantize_info,image,
8692 argument_list[0].image_reference);
8693 quantize_info=DestroyQuantizeInfo(quantize_info);
8696 case 42: /* MatteFloodfill */
8707 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8709 if (attribute_flag[0] != 0)
8710 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8711 &geometry,exception);
8712 if (attribute_flag[1] != 0)
8713 geometry.x=argument_list[1].integer_reference;
8714 if (attribute_flag[2] != 0)
8715 geometry.y=argument_list[2].integer_reference;
8716 if (image->matte == MagickFalse)
8717 (void) SetImageOpacity(image,OpaqueAlpha);
8718 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8720 if (attribute_flag[4] != 0)
8721 QueryMagickColor(argument_list[4].string_reference,&target,
8723 if (attribute_flag[3] != 0)
8724 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8726 if (attribute_flag[5] != 0)
8727 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8730 if (attribute_flag[6] != 0)
8731 invert=(MagickBooleanType) argument_list[6].integer_reference;
8732 PushPixelComponentMap(image,AlphaChannel);
8733 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8735 PopPixelComponentMap(image);
8736 StandardPixelComponentMap(image);
8737 draw_info=DestroyDrawInfo(draw_info);
8740 case 43: /* Modulate */
8743 modulate[MaxTextExtent];
8745 geometry_info.rho=100.0;
8746 geometry_info.sigma=100.0;
8747 geometry_info.xi=100.0;
8748 if (attribute_flag[0] != 0)
8749 (void)ParseGeometry(argument_list[0].string_reference,
8751 if (attribute_flag[1] != 0)
8752 geometry_info.xi=argument_list[1].real_reference;
8753 if (attribute_flag[2] != 0)
8754 geometry_info.sigma=argument_list[2].real_reference;
8755 if (attribute_flag[3] != 0)
8757 geometry_info.sigma=argument_list[3].real_reference;
8758 SetImageArtifact(image,"modulate:colorspace","HWB");
8760 if (attribute_flag[4] != 0)
8762 geometry_info.rho=argument_list[4].real_reference;
8763 SetImageArtifact(image,"modulate:colorspace","HSB");
8765 if (attribute_flag[5] != 0)
8767 geometry_info.sigma=argument_list[5].real_reference;
8768 SetImageArtifact(image,"modulate:colorspace","HSL");
8770 if (attribute_flag[6] != 0)
8772 geometry_info.rho=argument_list[6].real_reference;
8773 SetImageArtifact(image,"modulate:colorspace","HWB");
8775 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8776 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8777 (void) ModulateImage(image,modulate);
8780 case 44: /* Negate */
8782 if (attribute_flag[0] == 0)
8783 argument_list[0].integer_reference=0;
8784 if (attribute_flag[1] != 0)
8785 channel=(ChannelType) argument_list[1].integer_reference;
8786 PushPixelComponentMap(image,channel);
8787 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8788 MagickTrue : MagickFalse);
8789 PopPixelComponentMap(image);
8792 case 45: /* Normalize */
8794 if (attribute_flag[0] != 0)
8795 channel=(ChannelType) argument_list[0].integer_reference;
8796 PushPixelComponentMap(image,channel);
8797 NormalizeImage(image);
8798 PopPixelComponentMap(image);
8801 case 46: /* NumberColors */
8803 case 47: /* Opaque */
8812 (void) QueryMagickColor("none",&target,exception);
8813 (void) QueryMagickColor("none",&fill_color,exception);
8814 if (attribute_flag[0] != 0)
8815 (void) QueryMagickColor(argument_list[0].string_reference,
8817 if (attribute_flag[1] != 0)
8818 (void) QueryMagickColor(argument_list[1].string_reference,
8819 &fill_color,exception);
8820 if (attribute_flag[2] != 0)
8821 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8823 if (attribute_flag[3] != 0)
8824 channel=(ChannelType) argument_list[3].integer_reference;
8826 if (attribute_flag[4] != 0)
8827 invert=(MagickBooleanType) argument_list[4].integer_reference;
8828 PushPixelComponentMap(image,channel);
8829 (void) OpaquePaintImage(image,&target,&fill_color,invert);
8830 PopPixelComponentMap(image);
8833 case 48: /* Quantize */
8838 quantize_info=AcquireQuantizeInfo(info->image_info);
8839 if (attribute_flag[0] != 0)
8840 quantize_info->number_colors=(size_t)
8841 argument_list[0].integer_reference;
8842 if (attribute_flag[1] != 0)
8843 quantize_info->tree_depth=(size_t)
8844 argument_list[1].integer_reference;
8845 if (attribute_flag[2] != 0)
8846 quantize_info->colorspace=(ColorspaceType)
8847 argument_list[2].integer_reference;
8848 if (attribute_flag[3] != 0)
8849 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8850 MagickTrue : MagickFalse;
8851 if (attribute_flag[4] != 0)
8852 quantize_info->measure_error=
8853 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8854 if (attribute_flag[5] != 0)
8855 (void) QueryColorDatabase(argument_list[5].string_reference,
8856 &image->transparent_color,exception);
8857 if (attribute_flag[5] && argument_list[5].integer_reference)
8859 (void) QuantizeImages(quantize_info,image);
8862 if (attribute_flag[6] != 0)
8863 quantize_info->dither_method=(DitherMethod)
8864 argument_list[6].integer_reference;
8865 if ((image->storage_class == DirectClass) ||
8866 (image->colors > quantize_info->number_colors) ||
8867 (quantize_info->colorspace == GRAYColorspace))
8868 (void) QuantizeImage(quantize_info,image);
8870 CompressImageColormap(image);
8871 quantize_info=DestroyQuantizeInfo(quantize_info);
8874 case 49: /* Raise */
8876 if (attribute_flag[0] != 0)
8877 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8878 &geometry,exception);
8879 if (attribute_flag[1] != 0)
8880 geometry.width=argument_list[1].integer_reference;
8881 if (attribute_flag[2] != 0)
8882 geometry.height=argument_list[2].integer_reference;
8883 if (attribute_flag[3] == 0)
8884 argument_list[3].integer_reference=1;
8885 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8886 0 ? MagickTrue : MagickFalse);
8889 case 50: /* Segment */
8896 smoothing_threshold;
8901 cluster_threshold=1.0;
8902 smoothing_threshold=1.5;
8903 colorspace=RGBColorspace;
8904 verbose=MagickFalse;
8905 if (attribute_flag[0] != 0)
8907 flags=ParseGeometry(argument_list[0].string_reference,
8909 cluster_threshold=geometry_info.rho;
8910 if (flags & SigmaValue)
8911 smoothing_threshold=geometry_info.sigma;
8913 if (attribute_flag[1] != 0)
8914 cluster_threshold=argument_list[1].real_reference;
8915 if (attribute_flag[2] != 0)
8916 smoothing_threshold=argument_list[2].real_reference;
8917 if (attribute_flag[3] != 0)
8918 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8919 if (attribute_flag[4] != 0)
8920 verbose=argument_list[4].integer_reference != 0 ?
8921 MagickTrue : MagickFalse;
8922 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8923 smoothing_threshold);
8926 case 51: /* Signature */
8928 (void) SignatureImage(image);
8931 case 52: /* Solarize */
8933 geometry_info.rho=QuantumRange/2.0;
8934 if (attribute_flag[0] != 0)
8935 flags=ParseGeometry(argument_list[0].string_reference,
8937 if (attribute_flag[1] != 0)
8938 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8940 (void) SolarizeImage(image,geometry_info.rho);
8945 (void) SyncImage(image);
8948 case 54: /* Texture */
8950 if (attribute_flag[0] == 0)
8952 TextureImage(image,argument_list[0].image_reference);
8955 case 55: /* Evalute */
8957 MagickEvaluateOperator
8960 op=SetEvaluateOperator;
8961 if (attribute_flag[0] == MagickFalse)
8962 argument_list[0].real_reference=0.0;
8963 if (attribute_flag[1] != MagickFalse)
8964 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8965 if (attribute_flag[2] != MagickFalse)
8966 channel=(ChannelType) argument_list[2].integer_reference;
8967 PushPixelComponentMap(image,channel);
8968 (void) EvaluateImage(image,op,argument_list[0].real_reference,
8970 PopPixelComponentMap(image);
8973 case 56: /* Transparent */
8984 (void) QueryMagickColor("none",&target,exception);
8985 if (attribute_flag[0] != 0)
8986 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8988 opacity=TransparentAlpha;
8989 if (attribute_flag[1] != 0)
8990 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8992 if (attribute_flag[2] != 0)
8993 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8995 if (attribute_flag[3] == 0)
8996 argument_list[3].integer_reference=0;
8998 if (attribute_flag[3] != 0)
8999 invert=(MagickBooleanType) argument_list[3].integer_reference;
9000 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9004 case 57: /* Threshold */
9009 if (attribute_flag[0] == 0)
9010 argument_list[0].string_reference="50%";
9011 if (attribute_flag[1] != 0)
9012 channel=(ChannelType) argument_list[1].integer_reference;
9013 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9015 PushPixelComponentMap(image,channel);
9016 (void) BilevelImage(image,threshold);
9017 PopPixelComponentMap(image);
9020 case 58: /* Charcoal */
9022 if (attribute_flag[0] != 0)
9024 flags=ParseGeometry(argument_list[0].string_reference,
9026 if ((flags & SigmaValue) == 0)
9027 geometry_info.sigma=1.0;
9029 if (attribute_flag[1] != 0)
9030 geometry_info.rho=argument_list[1].real_reference;
9031 if (attribute_flag[2] != 0)
9032 geometry_info.sigma=argument_list[2].real_reference;
9033 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9039 if (attribute_flag[0] != 0)
9040 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9042 image=TrimImage(image,exception);
9047 if (attribute_flag[0] != 0)
9049 flags=ParseGeometry(argument_list[0].string_reference,
9051 if ((flags & SigmaValue) == 0)
9052 geometry_info.sigma=1.0;
9054 if (attribute_flag[1] != 0)
9055 geometry_info.rho=argument_list[1].real_reference;
9056 if (attribute_flag[2] != 0)
9057 geometry_info.sigma=argument_list[2].real_reference;
9058 if (attribute_flag[3] != 0)
9059 image->interpolate=(InterpolatePixelMethod)
9060 argument_list[3].integer_reference;
9061 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9065 case 61: /* Separate */
9067 if (attribute_flag[0] != 0)
9068 channel=(ChannelType) argument_list[0].integer_reference;
9069 PushPixelComponentMap(image,channel);
9070 (void) SeparateImage(image);
9071 PopPixelComponentMap(image);
9074 case 63: /* Stereo */
9076 if (attribute_flag[0] == 0)
9078 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9082 if (attribute_flag[1] != 0)
9083 geometry.x=argument_list[1].integer_reference;
9084 if (attribute_flag[2] != 0)
9085 geometry.y=argument_list[2].integer_reference;
9086 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9087 geometry.x,geometry.y,exception);
9090 case 64: /* Stegano */
9092 if (attribute_flag[0] == 0)
9094 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9098 if (attribute_flag[1] == 0)
9099 argument_list[1].integer_reference=0;
9100 image->offset=argument_list[1].integer_reference;
9101 image=SteganoImage(image,argument_list[0].image_reference,exception);
9104 case 65: /* Deconstruct */
9106 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9109 case 66: /* GaussianBlur */
9111 if (attribute_flag[0] != 0)
9113 flags=ParseGeometry(argument_list[0].string_reference,
9115 if ((flags & SigmaValue) == 0)
9116 geometry_info.sigma=1.0;
9118 if (attribute_flag[1] != 0)
9119 geometry_info.rho=argument_list[1].real_reference;
9120 if (attribute_flag[2] != 0)
9121 geometry_info.sigma=argument_list[2].real_reference;
9122 if (attribute_flag[3] != 0)
9123 channel=(ChannelType) argument_list[3].integer_reference;
9124 PushPixelComponentMap(image,channel);
9125 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9127 if (image != (Image *) NULL)
9128 PopPixelComponentMap(image);
9131 case 67: /* Convolve */
9142 if (attribute_flag[0] == 0)
9144 if (attribute_flag[1] != 0)
9145 channel=(ChannelType) argument_list[1].integer_reference;
9146 if (attribute_flag[2] != 0)
9147 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9149 av=(AV *) argument_list[0].array_reference;
9150 order=(size_t) sqrt(av_len(av)+1);
9151 kernel=(double *) AcquireQuantumMemory(order,order*sizeof(*kernel));
9152 if (kernel == (double *) NULL)
9154 ThrowPerlException(exception,ResourceLimitFatalError,
9155 "MemoryAllocationFailed",PackageName);
9158 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9159 kernel[j]=(double) SvNV(*(av_fetch(av,j,0)));
9160 for ( ; j < (ssize_t) (order*order); j++)
9162 PushPixelComponentMap(image,channel);
9163 image=ConvolveImage(image,order,kernel,exception);
9164 if (image != (Image *) NULL)
9165 PopPixelComponentMap(image);
9166 kernel=(double *) RelinquishMagickMemory(kernel);
9169 case 68: /* Profile */
9184 if (attribute_flag[0] != 0)
9185 name=argument_list[0].string_reference;
9186 if (attribute_flag[2] != 0)
9187 image->rendering_intent=(RenderingIntent)
9188 argument_list[2].integer_reference;
9189 if (attribute_flag[3] != 0)
9190 image->black_point_compensation=
9191 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9192 if (attribute_flag[1] != 0)
9194 if (argument_list[1].length == 0)
9197 Remove a profile from the image.
9199 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9204 Associate user supplied profile with the image.
9206 profile=AcquireStringInfo(argument_list[1].length);
9207 SetStringInfoDatum(profile,(const unsigned char *)
9208 argument_list[1].string_reference);
9209 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9210 (size_t) GetStringInfoLength(profile),MagickFalse);
9211 profile=DestroyStringInfo(profile);
9215 Associate a profile with the image.
9218 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9219 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9220 profile_image=ReadImages(profile_info,&image->exception);
9221 if (profile_image == (Image *) NULL)
9223 ResetImageProfileIterator(profile_image);
9224 name=GetNextImageProfile(profile_image);
9225 while (name != (const char *) NULL)
9230 profile=GetImageProfile(profile_image,name);
9231 if (profile != (const StringInfo *) NULL)
9232 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9233 (size_t) GetStringInfoLength(profile),MagickFalse);
9234 name=GetNextImageProfile(profile_image);
9236 profile_image=DestroyImage(profile_image);
9237 profile_info=DestroyImageInfo(profile_info);
9240 case 69: /* UnsharpMask */
9242 if (attribute_flag[0] != 0)
9244 flags=ParseGeometry(argument_list[0].string_reference,
9246 if ((flags & SigmaValue) == 0)
9247 geometry_info.sigma=1.0;
9248 if ((flags & XiValue) == 0)
9249 geometry_info.xi=1.0;
9250 if ((flags & PsiValue) == 0)
9251 geometry_info.psi=0.5;
9253 if (attribute_flag[1] != 0)
9254 geometry_info.rho=argument_list[1].real_reference;
9255 if (attribute_flag[2] != 0)
9256 geometry_info.sigma=argument_list[2].real_reference;
9257 if (attribute_flag[3] != 0)
9258 geometry_info.xi=argument_list[3].real_reference;
9259 if (attribute_flag[4] != 0)
9260 geometry_info.psi=argument_list[4].real_reference;
9261 if (attribute_flag[5] != 0)
9262 channel=(ChannelType) argument_list[5].integer_reference;
9263 PushPixelComponentMap(image,channel);
9264 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9265 geometry_info.xi,geometry_info.psi,exception);
9266 if (image != (Image *) NULL)
9267 PopPixelComponentMap(image);
9270 case 70: /* MotionBlur */
9272 if (attribute_flag[0] != 0)
9274 flags=ParseGeometry(argument_list[0].string_reference,
9276 if ((flags & SigmaValue) == 0)
9277 geometry_info.sigma=1.0;
9278 if ((flags & XiValue) == 0)
9279 geometry_info.xi=1.0;
9281 if (attribute_flag[1] != 0)
9282 geometry_info.rho=argument_list[1].real_reference;
9283 if (attribute_flag[2] != 0)
9284 geometry_info.sigma=argument_list[2].real_reference;
9285 if (attribute_flag[3] != 0)
9286 geometry_info.xi=argument_list[3].real_reference;
9287 if (attribute_flag[4] != 0)
9288 channel=(ChannelType) argument_list[4].integer_reference;
9289 PushPixelComponentMap(image,channel);
9290 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9291 geometry_info.xi,exception);
9292 if (image != (Image *) NULL)
9293 PopPixelComponentMap(image);
9296 case 71: /* OrderedDither */
9298 if (attribute_flag[0] == 0)
9299 argument_list[0].string_reference="o8x8";
9300 if (attribute_flag[1] != 0)
9301 channel=(ChannelType) argument_list[1].integer_reference;
9302 PushPixelComponentMap(image,channel);
9303 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9305 PopPixelComponentMap(image);
9308 case 72: /* Shave */
9310 if (attribute_flag[0] != 0)
9311 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9312 &geometry,exception);
9313 if (attribute_flag[1] != 0)
9314 geometry.width=argument_list[1].integer_reference;
9315 if (attribute_flag[2] != 0)
9316 geometry.height=argument_list[2].integer_reference;
9317 image=ShaveImage(image,&geometry,exception);
9320 case 73: /* Level */
9328 white_point=(MagickRealType) image->columns*image->rows;
9330 if (attribute_flag[0] != 0)
9332 flags=ParseGeometry(argument_list[0].string_reference,
9334 black_point=geometry_info.rho;
9335 if ((flags & SigmaValue) != 0)
9336 white_point=geometry_info.sigma;
9337 if ((flags & XiValue) != 0)
9338 gamma=geometry_info.xi;
9339 if ((flags & PercentValue) != 0)
9341 black_point*=(double) (QuantumRange/100.0);
9342 white_point*=(double) (QuantumRange/100.0);
9344 if ((flags & SigmaValue) == 0)
9345 white_point=(double) QuantumRange-black_point;
9347 if (attribute_flag[1] != 0)
9348 black_point=argument_list[1].real_reference;
9349 if (attribute_flag[2] != 0)
9350 white_point=argument_list[2].real_reference;
9351 if (attribute_flag[3] != 0)
9352 gamma=argument_list[3].real_reference;
9353 if (attribute_flag[4] != 0)
9354 channel=(ChannelType) argument_list[4].integer_reference;
9355 if (attribute_flag[5] != 0)
9357 argument_list[0].real_reference=argument_list[5].real_reference;
9358 attribute_flag[0]=attribute_flag[5];
9360 PushPixelComponentMap(image,channel);
9361 (void) LevelImage(image,black_point,white_point,gamma);
9362 PopPixelComponentMap(image);
9367 if (attribute_flag[0] == 0)
9368 argument_list[0].string_reference="#1";
9369 if (attribute_flag[1] == 0)
9370 argument_list[1].integer_reference=MagickTrue;
9371 (void) ClipImagePath(image,argument_list[0].string_reference,
9372 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9375 case 75: /* AffineTransform */
9380 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9382 if (attribute_flag[0] != 0)
9387 av=(AV *) argument_list[0].array_reference;
9388 if ((av_len(av) != 3) && (av_len(av) != 5))
9390 ThrowPerlException(exception,OptionError,
9391 "affine matrix must have 4 or 6 elements",PackageName);
9394 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9395 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9396 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9397 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9398 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9399 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9401 ThrowPerlException(exception,OptionError,
9402 "affine matrix is singular",PackageName);
9405 if (av_len(av) == 5)
9407 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9408 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9411 for (j=1; j < 6; j++)
9413 if (attribute_flag[j] == 0)
9415 value=argument_list[j].string_reference;
9416 angle=argument_list[j].real_reference;
9417 current=draw_info->affine;
9418 GetAffineMatrix(&affine);
9426 flags=ParseGeometry(value,&geometry_info);
9427 affine.tx=geometry_info.xi;
9428 affine.ty=geometry_info.psi;
9429 if ((flags & PsiValue) == 0)
9430 affine.ty=affine.tx;
9438 flags=ParseGeometry(value,&geometry_info);
9439 affine.sx=geometry_info.rho;
9440 affine.sy=geometry_info.sigma;
9441 if ((flags & SigmaValue) == 0)
9442 affine.sy=affine.sx;
9452 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9453 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9454 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9455 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9463 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9471 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9475 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9476 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9477 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9478 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9479 draw_info->affine.tx=
9480 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9481 draw_info->affine.ty=
9482 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9484 if (attribute_flag[6] != 0)
9485 image->interpolate=(InterpolatePixelMethod)
9486 argument_list[6].integer_reference;
9487 if (attribute_flag[7] != 0)
9488 QueryColorDatabase(argument_list[7].string_reference,
9489 &image->background_color,exception);
9490 image=AffineTransformImage(image,&draw_info->affine,exception);
9491 draw_info=DestroyDrawInfo(draw_info);
9494 case 76: /* Difference */
9496 if (attribute_flag[0] == 0)
9498 ThrowPerlException(exception,OptionError,
9499 "ReferenceImageRequired",PackageName);
9502 if (attribute_flag[1] != 0)
9503 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9505 (void) IsImagesEqual(image,argument_list[0].image_reference);
9508 case 77: /* AdaptiveThreshold */
9510 if (attribute_flag[0] != 0)
9512 flags=ParseGeometry(argument_list[0].string_reference,
9514 if ((flags & PercentValue) != 0)
9515 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9517 if (attribute_flag[1] != 0)
9518 geometry_info.rho=argument_list[1].integer_reference;
9519 if (attribute_flag[2] != 0)
9520 geometry_info.sigma=argument_list[2].integer_reference;
9521 if (attribute_flag[3] != 0)
9522 geometry_info.xi=argument_list[3].integer_reference;;
9523 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9524 (size_t) geometry_info.sigma,(ssize_t) geometry_info.xi,
9528 case 78: /* Resample */
9534 if (attribute_flag[0] != 0)
9536 flags=ParseGeometry(argument_list[0].string_reference,
9538 if ((flags & SigmaValue) == 0)
9539 geometry_info.sigma=geometry_info.rho;
9541 if (attribute_flag[1] != 0)
9542 geometry_info.rho=argument_list[1].real_reference;
9543 if (attribute_flag[2] != 0)
9544 geometry_info.sigma=argument_list[2].real_reference;
9545 if (attribute_flag[3] == 0)
9546 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9547 if (attribute_flag[4] == 0)
9548 SetImageArtifact(image,"filter:support",
9549 argument_list[4].string_reference);
9550 if (attribute_flag[5] != 0)
9551 argument_list[5].real_reference=1.0;
9552 width=(size_t) (geometry_info.rho*image->columns/
9553 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9554 height=(size_t) (geometry_info.sigma*image->rows/
9555 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9556 image=ResizeImage(image,width,height,(FilterTypes)
9557 argument_list[3].integer_reference,argument_list[5].real_reference,
9559 if (image != (Image *) NULL)
9561 image->x_resolution=geometry_info.rho;
9562 image->y_resolution=geometry_info.sigma;
9566 case 79: /* Describe */
9568 if (attribute_flag[0] == 0)
9569 argument_list[0].file_reference=(FILE *) NULL;
9570 if (attribute_flag[1] != 0)
9571 (void) SetImageArtifact(image,"identify:features",
9572 argument_list[1].string_reference);
9573 (void) IdentifyImage(image,argument_list[0].file_reference,
9577 case 80: /* BlackThreshold */
9579 if (attribute_flag[0] == 0)
9580 argument_list[0].string_reference="50%";
9581 if (attribute_flag[2] != 0)
9582 channel=(ChannelType) argument_list[2].integer_reference;
9583 PushPixelComponentMap(image,channel);
9584 BlackThresholdImage(image,argument_list[0].string_reference,
9586 PopPixelComponentMap(image);
9589 case 81: /* WhiteThreshold */
9591 if (attribute_flag[0] == 0)
9592 argument_list[0].string_reference="50%";
9593 if (attribute_flag[2] != 0)
9594 channel=(ChannelType) argument_list[2].integer_reference;
9595 PushPixelComponentMap(image,channel);
9596 WhiteThresholdImage(image,argument_list[0].string_reference,
9598 PopPixelComponentMap(image);
9601 case 82: /* RadialBlur */
9603 if (attribute_flag[0] != 0)
9605 flags=ParseGeometry(argument_list[0].string_reference,
9607 if ((flags & SigmaValue) == 0)
9608 geometry_info.sigma=1.0;
9610 if (attribute_flag[1] != 0)
9611 geometry_info.rho=argument_list[1].real_reference;
9612 if (attribute_flag[2] != 0)
9613 channel=(ChannelType) argument_list[2].integer_reference;
9614 PushPixelComponentMap(image,channel);
9615 image=RadialBlurImage(image,geometry_info.rho,exception);
9616 if (image != (Image *) NULL)
9617 PopPixelComponentMap(image);
9620 case 83: /* Thumbnail */
9622 if (attribute_flag[0] != 0)
9623 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9624 &geometry,exception);
9625 if (attribute_flag[1] != 0)
9626 geometry.width=argument_list[1].integer_reference;
9627 if (attribute_flag[2] != 0)
9628 geometry.height=argument_list[2].integer_reference;
9629 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9632 case 84: /* Strip */
9634 (void) StripImage(image);
9642 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9643 if (attribute_flag[0] != 0)
9644 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9646 if (attribute_flag[1] == 0)
9647 argument_list[1].string_reference="100";
9648 image=TintImage(image,argument_list[1].string_reference,target,
9652 case 86: /* Channel */
9654 if (attribute_flag[0] != 0)
9655 channel=(ChannelType) argument_list[0].integer_reference;
9656 PushPixelComponentMap(image,channel);
9657 (void) SeparateImage(image);
9658 PopPixelComponentMap(image);
9661 case 87: /* Splice */
9663 if (attribute_flag[0] != 0)
9664 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9665 &geometry,exception);
9666 if (attribute_flag[1] != 0)
9667 geometry.width=argument_list[1].integer_reference;
9668 if (attribute_flag[2] != 0)
9669 geometry.height=argument_list[2].integer_reference;
9670 if (attribute_flag[3] != 0)
9671 geometry.x=argument_list[3].integer_reference;
9672 if (attribute_flag[4] != 0)
9673 geometry.y=argument_list[4].integer_reference;
9674 if (attribute_flag[5] != 0)
9675 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9677 if (attribute_flag[6] != 0)
9678 (void) QueryColorDatabase(argument_list[6].string_reference,
9679 &image->background_color,exception);
9680 if (attribute_flag[7] != 0)
9681 image->gravity=(GravityType) argument_list[7].integer_reference;
9682 image=SpliceImage(image,&geometry,exception);
9685 case 88: /* Posterize */
9687 if (attribute_flag[0] == 0)
9688 argument_list[0].integer_reference=3;
9689 if (attribute_flag[1] == 0)
9690 argument_list[1].integer_reference=0;
9691 (void) PosterizeImage(image,argument_list[0].integer_reference,
9692 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9695 case 89: /* Shadow */
9697 if (attribute_flag[0] != 0)
9699 flags=ParseGeometry(argument_list[0].string_reference,
9701 if ((flags & SigmaValue) == 0)
9702 geometry_info.sigma=1.0;
9703 if ((flags & XiValue) == 0)
9704 geometry_info.xi=4.0;
9705 if ((flags & PsiValue) == 0)
9706 geometry_info.psi=4.0;
9708 if (attribute_flag[1] != 0)
9709 geometry_info.rho=argument_list[1].real_reference;
9710 if (attribute_flag[2] != 0)
9711 geometry_info.sigma=argument_list[2].real_reference;
9712 if (attribute_flag[3] != 0)
9713 geometry_info.xi=argument_list[3].integer_reference;
9714 if (attribute_flag[4] != 0)
9715 geometry_info.psi=argument_list[4].integer_reference;
9716 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9717 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9721 case 90: /* Identify */
9723 if (attribute_flag[0] == 0)
9724 argument_list[0].file_reference=(FILE *) NULL;
9725 if (attribute_flag[1] != 0)
9726 (void) SetImageArtifact(image,"identify:features",
9727 argument_list[1].string_reference);
9728 if ((attribute_flag[2] != 0) &&
9729 (argument_list[2].integer_reference != 0))
9730 (void) SetImageArtifact(image,"identify:unique","true");
9731 (void) IdentifyImage(image,argument_list[0].file_reference,
9735 case 91: /* SepiaTone */
9737 if (attribute_flag[0] == 0)
9738 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9739 image=SepiaToneImage(image,argument_list[0].real_reference,
9743 case 92: /* SigmoidalContrast */
9748 if (attribute_flag[0] != 0)
9750 flags=ParseGeometry(argument_list[0].string_reference,
9752 if ((flags & SigmaValue) == 0)
9753 geometry_info.sigma=QuantumRange/2.0;
9754 if ((flags & PercentValue) != 0)
9755 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9757 if (attribute_flag[1] != 0)
9758 geometry_info.rho=argument_list[1].real_reference;
9759 if (attribute_flag[2] != 0)
9760 geometry_info.sigma=argument_list[2].real_reference;
9761 if (attribute_flag[3] != 0)
9762 channel=(ChannelType) argument_list[3].integer_reference;
9764 if (attribute_flag[4] != 0)
9765 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9767 PushPixelComponentMap(image,channel);
9768 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9769 geometry_info.sigma);
9770 PopPixelComponentMap(image);
9773 case 93: /* Extent */
9775 if (attribute_flag[7] != 0)
9776 image->gravity=(GravityType) argument_list[7].integer_reference;
9777 if (attribute_flag[0] != 0)
9782 flags=ParseGravityGeometry(image,
9783 argument_list[0].string_reference,&geometry,exception);
9785 if (geometry.width == 0)
9786 geometry.width=image->columns;
9787 if (geometry.height == 0)
9788 geometry.height=image->rows;
9790 if (attribute_flag[1] != 0)
9791 geometry.width=argument_list[1].integer_reference;
9792 if (attribute_flag[2] != 0)
9793 geometry.height=argument_list[2].integer_reference;
9794 if (attribute_flag[3] != 0)
9795 geometry.x=argument_list[3].integer_reference;
9796 if (attribute_flag[4] != 0)
9797 geometry.y=argument_list[4].integer_reference;
9798 if (attribute_flag[5] != 0)
9799 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9801 if (attribute_flag[6] != 0)
9802 (void) QueryColorDatabase(argument_list[6].string_reference,
9803 &image->background_color,exception);
9804 image=ExtentImage(image,&geometry,exception);
9807 case 94: /* Vignette */
9809 if (attribute_flag[0] != 0)
9811 flags=ParseGeometry(argument_list[0].string_reference,
9813 if ((flags & SigmaValue) == 0)
9814 geometry_info.sigma=1.0;
9815 if ((flags & XiValue) == 0)
9816 geometry_info.xi=0.1*image->columns;
9817 if ((flags & PsiValue) == 0)
9818 geometry_info.psi=0.1*image->rows;
9820 if (attribute_flag[1] != 0)
9821 geometry_info.rho=argument_list[1].real_reference;
9822 if (attribute_flag[2] != 0)
9823 geometry_info.sigma=argument_list[2].real_reference;
9824 if (attribute_flag[3] != 0)
9825 geometry_info.xi=argument_list[3].integer_reference;
9826 if (attribute_flag[4] != 0)
9827 geometry_info.psi=argument_list[4].integer_reference;
9828 if (attribute_flag[5] != 0)
9829 (void) QueryColorDatabase(argument_list[5].string_reference,
9830 &image->background_color,exception);
9831 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9832 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9836 case 95: /* ContrastStretch */
9843 white_point=(MagickRealType) image->columns*image->rows;
9844 if (attribute_flag[0] != 0)
9846 flags=ParseGeometry(argument_list[0].string_reference,
9848 black_point=geometry_info.rho;
9849 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9851 if ((flags & PercentValue) != 0)
9853 black_point*=(double) image->columns*image->rows/100.0;
9854 white_point*=(double) image->columns*image->rows/100.0;
9856 white_point=(MagickRealType) image->columns*image->rows-
9859 if (attribute_flag[1] != 0)
9860 black_point=argument_list[1].real_reference;
9861 if (attribute_flag[2] != 0)
9862 white_point=argument_list[2].real_reference;
9863 if (attribute_flag[4] != 0)
9864 channel=(ChannelType) argument_list[4].integer_reference;
9865 PushPixelComponentMap(image,channel);
9866 (void) ContrastStretchImage(image,black_point,white_point);
9867 PopPixelComponentMap(image);
9870 case 96: /* Sans0 */
9874 case 97: /* Sans1 */
9878 case 98: /* AdaptiveSharpen */
9880 if (attribute_flag[0] != 0)
9882 flags=ParseGeometry(argument_list[0].string_reference,
9884 if ((flags & SigmaValue) == 0)
9885 geometry_info.sigma=1.0;
9887 if (attribute_flag[1] != 0)
9888 geometry_info.rho=argument_list[1].real_reference;
9889 if (attribute_flag[2] != 0)
9890 geometry_info.sigma=argument_list[2].real_reference;
9891 if (attribute_flag[3] != 0)
9892 channel=(ChannelType) argument_list[3].integer_reference;
9893 PushPixelComponentMap(image,channel);
9894 image=AdaptiveSharpenImage(image,geometry_info.rho,
9895 geometry_info.sigma,exception);
9896 if (image != (Image *) NULL)
9897 PopPixelComponentMap(image);
9900 case 99: /* Transpose */
9902 image=TransposeImage(image,exception);
9905 case 100: /* Tranverse */
9907 image=TransverseImage(image,exception);
9910 case 101: /* AutoOrient */
9912 switch (image->orientation)
9914 case TopRightOrientation:
9916 image=FlopImage(image,exception);
9919 case BottomRightOrientation:
9921 image=RotateImage(image,180.0,exception);
9924 case BottomLeftOrientation:
9926 image=FlipImage(image,exception);
9929 case LeftTopOrientation:
9931 image=TransposeImage(image,exception);
9934 case RightTopOrientation:
9936 image=RotateImage(image,90.0,exception);
9939 case RightBottomOrientation:
9941 image=TransverseImage(image,exception);
9944 case LeftBottomOrientation:
9946 image=RotateImage(image,270.0,exception);
9954 case 102: /* AdaptiveBlur */
9956 if (attribute_flag[0] != 0)
9958 flags=ParseGeometry(argument_list[0].string_reference,
9960 if ((flags & SigmaValue) == 0)
9961 geometry_info.sigma=1.0;
9963 if (attribute_flag[1] != 0)
9964 geometry_info.rho=argument_list[1].real_reference;
9965 if (attribute_flag[2] != 0)
9966 geometry_info.sigma=argument_list[2].real_reference;
9967 if (attribute_flag[3] != 0)
9968 channel=(ChannelType) argument_list[3].integer_reference;
9969 PushPixelComponentMap(image,channel);
9970 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
9972 if (image != (Image *) NULL)
9973 PopPixelComponentMap(image);
9976 case 103: /* Sketch */
9978 if (attribute_flag[0] != 0)
9980 flags=ParseGeometry(argument_list[0].string_reference,
9982 if ((flags & SigmaValue) == 0)
9983 geometry_info.sigma=1.0;
9984 if ((flags & XiValue) == 0)
9985 geometry_info.xi=1.0;
9987 if (attribute_flag[1] != 0)
9988 geometry_info.rho=argument_list[1].real_reference;
9989 if (attribute_flag[2] != 0)
9990 geometry_info.sigma=argument_list[2].real_reference;
9991 if (attribute_flag[3] != 0)
9992 geometry_info.xi=argument_list[3].real_reference;
9993 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
9994 geometry_info.xi,exception);
9997 case 104: /* UniqueColors */
9999 image=UniqueImageColors(image,exception);
10002 case 105: /* AdaptiveResize */
10004 if (attribute_flag[0] != 0)
10005 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10006 &geometry,exception);
10007 if (attribute_flag[1] != 0)
10008 geometry.width=argument_list[1].integer_reference;
10009 if (attribute_flag[2] != 0)
10010 geometry.height=argument_list[2].integer_reference;
10011 if (attribute_flag[3] != 0)
10012 image->filter=(FilterTypes) argument_list[4].integer_reference;
10013 if (attribute_flag[4] != 0)
10014 SetImageArtifact(image,"filter:support",
10015 argument_list[4].string_reference);
10016 if (attribute_flag[5] != 0)
10017 image->blur=argument_list[5].real_reference;
10018 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10022 case 106: /* ClipMask */
10024 if (attribute_flag[0] == 0)
10026 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10028 goto PerlException;
10030 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10031 MagickTrue,exception);
10032 (void) NegateImage(image->clip_mask,MagickFalse);
10035 case 107: /* LinearStretch */
10042 white_point=(MagickRealType) image->columns*image->rows;
10043 if (attribute_flag[0] != 0)
10045 flags=ParseGeometry(argument_list[0].string_reference,
10047 if ((flags & SigmaValue) != 0)
10048 white_point=geometry_info.sigma;
10049 if ((flags & PercentValue) != 0)
10051 black_point*=(double) image->columns*image->rows/100.0;
10052 white_point*=(double) image->columns*image->rows/100.0;
10054 if ((flags & SigmaValue) == 0)
10055 white_point=(double) image->columns*image->rows-black_point;
10057 if (attribute_flag[1] != 0)
10058 black_point=argument_list[1].real_reference;
10059 if (attribute_flag[2] != 0)
10060 white_point=argument_list[2].real_reference;
10061 (void) LinearStretchImage(image,black_point,white_point);
10064 case 109: /* Mask */
10066 if (attribute_flag[0] == 0)
10068 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10070 goto PerlException;
10072 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10073 MagickTrue,exception);
10074 (void) NegateImage(image->mask,MagickFalse);
10077 case 110: /* Polaroid */
10085 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10086 (DrawInfo *) NULL);
10087 if (attribute_flag[0] != 0)
10088 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10089 info ? info->image_info : (ImageInfo *) NULL,image,
10090 argument_list[0].string_reference));
10092 if (attribute_flag[1] != 0)
10093 angle=argument_list[1].real_reference;
10094 if (attribute_flag[2] != 0)
10095 (void) CloneString(&draw_info->font,
10096 argument_list[2].string_reference);
10097 if (attribute_flag[3] != 0)
10098 (void) QueryColorDatabase(argument_list[3].string_reference,
10099 &draw_info->stroke,exception);
10100 if (attribute_flag[4] != 0)
10101 (void) QueryColorDatabase(argument_list[4].string_reference,
10102 &draw_info->fill,exception);
10103 if (attribute_flag[5] != 0)
10104 draw_info->stroke_width=argument_list[5].real_reference;
10105 if (attribute_flag[6] != 0)
10106 draw_info->pointsize=argument_list[6].real_reference;
10107 if (attribute_flag[7] != 0)
10108 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10109 if (attribute_flag[8] != 0)
10110 (void) QueryColorDatabase(argument_list[8].string_reference,
10111 &image->background_color,exception);
10112 image=PolaroidImage(image,draw_info,angle,exception);
10113 draw_info=DestroyDrawInfo(draw_info);
10116 case 111: /* FloodfillPaint */
10127 draw_info=CloneDrawInfo(info ? info->image_info :
10128 (ImageInfo *) NULL,(DrawInfo *) NULL);
10129 if (attribute_flag[0] != 0)
10130 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10131 &geometry,exception);
10132 if (attribute_flag[1] != 0)
10133 geometry.x=argument_list[1].integer_reference;
10134 if (attribute_flag[2] != 0)
10135 geometry.y=argument_list[2].integer_reference;
10136 if (attribute_flag[3] != 0)
10137 (void) QueryColorDatabase(argument_list[3].string_reference,
10138 &draw_info->fill,exception);
10139 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10141 if (attribute_flag[4] != 0)
10142 QueryMagickColor(argument_list[4].string_reference,&target,
10144 if (attribute_flag[5] != 0)
10145 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10147 if (attribute_flag[6] != 0)
10148 channel=(ChannelType) argument_list[6].integer_reference;
10149 invert=MagickFalse;
10150 if (attribute_flag[7] != 0)
10151 invert=(MagickBooleanType) argument_list[7].integer_reference;
10152 PushPixelComponentMap(image,channel);
10153 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10154 geometry.y,invert);
10155 PopPixelComponentMap(image);
10156 draw_info=DestroyDrawInfo(draw_info);
10159 case 112: /* Distort */
10171 number_coordinates;
10176 if (attribute_flag[0] == 0)
10178 method=UndefinedDistortion;
10179 if (attribute_flag[1] != 0)
10180 method=(DistortImageMethod) argument_list[1].integer_reference;
10181 av=(AV *) argument_list[0].array_reference;
10182 number_coordinates=(size_t) av_len(av)+1;
10183 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10184 sizeof(*coordinates));
10185 if (coordinates == (double *) NULL)
10187 ThrowPerlException(exception,ResourceLimitFatalError,
10188 "MemoryAllocationFailed",PackageName);
10189 goto PerlException;
10191 for (j=0; j < (ssize_t) number_coordinates; j++)
10192 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10193 virtual_pixel=UndefinedVirtualPixelMethod;
10194 if (attribute_flag[2] != 0)
10195 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10196 argument_list[2].integer_reference);
10197 image=DistortImage(image,method,number_coordinates,coordinates,
10198 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10200 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10201 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10202 coordinates=(double *) RelinquishMagickMemory(coordinates);
10205 case 113: /* Clut */
10207 if (attribute_flag[0] == 0)
10209 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10211 goto PerlException;
10213 if (attribute_flag[1] != 0)
10214 channel=(ChannelType) argument_list[1].integer_reference;
10215 PushPixelComponentMap(image,channel);
10216 (void) ClutImage(image,argument_list[0].image_reference);
10217 PopPixelComponentMap(image);
10220 case 114: /* LiquidRescale */
10222 if (attribute_flag[0] != 0)
10223 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10224 &geometry,exception);
10225 if (attribute_flag[1] != 0)
10226 geometry.width=argument_list[1].integer_reference;
10227 if (attribute_flag[2] != 0)
10228 geometry.height=argument_list[2].integer_reference;
10229 if (attribute_flag[3] == 0)
10230 argument_list[3].real_reference=1.0;
10231 if (attribute_flag[4] == 0)
10232 argument_list[4].real_reference=0.0;
10233 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10234 argument_list[3].real_reference,argument_list[4].real_reference,
10238 case 115: /* EncipherImage */
10240 (void) EncipherImage(image,argument_list[0].string_reference,
10244 case 116: /* DecipherImage */
10246 (void) DecipherImage(image,argument_list[0].string_reference,
10250 case 117: /* Deskew */
10252 geometry_info.rho=QuantumRange/2.0;
10253 if (attribute_flag[0] != 0)
10254 flags=ParseGeometry(argument_list[0].string_reference,
10256 if (attribute_flag[1] != 0)
10257 geometry_info.rho=SiPrefixToDouble(
10258 argument_list[1].string_reference,QuantumRange);
10259 image=DeskewImage(image,geometry_info.rho,exception);
10262 case 118: /* Remap */
10267 if (attribute_flag[0] == 0)
10269 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10271 goto PerlException;
10273 quantize_info=AcquireQuantizeInfo(info->image_info);
10274 if (attribute_flag[1] != 0)
10275 quantize_info->dither=(MagickBooleanType)
10276 argument_list[1].integer_reference;
10277 if (attribute_flag[2] != 0)
10278 quantize_info->dither_method=(DitherMethod)
10279 argument_list[2].integer_reference;
10280 (void) RemapImages(quantize_info,image,
10281 argument_list[0].image_reference);
10282 quantize_info=DestroyQuantizeInfo(quantize_info);
10285 case 119: /* SparseColor */
10297 number_coordinates;
10302 if (attribute_flag[0] == 0)
10304 method=UndefinedColorInterpolate;
10305 if (attribute_flag[1] != 0)
10306 method=(SparseColorMethod) argument_list[1].integer_reference;
10307 av=(AV *) argument_list[0].array_reference;
10308 number_coordinates=(size_t) av_len(av)+1;
10309 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10310 sizeof(*coordinates));
10311 if (coordinates == (double *) NULL)
10313 ThrowPerlException(exception,ResourceLimitFatalError,
10314 "MemoryAllocationFailed",PackageName);
10315 goto PerlException;
10317 for (j=0; j < (ssize_t) number_coordinates; j++)
10318 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10319 virtual_pixel=UndefinedVirtualPixelMethod;
10320 if (attribute_flag[2] != 0)
10321 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10322 argument_list[2].integer_reference);
10323 if (attribute_flag[3] != 0)
10324 channel=(ChannelType) argument_list[3].integer_reference;
10325 PushPixelComponentMap(image,channel);
10326 image=SparseColorImage(image,method,number_coordinates,coordinates,
10328 if (image != (Image *) NULL)
10329 PopPixelComponentMap(image);
10330 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10331 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10332 coordinates=(double *) RelinquishMagickMemory(coordinates);
10335 case 120: /* Function */
10352 if (attribute_flag[0] == 0)
10354 function=UndefinedFunction;
10355 if (attribute_flag[1] != 0)
10356 function=(MagickFunction) argument_list[1].integer_reference;
10357 av=(AV *) argument_list[0].array_reference;
10358 number_parameters=(size_t) av_len(av)+1;
10359 parameters=(double *) AcquireQuantumMemory(number_parameters,
10360 sizeof(*parameters));
10361 if (parameters == (double *) NULL)
10363 ThrowPerlException(exception,ResourceLimitFatalError,
10364 "MemoryAllocationFailed",PackageName);
10365 goto PerlException;
10367 for (j=0; j < (ssize_t) number_parameters; j++)
10368 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10369 virtual_pixel=UndefinedVirtualPixelMethod;
10370 if (attribute_flag[2] != 0)
10371 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10372 argument_list[2].integer_reference);
10373 (void) FunctionImage(image,function,number_parameters,parameters,
10375 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10376 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10377 parameters=(double *) RelinquishMagickMemory(parameters);
10380 case 121: /* SelectiveBlur */
10382 if (attribute_flag[0] != 0)
10384 flags=ParseGeometry(argument_list[0].string_reference,
10386 if ((flags & SigmaValue) == 0)
10387 geometry_info.sigma=1.0;
10388 if ((flags & PercentValue) != 0)
10389 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10391 if (attribute_flag[1] != 0)
10392 geometry_info.rho=argument_list[1].real_reference;
10393 if (attribute_flag[2] != 0)
10394 geometry_info.sigma=argument_list[2].real_reference;
10395 if (attribute_flag[3] != 0)
10396 geometry_info.xi=argument_list[3].integer_reference;;
10397 if (attribute_flag[4] != 0)
10398 channel=(ChannelType) argument_list[4].integer_reference;
10399 PushPixelComponentMap(image,channel);
10400 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10401 geometry_info.xi,exception);
10402 if (image != (Image *) NULL)
10403 PopPixelComponentMap(image);
10406 case 122: /* HaldClut */
10408 if (attribute_flag[0] == 0)
10410 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10412 goto PerlException;
10414 if (attribute_flag[1] != 0)
10415 channel=(ChannelType) argument_list[1].integer_reference;
10416 PushPixelComponentMap(image,channel);
10417 (void) HaldClutImage(image,argument_list[0].image_reference);
10418 PopPixelComponentMap(image);
10421 case 123: /* BlueShift */
10423 if (attribute_flag[0] != 0)
10424 (void) ParseGeometry(argument_list[0].string_reference,
10426 image=BlueShiftImage(image,geometry_info.rho,exception);
10429 case 124: /* ForwardFourierTransformImage */
10431 image=ForwardFourierTransformImage(image,
10432 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10436 case 125: /* InverseFourierTransformImage */
10438 image=InverseFourierTransformImage(image,image->next,
10439 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10443 case 126: /* ColorDecisionList */
10445 if (attribute_flag[0] == 0)
10446 argument_list[0].string_reference=(char *) NULL;
10447 (void) ColorDecisionListImage(image,
10448 argument_list[0].string_reference);
10451 case 127: /* AutoGamma */
10453 if (attribute_flag[0] != 0)
10454 channel=(ChannelType) argument_list[0].integer_reference;
10455 PushPixelComponentMap(image,channel);
10456 (void) AutoGammaImage(image);
10457 PopPixelComponentMap(image);
10460 case 128: /* AutoLevel */
10462 if (attribute_flag[0] != 0)
10463 channel=(ChannelType) argument_list[0].integer_reference;
10464 PushPixelComponentMap(image,channel);
10465 (void) AutoLevelImage(image);
10466 PopPixelComponentMap(image);
10469 case 129: /* LevelColors */
10475 (void) QueryMagickColor("#000000",&black_point,exception);
10476 (void) QueryMagickColor("#ffffff",&white_point,exception);
10477 if (attribute_flag[1] != 0)
10478 (void) QueryMagickColor(argument_list[1].string_reference,
10479 &black_point,exception);
10480 if (attribute_flag[2] != 0)
10481 (void) QueryMagickColor(argument_list[2].string_reference,
10482 &white_point,exception);
10483 if (attribute_flag[3] != 0)
10484 channel=(ChannelType) argument_list[3].integer_reference;
10485 PushPixelComponentMap(image,channel);
10486 (void) LevelImageColors(image,&black_point,&white_point,
10487 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
10488 PopPixelComponentMap(image);
10491 case 130: /* Clamp */
10493 if (attribute_flag[0] != 0)
10494 channel=(ChannelType) argument_list[0].integer_reference;
10495 PushPixelComponentMap(image,channel);
10496 (void) ClampImage(image);
10497 PopPixelComponentMap(image);
10500 case 131: /* Filter */
10505 if (attribute_flag[0] == 0)
10507 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10508 if (kernel == (KernelInfo *) NULL)
10510 if (attribute_flag[1] != 0)
10511 channel=(ChannelType) argument_list[1].integer_reference;
10512 if (attribute_flag[2] != 0)
10513 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
10515 PushPixelComponentMap(image,channel);
10516 image=FilterImage(image,kernel,exception);
10517 if (image != (Image *) NULL)
10518 PopPixelComponentMap(image);
10519 kernel=DestroyKernelInfo(kernel);
10522 case 132: /* BrightnessContrast */
10530 if (attribute_flag[0] != 0)
10532 flags=ParseGeometry(argument_list[0].string_reference,
10534 brightness=geometry_info.rho;
10535 if ((flags & SigmaValue) == 0)
10536 contrast=geometry_info.sigma;
10538 if (attribute_flag[1] != 0)
10539 brightness=argument_list[1].real_reference;
10540 if (attribute_flag[2] != 0)
10541 contrast=argument_list[2].real_reference;
10542 if (attribute_flag[4] != 0)
10543 channel=(ChannelType) argument_list[4].integer_reference;
10544 PushPixelComponentMap(image,channel);
10545 (void) BrightnessContrastImage(image,brightness,contrast);
10546 PopPixelComponentMap(image);
10549 case 133: /* Morphology */
10560 if (attribute_flag[0] == 0)
10562 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10563 if (kernel == (KernelInfo *) NULL)
10565 if (attribute_flag[1] != 0)
10566 channel=(ChannelType) argument_list[1].integer_reference;
10567 method=UndefinedMorphology;
10568 if (attribute_flag[2] != 0)
10569 method=argument_list[2].integer_reference;
10571 if (attribute_flag[3] != 0)
10572 iterations=argument_list[4].integer_reference;
10573 PushPixelComponentMap(image,channel);
10574 image=MorphologyImage(image,method,iterations,kernel,exception);
10575 if (image != (Image *) NULL)
10576 PopPixelComponentMap(image);
10577 kernel=DestroyKernelInfo(kernel);
10580 case 108: /* Recolor */
10581 case 134: /* ColorMatrix */
10595 if (attribute_flag[0] == 0)
10597 av=(AV *) argument_list[0].array_reference;
10598 order=(size_t) sqrt(av_len(av)+1);
10599 color_matrix=(double *) AcquireQuantumMemory(order,order*
10600 sizeof(*color_matrix));
10601 if (color_matrix == (double *) NULL)
10603 ThrowPerlException(exception,ResourceLimitFatalError,
10604 "MemoryAllocationFailed",PackageName);
10605 goto PerlException;
10607 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10608 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10609 for ( ; j < (ssize_t) (order*order); j++)
10610 color_matrix[j]=0.0;
10611 kernel_info=AcquireKernelInfo("1");
10612 if (kernel_info == (KernelInfo *) NULL)
10614 kernel_info->width=order;
10615 kernel_info->height=order;
10616 kernel_info->values=color_matrix;
10617 image=ColorMatrixImage(image,kernel_info,exception);
10618 kernel_info->values=(double *) NULL;
10619 kernel_info=DestroyKernelInfo(kernel_info);
10620 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10623 case 135: /* Color */
10628 (void) QueryMagickColor("none",&color,exception);
10629 if (attribute_flag[0] != 0)
10630 (void) QueryMagickColor(argument_list[0].string_reference,
10632 (void) SetImageColor(image,&color);
10635 case 136: /* Mode */
10637 if (attribute_flag[0] != 0)
10639 flags=ParseGeometry(argument_list[0].string_reference,
10641 if ((flags & SigmaValue) == 0)
10642 geometry_info.sigma=1.0;
10644 if (attribute_flag[1] != 0)
10645 geometry_info.rho=argument_list[1].real_reference;
10646 if (attribute_flag[2] != 0)
10647 geometry_info.sigma=argument_list[2].real_reference;
10648 if (attribute_flag[3] != 0)
10649 channel=(ChannelType) argument_list[3].integer_reference;
10650 PushPixelComponentMap(image,channel);
10651 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10652 (size_t) geometry_info.sigma,exception);
10653 if (image != (Image *) NULL)
10654 PopPixelComponentMap(image);
10657 case 137: /* Statistic */
10662 statistic=UndefinedStatistic;
10663 if (attribute_flag[0] != 0)
10665 flags=ParseGeometry(argument_list[0].string_reference,
10667 if ((flags & SigmaValue) == 0)
10668 geometry_info.sigma=1.0;
10670 if (attribute_flag[1] != 0)
10671 geometry_info.rho=argument_list[1].real_reference;
10672 if (attribute_flag[2] != 0)
10673 geometry_info.sigma=argument_list[2].real_reference;
10674 if (attribute_flag[3] != 0)
10675 channel=(ChannelType) argument_list[3].integer_reference;
10676 if (attribute_flag[4] != 0)
10677 statistic=(StatisticType) argument_list[4].integer_reference;
10678 PushPixelComponentMap(image,channel);
10679 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10680 (size_t) geometry_info.sigma,exception);
10681 if (image != (Image *) NULL)
10682 PopPixelComponentMap(image);
10686 if (next != (Image *) NULL)
10687 (void) CatchImageException(next);
10688 if (region_image != (Image *) NULL)
10693 status=CompositeImage(region_image,CopyCompositeOp,image,
10694 region_info.x,region_info.y);
10696 (void) CatchImageException(region_image);
10697 image=DestroyImage(image);
10698 image=region_image;
10700 if (image != (Image *) NULL)
10703 if (next && (next != image))
10705 image->next=next->next;
10706 DeleteImageFromRegistry(*pv,next);
10708 sv_setiv(*pv,(IV) image);
10716 if (reference_vector)
10717 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10718 InheritPerlException(exception,perl_exception);
10719 exception=DestroyExceptionInfo(exception);
10720 sv_setiv(perl_exception,(IV) number_images);
10721 SvPOK_on(perl_exception);
10722 ST(0)=sv_2mortal(perl_exception);
10727 ###############################################################################
10735 ###############################################################################
10740 Image::Magick ref=NO_INIT
10785 PERL_UNUSED_VAR(ref);
10786 PERL_UNUSED_VAR(ix);
10787 exception=AcquireExceptionInfo();
10788 perl_exception=newSVpv("",0);
10791 if (sv_isobject(ST(0)) == 0)
10793 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10795 goto PerlException;
10797 reference=SvRV(ST(0));
10798 hv=SvSTASH(reference);
10800 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10802 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10803 if (image == (Image *) NULL)
10805 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10807 goto PerlException;
10812 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10813 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10814 (void) QueryMagickColor("none",&transparent_color,exception);
10815 for (i=2; i < items; i+=2)
10817 attribute=(char *) SvPV(ST(i-1),na);
10818 switch (*attribute)
10823 if (LocaleCompare(attribute,"background") == 0)
10825 (void) QueryColorDatabase(SvPV(ST(i),na),
10826 &montage_info->background_color,exception);
10827 for (next=image; next; next=next->next)
10828 next->background_color=montage_info->background_color;
10831 if (LocaleCompare(attribute,"border") == 0)
10833 montage_info->border_width=SvIV(ST(i));
10836 if (LocaleCompare(attribute,"bordercolor") == 0)
10838 (void) QueryColorDatabase(SvPV(ST(i),na),
10839 &montage_info->border_color,exception);
10840 for (next=image; next; next=next->next)
10841 next->border_color=montage_info->border_color;
10844 if (LocaleCompare(attribute,"borderwidth") == 0)
10846 montage_info->border_width=SvIV(ST(i));
10849 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10856 if (LocaleCompare(attribute,"compose") == 0)
10858 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10859 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10862 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10866 for (next=image; next; next=next->next)
10867 next->compose=(CompositeOperator) sp;
10870 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10877 if (LocaleCompare(attribute,"fill") == 0)
10879 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10883 if (LocaleCompare(attribute,"font") == 0)
10885 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10888 if (LocaleCompare(attribute,"frame") == 0)
10894 if (IsGeometry(p) == MagickFalse)
10896 ThrowPerlException(exception,OptionError,"MissingGeometry",
10900 (void) CloneString(&montage_info->frame,p);
10902 montage_info->frame=(char *) NULL;
10905 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10912 if (LocaleCompare(attribute,"geometry") == 0)
10918 if (IsGeometry(p) == MagickFalse)
10920 ThrowPerlException(exception,OptionError,"MissingGeometry",
10924 (void) CloneString(&montage_info->geometry,p);
10926 montage_info->geometry=(char *) NULL;
10929 if (LocaleCompare(attribute,"gravity") == 0)
10934 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10935 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10938 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10942 montage_info->gravity=(GravityType) in;
10943 for (next=image; next; next=next->next)
10944 next->gravity=(GravityType) in;
10947 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10954 if (LocaleCompare(attribute,"label") == 0)
10956 for (next=image; next; next=next->next)
10957 (void) SetImageProperty(next,"label",InterpretImageProperties(
10958 info ? info->image_info : (ImageInfo *) NULL,next,
10962 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10969 if (LocaleCompare(attribute,"mattecolor") == 0)
10971 (void) QueryColorDatabase(SvPV(ST(i),na),
10972 &montage_info->matte_color,exception);
10973 for (next=image; next; next=next->next)
10974 next->matte_color=montage_info->matte_color;
10977 if (LocaleCompare(attribute,"mode") == 0)
10982 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10983 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10988 ThrowPerlException(exception,OptionError,
10989 "UnrecognizedModeType",SvPV(ST(i),na));
10994 (void) CloneString(&montage_info->frame,"15x15+3+3");
10995 montage_info->shadow=MagickTrue;
11000 montage_info->frame=(char *) NULL;
11001 montage_info->shadow=MagickFalse;
11002 montage_info->border_width=0;
11005 case ConcatenateMode:
11007 montage_info->frame=(char *) NULL;
11008 montage_info->shadow=MagickFalse;
11009 (void) CloneString(&montage_info->geometry,"+0+0");
11010 montage_info->border_width=0;
11015 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11022 if (LocaleCompare(attribute,"pointsize") == 0)
11024 montage_info->pointsize=SvIV(ST(i));
11027 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11034 if (LocaleCompare(attribute,"shadow") == 0)
11036 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11037 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11040 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11044 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11047 if (LocaleCompare(attribute,"stroke") == 0)
11049 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11053 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11060 if (LocaleCompare(attribute,"texture") == 0)
11062 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11065 if (LocaleCompare(attribute,"tile") == 0)
11067 char *p=SvPV(ST(i),na);
11068 if (IsGeometry(p) == MagickFalse)
11070 ThrowPerlException(exception,OptionError,"MissingGeometry",
11074 (void) CloneString(&montage_info->tile,p);
11076 montage_info->tile=(char *) NULL;
11079 if (LocaleCompare(attribute,"title") == 0)
11081 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11084 if (LocaleCompare(attribute,"transparent") == 0)
11089 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11090 for (next=image; next; next=next->next)
11091 (void) TransparentPaintImage(next,&transparent_color,
11092 TransparentAlpha,MagickFalse);
11095 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11101 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11107 image=MontageImageList(info->image_info,montage_info,image,exception);
11108 montage_info=DestroyMontageInfo(montage_info);
11109 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11110 goto PerlException;
11111 if (transparent_color.alpha != TransparentAlpha)
11112 for (next=image; next; next=next->next)
11113 (void) TransparentPaintImage(next,&transparent_color,
11114 TransparentAlpha,MagickFalse);
11115 for ( ; image; image=image->next)
11117 AddImageToRegistry(sv,image);
11119 av_push(av,sv_bless(rv,hv));
11122 exception=DestroyExceptionInfo(exception);
11123 ST(0)=av_reference;
11124 SvREFCNT_dec(perl_exception);
11128 InheritPerlException(exception,perl_exception);
11129 exception=DestroyExceptionInfo(exception);
11130 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11131 SvPOK_on(perl_exception);
11132 ST(0)=sv_2mortal(perl_exception);
11137 ###############################################################################
11145 ###############################################################################
11150 Image::Magick ref=NO_INIT
11188 PERL_UNUSED_VAR(ref);
11189 PERL_UNUSED_VAR(ix);
11190 exception=AcquireExceptionInfo();
11191 perl_exception=newSVpv("",0);
11195 if (sv_isobject(ST(0)) == 0)
11197 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11199 goto PerlException;
11201 reference=SvRV(ST(0));
11202 hv=SvSTASH(reference);
11204 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11206 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11207 if (image == (Image *) NULL)
11209 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11211 goto PerlException;
11213 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11218 for (i=2; i < items; i+=2)
11220 attribute=(char *) SvPV(ST(i-1),na);
11221 switch (*attribute)
11226 if (LocaleCompare(attribute,"frames") == 0)
11228 number_frames=SvIV(ST(i));
11231 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11237 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11243 image=MorphImages(image,number_frames,exception);
11244 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11245 goto PerlException;
11246 for ( ; image; image=image->next)
11248 AddImageToRegistry(sv,image);
11250 av_push(av,sv_bless(rv,hv));
11253 exception=DestroyExceptionInfo(exception);
11254 ST(0)=av_reference;
11255 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11259 InheritPerlException(exception,perl_exception);
11260 exception=DestroyExceptionInfo(exception);
11261 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11262 SvPOK_on(perl_exception);
11263 ST(0)=sv_2mortal(perl_exception);
11268 ###############################################################################
11276 ###############################################################################
11281 Image::Magick ref=NO_INIT
11309 PERL_UNUSED_VAR(ref);
11310 PERL_UNUSED_VAR(ix);
11311 exception=AcquireExceptionInfo();
11312 perl_exception=newSVpv("",0);
11314 if (sv_isobject(ST(0)) == 0)
11316 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11318 goto PerlException;
11320 reference=SvRV(ST(0));
11321 hv=SvSTASH(reference);
11322 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11323 if (image == (Image *) NULL)
11325 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11327 goto PerlException;
11329 image=MergeImageLayers(image,MosaicLayer,exception);
11331 Create blessed Perl array for the returned image.
11334 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11336 AddImageToRegistry(sv,image);
11338 av_push(av,sv_bless(rv,hv));
11340 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11341 (void) CopyMagickString(image->filename,info->image_info->filename,
11343 SetImageInfo(info->image_info,0,&image->exception);
11344 exception=DestroyExceptionInfo(exception);
11345 SvREFCNT_dec(perl_exception);
11349 InheritPerlException(exception,perl_exception);
11350 exception=DestroyExceptionInfo(exception);
11351 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11352 SvPOK_on(perl_exception); /* return messages in string context */
11353 ST(0)=sv_2mortal(perl_exception);
11358 ###############################################################################
11366 ###############################################################################
11371 Image::Magick ref=NO_INIT
11421 PERL_UNUSED_VAR(ref);
11422 PERL_UNUSED_VAR(ix);
11423 exception=AcquireExceptionInfo();
11424 perl_exception=newSVpv("",0);
11425 package_info=(struct PackageInfo *) NULL;
11426 ac=(items < 2) ? 1 : items-1;
11427 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11429 length=(STRLEN *) NULL;
11430 if (list == (char **) NULL)
11432 ThrowPerlException(exception,ResourceLimitError,
11433 "MemoryAllocationFailed",PackageName);
11434 goto PerlException;
11437 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11438 if (length == (STRLEN *) NULL)
11440 ThrowPerlException(exception,ResourceLimitError,
11441 "MemoryAllocationFailed",PackageName);
11442 goto PerlException;
11444 if (sv_isobject(ST(0)) == 0)
11446 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11448 goto PerlException;
11450 reference=SvRV(ST(0));
11451 if (SvTYPE(reference) != SVt_PVAV)
11453 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11455 goto PerlException;
11457 av=(AV *) reference;
11458 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11460 package_info=ClonePackageInfo(info,exception);
11463 *list=(char *) (*package_info->image_info->filename ?
11464 package_info->image_info->filename : "XC:black");
11466 for (n=0, i=0; i < ac; i++)
11468 list[n]=(char *) SvPV(ST(i+1),length[n]);
11469 if ((items >= 3) && strEQcase(list[n],"blob"))
11475 blob=(void *) (SvPV(ST(i+1),length[n]));
11476 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11478 if ((items >= 3) && strEQcase(list[n],"filename"))
11480 if ((items >= 3) && strEQcase(list[n],"file"))
11489 io_info=IoIFP(sv_2io(ST(i+1)));
11490 if (io_info == (PerlIO *) NULL)
11492 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11496 file=PerlIO_findFILE(io_info);
11497 if (file == (FILE *) NULL)
11499 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11503 SetImageInfoFile(package_info->image_info,file);
11505 if ((items >= 3) && strEQcase(list[n],"magick"))
11509 list[n]=(char *) NULL;
11511 status=ExpandFilenames(&n,&list);
11512 if (status == MagickFalse)
11514 ThrowPerlException(exception,ResourceLimitError,
11515 "MemoryAllocationFailed",PackageName);
11516 goto PerlException;
11519 for (i=0; i < n; i++)
11521 (void) CopyMagickString(package_info->image_info->filename,list[i],
11523 image=PingImage(package_info->image_info,exception);
11524 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11526 if ((package_info->image_info->file != (FILE *) NULL) ||
11527 (package_info->image_info->blob != (void *) NULL))
11528 DisassociateImageStream(image);
11529 count+=GetImageListLength(image);
11530 EXTEND(sp,4*count);
11531 for (next=image; next; next=next->next)
11533 PUSHs(sv_2mortal(newSViv(next->columns)));
11534 PUSHs(sv_2mortal(newSViv(next->rows)));
11535 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11536 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11538 image=DestroyImageList(image);
11543 for (i=0; i < n; i++)
11544 if (list[i] != (char *) NULL)
11545 for (p=keep; list[i] != *p++; )
11548 list[i]=(char *) RelinquishMagickMemory(list[i]);
11553 if (package_info != (struct PackageInfo *) NULL)
11554 DestroyPackageInfo(package_info);
11555 if (list && (list != keep))
11556 list=(char **) RelinquishMagickMemory(list);
11558 keep=(char **) RelinquishMagickMemory(keep);
11560 length=(STRLEN *) RelinquishMagickMemory(length);
11561 InheritPerlException(exception,perl_exception);
11562 exception=DestroyExceptionInfo(exception);
11563 SvREFCNT_dec(perl_exception); /* throw away all errors */
11567 ###############################################################################
11575 ###############################################################################
11580 Image::Magick ref=NO_INIT
11613 PERL_UNUSED_VAR(ref);
11614 PERL_UNUSED_VAR(ix);
11615 exception=AcquireExceptionInfo();
11616 perl_exception=newSVpv("",0);
11619 if (sv_isobject(ST(0)) == 0)
11621 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11623 goto PerlException;
11625 reference=SvRV(ST(0));
11626 hv=SvSTASH(reference);
11628 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11630 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11631 if (image == (Image *) NULL)
11633 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11635 goto PerlException;
11637 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11638 preview_type=GammaPreview;
11640 preview_type=(PreviewType)
11641 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11642 for ( ; image; image=image->next)
11644 preview_image=PreviewImage(image,preview_type,exception);
11645 if (preview_image == (Image *) NULL)
11646 goto PerlException;
11647 AddImageToRegistry(sv,preview_image);
11649 av_push(av,sv_bless(rv,hv));
11652 exception=DestroyExceptionInfo(exception);
11653 ST(0)=av_reference;
11654 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11658 InheritPerlException(exception,perl_exception);
11659 exception=DestroyExceptionInfo(exception);
11660 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11661 SvPOK_on(perl_exception);
11662 ST(0)=sv_2mortal(perl_exception);
11667 ###############################################################################
11671 # Q u e r y C o l o r #
11675 ###############################################################################
11679 QueryColor(ref,...)
11680 Image::Magick ref=NO_INIT
11700 PERL_UNUSED_VAR(ref);
11701 PERL_UNUSED_VAR(ix);
11702 exception=AcquireExceptionInfo();
11703 perl_exception=newSVpv("",0);
11712 colorlist=GetColorInfoList("*",&colors,exception);
11714 for (i=0; i < (ssize_t) colors; i++)
11716 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11718 colorlist=(const ColorInfo **)
11719 RelinquishMagickMemory((ColorInfo **) colorlist);
11720 goto PerlException;
11722 EXTEND(sp,5*items);
11723 for (i=1; i < items; i++)
11725 name=(char *) SvPV(ST(i),na);
11726 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11731 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11732 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11733 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11734 if (color.colorspace == CMYKColorspace)
11735 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11736 if (color.matte != MagickFalse)
11737 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11741 InheritPerlException(exception,perl_exception);
11742 exception=DestroyExceptionInfo(exception);
11743 SvREFCNT_dec(perl_exception);
11747 ###############################################################################
11751 # Q u e r y C o l o r N a m e #
11755 ###############################################################################
11759 QueryColorname(ref,...)
11760 Image::Magick ref=NO_INIT
11769 message[MaxTextExtent];
11788 *reference; /* reference is the SV* of ref=SvIV(reference) */
11790 PERL_UNUSED_VAR(ref);
11791 PERL_UNUSED_VAR(ix);
11792 exception=AcquireExceptionInfo();
11793 perl_exception=newSVpv("",0);
11794 reference=SvRV(ST(0));
11795 av=(AV *) reference;
11796 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11798 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11799 if (image == (Image *) NULL)
11801 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11803 goto PerlException;
11806 for (i=1; i < items; i++)
11808 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11809 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11811 PUSHs(sv_2mortal(newSVpv(message,0)));
11815 InheritPerlException(exception,perl_exception);
11816 exception=DestroyExceptionInfo(exception);
11817 SvREFCNT_dec(perl_exception);
11821 ###############################################################################
11825 # Q u e r y F o n t #
11829 ###############################################################################
11834 Image::Magick ref=NO_INIT
11841 message[MaxTextExtent];
11852 volatile const TypeInfo
11855 PERL_UNUSED_VAR(ref);
11856 PERL_UNUSED_VAR(ix);
11857 exception=AcquireExceptionInfo();
11858 perl_exception=newSVpv("",0);
11867 typelist=GetTypeInfoList("*",&types,exception);
11869 for (i=0; i < (ssize_t) types; i++)
11871 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11873 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11875 goto PerlException;
11877 EXTEND(sp,10*items);
11878 for (i=1; i < items; i++)
11880 name=(char *) SvPV(ST(i),na);
11881 type_info=GetTypeInfo(name,exception);
11882 if (type_info == (TypeInfo *) NULL)
11887 if (type_info->name == (char *) NULL)
11890 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11891 if (type_info->description == (char *) NULL)
11894 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11895 if (type_info->family == (char *) NULL)
11898 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11899 if (type_info->style == UndefinedStyle)
11902 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11903 type_info->style),0)));
11904 if (type_info->stretch == UndefinedStretch)
11907 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11908 type_info->stretch),0)));
11909 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11910 type_info->weight);
11911 PUSHs(sv_2mortal(newSVpv(message,0)));
11912 if (type_info->encoding == (char *) NULL)
11915 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11916 if (type_info->foundry == (char *) NULL)
11919 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11920 if (type_info->format == (char *) NULL)
11923 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11924 if (type_info->metrics == (char *) NULL)
11927 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11928 if (type_info->glyphs == (char *) NULL)
11931 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11935 InheritPerlException(exception,perl_exception);
11936 exception=DestroyExceptionInfo(exception);
11937 SvREFCNT_dec(perl_exception);
11941 ###############################################################################
11945 # Q u e r y F o n t M e t r i c s #
11949 ###############################################################################
11953 QueryFontMetrics(ref,...)
11954 Image::Magick ref=NO_INIT
11956 queryfontmetrics = 1
12003 *reference; /* reference is the SV* of ref=SvIV(reference) */
12008 PERL_UNUSED_VAR(ref);
12009 PERL_UNUSED_VAR(ix);
12010 exception=AcquireExceptionInfo();
12011 package_info=(struct PackageInfo *) NULL;
12012 perl_exception=newSVpv("",0);
12013 reference=SvRV(ST(0));
12014 av=(AV *) reference;
12015 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12017 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12018 if (image == (Image *) NULL)
12020 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12022 goto PerlException;
12024 package_info=ClonePackageInfo(info,exception);
12025 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12026 CloneString(&draw_info->text,"");
12027 current=draw_info->affine;
12028 GetAffineMatrix(&affine);
12031 EXTEND(sp,7*items);
12032 for (i=2; i < items; i+=2)
12034 attribute=(char *) SvPV(ST(i-1),na);
12035 switch (*attribute)
12040 if (LocaleCompare(attribute,"antialias") == 0)
12042 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12046 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12050 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12053 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12060 if (LocaleCompare(attribute,"density") == 0)
12062 CloneString(&draw_info->density,SvPV(ST(i),na));
12065 if (LocaleCompare(attribute,"direction") == 0)
12067 draw_info->direction=(DirectionType) ParseCommandOption(
12068 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12071 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12078 if (LocaleCompare(attribute,"encoding") == 0)
12080 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12083 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12090 if (LocaleCompare(attribute,"family") == 0)
12092 CloneString(&draw_info->family,SvPV(ST(i),na));
12095 if (LocaleCompare(attribute,"fill") == 0)
12098 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12099 &image->exception);
12102 if (LocaleCompare(attribute,"font") == 0)
12104 CloneString(&draw_info->font,SvPV(ST(i),na));
12107 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12114 if (LocaleCompare(attribute,"geometry") == 0)
12116 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12119 if (LocaleCompare(attribute,"gravity") == 0)
12121 draw_info->gravity=(GravityType) ParseCommandOption(
12122 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12125 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12132 if (LocaleCompare(attribute,"interline-spacing") == 0)
12134 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12135 draw_info->interline_spacing=geometry_info.rho;
12138 if (LocaleCompare(attribute,"interword-spacing") == 0)
12140 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12141 draw_info->interword_spacing=geometry_info.rho;
12144 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12151 if (LocaleCompare(attribute,"kerning") == 0)
12153 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12154 draw_info->kerning=geometry_info.rho;
12157 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12164 if (LocaleCompare(attribute,"pointsize") == 0)
12166 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12167 draw_info->pointsize=geometry_info.rho;
12170 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12177 if (LocaleCompare(attribute,"rotate") == 0)
12179 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12180 affine.rx=geometry_info.rho;
12181 affine.ry=geometry_info.sigma;
12182 if ((flags & SigmaValue) == 0)
12183 affine.ry=affine.rx;
12186 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12193 if (LocaleCompare(attribute,"scale") == 0)
12195 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12196 affine.sx=geometry_info.rho;
12197 affine.sy=geometry_info.sigma;
12198 if ((flags & SigmaValue) == 0)
12199 affine.sy=affine.sx;
12202 if (LocaleCompare(attribute,"skew") == 0)
12208 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12209 x_angle=geometry_info.rho;
12210 y_angle=geometry_info.sigma;
12211 if ((flags & SigmaValue) == 0)
12213 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12214 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12217 if (LocaleCompare(attribute,"stroke") == 0)
12220 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12221 &image->exception);
12224 if (LocaleCompare(attribute,"style") == 0)
12226 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12230 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12234 draw_info->style=(StyleType) type;
12237 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12244 if (LocaleCompare(attribute,"text") == 0)
12246 CloneString(&draw_info->text,SvPV(ST(i),na));
12249 if (LocaleCompare(attribute,"translate") == 0)
12251 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12252 affine.tx=geometry_info.rho;
12253 affine.ty=geometry_info.sigma;
12254 if ((flags & SigmaValue) == 0)
12255 affine.ty=affine.tx;
12258 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12265 if (LocaleCompare(attribute,"weight") == 0)
12267 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12268 draw_info->weight=(size_t) geometry_info.rho;
12271 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12278 if (LocaleCompare(attribute,"x") == 0)
12280 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12281 x=geometry_info.rho;
12284 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12291 if (LocaleCompare(attribute,"y") == 0)
12293 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12294 y=geometry_info.rho;
12297 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12303 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12309 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12310 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12311 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12312 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12313 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12314 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12315 if (draw_info->geometry == (char *) NULL)
12317 draw_info->geometry=AcquireString((char *) NULL);
12318 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12319 "%.15g,%.15g",x,y);
12321 status=GetTypeMetrics(image,draw_info,&metrics);
12322 (void) CatchImageException(image);
12323 if (status == MagickFalse)
12327 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12328 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12329 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12330 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12331 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12332 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12333 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12334 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12335 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12336 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12337 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12338 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12339 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12341 draw_info=DestroyDrawInfo(draw_info);
12344 if (package_info != (struct PackageInfo *) NULL)
12345 DestroyPackageInfo(package_info);
12346 InheritPerlException(exception,perl_exception);
12347 exception=DestroyExceptionInfo(exception);
12348 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12352 ###############################################################################
12356 # 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 #
12360 ###############################################################################
12364 QueryMultilineFontMetrics(ref,...)
12365 Image::Magick ref=NO_INIT
12367 querymultilinefontmetrics = 1
12414 *reference; /* reference is the SV* of ref=SvIV(reference) */
12419 PERL_UNUSED_VAR(ref);
12420 PERL_UNUSED_VAR(ix);
12421 exception=AcquireExceptionInfo();
12422 package_info=(struct PackageInfo *) NULL;
12423 perl_exception=newSVpv("",0);
12424 reference=SvRV(ST(0));
12425 av=(AV *) reference;
12426 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12428 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12429 if (image == (Image *) NULL)
12431 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12433 goto PerlException;
12435 package_info=ClonePackageInfo(info,exception);
12436 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12437 CloneString(&draw_info->text,"");
12438 current=draw_info->affine;
12439 GetAffineMatrix(&affine);
12442 EXTEND(sp,7*items);
12443 for (i=2; i < items; i+=2)
12445 attribute=(char *) SvPV(ST(i-1),na);
12446 switch (*attribute)
12451 if (LocaleCompare(attribute,"antialias") == 0)
12453 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12457 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12461 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12464 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12471 if (LocaleCompare(attribute,"density") == 0)
12473 CloneString(&draw_info->density,SvPV(ST(i),na));
12476 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12483 if (LocaleCompare(attribute,"encoding") == 0)
12485 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12488 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12495 if (LocaleCompare(attribute,"family") == 0)
12497 CloneString(&draw_info->family,SvPV(ST(i),na));
12500 if (LocaleCompare(attribute,"fill") == 0)
12503 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12504 &image->exception);
12507 if (LocaleCompare(attribute,"font") == 0)
12509 CloneString(&draw_info->font,SvPV(ST(i),na));
12512 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12519 if (LocaleCompare(attribute,"geometry") == 0)
12521 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12524 if (LocaleCompare(attribute,"gravity") == 0)
12526 draw_info->gravity=(GravityType) ParseCommandOption(
12527 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12530 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12537 if (LocaleCompare(attribute,"pointsize") == 0)
12539 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12540 draw_info->pointsize=geometry_info.rho;
12543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12550 if (LocaleCompare(attribute,"rotate") == 0)
12552 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12553 affine.rx=geometry_info.rho;
12554 affine.ry=geometry_info.sigma;
12555 if ((flags & SigmaValue) == 0)
12556 affine.ry=affine.rx;
12559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12566 if (LocaleCompare(attribute,"scale") == 0)
12568 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12569 affine.sx=geometry_info.rho;
12570 affine.sy=geometry_info.sigma;
12571 if ((flags & SigmaValue) == 0)
12572 affine.sy=affine.sx;
12575 if (LocaleCompare(attribute,"skew") == 0)
12581 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12582 x_angle=geometry_info.rho;
12583 y_angle=geometry_info.sigma;
12584 if ((flags & SigmaValue) == 0)
12586 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12587 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12590 if (LocaleCompare(attribute,"stroke") == 0)
12593 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12594 &image->exception);
12597 if (LocaleCompare(attribute,"style") == 0)
12599 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12603 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12607 draw_info->style=(StyleType) type;
12610 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12617 if (LocaleCompare(attribute,"text") == 0)
12619 CloneString(&draw_info->text,SvPV(ST(i),na));
12622 if (LocaleCompare(attribute,"translate") == 0)
12624 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12625 affine.tx=geometry_info.rho;
12626 affine.ty=geometry_info.sigma;
12627 if ((flags & SigmaValue) == 0)
12628 affine.ty=affine.tx;
12631 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12638 if (LocaleCompare(attribute,"weight") == 0)
12640 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12641 draw_info->weight=(size_t) geometry_info.rho;
12644 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12651 if (LocaleCompare(attribute,"x") == 0)
12653 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12654 x=geometry_info.rho;
12657 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12664 if (LocaleCompare(attribute,"y") == 0)
12666 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12667 y=geometry_info.rho;
12670 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12676 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12682 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12683 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12684 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12685 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12686 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12687 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12688 if (draw_info->geometry == (char *) NULL)
12690 draw_info->geometry=AcquireString((char *) NULL);
12691 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12692 "%.15g,%.15g",x,y);
12694 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12695 (void) CatchImageException(image);
12696 if (status == MagickFalse)
12700 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12701 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12702 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12703 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12704 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12705 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12706 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12707 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12708 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12709 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12710 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12711 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12712 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12714 draw_info=DestroyDrawInfo(draw_info);
12717 if (package_info != (struct PackageInfo *) NULL)
12718 DestroyPackageInfo(package_info);
12719 InheritPerlException(exception,perl_exception);
12720 exception=DestroyExceptionInfo(exception);
12721 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12725 ###############################################################################
12729 # Q u e r y F o r m a t #
12733 ###############################################################################
12737 QueryFormat(ref,...)
12738 Image::Magick ref=NO_INIT
12755 volatile const MagickInfo
12758 PERL_UNUSED_VAR(ref);
12759 PERL_UNUSED_VAR(ix);
12760 exception=AcquireExceptionInfo();
12761 perl_exception=newSVpv("",0);
12765 format[MaxTextExtent];
12773 format_list=GetMagickInfoList("*",&types,exception);
12775 for (i=0; i < (ssize_t) types; i++)
12777 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12778 LocaleLower(format);
12779 PUSHs(sv_2mortal(newSVpv(format,0)));
12781 format_list=(const MagickInfo **)
12782 RelinquishMagickMemory((MagickInfo *) format_list);
12783 goto PerlException;
12785 EXTEND(sp,8*items);
12786 for (i=1; i < items; i++)
12788 name=(char *) SvPV(ST(i),na);
12789 magick_info=GetMagickInfo(name,exception);
12790 if (magick_info == (const MagickInfo *) NULL)
12795 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12796 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12797 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12798 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12799 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12800 if (magick_info->description == (char *) NULL)
12803 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12804 if (magick_info->module == (char *) NULL)
12807 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12811 InheritPerlException(exception,perl_exception);
12812 exception=DestroyExceptionInfo(exception);
12813 SvREFCNT_dec(perl_exception);
12817 ###############################################################################
12821 # Q u e r y O p t i o n #
12825 ###############################################################################
12829 QueryOption(ref,...)
12830 Image::Magick ref=NO_INIT
12851 PERL_UNUSED_VAR(ref);
12852 PERL_UNUSED_VAR(ix);
12853 exception=AcquireExceptionInfo();
12854 perl_exception=newSVpv("",0);
12855 EXTEND(sp,8*items);
12856 for (i=1; i < items; i++)
12858 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12860 options=GetCommandOptions((CommandOption) option);
12861 if (options == (char **) NULL)
12865 for (j=0; options[j] != (char *) NULL; j++)
12866 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12867 options=DestroyStringList(options);
12871 InheritPerlException(exception,perl_exception);
12872 exception=DestroyExceptionInfo(exception);
12873 SvREFCNT_dec(perl_exception);
12877 ###############################################################################
12885 ###############################################################################
12890 Image::Magick ref=NO_INIT
12937 *perl_exception, /* Perl variable for storing messages */
12942 PERL_UNUSED_VAR(ref);
12943 PERL_UNUSED_VAR(ix);
12944 exception=AcquireExceptionInfo();
12945 perl_exception=newSVpv("",0);
12947 package_info=(struct PackageInfo *) NULL;
12949 ac=(items < 2) ? 1 : items-1;
12950 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12952 length=(STRLEN *) NULL;
12953 if (list == (char **) NULL)
12955 ThrowPerlException(exception,ResourceLimitError,
12956 "MemoryAllocationFailed",PackageName);
12957 goto PerlException;
12959 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12960 if (length == (STRLEN *) NULL)
12962 ThrowPerlException(exception,ResourceLimitError,
12963 "MemoryAllocationFailed",PackageName);
12964 goto PerlException;
12966 if (sv_isobject(ST(0)) == 0)
12968 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12970 goto PerlException;
12972 reference=SvRV(ST(0));
12973 hv=SvSTASH(reference);
12974 if (SvTYPE(reference) != SVt_PVAV)
12976 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12978 goto PerlException;
12980 av=(AV *) reference;
12981 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12983 package_info=ClonePackageInfo(info,exception);
12986 *list=(char *) (*package_info->image_info->filename ?
12987 package_info->image_info->filename : "XC:black");
12989 for (n=0, i=0; i < ac; i++)
12991 list[n]=(char *) SvPV(ST(i+1),length[n]);
12992 if ((items >= 3) && strEQcase(list[n],"blob"))
12998 blob=(void *) (SvPV(ST(i+1),length[n]));
12999 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13001 if ((items >= 3) && strEQcase(list[n],"filename"))
13003 if ((items >= 3) && strEQcase(list[n],"file"))
13012 io_info=IoIFP(sv_2io(ST(i+1)));
13013 if (io_info == (PerlIO *) NULL)
13015 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13019 file=PerlIO_findFILE(io_info);
13020 if (file == (FILE *) NULL)
13022 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13026 SetImageInfoFile(package_info->image_info,file);
13028 if ((items >= 3) && strEQcase(list[n],"magick"))
13032 list[n]=(char *) NULL;
13034 status=ExpandFilenames(&n,&list);
13035 if (status == MagickFalse)
13037 ThrowPerlException(exception,ResourceLimitError,
13038 "MemoryAllocationFailed",PackageName);
13039 goto PerlException;
13042 for (i=0; i < n; i++)
13044 if ((package_info->image_info->file != (FILE *) NULL) ||
13045 (package_info->image_info->blob != (void *) NULL))
13047 image=ReadImages(package_info->image_info,exception);
13048 if (image != (Image *) NULL)
13049 DisassociateImageStream(image);
13053 (void) CopyMagickString(package_info->image_info->filename,list[i],
13055 image=ReadImages(package_info->image_info,exception);
13057 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13059 for ( ; image; image=image->next)
13061 AddImageToRegistry(sv,image);
13063 av_push(av,sv_bless(rv,hv));
13071 for (i=0; i < n; i++)
13072 if (list[i] != (char *) NULL)
13073 for (p=keep; list[i] != *p++; )
13074 if (*p == (char *) NULL)
13076 list[i]=(char *) RelinquishMagickMemory(list[i]);
13081 if (package_info != (struct PackageInfo *) NULL)
13082 DestroyPackageInfo(package_info);
13083 if (list && (list != keep))
13084 list=(char **) RelinquishMagickMemory(list);
13086 keep=(char **) RelinquishMagickMemory(keep);
13088 length=(STRLEN *) RelinquishMagickMemory(length);
13089 InheritPerlException(exception,perl_exception);
13090 exception=DestroyExceptionInfo(exception);
13091 sv_setiv(perl_exception,(IV) number_images);
13092 SvPOK_on(perl_exception);
13093 ST(0)=sv_2mortal(perl_exception);
13098 ###############################################################################
13106 ###############################################################################
13111 Image::Magick ref=NO_INIT
13134 PERL_UNUSED_VAR(ref);
13135 PERL_UNUSED_VAR(ix);
13136 exception=AcquireExceptionInfo();
13137 perl_exception=newSVpv("",0);
13138 reference=SvRV(ST(0));
13139 av=(AV *) reference;
13140 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13142 for (i=1; i < items; i++)
13143 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13144 SvPV(ST(i),na),exception);
13145 InheritPerlException(exception,perl_exception);
13146 exception=DestroyExceptionInfo(exception);
13147 SvREFCNT_dec(perl_exception); /* throw away all errors */
13151 ###############################################################################
13159 ###############################################################################
13164 Image::Magick ref=NO_INIT
13187 *reference; /* reference is the SV* of ref=SvIV(reference) */
13189 PERL_UNUSED_VAR(ref);
13190 PERL_UNUSED_VAR(ix);
13191 exception=AcquireExceptionInfo();
13192 perl_exception=newSVpv("",0);
13193 if (sv_isobject(ST(0)) == 0)
13195 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13197 goto PerlException;
13199 reference=SvRV(ST(0));
13200 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13202 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13204 for (i=2; i < items; i+=2)
13205 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13208 InheritPerlException(exception,perl_exception);
13209 exception=DestroyExceptionInfo(exception);
13210 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13211 SvPOK_on(perl_exception);
13212 ST(0)=sv_2mortal(perl_exception);
13217 ###############################################################################
13221 # S e t P i x e l #
13225 ###############################################################################
13230 Image::Magick ref=NO_INIT
13271 *reference; /* reference is the SV* of ref=SvIV(reference) */
13273 PERL_UNUSED_VAR(ref);
13274 PERL_UNUSED_VAR(ix);
13275 exception=AcquireExceptionInfo();
13276 perl_exception=newSVpv("",0);
13277 reference=SvRV(ST(0));
13278 av=(AV *) reference;
13279 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13281 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13282 if (image == (Image *) NULL)
13284 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13286 goto PerlException;
13289 normalize=MagickTrue;
13292 region.width=image->columns;
13295 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13296 channel=DefaultChannels;
13297 for (i=2; i < items; i+=2)
13299 attribute=(char *) SvPV(ST(i-1),na);
13300 switch (*attribute)
13305 if (LocaleCompare(attribute,"channel") == 0)
13310 option=ParseChannelOption(SvPV(ST(i),na));
13313 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13317 channel=(ChannelType) option;
13320 if (LocaleCompare(attribute,"color") == 0)
13322 if (SvTYPE(ST(i)) != SVt_RV)
13325 message[MaxTextExtent];
13327 (void) FormatLocaleString(message,MaxTextExtent,
13328 "invalid %.60s value",attribute);
13329 ThrowPerlException(exception,OptionError,message,
13332 av=(AV *) SvRV(ST(i));
13335 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13342 if (LocaleCompare(attribute,"geometry") == 0)
13344 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13354 if (LocaleCompare(attribute,"normalize") == 0)
13356 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13360 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13364 normalize=option != 0 ? MagickTrue : MagickFalse;
13367 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13374 if (LocaleCompare(attribute,"x") == 0)
13376 region.x=SvIV(ST(i));
13379 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13386 if (LocaleCompare(attribute,"y") == 0)
13388 region.y=SvIV(ST(i));
13391 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13397 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13403 (void) SetImageStorageClass(image,DirectClass);
13404 PushPixelComponentMap(image,channel);
13405 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13406 if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) ||
13407 (SvTYPE(av) != SVt_PVAV))
13419 if (normalize != MagickFalse)
13420 scale=QuantumRange;
13421 if (((GetPixelRedTraits(image) & ActivePixelTrait) != 0) &&
13424 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13425 av_fetch(av,i,0)))),q);
13428 if (((GetPixelGreenTraits(image) & ActivePixelTrait) != 0) &&
13431 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13432 av_fetch(av,i,0)))),q);
13435 if (((GetPixelBlueTraits(image) & ActivePixelTrait) != 0) &&
13438 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13439 av_fetch(av,i,0)))),q);
13442 if ((((GetPixelBlackTraits(image) & ActivePixelTrait) != 0) &&
13443 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13445 SetPixelBlack(image,ClampToQuantum(scale*
13446 SvNV(*(av_fetch(av,i,0)))),q);
13449 if (((GetPixelAlphaTraits(image) & ActivePixelTrait) != 0) &&
13452 SetPixelAlpha(image,ClampToQuantum(scale*
13453 SvNV(*(av_fetch(av,i,0)))),q);
13456 (void) SyncAuthenticPixels(image,exception);
13458 PopPixelComponentMap(image);
13461 InheritPerlException(exception,perl_exception);
13462 exception=DestroyExceptionInfo(exception);
13463 SvREFCNT_dec(perl_exception);
13467 ###############################################################################
13475 ###############################################################################
13480 Image::Magick ref=NO_INIT
13519 PERL_UNUSED_VAR(ref);
13520 PERL_UNUSED_VAR(ix);
13521 exception=AcquireExceptionInfo();
13522 perl_exception=newSVpv("",0);
13526 if (sv_isobject(ST(0)) == 0)
13528 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13530 goto PerlException;
13532 reference=SvRV(ST(0));
13533 hv=SvSTASH(reference);
13535 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13537 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13538 if (image == (Image *) NULL)
13540 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13542 goto PerlException;
13544 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13550 for (i=2; i < items; i+=2)
13552 attribute=(char *) SvPV(ST(i-1),na);
13553 switch (*attribute)
13558 if (LocaleCompare(attribute,"offset") == 0)
13560 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13563 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13570 if (LocaleCompare(attribute,"stack") == 0)
13572 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13576 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13582 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13588 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13594 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13596 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13597 goto PerlException;
13598 for ( ; image; image=image->next)
13600 AddImageToRegistry(sv,image);
13602 av_push(av,sv_bless(rv,hv));
13605 exception=DestroyExceptionInfo(exception);
13606 ST(0)=av_reference;
13607 SvREFCNT_dec(perl_exception);
13611 InheritPerlException(exception,perl_exception);
13612 exception=DestroyExceptionInfo(exception);
13613 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13614 SvPOK_on(perl_exception);
13615 ST(0)=sv_2mortal(perl_exception);
13620 ###############################################################################
13624 # S t a t i s t i c s #
13628 ###############################################################################
13632 Statistics(ref,...)
13633 Image::Magick ref=NO_INIT
13635 StatisticsImage = 1
13637 statisticsimage = 3
13640 #define ChannelStatistics(channel) \
13642 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13643 (double) channel_statistics[channel].depth); \
13644 PUSHs(sv_2mortal(newSVpv(message,0))); \
13645 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13646 channel_statistics[channel].minima/scale); \
13647 PUSHs(sv_2mortal(newSVpv(message,0))); \
13648 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13649 channel_statistics[channel].maxima/scale); \
13650 PUSHs(sv_2mortal(newSVpv(message,0))); \
13651 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13652 channel_statistics[channel].mean/scale); \
13653 PUSHs(sv_2mortal(newSVpv(message,0))); \
13654 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13655 channel_statistics[channel].standard_deviation/scale); \
13656 PUSHs(sv_2mortal(newSVpv(message,0))); \
13657 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13658 channel_statistics[channel].kurtosis); \
13659 PUSHs(sv_2mortal(newSVpv(message,0))); \
13660 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13661 channel_statistics[channel].skewness); \
13662 PUSHs(sv_2mortal(newSVpv(message,0))); \
13669 message[MaxTextExtent];
13672 *channel_statistics;
13693 PERL_UNUSED_VAR(ref);
13694 PERL_UNUSED_VAR(ix);
13695 exception=AcquireExceptionInfo();
13696 perl_exception=newSVpv("",0);
13698 if (sv_isobject(ST(0)) == 0)
13700 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13702 goto PerlException;
13704 reference=SvRV(ST(0));
13707 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13708 if (image == (Image *) NULL)
13710 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13712 goto PerlException;
13714 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13716 for ( ; image; image=image->next)
13718 channel_statistics=GetImageStatistics(image,&image->exception);
13719 if (channel_statistics == (ChannelStatistics *) NULL)
13722 EXTEND(sp,35*count);
13723 scale=(double) QuantumRange;
13724 ChannelStatistics(RedChannel);
13725 ChannelStatistics(GreenChannel);
13726 ChannelStatistics(BlueChannel);
13727 if (image->colorspace == CMYKColorspace)
13728 ChannelStatistics(BlackChannel);
13729 if (image->matte != MagickFalse)
13730 ChannelStatistics(AlphaChannel);
13731 channel_statistics=(ChannelStatistics *)
13732 RelinquishMagickMemory(channel_statistics);
13736 InheritPerlException(exception,perl_exception);
13737 exception=DestroyExceptionInfo(exception);
13738 SvREFCNT_dec(perl_exception);
13742 ###############################################################################
13746 # S y n c A u t h e n t i c P i x e l s #
13750 ###############################################################################
13754 SyncAuthenticPixels(ref,...)
13755 Image::Magick ref = NO_INIT
13757 Syncauthenticpixels = 1
13758 SyncImagePixels = 2
13759 syncimagepixels = 3
13778 PERL_UNUSED_VAR(ref);
13779 PERL_UNUSED_VAR(ix);
13780 exception=AcquireExceptionInfo();
13781 perl_exception=newSVpv("",0);
13782 if (sv_isobject(ST(0)) == 0)
13784 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13786 goto PerlException;
13789 reference=SvRV(ST(0));
13790 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13791 if (image == (Image *) NULL)
13793 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13795 goto PerlException;
13798 status=SyncAuthenticPixels(image,exception);
13799 if (status != MagickFalse)
13801 InheritException(exception,&image->exception);
13804 InheritPerlException(exception,perl_exception);
13805 exception=DestroyExceptionInfo(exception);
13806 SvREFCNT_dec(perl_exception); /* throw away all errors */
13810 ###############################################################################
13814 # T r a n s f o r m #
13818 ###############################################################################
13823 Image::Magick ref=NO_INIT
13861 PERL_UNUSED_VAR(ref);
13862 PERL_UNUSED_VAR(ix);
13863 exception=AcquireExceptionInfo();
13864 perl_exception=newSVpv("",0);
13868 if (sv_isobject(ST(0)) == 0)
13870 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13872 goto PerlException;
13874 reference=SvRV(ST(0));
13875 hv=SvSTASH(reference);
13877 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13879 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13880 if (image == (Image *) NULL)
13882 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13884 goto PerlException;
13886 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13890 crop_geometry=(char *) NULL;
13891 geometry=(char *) NULL;
13892 for (i=2; i < items; i+=2)
13894 attribute=(char *) SvPV(ST(i-1),na);
13895 switch (*attribute)
13900 if (LocaleCompare(attribute,"crop") == 0)
13902 crop_geometry=SvPV(ST(i),na);
13905 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13912 if (LocaleCompare(attribute,"geometry") == 0)
13914 geometry=SvPV(ST(i),na);
13917 if (LocaleCompare(attribute,"gravity") == 0)
13925 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13926 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13929 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13933 for (next=image; next; next=next->next)
13934 next->gravity=(GravityType) in;
13937 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13943 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13949 for ( ; image; image=image->next)
13951 clone=CloneImage(image,0,0,MagickTrue,exception);
13952 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13953 goto PerlException;
13954 TransformImage(&clone,crop_geometry,geometry);
13955 for ( ; clone; clone=clone->next)
13957 AddImageToRegistry(sv,clone);
13959 av_push(av,sv_bless(rv,hv));
13963 exception=DestroyExceptionInfo(exception);
13964 ST(0)=av_reference;
13965 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13969 InheritPerlException(exception,perl_exception);
13970 exception=DestroyExceptionInfo(exception);
13971 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13972 SvPOK_on(perl_exception);
13973 ST(0)=sv_2mortal(perl_exception);
13978 ###############################################################################
13986 ###############################################################################
13991 Image::Magick ref=NO_INIT
13999 filename[MaxTextExtent];
14023 PERL_UNUSED_VAR(ref);
14024 PERL_UNUSED_VAR(ix);
14025 exception=AcquireExceptionInfo();
14026 perl_exception=newSVpv("",0);
14028 package_info=(struct PackageInfo *) NULL;
14029 if (sv_isobject(ST(0)) == 0)
14031 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14033 goto PerlException;
14035 reference=SvRV(ST(0));
14036 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14037 if (image == (Image *) NULL)
14039 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14041 goto PerlException;
14043 package_info=ClonePackageInfo(info,exception);
14045 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14048 for (i=2; i < items; i+=2)
14049 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14051 (void) CopyMagickString(filename,package_info->image_info->filename,
14054 for (next=image; next; next=next->next)
14056 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14057 next->scene=scene++;
14059 SetImageInfo(package_info->image_info,(unsigned int)
14060 GetImageListLength(image),&image->exception);
14061 for (next=image; next; next=next->next)
14063 (void) WriteImage(package_info->image_info,next);
14064 if (next->exception.severity >= ErrorException)
14065 InheritException(exception,&next->exception);
14066 GetImageException(next,exception);
14068 if (package_info->image_info->adjoin)
14073 if (package_info != (struct PackageInfo *) NULL)
14074 DestroyPackageInfo(package_info);
14075 InheritPerlException(exception,perl_exception);
14076 exception=DestroyExceptionInfo(exception);
14077 sv_setiv(perl_exception,(IV) number_images);
14078 SvPOK_on(perl_exception);
14079 ST(0)=sv_2mortal(perl_exception);