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.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv((IV) image); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
218 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
219 {"height", IntegerReference}, {"x", IntegerReference},
220 {"y", IntegerReference} } },
221 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
222 {"height", IntegerReference}, {"x", IntegerReference},
223 {"y", IntegerReference}, {"fuzz", StringReference},
224 {"gravity", MagickGravityOptions} } },
226 { "Edge", { {"radius", RealReference} } },
227 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
228 {"sigma", RealReference} } },
232 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
233 {"height", IntegerReference}, {"inner", IntegerReference},
234 {"outer", IntegerReference}, {"fill", StringReference},
235 {"color", StringReference}, {"compose", MagickComposeOptions} } },
236 { "Implode", { {"amount", RealReference},
237 {"interpolate", MagickInterpolateOptions} } },
239 { "MedianFilter", { {"geometry", StringReference},
240 {"width", IntegerReference}, {"height", IntegerReference},
241 {"channel", MagickChannelOptions} } },
243 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
244 { "ReduceNoise", { {"geometry", StringReference},
245 {"width", IntegerReference},{"height", IntegerReference},
246 {"channel", MagickChannelOptions} } },
247 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
248 {"y", IntegerReference} } },
249 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
250 {"color", StringReference}, {"background", StringReference} } },
251 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
252 {"height", IntegerReference} } },
253 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
254 {"height", IntegerReference} } },
255 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
256 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
257 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
258 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
259 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
260 {"y", RealReference}, { "fill", StringReference},
261 {"color", StringReference} } },
262 { "Spread", { {"radius", RealReference} } },
263 { "Swirl", { {"degrees", RealReference},
264 {"interpolate", MagickInterpolateOptions} } },
265 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
266 {"height", IntegerReference}, {"filter", MagickFilterOptions},
267 {"support", StringReference }, {"blur", RealReference } } },
268 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
269 {"height", IntegerReference}, {"filter", MagickFilterOptions},
270 {"support", RealReference }, {"blur", RealReference } } },
271 { "Annotate", { {"text", StringReference}, {"font", StringReference},
272 {"pointsize", RealReference}, {"density", StringReference},
273 {"undercolor", StringReference}, {"stroke", StringReference},
274 {"fill", StringReference}, {"geometry", StringReference},
275 {"pen", StringReference}, {"x", RealReference},
276 {"y", RealReference}, {"gravity", MagickGravityOptions},
277 {"translate", StringReference}, {"scale", StringReference},
278 {"rotate", RealReference}, {"skewX", RealReference},
279 {"skewY", RealReference}, {"strokewidth", RealReference},
280 {"antialias", MagickBooleanOptions}, {"family", StringReference},
281 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
282 {"weight", IntegerReference}, {"align", MagickAlignOptions},
283 {"encoding", StringReference}, {"affine", ArrayReference},
284 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
285 {"tile", ImageReference}, {"kerning", RealReference},
286 {"interline-spacing", RealReference},
287 {"interword-spacing", RealReference},
288 {"direction", MagickDirectionOptions} } },
289 { "ColorFloodfill", { {"geometry", StringReference},
290 {"x", IntegerReference}, {"y", IntegerReference},
291 {"fill", StringReference}, {"bordercolor", StringReference},
292 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
293 { "Composite", { {"image", ImageReference},
294 {"compose", MagickComposeOptions}, {"geometry", StringReference},
295 {"x", IntegerReference}, {"y", IntegerReference},
296 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
297 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
298 {"color", StringReference}, {"mask", ImageReference},
299 {"channel", MagickChannelOptions},
300 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
301 {"blend", StringReference} } },
302 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
303 { "CycleColormap", { {"display", IntegerReference} } },
304 { "Draw", { {"primitive", MagickPrimitiveOptions},
305 {"points", StringReference}, {"method", MagickMethodOptions},
306 {"stroke", StringReference}, {"fill", StringReference},
307 {"strokewidth", RealReference}, {"font", StringReference},
308 {"bordercolor", StringReference}, {"x", RealReference},
309 {"y", RealReference}, {"translate", StringReference},
310 {"scale", StringReference}, {"rotate", RealReference},
311 {"skewX", RealReference}, {"skewY", RealReference},
312 {"tile", ImageReference}, {"pointsize", RealReference},
313 {"antialias", MagickBooleanOptions}, {"density", StringReference},
314 {"linewidth", RealReference}, {"affine", ArrayReference},
315 {"stroke-dashoffset", RealReference},
316 {"stroke-dasharray", ArrayReference},
317 {"interpolate", MagickInterpolateOptions},
318 {"origin", StringReference}, {"text", StringReference},
319 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
320 {"vector-graphics", StringReference}, {"kerning", RealReference},
321 {"interline-spacing", RealReference},
322 {"interword-spacing", RealReference},
323 {"direction", MagickDirectionOptions} } },
324 { "Equalize", { {"channel", MagickChannelOptions} } },
325 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
326 {"red", RealReference}, {"green", RealReference},
327 {"blue", RealReference} } },
328 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
329 {"dither-method", MagickDitherOptions} } },
330 { "MatteFloodfill", { {"geometry", StringReference},
331 {"x", IntegerReference}, {"y", IntegerReference},
332 {"opacity", StringReference}, {"bordercolor", StringReference},
333 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
334 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
335 {"saturation", RealReference}, {"whiteness", RealReference},
336 {"brightness", RealReference}, {"lightness", RealReference},
337 {"blackness", RealReference} } },
338 { "Negate", { {"gray", MagickBooleanOptions},
339 {"channel", MagickChannelOptions} } },
340 { "Normalize", { {"channel", MagickChannelOptions} } },
342 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
343 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
344 {"invert", MagickBooleanOptions} } },
345 { "Quantize", { {"colors", IntegerReference},
346 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
347 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
348 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
349 {"dither-method", MagickDitherOptions} } },
350 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
351 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
352 { "Segment", { {"geometry", StringReference},
353 {"cluster-threshold", RealReference},
354 {"smoothing-threshold", RealReference},
355 {"colorspace", MagickColorspaceOptions},
356 {"verbose", MagickBooleanOptions} } },
358 { "Solarize", { {"geometry", StringReference},
359 {"threshold", StringReference} } },
361 { "Texture", { {"texture", ImageReference} } },
362 { "Evaluate", { {"value", RealReference},
363 {"operator", MagickEvaluateOptions},
364 {"channel", MagickChannelOptions} } },
365 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
366 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
367 { "Threshold", { {"threshold", StringReference},
368 {"channel", MagickChannelOptions} } },
369 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
370 {"sigma", RealReference} } },
371 { "Trim", { {"fuzz", StringReference} } },
372 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
373 {"wavelength", RealReference},
374 {"interpolate", MagickInterpolateOptions} } },
375 { "Separate", { {"channel", MagickChannelOptions} } },
377 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
378 {"y", IntegerReference} } },
379 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
381 { "GaussianBlur", { {"geometry", StringReference},
382 {"radius", RealReference}, {"sigma", RealReference},
383 {"channel", MagickChannelOptions} } },
384 { "Convolve", { {"coefficients", ArrayReference},
385 {"channel", MagickChannelOptions}, {"bias", StringReference},
386 {"kernel", StringReference} } },
387 { "Profile", { {"name", StringReference}, {"profile", StringReference},
388 { "rendering-intent", MagickIntentOptions},
389 { "black-point-compensation", MagickBooleanOptions} } },
390 { "UnsharpMask", { {"geometry", StringReference},
391 {"radius", RealReference}, {"sigma", RealReference},
392 {"amount", RealReference}, {"threshold", RealReference},
393 {"channel", MagickChannelOptions} } },
394 { "MotionBlur", { {"geometry", StringReference},
395 {"radius", RealReference}, {"sigma", RealReference},
396 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
397 { "OrderedDither", { {"threshold", StringReference},
398 {"channel", MagickChannelOptions} } },
399 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
400 {"height", IntegerReference} } },
401 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
402 {"white-point", RealReference}, {"gamma", RealReference},
403 {"channel", MagickChannelOptions}, {"level", StringReference} } },
404 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
405 { "AffineTransform", { {"affine", ArrayReference},
406 {"translate", StringReference}, {"scale", StringReference},
407 {"rotate", RealReference}, {"skewX", RealReference},
408 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
409 {"background", StringReference} } },
410 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
411 { "AdaptiveThreshold", { {"geometry", StringReference},
412 {"width", IntegerReference}, {"height", IntegerReference},
413 {"bias", RealReference} } },
414 { "Resample", { {"density", StringReference}, {"x", RealReference},
415 {"y", RealReference}, {"filter", MagickFilterOptions},
416 {"support", RealReference }, {"blur", RealReference } } },
417 { "Describe", { {"file", FileReference} } },
418 { "BlackThreshold", { {"threshold", StringReference},
419 {"channel", MagickChannelOptions} } },
420 { "WhiteThreshold", { {"threshold", StringReference},
421 {"channel", MagickChannelOptions} } },
422 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
423 {"channel", MagickChannelOptions} } },
424 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
425 {"height", IntegerReference} } },
427 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
428 { "Channel", { {"channel", MagickChannelOptions} } },
429 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
430 {"height", IntegerReference}, {"x", IntegerReference},
431 {"y", IntegerReference}, {"fuzz", StringReference},
432 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
433 { "Posterize", { {"levels", IntegerReference},
434 {"dither", MagickBooleanOptions} } },
435 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
436 {"sigma", RealReference}, {"x", IntegerReference},
437 {"y", IntegerReference} } },
438 { "Identify", { {"file", FileReference}, {"features", StringReference},
439 {"unique", MagickBooleanOptions} } },
440 { "SepiaTone", { {"threshold", RealReference} } },
441 { "SigmoidalContrast", { {"geometry", StringReference},
442 {"contrast", RealReference}, {"mid-point", RealReference},
443 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
444 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
445 {"height", IntegerReference}, {"x", IntegerReference},
446 {"y", IntegerReference}, {"fuzz", StringReference},
447 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
448 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
449 {"sigma", RealReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"background", StringReference} } },
451 { "ContrastStretch", { {"levels", StringReference},
452 {"black-point", RealReference},{"white-point", RealReference},
453 {"channel", MagickChannelOptions} } },
456 { "AdaptiveSharpen", { {"geometry", StringReference},
457 {"radius", RealReference}, {"sigma", RealReference},
458 {"channel", MagickChannelOptions} } },
462 { "AdaptiveBlur", { {"geometry", StringReference},
463 {"radius", RealReference}, {"sigma", RealReference},
464 {"channel", MagickChannelOptions} } },
465 { "Sketch", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"angle", RealReference} } },
469 { "AdaptiveResize", { {"geometry", StringReference},
470 {"width", IntegerReference}, {"height", IntegerReference},
471 {"filter", MagickFilterOptions}, {"support", StringReference },
472 {"blur", RealReference } } },
473 { "ClipMask", { {"mask", ImageReference} } },
474 { "LinearStretch", { {"levels", StringReference},
475 {"black-point", RealReference},{"white-point", RealReference} } },
476 { "Recolor", { {"matrix", ArrayReference} } },
477 { "Mask", { {"mask", ImageReference} } },
478 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
479 {"font", StringReference}, {"stroke", StringReference},
480 {"fill", StringReference}, {"strokewidth", RealReference},
481 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
482 {"background", StringReference} } },
483 { "FloodfillPaint", { {"geometry", StringReference},
484 {"x", IntegerReference}, {"y", IntegerReference},
485 {"fill", StringReference}, {"bordercolor", StringReference},
486 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
487 {"invert", MagickBooleanOptions} } },
488 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
489 {"virtual-pixel", MagickVirtualPixelOptions},
490 {"best-fit", MagickBooleanOptions} } },
491 { "Clut", { {"image", ImageReference},
492 {"channel", MagickChannelOptions} } },
493 { "LiquidRescale", { {"geometry", StringReference},
494 {"width", IntegerReference}, {"height", IntegerReference},
495 {"delta-x", RealReference}, {"rigidity", RealReference } } },
496 { "Encipher", { {"passphrase", StringReference} } },
497 { "Decipher", { {"passphrase", StringReference} } },
498 { "Deskew", { {"geometry", StringReference},
499 {"threshold", StringReference} } },
500 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
501 {"dither-method", MagickDitherOptions} } },
502 { "SparseColor", { {"points", ArrayReference},
503 {"method", MagickSparseColorOptions},
504 {"virtual-pixel", MagickVirtualPixelOptions},
505 {"channel", MagickChannelOptions} } },
506 { "Function", { {"parameters", ArrayReference},
507 {"function", MagickFunctionOptions},
508 {"virtual-pixel", MagickVirtualPixelOptions} } },
509 { "SelectiveBlur", { {"geometry", StringReference},
510 {"radius", RealReference}, {"sigma", RealReference},
511 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
512 { "HaldClut", { {"image", ImageReference},
513 {"channel", MagickChannelOptions} } },
514 { "BlueShift", { {"factor", StringReference} } },
515 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
516 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
517 { "ColorDecisionList", {
518 {"color-correction-collection", StringReference} } },
519 { "AutoGamma", { {"channel", MagickChannelOptions} } },
520 { "AutoLevel", { {"channel", MagickChannelOptions} } },
521 { "LevelColors", { {"invert", MagickBooleanOptions},
522 {"black-point", StringReference}, {"white-point", StringReference},
523 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
524 { "Clamp", { {"channel", MagickChannelOptions} } },
525 { "BrightnessContrast", { {"levels", StringReference},
526 {"brightness", RealReference},{"contrast", RealReference},
527 {"channel", MagickChannelOptions} } },
528 { "Morphology", { {"kernel", StringReference},
529 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
530 {"iterations", IntegerReference} } },
531 { "ColorMatrix", { {"matrix", ArrayReference} } },
532 { "Color", { {"color", StringReference} } },
533 { "Mode", { {"geometry", StringReference},
534 {"width", IntegerReference},{"height", IntegerReference},
535 {"channel", MagickChannelOptions} } },
536 { "Statistic", { {"geometry", StringReference},
537 {"width", IntegerReference},{"height", IntegerReference},
538 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
542 *magick_registry = (SplayTreeInfo *) NULL;
545 Forward declarations.
548 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
551 strEQcase(const char *,const char *);
554 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
558 % C l o n e P a c k a g e I n f o %
562 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
564 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
567 % The format of the ClonePackageInfo routine is:
569 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
572 % A description of each parameter follows:
574 % o info: a structure of type info.
576 % o exception: Return any errors or warnings in this structure.
579 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
580 ExceptionInfo *exception)
585 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
586 if (clone_info == (struct PackageInfo *) NULL)
588 ThrowPerlException(exception,ResourceLimitError,
589 "UnableToClonePackageInfo",PackageName);
590 return((struct PackageInfo *) NULL);
592 if (info == (struct PackageInfo *) NULL)
594 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
598 clone_info->image_info=CloneImageInfo(info->image_info);
603 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 % constant() returns a double value for the specified name.
615 % The format of the constant routine is:
617 % double constant(char *name,ssize_t sans)
619 % A description of each parameter follows:
621 % o value: Method constant returns a double value for the specified name.
623 % o name: The name of the constant.
625 % o sans: This integer value is not used.
628 static double constant(char *name,ssize_t sans)
636 if (strEQ(name,"BlobError"))
638 if (strEQ(name,"BlobWarning"))
644 if (strEQ(name,"CacheError"))
646 if (strEQ(name,"CacheWarning"))
647 return(CacheWarning);
648 if (strEQ(name,"CoderError"))
650 if (strEQ(name,"CoderWarning"))
651 return(CoderWarning);
652 if (strEQ(name,"ConfigureError"))
653 return(ConfigureError);
654 if (strEQ(name,"ConfigureWarning"))
655 return(ConfigureWarning);
656 if (strEQ(name,"CorruptImageError"))
657 return(CorruptImageError);
658 if (strEQ(name,"CorruptImageWarning"))
659 return(CorruptImageWarning);
664 if (strEQ(name,"DelegateError"))
665 return(DelegateError);
666 if (strEQ(name,"DelegateWarning"))
667 return(DelegateWarning);
668 if (strEQ(name,"DrawError"))
670 if (strEQ(name,"DrawWarning"))
676 if (strEQ(name,"ErrorException"))
677 return(ErrorException);
678 if (strEQ(name,"ExceptionError"))
680 if (strEQ(name,"ExceptionWarning"))
681 return(CoderWarning);
686 if (strEQ(name,"FatalErrorException"))
687 return(FatalErrorException);
688 if (strEQ(name,"FileOpenError"))
689 return(FileOpenError);
690 if (strEQ(name,"FileOpenWarning"))
691 return(FileOpenWarning);
696 if (strEQ(name,"ImageError"))
698 if (strEQ(name,"ImageWarning"))
699 return(ImageWarning);
704 if (strEQ(name,"MaxRGB"))
705 return(QuantumRange);
706 if (strEQ(name,"MissingDelegateError"))
707 return(MissingDelegateError);
708 if (strEQ(name,"MissingDelegateWarning"))
709 return(MissingDelegateWarning);
710 if (strEQ(name,"ModuleError"))
712 if (strEQ(name,"ModuleWarning"))
713 return(ModuleWarning);
718 if (strEQ(name,"Opaque"))
720 if (strEQ(name,"OptionError"))
722 if (strEQ(name,"OptionWarning"))
723 return(OptionWarning);
728 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
729 return(MAGICKCORE_QUANTUM_DEPTH);
730 if (strEQ(name,"QuantumDepth"))
731 return(MAGICKCORE_QUANTUM_DEPTH);
732 if (strEQ(name,"QuantumRange"))
733 return(QuantumRange);
738 if (strEQ(name,"ResourceLimitError"))
739 return(ResourceLimitError);
740 if (strEQ(name,"ResourceLimitWarning"))
741 return(ResourceLimitWarning);
742 if (strEQ(name,"RegistryError"))
743 return(RegistryError);
744 if (strEQ(name,"RegistryWarning"))
745 return(RegistryWarning);
750 if (strEQ(name,"StreamError"))
752 if (strEQ(name,"StreamWarning"))
753 return(StreamWarning);
754 if (strEQ(name,"Success"))
760 if (strEQ(name,"Transparent"))
761 return(TransparentAlpha);
762 if (strEQ(name,"TypeError"))
764 if (strEQ(name,"TypeWarning"))
770 if (strEQ(name,"WarningException"))
771 return(WarningException);
776 if (strEQ(name,"XServerError"))
777 return(XServerError);
778 if (strEQ(name,"XServerWarning"))
779 return(XServerWarning);
788 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
792 % D e s t r o y P a c k a g e I n f o %
796 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
798 % Method DestroyPackageInfo frees a previously created info structure.
800 % The format of the DestroyPackageInfo routine is:
802 % DestroyPackageInfo(struct PackageInfo *info)
804 % A description of each parameter follows:
806 % o info: a structure of type info.
809 static void DestroyPackageInfo(struct PackageInfo *info)
811 info->image_info=DestroyImageInfo(info->image_info);
812 info=(struct PackageInfo *) RelinquishMagickMemory(info);
816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
824 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
826 % Method GetList is recursively called by SetupList to traverse the
827 % Image__Magick reference. If building an reference_vector (see SetupList),
828 % *current is the current position in *reference_vector and *last is the final
829 % entry in *reference_vector.
831 % The format of the GetList routine is:
835 % A description of each parameter follows:
837 % o info: a structure of type info.
840 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
841 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
846 if (reference == (SV *) NULL)
848 switch (SvTYPE(reference))
868 previous=(Image *) NULL;
872 for (i=0; i <= n; i++)
878 if (rv && *rv && sv_isobject(*rv))
880 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
882 if (image == (Image *) NULL)
884 if (image == previous)
886 image=CloneImage(image,0,0,MagickTrue,exception);
887 if (image == (Image *) NULL)
890 image->previous=previous;
891 *(previous ? &previous->next : &head)=image;
892 for (previous=image; previous->next; previous=previous->next) ;
900 Blessed scalar, one image.
902 image=(Image *) SvIV(reference);
903 if (image == (Image *) NULL)
905 image->previous=(Image *) NULL;
906 image->next=(Image *) NULL;
907 if (reference_vector)
909 if (*current == *last)
912 if (*reference_vector == (SV **) NULL)
913 *reference_vector=(SV **) AcquireQuantumMemory(*last,
914 sizeof(*reference_vector));
916 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
917 *last,sizeof(*reference_vector));
919 if (*reference_vector == (SV **) NULL)
921 ThrowPerlException(exception,ResourceLimitError,
922 "MemoryAllocationFailed",PackageName);
923 return((Image *) NULL);
925 (*reference_vector)[*current]=reference;
926 (*reference_vector)[++(*current)]=NULL;
933 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
934 (double) SvTYPE(reference));
935 return((Image *) NULL);
939 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
943 % G e t P a c k a g e I n f o %
947 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
949 % Method GetPackageInfo looks up or creates an info structure for the given
950 % Image__Magick reference. If it does create a new one, the information in
951 % package_info is used to initialize it.
953 % The format of the GetPackageInfo routine is:
955 % struct PackageInfo *GetPackageInfo(void *reference,
956 % struct PackageInfo *package_info,ExceptionInfo *exception)
958 % A description of each parameter follows:
960 % o info: a structure of type info.
962 % o exception: Return any errors or warnings in this structure.
965 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
966 struct PackageInfo *package_info,ExceptionInfo *exception)
969 message[MaxTextExtent];
977 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
978 PackageName,XS_VERSION,reference);
979 sv=perl_get_sv(message,(TRUE | 0x02));
980 if (sv == (SV *) NULL)
982 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
984 return(package_info);
986 if (SvREFCNT(sv) == 0)
987 (void) SvREFCNT_inc(sv);
988 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
990 clone_info=ClonePackageInfo(package_info,exception);
991 sv_setiv(sv,(IV) clone_info);
996 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1000 % S e t A t t r i b u t e %
1004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1006 % SetAttribute() sets the attribute to the value in sval. This can change
1007 % either or both of image or info.
1009 % The format of the SetAttribute routine is:
1011 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1012 % SV *sval,ExceptionInfo *exception)
1014 % A description of each parameter follows:
1016 % o list: a list of strings.
1018 % o string: a character string.
1022 static double SiPrefixToDouble(const char *string,const double interval)
1031 value=InterpretLocaleValue(string,&q);
1033 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1035 switch (tolower((int) ((unsigned char) *q)))
1037 case '%': value*=pow(scale,0)*interval/100.0; break;
1038 case 'k': value*=pow(scale,1); break;
1039 case 'm': value*=pow(scale,2); break;
1040 case 'g': value*=pow(scale,3); break;
1041 case 't': value*=pow(scale,4); break;
1042 case 'p': value*=pow(scale,5); break;
1043 case 'e': value*=pow(scale,6); break;
1044 case 'z': value*=pow(scale,7); break;
1045 case 'y': value*=pow(scale,8); break;
1051 static inline ssize_t StringToLong(const char *value)
1053 return(strtol(value,(char **) NULL,10));
1056 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1057 const char *attribute,SV *sval,ExceptionInfo *exception)
1084 if (LocaleCompare(attribute,"adjoin") == 0)
1086 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1087 SvPV(sval,na)) : SvIV(sval);
1090 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1095 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1098 if (LocaleCompare(attribute,"alpha") == 0)
1100 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1101 SvPV(sval,na)) : SvIV(sval);
1104 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1108 for ( ; image; image=image->next)
1109 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
1112 if (LocaleCompare(attribute,"antialias") == 0)
1114 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1115 SvPV(sval,na)) : SvIV(sval);
1118 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1123 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1126 if (LocaleCompare(attribute,"area-limit") == 0)
1131 limit=MagickResourceInfinity;
1132 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1133 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1134 (void) SetMagickResourceLimit(AreaResource,limit);
1137 if (LocaleCompare(attribute,"attenuate") == 0)
1140 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1143 if (LocaleCompare(attribute,"authenticate") == 0)
1146 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1150 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1151 for ( ; image; image=image->next)
1152 SetImageProperty(image,attribute,SvPV(sval,na));
1158 if (LocaleCompare(attribute,"background") == 0)
1160 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1162 info->image_info->background_color=target_color;
1163 for ( ; image; image=image->next)
1164 image->background_color=target_color;
1167 if (LocaleCompare(attribute,"bias") == 0)
1169 for ( ; image; image=image->next)
1170 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1173 if (LocaleCompare(attribute,"blue-primary") == 0)
1175 for ( ; image; image=image->next)
1177 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1178 image->chromaticity.blue_primary.x=geometry_info.rho;
1179 image->chromaticity.blue_primary.y=geometry_info.sigma;
1180 if ((flags & SigmaValue) == 0)
1181 image->chromaticity.blue_primary.y=
1182 image->chromaticity.blue_primary.x;
1186 if (LocaleCompare(attribute,"bordercolor") == 0)
1188 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1190 info->image_info->border_color=target_color;
1191 for ( ; image; image=image->next)
1192 image->border_color=target_color;
1196 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1197 for ( ; image; image=image->next)
1198 SetImageProperty(image,attribute,SvPV(sval,na));
1204 if (LocaleCompare(attribute,"cache-threshold") == 0)
1206 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1207 SiPrefixToDouble(SvPV(sval,na),100.0));
1208 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1209 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1212 if (LocaleCompare(attribute,"clip-mask") == 0)
1217 clip_mask=(Image *) NULL;
1219 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1220 for ( ; image; image=image->next)
1221 SetImageClipMask(image,clip_mask,exception);
1224 if (LocaleNCompare(attribute,"colormap",8) == 0)
1226 for ( ; image; image=image->next)
1234 if (image->storage_class == DirectClass)
1237 items=sscanf(attribute,"%*[^[][%ld",&i);
1239 if (i > (ssize_t) image->colors)
1241 if ((strchr(SvPV(sval,na),',') == 0) ||
1242 (strchr(SvPV(sval,na),')') != 0))
1243 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1246 color=image->colormap+i;
1247 pixel.red=color->red;
1248 pixel.green=color->green;
1249 pixel.blue=color->blue;
1250 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1251 pixel.red=geometry_info.rho;
1252 pixel.green=geometry_info.sigma;
1253 pixel.blue=geometry_info.xi;
1254 color->red=ClampToQuantum(pixel.red);
1255 color->green=ClampToQuantum(pixel.green);
1256 color->blue=ClampToQuantum(pixel.blue);
1261 if (LocaleCompare(attribute,"colorspace") == 0)
1263 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1264 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1267 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1271 for ( ; image; image=image->next)
1272 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1275 if (LocaleCompare(attribute,"comment") == 0)
1277 for ( ; image; image=image->next)
1278 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1279 info ? info->image_info : (ImageInfo *) NULL,image,
1280 SvPV(sval,na),exception));
1283 if (LocaleCompare(attribute,"compression") == 0)
1285 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1286 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1289 ThrowPerlException(exception,OptionError,
1290 "UnrecognizedImageCompression",SvPV(sval,na));
1294 info->image_info->compression=(CompressionType) sp;
1295 for ( ; image; image=image->next)
1296 image->compression=(CompressionType) sp;
1300 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1301 for ( ; image; image=image->next)
1302 SetImageProperty(image,attribute,SvPV(sval,na));
1308 if (LocaleCompare(attribute,"debug") == 0)
1310 SetLogEventMask(SvPV(sval,na));
1313 if (LocaleCompare(attribute,"delay") == 0)
1315 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1316 for ( ; image; image=image->next)
1318 image->delay=(size_t) floor(geometry_info.rho+0.5);
1319 if ((flags & SigmaValue) != 0)
1320 image->ticks_per_second=(ssize_t)
1321 floor(geometry_info.sigma+0.5);
1325 if (LocaleCompare(attribute,"disk-limit") == 0)
1330 limit=MagickResourceInfinity;
1331 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1332 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1333 (void) SetMagickResourceLimit(DiskResource,limit);
1336 if (LocaleCompare(attribute,"density") == 0)
1338 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1340 ThrowPerlException(exception,OptionError,"MissingGeometry",
1345 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1346 for ( ; image; image=image->next)
1348 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1349 image->x_resolution=geometry_info.rho;
1350 image->y_resolution=geometry_info.sigma;
1351 if ((flags & SigmaValue) == 0)
1352 image->y_resolution=image->x_resolution;
1356 if (LocaleCompare(attribute,"depth") == 0)
1359 info->image_info->depth=SvIV(sval);
1360 for ( ; image; image=image->next)
1361 (void) SetImageDepth(image,SvIV(sval));
1364 if (LocaleCompare(attribute,"dispose") == 0)
1366 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1367 SvPV(sval,na)) : SvIV(sval);
1370 ThrowPerlException(exception,OptionError,
1371 "UnrecognizedDisposeMethod",SvPV(sval,na));
1374 for ( ; image; image=image->next)
1375 image->dispose=(DisposeType) sp;
1378 if (LocaleCompare(attribute,"dither") == 0)
1382 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1383 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1386 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1390 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1394 if (LocaleCompare(attribute,"display") == 0)
1398 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1402 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1403 for ( ; image; image=image->next)
1404 SetImageProperty(image,attribute,SvPV(sval,na));
1410 if (LocaleCompare(attribute,"endian") == 0)
1412 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1413 SvPV(sval,na)) : SvIV(sval);
1416 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1421 info->image_info->endian=(EndianType) sp;
1422 for ( ; image; image=image->next)
1423 image->endian=(EndianType) sp;
1426 if (LocaleCompare(attribute,"extract") == 0)
1429 Set image extract geometry.
1431 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1435 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1436 for ( ; image; image=image->next)
1437 SetImageProperty(image,attribute,SvPV(sval,na));
1443 if (LocaleCompare(attribute,"filename") == 0)
1446 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1448 for ( ; image; image=image->next)
1449 (void) CopyMagickString(image->filename,SvPV(sval,na),
1453 if (LocaleCompare(attribute,"file") == 0)
1461 if (info == (struct PackageInfo *) NULL)
1463 io_info=IoIFP(sv_2io(sval));
1464 if (io_info == (PerlIO *) NULL)
1466 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1470 file=PerlIO_findFILE(io_info);
1471 if (file == (FILE *) NULL)
1473 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1477 SetImageInfoFile(info->image_info,file);
1480 if (LocaleCompare(attribute,"fill") == 0)
1483 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1486 if (LocaleCompare(attribute,"font") == 0)
1489 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1492 if (LocaleCompare(attribute,"foreground") == 0)
1494 if (LocaleCompare(attribute,"fuzz") == 0)
1497 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1498 for ( ; image; image=image->next)
1499 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1503 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1504 for ( ; image; image=image->next)
1505 SetImageProperty(image,attribute,SvPV(sval,na));
1511 if (LocaleCompare(attribute,"gamma") == 0)
1513 for ( ; image; image=image->next)
1514 image->gamma=SvNV(sval);
1517 if (LocaleCompare(attribute,"gravity") == 0)
1519 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1520 SvPV(sval,na)) : SvIV(sval);
1523 ThrowPerlException(exception,OptionError,
1524 "UnrecognizedGravityType",SvPV(sval,na));
1528 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1529 for ( ; image; image=image->next)
1530 image->gravity=(GravityType) sp;
1533 if (LocaleCompare(attribute,"green-primary") == 0)
1535 for ( ; image; image=image->next)
1537 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1538 image->chromaticity.green_primary.x=geometry_info.rho;
1539 image->chromaticity.green_primary.y=geometry_info.sigma;
1540 if ((flags & SigmaValue) == 0)
1541 image->chromaticity.green_primary.y=
1542 image->chromaticity.green_primary.x;
1547 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1548 for ( ; image; image=image->next)
1549 SetImageProperty(image,attribute,SvPV(sval,na));
1555 if (LocaleNCompare(attribute,"index",5) == 0)
1569 for ( ; image; image=image->next)
1571 if (image->storage_class != PseudoClass)
1575 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1577 image_view=AcquireCacheView(image);
1578 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1579 if (q != (Quantum *) NULL)
1581 items=sscanf(SvPV(sval,na),"%ld",&index);
1582 if ((index >= 0) && (index < (ssize_t) image->colors))
1583 SetPixelIndex(image,index,q);
1584 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1586 image_view=DestroyCacheView(image_view);
1590 if (LocaleCompare(attribute,"iterations") == 0)
1593 for ( ; image; image=image->next)
1594 image->iterations=SvIV(sval);
1597 if (LocaleCompare(attribute,"interlace") == 0)
1599 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1600 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1603 ThrowPerlException(exception,OptionError,
1604 "UnrecognizedInterlaceType",SvPV(sval,na));
1608 info->image_info->interlace=(InterlaceType) sp;
1609 for ( ; image; image=image->next)
1610 image->interlace=(InterlaceType) sp;
1614 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1615 for ( ; image; image=image->next)
1616 SetImageProperty(image,attribute,SvPV(sval,na));
1622 if (LocaleCompare(attribute,"label") == 0)
1624 for ( ; image; image=image->next)
1625 (void) SetImageProperty(image,"label",InterpretImageProperties(
1626 info ? info->image_info : (ImageInfo *) NULL,image,
1627 SvPV(sval,na),exception));
1630 if (LocaleCompare(attribute,"loop") == 0)
1633 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1634 for ( ; image; image=image->next)
1635 SetImageProperty(image,attribute,SvPV(sval,na));
1641 if (LocaleCompare(attribute,"magick") == 0)
1644 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1645 "%s:",SvPV(sval,na));
1646 for ( ; image; image=image->next)
1647 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1650 if (LocaleCompare(attribute,"map-limit") == 0)
1655 limit=MagickResourceInfinity;
1656 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1657 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1658 (void) SetMagickResourceLimit(MapResource,limit);
1661 if (LocaleCompare(attribute,"mask") == 0)
1666 mask=(Image *) NULL;
1668 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1669 for ( ; image; image=image->next)
1670 SetImageMask(image,mask,exception);
1673 if (LocaleCompare(attribute,"mattecolor") == 0)
1675 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1677 info->image_info->matte_color=target_color;
1678 for ( ; image; image=image->next)
1679 image->matte_color=target_color;
1682 if (LocaleCompare(attribute,"matte") == 0)
1684 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1685 SvPV(sval,na)) : SvIV(sval);
1688 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1692 for ( ; image; image=image->next)
1693 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1696 if (LocaleCompare(attribute,"memory-limit") == 0)
1701 limit=MagickResourceInfinity;
1702 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1703 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1704 (void) SetMagickResourceLimit(MemoryResource,limit);
1707 if (LocaleCompare(attribute,"monochrome") == 0)
1709 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1710 SvPV(sval,na)) : SvIV(sval);
1713 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1718 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1719 for ( ; image; image=image->next)
1720 (void) SetImageType(image,BilevelType,exception);
1724 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1725 for ( ; image; image=image->next)
1726 SetImageProperty(image,attribute,SvPV(sval,na));
1732 if (LocaleCompare(attribute,"option") == 0)
1735 DefineImageOption(info->image_info,SvPV(sval,na));
1738 if (LocaleCompare(attribute,"orientation") == 0)
1740 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1741 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1744 ThrowPerlException(exception,OptionError,
1745 "UnrecognizedOrientationType",SvPV(sval,na));
1749 info->image_info->orientation=(OrientationType) sp;
1750 for ( ; image; image=image->next)
1751 image->orientation=(OrientationType) sp;
1755 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1756 for ( ; image; image=image->next)
1757 SetImageProperty(image,attribute,SvPV(sval,na));
1763 if (LocaleCompare(attribute,"page") == 0)
1768 geometry=GetPageGeometry(SvPV(sval,na));
1770 (void) CloneString(&info->image_info->page,geometry);
1771 for ( ; image; image=image->next)
1772 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1773 geometry=(char *) RelinquishMagickMemory(geometry);
1776 if (LocaleCompare(attribute,"pen") == 0)
1779 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1782 if (LocaleNCompare(attribute,"pixel",5) == 0)
1796 for ( ; image; image=image->next)
1798 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1802 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1804 image_view=AcquireCacheView(image);
1805 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1806 if (q != (Quantum *) NULL)
1808 if ((strchr(SvPV(sval,na),',') == 0) ||
1809 (strchr(SvPV(sval,na),')') != 0))
1810 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1813 GetPixelInfo(image,&pixel);
1814 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1815 pixel.red=geometry_info.rho;
1816 if ((flags & SigmaValue) != 0)
1817 pixel.green=geometry_info.sigma;
1818 if ((flags & XiValue) != 0)
1819 pixel.blue=geometry_info.xi;
1820 if ((flags & PsiValue) != 0)
1821 pixel.alpha=geometry_info.psi;
1822 if ((flags & ChiValue) != 0)
1823 pixel.black=geometry_info.chi;
1825 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1826 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1827 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1828 if (image->colorspace == CMYKColorspace)
1829 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1830 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1831 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1833 image_view=DestroyCacheView(image_view);
1837 if (LocaleCompare(attribute,"pointsize") == 0)
1841 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1842 info->image_info->pointsize=geometry_info.rho;
1846 if (LocaleCompare(attribute,"preview") == 0)
1848 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1849 SvPV(sval,na)) : SvIV(sval);
1852 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1857 info->image_info->preview_type=(PreviewType) sp;
1861 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1862 for ( ; image; image=image->next)
1863 SetImageProperty(image,attribute,SvPV(sval,na));
1869 if (LocaleCompare(attribute,"quality") == 0)
1872 info->image_info->quality=SvIV(sval);
1873 for ( ; image; image=image->next)
1874 image->quality=SvIV(sval);
1878 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1879 for ( ; image; image=image->next)
1880 SetImageProperty(image,attribute,SvPV(sval,na));
1886 if (LocaleCompare(attribute,"red-primary") == 0)
1888 for ( ; image; image=image->next)
1890 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1891 image->chromaticity.red_primary.x=geometry_info.rho;
1892 image->chromaticity.red_primary.y=geometry_info.sigma;
1893 if ((flags & SigmaValue) == 0)
1894 image->chromaticity.red_primary.y=
1895 image->chromaticity.red_primary.x;
1899 if (LocaleCompare(attribute,"render") == 0)
1901 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1902 SvPV(sval,na)) : SvIV(sval);
1905 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1909 for ( ; image; image=image->next)
1910 image->rendering_intent=(RenderingIntent) sp;
1913 if (LocaleCompare(attribute,"repage") == 0)
1918 for ( ; image; image=image->next)
1920 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1921 if ((flags & WidthValue) != 0)
1923 if ((flags & HeightValue) == 0)
1924 geometry.height=geometry.width;
1925 image->page.width=geometry.width;
1926 image->page.height=geometry.height;
1928 if ((flags & AspectValue) != 0)
1930 if ((flags & XValue) != 0)
1931 image->page.x+=geometry.x;
1932 if ((flags & YValue) != 0)
1933 image->page.y+=geometry.y;
1937 if ((flags & XValue) != 0)
1939 image->page.x=geometry.x;
1940 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1941 image->page.width=image->columns+geometry.x;
1943 if ((flags & YValue) != 0)
1945 image->page.y=geometry.y;
1946 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1947 image->page.height=image->rows+geometry.y;
1954 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1955 for ( ; image; image=image->next)
1956 SetImageProperty(image,attribute,SvPV(sval,na));
1962 if (LocaleCompare(attribute,"sampling-factor") == 0)
1964 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1966 ThrowPerlException(exception,OptionError,"MissingGeometry",
1971 (void) CloneString(&info->image_info->sampling_factor,
1975 if (LocaleCompare(attribute,"scene") == 0)
1977 for ( ; image; image=image->next)
1978 image->scene=SvIV(sval);
1981 if (LocaleCompare(attribute,"server") == 0)
1983 if (LocaleCompare(attribute,"size") == 0)
1987 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1989 ThrowPerlException(exception,OptionError,"MissingGeometry",
1993 (void) CloneString(&info->image_info->size,SvPV(sval,na));
1997 if (LocaleCompare(attribute,"stroke") == 0)
2000 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2004 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2005 for ( ; image; image=image->next)
2006 SetImageProperty(image,attribute,SvPV(sval,na));
2012 if (LocaleCompare(attribute,"texture") == 0)
2015 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2018 if (LocaleCompare(attribute,"thread-limit") == 0)
2023 limit=MagickResourceInfinity;
2024 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2025 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2026 (void) SetMagickResourceLimit(ThreadResource,limit);
2029 if (LocaleCompare(attribute,"tile-offset") == 0)
2034 geometry=GetPageGeometry(SvPV(sval,na));
2036 (void) CloneString(&info->image_info->page,geometry);
2037 for ( ; image; image=image->next)
2038 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2040 geometry=(char *) RelinquishMagickMemory(geometry);
2043 if (LocaleCompare(attribute,"time-limit") == 0)
2048 limit=MagickResourceInfinity;
2049 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2050 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2051 (void) SetMagickResourceLimit(TimeResource,limit);
2054 if (LocaleCompare(attribute,"transparent-color") == 0)
2056 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2058 info->image_info->transparent_color=target_color;
2059 for ( ; image; image=image->next)
2060 image->transparent_color=target_color;
2063 if (LocaleCompare(attribute,"type") == 0)
2065 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2066 SvPV(sval,na)) : SvIV(sval);
2069 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2074 info->image_info->type=(ImageType) sp;
2075 for ( ; image; image=image->next)
2076 SetImageType(image,(ImageType) sp,exception);
2080 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2081 for ( ; image; image=image->next)
2082 SetImageProperty(image,attribute,SvPV(sval,na));
2088 if (LocaleCompare(attribute,"units") == 0)
2090 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2091 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2094 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2099 info->image_info->units=(ResolutionType) sp;
2100 for ( ; image; image=image->next)
2105 units=(ResolutionType) sp;
2106 if (image->units != units)
2107 switch (image->units)
2109 case UndefinedResolution:
2110 case PixelsPerInchResolution:
2112 if (units == PixelsPerCentimeterResolution)
2114 image->x_resolution*=2.54;
2115 image->y_resolution*=2.54;
2119 case PixelsPerCentimeterResolution:
2121 if (units == PixelsPerInchResolution)
2123 image->x_resolution/=2.54;
2124 image->y_resolution/=2.54;
2134 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2135 for ( ; image; image=image->next)
2136 SetImageProperty(image,attribute,SvPV(sval,na));
2142 if (LocaleCompare(attribute,"verbose") == 0)
2144 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2145 SvPV(sval,na)) : SvIV(sval);
2148 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2153 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2156 if (LocaleCompare(attribute,"view") == 0)
2159 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2162 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2164 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2165 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2168 ThrowPerlException(exception,OptionError,
2169 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2173 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2174 for ( ; image; image=image->next)
2175 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2179 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2180 for ( ; image; image=image->next)
2181 SetImageProperty(image,attribute,SvPV(sval,na));
2187 if (LocaleCompare(attribute,"white-point") == 0)
2189 for ( ; image; image=image->next)
2191 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2192 image->chromaticity.white_point.x=geometry_info.rho;
2193 image->chromaticity.white_point.y=geometry_info.sigma;
2194 if ((flags & SigmaValue) == 0)
2195 image->chromaticity.white_point.y=
2196 image->chromaticity.white_point.x;
2201 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2202 for ( ; image; image=image->next)
2203 SetImageProperty(image,attribute,SvPV(sval,na));
2209 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2210 for ( ; image; image=image->next)
2211 SetImageProperty(image,attribute,SvPV(sval,na));
2218 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2222 % S e t u p L i s t %
2226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2228 % Method SetupList returns the list of all the images linked by their
2229 % image->next and image->previous link lists for use with ImageMagick. If
2230 % info is non-NULL, an info structure is returned in *info. If
2231 % reference_vector is non-NULL,an array of SV* are returned in
2232 % *reference_vector. Reference_vector is used when the images are going to be
2233 % replaced with new Image*'s.
2235 % The format of the SetupList routine is:
2237 % Image *SetupList(SV *reference,struct PackageInfo **info,
2238 % SV ***reference_vector,ExceptionInfo *exception)
2240 % A description of each parameter follows:
2242 % o list: a list of strings.
2244 % o string: a character string.
2246 % o exception: Return any errors or warnings in this structure.
2249 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2250 SV ***reference_vector,ExceptionInfo *exception)
2259 if (reference_vector)
2260 *reference_vector=NULL;
2265 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2266 if (info && (SvTYPE(reference) == SVt_PVAV))
2267 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2277 % s t r E Q c a s e %
2281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2283 % strEQcase() compares two strings and returns 0 if they are the
2284 % same or if the second string runs out first. The comparison is case
2287 % The format of the strEQcase routine is:
2289 % ssize_t strEQcase(const char *p,const char *q)
2291 % A description of each parameter follows:
2293 % o p: a character string.
2295 % o q: a character string.
2299 static ssize_t strEQcase(const char *p,const char *q)
2307 for (i=0 ; (c=(*q)) != 0; i++)
2309 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2310 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2315 return(((*q == 0) && (*p == 0)) ? i : 0);
2319 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2323 % I m a g e : : M a g i c k %
2327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2331 MODULE = Image::Magick PACKAGE = Image::Magick
2336 MagickCoreGenesis("PerlMagick",MagickFalse);
2337 SetWarningHandler(NULL);
2338 SetErrorHandler(NULL);
2339 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2340 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2346 if (magick_registry != (SplayTreeInfo *) NULL)
2347 magick_registry=DestroySplayTree(magick_registry);
2348 MagickCoreTerminus();
2352 constant(name,argument)
2357 ###############################################################################
2365 ###############################################################################
2370 Image::Magick ref=NO_INIT
2394 PERL_UNUSED_VAR(ref);
2395 PERL_UNUSED_VAR(ix);
2396 exception=AcquireExceptionInfo();
2397 perl_exception=newSVpv("",0);
2398 package_info=(struct PackageInfo *) NULL;
2399 if (sv_isobject(ST(0)) == 0)
2401 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2405 reference=SvRV(ST(0));
2406 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2407 if (image == (Image *) NULL)
2409 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2413 package_info=ClonePackageInfo(info,exception);
2415 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2418 for (i=2; i < items; i+=2)
2419 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2421 (void) AnimateImages(package_info->image_info,image,exception);
2422 (void) CatchImageException(image);
2425 if (package_info != (struct PackageInfo *) NULL)
2426 DestroyPackageInfo(package_info);
2427 InheritPerlException(exception,perl_exception);
2428 exception=DestroyExceptionInfo(exception);
2429 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2430 SvPOK_on(perl_exception);
2431 ST(0)=sv_2mortal(perl_exception);
2436 ###############################################################################
2444 ###############################################################################
2449 Image::Magick ref=NO_INIT
2487 PERL_UNUSED_VAR(ref);
2488 PERL_UNUSED_VAR(ix);
2489 exception=AcquireExceptionInfo();
2490 perl_exception=newSVpv("",0);
2494 if (sv_isobject(ST(0)) == 0)
2496 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2500 reference=SvRV(ST(0));
2501 hv=SvSTASH(reference);
2503 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2505 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2506 if (image == (Image *) NULL)
2508 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2512 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2517 for (i=2; i < items; i+=2)
2519 attribute=(char *) SvPV(ST(i-1),na);
2525 if (LocaleCompare(attribute,"stack") == 0)
2527 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2531 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2537 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2549 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2550 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2552 for ( ; image; image=image->next)
2554 AddImageToRegistry(sv,image);
2556 av_push(av,sv_bless(rv,hv));
2559 exception=DestroyExceptionInfo(exception);
2561 SvREFCNT_dec(perl_exception);
2565 InheritPerlException(exception,perl_exception);
2566 exception=DestroyExceptionInfo(exception);
2567 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2568 SvPOK_on(perl_exception);
2569 ST(0)=sv_2mortal(perl_exception);
2574 ###############################################################################
2582 ###############################################################################
2587 Image::Magick ref=NO_INIT
2618 PERL_UNUSED_VAR(ref);
2619 PERL_UNUSED_VAR(ix);
2620 exception=AcquireExceptionInfo();
2621 perl_exception=newSVpv("",0);
2623 if (sv_isobject(ST(0)) == 0)
2625 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2629 reference=SvRV(ST(0));
2630 hv=SvSTASH(reference);
2631 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2632 if (image == (Image *) NULL)
2634 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2638 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2639 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2642 Create blessed Perl array for the returned image.
2645 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2647 AddImageToRegistry(sv,image);
2649 av_push(av,sv_bless(rv,hv));
2651 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2652 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2653 "average-%.*s",(int) (MaxTextExtent-9),
2654 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2655 (void) CopyMagickString(image->filename,info->image_info->filename,
2657 SetImageInfo(info->image_info,0,exception);
2658 exception=DestroyExceptionInfo(exception);
2659 SvREFCNT_dec(perl_exception);
2663 InheritPerlException(exception,perl_exception);
2664 exception=DestroyExceptionInfo(exception);
2665 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2666 SvPOK_on(perl_exception);
2667 ST(0)=sv_2mortal(perl_exception);
2672 ###############################################################################
2676 # B l o b T o I m a g e #
2680 ###############################################################################
2684 BlobToImage(ref,...)
2685 Image::Magick ref=NO_INIT
2731 PERL_UNUSED_VAR(ref);
2732 PERL_UNUSED_VAR(ix);
2733 exception=AcquireExceptionInfo();
2734 perl_exception=newSVpv("",0);
2737 ac=(items < 2) ? 1 : items-1;
2738 length=(STRLEN *) NULL;
2739 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2740 if (list == (char **) NULL)
2742 ThrowPerlException(exception,ResourceLimitError,
2743 "MemoryAllocationFailed",PackageName);
2746 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2747 if (length == (STRLEN *) NULL)
2749 ThrowPerlException(exception,ResourceLimitError,
2750 "MemoryAllocationFailed",PackageName);
2753 if (sv_isobject(ST(0)) == 0)
2755 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2759 reference=SvRV(ST(0));
2760 hv=SvSTASH(reference);
2761 if (SvTYPE(reference) != SVt_PVAV)
2763 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2767 av=(AV *) reference;
2768 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2773 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2776 for (n=0, i=0; i < ac; i++)
2778 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2779 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2781 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2786 list[n]=(char *) NULL;
2788 for (i=number_images=0; i < n; i++)
2790 image=BlobToImage(info->image_info,list[i],length[i],exception);
2791 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2793 for ( ; image; image=image->next)
2795 AddImageToRegistry(sv,image);
2797 av_push(av,sv_bless(rv,hv));
2805 for (i=0; i < n; i++)
2806 if (list[i] != (char *) NULL)
2807 for (p=keep; list[i] != *p++; )
2808 if (*p == (char *) NULL)
2810 list[i]=(char *) RelinquishMagickMemory(list[i]);
2816 list=(char **) RelinquishMagickMemory(list);
2818 length=(STRLEN *) RelinquishMagickMemory(length);
2819 InheritPerlException(exception,perl_exception);
2820 exception=DestroyExceptionInfo(exception);
2821 sv_setiv(perl_exception,(IV) number_images);
2822 SvPOK_on(perl_exception);
2823 ST(0)=sv_2mortal(perl_exception);
2828 ###############################################################################
2836 ###############################################################################
2841 Image::Magick ref=NO_INIT
2874 PERL_UNUSED_VAR(ref);
2875 PERL_UNUSED_VAR(ix);
2876 exception=AcquireExceptionInfo();
2877 perl_exception=newSVpv("",0);
2879 if (sv_isobject(ST(0)) == 0)
2881 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2885 reference=SvRV(ST(0));
2886 hv=SvSTASH(reference);
2887 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2888 if (image == (Image *) NULL)
2890 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2895 Create blessed Perl array for the returned image.
2898 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2900 for ( ; image; image=image->next)
2902 clone=CloneImage(image,0,0,MagickTrue,exception);
2903 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2905 AddImageToRegistry(sv,clone);
2907 av_push(av,sv_bless(rv,hv));
2910 exception=DestroyExceptionInfo(exception);
2911 SvREFCNT_dec(perl_exception);
2915 InheritPerlException(exception,perl_exception);
2916 exception=DestroyExceptionInfo(exception);
2917 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2918 SvPOK_on(perl_exception);
2919 ST(0)=sv_2mortal(perl_exception);
2924 ###############################################################################
2932 ###############################################################################
2940 PERL_UNUSED_VAR(ref);
2941 if (magick_registry != (SplayTreeInfo *) NULL)
2946 ResetSplayTreeIterator(magick_registry);
2947 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2948 while (p != (Image *) NULL)
2951 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2957 ###############################################################################
2965 ###############################################################################
2970 Image::Magick ref=NO_INIT
2999 PERL_UNUSED_VAR(ref);
3000 PERL_UNUSED_VAR(ix);
3001 exception=AcquireExceptionInfo();
3002 perl_exception=newSVpv("",0);
3004 if (sv_isobject(ST(0)) == 0)
3006 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3010 reference=SvRV(ST(0));
3011 hv=SvSTASH(reference);
3013 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3015 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3016 if (image == (Image *) NULL)
3018 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3022 image=CoalesceImages(image,exception);
3023 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3025 for ( ; image; image=image->next)
3027 AddImageToRegistry(sv,image);
3029 av_push(av,sv_bless(rv,hv));
3032 exception=DestroyExceptionInfo(exception);
3034 SvREFCNT_dec(perl_exception);
3038 InheritPerlException(exception,perl_exception);
3039 exception=DestroyExceptionInfo(exception);
3040 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3041 SvPOK_on(perl_exception);
3042 ST(0)=sv_2mortal(perl_exception);
3047 ###############################################################################
3055 ###############################################################################
3060 Image::Magick ref=NO_INIT
3106 PERL_UNUSED_VAR(ref);
3107 PERL_UNUSED_VAR(ix);
3108 exception=AcquireExceptionInfo();
3109 perl_exception=newSVpv("",0);
3113 if (sv_isobject(ST(0)) == 0)
3115 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3119 reference=SvRV(ST(0));
3120 hv=SvSTASH(reference);
3122 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3124 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3125 if (image == (Image *) NULL)
3127 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3131 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3135 reconstruct_image=image;
3136 metric=RootMeanSquaredErrorMetric;
3137 for (i=2; i < items; i+=2)
3139 attribute=(char *) SvPV(ST(i-1),na);
3145 if (LocaleCompare(attribute,"channel") == 0)
3150 option=ParseChannelOption(SvPV(ST(i),na));
3153 ThrowPerlException(exception,OptionError,
3154 "UnrecognizedType",SvPV(ST(i),na));
3157 SetPixelChannelMap(image,(ChannelType) option);
3160 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3167 if (LocaleCompare(attribute,"fuzz") == 0)
3169 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3172 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3179 if (LocaleCompare(attribute,"image") == 0)
3181 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3182 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3192 if (LocaleCompare(attribute,"metric") == 0)
3194 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3198 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3202 metric=(MetricType) option;
3205 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3211 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3217 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3219 if (difference_image != (Image *) NULL)
3221 difference_image->error.mean_error_per_pixel=distortion;
3222 AddImageToRegistry(sv,difference_image);
3224 av_push(av,sv_bless(rv,hv));
3227 exception=DestroyExceptionInfo(exception);
3229 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3233 InheritPerlException(exception,perl_exception);
3234 exception=DestroyExceptionInfo(exception);
3235 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3236 SvPOK_on(perl_exception);
3237 ST(0)=sv_2mortal(perl_exception);
3242 ###############################################################################
3246 # C o m p a r e L a y e r s #
3250 ###############################################################################
3255 Image::Magick ref=NO_INIT
3257 CompareImagesLayers = 1
3259 compareimagelayers = 3
3296 PERL_UNUSED_VAR(ref);
3297 PERL_UNUSED_VAR(ix);
3298 exception=AcquireExceptionInfo();
3299 perl_exception=newSVpv("",0);
3301 if (sv_isobject(ST(0)) == 0)
3303 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3307 reference=SvRV(ST(0));
3308 hv=SvSTASH(reference);
3310 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3312 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3313 if (image == (Image *) NULL)
3315 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3319 method=CompareAnyLayer;
3320 for (i=2; i < items; i+=2)
3322 attribute=(char *) SvPV(ST(i-1),na);
3328 if (LocaleCompare(attribute,"method") == 0)
3330 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3334 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3338 method=(ImageLayerMethod) option;
3341 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3353 image=CompareImagesLayers(image,method,exception);
3354 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3356 for ( ; image; image=image->next)
3358 AddImageToRegistry(sv,image);
3360 av_push(av,sv_bless(rv,hv));
3363 exception=DestroyExceptionInfo(exception);
3365 SvREFCNT_dec(perl_exception);
3369 InheritPerlException(exception,perl_exception);
3370 exception=DestroyExceptionInfo(exception);
3371 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3372 SvPOK_on(perl_exception);
3373 ST(0)=sv_2mortal(perl_exception);
3378 ###############################################################################
3386 ###############################################################################
3391 Image::Magick ref=NO_INIT
3397 PERL_UNUSED_VAR(ref);
3398 if (sv_isobject(ST(0)) == 0)
3399 croak("ReferenceIsNotMyType");
3400 reference=SvRV(ST(0));
3401 switch (SvTYPE(reference))
3406 message[MaxTextExtent];
3424 Array (AV *) reference
3426 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3427 XS_VERSION,reference);
3428 hv=gv_stashpv(PackageName, FALSE);
3431 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3435 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3437 info=(struct PackageInfo *) SvIV(sv);
3438 DestroyPackageInfo(info);
3440 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3450 Blessed scalar = (Image *) SvIV(reference)
3452 image=(Image *) SvIV(reference);
3453 if (image != (Image *) NULL)
3454 DeleteImageFromRegistry(reference,image);
3463 ###############################################################################
3471 ###############################################################################
3476 Image::Magick ref=NO_INIT
3500 PERL_UNUSED_VAR(ref);
3501 PERL_UNUSED_VAR(ix);
3502 exception=AcquireExceptionInfo();
3503 perl_exception=newSVpv("",0);
3504 package_info=(struct PackageInfo *) NULL;
3505 if (sv_isobject(ST(0)) == 0)
3507 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3511 reference=SvRV(ST(0));
3512 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3513 if (image == (Image *) NULL)
3515 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3519 package_info=ClonePackageInfo(info,exception);
3521 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3524 for (i=2; i < items; i+=2)
3525 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3527 (void) DisplayImages(package_info->image_info,image,exception);
3528 (void) CatchImageException(image);
3531 if (package_info != (struct PackageInfo *) NULL)
3532 DestroyPackageInfo(package_info);
3533 InheritPerlException(exception,perl_exception);
3534 exception=DestroyExceptionInfo(exception);
3535 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3536 SvPOK_on(perl_exception);
3537 ST(0)=sv_2mortal(perl_exception);
3542 ###############################################################################
3546 # E v a l u a t e I m a g e s #
3550 ###############################################################################
3555 Image::Magick ref=NO_INIT
3577 MagickEvaluateOperator
3592 PERL_UNUSED_VAR(ref);
3593 PERL_UNUSED_VAR(ix);
3594 exception=AcquireExceptionInfo();
3595 perl_exception=newSVpv("",0);
3597 if (sv_isobject(ST(0)) == 0)
3599 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3603 reference=SvRV(ST(0));
3604 hv=SvSTASH(reference);
3605 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3606 if (image == (Image *) NULL)
3608 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3612 op=MeanEvaluateOperator;
3618 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3622 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3626 op=(MagickEvaluateOperator) in;
3629 for (i=2; i < items; i+=2)
3631 attribute=(char *) SvPV(ST(i-1),na);
3637 if (LocaleCompare(attribute,"operator") == 0)
3642 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3643 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3646 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3650 op=(MagickEvaluateOperator) in;
3653 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3665 image=EvaluateImages(image,op,exception);
3666 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3669 Create blessed Perl array for the returned image.
3672 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3674 AddImageToRegistry(sv,image);
3676 av_push(av,sv_bless(rv,hv));
3678 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3679 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3680 "evaluate-%.*s",(int) (MaxTextExtent-9),
3681 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3682 (void) CopyMagickString(image->filename,info->image_info->filename,
3684 SetImageInfo(info->image_info,0,exception);
3685 exception=DestroyExceptionInfo(exception);
3686 SvREFCNT_dec(perl_exception);
3690 InheritPerlException(exception,perl_exception);
3691 exception=DestroyExceptionInfo(exception);
3692 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3693 SvPOK_on(perl_exception);
3694 ST(0)=sv_2mortal(perl_exception);
3699 ###############################################################################
3707 ###############################################################################
3712 Image::Magick ref=NO_INIT
3719 #define ChannelFeatures(channel,direction) \
3721 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3722 channel_features[channel].angular_second_moment[direction]); \
3723 PUSHs(sv_2mortal(newSVpv(message,0))); \
3724 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3725 channel_features[channel].contrast[direction]); \
3726 PUSHs(sv_2mortal(newSVpv(message,0))); \
3727 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3728 channel_features[channel].contrast[direction]); \
3729 PUSHs(sv_2mortal(newSVpv(message,0))); \
3730 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3731 channel_features[channel].variance_sum_of_squares[direction]); \
3732 PUSHs(sv_2mortal(newSVpv(message,0))); \
3733 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3734 channel_features[channel].inverse_difference_moment[direction]); \
3735 PUSHs(sv_2mortal(newSVpv(message,0))); \
3736 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3737 channel_features[channel].sum_average[direction]); \
3738 PUSHs(sv_2mortal(newSVpv(message,0))); \
3739 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3740 channel_features[channel].sum_variance[direction]); \
3741 PUSHs(sv_2mortal(newSVpv(message,0))); \
3742 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3743 channel_features[channel].sum_entropy[direction]); \
3744 PUSHs(sv_2mortal(newSVpv(message,0))); \
3745 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3746 channel_features[channel].entropy[direction]); \
3747 PUSHs(sv_2mortal(newSVpv(message,0))); \
3748 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3749 channel_features[channel].difference_variance[direction]); \
3750 PUSHs(sv_2mortal(newSVpv(message,0))); \
3751 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3752 channel_features[channel].difference_entropy[direction]); \
3753 PUSHs(sv_2mortal(newSVpv(message,0))); \
3754 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3755 channel_features[channel].measure_of_correlation_1[direction]); \
3756 PUSHs(sv_2mortal(newSVpv(message,0))); \
3757 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3758 channel_features[channel].measure_of_correlation_2[direction]); \
3759 PUSHs(sv_2mortal(newSVpv(message,0))); \
3760 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3761 channel_features[channel].maximum_correlation_coefficient[direction]); \
3762 PUSHs(sv_2mortal(newSVpv(message,0))); \
3770 message[MaxTextExtent];
3797 PERL_UNUSED_VAR(ref);
3798 PERL_UNUSED_VAR(ix);
3799 exception=AcquireExceptionInfo();
3800 perl_exception=newSVpv("",0);
3802 if (sv_isobject(ST(0)) == 0)
3804 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3808 reference=SvRV(ST(0));
3811 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3812 if (image == (Image *) NULL)
3814 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3818 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3820 for (i=2; i < items; i+=2)
3822 attribute=(char *) SvPV(ST(i-1),na);
3828 if (LocaleCompare(attribute,"distance") == 0)
3830 distance=StringToLong((char *) SvPV(ST(1),na));
3833 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3839 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3846 for ( ; image; image=image->next)
3848 channel_features=GetImageFeatures(image,distance,
3850 if (channel_features == (ChannelFeatures *) NULL)
3853 EXTEND(sp,75*count);
3854 for (i=0; i < 4; i++)
3856 ChannelFeatures(RedChannel,i);
3857 ChannelFeatures(GreenChannel,i);
3858 ChannelFeatures(BlueChannel,i);
3859 if (image->colorspace == CMYKColorspace)
3860 ChannelFeatures(BlackChannel,i);
3861 if (image->matte != MagickFalse)
3862 ChannelFeatures(AlphaChannel,i);
3864 channel_features=(ChannelFeatures *)
3865 RelinquishMagickMemory(channel_features);
3869 InheritPerlException(exception,perl_exception);
3870 exception=DestroyExceptionInfo(exception);
3871 SvREFCNT_dec(perl_exception);
3875 ###############################################################################
3883 ###############################################################################
3888 Image::Magick ref=NO_INIT
3926 PERL_UNUSED_VAR(ref);
3927 PERL_UNUSED_VAR(ix);
3928 exception=AcquireExceptionInfo();
3929 perl_exception=newSVpv("",0);
3931 if (sv_isobject(ST(0)) == 0)
3933 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3937 reference=SvRV(ST(0));
3938 hv=SvSTASH(reference);
3939 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3940 if (image == (Image *) NULL)
3942 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3946 background_color=image->background_color;
3948 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3951 for (i=2; i < items; i+=2)
3953 attribute=(char *) SvPV(ST(i-1),na);
3959 if (LocaleCompare(attribute,"background") == 0)
3961 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3962 &background_color,exception);
3965 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3971 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3977 image->background_color=background_color;
3978 image=MergeImageLayers(image,FlattenLayer,exception);
3979 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3982 Create blessed Perl array for the returned image.
3985 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3987 AddImageToRegistry(sv,image);
3989 av_push(av,sv_bless(rv,hv));
3991 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3992 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3993 "flatten-%.*s",(int) (MaxTextExtent-9),
3994 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3995 (void) CopyMagickString(image->filename,info->image_info->filename,
3997 SetImageInfo(info->image_info,0,exception);
3998 exception=DestroyExceptionInfo(exception);
3999 SvREFCNT_dec(perl_exception);
4003 InheritPerlException(exception,perl_exception);
4004 exception=DestroyExceptionInfo(exception);
4005 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4006 SvPOK_on(perl_exception); /* return messages in string context */
4007 ST(0)=sv_2mortal(perl_exception);
4012 ###############################################################################
4020 ###############################################################################
4025 Image::Magick ref=NO_INIT
4037 expression[MaxTextExtent];
4065 PERL_UNUSED_VAR(ref);
4066 PERL_UNUSED_VAR(ix);
4067 exception=AcquireExceptionInfo();
4068 perl_exception=newSVpv("",0);
4072 if (sv_isobject(ST(0)) == 0)
4074 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4078 reference=SvRV(ST(0));
4079 hv=SvSTASH(reference);
4081 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4083 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4084 if (image == (Image *) NULL)
4086 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4090 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4094 channel=DefaultChannels;
4095 (void) CopyMagickString(expression,"u",MaxTextExtent);
4097 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4099 for (i=2; i < items; i+=2)
4101 attribute=(char *) SvPV(ST(i-1),na);
4107 if (LocaleCompare(attribute,"channel") == 0)
4112 option=ParseChannelOption(SvPV(ST(i),na));
4115 ThrowPerlException(exception,OptionError,
4116 "UnrecognizedType",SvPV(ST(i),na));
4119 channel=(ChannelType) option;
4122 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4129 if (LocaleCompare(attribute,"expression") == 0)
4131 (void) CopyMagickString(expression,SvPV(ST(i),na),
4135 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4141 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4147 channel_mask=SetPixelChannelMask(image,channel);
4148 image=FxImage(image,expression,exception);
4149 if (image != (Image *) NULL)
4150 (void) SetPixelChannelMask(image,channel_mask);
4151 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4153 for ( ; image; image=image->next)
4155 AddImageToRegistry(sv,image);
4157 av_push(av,sv_bless(rv,hv));
4160 exception=DestroyExceptionInfo(exception);
4162 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4166 InheritPerlException(exception,perl_exception);
4167 exception=DestroyExceptionInfo(exception);
4168 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4169 SvPOK_on(perl_exception);
4170 ST(0)=sv_2mortal(perl_exception);
4175 ###############################################################################
4183 ###############################################################################
4188 Image::Magick ref=NO_INIT
4199 color[MaxTextExtent];
4224 PERL_UNUSED_VAR(ref);
4225 PERL_UNUSED_VAR(ix);
4226 exception=AcquireExceptionInfo();
4227 perl_exception=newSVpv("",0);
4228 if (sv_isobject(ST(0)) == 0)
4230 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4234 reference=SvRV(ST(0));
4235 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4236 if (image == (Image *) NULL && !info)
4239 for (i=1; i < items; i++)
4241 attribute=(char *) SvPV(ST(i),na);
4248 if (LocaleCompare(attribute,"adjoin") == 0)
4251 s=newSViv((ssize_t) info->image_info->adjoin);
4252 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4255 if (LocaleCompare(attribute,"antialias") == 0)
4258 s=newSViv((ssize_t) info->image_info->antialias);
4259 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4262 if (LocaleCompare(attribute,"area") == 0)
4264 s=newSViv(GetMagickResource(AreaResource));
4265 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4268 if (LocaleCompare(attribute,"attenuate") == 0)
4273 value=GetImageProperty(image,attribute);
4274 if (value != (const char *) NULL)
4276 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4279 if (LocaleCompare(attribute,"authenticate") == 0)
4282 s=newSVpv(info->image_info->authenticate,0);
4283 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4286 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4293 if (LocaleCompare(attribute,"background") == 0)
4295 if (image == (Image *) NULL)
4297 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4298 QuantumFormat "," QuantumFormat "," QuantumFormat,
4299 image->background_color.red,image->background_color.green,
4300 image->background_color.blue,image->background_color.alpha);
4302 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4305 if (LocaleCompare(attribute,"base-columns") == 0)
4307 if (image != (Image *) NULL)
4308 s=newSViv((ssize_t) image->magick_columns);
4309 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4312 if (LocaleCompare(attribute,"base-filename") == 0)
4314 if (image != (Image *) NULL)
4315 s=newSVpv(image->magick_filename,0);
4316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4319 if (LocaleCompare(attribute,"base-height") == 0)
4321 if (image != (Image *) NULL)
4322 s=newSViv((ssize_t) image->magick_rows);
4323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4326 if (LocaleCompare(attribute,"base-rows") == 0)
4328 if (image != (Image *) NULL)
4329 s=newSViv((ssize_t) image->magick_rows);
4330 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4333 if (LocaleCompare(attribute,"base-width") == 0)
4335 if (image != (Image *) NULL)
4336 s=newSViv((ssize_t) image->magick_columns);
4337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4340 if (LocaleCompare(attribute,"bias") == 0)
4342 if (image != (Image *) NULL)
4343 s=newSVnv(image->bias);
4344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4347 if (LocaleCompare(attribute,"blue-primary") == 0)
4349 if (image == (Image *) NULL)
4351 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4352 image->chromaticity.blue_primary.x,
4353 image->chromaticity.blue_primary.y);
4355 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4358 if (LocaleCompare(attribute,"bordercolor") == 0)
4360 if (image == (Image *) NULL)
4362 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4363 QuantumFormat "," QuantumFormat "," QuantumFormat,
4364 image->border_color.red,image->border_color.green,
4365 image->border_color.blue,image->border_color.alpha);
4367 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4370 if (LocaleCompare(attribute,"bounding-box") == 0)
4373 geometry[MaxTextExtent];
4378 if (image == (Image *) NULL)
4380 page=GetImageBoundingBox(image,&image->exception);
4381 (void) FormatLocaleString(geometry,MaxTextExtent,
4382 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4383 page.height,(double) page.x,(double) page.y);
4384 s=newSVpv(geometry,0);
4385 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4395 if (LocaleCompare(attribute,"class") == 0)
4397 if (image == (Image *) NULL)
4399 s=newSViv(image->storage_class);
4400 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4401 image->storage_class));
4403 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4406 if (LocaleCompare(attribute,"clip-mask") == 0)
4408 if (image != (Image *) NULL)
4414 if (image->mask == (Image *) NULL)
4415 ClipImage(image,exception);
4416 if (image->mask != (Image *) NULL)
4418 AddImageToRegistry(sv,image->mask);
4419 s=sv_bless(newRV(sv),SvSTASH(reference));
4422 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4425 if (LocaleCompare(attribute,"clip-path") == 0)
4427 if (image != (Image *) NULL)
4433 if (image->clip_mask == (Image *) NULL)
4434 ClipImage(image,exception);
4435 if (image->clip_mask != (Image *) NULL)
4437 AddImageToRegistry(sv,image->clip_mask);
4438 s=sv_bless(newRV(sv),SvSTASH(reference));
4441 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4444 if (LocaleCompare(attribute,"compression") == 0)
4446 j=info ? info->image_info->compression : image ?
4447 image->compression : UndefinedCompression;
4449 if (info->image_info->compression == UndefinedCompression)
4450 j=image->compression;
4452 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4455 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4458 if (LocaleCompare(attribute,"colorspace") == 0)
4460 j=image ? image->colorspace : RGBColorspace;
4462 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4465 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4468 if (LocaleCompare(attribute,"colors") == 0)
4470 if (image != (Image *) NULL)
4471 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4472 &image->exception));
4473 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4476 if (LocaleNCompare(attribute,"colormap",8) == 0)
4481 if (image == (Image *) NULL || !image->colormap)
4484 items=sscanf(attribute,"%*[^[][%ld",&j);
4486 if (j > (ssize_t) image->colors)
4488 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4489 QuantumFormat "," QuantumFormat "," QuantumFormat,
4490 image->colormap[j].red,image->colormap[j].green,
4491 image->colormap[j].blue,image->colormap[j].alpha);
4493 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4496 if (LocaleCompare(attribute,"columns") == 0)
4498 if (image != (Image *) NULL)
4499 s=newSViv((ssize_t) image->columns);
4500 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4503 if (LocaleCompare(attribute,"comment") == 0)
4508 value=GetImageProperty(image,attribute);
4509 if (value != (const char *) NULL)
4511 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4514 if (LocaleCompare(attribute,"copyright") == 0)
4516 s=newSVpv(GetMagickCopyright(),0);
4517 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4520 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4527 if (LocaleCompare(attribute,"density") == 0)
4530 geometry[MaxTextExtent];
4532 if (image == (Image *) NULL)
4534 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4535 image->x_resolution,image->y_resolution);
4536 s=newSVpv(geometry,0);
4537 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4540 if (LocaleCompare(attribute,"delay") == 0)
4542 if (image != (Image *) NULL)
4543 s=newSViv((ssize_t) image->delay);
4544 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4547 if (LocaleCompare(attribute,"depth") == 0)
4549 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4550 if (image != (Image *) NULL)
4551 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4552 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4555 if (LocaleCompare(attribute,"directory") == 0)
4557 if (image && image->directory)
4558 s=newSVpv(image->directory,0);
4559 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4562 if (LocaleCompare(attribute,"dispose") == 0)
4564 if (image == (Image *) NULL)
4567 s=newSViv(image->dispose);
4569 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4571 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4574 if (LocaleCompare(attribute,"disk") == 0)
4576 s=newSViv(GetMagickResource(DiskResource));
4577 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4580 if (LocaleCompare(attribute,"dither") == 0)
4583 s=newSViv((ssize_t) info->image_info->dither);
4584 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4587 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4589 if (info && info->image_info->server_name)
4590 s=newSVpv(info->image_info->server_name,0);
4591 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4594 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4601 if (LocaleCompare(attribute,"elapsed-time") == 0)
4603 if (image != (Image *) NULL)
4604 s=newSVnv(GetElapsedTime(&image->timer));
4605 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4608 if (LocaleCompare(attribute,"endian") == 0)
4610 j=info ? info->image_info->endian : image ? image->endian :
4613 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4615 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4618 if (LocaleCompare(attribute,"error") == 0)
4620 if (image != (Image *) NULL)
4621 s=newSVnv(image->error.mean_error_per_pixel);
4622 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4632 if (LocaleCompare(attribute,"filesize") == 0)
4634 if (image != (Image *) NULL)
4635 s=newSViv((ssize_t) GetBlobSize(image));
4636 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4639 if (LocaleCompare(attribute,"filename") == 0)
4641 if (info && info->image_info->filename &&
4642 *info->image_info->filename)
4643 s=newSVpv(info->image_info->filename,0);
4644 if (image != (Image *) NULL)
4645 s=newSVpv(image->filename,0);
4646 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4649 if (LocaleCompare(attribute,"filter") == 0)
4651 s=image ? newSViv(image->filter) : newSViv(0);
4652 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4655 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4658 if (LocaleCompare(attribute,"font") == 0)
4660 if (info && info->image_info->font)
4661 s=newSVpv(info->image_info->font,0);
4662 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4665 if (LocaleCompare(attribute,"foreground") == 0)
4667 if (LocaleCompare(attribute,"format") == 0)
4672 magick_info=(const MagickInfo *) NULL;
4673 if (info && (*info->image_info->magick != '\0'))
4674 magick_info=GetMagickInfo(info->image_info->magick,exception);
4675 if (image != (Image *) NULL)
4676 magick_info=GetMagickInfo(image->magick,&image->exception);
4677 if ((magick_info != (const MagickInfo *) NULL) &&
4678 (*magick_info->description != '\0'))
4679 s=newSVpv((char *) magick_info->description,0);
4680 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4683 if (LocaleCompare(attribute,"fuzz") == 0)
4686 s=newSVnv(info->image_info->fuzz);
4687 if (image != (Image *) NULL)
4688 s=newSVnv(image->fuzz);
4689 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4692 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4699 if (LocaleCompare(attribute,"gamma") == 0)
4701 if (image != (Image *) NULL)
4702 s=newSVnv(image->gamma);
4703 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4706 if (LocaleCompare(attribute,"geometry") == 0)
4708 if (image && image->geometry)
4709 s=newSVpv(image->geometry,0);
4710 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4713 if (LocaleCompare(attribute,"gravity") == 0)
4715 s=image ? newSViv(image->gravity) : newSViv(0);
4716 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4719 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4722 if (LocaleCompare(attribute,"green-primary") == 0)
4724 if (image == (Image *) NULL)
4726 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4727 image->chromaticity.green_primary.x,
4728 image->chromaticity.green_primary.y);
4730 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4733 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4740 if (LocaleCompare(attribute,"height") == 0)
4742 if (image != (Image *) NULL)
4743 s=newSViv((ssize_t) image->rows);
4744 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4747 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4754 if (LocaleCompare(attribute,"icc") == 0)
4756 if (image != (Image *) NULL)
4761 profile=GetImageProfile(image,"icc");
4762 if (profile != (StringInfo *) NULL)
4763 s=newSVpv((const char *) GetStringInfoDatum(profile),
4764 GetStringInfoLength(profile));
4766 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4769 if (LocaleCompare(attribute,"icm") == 0)
4771 if (image != (Image *) NULL)
4776 profile=GetImageProfile(image,"icm");
4777 if (profile != (const StringInfo *) NULL)
4778 s=newSVpv((const char *) GetStringInfoDatum(profile),
4779 GetStringInfoLength(profile));
4781 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4784 if (LocaleCompare(attribute,"id") == 0)
4786 if (image != (Image *) NULL)
4797 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4799 status=SetImageRegistry(ImageRegistryType,key,image,
4804 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4807 if (LocaleNCompare(attribute,"index",5) == 0)
4810 name[MaxTextExtent];
4819 register const Quantum
4825 if (image == (Image *) NULL)
4827 if (image->storage_class != PseudoClass)
4831 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4833 image_view=AcquireCacheView(image);
4834 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4835 if (p != (const Quantum *) NULL)
4837 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4838 GetPixelIndex(image,p));
4840 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4842 image_view=DestroyCacheView(image_view);
4845 if (LocaleCompare(attribute,"iptc") == 0)
4847 if (image != (Image *) NULL)
4852 profile=GetImageProfile(image,"iptc");
4853 if (profile != (const StringInfo *) NULL)
4854 s=newSVpv((const char *) GetStringInfoDatum(profile),
4855 GetStringInfoLength(profile));
4857 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4860 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4862 if (image != (Image *) NULL)
4863 s=newSViv((ssize_t) image->iterations);
4864 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4867 if (LocaleCompare(attribute,"interlace") == 0)
4869 j=info ? info->image_info->interlace : image ? image->interlace :
4872 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4875 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4878 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4885 if (LocaleCompare(attribute,"label") == 0)
4890 if (image == (Image *) NULL)
4892 value=GetImageProperty(image,"Label");
4893 if (value != (const char *) NULL)
4895 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4898 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4900 if (image != (Image *) NULL)
4901 s=newSViv((ssize_t) image->iterations);
4902 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4905 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4912 if (LocaleCompare(attribute,"magick") == 0)
4914 if (info && *info->image_info->magick)
4915 s=newSVpv(info->image_info->magick,0);
4916 if (image != (Image *) NULL)
4917 s=newSVpv(image->magick,0);
4918 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4921 if (LocaleCompare(attribute,"map") == 0)
4923 s=newSViv(GetMagickResource(MapResource));
4924 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4927 if (LocaleCompare(attribute,"maximum-error") == 0)
4929 if (image != (Image *) NULL)
4930 s=newSVnv(image->error.normalized_maximum_error);
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 if (LocaleCompare(attribute,"memory") == 0)
4936 s=newSViv(GetMagickResource(MemoryResource));
4937 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4940 if (LocaleCompare(attribute,"mean-error") == 0)
4942 if (image != (Image *) NULL)
4943 s=newSVnv(image->error.normalized_mean_error);
4944 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4947 if (LocaleCompare(attribute,"mime") == 0)
4949 if (info && *info->image_info->magick)
4950 s=newSVpv(MagickToMime(info->image_info->magick),0);
4951 if (image != (Image *) NULL)
4952 s=newSVpv(MagickToMime(image->magick),0);
4953 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4956 if (LocaleCompare(attribute,"mattecolor") == 0)
4958 if (image == (Image *) NULL)
4960 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4961 QuantumFormat "," QuantumFormat "," QuantumFormat,
4962 image->matte_color.red,image->matte_color.green,
4963 image->matte_color.blue,image->matte_color.alpha);
4965 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4968 if (LocaleCompare(attribute,"matte") == 0)
4970 if (image != (Image *) NULL)
4971 s=newSViv((ssize_t) image->matte);
4972 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4975 if (LocaleCompare(attribute,"mime") == 0)
4981 if (info && *info->image_info->magick)
4982 magick=info->image_info->magick;
4983 if (image != (Image *) NULL)
4984 magick=image->magick;
4990 mime=MagickToMime(magick);
4992 mime=(char *) RelinquishMagickMemory(mime);
4994 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4997 if (LocaleCompare(attribute,"monochrome") == 0)
4999 if (image == (Image *) NULL)
5001 j=info ? info->image_info->monochrome :
5002 IsImageMonochrome(image,&image->exception);
5004 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5007 if (LocaleCompare(attribute,"montage") == 0)
5009 if (image && image->montage)
5010 s=newSVpv(image->montage,0);
5011 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5014 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5021 if (LocaleCompare(attribute,"orientation") == 0)
5023 j=info ? info->image_info->orientation : image ?
5024 image->orientation : UndefinedOrientation;
5026 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5029 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5032 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5039 if (LocaleCompare(attribute,"page") == 0)
5041 if (info && info->image_info->page)
5042 s=newSVpv(info->image_info->page,0);
5043 if (image != (Image *) NULL)
5046 geometry[MaxTextExtent];
5048 (void) FormatLocaleString(geometry,MaxTextExtent,
5049 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5050 (double) image->page.height,(double) image->page.x,(double)
5052 s=newSVpv(geometry,0);
5054 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5057 if (LocaleCompare(attribute,"page.x") == 0)
5059 if (image != (Image *) NULL)
5060 s=newSViv((ssize_t) image->page.x);
5061 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5064 if (LocaleCompare(attribute,"page.y") == 0)
5066 if (image != (Image *) NULL)
5067 s=newSViv((ssize_t) image->page.y);
5068 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5071 if (LocaleNCompare(attribute,"pixel",5) == 0)
5074 tuple[MaxTextExtent];
5083 register const Quantum
5086 if (image == (Image *) NULL)
5090 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5092 p=GetVirtualPixels(image,x,y,1,1,exception);
5093 if (image->colorspace != CMYKColorspace)
5094 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5095 QuantumFormat "," QuantumFormat "," QuantumFormat,
5096 GetPixelRed(image,p),GetPixelGreen(image,p),
5097 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5099 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5100 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5101 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5102 GetPixelBlue(image,p),GetPixelBlack(image,p),
5103 GetPixelAlpha(image,p));
5105 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5108 if (LocaleCompare(attribute,"pointsize") == 0)
5111 s=newSViv((ssize_t) info->image_info->pointsize);
5112 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5115 if (LocaleCompare(attribute,"preview") == 0)
5117 s=newSViv(info->image_info->preview_type);
5118 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5119 info->image_info->preview_type));
5121 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5124 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5131 if (LocaleCompare(attribute,"quality") == 0)
5134 s=newSViv((ssize_t) info->image_info->quality);
5135 if (image != (Image *) NULL)
5136 s=newSViv((ssize_t) image->quality);
5137 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5140 if (LocaleCompare(attribute,"quantum") == 0)
5143 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5144 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5154 if (LocaleCompare(attribute,"rendering-intent") == 0)
5156 s=newSViv(image->rendering_intent);
5157 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5158 image->rendering_intent));
5160 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5163 if (LocaleCompare(attribute,"red-primary") == 0)
5165 if (image == (Image *) NULL)
5167 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5168 image->chromaticity.red_primary.x,
5169 image->chromaticity.red_primary.y);
5171 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5174 if (LocaleCompare(attribute,"rows") == 0)
5176 if (image != (Image *) NULL)
5177 s=newSViv((ssize_t) image->rows);
5178 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5181 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5188 if (LocaleCompare(attribute,"sampling-factor") == 0)
5190 if (info && info->image_info->sampling_factor)
5191 s=newSVpv(info->image_info->sampling_factor,0);
5192 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5195 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5197 if (info && info->image_info->server_name)
5198 s=newSVpv(info->image_info->server_name,0);
5199 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5202 if (LocaleCompare(attribute,"size") == 0)
5204 if (info && info->image_info->size)
5205 s=newSVpv(info->image_info->size,0);
5206 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5209 if (LocaleCompare(attribute,"scene") == 0)
5211 if (image != (Image *) NULL)
5212 s=newSViv((ssize_t) image->scene);
5213 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5216 if (LocaleCompare(attribute,"scenes") == 0)
5218 if (image != (Image *) NULL)
5219 s=newSViv((ssize_t) info->image_info->number_scenes);
5220 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5223 if (LocaleCompare(attribute,"signature") == 0)
5228 if (image == (Image *) NULL)
5230 (void) SignatureImage(image,exception);
5231 value=GetImageProperty(image,"Signature");
5232 if (value != (const char *) NULL)
5234 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5237 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5244 if (LocaleCompare(attribute,"taint") == 0)
5246 if (image != (Image *) NULL)
5247 s=newSViv((ssize_t) IsTaintImage(image));
5248 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5251 if (LocaleCompare(attribute,"texture") == 0)
5253 if (info && info->image_info->texture)
5254 s=newSVpv(info->image_info->texture,0);
5255 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5258 if (LocaleCompare(attribute,"total-ink-density") == 0)
5260 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5261 if (image != (Image *) NULL)
5262 s=newSVnv(GetImageTotalInkDensity(image));
5263 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5266 if (LocaleCompare(attribute,"transparent-color") == 0)
5268 if (image == (Image *) NULL)
5270 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5271 QuantumFormat "," QuantumFormat "," QuantumFormat,
5272 image->transparent_color.red,image->transparent_color.green,
5273 image->transparent_color.blue,image->transparent_color.alpha);
5275 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5278 if (LocaleCompare(attribute,"type") == 0)
5280 if (image == (Image *) NULL)
5282 j=(ssize_t) GetImageType(image,&image->exception);
5284 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5286 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5289 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5296 if (LocaleCompare(attribute,"units") == 0)
5298 j=info ? info->image_info->units : image ? image->units :
5299 UndefinedResolution;
5300 if (info && (info->image_info->units == UndefinedResolution))
5303 if (j == UndefinedResolution)
5304 s=newSVpv("undefined units",0);
5306 if (j == PixelsPerInchResolution)
5307 s=newSVpv("pixels / inch",0);
5309 s=newSVpv("pixels / centimeter",0);
5310 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5313 if (LocaleCompare(attribute,"user-time") == 0)
5315 if (image != (Image *) NULL)
5316 s=newSVnv(GetUserTime(&image->timer));
5317 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5320 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5327 if (LocaleCompare(attribute,"verbose") == 0)
5330 s=newSViv((ssize_t) info->image_info->verbose);
5331 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5334 if (LocaleCompare(attribute,"version") == 0)
5336 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5340 if (LocaleCompare(attribute,"view") == 0)
5342 if (info && info->image_info->view)
5343 s=newSVpv(info->image_info->view,0);
5344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5347 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5349 if (image == (Image *) NULL)
5351 j=(ssize_t) GetImageVirtualPixelMethod(image);
5353 (void) sv_setpv(s,CommandOptionToMnemonic(
5354 MagickVirtualPixelOptions,j));
5356 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5359 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5366 if (LocaleCompare(attribute,"white-point") == 0)
5368 if (image == (Image *) NULL)
5370 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5371 image->chromaticity.white_point.x,
5372 image->chromaticity.white_point.y);
5374 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5377 if (LocaleCompare(attribute,"width") == 0)
5379 if (image != (Image *) NULL)
5380 s=newSViv((ssize_t) image->columns);
5381 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5384 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5391 if (LocaleCompare(attribute,"x-resolution") == 0)
5393 if (image != (Image *) NULL)
5394 s=newSVnv(image->x_resolution);
5395 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5398 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5405 if (LocaleCompare(attribute,"y-resolution") == 0)
5407 if (image != (Image *) NULL)
5408 s=newSVnv(image->y_resolution);
5409 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5412 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5419 if (image == (Image *) NULL)
5420 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5424 value=GetImageProperty(image,attribute);
5425 if (value != (const char *) NULL)
5428 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5431 if (*attribute != '%')
5432 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5439 meta=InterpretImageProperties(info ? info->image_info :
5440 (ImageInfo *) NULL,image,attribute,exception);
5442 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5443 meta=(char *) RelinquishMagickMemory(meta);
5447 exception=DestroyExceptionInfo(exception);
5448 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5452 ###############################################################################
5456 # G e t A u t h e n t i c P i x e l s #
5460 ###############################################################################
5464 GetAuthenticPixels(ref,...)
5465 Image::Magick ref = NO_INIT
5467 getauthenticpixels = 1
5497 PERL_UNUSED_VAR(ref);
5498 PERL_UNUSED_VAR(ix);
5499 exception=AcquireExceptionInfo();
5500 perl_exception=newSVpv("",0);
5501 if (sv_isobject(ST(0)) == 0)
5503 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5507 reference=SvRV(ST(0));
5509 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5510 if (image == (Image *) NULL)
5512 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5519 region.width=image->columns;
5522 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5523 for (i=2; i < items; i+=2)
5525 attribute=(char *) SvPV(ST(i-1),na);
5531 if (LocaleCompare(attribute,"geometry") == 0)
5533 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5536 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5543 if (LocaleCompare(attribute,"height") == 0)
5545 region.height=SvIV(ST(i));
5548 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5555 if (LocaleCompare(attribute,"x") == 0)
5557 region.x=SvIV(ST(i));
5560 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5567 if (LocaleCompare(attribute,"y") == 0)
5569 region.y=SvIV(ST(i));
5572 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5579 if (LocaleCompare(attribute,"width") == 0)
5581 region.width=SvIV(ST(i));
5584 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5590 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5591 region.height,exception);
5592 if (blob != (void *) NULL)
5596 InheritPerlException(exception,perl_exception);
5597 exception=DestroyExceptionInfo(exception);
5598 SvREFCNT_dec(perl_exception); /* throw away all errors */
5607 ###############################################################################
5611 # G e t V i r t u a l P i x e l s #
5615 ###############################################################################
5619 GetVirtualPixels(ref,...)
5620 Image::Magick ref = NO_INIT
5622 getvirtualpixels = 1
5623 AcquireImagePixels = 2
5624 acquireimagepixels = 3
5652 PERL_UNUSED_VAR(ref);
5653 PERL_UNUSED_VAR(ix);
5654 exception=AcquireExceptionInfo();
5655 perl_exception=newSVpv("",0);
5656 if (sv_isobject(ST(0)) == 0)
5658 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5662 reference=SvRV(ST(0));
5664 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5665 if (image == (Image *) NULL)
5667 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5674 region.width=image->columns;
5677 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5678 for (i=2; i < items; i+=2)
5680 attribute=(char *) SvPV(ST(i-1),na);
5686 if (LocaleCompare(attribute,"geometry") == 0)
5688 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5691 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5698 if (LocaleCompare(attribute,"height") == 0)
5700 region.height=SvIV(ST(i));
5703 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5710 if (LocaleCompare(attribute,"x") == 0)
5712 region.x=SvIV(ST(i));
5715 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5722 if (LocaleCompare(attribute,"y") == 0)
5724 region.y=SvIV(ST(i));
5727 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5734 if (LocaleCompare(attribute,"width") == 0)
5736 region.width=SvIV(ST(i));
5739 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5745 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5746 region.height,exception);
5747 if (blob != (void *) NULL)
5751 InheritPerlException(exception,perl_exception);
5752 exception=DestroyExceptionInfo(exception);
5753 SvREFCNT_dec(perl_exception); /* throw away all errors */
5756 RETVAL = (void *) blob;
5762 ###############################################################################
5766 # G e t A u t h e n t i c M e t a c o n t e n t #
5770 ###############################################################################
5774 GetAuthenticMetacontent(ref,...)
5775 Image::Magick ref = NO_INIT
5777 getauthenticmetacontent = 1
5798 PERL_UNUSED_VAR(ref);
5799 PERL_UNUSED_VAR(ix);
5800 exception=AcquireExceptionInfo();
5801 perl_exception=newSVpv("",0);
5802 if (sv_isobject(ST(0)) == 0)
5804 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5808 reference=SvRV(ST(0));
5810 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5811 if (image == (Image *) NULL)
5813 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5818 blob=(void *) GetAuthenticMetacontent(image);
5819 if (blob != (void *) NULL)
5823 InheritPerlException(exception,perl_exception);
5824 exception=DestroyExceptionInfo(exception);
5825 SvREFCNT_dec(perl_exception); /* throw away all errors */
5834 ###############################################################################
5838 # G e t V i r t u a l M e t a c o n t e n t #
5842 ###############################################################################
5846 GetVirtualMetacontent(ref,...)
5847 Image::Magick ref = NO_INIT
5849 getvirtualmetacontent = 1
5868 PERL_UNUSED_VAR(ref);
5869 PERL_UNUSED_VAR(ix);
5870 exception=AcquireExceptionInfo();
5871 perl_exception=newSVpv("",0);
5872 if (sv_isobject(ST(0)) == 0)
5874 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5878 reference=SvRV(ST(0));
5880 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5881 if (image == (Image *) NULL)
5883 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5888 blob=(void *) GetVirtualMetacontent(image);
5889 if (blob != (void *) NULL)
5893 InheritPerlException(exception,perl_exception);
5894 exception=DestroyExceptionInfo(exception);
5895 SvREFCNT_dec(perl_exception); /* throw away all errors */
5904 ###############################################################################
5908 # H i s t o g r a m #
5912 ###############################################################################
5917 Image::Magick ref=NO_INIT
5928 message[MaxTextExtent];
5955 PERL_UNUSED_VAR(ref);
5956 PERL_UNUSED_VAR(ix);
5957 exception=AcquireExceptionInfo();
5958 perl_exception=newSVpv("",0);
5960 if (sv_isobject(ST(0)) == 0)
5962 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5966 reference=SvRV(ST(0));
5969 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5970 if (image == (Image *) NULL)
5972 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5976 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5978 for ( ; image; image=image->next)
5980 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5981 if (histogram == (PixelPacket *) NULL)
5983 count+=(ssize_t) number_colors;
5985 for (i=0; i < (ssize_t) number_colors; i++)
5987 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5989 PUSHs(sv_2mortal(newSVpv(message,0)));
5990 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5991 histogram[i].green);
5992 PUSHs(sv_2mortal(newSVpv(message,0)));
5993 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5995 PUSHs(sv_2mortal(newSVpv(message,0)));
5996 if (image->colorspace == CMYKColorspace)
5998 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5999 histogram[i].black);
6000 PUSHs(sv_2mortal(newSVpv(message,0)));
6002 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6003 histogram[i].alpha);
6004 PUSHs(sv_2mortal(newSVpv(message,0)));
6005 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6006 histogram[i].count);
6007 PUSHs(sv_2mortal(newSVpv(message,0)));
6009 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6013 InheritPerlException(exception,perl_exception);
6014 exception=DestroyExceptionInfo(exception);
6015 SvREFCNT_dec(perl_exception);
6019 ###############################################################################
6027 ###############################################################################
6032 Image::Magick ref=NO_INIT
6056 register const Quantum
6070 *reference; /* reference is the SV* of ref=SvIV(reference) */
6072 PERL_UNUSED_VAR(ref);
6073 PERL_UNUSED_VAR(ix);
6074 exception=AcquireExceptionInfo();
6075 perl_exception=newSVpv("",0);
6076 reference=SvRV(ST(0));
6077 av=(AV *) reference;
6078 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6080 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6081 if (image == (Image *) NULL)
6083 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6087 normalize=MagickTrue;
6090 region.width=image->columns;
6093 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6094 for (i=2; i < items; i+=2)
6096 attribute=(char *) SvPV(ST(i-1),na);
6102 if (LocaleCompare(attribute,"channel") == 0)
6107 option=ParseChannelOption(SvPV(ST(i),na));
6110 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6114 SetPixelChannelMap(image,(ChannelType) option);
6117 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6124 if (LocaleCompare(attribute,"geometry") == 0)
6126 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6136 if (LocaleCompare(attribute,"normalize") == 0)
6138 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6142 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6146 normalize=option != 0 ? MagickTrue : MagickFalse;
6149 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6156 if (LocaleCompare(attribute,"x") == 0)
6158 region.x=SvIV(ST(i));
6161 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6168 if (LocaleCompare(attribute,"y") == 0)
6170 region.y=SvIV(ST(i));
6173 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6179 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6185 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6186 if (p == (const Quantum *) NULL)
6194 if (normalize != MagickFalse)
6195 scale=1.0/QuantumRange;
6196 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6197 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6198 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6199 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6200 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6201 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6202 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6203 (image->colorspace == CMYKColorspace))
6204 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6205 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6206 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6210 InheritPerlException(exception,perl_exception);
6211 exception=DestroyExceptionInfo(exception);
6212 SvREFCNT_dec(perl_exception);
6216 ###############################################################################
6220 # G e t P i x e l s #
6224 ###############################################################################
6229 Image::Magick ref=NO_INIT
6268 *reference; /* reference is the SV* of ref=SvIV(reference) */
6270 PERL_UNUSED_VAR(ref);
6271 PERL_UNUSED_VAR(ix);
6272 exception=AcquireExceptionInfo();
6273 perl_exception=newSVpv("",0);
6274 reference=SvRV(ST(0));
6275 av=(AV *) reference;
6276 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6278 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6279 if (image == (Image *) NULL)
6281 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6286 if (image->matte != MagickFalse)
6288 if (image->colorspace == CMYKColorspace)
6291 if (image->matte != MagickFalse)
6294 normalize=MagickFalse;
6297 region.width=image->columns;
6300 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6301 for (i=2; i < items; i+=2)
6303 attribute=(char *) SvPV(ST(i-1),na);
6309 if (LocaleCompare(attribute,"geometry") == 0)
6311 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6314 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6321 if (LocaleCompare(attribute,"height") == 0)
6323 region.height=SvIV(ST(i));
6326 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6333 if (LocaleCompare(attribute,"map") == 0)
6338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6345 if (LocaleCompare(attribute,"normalize") == 0)
6347 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6351 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6355 normalize=option != 0 ? MagickTrue : MagickFalse;
6358 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6365 if (LocaleCompare(attribute,"width") == 0)
6367 region.width=SvIV(ST(i));
6370 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6377 if (LocaleCompare(attribute,"x") == 0)
6379 region.x=SvIV(ST(i));
6382 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6389 if (LocaleCompare(attribute,"y") == 0)
6391 region.y=SvIV(ST(i));
6394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6406 if (normalize != MagickFalse)
6411 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6412 region.height*sizeof(*pixels));
6413 if (pixels == (float *) NULL)
6415 ThrowPerlException(exception,ResourceLimitError,
6416 "MemoryAllocationFailed",PackageName);
6419 status=ExportImagePixels(image,region.x,region.y,region.width,
6420 region.height,map,FloatPixel,pixels,exception);
6421 if (status == MagickFalse)
6425 EXTEND(sp,strlen(map)*region.width*region.height);
6426 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6427 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6429 pixels=(float *) RelinquishMagickMemory(pixels);
6436 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6437 region.height*sizeof(*pixels));
6438 if (pixels == (Quantum *) NULL)
6440 ThrowPerlException(exception,ResourceLimitError,
6441 "MemoryAllocationFailed",PackageName);
6444 status=ExportImagePixels(image,region.x,region.y,region.width,
6445 region.height,map,QuantumPixel,pixels,exception);
6446 if (status == MagickFalse)
6450 EXTEND(sp,strlen(map)*region.width*region.height);
6451 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6452 PUSHs(sv_2mortal(newSViv(pixels[i])));
6454 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6458 InheritPerlException(exception,perl_exception);
6459 exception=DestroyExceptionInfo(exception);
6460 SvREFCNT_dec(perl_exception);
6464 ###############################################################################
6468 # I m a g e T o B l o b #
6472 ###############################################################################
6476 ImageToBlob(ref,...)
6477 Image::Magick ref=NO_INIT
6486 filename[MaxTextExtent];
6515 PERL_UNUSED_VAR(ref);
6516 PERL_UNUSED_VAR(ix);
6517 exception=AcquireExceptionInfo();
6518 perl_exception=newSVpv("",0);
6519 package_info=(struct PackageInfo *) NULL;
6520 if (sv_isobject(ST(0)) == 0)
6522 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6526 reference=SvRV(ST(0));
6527 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6528 if (image == (Image *) NULL)
6530 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6534 package_info=ClonePackageInfo(info,exception);
6535 for (i=2; i < items; i+=2)
6536 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6537 (void) CopyMagickString(filename,package_info->image_info->filename,
6540 for (next=image; next; next=next->next)
6542 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6543 next->scene=scene++;
6545 SetImageInfo(package_info->image_info,(unsigned int)
6546 GetImageListLength(image),&image->exception);
6547 EXTEND(sp,(ssize_t) GetImageListLength(image));
6548 for ( ; image; image=image->next)
6551 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6552 if (blob != (char *) NULL)
6554 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6555 blob=(unsigned char *) RelinquishMagickMemory(blob);
6557 if (package_info->image_info->adjoin)
6562 if (package_info != (struct PackageInfo *) NULL)
6563 DestroyPackageInfo(package_info);
6564 InheritPerlException(exception,perl_exception);
6565 exception=DestroyExceptionInfo(exception);
6566 SvREFCNT_dec(perl_exception); /* throw away all errors */
6570 ###############################################################################
6578 ###############################################################################
6583 Image::Magick ref=NO_INIT
6587 OptimizeImageLayers = 3
6589 optimizeimagelayers = 5
6631 PERL_UNUSED_VAR(ref);
6632 PERL_UNUSED_VAR(ix);
6633 exception=AcquireExceptionInfo();
6634 perl_exception=newSVpv("",0);
6636 if (sv_isobject(ST(0)) == 0)
6638 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6642 reference=SvRV(ST(0));
6643 hv=SvSTASH(reference);
6645 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6647 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6648 if (image == (Image *) NULL)
6650 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6654 compose=image->compose;
6655 method=OptimizeLayer;
6656 for (i=2; i < items; i+=2)
6658 attribute=(char *) SvPV(ST(i-1),na);
6664 if (LocaleCompare(attribute,"compose") == 0)
6666 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6667 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6670 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6674 compose=(CompositeOperator) sp;
6677 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6684 if (LocaleCompare(attribute,"method") == 0)
6686 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6690 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6694 method=(ImageLayerMethod) option;
6697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6703 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6709 layers=(Image *) NULL;
6712 case CompareAnyLayer:
6713 case CompareClearLayer:
6714 case CompareOverlayLayer:
6717 layers=CompareImagesLayers(image,method,exception);
6724 layers=MergeImageLayers(image,method,exception);
6729 layers=DisposeImages(image,exception);
6732 case OptimizeImageLayer:
6734 layers=OptimizeImageLayers(image,exception);
6737 case OptimizePlusLayer:
6739 layers=OptimizePlusImageLayers(image,exception);
6742 case OptimizeTransLayer:
6744 OptimizeImageTransparency(image,exception);
6745 InheritException(&(image->exception),exception);
6748 case RemoveDupsLayer:
6750 RemoveDuplicateLayers(&image,exception);
6751 InheritException(&(image->exception),exception);
6754 case RemoveZeroLayer:
6756 RemoveZeroDelayLayers(&image,exception);
6757 InheritException(&(image->exception),exception);
6766 General Purpose, GIF Animation Optimizer.
6768 layers=CoalesceImages(image,exception);
6769 if (layers == (Image *) NULL)
6771 InheritException(&(layers->exception),exception);
6773 layers=OptimizeImageLayers(image,exception);
6774 if (layers == (Image *) NULL)
6776 InheritException(&(layers->exception),exception);
6777 image=DestroyImageList(image);
6779 layers=(Image *) NULL;
6780 OptimizeImageTransparency(image,exception);
6781 InheritException(&(image->exception),exception);
6782 quantize_info=AcquireQuantizeInfo(info->image_info);
6783 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6784 quantize_info=DestroyQuantizeInfo(quantize_info);
6787 case CompositeLayer:
6796 Split image sequence at the first 'NULL:' image.
6799 while (source != (Image *) NULL)
6801 source=GetNextImageInList(source);
6802 if ((source != (Image *) NULL) &&
6803 (LocaleCompare(source->magick,"NULL") == 0))
6806 if (source != (Image *) NULL)
6808 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6809 (GetNextImageInList(source) == (Image *) NULL))
6810 source=(Image *) NULL;
6814 Separate the two lists, junk the null: image.
6816 source=SplitImageList(source->previous);
6817 DeleteImageFromList(&source);
6820 if (source == (Image *) NULL)
6822 (void) ThrowMagickException(exception,GetMagickModule(),
6823 OptionError,"MissingNullSeparator","layers Composite");
6827 Adjust offset with gravity and virtual canvas.
6829 SetGeometry(image,&geometry);
6830 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6831 geometry.width=source->page.width != 0 ? source->page.width :
6833 geometry.height=source->page.height != 0 ? source->page.height :
6835 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6836 image->columns,image->page.height != 0 ? image->page.height :
6837 image->rows,image->gravity,&geometry);
6838 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6839 source=DestroyImageList(source);
6840 InheritException(&(image->exception),exception);
6844 if (layers != (Image *) NULL)
6846 InheritException(&(layers->exception),exception);
6849 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6851 for ( ; image; image=image->next)
6853 AddImageToRegistry(sv,image);
6855 av_push(av,sv_bless(rv,hv));
6858 exception=DestroyExceptionInfo(exception);
6860 SvREFCNT_dec(perl_exception);
6864 InheritPerlException(exception,perl_exception);
6865 exception=DestroyExceptionInfo(exception);
6866 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6867 SvPOK_on(perl_exception);
6868 ST(0)=sv_2mortal(perl_exception);
6873 ###############################################################################
6877 # M a g i c k T o M i m e #
6881 ###############################################################################
6885 MagickToMime(ref,name)
6886 Image::Magick ref=NO_INIT
6895 PERL_UNUSED_VAR(ref);
6896 PERL_UNUSED_VAR(ix);
6897 mime=MagickToMime(name);
6898 RETVAL=newSVpv(mime,0);
6899 mime=(char *) RelinquishMagickMemory(mime);
6905 ###############################################################################
6913 ###############################################################################
6918 Image::Magick ref=NO_INIT
6955 MedianConvolveImage = 36
6961 ReduceNoiseImage = 42
6987 ColorFloodfillImage= 68
6993 CycleColormapImage = 74
7003 MatteFloodfillImage= 84
7011 NumberColorsImage = 92
7021 SignatureImage = 102
7031 TransparentImage = 112
7033 ThresholdImage = 114
7047 DeconstructImage = 130
7049 GaussianBlurImage = 132
7055 UnsharpMaskImage = 138
7057 MotionBlurImage = 140
7059 OrderedDitherImage = 142
7066 AffineTransform = 149
7067 AffineTransformImage = 150
7069 DifferenceImage = 152
7070 AdaptiveThreshold = 153
7071 AdaptiveThresholdImage = 154
7076 BlackThreshold = 159
7077 BlackThresholdImage= 160
7078 WhiteThreshold = 161
7079 WhiteThresholdImage= 162
7081 RadialBlurImage = 164
7083 ThumbnailImage = 166
7093 PosterizeImage = 176
7099 SepiaToneImage = 182
7100 SigmoidalContrast = 183
7101 SigmoidalContrastImage = 184
7106 ContrastStretch = 189
7107 ContrastStretchImage = 190
7112 AdaptiveSharpen = 195
7113 AdaptiveSharpenImage = 196
7115 TransposeImage = 198
7117 TransverseImage = 200
7119 AutoOrientImage = 202
7121 AdaptiveBlurImage = 204
7125 UniqueColorsImage = 208
7126 AdaptiveResize = 209
7127 AdaptiveResizeImage= 210
7131 LinearStretchImage = 214
7138 FloodfillPaint = 221
7139 FloodfillPaintImage= 222
7145 LiquidRescaleImage = 228
7155 SparseColorImage = 238
7159 SelectiveBlurImage = 242
7163 BlueShiftImage = 246
7164 ForwardFourierTransform = 247
7165 ForwardFourierTransformImage = 248
7166 InverseFourierTransform = 249
7167 InverseFourierTransformImage = 250
7168 ColorDecisionList = 251
7169 ColorDecisionListImage = 252
7171 AutoGammaImage = 254
7173 AutoLevelImage = 256
7175 LevelImageColors = 258
7178 BrightnessContrast = 263
7179 BrightnessContrastImage = 264
7181 MorphologyImage = 266
7183 ColorMatrixImage = 268
7189 StatisticImage = 274
7198 attribute_flag[MaxArguments],
7199 message[MaxTextExtent];
7260 argument_list[MaxArguments];
7262 PERL_UNUSED_VAR(ref);
7263 PERL_UNUSED_VAR(ix);
7264 exception=AcquireExceptionInfo();
7265 perl_exception=newSVpv("",0);
7266 reference_vector=NULL;
7270 if (sv_isobject(ST(0)) == 0)
7272 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7276 reference=SvRV(ST(0));
7277 region_info.width=0;
7278 region_info.height=0;
7281 region_image=(Image *) NULL;
7282 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7283 if (ix && (ix != 666))
7286 Called as Method(...)
7289 rp=(&Methods[ix-1]);
7295 Called as Mogrify("Method",...)
7297 attribute=(char *) SvPV(ST(1),na);
7300 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7301 attribute=(char *) SvPV(ST(2),na);
7304 for (rp=Methods; ; rp++)
7306 if (rp >= EndOf(Methods))
7308 ThrowPerlException(exception,OptionError,
7309 "UnrecognizedPerlMagickMethod",attribute);
7312 if (strEQcase(attribute,rp->name))
7318 if (image == (Image *) NULL)
7320 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7323 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7324 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7325 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7342 pp=(Arguments *) NULL;
7350 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7352 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7354 if (strEQcase(attribute,qq->method) > ssize_test)
7357 ssize_test=strEQcase(attribute,qq->method);
7360 if (pp == (Arguments *) NULL)
7362 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7364 goto continue_outer_loop;
7366 al=(&argument_list[pp-rp->arguments]);
7369 case ArrayReference:
7371 if (SvTYPE(sv) != SVt_RV)
7373 (void) FormatLocaleString(message,MaxTextExtent,
7374 "invalid %.60s value",pp->method);
7375 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7376 goto continue_outer_loop;
7378 al->array_reference=SvRV(sv);
7383 al->real_reference=SvNV(sv);
7388 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7391 case ImageReference:
7393 if (!sv_isobject(sv) ||
7394 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7395 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7397 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7403 case IntegerReference:
7405 al->integer_reference=SvIV(sv);
7408 case StringReference:
7410 al->string_reference=(char *) SvPV(sv,al->length);
7411 if (sv_isobject(sv))
7412 al->image_reference=SetupList(aTHX_ SvRV(sv),
7413 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7419 Is a string; look up name.
7421 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7423 al->string_reference=(char *) SvPV(sv,al->length);
7424 al->integer_reference=(-1);
7427 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7428 MagickFalse,SvPV(sv,na));
7429 if (pp->type == MagickChannelOptions)
7430 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7431 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7433 (void) FormatLocaleString(message,MaxTextExtent,
7434 "invalid %.60s value",pp->method);
7435 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7436 goto continue_outer_loop;
7441 attribute_flag[pp-rp->arguments]++;
7442 continue_outer_loop: ;
7444 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7445 pv=reference_vector;
7446 SetGeometryInfo(&geometry_info);
7447 channel=DefaultChannels;
7448 for (next=image; next; next=next->next)
7451 SetGeometry(image,&geometry);
7452 if ((region_info.width*region_info.height) != 0)
7455 image=CropImage(image,®ion_info,exception);
7461 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7462 ThrowPerlException(exception,OptionError,
7463 "UnrecognizedPerlMagickMethod",message);
7466 case 1: /* Comment */
7468 if (attribute_flag[0] == 0)
7469 argument_list[0].string_reference=(char *) NULL;
7470 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7471 info ? info->image_info : (ImageInfo *) NULL,image,
7472 argument_list[0].string_reference,exception));
7477 if (attribute_flag[0] == 0)
7478 argument_list[0].string_reference=(char *) NULL;
7479 (void) SetImageProperty(image,"label",InterpretImageProperties(
7480 info ? info->image_info : (ImageInfo *) NULL,image,
7481 argument_list[0].string_reference,exception));
7484 case 3: /* AddNoise */
7486 if (attribute_flag[0] == 0)
7487 argument_list[0].integer_reference=UniformNoise;
7488 if (attribute_flag[1] != 0)
7489 channel=(ChannelType) argument_list[1].integer_reference;
7490 channel_mask=SetPixelChannelMask(image,channel);
7491 image=AddNoiseImage(image,(NoiseType)
7492 argument_list[0].integer_reference,exception);
7493 if (image != (Image *) NULL)
7494 (void) SetPixelChannelMask(image,channel_mask);
7497 case 4: /* Colorize */
7502 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7503 if (attribute_flag[0] != 0)
7504 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7506 if (attribute_flag[1] == 0)
7507 argument_list[1].string_reference="100%";
7508 image=ColorizeImage(image,argument_list[1].string_reference,target,
7512 case 5: /* Border */
7516 if (attribute_flag[0] != 0)
7518 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7519 &geometry,exception);
7520 if ((flags & HeightValue) == 0)
7521 geometry.height=geometry.width;
7523 if (attribute_flag[1] != 0)
7524 geometry.width=argument_list[1].integer_reference;
7525 if (attribute_flag[2] != 0)
7526 geometry.height=argument_list[2].integer_reference;
7527 if (attribute_flag[3] != 0)
7528 QueryColorDatabase(argument_list[3].string_reference,
7529 &image->border_color,exception);
7530 if (attribute_flag[4] != 0)
7531 QueryColorDatabase(argument_list[4].string_reference,
7532 &image->border_color,exception);
7533 if (attribute_flag[5] != 0)
7534 QueryColorDatabase(argument_list[5].string_reference,
7535 &image->border_color,exception);
7536 if (attribute_flag[6] != 0)
7537 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7538 image=BorderImage(image,&geometry,exception);
7543 if (attribute_flag[0] != 0)
7545 flags=ParseGeometry(argument_list[0].string_reference,
7547 if ((flags & SigmaValue) == 0)
7548 geometry_info.sigma=1.0;
7550 if (attribute_flag[1] != 0)
7551 geometry_info.rho=argument_list[1].real_reference;
7552 if (attribute_flag[2] != 0)
7553 geometry_info.sigma=argument_list[2].real_reference;
7554 if (attribute_flag[3] != 0)
7555 channel=(ChannelType) argument_list[3].integer_reference;
7556 channel_mask=SetPixelChannelMask(image,channel);
7557 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7559 if (image != (Image *) NULL)
7560 (void) SetPixelChannelMask(image,channel_mask);
7565 if (attribute_flag[0] != 0)
7566 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7567 &geometry,exception);
7568 if (attribute_flag[1] != 0)
7569 geometry.width=argument_list[1].integer_reference;
7570 if (attribute_flag[2] != 0)
7571 geometry.height=argument_list[2].integer_reference;
7572 if (attribute_flag[3] != 0)
7573 geometry.x=argument_list[3].integer_reference;
7574 if (attribute_flag[4] != 0)
7575 geometry.y=argument_list[4].integer_reference;
7576 image=ChopImage(image,&geometry,exception);
7581 if (attribute_flag[6] != 0)
7582 image->gravity=(GravityType) argument_list[6].integer_reference;
7583 if (attribute_flag[0] != 0)
7584 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7585 &geometry,exception);
7586 if (attribute_flag[1] != 0)
7587 geometry.width=argument_list[1].integer_reference;
7588 if (attribute_flag[2] != 0)
7589 geometry.height=argument_list[2].integer_reference;
7590 if (attribute_flag[3] != 0)
7591 geometry.x=argument_list[3].integer_reference;
7592 if (attribute_flag[4] != 0)
7593 geometry.y=argument_list[4].integer_reference;
7594 if (attribute_flag[5] != 0)
7596 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7597 image=CropImage(image,&geometry,exception);
7600 case 9: /* Despeckle */
7602 image=DespeckleImage(image,exception);
7607 if (attribute_flag[0] != 0)
7608 geometry_info.rho=argument_list[0].real_reference;
7609 image=EdgeImage(image,geometry_info.rho,exception);
7612 case 11: /* Emboss */
7614 if (attribute_flag[0] != 0)
7616 flags=ParseGeometry(argument_list[0].string_reference,
7618 if ((flags & SigmaValue) == 0)
7619 geometry_info.sigma=1.0;
7621 if (attribute_flag[1] != 0)
7622 geometry_info.rho=argument_list[1].real_reference;
7623 if (attribute_flag[2] != 0)
7624 geometry_info.sigma=argument_list[2].real_reference;
7625 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7629 case 12: /* Enhance */
7631 image=EnhanceImage(image,exception);
7636 image=FlipImage(image,exception);
7641 image=FlopImage(image,exception);
7644 case 15: /* Frame */
7649 if (attribute_flag[0] != 0)
7651 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7652 &geometry,exception);
7653 if ((flags & HeightValue) == 0)
7654 geometry.height=geometry.width;
7655 frame_info.width=geometry.width;
7656 frame_info.height=geometry.height;
7657 frame_info.outer_bevel=geometry.x;
7658 frame_info.inner_bevel=geometry.y;
7660 if (attribute_flag[1] != 0)
7661 frame_info.width=argument_list[1].integer_reference;
7662 if (attribute_flag[2] != 0)
7663 frame_info.height=argument_list[2].integer_reference;
7664 if (attribute_flag[3] != 0)
7665 frame_info.inner_bevel=argument_list[3].integer_reference;
7666 if (attribute_flag[4] != 0)
7667 frame_info.outer_bevel=argument_list[4].integer_reference;
7668 if (attribute_flag[5] != 0)
7669 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7671 if (attribute_flag[6] != 0)
7672 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7674 frame_info.x=(ssize_t) frame_info.width;
7675 frame_info.y=(ssize_t) frame_info.height;
7676 frame_info.width=image->columns+2*frame_info.x;
7677 frame_info.height=image->rows+2*frame_info.y;
7678 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7679 image->matte_color=fill_color;
7680 if (attribute_flag[7] != 0)
7681 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7682 image=FrameImage(image,&frame_info,exception);
7685 case 16: /* Implode */
7687 if (attribute_flag[0] == 0)
7688 argument_list[0].real_reference=0.5;
7689 if (attribute_flag[1] != 0)
7690 image->interpolate=(InterpolatePixelMethod)
7691 argument_list[1].integer_reference;
7692 image=ImplodeImage(image,argument_list[0].real_reference,
7696 case 17: /* Magnify */
7698 image=MagnifyImage(image,exception);
7701 case 18: /* MedianFilter */
7703 if (attribute_flag[0] != 0)
7705 flags=ParseGeometry(argument_list[0].string_reference,
7707 if ((flags & SigmaValue) == 0)
7708 geometry_info.sigma=1.0;
7710 if (attribute_flag[1] != 0)
7711 geometry_info.rho=argument_list[1].real_reference;
7712 if (attribute_flag[2] != 0)
7713 geometry_info.sigma=argument_list[2].real_reference;
7714 if (attribute_flag[3] != 0)
7715 channel=(ChannelType) argument_list[3].integer_reference;
7716 channel_mask=SetPixelChannelMask(image,channel);
7717 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7718 (size_t) geometry_info.sigma,exception);
7719 if (image != (Image *) NULL)
7720 (void) SetPixelChannelMask(image,channel_mask);
7723 case 19: /* Minify */
7725 image=MinifyImage(image,exception);
7728 case 20: /* OilPaint */
7730 if (attribute_flag[0] == 0)
7731 argument_list[0].real_reference=0.0;
7732 if (attribute_flag[1] == 0)
7733 argument_list[1].real_reference=1.0;
7734 image=OilPaintImage(image,argument_list[0].real_reference,
7735 argument_list[1].real_reference,exception);
7738 case 21: /* ReduceNoise */
7740 if (attribute_flag[0] != 0)
7742 flags=ParseGeometry(argument_list[0].string_reference,
7744 if ((flags & SigmaValue) == 0)
7745 geometry_info.sigma=1.0;
7747 if (attribute_flag[1] != 0)
7748 geometry_info.rho=argument_list[1].real_reference;
7749 if (attribute_flag[2] != 0)
7750 geometry_info.sigma=argument_list[2].real_reference;
7751 if (attribute_flag[3] != 0)
7752 channel=(ChannelType) argument_list[3].integer_reference;
7753 channel_mask=SetPixelChannelMask(image,channel);
7754 image=StatisticImage(image,NonpeakStatistic,(size_t)
7755 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7756 if (image != (Image *) NULL)
7757 (void) SetPixelChannelMask(image,channel_mask);
7762 if (attribute_flag[0] != 0)
7763 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7764 &geometry,exception);
7765 if (attribute_flag[1] != 0)
7766 geometry.x=argument_list[1].integer_reference;
7767 if (attribute_flag[2] != 0)
7768 geometry.y=argument_list[2].integer_reference;
7769 image=RollImage(image,geometry.x,geometry.y,exception);
7772 case 23: /* Rotate */
7774 if (attribute_flag[0] == 0)
7775 argument_list[0].real_reference=90.0;
7776 if (attribute_flag[1] != 0)
7777 QueryColorDatabase(argument_list[1].string_reference,
7778 &image->background_color,exception);
7779 if (attribute_flag[2] != 0)
7780 QueryColorDatabase(argument_list[2].string_reference,
7781 &image->background_color,exception);
7782 if (attribute_flag[3] != 0)
7783 QueryColorDatabase(argument_list[3].string_reference,
7784 &image->background_color,exception);
7785 image=RotateImage(image,argument_list[0].real_reference,exception);
7788 case 24: /* Sample */
7790 if (attribute_flag[0] != 0)
7791 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7792 &geometry,exception);
7793 if (attribute_flag[1] != 0)
7794 geometry.width=argument_list[1].integer_reference;
7795 if (attribute_flag[2] != 0)
7796 geometry.height=argument_list[2].integer_reference;
7797 image=SampleImage(image,geometry.width,geometry.height,exception);
7800 case 25: /* Scale */
7802 if (attribute_flag[0] != 0)
7803 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7804 &geometry,exception);
7805 if (attribute_flag[1] != 0)
7806 geometry.width=argument_list[1].integer_reference;
7807 if (attribute_flag[2] != 0)
7808 geometry.height=argument_list[2].integer_reference;
7809 image=ScaleImage(image,geometry.width,geometry.height,exception);
7812 case 26: /* Shade */
7814 if (attribute_flag[0] != 0)
7816 flags=ParseGeometry(argument_list[0].string_reference,
7818 if ((flags & SigmaValue) == 0)
7819 geometry_info.sigma=0.0;
7821 if (attribute_flag[1] != 0)
7822 geometry_info.rho=argument_list[1].real_reference;
7823 if (attribute_flag[2] != 0)
7824 geometry_info.sigma=argument_list[2].real_reference;
7825 image=ShadeImage(image,
7826 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7827 geometry_info.rho,geometry_info.sigma,exception);
7830 case 27: /* Sharpen */
7832 if (attribute_flag[0] != 0)
7834 flags=ParseGeometry(argument_list[0].string_reference,
7836 if ((flags & SigmaValue) == 0)
7837 geometry_info.sigma=1.0;
7839 if (attribute_flag[1] != 0)
7840 geometry_info.rho=argument_list[1].real_reference;
7841 if (attribute_flag[2] != 0)
7842 geometry_info.sigma=argument_list[2].real_reference;
7843 if (attribute_flag[3] != 0)
7844 channel=(ChannelType) argument_list[3].integer_reference;
7845 channel_mask=SetPixelChannelMask(image,channel);
7846 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7848 if (image != (Image *) NULL)
7849 (void) SetPixelChannelMask(image,channel_mask);
7852 case 28: /* Shear */
7854 if (attribute_flag[0] != 0)
7856 flags=ParseGeometry(argument_list[0].string_reference,
7858 if ((flags & SigmaValue) == 0)
7859 geometry_info.sigma=geometry_info.rho;
7861 if (attribute_flag[1] != 0)
7862 geometry_info.rho=argument_list[1].real_reference;
7863 if (attribute_flag[2] != 0)
7864 geometry_info.sigma=argument_list[2].real_reference;
7865 if (attribute_flag[3] != 0)
7866 QueryColorDatabase(argument_list[3].string_reference,
7867 &image->background_color,exception);
7868 if (attribute_flag[4] != 0)
7869 QueryColorDatabase(argument_list[4].string_reference,
7870 &image->background_color,exception);
7871 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7875 case 29: /* Spread */
7877 if (attribute_flag[0] == 0)
7878 argument_list[0].real_reference=1.0;
7879 image=SpreadImage(image,argument_list[0].real_reference,exception);
7882 case 30: /* Swirl */
7884 if (attribute_flag[0] == 0)
7885 argument_list[0].real_reference=50.0;
7886 if (attribute_flag[1] != 0)
7887 image->interpolate=(InterpolatePixelMethod)
7888 argument_list[1].integer_reference;
7889 image=SwirlImage(image,argument_list[0].real_reference,exception);
7892 case 31: /* Resize */
7895 if (attribute_flag[0] != 0)
7896 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7897 &geometry,exception);
7898 if (attribute_flag[1] != 0)
7899 geometry.width=argument_list[1].integer_reference;
7900 if (attribute_flag[2] != 0)
7901 geometry.height=argument_list[2].integer_reference;
7902 if (attribute_flag[3] == 0)
7903 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7904 if (attribute_flag[4] != 0)
7905 SetImageArtifact(image,"filter:support",
7906 argument_list[4].string_reference);
7907 if (attribute_flag[5] == 0)
7908 argument_list[5].real_reference=1.0;
7909 image=ResizeImage(image,geometry.width,geometry.height,
7910 (FilterTypes) argument_list[3].integer_reference,
7911 argument_list[5].real_reference,exception);
7914 case 33: /* Annotate */
7919 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7921 if (attribute_flag[0] != 0)
7926 text=InterpretImageProperties(info ? info->image_info :
7927 (ImageInfo *) NULL,image,argument_list[0].string_reference,
7929 (void) CloneString(&draw_info->text,text);
7930 text=DestroyString(text);
7932 if (attribute_flag[1] != 0)
7933 (void) CloneString(&draw_info->font,
7934 argument_list[1].string_reference);
7935 if (attribute_flag[2] != 0)
7936 draw_info->pointsize=argument_list[2].real_reference;
7937 if (attribute_flag[3] != 0)
7938 (void) CloneString(&draw_info->density,
7939 argument_list[3].string_reference);
7940 if (attribute_flag[4] != 0)
7941 (void) QueryColorDatabase(argument_list[4].string_reference,
7942 &draw_info->undercolor,exception);
7943 if (attribute_flag[5] != 0)
7945 (void) QueryColorDatabase(argument_list[5].string_reference,
7946 &draw_info->stroke,exception);
7947 if (argument_list[5].image_reference != (Image *) NULL)
7948 draw_info->stroke_pattern=CloneImage(
7949 argument_list[5].image_reference,0,0,MagickTrue,exception);
7951 if (attribute_flag[6] != 0)
7953 (void) QueryColorDatabase(argument_list[6].string_reference,
7954 &draw_info->fill,exception);
7955 if (argument_list[6].image_reference != (Image *) NULL)
7956 draw_info->fill_pattern=CloneImage(
7957 argument_list[6].image_reference,0,0,MagickTrue,exception);
7959 if (attribute_flag[7] != 0)
7961 (void) CloneString(&draw_info->geometry,
7962 argument_list[7].string_reference);
7963 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7964 &geometry,exception);
7965 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7966 geometry_info.sigma=geometry_info.xi;
7968 if (attribute_flag[8] != 0)
7969 (void) QueryColorDatabase(argument_list[8].string_reference,
7970 &draw_info->fill,exception);
7971 if (attribute_flag[11] != 0)
7972 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7973 if (attribute_flag[25] != 0)
7978 av=(AV *) argument_list[25].array_reference;
7979 if ((av_len(av) != 3) && (av_len(av) != 5))
7981 ThrowPerlException(exception,OptionError,
7982 "affine matrix must have 4 or 6 elements",PackageName);
7985 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7986 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7987 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7988 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7989 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7990 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7992 ThrowPerlException(exception,OptionError,
7993 "affine matrix is singular",PackageName);
7996 if (av_len(av) == 5)
7998 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
7999 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8002 for (j=12; j < 17; j++)
8004 if (attribute_flag[j] == 0)
8006 value=argument_list[j].string_reference;
8007 angle=argument_list[j].real_reference;
8008 current=draw_info->affine;
8009 GetAffineMatrix(&affine);
8017 flags=ParseGeometry(value,&geometry_info);
8018 affine.tx=geometry_info.xi;
8019 affine.ty=geometry_info.psi;
8020 if ((flags & PsiValue) == 0)
8021 affine.ty=affine.tx;
8029 flags=ParseGeometry(value,&geometry_info);
8030 affine.sx=geometry_info.rho;
8031 affine.sy=geometry_info.sigma;
8032 if ((flags & SigmaValue) == 0)
8033 affine.sy=affine.sx;
8043 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8044 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8045 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8046 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8054 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8062 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8066 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8067 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8068 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8069 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8070 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8072 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8075 if (attribute_flag[9] == 0)
8076 argument_list[9].real_reference=0.0;
8077 if (attribute_flag[10] == 0)
8078 argument_list[10].real_reference=0.0;
8079 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8082 geometry[MaxTextExtent];
8084 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8085 (double) argument_list[9].real_reference+draw_info->affine.tx,
8086 (double) argument_list[10].real_reference+draw_info->affine.ty);
8087 (void) CloneString(&draw_info->geometry,geometry);
8089 if (attribute_flag[17] != 0)
8090 draw_info->stroke_width=argument_list[17].real_reference;
8091 if (attribute_flag[18] != 0)
8093 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8094 MagickTrue : MagickFalse;
8095 draw_info->stroke_antialias=draw_info->text_antialias;
8097 if (attribute_flag[19] != 0)
8098 (void) CloneString(&draw_info->family,
8099 argument_list[19].string_reference);
8100 if (attribute_flag[20] != 0)
8101 draw_info->style=(StyleType) argument_list[20].integer_reference;
8102 if (attribute_flag[21] != 0)
8103 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8104 if (attribute_flag[22] != 0)
8105 draw_info->weight=argument_list[22].integer_reference;
8106 if (attribute_flag[23] != 0)
8107 draw_info->align=(AlignType) argument_list[23].integer_reference;
8108 if (attribute_flag[24] != 0)
8109 (void) CloneString(&draw_info->encoding,
8110 argument_list[24].string_reference);
8111 if (attribute_flag[25] != 0)
8112 draw_info->fill_pattern=CloneImage(
8113 argument_list[25].image_reference,0,0,MagickTrue,exception);
8114 if (attribute_flag[26] != 0)
8115 draw_info->fill_pattern=CloneImage(
8116 argument_list[26].image_reference,0,0,MagickTrue,exception);
8117 if (attribute_flag[27] != 0)
8118 draw_info->stroke_pattern=CloneImage(
8119 argument_list[27].image_reference,0,0,MagickTrue,exception);
8120 if (attribute_flag[29] != 0)
8121 draw_info->kerning=argument_list[29].real_reference;
8122 if (attribute_flag[30] != 0)
8123 draw_info->interline_spacing=argument_list[30].real_reference;
8124 if (attribute_flag[31] != 0)
8125 draw_info->interword_spacing=argument_list[31].real_reference;
8126 if (attribute_flag[32] != 0)
8127 draw_info->direction=(DirectionType)
8128 argument_list[32].integer_reference;
8129 (void) AnnotateImage(image,draw_info,exception);
8130 draw_info=DestroyDrawInfo(draw_info);
8133 case 34: /* ColorFloodfill */
8144 draw_info=CloneDrawInfo(info ? info->image_info :
8145 (ImageInfo *) NULL,(DrawInfo *) NULL);
8146 if (attribute_flag[0] != 0)
8147 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8148 &geometry,exception);
8149 if (attribute_flag[1] != 0)
8150 geometry.x=argument_list[1].integer_reference;
8151 if (attribute_flag[2] != 0)
8152 geometry.y=argument_list[2].integer_reference;
8153 if (attribute_flag[3] != 0)
8154 (void) QueryColorDatabase(argument_list[3].string_reference,
8155 &draw_info->fill,exception);
8156 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8159 if (attribute_flag[4] != 0)
8161 QueryMagickColor(argument_list[4].string_reference,&target,
8165 if (attribute_flag[5] != 0)
8166 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8168 if (attribute_flag[6] != 0)
8169 invert=(MagickBooleanType) argument_list[6].integer_reference;
8170 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8171 geometry.y,invert,exception);
8172 draw_info=DestroyDrawInfo(draw_info);
8175 case 35: /* Composite */
8178 composite_geometry[MaxTextExtent];
8184 compose=OverCompositeOp;
8185 if (attribute_flag[0] != 0)
8186 composite_image=argument_list[0].image_reference;
8189 ThrowPerlException(exception,OptionError,
8190 "CompositeImageRequired",PackageName);
8194 Parameter Handling used for BOTH normal and tiled composition.
8196 if (attribute_flag[1] != 0) /* compose */
8197 compose=(CompositeOperator) argument_list[1].integer_reference;
8198 if (attribute_flag[6] != 0) /* opacity */
8200 if (compose != DissolveCompositeOp)
8201 (void) SetImageOpacity(composite_image,(Quantum)
8202 SiPrefixToDouble(argument_list[6].string_reference,
8225 Handle dissolve composite operator (patch by
8228 (void) CloneString(&image->geometry,
8229 argument_list[6].string_reference);
8230 opacity=(Quantum) SiPrefixToDouble(
8231 argument_list[6].string_reference,QuantumRange);
8232 if (composite_image->matte != MagickTrue)
8233 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8234 composite_view=AcquireCacheView(composite_image);
8235 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8237 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8238 composite_image->columns,1,exception);
8239 for (x=0; x < (ssize_t) composite_image->columns; x++)
8241 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8242 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8243 q+=GetPixelChannels(composite_image);
8245 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8246 if (sync == MagickFalse)
8249 composite_view=DestroyCacheView(composite_view);
8252 if (attribute_flag[9] != 0) /* "color=>" */
8253 QueryColorDatabase(argument_list[9].string_reference,
8254 &composite_image->background_color,exception);
8255 if (attribute_flag[12] != 0) /* "interpolate=>" */
8256 image->interpolate=(InterpolatePixelMethod)
8257 argument_list[12].integer_reference;
8258 if (attribute_flag[13] != 0) /* "args=>" */
8259 (void) SetImageArtifact(composite_image,"compose:args",
8260 argument_list[13].string_reference);
8261 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8262 (void) SetImageArtifact(composite_image,"compose:args",
8263 argument_list[14].string_reference);
8265 Tiling Composition (with orthogonal rotate).
8267 rotate_image=(Image *) NULL;
8268 if (attribute_flag[8] != 0) /* "rotate=>" */
8273 rotate_image=RotateImage(composite_image,
8274 argument_list[8].real_reference,exception);
8275 if (rotate_image == (Image *) NULL)
8278 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8285 Tile the composite image.
8287 if (attribute_flag[8] != 0) /* "tile=>" */
8288 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8291 (void) SetImageArtifact(composite_image,
8292 "compose:outside-overlay","false");
8293 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8294 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8296 if (attribute_flag[8] != 0) /* rotate */
8297 (void) CompositeImage(image,compose,rotate_image,x,y);
8299 (void) CompositeImage(image,compose,composite_image,x,y);
8301 if (attribute_flag[8] != 0) /* rotate */
8302 rotate_image=DestroyImage(rotate_image);
8306 Parameter Handling used used ONLY for normal composition.
8308 if (attribute_flag[5] != 0) /* gravity */
8309 image->gravity=(GravityType) argument_list[5].integer_reference;
8310 if (attribute_flag[2] != 0) /* geometry offset */
8312 SetGeometry(image,&geometry);
8313 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8315 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8318 if (attribute_flag[3] != 0) /* x offset */
8319 geometry.x=argument_list[3].integer_reference;
8320 if (attribute_flag[4] != 0) /* y offset */
8321 geometry.y=argument_list[4].integer_reference;
8322 if (attribute_flag[10] != 0) /* mask */
8324 if ((image->compose == DisplaceCompositeOp) ||
8325 (image->compose == DistortCompositeOp))
8328 Merge Y displacement into X displacement image.
8330 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8332 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8333 argument_list[10].image_reference,0,0);
8338 Set a blending mask for the composition.
8340 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8341 MagickTrue,&image->exception);
8342 (void) NegateImage(image->mask,MagickFalse,exception);
8345 if (attribute_flag[11] != 0) /* channel */
8346 channel=(ChannelType) argument_list[11].integer_reference;
8348 Composite two images (normal composition).
8350 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8351 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8352 (double) composite_image->rows,(double) geometry.x,(double)
8354 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8356 channel_mask=SetPixelChannelMask(image,channel);
8357 if (attribute_flag[8] == 0) /* no rotate */
8358 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8362 Position adjust rotated image then composite.
8364 geometry.x-=(ssize_t) (rotate_image->columns-
8365 composite_image->columns)/2;
8366 geometry.y-=(ssize_t) (rotate_image->rows-
8367 composite_image->rows)/2;
8368 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8369 rotate_image=DestroyImage(rotate_image);
8371 if (attribute_flag[10] != 0) /* mask */
8373 if ((image->compose == DisplaceCompositeOp) ||
8374 (image->compose == DistortCompositeOp))
8375 composite_image=DestroyImage(composite_image);
8377 image->mask=DestroyImage(image->mask);
8379 (void) SetPixelChannelMask(image,channel_mask);
8382 case 36: /* Contrast */
8384 if (attribute_flag[0] == 0)
8385 argument_list[0].integer_reference=0;
8386 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8387 MagickTrue : MagickFalse,exception);
8390 case 37: /* CycleColormap */
8392 if (attribute_flag[0] == 0)
8393 argument_list[0].integer_reference=6;
8394 (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,exception);
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 channel_mask=SetPixelChannelMask(image,channel);
8644 EqualizeImage(image,exception);
8645 (void) SetPixelChannelMask(image,channel_mask);
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,exception);
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 channel_mask=SetPixelChannelMask(image,AlphaChannel);
8730 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8731 geometry.y,invert,exception);
8732 (void) SetPixelChannelMask(image,channel_mask);
8733 draw_info=DestroyDrawInfo(draw_info);
8736 case 43: /* Modulate */
8739 modulate[MaxTextExtent];
8741 geometry_info.rho=100.0;
8742 geometry_info.sigma=100.0;
8743 geometry_info.xi=100.0;
8744 if (attribute_flag[0] != 0)
8745 (void)ParseGeometry(argument_list[0].string_reference,
8747 if (attribute_flag[1] != 0)
8748 geometry_info.xi=argument_list[1].real_reference;
8749 if (attribute_flag[2] != 0)
8750 geometry_info.sigma=argument_list[2].real_reference;
8751 if (attribute_flag[3] != 0)
8753 geometry_info.sigma=argument_list[3].real_reference;
8754 SetImageArtifact(image,"modulate:colorspace","HWB");
8756 if (attribute_flag[4] != 0)
8758 geometry_info.rho=argument_list[4].real_reference;
8759 SetImageArtifact(image,"modulate:colorspace","HSB");
8761 if (attribute_flag[5] != 0)
8763 geometry_info.sigma=argument_list[5].real_reference;
8764 SetImageArtifact(image,"modulate:colorspace","HSL");
8766 if (attribute_flag[6] != 0)
8768 geometry_info.rho=argument_list[6].real_reference;
8769 SetImageArtifact(image,"modulate:colorspace","HWB");
8771 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8772 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8773 (void) ModulateImage(image,modulate,exception);
8776 case 44: /* Negate */
8778 if (attribute_flag[0] == 0)
8779 argument_list[0].integer_reference=0;
8780 if (attribute_flag[1] != 0)
8781 channel=(ChannelType) argument_list[1].integer_reference;
8782 channel_mask=SetPixelChannelMask(image,channel);
8783 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8784 MagickTrue : MagickFalse,exception);
8785 (void) SetPixelChannelMask(image,channel_mask);
8788 case 45: /* Normalize */
8790 if (attribute_flag[0] != 0)
8791 channel=(ChannelType) argument_list[0].integer_reference;
8792 channel_mask=SetPixelChannelMask(image,channel);
8793 NormalizeImage(image,exception);
8794 (void) SetPixelChannelMask(image,channel_mask);
8797 case 46: /* NumberColors */
8799 case 47: /* Opaque */
8808 (void) QueryMagickColor("none",&target,exception);
8809 (void) QueryMagickColor("none",&fill_color,exception);
8810 if (attribute_flag[0] != 0)
8811 (void) QueryMagickColor(argument_list[0].string_reference,
8813 if (attribute_flag[1] != 0)
8814 (void) QueryMagickColor(argument_list[1].string_reference,
8815 &fill_color,exception);
8816 if (attribute_flag[2] != 0)
8817 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8819 if (attribute_flag[3] != 0)
8820 channel=(ChannelType) argument_list[3].integer_reference;
8822 if (attribute_flag[4] != 0)
8823 invert=(MagickBooleanType) argument_list[4].integer_reference;
8824 channel_mask=SetPixelChannelMask(image,channel);
8825 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
8826 (void) SetPixelChannelMask(image,channel_mask);
8829 case 48: /* Quantize */
8834 quantize_info=AcquireQuantizeInfo(info->image_info);
8835 if (attribute_flag[0] != 0)
8836 quantize_info->number_colors=(size_t)
8837 argument_list[0].integer_reference;
8838 if (attribute_flag[1] != 0)
8839 quantize_info->tree_depth=(size_t)
8840 argument_list[1].integer_reference;
8841 if (attribute_flag[2] != 0)
8842 quantize_info->colorspace=(ColorspaceType)
8843 argument_list[2].integer_reference;
8844 if (attribute_flag[3] != 0)
8845 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8846 MagickTrue : MagickFalse;
8847 if (attribute_flag[4] != 0)
8848 quantize_info->measure_error=
8849 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8850 if (attribute_flag[5] != 0)
8851 (void) QueryColorDatabase(argument_list[5].string_reference,
8852 &image->transparent_color,exception);
8853 if (attribute_flag[5] && argument_list[5].integer_reference)
8855 (void) QuantizeImages(quantize_info,image,exception);
8858 if (attribute_flag[6] != 0)
8859 quantize_info->dither_method=(DitherMethod)
8860 argument_list[6].integer_reference;
8861 if ((image->storage_class == DirectClass) ||
8862 (image->colors > quantize_info->number_colors) ||
8863 (quantize_info->colorspace == GRAYColorspace))
8864 (void) QuantizeImage(quantize_info,image,exception);
8866 CompressImageColormap(image,exception);
8867 quantize_info=DestroyQuantizeInfo(quantize_info);
8870 case 49: /* Raise */
8872 if (attribute_flag[0] != 0)
8873 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8874 &geometry,exception);
8875 if (attribute_flag[1] != 0)
8876 geometry.width=argument_list[1].integer_reference;
8877 if (attribute_flag[2] != 0)
8878 geometry.height=argument_list[2].integer_reference;
8879 if (attribute_flag[3] == 0)
8880 argument_list[3].integer_reference=1;
8881 (void) RaiseImage(image,&geometry,
8882 argument_list[3].integer_reference != 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,exception);
8923 case 51: /* Signature */
8925 (void) SignatureImage(image,exception);
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(
8936 argument_list[1].string_reference,QuantumRange);
8937 (void) SolarizeImage(image,geometry_info.rho,exception);
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 channel_mask=SetPixelChannelMask(image,channel);
8965 (void) EvaluateImage(image,op,argument_list[0].real_reference,
8967 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(image,channel);
9013 (void) BilevelImage(image,threshold);
9014 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(image,channel);
9067 (void) SeparateImage(image);
9068 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(image,channel);
9122 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9124 if (image != (Image *) NULL)
9125 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(image,channel);
9177 kernel->bias=image->bias;
9178 image=ConvolveImage(image,kernel,exception);
9179 if (image != (Image *) NULL)
9180 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(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 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(image,channel);
9305 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9306 geometry_info.xi,exception);
9307 if (image != (Image *) NULL)
9308 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(image,channel);
9318 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9320 (void) SetPixelChannelMask(image,channel_mask);
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 channel_mask=SetPixelChannelMask(image,channel);
9376 (void) LevelImage(image,black_point,white_point,gamma,exception);
9377 (void) SetPixelChannelMask(image,channel_mask);
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,
9391 case 75: /* AffineTransform */
9396 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9398 if (attribute_flag[0] != 0)
9403 av=(AV *) argument_list[0].array_reference;
9404 if ((av_len(av) != 3) && (av_len(av) != 5))
9406 ThrowPerlException(exception,OptionError,
9407 "affine matrix must have 4 or 6 elements",PackageName);
9410 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9411 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9412 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9413 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9414 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9415 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9417 ThrowPerlException(exception,OptionError,
9418 "affine matrix is singular",PackageName);
9421 if (av_len(av) == 5)
9423 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9424 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9427 for (j=1; j < 6; j++)
9429 if (attribute_flag[j] == 0)
9431 value=argument_list[j].string_reference;
9432 angle=argument_list[j].real_reference;
9433 current=draw_info->affine;
9434 GetAffineMatrix(&affine);
9442 flags=ParseGeometry(value,&geometry_info);
9443 affine.tx=geometry_info.xi;
9444 affine.ty=geometry_info.psi;
9445 if ((flags & PsiValue) == 0)
9446 affine.ty=affine.tx;
9454 flags=ParseGeometry(value,&geometry_info);
9455 affine.sx=geometry_info.rho;
9456 affine.sy=geometry_info.sigma;
9457 if ((flags & SigmaValue) == 0)
9458 affine.sy=affine.sx;
9468 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9469 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9470 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9471 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9479 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9487 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9491 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9492 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9493 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9494 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9495 draw_info->affine.tx=
9496 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9497 draw_info->affine.ty=
9498 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9500 if (attribute_flag[6] != 0)
9501 image->interpolate=(InterpolatePixelMethod)
9502 argument_list[6].integer_reference;
9503 if (attribute_flag[7] != 0)
9504 QueryColorDatabase(argument_list[7].string_reference,
9505 &image->background_color,exception);
9506 image=AffineTransformImage(image,&draw_info->affine,exception);
9507 draw_info=DestroyDrawInfo(draw_info);
9510 case 76: /* Difference */
9512 if (attribute_flag[0] == 0)
9514 ThrowPerlException(exception,OptionError,
9515 "ReferenceImageRequired",PackageName);
9518 if (attribute_flag[1] != 0)
9519 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9521 (void) IsImagesEqual(image,argument_list[0].image_reference,
9525 case 77: /* AdaptiveThreshold */
9527 if (attribute_flag[0] != 0)
9529 flags=ParseGeometry(argument_list[0].string_reference,
9531 if ((flags & PercentValue) != 0)
9532 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9534 if (attribute_flag[1] != 0)
9535 geometry_info.rho=argument_list[1].integer_reference;
9536 if (attribute_flag[2] != 0)
9537 geometry_info.sigma=argument_list[2].integer_reference;
9538 if (attribute_flag[3] != 0)
9539 geometry_info.xi=argument_list[3].integer_reference;;
9540 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9541 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9544 case 78: /* Resample */
9550 if (attribute_flag[0] != 0)
9552 flags=ParseGeometry(argument_list[0].string_reference,
9554 if ((flags & SigmaValue) == 0)
9555 geometry_info.sigma=geometry_info.rho;
9557 if (attribute_flag[1] != 0)
9558 geometry_info.rho=argument_list[1].real_reference;
9559 if (attribute_flag[2] != 0)
9560 geometry_info.sigma=argument_list[2].real_reference;
9561 if (attribute_flag[3] == 0)
9562 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9563 if (attribute_flag[4] == 0)
9564 SetImageArtifact(image,"filter:support",
9565 argument_list[4].string_reference);
9566 if (attribute_flag[5] != 0)
9567 argument_list[5].real_reference=1.0;
9568 width=(size_t) (geometry_info.rho*image->columns/
9569 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9570 height=(size_t) (geometry_info.sigma*image->rows/
9571 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9572 image=ResizeImage(image,width,height,(FilterTypes)
9573 argument_list[3].integer_reference,argument_list[5].real_reference,
9575 if (image != (Image *) NULL)
9577 image->x_resolution=geometry_info.rho;
9578 image->y_resolution=geometry_info.sigma;
9582 case 79: /* Describe */
9584 if (attribute_flag[0] == 0)
9585 argument_list[0].file_reference=(FILE *) NULL;
9586 if (attribute_flag[1] != 0)
9587 (void) SetImageArtifact(image,"identify:features",
9588 argument_list[1].string_reference);
9589 (void) IdentifyImage(image,argument_list[0].file_reference,
9590 MagickTrue,exception);
9593 case 80: /* BlackThreshold */
9595 if (attribute_flag[0] == 0)
9596 argument_list[0].string_reference="50%";
9597 if (attribute_flag[2] != 0)
9598 channel=(ChannelType) argument_list[2].integer_reference;
9599 channel_mask=SetPixelChannelMask(image,channel);
9600 BlackThresholdImage(image,argument_list[0].string_reference,
9602 (void) SetPixelChannelMask(image,channel_mask);
9605 case 81: /* WhiteThreshold */
9607 if (attribute_flag[0] == 0)
9608 argument_list[0].string_reference="50%";
9609 if (attribute_flag[2] != 0)
9610 channel=(ChannelType) argument_list[2].integer_reference;
9611 channel_mask=SetPixelChannelMask(image,channel);
9612 WhiteThresholdImage(image,argument_list[0].string_reference,
9614 (void) SetPixelChannelMask(image,channel_mask);
9617 case 82: /* RadialBlur */
9619 if (attribute_flag[0] != 0)
9621 flags=ParseGeometry(argument_list[0].string_reference,
9623 if ((flags & SigmaValue) == 0)
9624 geometry_info.sigma=1.0;
9626 if (attribute_flag[1] != 0)
9627 geometry_info.rho=argument_list[1].real_reference;
9628 if (attribute_flag[2] != 0)
9629 channel=(ChannelType) argument_list[2].integer_reference;
9630 channel_mask=SetPixelChannelMask(image,channel);
9631 image=RadialBlurImage(image,geometry_info.rho,exception);
9632 if (image != (Image *) NULL)
9633 (void) SetPixelChannelMask(image,channel_mask);
9636 case 83: /* Thumbnail */
9638 if (attribute_flag[0] != 0)
9639 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9640 &geometry,exception);
9641 if (attribute_flag[1] != 0)
9642 geometry.width=argument_list[1].integer_reference;
9643 if (attribute_flag[2] != 0)
9644 geometry.height=argument_list[2].integer_reference;
9645 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9648 case 84: /* Strip */
9650 (void) StripImage(image);
9658 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9659 if (attribute_flag[0] != 0)
9660 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9662 if (attribute_flag[1] == 0)
9663 argument_list[1].string_reference="100";
9664 image=TintImage(image,argument_list[1].string_reference,target,
9668 case 86: /* Channel */
9670 if (attribute_flag[0] != 0)
9671 channel=(ChannelType) argument_list[0].integer_reference;
9672 channel_mask=SetPixelChannelMask(image,channel);
9673 (void) SeparateImage(image);
9674 (void) SetPixelChannelMask(image,channel_mask);
9677 case 87: /* Splice */
9679 if (attribute_flag[0] != 0)
9680 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9681 &geometry,exception);
9682 if (attribute_flag[1] != 0)
9683 geometry.width=argument_list[1].integer_reference;
9684 if (attribute_flag[2] != 0)
9685 geometry.height=argument_list[2].integer_reference;
9686 if (attribute_flag[3] != 0)
9687 geometry.x=argument_list[3].integer_reference;
9688 if (attribute_flag[4] != 0)
9689 geometry.y=argument_list[4].integer_reference;
9690 if (attribute_flag[5] != 0)
9691 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9693 if (attribute_flag[6] != 0)
9694 (void) QueryColorDatabase(argument_list[6].string_reference,
9695 &image->background_color,exception);
9696 if (attribute_flag[7] != 0)
9697 image->gravity=(GravityType) argument_list[7].integer_reference;
9698 image=SpliceImage(image,&geometry,exception);
9701 case 88: /* Posterize */
9703 if (attribute_flag[0] == 0)
9704 argument_list[0].integer_reference=3;
9705 if (attribute_flag[1] == 0)
9706 argument_list[1].integer_reference=0;
9707 (void) PosterizeImage(image,argument_list[0].integer_reference,
9708 argument_list[1].integer_reference ? MagickTrue : MagickFalse,
9712 case 89: /* Shadow */
9714 if (attribute_flag[0] != 0)
9716 flags=ParseGeometry(argument_list[0].string_reference,
9718 if ((flags & SigmaValue) == 0)
9719 geometry_info.sigma=1.0;
9720 if ((flags & XiValue) == 0)
9721 geometry_info.xi=4.0;
9722 if ((flags & PsiValue) == 0)
9723 geometry_info.psi=4.0;
9725 if (attribute_flag[1] != 0)
9726 geometry_info.rho=argument_list[1].real_reference;
9727 if (attribute_flag[2] != 0)
9728 geometry_info.sigma=argument_list[2].real_reference;
9729 if (attribute_flag[3] != 0)
9730 geometry_info.xi=argument_list[3].integer_reference;
9731 if (attribute_flag[4] != 0)
9732 geometry_info.psi=argument_list[4].integer_reference;
9733 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9734 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9738 case 90: /* Identify */
9740 if (attribute_flag[0] == 0)
9741 argument_list[0].file_reference=(FILE *) NULL;
9742 if (attribute_flag[1] != 0)
9743 (void) SetImageArtifact(image,"identify:features",
9744 argument_list[1].string_reference);
9745 if ((attribute_flag[2] != 0) &&
9746 (argument_list[2].integer_reference != 0))
9747 (void) SetImageArtifact(image,"identify:unique","true");
9748 (void) IdentifyImage(image,argument_list[0].file_reference,
9749 MagickTrue,exception);
9752 case 91: /* SepiaTone */
9754 if (attribute_flag[0] == 0)
9755 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9756 image=SepiaToneImage(image,argument_list[0].real_reference,
9760 case 92: /* SigmoidalContrast */
9765 if (attribute_flag[0] != 0)
9767 flags=ParseGeometry(argument_list[0].string_reference,
9769 if ((flags & SigmaValue) == 0)
9770 geometry_info.sigma=QuantumRange/2.0;
9771 if ((flags & PercentValue) != 0)
9772 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9774 if (attribute_flag[1] != 0)
9775 geometry_info.rho=argument_list[1].real_reference;
9776 if (attribute_flag[2] != 0)
9777 geometry_info.sigma=argument_list[2].real_reference;
9778 if (attribute_flag[3] != 0)
9779 channel=(ChannelType) argument_list[3].integer_reference;
9781 if (attribute_flag[4] != 0)
9782 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9784 channel_mask=SetPixelChannelMask(image,channel);
9785 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9786 geometry_info.sigma,exception);
9787 (void) SetPixelChannelMask(image,channel_mask);
9790 case 93: /* Extent */
9792 if (attribute_flag[7] != 0)
9793 image->gravity=(GravityType) argument_list[7].integer_reference;
9794 if (attribute_flag[0] != 0)
9799 flags=ParseGravityGeometry(image,
9800 argument_list[0].string_reference,&geometry,exception);
9802 if (geometry.width == 0)
9803 geometry.width=image->columns;
9804 if (geometry.height == 0)
9805 geometry.height=image->rows;
9807 if (attribute_flag[1] != 0)
9808 geometry.width=argument_list[1].integer_reference;
9809 if (attribute_flag[2] != 0)
9810 geometry.height=argument_list[2].integer_reference;
9811 if (attribute_flag[3] != 0)
9812 geometry.x=argument_list[3].integer_reference;
9813 if (attribute_flag[4] != 0)
9814 geometry.y=argument_list[4].integer_reference;
9815 if (attribute_flag[5] != 0)
9816 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9818 if (attribute_flag[6] != 0)
9819 (void) QueryColorDatabase(argument_list[6].string_reference,
9820 &image->background_color,exception);
9821 image=ExtentImage(image,&geometry,exception);
9824 case 94: /* Vignette */
9826 if (attribute_flag[0] != 0)
9828 flags=ParseGeometry(argument_list[0].string_reference,
9830 if ((flags & SigmaValue) == 0)
9831 geometry_info.sigma=1.0;
9832 if ((flags & XiValue) == 0)
9833 geometry_info.xi=0.1*image->columns;
9834 if ((flags & PsiValue) == 0)
9835 geometry_info.psi=0.1*image->rows;
9837 if (attribute_flag[1] != 0)
9838 geometry_info.rho=argument_list[1].real_reference;
9839 if (attribute_flag[2] != 0)
9840 geometry_info.sigma=argument_list[2].real_reference;
9841 if (attribute_flag[3] != 0)
9842 geometry_info.xi=argument_list[3].integer_reference;
9843 if (attribute_flag[4] != 0)
9844 geometry_info.psi=argument_list[4].integer_reference;
9845 if (attribute_flag[5] != 0)
9846 (void) QueryColorDatabase(argument_list[5].string_reference,
9847 &image->background_color,exception);
9848 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9849 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9853 case 95: /* ContrastStretch */
9860 white_point=(MagickRealType) image->columns*image->rows;
9861 if (attribute_flag[0] != 0)
9863 flags=ParseGeometry(argument_list[0].string_reference,
9865 black_point=geometry_info.rho;
9866 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9868 if ((flags & PercentValue) != 0)
9870 black_point*=(double) image->columns*image->rows/100.0;
9871 white_point*=(double) image->columns*image->rows/100.0;
9873 white_point=(MagickRealType) image->columns*image->rows-
9876 if (attribute_flag[1] != 0)
9877 black_point=argument_list[1].real_reference;
9878 if (attribute_flag[2] != 0)
9879 white_point=argument_list[2].real_reference;
9880 if (attribute_flag[4] != 0)
9881 channel=(ChannelType) argument_list[4].integer_reference;
9882 channel_mask=SetPixelChannelMask(image,channel);
9883 (void) ContrastStretchImage(image,black_point,white_point,exception);
9884 (void) SetPixelChannelMask(image,channel_mask);
9887 case 96: /* Sans0 */
9891 case 97: /* Sans1 */
9895 case 98: /* AdaptiveSharpen */
9897 if (attribute_flag[0] != 0)
9899 flags=ParseGeometry(argument_list[0].string_reference,
9901 if ((flags & SigmaValue) == 0)
9902 geometry_info.sigma=1.0;
9904 if (attribute_flag[1] != 0)
9905 geometry_info.rho=argument_list[1].real_reference;
9906 if (attribute_flag[2] != 0)
9907 geometry_info.sigma=argument_list[2].real_reference;
9908 if (attribute_flag[3] != 0)
9909 channel=(ChannelType) argument_list[3].integer_reference;
9910 channel_mask=SetPixelChannelMask(image,channel);
9911 image=AdaptiveSharpenImage(image,geometry_info.rho,
9912 geometry_info.sigma,exception);
9913 if (image != (Image *) NULL)
9914 (void) SetPixelChannelMask(image,channel_mask);
9917 case 99: /* Transpose */
9919 image=TransposeImage(image,exception);
9922 case 100: /* Tranverse */
9924 image=TransverseImage(image,exception);
9927 case 101: /* AutoOrient */
9929 switch (image->orientation)
9931 case TopRightOrientation:
9933 image=FlopImage(image,exception);
9936 case BottomRightOrientation:
9938 image=RotateImage(image,180.0,exception);
9941 case BottomLeftOrientation:
9943 image=FlipImage(image,exception);
9946 case LeftTopOrientation:
9948 image=TransposeImage(image,exception);
9951 case RightTopOrientation:
9953 image=RotateImage(image,90.0,exception);
9956 case RightBottomOrientation:
9958 image=TransverseImage(image,exception);
9961 case LeftBottomOrientation:
9963 image=RotateImage(image,270.0,exception);
9971 case 102: /* AdaptiveBlur */
9973 if (attribute_flag[0] != 0)
9975 flags=ParseGeometry(argument_list[0].string_reference,
9977 if ((flags & SigmaValue) == 0)
9978 geometry_info.sigma=1.0;
9980 if (attribute_flag[1] != 0)
9981 geometry_info.rho=argument_list[1].real_reference;
9982 if (attribute_flag[2] != 0)
9983 geometry_info.sigma=argument_list[2].real_reference;
9984 if (attribute_flag[3] != 0)
9985 channel=(ChannelType) argument_list[3].integer_reference;
9986 channel_mask=SetPixelChannelMask(image,channel);
9987 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
9989 if (image != (Image *) NULL)
9990 (void) SetPixelChannelMask(image,channel_mask);
9993 case 103: /* Sketch */
9995 if (attribute_flag[0] != 0)
9997 flags=ParseGeometry(argument_list[0].string_reference,
9999 if ((flags & SigmaValue) == 0)
10000 geometry_info.sigma=1.0;
10001 if ((flags & XiValue) == 0)
10002 geometry_info.xi=1.0;
10004 if (attribute_flag[1] != 0)
10005 geometry_info.rho=argument_list[1].real_reference;
10006 if (attribute_flag[2] != 0)
10007 geometry_info.sigma=argument_list[2].real_reference;
10008 if (attribute_flag[3] != 0)
10009 geometry_info.xi=argument_list[3].real_reference;
10010 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10011 geometry_info.xi,exception);
10014 case 104: /* UniqueColors */
10016 image=UniqueImageColors(image,exception);
10019 case 105: /* AdaptiveResize */
10021 if (attribute_flag[0] != 0)
10022 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10023 &geometry,exception);
10024 if (attribute_flag[1] != 0)
10025 geometry.width=argument_list[1].integer_reference;
10026 if (attribute_flag[2] != 0)
10027 geometry.height=argument_list[2].integer_reference;
10028 if (attribute_flag[3] != 0)
10029 image->filter=(FilterTypes) argument_list[4].integer_reference;
10030 if (attribute_flag[4] != 0)
10031 SetImageArtifact(image,"filter:support",
10032 argument_list[4].string_reference);
10033 if (attribute_flag[5] != 0)
10034 image->blur=argument_list[5].real_reference;
10035 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10039 case 106: /* ClipMask */
10041 if (attribute_flag[0] == 0)
10043 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10045 goto PerlException;
10047 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10048 MagickTrue,exception);
10049 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10052 case 107: /* LinearStretch */
10059 white_point=(MagickRealType) image->columns*image->rows;
10060 if (attribute_flag[0] != 0)
10062 flags=ParseGeometry(argument_list[0].string_reference,
10064 if ((flags & SigmaValue) != 0)
10065 white_point=geometry_info.sigma;
10066 if ((flags & PercentValue) != 0)
10068 black_point*=(double) image->columns*image->rows/100.0;
10069 white_point*=(double) image->columns*image->rows/100.0;
10071 if ((flags & SigmaValue) == 0)
10072 white_point=(double) image->columns*image->rows-black_point;
10074 if (attribute_flag[1] != 0)
10075 black_point=argument_list[1].real_reference;
10076 if (attribute_flag[2] != 0)
10077 white_point=argument_list[2].real_reference;
10078 (void) LinearStretchImage(image,black_point,white_point,exception);
10081 case 109: /* Mask */
10083 if (attribute_flag[0] == 0)
10085 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10087 goto PerlException;
10089 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10090 MagickTrue,exception);
10091 (void) NegateImage(image->mask,MagickFalse,exception);
10094 case 110: /* Polaroid */
10102 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10103 (DrawInfo *) NULL);
10104 if (attribute_flag[0] != 0)
10105 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10106 info ? info->image_info : (ImageInfo *) NULL,image,
10107 argument_list[0].string_reference,exception));
10109 if (attribute_flag[1] != 0)
10110 angle=argument_list[1].real_reference;
10111 if (attribute_flag[2] != 0)
10112 (void) CloneString(&draw_info->font,
10113 argument_list[2].string_reference);
10114 if (attribute_flag[3] != 0)
10115 (void) QueryColorDatabase(argument_list[3].string_reference,
10116 &draw_info->stroke,exception);
10117 if (attribute_flag[4] != 0)
10118 (void) QueryColorDatabase(argument_list[4].string_reference,
10119 &draw_info->fill,exception);
10120 if (attribute_flag[5] != 0)
10121 draw_info->stroke_width=argument_list[5].real_reference;
10122 if (attribute_flag[6] != 0)
10123 draw_info->pointsize=argument_list[6].real_reference;
10124 if (attribute_flag[7] != 0)
10125 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10126 if (attribute_flag[8] != 0)
10127 (void) QueryColorDatabase(argument_list[8].string_reference,
10128 &image->background_color,exception);
10129 image=PolaroidImage(image,draw_info,angle,exception);
10130 draw_info=DestroyDrawInfo(draw_info);
10133 case 111: /* FloodfillPaint */
10144 draw_info=CloneDrawInfo(info ? info->image_info :
10145 (ImageInfo *) NULL,(DrawInfo *) NULL);
10146 if (attribute_flag[0] != 0)
10147 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10148 &geometry,exception);
10149 if (attribute_flag[1] != 0)
10150 geometry.x=argument_list[1].integer_reference;
10151 if (attribute_flag[2] != 0)
10152 geometry.y=argument_list[2].integer_reference;
10153 if (attribute_flag[3] != 0)
10154 (void) QueryColorDatabase(argument_list[3].string_reference,
10155 &draw_info->fill,exception);
10156 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10158 if (attribute_flag[4] != 0)
10159 QueryMagickColor(argument_list[4].string_reference,&target,
10161 if (attribute_flag[5] != 0)
10162 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10164 if (attribute_flag[6] != 0)
10165 channel=(ChannelType) argument_list[6].integer_reference;
10166 invert=MagickFalse;
10167 if (attribute_flag[7] != 0)
10168 invert=(MagickBooleanType) argument_list[7].integer_reference;
10169 channel_mask=SetPixelChannelMask(image,channel);
10170 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10171 geometry.y,invert,exception);
10172 (void) SetPixelChannelMask(image,channel_mask);
10173 draw_info=DestroyDrawInfo(draw_info);
10176 case 112: /* Distort */
10188 number_coordinates;
10193 if (attribute_flag[0] == 0)
10195 method=UndefinedDistortion;
10196 if (attribute_flag[1] != 0)
10197 method=(DistortImageMethod) argument_list[1].integer_reference;
10198 av=(AV *) argument_list[0].array_reference;
10199 number_coordinates=(size_t) av_len(av)+1;
10200 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10201 sizeof(*coordinates));
10202 if (coordinates == (double *) NULL)
10204 ThrowPerlException(exception,ResourceLimitFatalError,
10205 "MemoryAllocationFailed",PackageName);
10206 goto PerlException;
10208 for (j=0; j < (ssize_t) number_coordinates; j++)
10209 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10210 virtual_pixel=UndefinedVirtualPixelMethod;
10211 if (attribute_flag[2] != 0)
10212 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10213 argument_list[2].integer_reference);
10214 image=DistortImage(image,method,number_coordinates,coordinates,
10215 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10217 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10218 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10219 coordinates=(double *) RelinquishMagickMemory(coordinates);
10222 case 113: /* Clut */
10224 if (attribute_flag[0] == 0)
10226 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10228 goto PerlException;
10230 if (attribute_flag[1] != 0)
10231 channel=(ChannelType) argument_list[1].integer_reference;
10232 channel_mask=SetPixelChannelMask(image,channel);
10233 (void) ClutImage(image,argument_list[0].image_reference,exception);
10234 (void) SetPixelChannelMask(image,channel_mask);
10237 case 114: /* LiquidRescale */
10239 if (attribute_flag[0] != 0)
10240 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10241 &geometry,exception);
10242 if (attribute_flag[1] != 0)
10243 geometry.width=argument_list[1].integer_reference;
10244 if (attribute_flag[2] != 0)
10245 geometry.height=argument_list[2].integer_reference;
10246 if (attribute_flag[3] == 0)
10247 argument_list[3].real_reference=1.0;
10248 if (attribute_flag[4] == 0)
10249 argument_list[4].real_reference=0.0;
10250 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10251 argument_list[3].real_reference,argument_list[4].real_reference,
10255 case 115: /* EncipherImage */
10257 (void) EncipherImage(image,argument_list[0].string_reference,
10261 case 116: /* DecipherImage */
10263 (void) DecipherImage(image,argument_list[0].string_reference,
10267 case 117: /* Deskew */
10269 geometry_info.rho=QuantumRange/2.0;
10270 if (attribute_flag[0] != 0)
10271 flags=ParseGeometry(argument_list[0].string_reference,
10273 if (attribute_flag[1] != 0)
10274 geometry_info.rho=SiPrefixToDouble(
10275 argument_list[1].string_reference,QuantumRange);
10276 image=DeskewImage(image,geometry_info.rho,exception);
10279 case 118: /* Remap */
10284 if (attribute_flag[0] == 0)
10286 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10288 goto PerlException;
10290 quantize_info=AcquireQuantizeInfo(info->image_info);
10291 if (attribute_flag[1] != 0)
10292 quantize_info->dither=(MagickBooleanType)
10293 argument_list[1].integer_reference;
10294 if (attribute_flag[2] != 0)
10295 quantize_info->dither_method=(DitherMethod)
10296 argument_list[2].integer_reference;
10297 (void) RemapImages(quantize_info,image,
10298 argument_list[0].image_reference,exception);
10299 quantize_info=DestroyQuantizeInfo(quantize_info);
10302 case 119: /* SparseColor */
10314 number_coordinates;
10319 if (attribute_flag[0] == 0)
10321 method=UndefinedColorInterpolate;
10322 if (attribute_flag[1] != 0)
10323 method=(SparseColorMethod) argument_list[1].integer_reference;
10324 av=(AV *) argument_list[0].array_reference;
10325 number_coordinates=(size_t) av_len(av)+1;
10326 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10327 sizeof(*coordinates));
10328 if (coordinates == (double *) NULL)
10330 ThrowPerlException(exception,ResourceLimitFatalError,
10331 "MemoryAllocationFailed",PackageName);
10332 goto PerlException;
10334 for (j=0; j < (ssize_t) number_coordinates; j++)
10335 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10336 virtual_pixel=UndefinedVirtualPixelMethod;
10337 if (attribute_flag[2] != 0)
10338 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10339 argument_list[2].integer_reference);
10340 if (attribute_flag[3] != 0)
10341 channel=(ChannelType) argument_list[3].integer_reference;
10342 channel_mask=SetPixelChannelMask(image,channel);
10343 image=SparseColorImage(image,method,number_coordinates,coordinates,
10345 if (image != (Image *) NULL)
10346 (void) SetPixelChannelMask(image,channel_mask);
10347 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10348 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10349 coordinates=(double *) RelinquishMagickMemory(coordinates);
10352 case 120: /* Function */
10369 if (attribute_flag[0] == 0)
10371 function=UndefinedFunction;
10372 if (attribute_flag[1] != 0)
10373 function=(MagickFunction) argument_list[1].integer_reference;
10374 av=(AV *) argument_list[0].array_reference;
10375 number_parameters=(size_t) av_len(av)+1;
10376 parameters=(double *) AcquireQuantumMemory(number_parameters,
10377 sizeof(*parameters));
10378 if (parameters == (double *) NULL)
10380 ThrowPerlException(exception,ResourceLimitFatalError,
10381 "MemoryAllocationFailed",PackageName);
10382 goto PerlException;
10384 for (j=0; j < (ssize_t) number_parameters; j++)
10385 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10386 virtual_pixel=UndefinedVirtualPixelMethod;
10387 if (attribute_flag[2] != 0)
10388 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10389 argument_list[2].integer_reference);
10390 (void) FunctionImage(image,function,number_parameters,parameters,
10392 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10393 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10394 parameters=(double *) RelinquishMagickMemory(parameters);
10397 case 121: /* SelectiveBlur */
10399 if (attribute_flag[0] != 0)
10401 flags=ParseGeometry(argument_list[0].string_reference,
10403 if ((flags & SigmaValue) == 0)
10404 geometry_info.sigma=1.0;
10405 if ((flags & PercentValue) != 0)
10406 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10408 if (attribute_flag[1] != 0)
10409 geometry_info.rho=argument_list[1].real_reference;
10410 if (attribute_flag[2] != 0)
10411 geometry_info.sigma=argument_list[2].real_reference;
10412 if (attribute_flag[3] != 0)
10413 geometry_info.xi=argument_list[3].integer_reference;;
10414 if (attribute_flag[4] != 0)
10415 channel=(ChannelType) argument_list[4].integer_reference;
10416 channel_mask=SetPixelChannelMask(image,channel);
10417 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10418 geometry_info.xi,exception);
10419 if (image != (Image *) NULL)
10420 (void) SetPixelChannelMask(image,channel_mask);
10423 case 122: /* HaldClut */
10425 if (attribute_flag[0] == 0)
10427 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10429 goto PerlException;
10431 if (attribute_flag[1] != 0)
10432 channel=(ChannelType) argument_list[1].integer_reference;
10433 channel_mask=SetPixelChannelMask(image,channel);
10434 (void) HaldClutImage(image,argument_list[0].image_reference,
10436 (void) SetPixelChannelMask(image,channel_mask);
10439 case 123: /* BlueShift */
10441 if (attribute_flag[0] != 0)
10442 (void) ParseGeometry(argument_list[0].string_reference,
10444 image=BlueShiftImage(image,geometry_info.rho,exception);
10447 case 124: /* ForwardFourierTransformImage */
10449 image=ForwardFourierTransformImage(image,
10450 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10454 case 125: /* InverseFourierTransformImage */
10456 image=InverseFourierTransformImage(image,image->next,
10457 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10461 case 126: /* ColorDecisionList */
10463 if (attribute_flag[0] == 0)
10464 argument_list[0].string_reference=(char *) NULL;
10465 (void) ColorDecisionListImage(image,
10466 argument_list[0].string_reference,exception);
10469 case 127: /* AutoGamma */
10471 if (attribute_flag[0] != 0)
10472 channel=(ChannelType) argument_list[0].integer_reference;
10473 channel_mask=SetPixelChannelMask(image,channel);
10474 (void) AutoGammaImage(image,exception);
10475 (void) SetPixelChannelMask(image,channel_mask);
10478 case 128: /* AutoLevel */
10480 if (attribute_flag[0] != 0)
10481 channel=(ChannelType) argument_list[0].integer_reference;
10482 channel_mask=SetPixelChannelMask(image,channel);
10483 (void) AutoLevelImage(image,exception);
10484 (void) SetPixelChannelMask(image,channel_mask);
10487 case 129: /* LevelColors */
10493 (void) QueryMagickColor("#000000",&black_point,exception);
10494 (void) QueryMagickColor("#ffffff",&white_point,exception);
10495 if (attribute_flag[1] != 0)
10496 (void) QueryMagickColor(argument_list[1].string_reference,
10497 &black_point,exception);
10498 if (attribute_flag[2] != 0)
10499 (void) QueryMagickColor(argument_list[2].string_reference,
10500 &white_point,exception);
10501 if (attribute_flag[3] != 0)
10502 channel=(ChannelType) argument_list[3].integer_reference;
10503 channel_mask=SetPixelChannelMask(image,channel);
10504 (void) LevelImageColors(image,&black_point,&white_point,
10505 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10507 (void) SetPixelChannelMask(image,channel_mask);
10510 case 130: /* Clamp */
10512 if (attribute_flag[0] != 0)
10513 channel=(ChannelType) argument_list[0].integer_reference;
10514 channel_mask=SetPixelChannelMask(image,channel);
10515 (void) ClampImage(image);
10516 (void) SetPixelChannelMask(image,channel_mask);
10519 case 132: /* BrightnessContrast */
10527 if (attribute_flag[0] != 0)
10529 flags=ParseGeometry(argument_list[0].string_reference,
10531 brightness=geometry_info.rho;
10532 if ((flags & SigmaValue) == 0)
10533 contrast=geometry_info.sigma;
10535 if (attribute_flag[1] != 0)
10536 brightness=argument_list[1].real_reference;
10537 if (attribute_flag[2] != 0)
10538 contrast=argument_list[2].real_reference;
10539 if (attribute_flag[4] != 0)
10540 channel=(ChannelType) argument_list[4].integer_reference;
10541 channel_mask=SetPixelChannelMask(image,channel);
10542 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10543 (void) SetPixelChannelMask(image,channel_mask);
10546 case 133: /* Morphology */
10557 if (attribute_flag[0] == 0)
10559 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10560 if (kernel == (KernelInfo *) NULL)
10562 if (attribute_flag[1] != 0)
10563 channel=(ChannelType) argument_list[1].integer_reference;
10564 method=UndefinedMorphology;
10565 if (attribute_flag[2] != 0)
10566 method=argument_list[2].integer_reference;
10568 if (attribute_flag[3] != 0)
10569 iterations=argument_list[4].integer_reference;
10570 channel_mask=SetPixelChannelMask(image,channel);
10571 image=MorphologyImage(image,method,iterations,kernel,exception);
10572 if (image != (Image *) NULL)
10573 (void) SetPixelChannelMask(image,channel_mask);
10574 kernel=DestroyKernelInfo(kernel);
10577 case 108: /* Recolor */
10578 case 134: /* ColorMatrix */
10592 if (attribute_flag[0] == 0)
10594 av=(AV *) argument_list[0].array_reference;
10595 if (av == (AV *) NULL)
10597 order=(size_t) sqrt(av_len(av)+1);
10598 color_matrix=(double *) AcquireQuantumMemory(order,order*
10599 sizeof(*color_matrix));
10600 if (color_matrix == (double *) NULL)
10602 ThrowPerlException(exception,ResourceLimitFatalError,
10603 "MemoryAllocationFailed",PackageName);
10604 goto PerlException;
10606 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10607 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10608 for ( ; j < (ssize_t) (order*order); j++)
10609 color_matrix[j]=0.0;
10610 kernel_info=AcquireKernelInfo((const char *) NULL);
10611 if (kernel_info == (KernelInfo *) NULL)
10613 kernel_info->width=order;
10614 kernel_info->height=order;
10615 kernel_info->values=color_matrix;
10616 image=ColorMatrixImage(image,kernel_info,exception);
10617 kernel_info->values=(double *) NULL;
10618 kernel_info=DestroyKernelInfo(kernel_info);
10619 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10622 case 135: /* Color */
10627 (void) QueryMagickColor("none",&color,exception);
10628 if (attribute_flag[0] != 0)
10629 (void) QueryMagickColor(argument_list[0].string_reference,
10631 (void) SetImageColor(image,&color);
10634 case 136: /* Mode */
10636 if (attribute_flag[0] != 0)
10638 flags=ParseGeometry(argument_list[0].string_reference,
10640 if ((flags & SigmaValue) == 0)
10641 geometry_info.sigma=1.0;
10643 if (attribute_flag[1] != 0)
10644 geometry_info.rho=argument_list[1].real_reference;
10645 if (attribute_flag[2] != 0)
10646 geometry_info.sigma=argument_list[2].real_reference;
10647 if (attribute_flag[3] != 0)
10648 channel=(ChannelType) argument_list[3].integer_reference;
10649 channel_mask=SetPixelChannelMask(image,channel);
10650 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10651 (size_t) geometry_info.sigma,exception);
10652 if (image != (Image *) NULL)
10653 (void) SetPixelChannelMask(image,channel_mask);
10656 case 137: /* Statistic */
10661 statistic=UndefinedStatistic;
10662 if (attribute_flag[0] != 0)
10664 flags=ParseGeometry(argument_list[0].string_reference,
10666 if ((flags & SigmaValue) == 0)
10667 geometry_info.sigma=1.0;
10669 if (attribute_flag[1] != 0)
10670 geometry_info.rho=argument_list[1].real_reference;
10671 if (attribute_flag[2] != 0)
10672 geometry_info.sigma=argument_list[2].real_reference;
10673 if (attribute_flag[3] != 0)
10674 channel=(ChannelType) argument_list[3].integer_reference;
10675 if (attribute_flag[4] != 0)
10676 statistic=(StatisticType) argument_list[4].integer_reference;
10677 channel_mask=SetPixelChannelMask(image,channel);
10678 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10679 (size_t) geometry_info.sigma,exception);
10680 if (image != (Image *) NULL)
10681 (void) SetPixelChannelMask(image,channel_mask);
10685 if (next != (Image *) NULL)
10686 (void) CatchImageException(next);
10687 if (region_image != (Image *) NULL)
10692 status=CompositeImage(region_image,CopyCompositeOp,image,
10693 region_info.x,region_info.y);
10695 (void) CatchImageException(region_image);
10696 image=DestroyImage(image);
10697 image=region_image;
10699 if (image != (Image *) NULL)
10702 if (next && (next != image))
10704 image->next=next->next;
10705 if (image->next != (Image *) NULL)
10706 image->next->previous=image;
10707 DeleteImageFromRegistry(*pv,next);
10709 sv_setiv(*pv,(IV) image);
10717 if (reference_vector)
10718 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10719 InheritPerlException(exception,perl_exception);
10720 exception=DestroyExceptionInfo(exception);
10721 sv_setiv(perl_exception,(IV) number_images);
10722 SvPOK_on(perl_exception);
10723 ST(0)=sv_2mortal(perl_exception);
10728 ###############################################################################
10736 ###############################################################################
10741 Image::Magick ref=NO_INIT
10786 PERL_UNUSED_VAR(ref);
10787 PERL_UNUSED_VAR(ix);
10788 exception=AcquireExceptionInfo();
10789 perl_exception=newSVpv("",0);
10792 if (sv_isobject(ST(0)) == 0)
10794 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10796 goto PerlException;
10798 reference=SvRV(ST(0));
10799 hv=SvSTASH(reference);
10801 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10803 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10804 if (image == (Image *) NULL)
10806 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10808 goto PerlException;
10813 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10814 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10815 (void) QueryMagickColor("none",&transparent_color,exception);
10816 for (i=2; i < items; i+=2)
10818 attribute=(char *) SvPV(ST(i-1),na);
10819 switch (*attribute)
10824 if (LocaleCompare(attribute,"background") == 0)
10826 (void) QueryColorDatabase(SvPV(ST(i),na),
10827 &montage_info->background_color,exception);
10828 for (next=image; next; next=next->next)
10829 next->background_color=montage_info->background_color;
10832 if (LocaleCompare(attribute,"border") == 0)
10834 montage_info->border_width=SvIV(ST(i));
10837 if (LocaleCompare(attribute,"bordercolor") == 0)
10839 (void) QueryColorDatabase(SvPV(ST(i),na),
10840 &montage_info->border_color,exception);
10841 for (next=image; next; next=next->next)
10842 next->border_color=montage_info->border_color;
10845 if (LocaleCompare(attribute,"borderwidth") == 0)
10847 montage_info->border_width=SvIV(ST(i));
10850 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10857 if (LocaleCompare(attribute,"compose") == 0)
10859 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10860 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10863 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10867 for (next=image; next; next=next->next)
10868 next->compose=(CompositeOperator) sp;
10871 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10878 if (LocaleCompare(attribute,"fill") == 0)
10880 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10884 if (LocaleCompare(attribute,"font") == 0)
10886 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10889 if (LocaleCompare(attribute,"frame") == 0)
10895 if (IsGeometry(p) == MagickFalse)
10897 ThrowPerlException(exception,OptionError,"MissingGeometry",
10901 (void) CloneString(&montage_info->frame,p);
10903 montage_info->frame=(char *) NULL;
10906 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10913 if (LocaleCompare(attribute,"geometry") == 0)
10919 if (IsGeometry(p) == MagickFalse)
10921 ThrowPerlException(exception,OptionError,"MissingGeometry",
10925 (void) CloneString(&montage_info->geometry,p);
10927 montage_info->geometry=(char *) NULL;
10930 if (LocaleCompare(attribute,"gravity") == 0)
10935 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10936 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10939 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10943 montage_info->gravity=(GravityType) in;
10944 for (next=image; next; next=next->next)
10945 next->gravity=(GravityType) in;
10948 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10955 if (LocaleCompare(attribute,"label") == 0)
10957 for (next=image; next; next=next->next)
10958 (void) SetImageProperty(next,"label",InterpretImageProperties(
10959 info ? info->image_info : (ImageInfo *) NULL,next,
10960 SvPV(ST(i),na),exception));
10963 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10970 if (LocaleCompare(attribute,"mattecolor") == 0)
10972 (void) QueryColorDatabase(SvPV(ST(i),na),
10973 &montage_info->matte_color,exception);
10974 for (next=image; next; next=next->next)
10975 next->matte_color=montage_info->matte_color;
10978 if (LocaleCompare(attribute,"mode") == 0)
10983 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10984 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10989 ThrowPerlException(exception,OptionError,
10990 "UnrecognizedModeType",SvPV(ST(i),na));
10995 (void) CloneString(&montage_info->frame,"15x15+3+3");
10996 montage_info->shadow=MagickTrue;
11001 montage_info->frame=(char *) NULL;
11002 montage_info->shadow=MagickFalse;
11003 montage_info->border_width=0;
11006 case ConcatenateMode:
11008 montage_info->frame=(char *) NULL;
11009 montage_info->shadow=MagickFalse;
11010 (void) CloneString(&montage_info->geometry,"+0+0");
11011 montage_info->border_width=0;
11016 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11023 if (LocaleCompare(attribute,"pointsize") == 0)
11025 montage_info->pointsize=SvIV(ST(i));
11028 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11035 if (LocaleCompare(attribute,"shadow") == 0)
11037 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11038 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11041 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11045 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11048 if (LocaleCompare(attribute,"stroke") == 0)
11050 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11054 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11061 if (LocaleCompare(attribute,"texture") == 0)
11063 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11066 if (LocaleCompare(attribute,"tile") == 0)
11068 char *p=SvPV(ST(i),na);
11069 if (IsGeometry(p) == MagickFalse)
11071 ThrowPerlException(exception,OptionError,"MissingGeometry",
11075 (void) CloneString(&montage_info->tile,p);
11077 montage_info->tile=(char *) NULL;
11080 if (LocaleCompare(attribute,"title") == 0)
11082 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11085 if (LocaleCompare(attribute,"transparent") == 0)
11090 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11091 for (next=image; next; next=next->next)
11092 (void) TransparentPaintImage(next,&transparent_color,
11093 TransparentAlpha,MagickFalse,exception);
11096 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11102 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11108 image=MontageImageList(info->image_info,montage_info,image,exception);
11109 montage_info=DestroyMontageInfo(montage_info);
11110 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11111 goto PerlException;
11112 if (transparent_color.alpha != TransparentAlpha)
11113 for (next=image; next; next=next->next)
11114 (void) TransparentPaintImage(next,&transparent_color,
11115 TransparentAlpha,MagickFalse,exception);
11116 for ( ; image; image=image->next)
11118 AddImageToRegistry(sv,image);
11120 av_push(av,sv_bless(rv,hv));
11123 exception=DestroyExceptionInfo(exception);
11124 ST(0)=av_reference;
11125 SvREFCNT_dec(perl_exception);
11129 InheritPerlException(exception,perl_exception);
11130 exception=DestroyExceptionInfo(exception);
11131 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11132 SvPOK_on(perl_exception);
11133 ST(0)=sv_2mortal(perl_exception);
11138 ###############################################################################
11146 ###############################################################################
11151 Image::Magick ref=NO_INIT
11189 PERL_UNUSED_VAR(ref);
11190 PERL_UNUSED_VAR(ix);
11191 exception=AcquireExceptionInfo();
11192 perl_exception=newSVpv("",0);
11196 if (sv_isobject(ST(0)) == 0)
11198 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11200 goto PerlException;
11202 reference=SvRV(ST(0));
11203 hv=SvSTASH(reference);
11205 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11207 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11208 if (image == (Image *) NULL)
11210 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11212 goto PerlException;
11214 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11219 for (i=2; i < items; i+=2)
11221 attribute=(char *) SvPV(ST(i-1),na);
11222 switch (*attribute)
11227 if (LocaleCompare(attribute,"frames") == 0)
11229 number_frames=SvIV(ST(i));
11232 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11238 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11244 image=MorphImages(image,number_frames,exception);
11245 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11246 goto PerlException;
11247 for ( ; image; image=image->next)
11249 AddImageToRegistry(sv,image);
11251 av_push(av,sv_bless(rv,hv));
11254 exception=DestroyExceptionInfo(exception);
11255 ST(0)=av_reference;
11256 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11260 InheritPerlException(exception,perl_exception);
11261 exception=DestroyExceptionInfo(exception);
11262 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11263 SvPOK_on(perl_exception);
11264 ST(0)=sv_2mortal(perl_exception);
11269 ###############################################################################
11277 ###############################################################################
11282 Image::Magick ref=NO_INIT
11310 PERL_UNUSED_VAR(ref);
11311 PERL_UNUSED_VAR(ix);
11312 exception=AcquireExceptionInfo();
11313 perl_exception=newSVpv("",0);
11315 if (sv_isobject(ST(0)) == 0)
11317 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11319 goto PerlException;
11321 reference=SvRV(ST(0));
11322 hv=SvSTASH(reference);
11323 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11324 if (image == (Image *) NULL)
11326 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11328 goto PerlException;
11330 image=MergeImageLayers(image,MosaicLayer,exception);
11332 Create blessed Perl array for the returned image.
11335 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11337 AddImageToRegistry(sv,image);
11339 av_push(av,sv_bless(rv,hv));
11341 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11342 (void) CopyMagickString(info->image_info->filename,image->filename,
11344 SetImageInfo(info->image_info,0,&image->exception);
11345 exception=DestroyExceptionInfo(exception);
11346 SvREFCNT_dec(perl_exception);
11350 InheritPerlException(exception,perl_exception);
11351 exception=DestroyExceptionInfo(exception);
11352 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11353 SvPOK_on(perl_exception); /* return messages in string context */
11354 ST(0)=sv_2mortal(perl_exception);
11359 ###############################################################################
11367 ###############################################################################
11372 Image::Magick ref=NO_INIT
11422 PERL_UNUSED_VAR(ref);
11423 PERL_UNUSED_VAR(ix);
11424 exception=AcquireExceptionInfo();
11425 perl_exception=newSVpv("",0);
11426 package_info=(struct PackageInfo *) NULL;
11427 ac=(items < 2) ? 1 : items-1;
11428 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11430 length=(STRLEN *) NULL;
11431 if (list == (char **) NULL)
11433 ThrowPerlException(exception,ResourceLimitError,
11434 "MemoryAllocationFailed",PackageName);
11435 goto PerlException;
11438 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11439 if (length == (STRLEN *) NULL)
11441 ThrowPerlException(exception,ResourceLimitError,
11442 "MemoryAllocationFailed",PackageName);
11443 goto PerlException;
11445 if (sv_isobject(ST(0)) == 0)
11447 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11449 goto PerlException;
11451 reference=SvRV(ST(0));
11452 if (SvTYPE(reference) != SVt_PVAV)
11454 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11456 goto PerlException;
11458 av=(AV *) reference;
11459 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11461 package_info=ClonePackageInfo(info,exception);
11464 *list=(char *) (*package_info->image_info->filename ?
11465 package_info->image_info->filename : "XC:black");
11467 for (n=0, i=0; i < ac; i++)
11469 list[n]=(char *) SvPV(ST(i+1),length[n]);
11470 if ((items >= 3) && strEQcase(list[n],"blob"))
11476 blob=(void *) (SvPV(ST(i+1),length[n]));
11477 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11479 if ((items >= 3) && strEQcase(list[n],"filename"))
11481 if ((items >= 3) && strEQcase(list[n],"file"))
11490 io_info=IoIFP(sv_2io(ST(i+1)));
11491 if (io_info == (PerlIO *) NULL)
11493 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11497 file=PerlIO_findFILE(io_info);
11498 if (file == (FILE *) NULL)
11500 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11504 SetImageInfoFile(package_info->image_info,file);
11506 if ((items >= 3) && strEQcase(list[n],"magick"))
11510 list[n]=(char *) NULL;
11512 status=ExpandFilenames(&n,&list);
11513 if (status == MagickFalse)
11515 ThrowPerlException(exception,ResourceLimitError,
11516 "MemoryAllocationFailed",PackageName);
11517 goto PerlException;
11520 for (i=0; i < n; i++)
11522 (void) CopyMagickString(package_info->image_info->filename,list[i],
11524 image=PingImage(package_info->image_info,exception);
11525 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11527 if ((package_info->image_info->file != (FILE *) NULL) ||
11528 (package_info->image_info->blob != (void *) NULL))
11529 DisassociateImageStream(image);
11530 count+=GetImageListLength(image);
11531 EXTEND(sp,4*count);
11532 for (next=image; next; next=next->next)
11534 PUSHs(sv_2mortal(newSViv(next->columns)));
11535 PUSHs(sv_2mortal(newSViv(next->rows)));
11536 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11537 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11539 image=DestroyImageList(image);
11544 for (i=0; i < n; i++)
11545 if (list[i] != (char *) NULL)
11546 for (p=keep; list[i] != *p++; )
11549 list[i]=(char *) RelinquishMagickMemory(list[i]);
11554 if (package_info != (struct PackageInfo *) NULL)
11555 DestroyPackageInfo(package_info);
11556 if (list && (list != keep))
11557 list=(char **) RelinquishMagickMemory(list);
11559 keep=(char **) RelinquishMagickMemory(keep);
11561 length=(STRLEN *) RelinquishMagickMemory(length);
11562 InheritPerlException(exception,perl_exception);
11563 exception=DestroyExceptionInfo(exception);
11564 SvREFCNT_dec(perl_exception); /* throw away all errors */
11568 ###############################################################################
11576 ###############################################################################
11581 Image::Magick ref=NO_INIT
11614 PERL_UNUSED_VAR(ref);
11615 PERL_UNUSED_VAR(ix);
11616 exception=AcquireExceptionInfo();
11617 perl_exception=newSVpv("",0);
11620 if (sv_isobject(ST(0)) == 0)
11622 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11624 goto PerlException;
11626 reference=SvRV(ST(0));
11627 hv=SvSTASH(reference);
11629 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11631 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11632 if (image == (Image *) NULL)
11634 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11636 goto PerlException;
11638 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11639 preview_type=GammaPreview;
11641 preview_type=(PreviewType)
11642 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11643 for ( ; image; image=image->next)
11645 preview_image=PreviewImage(image,preview_type,exception);
11646 if (preview_image == (Image *) NULL)
11647 goto PerlException;
11648 AddImageToRegistry(sv,preview_image);
11650 av_push(av,sv_bless(rv,hv));
11653 exception=DestroyExceptionInfo(exception);
11654 ST(0)=av_reference;
11655 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11659 InheritPerlException(exception,perl_exception);
11660 exception=DestroyExceptionInfo(exception);
11661 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11662 SvPOK_on(perl_exception);
11663 ST(0)=sv_2mortal(perl_exception);
11668 ###############################################################################
11672 # Q u e r y C o l o r #
11676 ###############################################################################
11680 QueryColor(ref,...)
11681 Image::Magick ref=NO_INIT
11701 PERL_UNUSED_VAR(ref);
11702 PERL_UNUSED_VAR(ix);
11703 exception=AcquireExceptionInfo();
11704 perl_exception=newSVpv("",0);
11713 colorlist=GetColorInfoList("*",&colors,exception);
11715 for (i=0; i < (ssize_t) colors; i++)
11717 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11719 colorlist=(const ColorInfo **)
11720 RelinquishMagickMemory((ColorInfo **) colorlist);
11721 goto PerlException;
11723 EXTEND(sp,5*items);
11724 for (i=1; i < items; i++)
11726 name=(char *) SvPV(ST(i),na);
11727 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11732 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11733 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11734 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11735 if (color.colorspace == CMYKColorspace)
11736 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11737 if (color.matte != MagickFalse)
11738 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11742 InheritPerlException(exception,perl_exception);
11743 exception=DestroyExceptionInfo(exception);
11744 SvREFCNT_dec(perl_exception);
11748 ###############################################################################
11752 # Q u e r y C o l o r N a m e #
11756 ###############################################################################
11760 QueryColorname(ref,...)
11761 Image::Magick ref=NO_INIT
11770 message[MaxTextExtent];
11789 *reference; /* reference is the SV* of ref=SvIV(reference) */
11791 PERL_UNUSED_VAR(ref);
11792 PERL_UNUSED_VAR(ix);
11793 exception=AcquireExceptionInfo();
11794 perl_exception=newSVpv("",0);
11795 reference=SvRV(ST(0));
11796 av=(AV *) reference;
11797 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11799 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11800 if (image == (Image *) NULL)
11802 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11804 goto PerlException;
11807 for (i=1; i < items; i++)
11809 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11810 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11812 PUSHs(sv_2mortal(newSVpv(message,0)));
11816 InheritPerlException(exception,perl_exception);
11817 exception=DestroyExceptionInfo(exception);
11818 SvREFCNT_dec(perl_exception);
11822 ###############################################################################
11826 # Q u e r y F o n t #
11830 ###############################################################################
11835 Image::Magick ref=NO_INIT
11842 message[MaxTextExtent];
11853 volatile const TypeInfo
11856 PERL_UNUSED_VAR(ref);
11857 PERL_UNUSED_VAR(ix);
11858 exception=AcquireExceptionInfo();
11859 perl_exception=newSVpv("",0);
11868 typelist=GetTypeInfoList("*",&types,exception);
11870 for (i=0; i < (ssize_t) types; i++)
11872 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11874 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11876 goto PerlException;
11878 EXTEND(sp,10*items);
11879 for (i=1; i < items; i++)
11881 name=(char *) SvPV(ST(i),na);
11882 type_info=GetTypeInfo(name,exception);
11883 if (type_info == (TypeInfo *) NULL)
11888 if (type_info->name == (char *) NULL)
11891 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11892 if (type_info->description == (char *) NULL)
11895 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11896 if (type_info->family == (char *) NULL)
11899 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11900 if (type_info->style == UndefinedStyle)
11903 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11904 type_info->style),0)));
11905 if (type_info->stretch == UndefinedStretch)
11908 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11909 type_info->stretch),0)));
11910 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11911 type_info->weight);
11912 PUSHs(sv_2mortal(newSVpv(message,0)));
11913 if (type_info->encoding == (char *) NULL)
11916 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11917 if (type_info->foundry == (char *) NULL)
11920 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11921 if (type_info->format == (char *) NULL)
11924 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11925 if (type_info->metrics == (char *) NULL)
11928 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11929 if (type_info->glyphs == (char *) NULL)
11932 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11936 InheritPerlException(exception,perl_exception);
11937 exception=DestroyExceptionInfo(exception);
11938 SvREFCNT_dec(perl_exception);
11942 ###############################################################################
11946 # Q u e r y F o n t M e t r i c s #
11950 ###############################################################################
11954 QueryFontMetrics(ref,...)
11955 Image::Magick ref=NO_INIT
11957 queryfontmetrics = 1
12004 *reference; /* reference is the SV* of ref=SvIV(reference) */
12009 PERL_UNUSED_VAR(ref);
12010 PERL_UNUSED_VAR(ix);
12011 exception=AcquireExceptionInfo();
12012 package_info=(struct PackageInfo *) NULL;
12013 perl_exception=newSVpv("",0);
12014 reference=SvRV(ST(0));
12015 av=(AV *) reference;
12016 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12018 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12019 if (image == (Image *) NULL)
12021 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12023 goto PerlException;
12025 package_info=ClonePackageInfo(info,exception);
12026 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12027 CloneString(&draw_info->text,"");
12028 current=draw_info->affine;
12029 GetAffineMatrix(&affine);
12032 EXTEND(sp,7*items);
12033 for (i=2; i < items; i+=2)
12035 attribute=(char *) SvPV(ST(i-1),na);
12036 switch (*attribute)
12041 if (LocaleCompare(attribute,"antialias") == 0)
12043 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12047 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12051 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12054 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12061 if (LocaleCompare(attribute,"density") == 0)
12063 CloneString(&draw_info->density,SvPV(ST(i),na));
12066 if (LocaleCompare(attribute,"direction") == 0)
12068 draw_info->direction=(DirectionType) ParseCommandOption(
12069 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12072 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12079 if (LocaleCompare(attribute,"encoding") == 0)
12081 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12084 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12091 if (LocaleCompare(attribute,"family") == 0)
12093 CloneString(&draw_info->family,SvPV(ST(i),na));
12096 if (LocaleCompare(attribute,"fill") == 0)
12099 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12100 &image->exception);
12103 if (LocaleCompare(attribute,"font") == 0)
12105 CloneString(&draw_info->font,SvPV(ST(i),na));
12108 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12115 if (LocaleCompare(attribute,"geometry") == 0)
12117 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12120 if (LocaleCompare(attribute,"gravity") == 0)
12122 draw_info->gravity=(GravityType) ParseCommandOption(
12123 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12126 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12133 if (LocaleCompare(attribute,"interline-spacing") == 0)
12135 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12136 draw_info->interline_spacing=geometry_info.rho;
12139 if (LocaleCompare(attribute,"interword-spacing") == 0)
12141 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12142 draw_info->interword_spacing=geometry_info.rho;
12145 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12152 if (LocaleCompare(attribute,"kerning") == 0)
12154 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12155 draw_info->kerning=geometry_info.rho;
12158 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12165 if (LocaleCompare(attribute,"pointsize") == 0)
12167 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12168 draw_info->pointsize=geometry_info.rho;
12171 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12178 if (LocaleCompare(attribute,"rotate") == 0)
12180 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12181 affine.rx=geometry_info.rho;
12182 affine.ry=geometry_info.sigma;
12183 if ((flags & SigmaValue) == 0)
12184 affine.ry=affine.rx;
12187 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12194 if (LocaleCompare(attribute,"scale") == 0)
12196 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12197 affine.sx=geometry_info.rho;
12198 affine.sy=geometry_info.sigma;
12199 if ((flags & SigmaValue) == 0)
12200 affine.sy=affine.sx;
12203 if (LocaleCompare(attribute,"skew") == 0)
12209 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12210 x_angle=geometry_info.rho;
12211 y_angle=geometry_info.sigma;
12212 if ((flags & SigmaValue) == 0)
12214 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12215 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12218 if (LocaleCompare(attribute,"stroke") == 0)
12221 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12222 &image->exception);
12225 if (LocaleCompare(attribute,"style") == 0)
12227 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12231 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12235 draw_info->style=(StyleType) type;
12238 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12245 if (LocaleCompare(attribute,"text") == 0)
12247 CloneString(&draw_info->text,SvPV(ST(i),na));
12250 if (LocaleCompare(attribute,"translate") == 0)
12252 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12253 affine.tx=geometry_info.rho;
12254 affine.ty=geometry_info.sigma;
12255 if ((flags & SigmaValue) == 0)
12256 affine.ty=affine.tx;
12259 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12266 if (LocaleCompare(attribute,"weight") == 0)
12268 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12269 draw_info->weight=(size_t) geometry_info.rho;
12272 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12279 if (LocaleCompare(attribute,"x") == 0)
12281 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12282 x=geometry_info.rho;
12285 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12292 if (LocaleCompare(attribute,"y") == 0)
12294 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12295 y=geometry_info.rho;
12298 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12304 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12310 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12311 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12312 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12313 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12314 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12315 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12316 if (draw_info->geometry == (char *) NULL)
12318 draw_info->geometry=AcquireString((char *) NULL);
12319 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12320 "%.15g,%.15g",x,y);
12322 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12323 (void) CatchImageException(image);
12324 if (status == MagickFalse)
12328 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12329 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12330 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12331 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12332 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12333 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12334 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12335 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12336 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12337 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12338 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12339 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12340 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12342 draw_info=DestroyDrawInfo(draw_info);
12345 if (package_info != (struct PackageInfo *) NULL)
12346 DestroyPackageInfo(package_info);
12347 InheritPerlException(exception,perl_exception);
12348 exception=DestroyExceptionInfo(exception);
12349 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12353 ###############################################################################
12357 # 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 #
12361 ###############################################################################
12365 QueryMultilineFontMetrics(ref,...)
12366 Image::Magick ref=NO_INIT
12368 querymultilinefontmetrics = 1
12415 *reference; /* reference is the SV* of ref=SvIV(reference) */
12420 PERL_UNUSED_VAR(ref);
12421 PERL_UNUSED_VAR(ix);
12422 exception=AcquireExceptionInfo();
12423 package_info=(struct PackageInfo *) NULL;
12424 perl_exception=newSVpv("",0);
12425 reference=SvRV(ST(0));
12426 av=(AV *) reference;
12427 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12429 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12430 if (image == (Image *) NULL)
12432 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12434 goto PerlException;
12436 package_info=ClonePackageInfo(info,exception);
12437 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12438 CloneString(&draw_info->text,"");
12439 current=draw_info->affine;
12440 GetAffineMatrix(&affine);
12443 EXTEND(sp,7*items);
12444 for (i=2; i < items; i+=2)
12446 attribute=(char *) SvPV(ST(i-1),na);
12447 switch (*attribute)
12452 if (LocaleCompare(attribute,"antialias") == 0)
12454 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12458 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12462 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12465 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12472 if (LocaleCompare(attribute,"density") == 0)
12474 CloneString(&draw_info->density,SvPV(ST(i),na));
12477 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12484 if (LocaleCompare(attribute,"encoding") == 0)
12486 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12489 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12496 if (LocaleCompare(attribute,"family") == 0)
12498 CloneString(&draw_info->family,SvPV(ST(i),na));
12501 if (LocaleCompare(attribute,"fill") == 0)
12504 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12505 &image->exception);
12508 if (LocaleCompare(attribute,"font") == 0)
12510 CloneString(&draw_info->font,SvPV(ST(i),na));
12513 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12520 if (LocaleCompare(attribute,"geometry") == 0)
12522 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12525 if (LocaleCompare(attribute,"gravity") == 0)
12527 draw_info->gravity=(GravityType) ParseCommandOption(
12528 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12531 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12538 if (LocaleCompare(attribute,"pointsize") == 0)
12540 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12541 draw_info->pointsize=geometry_info.rho;
12544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12551 if (LocaleCompare(attribute,"rotate") == 0)
12553 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12554 affine.rx=geometry_info.rho;
12555 affine.ry=geometry_info.sigma;
12556 if ((flags & SigmaValue) == 0)
12557 affine.ry=affine.rx;
12560 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12567 if (LocaleCompare(attribute,"scale") == 0)
12569 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12570 affine.sx=geometry_info.rho;
12571 affine.sy=geometry_info.sigma;
12572 if ((flags & SigmaValue) == 0)
12573 affine.sy=affine.sx;
12576 if (LocaleCompare(attribute,"skew") == 0)
12582 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12583 x_angle=geometry_info.rho;
12584 y_angle=geometry_info.sigma;
12585 if ((flags & SigmaValue) == 0)
12587 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12588 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12591 if (LocaleCompare(attribute,"stroke") == 0)
12594 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12595 &image->exception);
12598 if (LocaleCompare(attribute,"style") == 0)
12600 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12604 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12608 draw_info->style=(StyleType) type;
12611 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12618 if (LocaleCompare(attribute,"text") == 0)
12620 CloneString(&draw_info->text,SvPV(ST(i),na));
12623 if (LocaleCompare(attribute,"translate") == 0)
12625 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12626 affine.tx=geometry_info.rho;
12627 affine.ty=geometry_info.sigma;
12628 if ((flags & SigmaValue) == 0)
12629 affine.ty=affine.tx;
12632 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12639 if (LocaleCompare(attribute,"weight") == 0)
12641 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12642 draw_info->weight=(size_t) geometry_info.rho;
12645 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12652 if (LocaleCompare(attribute,"x") == 0)
12654 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12655 x=geometry_info.rho;
12658 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12665 if (LocaleCompare(attribute,"y") == 0)
12667 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12668 y=geometry_info.rho;
12671 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12677 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12683 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12684 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12685 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12686 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12687 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12688 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12689 if (draw_info->geometry == (char *) NULL)
12691 draw_info->geometry=AcquireString((char *) NULL);
12692 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12693 "%.15g,%.15g",x,y);
12695 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12696 (void) CatchException(exception);
12697 if (status == MagickFalse)
12701 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12702 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12703 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12704 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12705 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12706 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12707 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12708 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12709 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12710 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12711 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12712 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12713 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12715 draw_info=DestroyDrawInfo(draw_info);
12718 if (package_info != (struct PackageInfo *) NULL)
12719 DestroyPackageInfo(package_info);
12720 InheritPerlException(exception,perl_exception);
12721 exception=DestroyExceptionInfo(exception);
12722 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12726 ###############################################################################
12730 # Q u e r y F o r m a t #
12734 ###############################################################################
12738 QueryFormat(ref,...)
12739 Image::Magick ref=NO_INIT
12756 volatile const MagickInfo
12759 PERL_UNUSED_VAR(ref);
12760 PERL_UNUSED_VAR(ix);
12761 exception=AcquireExceptionInfo();
12762 perl_exception=newSVpv("",0);
12766 format[MaxTextExtent];
12774 format_list=GetMagickInfoList("*",&types,exception);
12776 for (i=0; i < (ssize_t) types; i++)
12778 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12779 LocaleLower(format);
12780 PUSHs(sv_2mortal(newSVpv(format,0)));
12782 format_list=(const MagickInfo **)
12783 RelinquishMagickMemory((MagickInfo *) format_list);
12784 goto PerlException;
12786 EXTEND(sp,8*items);
12787 for (i=1; i < items; i++)
12789 name=(char *) SvPV(ST(i),na);
12790 magick_info=GetMagickInfo(name,exception);
12791 if (magick_info == (const MagickInfo *) NULL)
12796 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12797 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12798 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12799 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12800 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12801 if (magick_info->description == (char *) NULL)
12804 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12805 if (magick_info->module == (char *) NULL)
12808 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12812 InheritPerlException(exception,perl_exception);
12813 exception=DestroyExceptionInfo(exception);
12814 SvREFCNT_dec(perl_exception);
12818 ###############################################################################
12822 # Q u e r y O p t i o n #
12826 ###############################################################################
12830 QueryOption(ref,...)
12831 Image::Magick ref=NO_INIT
12852 PERL_UNUSED_VAR(ref);
12853 PERL_UNUSED_VAR(ix);
12854 exception=AcquireExceptionInfo();
12855 perl_exception=newSVpv("",0);
12856 EXTEND(sp,8*items);
12857 for (i=1; i < items; i++)
12859 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12861 options=GetCommandOptions((CommandOption) option);
12862 if (options == (char **) NULL)
12866 for (j=0; options[j] != (char *) NULL; j++)
12867 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12868 options=DestroyStringList(options);
12872 InheritPerlException(exception,perl_exception);
12873 exception=DestroyExceptionInfo(exception);
12874 SvREFCNT_dec(perl_exception);
12878 ###############################################################################
12886 ###############################################################################
12891 Image::Magick ref=NO_INIT
12938 *perl_exception, /* Perl variable for storing messages */
12943 PERL_UNUSED_VAR(ref);
12944 PERL_UNUSED_VAR(ix);
12945 exception=AcquireExceptionInfo();
12946 perl_exception=newSVpv("",0);
12948 package_info=(struct PackageInfo *) NULL;
12950 ac=(items < 2) ? 1 : items-1;
12951 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12953 length=(STRLEN *) NULL;
12954 if (list == (char **) NULL)
12956 ThrowPerlException(exception,ResourceLimitError,
12957 "MemoryAllocationFailed",PackageName);
12958 goto PerlException;
12960 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12961 if (length == (STRLEN *) NULL)
12963 ThrowPerlException(exception,ResourceLimitError,
12964 "MemoryAllocationFailed",PackageName);
12965 goto PerlException;
12967 if (sv_isobject(ST(0)) == 0)
12969 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12971 goto PerlException;
12973 reference=SvRV(ST(0));
12974 hv=SvSTASH(reference);
12975 if (SvTYPE(reference) != SVt_PVAV)
12977 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12979 goto PerlException;
12981 av=(AV *) reference;
12982 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12984 package_info=ClonePackageInfo(info,exception);
12987 *list=(char *) (*package_info->image_info->filename ?
12988 package_info->image_info->filename : "XC:black");
12990 for (n=0, i=0; i < ac; i++)
12992 list[n]=(char *) SvPV(ST(i+1),length[n]);
12993 if ((items >= 3) && strEQcase(list[n],"blob"))
12999 blob=(void *) (SvPV(ST(i+1),length[n]));
13000 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13002 if ((items >= 3) && strEQcase(list[n],"filename"))
13004 if ((items >= 3) && strEQcase(list[n],"file"))
13013 io_info=IoIFP(sv_2io(ST(i+1)));
13014 if (io_info == (PerlIO *) NULL)
13016 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13020 file=PerlIO_findFILE(io_info);
13021 if (file == (FILE *) NULL)
13023 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13027 SetImageInfoFile(package_info->image_info,file);
13029 if ((items >= 3) && strEQcase(list[n],"magick"))
13033 list[n]=(char *) NULL;
13035 status=ExpandFilenames(&n,&list);
13036 if (status == MagickFalse)
13038 ThrowPerlException(exception,ResourceLimitError,
13039 "MemoryAllocationFailed",PackageName);
13040 goto PerlException;
13043 for (i=0; i < n; i++)
13045 if ((package_info->image_info->file != (FILE *) NULL) ||
13046 (package_info->image_info->blob != (void *) NULL))
13048 image=ReadImages(package_info->image_info,exception);
13049 if (image != (Image *) NULL)
13050 DisassociateImageStream(image);
13054 (void) CopyMagickString(package_info->image_info->filename,list[i],
13056 image=ReadImages(package_info->image_info,exception);
13058 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13060 for ( ; image; image=image->next)
13062 AddImageToRegistry(sv,image);
13064 av_push(av,sv_bless(rv,hv));
13072 for (i=0; i < n; i++)
13073 if (list[i] != (char *) NULL)
13074 for (p=keep; list[i] != *p++; )
13075 if (*p == (char *) NULL)
13077 list[i]=(char *) RelinquishMagickMemory(list[i]);
13082 if (package_info != (struct PackageInfo *) NULL)
13083 DestroyPackageInfo(package_info);
13084 if (list && (list != keep))
13085 list=(char **) RelinquishMagickMemory(list);
13087 keep=(char **) RelinquishMagickMemory(keep);
13089 length=(STRLEN *) RelinquishMagickMemory(length);
13090 InheritPerlException(exception,perl_exception);
13091 exception=DestroyExceptionInfo(exception);
13092 sv_setiv(perl_exception,(IV) number_images);
13093 SvPOK_on(perl_exception);
13094 ST(0)=sv_2mortal(perl_exception);
13099 ###############################################################################
13107 ###############################################################################
13112 Image::Magick ref=NO_INIT
13135 PERL_UNUSED_VAR(ref);
13136 PERL_UNUSED_VAR(ix);
13137 exception=AcquireExceptionInfo();
13138 perl_exception=newSVpv("",0);
13139 reference=SvRV(ST(0));
13140 av=(AV *) reference;
13141 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13143 for (i=1; i < items; i++)
13144 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13145 SvPV(ST(i),na),exception);
13146 InheritPerlException(exception,perl_exception);
13147 exception=DestroyExceptionInfo(exception);
13148 SvREFCNT_dec(perl_exception); /* throw away all errors */
13152 ###############################################################################
13160 ###############################################################################
13165 Image::Magick ref=NO_INIT
13188 *reference; /* reference is the SV* of ref=SvIV(reference) */
13190 PERL_UNUSED_VAR(ref);
13191 PERL_UNUSED_VAR(ix);
13192 exception=AcquireExceptionInfo();
13193 perl_exception=newSVpv("",0);
13194 if (sv_isobject(ST(0)) == 0)
13196 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13198 goto PerlException;
13200 reference=SvRV(ST(0));
13201 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13203 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13205 for (i=2; i < items; i+=2)
13206 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13209 InheritPerlException(exception,perl_exception);
13210 exception=DestroyExceptionInfo(exception);
13211 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13212 SvPOK_on(perl_exception);
13213 ST(0)=sv_2mortal(perl_exception);
13218 ###############################################################################
13222 # S e t P i x e l #
13226 ###############################################################################
13231 Image::Magick ref=NO_INIT
13273 *reference; /* reference is the SV* of ref=SvIV(reference) */
13275 PERL_UNUSED_VAR(ref);
13276 PERL_UNUSED_VAR(ix);
13277 exception=AcquireExceptionInfo();
13278 perl_exception=newSVpv("",0);
13279 reference=SvRV(ST(0));
13280 av=(AV *) reference;
13281 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13283 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13284 if (image == (Image *) NULL)
13286 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13288 goto PerlException;
13291 normalize=MagickTrue;
13294 region.width=image->columns;
13297 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13298 channel=DefaultChannels;
13299 for (i=2; i < items; i+=2)
13301 attribute=(char *) SvPV(ST(i-1),na);
13302 switch (*attribute)
13307 if (LocaleCompare(attribute,"channel") == 0)
13312 option=ParseChannelOption(SvPV(ST(i),na));
13315 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13319 channel=(ChannelType) option;
13322 if (LocaleCompare(attribute,"color") == 0)
13324 if (SvTYPE(ST(i)) != SVt_RV)
13327 message[MaxTextExtent];
13329 (void) FormatLocaleString(message,MaxTextExtent,
13330 "invalid %.60s value",attribute);
13331 ThrowPerlException(exception,OptionError,message,
13334 av=(AV *) SvRV(ST(i));
13337 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13344 if (LocaleCompare(attribute,"geometry") == 0)
13346 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13349 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13356 if (LocaleCompare(attribute,"normalize") == 0)
13358 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13362 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13366 normalize=option != 0 ? MagickTrue : MagickFalse;
13369 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13376 if (LocaleCompare(attribute,"x") == 0)
13378 region.x=SvIV(ST(i));
13381 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13388 if (LocaleCompare(attribute,"y") == 0)
13390 region.y=SvIV(ST(i));
13393 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13399 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13405 (void) SetImageStorageClass(image,DirectClass,exception);
13406 channel_mask=SetPixelChannelMask(image,channel);
13407 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13408 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13409 (SvTYPE(av) != SVt_PVAV))
13421 if (normalize != MagickFalse)
13422 scale=QuantumRange;
13423 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13426 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13427 av_fetch(av,i,0)))),q);
13430 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13433 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13434 av_fetch(av,i,0)))),q);
13437 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13440 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13441 av_fetch(av,i,0)))),q);
13444 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13445 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13447 SetPixelBlack(image,ClampToQuantum(scale*
13448 SvNV(*(av_fetch(av,i,0)))),q);
13451 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13454 SetPixelAlpha(image,ClampToQuantum(scale*
13455 SvNV(*(av_fetch(av,i,0)))),q);
13458 (void) SyncAuthenticPixels(image,exception);
13460 (void) SetPixelChannelMask(image,channel_mask);
13463 InheritPerlException(exception,perl_exception);
13464 exception=DestroyExceptionInfo(exception);
13465 SvREFCNT_dec(perl_exception);
13469 ###############################################################################
13477 ###############################################################################
13482 Image::Magick ref=NO_INIT
13521 PERL_UNUSED_VAR(ref);
13522 PERL_UNUSED_VAR(ix);
13523 exception=AcquireExceptionInfo();
13524 perl_exception=newSVpv("",0);
13528 if (sv_isobject(ST(0)) == 0)
13530 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13532 goto PerlException;
13534 reference=SvRV(ST(0));
13535 hv=SvSTASH(reference);
13537 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13539 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13540 if (image == (Image *) NULL)
13542 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13544 goto PerlException;
13546 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13552 for (i=2; i < items; i+=2)
13554 attribute=(char *) SvPV(ST(i-1),na);
13555 switch (*attribute)
13560 if (LocaleCompare(attribute,"offset") == 0)
13562 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13565 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13572 if (LocaleCompare(attribute,"stack") == 0)
13574 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13578 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13584 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13590 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13596 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13598 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13599 goto PerlException;
13600 for ( ; image; image=image->next)
13602 AddImageToRegistry(sv,image);
13604 av_push(av,sv_bless(rv,hv));
13607 exception=DestroyExceptionInfo(exception);
13608 ST(0)=av_reference;
13609 SvREFCNT_dec(perl_exception);
13613 InheritPerlException(exception,perl_exception);
13614 exception=DestroyExceptionInfo(exception);
13615 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13616 SvPOK_on(perl_exception);
13617 ST(0)=sv_2mortal(perl_exception);
13622 ###############################################################################
13626 # S t a t i s t i c s #
13630 ###############################################################################
13634 Statistics(ref,...)
13635 Image::Magick ref=NO_INIT
13637 StatisticsImage = 1
13639 statisticsimage = 3
13642 #define ChannelStatistics(channel) \
13644 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13645 (double) channel_statistics[channel].depth); \
13646 PUSHs(sv_2mortal(newSVpv(message,0))); \
13647 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13648 channel_statistics[channel].minima/scale); \
13649 PUSHs(sv_2mortal(newSVpv(message,0))); \
13650 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13651 channel_statistics[channel].maxima/scale); \
13652 PUSHs(sv_2mortal(newSVpv(message,0))); \
13653 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13654 channel_statistics[channel].mean/scale); \
13655 PUSHs(sv_2mortal(newSVpv(message,0))); \
13656 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13657 channel_statistics[channel].standard_deviation/scale); \
13658 PUSHs(sv_2mortal(newSVpv(message,0))); \
13659 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13660 channel_statistics[channel].kurtosis); \
13661 PUSHs(sv_2mortal(newSVpv(message,0))); \
13662 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13663 channel_statistics[channel].skewness); \
13664 PUSHs(sv_2mortal(newSVpv(message,0))); \
13671 message[MaxTextExtent];
13674 *channel_statistics;
13695 PERL_UNUSED_VAR(ref);
13696 PERL_UNUSED_VAR(ix);
13697 exception=AcquireExceptionInfo();
13698 perl_exception=newSVpv("",0);
13700 if (sv_isobject(ST(0)) == 0)
13702 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13704 goto PerlException;
13706 reference=SvRV(ST(0));
13709 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13710 if (image == (Image *) NULL)
13712 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13714 goto PerlException;
13716 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13718 for ( ; image; image=image->next)
13720 channel_statistics=GetImageStatistics(image,&image->exception);
13721 if (channel_statistics == (ChannelStatistics *) NULL)
13724 EXTEND(sp,35*count);
13725 scale=(double) QuantumRange;
13726 ChannelStatistics(RedChannel);
13727 ChannelStatistics(GreenChannel);
13728 ChannelStatistics(BlueChannel);
13729 if (image->colorspace == CMYKColorspace)
13730 ChannelStatistics(BlackChannel);
13731 if (image->matte != MagickFalse)
13732 ChannelStatistics(AlphaChannel);
13733 channel_statistics=(ChannelStatistics *)
13734 RelinquishMagickMemory(channel_statistics);
13738 InheritPerlException(exception,perl_exception);
13739 exception=DestroyExceptionInfo(exception);
13740 SvREFCNT_dec(perl_exception);
13744 ###############################################################################
13748 # S y n c A u t h e n t i c P i x e l s #
13752 ###############################################################################
13756 SyncAuthenticPixels(ref,...)
13757 Image::Magick ref = NO_INIT
13759 Syncauthenticpixels = 1
13760 SyncImagePixels = 2
13761 syncimagepixels = 3
13780 PERL_UNUSED_VAR(ref);
13781 PERL_UNUSED_VAR(ix);
13782 exception=AcquireExceptionInfo();
13783 perl_exception=newSVpv("",0);
13784 if (sv_isobject(ST(0)) == 0)
13786 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13788 goto PerlException;
13791 reference=SvRV(ST(0));
13792 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13793 if (image == (Image *) NULL)
13795 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13797 goto PerlException;
13800 status=SyncAuthenticPixels(image,exception);
13801 if (status != MagickFalse)
13803 InheritException(exception,&image->exception);
13806 InheritPerlException(exception,perl_exception);
13807 exception=DestroyExceptionInfo(exception);
13808 SvREFCNT_dec(perl_exception); /* throw away all errors */
13812 ###############################################################################
13816 # T r a n s f o r m #
13820 ###############################################################################
13825 Image::Magick ref=NO_INIT
13863 PERL_UNUSED_VAR(ref);
13864 PERL_UNUSED_VAR(ix);
13865 exception=AcquireExceptionInfo();
13866 perl_exception=newSVpv("",0);
13870 if (sv_isobject(ST(0)) == 0)
13872 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13874 goto PerlException;
13876 reference=SvRV(ST(0));
13877 hv=SvSTASH(reference);
13879 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13881 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13882 if (image == (Image *) NULL)
13884 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13886 goto PerlException;
13888 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13892 crop_geometry=(char *) NULL;
13893 geometry=(char *) NULL;
13894 for (i=2; i < items; i+=2)
13896 attribute=(char *) SvPV(ST(i-1),na);
13897 switch (*attribute)
13902 if (LocaleCompare(attribute,"crop") == 0)
13904 crop_geometry=SvPV(ST(i),na);
13907 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13914 if (LocaleCompare(attribute,"geometry") == 0)
13916 geometry=SvPV(ST(i),na);
13919 if (LocaleCompare(attribute,"gravity") == 0)
13927 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13928 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13931 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13935 for (next=image; next; next=next->next)
13936 next->gravity=(GravityType) in;
13939 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13945 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13951 for ( ; image; image=image->next)
13953 clone=CloneImage(image,0,0,MagickTrue,exception);
13954 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13955 goto PerlException;
13956 TransformImage(&clone,crop_geometry,geometry);
13957 for ( ; clone; clone=clone->next)
13959 AddImageToRegistry(sv,clone);
13961 av_push(av,sv_bless(rv,hv));
13965 exception=DestroyExceptionInfo(exception);
13966 ST(0)=av_reference;
13967 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13971 InheritPerlException(exception,perl_exception);
13972 exception=DestroyExceptionInfo(exception);
13973 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13974 SvPOK_on(perl_exception);
13975 ST(0)=sv_2mortal(perl_exception);
13980 ###############################################################################
13988 ###############################################################################
13993 Image::Magick ref=NO_INIT
14001 filename[MaxTextExtent];
14025 PERL_UNUSED_VAR(ref);
14026 PERL_UNUSED_VAR(ix);
14027 exception=AcquireExceptionInfo();
14028 perl_exception=newSVpv("",0);
14030 package_info=(struct PackageInfo *) NULL;
14031 if (sv_isobject(ST(0)) == 0)
14033 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14035 goto PerlException;
14037 reference=SvRV(ST(0));
14038 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14039 if (image == (Image *) NULL)
14041 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14043 goto PerlException;
14045 package_info=ClonePackageInfo(info,exception);
14047 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14050 for (i=2; i < items; i+=2)
14051 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14053 (void) CopyMagickString(filename,package_info->image_info->filename,
14056 for (next=image; next; next=next->next)
14058 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14059 next->scene=scene++;
14061 SetImageInfo(package_info->image_info,(unsigned int)
14062 GetImageListLength(image),&image->exception);
14063 for (next=image; next; next=next->next)
14065 (void) WriteImage(package_info->image_info,next,exception);
14067 if (package_info->image_info->adjoin)
14072 if (package_info != (struct PackageInfo *) NULL)
14073 DestroyPackageInfo(package_info);
14074 InheritPerlException(exception,perl_exception);
14075 exception=DestroyExceptionInfo(exception);
14076 sv_setiv(perl_exception,(IV) number_images);
14077 SvPOK_on(perl_exception);
14078 ST(0)=sv_2mortal(perl_exception);