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 {"kernel", StringReference} } },
391 { "Profile", { {"name", StringReference}, {"profile", StringReference},
392 { "rendering-intent", MagickIntentOptions},
393 { "black-point-compensation", MagickBooleanOptions} } },
394 { "UnsharpMask", { {"geometry", StringReference},
395 {"radius", RealReference}, {"sigma", RealReference},
396 {"amount", RealReference}, {"threshold", RealReference},
397 {"channel", MagickChannelOptions} } },
398 { "MotionBlur", { {"geometry", StringReference},
399 {"radius", RealReference}, {"sigma", RealReference},
400 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
401 { "OrderedDither", { {"threshold", StringReference},
402 {"channel", MagickChannelOptions} } },
403 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
404 {"height", IntegerReference} } },
405 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
406 {"white-point", RealReference}, {"gamma", RealReference},
407 {"channel", MagickChannelOptions}, {"level", StringReference} } },
408 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
409 { "AffineTransform", { {"affine", ArrayReference},
410 {"translate", StringReference}, {"scale", StringReference},
411 {"rotate", RealReference}, {"skewX", RealReference},
412 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
413 {"background", StringReference} } },
414 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
415 { "AdaptiveThreshold", { {"geometry", StringReference},
416 {"width", IntegerReference}, {"height", IntegerReference},
417 {"bias", RealReference} } },
418 { "Resample", { {"density", StringReference}, {"x", RealReference},
419 {"y", RealReference}, {"filter", MagickFilterOptions},
420 {"support", RealReference }, {"blur", RealReference } } },
421 { "Describe", { {"file", FileReference} } },
422 { "BlackThreshold", { {"threshold", StringReference},
423 {"channel", MagickChannelOptions} } },
424 { "WhiteThreshold", { {"threshold", StringReference},
425 {"channel", MagickChannelOptions} } },
426 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
427 {"channel", MagickChannelOptions} } },
428 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference} } },
431 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
440 {"sigma", RealReference}, {"x", IntegerReference},
441 {"y", IntegerReference} } },
442 { "Identify", { {"file", FileReference}, {"features", StringReference},
443 {"unique", MagickBooleanOptions} } },
444 { "SepiaTone", { {"threshold", RealReference} } },
445 { "SigmoidalContrast", { {"geometry", StringReference},
446 {"contrast", RealReference}, {"mid-point", RealReference},
447 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
448 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
449 {"height", IntegerReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"fuzz", StringReference},
451 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
452 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
453 {"sigma", RealReference}, {"x", IntegerReference},
454 {"y", IntegerReference}, {"background", StringReference} } },
455 { "ContrastStretch", { {"levels", StringReference},
456 {"black-point", RealReference},{"white-point", RealReference},
457 {"channel", MagickChannelOptions} } },
460 { "AdaptiveSharpen", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"channel", MagickChannelOptions} } },
466 { "AdaptiveBlur", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"channel", MagickChannelOptions} } },
469 { "Sketch", { {"geometry", StringReference},
470 {"radius", RealReference}, {"sigma", RealReference},
471 {"angle", RealReference} } },
473 { "AdaptiveResize", { {"geometry", StringReference},
474 {"width", IntegerReference}, {"height", IntegerReference},
475 {"filter", MagickFilterOptions}, {"support", StringReference },
476 {"blur", RealReference } } },
477 { "ClipMask", { {"mask", ImageReference} } },
478 { "LinearStretch", { {"levels", StringReference},
479 {"black-point", RealReference},{"white-point", RealReference} } },
480 { "Recolor", { {"matrix", ArrayReference} } },
481 { "Mask", { {"mask", ImageReference} } },
482 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
483 {"font", StringReference}, {"stroke", StringReference},
484 {"fill", StringReference}, {"strokewidth", RealReference},
485 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
486 {"background", StringReference} } },
487 { "FloodfillPaint", { {"geometry", StringReference},
488 {"x", IntegerReference}, {"y", IntegerReference},
489 {"fill", StringReference}, {"bordercolor", StringReference},
490 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
491 {"invert", MagickBooleanOptions} } },
492 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
493 {"virtual-pixel", MagickVirtualPixelOptions},
494 {"best-fit", MagickBooleanOptions} } },
495 { "Clut", { {"image", ImageReference},
496 {"channel", MagickChannelOptions} } },
497 { "LiquidRescale", { {"geometry", StringReference},
498 {"width", IntegerReference}, {"height", IntegerReference},
499 {"delta-x", RealReference}, {"rigidity", RealReference } } },
500 { "Encipher", { {"passphrase", StringReference} } },
501 { "Decipher", { {"passphrase", StringReference} } },
502 { "Deskew", { {"geometry", StringReference},
503 {"threshold", StringReference} } },
504 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
505 {"dither-method", MagickDitherOptions} } },
506 { "SparseColor", { {"points", ArrayReference},
507 {"method", MagickSparseColorOptions},
508 {"virtual-pixel", MagickVirtualPixelOptions},
509 {"channel", MagickChannelOptions} } },
510 { "Function", { {"parameters", ArrayReference},
511 {"function", MagickFunctionOptions},
512 {"virtual-pixel", MagickVirtualPixelOptions} } },
513 { "SelectiveBlur", { {"geometry", StringReference},
514 {"radius", RealReference}, {"sigma", RealReference},
515 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
516 { "HaldClut", { {"image", ImageReference},
517 {"channel", MagickChannelOptions} } },
518 { "BlueShift", { {"factor", StringReference} } },
519 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
521 { "ColorDecisionList", {
522 {"color-correction-collection", StringReference} } },
523 { "AutoGamma", { {"channel", MagickChannelOptions} } },
524 { "AutoLevel", { {"channel", MagickChannelOptions} } },
525 { "LevelColors", { {"invert", MagickBooleanOptions},
526 {"black-point", StringReference}, {"white-point", StringReference},
527 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
528 { "Clamp", { {"channel", MagickChannelOptions} } },
529 { "BrightnessContrast", { {"levels", StringReference},
530 {"brightness", RealReference},{"contrast", RealReference},
531 {"channel", MagickChannelOptions} } },
532 { "Morphology", { {"kernel", StringReference},
533 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
534 {"iterations", IntegerReference} } },
535 { "ColorMatrix", { {"matrix", ArrayReference} } },
536 { "Color", { {"color", StringReference} } },
537 { "Mode", { {"geometry", StringReference},
538 {"width", IntegerReference},{"height", IntegerReference},
539 {"channel", MagickChannelOptions} } },
540 { "Statistic", { {"geometry", StringReference},
541 {"width", IntegerReference},{"height", IntegerReference},
542 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
546 *magick_registry = (SplayTreeInfo *) NULL;
549 Forward declarations.
552 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
555 strEQcase(const char *,const char *);
558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 % C l o n e P a c k a g e I n f o %
566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
571 % The format of the ClonePackageInfo routine is:
573 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
576 % A description of each parameter follows:
578 % o info: a structure of type info.
580 % o exception: Return any errors or warnings in this structure.
583 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
584 ExceptionInfo *exception)
589 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
590 if (clone_info == (struct PackageInfo *) NULL)
592 ThrowPerlException(exception,ResourceLimitError,
593 "UnableToClonePackageInfo",PackageName);
594 return((struct PackageInfo *) NULL);
596 if (info == (struct PackageInfo *) NULL)
598 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
602 clone_info->image_info=CloneImageInfo(info->image_info);
607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 % constant() returns a double value for the specified name.
619 % The format of the constant routine is:
621 % double constant(char *name,ssize_t sans)
623 % A description of each parameter follows:
625 % o value: Method constant returns a double value for the specified name.
627 % o name: The name of the constant.
629 % o sans: This integer value is not used.
632 static double constant(char *name,ssize_t sans)
640 if (strEQ(name,"BlobError"))
642 if (strEQ(name,"BlobWarning"))
648 if (strEQ(name,"CacheError"))
650 if (strEQ(name,"CacheWarning"))
651 return(CacheWarning);
652 if (strEQ(name,"CoderError"))
654 if (strEQ(name,"CoderWarning"))
655 return(CoderWarning);
656 if (strEQ(name,"ConfigureError"))
657 return(ConfigureError);
658 if (strEQ(name,"ConfigureWarning"))
659 return(ConfigureWarning);
660 if (strEQ(name,"CorruptImageError"))
661 return(CorruptImageError);
662 if (strEQ(name,"CorruptImageWarning"))
663 return(CorruptImageWarning);
668 if (strEQ(name,"DelegateError"))
669 return(DelegateError);
670 if (strEQ(name,"DelegateWarning"))
671 return(DelegateWarning);
672 if (strEQ(name,"DrawError"))
674 if (strEQ(name,"DrawWarning"))
680 if (strEQ(name,"ErrorException"))
681 return(ErrorException);
682 if (strEQ(name,"ExceptionError"))
684 if (strEQ(name,"ExceptionWarning"))
685 return(CoderWarning);
690 if (strEQ(name,"FatalErrorException"))
691 return(FatalErrorException);
692 if (strEQ(name,"FileOpenError"))
693 return(FileOpenError);
694 if (strEQ(name,"FileOpenWarning"))
695 return(FileOpenWarning);
700 if (strEQ(name,"ImageError"))
702 if (strEQ(name,"ImageWarning"))
703 return(ImageWarning);
708 if (strEQ(name,"MaxRGB"))
709 return(QuantumRange);
710 if (strEQ(name,"MissingDelegateError"))
711 return(MissingDelegateError);
712 if (strEQ(name,"MissingDelegateWarning"))
713 return(MissingDelegateWarning);
714 if (strEQ(name,"ModuleError"))
716 if (strEQ(name,"ModuleWarning"))
717 return(ModuleWarning);
722 if (strEQ(name,"Opaque"))
724 if (strEQ(name,"OptionError"))
726 if (strEQ(name,"OptionWarning"))
727 return(OptionWarning);
732 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
733 return(MAGICKCORE_QUANTUM_DEPTH);
734 if (strEQ(name,"QuantumDepth"))
735 return(MAGICKCORE_QUANTUM_DEPTH);
736 if (strEQ(name,"QuantumRange"))
737 return(QuantumRange);
742 if (strEQ(name,"ResourceLimitError"))
743 return(ResourceLimitError);
744 if (strEQ(name,"ResourceLimitWarning"))
745 return(ResourceLimitWarning);
746 if (strEQ(name,"RegistryError"))
747 return(RegistryError);
748 if (strEQ(name,"RegistryWarning"))
749 return(RegistryWarning);
754 if (strEQ(name,"StreamError"))
756 if (strEQ(name,"StreamWarning"))
757 return(StreamWarning);
758 if (strEQ(name,"Success"))
764 if (strEQ(name,"Transparent"))
765 return(TransparentAlpha);
766 if (strEQ(name,"TypeError"))
768 if (strEQ(name,"TypeWarning"))
774 if (strEQ(name,"WarningException"))
775 return(WarningException);
780 if (strEQ(name,"XServerError"))
781 return(XServerError);
782 if (strEQ(name,"XServerWarning"))
783 return(XServerWarning);
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
796 % D e s t r o y P a c k a g e I n f o %
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
802 % Method DestroyPackageInfo frees a previously created info structure.
804 % The format of the DestroyPackageInfo routine is:
806 % DestroyPackageInfo(struct PackageInfo *info)
808 % A description of each parameter follows:
810 % o info: a structure of type info.
813 static void DestroyPackageInfo(struct PackageInfo *info)
815 info->image_info=DestroyImageInfo(info->image_info);
816 info=(struct PackageInfo *) RelinquishMagickMemory(info);
820 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 % Method GetList is recursively called by SetupList to traverse the
831 % Image__Magick reference. If building an reference_vector (see SetupList),
832 % *current is the current position in *reference_vector and *last is the final
833 % entry in *reference_vector.
835 % The format of the GetList routine is:
839 % A description of each parameter follows:
841 % o info: a structure of type info.
844 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
845 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
850 if (reference == (SV *) NULL)
852 switch (SvTYPE(reference))
872 previous=(Image *) NULL;
876 for (i=0; i <= n; i++)
882 if (rv && *rv && sv_isobject(*rv))
884 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
886 if (image == (Image *) NULL)
888 if (image == previous)
890 image=CloneImage(image,0,0,MagickTrue,exception);
891 if (image == (Image *) NULL)
894 image->previous=previous;
895 *(previous ? &previous->next : &head)=image;
896 for (previous=image; previous->next; previous=previous->next) ;
904 Blessed scalar, one image.
906 image=(Image *) SvIV(reference);
907 if (image == (Image *) NULL)
909 image->previous=(Image *) NULL;
910 image->next=(Image *) NULL;
911 if (reference_vector)
913 if (*current == *last)
916 if (*reference_vector == (SV **) NULL)
917 *reference_vector=(SV **) AcquireQuantumMemory(*last,
918 sizeof(*reference_vector));
920 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
921 *last,sizeof(*reference_vector));
923 if (*reference_vector == (SV **) NULL)
925 ThrowPerlException(exception,ResourceLimitError,
926 "MemoryAllocationFailed",PackageName);
927 return((Image *) NULL);
929 (*reference_vector)[*current]=reference;
930 (*reference_vector)[++(*current)]=NULL;
937 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
938 (double) SvTYPE(reference));
939 return((Image *) NULL);
943 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
947 % G e t P a c k a g e I n f o %
951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953 % Method GetPackageInfo looks up or creates an info structure for the given
954 % Image__Magick reference. If it does create a new one, the information in
955 % package_info is used to initialize it.
957 % The format of the GetPackageInfo routine is:
959 % struct PackageInfo *GetPackageInfo(void *reference,
960 % struct PackageInfo *package_info,ExceptionInfo *exception)
962 % A description of each parameter follows:
964 % o info: a structure of type info.
966 % o exception: Return any errors or warnings in this structure.
969 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
970 struct PackageInfo *package_info,ExceptionInfo *exception)
973 message[MaxTextExtent];
981 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
982 PackageName,XS_VERSION,reference);
983 sv=perl_get_sv(message,(TRUE | 0x02));
984 if (sv == (SV *) NULL)
986 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
988 return(package_info);
990 if (SvREFCNT(sv) == 0)
991 (void) SvREFCNT_inc(sv);
992 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
994 clone_info=ClonePackageInfo(package_info,exception);
995 sv_setiv(sv,(IV) clone_info);
1000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1004 % S e t A t t r i b u t e %
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1010 % SetAttribute() sets the attribute to the value in sval. This can change
1011 % either or both of image or info.
1013 % The format of the SetAttribute routine is:
1015 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1016 % SV *sval,ExceptionInfo *exception)
1018 % A description of each parameter follows:
1020 % o list: a list of strings.
1022 % o string: a character string.
1026 static double SiPrefixToDouble(const char *string,const double interval)
1035 value=InterpretLocaleValue(string,&q);
1037 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1039 switch (tolower((int) ((unsigned char) *q)))
1041 case '%': value*=pow(scale,0)*interval/100.0; break;
1042 case 'k': value*=pow(scale,1); break;
1043 case 'm': value*=pow(scale,2); break;
1044 case 'g': value*=pow(scale,3); break;
1045 case 't': value*=pow(scale,4); break;
1046 case 'p': value*=pow(scale,5); break;
1047 case 'e': value*=pow(scale,6); break;
1048 case 'z': value*=pow(scale,7); break;
1049 case 'y': value*=pow(scale,8); break;
1055 static inline ssize_t StringToLong(const char *value)
1057 return(strtol(value,(char **) NULL,10));
1060 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1061 const char *attribute,SV *sval,ExceptionInfo *exception)
1088 if (LocaleCompare(attribute,"adjoin") == 0)
1090 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1091 SvPV(sval,na)) : SvIV(sval);
1094 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1099 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1102 if (LocaleCompare(attribute,"alpha") == 0)
1104 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1105 SvPV(sval,na)) : SvIV(sval);
1108 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1112 for ( ; image; image=image->next)
1113 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
1116 if (LocaleCompare(attribute,"antialias") == 0)
1118 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1119 SvPV(sval,na)) : SvIV(sval);
1122 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1127 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1130 if (LocaleCompare(attribute,"area-limit") == 0)
1135 limit=MagickResourceInfinity;
1136 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1137 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1138 (void) SetMagickResourceLimit(AreaResource,limit);
1141 if (LocaleCompare(attribute,"attenuate") == 0)
1144 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1147 if (LocaleCompare(attribute,"authenticate") == 0)
1150 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1154 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1155 for ( ; image; image=image->next)
1156 SetImageProperty(image,attribute,SvPV(sval,na));
1162 if (LocaleCompare(attribute,"background") == 0)
1164 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1166 info->image_info->background_color=target_color;
1167 for ( ; image; image=image->next)
1168 image->background_color=target_color;
1171 if (LocaleCompare(attribute,"bias") == 0)
1173 for ( ; image; image=image->next)
1174 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1177 if (LocaleCompare(attribute,"blue-primary") == 0)
1179 for ( ; image; image=image->next)
1181 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1182 image->chromaticity.blue_primary.x=geometry_info.rho;
1183 image->chromaticity.blue_primary.y=geometry_info.sigma;
1184 if ((flags & SigmaValue) == 0)
1185 image->chromaticity.blue_primary.y=
1186 image->chromaticity.blue_primary.x;
1190 if (LocaleCompare(attribute,"bordercolor") == 0)
1192 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1194 info->image_info->border_color=target_color;
1195 for ( ; image; image=image->next)
1196 image->border_color=target_color;
1200 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1201 for ( ; image; image=image->next)
1202 SetImageProperty(image,attribute,SvPV(sval,na));
1208 if (LocaleCompare(attribute,"cache-threshold") == 0)
1210 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1211 SiPrefixToDouble(SvPV(sval,na),100.0));
1212 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1213 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1216 if (LocaleCompare(attribute,"clip-mask") == 0)
1221 clip_mask=(Image *) NULL;
1223 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1224 for ( ; image; image=image->next)
1225 SetImageClipMask(image,clip_mask);
1228 if (LocaleNCompare(attribute,"colormap",8) == 0)
1230 for ( ; image; image=image->next)
1238 if (image->storage_class == DirectClass)
1241 items=sscanf(attribute,"%*[^[][%ld",&i);
1243 if (i > (ssize_t) image->colors)
1245 if ((strchr(SvPV(sval,na),',') == 0) ||
1246 (strchr(SvPV(sval,na),')') != 0))
1247 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1250 color=image->colormap+i;
1251 pixel.red=color->red;
1252 pixel.green=color->green;
1253 pixel.blue=color->blue;
1254 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1255 pixel.red=geometry_info.rho;
1256 pixel.green=geometry_info.sigma;
1257 pixel.blue=geometry_info.xi;
1258 color->red=ClampToQuantum(pixel.red);
1259 color->green=ClampToQuantum(pixel.green);
1260 color->blue=ClampToQuantum(pixel.blue);
1265 if (LocaleCompare(attribute,"colorspace") == 0)
1267 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1268 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1271 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1275 for ( ; image; image=image->next)
1276 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1279 if (LocaleCompare(attribute,"comment") == 0)
1281 for ( ; image; image=image->next)
1282 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1283 info ? info->image_info : (ImageInfo *) NULL,image,
1287 if (LocaleCompare(attribute,"compression") == 0)
1289 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1290 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1293 ThrowPerlException(exception,OptionError,
1294 "UnrecognizedImageCompression",SvPV(sval,na));
1298 info->image_info->compression=(CompressionType) sp;
1299 for ( ; image; image=image->next)
1300 image->compression=(CompressionType) sp;
1304 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1305 for ( ; image; image=image->next)
1306 SetImageProperty(image,attribute,SvPV(sval,na));
1312 if (LocaleCompare(attribute,"debug") == 0)
1314 SetLogEventMask(SvPV(sval,na));
1317 if (LocaleCompare(attribute,"delay") == 0)
1319 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1320 for ( ; image; image=image->next)
1322 image->delay=(size_t) floor(geometry_info.rho+0.5);
1323 if ((flags & SigmaValue) != 0)
1324 image->ticks_per_second=(ssize_t)
1325 floor(geometry_info.sigma+0.5);
1329 if (LocaleCompare(attribute,"disk-limit") == 0)
1334 limit=MagickResourceInfinity;
1335 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1336 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1337 (void) SetMagickResourceLimit(DiskResource,limit);
1340 if (LocaleCompare(attribute,"density") == 0)
1342 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1344 ThrowPerlException(exception,OptionError,"MissingGeometry",
1349 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1350 for ( ; image; image=image->next)
1352 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1353 image->x_resolution=geometry_info.rho;
1354 image->y_resolution=geometry_info.sigma;
1355 if ((flags & SigmaValue) == 0)
1356 image->y_resolution=image->x_resolution;
1360 if (LocaleCompare(attribute,"depth") == 0)
1363 info->image_info->depth=SvIV(sval);
1364 for ( ; image; image=image->next)
1365 (void) SetImageDepth(image,SvIV(sval));
1368 if (LocaleCompare(attribute,"dispose") == 0)
1370 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1371 SvPV(sval,na)) : SvIV(sval);
1374 ThrowPerlException(exception,OptionError,
1375 "UnrecognizedDisposeMethod",SvPV(sval,na));
1378 for ( ; image; image=image->next)
1379 image->dispose=(DisposeType) sp;
1382 if (LocaleCompare(attribute,"dither") == 0)
1386 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1387 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1390 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1394 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1398 if (LocaleCompare(attribute,"display") == 0)
1402 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1406 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1407 for ( ; image; image=image->next)
1408 SetImageProperty(image,attribute,SvPV(sval,na));
1414 if (LocaleCompare(attribute,"endian") == 0)
1416 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1417 SvPV(sval,na)) : SvIV(sval);
1420 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1425 info->image_info->endian=(EndianType) sp;
1426 for ( ; image; image=image->next)
1427 image->endian=(EndianType) sp;
1430 if (LocaleCompare(attribute,"extract") == 0)
1433 Set image extract geometry.
1435 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1439 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1440 for ( ; image; image=image->next)
1441 SetImageProperty(image,attribute,SvPV(sval,na));
1447 if (LocaleCompare(attribute,"filename") == 0)
1450 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1452 for ( ; image; image=image->next)
1453 (void) CopyMagickString(image->filename,SvPV(sval,na),
1457 if (LocaleCompare(attribute,"file") == 0)
1465 if (info == (struct PackageInfo *) NULL)
1467 io_info=IoIFP(sv_2io(sval));
1468 if (io_info == (PerlIO *) NULL)
1470 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1474 file=PerlIO_findFILE(io_info);
1475 if (file == (FILE *) NULL)
1477 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1481 SetImageInfoFile(info->image_info,file);
1484 if (LocaleCompare(attribute,"fill") == 0)
1487 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1490 if (LocaleCompare(attribute,"font") == 0)
1493 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1496 if (LocaleCompare(attribute,"foreground") == 0)
1498 if (LocaleCompare(attribute,"fuzz") == 0)
1501 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1502 for ( ; image; image=image->next)
1503 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1507 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1508 for ( ; image; image=image->next)
1509 SetImageProperty(image,attribute,SvPV(sval,na));
1515 if (LocaleCompare(attribute,"gamma") == 0)
1517 for ( ; image; image=image->next)
1518 image->gamma=SvNV(sval);
1521 if (LocaleCompare(attribute,"gravity") == 0)
1523 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1524 SvPV(sval,na)) : SvIV(sval);
1527 ThrowPerlException(exception,OptionError,
1528 "UnrecognizedGravityType",SvPV(sval,na));
1532 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1533 for ( ; image; image=image->next)
1534 image->gravity=(GravityType) sp;
1537 if (LocaleCompare(attribute,"green-primary") == 0)
1539 for ( ; image; image=image->next)
1541 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1542 image->chromaticity.green_primary.x=geometry_info.rho;
1543 image->chromaticity.green_primary.y=geometry_info.sigma;
1544 if ((flags & SigmaValue) == 0)
1545 image->chromaticity.green_primary.y=
1546 image->chromaticity.green_primary.x;
1551 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1552 for ( ; image; image=image->next)
1553 SetImageProperty(image,attribute,SvPV(sval,na));
1559 if (LocaleNCompare(attribute,"index",5) == 0)
1573 for ( ; image; image=image->next)
1575 if (image->storage_class != PseudoClass)
1579 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1581 image_view=AcquireCacheView(image);
1582 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1583 if (q != (Quantum *) NULL)
1585 items=sscanf(SvPV(sval,na),"%ld",&index);
1586 if ((index >= 0) && (index < (ssize_t) image->colors))
1587 SetPixelIndex(image,index,q);
1588 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1590 image_view=DestroyCacheView(image_view);
1594 if (LocaleCompare(attribute,"iterations") == 0)
1597 for ( ; image; image=image->next)
1598 image->iterations=SvIV(sval);
1601 if (LocaleCompare(attribute,"interlace") == 0)
1603 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1604 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1607 ThrowPerlException(exception,OptionError,
1608 "UnrecognizedInterlaceType",SvPV(sval,na));
1612 info->image_info->interlace=(InterlaceType) sp;
1613 for ( ; image; image=image->next)
1614 image->interlace=(InterlaceType) sp;
1618 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1619 for ( ; image; image=image->next)
1620 SetImageProperty(image,attribute,SvPV(sval,na));
1626 if (LocaleCompare(attribute,"label") == 0)
1628 for ( ; image; image=image->next)
1629 (void) SetImageProperty(image,"label",InterpretImageProperties(
1630 info ? info->image_info : (ImageInfo *) NULL,image,
1634 if (LocaleCompare(attribute,"loop") == 0)
1637 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1638 for ( ; image; image=image->next)
1639 SetImageProperty(image,attribute,SvPV(sval,na));
1645 if (LocaleCompare(attribute,"magick") == 0)
1648 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1649 "%s:",SvPV(sval,na));
1650 for ( ; image; image=image->next)
1651 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1654 if (LocaleCompare(attribute,"map-limit") == 0)
1659 limit=MagickResourceInfinity;
1660 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1661 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1662 (void) SetMagickResourceLimit(MapResource,limit);
1665 if (LocaleCompare(attribute,"mask") == 0)
1670 mask=(Image *) NULL;
1672 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1673 for ( ; image; image=image->next)
1674 SetImageMask(image,mask);
1677 if (LocaleCompare(attribute,"mattecolor") == 0)
1679 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1681 info->image_info->matte_color=target_color;
1682 for ( ; image; image=image->next)
1683 image->matte_color=target_color;
1686 if (LocaleCompare(attribute,"matte") == 0)
1688 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1689 SvPV(sval,na)) : SvIV(sval);
1692 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1696 for ( ; image; image=image->next)
1697 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1700 if (LocaleCompare(attribute,"memory-limit") == 0)
1705 limit=MagickResourceInfinity;
1706 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1707 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1708 (void) SetMagickResourceLimit(MemoryResource,limit);
1711 if (LocaleCompare(attribute,"monochrome") == 0)
1713 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1714 SvPV(sval,na)) : SvIV(sval);
1717 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1722 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1723 for ( ; image; image=image->next)
1724 (void) SetImageType(image,BilevelType);
1728 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1729 for ( ; image; image=image->next)
1730 SetImageProperty(image,attribute,SvPV(sval,na));
1736 if (LocaleCompare(attribute,"option") == 0)
1739 DefineImageOption(info->image_info,SvPV(sval,na));
1742 if (LocaleCompare(attribute,"orientation") == 0)
1744 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1745 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1748 ThrowPerlException(exception,OptionError,
1749 "UnrecognizedOrientationType",SvPV(sval,na));
1753 info->image_info->orientation=(OrientationType) sp;
1754 for ( ; image; image=image->next)
1755 image->orientation=(OrientationType) sp;
1759 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1760 for ( ; image; image=image->next)
1761 SetImageProperty(image,attribute,SvPV(sval,na));
1767 if (LocaleCompare(attribute,"page") == 0)
1772 geometry=GetPageGeometry(SvPV(sval,na));
1774 (void) CloneString(&info->image_info->page,geometry);
1775 for ( ; image; image=image->next)
1776 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1777 geometry=(char *) RelinquishMagickMemory(geometry);
1780 if (LocaleCompare(attribute,"pen") == 0)
1783 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1786 if (LocaleNCompare(attribute,"pixel",5) == 0)
1800 for ( ; image; image=image->next)
1802 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1806 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1808 image_view=AcquireCacheView(image);
1809 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1810 if (q != (Quantum *) NULL)
1812 if ((strchr(SvPV(sval,na),',') == 0) ||
1813 (strchr(SvPV(sval,na),')') != 0))
1814 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1817 GetPixelInfo(image,&pixel);
1818 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1819 pixel.red=geometry_info.rho;
1820 if ((flags & SigmaValue) != 0)
1821 pixel.green=geometry_info.sigma;
1822 if ((flags & XiValue) != 0)
1823 pixel.blue=geometry_info.xi;
1824 if ((flags & PsiValue) != 0)
1825 pixel.alpha=geometry_info.psi;
1826 if ((flags & ChiValue) != 0)
1827 pixel.black=geometry_info.chi;
1829 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1830 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1831 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1832 if (image->colorspace == CMYKColorspace)
1833 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1834 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1835 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1837 image_view=DestroyCacheView(image_view);
1841 if (LocaleCompare(attribute,"pointsize") == 0)
1845 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1846 info->image_info->pointsize=geometry_info.rho;
1850 if (LocaleCompare(attribute,"preview") == 0)
1852 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1853 SvPV(sval,na)) : SvIV(sval);
1856 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1861 info->image_info->preview_type=(PreviewType) sp;
1865 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1866 for ( ; image; image=image->next)
1867 SetImageProperty(image,attribute,SvPV(sval,na));
1873 if (LocaleCompare(attribute,"quality") == 0)
1876 info->image_info->quality=SvIV(sval);
1877 for ( ; image; image=image->next)
1878 image->quality=SvIV(sval);
1882 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1883 for ( ; image; image=image->next)
1884 SetImageProperty(image,attribute,SvPV(sval,na));
1890 if (LocaleCompare(attribute,"red-primary") == 0)
1892 for ( ; image; image=image->next)
1894 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1895 image->chromaticity.red_primary.x=geometry_info.rho;
1896 image->chromaticity.red_primary.y=geometry_info.sigma;
1897 if ((flags & SigmaValue) == 0)
1898 image->chromaticity.red_primary.y=
1899 image->chromaticity.red_primary.x;
1903 if (LocaleCompare(attribute,"render") == 0)
1905 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1906 SvPV(sval,na)) : SvIV(sval);
1909 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1913 for ( ; image; image=image->next)
1914 image->rendering_intent=(RenderingIntent) sp;
1917 if (LocaleCompare(attribute,"repage") == 0)
1922 for ( ; image; image=image->next)
1924 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1925 if ((flags & WidthValue) != 0)
1927 if ((flags & HeightValue) == 0)
1928 geometry.height=geometry.width;
1929 image->page.width=geometry.width;
1930 image->page.height=geometry.height;
1932 if ((flags & AspectValue) != 0)
1934 if ((flags & XValue) != 0)
1935 image->page.x+=geometry.x;
1936 if ((flags & YValue) != 0)
1937 image->page.y+=geometry.y;
1941 if ((flags & XValue) != 0)
1943 image->page.x=geometry.x;
1944 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1945 image->page.width=image->columns+geometry.x;
1947 if ((flags & YValue) != 0)
1949 image->page.y=geometry.y;
1950 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1951 image->page.height=image->rows+geometry.y;
1958 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1959 for ( ; image; image=image->next)
1960 SetImageProperty(image,attribute,SvPV(sval,na));
1966 if (LocaleCompare(attribute,"sampling-factor") == 0)
1968 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1970 ThrowPerlException(exception,OptionError,"MissingGeometry",
1975 (void) CloneString(&info->image_info->sampling_factor,
1979 if (LocaleCompare(attribute,"scene") == 0)
1981 for ( ; image; image=image->next)
1982 image->scene=SvIV(sval);
1985 if (LocaleCompare(attribute,"server") == 0)
1987 if (LocaleCompare(attribute,"size") == 0)
1991 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1993 ThrowPerlException(exception,OptionError,"MissingGeometry",
1997 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2001 if (LocaleCompare(attribute,"stroke") == 0)
2004 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2008 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2009 for ( ; image; image=image->next)
2010 SetImageProperty(image,attribute,SvPV(sval,na));
2016 if (LocaleCompare(attribute,"texture") == 0)
2019 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2022 if (LocaleCompare(attribute,"thread-limit") == 0)
2027 limit=MagickResourceInfinity;
2028 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2029 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2030 (void) SetMagickResourceLimit(ThreadResource,limit);
2033 if (LocaleCompare(attribute,"tile-offset") == 0)
2038 geometry=GetPageGeometry(SvPV(sval,na));
2040 (void) CloneString(&info->image_info->page,geometry);
2041 for ( ; image; image=image->next)
2042 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2044 geometry=(char *) RelinquishMagickMemory(geometry);
2047 if (LocaleCompare(attribute,"time-limit") == 0)
2052 limit=MagickResourceInfinity;
2053 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2054 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2055 (void) SetMagickResourceLimit(TimeResource,limit);
2058 if (LocaleCompare(attribute,"transparent-color") == 0)
2060 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2062 info->image_info->transparent_color=target_color;
2063 for ( ; image; image=image->next)
2064 image->transparent_color=target_color;
2067 if (LocaleCompare(attribute,"type") == 0)
2069 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2070 SvPV(sval,na)) : SvIV(sval);
2073 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2078 info->image_info->type=(ImageType) sp;
2079 for ( ; image; image=image->next)
2080 SetImageType(image,(ImageType) sp);
2084 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2085 for ( ; image; image=image->next)
2086 SetImageProperty(image,attribute,SvPV(sval,na));
2092 if (LocaleCompare(attribute,"units") == 0)
2094 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2095 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2098 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2103 info->image_info->units=(ResolutionType) sp;
2104 for ( ; image; image=image->next)
2109 units=(ResolutionType) sp;
2110 if (image->units != units)
2111 switch (image->units)
2113 case UndefinedResolution:
2114 case PixelsPerInchResolution:
2116 if (units == PixelsPerCentimeterResolution)
2118 image->x_resolution*=2.54;
2119 image->y_resolution*=2.54;
2123 case PixelsPerCentimeterResolution:
2125 if (units == PixelsPerInchResolution)
2127 image->x_resolution/=2.54;
2128 image->y_resolution/=2.54;
2138 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2139 for ( ; image; image=image->next)
2140 SetImageProperty(image,attribute,SvPV(sval,na));
2146 if (LocaleCompare(attribute,"verbose") == 0)
2148 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2149 SvPV(sval,na)) : SvIV(sval);
2152 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2157 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2160 if (LocaleCompare(attribute,"view") == 0)
2163 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2166 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2168 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2169 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2172 ThrowPerlException(exception,OptionError,
2173 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2177 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2178 for ( ; image; image=image->next)
2179 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2183 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2184 for ( ; image; image=image->next)
2185 SetImageProperty(image,attribute,SvPV(sval,na));
2191 if (LocaleCompare(attribute,"white-point") == 0)
2193 for ( ; image; image=image->next)
2195 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2196 image->chromaticity.white_point.x=geometry_info.rho;
2197 image->chromaticity.white_point.y=geometry_info.sigma;
2198 if ((flags & SigmaValue) == 0)
2199 image->chromaticity.white_point.y=
2200 image->chromaticity.white_point.x;
2205 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2206 for ( ; image; image=image->next)
2207 SetImageProperty(image,attribute,SvPV(sval,na));
2213 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2214 for ( ; image; image=image->next)
2215 SetImageProperty(image,attribute,SvPV(sval,na));
2222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2226 % S e t u p L i s t %
2230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2232 % Method SetupList returns the list of all the images linked by their
2233 % image->next and image->previous link lists for use with ImageMagick. If
2234 % info is non-NULL, an info structure is returned in *info. If
2235 % reference_vector is non-NULL,an array of SV* are returned in
2236 % *reference_vector. Reference_vector is used when the images are going to be
2237 % replaced with new Image*'s.
2239 % The format of the SetupList routine is:
2241 % Image *SetupList(SV *reference,struct PackageInfo **info,
2242 % SV ***reference_vector,ExceptionInfo *exception)
2244 % A description of each parameter follows:
2246 % o list: a list of strings.
2248 % o string: a character string.
2250 % o exception: Return any errors or warnings in this structure.
2253 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2254 SV ***reference_vector,ExceptionInfo *exception)
2263 if (reference_vector)
2264 *reference_vector=NULL;
2269 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2270 if (info && (SvTYPE(reference) == SVt_PVAV))
2271 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2281 % s t r E Q c a s e %
2285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2287 % strEQcase() compares two strings and returns 0 if they are the
2288 % same or if the second string runs out first. The comparison is case
2291 % The format of the strEQcase routine is:
2293 % ssize_t strEQcase(const char *p,const char *q)
2295 % A description of each parameter follows:
2297 % o p: a character string.
2299 % o q: a character string.
2303 static ssize_t strEQcase(const char *p,const char *q)
2311 for (i=0 ; (c=(*q)) != 0; i++)
2313 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2314 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2319 return(((*q == 0) && (*p == 0)) ? i : 0);
2323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2327 % I m a g e : : M a g i c k %
2331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2335 MODULE = Image::Magick PACKAGE = Image::Magick
2340 MagickCoreGenesis("PerlMagick",MagickFalse);
2341 SetWarningHandler(NULL);
2342 SetErrorHandler(NULL);
2343 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2344 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2350 if (magick_registry != (SplayTreeInfo *) NULL)
2351 magick_registry=DestroySplayTree(magick_registry);
2352 MagickCoreTerminus();
2356 constant(name,argument)
2361 ###############################################################################
2369 ###############################################################################
2374 Image::Magick ref=NO_INIT
2398 PERL_UNUSED_VAR(ref);
2399 PERL_UNUSED_VAR(ix);
2400 exception=AcquireExceptionInfo();
2401 perl_exception=newSVpv("",0);
2402 package_info=(struct PackageInfo *) NULL;
2403 if (sv_isobject(ST(0)) == 0)
2405 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2409 reference=SvRV(ST(0));
2410 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2411 if (image == (Image *) NULL)
2413 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2417 package_info=ClonePackageInfo(info,exception);
2419 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2422 for (i=2; i < items; i+=2)
2423 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2425 (void) AnimateImages(package_info->image_info,image);
2426 (void) CatchImageException(image);
2427 InheritException(exception,&image->exception);
2430 if (package_info != (struct PackageInfo *) NULL)
2431 DestroyPackageInfo(package_info);
2432 InheritPerlException(exception,perl_exception);
2433 exception=DestroyExceptionInfo(exception);
2434 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2435 SvPOK_on(perl_exception);
2436 ST(0)=sv_2mortal(perl_exception);
2441 ###############################################################################
2449 ###############################################################################
2454 Image::Magick ref=NO_INIT
2492 PERL_UNUSED_VAR(ref);
2493 PERL_UNUSED_VAR(ix);
2494 exception=AcquireExceptionInfo();
2495 perl_exception=newSVpv("",0);
2499 if (sv_isobject(ST(0)) == 0)
2501 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2505 reference=SvRV(ST(0));
2506 hv=SvSTASH(reference);
2508 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2510 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2511 if (image == (Image *) NULL)
2513 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2517 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2522 for (i=2; i < items; i+=2)
2524 attribute=(char *) SvPV(ST(i-1),na);
2530 if (LocaleCompare(attribute,"stack") == 0)
2532 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2536 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2542 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2548 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2554 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2555 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2557 for ( ; image; image=image->next)
2559 AddImageToRegistry(sv,image);
2561 av_push(av,sv_bless(rv,hv));
2564 exception=DestroyExceptionInfo(exception);
2566 SvREFCNT_dec(perl_exception);
2570 InheritPerlException(exception,perl_exception);
2571 exception=DestroyExceptionInfo(exception);
2572 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2573 SvPOK_on(perl_exception);
2574 ST(0)=sv_2mortal(perl_exception);
2579 ###############################################################################
2587 ###############################################################################
2592 Image::Magick ref=NO_INIT
2623 PERL_UNUSED_VAR(ref);
2624 PERL_UNUSED_VAR(ix);
2625 exception=AcquireExceptionInfo();
2626 perl_exception=newSVpv("",0);
2628 if (sv_isobject(ST(0)) == 0)
2630 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2634 reference=SvRV(ST(0));
2635 hv=SvSTASH(reference);
2636 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2637 if (image == (Image *) NULL)
2639 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2643 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2644 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2647 Create blessed Perl array for the returned image.
2650 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2652 AddImageToRegistry(sv,image);
2654 av_push(av,sv_bless(rv,hv));
2656 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2657 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2658 "average-%.*s",(int) (MaxTextExtent-9),
2659 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2660 (void) CopyMagickString(image->filename,info->image_info->filename,
2662 SetImageInfo(info->image_info,0,exception);
2663 exception=DestroyExceptionInfo(exception);
2664 SvREFCNT_dec(perl_exception);
2668 InheritPerlException(exception,perl_exception);
2669 exception=DestroyExceptionInfo(exception);
2670 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2671 SvPOK_on(perl_exception);
2672 ST(0)=sv_2mortal(perl_exception);
2677 ###############################################################################
2681 # B l o b T o I m a g e #
2685 ###############################################################################
2689 BlobToImage(ref,...)
2690 Image::Magick ref=NO_INIT
2736 PERL_UNUSED_VAR(ref);
2737 PERL_UNUSED_VAR(ix);
2738 exception=AcquireExceptionInfo();
2739 perl_exception=newSVpv("",0);
2742 ac=(items < 2) ? 1 : items-1;
2743 length=(STRLEN *) NULL;
2744 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2745 if (list == (char **) NULL)
2747 ThrowPerlException(exception,ResourceLimitError,
2748 "MemoryAllocationFailed",PackageName);
2751 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2752 if (length == (STRLEN *) NULL)
2754 ThrowPerlException(exception,ResourceLimitError,
2755 "MemoryAllocationFailed",PackageName);
2758 if (sv_isobject(ST(0)) == 0)
2760 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2764 reference=SvRV(ST(0));
2765 hv=SvSTASH(reference);
2766 if (SvTYPE(reference) != SVt_PVAV)
2768 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2772 av=(AV *) reference;
2773 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2778 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2781 for (n=0, i=0; i < ac; i++)
2783 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2784 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2786 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2791 list[n]=(char *) NULL;
2793 for (i=number_images=0; i < n; i++)
2795 image=BlobToImage(info->image_info,list[i],length[i],exception);
2796 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2798 for ( ; image; image=image->next)
2800 AddImageToRegistry(sv,image);
2802 av_push(av,sv_bless(rv,hv));
2810 for (i=0; i < n; i++)
2811 if (list[i] != (char *) NULL)
2812 for (p=keep; list[i] != *p++; )
2813 if (*p == (char *) NULL)
2815 list[i]=(char *) RelinquishMagickMemory(list[i]);
2821 list=(char **) RelinquishMagickMemory(list);
2823 length=(STRLEN *) RelinquishMagickMemory(length);
2824 InheritPerlException(exception,perl_exception);
2825 exception=DestroyExceptionInfo(exception);
2826 sv_setiv(perl_exception,(IV) number_images);
2827 SvPOK_on(perl_exception);
2828 ST(0)=sv_2mortal(perl_exception);
2833 ###############################################################################
2841 ###############################################################################
2846 Image::Magick ref=NO_INIT
2879 PERL_UNUSED_VAR(ref);
2880 PERL_UNUSED_VAR(ix);
2881 exception=AcquireExceptionInfo();
2882 perl_exception=newSVpv("",0);
2884 if (sv_isobject(ST(0)) == 0)
2886 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2890 reference=SvRV(ST(0));
2891 hv=SvSTASH(reference);
2892 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2893 if (image == (Image *) NULL)
2895 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2900 Create blessed Perl array for the returned image.
2903 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2905 for ( ; image; image=image->next)
2907 clone=CloneImage(image,0,0,MagickTrue,exception);
2908 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2910 AddImageToRegistry(sv,clone);
2912 av_push(av,sv_bless(rv,hv));
2915 exception=DestroyExceptionInfo(exception);
2916 SvREFCNT_dec(perl_exception);
2920 InheritPerlException(exception,perl_exception);
2921 exception=DestroyExceptionInfo(exception);
2922 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2923 SvPOK_on(perl_exception);
2924 ST(0)=sv_2mortal(perl_exception);
2929 ###############################################################################
2937 ###############################################################################
2945 PERL_UNUSED_VAR(ref);
2946 if (magick_registry != (SplayTreeInfo *) NULL)
2951 ResetSplayTreeIterator(magick_registry);
2952 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2953 while (p != (Image *) NULL)
2956 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2962 ###############################################################################
2970 ###############################################################################
2975 Image::Magick ref=NO_INIT
3004 PERL_UNUSED_VAR(ref);
3005 PERL_UNUSED_VAR(ix);
3006 exception=AcquireExceptionInfo();
3007 perl_exception=newSVpv("",0);
3009 if (sv_isobject(ST(0)) == 0)
3011 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3015 reference=SvRV(ST(0));
3016 hv=SvSTASH(reference);
3018 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3020 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3021 if (image == (Image *) NULL)
3023 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3027 image=CoalesceImages(image,exception);
3028 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3030 for ( ; image; image=image->next)
3032 AddImageToRegistry(sv,image);
3034 av_push(av,sv_bless(rv,hv));
3037 exception=DestroyExceptionInfo(exception);
3039 SvREFCNT_dec(perl_exception);
3043 InheritPerlException(exception,perl_exception);
3044 exception=DestroyExceptionInfo(exception);
3045 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3046 SvPOK_on(perl_exception);
3047 ST(0)=sv_2mortal(perl_exception);
3052 ###############################################################################
3060 ###############################################################################
3065 Image::Magick ref=NO_INIT
3111 PERL_UNUSED_VAR(ref);
3112 PERL_UNUSED_VAR(ix);
3113 exception=AcquireExceptionInfo();
3114 perl_exception=newSVpv("",0);
3118 if (sv_isobject(ST(0)) == 0)
3120 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3124 reference=SvRV(ST(0));
3125 hv=SvSTASH(reference);
3127 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3129 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3130 if (image == (Image *) NULL)
3132 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3136 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3140 reconstruct_image=image;
3141 metric=RootMeanSquaredErrorMetric;
3142 for (i=2; i < items; i+=2)
3144 attribute=(char *) SvPV(ST(i-1),na);
3150 if (LocaleCompare(attribute,"channel") == 0)
3155 option=ParseChannelOption(SvPV(ST(i),na));
3158 ThrowPerlException(exception,OptionError,
3159 "UnrecognizedType",SvPV(ST(i),na));
3162 SetPixelChannelMap(image,(ChannelType) option);
3165 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3172 if (LocaleCompare(attribute,"fuzz") == 0)
3174 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3177 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3184 if (LocaleCompare(attribute,"image") == 0)
3186 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3187 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3190 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3197 if (LocaleCompare(attribute,"metric") == 0)
3199 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3203 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3207 metric=(MetricType) option;
3210 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3216 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3222 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3224 if (difference_image != (Image *) NULL)
3226 difference_image->error.mean_error_per_pixel=distortion;
3227 AddImageToRegistry(sv,difference_image);
3229 av_push(av,sv_bless(rv,hv));
3232 exception=DestroyExceptionInfo(exception);
3234 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3238 InheritPerlException(exception,perl_exception);
3239 exception=DestroyExceptionInfo(exception);
3240 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3241 SvPOK_on(perl_exception);
3242 ST(0)=sv_2mortal(perl_exception);
3247 ###############################################################################
3251 # C o m p a r e L a y e r s #
3255 ###############################################################################
3260 Image::Magick ref=NO_INIT
3262 CompareImagesLayers = 1
3264 compareimagelayers = 3
3301 PERL_UNUSED_VAR(ref);
3302 PERL_UNUSED_VAR(ix);
3303 exception=AcquireExceptionInfo();
3304 perl_exception=newSVpv("",0);
3306 if (sv_isobject(ST(0)) == 0)
3308 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3312 reference=SvRV(ST(0));
3313 hv=SvSTASH(reference);
3315 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3317 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3318 if (image == (Image *) NULL)
3320 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3324 method=CompareAnyLayer;
3325 for (i=2; i < items; i+=2)
3327 attribute=(char *) SvPV(ST(i-1),na);
3333 if (LocaleCompare(attribute,"method") == 0)
3335 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3339 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3343 method=(ImageLayerMethod) option;
3346 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3352 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3358 image=CompareImagesLayers(image,method,exception);
3359 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3361 for ( ; image; image=image->next)
3363 AddImageToRegistry(sv,image);
3365 av_push(av,sv_bless(rv,hv));
3368 exception=DestroyExceptionInfo(exception);
3370 SvREFCNT_dec(perl_exception);
3374 InheritPerlException(exception,perl_exception);
3375 exception=DestroyExceptionInfo(exception);
3376 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3377 SvPOK_on(perl_exception);
3378 ST(0)=sv_2mortal(perl_exception);
3383 ###############################################################################
3391 ###############################################################################
3396 Image::Magick ref=NO_INIT
3402 PERL_UNUSED_VAR(ref);
3403 if (sv_isobject(ST(0)) == 0)
3404 croak("ReferenceIsNotMyType");
3405 reference=SvRV(ST(0));
3406 switch (SvTYPE(reference))
3411 message[MaxTextExtent];
3429 Array (AV *) reference
3431 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3432 XS_VERSION,reference);
3433 hv=gv_stashpv(PackageName, FALSE);
3436 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3440 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3442 info=(struct PackageInfo *) SvIV(sv);
3443 DestroyPackageInfo(info);
3445 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3455 Blessed scalar = (Image *) SvIV(reference)
3457 image=(Image *) SvIV(reference);
3458 if (image != (Image *) NULL)
3459 DeleteImageFromRegistry(reference,image);
3468 ###############################################################################
3476 ###############################################################################
3481 Image::Magick ref=NO_INIT
3505 PERL_UNUSED_VAR(ref);
3506 PERL_UNUSED_VAR(ix);
3507 exception=AcquireExceptionInfo();
3508 perl_exception=newSVpv("",0);
3509 package_info=(struct PackageInfo *) NULL;
3510 if (sv_isobject(ST(0)) == 0)
3512 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3516 reference=SvRV(ST(0));
3517 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3518 if (image == (Image *) NULL)
3520 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3524 package_info=ClonePackageInfo(info,exception);
3526 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3529 for (i=2; i < items; i+=2)
3530 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3532 (void) DisplayImages(package_info->image_info,image);
3533 (void) CatchImageException(image);
3534 InheritException(exception,&image->exception);
3537 if (package_info != (struct PackageInfo *) NULL)
3538 DestroyPackageInfo(package_info);
3539 InheritPerlException(exception,perl_exception);
3540 exception=DestroyExceptionInfo(exception);
3541 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3542 SvPOK_on(perl_exception);
3543 ST(0)=sv_2mortal(perl_exception);
3548 ###############################################################################
3552 # E v a l u a t e I m a g e s #
3556 ###############################################################################
3561 Image::Magick ref=NO_INIT
3583 MagickEvaluateOperator
3598 PERL_UNUSED_VAR(ref);
3599 PERL_UNUSED_VAR(ix);
3600 exception=AcquireExceptionInfo();
3601 perl_exception=newSVpv("",0);
3603 if (sv_isobject(ST(0)) == 0)
3605 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3609 reference=SvRV(ST(0));
3610 hv=SvSTASH(reference);
3611 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3612 if (image == (Image *) NULL)
3614 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3618 op=MeanEvaluateOperator;
3624 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3628 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3632 op=(MagickEvaluateOperator) in;
3635 for (i=2; i < items; i+=2)
3637 attribute=(char *) SvPV(ST(i-1),na);
3643 if (LocaleCompare(attribute,"operator") == 0)
3648 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3649 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3652 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3656 op=(MagickEvaluateOperator) in;
3659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3665 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3671 image=EvaluateImages(image,op,exception);
3672 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3675 Create blessed Perl array for the returned image.
3678 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3680 AddImageToRegistry(sv,image);
3682 av_push(av,sv_bless(rv,hv));
3684 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3685 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3686 "evaluate-%.*s",(int) (MaxTextExtent-9),
3687 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3688 (void) CopyMagickString(image->filename,info->image_info->filename,
3690 SetImageInfo(info->image_info,0,exception);
3691 exception=DestroyExceptionInfo(exception);
3692 SvREFCNT_dec(perl_exception);
3696 InheritPerlException(exception,perl_exception);
3697 exception=DestroyExceptionInfo(exception);
3698 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3699 SvPOK_on(perl_exception);
3700 ST(0)=sv_2mortal(perl_exception);
3705 ###############################################################################
3713 ###############################################################################
3718 Image::Magick ref=NO_INIT
3725 #define ChannelFeatures(channel,direction) \
3727 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3728 channel_features[channel].angular_second_moment[direction]); \
3729 PUSHs(sv_2mortal(newSVpv(message,0))); \
3730 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3731 channel_features[channel].contrast[direction]); \
3732 PUSHs(sv_2mortal(newSVpv(message,0))); \
3733 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3734 channel_features[channel].contrast[direction]); \
3735 PUSHs(sv_2mortal(newSVpv(message,0))); \
3736 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3737 channel_features[channel].variance_sum_of_squares[direction]); \
3738 PUSHs(sv_2mortal(newSVpv(message,0))); \
3739 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3740 channel_features[channel].inverse_difference_moment[direction]); \
3741 PUSHs(sv_2mortal(newSVpv(message,0))); \
3742 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3743 channel_features[channel].sum_average[direction]); \
3744 PUSHs(sv_2mortal(newSVpv(message,0))); \
3745 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3746 channel_features[channel].sum_variance[direction]); \
3747 PUSHs(sv_2mortal(newSVpv(message,0))); \
3748 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3749 channel_features[channel].sum_entropy[direction]); \
3750 PUSHs(sv_2mortal(newSVpv(message,0))); \
3751 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3752 channel_features[channel].entropy[direction]); \
3753 PUSHs(sv_2mortal(newSVpv(message,0))); \
3754 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3755 channel_features[channel].difference_variance[direction]); \
3756 PUSHs(sv_2mortal(newSVpv(message,0))); \
3757 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3758 channel_features[channel].difference_entropy[direction]); \
3759 PUSHs(sv_2mortal(newSVpv(message,0))); \
3760 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3761 channel_features[channel].measure_of_correlation_1[direction]); \
3762 PUSHs(sv_2mortal(newSVpv(message,0))); \
3763 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3764 channel_features[channel].measure_of_correlation_2[direction]); \
3765 PUSHs(sv_2mortal(newSVpv(message,0))); \
3766 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3767 channel_features[channel].maximum_correlation_coefficient[direction]); \
3768 PUSHs(sv_2mortal(newSVpv(message,0))); \
3776 message[MaxTextExtent];
3803 PERL_UNUSED_VAR(ref);
3804 PERL_UNUSED_VAR(ix);
3805 exception=AcquireExceptionInfo();
3806 perl_exception=newSVpv("",0);
3808 if (sv_isobject(ST(0)) == 0)
3810 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3814 reference=SvRV(ST(0));
3817 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3818 if (image == (Image *) NULL)
3820 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3824 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3826 for (i=2; i < items; i+=2)
3828 attribute=(char *) SvPV(ST(i-1),na);
3834 if (LocaleCompare(attribute,"distance") == 0)
3836 distance=StringToLong((char *) SvPV(ST(1),na));
3839 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3845 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3852 for ( ; image; image=image->next)
3854 channel_features=GetImageFeatures(image,distance,
3856 if (channel_features == (ChannelFeatures *) NULL)
3859 EXTEND(sp,75*count);
3860 for (i=0; i < 4; i++)
3862 ChannelFeatures(RedChannel,i);
3863 ChannelFeatures(GreenChannel,i);
3864 ChannelFeatures(BlueChannel,i);
3865 if (image->colorspace == CMYKColorspace)
3866 ChannelFeatures(BlackChannel,i);
3867 if (image->matte != MagickFalse)
3868 ChannelFeatures(AlphaChannel,i);
3870 channel_features=(ChannelFeatures *)
3871 RelinquishMagickMemory(channel_features);
3875 InheritPerlException(exception,perl_exception);
3876 exception=DestroyExceptionInfo(exception);
3877 SvREFCNT_dec(perl_exception);
3881 ###############################################################################
3889 ###############################################################################
3894 Image::Magick ref=NO_INIT
3932 PERL_UNUSED_VAR(ref);
3933 PERL_UNUSED_VAR(ix);
3934 exception=AcquireExceptionInfo();
3935 perl_exception=newSVpv("",0);
3937 if (sv_isobject(ST(0)) == 0)
3939 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3943 reference=SvRV(ST(0));
3944 hv=SvSTASH(reference);
3945 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3946 if (image == (Image *) NULL)
3948 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3952 background_color=image->background_color;
3954 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3957 for (i=2; i < items; i+=2)
3959 attribute=(char *) SvPV(ST(i-1),na);
3965 if (LocaleCompare(attribute,"background") == 0)
3967 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3968 &background_color,exception);
3971 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3977 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3983 image->background_color=background_color;
3984 image=MergeImageLayers(image,FlattenLayer,exception);
3985 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3988 Create blessed Perl array for the returned image.
3991 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3993 AddImageToRegistry(sv,image);
3995 av_push(av,sv_bless(rv,hv));
3997 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3998 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3999 "flatten-%.*s",(int) (MaxTextExtent-9),
4000 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4001 (void) CopyMagickString(image->filename,info->image_info->filename,
4003 SetImageInfo(info->image_info,0,exception);
4004 exception=DestroyExceptionInfo(exception);
4005 SvREFCNT_dec(perl_exception);
4009 InheritPerlException(exception,perl_exception);
4010 exception=DestroyExceptionInfo(exception);
4011 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4012 SvPOK_on(perl_exception); /* return messages in string context */
4013 ST(0)=sv_2mortal(perl_exception);
4018 ###############################################################################
4026 ###############################################################################
4031 Image::Magick ref=NO_INIT
4043 expression[MaxTextExtent];
4070 PERL_UNUSED_VAR(ref);
4071 PERL_UNUSED_VAR(ix);
4072 exception=AcquireExceptionInfo();
4073 perl_exception=newSVpv("",0);
4077 if (sv_isobject(ST(0)) == 0)
4079 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4083 reference=SvRV(ST(0));
4084 hv=SvSTASH(reference);
4086 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4088 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4089 if (image == (Image *) NULL)
4091 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4095 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4099 channel=DefaultChannels;
4100 (void) CopyMagickString(expression,"u",MaxTextExtent);
4102 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4104 for (i=2; i < items; i+=2)
4106 attribute=(char *) SvPV(ST(i-1),na);
4112 if (LocaleCompare(attribute,"channel") == 0)
4117 option=ParseChannelOption(SvPV(ST(i),na));
4120 ThrowPerlException(exception,OptionError,
4121 "UnrecognizedType",SvPV(ST(i),na));
4124 channel=(ChannelType) option;
4127 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4134 if (LocaleCompare(attribute,"expression") == 0)
4136 (void) CopyMagickString(expression,SvPV(ST(i),na),
4140 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4146 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4152 PushPixelChannelMap(image,channel);
4153 image=FxImage(image,expression,exception);
4154 if (image != (Image *) NULL)
4155 PopPixelChannelMap(image);
4156 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4158 for ( ; image; image=image->next)
4160 AddImageToRegistry(sv,image);
4162 av_push(av,sv_bless(rv,hv));
4165 exception=DestroyExceptionInfo(exception);
4167 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4171 InheritPerlException(exception,perl_exception);
4172 exception=DestroyExceptionInfo(exception);
4173 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4174 SvPOK_on(perl_exception);
4175 ST(0)=sv_2mortal(perl_exception);
4180 ###############################################################################
4188 ###############################################################################
4193 Image::Magick ref=NO_INIT
4204 color[MaxTextExtent];
4229 PERL_UNUSED_VAR(ref);
4230 PERL_UNUSED_VAR(ix);
4231 exception=AcquireExceptionInfo();
4232 perl_exception=newSVpv("",0);
4233 if (sv_isobject(ST(0)) == 0)
4235 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4239 reference=SvRV(ST(0));
4240 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4241 if (image == (Image *) NULL && !info)
4244 for (i=1; i < items; i++)
4246 attribute=(char *) SvPV(ST(i),na);
4253 if (LocaleCompare(attribute,"adjoin") == 0)
4256 s=newSViv((ssize_t) info->image_info->adjoin);
4257 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4260 if (LocaleCompare(attribute,"antialias") == 0)
4263 s=newSViv((ssize_t) info->image_info->antialias);
4264 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4267 if (LocaleCompare(attribute,"area") == 0)
4269 s=newSViv(GetMagickResource(AreaResource));
4270 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4273 if (LocaleCompare(attribute,"attenuate") == 0)
4278 value=GetImageProperty(image,attribute);
4279 if (value != (const char *) NULL)
4281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4284 if (LocaleCompare(attribute,"authenticate") == 0)
4287 s=newSVpv(info->image_info->authenticate,0);
4288 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4291 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4298 if (LocaleCompare(attribute,"background") == 0)
4300 if (image == (Image *) NULL)
4302 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4303 QuantumFormat "," QuantumFormat "," QuantumFormat,
4304 image->background_color.red,image->background_color.green,
4305 image->background_color.blue,image->background_color.alpha);
4307 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4310 if (LocaleCompare(attribute,"base-columns") == 0)
4312 if (image != (Image *) NULL)
4313 s=newSViv((ssize_t) image->magick_columns);
4314 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4317 if (LocaleCompare(attribute,"base-filename") == 0)
4319 if (image != (Image *) NULL)
4320 s=newSVpv(image->magick_filename,0);
4321 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4324 if (LocaleCompare(attribute,"base-height") == 0)
4326 if (image != (Image *) NULL)
4327 s=newSViv((ssize_t) image->magick_rows);
4328 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4331 if (LocaleCompare(attribute,"base-rows") == 0)
4333 if (image != (Image *) NULL)
4334 s=newSViv((ssize_t) image->magick_rows);
4335 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4338 if (LocaleCompare(attribute,"base-width") == 0)
4340 if (image != (Image *) NULL)
4341 s=newSViv((ssize_t) image->magick_columns);
4342 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4345 if (LocaleCompare(attribute,"bias") == 0)
4347 if (image != (Image *) NULL)
4348 s=newSVnv(image->bias);
4349 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4352 if (LocaleCompare(attribute,"blue-primary") == 0)
4354 if (image == (Image *) NULL)
4356 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4357 image->chromaticity.blue_primary.x,
4358 image->chromaticity.blue_primary.y);
4360 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4363 if (LocaleCompare(attribute,"bordercolor") == 0)
4365 if (image == (Image *) NULL)
4367 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4368 QuantumFormat "," QuantumFormat "," QuantumFormat,
4369 image->border_color.red,image->border_color.green,
4370 image->border_color.blue,image->border_color.alpha);
4372 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4375 if (LocaleCompare(attribute,"bounding-box") == 0)
4378 geometry[MaxTextExtent];
4383 if (image == (Image *) NULL)
4385 page=GetImageBoundingBox(image,&image->exception);
4386 (void) FormatLocaleString(geometry,MaxTextExtent,
4387 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4388 page.height,(double) page.x,(double) page.y);
4389 s=newSVpv(geometry,0);
4390 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4393 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4400 if (LocaleCompare(attribute,"class") == 0)
4402 if (image == (Image *) NULL)
4404 s=newSViv(image->storage_class);
4405 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4406 image->storage_class));
4408 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4411 if (LocaleCompare(attribute,"clip-mask") == 0)
4413 if (image != (Image *) NULL)
4419 if (image->mask == (Image *) NULL)
4421 if (image->mask != (Image *) NULL)
4423 AddImageToRegistry(sv,image->mask);
4424 s=sv_bless(newRV(sv),SvSTASH(reference));
4427 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4430 if (LocaleCompare(attribute,"clip-path") == 0)
4432 if (image != (Image *) NULL)
4438 if (image->clip_mask == (Image *) NULL)
4440 if (image->clip_mask != (Image *) NULL)
4442 AddImageToRegistry(sv,image->clip_mask);
4443 s=sv_bless(newRV(sv),SvSTASH(reference));
4446 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4449 if (LocaleCompare(attribute,"compression") == 0)
4451 j=info ? info->image_info->compression : image ?
4452 image->compression : UndefinedCompression;
4454 if (info->image_info->compression == UndefinedCompression)
4455 j=image->compression;
4457 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4460 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4463 if (LocaleCompare(attribute,"colorspace") == 0)
4465 j=image ? image->colorspace : RGBColorspace;
4467 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4470 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4473 if (LocaleCompare(attribute,"colors") == 0)
4475 if (image != (Image *) NULL)
4476 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4477 &image->exception));
4478 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4481 if (LocaleNCompare(attribute,"colormap",8) == 0)
4486 if (image == (Image *) NULL || !image->colormap)
4489 items=sscanf(attribute,"%*[^[][%ld",&j);
4491 if (j > (ssize_t) image->colors)
4493 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4494 QuantumFormat "," QuantumFormat "," QuantumFormat,
4495 image->colormap[j].red,image->colormap[j].green,
4496 image->colormap[j].blue,image->colormap[j].alpha);
4498 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4501 if (LocaleCompare(attribute,"columns") == 0)
4503 if (image != (Image *) NULL)
4504 s=newSViv((ssize_t) image->columns);
4505 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4508 if (LocaleCompare(attribute,"comment") == 0)
4513 value=GetImageProperty(image,attribute);
4514 if (value != (const char *) NULL)
4516 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4519 if (LocaleCompare(attribute,"copyright") == 0)
4521 s=newSVpv(GetMagickCopyright(),0);
4522 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4525 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4532 if (LocaleCompare(attribute,"density") == 0)
4535 geometry[MaxTextExtent];
4537 if (image == (Image *) NULL)
4539 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4540 image->x_resolution,image->y_resolution);
4541 s=newSVpv(geometry,0);
4542 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4545 if (LocaleCompare(attribute,"delay") == 0)
4547 if (image != (Image *) NULL)
4548 s=newSViv((ssize_t) image->delay);
4549 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4552 if (LocaleCompare(attribute,"depth") == 0)
4554 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4555 if (image != (Image *) NULL)
4556 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4557 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4560 if (LocaleCompare(attribute,"directory") == 0)
4562 if (image && image->directory)
4563 s=newSVpv(image->directory,0);
4564 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4567 if (LocaleCompare(attribute,"dispose") == 0)
4569 if (image == (Image *) NULL)
4572 s=newSViv(image->dispose);
4574 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4576 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4579 if (LocaleCompare(attribute,"disk") == 0)
4581 s=newSViv(GetMagickResource(DiskResource));
4582 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4585 if (LocaleCompare(attribute,"dither") == 0)
4588 s=newSViv((ssize_t) info->image_info->dither);
4589 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4592 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4594 if (info && info->image_info->server_name)
4595 s=newSVpv(info->image_info->server_name,0);
4596 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4599 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4606 if (LocaleCompare(attribute,"elapsed-time") == 0)
4608 if (image != (Image *) NULL)
4609 s=newSVnv(GetElapsedTime(&image->timer));
4610 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4613 if (LocaleCompare(attribute,"endian") == 0)
4615 j=info ? info->image_info->endian : image ? image->endian :
4618 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4623 if (LocaleCompare(attribute,"error") == 0)
4625 if (image != (Image *) NULL)
4626 s=newSVnv(image->error.mean_error_per_pixel);
4627 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4630 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4637 if (LocaleCompare(attribute,"filesize") == 0)
4639 if (image != (Image *) NULL)
4640 s=newSViv((ssize_t) GetBlobSize(image));
4641 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4644 if (LocaleCompare(attribute,"filename") == 0)
4646 if (info && info->image_info->filename &&
4647 *info->image_info->filename)
4648 s=newSVpv(info->image_info->filename,0);
4649 if (image != (Image *) NULL)
4650 s=newSVpv(image->filename,0);
4651 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4654 if (LocaleCompare(attribute,"filter") == 0)
4656 s=image ? newSViv(image->filter) : newSViv(0);
4657 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4660 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4663 if (LocaleCompare(attribute,"font") == 0)
4665 if (info && info->image_info->font)
4666 s=newSVpv(info->image_info->font,0);
4667 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4670 if (LocaleCompare(attribute,"foreground") == 0)
4672 if (LocaleCompare(attribute,"format") == 0)
4677 magick_info=(const MagickInfo *) NULL;
4678 if (info && (*info->image_info->magick != '\0'))
4679 magick_info=GetMagickInfo(info->image_info->magick,exception);
4680 if (image != (Image *) NULL)
4681 magick_info=GetMagickInfo(image->magick,&image->exception);
4682 if ((magick_info != (const MagickInfo *) NULL) &&
4683 (*magick_info->description != '\0'))
4684 s=newSVpv((char *) magick_info->description,0);
4685 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4688 if (LocaleCompare(attribute,"fuzz") == 0)
4691 s=newSVnv(info->image_info->fuzz);
4692 if (image != (Image *) NULL)
4693 s=newSVnv(image->fuzz);
4694 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4704 if (LocaleCompare(attribute,"gamma") == 0)
4706 if (image != (Image *) NULL)
4707 s=newSVnv(image->gamma);
4708 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4711 if (LocaleCompare(attribute,"geometry") == 0)
4713 if (image && image->geometry)
4714 s=newSVpv(image->geometry,0);
4715 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4718 if (LocaleCompare(attribute,"gravity") == 0)
4720 s=image ? newSViv(image->gravity) : newSViv(0);
4721 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4724 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4727 if (LocaleCompare(attribute,"green-primary") == 0)
4729 if (image == (Image *) NULL)
4731 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4732 image->chromaticity.green_primary.x,
4733 image->chromaticity.green_primary.y);
4735 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4738 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4745 if (LocaleCompare(attribute,"height") == 0)
4747 if (image != (Image *) NULL)
4748 s=newSViv((ssize_t) image->rows);
4749 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4752 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4759 if (LocaleCompare(attribute,"icc") == 0)
4761 if (image != (Image *) NULL)
4766 profile=GetImageProfile(image,"icc");
4767 if (profile != (StringInfo *) NULL)
4768 s=newSVpv((const char *) GetStringInfoDatum(profile),
4769 GetStringInfoLength(profile));
4771 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4774 if (LocaleCompare(attribute,"icm") == 0)
4776 if (image != (Image *) NULL)
4781 profile=GetImageProfile(image,"icm");
4782 if (profile != (const StringInfo *) NULL)
4783 s=newSVpv((const char *) GetStringInfoDatum(profile),
4784 GetStringInfoLength(profile));
4786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4789 if (LocaleCompare(attribute,"id") == 0)
4791 if (image != (Image *) NULL)
4802 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4804 status=SetImageRegistry(ImageRegistryType,key,image,
4809 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4812 if (LocaleNCompare(attribute,"index",5) == 0)
4815 name[MaxTextExtent];
4824 register const Quantum
4830 if (image == (Image *) NULL)
4832 if (image->storage_class != PseudoClass)
4836 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4838 image_view=AcquireCacheView(image);
4839 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4840 if (p != (const Quantum *) NULL)
4842 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4843 GetPixelIndex(image,p));
4845 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4847 image_view=DestroyCacheView(image_view);
4850 if (LocaleCompare(attribute,"iptc") == 0)
4852 if (image != (Image *) NULL)
4857 profile=GetImageProfile(image,"iptc");
4858 if (profile != (const StringInfo *) NULL)
4859 s=newSVpv((const char *) GetStringInfoDatum(profile),
4860 GetStringInfoLength(profile));
4862 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4865 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4867 if (image != (Image *) NULL)
4868 s=newSViv((ssize_t) image->iterations);
4869 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4872 if (LocaleCompare(attribute,"interlace") == 0)
4874 j=info ? info->image_info->interlace : image ? image->interlace :
4877 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4880 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4883 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4890 if (LocaleCompare(attribute,"label") == 0)
4895 if (image == (Image *) NULL)
4897 value=GetImageProperty(image,"Label");
4898 if (value != (const char *) NULL)
4900 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4903 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4905 if (image != (Image *) NULL)
4906 s=newSViv((ssize_t) image->iterations);
4907 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4910 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4917 if (LocaleCompare(attribute,"magick") == 0)
4919 if (info && *info->image_info->magick)
4920 s=newSVpv(info->image_info->magick,0);
4921 if (image != (Image *) NULL)
4922 s=newSVpv(image->magick,0);
4923 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4926 if (LocaleCompare(attribute,"map") == 0)
4928 s=newSViv(GetMagickResource(MapResource));
4929 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4932 if (LocaleCompare(attribute,"maximum-error") == 0)
4934 if (image != (Image *) NULL)
4935 s=newSVnv(image->error.normalized_maximum_error);
4936 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4939 if (LocaleCompare(attribute,"memory") == 0)
4941 s=newSViv(GetMagickResource(MemoryResource));
4942 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4945 if (LocaleCompare(attribute,"mean-error") == 0)
4947 if (image != (Image *) NULL)
4948 s=newSVnv(image->error.normalized_mean_error);
4949 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4952 if (LocaleCompare(attribute,"mime") == 0)
4954 if (info && *info->image_info->magick)
4955 s=newSVpv(MagickToMime(info->image_info->magick),0);
4956 if (image != (Image *) NULL)
4957 s=newSVpv(MagickToMime(image->magick),0);
4958 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4961 if (LocaleCompare(attribute,"mattecolor") == 0)
4963 if (image == (Image *) NULL)
4965 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4966 QuantumFormat "," QuantumFormat "," QuantumFormat,
4967 image->matte_color.red,image->matte_color.green,
4968 image->matte_color.blue,image->matte_color.alpha);
4970 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4973 if (LocaleCompare(attribute,"matte") == 0)
4975 if (image != (Image *) NULL)
4976 s=newSViv((ssize_t) image->matte);
4977 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4980 if (LocaleCompare(attribute,"mime") == 0)
4986 if (info && *info->image_info->magick)
4987 magick=info->image_info->magick;
4988 if (image != (Image *) NULL)
4989 magick=image->magick;
4995 mime=MagickToMime(magick);
4997 mime=(char *) RelinquishMagickMemory(mime);
4999 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5002 if (LocaleCompare(attribute,"monochrome") == 0)
5004 if (image == (Image *) NULL)
5006 j=info ? info->image_info->monochrome :
5007 IsImageMonochrome(image,&image->exception);
5009 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5012 if (LocaleCompare(attribute,"montage") == 0)
5014 if (image && image->montage)
5015 s=newSVpv(image->montage,0);
5016 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5019 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5026 if (LocaleCompare(attribute,"orientation") == 0)
5028 j=info ? info->image_info->orientation : image ?
5029 image->orientation : UndefinedOrientation;
5031 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5034 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5037 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5044 if (LocaleCompare(attribute,"page") == 0)
5046 if (info && info->image_info->page)
5047 s=newSVpv(info->image_info->page,0);
5048 if (image != (Image *) NULL)
5051 geometry[MaxTextExtent];
5053 (void) FormatLocaleString(geometry,MaxTextExtent,
5054 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5055 (double) image->page.height,(double) image->page.x,(double)
5057 s=newSVpv(geometry,0);
5059 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5062 if (LocaleCompare(attribute,"page.x") == 0)
5064 if (image != (Image *) NULL)
5065 s=newSViv((ssize_t) image->page.x);
5066 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5069 if (LocaleCompare(attribute,"page.y") == 0)
5071 if (image != (Image *) NULL)
5072 s=newSViv((ssize_t) image->page.y);
5073 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5076 if (LocaleNCompare(attribute,"pixel",5) == 0)
5079 tuple[MaxTextExtent];
5088 register const Quantum
5091 if (image == (Image *) NULL)
5095 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5097 p=GetVirtualPixels(image,x,y,1,1,exception);
5098 if (image->colorspace != CMYKColorspace)
5099 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5100 QuantumFormat "," QuantumFormat "," QuantumFormat,
5101 GetPixelRed(image,p),GetPixelGreen(image,p),
5102 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5104 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5105 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5106 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5107 GetPixelBlue(image,p),GetPixelBlack(image,p),
5108 GetPixelAlpha(image,p));
5110 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5113 if (LocaleCompare(attribute,"pointsize") == 0)
5116 s=newSViv((ssize_t) info->image_info->pointsize);
5117 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5120 if (LocaleCompare(attribute,"preview") == 0)
5122 s=newSViv(info->image_info->preview_type);
5123 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5124 info->image_info->preview_type));
5126 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5136 if (LocaleCompare(attribute,"quality") == 0)
5139 s=newSViv((ssize_t) info->image_info->quality);
5140 if (image != (Image *) NULL)
5141 s=newSViv((ssize_t) image->quality);
5142 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5145 if (LocaleCompare(attribute,"quantum") == 0)
5148 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5149 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5152 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5159 if (LocaleCompare(attribute,"rendering-intent") == 0)
5161 s=newSViv(image->rendering_intent);
5162 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5163 image->rendering_intent));
5165 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5168 if (LocaleCompare(attribute,"red-primary") == 0)
5170 if (image == (Image *) NULL)
5172 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5173 image->chromaticity.red_primary.x,
5174 image->chromaticity.red_primary.y);
5176 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5179 if (LocaleCompare(attribute,"rows") == 0)
5181 if (image != (Image *) NULL)
5182 s=newSViv((ssize_t) image->rows);
5183 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5186 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5193 if (LocaleCompare(attribute,"sampling-factor") == 0)
5195 if (info && info->image_info->sampling_factor)
5196 s=newSVpv(info->image_info->sampling_factor,0);
5197 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5200 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5202 if (info && info->image_info->server_name)
5203 s=newSVpv(info->image_info->server_name,0);
5204 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5207 if (LocaleCompare(attribute,"size") == 0)
5209 if (info && info->image_info->size)
5210 s=newSVpv(info->image_info->size,0);
5211 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5214 if (LocaleCompare(attribute,"scene") == 0)
5216 if (image != (Image *) NULL)
5217 s=newSViv((ssize_t) image->scene);
5218 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5221 if (LocaleCompare(attribute,"scenes") == 0)
5223 if (image != (Image *) NULL)
5224 s=newSViv((ssize_t) info->image_info->number_scenes);
5225 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5228 if (LocaleCompare(attribute,"signature") == 0)
5233 if (image == (Image *) NULL)
5235 (void) SignatureImage(image);
5236 value=GetImageProperty(image,"Signature");
5237 if (value != (const char *) NULL)
5239 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5242 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5249 if (LocaleCompare(attribute,"taint") == 0)
5251 if (image != (Image *) NULL)
5252 s=newSViv((ssize_t) IsTaintImage(image));
5253 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5256 if (LocaleCompare(attribute,"texture") == 0)
5258 if (info && info->image_info->texture)
5259 s=newSVpv(info->image_info->texture,0);
5260 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5263 if (LocaleCompare(attribute,"total-ink-density") == 0)
5265 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5266 if (image != (Image *) NULL)
5267 s=newSVnv(GetImageTotalInkDensity(image));
5268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5271 if (LocaleCompare(attribute,"transparent-color") == 0)
5273 if (image == (Image *) NULL)
5275 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5276 QuantumFormat "," QuantumFormat "," QuantumFormat,
5277 image->transparent_color.red,image->transparent_color.green,
5278 image->transparent_color.blue,image->transparent_color.alpha);
5280 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5283 if (LocaleCompare(attribute,"type") == 0)
5285 if (image == (Image *) NULL)
5287 j=(ssize_t) GetImageType(image,&image->exception);
5289 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5291 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5294 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5301 if (LocaleCompare(attribute,"units") == 0)
5303 j=info ? info->image_info->units : image ? image->units :
5304 UndefinedResolution;
5305 if (info && (info->image_info->units == UndefinedResolution))
5308 if (j == UndefinedResolution)
5309 s=newSVpv("undefined units",0);
5311 if (j == PixelsPerInchResolution)
5312 s=newSVpv("pixels / inch",0);
5314 s=newSVpv("pixels / centimeter",0);
5315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5318 if (LocaleCompare(attribute,"user-time") == 0)
5320 if (image != (Image *) NULL)
5321 s=newSVnv(GetUserTime(&image->timer));
5322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5325 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5332 if (LocaleCompare(attribute,"verbose") == 0)
5335 s=newSViv((ssize_t) info->image_info->verbose);
5336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5339 if (LocaleCompare(attribute,"version") == 0)
5341 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5342 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5345 if (LocaleCompare(attribute,"view") == 0)
5347 if (info && info->image_info->view)
5348 s=newSVpv(info->image_info->view,0);
5349 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5352 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5354 if (image == (Image *) NULL)
5356 j=(ssize_t) GetImageVirtualPixelMethod(image);
5358 (void) sv_setpv(s,CommandOptionToMnemonic(
5359 MagickVirtualPixelOptions,j));
5361 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5364 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5371 if (LocaleCompare(attribute,"white-point") == 0)
5373 if (image == (Image *) NULL)
5375 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5376 image->chromaticity.white_point.x,
5377 image->chromaticity.white_point.y);
5379 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5382 if (LocaleCompare(attribute,"width") == 0)
5384 if (image != (Image *) NULL)
5385 s=newSViv((ssize_t) image->columns);
5386 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5389 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5396 if (LocaleCompare(attribute,"x-resolution") == 0)
5398 if (image != (Image *) NULL)
5399 s=newSVnv(image->x_resolution);
5400 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5403 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5410 if (LocaleCompare(attribute,"y-resolution") == 0)
5412 if (image != (Image *) NULL)
5413 s=newSVnv(image->y_resolution);
5414 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5417 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5424 if (image == (Image *) NULL)
5425 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5429 value=GetImageProperty(image,attribute);
5430 if (value != (const char *) NULL)
5433 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5436 if (*attribute != '%')
5437 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5444 meta=InterpretImageProperties(info ? info->image_info :
5445 (ImageInfo *) NULL,image,attribute);
5447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5448 meta=(char *) RelinquishMagickMemory(meta);
5452 exception=DestroyExceptionInfo(exception);
5453 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5457 ###############################################################################
5461 # G e t A u t h e n t i c P i x e l s #
5465 ###############################################################################
5469 GetAuthenticPixels(ref,...)
5470 Image::Magick ref = NO_INIT
5472 getauthenticpixels = 1
5502 PERL_UNUSED_VAR(ref);
5503 PERL_UNUSED_VAR(ix);
5504 exception=AcquireExceptionInfo();
5505 perl_exception=newSVpv("",0);
5506 if (sv_isobject(ST(0)) == 0)
5508 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5512 reference=SvRV(ST(0));
5514 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5515 if (image == (Image *) NULL)
5517 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5524 region.width=image->columns;
5527 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5528 for (i=2; i < items; i+=2)
5530 attribute=(char *) SvPV(ST(i-1),na);
5536 if (LocaleCompare(attribute,"geometry") == 0)
5538 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5548 if (LocaleCompare(attribute,"height") == 0)
5550 region.height=SvIV(ST(i));
5553 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5560 if (LocaleCompare(attribute,"x") == 0)
5562 region.x=SvIV(ST(i));
5565 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5572 if (LocaleCompare(attribute,"y") == 0)
5574 region.y=SvIV(ST(i));
5577 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5584 if (LocaleCompare(attribute,"width") == 0)
5586 region.width=SvIV(ST(i));
5589 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5595 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5596 region.height,exception);
5597 if (blob != (void *) NULL)
5601 InheritPerlException(exception,perl_exception);
5602 exception=DestroyExceptionInfo(exception);
5603 SvREFCNT_dec(perl_exception); /* throw away all errors */
5612 ###############################################################################
5616 # G e t V i r t u a l P i x e l s #
5620 ###############################################################################
5624 GetVirtualPixels(ref,...)
5625 Image::Magick ref = NO_INIT
5627 getvirtualpixels = 1
5628 AcquireImagePixels = 2
5629 acquireimagepixels = 3
5657 PERL_UNUSED_VAR(ref);
5658 PERL_UNUSED_VAR(ix);
5659 exception=AcquireExceptionInfo();
5660 perl_exception=newSVpv("",0);
5661 if (sv_isobject(ST(0)) == 0)
5663 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5667 reference=SvRV(ST(0));
5669 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5670 if (image == (Image *) NULL)
5672 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5679 region.width=image->columns;
5682 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5683 for (i=2; i < items; i+=2)
5685 attribute=(char *) SvPV(ST(i-1),na);
5691 if (LocaleCompare(attribute,"geometry") == 0)
5693 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5696 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5703 if (LocaleCompare(attribute,"height") == 0)
5705 region.height=SvIV(ST(i));
5708 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5715 if (LocaleCompare(attribute,"x") == 0)
5717 region.x=SvIV(ST(i));
5720 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5727 if (LocaleCompare(attribute,"y") == 0)
5729 region.y=SvIV(ST(i));
5732 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5739 if (LocaleCompare(attribute,"width") == 0)
5741 region.width=SvIV(ST(i));
5744 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5750 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5751 region.height,exception);
5752 if (blob != (void *) NULL)
5756 InheritPerlException(exception,perl_exception);
5757 exception=DestroyExceptionInfo(exception);
5758 SvREFCNT_dec(perl_exception); /* throw away all errors */
5761 RETVAL = (void *) blob;
5767 ###############################################################################
5771 # G e t A u t h e n t i c M e t a c o n t e n t #
5775 ###############################################################################
5779 GetAuthenticMetacontent(ref,...)
5780 Image::Magick ref = NO_INIT
5782 getauthenticmetacontent = 1
5803 PERL_UNUSED_VAR(ref);
5804 PERL_UNUSED_VAR(ix);
5805 exception=AcquireExceptionInfo();
5806 perl_exception=newSVpv("",0);
5807 if (sv_isobject(ST(0)) == 0)
5809 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5813 reference=SvRV(ST(0));
5815 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5816 if (image == (Image *) NULL)
5818 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5823 blob=(void *) GetAuthenticMetacontent(image);
5824 if (blob != (void *) NULL)
5828 InheritPerlException(exception,perl_exception);
5829 exception=DestroyExceptionInfo(exception);
5830 SvREFCNT_dec(perl_exception); /* throw away all errors */
5839 ###############################################################################
5843 # G e t V i r t u a l M e t a c o n t e n t #
5847 ###############################################################################
5851 GetVirtualMetacontent(ref,...)
5852 Image::Magick ref = NO_INIT
5854 getvirtualmetacontent = 1
5873 PERL_UNUSED_VAR(ref);
5874 PERL_UNUSED_VAR(ix);
5875 exception=AcquireExceptionInfo();
5876 perl_exception=newSVpv("",0);
5877 if (sv_isobject(ST(0)) == 0)
5879 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5883 reference=SvRV(ST(0));
5885 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5886 if (image == (Image *) NULL)
5888 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5893 blob=(void *) GetVirtualMetacontent(image);
5894 if (blob != (void *) NULL)
5898 InheritPerlException(exception,perl_exception);
5899 exception=DestroyExceptionInfo(exception);
5900 SvREFCNT_dec(perl_exception); /* throw away all errors */
5909 ###############################################################################
5913 # H i s t o g r a m #
5917 ###############################################################################
5922 Image::Magick ref=NO_INIT
5933 message[MaxTextExtent];
5960 PERL_UNUSED_VAR(ref);
5961 PERL_UNUSED_VAR(ix);
5962 exception=AcquireExceptionInfo();
5963 perl_exception=newSVpv("",0);
5965 if (sv_isobject(ST(0)) == 0)
5967 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5971 reference=SvRV(ST(0));
5974 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5975 if (image == (Image *) NULL)
5977 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5981 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5983 for ( ; image; image=image->next)
5985 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5986 if (histogram == (PixelPacket *) NULL)
5988 count+=(ssize_t) number_colors;
5990 for (i=0; i < (ssize_t) number_colors; i++)
5992 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5994 PUSHs(sv_2mortal(newSVpv(message,0)));
5995 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5996 histogram[i].green);
5997 PUSHs(sv_2mortal(newSVpv(message,0)));
5998 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6000 PUSHs(sv_2mortal(newSVpv(message,0)));
6001 if (image->colorspace == CMYKColorspace)
6003 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6004 histogram[i].black);
6005 PUSHs(sv_2mortal(newSVpv(message,0)));
6007 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6008 histogram[i].alpha);
6009 PUSHs(sv_2mortal(newSVpv(message,0)));
6010 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6011 histogram[i].count);
6012 PUSHs(sv_2mortal(newSVpv(message,0)));
6014 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6018 InheritPerlException(exception,perl_exception);
6019 exception=DestroyExceptionInfo(exception);
6020 SvREFCNT_dec(perl_exception);
6024 ###############################################################################
6032 ###############################################################################
6037 Image::Magick ref=NO_INIT
6061 register const Quantum
6075 *reference; /* reference is the SV* of ref=SvIV(reference) */
6077 PERL_UNUSED_VAR(ref);
6078 PERL_UNUSED_VAR(ix);
6079 exception=AcquireExceptionInfo();
6080 perl_exception=newSVpv("",0);
6081 reference=SvRV(ST(0));
6082 av=(AV *) reference;
6083 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6085 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6086 if (image == (Image *) NULL)
6088 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6092 normalize=MagickTrue;
6095 region.width=image->columns;
6098 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6099 for (i=2; i < items; i+=2)
6101 attribute=(char *) SvPV(ST(i-1),na);
6107 if (LocaleCompare(attribute,"channel") == 0)
6112 option=ParseChannelOption(SvPV(ST(i),na));
6115 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6119 SetPixelChannelMap(image,(ChannelType) option);
6122 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6129 if (LocaleCompare(attribute,"geometry") == 0)
6131 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6134 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6141 if (LocaleCompare(attribute,"normalize") == 0)
6143 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6147 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6151 normalize=option != 0 ? MagickTrue : MagickFalse;
6154 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6161 if (LocaleCompare(attribute,"x") == 0)
6163 region.x=SvIV(ST(i));
6166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6173 if (LocaleCompare(attribute,"y") == 0)
6175 region.y=SvIV(ST(i));
6178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6184 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6190 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6191 if (p == (const Quantum *) NULL)
6199 if (normalize != MagickFalse)
6200 scale=1.0/QuantumRange;
6201 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6202 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6203 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6204 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6205 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6206 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6207 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6208 (image->colorspace == CMYKColorspace))
6209 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6210 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6211 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6215 InheritPerlException(exception,perl_exception);
6216 exception=DestroyExceptionInfo(exception);
6217 SvREFCNT_dec(perl_exception);
6221 ###############################################################################
6225 # G e t P i x e l s #
6229 ###############################################################################
6234 Image::Magick ref=NO_INIT
6273 *reference; /* reference is the SV* of ref=SvIV(reference) */
6275 PERL_UNUSED_VAR(ref);
6276 PERL_UNUSED_VAR(ix);
6277 exception=AcquireExceptionInfo();
6278 perl_exception=newSVpv("",0);
6279 reference=SvRV(ST(0));
6280 av=(AV *) reference;
6281 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6283 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6284 if (image == (Image *) NULL)
6286 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6291 if (image->matte != MagickFalse)
6293 if (image->colorspace == CMYKColorspace)
6296 if (image->matte != MagickFalse)
6299 normalize=MagickFalse;
6302 region.width=image->columns;
6305 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6306 for (i=2; i < items; i+=2)
6308 attribute=(char *) SvPV(ST(i-1),na);
6314 if (LocaleCompare(attribute,"geometry") == 0)
6316 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6319 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6326 if (LocaleCompare(attribute,"height") == 0)
6328 region.height=SvIV(ST(i));
6331 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6338 if (LocaleCompare(attribute,"map") == 0)
6343 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6350 if (LocaleCompare(attribute,"normalize") == 0)
6352 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6356 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6360 normalize=option != 0 ? MagickTrue : MagickFalse;
6363 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6370 if (LocaleCompare(attribute,"width") == 0)
6372 region.width=SvIV(ST(i));
6375 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6382 if (LocaleCompare(attribute,"x") == 0)
6384 region.x=SvIV(ST(i));
6387 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6394 if (LocaleCompare(attribute,"y") == 0)
6396 region.y=SvIV(ST(i));
6399 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6405 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6411 if (normalize != MagickFalse)
6416 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6417 region.height*sizeof(*pixels));
6418 if (pixels == (float *) NULL)
6420 ThrowPerlException(exception,ResourceLimitError,
6421 "MemoryAllocationFailed",PackageName);
6424 status=ExportImagePixels(image,region.x,region.y,region.width,
6425 region.height,map,FloatPixel,pixels,exception);
6426 if (status == MagickFalse)
6430 EXTEND(sp,strlen(map)*region.width*region.height);
6431 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6432 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6434 pixels=(float *) RelinquishMagickMemory(pixels);
6441 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6442 region.height*sizeof(*pixels));
6443 if (pixels == (Quantum *) NULL)
6445 ThrowPerlException(exception,ResourceLimitError,
6446 "MemoryAllocationFailed",PackageName);
6449 status=ExportImagePixels(image,region.x,region.y,region.width,
6450 region.height,map,QuantumPixel,pixels,exception);
6451 if (status == MagickFalse)
6455 EXTEND(sp,strlen(map)*region.width*region.height);
6456 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6457 PUSHs(sv_2mortal(newSViv(pixels[i])));
6459 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6463 InheritPerlException(exception,perl_exception);
6464 exception=DestroyExceptionInfo(exception);
6465 SvREFCNT_dec(perl_exception);
6469 ###############################################################################
6473 # I m a g e T o B l o b #
6477 ###############################################################################
6481 ImageToBlob(ref,...)
6482 Image::Magick ref=NO_INIT
6491 filename[MaxTextExtent];
6520 PERL_UNUSED_VAR(ref);
6521 PERL_UNUSED_VAR(ix);
6522 exception=AcquireExceptionInfo();
6523 perl_exception=newSVpv("",0);
6524 package_info=(struct PackageInfo *) NULL;
6525 if (sv_isobject(ST(0)) == 0)
6527 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6531 reference=SvRV(ST(0));
6532 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6533 if (image == (Image *) NULL)
6535 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6539 package_info=ClonePackageInfo(info,exception);
6540 for (i=2; i < items; i+=2)
6541 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6542 (void) CopyMagickString(filename,package_info->image_info->filename,
6545 for (next=image; next; next=next->next)
6547 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6548 next->scene=scene++;
6550 SetImageInfo(package_info->image_info,(unsigned int)
6551 GetImageListLength(image),&image->exception);
6552 EXTEND(sp,(ssize_t) GetImageListLength(image));
6553 for ( ; image; image=image->next)
6556 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6557 if (blob != (char *) NULL)
6559 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6560 blob=(unsigned char *) RelinquishMagickMemory(blob);
6562 if (package_info->image_info->adjoin)
6567 if (package_info != (struct PackageInfo *) NULL)
6568 DestroyPackageInfo(package_info);
6569 InheritPerlException(exception,perl_exception);
6570 exception=DestroyExceptionInfo(exception);
6571 SvREFCNT_dec(perl_exception); /* throw away all errors */
6575 ###############################################################################
6583 ###############################################################################
6588 Image::Magick ref=NO_INIT
6592 OptimizeImageLayers = 3
6594 optimizeimagelayers = 5
6636 PERL_UNUSED_VAR(ref);
6637 PERL_UNUSED_VAR(ix);
6638 exception=AcquireExceptionInfo();
6639 perl_exception=newSVpv("",0);
6641 if (sv_isobject(ST(0)) == 0)
6643 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6647 reference=SvRV(ST(0));
6648 hv=SvSTASH(reference);
6650 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6652 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6653 if (image == (Image *) NULL)
6655 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6659 compose=image->compose;
6660 method=OptimizeLayer;
6661 for (i=2; i < items; i+=2)
6663 attribute=(char *) SvPV(ST(i-1),na);
6669 if (LocaleCompare(attribute,"compose") == 0)
6671 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6672 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6675 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6679 compose=(CompositeOperator) sp;
6682 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6689 if (LocaleCompare(attribute,"method") == 0)
6691 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6695 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6699 method=(ImageLayerMethod) option;
6702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6708 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6714 layers=(Image *) NULL;
6717 case CompareAnyLayer:
6718 case CompareClearLayer:
6719 case CompareOverlayLayer:
6722 layers=CompareImagesLayers(image,method,exception);
6729 layers=MergeImageLayers(image,method,exception);
6734 layers=DisposeImages(image,exception);
6737 case OptimizeImageLayer:
6739 layers=OptimizeImageLayers(image,exception);
6742 case OptimizePlusLayer:
6744 layers=OptimizePlusImageLayers(image,exception);
6747 case OptimizeTransLayer:
6749 OptimizeImageTransparency(image,exception);
6750 InheritException(&(image->exception),exception);
6753 case RemoveDupsLayer:
6755 RemoveDuplicateLayers(&image,exception);
6756 InheritException(&(image->exception),exception);
6759 case RemoveZeroLayer:
6761 RemoveZeroDelayLayers(&image,exception);
6762 InheritException(&(image->exception),exception);
6771 General Purpose, GIF Animation Optimizer.
6773 layers=CoalesceImages(image,exception);
6774 if (layers == (Image *) NULL)
6776 InheritException(&(layers->exception),exception);
6778 layers=OptimizeImageLayers(image,exception);
6779 if (layers == (Image *) NULL)
6781 InheritException(&(layers->exception),exception);
6782 image=DestroyImageList(image);
6784 layers=(Image *) NULL;
6785 OptimizeImageTransparency(image,exception);
6786 InheritException(&(image->exception),exception);
6787 quantize_info=AcquireQuantizeInfo(info->image_info);
6788 (void) RemapImages(quantize_info,image,(Image *) NULL);
6789 quantize_info=DestroyQuantizeInfo(quantize_info);
6792 case CompositeLayer:
6801 Split image sequence at the first 'NULL:' image.
6804 while (source != (Image *) NULL)
6806 source=GetNextImageInList(source);
6807 if ((source != (Image *) NULL) &&
6808 (LocaleCompare(source->magick,"NULL") == 0))
6811 if (source != (Image *) NULL)
6813 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6814 (GetNextImageInList(source) == (Image *) NULL))
6815 source=(Image *) NULL;
6819 Separate the two lists, junk the null: image.
6821 source=SplitImageList(source->previous);
6822 DeleteImageFromList(&source);
6825 if (source == (Image *) NULL)
6827 (void) ThrowMagickException(exception,GetMagickModule(),
6828 OptionError,"MissingNullSeparator","layers Composite");
6832 Adjust offset with gravity and virtual canvas.
6834 SetGeometry(image,&geometry);
6835 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6836 geometry.width=source->page.width != 0 ? source->page.width :
6838 geometry.height=source->page.height != 0 ? source->page.height :
6840 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6841 image->columns,image->page.height != 0 ? image->page.height :
6842 image->rows,image->gravity,&geometry);
6843 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6844 source=DestroyImageList(source);
6845 InheritException(&(image->exception),exception);
6849 if (layers != (Image *) NULL)
6851 InheritException(&(layers->exception),exception);
6854 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6856 for ( ; image; image=image->next)
6858 AddImageToRegistry(sv,image);
6860 av_push(av,sv_bless(rv,hv));
6863 exception=DestroyExceptionInfo(exception);
6865 SvREFCNT_dec(perl_exception);
6869 InheritPerlException(exception,perl_exception);
6870 exception=DestroyExceptionInfo(exception);
6871 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6872 SvPOK_on(perl_exception);
6873 ST(0)=sv_2mortal(perl_exception);
6878 ###############################################################################
6882 # M a g i c k T o M i m e #
6886 ###############################################################################
6890 MagickToMime(ref,name)
6891 Image::Magick ref=NO_INIT
6900 PERL_UNUSED_VAR(ref);
6901 PERL_UNUSED_VAR(ix);
6902 mime=MagickToMime(name);
6903 RETVAL=newSVpv(mime,0);
6904 mime=(char *) RelinquishMagickMemory(mime);
6910 ###############################################################################
6918 ###############################################################################
6923 Image::Magick ref=NO_INIT
6960 MedianConvolveImage = 36
6966 ReduceNoiseImage = 42
6992 ColorFloodfillImage= 68
6998 CycleColormapImage = 74
7008 MatteFloodfillImage= 84
7016 NumberColorsImage = 92
7026 SignatureImage = 102
7036 TransparentImage = 112
7038 ThresholdImage = 114
7052 DeconstructImage = 130
7054 GaussianBlurImage = 132
7060 UnsharpMaskImage = 138
7062 MotionBlurImage = 140
7064 OrderedDitherImage = 142
7071 AffineTransform = 149
7072 AffineTransformImage = 150
7074 DifferenceImage = 152
7075 AdaptiveThreshold = 153
7076 AdaptiveThresholdImage = 154
7081 BlackThreshold = 159
7082 BlackThresholdImage= 160
7083 WhiteThreshold = 161
7084 WhiteThresholdImage= 162
7086 RadialBlurImage = 164
7088 ThumbnailImage = 166
7098 PosterizeImage = 176
7104 SepiaToneImage = 182
7105 SigmoidalContrast = 183
7106 SigmoidalContrastImage = 184
7111 ContrastStretch = 189
7112 ContrastStretchImage = 190
7117 AdaptiveSharpen = 195
7118 AdaptiveSharpenImage = 196
7120 TransposeImage = 198
7122 TransverseImage = 200
7124 AutoOrientImage = 202
7126 AdaptiveBlurImage = 204
7130 UniqueColorsImage = 208
7131 AdaptiveResize = 209
7132 AdaptiveResizeImage= 210
7136 LinearStretchImage = 214
7143 FloodfillPaint = 221
7144 FloodfillPaintImage= 222
7150 LiquidRescaleImage = 228
7160 SparseColorImage = 238
7164 SelectiveBlurImage = 242
7168 BlueShiftImage = 246
7169 ForwardFourierTransform = 247
7170 ForwardFourierTransformImage = 248
7171 InverseFourierTransform = 249
7172 InverseFourierTransformImage = 250
7173 ColorDecisionList = 251
7174 ColorDecisionListImage = 252
7176 AutoGammaImage = 254
7178 AutoLevelImage = 256
7180 LevelImageColors = 258
7183 BrightnessContrast = 263
7184 BrightnessContrastImage = 264
7186 MorphologyImage = 266
7188 ColorMatrixImage = 268
7194 StatisticImage = 274
7203 attribute_flag[MaxArguments],
7204 message[MaxTextExtent];
7264 argument_list[MaxArguments];
7266 PERL_UNUSED_VAR(ref);
7267 PERL_UNUSED_VAR(ix);
7268 exception=AcquireExceptionInfo();
7269 perl_exception=newSVpv("",0);
7270 reference_vector=NULL;
7274 if (sv_isobject(ST(0)) == 0)
7276 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7280 reference=SvRV(ST(0));
7281 region_info.width=0;
7282 region_info.height=0;
7285 region_image=(Image *) NULL;
7286 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7287 if (ix && (ix != 666))
7290 Called as Method(...)
7293 rp=(&Methods[ix-1]);
7299 Called as Mogrify("Method",...)
7301 attribute=(char *) SvPV(ST(1),na);
7304 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7305 attribute=(char *) SvPV(ST(2),na);
7308 for (rp=Methods; ; rp++)
7310 if (rp >= EndOf(Methods))
7312 ThrowPerlException(exception,OptionError,
7313 "UnrecognizedPerlMagickMethod",attribute);
7316 if (strEQcase(attribute,rp->name))
7322 if (image == (Image *) NULL)
7324 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7327 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7328 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7329 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7346 pp=(Arguments *) NULL;
7354 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7356 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7358 if (strEQcase(attribute,qq->method) > ssize_test)
7361 ssize_test=strEQcase(attribute,qq->method);
7364 if (pp == (Arguments *) NULL)
7366 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7368 goto continue_outer_loop;
7370 al=(&argument_list[pp-rp->arguments]);
7373 case ArrayReference:
7375 if (SvTYPE(sv) != SVt_RV)
7377 (void) FormatLocaleString(message,MaxTextExtent,
7378 "invalid %.60s value",pp->method);
7379 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7380 goto continue_outer_loop;
7382 al->array_reference=SvRV(sv);
7387 al->real_reference=SvNV(sv);
7392 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7395 case ImageReference:
7397 if (!sv_isobject(sv) ||
7398 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7399 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7401 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7407 case IntegerReference:
7409 al->integer_reference=SvIV(sv);
7412 case StringReference:
7414 al->string_reference=(char *) SvPV(sv,al->length);
7415 if (sv_isobject(sv))
7416 al->image_reference=SetupList(aTHX_ SvRV(sv),
7417 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7423 Is a string; look up name.
7425 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7427 al->string_reference=(char *) SvPV(sv,al->length);
7428 al->integer_reference=(-1);
7431 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7432 MagickFalse,SvPV(sv,na));
7433 if (pp->type == MagickChannelOptions)
7434 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7435 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7437 (void) FormatLocaleString(message,MaxTextExtent,
7438 "invalid %.60s value",pp->method);
7439 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7440 goto continue_outer_loop;
7445 attribute_flag[pp-rp->arguments]++;
7446 continue_outer_loop: ;
7448 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7449 pv=reference_vector;
7450 SetGeometryInfo(&geometry_info);
7451 channel=DefaultChannels;
7452 for (next=image; next; next=next->next)
7455 SetGeometry(image,&geometry);
7456 if ((region_info.width*region_info.height) != 0)
7459 image=CropImage(image,®ion_info,exception);
7465 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7466 ThrowPerlException(exception,OptionError,
7467 "UnrecognizedPerlMagickMethod",message);
7470 case 1: /* Comment */
7472 if (attribute_flag[0] == 0)
7473 argument_list[0].string_reference=(char *) NULL;
7474 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7475 info ? info->image_info : (ImageInfo *) NULL,image,
7476 argument_list[0].string_reference));
7481 if (attribute_flag[0] == 0)
7482 argument_list[0].string_reference=(char *) NULL;
7483 (void) SetImageProperty(image,"label",InterpretImageProperties(
7484 info ? info->image_info : (ImageInfo *) NULL,image,
7485 argument_list[0].string_reference));
7488 case 3: /* AddNoise */
7490 if (attribute_flag[0] == 0)
7491 argument_list[0].integer_reference=UniformNoise;
7492 if (attribute_flag[1] != 0)
7493 channel=(ChannelType) argument_list[1].integer_reference;
7494 PushPixelChannelMap(image,channel);
7495 image=AddNoiseImage(image,(NoiseType)
7496 argument_list[0].integer_reference,exception);
7497 if (image != (Image *) NULL)
7498 PopPixelChannelMap(image);
7501 case 4: /* Colorize */
7506 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7507 if (attribute_flag[0] != 0)
7508 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7510 if (attribute_flag[1] == 0)
7511 argument_list[1].string_reference="100%";
7512 image=ColorizeImage(image,argument_list[1].string_reference,target,
7516 case 5: /* Border */
7520 if (attribute_flag[0] != 0)
7522 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7523 &geometry,exception);
7524 if ((flags & HeightValue) == 0)
7525 geometry.height=geometry.width;
7527 if (attribute_flag[1] != 0)
7528 geometry.width=argument_list[1].integer_reference;
7529 if (attribute_flag[2] != 0)
7530 geometry.height=argument_list[2].integer_reference;
7531 if (attribute_flag[3] != 0)
7532 QueryColorDatabase(argument_list[3].string_reference,
7533 &image->border_color,exception);
7534 if (attribute_flag[4] != 0)
7535 QueryColorDatabase(argument_list[4].string_reference,
7536 &image->border_color,exception);
7537 if (attribute_flag[5] != 0)
7538 QueryColorDatabase(argument_list[5].string_reference,
7539 &image->border_color,exception);
7540 if (attribute_flag[6] != 0)
7541 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7542 image=BorderImage(image,&geometry,exception);
7547 if (attribute_flag[0] != 0)
7549 flags=ParseGeometry(argument_list[0].string_reference,
7551 if ((flags & SigmaValue) == 0)
7552 geometry_info.sigma=1.0;
7554 if (attribute_flag[1] != 0)
7555 geometry_info.rho=argument_list[1].real_reference;
7556 if (attribute_flag[2] != 0)
7557 geometry_info.sigma=argument_list[2].real_reference;
7558 if (attribute_flag[3] != 0)
7559 channel=(ChannelType) argument_list[3].integer_reference;
7560 PushPixelChannelMap(image,channel);
7561 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7563 if (image != (Image *) NULL)
7564 PopPixelChannelMap(image);
7569 if (attribute_flag[0] != 0)
7570 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7571 &geometry,exception);
7572 if (attribute_flag[1] != 0)
7573 geometry.width=argument_list[1].integer_reference;
7574 if (attribute_flag[2] != 0)
7575 geometry.height=argument_list[2].integer_reference;
7576 if (attribute_flag[3] != 0)
7577 geometry.x=argument_list[3].integer_reference;
7578 if (attribute_flag[4] != 0)
7579 geometry.y=argument_list[4].integer_reference;
7580 image=ChopImage(image,&geometry,exception);
7585 if (attribute_flag[6] != 0)
7586 image->gravity=(GravityType) argument_list[6].integer_reference;
7587 if (attribute_flag[0] != 0)
7588 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7589 &geometry,exception);
7590 if (attribute_flag[1] != 0)
7591 geometry.width=argument_list[1].integer_reference;
7592 if (attribute_flag[2] != 0)
7593 geometry.height=argument_list[2].integer_reference;
7594 if (attribute_flag[3] != 0)
7595 geometry.x=argument_list[3].integer_reference;
7596 if (attribute_flag[4] != 0)
7597 geometry.y=argument_list[4].integer_reference;
7598 if (attribute_flag[5] != 0)
7600 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7601 image=CropImage(image,&geometry,exception);
7604 case 9: /* Despeckle */
7606 image=DespeckleImage(image,exception);
7611 if (attribute_flag[0] != 0)
7612 geometry_info.rho=argument_list[0].real_reference;
7613 image=EdgeImage(image,geometry_info.rho,exception);
7616 case 11: /* Emboss */
7618 if (attribute_flag[0] != 0)
7620 flags=ParseGeometry(argument_list[0].string_reference,
7622 if ((flags & SigmaValue) == 0)
7623 geometry_info.sigma=1.0;
7625 if (attribute_flag[1] != 0)
7626 geometry_info.rho=argument_list[1].real_reference;
7627 if (attribute_flag[2] != 0)
7628 geometry_info.sigma=argument_list[2].real_reference;
7629 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7633 case 12: /* Enhance */
7635 image=EnhanceImage(image,exception);
7640 image=FlipImage(image,exception);
7645 image=FlopImage(image,exception);
7648 case 15: /* Frame */
7653 if (attribute_flag[0] != 0)
7655 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7656 &geometry,exception);
7657 if ((flags & HeightValue) == 0)
7658 geometry.height=geometry.width;
7659 frame_info.width=geometry.width;
7660 frame_info.height=geometry.height;
7661 frame_info.outer_bevel=geometry.x;
7662 frame_info.inner_bevel=geometry.y;
7664 if (attribute_flag[1] != 0)
7665 frame_info.width=argument_list[1].integer_reference;
7666 if (attribute_flag[2] != 0)
7667 frame_info.height=argument_list[2].integer_reference;
7668 if (attribute_flag[3] != 0)
7669 frame_info.inner_bevel=argument_list[3].integer_reference;
7670 if (attribute_flag[4] != 0)
7671 frame_info.outer_bevel=argument_list[4].integer_reference;
7672 if (attribute_flag[5] != 0)
7673 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7675 if (attribute_flag[6] != 0)
7676 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7678 frame_info.x=(ssize_t) frame_info.width;
7679 frame_info.y=(ssize_t) frame_info.height;
7680 frame_info.width=image->columns+2*frame_info.x;
7681 frame_info.height=image->rows+2*frame_info.y;
7682 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7683 image->matte_color=fill_color;
7684 if (attribute_flag[7] != 0)
7685 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7686 image=FrameImage(image,&frame_info,exception);
7689 case 16: /* Implode */
7691 if (attribute_flag[0] == 0)
7692 argument_list[0].real_reference=0.5;
7693 if (attribute_flag[1] != 0)
7694 image->interpolate=(InterpolatePixelMethod)
7695 argument_list[1].integer_reference;
7696 image=ImplodeImage(image,argument_list[0].real_reference,
7700 case 17: /* Magnify */
7702 image=MagnifyImage(image,exception);
7705 case 18: /* MedianFilter */
7707 if (attribute_flag[0] != 0)
7709 flags=ParseGeometry(argument_list[0].string_reference,
7711 if ((flags & SigmaValue) == 0)
7712 geometry_info.sigma=1.0;
7714 if (attribute_flag[1] != 0)
7715 geometry_info.rho=argument_list[1].real_reference;
7716 if (attribute_flag[2] != 0)
7717 geometry_info.sigma=argument_list[2].real_reference;
7718 if (attribute_flag[3] != 0)
7719 channel=(ChannelType) argument_list[3].integer_reference;
7720 PushPixelChannelMap(image,channel);
7721 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7722 (size_t) geometry_info.sigma,exception);
7723 if (image != (Image *) NULL)
7724 PopPixelChannelMap(image);
7727 case 19: /* Minify */
7729 image=MinifyImage(image,exception);
7732 case 20: /* OilPaint */
7734 if (attribute_flag[0] == 0)
7735 argument_list[0].real_reference=0.0;
7736 image=OilPaintImage(image,argument_list[0].real_reference,
7740 case 21: /* ReduceNoise */
7742 if (attribute_flag[0] != 0)
7744 flags=ParseGeometry(argument_list[0].string_reference,
7746 if ((flags & SigmaValue) == 0)
7747 geometry_info.sigma=1.0;
7749 if (attribute_flag[1] != 0)
7750 geometry_info.rho=argument_list[1].real_reference;
7751 if (attribute_flag[2] != 0)
7752 geometry_info.sigma=argument_list[2].real_reference;
7753 if (attribute_flag[3] != 0)
7754 channel=(ChannelType) argument_list[3].integer_reference;
7755 PushPixelChannelMap(image,channel);
7756 image=StatisticImage(image,NonpeakStatistic,(size_t)
7757 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7758 if (image != (Image *) NULL)
7759 PopPixelChannelMap(image);
7764 if (attribute_flag[0] != 0)
7765 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7766 &geometry,exception);
7767 if (attribute_flag[1] != 0)
7768 geometry.x=argument_list[1].integer_reference;
7769 if (attribute_flag[2] != 0)
7770 geometry.y=argument_list[2].integer_reference;
7771 image=RollImage(image,geometry.x,geometry.y,exception);
7774 case 23: /* Rotate */
7776 if (attribute_flag[0] == 0)
7777 argument_list[0].real_reference=90.0;
7778 if (attribute_flag[1] != 0)
7779 QueryColorDatabase(argument_list[1].string_reference,
7780 &image->background_color,exception);
7781 if (attribute_flag[2] != 0)
7782 QueryColorDatabase(argument_list[2].string_reference,
7783 &image->background_color,exception);
7784 if (attribute_flag[3] != 0)
7785 QueryColorDatabase(argument_list[3].string_reference,
7786 &image->background_color,exception);
7787 image=RotateImage(image,argument_list[0].real_reference,exception);
7790 case 24: /* Sample */
7792 if (attribute_flag[0] != 0)
7793 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7794 &geometry,exception);
7795 if (attribute_flag[1] != 0)
7796 geometry.width=argument_list[1].integer_reference;
7797 if (attribute_flag[2] != 0)
7798 geometry.height=argument_list[2].integer_reference;
7799 image=SampleImage(image,geometry.width,geometry.height,exception);
7802 case 25: /* Scale */
7804 if (attribute_flag[0] != 0)
7805 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7806 &geometry,exception);
7807 if (attribute_flag[1] != 0)
7808 geometry.width=argument_list[1].integer_reference;
7809 if (attribute_flag[2] != 0)
7810 geometry.height=argument_list[2].integer_reference;
7811 image=ScaleImage(image,geometry.width,geometry.height,exception);
7814 case 26: /* Shade */
7816 if (attribute_flag[0] != 0)
7818 flags=ParseGeometry(argument_list[0].string_reference,
7820 if ((flags & SigmaValue) == 0)
7821 geometry_info.sigma=0.0;
7823 if (attribute_flag[1] != 0)
7824 geometry_info.rho=argument_list[1].real_reference;
7825 if (attribute_flag[2] != 0)
7826 geometry_info.sigma=argument_list[2].real_reference;
7827 image=ShadeImage(image,
7828 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7829 geometry_info.rho,geometry_info.sigma,exception);
7832 case 27: /* Sharpen */
7834 if (attribute_flag[0] != 0)
7836 flags=ParseGeometry(argument_list[0].string_reference,
7838 if ((flags & SigmaValue) == 0)
7839 geometry_info.sigma=1.0;
7841 if (attribute_flag[1] != 0)
7842 geometry_info.rho=argument_list[1].real_reference;
7843 if (attribute_flag[2] != 0)
7844 geometry_info.sigma=argument_list[2].real_reference;
7845 if (attribute_flag[3] != 0)
7846 channel=(ChannelType) argument_list[3].integer_reference;
7847 PushPixelChannelMap(image,channel);
7848 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7850 if (image != (Image *) NULL)
7851 PopPixelChannelMap(image);
7854 case 28: /* Shear */
7856 if (attribute_flag[0] != 0)
7858 flags=ParseGeometry(argument_list[0].string_reference,
7860 if ((flags & SigmaValue) == 0)
7861 geometry_info.sigma=geometry_info.rho;
7863 if (attribute_flag[1] != 0)
7864 geometry_info.rho=argument_list[1].real_reference;
7865 if (attribute_flag[2] != 0)
7866 geometry_info.sigma=argument_list[2].real_reference;
7867 if (attribute_flag[3] != 0)
7868 QueryColorDatabase(argument_list[3].string_reference,
7869 &image->background_color,exception);
7870 if (attribute_flag[4] != 0)
7871 QueryColorDatabase(argument_list[4].string_reference,
7872 &image->background_color,exception);
7873 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7877 case 29: /* Spread */
7879 if (attribute_flag[0] == 0)
7880 argument_list[0].real_reference=1.0;
7881 image=SpreadImage(image,argument_list[0].real_reference,exception);
7884 case 30: /* Swirl */
7886 if (attribute_flag[0] == 0)
7887 argument_list[0].real_reference=50.0;
7888 if (attribute_flag[1] != 0)
7889 image->interpolate=(InterpolatePixelMethod)
7890 argument_list[1].integer_reference;
7891 image=SwirlImage(image,argument_list[0].real_reference,exception);
7894 case 31: /* Resize */
7897 if (attribute_flag[0] != 0)
7898 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7899 &geometry,exception);
7900 if (attribute_flag[1] != 0)
7901 geometry.width=argument_list[1].integer_reference;
7902 if (attribute_flag[2] != 0)
7903 geometry.height=argument_list[2].integer_reference;
7904 if (attribute_flag[3] == 0)
7905 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7906 if (attribute_flag[4] != 0)
7907 SetImageArtifact(image,"filter:support",
7908 argument_list[4].string_reference);
7909 if (attribute_flag[5] == 0)
7910 argument_list[5].real_reference=1.0;
7911 image=ResizeImage(image,geometry.width,geometry.height,
7912 (FilterTypes) argument_list[3].integer_reference,
7913 argument_list[5].real_reference,exception);
7916 case 33: /* Annotate */
7921 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7923 if (attribute_flag[0] != 0)
7928 text=InterpretImageProperties(info ? info->image_info :
7929 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7930 (void) CloneString(&draw_info->text,text);
7931 text=DestroyString(text);
7933 if (attribute_flag[1] != 0)
7934 (void) CloneString(&draw_info->font,
7935 argument_list[1].string_reference);
7936 if (attribute_flag[2] != 0)
7937 draw_info->pointsize=argument_list[2].real_reference;
7938 if (attribute_flag[3] != 0)
7939 (void) CloneString(&draw_info->density,
7940 argument_list[3].string_reference);
7941 if (attribute_flag[4] != 0)
7942 (void) QueryColorDatabase(argument_list[4].string_reference,
7943 &draw_info->undercolor,exception);
7944 if (attribute_flag[5] != 0)
7946 (void) QueryColorDatabase(argument_list[5].string_reference,
7947 &draw_info->stroke,exception);
7948 if (argument_list[5].image_reference != (Image *) NULL)
7949 draw_info->stroke_pattern=CloneImage(
7950 argument_list[5].image_reference,0,0,MagickTrue,exception);
7952 if (attribute_flag[6] != 0)
7954 (void) QueryColorDatabase(argument_list[6].string_reference,
7955 &draw_info->fill,exception);
7956 if (argument_list[6].image_reference != (Image *) NULL)
7957 draw_info->fill_pattern=CloneImage(
7958 argument_list[6].image_reference,0,0,MagickTrue,exception);
7960 if (attribute_flag[7] != 0)
7962 (void) CloneString(&draw_info->geometry,
7963 argument_list[7].string_reference);
7964 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7965 &geometry,exception);
7966 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7967 geometry_info.sigma=geometry_info.xi;
7969 if (attribute_flag[8] != 0)
7970 (void) QueryColorDatabase(argument_list[8].string_reference,
7971 &draw_info->fill,exception);
7972 if (attribute_flag[11] != 0)
7973 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7974 if (attribute_flag[25] != 0)
7979 av=(AV *) argument_list[25].array_reference;
7980 if ((av_len(av) != 3) && (av_len(av) != 5))
7982 ThrowPerlException(exception,OptionError,
7983 "affine matrix must have 4 or 6 elements",PackageName);
7986 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7987 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7988 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7989 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7990 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7991 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7993 ThrowPerlException(exception,OptionError,
7994 "affine matrix is singular",PackageName);
7997 if (av_len(av) == 5)
7999 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8000 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8003 for (j=12; j < 17; j++)
8005 if (attribute_flag[j] == 0)
8007 value=argument_list[j].string_reference;
8008 angle=argument_list[j].real_reference;
8009 current=draw_info->affine;
8010 GetAffineMatrix(&affine);
8018 flags=ParseGeometry(value,&geometry_info);
8019 affine.tx=geometry_info.xi;
8020 affine.ty=geometry_info.psi;
8021 if ((flags & PsiValue) == 0)
8022 affine.ty=affine.tx;
8030 flags=ParseGeometry(value,&geometry_info);
8031 affine.sx=geometry_info.rho;
8032 affine.sy=geometry_info.sigma;
8033 if ((flags & SigmaValue) == 0)
8034 affine.sy=affine.sx;
8044 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8045 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8046 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8047 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8055 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8063 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8067 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8068 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8069 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8070 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8071 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8073 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8076 if (attribute_flag[9] == 0)
8077 argument_list[9].real_reference=0.0;
8078 if (attribute_flag[10] == 0)
8079 argument_list[10].real_reference=0.0;
8080 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8083 geometry[MaxTextExtent];
8085 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8086 (double) argument_list[9].real_reference+draw_info->affine.tx,
8087 (double) argument_list[10].real_reference+draw_info->affine.ty);
8088 (void) CloneString(&draw_info->geometry,geometry);
8090 if (attribute_flag[17] != 0)
8091 draw_info->stroke_width=argument_list[17].real_reference;
8092 if (attribute_flag[18] != 0)
8094 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8095 MagickTrue : MagickFalse;
8096 draw_info->stroke_antialias=draw_info->text_antialias;
8098 if (attribute_flag[19] != 0)
8099 (void) CloneString(&draw_info->family,
8100 argument_list[19].string_reference);
8101 if (attribute_flag[20] != 0)
8102 draw_info->style=(StyleType) argument_list[20].integer_reference;
8103 if (attribute_flag[21] != 0)
8104 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8105 if (attribute_flag[22] != 0)
8106 draw_info->weight=argument_list[22].integer_reference;
8107 if (attribute_flag[23] != 0)
8108 draw_info->align=(AlignType) argument_list[23].integer_reference;
8109 if (attribute_flag[24] != 0)
8110 (void) CloneString(&draw_info->encoding,
8111 argument_list[24].string_reference);
8112 if (attribute_flag[25] != 0)
8113 draw_info->fill_pattern=CloneImage(
8114 argument_list[25].image_reference,0,0,MagickTrue,exception);
8115 if (attribute_flag[26] != 0)
8116 draw_info->fill_pattern=CloneImage(
8117 argument_list[26].image_reference,0,0,MagickTrue,exception);
8118 if (attribute_flag[27] != 0)
8119 draw_info->stroke_pattern=CloneImage(
8120 argument_list[27].image_reference,0,0,MagickTrue,exception);
8121 if (attribute_flag[29] != 0)
8122 draw_info->kerning=argument_list[29].real_reference;
8123 if (attribute_flag[30] != 0)
8124 draw_info->interline_spacing=argument_list[30].real_reference;
8125 if (attribute_flag[31] != 0)
8126 draw_info->interword_spacing=argument_list[31].real_reference;
8127 if (attribute_flag[32] != 0)
8128 draw_info->direction=(DirectionType)
8129 argument_list[32].integer_reference;
8130 (void) AnnotateImage(image,draw_info);
8131 draw_info=DestroyDrawInfo(draw_info);
8134 case 34: /* ColorFloodfill */
8145 draw_info=CloneDrawInfo(info ? info->image_info :
8146 (ImageInfo *) NULL,(DrawInfo *) NULL);
8147 if (attribute_flag[0] != 0)
8148 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8149 &geometry,exception);
8150 if (attribute_flag[1] != 0)
8151 geometry.x=argument_list[1].integer_reference;
8152 if (attribute_flag[2] != 0)
8153 geometry.y=argument_list[2].integer_reference;
8154 if (attribute_flag[3] != 0)
8155 (void) QueryColorDatabase(argument_list[3].string_reference,
8156 &draw_info->fill,exception);
8157 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8160 if (attribute_flag[4] != 0)
8162 QueryMagickColor(argument_list[4].string_reference,&target,
8166 if (attribute_flag[5] != 0)
8167 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8169 if (attribute_flag[6] != 0)
8170 invert=(MagickBooleanType) argument_list[6].integer_reference;
8171 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8173 draw_info=DestroyDrawInfo(draw_info);
8176 case 35: /* Composite */
8179 composite_geometry[MaxTextExtent];
8185 compose=OverCompositeOp;
8186 if (attribute_flag[0] != 0)
8187 composite_image=argument_list[0].image_reference;
8190 ThrowPerlException(exception,OptionError,
8191 "CompositeImageRequired",PackageName);
8195 Parameter Handling used for BOTH normal and tiled composition.
8197 if (attribute_flag[1] != 0) /* compose */
8198 compose=(CompositeOperator) argument_list[1].integer_reference;
8199 if (attribute_flag[6] != 0) /* opacity */
8201 if (compose != DissolveCompositeOp)
8202 (void) SetImageOpacity(composite_image,(Quantum)
8203 SiPrefixToDouble(argument_list[6].string_reference,
8226 Handle dissolve composite operator (patch by
8229 (void) CloneString(&image->geometry,
8230 argument_list[6].string_reference);
8231 opacity=(Quantum) SiPrefixToDouble(
8232 argument_list[6].string_reference,QuantumRange);
8233 if (composite_image->matte != MagickTrue)
8234 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8235 composite_view=AcquireCacheView(composite_image);
8236 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8238 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8239 composite_image->columns,1,exception);
8240 for (x=0; x < (ssize_t) composite_image->columns; x++)
8242 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8243 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8244 q+=GetPixelChannels(composite_image);
8246 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8247 if (sync == MagickFalse)
8250 composite_view=DestroyCacheView(composite_view);
8253 if (attribute_flag[9] != 0) /* "color=>" */
8254 QueryColorDatabase(argument_list[9].string_reference,
8255 &composite_image->background_color,exception);
8256 if (attribute_flag[12] != 0) /* "interpolate=>" */
8257 image->interpolate=(InterpolatePixelMethod)
8258 argument_list[12].integer_reference;
8259 if (attribute_flag[13] != 0) /* "args=>" */
8260 (void) SetImageArtifact(composite_image,"compose:args",
8261 argument_list[13].string_reference);
8262 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8263 (void) SetImageArtifact(composite_image,"compose:args",
8264 argument_list[14].string_reference);
8266 Tiling Composition (with orthogonal rotate).
8268 rotate_image=(Image *) NULL;
8269 if (attribute_flag[8] != 0) /* "rotate=>" */
8274 rotate_image=RotateImage(composite_image,
8275 argument_list[8].real_reference,exception);
8276 if (rotate_image == (Image *) NULL)
8279 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8286 Tile the composite image.
8288 if (attribute_flag[8] != 0) /* "tile=>" */
8289 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8292 (void) SetImageArtifact(composite_image,
8293 "compose:outside-overlay","false");
8294 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8295 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8297 if (attribute_flag[8] != 0) /* rotate */
8298 (void) CompositeImage(image,compose,rotate_image,x,y);
8300 (void) CompositeImage(image,compose,composite_image,x,y);
8302 if (attribute_flag[8] != 0) /* rotate */
8303 rotate_image=DestroyImage(rotate_image);
8307 Parameter Handling used used ONLY for normal composition.
8309 if (attribute_flag[5] != 0) /* gravity */
8310 image->gravity=(GravityType) argument_list[5].integer_reference;
8311 if (attribute_flag[2] != 0) /* geometry offset */
8313 SetGeometry(image,&geometry);
8314 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8316 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8319 if (attribute_flag[3] != 0) /* x offset */
8320 geometry.x=argument_list[3].integer_reference;
8321 if (attribute_flag[4] != 0) /* y offset */
8322 geometry.y=argument_list[4].integer_reference;
8323 if (attribute_flag[10] != 0) /* mask */
8325 if ((image->compose == DisplaceCompositeOp) ||
8326 (image->compose == DistortCompositeOp))
8329 Merge Y displacement into X displacement image.
8331 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8333 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8334 argument_list[10].image_reference,0,0);
8339 Set a blending mask for the composition.
8341 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8342 MagickTrue,&image->exception);
8343 (void) NegateImage(image->mask,MagickFalse,exception);
8346 if (attribute_flag[11] != 0) /* channel */
8347 channel=(ChannelType) argument_list[11].integer_reference;
8349 Composite two images (normal composition).
8351 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8352 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8353 (double) composite_image->rows,(double) geometry.x,(double)
8355 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8357 PushPixelChannelMap(image,channel);
8358 if (attribute_flag[8] == 0) /* no rotate */
8359 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8363 Position adjust rotated image then composite.
8365 geometry.x-=(ssize_t) (rotate_image->columns-
8366 composite_image->columns)/2;
8367 geometry.y-=(ssize_t) (rotate_image->rows-
8368 composite_image->rows)/2;
8369 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8370 rotate_image=DestroyImage(rotate_image);
8372 if (attribute_flag[10] != 0) /* mask */
8374 if ((image->compose == DisplaceCompositeOp) ||
8375 (image->compose == DistortCompositeOp))
8376 composite_image=DestroyImage(composite_image);
8378 image->mask=DestroyImage(image->mask);
8380 PopPixelChannelMap(image);
8383 case 36: /* Contrast */
8385 if (attribute_flag[0] == 0)
8386 argument_list[0].integer_reference=0;
8387 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8388 MagickTrue : MagickFalse);
8391 case 37: /* CycleColormap */
8393 if (attribute_flag[0] == 0)
8394 argument_list[0].integer_reference=6;
8395 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8403 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8405 (void) CloneString(&draw_info->primitive,"point");
8406 if (attribute_flag[0] != 0)
8408 if (argument_list[0].integer_reference < 0)
8409 (void) CloneString(&draw_info->primitive,
8410 argument_list[0].string_reference);
8412 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8413 MagickPrimitiveOptions,argument_list[0].integer_reference));
8415 if (attribute_flag[1] != 0)
8417 if (LocaleCompare(draw_info->primitive,"path") == 0)
8419 (void) ConcatenateString(&draw_info->primitive," '");
8420 ConcatenateString(&draw_info->primitive,
8421 argument_list[1].string_reference);
8422 (void) ConcatenateString(&draw_info->primitive,"'");
8426 (void) ConcatenateString(&draw_info->primitive," ");
8427 ConcatenateString(&draw_info->primitive,
8428 argument_list[1].string_reference);
8431 if (attribute_flag[2] != 0)
8433 (void) ConcatenateString(&draw_info->primitive," ");
8434 (void) ConcatenateString(&draw_info->primitive,
8435 CommandOptionToMnemonic(MagickMethodOptions,
8436 argument_list[2].integer_reference));
8438 if (attribute_flag[3] != 0)
8440 (void) QueryColorDatabase(argument_list[3].string_reference,
8441 &draw_info->stroke,exception);
8442 if (argument_list[3].image_reference != (Image *) NULL)
8443 draw_info->stroke_pattern=CloneImage(
8444 argument_list[3].image_reference,0,0,MagickTrue,exception);
8446 if (attribute_flag[4] != 0)
8448 (void) QueryColorDatabase(argument_list[4].string_reference,
8449 &draw_info->fill,exception);
8450 if (argument_list[4].image_reference != (Image *) NULL)
8451 draw_info->fill_pattern=CloneImage(
8452 argument_list[4].image_reference,0,0,MagickTrue,exception);
8454 if (attribute_flag[5] != 0)
8455 draw_info->stroke_width=argument_list[5].real_reference;
8456 if (attribute_flag[6] != 0)
8457 (void) CloneString(&draw_info->font,
8458 argument_list[6].string_reference);
8459 if (attribute_flag[7] != 0)
8460 (void) QueryColorDatabase(argument_list[7].string_reference,
8461 &draw_info->border_color,exception);
8462 if (attribute_flag[8] != 0)
8463 draw_info->affine.tx=argument_list[8].real_reference;
8464 if (attribute_flag[9] != 0)
8465 draw_info->affine.ty=argument_list[9].real_reference;
8466 if (attribute_flag[20] != 0)
8471 av=(AV *) argument_list[20].array_reference;
8472 if ((av_len(av) != 3) && (av_len(av) != 5))
8474 ThrowPerlException(exception,OptionError,
8475 "affine matrix must have 4 or 6 elements",PackageName);
8478 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8479 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8480 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8481 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8482 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8483 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8485 ThrowPerlException(exception,OptionError,
8486 "affine matrix is singular",PackageName);
8489 if (av_len(av) == 5)
8491 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8492 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8495 for (j=10; j < 15; j++)
8497 if (attribute_flag[j] == 0)
8499 value=argument_list[j].string_reference;
8500 angle=argument_list[j].real_reference;
8501 current=draw_info->affine;
8502 GetAffineMatrix(&affine);
8510 flags=ParseGeometry(value,&geometry_info);
8511 affine.tx=geometry_info.xi;
8512 affine.ty=geometry_info.psi;
8513 if ((flags & PsiValue) == 0)
8514 affine.ty=affine.tx;
8522 flags=ParseGeometry(value,&geometry_info);
8523 affine.sx=geometry_info.rho;
8524 affine.sy=geometry_info.sigma;
8525 if ((flags & SigmaValue) == 0)
8526 affine.sy=affine.sx;
8536 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8537 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8538 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8539 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8547 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8555 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8559 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8560 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8561 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8562 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8563 draw_info->affine.tx=
8564 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8565 draw_info->affine.ty=
8566 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8568 if (attribute_flag[15] != 0)
8569 draw_info->fill_pattern=CloneImage(
8570 argument_list[15].image_reference,0,0,MagickTrue,exception);
8571 if (attribute_flag[16] != 0)
8572 draw_info->pointsize=argument_list[16].real_reference;
8573 if (attribute_flag[17] != 0)
8575 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8576 ? MagickTrue : MagickFalse;
8577 draw_info->text_antialias=draw_info->stroke_antialias;
8579 if (attribute_flag[18] != 0)
8580 (void) CloneString(&draw_info->density,
8581 argument_list[18].string_reference);
8582 if (attribute_flag[19] != 0)
8583 draw_info->stroke_width=argument_list[19].real_reference;
8584 if (attribute_flag[21] != 0)
8585 draw_info->dash_offset=argument_list[21].real_reference;
8586 if (attribute_flag[22] != 0)
8591 av=(AV *) argument_list[22].array_reference;
8592 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8593 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8594 if (draw_info->dash_pattern != (double *) NULL)
8596 for (i=0; i <= av_len(av); i++)
8597 draw_info->dash_pattern[i]=(double)
8598 SvNV(*(av_fetch(av,i,0)));
8599 draw_info->dash_pattern[i]=0.0;
8602 if (attribute_flag[23] != 0)
8603 image->interpolate=(InterpolatePixelMethod)
8604 argument_list[23].integer_reference;
8605 if ((attribute_flag[24] != 0) &&
8606 (draw_info->fill_pattern != (Image *) NULL))
8607 flags=ParsePageGeometry(draw_info->fill_pattern,
8608 argument_list[24].string_reference,
8609 &draw_info->fill_pattern->tile_offset,exception);
8610 if (attribute_flag[25] != 0)
8612 (void) ConcatenateString(&draw_info->primitive," '");
8613 (void) ConcatenateString(&draw_info->primitive,
8614 argument_list[25].string_reference);
8615 (void) ConcatenateString(&draw_info->primitive,"'");
8617 if (attribute_flag[26] != 0)
8618 draw_info->fill_pattern=CloneImage(
8619 argument_list[26].image_reference,0,0,MagickTrue,exception);
8620 if (attribute_flag[27] != 0)
8621 draw_info->stroke_pattern=CloneImage(
8622 argument_list[27].image_reference,0,0,MagickTrue,exception);
8623 if (attribute_flag[28] != 0)
8624 (void) CloneString(&draw_info->primitive,
8625 argument_list[28].string_reference);
8626 if (attribute_flag[29] != 0)
8627 draw_info->kerning=argument_list[29].real_reference;
8628 if (attribute_flag[30] != 0)
8629 draw_info->interline_spacing=argument_list[30].real_reference;
8630 if (attribute_flag[31] != 0)
8631 draw_info->interword_spacing=argument_list[31].real_reference;
8632 if (attribute_flag[32] != 0)
8633 draw_info->direction=(DirectionType)
8634 argument_list[32].integer_reference;
8635 DrawImage(image,draw_info);
8636 draw_info=DestroyDrawInfo(draw_info);
8639 case 39: /* Equalize */
8641 if (attribute_flag[0] != 0)
8642 channel=(ChannelType) argument_list[0].integer_reference;
8643 PushPixelChannelMap(image,channel);
8644 EqualizeImage(image);
8645 PopPixelChannelMap(image);
8648 case 40: /* Gamma */
8650 if (attribute_flag[1] != 0)
8651 channel=(ChannelType) argument_list[1].integer_reference;
8652 if (attribute_flag[2] == 0)
8653 argument_list[2].real_reference=1.0;
8654 if (attribute_flag[3] == 0)
8655 argument_list[3].real_reference=1.0;
8656 if (attribute_flag[4] == 0)
8657 argument_list[4].real_reference=1.0;
8658 if (attribute_flag[0] == 0)
8660 (void) FormatLocaleString(message,MaxTextExtent,
8661 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8662 (double) argument_list[3].real_reference,
8663 (double) argument_list[4].real_reference);
8664 argument_list[0].string_reference=message;
8666 (void) GammaImage(image,InterpretLocaleValue(
8667 argument_list[0].string_reference,(char **) NULL),exception);
8675 if (attribute_flag[0] == 0)
8677 ThrowPerlException(exception,OptionError,"MapImageRequired",
8681 quantize_info=AcquireQuantizeInfo(info->image_info);
8682 if (attribute_flag[1] != 0)
8683 quantize_info->dither=(MagickBooleanType)
8684 argument_list[1].integer_reference;
8685 if (attribute_flag[2] != 0)
8686 quantize_info->dither_method=(DitherMethod)
8687 argument_list[2].integer_reference;
8688 (void) RemapImages(quantize_info,image,
8689 argument_list[0].image_reference);
8690 quantize_info=DestroyQuantizeInfo(quantize_info);
8693 case 42: /* MatteFloodfill */
8704 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8706 if (attribute_flag[0] != 0)
8707 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8708 &geometry,exception);
8709 if (attribute_flag[1] != 0)
8710 geometry.x=argument_list[1].integer_reference;
8711 if (attribute_flag[2] != 0)
8712 geometry.y=argument_list[2].integer_reference;
8713 if (image->matte == MagickFalse)
8714 (void) SetImageOpacity(image,OpaqueAlpha);
8715 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8717 if (attribute_flag[4] != 0)
8718 QueryMagickColor(argument_list[4].string_reference,&target,
8720 if (attribute_flag[3] != 0)
8721 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8723 if (attribute_flag[5] != 0)
8724 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8727 if (attribute_flag[6] != 0)
8728 invert=(MagickBooleanType) argument_list[6].integer_reference;
8729 PushPixelChannelMap(image,AlphaChannel);
8730 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8732 PopPixelChannelMap(image);
8733 StandardPixelChannelMap(image);
8734 draw_info=DestroyDrawInfo(draw_info);
8737 case 43: /* Modulate */
8740 modulate[MaxTextExtent];
8742 geometry_info.rho=100.0;
8743 geometry_info.sigma=100.0;
8744 geometry_info.xi=100.0;
8745 if (attribute_flag[0] != 0)
8746 (void)ParseGeometry(argument_list[0].string_reference,
8748 if (attribute_flag[1] != 0)
8749 geometry_info.xi=argument_list[1].real_reference;
8750 if (attribute_flag[2] != 0)
8751 geometry_info.sigma=argument_list[2].real_reference;
8752 if (attribute_flag[3] != 0)
8754 geometry_info.sigma=argument_list[3].real_reference;
8755 SetImageArtifact(image,"modulate:colorspace","HWB");
8757 if (attribute_flag[4] != 0)
8759 geometry_info.rho=argument_list[4].real_reference;
8760 SetImageArtifact(image,"modulate:colorspace","HSB");
8762 if (attribute_flag[5] != 0)
8764 geometry_info.sigma=argument_list[5].real_reference;
8765 SetImageArtifact(image,"modulate:colorspace","HSL");
8767 if (attribute_flag[6] != 0)
8769 geometry_info.rho=argument_list[6].real_reference;
8770 SetImageArtifact(image,"modulate:colorspace","HWB");
8772 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8773 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8774 (void) ModulateImage(image,modulate);
8777 case 44: /* Negate */
8779 if (attribute_flag[0] == 0)
8780 argument_list[0].integer_reference=0;
8781 if (attribute_flag[1] != 0)
8782 channel=(ChannelType) argument_list[1].integer_reference;
8783 PushPixelChannelMap(image,channel);
8784 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8785 MagickTrue : MagickFalse,exception);
8786 PopPixelChannelMap(image);
8789 case 45: /* Normalize */
8791 if (attribute_flag[0] != 0)
8792 channel=(ChannelType) argument_list[0].integer_reference;
8793 PushPixelChannelMap(image,channel);
8794 NormalizeImage(image);
8795 PopPixelChannelMap(image);
8798 case 46: /* NumberColors */
8800 case 47: /* Opaque */
8809 (void) QueryMagickColor("none",&target,exception);
8810 (void) QueryMagickColor("none",&fill_color,exception);
8811 if (attribute_flag[0] != 0)
8812 (void) QueryMagickColor(argument_list[0].string_reference,
8814 if (attribute_flag[1] != 0)
8815 (void) QueryMagickColor(argument_list[1].string_reference,
8816 &fill_color,exception);
8817 if (attribute_flag[2] != 0)
8818 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8820 if (attribute_flag[3] != 0)
8821 channel=(ChannelType) argument_list[3].integer_reference;
8823 if (attribute_flag[4] != 0)
8824 invert=(MagickBooleanType) argument_list[4].integer_reference;
8825 PushPixelChannelMap(image,channel);
8826 (void) OpaquePaintImage(image,&target,&fill_color,invert);
8827 PopPixelChannelMap(image);
8830 case 48: /* Quantize */
8835 quantize_info=AcquireQuantizeInfo(info->image_info);
8836 if (attribute_flag[0] != 0)
8837 quantize_info->number_colors=(size_t)
8838 argument_list[0].integer_reference;
8839 if (attribute_flag[1] != 0)
8840 quantize_info->tree_depth=(size_t)
8841 argument_list[1].integer_reference;
8842 if (attribute_flag[2] != 0)
8843 quantize_info->colorspace=(ColorspaceType)
8844 argument_list[2].integer_reference;
8845 if (attribute_flag[3] != 0)
8846 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8847 MagickTrue : MagickFalse;
8848 if (attribute_flag[4] != 0)
8849 quantize_info->measure_error=
8850 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8851 if (attribute_flag[5] != 0)
8852 (void) QueryColorDatabase(argument_list[5].string_reference,
8853 &image->transparent_color,exception);
8854 if (attribute_flag[5] && argument_list[5].integer_reference)
8856 (void) QuantizeImages(quantize_info,image);
8859 if (attribute_flag[6] != 0)
8860 quantize_info->dither_method=(DitherMethod)
8861 argument_list[6].integer_reference;
8862 if ((image->storage_class == DirectClass) ||
8863 (image->colors > quantize_info->number_colors) ||
8864 (quantize_info->colorspace == GRAYColorspace))
8865 (void) QuantizeImage(quantize_info,image);
8867 CompressImageColormap(image);
8868 quantize_info=DestroyQuantizeInfo(quantize_info);
8871 case 49: /* Raise */
8873 if (attribute_flag[0] != 0)
8874 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8875 &geometry,exception);
8876 if (attribute_flag[1] != 0)
8877 geometry.width=argument_list[1].integer_reference;
8878 if (attribute_flag[2] != 0)
8879 geometry.height=argument_list[2].integer_reference;
8880 if (attribute_flag[3] == 0)
8881 argument_list[3].integer_reference=1;
8882 (void) RaiseImage(image,&geometry,argument_list[3].integer_reference !=
8883 0 ? MagickTrue : MagickFalse);
8886 case 50: /* Segment */
8893 smoothing_threshold;
8898 cluster_threshold=1.0;
8899 smoothing_threshold=1.5;
8900 colorspace=RGBColorspace;
8901 verbose=MagickFalse;
8902 if (attribute_flag[0] != 0)
8904 flags=ParseGeometry(argument_list[0].string_reference,
8906 cluster_threshold=geometry_info.rho;
8907 if (flags & SigmaValue)
8908 smoothing_threshold=geometry_info.sigma;
8910 if (attribute_flag[1] != 0)
8911 cluster_threshold=argument_list[1].real_reference;
8912 if (attribute_flag[2] != 0)
8913 smoothing_threshold=argument_list[2].real_reference;
8914 if (attribute_flag[3] != 0)
8915 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8916 if (attribute_flag[4] != 0)
8917 verbose=argument_list[4].integer_reference != 0 ?
8918 MagickTrue : MagickFalse;
8919 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8920 smoothing_threshold);
8923 case 51: /* Signature */
8925 (void) SignatureImage(image);
8928 case 52: /* Solarize */
8930 geometry_info.rho=QuantumRange/2.0;
8931 if (attribute_flag[0] != 0)
8932 flags=ParseGeometry(argument_list[0].string_reference,
8934 if (attribute_flag[1] != 0)
8935 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8937 (void) SolarizeImage(image,geometry_info.rho);
8942 (void) SyncImage(image);
8945 case 54: /* Texture */
8947 if (attribute_flag[0] == 0)
8949 TextureImage(image,argument_list[0].image_reference);
8952 case 55: /* Evalute */
8954 MagickEvaluateOperator
8957 op=SetEvaluateOperator;
8958 if (attribute_flag[0] == MagickFalse)
8959 argument_list[0].real_reference=0.0;
8960 if (attribute_flag[1] != MagickFalse)
8961 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8962 if (attribute_flag[2] != MagickFalse)
8963 channel=(ChannelType) argument_list[2].integer_reference;
8964 PushPixelChannelMap(image,channel);
8965 (void) EvaluateImage(image,op,argument_list[0].real_reference,
8967 PopPixelChannelMap(image);
8970 case 56: /* Transparent */
8981 (void) QueryMagickColor("none",&target,exception);
8982 if (attribute_flag[0] != 0)
8983 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8985 opacity=TransparentAlpha;
8986 if (attribute_flag[1] != 0)
8987 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8989 if (attribute_flag[2] != 0)
8990 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8992 if (attribute_flag[3] == 0)
8993 argument_list[3].integer_reference=0;
8995 if (attribute_flag[3] != 0)
8996 invert=(MagickBooleanType) argument_list[3].integer_reference;
8997 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9001 case 57: /* Threshold */
9006 if (attribute_flag[0] == 0)
9007 argument_list[0].string_reference="50%";
9008 if (attribute_flag[1] != 0)
9009 channel=(ChannelType) argument_list[1].integer_reference;
9010 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9012 PushPixelChannelMap(image,channel);
9013 (void) BilevelImage(image,threshold);
9014 PopPixelChannelMap(image);
9017 case 58: /* Charcoal */
9019 if (attribute_flag[0] != 0)
9021 flags=ParseGeometry(argument_list[0].string_reference,
9023 if ((flags & SigmaValue) == 0)
9024 geometry_info.sigma=1.0;
9026 if (attribute_flag[1] != 0)
9027 geometry_info.rho=argument_list[1].real_reference;
9028 if (attribute_flag[2] != 0)
9029 geometry_info.sigma=argument_list[2].real_reference;
9030 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9036 if (attribute_flag[0] != 0)
9037 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9039 image=TrimImage(image,exception);
9044 if (attribute_flag[0] != 0)
9046 flags=ParseGeometry(argument_list[0].string_reference,
9048 if ((flags & SigmaValue) == 0)
9049 geometry_info.sigma=1.0;
9051 if (attribute_flag[1] != 0)
9052 geometry_info.rho=argument_list[1].real_reference;
9053 if (attribute_flag[2] != 0)
9054 geometry_info.sigma=argument_list[2].real_reference;
9055 if (attribute_flag[3] != 0)
9056 image->interpolate=(InterpolatePixelMethod)
9057 argument_list[3].integer_reference;
9058 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9062 case 61: /* Separate */
9064 if (attribute_flag[0] != 0)
9065 channel=(ChannelType) argument_list[0].integer_reference;
9066 PushPixelChannelMap(image,channel);
9067 (void) SeparateImage(image);
9068 PopPixelChannelMap(image);
9071 case 63: /* Stereo */
9073 if (attribute_flag[0] == 0)
9075 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9079 if (attribute_flag[1] != 0)
9080 geometry.x=argument_list[1].integer_reference;
9081 if (attribute_flag[2] != 0)
9082 geometry.y=argument_list[2].integer_reference;
9083 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9084 geometry.x,geometry.y,exception);
9087 case 64: /* Stegano */
9089 if (attribute_flag[0] == 0)
9091 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9095 if (attribute_flag[1] == 0)
9096 argument_list[1].integer_reference=0;
9097 image->offset=argument_list[1].integer_reference;
9098 image=SteganoImage(image,argument_list[0].image_reference,exception);
9101 case 65: /* Deconstruct */
9103 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9106 case 66: /* GaussianBlur */
9108 if (attribute_flag[0] != 0)
9110 flags=ParseGeometry(argument_list[0].string_reference,
9112 if ((flags & SigmaValue) == 0)
9113 geometry_info.sigma=1.0;
9115 if (attribute_flag[1] != 0)
9116 geometry_info.rho=argument_list[1].real_reference;
9117 if (attribute_flag[2] != 0)
9118 geometry_info.sigma=argument_list[2].real_reference;
9119 if (attribute_flag[3] != 0)
9120 channel=(ChannelType) argument_list[3].integer_reference;
9121 PushPixelChannelMap(image,channel);
9122 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9124 if (image != (Image *) NULL)
9125 PopPixelChannelMap(image);
9128 case 67: /* Convolve */
9133 kernel=(KernelInfo *) NULL;
9134 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9136 if (attribute_flag[0] != 0)
9144 kernel=AcquireKernelInfo((const char *) NULL);
9145 if (kernel == (KernelInfo *) NULL)
9147 av=(AV *) argument_list[0].array_reference;
9148 order=(size_t) sqrt(av_len(av)+1);
9149 kernel->width=order;
9150 kernel->height=order;
9151 kernel->values=(double *) AcquireQuantumMemory(order,order*
9152 sizeof(*kernel->values));
9153 if (kernel->values == (double *) NULL)
9155 kernel=DestroyKernelInfo(kernel);
9156 ThrowPerlException(exception,ResourceLimitFatalError,
9157 "MemoryAllocationFailed",PackageName);
9160 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9161 kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
9162 for ( ; j < (ssize_t) (order*order); j++)
9163 kernel->values[j]=0.0;
9165 if (attribute_flag[1] != 0)
9166 channel=(ChannelType) argument_list[1].integer_reference;
9167 if (attribute_flag[2] != 0)
9168 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9170 if (attribute_flag[3] != 0)
9172 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9173 if (kernel == (KernelInfo *) NULL)
9176 PushPixelChannelMap(image,channel);
9177 kernel->bias=image->bias;
9178 image=ConvolveImage(image,kernel,exception);
9179 if (image != (Image *) NULL)
9180 PopPixelChannelMap(image);
9181 kernel=DestroyKernelInfo(kernel);
9184 case 68: /* Profile */
9199 if (attribute_flag[0] != 0)
9200 name=argument_list[0].string_reference;
9201 if (attribute_flag[2] != 0)
9202 image->rendering_intent=(RenderingIntent)
9203 argument_list[2].integer_reference;
9204 if (attribute_flag[3] != 0)
9205 image->black_point_compensation=
9206 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9207 if (attribute_flag[1] != 0)
9209 if (argument_list[1].length == 0)
9212 Remove a profile from the image.
9214 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9219 Associate user supplied profile with the image.
9221 profile=AcquireStringInfo(argument_list[1].length);
9222 SetStringInfoDatum(profile,(const unsigned char *)
9223 argument_list[1].string_reference);
9224 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9225 (size_t) GetStringInfoLength(profile),MagickFalse);
9226 profile=DestroyStringInfo(profile);
9230 Associate a profile with the image.
9233 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9234 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9235 profile_image=ReadImages(profile_info,&image->exception);
9236 if (profile_image == (Image *) NULL)
9238 ResetImageProfileIterator(profile_image);
9239 name=GetNextImageProfile(profile_image);
9240 while (name != (const char *) NULL)
9245 profile=GetImageProfile(profile_image,name);
9246 if (profile != (const StringInfo *) NULL)
9247 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9248 (size_t) GetStringInfoLength(profile),MagickFalse);
9249 name=GetNextImageProfile(profile_image);
9251 profile_image=DestroyImage(profile_image);
9252 profile_info=DestroyImageInfo(profile_info);
9255 case 69: /* UnsharpMask */
9257 if (attribute_flag[0] != 0)
9259 flags=ParseGeometry(argument_list[0].string_reference,
9261 if ((flags & SigmaValue) == 0)
9262 geometry_info.sigma=1.0;
9263 if ((flags & XiValue) == 0)
9264 geometry_info.xi=1.0;
9265 if ((flags & PsiValue) == 0)
9266 geometry_info.psi=0.5;
9268 if (attribute_flag[1] != 0)
9269 geometry_info.rho=argument_list[1].real_reference;
9270 if (attribute_flag[2] != 0)
9271 geometry_info.sigma=argument_list[2].real_reference;
9272 if (attribute_flag[3] != 0)
9273 geometry_info.xi=argument_list[3].real_reference;
9274 if (attribute_flag[4] != 0)
9275 geometry_info.psi=argument_list[4].real_reference;
9276 if (attribute_flag[5] != 0)
9277 channel=(ChannelType) argument_list[5].integer_reference;
9278 PushPixelChannelMap(image,channel);
9279 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9280 geometry_info.xi,geometry_info.psi,exception);
9281 if (image != (Image *) NULL)
9282 PopPixelChannelMap(image);
9285 case 70: /* MotionBlur */
9287 if (attribute_flag[0] != 0)
9289 flags=ParseGeometry(argument_list[0].string_reference,
9291 if ((flags & SigmaValue) == 0)
9292 geometry_info.sigma=1.0;
9293 if ((flags & XiValue) == 0)
9294 geometry_info.xi=1.0;
9296 if (attribute_flag[1] != 0)
9297 geometry_info.rho=argument_list[1].real_reference;
9298 if (attribute_flag[2] != 0)
9299 geometry_info.sigma=argument_list[2].real_reference;
9300 if (attribute_flag[3] != 0)
9301 geometry_info.xi=argument_list[3].real_reference;
9302 if (attribute_flag[4] != 0)
9303 channel=(ChannelType) argument_list[4].integer_reference;
9304 PushPixelChannelMap(image,channel);
9305 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9306 geometry_info.xi,exception);
9307 if (image != (Image *) NULL)
9308 PopPixelChannelMap(image);
9311 case 71: /* OrderedDither */
9313 if (attribute_flag[0] == 0)
9314 argument_list[0].string_reference="o8x8";
9315 if (attribute_flag[1] != 0)
9316 channel=(ChannelType) argument_list[1].integer_reference;
9317 PushPixelChannelMap(image,channel);
9318 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9320 PopPixelChannelMap(image);
9323 case 72: /* Shave */
9325 if (attribute_flag[0] != 0)
9326 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9327 &geometry,exception);
9328 if (attribute_flag[1] != 0)
9329 geometry.width=argument_list[1].integer_reference;
9330 if (attribute_flag[2] != 0)
9331 geometry.height=argument_list[2].integer_reference;
9332 image=ShaveImage(image,&geometry,exception);
9335 case 73: /* Level */
9343 white_point=(MagickRealType) image->columns*image->rows;
9345 if (attribute_flag[0] != 0)
9347 flags=ParseGeometry(argument_list[0].string_reference,
9349 black_point=geometry_info.rho;
9350 if ((flags & SigmaValue) != 0)
9351 white_point=geometry_info.sigma;
9352 if ((flags & XiValue) != 0)
9353 gamma=geometry_info.xi;
9354 if ((flags & PercentValue) != 0)
9356 black_point*=(double) (QuantumRange/100.0);
9357 white_point*=(double) (QuantumRange/100.0);
9359 if ((flags & SigmaValue) == 0)
9360 white_point=(double) QuantumRange-black_point;
9362 if (attribute_flag[1] != 0)
9363 black_point=argument_list[1].real_reference;
9364 if (attribute_flag[2] != 0)
9365 white_point=argument_list[2].real_reference;
9366 if (attribute_flag[3] != 0)
9367 gamma=argument_list[3].real_reference;
9368 if (attribute_flag[4] != 0)
9369 channel=(ChannelType) argument_list[4].integer_reference;
9370 if (attribute_flag[5] != 0)
9372 argument_list[0].real_reference=argument_list[5].real_reference;
9373 attribute_flag[0]=attribute_flag[5];
9375 PushPixelChannelMap(image,channel);
9376 (void) LevelImage(image,black_point,white_point,gamma);
9377 PopPixelChannelMap(image);
9382 if (attribute_flag[0] == 0)
9383 argument_list[0].string_reference="#1";
9384 if (attribute_flag[1] == 0)
9385 argument_list[1].integer_reference=MagickTrue;
9386 (void) ClipImagePath(image,argument_list[0].string_reference,
9387 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9390 case 75: /* AffineTransform */
9395 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9397 if (attribute_flag[0] != 0)
9402 av=(AV *) argument_list[0].array_reference;
9403 if ((av_len(av) != 3) && (av_len(av) != 5))
9405 ThrowPerlException(exception,OptionError,
9406 "affine matrix must have 4 or 6 elements",PackageName);
9409 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9410 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9411 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9412 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9413 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9414 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9416 ThrowPerlException(exception,OptionError,
9417 "affine matrix is singular",PackageName);
9420 if (av_len(av) == 5)
9422 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9423 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9426 for (j=1; j < 6; j++)
9428 if (attribute_flag[j] == 0)
9430 value=argument_list[j].string_reference;
9431 angle=argument_list[j].real_reference;
9432 current=draw_info->affine;
9433 GetAffineMatrix(&affine);
9441 flags=ParseGeometry(value,&geometry_info);
9442 affine.tx=geometry_info.xi;
9443 affine.ty=geometry_info.psi;
9444 if ((flags & PsiValue) == 0)
9445 affine.ty=affine.tx;
9453 flags=ParseGeometry(value,&geometry_info);
9454 affine.sx=geometry_info.rho;
9455 affine.sy=geometry_info.sigma;
9456 if ((flags & SigmaValue) == 0)
9457 affine.sy=affine.sx;
9467 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9468 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9469 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9470 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9478 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9486 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9490 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9491 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9492 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9493 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9494 draw_info->affine.tx=
9495 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9496 draw_info->affine.ty=
9497 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9499 if (attribute_flag[6] != 0)
9500 image->interpolate=(InterpolatePixelMethod)
9501 argument_list[6].integer_reference;
9502 if (attribute_flag[7] != 0)
9503 QueryColorDatabase(argument_list[7].string_reference,
9504 &image->background_color,exception);
9505 image=AffineTransformImage(image,&draw_info->affine,exception);
9506 draw_info=DestroyDrawInfo(draw_info);
9509 case 76: /* Difference */
9511 if (attribute_flag[0] == 0)
9513 ThrowPerlException(exception,OptionError,
9514 "ReferenceImageRequired",PackageName);
9517 if (attribute_flag[1] != 0)
9518 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9520 (void) IsImagesEqual(image,argument_list[0].image_reference);
9523 case 77: /* AdaptiveThreshold */
9525 if (attribute_flag[0] != 0)
9527 flags=ParseGeometry(argument_list[0].string_reference,
9529 if ((flags & PercentValue) != 0)
9530 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9532 if (attribute_flag[1] != 0)
9533 geometry_info.rho=argument_list[1].integer_reference;
9534 if (attribute_flag[2] != 0)
9535 geometry_info.sigma=argument_list[2].integer_reference;
9536 if (attribute_flag[3] != 0)
9537 geometry_info.xi=argument_list[3].integer_reference;;
9538 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9539 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9542 case 78: /* Resample */
9548 if (attribute_flag[0] != 0)
9550 flags=ParseGeometry(argument_list[0].string_reference,
9552 if ((flags & SigmaValue) == 0)
9553 geometry_info.sigma=geometry_info.rho;
9555 if (attribute_flag[1] != 0)
9556 geometry_info.rho=argument_list[1].real_reference;
9557 if (attribute_flag[2] != 0)
9558 geometry_info.sigma=argument_list[2].real_reference;
9559 if (attribute_flag[3] == 0)
9560 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9561 if (attribute_flag[4] == 0)
9562 SetImageArtifact(image,"filter:support",
9563 argument_list[4].string_reference);
9564 if (attribute_flag[5] != 0)
9565 argument_list[5].real_reference=1.0;
9566 width=(size_t) (geometry_info.rho*image->columns/
9567 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9568 height=(size_t) (geometry_info.sigma*image->rows/
9569 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9570 image=ResizeImage(image,width,height,(FilterTypes)
9571 argument_list[3].integer_reference,argument_list[5].real_reference,
9573 if (image != (Image *) NULL)
9575 image->x_resolution=geometry_info.rho;
9576 image->y_resolution=geometry_info.sigma;
9580 case 79: /* Describe */
9582 if (attribute_flag[0] == 0)
9583 argument_list[0].file_reference=(FILE *) NULL;
9584 if (attribute_flag[1] != 0)
9585 (void) SetImageArtifact(image,"identify:features",
9586 argument_list[1].string_reference);
9587 (void) IdentifyImage(image,argument_list[0].file_reference,
9591 case 80: /* BlackThreshold */
9593 if (attribute_flag[0] == 0)
9594 argument_list[0].string_reference="50%";
9595 if (attribute_flag[2] != 0)
9596 channel=(ChannelType) argument_list[2].integer_reference;
9597 PushPixelChannelMap(image,channel);
9598 BlackThresholdImage(image,argument_list[0].string_reference,
9600 PopPixelChannelMap(image);
9603 case 81: /* WhiteThreshold */
9605 if (attribute_flag[0] == 0)
9606 argument_list[0].string_reference="50%";
9607 if (attribute_flag[2] != 0)
9608 channel=(ChannelType) argument_list[2].integer_reference;
9609 PushPixelChannelMap(image,channel);
9610 WhiteThresholdImage(image,argument_list[0].string_reference,
9612 PopPixelChannelMap(image);
9615 case 82: /* RadialBlur */
9617 if (attribute_flag[0] != 0)
9619 flags=ParseGeometry(argument_list[0].string_reference,
9621 if ((flags & SigmaValue) == 0)
9622 geometry_info.sigma=1.0;
9624 if (attribute_flag[1] != 0)
9625 geometry_info.rho=argument_list[1].real_reference;
9626 if (attribute_flag[2] != 0)
9627 channel=(ChannelType) argument_list[2].integer_reference;
9628 PushPixelChannelMap(image,channel);
9629 image=RadialBlurImage(image,geometry_info.rho,exception);
9630 if (image != (Image *) NULL)
9631 PopPixelChannelMap(image);
9634 case 83: /* Thumbnail */
9636 if (attribute_flag[0] != 0)
9637 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9638 &geometry,exception);
9639 if (attribute_flag[1] != 0)
9640 geometry.width=argument_list[1].integer_reference;
9641 if (attribute_flag[2] != 0)
9642 geometry.height=argument_list[2].integer_reference;
9643 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9646 case 84: /* Strip */
9648 (void) StripImage(image);
9656 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9657 if (attribute_flag[0] != 0)
9658 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9660 if (attribute_flag[1] == 0)
9661 argument_list[1].string_reference="100";
9662 image=TintImage(image,argument_list[1].string_reference,target,
9666 case 86: /* Channel */
9668 if (attribute_flag[0] != 0)
9669 channel=(ChannelType) argument_list[0].integer_reference;
9670 PushPixelChannelMap(image,channel);
9671 (void) SeparateImage(image);
9672 PopPixelChannelMap(image);
9675 case 87: /* Splice */
9677 if (attribute_flag[0] != 0)
9678 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9679 &geometry,exception);
9680 if (attribute_flag[1] != 0)
9681 geometry.width=argument_list[1].integer_reference;
9682 if (attribute_flag[2] != 0)
9683 geometry.height=argument_list[2].integer_reference;
9684 if (attribute_flag[3] != 0)
9685 geometry.x=argument_list[3].integer_reference;
9686 if (attribute_flag[4] != 0)
9687 geometry.y=argument_list[4].integer_reference;
9688 if (attribute_flag[5] != 0)
9689 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9691 if (attribute_flag[6] != 0)
9692 (void) QueryColorDatabase(argument_list[6].string_reference,
9693 &image->background_color,exception);
9694 if (attribute_flag[7] != 0)
9695 image->gravity=(GravityType) argument_list[7].integer_reference;
9696 image=SpliceImage(image,&geometry,exception);
9699 case 88: /* Posterize */
9701 if (attribute_flag[0] == 0)
9702 argument_list[0].integer_reference=3;
9703 if (attribute_flag[1] == 0)
9704 argument_list[1].integer_reference=0;
9705 (void) PosterizeImage(image,argument_list[0].integer_reference,
9706 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9709 case 89: /* Shadow */
9711 if (attribute_flag[0] != 0)
9713 flags=ParseGeometry(argument_list[0].string_reference,
9715 if ((flags & SigmaValue) == 0)
9716 geometry_info.sigma=1.0;
9717 if ((flags & XiValue) == 0)
9718 geometry_info.xi=4.0;
9719 if ((flags & PsiValue) == 0)
9720 geometry_info.psi=4.0;
9722 if (attribute_flag[1] != 0)
9723 geometry_info.rho=argument_list[1].real_reference;
9724 if (attribute_flag[2] != 0)
9725 geometry_info.sigma=argument_list[2].real_reference;
9726 if (attribute_flag[3] != 0)
9727 geometry_info.xi=argument_list[3].integer_reference;
9728 if (attribute_flag[4] != 0)
9729 geometry_info.psi=argument_list[4].integer_reference;
9730 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9731 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9735 case 90: /* Identify */
9737 if (attribute_flag[0] == 0)
9738 argument_list[0].file_reference=(FILE *) NULL;
9739 if (attribute_flag[1] != 0)
9740 (void) SetImageArtifact(image,"identify:features",
9741 argument_list[1].string_reference);
9742 if ((attribute_flag[2] != 0) &&
9743 (argument_list[2].integer_reference != 0))
9744 (void) SetImageArtifact(image,"identify:unique","true");
9745 (void) IdentifyImage(image,argument_list[0].file_reference,
9749 case 91: /* SepiaTone */
9751 if (attribute_flag[0] == 0)
9752 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9753 image=SepiaToneImage(image,argument_list[0].real_reference,
9757 case 92: /* SigmoidalContrast */
9762 if (attribute_flag[0] != 0)
9764 flags=ParseGeometry(argument_list[0].string_reference,
9766 if ((flags & SigmaValue) == 0)
9767 geometry_info.sigma=QuantumRange/2.0;
9768 if ((flags & PercentValue) != 0)
9769 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9771 if (attribute_flag[1] != 0)
9772 geometry_info.rho=argument_list[1].real_reference;
9773 if (attribute_flag[2] != 0)
9774 geometry_info.sigma=argument_list[2].real_reference;
9775 if (attribute_flag[3] != 0)
9776 channel=(ChannelType) argument_list[3].integer_reference;
9778 if (attribute_flag[4] != 0)
9779 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9781 PushPixelChannelMap(image,channel);
9782 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9783 geometry_info.sigma);
9784 PopPixelChannelMap(image);
9787 case 93: /* Extent */
9789 if (attribute_flag[7] != 0)
9790 image->gravity=(GravityType) argument_list[7].integer_reference;
9791 if (attribute_flag[0] != 0)
9796 flags=ParseGravityGeometry(image,
9797 argument_list[0].string_reference,&geometry,exception);
9799 if (geometry.width == 0)
9800 geometry.width=image->columns;
9801 if (geometry.height == 0)
9802 geometry.height=image->rows;
9804 if (attribute_flag[1] != 0)
9805 geometry.width=argument_list[1].integer_reference;
9806 if (attribute_flag[2] != 0)
9807 geometry.height=argument_list[2].integer_reference;
9808 if (attribute_flag[3] != 0)
9809 geometry.x=argument_list[3].integer_reference;
9810 if (attribute_flag[4] != 0)
9811 geometry.y=argument_list[4].integer_reference;
9812 if (attribute_flag[5] != 0)
9813 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9815 if (attribute_flag[6] != 0)
9816 (void) QueryColorDatabase(argument_list[6].string_reference,
9817 &image->background_color,exception);
9818 image=ExtentImage(image,&geometry,exception);
9821 case 94: /* Vignette */
9823 if (attribute_flag[0] != 0)
9825 flags=ParseGeometry(argument_list[0].string_reference,
9827 if ((flags & SigmaValue) == 0)
9828 geometry_info.sigma=1.0;
9829 if ((flags & XiValue) == 0)
9830 geometry_info.xi=0.1*image->columns;
9831 if ((flags & PsiValue) == 0)
9832 geometry_info.psi=0.1*image->rows;
9834 if (attribute_flag[1] != 0)
9835 geometry_info.rho=argument_list[1].real_reference;
9836 if (attribute_flag[2] != 0)
9837 geometry_info.sigma=argument_list[2].real_reference;
9838 if (attribute_flag[3] != 0)
9839 geometry_info.xi=argument_list[3].integer_reference;
9840 if (attribute_flag[4] != 0)
9841 geometry_info.psi=argument_list[4].integer_reference;
9842 if (attribute_flag[5] != 0)
9843 (void) QueryColorDatabase(argument_list[5].string_reference,
9844 &image->background_color,exception);
9845 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9846 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9850 case 95: /* ContrastStretch */
9857 white_point=(MagickRealType) image->columns*image->rows;
9858 if (attribute_flag[0] != 0)
9860 flags=ParseGeometry(argument_list[0].string_reference,
9862 black_point=geometry_info.rho;
9863 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9865 if ((flags & PercentValue) != 0)
9867 black_point*=(double) image->columns*image->rows/100.0;
9868 white_point*=(double) image->columns*image->rows/100.0;
9870 white_point=(MagickRealType) image->columns*image->rows-
9873 if (attribute_flag[1] != 0)
9874 black_point=argument_list[1].real_reference;
9875 if (attribute_flag[2] != 0)
9876 white_point=argument_list[2].real_reference;
9877 if (attribute_flag[4] != 0)
9878 channel=(ChannelType) argument_list[4].integer_reference;
9879 PushPixelChannelMap(image,channel);
9880 (void) ContrastStretchImage(image,black_point,white_point);
9881 PopPixelChannelMap(image);
9884 case 96: /* Sans0 */
9888 case 97: /* Sans1 */
9892 case 98: /* AdaptiveSharpen */
9894 if (attribute_flag[0] != 0)
9896 flags=ParseGeometry(argument_list[0].string_reference,
9898 if ((flags & SigmaValue) == 0)
9899 geometry_info.sigma=1.0;
9901 if (attribute_flag[1] != 0)
9902 geometry_info.rho=argument_list[1].real_reference;
9903 if (attribute_flag[2] != 0)
9904 geometry_info.sigma=argument_list[2].real_reference;
9905 if (attribute_flag[3] != 0)
9906 channel=(ChannelType) argument_list[3].integer_reference;
9907 PushPixelChannelMap(image,channel);
9908 image=AdaptiveSharpenImage(image,geometry_info.rho,
9909 geometry_info.sigma,exception);
9910 if (image != (Image *) NULL)
9911 PopPixelChannelMap(image);
9914 case 99: /* Transpose */
9916 image=TransposeImage(image,exception);
9919 case 100: /* Tranverse */
9921 image=TransverseImage(image,exception);
9924 case 101: /* AutoOrient */
9926 switch (image->orientation)
9928 case TopRightOrientation:
9930 image=FlopImage(image,exception);
9933 case BottomRightOrientation:
9935 image=RotateImage(image,180.0,exception);
9938 case BottomLeftOrientation:
9940 image=FlipImage(image,exception);
9943 case LeftTopOrientation:
9945 image=TransposeImage(image,exception);
9948 case RightTopOrientation:
9950 image=RotateImage(image,90.0,exception);
9953 case RightBottomOrientation:
9955 image=TransverseImage(image,exception);
9958 case LeftBottomOrientation:
9960 image=RotateImage(image,270.0,exception);
9968 case 102: /* AdaptiveBlur */
9970 if (attribute_flag[0] != 0)
9972 flags=ParseGeometry(argument_list[0].string_reference,
9974 if ((flags & SigmaValue) == 0)
9975 geometry_info.sigma=1.0;
9977 if (attribute_flag[1] != 0)
9978 geometry_info.rho=argument_list[1].real_reference;
9979 if (attribute_flag[2] != 0)
9980 geometry_info.sigma=argument_list[2].real_reference;
9981 if (attribute_flag[3] != 0)
9982 channel=(ChannelType) argument_list[3].integer_reference;
9983 PushPixelChannelMap(image,channel);
9984 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
9986 if (image != (Image *) NULL)
9987 PopPixelChannelMap(image);
9990 case 103: /* Sketch */
9992 if (attribute_flag[0] != 0)
9994 flags=ParseGeometry(argument_list[0].string_reference,
9996 if ((flags & SigmaValue) == 0)
9997 geometry_info.sigma=1.0;
9998 if ((flags & XiValue) == 0)
9999 geometry_info.xi=1.0;
10001 if (attribute_flag[1] != 0)
10002 geometry_info.rho=argument_list[1].real_reference;
10003 if (attribute_flag[2] != 0)
10004 geometry_info.sigma=argument_list[2].real_reference;
10005 if (attribute_flag[3] != 0)
10006 geometry_info.xi=argument_list[3].real_reference;
10007 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10008 geometry_info.xi,exception);
10011 case 104: /* UniqueColors */
10013 image=UniqueImageColors(image,exception);
10016 case 105: /* AdaptiveResize */
10018 if (attribute_flag[0] != 0)
10019 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10020 &geometry,exception);
10021 if (attribute_flag[1] != 0)
10022 geometry.width=argument_list[1].integer_reference;
10023 if (attribute_flag[2] != 0)
10024 geometry.height=argument_list[2].integer_reference;
10025 if (attribute_flag[3] != 0)
10026 image->filter=(FilterTypes) argument_list[4].integer_reference;
10027 if (attribute_flag[4] != 0)
10028 SetImageArtifact(image,"filter:support",
10029 argument_list[4].string_reference);
10030 if (attribute_flag[5] != 0)
10031 image->blur=argument_list[5].real_reference;
10032 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10036 case 106: /* ClipMask */
10038 if (attribute_flag[0] == 0)
10040 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10042 goto PerlException;
10044 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10045 MagickTrue,exception);
10046 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10049 case 107: /* LinearStretch */
10056 white_point=(MagickRealType) image->columns*image->rows;
10057 if (attribute_flag[0] != 0)
10059 flags=ParseGeometry(argument_list[0].string_reference,
10061 if ((flags & SigmaValue) != 0)
10062 white_point=geometry_info.sigma;
10063 if ((flags & PercentValue) != 0)
10065 black_point*=(double) image->columns*image->rows/100.0;
10066 white_point*=(double) image->columns*image->rows/100.0;
10068 if ((flags & SigmaValue) == 0)
10069 white_point=(double) image->columns*image->rows-black_point;
10071 if (attribute_flag[1] != 0)
10072 black_point=argument_list[1].real_reference;
10073 if (attribute_flag[2] != 0)
10074 white_point=argument_list[2].real_reference;
10075 (void) LinearStretchImage(image,black_point,white_point);
10078 case 109: /* Mask */
10080 if (attribute_flag[0] == 0)
10082 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10084 goto PerlException;
10086 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10087 MagickTrue,exception);
10088 (void) NegateImage(image->mask,MagickFalse,exception);
10091 case 110: /* Polaroid */
10099 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10100 (DrawInfo *) NULL);
10101 if (attribute_flag[0] != 0)
10102 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10103 info ? info->image_info : (ImageInfo *) NULL,image,
10104 argument_list[0].string_reference));
10106 if (attribute_flag[1] != 0)
10107 angle=argument_list[1].real_reference;
10108 if (attribute_flag[2] != 0)
10109 (void) CloneString(&draw_info->font,
10110 argument_list[2].string_reference);
10111 if (attribute_flag[3] != 0)
10112 (void) QueryColorDatabase(argument_list[3].string_reference,
10113 &draw_info->stroke,exception);
10114 if (attribute_flag[4] != 0)
10115 (void) QueryColorDatabase(argument_list[4].string_reference,
10116 &draw_info->fill,exception);
10117 if (attribute_flag[5] != 0)
10118 draw_info->stroke_width=argument_list[5].real_reference;
10119 if (attribute_flag[6] != 0)
10120 draw_info->pointsize=argument_list[6].real_reference;
10121 if (attribute_flag[7] != 0)
10122 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10123 if (attribute_flag[8] != 0)
10124 (void) QueryColorDatabase(argument_list[8].string_reference,
10125 &image->background_color,exception);
10126 image=PolaroidImage(image,draw_info,angle,exception);
10127 draw_info=DestroyDrawInfo(draw_info);
10130 case 111: /* FloodfillPaint */
10141 draw_info=CloneDrawInfo(info ? info->image_info :
10142 (ImageInfo *) NULL,(DrawInfo *) NULL);
10143 if (attribute_flag[0] != 0)
10144 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10145 &geometry,exception);
10146 if (attribute_flag[1] != 0)
10147 geometry.x=argument_list[1].integer_reference;
10148 if (attribute_flag[2] != 0)
10149 geometry.y=argument_list[2].integer_reference;
10150 if (attribute_flag[3] != 0)
10151 (void) QueryColorDatabase(argument_list[3].string_reference,
10152 &draw_info->fill,exception);
10153 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10155 if (attribute_flag[4] != 0)
10156 QueryMagickColor(argument_list[4].string_reference,&target,
10158 if (attribute_flag[5] != 0)
10159 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10161 if (attribute_flag[6] != 0)
10162 channel=(ChannelType) argument_list[6].integer_reference;
10163 invert=MagickFalse;
10164 if (attribute_flag[7] != 0)
10165 invert=(MagickBooleanType) argument_list[7].integer_reference;
10166 PushPixelChannelMap(image,channel);
10167 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10168 geometry.y,invert);
10169 PopPixelChannelMap(image);
10170 draw_info=DestroyDrawInfo(draw_info);
10173 case 112: /* Distort */
10185 number_coordinates;
10190 if (attribute_flag[0] == 0)
10192 method=UndefinedDistortion;
10193 if (attribute_flag[1] != 0)
10194 method=(DistortImageMethod) argument_list[1].integer_reference;
10195 av=(AV *) argument_list[0].array_reference;
10196 number_coordinates=(size_t) av_len(av)+1;
10197 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10198 sizeof(*coordinates));
10199 if (coordinates == (double *) NULL)
10201 ThrowPerlException(exception,ResourceLimitFatalError,
10202 "MemoryAllocationFailed",PackageName);
10203 goto PerlException;
10205 for (j=0; j < (ssize_t) number_coordinates; j++)
10206 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10207 virtual_pixel=UndefinedVirtualPixelMethod;
10208 if (attribute_flag[2] != 0)
10209 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10210 argument_list[2].integer_reference);
10211 image=DistortImage(image,method,number_coordinates,coordinates,
10212 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10214 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10215 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10216 coordinates=(double *) RelinquishMagickMemory(coordinates);
10219 case 113: /* Clut */
10221 if (attribute_flag[0] == 0)
10223 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10225 goto PerlException;
10227 if (attribute_flag[1] != 0)
10228 channel=(ChannelType) argument_list[1].integer_reference;
10229 PushPixelChannelMap(image,channel);
10230 (void) ClutImage(image,argument_list[0].image_reference);
10231 PopPixelChannelMap(image);
10234 case 114: /* LiquidRescale */
10236 if (attribute_flag[0] != 0)
10237 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10238 &geometry,exception);
10239 if (attribute_flag[1] != 0)
10240 geometry.width=argument_list[1].integer_reference;
10241 if (attribute_flag[2] != 0)
10242 geometry.height=argument_list[2].integer_reference;
10243 if (attribute_flag[3] == 0)
10244 argument_list[3].real_reference=1.0;
10245 if (attribute_flag[4] == 0)
10246 argument_list[4].real_reference=0.0;
10247 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10248 argument_list[3].real_reference,argument_list[4].real_reference,
10252 case 115: /* EncipherImage */
10254 (void) EncipherImage(image,argument_list[0].string_reference,
10258 case 116: /* DecipherImage */
10260 (void) DecipherImage(image,argument_list[0].string_reference,
10264 case 117: /* Deskew */
10266 geometry_info.rho=QuantumRange/2.0;
10267 if (attribute_flag[0] != 0)
10268 flags=ParseGeometry(argument_list[0].string_reference,
10270 if (attribute_flag[1] != 0)
10271 geometry_info.rho=SiPrefixToDouble(
10272 argument_list[1].string_reference,QuantumRange);
10273 image=DeskewImage(image,geometry_info.rho,exception);
10276 case 118: /* Remap */
10281 if (attribute_flag[0] == 0)
10283 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10285 goto PerlException;
10287 quantize_info=AcquireQuantizeInfo(info->image_info);
10288 if (attribute_flag[1] != 0)
10289 quantize_info->dither=(MagickBooleanType)
10290 argument_list[1].integer_reference;
10291 if (attribute_flag[2] != 0)
10292 quantize_info->dither_method=(DitherMethod)
10293 argument_list[2].integer_reference;
10294 (void) RemapImages(quantize_info,image,
10295 argument_list[0].image_reference);
10296 quantize_info=DestroyQuantizeInfo(quantize_info);
10299 case 119: /* SparseColor */
10311 number_coordinates;
10316 if (attribute_flag[0] == 0)
10318 method=UndefinedColorInterpolate;
10319 if (attribute_flag[1] != 0)
10320 method=(SparseColorMethod) argument_list[1].integer_reference;
10321 av=(AV *) argument_list[0].array_reference;
10322 number_coordinates=(size_t) av_len(av)+1;
10323 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10324 sizeof(*coordinates));
10325 if (coordinates == (double *) NULL)
10327 ThrowPerlException(exception,ResourceLimitFatalError,
10328 "MemoryAllocationFailed",PackageName);
10329 goto PerlException;
10331 for (j=0; j < (ssize_t) number_coordinates; j++)
10332 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10333 virtual_pixel=UndefinedVirtualPixelMethod;
10334 if (attribute_flag[2] != 0)
10335 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10336 argument_list[2].integer_reference);
10337 if (attribute_flag[3] != 0)
10338 channel=(ChannelType) argument_list[3].integer_reference;
10339 PushPixelChannelMap(image,channel);
10340 image=SparseColorImage(image,method,number_coordinates,coordinates,
10342 if (image != (Image *) NULL)
10343 PopPixelChannelMap(image);
10344 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10345 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10346 coordinates=(double *) RelinquishMagickMemory(coordinates);
10349 case 120: /* Function */
10366 if (attribute_flag[0] == 0)
10368 function=UndefinedFunction;
10369 if (attribute_flag[1] != 0)
10370 function=(MagickFunction) argument_list[1].integer_reference;
10371 av=(AV *) argument_list[0].array_reference;
10372 number_parameters=(size_t) av_len(av)+1;
10373 parameters=(double *) AcquireQuantumMemory(number_parameters,
10374 sizeof(*parameters));
10375 if (parameters == (double *) NULL)
10377 ThrowPerlException(exception,ResourceLimitFatalError,
10378 "MemoryAllocationFailed",PackageName);
10379 goto PerlException;
10381 for (j=0; j < (ssize_t) number_parameters; j++)
10382 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10383 virtual_pixel=UndefinedVirtualPixelMethod;
10384 if (attribute_flag[2] != 0)
10385 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10386 argument_list[2].integer_reference);
10387 (void) FunctionImage(image,function,number_parameters,parameters,
10389 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10390 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10391 parameters=(double *) RelinquishMagickMemory(parameters);
10394 case 121: /* SelectiveBlur */
10396 if (attribute_flag[0] != 0)
10398 flags=ParseGeometry(argument_list[0].string_reference,
10400 if ((flags & SigmaValue) == 0)
10401 geometry_info.sigma=1.0;
10402 if ((flags & PercentValue) != 0)
10403 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10405 if (attribute_flag[1] != 0)
10406 geometry_info.rho=argument_list[1].real_reference;
10407 if (attribute_flag[2] != 0)
10408 geometry_info.sigma=argument_list[2].real_reference;
10409 if (attribute_flag[3] != 0)
10410 geometry_info.xi=argument_list[3].integer_reference;;
10411 if (attribute_flag[4] != 0)
10412 channel=(ChannelType) argument_list[4].integer_reference;
10413 PushPixelChannelMap(image,channel);
10414 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10415 geometry_info.xi,exception);
10416 if (image != (Image *) NULL)
10417 PopPixelChannelMap(image);
10420 case 122: /* HaldClut */
10422 if (attribute_flag[0] == 0)
10424 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10426 goto PerlException;
10428 if (attribute_flag[1] != 0)
10429 channel=(ChannelType) argument_list[1].integer_reference;
10430 PushPixelChannelMap(image,channel);
10431 (void) HaldClutImage(image,argument_list[0].image_reference);
10432 PopPixelChannelMap(image);
10435 case 123: /* BlueShift */
10437 if (attribute_flag[0] != 0)
10438 (void) ParseGeometry(argument_list[0].string_reference,
10440 image=BlueShiftImage(image,geometry_info.rho,exception);
10443 case 124: /* ForwardFourierTransformImage */
10445 image=ForwardFourierTransformImage(image,
10446 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10450 case 125: /* InverseFourierTransformImage */
10452 image=InverseFourierTransformImage(image,image->next,
10453 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10457 case 126: /* ColorDecisionList */
10459 if (attribute_flag[0] == 0)
10460 argument_list[0].string_reference=(char *) NULL;
10461 (void) ColorDecisionListImage(image,
10462 argument_list[0].string_reference);
10465 case 127: /* AutoGamma */
10467 if (attribute_flag[0] != 0)
10468 channel=(ChannelType) argument_list[0].integer_reference;
10469 PushPixelChannelMap(image,channel);
10470 (void) AutoGammaImage(image,exception);
10471 PopPixelChannelMap(image);
10474 case 128: /* AutoLevel */
10476 if (attribute_flag[0] != 0)
10477 channel=(ChannelType) argument_list[0].integer_reference;
10478 PushPixelChannelMap(image,channel);
10479 (void) AutoLevelImage(image,exception);
10480 PopPixelChannelMap(image);
10483 case 129: /* LevelColors */
10489 (void) QueryMagickColor("#000000",&black_point,exception);
10490 (void) QueryMagickColor("#ffffff",&white_point,exception);
10491 if (attribute_flag[1] != 0)
10492 (void) QueryMagickColor(argument_list[1].string_reference,
10493 &black_point,exception);
10494 if (attribute_flag[2] != 0)
10495 (void) QueryMagickColor(argument_list[2].string_reference,
10496 &white_point,exception);
10497 if (attribute_flag[3] != 0)
10498 channel=(ChannelType) argument_list[3].integer_reference;
10499 PushPixelChannelMap(image,channel);
10500 (void) LevelImageColors(image,&black_point,&white_point,
10501 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse);
10502 PopPixelChannelMap(image);
10505 case 130: /* Clamp */
10507 if (attribute_flag[0] != 0)
10508 channel=(ChannelType) argument_list[0].integer_reference;
10509 PushPixelChannelMap(image,channel);
10510 (void) ClampImage(image);
10511 PopPixelChannelMap(image);
10514 case 132: /* BrightnessContrast */
10522 if (attribute_flag[0] != 0)
10524 flags=ParseGeometry(argument_list[0].string_reference,
10526 brightness=geometry_info.rho;
10527 if ((flags & SigmaValue) == 0)
10528 contrast=geometry_info.sigma;
10530 if (attribute_flag[1] != 0)
10531 brightness=argument_list[1].real_reference;
10532 if (attribute_flag[2] != 0)
10533 contrast=argument_list[2].real_reference;
10534 if (attribute_flag[4] != 0)
10535 channel=(ChannelType) argument_list[4].integer_reference;
10536 PushPixelChannelMap(image,channel);
10537 (void) BrightnessContrastImage(image,brightness,contrast);
10538 PopPixelChannelMap(image);
10541 case 133: /* Morphology */
10552 if (attribute_flag[0] == 0)
10554 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10555 if (kernel == (KernelInfo *) NULL)
10557 if (attribute_flag[1] != 0)
10558 channel=(ChannelType) argument_list[1].integer_reference;
10559 method=UndefinedMorphology;
10560 if (attribute_flag[2] != 0)
10561 method=argument_list[2].integer_reference;
10563 if (attribute_flag[3] != 0)
10564 iterations=argument_list[4].integer_reference;
10565 PushPixelChannelMap(image,channel);
10566 image=MorphologyImage(image,method,iterations,kernel,exception);
10567 if (image != (Image *) NULL)
10568 PopPixelChannelMap(image);
10569 kernel=DestroyKernelInfo(kernel);
10572 case 108: /* Recolor */
10573 case 134: /* ColorMatrix */
10587 if (attribute_flag[0] == 0)
10589 av=(AV *) argument_list[0].array_reference;
10590 if (av == (AV *) NULL)
10592 order=(size_t) sqrt(av_len(av)+1);
10593 color_matrix=(double *) AcquireQuantumMemory(order,order*
10594 sizeof(*color_matrix));
10595 if (color_matrix == (double *) NULL)
10597 ThrowPerlException(exception,ResourceLimitFatalError,
10598 "MemoryAllocationFailed",PackageName);
10599 goto PerlException;
10601 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10602 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10603 for ( ; j < (ssize_t) (order*order); j++)
10604 color_matrix[j]=0.0;
10605 kernel_info=AcquireKernelInfo((const char *) NULL);
10606 if (kernel_info == (KernelInfo *) NULL)
10608 kernel_info->width=order;
10609 kernel_info->height=order;
10610 kernel_info->values=color_matrix;
10611 image=ColorMatrixImage(image,kernel_info,exception);
10612 kernel_info->values=(double *) NULL;
10613 kernel_info=DestroyKernelInfo(kernel_info);
10614 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10617 case 135: /* Color */
10622 (void) QueryMagickColor("none",&color,exception);
10623 if (attribute_flag[0] != 0)
10624 (void) QueryMagickColor(argument_list[0].string_reference,
10626 (void) SetImageColor(image,&color);
10629 case 136: /* Mode */
10631 if (attribute_flag[0] != 0)
10633 flags=ParseGeometry(argument_list[0].string_reference,
10635 if ((flags & SigmaValue) == 0)
10636 geometry_info.sigma=1.0;
10638 if (attribute_flag[1] != 0)
10639 geometry_info.rho=argument_list[1].real_reference;
10640 if (attribute_flag[2] != 0)
10641 geometry_info.sigma=argument_list[2].real_reference;
10642 if (attribute_flag[3] != 0)
10643 channel=(ChannelType) argument_list[3].integer_reference;
10644 PushPixelChannelMap(image,channel);
10645 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10646 (size_t) geometry_info.sigma,exception);
10647 if (image != (Image *) NULL)
10648 PopPixelChannelMap(image);
10651 case 137: /* Statistic */
10656 statistic=UndefinedStatistic;
10657 if (attribute_flag[0] != 0)
10659 flags=ParseGeometry(argument_list[0].string_reference,
10661 if ((flags & SigmaValue) == 0)
10662 geometry_info.sigma=1.0;
10664 if (attribute_flag[1] != 0)
10665 geometry_info.rho=argument_list[1].real_reference;
10666 if (attribute_flag[2] != 0)
10667 geometry_info.sigma=argument_list[2].real_reference;
10668 if (attribute_flag[3] != 0)
10669 channel=(ChannelType) argument_list[3].integer_reference;
10670 if (attribute_flag[4] != 0)
10671 statistic=(StatisticType) argument_list[4].integer_reference;
10672 PushPixelChannelMap(image,channel);
10673 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10674 (size_t) geometry_info.sigma,exception);
10675 if (image != (Image *) NULL)
10676 PopPixelChannelMap(image);
10680 if (next != (Image *) NULL)
10681 (void) CatchImageException(next);
10682 if (region_image != (Image *) NULL)
10687 status=CompositeImage(region_image,CopyCompositeOp,image,
10688 region_info.x,region_info.y);
10690 (void) CatchImageException(region_image);
10691 image=DestroyImage(image);
10692 image=region_image;
10694 if (image != (Image *) NULL)
10697 if (next && (next != image))
10699 image->next=next->next;
10700 DeleteImageFromRegistry(*pv,next);
10702 sv_setiv(*pv,(IV) image);
10710 if (reference_vector)
10711 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10712 InheritPerlException(exception,perl_exception);
10713 exception=DestroyExceptionInfo(exception);
10714 sv_setiv(perl_exception,(IV) number_images);
10715 SvPOK_on(perl_exception);
10716 ST(0)=sv_2mortal(perl_exception);
10721 ###############################################################################
10729 ###############################################################################
10734 Image::Magick ref=NO_INIT
10779 PERL_UNUSED_VAR(ref);
10780 PERL_UNUSED_VAR(ix);
10781 exception=AcquireExceptionInfo();
10782 perl_exception=newSVpv("",0);
10785 if (sv_isobject(ST(0)) == 0)
10787 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10789 goto PerlException;
10791 reference=SvRV(ST(0));
10792 hv=SvSTASH(reference);
10794 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10796 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10797 if (image == (Image *) NULL)
10799 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10801 goto PerlException;
10806 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10807 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10808 (void) QueryMagickColor("none",&transparent_color,exception);
10809 for (i=2; i < items; i+=2)
10811 attribute=(char *) SvPV(ST(i-1),na);
10812 switch (*attribute)
10817 if (LocaleCompare(attribute,"background") == 0)
10819 (void) QueryColorDatabase(SvPV(ST(i),na),
10820 &montage_info->background_color,exception);
10821 for (next=image; next; next=next->next)
10822 next->background_color=montage_info->background_color;
10825 if (LocaleCompare(attribute,"border") == 0)
10827 montage_info->border_width=SvIV(ST(i));
10830 if (LocaleCompare(attribute,"bordercolor") == 0)
10832 (void) QueryColorDatabase(SvPV(ST(i),na),
10833 &montage_info->border_color,exception);
10834 for (next=image; next; next=next->next)
10835 next->border_color=montage_info->border_color;
10838 if (LocaleCompare(attribute,"borderwidth") == 0)
10840 montage_info->border_width=SvIV(ST(i));
10843 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10850 if (LocaleCompare(attribute,"compose") == 0)
10852 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10853 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10856 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10860 for (next=image; next; next=next->next)
10861 next->compose=(CompositeOperator) sp;
10864 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10871 if (LocaleCompare(attribute,"fill") == 0)
10873 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10877 if (LocaleCompare(attribute,"font") == 0)
10879 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10882 if (LocaleCompare(attribute,"frame") == 0)
10888 if (IsGeometry(p) == MagickFalse)
10890 ThrowPerlException(exception,OptionError,"MissingGeometry",
10894 (void) CloneString(&montage_info->frame,p);
10896 montage_info->frame=(char *) NULL;
10899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10906 if (LocaleCompare(attribute,"geometry") == 0)
10912 if (IsGeometry(p) == MagickFalse)
10914 ThrowPerlException(exception,OptionError,"MissingGeometry",
10918 (void) CloneString(&montage_info->geometry,p);
10920 montage_info->geometry=(char *) NULL;
10923 if (LocaleCompare(attribute,"gravity") == 0)
10928 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10929 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10932 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10936 montage_info->gravity=(GravityType) in;
10937 for (next=image; next; next=next->next)
10938 next->gravity=(GravityType) in;
10941 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10948 if (LocaleCompare(attribute,"label") == 0)
10950 for (next=image; next; next=next->next)
10951 (void) SetImageProperty(next,"label",InterpretImageProperties(
10952 info ? info->image_info : (ImageInfo *) NULL,next,
10956 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10963 if (LocaleCompare(attribute,"mattecolor") == 0)
10965 (void) QueryColorDatabase(SvPV(ST(i),na),
10966 &montage_info->matte_color,exception);
10967 for (next=image; next; next=next->next)
10968 next->matte_color=montage_info->matte_color;
10971 if (LocaleCompare(attribute,"mode") == 0)
10976 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10977 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10982 ThrowPerlException(exception,OptionError,
10983 "UnrecognizedModeType",SvPV(ST(i),na));
10988 (void) CloneString(&montage_info->frame,"15x15+3+3");
10989 montage_info->shadow=MagickTrue;
10994 montage_info->frame=(char *) NULL;
10995 montage_info->shadow=MagickFalse;
10996 montage_info->border_width=0;
10999 case ConcatenateMode:
11001 montage_info->frame=(char *) NULL;
11002 montage_info->shadow=MagickFalse;
11003 (void) CloneString(&montage_info->geometry,"+0+0");
11004 montage_info->border_width=0;
11009 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11016 if (LocaleCompare(attribute,"pointsize") == 0)
11018 montage_info->pointsize=SvIV(ST(i));
11021 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11028 if (LocaleCompare(attribute,"shadow") == 0)
11030 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11031 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11034 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11038 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11041 if (LocaleCompare(attribute,"stroke") == 0)
11043 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11047 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11054 if (LocaleCompare(attribute,"texture") == 0)
11056 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11059 if (LocaleCompare(attribute,"tile") == 0)
11061 char *p=SvPV(ST(i),na);
11062 if (IsGeometry(p) == MagickFalse)
11064 ThrowPerlException(exception,OptionError,"MissingGeometry",
11068 (void) CloneString(&montage_info->tile,p);
11070 montage_info->tile=(char *) NULL;
11073 if (LocaleCompare(attribute,"title") == 0)
11075 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11078 if (LocaleCompare(attribute,"transparent") == 0)
11083 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11084 for (next=image; next; next=next->next)
11085 (void) TransparentPaintImage(next,&transparent_color,
11086 TransparentAlpha,MagickFalse);
11089 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11095 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11101 image=MontageImageList(info->image_info,montage_info,image,exception);
11102 montage_info=DestroyMontageInfo(montage_info);
11103 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11104 goto PerlException;
11105 if (transparent_color.alpha != TransparentAlpha)
11106 for (next=image; next; next=next->next)
11107 (void) TransparentPaintImage(next,&transparent_color,
11108 TransparentAlpha,MagickFalse);
11109 for ( ; image; image=image->next)
11111 AddImageToRegistry(sv,image);
11113 av_push(av,sv_bless(rv,hv));
11116 exception=DestroyExceptionInfo(exception);
11117 ST(0)=av_reference;
11118 SvREFCNT_dec(perl_exception);
11122 InheritPerlException(exception,perl_exception);
11123 exception=DestroyExceptionInfo(exception);
11124 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11125 SvPOK_on(perl_exception);
11126 ST(0)=sv_2mortal(perl_exception);
11131 ###############################################################################
11139 ###############################################################################
11144 Image::Magick ref=NO_INIT
11182 PERL_UNUSED_VAR(ref);
11183 PERL_UNUSED_VAR(ix);
11184 exception=AcquireExceptionInfo();
11185 perl_exception=newSVpv("",0);
11189 if (sv_isobject(ST(0)) == 0)
11191 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11193 goto PerlException;
11195 reference=SvRV(ST(0));
11196 hv=SvSTASH(reference);
11198 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11200 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11201 if (image == (Image *) NULL)
11203 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11205 goto PerlException;
11207 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11212 for (i=2; i < items; i+=2)
11214 attribute=(char *) SvPV(ST(i-1),na);
11215 switch (*attribute)
11220 if (LocaleCompare(attribute,"frames") == 0)
11222 number_frames=SvIV(ST(i));
11225 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11231 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11237 image=MorphImages(image,number_frames,exception);
11238 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11239 goto PerlException;
11240 for ( ; image; image=image->next)
11242 AddImageToRegistry(sv,image);
11244 av_push(av,sv_bless(rv,hv));
11247 exception=DestroyExceptionInfo(exception);
11248 ST(0)=av_reference;
11249 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11253 InheritPerlException(exception,perl_exception);
11254 exception=DestroyExceptionInfo(exception);
11255 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11256 SvPOK_on(perl_exception);
11257 ST(0)=sv_2mortal(perl_exception);
11262 ###############################################################################
11270 ###############################################################################
11275 Image::Magick ref=NO_INIT
11303 PERL_UNUSED_VAR(ref);
11304 PERL_UNUSED_VAR(ix);
11305 exception=AcquireExceptionInfo();
11306 perl_exception=newSVpv("",0);
11308 if (sv_isobject(ST(0)) == 0)
11310 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11312 goto PerlException;
11314 reference=SvRV(ST(0));
11315 hv=SvSTASH(reference);
11316 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11317 if (image == (Image *) NULL)
11319 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11321 goto PerlException;
11323 image=MergeImageLayers(image,MosaicLayer,exception);
11325 Create blessed Perl array for the returned image.
11328 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11330 AddImageToRegistry(sv,image);
11332 av_push(av,sv_bless(rv,hv));
11334 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11335 (void) CopyMagickString(image->filename,info->image_info->filename,
11337 SetImageInfo(info->image_info,0,&image->exception);
11338 exception=DestroyExceptionInfo(exception);
11339 SvREFCNT_dec(perl_exception);
11343 InheritPerlException(exception,perl_exception);
11344 exception=DestroyExceptionInfo(exception);
11345 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11346 SvPOK_on(perl_exception); /* return messages in string context */
11347 ST(0)=sv_2mortal(perl_exception);
11352 ###############################################################################
11360 ###############################################################################
11365 Image::Magick ref=NO_INIT
11415 PERL_UNUSED_VAR(ref);
11416 PERL_UNUSED_VAR(ix);
11417 exception=AcquireExceptionInfo();
11418 perl_exception=newSVpv("",0);
11419 package_info=(struct PackageInfo *) NULL;
11420 ac=(items < 2) ? 1 : items-1;
11421 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11423 length=(STRLEN *) NULL;
11424 if (list == (char **) NULL)
11426 ThrowPerlException(exception,ResourceLimitError,
11427 "MemoryAllocationFailed",PackageName);
11428 goto PerlException;
11431 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11432 if (length == (STRLEN *) NULL)
11434 ThrowPerlException(exception,ResourceLimitError,
11435 "MemoryAllocationFailed",PackageName);
11436 goto PerlException;
11438 if (sv_isobject(ST(0)) == 0)
11440 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11442 goto PerlException;
11444 reference=SvRV(ST(0));
11445 if (SvTYPE(reference) != SVt_PVAV)
11447 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11449 goto PerlException;
11451 av=(AV *) reference;
11452 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11454 package_info=ClonePackageInfo(info,exception);
11457 *list=(char *) (*package_info->image_info->filename ?
11458 package_info->image_info->filename : "XC:black");
11460 for (n=0, i=0; i < ac; i++)
11462 list[n]=(char *) SvPV(ST(i+1),length[n]);
11463 if ((items >= 3) && strEQcase(list[n],"blob"))
11469 blob=(void *) (SvPV(ST(i+1),length[n]));
11470 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11472 if ((items >= 3) && strEQcase(list[n],"filename"))
11474 if ((items >= 3) && strEQcase(list[n],"file"))
11483 io_info=IoIFP(sv_2io(ST(i+1)));
11484 if (io_info == (PerlIO *) NULL)
11486 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11490 file=PerlIO_findFILE(io_info);
11491 if (file == (FILE *) NULL)
11493 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11497 SetImageInfoFile(package_info->image_info,file);
11499 if ((items >= 3) && strEQcase(list[n],"magick"))
11503 list[n]=(char *) NULL;
11505 status=ExpandFilenames(&n,&list);
11506 if (status == MagickFalse)
11508 ThrowPerlException(exception,ResourceLimitError,
11509 "MemoryAllocationFailed",PackageName);
11510 goto PerlException;
11513 for (i=0; i < n; i++)
11515 (void) CopyMagickString(package_info->image_info->filename,list[i],
11517 image=PingImage(package_info->image_info,exception);
11518 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11520 if ((package_info->image_info->file != (FILE *) NULL) ||
11521 (package_info->image_info->blob != (void *) NULL))
11522 DisassociateImageStream(image);
11523 count+=GetImageListLength(image);
11524 EXTEND(sp,4*count);
11525 for (next=image; next; next=next->next)
11527 PUSHs(sv_2mortal(newSViv(next->columns)));
11528 PUSHs(sv_2mortal(newSViv(next->rows)));
11529 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11530 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11532 image=DestroyImageList(image);
11537 for (i=0; i < n; i++)
11538 if (list[i] != (char *) NULL)
11539 for (p=keep; list[i] != *p++; )
11542 list[i]=(char *) RelinquishMagickMemory(list[i]);
11547 if (package_info != (struct PackageInfo *) NULL)
11548 DestroyPackageInfo(package_info);
11549 if (list && (list != keep))
11550 list=(char **) RelinquishMagickMemory(list);
11552 keep=(char **) RelinquishMagickMemory(keep);
11554 length=(STRLEN *) RelinquishMagickMemory(length);
11555 InheritPerlException(exception,perl_exception);
11556 exception=DestroyExceptionInfo(exception);
11557 SvREFCNT_dec(perl_exception); /* throw away all errors */
11561 ###############################################################################
11569 ###############################################################################
11574 Image::Magick ref=NO_INIT
11607 PERL_UNUSED_VAR(ref);
11608 PERL_UNUSED_VAR(ix);
11609 exception=AcquireExceptionInfo();
11610 perl_exception=newSVpv("",0);
11613 if (sv_isobject(ST(0)) == 0)
11615 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11617 goto PerlException;
11619 reference=SvRV(ST(0));
11620 hv=SvSTASH(reference);
11622 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11624 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11625 if (image == (Image *) NULL)
11627 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11629 goto PerlException;
11631 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11632 preview_type=GammaPreview;
11634 preview_type=(PreviewType)
11635 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11636 for ( ; image; image=image->next)
11638 preview_image=PreviewImage(image,preview_type,exception);
11639 if (preview_image == (Image *) NULL)
11640 goto PerlException;
11641 AddImageToRegistry(sv,preview_image);
11643 av_push(av,sv_bless(rv,hv));
11646 exception=DestroyExceptionInfo(exception);
11647 ST(0)=av_reference;
11648 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11652 InheritPerlException(exception,perl_exception);
11653 exception=DestroyExceptionInfo(exception);
11654 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11655 SvPOK_on(perl_exception);
11656 ST(0)=sv_2mortal(perl_exception);
11661 ###############################################################################
11665 # Q u e r y C o l o r #
11669 ###############################################################################
11673 QueryColor(ref,...)
11674 Image::Magick ref=NO_INIT
11694 PERL_UNUSED_VAR(ref);
11695 PERL_UNUSED_VAR(ix);
11696 exception=AcquireExceptionInfo();
11697 perl_exception=newSVpv("",0);
11706 colorlist=GetColorInfoList("*",&colors,exception);
11708 for (i=0; i < (ssize_t) colors; i++)
11710 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11712 colorlist=(const ColorInfo **)
11713 RelinquishMagickMemory((ColorInfo **) colorlist);
11714 goto PerlException;
11716 EXTEND(sp,5*items);
11717 for (i=1; i < items; i++)
11719 name=(char *) SvPV(ST(i),na);
11720 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11725 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11726 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11727 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11728 if (color.colorspace == CMYKColorspace)
11729 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11730 if (color.matte != MagickFalse)
11731 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11735 InheritPerlException(exception,perl_exception);
11736 exception=DestroyExceptionInfo(exception);
11737 SvREFCNT_dec(perl_exception);
11741 ###############################################################################
11745 # Q u e r y C o l o r N a m e #
11749 ###############################################################################
11753 QueryColorname(ref,...)
11754 Image::Magick ref=NO_INIT
11763 message[MaxTextExtent];
11782 *reference; /* reference is the SV* of ref=SvIV(reference) */
11784 PERL_UNUSED_VAR(ref);
11785 PERL_UNUSED_VAR(ix);
11786 exception=AcquireExceptionInfo();
11787 perl_exception=newSVpv("",0);
11788 reference=SvRV(ST(0));
11789 av=(AV *) reference;
11790 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11792 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11793 if (image == (Image *) NULL)
11795 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11797 goto PerlException;
11800 for (i=1; i < items; i++)
11802 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11803 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11805 PUSHs(sv_2mortal(newSVpv(message,0)));
11809 InheritPerlException(exception,perl_exception);
11810 exception=DestroyExceptionInfo(exception);
11811 SvREFCNT_dec(perl_exception);
11815 ###############################################################################
11819 # Q u e r y F o n t #
11823 ###############################################################################
11828 Image::Magick ref=NO_INIT
11835 message[MaxTextExtent];
11846 volatile const TypeInfo
11849 PERL_UNUSED_VAR(ref);
11850 PERL_UNUSED_VAR(ix);
11851 exception=AcquireExceptionInfo();
11852 perl_exception=newSVpv("",0);
11861 typelist=GetTypeInfoList("*",&types,exception);
11863 for (i=0; i < (ssize_t) types; i++)
11865 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11867 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11869 goto PerlException;
11871 EXTEND(sp,10*items);
11872 for (i=1; i < items; i++)
11874 name=(char *) SvPV(ST(i),na);
11875 type_info=GetTypeInfo(name,exception);
11876 if (type_info == (TypeInfo *) NULL)
11881 if (type_info->name == (char *) NULL)
11884 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11885 if (type_info->description == (char *) NULL)
11888 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11889 if (type_info->family == (char *) NULL)
11892 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11893 if (type_info->style == UndefinedStyle)
11896 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11897 type_info->style),0)));
11898 if (type_info->stretch == UndefinedStretch)
11901 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11902 type_info->stretch),0)));
11903 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11904 type_info->weight);
11905 PUSHs(sv_2mortal(newSVpv(message,0)));
11906 if (type_info->encoding == (char *) NULL)
11909 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11910 if (type_info->foundry == (char *) NULL)
11913 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11914 if (type_info->format == (char *) NULL)
11917 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11918 if (type_info->metrics == (char *) NULL)
11921 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11922 if (type_info->glyphs == (char *) NULL)
11925 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11929 InheritPerlException(exception,perl_exception);
11930 exception=DestroyExceptionInfo(exception);
11931 SvREFCNT_dec(perl_exception);
11935 ###############################################################################
11939 # Q u e r y F o n t M e t r i c s #
11943 ###############################################################################
11947 QueryFontMetrics(ref,...)
11948 Image::Magick ref=NO_INIT
11950 queryfontmetrics = 1
11997 *reference; /* reference is the SV* of ref=SvIV(reference) */
12002 PERL_UNUSED_VAR(ref);
12003 PERL_UNUSED_VAR(ix);
12004 exception=AcquireExceptionInfo();
12005 package_info=(struct PackageInfo *) NULL;
12006 perl_exception=newSVpv("",0);
12007 reference=SvRV(ST(0));
12008 av=(AV *) reference;
12009 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12011 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12012 if (image == (Image *) NULL)
12014 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12016 goto PerlException;
12018 package_info=ClonePackageInfo(info,exception);
12019 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12020 CloneString(&draw_info->text,"");
12021 current=draw_info->affine;
12022 GetAffineMatrix(&affine);
12025 EXTEND(sp,7*items);
12026 for (i=2; i < items; i+=2)
12028 attribute=(char *) SvPV(ST(i-1),na);
12029 switch (*attribute)
12034 if (LocaleCompare(attribute,"antialias") == 0)
12036 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12040 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12044 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12047 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12054 if (LocaleCompare(attribute,"density") == 0)
12056 CloneString(&draw_info->density,SvPV(ST(i),na));
12059 if (LocaleCompare(attribute,"direction") == 0)
12061 draw_info->direction=(DirectionType) ParseCommandOption(
12062 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12065 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12072 if (LocaleCompare(attribute,"encoding") == 0)
12074 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12077 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12084 if (LocaleCompare(attribute,"family") == 0)
12086 CloneString(&draw_info->family,SvPV(ST(i),na));
12089 if (LocaleCompare(attribute,"fill") == 0)
12092 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12093 &image->exception);
12096 if (LocaleCompare(attribute,"font") == 0)
12098 CloneString(&draw_info->font,SvPV(ST(i),na));
12101 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12108 if (LocaleCompare(attribute,"geometry") == 0)
12110 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12113 if (LocaleCompare(attribute,"gravity") == 0)
12115 draw_info->gravity=(GravityType) ParseCommandOption(
12116 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12119 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12126 if (LocaleCompare(attribute,"interline-spacing") == 0)
12128 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12129 draw_info->interline_spacing=geometry_info.rho;
12132 if (LocaleCompare(attribute,"interword-spacing") == 0)
12134 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12135 draw_info->interword_spacing=geometry_info.rho;
12138 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12145 if (LocaleCompare(attribute,"kerning") == 0)
12147 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12148 draw_info->kerning=geometry_info.rho;
12151 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12158 if (LocaleCompare(attribute,"pointsize") == 0)
12160 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12161 draw_info->pointsize=geometry_info.rho;
12164 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12171 if (LocaleCompare(attribute,"rotate") == 0)
12173 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12174 affine.rx=geometry_info.rho;
12175 affine.ry=geometry_info.sigma;
12176 if ((flags & SigmaValue) == 0)
12177 affine.ry=affine.rx;
12180 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12187 if (LocaleCompare(attribute,"scale") == 0)
12189 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12190 affine.sx=geometry_info.rho;
12191 affine.sy=geometry_info.sigma;
12192 if ((flags & SigmaValue) == 0)
12193 affine.sy=affine.sx;
12196 if (LocaleCompare(attribute,"skew") == 0)
12202 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12203 x_angle=geometry_info.rho;
12204 y_angle=geometry_info.sigma;
12205 if ((flags & SigmaValue) == 0)
12207 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12208 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12211 if (LocaleCompare(attribute,"stroke") == 0)
12214 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12215 &image->exception);
12218 if (LocaleCompare(attribute,"style") == 0)
12220 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12224 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12228 draw_info->style=(StyleType) type;
12231 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12238 if (LocaleCompare(attribute,"text") == 0)
12240 CloneString(&draw_info->text,SvPV(ST(i),na));
12243 if (LocaleCompare(attribute,"translate") == 0)
12245 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12246 affine.tx=geometry_info.rho;
12247 affine.ty=geometry_info.sigma;
12248 if ((flags & SigmaValue) == 0)
12249 affine.ty=affine.tx;
12252 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12259 if (LocaleCompare(attribute,"weight") == 0)
12261 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12262 draw_info->weight=(size_t) geometry_info.rho;
12265 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12272 if (LocaleCompare(attribute,"x") == 0)
12274 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12275 x=geometry_info.rho;
12278 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12285 if (LocaleCompare(attribute,"y") == 0)
12287 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12288 y=geometry_info.rho;
12291 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12297 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12303 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12304 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12305 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12306 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12307 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12308 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12309 if (draw_info->geometry == (char *) NULL)
12311 draw_info->geometry=AcquireString((char *) NULL);
12312 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12313 "%.15g,%.15g",x,y);
12315 status=GetTypeMetrics(image,draw_info,&metrics);
12316 (void) CatchImageException(image);
12317 if (status == MagickFalse)
12321 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12322 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12323 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12324 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12325 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12326 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12327 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12328 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12329 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12330 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12331 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12332 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12333 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12335 draw_info=DestroyDrawInfo(draw_info);
12338 if (package_info != (struct PackageInfo *) NULL)
12339 DestroyPackageInfo(package_info);
12340 InheritPerlException(exception,perl_exception);
12341 exception=DestroyExceptionInfo(exception);
12342 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12346 ###############################################################################
12350 # 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 #
12354 ###############################################################################
12358 QueryMultilineFontMetrics(ref,...)
12359 Image::Magick ref=NO_INIT
12361 querymultilinefontmetrics = 1
12408 *reference; /* reference is the SV* of ref=SvIV(reference) */
12413 PERL_UNUSED_VAR(ref);
12414 PERL_UNUSED_VAR(ix);
12415 exception=AcquireExceptionInfo();
12416 package_info=(struct PackageInfo *) NULL;
12417 perl_exception=newSVpv("",0);
12418 reference=SvRV(ST(0));
12419 av=(AV *) reference;
12420 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12422 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12423 if (image == (Image *) NULL)
12425 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12427 goto PerlException;
12429 package_info=ClonePackageInfo(info,exception);
12430 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12431 CloneString(&draw_info->text,"");
12432 current=draw_info->affine;
12433 GetAffineMatrix(&affine);
12436 EXTEND(sp,7*items);
12437 for (i=2; i < items; i+=2)
12439 attribute=(char *) SvPV(ST(i-1),na);
12440 switch (*attribute)
12445 if (LocaleCompare(attribute,"antialias") == 0)
12447 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12451 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12455 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12458 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12465 if (LocaleCompare(attribute,"density") == 0)
12467 CloneString(&draw_info->density,SvPV(ST(i),na));
12470 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12477 if (LocaleCompare(attribute,"encoding") == 0)
12479 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12482 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12489 if (LocaleCompare(attribute,"family") == 0)
12491 CloneString(&draw_info->family,SvPV(ST(i),na));
12494 if (LocaleCompare(attribute,"fill") == 0)
12497 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12498 &image->exception);
12501 if (LocaleCompare(attribute,"font") == 0)
12503 CloneString(&draw_info->font,SvPV(ST(i),na));
12506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12513 if (LocaleCompare(attribute,"geometry") == 0)
12515 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12518 if (LocaleCompare(attribute,"gravity") == 0)
12520 draw_info->gravity=(GravityType) ParseCommandOption(
12521 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12524 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12531 if (LocaleCompare(attribute,"pointsize") == 0)
12533 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12534 draw_info->pointsize=geometry_info.rho;
12537 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12544 if (LocaleCompare(attribute,"rotate") == 0)
12546 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12547 affine.rx=geometry_info.rho;
12548 affine.ry=geometry_info.sigma;
12549 if ((flags & SigmaValue) == 0)
12550 affine.ry=affine.rx;
12553 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12560 if (LocaleCompare(attribute,"scale") == 0)
12562 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12563 affine.sx=geometry_info.rho;
12564 affine.sy=geometry_info.sigma;
12565 if ((flags & SigmaValue) == 0)
12566 affine.sy=affine.sx;
12569 if (LocaleCompare(attribute,"skew") == 0)
12575 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12576 x_angle=geometry_info.rho;
12577 y_angle=geometry_info.sigma;
12578 if ((flags & SigmaValue) == 0)
12580 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12581 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12584 if (LocaleCompare(attribute,"stroke") == 0)
12587 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12588 &image->exception);
12591 if (LocaleCompare(attribute,"style") == 0)
12593 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12597 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12601 draw_info->style=(StyleType) type;
12604 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12611 if (LocaleCompare(attribute,"text") == 0)
12613 CloneString(&draw_info->text,SvPV(ST(i),na));
12616 if (LocaleCompare(attribute,"translate") == 0)
12618 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12619 affine.tx=geometry_info.rho;
12620 affine.ty=geometry_info.sigma;
12621 if ((flags & SigmaValue) == 0)
12622 affine.ty=affine.tx;
12625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12632 if (LocaleCompare(attribute,"weight") == 0)
12634 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12635 draw_info->weight=(size_t) geometry_info.rho;
12638 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12645 if (LocaleCompare(attribute,"x") == 0)
12647 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12648 x=geometry_info.rho;
12651 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12658 if (LocaleCompare(attribute,"y") == 0)
12660 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12661 y=geometry_info.rho;
12664 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12670 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12676 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12677 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12678 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12679 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12680 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12681 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12682 if (draw_info->geometry == (char *) NULL)
12684 draw_info->geometry=AcquireString((char *) NULL);
12685 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12686 "%.15g,%.15g",x,y);
12688 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12689 (void) CatchImageException(image);
12690 if (status == MagickFalse)
12694 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12695 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12696 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12697 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12698 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12699 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12700 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12701 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12702 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12703 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12704 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12705 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12706 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12708 draw_info=DestroyDrawInfo(draw_info);
12711 if (package_info != (struct PackageInfo *) NULL)
12712 DestroyPackageInfo(package_info);
12713 InheritPerlException(exception,perl_exception);
12714 exception=DestroyExceptionInfo(exception);
12715 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12719 ###############################################################################
12723 # Q u e r y F o r m a t #
12727 ###############################################################################
12731 QueryFormat(ref,...)
12732 Image::Magick ref=NO_INIT
12749 volatile const MagickInfo
12752 PERL_UNUSED_VAR(ref);
12753 PERL_UNUSED_VAR(ix);
12754 exception=AcquireExceptionInfo();
12755 perl_exception=newSVpv("",0);
12759 format[MaxTextExtent];
12767 format_list=GetMagickInfoList("*",&types,exception);
12769 for (i=0; i < (ssize_t) types; i++)
12771 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12772 LocaleLower(format);
12773 PUSHs(sv_2mortal(newSVpv(format,0)));
12775 format_list=(const MagickInfo **)
12776 RelinquishMagickMemory((MagickInfo *) format_list);
12777 goto PerlException;
12779 EXTEND(sp,8*items);
12780 for (i=1; i < items; i++)
12782 name=(char *) SvPV(ST(i),na);
12783 magick_info=GetMagickInfo(name,exception);
12784 if (magick_info == (const MagickInfo *) NULL)
12789 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12790 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12791 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12792 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12793 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12794 if (magick_info->description == (char *) NULL)
12797 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12798 if (magick_info->module == (char *) NULL)
12801 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12805 InheritPerlException(exception,perl_exception);
12806 exception=DestroyExceptionInfo(exception);
12807 SvREFCNT_dec(perl_exception);
12811 ###############################################################################
12815 # Q u e r y O p t i o n #
12819 ###############################################################################
12823 QueryOption(ref,...)
12824 Image::Magick ref=NO_INIT
12845 PERL_UNUSED_VAR(ref);
12846 PERL_UNUSED_VAR(ix);
12847 exception=AcquireExceptionInfo();
12848 perl_exception=newSVpv("",0);
12849 EXTEND(sp,8*items);
12850 for (i=1; i < items; i++)
12852 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12854 options=GetCommandOptions((CommandOption) option);
12855 if (options == (char **) NULL)
12859 for (j=0; options[j] != (char *) NULL; j++)
12860 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12861 options=DestroyStringList(options);
12865 InheritPerlException(exception,perl_exception);
12866 exception=DestroyExceptionInfo(exception);
12867 SvREFCNT_dec(perl_exception);
12871 ###############################################################################
12879 ###############################################################################
12884 Image::Magick ref=NO_INIT
12931 *perl_exception, /* Perl variable for storing messages */
12936 PERL_UNUSED_VAR(ref);
12937 PERL_UNUSED_VAR(ix);
12938 exception=AcquireExceptionInfo();
12939 perl_exception=newSVpv("",0);
12941 package_info=(struct PackageInfo *) NULL;
12943 ac=(items < 2) ? 1 : items-1;
12944 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12946 length=(STRLEN *) NULL;
12947 if (list == (char **) NULL)
12949 ThrowPerlException(exception,ResourceLimitError,
12950 "MemoryAllocationFailed",PackageName);
12951 goto PerlException;
12953 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12954 if (length == (STRLEN *) NULL)
12956 ThrowPerlException(exception,ResourceLimitError,
12957 "MemoryAllocationFailed",PackageName);
12958 goto PerlException;
12960 if (sv_isobject(ST(0)) == 0)
12962 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12964 goto PerlException;
12966 reference=SvRV(ST(0));
12967 hv=SvSTASH(reference);
12968 if (SvTYPE(reference) != SVt_PVAV)
12970 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12972 goto PerlException;
12974 av=(AV *) reference;
12975 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12977 package_info=ClonePackageInfo(info,exception);
12980 *list=(char *) (*package_info->image_info->filename ?
12981 package_info->image_info->filename : "XC:black");
12983 for (n=0, i=0; i < ac; i++)
12985 list[n]=(char *) SvPV(ST(i+1),length[n]);
12986 if ((items >= 3) && strEQcase(list[n],"blob"))
12992 blob=(void *) (SvPV(ST(i+1),length[n]));
12993 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12995 if ((items >= 3) && strEQcase(list[n],"filename"))
12997 if ((items >= 3) && strEQcase(list[n],"file"))
13006 io_info=IoIFP(sv_2io(ST(i+1)));
13007 if (io_info == (PerlIO *) NULL)
13009 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13013 file=PerlIO_findFILE(io_info);
13014 if (file == (FILE *) NULL)
13016 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13020 SetImageInfoFile(package_info->image_info,file);
13022 if ((items >= 3) && strEQcase(list[n],"magick"))
13026 list[n]=(char *) NULL;
13028 status=ExpandFilenames(&n,&list);
13029 if (status == MagickFalse)
13031 ThrowPerlException(exception,ResourceLimitError,
13032 "MemoryAllocationFailed",PackageName);
13033 goto PerlException;
13036 for (i=0; i < n; i++)
13038 if ((package_info->image_info->file != (FILE *) NULL) ||
13039 (package_info->image_info->blob != (void *) NULL))
13041 image=ReadImages(package_info->image_info,exception);
13042 if (image != (Image *) NULL)
13043 DisassociateImageStream(image);
13047 (void) CopyMagickString(package_info->image_info->filename,list[i],
13049 image=ReadImages(package_info->image_info,exception);
13051 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13053 for ( ; image; image=image->next)
13055 AddImageToRegistry(sv,image);
13057 av_push(av,sv_bless(rv,hv));
13065 for (i=0; i < n; i++)
13066 if (list[i] != (char *) NULL)
13067 for (p=keep; list[i] != *p++; )
13068 if (*p == (char *) NULL)
13070 list[i]=(char *) RelinquishMagickMemory(list[i]);
13075 if (package_info != (struct PackageInfo *) NULL)
13076 DestroyPackageInfo(package_info);
13077 if (list && (list != keep))
13078 list=(char **) RelinquishMagickMemory(list);
13080 keep=(char **) RelinquishMagickMemory(keep);
13082 length=(STRLEN *) RelinquishMagickMemory(length);
13083 InheritPerlException(exception,perl_exception);
13084 exception=DestroyExceptionInfo(exception);
13085 sv_setiv(perl_exception,(IV) number_images);
13086 SvPOK_on(perl_exception);
13087 ST(0)=sv_2mortal(perl_exception);
13092 ###############################################################################
13100 ###############################################################################
13105 Image::Magick ref=NO_INIT
13128 PERL_UNUSED_VAR(ref);
13129 PERL_UNUSED_VAR(ix);
13130 exception=AcquireExceptionInfo();
13131 perl_exception=newSVpv("",0);
13132 reference=SvRV(ST(0));
13133 av=(AV *) reference;
13134 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13136 for (i=1; i < items; i++)
13137 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13138 SvPV(ST(i),na),exception);
13139 InheritPerlException(exception,perl_exception);
13140 exception=DestroyExceptionInfo(exception);
13141 SvREFCNT_dec(perl_exception); /* throw away all errors */
13145 ###############################################################################
13153 ###############################################################################
13158 Image::Magick ref=NO_INIT
13181 *reference; /* reference is the SV* of ref=SvIV(reference) */
13183 PERL_UNUSED_VAR(ref);
13184 PERL_UNUSED_VAR(ix);
13185 exception=AcquireExceptionInfo();
13186 perl_exception=newSVpv("",0);
13187 if (sv_isobject(ST(0)) == 0)
13189 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13191 goto PerlException;
13193 reference=SvRV(ST(0));
13194 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13196 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13198 for (i=2; i < items; i+=2)
13199 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13202 InheritPerlException(exception,perl_exception);
13203 exception=DestroyExceptionInfo(exception);
13204 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13205 SvPOK_on(perl_exception);
13206 ST(0)=sv_2mortal(perl_exception);
13211 ###############################################################################
13215 # S e t P i x e l #
13219 ###############################################################################
13224 Image::Magick ref=NO_INIT
13265 *reference; /* reference is the SV* of ref=SvIV(reference) */
13267 PERL_UNUSED_VAR(ref);
13268 PERL_UNUSED_VAR(ix);
13269 exception=AcquireExceptionInfo();
13270 perl_exception=newSVpv("",0);
13271 reference=SvRV(ST(0));
13272 av=(AV *) reference;
13273 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13275 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13276 if (image == (Image *) NULL)
13278 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13280 goto PerlException;
13283 normalize=MagickTrue;
13286 region.width=image->columns;
13289 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13290 channel=DefaultChannels;
13291 for (i=2; i < items; i+=2)
13293 attribute=(char *) SvPV(ST(i-1),na);
13294 switch (*attribute)
13299 if (LocaleCompare(attribute,"channel") == 0)
13304 option=ParseChannelOption(SvPV(ST(i),na));
13307 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13311 channel=(ChannelType) option;
13314 if (LocaleCompare(attribute,"color") == 0)
13316 if (SvTYPE(ST(i)) != SVt_RV)
13319 message[MaxTextExtent];
13321 (void) FormatLocaleString(message,MaxTextExtent,
13322 "invalid %.60s value",attribute);
13323 ThrowPerlException(exception,OptionError,message,
13326 av=(AV *) SvRV(ST(i));
13329 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13336 if (LocaleCompare(attribute,"geometry") == 0)
13338 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13341 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13348 if (LocaleCompare(attribute,"normalize") == 0)
13350 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13354 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13358 normalize=option != 0 ? MagickTrue : MagickFalse;
13361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13368 if (LocaleCompare(attribute,"x") == 0)
13370 region.x=SvIV(ST(i));
13373 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13380 if (LocaleCompare(attribute,"y") == 0)
13382 region.y=SvIV(ST(i));
13385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13391 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13397 (void) SetImageStorageClass(image,DirectClass,exception);
13398 PushPixelChannelMap(image,channel);
13399 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13400 if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) ||
13401 (SvTYPE(av) != SVt_PVAV))
13413 if (normalize != MagickFalse)
13414 scale=QuantumRange;
13415 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13418 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13419 av_fetch(av,i,0)))),q);
13422 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13425 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13426 av_fetch(av,i,0)))),q);
13429 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13432 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13433 av_fetch(av,i,0)))),q);
13436 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13437 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13439 SetPixelBlack(image,ClampToQuantum(scale*
13440 SvNV(*(av_fetch(av,i,0)))),q);
13443 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13446 SetPixelAlpha(image,ClampToQuantum(scale*
13447 SvNV(*(av_fetch(av,i,0)))),q);
13450 (void) SyncAuthenticPixels(image,exception);
13452 PopPixelChannelMap(image);
13455 InheritPerlException(exception,perl_exception);
13456 exception=DestroyExceptionInfo(exception);
13457 SvREFCNT_dec(perl_exception);
13461 ###############################################################################
13469 ###############################################################################
13474 Image::Magick ref=NO_INIT
13513 PERL_UNUSED_VAR(ref);
13514 PERL_UNUSED_VAR(ix);
13515 exception=AcquireExceptionInfo();
13516 perl_exception=newSVpv("",0);
13520 if (sv_isobject(ST(0)) == 0)
13522 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13524 goto PerlException;
13526 reference=SvRV(ST(0));
13527 hv=SvSTASH(reference);
13529 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13531 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13532 if (image == (Image *) NULL)
13534 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13536 goto PerlException;
13538 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13544 for (i=2; i < items; i+=2)
13546 attribute=(char *) SvPV(ST(i-1),na);
13547 switch (*attribute)
13552 if (LocaleCompare(attribute,"offset") == 0)
13554 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13557 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13564 if (LocaleCompare(attribute,"stack") == 0)
13566 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13570 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13576 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13582 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13588 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13590 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13591 goto PerlException;
13592 for ( ; image; image=image->next)
13594 AddImageToRegistry(sv,image);
13596 av_push(av,sv_bless(rv,hv));
13599 exception=DestroyExceptionInfo(exception);
13600 ST(0)=av_reference;
13601 SvREFCNT_dec(perl_exception);
13605 InheritPerlException(exception,perl_exception);
13606 exception=DestroyExceptionInfo(exception);
13607 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13608 SvPOK_on(perl_exception);
13609 ST(0)=sv_2mortal(perl_exception);
13614 ###############################################################################
13618 # S t a t i s t i c s #
13622 ###############################################################################
13626 Statistics(ref,...)
13627 Image::Magick ref=NO_INIT
13629 StatisticsImage = 1
13631 statisticsimage = 3
13634 #define ChannelStatistics(channel) \
13636 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13637 (double) channel_statistics[channel].depth); \
13638 PUSHs(sv_2mortal(newSVpv(message,0))); \
13639 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13640 channel_statistics[channel].minima/scale); \
13641 PUSHs(sv_2mortal(newSVpv(message,0))); \
13642 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13643 channel_statistics[channel].maxima/scale); \
13644 PUSHs(sv_2mortal(newSVpv(message,0))); \
13645 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13646 channel_statistics[channel].mean/scale); \
13647 PUSHs(sv_2mortal(newSVpv(message,0))); \
13648 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13649 channel_statistics[channel].standard_deviation/scale); \
13650 PUSHs(sv_2mortal(newSVpv(message,0))); \
13651 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13652 channel_statistics[channel].kurtosis); \
13653 PUSHs(sv_2mortal(newSVpv(message,0))); \
13654 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13655 channel_statistics[channel].skewness); \
13656 PUSHs(sv_2mortal(newSVpv(message,0))); \
13663 message[MaxTextExtent];
13666 *channel_statistics;
13687 PERL_UNUSED_VAR(ref);
13688 PERL_UNUSED_VAR(ix);
13689 exception=AcquireExceptionInfo();
13690 perl_exception=newSVpv("",0);
13692 if (sv_isobject(ST(0)) == 0)
13694 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13696 goto PerlException;
13698 reference=SvRV(ST(0));
13701 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13702 if (image == (Image *) NULL)
13704 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13706 goto PerlException;
13708 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13710 for ( ; image; image=image->next)
13712 channel_statistics=GetImageStatistics(image,&image->exception);
13713 if (channel_statistics == (ChannelStatistics *) NULL)
13716 EXTEND(sp,35*count);
13717 scale=(double) QuantumRange;
13718 ChannelStatistics(RedChannel);
13719 ChannelStatistics(GreenChannel);
13720 ChannelStatistics(BlueChannel);
13721 if (image->colorspace == CMYKColorspace)
13722 ChannelStatistics(BlackChannel);
13723 if (image->matte != MagickFalse)
13724 ChannelStatistics(AlphaChannel);
13725 channel_statistics=(ChannelStatistics *)
13726 RelinquishMagickMemory(channel_statistics);
13730 InheritPerlException(exception,perl_exception);
13731 exception=DestroyExceptionInfo(exception);
13732 SvREFCNT_dec(perl_exception);
13736 ###############################################################################
13740 # S y n c A u t h e n t i c P i x e l s #
13744 ###############################################################################
13748 SyncAuthenticPixels(ref,...)
13749 Image::Magick ref = NO_INIT
13751 Syncauthenticpixels = 1
13752 SyncImagePixels = 2
13753 syncimagepixels = 3
13772 PERL_UNUSED_VAR(ref);
13773 PERL_UNUSED_VAR(ix);
13774 exception=AcquireExceptionInfo();
13775 perl_exception=newSVpv("",0);
13776 if (sv_isobject(ST(0)) == 0)
13778 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13780 goto PerlException;
13783 reference=SvRV(ST(0));
13784 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13785 if (image == (Image *) NULL)
13787 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13789 goto PerlException;
13792 status=SyncAuthenticPixels(image,exception);
13793 if (status != MagickFalse)
13795 InheritException(exception,&image->exception);
13798 InheritPerlException(exception,perl_exception);
13799 exception=DestroyExceptionInfo(exception);
13800 SvREFCNT_dec(perl_exception); /* throw away all errors */
13804 ###############################################################################
13808 # T r a n s f o r m #
13812 ###############################################################################
13817 Image::Magick ref=NO_INIT
13855 PERL_UNUSED_VAR(ref);
13856 PERL_UNUSED_VAR(ix);
13857 exception=AcquireExceptionInfo();
13858 perl_exception=newSVpv("",0);
13862 if (sv_isobject(ST(0)) == 0)
13864 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13866 goto PerlException;
13868 reference=SvRV(ST(0));
13869 hv=SvSTASH(reference);
13871 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13873 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13874 if (image == (Image *) NULL)
13876 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13878 goto PerlException;
13880 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13884 crop_geometry=(char *) NULL;
13885 geometry=(char *) NULL;
13886 for (i=2; i < items; i+=2)
13888 attribute=(char *) SvPV(ST(i-1),na);
13889 switch (*attribute)
13894 if (LocaleCompare(attribute,"crop") == 0)
13896 crop_geometry=SvPV(ST(i),na);
13899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13906 if (LocaleCompare(attribute,"geometry") == 0)
13908 geometry=SvPV(ST(i),na);
13911 if (LocaleCompare(attribute,"gravity") == 0)
13919 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13920 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13923 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13927 for (next=image; next; next=next->next)
13928 next->gravity=(GravityType) in;
13931 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13937 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13943 for ( ; image; image=image->next)
13945 clone=CloneImage(image,0,0,MagickTrue,exception);
13946 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13947 goto PerlException;
13948 TransformImage(&clone,crop_geometry,geometry);
13949 for ( ; clone; clone=clone->next)
13951 AddImageToRegistry(sv,clone);
13953 av_push(av,sv_bless(rv,hv));
13957 exception=DestroyExceptionInfo(exception);
13958 ST(0)=av_reference;
13959 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13963 InheritPerlException(exception,perl_exception);
13964 exception=DestroyExceptionInfo(exception);
13965 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13966 SvPOK_on(perl_exception);
13967 ST(0)=sv_2mortal(perl_exception);
13972 ###############################################################################
13980 ###############################################################################
13985 Image::Magick ref=NO_INIT
13993 filename[MaxTextExtent];
14017 PERL_UNUSED_VAR(ref);
14018 PERL_UNUSED_VAR(ix);
14019 exception=AcquireExceptionInfo();
14020 perl_exception=newSVpv("",0);
14022 package_info=(struct PackageInfo *) NULL;
14023 if (sv_isobject(ST(0)) == 0)
14025 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14027 goto PerlException;
14029 reference=SvRV(ST(0));
14030 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14031 if (image == (Image *) NULL)
14033 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14035 goto PerlException;
14037 package_info=ClonePackageInfo(info,exception);
14039 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14042 for (i=2; i < items; i+=2)
14043 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14045 (void) CopyMagickString(filename,package_info->image_info->filename,
14048 for (next=image; next; next=next->next)
14050 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14051 next->scene=scene++;
14053 SetImageInfo(package_info->image_info,(unsigned int)
14054 GetImageListLength(image),&image->exception);
14055 for (next=image; next; next=next->next)
14057 (void) WriteImage(package_info->image_info,next);
14058 if (next->exception.severity >= ErrorException)
14059 InheritException(exception,&next->exception);
14060 GetImageException(next,exception);
14062 if (package_info->image_info->adjoin)
14067 if (package_info != (struct PackageInfo *) NULL)
14068 DestroyPackageInfo(package_info);
14069 InheritPerlException(exception,perl_exception);
14070 exception=DestroyExceptionInfo(exception);
14071 sv_setiv(perl_exception,(IV) number_images);
14072 SvPOK_on(perl_exception);
14073 ST(0)=sv_2mortal(perl_exception);