2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
55 #if defined(__cplusplus) || defined(c_plusplus)
59 #define PERL_NO_GET_CONTEXT
64 #include <MagickCore/MagickCore.h>
67 #if defined(__cplusplus) || defined(c_plusplus)
79 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
80 #define EndOf(array) (&array[NumberOf(array)])
81 #define MaxArguments 33
85 #define NumberOf(array) (sizeof(array)/sizeof(*array))
86 #define PackageName "Image::Magick"
89 #define PerlIO_importFILE(f, fl) (f)
90 #define PerlIO_findFILE(f) NULL
93 #define sv_undef PL_sv_undef
96 #define AddImageToRegistry(sv,image) \
98 if (magick_registry != (SplayTreeInfo *) NULL) \
100 (void) AddValueToSplayTree(magick_registry,image,image); \
101 (sv)=newSViv((IV) image); \
105 #define DeleteImageFromRegistry(reference,image) \
107 if (magick_registry != (SplayTreeInfo *) NULL) \
109 if (GetImageReferenceCount(image) == 1) \
110 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
111 image=DestroyImage(image); \
112 sv_setiv(reference,0); \
116 #define InheritPerlException(exception,perl_exception) \
119 message[MaxTextExtent]; \
121 if ((exception)->severity != UndefinedException) \
123 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
124 (exception)->severity, (exception)->reason ? \
125 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
126 "Unknown", (exception)->description ? " (" : "", \
127 (exception)->description ? GetLocaleExceptionMessage( \
128 (exception)->severity,(exception)->description) : "", \
129 (exception)->description ? ")" : ""); \
130 if ((perl_exception) != (SV *) NULL) \
132 if (SvCUR(perl_exception)) \
133 sv_catpv(perl_exception,"\n"); \
134 sv_catpv(perl_exception,message); \
139 #define ThrowPerlException(exception,severity,tag,reason) \
140 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
141 tag,"`%s'",reason); \
144 Typedef and structure declarations.
148 ArrayReference = (~0),
149 RealReference = (~0)-1,
150 FileReference = (~0)-2,
151 ImageReference = (~0)-3,
152 IntegerReference = (~0)-4,
153 StringReference = (~0)-5
156 typedef struct _Arguments
196 *Image__Magick; /* data type for the Image::Magick package */
208 arguments[MaxArguments];
211 { "Comment", { {"comment", StringReference} } },
212 { "Label", { {"label", StringReference} } },
213 { "AddNoise", { {"noise", MagickNoiseOptions},
214 {"channel", MagickChannelOptions} } },
215 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
216 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
217 {"height", IntegerReference}, {"fill", StringReference},
218 {"bordercolor", StringReference}, {"color", StringReference},
219 {"compose", MagickComposeOptions} } },
220 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
221 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
222 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference} } },
225 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
226 {"height", IntegerReference}, {"x", IntegerReference},
227 {"y", IntegerReference}, {"fuzz", StringReference},
228 {"gravity", MagickGravityOptions} } },
230 { "Edge", { {"radius", RealReference} } },
231 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
232 {"sigma", RealReference} } },
236 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
237 {"height", IntegerReference}, {"inner", IntegerReference},
238 {"outer", IntegerReference}, {"fill", StringReference},
239 {"color", StringReference}, {"compose", MagickComposeOptions} } },
240 { "Implode", { {"amount", RealReference},
241 {"interpolate", MagickInterpolateOptions} } },
243 { "MedianFilter", { {"geometry", StringReference},
244 {"width", IntegerReference}, {"height", IntegerReference},
245 {"channel", MagickChannelOptions} } },
247 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
248 { "ReduceNoise", { {"geometry", StringReference},
249 {"width", IntegerReference},{"height", IntegerReference},
250 {"channel", MagickChannelOptions} } },
251 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
252 {"y", IntegerReference} } },
253 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
254 {"color", StringReference}, {"background", StringReference} } },
255 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
256 {"height", IntegerReference} } },
257 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
258 {"height", IntegerReference} } },
259 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
260 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
261 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
262 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
263 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
264 {"y", RealReference}, { "fill", StringReference},
265 {"color", StringReference} } },
266 { "Spread", { {"radius", RealReference} } },
267 { "Swirl", { {"degrees", RealReference},
268 {"interpolate", MagickInterpolateOptions} } },
269 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", StringReference }, {"blur", RealReference } } },
272 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
273 {"height", IntegerReference}, {"filter", MagickFilterOptions},
274 {"support", RealReference }, {"blur", RealReference } } },
275 { "Annotate", { {"text", StringReference}, {"font", StringReference},
276 {"pointsize", RealReference}, {"density", StringReference},
277 {"undercolor", StringReference}, {"stroke", StringReference},
278 {"fill", StringReference}, {"geometry", StringReference},
279 {"pen", StringReference}, {"x", RealReference},
280 {"y", RealReference}, {"gravity", MagickGravityOptions},
281 {"translate", StringReference}, {"scale", StringReference},
282 {"rotate", RealReference}, {"skewX", RealReference},
283 {"skewY", RealReference}, {"strokewidth", RealReference},
284 {"antialias", MagickBooleanOptions}, {"family", StringReference},
285 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
286 {"weight", IntegerReference}, {"align", MagickAlignOptions},
287 {"encoding", StringReference}, {"affine", ArrayReference},
288 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
289 {"tile", ImageReference}, {"kerning", RealReference},
290 {"interline-spacing", RealReference},
291 {"interword-spacing", RealReference},
292 {"direction", MagickDirectionOptions} } },
293 { "ColorFloodfill", { {"geometry", StringReference},
294 {"x", IntegerReference}, {"y", IntegerReference},
295 {"fill", StringReference}, {"bordercolor", StringReference},
296 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
297 { "Composite", { {"image", ImageReference},
298 {"compose", MagickComposeOptions}, {"geometry", StringReference},
299 {"x", IntegerReference}, {"y", IntegerReference},
300 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
301 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
302 {"color", StringReference}, {"mask", ImageReference},
303 {"channel", MagickChannelOptions},
304 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
305 {"blend", StringReference} } },
306 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
307 { "CycleColormap", { {"display", IntegerReference} } },
308 { "Draw", { {"primitive", MagickPrimitiveOptions},
309 {"points", StringReference}, {"method", MagickMethodOptions},
310 {"stroke", StringReference}, {"fill", StringReference},
311 {"strokewidth", RealReference}, {"font", StringReference},
312 {"bordercolor", StringReference}, {"x", RealReference},
313 {"y", RealReference}, {"translate", StringReference},
314 {"scale", StringReference}, {"rotate", RealReference},
315 {"skewX", RealReference}, {"skewY", RealReference},
316 {"tile", ImageReference}, {"pointsize", RealReference},
317 {"antialias", MagickBooleanOptions}, {"density", StringReference},
318 {"linewidth", RealReference}, {"affine", ArrayReference},
319 {"stroke-dashoffset", RealReference},
320 {"stroke-dasharray", ArrayReference},
321 {"interpolate", MagickInterpolateOptions},
322 {"origin", StringReference}, {"text", StringReference},
323 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
324 {"vector-graphics", StringReference}, {"kerning", RealReference},
325 {"interline-spacing", RealReference},
326 {"interword-spacing", RealReference},
327 {"direction", MagickDirectionOptions} } },
328 { "Equalize", { {"channel", MagickChannelOptions} } },
329 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
330 {"red", RealReference}, {"green", RealReference},
331 {"blue", RealReference} } },
332 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
333 {"dither-method", MagickDitherOptions} } },
334 { "MatteFloodfill", { {"geometry", StringReference},
335 {"x", IntegerReference}, {"y", IntegerReference},
336 {"opacity", StringReference}, {"bordercolor", StringReference},
337 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
338 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
339 {"saturation", RealReference}, {"whiteness", RealReference},
340 {"brightness", RealReference}, {"lightness", RealReference},
341 {"blackness", RealReference} } },
342 { "Negate", { {"gray", MagickBooleanOptions},
343 {"channel", MagickChannelOptions} } },
344 { "Normalize", { {"channel", MagickChannelOptions} } },
346 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
347 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
348 {"invert", MagickBooleanOptions} } },
349 { "Quantize", { {"colors", IntegerReference},
350 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
351 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
352 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
353 {"dither-method", MagickDitherOptions} } },
354 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
355 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
356 { "Segment", { {"geometry", StringReference},
357 {"cluster-threshold", RealReference},
358 {"smoothing-threshold", RealReference},
359 {"colorspace", MagickColorspaceOptions},
360 {"verbose", MagickBooleanOptions} } },
362 { "Solarize", { {"geometry", StringReference},
363 {"threshold", StringReference} } },
365 { "Texture", { {"texture", ImageReference} } },
366 { "Evaluate", { {"value", RealReference},
367 {"operator", MagickEvaluateOptions},
368 {"channel", MagickChannelOptions} } },
369 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
370 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
371 { "Threshold", { {"threshold", StringReference},
372 {"channel", MagickChannelOptions} } },
373 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
374 {"sigma", RealReference} } },
375 { "Trim", { {"fuzz", StringReference} } },
376 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
377 {"wavelength", RealReference},
378 {"interpolate", MagickInterpolateOptions} } },
379 { "Separate", { {"channel", MagickChannelOptions} } },
381 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
382 {"y", IntegerReference} } },
383 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
385 { "GaussianBlur", { {"geometry", StringReference},
386 {"radius", RealReference}, {"sigma", RealReference},
387 {"channel", MagickChannelOptions} } },
388 { "Convolve", { {"coefficients", ArrayReference},
389 {"channel", MagickChannelOptions}, {"bias", StringReference},
390 {"kernel", StringReference} } },
391 { "Profile", { {"name", StringReference}, {"profile", StringReference},
392 { "rendering-intent", MagickIntentOptions},
393 { "black-point-compensation", MagickBooleanOptions} } },
394 { "UnsharpMask", { {"geometry", StringReference},
395 {"radius", RealReference}, {"sigma", RealReference},
396 {"amount", RealReference}, {"threshold", RealReference},
397 {"channel", MagickChannelOptions} } },
398 { "MotionBlur", { {"geometry", StringReference},
399 {"radius", RealReference}, {"sigma", RealReference},
400 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
401 { "OrderedDither", { {"threshold", StringReference},
402 {"channel", MagickChannelOptions} } },
403 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
404 {"height", IntegerReference} } },
405 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
406 {"white-point", RealReference}, {"gamma", RealReference},
407 {"channel", MagickChannelOptions}, {"level", StringReference} } },
408 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
409 { "AffineTransform", { {"affine", ArrayReference},
410 {"translate", StringReference}, {"scale", StringReference},
411 {"rotate", RealReference}, {"skewX", RealReference},
412 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
413 {"background", StringReference} } },
414 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
415 { "AdaptiveThreshold", { {"geometry", StringReference},
416 {"width", IntegerReference}, {"height", IntegerReference},
417 {"bias", RealReference} } },
418 { "Resample", { {"density", StringReference}, {"x", RealReference},
419 {"y", RealReference}, {"filter", MagickFilterOptions},
420 {"support", RealReference }, {"blur", RealReference } } },
421 { "Describe", { {"file", FileReference} } },
422 { "BlackThreshold", { {"threshold", StringReference},
423 {"channel", MagickChannelOptions} } },
424 { "WhiteThreshold", { {"threshold", StringReference},
425 {"channel", MagickChannelOptions} } },
426 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
427 {"channel", MagickChannelOptions} } },
428 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference} } },
431 { "Tint", { {"fill", StringReference}, {"opacity", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
440 {"sigma", RealReference}, {"x", IntegerReference},
441 {"y", IntegerReference} } },
442 { "Identify", { {"file", FileReference}, {"features", StringReference},
443 {"unique", MagickBooleanOptions} } },
444 { "SepiaTone", { {"threshold", RealReference} } },
445 { "SigmoidalContrast", { {"geometry", StringReference},
446 {"contrast", RealReference}, {"mid-point", RealReference},
447 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
448 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
449 {"height", IntegerReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"fuzz", StringReference},
451 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
452 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
453 {"sigma", RealReference}, {"x", IntegerReference},
454 {"y", IntegerReference}, {"background", StringReference} } },
455 { "ContrastStretch", { {"levels", StringReference},
456 {"black-point", RealReference},{"white-point", RealReference},
457 {"channel", MagickChannelOptions} } },
460 { "AdaptiveSharpen", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"channel", MagickChannelOptions} } },
466 { "AdaptiveBlur", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"channel", MagickChannelOptions} } },
469 { "Sketch", { {"geometry", StringReference},
470 {"radius", RealReference}, {"sigma", RealReference},
471 {"angle", RealReference} } },
473 { "AdaptiveResize", { {"geometry", StringReference},
474 {"width", IntegerReference}, {"height", IntegerReference},
475 {"filter", MagickFilterOptions}, {"support", StringReference },
476 {"blur", RealReference } } },
477 { "ClipMask", { {"mask", ImageReference} } },
478 { "LinearStretch", { {"levels", StringReference},
479 {"black-point", RealReference},{"white-point", RealReference} } },
480 { "Recolor", { {"matrix", ArrayReference} } },
481 { "Mask", { {"mask", ImageReference} } },
482 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
483 {"font", StringReference}, {"stroke", StringReference},
484 {"fill", StringReference}, {"strokewidth", RealReference},
485 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
486 {"background", StringReference} } },
487 { "FloodfillPaint", { {"geometry", StringReference},
488 {"x", IntegerReference}, {"y", IntegerReference},
489 {"fill", StringReference}, {"bordercolor", StringReference},
490 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
491 {"invert", MagickBooleanOptions} } },
492 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
493 {"virtual-pixel", MagickVirtualPixelOptions},
494 {"best-fit", MagickBooleanOptions} } },
495 { "Clut", { {"image", ImageReference},
496 {"channel", MagickChannelOptions} } },
497 { "LiquidRescale", { {"geometry", StringReference},
498 {"width", IntegerReference}, {"height", IntegerReference},
499 {"delta-x", RealReference}, {"rigidity", RealReference } } },
500 { "Encipher", { {"passphrase", StringReference} } },
501 { "Decipher", { {"passphrase", StringReference} } },
502 { "Deskew", { {"geometry", StringReference},
503 {"threshold", StringReference} } },
504 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
505 {"dither-method", MagickDitherOptions} } },
506 { "SparseColor", { {"points", ArrayReference},
507 {"method", MagickSparseColorOptions},
508 {"virtual-pixel", MagickVirtualPixelOptions},
509 {"channel", MagickChannelOptions} } },
510 { "Function", { {"parameters", ArrayReference},
511 {"function", MagickFunctionOptions},
512 {"virtual-pixel", MagickVirtualPixelOptions} } },
513 { "SelectiveBlur", { {"geometry", StringReference},
514 {"radius", RealReference}, {"sigma", RealReference},
515 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
516 { "HaldClut", { {"image", ImageReference},
517 {"channel", MagickChannelOptions} } },
518 { "BlueShift", { {"factor", StringReference} } },
519 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
521 { "ColorDecisionList", {
522 {"color-correction-collection", StringReference} } },
523 { "AutoGamma", { {"channel", MagickChannelOptions} } },
524 { "AutoLevel", { {"channel", MagickChannelOptions} } },
525 { "LevelColors", { {"invert", MagickBooleanOptions},
526 {"black-point", StringReference}, {"white-point", StringReference},
527 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
528 { "Clamp", { {"channel", MagickChannelOptions} } },
529 { "BrightnessContrast", { {"levels", StringReference},
530 {"brightness", RealReference},{"contrast", RealReference},
531 {"channel", MagickChannelOptions} } },
532 { "Morphology", { {"kernel", StringReference},
533 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
534 {"iterations", IntegerReference} } },
535 { "ColorMatrix", { {"matrix", ArrayReference} } },
536 { "Color", { {"color", StringReference} } },
537 { "Mode", { {"geometry", StringReference},
538 {"width", IntegerReference},{"height", IntegerReference},
539 {"channel", MagickChannelOptions} } },
540 { "Statistic", { {"geometry", StringReference},
541 {"width", IntegerReference},{"height", IntegerReference},
542 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
546 *magick_registry = (SplayTreeInfo *) NULL;
549 Forward declarations.
552 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
555 strEQcase(const char *,const char *);
558 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
562 % C l o n e P a c k a g e I n f o %
566 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
568 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
571 % The format of the ClonePackageInfo routine is:
573 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
576 % A description of each parameter follows:
578 % o info: a structure of type info.
580 % o exception: Return any errors or warnings in this structure.
583 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
584 ExceptionInfo *exception)
589 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
590 if (clone_info == (struct PackageInfo *) NULL)
592 ThrowPerlException(exception,ResourceLimitError,
593 "UnableToClonePackageInfo",PackageName);
594 return((struct PackageInfo *) NULL);
596 if (info == (struct PackageInfo *) NULL)
598 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
602 clone_info->image_info=CloneImageInfo(info->image_info);
607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
615 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 % constant() returns a double value for the specified name.
619 % The format of the constant routine is:
621 % double constant(char *name,ssize_t sans)
623 % A description of each parameter follows:
625 % o value: Method constant returns a double value for the specified name.
627 % o name: The name of the constant.
629 % o sans: This integer value is not used.
632 static double constant(char *name,ssize_t sans)
640 if (strEQ(name,"BlobError"))
642 if (strEQ(name,"BlobWarning"))
648 if (strEQ(name,"CacheError"))
650 if (strEQ(name,"CacheWarning"))
651 return(CacheWarning);
652 if (strEQ(name,"CoderError"))
654 if (strEQ(name,"CoderWarning"))
655 return(CoderWarning);
656 if (strEQ(name,"ConfigureError"))
657 return(ConfigureError);
658 if (strEQ(name,"ConfigureWarning"))
659 return(ConfigureWarning);
660 if (strEQ(name,"CorruptImageError"))
661 return(CorruptImageError);
662 if (strEQ(name,"CorruptImageWarning"))
663 return(CorruptImageWarning);
668 if (strEQ(name,"DelegateError"))
669 return(DelegateError);
670 if (strEQ(name,"DelegateWarning"))
671 return(DelegateWarning);
672 if (strEQ(name,"DrawError"))
674 if (strEQ(name,"DrawWarning"))
680 if (strEQ(name,"ErrorException"))
681 return(ErrorException);
682 if (strEQ(name,"ExceptionError"))
684 if (strEQ(name,"ExceptionWarning"))
685 return(CoderWarning);
690 if (strEQ(name,"FatalErrorException"))
691 return(FatalErrorException);
692 if (strEQ(name,"FileOpenError"))
693 return(FileOpenError);
694 if (strEQ(name,"FileOpenWarning"))
695 return(FileOpenWarning);
700 if (strEQ(name,"ImageError"))
702 if (strEQ(name,"ImageWarning"))
703 return(ImageWarning);
708 if (strEQ(name,"MaxRGB"))
709 return(QuantumRange);
710 if (strEQ(name,"MissingDelegateError"))
711 return(MissingDelegateError);
712 if (strEQ(name,"MissingDelegateWarning"))
713 return(MissingDelegateWarning);
714 if (strEQ(name,"ModuleError"))
716 if (strEQ(name,"ModuleWarning"))
717 return(ModuleWarning);
722 if (strEQ(name,"Opaque"))
724 if (strEQ(name,"OptionError"))
726 if (strEQ(name,"OptionWarning"))
727 return(OptionWarning);
732 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
733 return(MAGICKCORE_QUANTUM_DEPTH);
734 if (strEQ(name,"QuantumDepth"))
735 return(MAGICKCORE_QUANTUM_DEPTH);
736 if (strEQ(name,"QuantumRange"))
737 return(QuantumRange);
742 if (strEQ(name,"ResourceLimitError"))
743 return(ResourceLimitError);
744 if (strEQ(name,"ResourceLimitWarning"))
745 return(ResourceLimitWarning);
746 if (strEQ(name,"RegistryError"))
747 return(RegistryError);
748 if (strEQ(name,"RegistryWarning"))
749 return(RegistryWarning);
754 if (strEQ(name,"StreamError"))
756 if (strEQ(name,"StreamWarning"))
757 return(StreamWarning);
758 if (strEQ(name,"Success"))
764 if (strEQ(name,"Transparent"))
765 return(TransparentAlpha);
766 if (strEQ(name,"TypeError"))
768 if (strEQ(name,"TypeWarning"))
774 if (strEQ(name,"WarningException"))
775 return(WarningException);
780 if (strEQ(name,"XServerError"))
781 return(XServerError);
782 if (strEQ(name,"XServerWarning"))
783 return(XServerWarning);
792 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
796 % D e s t r o y P a c k a g e I n f o %
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
802 % Method DestroyPackageInfo frees a previously created info structure.
804 % The format of the DestroyPackageInfo routine is:
806 % DestroyPackageInfo(struct PackageInfo *info)
808 % A description of each parameter follows:
810 % o info: a structure of type info.
813 static void DestroyPackageInfo(struct PackageInfo *info)
815 info->image_info=DestroyImageInfo(info->image_info);
816 info=(struct PackageInfo *) RelinquishMagickMemory(info);
820 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
830 % Method GetList is recursively called by SetupList to traverse the
831 % Image__Magick reference. If building an reference_vector (see SetupList),
832 % *current is the current position in *reference_vector and *last is the final
833 % entry in *reference_vector.
835 % The format of the GetList routine is:
839 % A description of each parameter follows:
841 % o info: a structure of type info.
844 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
845 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
850 if (reference == (SV *) NULL)
852 switch (SvTYPE(reference))
872 previous=(Image *) NULL;
876 for (i=0; i <= n; i++)
882 if (rv && *rv && sv_isobject(*rv))
884 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
886 if (image == (Image *) NULL)
888 if (image == previous)
890 image=CloneImage(image,0,0,MagickTrue,exception);
891 if (image == (Image *) NULL)
894 image->previous=previous;
895 *(previous ? &previous->next : &head)=image;
896 for (previous=image; previous->next; previous=previous->next) ;
904 Blessed scalar, one image.
906 image=(Image *) SvIV(reference);
907 if (image == (Image *) NULL)
909 image->previous=(Image *) NULL;
910 image->next=(Image *) NULL;
911 if (reference_vector)
913 if (*current == *last)
916 if (*reference_vector == (SV **) NULL)
917 *reference_vector=(SV **) AcquireQuantumMemory(*last,
918 sizeof(*reference_vector));
920 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
921 *last,sizeof(*reference_vector));
923 if (*reference_vector == (SV **) NULL)
925 ThrowPerlException(exception,ResourceLimitError,
926 "MemoryAllocationFailed",PackageName);
927 return((Image *) NULL);
929 (*reference_vector)[*current]=reference;
930 (*reference_vector)[++(*current)]=NULL;
937 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
938 (double) SvTYPE(reference));
939 return((Image *) NULL);
943 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
947 % G e t P a c k a g e I n f o %
951 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
953 % Method GetPackageInfo looks up or creates an info structure for the given
954 % Image__Magick reference. If it does create a new one, the information in
955 % package_info is used to initialize it.
957 % The format of the GetPackageInfo routine is:
959 % struct PackageInfo *GetPackageInfo(void *reference,
960 % struct PackageInfo *package_info,ExceptionInfo *exception)
962 % A description of each parameter follows:
964 % o info: a structure of type info.
966 % o exception: Return any errors or warnings in this structure.
969 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
970 struct PackageInfo *package_info,ExceptionInfo *exception)
973 message[MaxTextExtent];
981 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
982 PackageName,XS_VERSION,reference);
983 sv=perl_get_sv(message,(TRUE | 0x02));
984 if (sv == (SV *) NULL)
986 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
988 return(package_info);
990 if (SvREFCNT(sv) == 0)
991 (void) SvREFCNT_inc(sv);
992 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
994 clone_info=ClonePackageInfo(package_info,exception);
995 sv_setiv(sv,(IV) clone_info);
1000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1004 % S e t A t t r i b u t e %
1008 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1010 % SetAttribute() sets the attribute to the value in sval. This can change
1011 % either or both of image or info.
1013 % The format of the SetAttribute routine is:
1015 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1016 % SV *sval,ExceptionInfo *exception)
1018 % A description of each parameter follows:
1020 % o list: a list of strings.
1022 % o string: a character string.
1026 static double SiPrefixToDouble(const char *string,const double interval)
1035 value=InterpretLocaleValue(string,&q);
1037 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1039 switch (tolower((int) ((unsigned char) *q)))
1041 case '%': value*=pow(scale,0)*interval/100.0; break;
1042 case 'k': value*=pow(scale,1); break;
1043 case 'm': value*=pow(scale,2); break;
1044 case 'g': value*=pow(scale,3); break;
1045 case 't': value*=pow(scale,4); break;
1046 case 'p': value*=pow(scale,5); break;
1047 case 'e': value*=pow(scale,6); break;
1048 case 'z': value*=pow(scale,7); break;
1049 case 'y': value*=pow(scale,8); break;
1055 static inline ssize_t StringToLong(const char *value)
1057 return(strtol(value,(char **) NULL,10));
1060 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1061 const char *attribute,SV *sval,ExceptionInfo *exception)
1088 if (LocaleCompare(attribute,"adjoin") == 0)
1090 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1091 SvPV(sval,na)) : SvIV(sval);
1094 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1099 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1102 if (LocaleCompare(attribute,"alpha") == 0)
1104 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1105 SvPV(sval,na)) : SvIV(sval);
1108 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1112 for ( ; image; image=image->next)
1113 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
1116 if (LocaleCompare(attribute,"antialias") == 0)
1118 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1119 SvPV(sval,na)) : SvIV(sval);
1122 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1127 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1130 if (LocaleCompare(attribute,"area-limit") == 0)
1135 limit=MagickResourceInfinity;
1136 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1137 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1138 (void) SetMagickResourceLimit(AreaResource,limit);
1141 if (LocaleCompare(attribute,"attenuate") == 0)
1144 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1147 if (LocaleCompare(attribute,"authenticate") == 0)
1150 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1154 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1155 for ( ; image; image=image->next)
1156 SetImageProperty(image,attribute,SvPV(sval,na));
1162 if (LocaleCompare(attribute,"background") == 0)
1164 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1166 info->image_info->background_color=target_color;
1167 for ( ; image; image=image->next)
1168 image->background_color=target_color;
1171 if (LocaleCompare(attribute,"bias") == 0)
1173 for ( ; image; image=image->next)
1174 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1177 if (LocaleCompare(attribute,"blue-primary") == 0)
1179 for ( ; image; image=image->next)
1181 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1182 image->chromaticity.blue_primary.x=geometry_info.rho;
1183 image->chromaticity.blue_primary.y=geometry_info.sigma;
1184 if ((flags & SigmaValue) == 0)
1185 image->chromaticity.blue_primary.y=
1186 image->chromaticity.blue_primary.x;
1190 if (LocaleCompare(attribute,"bordercolor") == 0)
1192 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1194 info->image_info->border_color=target_color;
1195 for ( ; image; image=image->next)
1196 image->border_color=target_color;
1200 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1201 for ( ; image; image=image->next)
1202 SetImageProperty(image,attribute,SvPV(sval,na));
1208 if (LocaleCompare(attribute,"cache-threshold") == 0)
1210 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1211 SiPrefixToDouble(SvPV(sval,na),100.0));
1212 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1213 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1216 if (LocaleCompare(attribute,"clip-mask") == 0)
1221 clip_mask=(Image *) NULL;
1223 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1224 for ( ; image; image=image->next)
1225 SetImageClipMask(image,clip_mask);
1228 if (LocaleNCompare(attribute,"colormap",8) == 0)
1230 for ( ; image; image=image->next)
1238 if (image->storage_class == DirectClass)
1241 items=sscanf(attribute,"%*[^[][%ld",&i);
1243 if (i > (ssize_t) image->colors)
1245 if ((strchr(SvPV(sval,na),',') == 0) ||
1246 (strchr(SvPV(sval,na),')') != 0))
1247 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1250 color=image->colormap+i;
1251 pixel.red=color->red;
1252 pixel.green=color->green;
1253 pixel.blue=color->blue;
1254 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1255 pixel.red=geometry_info.rho;
1256 pixel.green=geometry_info.sigma;
1257 pixel.blue=geometry_info.xi;
1258 color->red=ClampToQuantum(pixel.red);
1259 color->green=ClampToQuantum(pixel.green);
1260 color->blue=ClampToQuantum(pixel.blue);
1265 if (LocaleCompare(attribute,"colorspace") == 0)
1267 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1268 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1271 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1275 for ( ; image; image=image->next)
1276 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1279 if (LocaleCompare(attribute,"comment") == 0)
1281 for ( ; image; image=image->next)
1282 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1283 info ? info->image_info : (ImageInfo *) NULL,image,
1287 if (LocaleCompare(attribute,"compression") == 0)
1289 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1290 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1293 ThrowPerlException(exception,OptionError,
1294 "UnrecognizedImageCompression",SvPV(sval,na));
1298 info->image_info->compression=(CompressionType) sp;
1299 for ( ; image; image=image->next)
1300 image->compression=(CompressionType) sp;
1304 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1305 for ( ; image; image=image->next)
1306 SetImageProperty(image,attribute,SvPV(sval,na));
1312 if (LocaleCompare(attribute,"debug") == 0)
1314 SetLogEventMask(SvPV(sval,na));
1317 if (LocaleCompare(attribute,"delay") == 0)
1319 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1320 for ( ; image; image=image->next)
1322 image->delay=(size_t) floor(geometry_info.rho+0.5);
1323 if ((flags & SigmaValue) != 0)
1324 image->ticks_per_second=(ssize_t)
1325 floor(geometry_info.sigma+0.5);
1329 if (LocaleCompare(attribute,"disk-limit") == 0)
1334 limit=MagickResourceInfinity;
1335 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1336 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1337 (void) SetMagickResourceLimit(DiskResource,limit);
1340 if (LocaleCompare(attribute,"density") == 0)
1342 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1344 ThrowPerlException(exception,OptionError,"MissingGeometry",
1349 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1350 for ( ; image; image=image->next)
1352 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1353 image->x_resolution=geometry_info.rho;
1354 image->y_resolution=geometry_info.sigma;
1355 if ((flags & SigmaValue) == 0)
1356 image->y_resolution=image->x_resolution;
1360 if (LocaleCompare(attribute,"depth") == 0)
1363 info->image_info->depth=SvIV(sval);
1364 for ( ; image; image=image->next)
1365 (void) SetImageDepth(image,SvIV(sval));
1368 if (LocaleCompare(attribute,"dispose") == 0)
1370 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1371 SvPV(sval,na)) : SvIV(sval);
1374 ThrowPerlException(exception,OptionError,
1375 "UnrecognizedDisposeMethod",SvPV(sval,na));
1378 for ( ; image; image=image->next)
1379 image->dispose=(DisposeType) sp;
1382 if (LocaleCompare(attribute,"dither") == 0)
1386 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1387 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1390 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1394 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1398 if (LocaleCompare(attribute,"display") == 0)
1402 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1406 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1407 for ( ; image; image=image->next)
1408 SetImageProperty(image,attribute,SvPV(sval,na));
1414 if (LocaleCompare(attribute,"endian") == 0)
1416 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1417 SvPV(sval,na)) : SvIV(sval);
1420 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1425 info->image_info->endian=(EndianType) sp;
1426 for ( ; image; image=image->next)
1427 image->endian=(EndianType) sp;
1430 if (LocaleCompare(attribute,"extract") == 0)
1433 Set image extract geometry.
1435 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1439 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1440 for ( ; image; image=image->next)
1441 SetImageProperty(image,attribute,SvPV(sval,na));
1447 if (LocaleCompare(attribute,"filename") == 0)
1450 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1452 for ( ; image; image=image->next)
1453 (void) CopyMagickString(image->filename,SvPV(sval,na),
1457 if (LocaleCompare(attribute,"file") == 0)
1465 if (info == (struct PackageInfo *) NULL)
1467 io_info=IoIFP(sv_2io(sval));
1468 if (io_info == (PerlIO *) NULL)
1470 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1474 file=PerlIO_findFILE(io_info);
1475 if (file == (FILE *) NULL)
1477 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1481 SetImageInfoFile(info->image_info,file);
1484 if (LocaleCompare(attribute,"fill") == 0)
1487 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1490 if (LocaleCompare(attribute,"font") == 0)
1493 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1496 if (LocaleCompare(attribute,"foreground") == 0)
1498 if (LocaleCompare(attribute,"fuzz") == 0)
1501 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1502 for ( ; image; image=image->next)
1503 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1507 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1508 for ( ; image; image=image->next)
1509 SetImageProperty(image,attribute,SvPV(sval,na));
1515 if (LocaleCompare(attribute,"gamma") == 0)
1517 for ( ; image; image=image->next)
1518 image->gamma=SvNV(sval);
1521 if (LocaleCompare(attribute,"gravity") == 0)
1523 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1524 SvPV(sval,na)) : SvIV(sval);
1527 ThrowPerlException(exception,OptionError,
1528 "UnrecognizedGravityType",SvPV(sval,na));
1532 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1533 for ( ; image; image=image->next)
1534 image->gravity=(GravityType) sp;
1537 if (LocaleCompare(attribute,"green-primary") == 0)
1539 for ( ; image; image=image->next)
1541 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1542 image->chromaticity.green_primary.x=geometry_info.rho;
1543 image->chromaticity.green_primary.y=geometry_info.sigma;
1544 if ((flags & SigmaValue) == 0)
1545 image->chromaticity.green_primary.y=
1546 image->chromaticity.green_primary.x;
1551 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1552 for ( ; image; image=image->next)
1553 SetImageProperty(image,attribute,SvPV(sval,na));
1559 if (LocaleNCompare(attribute,"index",5) == 0)
1573 for ( ; image; image=image->next)
1575 if (image->storage_class != PseudoClass)
1579 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1581 image_view=AcquireCacheView(image);
1582 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1583 if (q != (Quantum *) NULL)
1585 items=sscanf(SvPV(sval,na),"%ld",&index);
1586 if ((index >= 0) && (index < (ssize_t) image->colors))
1587 SetPixelIndex(image,index,q);
1588 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1590 image_view=DestroyCacheView(image_view);
1594 if (LocaleCompare(attribute,"iterations") == 0)
1597 for ( ; image; image=image->next)
1598 image->iterations=SvIV(sval);
1601 if (LocaleCompare(attribute,"interlace") == 0)
1603 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1604 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1607 ThrowPerlException(exception,OptionError,
1608 "UnrecognizedInterlaceType",SvPV(sval,na));
1612 info->image_info->interlace=(InterlaceType) sp;
1613 for ( ; image; image=image->next)
1614 image->interlace=(InterlaceType) sp;
1618 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1619 for ( ; image; image=image->next)
1620 SetImageProperty(image,attribute,SvPV(sval,na));
1626 if (LocaleCompare(attribute,"label") == 0)
1628 for ( ; image; image=image->next)
1629 (void) SetImageProperty(image,"label",InterpretImageProperties(
1630 info ? info->image_info : (ImageInfo *) NULL,image,
1634 if (LocaleCompare(attribute,"loop") == 0)
1637 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1638 for ( ; image; image=image->next)
1639 SetImageProperty(image,attribute,SvPV(sval,na));
1645 if (LocaleCompare(attribute,"magick") == 0)
1648 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1649 "%s:",SvPV(sval,na));
1650 for ( ; image; image=image->next)
1651 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1654 if (LocaleCompare(attribute,"map-limit") == 0)
1659 limit=MagickResourceInfinity;
1660 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1661 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1662 (void) SetMagickResourceLimit(MapResource,limit);
1665 if (LocaleCompare(attribute,"mask") == 0)
1670 mask=(Image *) NULL;
1672 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1673 for ( ; image; image=image->next)
1674 SetImageMask(image,mask);
1677 if (LocaleCompare(attribute,"mattecolor") == 0)
1679 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1681 info->image_info->matte_color=target_color;
1682 for ( ; image; image=image->next)
1683 image->matte_color=target_color;
1686 if (LocaleCompare(attribute,"matte") == 0)
1688 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1689 SvPV(sval,na)) : SvIV(sval);
1692 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1696 for ( ; image; image=image->next)
1697 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1700 if (LocaleCompare(attribute,"memory-limit") == 0)
1705 limit=MagickResourceInfinity;
1706 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1707 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1708 (void) SetMagickResourceLimit(MemoryResource,limit);
1711 if (LocaleCompare(attribute,"monochrome") == 0)
1713 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1714 SvPV(sval,na)) : SvIV(sval);
1717 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1722 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1723 for ( ; image; image=image->next)
1724 (void) SetImageType(image,BilevelType);
1728 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1729 for ( ; image; image=image->next)
1730 SetImageProperty(image,attribute,SvPV(sval,na));
1736 if (LocaleCompare(attribute,"option") == 0)
1739 DefineImageOption(info->image_info,SvPV(sval,na));
1742 if (LocaleCompare(attribute,"orientation") == 0)
1744 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1745 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1748 ThrowPerlException(exception,OptionError,
1749 "UnrecognizedOrientationType",SvPV(sval,na));
1753 info->image_info->orientation=(OrientationType) sp;
1754 for ( ; image; image=image->next)
1755 image->orientation=(OrientationType) sp;
1759 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1760 for ( ; image; image=image->next)
1761 SetImageProperty(image,attribute,SvPV(sval,na));
1767 if (LocaleCompare(attribute,"page") == 0)
1772 geometry=GetPageGeometry(SvPV(sval,na));
1774 (void) CloneString(&info->image_info->page,geometry);
1775 for ( ; image; image=image->next)
1776 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1777 geometry=(char *) RelinquishMagickMemory(geometry);
1780 if (LocaleCompare(attribute,"pen") == 0)
1783 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1786 if (LocaleNCompare(attribute,"pixel",5) == 0)
1800 for ( ; image; image=image->next)
1802 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1806 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1808 image_view=AcquireCacheView(image);
1809 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1810 if (q != (Quantum *) NULL)
1812 if ((strchr(SvPV(sval,na),',') == 0) ||
1813 (strchr(SvPV(sval,na),')') != 0))
1814 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1817 GetPixelInfo(image,&pixel);
1818 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1819 pixel.red=geometry_info.rho;
1820 if ((flags & SigmaValue) != 0)
1821 pixel.green=geometry_info.sigma;
1822 if ((flags & XiValue) != 0)
1823 pixel.blue=geometry_info.xi;
1824 if ((flags & PsiValue) != 0)
1825 pixel.alpha=geometry_info.psi;
1826 if ((flags & ChiValue) != 0)
1827 pixel.black=geometry_info.chi;
1829 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1830 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1831 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1832 if (image->colorspace == CMYKColorspace)
1833 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1834 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1835 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1837 image_view=DestroyCacheView(image_view);
1841 if (LocaleCompare(attribute,"pointsize") == 0)
1845 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1846 info->image_info->pointsize=geometry_info.rho;
1850 if (LocaleCompare(attribute,"preview") == 0)
1852 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1853 SvPV(sval,na)) : SvIV(sval);
1856 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1861 info->image_info->preview_type=(PreviewType) sp;
1865 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1866 for ( ; image; image=image->next)
1867 SetImageProperty(image,attribute,SvPV(sval,na));
1873 if (LocaleCompare(attribute,"quality") == 0)
1876 info->image_info->quality=SvIV(sval);
1877 for ( ; image; image=image->next)
1878 image->quality=SvIV(sval);
1882 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1883 for ( ; image; image=image->next)
1884 SetImageProperty(image,attribute,SvPV(sval,na));
1890 if (LocaleCompare(attribute,"red-primary") == 0)
1892 for ( ; image; image=image->next)
1894 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1895 image->chromaticity.red_primary.x=geometry_info.rho;
1896 image->chromaticity.red_primary.y=geometry_info.sigma;
1897 if ((flags & SigmaValue) == 0)
1898 image->chromaticity.red_primary.y=
1899 image->chromaticity.red_primary.x;
1903 if (LocaleCompare(attribute,"render") == 0)
1905 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1906 SvPV(sval,na)) : SvIV(sval);
1909 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1913 for ( ; image; image=image->next)
1914 image->rendering_intent=(RenderingIntent) sp;
1917 if (LocaleCompare(attribute,"repage") == 0)
1922 for ( ; image; image=image->next)
1924 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1925 if ((flags & WidthValue) != 0)
1927 if ((flags & HeightValue) == 0)
1928 geometry.height=geometry.width;
1929 image->page.width=geometry.width;
1930 image->page.height=geometry.height;
1932 if ((flags & AspectValue) != 0)
1934 if ((flags & XValue) != 0)
1935 image->page.x+=geometry.x;
1936 if ((flags & YValue) != 0)
1937 image->page.y+=geometry.y;
1941 if ((flags & XValue) != 0)
1943 image->page.x=geometry.x;
1944 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1945 image->page.width=image->columns+geometry.x;
1947 if ((flags & YValue) != 0)
1949 image->page.y=geometry.y;
1950 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1951 image->page.height=image->rows+geometry.y;
1958 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1959 for ( ; image; image=image->next)
1960 SetImageProperty(image,attribute,SvPV(sval,na));
1966 if (LocaleCompare(attribute,"sampling-factor") == 0)
1968 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1970 ThrowPerlException(exception,OptionError,"MissingGeometry",
1975 (void) CloneString(&info->image_info->sampling_factor,
1979 if (LocaleCompare(attribute,"scene") == 0)
1981 for ( ; image; image=image->next)
1982 image->scene=SvIV(sval);
1985 if (LocaleCompare(attribute,"server") == 0)
1987 if (LocaleCompare(attribute,"size") == 0)
1991 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1993 ThrowPerlException(exception,OptionError,"MissingGeometry",
1997 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2001 if (LocaleCompare(attribute,"stroke") == 0)
2004 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2008 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2009 for ( ; image; image=image->next)
2010 SetImageProperty(image,attribute,SvPV(sval,na));
2016 if (LocaleCompare(attribute,"texture") == 0)
2019 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2022 if (LocaleCompare(attribute,"thread-limit") == 0)
2027 limit=MagickResourceInfinity;
2028 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2029 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2030 (void) SetMagickResourceLimit(ThreadResource,limit);
2033 if (LocaleCompare(attribute,"tile-offset") == 0)
2038 geometry=GetPageGeometry(SvPV(sval,na));
2040 (void) CloneString(&info->image_info->page,geometry);
2041 for ( ; image; image=image->next)
2042 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2044 geometry=(char *) RelinquishMagickMemory(geometry);
2047 if (LocaleCompare(attribute,"time-limit") == 0)
2052 limit=MagickResourceInfinity;
2053 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2054 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2055 (void) SetMagickResourceLimit(TimeResource,limit);
2058 if (LocaleCompare(attribute,"transparent-color") == 0)
2060 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2062 info->image_info->transparent_color=target_color;
2063 for ( ; image; image=image->next)
2064 image->transparent_color=target_color;
2067 if (LocaleCompare(attribute,"type") == 0)
2069 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2070 SvPV(sval,na)) : SvIV(sval);
2073 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2078 info->image_info->type=(ImageType) sp;
2079 for ( ; image; image=image->next)
2080 SetImageType(image,(ImageType) sp);
2084 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2085 for ( ; image; image=image->next)
2086 SetImageProperty(image,attribute,SvPV(sval,na));
2092 if (LocaleCompare(attribute,"units") == 0)
2094 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2095 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2098 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2103 info->image_info->units=(ResolutionType) sp;
2104 for ( ; image; image=image->next)
2109 units=(ResolutionType) sp;
2110 if (image->units != units)
2111 switch (image->units)
2113 case UndefinedResolution:
2114 case PixelsPerInchResolution:
2116 if (units == PixelsPerCentimeterResolution)
2118 image->x_resolution*=2.54;
2119 image->y_resolution*=2.54;
2123 case PixelsPerCentimeterResolution:
2125 if (units == PixelsPerInchResolution)
2127 image->x_resolution/=2.54;
2128 image->y_resolution/=2.54;
2138 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2139 for ( ; image; image=image->next)
2140 SetImageProperty(image,attribute,SvPV(sval,na));
2146 if (LocaleCompare(attribute,"verbose") == 0)
2148 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2149 SvPV(sval,na)) : SvIV(sval);
2152 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2157 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2160 if (LocaleCompare(attribute,"view") == 0)
2163 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2166 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2168 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2169 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2172 ThrowPerlException(exception,OptionError,
2173 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2177 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2178 for ( ; image; image=image->next)
2179 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2183 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2184 for ( ; image; image=image->next)
2185 SetImageProperty(image,attribute,SvPV(sval,na));
2191 if (LocaleCompare(attribute,"white-point") == 0)
2193 for ( ; image; image=image->next)
2195 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2196 image->chromaticity.white_point.x=geometry_info.rho;
2197 image->chromaticity.white_point.y=geometry_info.sigma;
2198 if ((flags & SigmaValue) == 0)
2199 image->chromaticity.white_point.y=
2200 image->chromaticity.white_point.x;
2205 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2206 for ( ; image; image=image->next)
2207 SetImageProperty(image,attribute,SvPV(sval,na));
2213 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2214 for ( ; image; image=image->next)
2215 SetImageProperty(image,attribute,SvPV(sval,na));
2222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2226 % S e t u p L i s t %
2230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2232 % Method SetupList returns the list of all the images linked by their
2233 % image->next and image->previous link lists for use with ImageMagick. If
2234 % info is non-NULL, an info structure is returned in *info. If
2235 % reference_vector is non-NULL,an array of SV* are returned in
2236 % *reference_vector. Reference_vector is used when the images are going to be
2237 % replaced with new Image*'s.
2239 % The format of the SetupList routine is:
2241 % Image *SetupList(SV *reference,struct PackageInfo **info,
2242 % SV ***reference_vector,ExceptionInfo *exception)
2244 % A description of each parameter follows:
2246 % o list: a list of strings.
2248 % o string: a character string.
2250 % o exception: Return any errors or warnings in this structure.
2253 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2254 SV ***reference_vector,ExceptionInfo *exception)
2263 if (reference_vector)
2264 *reference_vector=NULL;
2269 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2270 if (info && (SvTYPE(reference) == SVt_PVAV))
2271 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2281 % s t r E Q c a s e %
2285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2287 % strEQcase() compares two strings and returns 0 if they are the
2288 % same or if the second string runs out first. The comparison is case
2291 % The format of the strEQcase routine is:
2293 % ssize_t strEQcase(const char *p,const char *q)
2295 % A description of each parameter follows:
2297 % o p: a character string.
2299 % o q: a character string.
2303 static ssize_t strEQcase(const char *p,const char *q)
2311 for (i=0 ; (c=(*q)) != 0; i++)
2313 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2314 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2319 return(((*q == 0) && (*p == 0)) ? i : 0);
2323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2327 % I m a g e : : M a g i c k %
2331 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2335 MODULE = Image::Magick PACKAGE = Image::Magick
2340 MagickCoreGenesis("PerlMagick",MagickFalse);
2341 SetWarningHandler(NULL);
2342 SetErrorHandler(NULL);
2343 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2344 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2350 if (magick_registry != (SplayTreeInfo *) NULL)
2351 magick_registry=DestroySplayTree(magick_registry);
2352 MagickCoreTerminus();
2356 constant(name,argument)
2361 ###############################################################################
2369 ###############################################################################
2374 Image::Magick ref=NO_INIT
2398 PERL_UNUSED_VAR(ref);
2399 PERL_UNUSED_VAR(ix);
2400 exception=AcquireExceptionInfo();
2401 perl_exception=newSVpv("",0);
2402 package_info=(struct PackageInfo *) NULL;
2403 if (sv_isobject(ST(0)) == 0)
2405 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2409 reference=SvRV(ST(0));
2410 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2411 if (image == (Image *) NULL)
2413 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2417 package_info=ClonePackageInfo(info,exception);
2419 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2422 for (i=2; i < items; i+=2)
2423 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2425 (void) AnimateImages(package_info->image_info,image);
2426 (void) CatchImageException(image);
2427 InheritException(exception,&image->exception);
2430 if (package_info != (struct PackageInfo *) NULL)
2431 DestroyPackageInfo(package_info);
2432 InheritPerlException(exception,perl_exception);
2433 exception=DestroyExceptionInfo(exception);
2434 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2435 SvPOK_on(perl_exception);
2436 ST(0)=sv_2mortal(perl_exception);
2441 ###############################################################################
2449 ###############################################################################
2454 Image::Magick ref=NO_INIT
2492 PERL_UNUSED_VAR(ref);
2493 PERL_UNUSED_VAR(ix);
2494 exception=AcquireExceptionInfo();
2495 perl_exception=newSVpv("",0);
2499 if (sv_isobject(ST(0)) == 0)
2501 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2505 reference=SvRV(ST(0));
2506 hv=SvSTASH(reference);
2508 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2510 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2511 if (image == (Image *) NULL)
2513 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2517 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2522 for (i=2; i < items; i+=2)
2524 attribute=(char *) SvPV(ST(i-1),na);
2530 if (LocaleCompare(attribute,"stack") == 0)
2532 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2536 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2542 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2548 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2554 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2555 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2557 for ( ; image; image=image->next)
2559 AddImageToRegistry(sv,image);
2561 av_push(av,sv_bless(rv,hv));
2564 exception=DestroyExceptionInfo(exception);
2566 SvREFCNT_dec(perl_exception);
2570 InheritPerlException(exception,perl_exception);
2571 exception=DestroyExceptionInfo(exception);
2572 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2573 SvPOK_on(perl_exception);
2574 ST(0)=sv_2mortal(perl_exception);
2579 ###############################################################################
2587 ###############################################################################
2592 Image::Magick ref=NO_INIT
2623 PERL_UNUSED_VAR(ref);
2624 PERL_UNUSED_VAR(ix);
2625 exception=AcquireExceptionInfo();
2626 perl_exception=newSVpv("",0);
2628 if (sv_isobject(ST(0)) == 0)
2630 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2634 reference=SvRV(ST(0));
2635 hv=SvSTASH(reference);
2636 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2637 if (image == (Image *) NULL)
2639 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2643 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2644 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2647 Create blessed Perl array for the returned image.
2650 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2652 AddImageToRegistry(sv,image);
2654 av_push(av,sv_bless(rv,hv));
2656 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2657 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2658 "average-%.*s",(int) (MaxTextExtent-9),
2659 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2660 (void) CopyMagickString(image->filename,info->image_info->filename,
2662 SetImageInfo(info->image_info,0,exception);
2663 exception=DestroyExceptionInfo(exception);
2664 SvREFCNT_dec(perl_exception);
2668 InheritPerlException(exception,perl_exception);
2669 exception=DestroyExceptionInfo(exception);
2670 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2671 SvPOK_on(perl_exception);
2672 ST(0)=sv_2mortal(perl_exception);
2677 ###############################################################################
2681 # B l o b T o I m a g e #
2685 ###############################################################################
2689 BlobToImage(ref,...)
2690 Image::Magick ref=NO_INIT
2736 PERL_UNUSED_VAR(ref);
2737 PERL_UNUSED_VAR(ix);
2738 exception=AcquireExceptionInfo();
2739 perl_exception=newSVpv("",0);
2742 ac=(items < 2) ? 1 : items-1;
2743 length=(STRLEN *) NULL;
2744 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2745 if (list == (char **) NULL)
2747 ThrowPerlException(exception,ResourceLimitError,
2748 "MemoryAllocationFailed",PackageName);
2751 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2752 if (length == (STRLEN *) NULL)
2754 ThrowPerlException(exception,ResourceLimitError,
2755 "MemoryAllocationFailed",PackageName);
2758 if (sv_isobject(ST(0)) == 0)
2760 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2764 reference=SvRV(ST(0));
2765 hv=SvSTASH(reference);
2766 if (SvTYPE(reference) != SVt_PVAV)
2768 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2772 av=(AV *) reference;
2773 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2778 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2781 for (n=0, i=0; i < ac; i++)
2783 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2784 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2786 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2791 list[n]=(char *) NULL;
2793 for (i=number_images=0; i < n; i++)
2795 image=BlobToImage(info->image_info,list[i],length[i],exception);
2796 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2798 for ( ; image; image=image->next)
2800 AddImageToRegistry(sv,image);
2802 av_push(av,sv_bless(rv,hv));
2810 for (i=0; i < n; i++)
2811 if (list[i] != (char *) NULL)
2812 for (p=keep; list[i] != *p++; )
2813 if (*p == (char *) NULL)
2815 list[i]=(char *) RelinquishMagickMemory(list[i]);
2821 list=(char **) RelinquishMagickMemory(list);
2823 length=(STRLEN *) RelinquishMagickMemory(length);
2824 InheritPerlException(exception,perl_exception);
2825 exception=DestroyExceptionInfo(exception);
2826 sv_setiv(perl_exception,(IV) number_images);
2827 SvPOK_on(perl_exception);
2828 ST(0)=sv_2mortal(perl_exception);
2833 ###############################################################################
2841 ###############################################################################
2846 Image::Magick ref=NO_INIT
2879 PERL_UNUSED_VAR(ref);
2880 PERL_UNUSED_VAR(ix);
2881 exception=AcquireExceptionInfo();
2882 perl_exception=newSVpv("",0);
2884 if (sv_isobject(ST(0)) == 0)
2886 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2890 reference=SvRV(ST(0));
2891 hv=SvSTASH(reference);
2892 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2893 if (image == (Image *) NULL)
2895 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2900 Create blessed Perl array for the returned image.
2903 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2905 for ( ; image; image=image->next)
2907 clone=CloneImage(image,0,0,MagickTrue,exception);
2908 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2910 AddImageToRegistry(sv,clone);
2912 av_push(av,sv_bless(rv,hv));
2915 exception=DestroyExceptionInfo(exception);
2916 SvREFCNT_dec(perl_exception);
2920 InheritPerlException(exception,perl_exception);
2921 exception=DestroyExceptionInfo(exception);
2922 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2923 SvPOK_on(perl_exception);
2924 ST(0)=sv_2mortal(perl_exception);
2929 ###############################################################################
2937 ###############################################################################
2945 PERL_UNUSED_VAR(ref);
2946 if (magick_registry != (SplayTreeInfo *) NULL)
2951 ResetSplayTreeIterator(magick_registry);
2952 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2953 while (p != (Image *) NULL)
2956 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2962 ###############################################################################
2970 ###############################################################################
2975 Image::Magick ref=NO_INIT
3004 PERL_UNUSED_VAR(ref);
3005 PERL_UNUSED_VAR(ix);
3006 exception=AcquireExceptionInfo();
3007 perl_exception=newSVpv("",0);
3009 if (sv_isobject(ST(0)) == 0)
3011 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3015 reference=SvRV(ST(0));
3016 hv=SvSTASH(reference);
3018 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3020 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3021 if (image == (Image *) NULL)
3023 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3027 image=CoalesceImages(image,exception);
3028 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3030 for ( ; image; image=image->next)
3032 AddImageToRegistry(sv,image);
3034 av_push(av,sv_bless(rv,hv));
3037 exception=DestroyExceptionInfo(exception);
3039 SvREFCNT_dec(perl_exception);
3043 InheritPerlException(exception,perl_exception);
3044 exception=DestroyExceptionInfo(exception);
3045 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3046 SvPOK_on(perl_exception);
3047 ST(0)=sv_2mortal(perl_exception);
3052 ###############################################################################
3060 ###############################################################################
3065 Image::Magick ref=NO_INIT
3111 PERL_UNUSED_VAR(ref);
3112 PERL_UNUSED_VAR(ix);
3113 exception=AcquireExceptionInfo();
3114 perl_exception=newSVpv("",0);
3118 if (sv_isobject(ST(0)) == 0)
3120 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3124 reference=SvRV(ST(0));
3125 hv=SvSTASH(reference);
3127 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3129 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3130 if (image == (Image *) NULL)
3132 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3136 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3140 reconstruct_image=image;
3141 metric=RootMeanSquaredErrorMetric;
3142 for (i=2; i < items; i+=2)
3144 attribute=(char *) SvPV(ST(i-1),na);
3150 if (LocaleCompare(attribute,"channel") == 0)
3155 option=ParseChannelOption(SvPV(ST(i),na));
3158 ThrowPerlException(exception,OptionError,
3159 "UnrecognizedType",SvPV(ST(i),na));
3162 SetPixelChannelMap(image,(ChannelType) option);
3165 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3172 if (LocaleCompare(attribute,"fuzz") == 0)
3174 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3177 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3184 if (LocaleCompare(attribute,"image") == 0)
3186 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3187 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3190 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3197 if (LocaleCompare(attribute,"metric") == 0)
3199 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3203 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3207 metric=(MetricType) option;
3210 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3216 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3222 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3224 if (difference_image != (Image *) NULL)
3226 difference_image->error.mean_error_per_pixel=distortion;
3227 AddImageToRegistry(sv,difference_image);
3229 av_push(av,sv_bless(rv,hv));
3232 exception=DestroyExceptionInfo(exception);
3234 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3238 InheritPerlException(exception,perl_exception);
3239 exception=DestroyExceptionInfo(exception);
3240 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3241 SvPOK_on(perl_exception);
3242 ST(0)=sv_2mortal(perl_exception);
3247 ###############################################################################
3251 # C o m p a r e L a y e r s #
3255 ###############################################################################
3260 Image::Magick ref=NO_INIT
3262 CompareImagesLayers = 1
3264 compareimagelayers = 3
3301 PERL_UNUSED_VAR(ref);
3302 PERL_UNUSED_VAR(ix);
3303 exception=AcquireExceptionInfo();
3304 perl_exception=newSVpv("",0);
3306 if (sv_isobject(ST(0)) == 0)
3308 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3312 reference=SvRV(ST(0));
3313 hv=SvSTASH(reference);
3315 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3317 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3318 if (image == (Image *) NULL)
3320 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3324 method=CompareAnyLayer;
3325 for (i=2; i < items; i+=2)
3327 attribute=(char *) SvPV(ST(i-1),na);
3333 if (LocaleCompare(attribute,"method") == 0)
3335 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3339 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3343 method=(ImageLayerMethod) option;
3346 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3352 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3358 image=CompareImagesLayers(image,method,exception);
3359 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3361 for ( ; image; image=image->next)
3363 AddImageToRegistry(sv,image);
3365 av_push(av,sv_bless(rv,hv));
3368 exception=DestroyExceptionInfo(exception);
3370 SvREFCNT_dec(perl_exception);
3374 InheritPerlException(exception,perl_exception);
3375 exception=DestroyExceptionInfo(exception);
3376 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3377 SvPOK_on(perl_exception);
3378 ST(0)=sv_2mortal(perl_exception);
3383 ###############################################################################
3391 ###############################################################################
3396 Image::Magick ref=NO_INIT
3402 PERL_UNUSED_VAR(ref);
3403 if (sv_isobject(ST(0)) == 0)
3404 croak("ReferenceIsNotMyType");
3405 reference=SvRV(ST(0));
3406 switch (SvTYPE(reference))
3411 message[MaxTextExtent];
3429 Array (AV *) reference
3431 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3432 XS_VERSION,reference);
3433 hv=gv_stashpv(PackageName, FALSE);
3436 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3440 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3442 info=(struct PackageInfo *) SvIV(sv);
3443 DestroyPackageInfo(info);
3445 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3455 Blessed scalar = (Image *) SvIV(reference)
3457 image=(Image *) SvIV(reference);
3458 if (image != (Image *) NULL)
3459 DeleteImageFromRegistry(reference,image);
3468 ###############################################################################
3476 ###############################################################################
3481 Image::Magick ref=NO_INIT
3505 PERL_UNUSED_VAR(ref);
3506 PERL_UNUSED_VAR(ix);
3507 exception=AcquireExceptionInfo();
3508 perl_exception=newSVpv("",0);
3509 package_info=(struct PackageInfo *) NULL;
3510 if (sv_isobject(ST(0)) == 0)
3512 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3516 reference=SvRV(ST(0));
3517 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3518 if (image == (Image *) NULL)
3520 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3524 package_info=ClonePackageInfo(info,exception);
3526 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3529 for (i=2; i < items; i+=2)
3530 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3532 (void) DisplayImages(package_info->image_info,image);
3533 (void) CatchImageException(image);
3534 InheritException(exception,&image->exception);
3537 if (package_info != (struct PackageInfo *) NULL)
3538 DestroyPackageInfo(package_info);
3539 InheritPerlException(exception,perl_exception);
3540 exception=DestroyExceptionInfo(exception);
3541 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3542 SvPOK_on(perl_exception);
3543 ST(0)=sv_2mortal(perl_exception);
3548 ###############################################################################
3552 # E v a l u a t e I m a g e s #
3556 ###############################################################################
3561 Image::Magick ref=NO_INIT
3583 MagickEvaluateOperator
3598 PERL_UNUSED_VAR(ref);
3599 PERL_UNUSED_VAR(ix);
3600 exception=AcquireExceptionInfo();
3601 perl_exception=newSVpv("",0);
3603 if (sv_isobject(ST(0)) == 0)
3605 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3609 reference=SvRV(ST(0));
3610 hv=SvSTASH(reference);
3611 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3612 if (image == (Image *) NULL)
3614 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3618 op=MeanEvaluateOperator;
3624 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3628 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3632 op=(MagickEvaluateOperator) in;
3635 for (i=2; i < items; i+=2)
3637 attribute=(char *) SvPV(ST(i-1),na);
3643 if (LocaleCompare(attribute,"operator") == 0)
3648 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3649 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3652 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3656 op=(MagickEvaluateOperator) in;
3659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3665 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3671 image=EvaluateImages(image,op,exception);
3672 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3675 Create blessed Perl array for the returned image.
3678 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3680 AddImageToRegistry(sv,image);
3682 av_push(av,sv_bless(rv,hv));
3684 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3685 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3686 "evaluate-%.*s",(int) (MaxTextExtent-9),
3687 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3688 (void) CopyMagickString(image->filename,info->image_info->filename,
3690 SetImageInfo(info->image_info,0,exception);
3691 exception=DestroyExceptionInfo(exception);
3692 SvREFCNT_dec(perl_exception);
3696 InheritPerlException(exception,perl_exception);
3697 exception=DestroyExceptionInfo(exception);
3698 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3699 SvPOK_on(perl_exception);
3700 ST(0)=sv_2mortal(perl_exception);
3705 ###############################################################################
3713 ###############################################################################
3718 Image::Magick ref=NO_INIT
3725 #define ChannelFeatures(channel,direction) \
3727 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3728 channel_features[channel].angular_second_moment[direction]); \
3729 PUSHs(sv_2mortal(newSVpv(message,0))); \
3730 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3731 channel_features[channel].contrast[direction]); \
3732 PUSHs(sv_2mortal(newSVpv(message,0))); \
3733 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3734 channel_features[channel].contrast[direction]); \
3735 PUSHs(sv_2mortal(newSVpv(message,0))); \
3736 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3737 channel_features[channel].variance_sum_of_squares[direction]); \
3738 PUSHs(sv_2mortal(newSVpv(message,0))); \
3739 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3740 channel_features[channel].inverse_difference_moment[direction]); \
3741 PUSHs(sv_2mortal(newSVpv(message,0))); \
3742 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3743 channel_features[channel].sum_average[direction]); \
3744 PUSHs(sv_2mortal(newSVpv(message,0))); \
3745 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3746 channel_features[channel].sum_variance[direction]); \
3747 PUSHs(sv_2mortal(newSVpv(message,0))); \
3748 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3749 channel_features[channel].sum_entropy[direction]); \
3750 PUSHs(sv_2mortal(newSVpv(message,0))); \
3751 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3752 channel_features[channel].entropy[direction]); \
3753 PUSHs(sv_2mortal(newSVpv(message,0))); \
3754 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3755 channel_features[channel].difference_variance[direction]); \
3756 PUSHs(sv_2mortal(newSVpv(message,0))); \
3757 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3758 channel_features[channel].difference_entropy[direction]); \
3759 PUSHs(sv_2mortal(newSVpv(message,0))); \
3760 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3761 channel_features[channel].measure_of_correlation_1[direction]); \
3762 PUSHs(sv_2mortal(newSVpv(message,0))); \
3763 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3764 channel_features[channel].measure_of_correlation_2[direction]); \
3765 PUSHs(sv_2mortal(newSVpv(message,0))); \
3766 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3767 channel_features[channel].maximum_correlation_coefficient[direction]); \
3768 PUSHs(sv_2mortal(newSVpv(message,0))); \
3776 message[MaxTextExtent];
3803 PERL_UNUSED_VAR(ref);
3804 PERL_UNUSED_VAR(ix);
3805 exception=AcquireExceptionInfo();
3806 perl_exception=newSVpv("",0);
3808 if (sv_isobject(ST(0)) == 0)
3810 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3814 reference=SvRV(ST(0));
3817 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3818 if (image == (Image *) NULL)
3820 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3824 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3826 for (i=2; i < items; i+=2)
3828 attribute=(char *) SvPV(ST(i-1),na);
3834 if (LocaleCompare(attribute,"distance") == 0)
3836 distance=StringToLong((char *) SvPV(ST(1),na));
3839 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3845 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3852 for ( ; image; image=image->next)
3854 channel_features=GetImageFeatures(image,distance,
3856 if (channel_features == (ChannelFeatures *) NULL)
3859 EXTEND(sp,75*count);
3860 for (i=0; i < 4; i++)
3862 ChannelFeatures(RedChannel,i);
3863 ChannelFeatures(GreenChannel,i);
3864 ChannelFeatures(BlueChannel,i);
3865 if (image->colorspace == CMYKColorspace)
3866 ChannelFeatures(BlackChannel,i);
3867 if (image->matte != MagickFalse)
3868 ChannelFeatures(AlphaChannel,i);
3870 channel_features=(ChannelFeatures *)
3871 RelinquishMagickMemory(channel_features);
3875 InheritPerlException(exception,perl_exception);
3876 exception=DestroyExceptionInfo(exception);
3877 SvREFCNT_dec(perl_exception);
3881 ###############################################################################
3889 ###############################################################################
3894 Image::Magick ref=NO_INIT
3932 PERL_UNUSED_VAR(ref);
3933 PERL_UNUSED_VAR(ix);
3934 exception=AcquireExceptionInfo();
3935 perl_exception=newSVpv("",0);
3937 if (sv_isobject(ST(0)) == 0)
3939 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3943 reference=SvRV(ST(0));
3944 hv=SvSTASH(reference);
3945 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3946 if (image == (Image *) NULL)
3948 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3952 background_color=image->background_color;
3954 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3957 for (i=2; i < items; i+=2)
3959 attribute=(char *) SvPV(ST(i-1),na);
3965 if (LocaleCompare(attribute,"background") == 0)
3967 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3968 &background_color,exception);
3971 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3977 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3983 image->background_color=background_color;
3984 image=MergeImageLayers(image,FlattenLayer,exception);
3985 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3988 Create blessed Perl array for the returned image.
3991 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3993 AddImageToRegistry(sv,image);
3995 av_push(av,sv_bless(rv,hv));
3997 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3998 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3999 "flatten-%.*s",(int) (MaxTextExtent-9),
4000 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4001 (void) CopyMagickString(image->filename,info->image_info->filename,
4003 SetImageInfo(info->image_info,0,exception);
4004 exception=DestroyExceptionInfo(exception);
4005 SvREFCNT_dec(perl_exception);
4009 InheritPerlException(exception,perl_exception);
4010 exception=DestroyExceptionInfo(exception);
4011 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4012 SvPOK_on(perl_exception); /* return messages in string context */
4013 ST(0)=sv_2mortal(perl_exception);
4018 ###############################################################################
4026 ###############################################################################
4031 Image::Magick ref=NO_INIT
4043 expression[MaxTextExtent];
4071 PERL_UNUSED_VAR(ref);
4072 PERL_UNUSED_VAR(ix);
4073 exception=AcquireExceptionInfo();
4074 perl_exception=newSVpv("",0);
4078 if (sv_isobject(ST(0)) == 0)
4080 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4084 reference=SvRV(ST(0));
4085 hv=SvSTASH(reference);
4087 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4089 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4090 if (image == (Image *) NULL)
4092 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4096 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4100 channel=DefaultChannels;
4101 (void) CopyMagickString(expression,"u",MaxTextExtent);
4103 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4105 for (i=2; i < items; i+=2)
4107 attribute=(char *) SvPV(ST(i-1),na);
4113 if (LocaleCompare(attribute,"channel") == 0)
4118 option=ParseChannelOption(SvPV(ST(i),na));
4121 ThrowPerlException(exception,OptionError,
4122 "UnrecognizedType",SvPV(ST(i),na));
4125 channel=(ChannelType) option;
4128 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4135 if (LocaleCompare(attribute,"expression") == 0)
4137 (void) CopyMagickString(expression,SvPV(ST(i),na),
4141 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4153 channel_mask=SetPixelChannelMask(image,channel);
4154 image=FxImage(image,expression,exception);
4155 if (image != (Image *) NULL)
4156 (void) SetPixelChannelMask(image,channel_mask);
4157 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4159 for ( ; image; image=image->next)
4161 AddImageToRegistry(sv,image);
4163 av_push(av,sv_bless(rv,hv));
4166 exception=DestroyExceptionInfo(exception);
4168 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4172 InheritPerlException(exception,perl_exception);
4173 exception=DestroyExceptionInfo(exception);
4174 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4175 SvPOK_on(perl_exception);
4176 ST(0)=sv_2mortal(perl_exception);
4181 ###############################################################################
4189 ###############################################################################
4194 Image::Magick ref=NO_INIT
4205 color[MaxTextExtent];
4230 PERL_UNUSED_VAR(ref);
4231 PERL_UNUSED_VAR(ix);
4232 exception=AcquireExceptionInfo();
4233 perl_exception=newSVpv("",0);
4234 if (sv_isobject(ST(0)) == 0)
4236 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4240 reference=SvRV(ST(0));
4241 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4242 if (image == (Image *) NULL && !info)
4245 for (i=1; i < items; i++)
4247 attribute=(char *) SvPV(ST(i),na);
4254 if (LocaleCompare(attribute,"adjoin") == 0)
4257 s=newSViv((ssize_t) info->image_info->adjoin);
4258 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4261 if (LocaleCompare(attribute,"antialias") == 0)
4264 s=newSViv((ssize_t) info->image_info->antialias);
4265 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4268 if (LocaleCompare(attribute,"area") == 0)
4270 s=newSViv(GetMagickResource(AreaResource));
4271 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4274 if (LocaleCompare(attribute,"attenuate") == 0)
4279 value=GetImageProperty(image,attribute);
4280 if (value != (const char *) NULL)
4282 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4285 if (LocaleCompare(attribute,"authenticate") == 0)
4288 s=newSVpv(info->image_info->authenticate,0);
4289 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4292 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4299 if (LocaleCompare(attribute,"background") == 0)
4301 if (image == (Image *) NULL)
4303 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4304 QuantumFormat "," QuantumFormat "," QuantumFormat,
4305 image->background_color.red,image->background_color.green,
4306 image->background_color.blue,image->background_color.alpha);
4308 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4311 if (LocaleCompare(attribute,"base-columns") == 0)
4313 if (image != (Image *) NULL)
4314 s=newSViv((ssize_t) image->magick_columns);
4315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4318 if (LocaleCompare(attribute,"base-filename") == 0)
4320 if (image != (Image *) NULL)
4321 s=newSVpv(image->magick_filename,0);
4322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4325 if (LocaleCompare(attribute,"base-height") == 0)
4327 if (image != (Image *) NULL)
4328 s=newSViv((ssize_t) image->magick_rows);
4329 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4332 if (LocaleCompare(attribute,"base-rows") == 0)
4334 if (image != (Image *) NULL)
4335 s=newSViv((ssize_t) image->magick_rows);
4336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4339 if (LocaleCompare(attribute,"base-width") == 0)
4341 if (image != (Image *) NULL)
4342 s=newSViv((ssize_t) image->magick_columns);
4343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4346 if (LocaleCompare(attribute,"bias") == 0)
4348 if (image != (Image *) NULL)
4349 s=newSVnv(image->bias);
4350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4353 if (LocaleCompare(attribute,"blue-primary") == 0)
4355 if (image == (Image *) NULL)
4357 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4358 image->chromaticity.blue_primary.x,
4359 image->chromaticity.blue_primary.y);
4361 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4364 if (LocaleCompare(attribute,"bordercolor") == 0)
4366 if (image == (Image *) NULL)
4368 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4369 QuantumFormat "," QuantumFormat "," QuantumFormat,
4370 image->border_color.red,image->border_color.green,
4371 image->border_color.blue,image->border_color.alpha);
4373 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4376 if (LocaleCompare(attribute,"bounding-box") == 0)
4379 geometry[MaxTextExtent];
4384 if (image == (Image *) NULL)
4386 page=GetImageBoundingBox(image,&image->exception);
4387 (void) FormatLocaleString(geometry,MaxTextExtent,
4388 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4389 page.height,(double) page.x,(double) page.y);
4390 s=newSVpv(geometry,0);
4391 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4401 if (LocaleCompare(attribute,"class") == 0)
4403 if (image == (Image *) NULL)
4405 s=newSViv(image->storage_class);
4406 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4407 image->storage_class));
4409 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4412 if (LocaleCompare(attribute,"clip-mask") == 0)
4414 if (image != (Image *) NULL)
4420 if (image->mask == (Image *) NULL)
4422 if (image->mask != (Image *) NULL)
4424 AddImageToRegistry(sv,image->mask);
4425 s=sv_bless(newRV(sv),SvSTASH(reference));
4428 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4431 if (LocaleCompare(attribute,"clip-path") == 0)
4433 if (image != (Image *) NULL)
4439 if (image->clip_mask == (Image *) NULL)
4441 if (image->clip_mask != (Image *) NULL)
4443 AddImageToRegistry(sv,image->clip_mask);
4444 s=sv_bless(newRV(sv),SvSTASH(reference));
4447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4450 if (LocaleCompare(attribute,"compression") == 0)
4452 j=info ? info->image_info->compression : image ?
4453 image->compression : UndefinedCompression;
4455 if (info->image_info->compression == UndefinedCompression)
4456 j=image->compression;
4458 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4461 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4464 if (LocaleCompare(attribute,"colorspace") == 0)
4466 j=image ? image->colorspace : RGBColorspace;
4468 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4471 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4474 if (LocaleCompare(attribute,"colors") == 0)
4476 if (image != (Image *) NULL)
4477 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4478 &image->exception));
4479 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4482 if (LocaleNCompare(attribute,"colormap",8) == 0)
4487 if (image == (Image *) NULL || !image->colormap)
4490 items=sscanf(attribute,"%*[^[][%ld",&j);
4492 if (j > (ssize_t) image->colors)
4494 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4495 QuantumFormat "," QuantumFormat "," QuantumFormat,
4496 image->colormap[j].red,image->colormap[j].green,
4497 image->colormap[j].blue,image->colormap[j].alpha);
4499 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4502 if (LocaleCompare(attribute,"columns") == 0)
4504 if (image != (Image *) NULL)
4505 s=newSViv((ssize_t) image->columns);
4506 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4509 if (LocaleCompare(attribute,"comment") == 0)
4514 value=GetImageProperty(image,attribute);
4515 if (value != (const char *) NULL)
4517 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4520 if (LocaleCompare(attribute,"copyright") == 0)
4522 s=newSVpv(GetMagickCopyright(),0);
4523 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4526 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4533 if (LocaleCompare(attribute,"density") == 0)
4536 geometry[MaxTextExtent];
4538 if (image == (Image *) NULL)
4540 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4541 image->x_resolution,image->y_resolution);
4542 s=newSVpv(geometry,0);
4543 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4546 if (LocaleCompare(attribute,"delay") == 0)
4548 if (image != (Image *) NULL)
4549 s=newSViv((ssize_t) image->delay);
4550 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4553 if (LocaleCompare(attribute,"depth") == 0)
4555 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4556 if (image != (Image *) NULL)
4557 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4558 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4561 if (LocaleCompare(attribute,"directory") == 0)
4563 if (image && image->directory)
4564 s=newSVpv(image->directory,0);
4565 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4568 if (LocaleCompare(attribute,"dispose") == 0)
4570 if (image == (Image *) NULL)
4573 s=newSViv(image->dispose);
4575 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4577 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4580 if (LocaleCompare(attribute,"disk") == 0)
4582 s=newSViv(GetMagickResource(DiskResource));
4583 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4586 if (LocaleCompare(attribute,"dither") == 0)
4589 s=newSViv((ssize_t) info->image_info->dither);
4590 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4593 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4595 if (info && info->image_info->server_name)
4596 s=newSVpv(info->image_info->server_name,0);
4597 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4600 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4607 if (LocaleCompare(attribute,"elapsed-time") == 0)
4609 if (image != (Image *) NULL)
4610 s=newSVnv(GetElapsedTime(&image->timer));
4611 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4614 if (LocaleCompare(attribute,"endian") == 0)
4616 j=info ? info->image_info->endian : image ? image->endian :
4619 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4621 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4624 if (LocaleCompare(attribute,"error") == 0)
4626 if (image != (Image *) NULL)
4627 s=newSVnv(image->error.mean_error_per_pixel);
4628 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4631 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4638 if (LocaleCompare(attribute,"filesize") == 0)
4640 if (image != (Image *) NULL)
4641 s=newSViv((ssize_t) GetBlobSize(image));
4642 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4645 if (LocaleCompare(attribute,"filename") == 0)
4647 if (info && info->image_info->filename &&
4648 *info->image_info->filename)
4649 s=newSVpv(info->image_info->filename,0);
4650 if (image != (Image *) NULL)
4651 s=newSVpv(image->filename,0);
4652 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4655 if (LocaleCompare(attribute,"filter") == 0)
4657 s=image ? newSViv(image->filter) : newSViv(0);
4658 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4661 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4664 if (LocaleCompare(attribute,"font") == 0)
4666 if (info && info->image_info->font)
4667 s=newSVpv(info->image_info->font,0);
4668 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4671 if (LocaleCompare(attribute,"foreground") == 0)
4673 if (LocaleCompare(attribute,"format") == 0)
4678 magick_info=(const MagickInfo *) NULL;
4679 if (info && (*info->image_info->magick != '\0'))
4680 magick_info=GetMagickInfo(info->image_info->magick,exception);
4681 if (image != (Image *) NULL)
4682 magick_info=GetMagickInfo(image->magick,&image->exception);
4683 if ((magick_info != (const MagickInfo *) NULL) &&
4684 (*magick_info->description != '\0'))
4685 s=newSVpv((char *) magick_info->description,0);
4686 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4689 if (LocaleCompare(attribute,"fuzz") == 0)
4692 s=newSVnv(info->image_info->fuzz);
4693 if (image != (Image *) NULL)
4694 s=newSVnv(image->fuzz);
4695 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4705 if (LocaleCompare(attribute,"gamma") == 0)
4707 if (image != (Image *) NULL)
4708 s=newSVnv(image->gamma);
4709 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4712 if (LocaleCompare(attribute,"geometry") == 0)
4714 if (image && image->geometry)
4715 s=newSVpv(image->geometry,0);
4716 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4719 if (LocaleCompare(attribute,"gravity") == 0)
4721 s=image ? newSViv(image->gravity) : newSViv(0);
4722 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4725 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4728 if (LocaleCompare(attribute,"green-primary") == 0)
4730 if (image == (Image *) NULL)
4732 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4733 image->chromaticity.green_primary.x,
4734 image->chromaticity.green_primary.y);
4736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4746 if (LocaleCompare(attribute,"height") == 0)
4748 if (image != (Image *) NULL)
4749 s=newSViv((ssize_t) image->rows);
4750 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4753 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4760 if (LocaleCompare(attribute,"icc") == 0)
4762 if (image != (Image *) NULL)
4767 profile=GetImageProfile(image,"icc");
4768 if (profile != (StringInfo *) NULL)
4769 s=newSVpv((const char *) GetStringInfoDatum(profile),
4770 GetStringInfoLength(profile));
4772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4775 if (LocaleCompare(attribute,"icm") == 0)
4777 if (image != (Image *) NULL)
4782 profile=GetImageProfile(image,"icm");
4783 if (profile != (const StringInfo *) NULL)
4784 s=newSVpv((const char *) GetStringInfoDatum(profile),
4785 GetStringInfoLength(profile));
4787 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4790 if (LocaleCompare(attribute,"id") == 0)
4792 if (image != (Image *) NULL)
4803 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4805 status=SetImageRegistry(ImageRegistryType,key,image,
4810 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4813 if (LocaleNCompare(attribute,"index",5) == 0)
4816 name[MaxTextExtent];
4825 register const Quantum
4831 if (image == (Image *) NULL)
4833 if (image->storage_class != PseudoClass)
4837 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4839 image_view=AcquireCacheView(image);
4840 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4841 if (p != (const Quantum *) NULL)
4843 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4844 GetPixelIndex(image,p));
4846 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4848 image_view=DestroyCacheView(image_view);
4851 if (LocaleCompare(attribute,"iptc") == 0)
4853 if (image != (Image *) NULL)
4858 profile=GetImageProfile(image,"iptc");
4859 if (profile != (const StringInfo *) NULL)
4860 s=newSVpv((const char *) GetStringInfoDatum(profile),
4861 GetStringInfoLength(profile));
4863 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4866 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4868 if (image != (Image *) NULL)
4869 s=newSViv((ssize_t) image->iterations);
4870 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4873 if (LocaleCompare(attribute,"interlace") == 0)
4875 j=info ? info->image_info->interlace : image ? image->interlace :
4878 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4881 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4884 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4891 if (LocaleCompare(attribute,"label") == 0)
4896 if (image == (Image *) NULL)
4898 value=GetImageProperty(image,"Label");
4899 if (value != (const char *) NULL)
4901 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4904 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4906 if (image != (Image *) NULL)
4907 s=newSViv((ssize_t) image->iterations);
4908 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4911 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4918 if (LocaleCompare(attribute,"magick") == 0)
4920 if (info && *info->image_info->magick)
4921 s=newSVpv(info->image_info->magick,0);
4922 if (image != (Image *) NULL)
4923 s=newSVpv(image->magick,0);
4924 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4927 if (LocaleCompare(attribute,"map") == 0)
4929 s=newSViv(GetMagickResource(MapResource));
4930 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4933 if (LocaleCompare(attribute,"maximum-error") == 0)
4935 if (image != (Image *) NULL)
4936 s=newSVnv(image->error.normalized_maximum_error);
4937 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4940 if (LocaleCompare(attribute,"memory") == 0)
4942 s=newSViv(GetMagickResource(MemoryResource));
4943 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4946 if (LocaleCompare(attribute,"mean-error") == 0)
4948 if (image != (Image *) NULL)
4949 s=newSVnv(image->error.normalized_mean_error);
4950 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4953 if (LocaleCompare(attribute,"mime") == 0)
4955 if (info && *info->image_info->magick)
4956 s=newSVpv(MagickToMime(info->image_info->magick),0);
4957 if (image != (Image *) NULL)
4958 s=newSVpv(MagickToMime(image->magick),0);
4959 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4962 if (LocaleCompare(attribute,"mattecolor") == 0)
4964 if (image == (Image *) NULL)
4966 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4967 QuantumFormat "," QuantumFormat "," QuantumFormat,
4968 image->matte_color.red,image->matte_color.green,
4969 image->matte_color.blue,image->matte_color.alpha);
4971 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4974 if (LocaleCompare(attribute,"matte") == 0)
4976 if (image != (Image *) NULL)
4977 s=newSViv((ssize_t) image->matte);
4978 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4981 if (LocaleCompare(attribute,"mime") == 0)
4987 if (info && *info->image_info->magick)
4988 magick=info->image_info->magick;
4989 if (image != (Image *) NULL)
4990 magick=image->magick;
4996 mime=MagickToMime(magick);
4998 mime=(char *) RelinquishMagickMemory(mime);
5000 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5003 if (LocaleCompare(attribute,"monochrome") == 0)
5005 if (image == (Image *) NULL)
5007 j=info ? info->image_info->monochrome :
5008 IsImageMonochrome(image,&image->exception);
5010 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5013 if (LocaleCompare(attribute,"montage") == 0)
5015 if (image && image->montage)
5016 s=newSVpv(image->montage,0);
5017 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5020 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5027 if (LocaleCompare(attribute,"orientation") == 0)
5029 j=info ? info->image_info->orientation : image ?
5030 image->orientation : UndefinedOrientation;
5032 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5035 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5038 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5045 if (LocaleCompare(attribute,"page") == 0)
5047 if (info && info->image_info->page)
5048 s=newSVpv(info->image_info->page,0);
5049 if (image != (Image *) NULL)
5052 geometry[MaxTextExtent];
5054 (void) FormatLocaleString(geometry,MaxTextExtent,
5055 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5056 (double) image->page.height,(double) image->page.x,(double)
5058 s=newSVpv(geometry,0);
5060 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5063 if (LocaleCompare(attribute,"page.x") == 0)
5065 if (image != (Image *) NULL)
5066 s=newSViv((ssize_t) image->page.x);
5067 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5070 if (LocaleCompare(attribute,"page.y") == 0)
5072 if (image != (Image *) NULL)
5073 s=newSViv((ssize_t) image->page.y);
5074 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5077 if (LocaleNCompare(attribute,"pixel",5) == 0)
5080 tuple[MaxTextExtent];
5089 register const Quantum
5092 if (image == (Image *) NULL)
5096 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5098 p=GetVirtualPixels(image,x,y,1,1,exception);
5099 if (image->colorspace != CMYKColorspace)
5100 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5101 QuantumFormat "," QuantumFormat "," QuantumFormat,
5102 GetPixelRed(image,p),GetPixelGreen(image,p),
5103 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5105 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5106 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5107 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5108 GetPixelBlue(image,p),GetPixelBlack(image,p),
5109 GetPixelAlpha(image,p));
5111 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5114 if (LocaleCompare(attribute,"pointsize") == 0)
5117 s=newSViv((ssize_t) info->image_info->pointsize);
5118 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5121 if (LocaleCompare(attribute,"preview") == 0)
5123 s=newSViv(info->image_info->preview_type);
5124 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5125 info->image_info->preview_type));
5127 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5130 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5137 if (LocaleCompare(attribute,"quality") == 0)
5140 s=newSViv((ssize_t) info->image_info->quality);
5141 if (image != (Image *) NULL)
5142 s=newSViv((ssize_t) image->quality);
5143 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5146 if (LocaleCompare(attribute,"quantum") == 0)
5149 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5150 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5153 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5160 if (LocaleCompare(attribute,"rendering-intent") == 0)
5162 s=newSViv(image->rendering_intent);
5163 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5164 image->rendering_intent));
5166 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5169 if (LocaleCompare(attribute,"red-primary") == 0)
5171 if (image == (Image *) NULL)
5173 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5174 image->chromaticity.red_primary.x,
5175 image->chromaticity.red_primary.y);
5177 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5180 if (LocaleCompare(attribute,"rows") == 0)
5182 if (image != (Image *) NULL)
5183 s=newSViv((ssize_t) image->rows);
5184 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5187 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5194 if (LocaleCompare(attribute,"sampling-factor") == 0)
5196 if (info && info->image_info->sampling_factor)
5197 s=newSVpv(info->image_info->sampling_factor,0);
5198 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5201 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5203 if (info && info->image_info->server_name)
5204 s=newSVpv(info->image_info->server_name,0);
5205 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5208 if (LocaleCompare(attribute,"size") == 0)
5210 if (info && info->image_info->size)
5211 s=newSVpv(info->image_info->size,0);
5212 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5215 if (LocaleCompare(attribute,"scene") == 0)
5217 if (image != (Image *) NULL)
5218 s=newSViv((ssize_t) image->scene);
5219 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5222 if (LocaleCompare(attribute,"scenes") == 0)
5224 if (image != (Image *) NULL)
5225 s=newSViv((ssize_t) info->image_info->number_scenes);
5226 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5229 if (LocaleCompare(attribute,"signature") == 0)
5234 if (image == (Image *) NULL)
5236 (void) SignatureImage(image);
5237 value=GetImageProperty(image,"Signature");
5238 if (value != (const char *) NULL)
5240 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5243 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5250 if (LocaleCompare(attribute,"taint") == 0)
5252 if (image != (Image *) NULL)
5253 s=newSViv((ssize_t) IsTaintImage(image));
5254 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5257 if (LocaleCompare(attribute,"texture") == 0)
5259 if (info && info->image_info->texture)
5260 s=newSVpv(info->image_info->texture,0);
5261 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5264 if (LocaleCompare(attribute,"total-ink-density") == 0)
5266 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5267 if (image != (Image *) NULL)
5268 s=newSVnv(GetImageTotalInkDensity(image));
5269 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5272 if (LocaleCompare(attribute,"transparent-color") == 0)
5274 if (image == (Image *) NULL)
5276 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5277 QuantumFormat "," QuantumFormat "," QuantumFormat,
5278 image->transparent_color.red,image->transparent_color.green,
5279 image->transparent_color.blue,image->transparent_color.alpha);
5281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5284 if (LocaleCompare(attribute,"type") == 0)
5286 if (image == (Image *) NULL)
5288 j=(ssize_t) GetImageType(image,&image->exception);
5290 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5292 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5302 if (LocaleCompare(attribute,"units") == 0)
5304 j=info ? info->image_info->units : image ? image->units :
5305 UndefinedResolution;
5306 if (info && (info->image_info->units == UndefinedResolution))
5309 if (j == UndefinedResolution)
5310 s=newSVpv("undefined units",0);
5312 if (j == PixelsPerInchResolution)
5313 s=newSVpv("pixels / inch",0);
5315 s=newSVpv("pixels / centimeter",0);
5316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5319 if (LocaleCompare(attribute,"user-time") == 0)
5321 if (image != (Image *) NULL)
5322 s=newSVnv(GetUserTime(&image->timer));
5323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5326 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5333 if (LocaleCompare(attribute,"verbose") == 0)
5336 s=newSViv((ssize_t) info->image_info->verbose);
5337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5340 if (LocaleCompare(attribute,"version") == 0)
5342 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5346 if (LocaleCompare(attribute,"view") == 0)
5348 if (info && info->image_info->view)
5349 s=newSVpv(info->image_info->view,0);
5350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5353 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5355 if (image == (Image *) NULL)
5357 j=(ssize_t) GetImageVirtualPixelMethod(image);
5359 (void) sv_setpv(s,CommandOptionToMnemonic(
5360 MagickVirtualPixelOptions,j));
5362 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5365 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5372 if (LocaleCompare(attribute,"white-point") == 0)
5374 if (image == (Image *) NULL)
5376 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5377 image->chromaticity.white_point.x,
5378 image->chromaticity.white_point.y);
5380 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5383 if (LocaleCompare(attribute,"width") == 0)
5385 if (image != (Image *) NULL)
5386 s=newSViv((ssize_t) image->columns);
5387 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5390 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5397 if (LocaleCompare(attribute,"x-resolution") == 0)
5399 if (image != (Image *) NULL)
5400 s=newSVnv(image->x_resolution);
5401 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5411 if (LocaleCompare(attribute,"y-resolution") == 0)
5413 if (image != (Image *) NULL)
5414 s=newSVnv(image->y_resolution);
5415 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5425 if (image == (Image *) NULL)
5426 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5430 value=GetImageProperty(image,attribute);
5431 if (value != (const char *) NULL)
5434 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5437 if (*attribute != '%')
5438 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5445 meta=InterpretImageProperties(info ? info->image_info :
5446 (ImageInfo *) NULL,image,attribute);
5448 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5449 meta=(char *) RelinquishMagickMemory(meta);
5453 exception=DestroyExceptionInfo(exception);
5454 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5458 ###############################################################################
5462 # G e t A u t h e n t i c P i x e l s #
5466 ###############################################################################
5470 GetAuthenticPixels(ref,...)
5471 Image::Magick ref = NO_INIT
5473 getauthenticpixels = 1
5503 PERL_UNUSED_VAR(ref);
5504 PERL_UNUSED_VAR(ix);
5505 exception=AcquireExceptionInfo();
5506 perl_exception=newSVpv("",0);
5507 if (sv_isobject(ST(0)) == 0)
5509 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5513 reference=SvRV(ST(0));
5515 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5516 if (image == (Image *) NULL)
5518 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5525 region.width=image->columns;
5528 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5529 for (i=2; i < items; i+=2)
5531 attribute=(char *) SvPV(ST(i-1),na);
5537 if (LocaleCompare(attribute,"geometry") == 0)
5539 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5542 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5549 if (LocaleCompare(attribute,"height") == 0)
5551 region.height=SvIV(ST(i));
5554 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5561 if (LocaleCompare(attribute,"x") == 0)
5563 region.x=SvIV(ST(i));
5566 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5573 if (LocaleCompare(attribute,"y") == 0)
5575 region.y=SvIV(ST(i));
5578 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5585 if (LocaleCompare(attribute,"width") == 0)
5587 region.width=SvIV(ST(i));
5590 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5596 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5597 region.height,exception);
5598 if (blob != (void *) NULL)
5602 InheritPerlException(exception,perl_exception);
5603 exception=DestroyExceptionInfo(exception);
5604 SvREFCNT_dec(perl_exception); /* throw away all errors */
5613 ###############################################################################
5617 # G e t V i r t u a l P i x e l s #
5621 ###############################################################################
5625 GetVirtualPixels(ref,...)
5626 Image::Magick ref = NO_INIT
5628 getvirtualpixels = 1
5629 AcquireImagePixels = 2
5630 acquireimagepixels = 3
5658 PERL_UNUSED_VAR(ref);
5659 PERL_UNUSED_VAR(ix);
5660 exception=AcquireExceptionInfo();
5661 perl_exception=newSVpv("",0);
5662 if (sv_isobject(ST(0)) == 0)
5664 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5668 reference=SvRV(ST(0));
5670 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5671 if (image == (Image *) NULL)
5673 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5680 region.width=image->columns;
5683 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5684 for (i=2; i < items; i+=2)
5686 attribute=(char *) SvPV(ST(i-1),na);
5692 if (LocaleCompare(attribute,"geometry") == 0)
5694 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5704 if (LocaleCompare(attribute,"height") == 0)
5706 region.height=SvIV(ST(i));
5709 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5716 if (LocaleCompare(attribute,"x") == 0)
5718 region.x=SvIV(ST(i));
5721 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5728 if (LocaleCompare(attribute,"y") == 0)
5730 region.y=SvIV(ST(i));
5733 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5740 if (LocaleCompare(attribute,"width") == 0)
5742 region.width=SvIV(ST(i));
5745 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5751 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5752 region.height,exception);
5753 if (blob != (void *) NULL)
5757 InheritPerlException(exception,perl_exception);
5758 exception=DestroyExceptionInfo(exception);
5759 SvREFCNT_dec(perl_exception); /* throw away all errors */
5762 RETVAL = (void *) blob;
5768 ###############################################################################
5772 # G e t A u t h e n t i c M e t a c o n t e n t #
5776 ###############################################################################
5780 GetAuthenticMetacontent(ref,...)
5781 Image::Magick ref = NO_INIT
5783 getauthenticmetacontent = 1
5804 PERL_UNUSED_VAR(ref);
5805 PERL_UNUSED_VAR(ix);
5806 exception=AcquireExceptionInfo();
5807 perl_exception=newSVpv("",0);
5808 if (sv_isobject(ST(0)) == 0)
5810 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5814 reference=SvRV(ST(0));
5816 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5817 if (image == (Image *) NULL)
5819 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5824 blob=(void *) GetAuthenticMetacontent(image);
5825 if (blob != (void *) NULL)
5829 InheritPerlException(exception,perl_exception);
5830 exception=DestroyExceptionInfo(exception);
5831 SvREFCNT_dec(perl_exception); /* throw away all errors */
5840 ###############################################################################
5844 # G e t V i r t u a l M e t a c o n t e n t #
5848 ###############################################################################
5852 GetVirtualMetacontent(ref,...)
5853 Image::Magick ref = NO_INIT
5855 getvirtualmetacontent = 1
5874 PERL_UNUSED_VAR(ref);
5875 PERL_UNUSED_VAR(ix);
5876 exception=AcquireExceptionInfo();
5877 perl_exception=newSVpv("",0);
5878 if (sv_isobject(ST(0)) == 0)
5880 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5884 reference=SvRV(ST(0));
5886 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5887 if (image == (Image *) NULL)
5889 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5894 blob=(void *) GetVirtualMetacontent(image);
5895 if (blob != (void *) NULL)
5899 InheritPerlException(exception,perl_exception);
5900 exception=DestroyExceptionInfo(exception);
5901 SvREFCNT_dec(perl_exception); /* throw away all errors */
5910 ###############################################################################
5914 # H i s t o g r a m #
5918 ###############################################################################
5923 Image::Magick ref=NO_INIT
5934 message[MaxTextExtent];
5961 PERL_UNUSED_VAR(ref);
5962 PERL_UNUSED_VAR(ix);
5963 exception=AcquireExceptionInfo();
5964 perl_exception=newSVpv("",0);
5966 if (sv_isobject(ST(0)) == 0)
5968 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5972 reference=SvRV(ST(0));
5975 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5976 if (image == (Image *) NULL)
5978 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5982 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5984 for ( ; image; image=image->next)
5986 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5987 if (histogram == (PixelPacket *) NULL)
5989 count+=(ssize_t) number_colors;
5991 for (i=0; i < (ssize_t) number_colors; i++)
5993 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5995 PUSHs(sv_2mortal(newSVpv(message,0)));
5996 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5997 histogram[i].green);
5998 PUSHs(sv_2mortal(newSVpv(message,0)));
5999 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6001 PUSHs(sv_2mortal(newSVpv(message,0)));
6002 if (image->colorspace == CMYKColorspace)
6004 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6005 histogram[i].black);
6006 PUSHs(sv_2mortal(newSVpv(message,0)));
6008 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6009 histogram[i].alpha);
6010 PUSHs(sv_2mortal(newSVpv(message,0)));
6011 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6012 histogram[i].count);
6013 PUSHs(sv_2mortal(newSVpv(message,0)));
6015 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6019 InheritPerlException(exception,perl_exception);
6020 exception=DestroyExceptionInfo(exception);
6021 SvREFCNT_dec(perl_exception);
6025 ###############################################################################
6033 ###############################################################################
6038 Image::Magick ref=NO_INIT
6062 register const Quantum
6076 *reference; /* reference is the SV* of ref=SvIV(reference) */
6078 PERL_UNUSED_VAR(ref);
6079 PERL_UNUSED_VAR(ix);
6080 exception=AcquireExceptionInfo();
6081 perl_exception=newSVpv("",0);
6082 reference=SvRV(ST(0));
6083 av=(AV *) reference;
6084 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6086 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6087 if (image == (Image *) NULL)
6089 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6093 normalize=MagickTrue;
6096 region.width=image->columns;
6099 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6100 for (i=2; i < items; i+=2)
6102 attribute=(char *) SvPV(ST(i-1),na);
6108 if (LocaleCompare(attribute,"channel") == 0)
6113 option=ParseChannelOption(SvPV(ST(i),na));
6116 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6120 SetPixelChannelMap(image,(ChannelType) option);
6123 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6130 if (LocaleCompare(attribute,"geometry") == 0)
6132 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6135 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6142 if (LocaleCompare(attribute,"normalize") == 0)
6144 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6148 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6152 normalize=option != 0 ? MagickTrue : MagickFalse;
6155 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6162 if (LocaleCompare(attribute,"x") == 0)
6164 region.x=SvIV(ST(i));
6167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6174 if (LocaleCompare(attribute,"y") == 0)
6176 region.y=SvIV(ST(i));
6179 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6191 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6192 if (p == (const Quantum *) NULL)
6200 if (normalize != MagickFalse)
6201 scale=1.0/QuantumRange;
6202 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6203 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6204 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6205 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6206 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6207 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6208 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6209 (image->colorspace == CMYKColorspace))
6210 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6211 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6212 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6216 InheritPerlException(exception,perl_exception);
6217 exception=DestroyExceptionInfo(exception);
6218 SvREFCNT_dec(perl_exception);
6222 ###############################################################################
6226 # G e t P i x e l s #
6230 ###############################################################################
6235 Image::Magick ref=NO_INIT
6274 *reference; /* reference is the SV* of ref=SvIV(reference) */
6276 PERL_UNUSED_VAR(ref);
6277 PERL_UNUSED_VAR(ix);
6278 exception=AcquireExceptionInfo();
6279 perl_exception=newSVpv("",0);
6280 reference=SvRV(ST(0));
6281 av=(AV *) reference;
6282 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6284 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6285 if (image == (Image *) NULL)
6287 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6292 if (image->matte != MagickFalse)
6294 if (image->colorspace == CMYKColorspace)
6297 if (image->matte != MagickFalse)
6300 normalize=MagickFalse;
6303 region.width=image->columns;
6306 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6307 for (i=2; i < items; i+=2)
6309 attribute=(char *) SvPV(ST(i-1),na);
6315 if (LocaleCompare(attribute,"geometry") == 0)
6317 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6320 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6327 if (LocaleCompare(attribute,"height") == 0)
6329 region.height=SvIV(ST(i));
6332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6339 if (LocaleCompare(attribute,"map") == 0)
6344 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6351 if (LocaleCompare(attribute,"normalize") == 0)
6353 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6357 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6361 normalize=option != 0 ? MagickTrue : MagickFalse;
6364 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6371 if (LocaleCompare(attribute,"width") == 0)
6373 region.width=SvIV(ST(i));
6376 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6383 if (LocaleCompare(attribute,"x") == 0)
6385 region.x=SvIV(ST(i));
6388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6395 if (LocaleCompare(attribute,"y") == 0)
6397 region.y=SvIV(ST(i));
6400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6406 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6412 if (normalize != MagickFalse)
6417 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6418 region.height*sizeof(*pixels));
6419 if (pixels == (float *) NULL)
6421 ThrowPerlException(exception,ResourceLimitError,
6422 "MemoryAllocationFailed",PackageName);
6425 status=ExportImagePixels(image,region.x,region.y,region.width,
6426 region.height,map,FloatPixel,pixels,exception);
6427 if (status == MagickFalse)
6431 EXTEND(sp,strlen(map)*region.width*region.height);
6432 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6433 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6435 pixels=(float *) RelinquishMagickMemory(pixels);
6442 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6443 region.height*sizeof(*pixels));
6444 if (pixels == (Quantum *) NULL)
6446 ThrowPerlException(exception,ResourceLimitError,
6447 "MemoryAllocationFailed",PackageName);
6450 status=ExportImagePixels(image,region.x,region.y,region.width,
6451 region.height,map,QuantumPixel,pixels,exception);
6452 if (status == MagickFalse)
6456 EXTEND(sp,strlen(map)*region.width*region.height);
6457 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6458 PUSHs(sv_2mortal(newSViv(pixels[i])));
6460 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6464 InheritPerlException(exception,perl_exception);
6465 exception=DestroyExceptionInfo(exception);
6466 SvREFCNT_dec(perl_exception);
6470 ###############################################################################
6474 # I m a g e T o B l o b #
6478 ###############################################################################
6482 ImageToBlob(ref,...)
6483 Image::Magick ref=NO_INIT
6492 filename[MaxTextExtent];
6521 PERL_UNUSED_VAR(ref);
6522 PERL_UNUSED_VAR(ix);
6523 exception=AcquireExceptionInfo();
6524 perl_exception=newSVpv("",0);
6525 package_info=(struct PackageInfo *) NULL;
6526 if (sv_isobject(ST(0)) == 0)
6528 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6532 reference=SvRV(ST(0));
6533 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6534 if (image == (Image *) NULL)
6536 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6540 package_info=ClonePackageInfo(info,exception);
6541 for (i=2; i < items; i+=2)
6542 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6543 (void) CopyMagickString(filename,package_info->image_info->filename,
6546 for (next=image; next; next=next->next)
6548 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6549 next->scene=scene++;
6551 SetImageInfo(package_info->image_info,(unsigned int)
6552 GetImageListLength(image),&image->exception);
6553 EXTEND(sp,(ssize_t) GetImageListLength(image));
6554 for ( ; image; image=image->next)
6557 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6558 if (blob != (char *) NULL)
6560 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6561 blob=(unsigned char *) RelinquishMagickMemory(blob);
6563 if (package_info->image_info->adjoin)
6568 if (package_info != (struct PackageInfo *) NULL)
6569 DestroyPackageInfo(package_info);
6570 InheritPerlException(exception,perl_exception);
6571 exception=DestroyExceptionInfo(exception);
6572 SvREFCNT_dec(perl_exception); /* throw away all errors */
6576 ###############################################################################
6584 ###############################################################################
6589 Image::Magick ref=NO_INIT
6593 OptimizeImageLayers = 3
6595 optimizeimagelayers = 5
6637 PERL_UNUSED_VAR(ref);
6638 PERL_UNUSED_VAR(ix);
6639 exception=AcquireExceptionInfo();
6640 perl_exception=newSVpv("",0);
6642 if (sv_isobject(ST(0)) == 0)
6644 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6648 reference=SvRV(ST(0));
6649 hv=SvSTASH(reference);
6651 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6653 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6654 if (image == (Image *) NULL)
6656 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6660 compose=image->compose;
6661 method=OptimizeLayer;
6662 for (i=2; i < items; i+=2)
6664 attribute=(char *) SvPV(ST(i-1),na);
6670 if (LocaleCompare(attribute,"compose") == 0)
6672 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6673 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6676 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6680 compose=(CompositeOperator) sp;
6683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6690 if (LocaleCompare(attribute,"method") == 0)
6692 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6696 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6700 method=(ImageLayerMethod) option;
6703 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6709 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6715 layers=(Image *) NULL;
6718 case CompareAnyLayer:
6719 case CompareClearLayer:
6720 case CompareOverlayLayer:
6723 layers=CompareImagesLayers(image,method,exception);
6730 layers=MergeImageLayers(image,method,exception);
6735 layers=DisposeImages(image,exception);
6738 case OptimizeImageLayer:
6740 layers=OptimizeImageLayers(image,exception);
6743 case OptimizePlusLayer:
6745 layers=OptimizePlusImageLayers(image,exception);
6748 case OptimizeTransLayer:
6750 OptimizeImageTransparency(image,exception);
6751 InheritException(&(image->exception),exception);
6754 case RemoveDupsLayer:
6756 RemoveDuplicateLayers(&image,exception);
6757 InheritException(&(image->exception),exception);
6760 case RemoveZeroLayer:
6762 RemoveZeroDelayLayers(&image,exception);
6763 InheritException(&(image->exception),exception);
6772 General Purpose, GIF Animation Optimizer.
6774 layers=CoalesceImages(image,exception);
6775 if (layers == (Image *) NULL)
6777 InheritException(&(layers->exception),exception);
6779 layers=OptimizeImageLayers(image,exception);
6780 if (layers == (Image *) NULL)
6782 InheritException(&(layers->exception),exception);
6783 image=DestroyImageList(image);
6785 layers=(Image *) NULL;
6786 OptimizeImageTransparency(image,exception);
6787 InheritException(&(image->exception),exception);
6788 quantize_info=AcquireQuantizeInfo(info->image_info);
6789 (void) RemapImages(quantize_info,image,(Image *) NULL);
6790 quantize_info=DestroyQuantizeInfo(quantize_info);
6793 case CompositeLayer:
6802 Split image sequence at the first 'NULL:' image.
6805 while (source != (Image *) NULL)
6807 source=GetNextImageInList(source);
6808 if ((source != (Image *) NULL) &&
6809 (LocaleCompare(source->magick,"NULL") == 0))
6812 if (source != (Image *) NULL)
6814 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6815 (GetNextImageInList(source) == (Image *) NULL))
6816 source=(Image *) NULL;
6820 Separate the two lists, junk the null: image.
6822 source=SplitImageList(source->previous);
6823 DeleteImageFromList(&source);
6826 if (source == (Image *) NULL)
6828 (void) ThrowMagickException(exception,GetMagickModule(),
6829 OptionError,"MissingNullSeparator","layers Composite");
6833 Adjust offset with gravity and virtual canvas.
6835 SetGeometry(image,&geometry);
6836 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6837 geometry.width=source->page.width != 0 ? source->page.width :
6839 geometry.height=source->page.height != 0 ? source->page.height :
6841 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6842 image->columns,image->page.height != 0 ? image->page.height :
6843 image->rows,image->gravity,&geometry);
6844 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6845 source=DestroyImageList(source);
6846 InheritException(&(image->exception),exception);
6850 if (layers != (Image *) NULL)
6852 InheritException(&(layers->exception),exception);
6855 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6857 for ( ; image; image=image->next)
6859 AddImageToRegistry(sv,image);
6861 av_push(av,sv_bless(rv,hv));
6864 exception=DestroyExceptionInfo(exception);
6866 SvREFCNT_dec(perl_exception);
6870 InheritPerlException(exception,perl_exception);
6871 exception=DestroyExceptionInfo(exception);
6872 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6873 SvPOK_on(perl_exception);
6874 ST(0)=sv_2mortal(perl_exception);
6879 ###############################################################################
6883 # M a g i c k T o M i m e #
6887 ###############################################################################
6891 MagickToMime(ref,name)
6892 Image::Magick ref=NO_INIT
6901 PERL_UNUSED_VAR(ref);
6902 PERL_UNUSED_VAR(ix);
6903 mime=MagickToMime(name);
6904 RETVAL=newSVpv(mime,0);
6905 mime=(char *) RelinquishMagickMemory(mime);
6911 ###############################################################################
6919 ###############################################################################
6924 Image::Magick ref=NO_INIT
6961 MedianConvolveImage = 36
6967 ReduceNoiseImage = 42
6993 ColorFloodfillImage= 68
6999 CycleColormapImage = 74
7009 MatteFloodfillImage= 84
7017 NumberColorsImage = 92
7027 SignatureImage = 102
7037 TransparentImage = 112
7039 ThresholdImage = 114
7053 DeconstructImage = 130
7055 GaussianBlurImage = 132
7061 UnsharpMaskImage = 138
7063 MotionBlurImage = 140
7065 OrderedDitherImage = 142
7072 AffineTransform = 149
7073 AffineTransformImage = 150
7075 DifferenceImage = 152
7076 AdaptiveThreshold = 153
7077 AdaptiveThresholdImage = 154
7082 BlackThreshold = 159
7083 BlackThresholdImage= 160
7084 WhiteThreshold = 161
7085 WhiteThresholdImage= 162
7087 RadialBlurImage = 164
7089 ThumbnailImage = 166
7099 PosterizeImage = 176
7105 SepiaToneImage = 182
7106 SigmoidalContrast = 183
7107 SigmoidalContrastImage = 184
7112 ContrastStretch = 189
7113 ContrastStretchImage = 190
7118 AdaptiveSharpen = 195
7119 AdaptiveSharpenImage = 196
7121 TransposeImage = 198
7123 TransverseImage = 200
7125 AutoOrientImage = 202
7127 AdaptiveBlurImage = 204
7131 UniqueColorsImage = 208
7132 AdaptiveResize = 209
7133 AdaptiveResizeImage= 210
7137 LinearStretchImage = 214
7144 FloodfillPaint = 221
7145 FloodfillPaintImage= 222
7151 LiquidRescaleImage = 228
7161 SparseColorImage = 238
7165 SelectiveBlurImage = 242
7169 BlueShiftImage = 246
7170 ForwardFourierTransform = 247
7171 ForwardFourierTransformImage = 248
7172 InverseFourierTransform = 249
7173 InverseFourierTransformImage = 250
7174 ColorDecisionList = 251
7175 ColorDecisionListImage = 252
7177 AutoGammaImage = 254
7179 AutoLevelImage = 256
7181 LevelImageColors = 258
7184 BrightnessContrast = 263
7185 BrightnessContrastImage = 264
7187 MorphologyImage = 266
7189 ColorMatrixImage = 268
7195 StatisticImage = 274
7204 attribute_flag[MaxArguments],
7205 message[MaxTextExtent];
7266 argument_list[MaxArguments];
7268 PERL_UNUSED_VAR(ref);
7269 PERL_UNUSED_VAR(ix);
7270 exception=AcquireExceptionInfo();
7271 perl_exception=newSVpv("",0);
7272 reference_vector=NULL;
7276 if (sv_isobject(ST(0)) == 0)
7278 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7282 reference=SvRV(ST(0));
7283 region_info.width=0;
7284 region_info.height=0;
7287 region_image=(Image *) NULL;
7288 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7289 if (ix && (ix != 666))
7292 Called as Method(...)
7295 rp=(&Methods[ix-1]);
7301 Called as Mogrify("Method",...)
7303 attribute=(char *) SvPV(ST(1),na);
7306 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7307 attribute=(char *) SvPV(ST(2),na);
7310 for (rp=Methods; ; rp++)
7312 if (rp >= EndOf(Methods))
7314 ThrowPerlException(exception,OptionError,
7315 "UnrecognizedPerlMagickMethod",attribute);
7318 if (strEQcase(attribute,rp->name))
7324 if (image == (Image *) NULL)
7326 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7329 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7330 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7331 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7348 pp=(Arguments *) NULL;
7356 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7358 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7360 if (strEQcase(attribute,qq->method) > ssize_test)
7363 ssize_test=strEQcase(attribute,qq->method);
7366 if (pp == (Arguments *) NULL)
7368 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7370 goto continue_outer_loop;
7372 al=(&argument_list[pp-rp->arguments]);
7375 case ArrayReference:
7377 if (SvTYPE(sv) != SVt_RV)
7379 (void) FormatLocaleString(message,MaxTextExtent,
7380 "invalid %.60s value",pp->method);
7381 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7382 goto continue_outer_loop;
7384 al->array_reference=SvRV(sv);
7389 al->real_reference=SvNV(sv);
7394 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7397 case ImageReference:
7399 if (!sv_isobject(sv) ||
7400 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7401 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7403 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7409 case IntegerReference:
7411 al->integer_reference=SvIV(sv);
7414 case StringReference:
7416 al->string_reference=(char *) SvPV(sv,al->length);
7417 if (sv_isobject(sv))
7418 al->image_reference=SetupList(aTHX_ SvRV(sv),
7419 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7425 Is a string; look up name.
7427 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7429 al->string_reference=(char *) SvPV(sv,al->length);
7430 al->integer_reference=(-1);
7433 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7434 MagickFalse,SvPV(sv,na));
7435 if (pp->type == MagickChannelOptions)
7436 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7437 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7439 (void) FormatLocaleString(message,MaxTextExtent,
7440 "invalid %.60s value",pp->method);
7441 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7442 goto continue_outer_loop;
7447 attribute_flag[pp-rp->arguments]++;
7448 continue_outer_loop: ;
7450 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7451 pv=reference_vector;
7452 SetGeometryInfo(&geometry_info);
7453 channel=DefaultChannels;
7454 for (next=image; next; next=next->next)
7457 SetGeometry(image,&geometry);
7458 if ((region_info.width*region_info.height) != 0)
7461 image=CropImage(image,®ion_info,exception);
7467 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7468 ThrowPerlException(exception,OptionError,
7469 "UnrecognizedPerlMagickMethod",message);
7472 case 1: /* Comment */
7474 if (attribute_flag[0] == 0)
7475 argument_list[0].string_reference=(char *) NULL;
7476 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7477 info ? info->image_info : (ImageInfo *) NULL,image,
7478 argument_list[0].string_reference));
7483 if (attribute_flag[0] == 0)
7484 argument_list[0].string_reference=(char *) NULL;
7485 (void) SetImageProperty(image,"label",InterpretImageProperties(
7486 info ? info->image_info : (ImageInfo *) NULL,image,
7487 argument_list[0].string_reference));
7490 case 3: /* AddNoise */
7492 if (attribute_flag[0] == 0)
7493 argument_list[0].integer_reference=UniformNoise;
7494 if (attribute_flag[1] != 0)
7495 channel=(ChannelType) argument_list[1].integer_reference;
7496 channel_mask=SetPixelChannelMask(image,channel);
7497 image=AddNoiseImage(image,(NoiseType)
7498 argument_list[0].integer_reference,exception);
7499 if (image != (Image *) NULL)
7500 (void) SetPixelChannelMask(image,channel_mask);
7503 case 4: /* Colorize */
7508 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7509 if (attribute_flag[0] != 0)
7510 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7512 if (attribute_flag[1] == 0)
7513 argument_list[1].string_reference="100%";
7514 image=ColorizeImage(image,argument_list[1].string_reference,target,
7518 case 5: /* Border */
7522 if (attribute_flag[0] != 0)
7524 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7525 &geometry,exception);
7526 if ((flags & HeightValue) == 0)
7527 geometry.height=geometry.width;
7529 if (attribute_flag[1] != 0)
7530 geometry.width=argument_list[1].integer_reference;
7531 if (attribute_flag[2] != 0)
7532 geometry.height=argument_list[2].integer_reference;
7533 if (attribute_flag[3] != 0)
7534 QueryColorDatabase(argument_list[3].string_reference,
7535 &image->border_color,exception);
7536 if (attribute_flag[4] != 0)
7537 QueryColorDatabase(argument_list[4].string_reference,
7538 &image->border_color,exception);
7539 if (attribute_flag[5] != 0)
7540 QueryColorDatabase(argument_list[5].string_reference,
7541 &image->border_color,exception);
7542 if (attribute_flag[6] != 0)
7543 image->compose=(CompositeOperator) argument_list[6].integer_reference;
7544 image=BorderImage(image,&geometry,exception);
7549 if (attribute_flag[0] != 0)
7551 flags=ParseGeometry(argument_list[0].string_reference,
7553 if ((flags & SigmaValue) == 0)
7554 geometry_info.sigma=1.0;
7556 if (attribute_flag[1] != 0)
7557 geometry_info.rho=argument_list[1].real_reference;
7558 if (attribute_flag[2] != 0)
7559 geometry_info.sigma=argument_list[2].real_reference;
7560 if (attribute_flag[3] != 0)
7561 channel=(ChannelType) argument_list[3].integer_reference;
7562 channel_mask=SetPixelChannelMask(image,channel);
7563 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7565 if (image != (Image *) NULL)
7566 (void) SetPixelChannelMask(image,channel_mask);
7571 if (attribute_flag[0] != 0)
7572 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7573 &geometry,exception);
7574 if (attribute_flag[1] != 0)
7575 geometry.width=argument_list[1].integer_reference;
7576 if (attribute_flag[2] != 0)
7577 geometry.height=argument_list[2].integer_reference;
7578 if (attribute_flag[3] != 0)
7579 geometry.x=argument_list[3].integer_reference;
7580 if (attribute_flag[4] != 0)
7581 geometry.y=argument_list[4].integer_reference;
7582 image=ChopImage(image,&geometry,exception);
7587 if (attribute_flag[6] != 0)
7588 image->gravity=(GravityType) argument_list[6].integer_reference;
7589 if (attribute_flag[0] != 0)
7590 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7591 &geometry,exception);
7592 if (attribute_flag[1] != 0)
7593 geometry.width=argument_list[1].integer_reference;
7594 if (attribute_flag[2] != 0)
7595 geometry.height=argument_list[2].integer_reference;
7596 if (attribute_flag[3] != 0)
7597 geometry.x=argument_list[3].integer_reference;
7598 if (attribute_flag[4] != 0)
7599 geometry.y=argument_list[4].integer_reference;
7600 if (attribute_flag[5] != 0)
7602 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7603 image=CropImage(image,&geometry,exception);
7606 case 9: /* Despeckle */
7608 image=DespeckleImage(image,exception);
7613 if (attribute_flag[0] != 0)
7614 geometry_info.rho=argument_list[0].real_reference;
7615 image=EdgeImage(image,geometry_info.rho,exception);
7618 case 11: /* Emboss */
7620 if (attribute_flag[0] != 0)
7622 flags=ParseGeometry(argument_list[0].string_reference,
7624 if ((flags & SigmaValue) == 0)
7625 geometry_info.sigma=1.0;
7627 if (attribute_flag[1] != 0)
7628 geometry_info.rho=argument_list[1].real_reference;
7629 if (attribute_flag[2] != 0)
7630 geometry_info.sigma=argument_list[2].real_reference;
7631 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7635 case 12: /* Enhance */
7637 image=EnhanceImage(image,exception);
7642 image=FlipImage(image,exception);
7647 image=FlopImage(image,exception);
7650 case 15: /* Frame */
7655 if (attribute_flag[0] != 0)
7657 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7658 &geometry,exception);
7659 if ((flags & HeightValue) == 0)
7660 geometry.height=geometry.width;
7661 frame_info.width=geometry.width;
7662 frame_info.height=geometry.height;
7663 frame_info.outer_bevel=geometry.x;
7664 frame_info.inner_bevel=geometry.y;
7666 if (attribute_flag[1] != 0)
7667 frame_info.width=argument_list[1].integer_reference;
7668 if (attribute_flag[2] != 0)
7669 frame_info.height=argument_list[2].integer_reference;
7670 if (attribute_flag[3] != 0)
7671 frame_info.inner_bevel=argument_list[3].integer_reference;
7672 if (attribute_flag[4] != 0)
7673 frame_info.outer_bevel=argument_list[4].integer_reference;
7674 if (attribute_flag[5] != 0)
7675 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7677 if (attribute_flag[6] != 0)
7678 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7680 frame_info.x=(ssize_t) frame_info.width;
7681 frame_info.y=(ssize_t) frame_info.height;
7682 frame_info.width=image->columns+2*frame_info.x;
7683 frame_info.height=image->rows+2*frame_info.y;
7684 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7685 image->matte_color=fill_color;
7686 if (attribute_flag[7] != 0)
7687 image->compose=(CompositeOperator) argument_list[7].integer_reference;
7688 image=FrameImage(image,&frame_info,exception);
7691 case 16: /* Implode */
7693 if (attribute_flag[0] == 0)
7694 argument_list[0].real_reference=0.5;
7695 if (attribute_flag[1] != 0)
7696 image->interpolate=(InterpolatePixelMethod)
7697 argument_list[1].integer_reference;
7698 image=ImplodeImage(image,argument_list[0].real_reference,
7702 case 17: /* Magnify */
7704 image=MagnifyImage(image,exception);
7707 case 18: /* MedianFilter */
7709 if (attribute_flag[0] != 0)
7711 flags=ParseGeometry(argument_list[0].string_reference,
7713 if ((flags & SigmaValue) == 0)
7714 geometry_info.sigma=1.0;
7716 if (attribute_flag[1] != 0)
7717 geometry_info.rho=argument_list[1].real_reference;
7718 if (attribute_flag[2] != 0)
7719 geometry_info.sigma=argument_list[2].real_reference;
7720 if (attribute_flag[3] != 0)
7721 channel=(ChannelType) argument_list[3].integer_reference;
7722 channel_mask=SetPixelChannelMask(image,channel);
7723 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7724 (size_t) geometry_info.sigma,exception);
7725 if (image != (Image *) NULL)
7726 (void) SetPixelChannelMask(image,channel_mask);
7729 case 19: /* Minify */
7731 image=MinifyImage(image,exception);
7734 case 20: /* OilPaint */
7736 if (attribute_flag[0] == 0)
7737 argument_list[0].real_reference=0.0;
7738 if (attribute_flag[1] == 0)
7739 argument_list[1].real_reference=1.0;
7740 image=OilPaintImage(image,argument_list[0].real_reference,
7741 argument_list[1].real_reference,exception);
7744 case 21: /* ReduceNoise */
7746 if (attribute_flag[0] != 0)
7748 flags=ParseGeometry(argument_list[0].string_reference,
7750 if ((flags & SigmaValue) == 0)
7751 geometry_info.sigma=1.0;
7753 if (attribute_flag[1] != 0)
7754 geometry_info.rho=argument_list[1].real_reference;
7755 if (attribute_flag[2] != 0)
7756 geometry_info.sigma=argument_list[2].real_reference;
7757 if (attribute_flag[3] != 0)
7758 channel=(ChannelType) argument_list[3].integer_reference;
7759 channel_mask=SetPixelChannelMask(image,channel);
7760 image=StatisticImage(image,NonpeakStatistic,(size_t)
7761 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7762 if (image != (Image *) NULL)
7763 (void) SetPixelChannelMask(image,channel_mask);
7768 if (attribute_flag[0] != 0)
7769 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7770 &geometry,exception);
7771 if (attribute_flag[1] != 0)
7772 geometry.x=argument_list[1].integer_reference;
7773 if (attribute_flag[2] != 0)
7774 geometry.y=argument_list[2].integer_reference;
7775 image=RollImage(image,geometry.x,geometry.y,exception);
7778 case 23: /* Rotate */
7780 if (attribute_flag[0] == 0)
7781 argument_list[0].real_reference=90.0;
7782 if (attribute_flag[1] != 0)
7783 QueryColorDatabase(argument_list[1].string_reference,
7784 &image->background_color,exception);
7785 if (attribute_flag[2] != 0)
7786 QueryColorDatabase(argument_list[2].string_reference,
7787 &image->background_color,exception);
7788 if (attribute_flag[3] != 0)
7789 QueryColorDatabase(argument_list[3].string_reference,
7790 &image->background_color,exception);
7791 image=RotateImage(image,argument_list[0].real_reference,exception);
7794 case 24: /* Sample */
7796 if (attribute_flag[0] != 0)
7797 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7798 &geometry,exception);
7799 if (attribute_flag[1] != 0)
7800 geometry.width=argument_list[1].integer_reference;
7801 if (attribute_flag[2] != 0)
7802 geometry.height=argument_list[2].integer_reference;
7803 image=SampleImage(image,geometry.width,geometry.height,exception);
7806 case 25: /* Scale */
7808 if (attribute_flag[0] != 0)
7809 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7810 &geometry,exception);
7811 if (attribute_flag[1] != 0)
7812 geometry.width=argument_list[1].integer_reference;
7813 if (attribute_flag[2] != 0)
7814 geometry.height=argument_list[2].integer_reference;
7815 image=ScaleImage(image,geometry.width,geometry.height,exception);
7818 case 26: /* Shade */
7820 if (attribute_flag[0] != 0)
7822 flags=ParseGeometry(argument_list[0].string_reference,
7824 if ((flags & SigmaValue) == 0)
7825 geometry_info.sigma=0.0;
7827 if (attribute_flag[1] != 0)
7828 geometry_info.rho=argument_list[1].real_reference;
7829 if (attribute_flag[2] != 0)
7830 geometry_info.sigma=argument_list[2].real_reference;
7831 image=ShadeImage(image,
7832 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7833 geometry_info.rho,geometry_info.sigma,exception);
7836 case 27: /* Sharpen */
7838 if (attribute_flag[0] != 0)
7840 flags=ParseGeometry(argument_list[0].string_reference,
7842 if ((flags & SigmaValue) == 0)
7843 geometry_info.sigma=1.0;
7845 if (attribute_flag[1] != 0)
7846 geometry_info.rho=argument_list[1].real_reference;
7847 if (attribute_flag[2] != 0)
7848 geometry_info.sigma=argument_list[2].real_reference;
7849 if (attribute_flag[3] != 0)
7850 channel=(ChannelType) argument_list[3].integer_reference;
7851 channel_mask=SetPixelChannelMask(image,channel);
7852 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7854 if (image != (Image *) NULL)
7855 (void) SetPixelChannelMask(image,channel_mask);
7858 case 28: /* Shear */
7860 if (attribute_flag[0] != 0)
7862 flags=ParseGeometry(argument_list[0].string_reference,
7864 if ((flags & SigmaValue) == 0)
7865 geometry_info.sigma=geometry_info.rho;
7867 if (attribute_flag[1] != 0)
7868 geometry_info.rho=argument_list[1].real_reference;
7869 if (attribute_flag[2] != 0)
7870 geometry_info.sigma=argument_list[2].real_reference;
7871 if (attribute_flag[3] != 0)
7872 QueryColorDatabase(argument_list[3].string_reference,
7873 &image->background_color,exception);
7874 if (attribute_flag[4] != 0)
7875 QueryColorDatabase(argument_list[4].string_reference,
7876 &image->background_color,exception);
7877 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7881 case 29: /* Spread */
7883 if (attribute_flag[0] == 0)
7884 argument_list[0].real_reference=1.0;
7885 image=SpreadImage(image,argument_list[0].real_reference,exception);
7888 case 30: /* Swirl */
7890 if (attribute_flag[0] == 0)
7891 argument_list[0].real_reference=50.0;
7892 if (attribute_flag[1] != 0)
7893 image->interpolate=(InterpolatePixelMethod)
7894 argument_list[1].integer_reference;
7895 image=SwirlImage(image,argument_list[0].real_reference,exception);
7898 case 31: /* Resize */
7901 if (attribute_flag[0] != 0)
7902 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7903 &geometry,exception);
7904 if (attribute_flag[1] != 0)
7905 geometry.width=argument_list[1].integer_reference;
7906 if (attribute_flag[2] != 0)
7907 geometry.height=argument_list[2].integer_reference;
7908 if (attribute_flag[3] == 0)
7909 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7910 if (attribute_flag[4] != 0)
7911 SetImageArtifact(image,"filter:support",
7912 argument_list[4].string_reference);
7913 if (attribute_flag[5] == 0)
7914 argument_list[5].real_reference=1.0;
7915 image=ResizeImage(image,geometry.width,geometry.height,
7916 (FilterTypes) argument_list[3].integer_reference,
7917 argument_list[5].real_reference,exception);
7920 case 33: /* Annotate */
7925 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7927 if (attribute_flag[0] != 0)
7932 text=InterpretImageProperties(info ? info->image_info :
7933 (ImageInfo *) NULL,image,argument_list[0].string_reference);
7934 (void) CloneString(&draw_info->text,text);
7935 text=DestroyString(text);
7937 if (attribute_flag[1] != 0)
7938 (void) CloneString(&draw_info->font,
7939 argument_list[1].string_reference);
7940 if (attribute_flag[2] != 0)
7941 draw_info->pointsize=argument_list[2].real_reference;
7942 if (attribute_flag[3] != 0)
7943 (void) CloneString(&draw_info->density,
7944 argument_list[3].string_reference);
7945 if (attribute_flag[4] != 0)
7946 (void) QueryColorDatabase(argument_list[4].string_reference,
7947 &draw_info->undercolor,exception);
7948 if (attribute_flag[5] != 0)
7950 (void) QueryColorDatabase(argument_list[5].string_reference,
7951 &draw_info->stroke,exception);
7952 if (argument_list[5].image_reference != (Image *) NULL)
7953 draw_info->stroke_pattern=CloneImage(
7954 argument_list[5].image_reference,0,0,MagickTrue,exception);
7956 if (attribute_flag[6] != 0)
7958 (void) QueryColorDatabase(argument_list[6].string_reference,
7959 &draw_info->fill,exception);
7960 if (argument_list[6].image_reference != (Image *) NULL)
7961 draw_info->fill_pattern=CloneImage(
7962 argument_list[6].image_reference,0,0,MagickTrue,exception);
7964 if (attribute_flag[7] != 0)
7966 (void) CloneString(&draw_info->geometry,
7967 argument_list[7].string_reference);
7968 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7969 &geometry,exception);
7970 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
7971 geometry_info.sigma=geometry_info.xi;
7973 if (attribute_flag[8] != 0)
7974 (void) QueryColorDatabase(argument_list[8].string_reference,
7975 &draw_info->fill,exception);
7976 if (attribute_flag[11] != 0)
7977 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
7978 if (attribute_flag[25] != 0)
7983 av=(AV *) argument_list[25].array_reference;
7984 if ((av_len(av) != 3) && (av_len(av) != 5))
7986 ThrowPerlException(exception,OptionError,
7987 "affine matrix must have 4 or 6 elements",PackageName);
7990 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
7991 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
7992 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
7993 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
7994 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
7995 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
7997 ThrowPerlException(exception,OptionError,
7998 "affine matrix is singular",PackageName);
8001 if (av_len(av) == 5)
8003 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8004 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8007 for (j=12; j < 17; j++)
8009 if (attribute_flag[j] == 0)
8011 value=argument_list[j].string_reference;
8012 angle=argument_list[j].real_reference;
8013 current=draw_info->affine;
8014 GetAffineMatrix(&affine);
8022 flags=ParseGeometry(value,&geometry_info);
8023 affine.tx=geometry_info.xi;
8024 affine.ty=geometry_info.psi;
8025 if ((flags & PsiValue) == 0)
8026 affine.ty=affine.tx;
8034 flags=ParseGeometry(value,&geometry_info);
8035 affine.sx=geometry_info.rho;
8036 affine.sy=geometry_info.sigma;
8037 if ((flags & SigmaValue) == 0)
8038 affine.sy=affine.sx;
8048 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8049 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8050 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8051 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8059 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8067 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8071 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8072 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8073 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8074 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8075 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8077 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8080 if (attribute_flag[9] == 0)
8081 argument_list[9].real_reference=0.0;
8082 if (attribute_flag[10] == 0)
8083 argument_list[10].real_reference=0.0;
8084 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8087 geometry[MaxTextExtent];
8089 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8090 (double) argument_list[9].real_reference+draw_info->affine.tx,
8091 (double) argument_list[10].real_reference+draw_info->affine.ty);
8092 (void) CloneString(&draw_info->geometry,geometry);
8094 if (attribute_flag[17] != 0)
8095 draw_info->stroke_width=argument_list[17].real_reference;
8096 if (attribute_flag[18] != 0)
8098 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8099 MagickTrue : MagickFalse;
8100 draw_info->stroke_antialias=draw_info->text_antialias;
8102 if (attribute_flag[19] != 0)
8103 (void) CloneString(&draw_info->family,
8104 argument_list[19].string_reference);
8105 if (attribute_flag[20] != 0)
8106 draw_info->style=(StyleType) argument_list[20].integer_reference;
8107 if (attribute_flag[21] != 0)
8108 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8109 if (attribute_flag[22] != 0)
8110 draw_info->weight=argument_list[22].integer_reference;
8111 if (attribute_flag[23] != 0)
8112 draw_info->align=(AlignType) argument_list[23].integer_reference;
8113 if (attribute_flag[24] != 0)
8114 (void) CloneString(&draw_info->encoding,
8115 argument_list[24].string_reference);
8116 if (attribute_flag[25] != 0)
8117 draw_info->fill_pattern=CloneImage(
8118 argument_list[25].image_reference,0,0,MagickTrue,exception);
8119 if (attribute_flag[26] != 0)
8120 draw_info->fill_pattern=CloneImage(
8121 argument_list[26].image_reference,0,0,MagickTrue,exception);
8122 if (attribute_flag[27] != 0)
8123 draw_info->stroke_pattern=CloneImage(
8124 argument_list[27].image_reference,0,0,MagickTrue,exception);
8125 if (attribute_flag[29] != 0)
8126 draw_info->kerning=argument_list[29].real_reference;
8127 if (attribute_flag[30] != 0)
8128 draw_info->interline_spacing=argument_list[30].real_reference;
8129 if (attribute_flag[31] != 0)
8130 draw_info->interword_spacing=argument_list[31].real_reference;
8131 if (attribute_flag[32] != 0)
8132 draw_info->direction=(DirectionType)
8133 argument_list[32].integer_reference;
8134 (void) AnnotateImage(image,draw_info);
8135 draw_info=DestroyDrawInfo(draw_info);
8138 case 34: /* ColorFloodfill */
8149 draw_info=CloneDrawInfo(info ? info->image_info :
8150 (ImageInfo *) NULL,(DrawInfo *) NULL);
8151 if (attribute_flag[0] != 0)
8152 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8153 &geometry,exception);
8154 if (attribute_flag[1] != 0)
8155 geometry.x=argument_list[1].integer_reference;
8156 if (attribute_flag[2] != 0)
8157 geometry.y=argument_list[2].integer_reference;
8158 if (attribute_flag[3] != 0)
8159 (void) QueryColorDatabase(argument_list[3].string_reference,
8160 &draw_info->fill,exception);
8161 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8164 if (attribute_flag[4] != 0)
8166 QueryMagickColor(argument_list[4].string_reference,&target,
8170 if (attribute_flag[5] != 0)
8171 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8173 if (attribute_flag[6] != 0)
8174 invert=(MagickBooleanType) argument_list[6].integer_reference;
8175 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8176 geometry.y,invert,exception);
8177 draw_info=DestroyDrawInfo(draw_info);
8180 case 35: /* Composite */
8183 composite_geometry[MaxTextExtent];
8189 compose=OverCompositeOp;
8190 if (attribute_flag[0] != 0)
8191 composite_image=argument_list[0].image_reference;
8194 ThrowPerlException(exception,OptionError,
8195 "CompositeImageRequired",PackageName);
8199 Parameter Handling used for BOTH normal and tiled composition.
8201 if (attribute_flag[1] != 0) /* compose */
8202 compose=(CompositeOperator) argument_list[1].integer_reference;
8203 if (attribute_flag[6] != 0) /* opacity */
8205 if (compose != DissolveCompositeOp)
8206 (void) SetImageOpacity(composite_image,(Quantum)
8207 SiPrefixToDouble(argument_list[6].string_reference,
8230 Handle dissolve composite operator (patch by
8233 (void) CloneString(&image->geometry,
8234 argument_list[6].string_reference);
8235 opacity=(Quantum) SiPrefixToDouble(
8236 argument_list[6].string_reference,QuantumRange);
8237 if (composite_image->matte != MagickTrue)
8238 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8239 composite_view=AcquireCacheView(composite_image);
8240 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8242 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8243 composite_image->columns,1,exception);
8244 for (x=0; x < (ssize_t) composite_image->columns; x++)
8246 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8247 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8248 q+=GetPixelChannels(composite_image);
8250 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8251 if (sync == MagickFalse)
8254 composite_view=DestroyCacheView(composite_view);
8257 if (attribute_flag[9] != 0) /* "color=>" */
8258 QueryColorDatabase(argument_list[9].string_reference,
8259 &composite_image->background_color,exception);
8260 if (attribute_flag[12] != 0) /* "interpolate=>" */
8261 image->interpolate=(InterpolatePixelMethod)
8262 argument_list[12].integer_reference;
8263 if (attribute_flag[13] != 0) /* "args=>" */
8264 (void) SetImageArtifact(composite_image,"compose:args",
8265 argument_list[13].string_reference);
8266 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8267 (void) SetImageArtifact(composite_image,"compose:args",
8268 argument_list[14].string_reference);
8270 Tiling Composition (with orthogonal rotate).
8272 rotate_image=(Image *) NULL;
8273 if (attribute_flag[8] != 0) /* "rotate=>" */
8278 rotate_image=RotateImage(composite_image,
8279 argument_list[8].real_reference,exception);
8280 if (rotate_image == (Image *) NULL)
8283 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8290 Tile the composite image.
8292 if (attribute_flag[8] != 0) /* "tile=>" */
8293 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8296 (void) SetImageArtifact(composite_image,
8297 "compose:outside-overlay","false");
8298 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8299 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8301 if (attribute_flag[8] != 0) /* rotate */
8302 (void) CompositeImage(image,compose,rotate_image,x,y);
8304 (void) CompositeImage(image,compose,composite_image,x,y);
8306 if (attribute_flag[8] != 0) /* rotate */
8307 rotate_image=DestroyImage(rotate_image);
8311 Parameter Handling used used ONLY for normal composition.
8313 if (attribute_flag[5] != 0) /* gravity */
8314 image->gravity=(GravityType) argument_list[5].integer_reference;
8315 if (attribute_flag[2] != 0) /* geometry offset */
8317 SetGeometry(image,&geometry);
8318 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8320 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8323 if (attribute_flag[3] != 0) /* x offset */
8324 geometry.x=argument_list[3].integer_reference;
8325 if (attribute_flag[4] != 0) /* y offset */
8326 geometry.y=argument_list[4].integer_reference;
8327 if (attribute_flag[10] != 0) /* mask */
8329 if ((image->compose == DisplaceCompositeOp) ||
8330 (image->compose == DistortCompositeOp))
8333 Merge Y displacement into X displacement image.
8335 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8337 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8338 argument_list[10].image_reference,0,0);
8343 Set a blending mask for the composition.
8345 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8346 MagickTrue,&image->exception);
8347 (void) NegateImage(image->mask,MagickFalse,exception);
8350 if (attribute_flag[11] != 0) /* channel */
8351 channel=(ChannelType) argument_list[11].integer_reference;
8353 Composite two images (normal composition).
8355 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8356 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8357 (double) composite_image->rows,(double) geometry.x,(double)
8359 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8361 channel_mask=SetPixelChannelMask(image,channel);
8362 if (attribute_flag[8] == 0) /* no rotate */
8363 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8367 Position adjust rotated image then composite.
8369 geometry.x-=(ssize_t) (rotate_image->columns-
8370 composite_image->columns)/2;
8371 geometry.y-=(ssize_t) (rotate_image->rows-
8372 composite_image->rows)/2;
8373 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8374 rotate_image=DestroyImage(rotate_image);
8376 if (attribute_flag[10] != 0) /* mask */
8378 if ((image->compose == DisplaceCompositeOp) ||
8379 (image->compose == DistortCompositeOp))
8380 composite_image=DestroyImage(composite_image);
8382 image->mask=DestroyImage(image->mask);
8384 (void) SetPixelChannelMask(image,channel_mask);
8387 case 36: /* Contrast */
8389 if (attribute_flag[0] == 0)
8390 argument_list[0].integer_reference=0;
8391 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8392 MagickTrue : MagickFalse,exception);
8395 case 37: /* CycleColormap */
8397 if (attribute_flag[0] == 0)
8398 argument_list[0].integer_reference=6;
8399 (void) CycleColormapImage(image,argument_list[0].integer_reference);
8407 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8409 (void) CloneString(&draw_info->primitive,"point");
8410 if (attribute_flag[0] != 0)
8412 if (argument_list[0].integer_reference < 0)
8413 (void) CloneString(&draw_info->primitive,
8414 argument_list[0].string_reference);
8416 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8417 MagickPrimitiveOptions,argument_list[0].integer_reference));
8419 if (attribute_flag[1] != 0)
8421 if (LocaleCompare(draw_info->primitive,"path") == 0)
8423 (void) ConcatenateString(&draw_info->primitive," '");
8424 ConcatenateString(&draw_info->primitive,
8425 argument_list[1].string_reference);
8426 (void) ConcatenateString(&draw_info->primitive,"'");
8430 (void) ConcatenateString(&draw_info->primitive," ");
8431 ConcatenateString(&draw_info->primitive,
8432 argument_list[1].string_reference);
8435 if (attribute_flag[2] != 0)
8437 (void) ConcatenateString(&draw_info->primitive," ");
8438 (void) ConcatenateString(&draw_info->primitive,
8439 CommandOptionToMnemonic(MagickMethodOptions,
8440 argument_list[2].integer_reference));
8442 if (attribute_flag[3] != 0)
8444 (void) QueryColorDatabase(argument_list[3].string_reference,
8445 &draw_info->stroke,exception);
8446 if (argument_list[3].image_reference != (Image *) NULL)
8447 draw_info->stroke_pattern=CloneImage(
8448 argument_list[3].image_reference,0,0,MagickTrue,exception);
8450 if (attribute_flag[4] != 0)
8452 (void) QueryColorDatabase(argument_list[4].string_reference,
8453 &draw_info->fill,exception);
8454 if (argument_list[4].image_reference != (Image *) NULL)
8455 draw_info->fill_pattern=CloneImage(
8456 argument_list[4].image_reference,0,0,MagickTrue,exception);
8458 if (attribute_flag[5] != 0)
8459 draw_info->stroke_width=argument_list[5].real_reference;
8460 if (attribute_flag[6] != 0)
8461 (void) CloneString(&draw_info->font,
8462 argument_list[6].string_reference);
8463 if (attribute_flag[7] != 0)
8464 (void) QueryColorDatabase(argument_list[7].string_reference,
8465 &draw_info->border_color,exception);
8466 if (attribute_flag[8] != 0)
8467 draw_info->affine.tx=argument_list[8].real_reference;
8468 if (attribute_flag[9] != 0)
8469 draw_info->affine.ty=argument_list[9].real_reference;
8470 if (attribute_flag[20] != 0)
8475 av=(AV *) argument_list[20].array_reference;
8476 if ((av_len(av) != 3) && (av_len(av) != 5))
8478 ThrowPerlException(exception,OptionError,
8479 "affine matrix must have 4 or 6 elements",PackageName);
8482 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8483 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8484 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8485 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8486 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8487 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8489 ThrowPerlException(exception,OptionError,
8490 "affine matrix is singular",PackageName);
8493 if (av_len(av) == 5)
8495 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8496 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8499 for (j=10; j < 15; j++)
8501 if (attribute_flag[j] == 0)
8503 value=argument_list[j].string_reference;
8504 angle=argument_list[j].real_reference;
8505 current=draw_info->affine;
8506 GetAffineMatrix(&affine);
8514 flags=ParseGeometry(value,&geometry_info);
8515 affine.tx=geometry_info.xi;
8516 affine.ty=geometry_info.psi;
8517 if ((flags & PsiValue) == 0)
8518 affine.ty=affine.tx;
8526 flags=ParseGeometry(value,&geometry_info);
8527 affine.sx=geometry_info.rho;
8528 affine.sy=geometry_info.sigma;
8529 if ((flags & SigmaValue) == 0)
8530 affine.sy=affine.sx;
8540 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8541 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8542 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8543 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8551 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8559 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8563 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8564 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8565 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8566 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8567 draw_info->affine.tx=
8568 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8569 draw_info->affine.ty=
8570 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8572 if (attribute_flag[15] != 0)
8573 draw_info->fill_pattern=CloneImage(
8574 argument_list[15].image_reference,0,0,MagickTrue,exception);
8575 if (attribute_flag[16] != 0)
8576 draw_info->pointsize=argument_list[16].real_reference;
8577 if (attribute_flag[17] != 0)
8579 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8580 ? MagickTrue : MagickFalse;
8581 draw_info->text_antialias=draw_info->stroke_antialias;
8583 if (attribute_flag[18] != 0)
8584 (void) CloneString(&draw_info->density,
8585 argument_list[18].string_reference);
8586 if (attribute_flag[19] != 0)
8587 draw_info->stroke_width=argument_list[19].real_reference;
8588 if (attribute_flag[21] != 0)
8589 draw_info->dash_offset=argument_list[21].real_reference;
8590 if (attribute_flag[22] != 0)
8595 av=(AV *) argument_list[22].array_reference;
8596 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8597 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8598 if (draw_info->dash_pattern != (double *) NULL)
8600 for (i=0; i <= av_len(av); i++)
8601 draw_info->dash_pattern[i]=(double)
8602 SvNV(*(av_fetch(av,i,0)));
8603 draw_info->dash_pattern[i]=0.0;
8606 if (attribute_flag[23] != 0)
8607 image->interpolate=(InterpolatePixelMethod)
8608 argument_list[23].integer_reference;
8609 if ((attribute_flag[24] != 0) &&
8610 (draw_info->fill_pattern != (Image *) NULL))
8611 flags=ParsePageGeometry(draw_info->fill_pattern,
8612 argument_list[24].string_reference,
8613 &draw_info->fill_pattern->tile_offset,exception);
8614 if (attribute_flag[25] != 0)
8616 (void) ConcatenateString(&draw_info->primitive," '");
8617 (void) ConcatenateString(&draw_info->primitive,
8618 argument_list[25].string_reference);
8619 (void) ConcatenateString(&draw_info->primitive,"'");
8621 if (attribute_flag[26] != 0)
8622 draw_info->fill_pattern=CloneImage(
8623 argument_list[26].image_reference,0,0,MagickTrue,exception);
8624 if (attribute_flag[27] != 0)
8625 draw_info->stroke_pattern=CloneImage(
8626 argument_list[27].image_reference,0,0,MagickTrue,exception);
8627 if (attribute_flag[28] != 0)
8628 (void) CloneString(&draw_info->primitive,
8629 argument_list[28].string_reference);
8630 if (attribute_flag[29] != 0)
8631 draw_info->kerning=argument_list[29].real_reference;
8632 if (attribute_flag[30] != 0)
8633 draw_info->interline_spacing=argument_list[30].real_reference;
8634 if (attribute_flag[31] != 0)
8635 draw_info->interword_spacing=argument_list[31].real_reference;
8636 if (attribute_flag[32] != 0)
8637 draw_info->direction=(DirectionType)
8638 argument_list[32].integer_reference;
8639 DrawImage(image,draw_info);
8640 draw_info=DestroyDrawInfo(draw_info);
8643 case 39: /* Equalize */
8645 if (attribute_flag[0] != 0)
8646 channel=(ChannelType) argument_list[0].integer_reference;
8647 channel_mask=SetPixelChannelMask(image,channel);
8648 EqualizeImage(image,exception);
8649 (void) SetPixelChannelMask(image,channel_mask);
8652 case 40: /* Gamma */
8654 if (attribute_flag[1] != 0)
8655 channel=(ChannelType) argument_list[1].integer_reference;
8656 if (attribute_flag[2] == 0)
8657 argument_list[2].real_reference=1.0;
8658 if (attribute_flag[3] == 0)
8659 argument_list[3].real_reference=1.0;
8660 if (attribute_flag[4] == 0)
8661 argument_list[4].real_reference=1.0;
8662 if (attribute_flag[0] == 0)
8664 (void) FormatLocaleString(message,MaxTextExtent,
8665 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8666 (double) argument_list[3].real_reference,
8667 (double) argument_list[4].real_reference);
8668 argument_list[0].string_reference=message;
8670 (void) GammaImage(image,InterpretLocaleValue(
8671 argument_list[0].string_reference,(char **) NULL),exception);
8679 if (attribute_flag[0] == 0)
8681 ThrowPerlException(exception,OptionError,"MapImageRequired",
8685 quantize_info=AcquireQuantizeInfo(info->image_info);
8686 if (attribute_flag[1] != 0)
8687 quantize_info->dither=(MagickBooleanType)
8688 argument_list[1].integer_reference;
8689 if (attribute_flag[2] != 0)
8690 quantize_info->dither_method=(DitherMethod)
8691 argument_list[2].integer_reference;
8692 (void) RemapImages(quantize_info,image,
8693 argument_list[0].image_reference);
8694 quantize_info=DestroyQuantizeInfo(quantize_info);
8697 case 42: /* MatteFloodfill */
8708 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8710 if (attribute_flag[0] != 0)
8711 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8712 &geometry,exception);
8713 if (attribute_flag[1] != 0)
8714 geometry.x=argument_list[1].integer_reference;
8715 if (attribute_flag[2] != 0)
8716 geometry.y=argument_list[2].integer_reference;
8717 if (image->matte == MagickFalse)
8718 (void) SetImageOpacity(image,OpaqueAlpha);
8719 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8721 if (attribute_flag[4] != 0)
8722 QueryMagickColor(argument_list[4].string_reference,&target,
8724 if (attribute_flag[3] != 0)
8725 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8727 if (attribute_flag[5] != 0)
8728 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8731 if (attribute_flag[6] != 0)
8732 invert=(MagickBooleanType) argument_list[6].integer_reference;
8733 channel_mask=SetPixelChannelMask(image,AlphaChannel);
8734 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8735 geometry.y,invert,exception);
8736 (void) SetPixelChannelMask(image,channel_mask);
8737 draw_info=DestroyDrawInfo(draw_info);
8740 case 43: /* Modulate */
8743 modulate[MaxTextExtent];
8745 geometry_info.rho=100.0;
8746 geometry_info.sigma=100.0;
8747 geometry_info.xi=100.0;
8748 if (attribute_flag[0] != 0)
8749 (void)ParseGeometry(argument_list[0].string_reference,
8751 if (attribute_flag[1] != 0)
8752 geometry_info.xi=argument_list[1].real_reference;
8753 if (attribute_flag[2] != 0)
8754 geometry_info.sigma=argument_list[2].real_reference;
8755 if (attribute_flag[3] != 0)
8757 geometry_info.sigma=argument_list[3].real_reference;
8758 SetImageArtifact(image,"modulate:colorspace","HWB");
8760 if (attribute_flag[4] != 0)
8762 geometry_info.rho=argument_list[4].real_reference;
8763 SetImageArtifact(image,"modulate:colorspace","HSB");
8765 if (attribute_flag[5] != 0)
8767 geometry_info.sigma=argument_list[5].real_reference;
8768 SetImageArtifact(image,"modulate:colorspace","HSL");
8770 if (attribute_flag[6] != 0)
8772 geometry_info.rho=argument_list[6].real_reference;
8773 SetImageArtifact(image,"modulate:colorspace","HWB");
8775 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8776 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8777 (void) ModulateImage(image,modulate,exception);
8780 case 44: /* Negate */
8782 if (attribute_flag[0] == 0)
8783 argument_list[0].integer_reference=0;
8784 if (attribute_flag[1] != 0)
8785 channel=(ChannelType) argument_list[1].integer_reference;
8786 channel_mask=SetPixelChannelMask(image,channel);
8787 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8788 MagickTrue : MagickFalse,exception);
8789 (void) SetPixelChannelMask(image,channel_mask);
8792 case 45: /* Normalize */
8794 if (attribute_flag[0] != 0)
8795 channel=(ChannelType) argument_list[0].integer_reference;
8796 channel_mask=SetPixelChannelMask(image,channel);
8797 NormalizeImage(image,exception);
8798 (void) SetPixelChannelMask(image,channel_mask);
8801 case 46: /* NumberColors */
8803 case 47: /* Opaque */
8812 (void) QueryMagickColor("none",&target,exception);
8813 (void) QueryMagickColor("none",&fill_color,exception);
8814 if (attribute_flag[0] != 0)
8815 (void) QueryMagickColor(argument_list[0].string_reference,
8817 if (attribute_flag[1] != 0)
8818 (void) QueryMagickColor(argument_list[1].string_reference,
8819 &fill_color,exception);
8820 if (attribute_flag[2] != 0)
8821 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8823 if (attribute_flag[3] != 0)
8824 channel=(ChannelType) argument_list[3].integer_reference;
8826 if (attribute_flag[4] != 0)
8827 invert=(MagickBooleanType) argument_list[4].integer_reference;
8828 channel_mask=SetPixelChannelMask(image,channel);
8829 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
8830 (void) SetPixelChannelMask(image,channel_mask);
8833 case 48: /* Quantize */
8838 quantize_info=AcquireQuantizeInfo(info->image_info);
8839 if (attribute_flag[0] != 0)
8840 quantize_info->number_colors=(size_t)
8841 argument_list[0].integer_reference;
8842 if (attribute_flag[1] != 0)
8843 quantize_info->tree_depth=(size_t)
8844 argument_list[1].integer_reference;
8845 if (attribute_flag[2] != 0)
8846 quantize_info->colorspace=(ColorspaceType)
8847 argument_list[2].integer_reference;
8848 if (attribute_flag[3] != 0)
8849 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8850 MagickTrue : MagickFalse;
8851 if (attribute_flag[4] != 0)
8852 quantize_info->measure_error=
8853 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8854 if (attribute_flag[5] != 0)
8855 (void) QueryColorDatabase(argument_list[5].string_reference,
8856 &image->transparent_color,exception);
8857 if (attribute_flag[5] && argument_list[5].integer_reference)
8859 (void) QuantizeImages(quantize_info,image);
8862 if (attribute_flag[6] != 0)
8863 quantize_info->dither_method=(DitherMethod)
8864 argument_list[6].integer_reference;
8865 if ((image->storage_class == DirectClass) ||
8866 (image->colors > quantize_info->number_colors) ||
8867 (quantize_info->colorspace == GRAYColorspace))
8868 (void) QuantizeImage(quantize_info,image);
8870 CompressImageColormap(image);
8871 quantize_info=DestroyQuantizeInfo(quantize_info);
8874 case 49: /* Raise */
8876 if (attribute_flag[0] != 0)
8877 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8878 &geometry,exception);
8879 if (attribute_flag[1] != 0)
8880 geometry.width=argument_list[1].integer_reference;
8881 if (attribute_flag[2] != 0)
8882 geometry.height=argument_list[2].integer_reference;
8883 if (attribute_flag[3] == 0)
8884 argument_list[3].integer_reference=1;
8885 (void) RaiseImage(image,&geometry,
8886 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8890 case 50: /* Segment */
8897 smoothing_threshold;
8902 cluster_threshold=1.0;
8903 smoothing_threshold=1.5;
8904 colorspace=RGBColorspace;
8905 verbose=MagickFalse;
8906 if (attribute_flag[0] != 0)
8908 flags=ParseGeometry(argument_list[0].string_reference,
8910 cluster_threshold=geometry_info.rho;
8911 if (flags & SigmaValue)
8912 smoothing_threshold=geometry_info.sigma;
8914 if (attribute_flag[1] != 0)
8915 cluster_threshold=argument_list[1].real_reference;
8916 if (attribute_flag[2] != 0)
8917 smoothing_threshold=argument_list[2].real_reference;
8918 if (attribute_flag[3] != 0)
8919 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8920 if (attribute_flag[4] != 0)
8921 verbose=argument_list[4].integer_reference != 0 ?
8922 MagickTrue : MagickFalse;
8923 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8924 smoothing_threshold);
8927 case 51: /* Signature */
8929 (void) SignatureImage(image);
8932 case 52: /* Solarize */
8934 geometry_info.rho=QuantumRange/2.0;
8935 if (attribute_flag[0] != 0)
8936 flags=ParseGeometry(argument_list[0].string_reference,
8938 if (attribute_flag[1] != 0)
8939 geometry_info.rho=SiPrefixToDouble(argument_list[1].string_reference,
8941 (void) SolarizeImage(image,geometry_info.rho);
8946 (void) SyncImage(image);
8949 case 54: /* Texture */
8951 if (attribute_flag[0] == 0)
8953 TextureImage(image,argument_list[0].image_reference);
8956 case 55: /* Evalute */
8958 MagickEvaluateOperator
8961 op=SetEvaluateOperator;
8962 if (attribute_flag[0] == MagickFalse)
8963 argument_list[0].real_reference=0.0;
8964 if (attribute_flag[1] != MagickFalse)
8965 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8966 if (attribute_flag[2] != MagickFalse)
8967 channel=(ChannelType) argument_list[2].integer_reference;
8968 channel_mask=SetPixelChannelMask(image,channel);
8969 (void) EvaluateImage(image,op,argument_list[0].real_reference,
8971 (void) SetPixelChannelMask(image,channel_mask);
8974 case 56: /* Transparent */
8985 (void) QueryMagickColor("none",&target,exception);
8986 if (attribute_flag[0] != 0)
8987 (void) QueryMagickColor(argument_list[0].string_reference,&target,
8989 opacity=TransparentAlpha;
8990 if (attribute_flag[1] != 0)
8991 opacity=SiPrefixToDouble(argument_list[1].string_reference,
8993 if (attribute_flag[2] != 0)
8994 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8996 if (attribute_flag[3] == 0)
8997 argument_list[3].integer_reference=0;
8999 if (attribute_flag[3] != 0)
9000 invert=(MagickBooleanType) argument_list[3].integer_reference;
9001 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9005 case 57: /* Threshold */
9010 if (attribute_flag[0] == 0)
9011 argument_list[0].string_reference="50%";
9012 if (attribute_flag[1] != 0)
9013 channel=(ChannelType) argument_list[1].integer_reference;
9014 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9016 channel_mask=SetPixelChannelMask(image,channel);
9017 (void) BilevelImage(image,threshold);
9018 (void) SetPixelChannelMask(image,channel_mask);
9021 case 58: /* Charcoal */
9023 if (attribute_flag[0] != 0)
9025 flags=ParseGeometry(argument_list[0].string_reference,
9027 if ((flags & SigmaValue) == 0)
9028 geometry_info.sigma=1.0;
9030 if (attribute_flag[1] != 0)
9031 geometry_info.rho=argument_list[1].real_reference;
9032 if (attribute_flag[2] != 0)
9033 geometry_info.sigma=argument_list[2].real_reference;
9034 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9040 if (attribute_flag[0] != 0)
9041 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9043 image=TrimImage(image,exception);
9048 if (attribute_flag[0] != 0)
9050 flags=ParseGeometry(argument_list[0].string_reference,
9052 if ((flags & SigmaValue) == 0)
9053 geometry_info.sigma=1.0;
9055 if (attribute_flag[1] != 0)
9056 geometry_info.rho=argument_list[1].real_reference;
9057 if (attribute_flag[2] != 0)
9058 geometry_info.sigma=argument_list[2].real_reference;
9059 if (attribute_flag[3] != 0)
9060 image->interpolate=(InterpolatePixelMethod)
9061 argument_list[3].integer_reference;
9062 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9066 case 61: /* Separate */
9068 if (attribute_flag[0] != 0)
9069 channel=(ChannelType) argument_list[0].integer_reference;
9070 channel_mask=SetPixelChannelMask(image,channel);
9071 (void) SeparateImage(image);
9072 (void) SetPixelChannelMask(image,channel_mask);
9075 case 63: /* Stereo */
9077 if (attribute_flag[0] == 0)
9079 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9083 if (attribute_flag[1] != 0)
9084 geometry.x=argument_list[1].integer_reference;
9085 if (attribute_flag[2] != 0)
9086 geometry.y=argument_list[2].integer_reference;
9087 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9088 geometry.x,geometry.y,exception);
9091 case 64: /* Stegano */
9093 if (attribute_flag[0] == 0)
9095 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9099 if (attribute_flag[1] == 0)
9100 argument_list[1].integer_reference=0;
9101 image->offset=argument_list[1].integer_reference;
9102 image=SteganoImage(image,argument_list[0].image_reference,exception);
9105 case 65: /* Deconstruct */
9107 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9110 case 66: /* GaussianBlur */
9112 if (attribute_flag[0] != 0)
9114 flags=ParseGeometry(argument_list[0].string_reference,
9116 if ((flags & SigmaValue) == 0)
9117 geometry_info.sigma=1.0;
9119 if (attribute_flag[1] != 0)
9120 geometry_info.rho=argument_list[1].real_reference;
9121 if (attribute_flag[2] != 0)
9122 geometry_info.sigma=argument_list[2].real_reference;
9123 if (attribute_flag[3] != 0)
9124 channel=(ChannelType) argument_list[3].integer_reference;
9125 channel_mask=SetPixelChannelMask(image,channel);
9126 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9128 if (image != (Image *) NULL)
9129 (void) SetPixelChannelMask(image,channel_mask);
9132 case 67: /* Convolve */
9137 kernel=(KernelInfo *) NULL;
9138 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9140 if (attribute_flag[0] != 0)
9148 kernel=AcquireKernelInfo((const char *) NULL);
9149 if (kernel == (KernelInfo *) NULL)
9151 av=(AV *) argument_list[0].array_reference;
9152 order=(size_t) sqrt(av_len(av)+1);
9153 kernel->width=order;
9154 kernel->height=order;
9155 kernel->values=(double *) AcquireQuantumMemory(order,order*
9156 sizeof(*kernel->values));
9157 if (kernel->values == (double *) NULL)
9159 kernel=DestroyKernelInfo(kernel);
9160 ThrowPerlException(exception,ResourceLimitFatalError,
9161 "MemoryAllocationFailed",PackageName);
9164 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9165 kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
9166 for ( ; j < (ssize_t) (order*order); j++)
9167 kernel->values[j]=0.0;
9169 if (attribute_flag[1] != 0)
9170 channel=(ChannelType) argument_list[1].integer_reference;
9171 if (attribute_flag[2] != 0)
9172 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9174 if (attribute_flag[3] != 0)
9176 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9177 if (kernel == (KernelInfo *) NULL)
9180 channel_mask=SetPixelChannelMask(image,channel);
9181 kernel->bias=image->bias;
9182 image=ConvolveImage(image,kernel,exception);
9183 if (image != (Image *) NULL)
9184 (void) SetPixelChannelMask(image,channel_mask);
9185 kernel=DestroyKernelInfo(kernel);
9188 case 68: /* Profile */
9203 if (attribute_flag[0] != 0)
9204 name=argument_list[0].string_reference;
9205 if (attribute_flag[2] != 0)
9206 image->rendering_intent=(RenderingIntent)
9207 argument_list[2].integer_reference;
9208 if (attribute_flag[3] != 0)
9209 image->black_point_compensation=
9210 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9211 if (attribute_flag[1] != 0)
9213 if (argument_list[1].length == 0)
9216 Remove a profile from the image.
9218 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9223 Associate user supplied profile with the image.
9225 profile=AcquireStringInfo(argument_list[1].length);
9226 SetStringInfoDatum(profile,(const unsigned char *)
9227 argument_list[1].string_reference);
9228 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9229 (size_t) GetStringInfoLength(profile),MagickFalse);
9230 profile=DestroyStringInfo(profile);
9234 Associate a profile with the image.
9237 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9238 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9239 profile_image=ReadImages(profile_info,&image->exception);
9240 if (profile_image == (Image *) NULL)
9242 ResetImageProfileIterator(profile_image);
9243 name=GetNextImageProfile(profile_image);
9244 while (name != (const char *) NULL)
9249 profile=GetImageProfile(profile_image,name);
9250 if (profile != (const StringInfo *) NULL)
9251 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9252 (size_t) GetStringInfoLength(profile),MagickFalse);
9253 name=GetNextImageProfile(profile_image);
9255 profile_image=DestroyImage(profile_image);
9256 profile_info=DestroyImageInfo(profile_info);
9259 case 69: /* UnsharpMask */
9261 if (attribute_flag[0] != 0)
9263 flags=ParseGeometry(argument_list[0].string_reference,
9265 if ((flags & SigmaValue) == 0)
9266 geometry_info.sigma=1.0;
9267 if ((flags & XiValue) == 0)
9268 geometry_info.xi=1.0;
9269 if ((flags & PsiValue) == 0)
9270 geometry_info.psi=0.5;
9272 if (attribute_flag[1] != 0)
9273 geometry_info.rho=argument_list[1].real_reference;
9274 if (attribute_flag[2] != 0)
9275 geometry_info.sigma=argument_list[2].real_reference;
9276 if (attribute_flag[3] != 0)
9277 geometry_info.xi=argument_list[3].real_reference;
9278 if (attribute_flag[4] != 0)
9279 geometry_info.psi=argument_list[4].real_reference;
9280 if (attribute_flag[5] != 0)
9281 channel=(ChannelType) argument_list[5].integer_reference;
9282 channel_mask=SetPixelChannelMask(image,channel);
9283 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9284 geometry_info.xi,geometry_info.psi,exception);
9285 if (image != (Image *) NULL)
9286 (void) SetPixelChannelMask(image,channel_mask);
9289 case 70: /* MotionBlur */
9291 if (attribute_flag[0] != 0)
9293 flags=ParseGeometry(argument_list[0].string_reference,
9295 if ((flags & SigmaValue) == 0)
9296 geometry_info.sigma=1.0;
9297 if ((flags & XiValue) == 0)
9298 geometry_info.xi=1.0;
9300 if (attribute_flag[1] != 0)
9301 geometry_info.rho=argument_list[1].real_reference;
9302 if (attribute_flag[2] != 0)
9303 geometry_info.sigma=argument_list[2].real_reference;
9304 if (attribute_flag[3] != 0)
9305 geometry_info.xi=argument_list[3].real_reference;
9306 if (attribute_flag[4] != 0)
9307 channel=(ChannelType) argument_list[4].integer_reference;
9308 channel_mask=SetPixelChannelMask(image,channel);
9309 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9310 geometry_info.xi,exception);
9311 if (image != (Image *) NULL)
9312 (void) SetPixelChannelMask(image,channel_mask);
9315 case 71: /* OrderedDither */
9317 if (attribute_flag[0] == 0)
9318 argument_list[0].string_reference="o8x8";
9319 if (attribute_flag[1] != 0)
9320 channel=(ChannelType) argument_list[1].integer_reference;
9321 channel_mask=SetPixelChannelMask(image,channel);
9322 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9324 (void) SetPixelChannelMask(image,channel_mask);
9327 case 72: /* Shave */
9329 if (attribute_flag[0] != 0)
9330 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9331 &geometry,exception);
9332 if (attribute_flag[1] != 0)
9333 geometry.width=argument_list[1].integer_reference;
9334 if (attribute_flag[2] != 0)
9335 geometry.height=argument_list[2].integer_reference;
9336 image=ShaveImage(image,&geometry,exception);
9339 case 73: /* Level */
9347 white_point=(MagickRealType) image->columns*image->rows;
9349 if (attribute_flag[0] != 0)
9351 flags=ParseGeometry(argument_list[0].string_reference,
9353 black_point=geometry_info.rho;
9354 if ((flags & SigmaValue) != 0)
9355 white_point=geometry_info.sigma;
9356 if ((flags & XiValue) != 0)
9357 gamma=geometry_info.xi;
9358 if ((flags & PercentValue) != 0)
9360 black_point*=(double) (QuantumRange/100.0);
9361 white_point*=(double) (QuantumRange/100.0);
9363 if ((flags & SigmaValue) == 0)
9364 white_point=(double) QuantumRange-black_point;
9366 if (attribute_flag[1] != 0)
9367 black_point=argument_list[1].real_reference;
9368 if (attribute_flag[2] != 0)
9369 white_point=argument_list[2].real_reference;
9370 if (attribute_flag[3] != 0)
9371 gamma=argument_list[3].real_reference;
9372 if (attribute_flag[4] != 0)
9373 channel=(ChannelType) argument_list[4].integer_reference;
9374 if (attribute_flag[5] != 0)
9376 argument_list[0].real_reference=argument_list[5].real_reference;
9377 attribute_flag[0]=attribute_flag[5];
9379 channel_mask=SetPixelChannelMask(image,channel);
9380 (void) LevelImage(image,black_point,white_point,gamma,exception);
9381 (void) SetPixelChannelMask(image,channel_mask);
9386 if (attribute_flag[0] == 0)
9387 argument_list[0].string_reference="#1";
9388 if (attribute_flag[1] == 0)
9389 argument_list[1].integer_reference=MagickTrue;
9390 (void) ClipImagePath(image,argument_list[0].string_reference,
9391 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse);
9394 case 75: /* AffineTransform */
9399 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9401 if (attribute_flag[0] != 0)
9406 av=(AV *) argument_list[0].array_reference;
9407 if ((av_len(av) != 3) && (av_len(av) != 5))
9409 ThrowPerlException(exception,OptionError,
9410 "affine matrix must have 4 or 6 elements",PackageName);
9413 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9414 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9415 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9416 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9417 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9418 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9420 ThrowPerlException(exception,OptionError,
9421 "affine matrix is singular",PackageName);
9424 if (av_len(av) == 5)
9426 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9427 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9430 for (j=1; j < 6; j++)
9432 if (attribute_flag[j] == 0)
9434 value=argument_list[j].string_reference;
9435 angle=argument_list[j].real_reference;
9436 current=draw_info->affine;
9437 GetAffineMatrix(&affine);
9445 flags=ParseGeometry(value,&geometry_info);
9446 affine.tx=geometry_info.xi;
9447 affine.ty=geometry_info.psi;
9448 if ((flags & PsiValue) == 0)
9449 affine.ty=affine.tx;
9457 flags=ParseGeometry(value,&geometry_info);
9458 affine.sx=geometry_info.rho;
9459 affine.sy=geometry_info.sigma;
9460 if ((flags & SigmaValue) == 0)
9461 affine.sy=affine.sx;
9471 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9472 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9473 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9474 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9482 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9490 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9494 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9495 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9496 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9497 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9498 draw_info->affine.tx=
9499 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9500 draw_info->affine.ty=
9501 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9503 if (attribute_flag[6] != 0)
9504 image->interpolate=(InterpolatePixelMethod)
9505 argument_list[6].integer_reference;
9506 if (attribute_flag[7] != 0)
9507 QueryColorDatabase(argument_list[7].string_reference,
9508 &image->background_color,exception);
9509 image=AffineTransformImage(image,&draw_info->affine,exception);
9510 draw_info=DestroyDrawInfo(draw_info);
9513 case 76: /* Difference */
9515 if (attribute_flag[0] == 0)
9517 ThrowPerlException(exception,OptionError,
9518 "ReferenceImageRequired",PackageName);
9521 if (attribute_flag[1] != 0)
9522 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9524 (void) IsImagesEqual(image,argument_list[0].image_reference);
9527 case 77: /* AdaptiveThreshold */
9529 if (attribute_flag[0] != 0)
9531 flags=ParseGeometry(argument_list[0].string_reference,
9533 if ((flags & PercentValue) != 0)
9534 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9536 if (attribute_flag[1] != 0)
9537 geometry_info.rho=argument_list[1].integer_reference;
9538 if (attribute_flag[2] != 0)
9539 geometry_info.sigma=argument_list[2].integer_reference;
9540 if (attribute_flag[3] != 0)
9541 geometry_info.xi=argument_list[3].integer_reference;;
9542 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9543 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9546 case 78: /* Resample */
9552 if (attribute_flag[0] != 0)
9554 flags=ParseGeometry(argument_list[0].string_reference,
9556 if ((flags & SigmaValue) == 0)
9557 geometry_info.sigma=geometry_info.rho;
9559 if (attribute_flag[1] != 0)
9560 geometry_info.rho=argument_list[1].real_reference;
9561 if (attribute_flag[2] != 0)
9562 geometry_info.sigma=argument_list[2].real_reference;
9563 if (attribute_flag[3] == 0)
9564 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9565 if (attribute_flag[4] == 0)
9566 SetImageArtifact(image,"filter:support",
9567 argument_list[4].string_reference);
9568 if (attribute_flag[5] != 0)
9569 argument_list[5].real_reference=1.0;
9570 width=(size_t) (geometry_info.rho*image->columns/
9571 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9572 height=(size_t) (geometry_info.sigma*image->rows/
9573 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9574 image=ResizeImage(image,width,height,(FilterTypes)
9575 argument_list[3].integer_reference,argument_list[5].real_reference,
9577 if (image != (Image *) NULL)
9579 image->x_resolution=geometry_info.rho;
9580 image->y_resolution=geometry_info.sigma;
9584 case 79: /* Describe */
9586 if (attribute_flag[0] == 0)
9587 argument_list[0].file_reference=(FILE *) NULL;
9588 if (attribute_flag[1] != 0)
9589 (void) SetImageArtifact(image,"identify:features",
9590 argument_list[1].string_reference);
9591 (void) IdentifyImage(image,argument_list[0].file_reference,
9592 MagickTrue,exception);
9595 case 80: /* BlackThreshold */
9597 if (attribute_flag[0] == 0)
9598 argument_list[0].string_reference="50%";
9599 if (attribute_flag[2] != 0)
9600 channel=(ChannelType) argument_list[2].integer_reference;
9601 channel_mask=SetPixelChannelMask(image,channel);
9602 BlackThresholdImage(image,argument_list[0].string_reference,
9604 (void) SetPixelChannelMask(image,channel_mask);
9607 case 81: /* WhiteThreshold */
9609 if (attribute_flag[0] == 0)
9610 argument_list[0].string_reference="50%";
9611 if (attribute_flag[2] != 0)
9612 channel=(ChannelType) argument_list[2].integer_reference;
9613 channel_mask=SetPixelChannelMask(image,channel);
9614 WhiteThresholdImage(image,argument_list[0].string_reference,
9616 (void) SetPixelChannelMask(image,channel_mask);
9619 case 82: /* RadialBlur */
9621 if (attribute_flag[0] != 0)
9623 flags=ParseGeometry(argument_list[0].string_reference,
9625 if ((flags & SigmaValue) == 0)
9626 geometry_info.sigma=1.0;
9628 if (attribute_flag[1] != 0)
9629 geometry_info.rho=argument_list[1].real_reference;
9630 if (attribute_flag[2] != 0)
9631 channel=(ChannelType) argument_list[2].integer_reference;
9632 channel_mask=SetPixelChannelMask(image,channel);
9633 image=RadialBlurImage(image,geometry_info.rho,exception);
9634 if (image != (Image *) NULL)
9635 (void) SetPixelChannelMask(image,channel_mask);
9638 case 83: /* Thumbnail */
9640 if (attribute_flag[0] != 0)
9641 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9642 &geometry,exception);
9643 if (attribute_flag[1] != 0)
9644 geometry.width=argument_list[1].integer_reference;
9645 if (attribute_flag[2] != 0)
9646 geometry.height=argument_list[2].integer_reference;
9647 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9650 case 84: /* Strip */
9652 (void) StripImage(image);
9660 (void) GetOneVirtualPixel(image,0,0,&target,exception);
9661 if (attribute_flag[0] != 0)
9662 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
9664 if (attribute_flag[1] == 0)
9665 argument_list[1].string_reference="100";
9666 image=TintImage(image,argument_list[1].string_reference,target,
9670 case 86: /* Channel */
9672 if (attribute_flag[0] != 0)
9673 channel=(ChannelType) argument_list[0].integer_reference;
9674 channel_mask=SetPixelChannelMask(image,channel);
9675 (void) SeparateImage(image);
9676 (void) SetPixelChannelMask(image,channel_mask);
9679 case 87: /* Splice */
9681 if (attribute_flag[0] != 0)
9682 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9683 &geometry,exception);
9684 if (attribute_flag[1] != 0)
9685 geometry.width=argument_list[1].integer_reference;
9686 if (attribute_flag[2] != 0)
9687 geometry.height=argument_list[2].integer_reference;
9688 if (attribute_flag[3] != 0)
9689 geometry.x=argument_list[3].integer_reference;
9690 if (attribute_flag[4] != 0)
9691 geometry.y=argument_list[4].integer_reference;
9692 if (attribute_flag[5] != 0)
9693 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9695 if (attribute_flag[6] != 0)
9696 (void) QueryColorDatabase(argument_list[6].string_reference,
9697 &image->background_color,exception);
9698 if (attribute_flag[7] != 0)
9699 image->gravity=(GravityType) argument_list[7].integer_reference;
9700 image=SpliceImage(image,&geometry,exception);
9703 case 88: /* Posterize */
9705 if (attribute_flag[0] == 0)
9706 argument_list[0].integer_reference=3;
9707 if (attribute_flag[1] == 0)
9708 argument_list[1].integer_reference=0;
9709 (void) PosterizeImage(image,argument_list[0].integer_reference,
9710 argument_list[1].integer_reference ? MagickTrue : MagickFalse);
9713 case 89: /* Shadow */
9715 if (attribute_flag[0] != 0)
9717 flags=ParseGeometry(argument_list[0].string_reference,
9719 if ((flags & SigmaValue) == 0)
9720 geometry_info.sigma=1.0;
9721 if ((flags & XiValue) == 0)
9722 geometry_info.xi=4.0;
9723 if ((flags & PsiValue) == 0)
9724 geometry_info.psi=4.0;
9726 if (attribute_flag[1] != 0)
9727 geometry_info.rho=argument_list[1].real_reference;
9728 if (attribute_flag[2] != 0)
9729 geometry_info.sigma=argument_list[2].real_reference;
9730 if (attribute_flag[3] != 0)
9731 geometry_info.xi=argument_list[3].integer_reference;
9732 if (attribute_flag[4] != 0)
9733 geometry_info.psi=argument_list[4].integer_reference;
9734 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9735 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9739 case 90: /* Identify */
9741 if (attribute_flag[0] == 0)
9742 argument_list[0].file_reference=(FILE *) NULL;
9743 if (attribute_flag[1] != 0)
9744 (void) SetImageArtifact(image,"identify:features",
9745 argument_list[1].string_reference);
9746 if ((attribute_flag[2] != 0) &&
9747 (argument_list[2].integer_reference != 0))
9748 (void) SetImageArtifact(image,"identify:unique","true");
9749 (void) IdentifyImage(image,argument_list[0].file_reference,
9750 MagickTrue,exception);
9753 case 91: /* SepiaTone */
9755 if (attribute_flag[0] == 0)
9756 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9757 image=SepiaToneImage(image,argument_list[0].real_reference,
9761 case 92: /* SigmoidalContrast */
9766 if (attribute_flag[0] != 0)
9768 flags=ParseGeometry(argument_list[0].string_reference,
9770 if ((flags & SigmaValue) == 0)
9771 geometry_info.sigma=QuantumRange/2.0;
9772 if ((flags & PercentValue) != 0)
9773 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9775 if (attribute_flag[1] != 0)
9776 geometry_info.rho=argument_list[1].real_reference;
9777 if (attribute_flag[2] != 0)
9778 geometry_info.sigma=argument_list[2].real_reference;
9779 if (attribute_flag[3] != 0)
9780 channel=(ChannelType) argument_list[3].integer_reference;
9782 if (attribute_flag[4] != 0)
9783 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9785 channel_mask=SetPixelChannelMask(image,channel);
9786 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9787 geometry_info.sigma,exception);
9788 (void) SetPixelChannelMask(image,channel_mask);
9791 case 93: /* Extent */
9793 if (attribute_flag[7] != 0)
9794 image->gravity=(GravityType) argument_list[7].integer_reference;
9795 if (attribute_flag[0] != 0)
9800 flags=ParseGravityGeometry(image,
9801 argument_list[0].string_reference,&geometry,exception);
9803 if (geometry.width == 0)
9804 geometry.width=image->columns;
9805 if (geometry.height == 0)
9806 geometry.height=image->rows;
9808 if (attribute_flag[1] != 0)
9809 geometry.width=argument_list[1].integer_reference;
9810 if (attribute_flag[2] != 0)
9811 geometry.height=argument_list[2].integer_reference;
9812 if (attribute_flag[3] != 0)
9813 geometry.x=argument_list[3].integer_reference;
9814 if (attribute_flag[4] != 0)
9815 geometry.y=argument_list[4].integer_reference;
9816 if (attribute_flag[5] != 0)
9817 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9819 if (attribute_flag[6] != 0)
9820 (void) QueryColorDatabase(argument_list[6].string_reference,
9821 &image->background_color,exception);
9822 image=ExtentImage(image,&geometry,exception);
9825 case 94: /* Vignette */
9827 if (attribute_flag[0] != 0)
9829 flags=ParseGeometry(argument_list[0].string_reference,
9831 if ((flags & SigmaValue) == 0)
9832 geometry_info.sigma=1.0;
9833 if ((flags & XiValue) == 0)
9834 geometry_info.xi=0.1*image->columns;
9835 if ((flags & PsiValue) == 0)
9836 geometry_info.psi=0.1*image->rows;
9838 if (attribute_flag[1] != 0)
9839 geometry_info.rho=argument_list[1].real_reference;
9840 if (attribute_flag[2] != 0)
9841 geometry_info.sigma=argument_list[2].real_reference;
9842 if (attribute_flag[3] != 0)
9843 geometry_info.xi=argument_list[3].integer_reference;
9844 if (attribute_flag[4] != 0)
9845 geometry_info.psi=argument_list[4].integer_reference;
9846 if (attribute_flag[5] != 0)
9847 (void) QueryColorDatabase(argument_list[5].string_reference,
9848 &image->background_color,exception);
9849 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9850 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9854 case 95: /* ContrastStretch */
9861 white_point=(MagickRealType) image->columns*image->rows;
9862 if (attribute_flag[0] != 0)
9864 flags=ParseGeometry(argument_list[0].string_reference,
9866 black_point=geometry_info.rho;
9867 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9869 if ((flags & PercentValue) != 0)
9871 black_point*=(double) image->columns*image->rows/100.0;
9872 white_point*=(double) image->columns*image->rows/100.0;
9874 white_point=(MagickRealType) image->columns*image->rows-
9877 if (attribute_flag[1] != 0)
9878 black_point=argument_list[1].real_reference;
9879 if (attribute_flag[2] != 0)
9880 white_point=argument_list[2].real_reference;
9881 if (attribute_flag[4] != 0)
9882 channel=(ChannelType) argument_list[4].integer_reference;
9883 channel_mask=SetPixelChannelMask(image,channel);
9884 (void) ContrastStretchImage(image,black_point,white_point,exception);
9885 (void) SetPixelChannelMask(image,channel_mask);
9888 case 96: /* Sans0 */
9892 case 97: /* Sans1 */
9896 case 98: /* AdaptiveSharpen */
9898 if (attribute_flag[0] != 0)
9900 flags=ParseGeometry(argument_list[0].string_reference,
9902 if ((flags & SigmaValue) == 0)
9903 geometry_info.sigma=1.0;
9905 if (attribute_flag[1] != 0)
9906 geometry_info.rho=argument_list[1].real_reference;
9907 if (attribute_flag[2] != 0)
9908 geometry_info.sigma=argument_list[2].real_reference;
9909 if (attribute_flag[3] != 0)
9910 channel=(ChannelType) argument_list[3].integer_reference;
9911 channel_mask=SetPixelChannelMask(image,channel);
9912 image=AdaptiveSharpenImage(image,geometry_info.rho,
9913 geometry_info.sigma,exception);
9914 if (image != (Image *) NULL)
9915 (void) SetPixelChannelMask(image,channel_mask);
9918 case 99: /* Transpose */
9920 image=TransposeImage(image,exception);
9923 case 100: /* Tranverse */
9925 image=TransverseImage(image,exception);
9928 case 101: /* AutoOrient */
9930 switch (image->orientation)
9932 case TopRightOrientation:
9934 image=FlopImage(image,exception);
9937 case BottomRightOrientation:
9939 image=RotateImage(image,180.0,exception);
9942 case BottomLeftOrientation:
9944 image=FlipImage(image,exception);
9947 case LeftTopOrientation:
9949 image=TransposeImage(image,exception);
9952 case RightTopOrientation:
9954 image=RotateImage(image,90.0,exception);
9957 case RightBottomOrientation:
9959 image=TransverseImage(image,exception);
9962 case LeftBottomOrientation:
9964 image=RotateImage(image,270.0,exception);
9972 case 102: /* AdaptiveBlur */
9974 if (attribute_flag[0] != 0)
9976 flags=ParseGeometry(argument_list[0].string_reference,
9978 if ((flags & SigmaValue) == 0)
9979 geometry_info.sigma=1.0;
9981 if (attribute_flag[1] != 0)
9982 geometry_info.rho=argument_list[1].real_reference;
9983 if (attribute_flag[2] != 0)
9984 geometry_info.sigma=argument_list[2].real_reference;
9985 if (attribute_flag[3] != 0)
9986 channel=(ChannelType) argument_list[3].integer_reference;
9987 channel_mask=SetPixelChannelMask(image,channel);
9988 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
9990 if (image != (Image *) NULL)
9991 (void) SetPixelChannelMask(image,channel_mask);
9994 case 103: /* Sketch */
9996 if (attribute_flag[0] != 0)
9998 flags=ParseGeometry(argument_list[0].string_reference,
10000 if ((flags & SigmaValue) == 0)
10001 geometry_info.sigma=1.0;
10002 if ((flags & XiValue) == 0)
10003 geometry_info.xi=1.0;
10005 if (attribute_flag[1] != 0)
10006 geometry_info.rho=argument_list[1].real_reference;
10007 if (attribute_flag[2] != 0)
10008 geometry_info.sigma=argument_list[2].real_reference;
10009 if (attribute_flag[3] != 0)
10010 geometry_info.xi=argument_list[3].real_reference;
10011 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10012 geometry_info.xi,exception);
10015 case 104: /* UniqueColors */
10017 image=UniqueImageColors(image,exception);
10020 case 105: /* AdaptiveResize */
10022 if (attribute_flag[0] != 0)
10023 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10024 &geometry,exception);
10025 if (attribute_flag[1] != 0)
10026 geometry.width=argument_list[1].integer_reference;
10027 if (attribute_flag[2] != 0)
10028 geometry.height=argument_list[2].integer_reference;
10029 if (attribute_flag[3] != 0)
10030 image->filter=(FilterTypes) argument_list[4].integer_reference;
10031 if (attribute_flag[4] != 0)
10032 SetImageArtifact(image,"filter:support",
10033 argument_list[4].string_reference);
10034 if (attribute_flag[5] != 0)
10035 image->blur=argument_list[5].real_reference;
10036 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10040 case 106: /* ClipMask */
10042 if (attribute_flag[0] == 0)
10044 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10046 goto PerlException;
10048 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10049 MagickTrue,exception);
10050 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10053 case 107: /* LinearStretch */
10060 white_point=(MagickRealType) image->columns*image->rows;
10061 if (attribute_flag[0] != 0)
10063 flags=ParseGeometry(argument_list[0].string_reference,
10065 if ((flags & SigmaValue) != 0)
10066 white_point=geometry_info.sigma;
10067 if ((flags & PercentValue) != 0)
10069 black_point*=(double) image->columns*image->rows/100.0;
10070 white_point*=(double) image->columns*image->rows/100.0;
10072 if ((flags & SigmaValue) == 0)
10073 white_point=(double) image->columns*image->rows-black_point;
10075 if (attribute_flag[1] != 0)
10076 black_point=argument_list[1].real_reference;
10077 if (attribute_flag[2] != 0)
10078 white_point=argument_list[2].real_reference;
10079 (void) LinearStretchImage(image,black_point,white_point,exception);
10082 case 109: /* Mask */
10084 if (attribute_flag[0] == 0)
10086 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10088 goto PerlException;
10090 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10091 MagickTrue,exception);
10092 (void) NegateImage(image->mask,MagickFalse,exception);
10095 case 110: /* Polaroid */
10103 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10104 (DrawInfo *) NULL);
10105 if (attribute_flag[0] != 0)
10106 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10107 info ? info->image_info : (ImageInfo *) NULL,image,
10108 argument_list[0].string_reference));
10110 if (attribute_flag[1] != 0)
10111 angle=argument_list[1].real_reference;
10112 if (attribute_flag[2] != 0)
10113 (void) CloneString(&draw_info->font,
10114 argument_list[2].string_reference);
10115 if (attribute_flag[3] != 0)
10116 (void) QueryColorDatabase(argument_list[3].string_reference,
10117 &draw_info->stroke,exception);
10118 if (attribute_flag[4] != 0)
10119 (void) QueryColorDatabase(argument_list[4].string_reference,
10120 &draw_info->fill,exception);
10121 if (attribute_flag[5] != 0)
10122 draw_info->stroke_width=argument_list[5].real_reference;
10123 if (attribute_flag[6] != 0)
10124 draw_info->pointsize=argument_list[6].real_reference;
10125 if (attribute_flag[7] != 0)
10126 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10127 if (attribute_flag[8] != 0)
10128 (void) QueryColorDatabase(argument_list[8].string_reference,
10129 &image->background_color,exception);
10130 image=PolaroidImage(image,draw_info,angle,exception);
10131 draw_info=DestroyDrawInfo(draw_info);
10134 case 111: /* FloodfillPaint */
10145 draw_info=CloneDrawInfo(info ? info->image_info :
10146 (ImageInfo *) NULL,(DrawInfo *) NULL);
10147 if (attribute_flag[0] != 0)
10148 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10149 &geometry,exception);
10150 if (attribute_flag[1] != 0)
10151 geometry.x=argument_list[1].integer_reference;
10152 if (attribute_flag[2] != 0)
10153 geometry.y=argument_list[2].integer_reference;
10154 if (attribute_flag[3] != 0)
10155 (void) QueryColorDatabase(argument_list[3].string_reference,
10156 &draw_info->fill,exception);
10157 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10159 if (attribute_flag[4] != 0)
10160 QueryMagickColor(argument_list[4].string_reference,&target,
10162 if (attribute_flag[5] != 0)
10163 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10165 if (attribute_flag[6] != 0)
10166 channel=(ChannelType) argument_list[6].integer_reference;
10167 invert=MagickFalse;
10168 if (attribute_flag[7] != 0)
10169 invert=(MagickBooleanType) argument_list[7].integer_reference;
10170 channel_mask=SetPixelChannelMask(image,channel);
10171 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10172 geometry.y,invert,exception);
10173 (void) SetPixelChannelMask(image,channel_mask);
10174 draw_info=DestroyDrawInfo(draw_info);
10177 case 112: /* Distort */
10189 number_coordinates;
10194 if (attribute_flag[0] == 0)
10196 method=UndefinedDistortion;
10197 if (attribute_flag[1] != 0)
10198 method=(DistortImageMethod) argument_list[1].integer_reference;
10199 av=(AV *) argument_list[0].array_reference;
10200 number_coordinates=(size_t) av_len(av)+1;
10201 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10202 sizeof(*coordinates));
10203 if (coordinates == (double *) NULL)
10205 ThrowPerlException(exception,ResourceLimitFatalError,
10206 "MemoryAllocationFailed",PackageName);
10207 goto PerlException;
10209 for (j=0; j < (ssize_t) number_coordinates; j++)
10210 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10211 virtual_pixel=UndefinedVirtualPixelMethod;
10212 if (attribute_flag[2] != 0)
10213 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10214 argument_list[2].integer_reference);
10215 image=DistortImage(image,method,number_coordinates,coordinates,
10216 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10218 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10219 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10220 coordinates=(double *) RelinquishMagickMemory(coordinates);
10223 case 113: /* Clut */
10225 if (attribute_flag[0] == 0)
10227 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10229 goto PerlException;
10231 if (attribute_flag[1] != 0)
10232 channel=(ChannelType) argument_list[1].integer_reference;
10233 channel_mask=SetPixelChannelMask(image,channel);
10234 (void) ClutImage(image,argument_list[0].image_reference,exception);
10235 (void) SetPixelChannelMask(image,channel_mask);
10238 case 114: /* LiquidRescale */
10240 if (attribute_flag[0] != 0)
10241 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10242 &geometry,exception);
10243 if (attribute_flag[1] != 0)
10244 geometry.width=argument_list[1].integer_reference;
10245 if (attribute_flag[2] != 0)
10246 geometry.height=argument_list[2].integer_reference;
10247 if (attribute_flag[3] == 0)
10248 argument_list[3].real_reference=1.0;
10249 if (attribute_flag[4] == 0)
10250 argument_list[4].real_reference=0.0;
10251 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10252 argument_list[3].real_reference,argument_list[4].real_reference,
10256 case 115: /* EncipherImage */
10258 (void) EncipherImage(image,argument_list[0].string_reference,
10262 case 116: /* DecipherImage */
10264 (void) DecipherImage(image,argument_list[0].string_reference,
10268 case 117: /* Deskew */
10270 geometry_info.rho=QuantumRange/2.0;
10271 if (attribute_flag[0] != 0)
10272 flags=ParseGeometry(argument_list[0].string_reference,
10274 if (attribute_flag[1] != 0)
10275 geometry_info.rho=SiPrefixToDouble(
10276 argument_list[1].string_reference,QuantumRange);
10277 image=DeskewImage(image,geometry_info.rho,exception);
10280 case 118: /* Remap */
10285 if (attribute_flag[0] == 0)
10287 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10289 goto PerlException;
10291 quantize_info=AcquireQuantizeInfo(info->image_info);
10292 if (attribute_flag[1] != 0)
10293 quantize_info->dither=(MagickBooleanType)
10294 argument_list[1].integer_reference;
10295 if (attribute_flag[2] != 0)
10296 quantize_info->dither_method=(DitherMethod)
10297 argument_list[2].integer_reference;
10298 (void) RemapImages(quantize_info,image,
10299 argument_list[0].image_reference);
10300 quantize_info=DestroyQuantizeInfo(quantize_info);
10303 case 119: /* SparseColor */
10315 number_coordinates;
10320 if (attribute_flag[0] == 0)
10322 method=UndefinedColorInterpolate;
10323 if (attribute_flag[1] != 0)
10324 method=(SparseColorMethod) argument_list[1].integer_reference;
10325 av=(AV *) argument_list[0].array_reference;
10326 number_coordinates=(size_t) av_len(av)+1;
10327 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10328 sizeof(*coordinates));
10329 if (coordinates == (double *) NULL)
10331 ThrowPerlException(exception,ResourceLimitFatalError,
10332 "MemoryAllocationFailed",PackageName);
10333 goto PerlException;
10335 for (j=0; j < (ssize_t) number_coordinates; j++)
10336 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10337 virtual_pixel=UndefinedVirtualPixelMethod;
10338 if (attribute_flag[2] != 0)
10339 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10340 argument_list[2].integer_reference);
10341 if (attribute_flag[3] != 0)
10342 channel=(ChannelType) argument_list[3].integer_reference;
10343 channel_mask=SetPixelChannelMask(image,channel);
10344 image=SparseColorImage(image,method,number_coordinates,coordinates,
10346 if (image != (Image *) NULL)
10347 (void) SetPixelChannelMask(image,channel_mask);
10348 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10349 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10350 coordinates=(double *) RelinquishMagickMemory(coordinates);
10353 case 120: /* Function */
10370 if (attribute_flag[0] == 0)
10372 function=UndefinedFunction;
10373 if (attribute_flag[1] != 0)
10374 function=(MagickFunction) argument_list[1].integer_reference;
10375 av=(AV *) argument_list[0].array_reference;
10376 number_parameters=(size_t) av_len(av)+1;
10377 parameters=(double *) AcquireQuantumMemory(number_parameters,
10378 sizeof(*parameters));
10379 if (parameters == (double *) NULL)
10381 ThrowPerlException(exception,ResourceLimitFatalError,
10382 "MemoryAllocationFailed",PackageName);
10383 goto PerlException;
10385 for (j=0; j < (ssize_t) number_parameters; j++)
10386 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10387 virtual_pixel=UndefinedVirtualPixelMethod;
10388 if (attribute_flag[2] != 0)
10389 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10390 argument_list[2].integer_reference);
10391 (void) FunctionImage(image,function,number_parameters,parameters,
10393 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10394 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10395 parameters=(double *) RelinquishMagickMemory(parameters);
10398 case 121: /* SelectiveBlur */
10400 if (attribute_flag[0] != 0)
10402 flags=ParseGeometry(argument_list[0].string_reference,
10404 if ((flags & SigmaValue) == 0)
10405 geometry_info.sigma=1.0;
10406 if ((flags & PercentValue) != 0)
10407 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10409 if (attribute_flag[1] != 0)
10410 geometry_info.rho=argument_list[1].real_reference;
10411 if (attribute_flag[2] != 0)
10412 geometry_info.sigma=argument_list[2].real_reference;
10413 if (attribute_flag[3] != 0)
10414 geometry_info.xi=argument_list[3].integer_reference;;
10415 if (attribute_flag[4] != 0)
10416 channel=(ChannelType) argument_list[4].integer_reference;
10417 channel_mask=SetPixelChannelMask(image,channel);
10418 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10419 geometry_info.xi,exception);
10420 if (image != (Image *) NULL)
10421 (void) SetPixelChannelMask(image,channel_mask);
10424 case 122: /* HaldClut */
10426 if (attribute_flag[0] == 0)
10428 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10430 goto PerlException;
10432 if (attribute_flag[1] != 0)
10433 channel=(ChannelType) argument_list[1].integer_reference;
10434 channel_mask=SetPixelChannelMask(image,channel);
10435 (void) HaldClutImage(image,argument_list[0].image_reference,
10437 (void) SetPixelChannelMask(image,channel_mask);
10440 case 123: /* BlueShift */
10442 if (attribute_flag[0] != 0)
10443 (void) ParseGeometry(argument_list[0].string_reference,
10445 image=BlueShiftImage(image,geometry_info.rho,exception);
10448 case 124: /* ForwardFourierTransformImage */
10450 image=ForwardFourierTransformImage(image,
10451 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10455 case 125: /* InverseFourierTransformImage */
10457 image=InverseFourierTransformImage(image,image->next,
10458 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10462 case 126: /* ColorDecisionList */
10464 if (attribute_flag[0] == 0)
10465 argument_list[0].string_reference=(char *) NULL;
10466 (void) ColorDecisionListImage(image,
10467 argument_list[0].string_reference,exception);
10470 case 127: /* AutoGamma */
10472 if (attribute_flag[0] != 0)
10473 channel=(ChannelType) argument_list[0].integer_reference;
10474 channel_mask=SetPixelChannelMask(image,channel);
10475 (void) AutoGammaImage(image,exception);
10476 (void) SetPixelChannelMask(image,channel_mask);
10479 case 128: /* AutoLevel */
10481 if (attribute_flag[0] != 0)
10482 channel=(ChannelType) argument_list[0].integer_reference;
10483 channel_mask=SetPixelChannelMask(image,channel);
10484 (void) AutoLevelImage(image,exception);
10485 (void) SetPixelChannelMask(image,channel_mask);
10488 case 129: /* LevelColors */
10494 (void) QueryMagickColor("#000000",&black_point,exception);
10495 (void) QueryMagickColor("#ffffff",&white_point,exception);
10496 if (attribute_flag[1] != 0)
10497 (void) QueryMagickColor(argument_list[1].string_reference,
10498 &black_point,exception);
10499 if (attribute_flag[2] != 0)
10500 (void) QueryMagickColor(argument_list[2].string_reference,
10501 &white_point,exception);
10502 if (attribute_flag[3] != 0)
10503 channel=(ChannelType) argument_list[3].integer_reference;
10504 channel_mask=SetPixelChannelMask(image,channel);
10505 (void) LevelImageColors(image,&black_point,&white_point,
10506 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10508 (void) SetPixelChannelMask(image,channel_mask);
10511 case 130: /* Clamp */
10513 if (attribute_flag[0] != 0)
10514 channel=(ChannelType) argument_list[0].integer_reference;
10515 channel_mask=SetPixelChannelMask(image,channel);
10516 (void) ClampImage(image);
10517 (void) SetPixelChannelMask(image,channel_mask);
10520 case 132: /* BrightnessContrast */
10528 if (attribute_flag[0] != 0)
10530 flags=ParseGeometry(argument_list[0].string_reference,
10532 brightness=geometry_info.rho;
10533 if ((flags & SigmaValue) == 0)
10534 contrast=geometry_info.sigma;
10536 if (attribute_flag[1] != 0)
10537 brightness=argument_list[1].real_reference;
10538 if (attribute_flag[2] != 0)
10539 contrast=argument_list[2].real_reference;
10540 if (attribute_flag[4] != 0)
10541 channel=(ChannelType) argument_list[4].integer_reference;
10542 channel_mask=SetPixelChannelMask(image,channel);
10543 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10544 (void) SetPixelChannelMask(image,channel_mask);
10547 case 133: /* Morphology */
10558 if (attribute_flag[0] == 0)
10560 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10561 if (kernel == (KernelInfo *) NULL)
10563 if (attribute_flag[1] != 0)
10564 channel=(ChannelType) argument_list[1].integer_reference;
10565 method=UndefinedMorphology;
10566 if (attribute_flag[2] != 0)
10567 method=argument_list[2].integer_reference;
10569 if (attribute_flag[3] != 0)
10570 iterations=argument_list[4].integer_reference;
10571 channel_mask=SetPixelChannelMask(image,channel);
10572 image=MorphologyImage(image,method,iterations,kernel,exception);
10573 if (image != (Image *) NULL)
10574 (void) SetPixelChannelMask(image,channel_mask);
10575 kernel=DestroyKernelInfo(kernel);
10578 case 108: /* Recolor */
10579 case 134: /* ColorMatrix */
10593 if (attribute_flag[0] == 0)
10595 av=(AV *) argument_list[0].array_reference;
10596 if (av == (AV *) NULL)
10598 order=(size_t) sqrt(av_len(av)+1);
10599 color_matrix=(double *) AcquireQuantumMemory(order,order*
10600 sizeof(*color_matrix));
10601 if (color_matrix == (double *) NULL)
10603 ThrowPerlException(exception,ResourceLimitFatalError,
10604 "MemoryAllocationFailed",PackageName);
10605 goto PerlException;
10607 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10608 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10609 for ( ; j < (ssize_t) (order*order); j++)
10610 color_matrix[j]=0.0;
10611 kernel_info=AcquireKernelInfo((const char *) NULL);
10612 if (kernel_info == (KernelInfo *) NULL)
10614 kernel_info->width=order;
10615 kernel_info->height=order;
10616 kernel_info->values=color_matrix;
10617 image=ColorMatrixImage(image,kernel_info,exception);
10618 kernel_info->values=(double *) NULL;
10619 kernel_info=DestroyKernelInfo(kernel_info);
10620 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10623 case 135: /* Color */
10628 (void) QueryMagickColor("none",&color,exception);
10629 if (attribute_flag[0] != 0)
10630 (void) QueryMagickColor(argument_list[0].string_reference,
10632 (void) SetImageColor(image,&color);
10635 case 136: /* Mode */
10637 if (attribute_flag[0] != 0)
10639 flags=ParseGeometry(argument_list[0].string_reference,
10641 if ((flags & SigmaValue) == 0)
10642 geometry_info.sigma=1.0;
10644 if (attribute_flag[1] != 0)
10645 geometry_info.rho=argument_list[1].real_reference;
10646 if (attribute_flag[2] != 0)
10647 geometry_info.sigma=argument_list[2].real_reference;
10648 if (attribute_flag[3] != 0)
10649 channel=(ChannelType) argument_list[3].integer_reference;
10650 channel_mask=SetPixelChannelMask(image,channel);
10651 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10652 (size_t) geometry_info.sigma,exception);
10653 if (image != (Image *) NULL)
10654 (void) SetPixelChannelMask(image,channel_mask);
10657 case 137: /* Statistic */
10662 statistic=UndefinedStatistic;
10663 if (attribute_flag[0] != 0)
10665 flags=ParseGeometry(argument_list[0].string_reference,
10667 if ((flags & SigmaValue) == 0)
10668 geometry_info.sigma=1.0;
10670 if (attribute_flag[1] != 0)
10671 geometry_info.rho=argument_list[1].real_reference;
10672 if (attribute_flag[2] != 0)
10673 geometry_info.sigma=argument_list[2].real_reference;
10674 if (attribute_flag[3] != 0)
10675 channel=(ChannelType) argument_list[3].integer_reference;
10676 if (attribute_flag[4] != 0)
10677 statistic=(StatisticType) argument_list[4].integer_reference;
10678 channel_mask=SetPixelChannelMask(image,channel);
10679 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10680 (size_t) geometry_info.sigma,exception);
10681 if (image != (Image *) NULL)
10682 (void) SetPixelChannelMask(image,channel_mask);
10686 if (next != (Image *) NULL)
10687 (void) CatchImageException(next);
10688 if (region_image != (Image *) NULL)
10693 status=CompositeImage(region_image,CopyCompositeOp,image,
10694 region_info.x,region_info.y);
10696 (void) CatchImageException(region_image);
10697 image=DestroyImage(image);
10698 image=region_image;
10700 if (image != (Image *) NULL)
10703 if (next && (next != image))
10705 image->next=next->next;
10706 if (image->next != (Image *) NULL)
10707 image->next->previous=image;
10708 DeleteImageFromRegistry(*pv,next);
10710 sv_setiv(*pv,(IV) image);
10718 if (reference_vector)
10719 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10720 InheritPerlException(exception,perl_exception);
10721 exception=DestroyExceptionInfo(exception);
10722 sv_setiv(perl_exception,(IV) number_images);
10723 SvPOK_on(perl_exception);
10724 ST(0)=sv_2mortal(perl_exception);
10729 ###############################################################################
10737 ###############################################################################
10742 Image::Magick ref=NO_INIT
10787 PERL_UNUSED_VAR(ref);
10788 PERL_UNUSED_VAR(ix);
10789 exception=AcquireExceptionInfo();
10790 perl_exception=newSVpv("",0);
10793 if (sv_isobject(ST(0)) == 0)
10795 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10797 goto PerlException;
10799 reference=SvRV(ST(0));
10800 hv=SvSTASH(reference);
10802 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10804 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10805 if (image == (Image *) NULL)
10807 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10809 goto PerlException;
10814 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10815 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10816 (void) QueryMagickColor("none",&transparent_color,exception);
10817 for (i=2; i < items; i+=2)
10819 attribute=(char *) SvPV(ST(i-1),na);
10820 switch (*attribute)
10825 if (LocaleCompare(attribute,"background") == 0)
10827 (void) QueryColorDatabase(SvPV(ST(i),na),
10828 &montage_info->background_color,exception);
10829 for (next=image; next; next=next->next)
10830 next->background_color=montage_info->background_color;
10833 if (LocaleCompare(attribute,"border") == 0)
10835 montage_info->border_width=SvIV(ST(i));
10838 if (LocaleCompare(attribute,"bordercolor") == 0)
10840 (void) QueryColorDatabase(SvPV(ST(i),na),
10841 &montage_info->border_color,exception);
10842 for (next=image; next; next=next->next)
10843 next->border_color=montage_info->border_color;
10846 if (LocaleCompare(attribute,"borderwidth") == 0)
10848 montage_info->border_width=SvIV(ST(i));
10851 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10858 if (LocaleCompare(attribute,"compose") == 0)
10860 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10861 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10864 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10868 for (next=image; next; next=next->next)
10869 next->compose=(CompositeOperator) sp;
10872 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10879 if (LocaleCompare(attribute,"fill") == 0)
10881 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10885 if (LocaleCompare(attribute,"font") == 0)
10887 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10890 if (LocaleCompare(attribute,"frame") == 0)
10896 if (IsGeometry(p) == MagickFalse)
10898 ThrowPerlException(exception,OptionError,"MissingGeometry",
10902 (void) CloneString(&montage_info->frame,p);
10904 montage_info->frame=(char *) NULL;
10907 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10914 if (LocaleCompare(attribute,"geometry") == 0)
10920 if (IsGeometry(p) == MagickFalse)
10922 ThrowPerlException(exception,OptionError,"MissingGeometry",
10926 (void) CloneString(&montage_info->geometry,p);
10928 montage_info->geometry=(char *) NULL;
10931 if (LocaleCompare(attribute,"gravity") == 0)
10936 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10937 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
10940 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10944 montage_info->gravity=(GravityType) in;
10945 for (next=image; next; next=next->next)
10946 next->gravity=(GravityType) in;
10949 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10956 if (LocaleCompare(attribute,"label") == 0)
10958 for (next=image; next; next=next->next)
10959 (void) SetImageProperty(next,"label",InterpretImageProperties(
10960 info ? info->image_info : (ImageInfo *) NULL,next,
10964 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10971 if (LocaleCompare(attribute,"mattecolor") == 0)
10973 (void) QueryColorDatabase(SvPV(ST(i),na),
10974 &montage_info->matte_color,exception);
10975 for (next=image; next; next=next->next)
10976 next->matte_color=montage_info->matte_color;
10979 if (LocaleCompare(attribute,"mode") == 0)
10984 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
10985 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
10990 ThrowPerlException(exception,OptionError,
10991 "UnrecognizedModeType",SvPV(ST(i),na));
10996 (void) CloneString(&montage_info->frame,"15x15+3+3");
10997 montage_info->shadow=MagickTrue;
11002 montage_info->frame=(char *) NULL;
11003 montage_info->shadow=MagickFalse;
11004 montage_info->border_width=0;
11007 case ConcatenateMode:
11009 montage_info->frame=(char *) NULL;
11010 montage_info->shadow=MagickFalse;
11011 (void) CloneString(&montage_info->geometry,"+0+0");
11012 montage_info->border_width=0;
11017 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11024 if (LocaleCompare(attribute,"pointsize") == 0)
11026 montage_info->pointsize=SvIV(ST(i));
11029 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11036 if (LocaleCompare(attribute,"shadow") == 0)
11038 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11039 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11042 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11046 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11049 if (LocaleCompare(attribute,"stroke") == 0)
11051 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11055 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11062 if (LocaleCompare(attribute,"texture") == 0)
11064 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11067 if (LocaleCompare(attribute,"tile") == 0)
11069 char *p=SvPV(ST(i),na);
11070 if (IsGeometry(p) == MagickFalse)
11072 ThrowPerlException(exception,OptionError,"MissingGeometry",
11076 (void) CloneString(&montage_info->tile,p);
11078 montage_info->tile=(char *) NULL;
11081 if (LocaleCompare(attribute,"title") == 0)
11083 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11086 if (LocaleCompare(attribute,"transparent") == 0)
11091 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11092 for (next=image; next; next=next->next)
11093 (void) TransparentPaintImage(next,&transparent_color,
11094 TransparentAlpha,MagickFalse,exception);
11097 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11103 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11109 image=MontageImageList(info->image_info,montage_info,image,exception);
11110 montage_info=DestroyMontageInfo(montage_info);
11111 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11112 goto PerlException;
11113 if (transparent_color.alpha != TransparentAlpha)
11114 for (next=image; next; next=next->next)
11115 (void) TransparentPaintImage(next,&transparent_color,
11116 TransparentAlpha,MagickFalse,exception);
11117 for ( ; image; image=image->next)
11119 AddImageToRegistry(sv,image);
11121 av_push(av,sv_bless(rv,hv));
11124 exception=DestroyExceptionInfo(exception);
11125 ST(0)=av_reference;
11126 SvREFCNT_dec(perl_exception);
11130 InheritPerlException(exception,perl_exception);
11131 exception=DestroyExceptionInfo(exception);
11132 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11133 SvPOK_on(perl_exception);
11134 ST(0)=sv_2mortal(perl_exception);
11139 ###############################################################################
11147 ###############################################################################
11152 Image::Magick ref=NO_INIT
11190 PERL_UNUSED_VAR(ref);
11191 PERL_UNUSED_VAR(ix);
11192 exception=AcquireExceptionInfo();
11193 perl_exception=newSVpv("",0);
11197 if (sv_isobject(ST(0)) == 0)
11199 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11201 goto PerlException;
11203 reference=SvRV(ST(0));
11204 hv=SvSTASH(reference);
11206 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11208 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11209 if (image == (Image *) NULL)
11211 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11213 goto PerlException;
11215 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11220 for (i=2; i < items; i+=2)
11222 attribute=(char *) SvPV(ST(i-1),na);
11223 switch (*attribute)
11228 if (LocaleCompare(attribute,"frames") == 0)
11230 number_frames=SvIV(ST(i));
11233 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11239 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11245 image=MorphImages(image,number_frames,exception);
11246 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11247 goto PerlException;
11248 for ( ; image; image=image->next)
11250 AddImageToRegistry(sv,image);
11252 av_push(av,sv_bless(rv,hv));
11255 exception=DestroyExceptionInfo(exception);
11256 ST(0)=av_reference;
11257 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11261 InheritPerlException(exception,perl_exception);
11262 exception=DestroyExceptionInfo(exception);
11263 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11264 SvPOK_on(perl_exception);
11265 ST(0)=sv_2mortal(perl_exception);
11270 ###############################################################################
11278 ###############################################################################
11283 Image::Magick ref=NO_INIT
11311 PERL_UNUSED_VAR(ref);
11312 PERL_UNUSED_VAR(ix);
11313 exception=AcquireExceptionInfo();
11314 perl_exception=newSVpv("",0);
11316 if (sv_isobject(ST(0)) == 0)
11318 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11320 goto PerlException;
11322 reference=SvRV(ST(0));
11323 hv=SvSTASH(reference);
11324 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11325 if (image == (Image *) NULL)
11327 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11329 goto PerlException;
11331 image=MergeImageLayers(image,MosaicLayer,exception);
11333 Create blessed Perl array for the returned image.
11336 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11338 AddImageToRegistry(sv,image);
11340 av_push(av,sv_bless(rv,hv));
11342 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11343 (void) CopyMagickString(image->filename,info->image_info->filename,
11345 SetImageInfo(info->image_info,0,&image->exception);
11346 exception=DestroyExceptionInfo(exception);
11347 SvREFCNT_dec(perl_exception);
11351 InheritPerlException(exception,perl_exception);
11352 exception=DestroyExceptionInfo(exception);
11353 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11354 SvPOK_on(perl_exception); /* return messages in string context */
11355 ST(0)=sv_2mortal(perl_exception);
11360 ###############################################################################
11368 ###############################################################################
11373 Image::Magick ref=NO_INIT
11423 PERL_UNUSED_VAR(ref);
11424 PERL_UNUSED_VAR(ix);
11425 exception=AcquireExceptionInfo();
11426 perl_exception=newSVpv("",0);
11427 package_info=(struct PackageInfo *) NULL;
11428 ac=(items < 2) ? 1 : items-1;
11429 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11431 length=(STRLEN *) NULL;
11432 if (list == (char **) NULL)
11434 ThrowPerlException(exception,ResourceLimitError,
11435 "MemoryAllocationFailed",PackageName);
11436 goto PerlException;
11439 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11440 if (length == (STRLEN *) NULL)
11442 ThrowPerlException(exception,ResourceLimitError,
11443 "MemoryAllocationFailed",PackageName);
11444 goto PerlException;
11446 if (sv_isobject(ST(0)) == 0)
11448 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11450 goto PerlException;
11452 reference=SvRV(ST(0));
11453 if (SvTYPE(reference) != SVt_PVAV)
11455 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11457 goto PerlException;
11459 av=(AV *) reference;
11460 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11462 package_info=ClonePackageInfo(info,exception);
11465 *list=(char *) (*package_info->image_info->filename ?
11466 package_info->image_info->filename : "XC:black");
11468 for (n=0, i=0; i < ac; i++)
11470 list[n]=(char *) SvPV(ST(i+1),length[n]);
11471 if ((items >= 3) && strEQcase(list[n],"blob"))
11477 blob=(void *) (SvPV(ST(i+1),length[n]));
11478 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11480 if ((items >= 3) && strEQcase(list[n],"filename"))
11482 if ((items >= 3) && strEQcase(list[n],"file"))
11491 io_info=IoIFP(sv_2io(ST(i+1)));
11492 if (io_info == (PerlIO *) NULL)
11494 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11498 file=PerlIO_findFILE(io_info);
11499 if (file == (FILE *) NULL)
11501 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11505 SetImageInfoFile(package_info->image_info,file);
11507 if ((items >= 3) && strEQcase(list[n],"magick"))
11511 list[n]=(char *) NULL;
11513 status=ExpandFilenames(&n,&list);
11514 if (status == MagickFalse)
11516 ThrowPerlException(exception,ResourceLimitError,
11517 "MemoryAllocationFailed",PackageName);
11518 goto PerlException;
11521 for (i=0; i < n; i++)
11523 (void) CopyMagickString(package_info->image_info->filename,list[i],
11525 image=PingImage(package_info->image_info,exception);
11526 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11528 if ((package_info->image_info->file != (FILE *) NULL) ||
11529 (package_info->image_info->blob != (void *) NULL))
11530 DisassociateImageStream(image);
11531 count+=GetImageListLength(image);
11532 EXTEND(sp,4*count);
11533 for (next=image; next; next=next->next)
11535 PUSHs(sv_2mortal(newSViv(next->columns)));
11536 PUSHs(sv_2mortal(newSViv(next->rows)));
11537 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11538 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11540 image=DestroyImageList(image);
11545 for (i=0; i < n; i++)
11546 if (list[i] != (char *) NULL)
11547 for (p=keep; list[i] != *p++; )
11550 list[i]=(char *) RelinquishMagickMemory(list[i]);
11555 if (package_info != (struct PackageInfo *) NULL)
11556 DestroyPackageInfo(package_info);
11557 if (list && (list != keep))
11558 list=(char **) RelinquishMagickMemory(list);
11560 keep=(char **) RelinquishMagickMemory(keep);
11562 length=(STRLEN *) RelinquishMagickMemory(length);
11563 InheritPerlException(exception,perl_exception);
11564 exception=DestroyExceptionInfo(exception);
11565 SvREFCNT_dec(perl_exception); /* throw away all errors */
11569 ###############################################################################
11577 ###############################################################################
11582 Image::Magick ref=NO_INIT
11615 PERL_UNUSED_VAR(ref);
11616 PERL_UNUSED_VAR(ix);
11617 exception=AcquireExceptionInfo();
11618 perl_exception=newSVpv("",0);
11621 if (sv_isobject(ST(0)) == 0)
11623 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11625 goto PerlException;
11627 reference=SvRV(ST(0));
11628 hv=SvSTASH(reference);
11630 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11632 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11633 if (image == (Image *) NULL)
11635 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11637 goto PerlException;
11639 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11640 preview_type=GammaPreview;
11642 preview_type=(PreviewType)
11643 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11644 for ( ; image; image=image->next)
11646 preview_image=PreviewImage(image,preview_type,exception);
11647 if (preview_image == (Image *) NULL)
11648 goto PerlException;
11649 AddImageToRegistry(sv,preview_image);
11651 av_push(av,sv_bless(rv,hv));
11654 exception=DestroyExceptionInfo(exception);
11655 ST(0)=av_reference;
11656 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11660 InheritPerlException(exception,perl_exception);
11661 exception=DestroyExceptionInfo(exception);
11662 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11663 SvPOK_on(perl_exception);
11664 ST(0)=sv_2mortal(perl_exception);
11669 ###############################################################################
11673 # Q u e r y C o l o r #
11677 ###############################################################################
11681 QueryColor(ref,...)
11682 Image::Magick ref=NO_INIT
11702 PERL_UNUSED_VAR(ref);
11703 PERL_UNUSED_VAR(ix);
11704 exception=AcquireExceptionInfo();
11705 perl_exception=newSVpv("",0);
11714 colorlist=GetColorInfoList("*",&colors,exception);
11716 for (i=0; i < (ssize_t) colors; i++)
11718 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11720 colorlist=(const ColorInfo **)
11721 RelinquishMagickMemory((ColorInfo **) colorlist);
11722 goto PerlException;
11724 EXTEND(sp,5*items);
11725 for (i=1; i < items; i++)
11727 name=(char *) SvPV(ST(i),na);
11728 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11733 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11734 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11735 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11736 if (color.colorspace == CMYKColorspace)
11737 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11738 if (color.matte != MagickFalse)
11739 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11743 InheritPerlException(exception,perl_exception);
11744 exception=DestroyExceptionInfo(exception);
11745 SvREFCNT_dec(perl_exception);
11749 ###############################################################################
11753 # Q u e r y C o l o r N a m e #
11757 ###############################################################################
11761 QueryColorname(ref,...)
11762 Image::Magick ref=NO_INIT
11771 message[MaxTextExtent];
11790 *reference; /* reference is the SV* of ref=SvIV(reference) */
11792 PERL_UNUSED_VAR(ref);
11793 PERL_UNUSED_VAR(ix);
11794 exception=AcquireExceptionInfo();
11795 perl_exception=newSVpv("",0);
11796 reference=SvRV(ST(0));
11797 av=(AV *) reference;
11798 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11800 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11801 if (image == (Image *) NULL)
11803 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11805 goto PerlException;
11808 for (i=1; i < items; i++)
11810 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11811 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11813 PUSHs(sv_2mortal(newSVpv(message,0)));
11817 InheritPerlException(exception,perl_exception);
11818 exception=DestroyExceptionInfo(exception);
11819 SvREFCNT_dec(perl_exception);
11823 ###############################################################################
11827 # Q u e r y F o n t #
11831 ###############################################################################
11836 Image::Magick ref=NO_INIT
11843 message[MaxTextExtent];
11854 volatile const TypeInfo
11857 PERL_UNUSED_VAR(ref);
11858 PERL_UNUSED_VAR(ix);
11859 exception=AcquireExceptionInfo();
11860 perl_exception=newSVpv("",0);
11869 typelist=GetTypeInfoList("*",&types,exception);
11871 for (i=0; i < (ssize_t) types; i++)
11873 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11875 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11877 goto PerlException;
11879 EXTEND(sp,10*items);
11880 for (i=1; i < items; i++)
11882 name=(char *) SvPV(ST(i),na);
11883 type_info=GetTypeInfo(name,exception);
11884 if (type_info == (TypeInfo *) NULL)
11889 if (type_info->name == (char *) NULL)
11892 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11893 if (type_info->description == (char *) NULL)
11896 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11897 if (type_info->family == (char *) NULL)
11900 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11901 if (type_info->style == UndefinedStyle)
11904 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11905 type_info->style),0)));
11906 if (type_info->stretch == UndefinedStretch)
11909 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11910 type_info->stretch),0)));
11911 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11912 type_info->weight);
11913 PUSHs(sv_2mortal(newSVpv(message,0)));
11914 if (type_info->encoding == (char *) NULL)
11917 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11918 if (type_info->foundry == (char *) NULL)
11921 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11922 if (type_info->format == (char *) NULL)
11925 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
11926 if (type_info->metrics == (char *) NULL)
11929 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
11930 if (type_info->glyphs == (char *) NULL)
11933 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
11937 InheritPerlException(exception,perl_exception);
11938 exception=DestroyExceptionInfo(exception);
11939 SvREFCNT_dec(perl_exception);
11943 ###############################################################################
11947 # Q u e r y F o n t M e t r i c s #
11951 ###############################################################################
11955 QueryFontMetrics(ref,...)
11956 Image::Magick ref=NO_INIT
11958 queryfontmetrics = 1
12005 *reference; /* reference is the SV* of ref=SvIV(reference) */
12010 PERL_UNUSED_VAR(ref);
12011 PERL_UNUSED_VAR(ix);
12012 exception=AcquireExceptionInfo();
12013 package_info=(struct PackageInfo *) NULL;
12014 perl_exception=newSVpv("",0);
12015 reference=SvRV(ST(0));
12016 av=(AV *) reference;
12017 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12019 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12020 if (image == (Image *) NULL)
12022 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12024 goto PerlException;
12026 package_info=ClonePackageInfo(info,exception);
12027 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12028 CloneString(&draw_info->text,"");
12029 current=draw_info->affine;
12030 GetAffineMatrix(&affine);
12033 EXTEND(sp,7*items);
12034 for (i=2; i < items; i+=2)
12036 attribute=(char *) SvPV(ST(i-1),na);
12037 switch (*attribute)
12042 if (LocaleCompare(attribute,"antialias") == 0)
12044 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12048 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12052 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12055 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12062 if (LocaleCompare(attribute,"density") == 0)
12064 CloneString(&draw_info->density,SvPV(ST(i),na));
12067 if (LocaleCompare(attribute,"direction") == 0)
12069 draw_info->direction=(DirectionType) ParseCommandOption(
12070 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12073 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12080 if (LocaleCompare(attribute,"encoding") == 0)
12082 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12085 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12092 if (LocaleCompare(attribute,"family") == 0)
12094 CloneString(&draw_info->family,SvPV(ST(i),na));
12097 if (LocaleCompare(attribute,"fill") == 0)
12100 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12101 &image->exception);
12104 if (LocaleCompare(attribute,"font") == 0)
12106 CloneString(&draw_info->font,SvPV(ST(i),na));
12109 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12116 if (LocaleCompare(attribute,"geometry") == 0)
12118 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12121 if (LocaleCompare(attribute,"gravity") == 0)
12123 draw_info->gravity=(GravityType) ParseCommandOption(
12124 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12127 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12134 if (LocaleCompare(attribute,"interline-spacing") == 0)
12136 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12137 draw_info->interline_spacing=geometry_info.rho;
12140 if (LocaleCompare(attribute,"interword-spacing") == 0)
12142 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12143 draw_info->interword_spacing=geometry_info.rho;
12146 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12153 if (LocaleCompare(attribute,"kerning") == 0)
12155 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12156 draw_info->kerning=geometry_info.rho;
12159 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12166 if (LocaleCompare(attribute,"pointsize") == 0)
12168 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12169 draw_info->pointsize=geometry_info.rho;
12172 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12179 if (LocaleCompare(attribute,"rotate") == 0)
12181 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12182 affine.rx=geometry_info.rho;
12183 affine.ry=geometry_info.sigma;
12184 if ((flags & SigmaValue) == 0)
12185 affine.ry=affine.rx;
12188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12195 if (LocaleCompare(attribute,"scale") == 0)
12197 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12198 affine.sx=geometry_info.rho;
12199 affine.sy=geometry_info.sigma;
12200 if ((flags & SigmaValue) == 0)
12201 affine.sy=affine.sx;
12204 if (LocaleCompare(attribute,"skew") == 0)
12210 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12211 x_angle=geometry_info.rho;
12212 y_angle=geometry_info.sigma;
12213 if ((flags & SigmaValue) == 0)
12215 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12216 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12219 if (LocaleCompare(attribute,"stroke") == 0)
12222 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12223 &image->exception);
12226 if (LocaleCompare(attribute,"style") == 0)
12228 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12232 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12236 draw_info->style=(StyleType) type;
12239 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12246 if (LocaleCompare(attribute,"text") == 0)
12248 CloneString(&draw_info->text,SvPV(ST(i),na));
12251 if (LocaleCompare(attribute,"translate") == 0)
12253 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12254 affine.tx=geometry_info.rho;
12255 affine.ty=geometry_info.sigma;
12256 if ((flags & SigmaValue) == 0)
12257 affine.ty=affine.tx;
12260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12267 if (LocaleCompare(attribute,"weight") == 0)
12269 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12270 draw_info->weight=(size_t) geometry_info.rho;
12273 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12280 if (LocaleCompare(attribute,"x") == 0)
12282 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12283 x=geometry_info.rho;
12286 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12293 if (LocaleCompare(attribute,"y") == 0)
12295 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12296 y=geometry_info.rho;
12299 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12305 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12311 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12312 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12313 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12314 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12315 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12316 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12317 if (draw_info->geometry == (char *) NULL)
12319 draw_info->geometry=AcquireString((char *) NULL);
12320 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12321 "%.15g,%.15g",x,y);
12323 status=GetTypeMetrics(image,draw_info,&metrics);
12324 (void) CatchImageException(image);
12325 if (status == MagickFalse)
12329 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12330 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12331 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12332 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12333 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12334 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12335 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12336 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12337 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12338 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12339 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12340 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12341 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12343 draw_info=DestroyDrawInfo(draw_info);
12346 if (package_info != (struct PackageInfo *) NULL)
12347 DestroyPackageInfo(package_info);
12348 InheritPerlException(exception,perl_exception);
12349 exception=DestroyExceptionInfo(exception);
12350 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12354 ###############################################################################
12358 # 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 #
12362 ###############################################################################
12366 QueryMultilineFontMetrics(ref,...)
12367 Image::Magick ref=NO_INIT
12369 querymultilinefontmetrics = 1
12416 *reference; /* reference is the SV* of ref=SvIV(reference) */
12421 PERL_UNUSED_VAR(ref);
12422 PERL_UNUSED_VAR(ix);
12423 exception=AcquireExceptionInfo();
12424 package_info=(struct PackageInfo *) NULL;
12425 perl_exception=newSVpv("",0);
12426 reference=SvRV(ST(0));
12427 av=(AV *) reference;
12428 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12430 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12431 if (image == (Image *) NULL)
12433 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12435 goto PerlException;
12437 package_info=ClonePackageInfo(info,exception);
12438 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12439 CloneString(&draw_info->text,"");
12440 current=draw_info->affine;
12441 GetAffineMatrix(&affine);
12444 EXTEND(sp,7*items);
12445 for (i=2; i < items; i+=2)
12447 attribute=(char *) SvPV(ST(i-1),na);
12448 switch (*attribute)
12453 if (LocaleCompare(attribute,"antialias") == 0)
12455 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12459 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12463 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12473 if (LocaleCompare(attribute,"density") == 0)
12475 CloneString(&draw_info->density,SvPV(ST(i),na));
12478 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12485 if (LocaleCompare(attribute,"encoding") == 0)
12487 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12490 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12497 if (LocaleCompare(attribute,"family") == 0)
12499 CloneString(&draw_info->family,SvPV(ST(i),na));
12502 if (LocaleCompare(attribute,"fill") == 0)
12505 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12506 &image->exception);
12509 if (LocaleCompare(attribute,"font") == 0)
12511 CloneString(&draw_info->font,SvPV(ST(i),na));
12514 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12521 if (LocaleCompare(attribute,"geometry") == 0)
12523 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12526 if (LocaleCompare(attribute,"gravity") == 0)
12528 draw_info->gravity=(GravityType) ParseCommandOption(
12529 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12532 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12539 if (LocaleCompare(attribute,"pointsize") == 0)
12541 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12542 draw_info->pointsize=geometry_info.rho;
12545 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12552 if (LocaleCompare(attribute,"rotate") == 0)
12554 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12555 affine.rx=geometry_info.rho;
12556 affine.ry=geometry_info.sigma;
12557 if ((flags & SigmaValue) == 0)
12558 affine.ry=affine.rx;
12561 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12568 if (LocaleCompare(attribute,"scale") == 0)
12570 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12571 affine.sx=geometry_info.rho;
12572 affine.sy=geometry_info.sigma;
12573 if ((flags & SigmaValue) == 0)
12574 affine.sy=affine.sx;
12577 if (LocaleCompare(attribute,"skew") == 0)
12583 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12584 x_angle=geometry_info.rho;
12585 y_angle=geometry_info.sigma;
12586 if ((flags & SigmaValue) == 0)
12588 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12589 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12592 if (LocaleCompare(attribute,"stroke") == 0)
12595 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12596 &image->exception);
12599 if (LocaleCompare(attribute,"style") == 0)
12601 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12605 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12609 draw_info->style=(StyleType) type;
12612 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12619 if (LocaleCompare(attribute,"text") == 0)
12621 CloneString(&draw_info->text,SvPV(ST(i),na));
12624 if (LocaleCompare(attribute,"translate") == 0)
12626 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12627 affine.tx=geometry_info.rho;
12628 affine.ty=geometry_info.sigma;
12629 if ((flags & SigmaValue) == 0)
12630 affine.ty=affine.tx;
12633 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12640 if (LocaleCompare(attribute,"weight") == 0)
12642 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12643 draw_info->weight=(size_t) geometry_info.rho;
12646 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12653 if (LocaleCompare(attribute,"x") == 0)
12655 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12656 x=geometry_info.rho;
12659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12666 if (LocaleCompare(attribute,"y") == 0)
12668 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12669 y=geometry_info.rho;
12672 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12678 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12684 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12685 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12686 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12687 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12688 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12689 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12690 if (draw_info->geometry == (char *) NULL)
12692 draw_info->geometry=AcquireString((char *) NULL);
12693 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12694 "%.15g,%.15g",x,y);
12696 status=GetMultilineTypeMetrics(image,draw_info,&metrics);
12697 (void) CatchImageException(image);
12698 if (status == MagickFalse)
12702 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12703 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12704 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12705 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12706 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12707 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12708 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12709 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12710 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12711 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12712 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12713 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12714 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12716 draw_info=DestroyDrawInfo(draw_info);
12719 if (package_info != (struct PackageInfo *) NULL)
12720 DestroyPackageInfo(package_info);
12721 InheritPerlException(exception,perl_exception);
12722 exception=DestroyExceptionInfo(exception);
12723 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12727 ###############################################################################
12731 # Q u e r y F o r m a t #
12735 ###############################################################################
12739 QueryFormat(ref,...)
12740 Image::Magick ref=NO_INIT
12757 volatile const MagickInfo
12760 PERL_UNUSED_VAR(ref);
12761 PERL_UNUSED_VAR(ix);
12762 exception=AcquireExceptionInfo();
12763 perl_exception=newSVpv("",0);
12767 format[MaxTextExtent];
12775 format_list=GetMagickInfoList("*",&types,exception);
12777 for (i=0; i < (ssize_t) types; i++)
12779 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12780 LocaleLower(format);
12781 PUSHs(sv_2mortal(newSVpv(format,0)));
12783 format_list=(const MagickInfo **)
12784 RelinquishMagickMemory((MagickInfo *) format_list);
12785 goto PerlException;
12787 EXTEND(sp,8*items);
12788 for (i=1; i < items; i++)
12790 name=(char *) SvPV(ST(i),na);
12791 magick_info=GetMagickInfo(name,exception);
12792 if (magick_info == (const MagickInfo *) NULL)
12797 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12798 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12799 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12800 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12801 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12802 if (magick_info->description == (char *) NULL)
12805 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12806 if (magick_info->module == (char *) NULL)
12809 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12813 InheritPerlException(exception,perl_exception);
12814 exception=DestroyExceptionInfo(exception);
12815 SvREFCNT_dec(perl_exception);
12819 ###############################################################################
12823 # Q u e r y O p t i o n #
12827 ###############################################################################
12831 QueryOption(ref,...)
12832 Image::Magick ref=NO_INIT
12853 PERL_UNUSED_VAR(ref);
12854 PERL_UNUSED_VAR(ix);
12855 exception=AcquireExceptionInfo();
12856 perl_exception=newSVpv("",0);
12857 EXTEND(sp,8*items);
12858 for (i=1; i < items; i++)
12860 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12862 options=GetCommandOptions((CommandOption) option);
12863 if (options == (char **) NULL)
12867 for (j=0; options[j] != (char *) NULL; j++)
12868 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12869 options=DestroyStringList(options);
12873 InheritPerlException(exception,perl_exception);
12874 exception=DestroyExceptionInfo(exception);
12875 SvREFCNT_dec(perl_exception);
12879 ###############################################################################
12887 ###############################################################################
12892 Image::Magick ref=NO_INIT
12939 *perl_exception, /* Perl variable for storing messages */
12944 PERL_UNUSED_VAR(ref);
12945 PERL_UNUSED_VAR(ix);
12946 exception=AcquireExceptionInfo();
12947 perl_exception=newSVpv("",0);
12949 package_info=(struct PackageInfo *) NULL;
12951 ac=(items < 2) ? 1 : items-1;
12952 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12954 length=(STRLEN *) NULL;
12955 if (list == (char **) NULL)
12957 ThrowPerlException(exception,ResourceLimitError,
12958 "MemoryAllocationFailed",PackageName);
12959 goto PerlException;
12961 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12962 if (length == (STRLEN *) NULL)
12964 ThrowPerlException(exception,ResourceLimitError,
12965 "MemoryAllocationFailed",PackageName);
12966 goto PerlException;
12968 if (sv_isobject(ST(0)) == 0)
12970 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12972 goto PerlException;
12974 reference=SvRV(ST(0));
12975 hv=SvSTASH(reference);
12976 if (SvTYPE(reference) != SVt_PVAV)
12978 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12980 goto PerlException;
12982 av=(AV *) reference;
12983 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12985 package_info=ClonePackageInfo(info,exception);
12988 *list=(char *) (*package_info->image_info->filename ?
12989 package_info->image_info->filename : "XC:black");
12991 for (n=0, i=0; i < ac; i++)
12993 list[n]=(char *) SvPV(ST(i+1),length[n]);
12994 if ((items >= 3) && strEQcase(list[n],"blob"))
13000 blob=(void *) (SvPV(ST(i+1),length[n]));
13001 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13003 if ((items >= 3) && strEQcase(list[n],"filename"))
13005 if ((items >= 3) && strEQcase(list[n],"file"))
13014 io_info=IoIFP(sv_2io(ST(i+1)));
13015 if (io_info == (PerlIO *) NULL)
13017 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13021 file=PerlIO_findFILE(io_info);
13022 if (file == (FILE *) NULL)
13024 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13028 SetImageInfoFile(package_info->image_info,file);
13030 if ((items >= 3) && strEQcase(list[n],"magick"))
13034 list[n]=(char *) NULL;
13036 status=ExpandFilenames(&n,&list);
13037 if (status == MagickFalse)
13039 ThrowPerlException(exception,ResourceLimitError,
13040 "MemoryAllocationFailed",PackageName);
13041 goto PerlException;
13044 for (i=0; i < n; i++)
13046 if ((package_info->image_info->file != (FILE *) NULL) ||
13047 (package_info->image_info->blob != (void *) NULL))
13049 image=ReadImages(package_info->image_info,exception);
13050 if (image != (Image *) NULL)
13051 DisassociateImageStream(image);
13055 (void) CopyMagickString(package_info->image_info->filename,list[i],
13057 image=ReadImages(package_info->image_info,exception);
13059 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13061 for ( ; image; image=image->next)
13063 AddImageToRegistry(sv,image);
13065 av_push(av,sv_bless(rv,hv));
13073 for (i=0; i < n; i++)
13074 if (list[i] != (char *) NULL)
13075 for (p=keep; list[i] != *p++; )
13076 if (*p == (char *) NULL)
13078 list[i]=(char *) RelinquishMagickMemory(list[i]);
13083 if (package_info != (struct PackageInfo *) NULL)
13084 DestroyPackageInfo(package_info);
13085 if (list && (list != keep))
13086 list=(char **) RelinquishMagickMemory(list);
13088 keep=(char **) RelinquishMagickMemory(keep);
13090 length=(STRLEN *) RelinquishMagickMemory(length);
13091 InheritPerlException(exception,perl_exception);
13092 exception=DestroyExceptionInfo(exception);
13093 sv_setiv(perl_exception,(IV) number_images);
13094 SvPOK_on(perl_exception);
13095 ST(0)=sv_2mortal(perl_exception);
13100 ###############################################################################
13108 ###############################################################################
13113 Image::Magick ref=NO_INIT
13136 PERL_UNUSED_VAR(ref);
13137 PERL_UNUSED_VAR(ix);
13138 exception=AcquireExceptionInfo();
13139 perl_exception=newSVpv("",0);
13140 reference=SvRV(ST(0));
13141 av=(AV *) reference;
13142 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13144 for (i=1; i < items; i++)
13145 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13146 SvPV(ST(i),na),exception);
13147 InheritPerlException(exception,perl_exception);
13148 exception=DestroyExceptionInfo(exception);
13149 SvREFCNT_dec(perl_exception); /* throw away all errors */
13153 ###############################################################################
13161 ###############################################################################
13166 Image::Magick ref=NO_INIT
13189 *reference; /* reference is the SV* of ref=SvIV(reference) */
13191 PERL_UNUSED_VAR(ref);
13192 PERL_UNUSED_VAR(ix);
13193 exception=AcquireExceptionInfo();
13194 perl_exception=newSVpv("",0);
13195 if (sv_isobject(ST(0)) == 0)
13197 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13199 goto PerlException;
13201 reference=SvRV(ST(0));
13202 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13204 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13206 for (i=2; i < items; i+=2)
13207 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13210 InheritPerlException(exception,perl_exception);
13211 exception=DestroyExceptionInfo(exception);
13212 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13213 SvPOK_on(perl_exception);
13214 ST(0)=sv_2mortal(perl_exception);
13219 ###############################################################################
13223 # S e t P i x e l #
13227 ###############################################################################
13232 Image::Magick ref=NO_INIT
13274 *reference; /* reference is the SV* of ref=SvIV(reference) */
13276 PERL_UNUSED_VAR(ref);
13277 PERL_UNUSED_VAR(ix);
13278 exception=AcquireExceptionInfo();
13279 perl_exception=newSVpv("",0);
13280 reference=SvRV(ST(0));
13281 av=(AV *) reference;
13282 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13284 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13285 if (image == (Image *) NULL)
13287 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13289 goto PerlException;
13292 normalize=MagickTrue;
13295 region.width=image->columns;
13298 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13299 channel=DefaultChannels;
13300 for (i=2; i < items; i+=2)
13302 attribute=(char *) SvPV(ST(i-1),na);
13303 switch (*attribute)
13308 if (LocaleCompare(attribute,"channel") == 0)
13313 option=ParseChannelOption(SvPV(ST(i),na));
13316 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13320 channel=(ChannelType) option;
13323 if (LocaleCompare(attribute,"color") == 0)
13325 if (SvTYPE(ST(i)) != SVt_RV)
13328 message[MaxTextExtent];
13330 (void) FormatLocaleString(message,MaxTextExtent,
13331 "invalid %.60s value",attribute);
13332 ThrowPerlException(exception,OptionError,message,
13335 av=(AV *) SvRV(ST(i));
13338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13345 if (LocaleCompare(attribute,"geometry") == 0)
13347 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13350 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13357 if (LocaleCompare(attribute,"normalize") == 0)
13359 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13363 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13367 normalize=option != 0 ? MagickTrue : MagickFalse;
13370 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13377 if (LocaleCompare(attribute,"x") == 0)
13379 region.x=SvIV(ST(i));
13382 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13389 if (LocaleCompare(attribute,"y") == 0)
13391 region.y=SvIV(ST(i));
13394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13406 (void) SetImageStorageClass(image,DirectClass,exception);
13407 channel_mask=SetPixelChannelMask(image,channel);
13408 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13409 if ((q == (const Quantum *) NULL) || (av == (AV *) NULL) ||
13410 (SvTYPE(av) != SVt_PVAV))
13422 if (normalize != MagickFalse)
13423 scale=QuantumRange;
13424 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13427 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13428 av_fetch(av,i,0)))),q);
13431 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13434 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13435 av_fetch(av,i,0)))),q);
13438 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13441 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13442 av_fetch(av,i,0)))),q);
13445 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13446 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13448 SetPixelBlack(image,ClampToQuantum(scale*
13449 SvNV(*(av_fetch(av,i,0)))),q);
13452 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13455 SetPixelAlpha(image,ClampToQuantum(scale*
13456 SvNV(*(av_fetch(av,i,0)))),q);
13459 (void) SyncAuthenticPixels(image,exception);
13461 (void) SetPixelChannelMask(image,channel_mask);
13464 InheritPerlException(exception,perl_exception);
13465 exception=DestroyExceptionInfo(exception);
13466 SvREFCNT_dec(perl_exception);
13470 ###############################################################################
13478 ###############################################################################
13483 Image::Magick ref=NO_INIT
13522 PERL_UNUSED_VAR(ref);
13523 PERL_UNUSED_VAR(ix);
13524 exception=AcquireExceptionInfo();
13525 perl_exception=newSVpv("",0);
13529 if (sv_isobject(ST(0)) == 0)
13531 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13533 goto PerlException;
13535 reference=SvRV(ST(0));
13536 hv=SvSTASH(reference);
13538 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13540 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13541 if (image == (Image *) NULL)
13543 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13545 goto PerlException;
13547 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13553 for (i=2; i < items; i+=2)
13555 attribute=(char *) SvPV(ST(i-1),na);
13556 switch (*attribute)
13561 if (LocaleCompare(attribute,"offset") == 0)
13563 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13566 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13573 if (LocaleCompare(attribute,"stack") == 0)
13575 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13579 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13585 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13591 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13597 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13599 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13600 goto PerlException;
13601 for ( ; image; image=image->next)
13603 AddImageToRegistry(sv,image);
13605 av_push(av,sv_bless(rv,hv));
13608 exception=DestroyExceptionInfo(exception);
13609 ST(0)=av_reference;
13610 SvREFCNT_dec(perl_exception);
13614 InheritPerlException(exception,perl_exception);
13615 exception=DestroyExceptionInfo(exception);
13616 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13617 SvPOK_on(perl_exception);
13618 ST(0)=sv_2mortal(perl_exception);
13623 ###############################################################################
13627 # S t a t i s t i c s #
13631 ###############################################################################
13635 Statistics(ref,...)
13636 Image::Magick ref=NO_INIT
13638 StatisticsImage = 1
13640 statisticsimage = 3
13643 #define ChannelStatistics(channel) \
13645 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13646 (double) channel_statistics[channel].depth); \
13647 PUSHs(sv_2mortal(newSVpv(message,0))); \
13648 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13649 channel_statistics[channel].minima/scale); \
13650 PUSHs(sv_2mortal(newSVpv(message,0))); \
13651 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13652 channel_statistics[channel].maxima/scale); \
13653 PUSHs(sv_2mortal(newSVpv(message,0))); \
13654 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13655 channel_statistics[channel].mean/scale); \
13656 PUSHs(sv_2mortal(newSVpv(message,0))); \
13657 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13658 channel_statistics[channel].standard_deviation/scale); \
13659 PUSHs(sv_2mortal(newSVpv(message,0))); \
13660 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13661 channel_statistics[channel].kurtosis); \
13662 PUSHs(sv_2mortal(newSVpv(message,0))); \
13663 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13664 channel_statistics[channel].skewness); \
13665 PUSHs(sv_2mortal(newSVpv(message,0))); \
13672 message[MaxTextExtent];
13675 *channel_statistics;
13696 PERL_UNUSED_VAR(ref);
13697 PERL_UNUSED_VAR(ix);
13698 exception=AcquireExceptionInfo();
13699 perl_exception=newSVpv("",0);
13701 if (sv_isobject(ST(0)) == 0)
13703 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13705 goto PerlException;
13707 reference=SvRV(ST(0));
13710 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13711 if (image == (Image *) NULL)
13713 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13715 goto PerlException;
13717 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13719 for ( ; image; image=image->next)
13721 channel_statistics=GetImageStatistics(image,&image->exception);
13722 if (channel_statistics == (ChannelStatistics *) NULL)
13725 EXTEND(sp,35*count);
13726 scale=(double) QuantumRange;
13727 ChannelStatistics(RedChannel);
13728 ChannelStatistics(GreenChannel);
13729 ChannelStatistics(BlueChannel);
13730 if (image->colorspace == CMYKColorspace)
13731 ChannelStatistics(BlackChannel);
13732 if (image->matte != MagickFalse)
13733 ChannelStatistics(AlphaChannel);
13734 channel_statistics=(ChannelStatistics *)
13735 RelinquishMagickMemory(channel_statistics);
13739 InheritPerlException(exception,perl_exception);
13740 exception=DestroyExceptionInfo(exception);
13741 SvREFCNT_dec(perl_exception);
13745 ###############################################################################
13749 # S y n c A u t h e n t i c P i x e l s #
13753 ###############################################################################
13757 SyncAuthenticPixels(ref,...)
13758 Image::Magick ref = NO_INIT
13760 Syncauthenticpixels = 1
13761 SyncImagePixels = 2
13762 syncimagepixels = 3
13781 PERL_UNUSED_VAR(ref);
13782 PERL_UNUSED_VAR(ix);
13783 exception=AcquireExceptionInfo();
13784 perl_exception=newSVpv("",0);
13785 if (sv_isobject(ST(0)) == 0)
13787 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13789 goto PerlException;
13792 reference=SvRV(ST(0));
13793 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13794 if (image == (Image *) NULL)
13796 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13798 goto PerlException;
13801 status=SyncAuthenticPixels(image,exception);
13802 if (status != MagickFalse)
13804 InheritException(exception,&image->exception);
13807 InheritPerlException(exception,perl_exception);
13808 exception=DestroyExceptionInfo(exception);
13809 SvREFCNT_dec(perl_exception); /* throw away all errors */
13813 ###############################################################################
13817 # T r a n s f o r m #
13821 ###############################################################################
13826 Image::Magick ref=NO_INIT
13864 PERL_UNUSED_VAR(ref);
13865 PERL_UNUSED_VAR(ix);
13866 exception=AcquireExceptionInfo();
13867 perl_exception=newSVpv("",0);
13871 if (sv_isobject(ST(0)) == 0)
13873 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13875 goto PerlException;
13877 reference=SvRV(ST(0));
13878 hv=SvSTASH(reference);
13880 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13882 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13883 if (image == (Image *) NULL)
13885 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13887 goto PerlException;
13889 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13893 crop_geometry=(char *) NULL;
13894 geometry=(char *) NULL;
13895 for (i=2; i < items; i+=2)
13897 attribute=(char *) SvPV(ST(i-1),na);
13898 switch (*attribute)
13903 if (LocaleCompare(attribute,"crop") == 0)
13905 crop_geometry=SvPV(ST(i),na);
13908 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13915 if (LocaleCompare(attribute,"geometry") == 0)
13917 geometry=SvPV(ST(i),na);
13920 if (LocaleCompare(attribute,"gravity") == 0)
13928 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
13929 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13932 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13936 for (next=image; next; next=next->next)
13937 next->gravity=(GravityType) in;
13940 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13946 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13952 for ( ; image; image=image->next)
13954 clone=CloneImage(image,0,0,MagickTrue,exception);
13955 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
13956 goto PerlException;
13957 TransformImage(&clone,crop_geometry,geometry);
13958 for ( ; clone; clone=clone->next)
13960 AddImageToRegistry(sv,clone);
13962 av_push(av,sv_bless(rv,hv));
13966 exception=DestroyExceptionInfo(exception);
13967 ST(0)=av_reference;
13968 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13972 InheritPerlException(exception,perl_exception);
13973 exception=DestroyExceptionInfo(exception);
13974 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13975 SvPOK_on(perl_exception);
13976 ST(0)=sv_2mortal(perl_exception);
13981 ###############################################################################
13989 ###############################################################################
13994 Image::Magick ref=NO_INIT
14002 filename[MaxTextExtent];
14026 PERL_UNUSED_VAR(ref);
14027 PERL_UNUSED_VAR(ix);
14028 exception=AcquireExceptionInfo();
14029 perl_exception=newSVpv("",0);
14031 package_info=(struct PackageInfo *) NULL;
14032 if (sv_isobject(ST(0)) == 0)
14034 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14036 goto PerlException;
14038 reference=SvRV(ST(0));
14039 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14040 if (image == (Image *) NULL)
14042 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14044 goto PerlException;
14046 package_info=ClonePackageInfo(info,exception);
14048 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14051 for (i=2; i < items; i+=2)
14052 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14054 (void) CopyMagickString(filename,package_info->image_info->filename,
14057 for (next=image; next; next=next->next)
14059 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14060 next->scene=scene++;
14062 SetImageInfo(package_info->image_info,(unsigned int)
14063 GetImageListLength(image),&image->exception);
14064 for (next=image; next; next=next->next)
14066 (void) WriteImage(package_info->image_info,next,exception);
14068 if (package_info->image_info->adjoin)
14073 if (package_info != (struct PackageInfo *) NULL)
14074 DestroyPackageInfo(package_info);
14075 InheritPerlException(exception,perl_exception);
14076 exception=DestroyExceptionInfo(exception);
14077 sv_setiv(perl_exception,(IV) number_images);
14078 SvPOK_on(perl_exception);
14079 ST(0)=sv_2mortal(perl_exception);