2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv((IV) image); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"bias", RealReference},
218 {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference} } },
222 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference}, {"fuzz", StringReference},
225 {"gravity", MagickGravityOptions} } },
227 { "Edge", { {"radius", RealReference} } },
228 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
229 {"sigma", RealReference} } },
233 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
234 {"height", IntegerReference}, {"inner", IntegerReference},
235 {"outer", IntegerReference}, {"fill", StringReference},
236 {"color", StringReference}, {"compose", MagickComposeOptions} } },
237 { "Implode", { {"amount", RealReference},
238 {"interpolate", MagickInterpolateOptions} } },
240 { "MedianFilter", { {"geometry", StringReference},
241 {"width", IntegerReference}, {"height", IntegerReference},
242 {"channel", MagickChannelOptions} } },
244 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
245 { "ReduceNoise", { {"geometry", StringReference},
246 {"width", IntegerReference},{"height", IntegerReference},
247 {"channel", MagickChannelOptions} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
251 {"color", StringReference}, {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"bias", RealReference},
260 {"channel", MagickChannelOptions} } },
261 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
262 {"y", RealReference}, { "fill", StringReference},
263 {"color", StringReference} } },
264 { "Spread", { {"radius", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Swirl", { {"degrees", RealReference},
267 {"interpolate", MagickInterpolateOptions} } },
268 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
269 {"height", IntegerReference}, {"filter", MagickFilterOptions},
270 {"support", StringReference }, {"blur", RealReference } } },
271 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
272 {"height", IntegerReference}, {"filter", MagickFilterOptions},
273 {"support", RealReference }, {"blur", RealReference } } },
274 { "Annotate", { {"text", StringReference}, {"font", StringReference},
275 {"pointsize", RealReference}, {"density", StringReference},
276 {"undercolor", StringReference}, {"stroke", StringReference},
277 {"fill", StringReference}, {"geometry", StringReference},
278 {"pen", StringReference}, {"x", RealReference},
279 {"y", RealReference}, {"gravity", MagickGravityOptions},
280 {"translate", StringReference}, {"scale", StringReference},
281 {"rotate", RealReference}, {"skewX", RealReference},
282 {"skewY", RealReference}, {"strokewidth", RealReference},
283 {"antialias", MagickBooleanOptions}, {"family", StringReference},
284 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
285 {"weight", IntegerReference}, {"align", MagickAlignOptions},
286 {"encoding", StringReference}, {"affine", ArrayReference},
287 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
288 {"tile", ImageReference}, {"kerning", RealReference},
289 {"interline-spacing", RealReference},
290 {"interword-spacing", RealReference},
291 {"direction", MagickDirectionOptions} } },
292 { "ColorFloodfill", { {"geometry", StringReference},
293 {"x", IntegerReference}, {"y", IntegerReference},
294 {"fill", StringReference}, {"bordercolor", StringReference},
295 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
296 { "Composite", { {"image", ImageReference},
297 {"compose", MagickComposeOptions}, {"geometry", StringReference},
298 {"x", IntegerReference}, {"y", IntegerReference},
299 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
300 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
301 {"color", StringReference}, {"mask", ImageReference},
302 {"channel", MagickChannelOptions},
303 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
304 {"blend", StringReference} } },
305 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
306 { "CycleColormap", { {"display", IntegerReference} } },
307 { "Draw", { {"primitive", MagickPrimitiveOptions},
308 {"points", StringReference}, {"method", MagickMethodOptions},
309 {"stroke", StringReference}, {"fill", StringReference},
310 {"strokewidth", RealReference}, {"font", StringReference},
311 {"bordercolor", StringReference}, {"x", RealReference},
312 {"y", RealReference}, {"translate", StringReference},
313 {"scale", StringReference}, {"rotate", RealReference},
314 {"skewX", RealReference}, {"skewY", RealReference},
315 {"tile", ImageReference}, {"pointsize", RealReference},
316 {"antialias", MagickBooleanOptions}, {"density", StringReference},
317 {"linewidth", RealReference}, {"affine", ArrayReference},
318 {"stroke-dashoffset", RealReference},
319 {"stroke-dasharray", ArrayReference},
320 {"interpolate", MagickInterpolateOptions},
321 {"origin", StringReference}, {"text", StringReference},
322 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
323 {"vector-graphics", StringReference}, {"kerning", RealReference},
324 {"interline-spacing", RealReference},
325 {"interword-spacing", RealReference},
326 {"direction", MagickDirectionOptions} } },
327 { "Equalize", { {"channel", MagickChannelOptions} } },
328 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
329 {"red", RealReference}, {"green", RealReference},
330 {"blue", RealReference} } },
331 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
332 {"dither-method", MagickDitherOptions} } },
333 { "MatteFloodfill", { {"geometry", StringReference},
334 {"x", IntegerReference}, {"y", IntegerReference},
335 {"opacity", StringReference}, {"bordercolor", StringReference},
336 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
337 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
338 {"saturation", RealReference}, {"whiteness", RealReference},
339 {"brightness", RealReference}, {"lightness", RealReference},
340 {"blackness", RealReference} } },
341 { "Negate", { {"gray", MagickBooleanOptions},
342 {"channel", MagickChannelOptions} } },
343 { "Normalize", { {"channel", MagickChannelOptions} } },
345 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
346 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
347 {"invert", MagickBooleanOptions} } },
348 { "Quantize", { {"colors", IntegerReference},
349 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
350 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
351 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
352 {"dither-method", MagickDitherOptions} } },
353 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
354 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
355 { "Segment", { {"geometry", StringReference},
356 {"cluster-threshold", RealReference},
357 {"smoothing-threshold", RealReference},
358 {"colorspace", MagickColorspaceOptions},
359 {"verbose", MagickBooleanOptions} } },
361 { "Solarize", { {"geometry", StringReference},
362 {"threshold", StringReference} } },
364 { "Texture", { {"texture", ImageReference} } },
365 { "Evaluate", { {"value", RealReference},
366 {"operator", MagickEvaluateOptions},
367 {"channel", MagickChannelOptions} } },
368 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
369 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
370 { "Threshold", { {"threshold", StringReference},
371 {"channel", MagickChannelOptions} } },
372 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
373 {"sigma", RealReference}, {"biabias", RealReference} } },
374 { "Trim", { {"fuzz", StringReference} } },
375 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
376 {"wavelength", RealReference},
377 {"interpolate", MagickInterpolateOptions} } },
378 { "Separate", { {"channel", MagickChannelOptions} } },
380 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
381 {"y", IntegerReference} } },
382 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
384 { "GaussianBlur", { {"geometry", StringReference},
385 {"radius", RealReference}, {"sigma", RealReference},
386 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
387 { "Convolve", { {"coefficients", ArrayReference},
388 {"channel", MagickChannelOptions}, {"bias", StringReference},
389 {"kernel", StringReference} } },
390 { "Profile", { {"name", StringReference}, {"profile", StringReference},
391 { "rendering-intent", MagickIntentOptions},
392 { "black-point-compensation", MagickBooleanOptions} } },
393 { "UnsharpMask", { {"geometry", StringReference},
394 {"radius", RealReference}, {"sigma", RealReference},
395 {"amount", RealReference}, {"threshold", RealReference},
396 {"channel", MagickChannelOptions} } },
397 { "MotionBlur", { {"geometry", StringReference},
398 {"radius", RealReference}, {"sigma", RealReference},
399 {"angle", RealReference}, {"bias", RealReference},
400 {"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 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
428 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference} } },
431 { "Tint", { {"fill", StringReference}, {"blend", 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}, {"alpha", 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 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
466 { "AdaptiveBlur", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
469 { "Sketch", { {"geometry", StringReference},
470 {"radius", RealReference}, {"sigma", RealReference},
471 {"angle", RealReference}, {"bias", RealReference} } },
473 { "AdaptiveResize", { {"geometry", StringReference},
474 {"width", IntegerReference}, {"height", IntegerReference},
475 {"filter", MagickFilterOptions}, {"support", StringReference },
476 {"blur", RealReference }, {"interpolate", MagickInterpolateOptions} } },
477 { "ClipMask", { {"mask", ImageReference} } },
478 { "LinearStretch", { {"levels", StringReference},
479 {"black-point", RealReference},{"white-point", RealReference} } },
480 { "ColorMatrix", { {"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 {"interpolate", MagickInterpolateOptions} } },
488 { "FloodfillPaint", { {"geometry", StringReference},
489 {"x", IntegerReference}, {"y", IntegerReference},
490 {"fill", StringReference}, {"bordercolor", StringReference},
491 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
492 {"invert", MagickBooleanOptions} } },
493 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
494 {"virtual-pixel", MagickVirtualPixelOptions},
495 {"best-fit", MagickBooleanOptions} } },
496 { "Clut", { {"image", ImageReference},
497 {"interpolate", MagickInterpolateOptions},
498 {"channel", MagickChannelOptions} } },
499 { "LiquidRescale", { {"geometry", StringReference},
500 {"width", IntegerReference}, {"height", IntegerReference},
501 {"delta-x", RealReference}, {"rigidity", RealReference } } },
502 { "Encipher", { {"passphrase", StringReference} } },
503 { "Decipher", { {"passphrase", StringReference} } },
504 { "Deskew", { {"geometry", StringReference},
505 {"threshold", StringReference} } },
506 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
507 {"dither-method", MagickDitherOptions} } },
508 { "SparseColor", { {"points", ArrayReference},
509 {"method", MagickSparseColorOptions},
510 {"virtual-pixel", MagickVirtualPixelOptions},
511 {"channel", MagickChannelOptions} } },
512 { "Function", { {"parameters", ArrayReference},
513 {"function", MagickFunctionOptions},
514 {"virtual-pixel", MagickVirtualPixelOptions} } },
515 { "SelectiveBlur", { {"geometry", StringReference},
516 {"radius", RealReference}, {"sigma", RealReference},
517 {"threshold", RealReference}, {"bias", RealReference},
518 {"channel", MagickChannelOptions} } },
519 { "HaldClut", { {"image", ImageReference},
520 {"channel", MagickChannelOptions} } },
521 { "BlueShift", { {"factor", StringReference} } },
522 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
523 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
524 { "ColorDecisionList", {
525 {"color-correction-collection", StringReference} } },
526 { "AutoGamma", { {"channel", MagickChannelOptions} } },
527 { "AutoLevel", { {"channel", MagickChannelOptions} } },
528 { "LevelColors", { {"invert", MagickBooleanOptions},
529 {"black-point", StringReference}, {"white-point", StringReference},
530 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
531 { "Clamp", { {"channel", MagickChannelOptions} } },
532 { "BrightnessContrast", { {"levels", StringReference},
533 {"brightness", RealReference},{"contrast", RealReference},
534 {"channel", MagickChannelOptions} } },
535 { "Morphology", { {"kernel", StringReference},
536 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
537 {"iterations", IntegerReference} } },
538 { "Sans", { {"matrix", ArrayReference} } },
539 { "Color", { {"color", StringReference} } },
540 { "Mode", { {"geometry", StringReference},
541 {"width", IntegerReference},{"height", IntegerReference},
542 {"channel", MagickChannelOptions} } },
543 { "Statistic", { {"geometry", StringReference},
544 {"width", IntegerReference},{"height", IntegerReference},
545 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
549 *magick_registry = (SplayTreeInfo *) NULL;
552 Forward declarations.
555 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
558 strEQcase(const char *,const char *);
561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 % C l o n e P a c k a g e I n f o %
569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
571 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
574 % The format of the ClonePackageInfo routine is:
576 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
579 % A description of each parameter follows:
581 % o info: a structure of type info.
583 % o exception: Return any errors or warnings in this structure.
586 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
587 ExceptionInfo *exception)
592 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
593 if (clone_info == (struct PackageInfo *) NULL)
595 ThrowPerlException(exception,ResourceLimitError,
596 "UnableToClonePackageInfo",PackageName);
597 return((struct PackageInfo *) NULL);
599 if (info == (struct PackageInfo *) NULL)
601 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
605 clone_info->image_info=CloneImageInfo(info->image_info);
610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
620 % constant() returns a double value for the specified name.
622 % The format of the constant routine is:
624 % double constant(char *name,ssize_t sans)
626 % A description of each parameter follows:
628 % o value: Method constant returns a double value for the specified name.
630 % o name: The name of the constant.
632 % o sans: This integer value is not used.
635 static double constant(char *name,ssize_t sans)
643 if (strEQ(name,"BlobError"))
645 if (strEQ(name,"BlobWarning"))
651 if (strEQ(name,"CacheError"))
653 if (strEQ(name,"CacheWarning"))
654 return(CacheWarning);
655 if (strEQ(name,"CoderError"))
657 if (strEQ(name,"CoderWarning"))
658 return(CoderWarning);
659 if (strEQ(name,"ConfigureError"))
660 return(ConfigureError);
661 if (strEQ(name,"ConfigureWarning"))
662 return(ConfigureWarning);
663 if (strEQ(name,"CorruptImageError"))
664 return(CorruptImageError);
665 if (strEQ(name,"CorruptImageWarning"))
666 return(CorruptImageWarning);
671 if (strEQ(name,"DelegateError"))
672 return(DelegateError);
673 if (strEQ(name,"DelegateWarning"))
674 return(DelegateWarning);
675 if (strEQ(name,"DrawError"))
677 if (strEQ(name,"DrawWarning"))
683 if (strEQ(name,"ErrorException"))
684 return(ErrorException);
685 if (strEQ(name,"ExceptionError"))
687 if (strEQ(name,"ExceptionWarning"))
688 return(CoderWarning);
693 if (strEQ(name,"FatalErrorException"))
694 return(FatalErrorException);
695 if (strEQ(name,"FileOpenError"))
696 return(FileOpenError);
697 if (strEQ(name,"FileOpenWarning"))
698 return(FileOpenWarning);
703 if (strEQ(name,"ImageError"))
705 if (strEQ(name,"ImageWarning"))
706 return(ImageWarning);
711 if (strEQ(name,"MaxRGB"))
712 return(QuantumRange);
713 if (strEQ(name,"MissingDelegateError"))
714 return(MissingDelegateError);
715 if (strEQ(name,"MissingDelegateWarning"))
716 return(MissingDelegateWarning);
717 if (strEQ(name,"ModuleError"))
719 if (strEQ(name,"ModuleWarning"))
720 return(ModuleWarning);
725 if (strEQ(name,"Opaque"))
727 if (strEQ(name,"OptionError"))
729 if (strEQ(name,"OptionWarning"))
730 return(OptionWarning);
735 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
736 return(MAGICKCORE_QUANTUM_DEPTH);
737 if (strEQ(name,"QuantumDepth"))
738 return(MAGICKCORE_QUANTUM_DEPTH);
739 if (strEQ(name,"QuantumRange"))
740 return(QuantumRange);
745 if (strEQ(name,"ResourceLimitError"))
746 return(ResourceLimitError);
747 if (strEQ(name,"ResourceLimitWarning"))
748 return(ResourceLimitWarning);
749 if (strEQ(name,"RegistryError"))
750 return(RegistryError);
751 if (strEQ(name,"RegistryWarning"))
752 return(RegistryWarning);
757 if (strEQ(name,"StreamError"))
759 if (strEQ(name,"StreamWarning"))
760 return(StreamWarning);
761 if (strEQ(name,"Success"))
767 if (strEQ(name,"Transparent"))
768 return(TransparentAlpha);
769 if (strEQ(name,"TypeError"))
771 if (strEQ(name,"TypeWarning"))
777 if (strEQ(name,"WarningException"))
778 return(WarningException);
783 if (strEQ(name,"XServerError"))
784 return(XServerError);
785 if (strEQ(name,"XServerWarning"))
786 return(XServerWarning);
795 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
799 % D e s t r o y P a c k a g e I n f o %
803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
805 % Method DestroyPackageInfo frees a previously created info structure.
807 % The format of the DestroyPackageInfo routine is:
809 % DestroyPackageInfo(struct PackageInfo *info)
811 % A description of each parameter follows:
813 % o info: a structure of type info.
816 static void DestroyPackageInfo(struct PackageInfo *info)
818 info->image_info=DestroyImageInfo(info->image_info);
819 info=(struct PackageInfo *) RelinquishMagickMemory(info);
823 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
831 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833 % Method GetList is recursively called by SetupList to traverse the
834 % Image__Magick reference. If building an reference_vector (see SetupList),
835 % *current is the current position in *reference_vector and *last is the final
836 % entry in *reference_vector.
838 % The format of the GetList routine is:
842 % A description of each parameter follows:
844 % o info: a structure of type info.
847 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
848 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
853 if (reference == (SV *) NULL)
855 switch (SvTYPE(reference))
875 previous=(Image *) NULL;
879 for (i=0; i <= n; i++)
885 if (rv && *rv && sv_isobject(*rv))
887 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
889 if (image == (Image *) NULL)
891 if (image == previous)
893 image=CloneImage(image,0,0,MagickTrue,exception);
894 if (image == (Image *) NULL)
897 image->previous=previous;
898 *(previous ? &previous->next : &head)=image;
899 for (previous=image; previous->next; previous=previous->next) ;
907 Blessed scalar, one image.
909 image=(Image *) SvIV(reference);
910 if (image == (Image *) NULL)
912 image->previous=(Image *) NULL;
913 image->next=(Image *) NULL;
914 if (reference_vector)
916 if (*current == *last)
919 if (*reference_vector == (SV **) NULL)
920 *reference_vector=(SV **) AcquireQuantumMemory(*last,
921 sizeof(*reference_vector));
923 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
924 *last,sizeof(*reference_vector));
926 if (*reference_vector == (SV **) NULL)
928 ThrowPerlException(exception,ResourceLimitError,
929 "MemoryAllocationFailed",PackageName);
930 return((Image *) NULL);
932 (*reference_vector)[*current]=reference;
933 (*reference_vector)[++(*current)]=NULL;
940 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
941 (double) SvTYPE(reference));
942 return((Image *) NULL);
946 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
950 % G e t P a c k a g e I n f o %
954 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
956 % Method GetPackageInfo looks up or creates an info structure for the given
957 % Image__Magick reference. If it does create a new one, the information in
958 % package_info is used to initialize it.
960 % The format of the GetPackageInfo routine is:
962 % struct PackageInfo *GetPackageInfo(void *reference,
963 % struct PackageInfo *package_info,ExceptionInfo *exception)
965 % A description of each parameter follows:
967 % o info: a structure of type info.
969 % o exception: Return any errors or warnings in this structure.
972 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
973 struct PackageInfo *package_info,ExceptionInfo *exception)
976 message[MaxTextExtent];
984 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
985 PackageName,XS_VERSION,reference);
986 sv=perl_get_sv(message,(TRUE | 0x02));
987 if (sv == (SV *) NULL)
989 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
991 return(package_info);
993 if (SvREFCNT(sv) == 0)
994 (void) SvREFCNT_inc(sv);
995 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
997 clone_info=ClonePackageInfo(package_info,exception);
998 sv_setiv(sv,(IV) clone_info);
1003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 % S e t A t t r i b u t e %
1011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1013 % SetAttribute() sets the attribute to the value in sval. This can change
1014 % either or both of image or info.
1016 % The format of the SetAttribute routine is:
1018 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1019 % SV *sval,ExceptionInfo *exception)
1021 % A description of each parameter follows:
1023 % o list: a list of strings.
1025 % o string: a character string.
1029 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1037 value=InterpretSiPrefixValue(string,&q);
1039 value*=interval/100.0;
1043 static inline double StringToDouble(const char *restrict string,
1044 char **restrict sentinal)
1046 return(InterpretLocaleValue(string,sentinal));
1049 static double StringToDoubleInterval(const char *string,const double interval)
1057 value=InterpretLocaleValue(string,&q);
1059 value*=interval/100.0;
1063 static inline ssize_t StringToLong(const char *value)
1065 return(strtol(value,(char **) NULL,10));
1068 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1069 const char *attribute,SV *sval,ExceptionInfo *exception)
1096 if (LocaleCompare(attribute,"adjoin") == 0)
1098 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1099 SvPV(sval,na)) : SvIV(sval);
1102 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1107 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1110 if (LocaleCompare(attribute,"alpha") == 0)
1112 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1113 SvPV(sval,na)) : SvIV(sval);
1116 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1120 for ( ; image; image=image->next)
1121 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
1124 if (LocaleCompare(attribute,"antialias") == 0)
1126 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1127 SvPV(sval,na)) : SvIV(sval);
1130 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1135 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1138 if (LocaleCompare(attribute,"area-limit") == 0)
1143 limit=MagickResourceInfinity;
1144 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1145 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1147 (void) SetMagickResourceLimit(AreaResource,limit);
1150 if (LocaleCompare(attribute,"attenuate") == 0)
1153 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1156 if (LocaleCompare(attribute,"authenticate") == 0)
1159 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1163 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1164 for ( ; image; image=image->next)
1165 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1171 if (LocaleCompare(attribute,"background") == 0)
1173 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1176 info->image_info->background_color=target_color;
1177 for ( ; image; image=image->next)
1178 image->background_color=target_color;
1181 if (LocaleCompare(attribute,"bias") == 0)
1183 for ( ; image; image=image->next)
1184 image->bias=StringToDoubleInterval(SvPV(sval,na),(double)
1188 if (LocaleCompare(attribute,"blue-primary") == 0)
1190 for ( ; image; image=image->next)
1192 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1193 image->chromaticity.blue_primary.x=geometry_info.rho;
1194 image->chromaticity.blue_primary.y=geometry_info.sigma;
1195 if ((flags & SigmaValue) == 0)
1196 image->chromaticity.blue_primary.y=
1197 image->chromaticity.blue_primary.x;
1201 if (LocaleCompare(attribute,"bordercolor") == 0)
1203 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1206 info->image_info->border_color=target_color;
1207 for ( ; image; image=image->next)
1208 image->border_color=target_color;
1212 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1213 for ( ; image; image=image->next)
1214 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1220 if (LocaleCompare(attribute,"cache-threshold") == 0)
1222 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1223 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1224 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1225 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1228 if (LocaleCompare(attribute,"clip-mask") == 0)
1233 clip_mask=(Image *) NULL;
1235 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1236 for ( ; image; image=image->next)
1237 SetImageClipMask(image,clip_mask,exception);
1240 if (LocaleNCompare(attribute,"colormap",8) == 0)
1242 for ( ; image; image=image->next)
1250 if (image->storage_class == DirectClass)
1253 items=sscanf(attribute,"%*[^[][%ld",&i);
1255 if (i > (ssize_t) image->colors)
1257 if ((strchr(SvPV(sval,na),',') == 0) ||
1258 (strchr(SvPV(sval,na),')') != 0))
1259 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1260 image->colormap+i,exception);
1263 color=image->colormap+i;
1264 pixel.red=color->red;
1265 pixel.green=color->green;
1266 pixel.blue=color->blue;
1267 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1268 pixel.red=geometry_info.rho;
1269 pixel.green=geometry_info.sigma;
1270 pixel.blue=geometry_info.xi;
1271 color->red=ClampToQuantum(pixel.red);
1272 color->green=ClampToQuantum(pixel.green);
1273 color->blue=ClampToQuantum(pixel.blue);
1278 if (LocaleCompare(attribute,"colorspace") == 0)
1280 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1281 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1284 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1288 for ( ; image; image=image->next)
1289 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1293 if (LocaleCompare(attribute,"comment") == 0)
1295 for ( ; image; image=image->next)
1296 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1297 info ? info->image_info : (ImageInfo *) NULL,image,
1298 SvPV(sval,na),exception),exception);
1301 if (LocaleCompare(attribute,"compression") == 0)
1303 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1304 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1307 ThrowPerlException(exception,OptionError,
1308 "UnrecognizedImageCompression",SvPV(sval,na));
1312 info->image_info->compression=(CompressionType) sp;
1313 for ( ; image; image=image->next)
1314 image->compression=(CompressionType) sp;
1318 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1319 for ( ; image; image=image->next)
1320 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1326 if (LocaleCompare(attribute,"debug") == 0)
1328 SetLogEventMask(SvPV(sval,na));
1331 if (LocaleCompare(attribute,"delay") == 0)
1333 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1334 for ( ; image; image=image->next)
1336 image->delay=(size_t) floor(geometry_info.rho+0.5);
1337 if ((flags & SigmaValue) != 0)
1338 image->ticks_per_second=(ssize_t)
1339 floor(geometry_info.sigma+0.5);
1343 if (LocaleCompare(attribute,"disk-limit") == 0)
1348 limit=MagickResourceInfinity;
1349 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1350 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1352 (void) SetMagickResourceLimit(DiskResource,limit);
1355 if (LocaleCompare(attribute,"density") == 0)
1357 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1359 ThrowPerlException(exception,OptionError,"MissingGeometry",
1364 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1365 for ( ; image; image=image->next)
1367 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1368 image->resolution.x=geometry_info.rho;
1369 image->resolution.y=geometry_info.sigma;
1370 if ((flags & SigmaValue) == 0)
1371 image->resolution.y=image->resolution.x;
1375 if (LocaleCompare(attribute,"depth") == 0)
1378 info->image_info->depth=SvIV(sval);
1379 for ( ; image; image=image->next)
1380 (void) SetImageDepth(image,SvIV(sval),exception);
1383 if (LocaleCompare(attribute,"dispose") == 0)
1385 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1386 SvPV(sval,na)) : SvIV(sval);
1389 ThrowPerlException(exception,OptionError,
1390 "UnrecognizedDisposeMethod",SvPV(sval,na));
1393 for ( ; image; image=image->next)
1394 image->dispose=(DisposeType) sp;
1397 if (LocaleCompare(attribute,"dither") == 0)
1401 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1402 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1405 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1409 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1413 if (LocaleCompare(attribute,"display") == 0)
1417 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1421 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1422 for ( ; image; image=image->next)
1423 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1429 if (LocaleCompare(attribute,"endian") == 0)
1431 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1432 SvPV(sval,na)) : SvIV(sval);
1435 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1440 info->image_info->endian=(EndianType) sp;
1441 for ( ; image; image=image->next)
1442 image->endian=(EndianType) sp;
1445 if (LocaleCompare(attribute,"extract") == 0)
1448 Set image extract geometry.
1450 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1454 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1455 for ( ; image; image=image->next)
1456 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1462 if (LocaleCompare(attribute,"filename") == 0)
1465 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1467 for ( ; image; image=image->next)
1468 (void) CopyMagickString(image->filename,SvPV(sval,na),
1472 if (LocaleCompare(attribute,"file") == 0)
1480 if (info == (struct PackageInfo *) NULL)
1482 io_info=IoIFP(sv_2io(sval));
1483 if (io_info == (PerlIO *) NULL)
1485 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1489 file=PerlIO_findFILE(io_info);
1490 if (file == (FILE *) NULL)
1492 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1496 SetImageInfoFile(info->image_info,file);
1499 if (LocaleCompare(attribute,"fill") == 0)
1502 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1505 if (LocaleCompare(attribute,"font") == 0)
1508 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1511 if (LocaleCompare(attribute,"foreground") == 0)
1513 if (LocaleCompare(attribute,"fuzz") == 0)
1516 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1518 for ( ; image; image=image->next)
1519 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1524 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1525 for ( ; image; image=image->next)
1526 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1532 if (LocaleCompare(attribute,"gamma") == 0)
1534 for ( ; image; image=image->next)
1535 image->gamma=SvNV(sval);
1538 if (LocaleCompare(attribute,"gravity") == 0)
1540 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1541 SvPV(sval,na)) : SvIV(sval);
1544 ThrowPerlException(exception,OptionError,
1545 "UnrecognizedGravityType",SvPV(sval,na));
1549 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1550 for ( ; image; image=image->next)
1551 image->gravity=(GravityType) sp;
1554 if (LocaleCompare(attribute,"green-primary") == 0)
1556 for ( ; image; image=image->next)
1558 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1559 image->chromaticity.green_primary.x=geometry_info.rho;
1560 image->chromaticity.green_primary.y=geometry_info.sigma;
1561 if ((flags & SigmaValue) == 0)
1562 image->chromaticity.green_primary.y=
1563 image->chromaticity.green_primary.x;
1568 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1569 for ( ; image; image=image->next)
1570 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1576 if (LocaleNCompare(attribute,"index",5) == 0)
1590 for ( ; image; image=image->next)
1592 if (image->storage_class != PseudoClass)
1596 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1598 image_view=AcquireCacheView(image);
1599 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1600 if (q != (Quantum *) NULL)
1602 items=sscanf(SvPV(sval,na),"%ld",&index);
1603 if ((index >= 0) && (index < (ssize_t) image->colors))
1604 SetPixelIndex(image,index,q);
1605 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1607 image_view=DestroyCacheView(image_view);
1611 if (LocaleCompare(attribute,"iterations") == 0)
1614 for ( ; image; image=image->next)
1615 image->iterations=SvIV(sval);
1618 if (LocaleCompare(attribute,"interlace") == 0)
1620 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1621 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1624 ThrowPerlException(exception,OptionError,
1625 "UnrecognizedInterlaceType",SvPV(sval,na));
1629 info->image_info->interlace=(InterlaceType) sp;
1630 for ( ; image; image=image->next)
1631 image->interlace=(InterlaceType) sp;
1635 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1636 for ( ; image; image=image->next)
1637 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1643 if (LocaleCompare(attribute,"label") == 0)
1645 for ( ; image; image=image->next)
1646 (void) SetImageProperty(image,"label",InterpretImageProperties(
1647 info ? info->image_info : (ImageInfo *) NULL,image,
1648 SvPV(sval,na),exception),exception);
1651 if (LocaleCompare(attribute,"loop") == 0)
1654 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1655 for ( ; image; image=image->next)
1656 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1662 if (LocaleCompare(attribute,"magick") == 0)
1665 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1666 "%s:",SvPV(sval,na));
1667 for ( ; image; image=image->next)
1668 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1671 if (LocaleCompare(attribute,"map-limit") == 0)
1676 limit=MagickResourceInfinity;
1677 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1678 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1680 (void) SetMagickResourceLimit(MapResource,limit);
1683 if (LocaleCompare(attribute,"mask") == 0)
1688 mask=(Image *) NULL;
1690 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1691 for ( ; image; image=image->next)
1692 SetImageMask(image,mask,exception);
1695 if (LocaleCompare(attribute,"mattecolor") == 0)
1697 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1700 info->image_info->matte_color=target_color;
1701 for ( ; image; image=image->next)
1702 image->matte_color=target_color;
1705 if (LocaleCompare(attribute,"matte") == 0)
1707 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1708 SvPV(sval,na)) : SvIV(sval);
1711 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1715 for ( ; image; image=image->next)
1716 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1719 if (LocaleCompare(attribute,"memory-limit") == 0)
1724 limit=MagickResourceInfinity;
1725 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1726 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1728 (void) SetMagickResourceLimit(MemoryResource,limit);
1731 if (LocaleCompare(attribute,"monochrome") == 0)
1733 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1734 SvPV(sval,na)) : SvIV(sval);
1737 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1742 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1743 for ( ; image; image=image->next)
1744 (void) SetImageType(image,BilevelType,exception);
1748 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1749 for ( ; image; image=image->next)
1750 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1756 if (LocaleCompare(attribute,"option") == 0)
1759 DefineImageOption(info->image_info,SvPV(sval,na));
1762 if (LocaleCompare(attribute,"orientation") == 0)
1764 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1765 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1768 ThrowPerlException(exception,OptionError,
1769 "UnrecognizedOrientationType",SvPV(sval,na));
1773 info->image_info->orientation=(OrientationType) sp;
1774 for ( ; image; image=image->next)
1775 image->orientation=(OrientationType) sp;
1779 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1780 for ( ; image; image=image->next)
1781 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1787 if (LocaleCompare(attribute,"page") == 0)
1792 geometry=GetPageGeometry(SvPV(sval,na));
1794 (void) CloneString(&info->image_info->page,geometry);
1795 for ( ; image; image=image->next)
1796 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1797 geometry=(char *) RelinquishMagickMemory(geometry);
1800 if (LocaleCompare(attribute,"pen") == 0)
1803 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1806 if (LocaleNCompare(attribute,"pixel",5) == 0)
1820 for ( ; image; image=image->next)
1822 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1826 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1828 image_view=AcquireCacheView(image);
1829 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1830 if (q != (Quantum *) NULL)
1832 if ((strchr(SvPV(sval,na),',') == 0) ||
1833 (strchr(SvPV(sval,na),')') != 0))
1834 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1838 GetPixelInfo(image,&pixel);
1839 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1840 pixel.red=geometry_info.rho;
1841 if ((flags & SigmaValue) != 0)
1842 pixel.green=geometry_info.sigma;
1843 if ((flags & XiValue) != 0)
1844 pixel.blue=geometry_info.xi;
1845 if ((flags & PsiValue) != 0)
1846 pixel.alpha=geometry_info.psi;
1847 if ((flags & ChiValue) != 0)
1848 pixel.black=geometry_info.chi;
1850 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1851 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1852 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1853 if (image->colorspace == CMYKColorspace)
1854 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1855 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1856 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1858 image_view=DestroyCacheView(image_view);
1862 if (LocaleCompare(attribute,"pointsize") == 0)
1866 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1867 info->image_info->pointsize=geometry_info.rho;
1871 if (LocaleCompare(attribute,"preview") == 0)
1873 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1874 SvPV(sval,na)) : SvIV(sval);
1877 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1882 info->image_info->preview_type=(PreviewType) sp;
1886 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1887 for ( ; image; image=image->next)
1888 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1894 if (LocaleCompare(attribute,"quality") == 0)
1897 info->image_info->quality=SvIV(sval);
1898 for ( ; image; image=image->next)
1899 image->quality=SvIV(sval);
1903 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1904 for ( ; image; image=image->next)
1905 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1911 if (LocaleCompare(attribute,"red-primary") == 0)
1913 for ( ; image; image=image->next)
1915 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1916 image->chromaticity.red_primary.x=geometry_info.rho;
1917 image->chromaticity.red_primary.y=geometry_info.sigma;
1918 if ((flags & SigmaValue) == 0)
1919 image->chromaticity.red_primary.y=
1920 image->chromaticity.red_primary.x;
1924 if (LocaleCompare(attribute,"render") == 0)
1926 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1927 SvPV(sval,na)) : SvIV(sval);
1930 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1934 for ( ; image; image=image->next)
1935 image->rendering_intent=(RenderingIntent) sp;
1938 if (LocaleCompare(attribute,"repage") == 0)
1943 for ( ; image; image=image->next)
1945 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1946 if ((flags & WidthValue) != 0)
1948 if ((flags & HeightValue) == 0)
1949 geometry.height=geometry.width;
1950 image->page.width=geometry.width;
1951 image->page.height=geometry.height;
1953 if ((flags & AspectValue) != 0)
1955 if ((flags & XValue) != 0)
1956 image->page.x+=geometry.x;
1957 if ((flags & YValue) != 0)
1958 image->page.y+=geometry.y;
1962 if ((flags & XValue) != 0)
1964 image->page.x=geometry.x;
1965 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1966 image->page.width=image->columns+geometry.x;
1968 if ((flags & YValue) != 0)
1970 image->page.y=geometry.y;
1971 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1972 image->page.height=image->rows+geometry.y;
1979 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1980 for ( ; image; image=image->next)
1981 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1987 if (LocaleCompare(attribute,"sampling-factor") == 0)
1989 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1991 ThrowPerlException(exception,OptionError,"MissingGeometry",
1996 (void) CloneString(&info->image_info->sampling_factor,
2000 if (LocaleCompare(attribute,"scene") == 0)
2002 for ( ; image; image=image->next)
2003 image->scene=SvIV(sval);
2006 if (LocaleCompare(attribute,"server") == 0)
2008 if (LocaleCompare(attribute,"size") == 0)
2012 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2014 ThrowPerlException(exception,OptionError,"MissingGeometry",
2018 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2022 if (LocaleCompare(attribute,"stroke") == 0)
2025 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2029 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2030 for ( ; image; image=image->next)
2031 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2037 if (LocaleCompare(attribute,"texture") == 0)
2040 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2043 if (LocaleCompare(attribute,"thread-limit") == 0)
2048 limit=MagickResourceInfinity;
2049 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2050 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2052 (void) SetMagickResourceLimit(ThreadResource,limit);
2055 if (LocaleCompare(attribute,"tile-offset") == 0)
2060 geometry=GetPageGeometry(SvPV(sval,na));
2062 (void) CloneString(&info->image_info->page,geometry);
2063 for ( ; image; image=image->next)
2064 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2066 geometry=(char *) RelinquishMagickMemory(geometry);
2069 if (LocaleCompare(attribute,"time-limit") == 0)
2074 limit=MagickResourceInfinity;
2075 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2076 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2078 (void) SetMagickResourceLimit(TimeResource,limit);
2081 if (LocaleCompare(attribute,"transparent-color") == 0)
2083 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2086 info->image_info->transparent_color=target_color;
2087 for ( ; image; image=image->next)
2088 image->transparent_color=target_color;
2091 if (LocaleCompare(attribute,"type") == 0)
2093 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2094 SvPV(sval,na)) : SvIV(sval);
2097 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2102 info->image_info->type=(ImageType) sp;
2103 for ( ; image; image=image->next)
2104 SetImageType(image,(ImageType) sp,exception);
2108 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2109 for ( ; image; image=image->next)
2110 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2116 if (LocaleCompare(attribute,"units") == 0)
2118 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2119 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2122 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2127 info->image_info->units=(ResolutionType) sp;
2128 for ( ; image; image=image->next)
2133 units=(ResolutionType) sp;
2134 if (image->units != units)
2135 switch (image->units)
2137 case UndefinedResolution:
2138 case PixelsPerInchResolution:
2140 if (units == PixelsPerCentimeterResolution)
2142 image->resolution.x*=2.54;
2143 image->resolution.y*=2.54;
2147 case PixelsPerCentimeterResolution:
2149 if (units == PixelsPerInchResolution)
2151 image->resolution.x/=2.54;
2152 image->resolution.y/=2.54;
2162 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2163 for ( ; image; image=image->next)
2164 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2170 if (LocaleCompare(attribute,"verbose") == 0)
2172 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2173 SvPV(sval,na)) : SvIV(sval);
2176 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2181 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2184 if (LocaleCompare(attribute,"view") == 0)
2187 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2190 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2192 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2193 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2196 ThrowPerlException(exception,OptionError,
2197 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2201 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2202 for ( ; image; image=image->next)
2203 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2207 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2208 for ( ; image; image=image->next)
2209 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2215 if (LocaleCompare(attribute,"white-point") == 0)
2217 for ( ; image; image=image->next)
2219 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2220 image->chromaticity.white_point.x=geometry_info.rho;
2221 image->chromaticity.white_point.y=geometry_info.sigma;
2222 if ((flags & SigmaValue) == 0)
2223 image->chromaticity.white_point.y=
2224 image->chromaticity.white_point.x;
2229 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2230 for ( ; image; image=image->next)
2231 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2237 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2238 for ( ; image; image=image->next)
2239 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2246 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2250 % S e t u p L i s t %
2254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2256 % Method SetupList returns the list of all the images linked by their
2257 % image->next and image->previous link lists for use with ImageMagick. If
2258 % info is non-NULL, an info structure is returned in *info. If
2259 % reference_vector is non-NULL,an array of SV* are returned in
2260 % *reference_vector. Reference_vector is used when the images are going to be
2261 % replaced with new Image*'s.
2263 % The format of the SetupList routine is:
2265 % Image *SetupList(SV *reference,struct PackageInfo **info,
2266 % SV ***reference_vector,ExceptionInfo *exception)
2268 % A description of each parameter follows:
2270 % o list: a list of strings.
2272 % o string: a character string.
2274 % o exception: Return any errors or warnings in this structure.
2277 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2278 SV ***reference_vector,ExceptionInfo *exception)
2287 if (reference_vector)
2288 *reference_vector=NULL;
2293 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2294 if (info && (SvTYPE(reference) == SVt_PVAV))
2295 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2305 % s t r E Q c a s e %
2309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2311 % strEQcase() compares two strings and returns 0 if they are the
2312 % same or if the second string runs out first. The comparison is case
2315 % The format of the strEQcase routine is:
2317 % ssize_t strEQcase(const char *p,const char *q)
2319 % A description of each parameter follows:
2321 % o p: a character string.
2323 % o q: a character string.
2327 static ssize_t strEQcase(const char *p,const char *q)
2335 for (i=0 ; (c=(*q)) != 0; i++)
2337 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2338 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2343 return(((*q == 0) && (*p == 0)) ? i : 0);
2347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2351 % I m a g e : : M a g i c k %
2355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2359 MODULE = Image::Magick PACKAGE = Image::Magick
2364 MagickCoreGenesis("PerlMagick",MagickFalse);
2365 SetWarningHandler(NULL);
2366 SetErrorHandler(NULL);
2367 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2368 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2374 if (magick_registry != (SplayTreeInfo *) NULL)
2375 magick_registry=DestroySplayTree(magick_registry);
2376 MagickCoreTerminus();
2380 constant(name,argument)
2385 ###############################################################################
2393 ###############################################################################
2398 Image::Magick ref=NO_INIT
2422 PERL_UNUSED_VAR(ref);
2423 PERL_UNUSED_VAR(ix);
2424 exception=AcquireExceptionInfo();
2425 perl_exception=newSVpv("",0);
2426 package_info=(struct PackageInfo *) NULL;
2427 if (sv_isobject(ST(0)) == 0)
2429 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2433 reference=SvRV(ST(0));
2434 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2435 if (image == (Image *) NULL)
2437 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2441 package_info=ClonePackageInfo(info,exception);
2443 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2446 for (i=2; i < items; i+=2)
2447 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2449 (void) AnimateImages(package_info->image_info,image,exception);
2450 (void) CatchImageException(image);
2453 if (package_info != (struct PackageInfo *) NULL)
2454 DestroyPackageInfo(package_info);
2455 InheritPerlException(exception,perl_exception);
2456 exception=DestroyExceptionInfo(exception);
2457 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2458 SvPOK_on(perl_exception);
2459 ST(0)=sv_2mortal(perl_exception);
2464 ###############################################################################
2472 ###############################################################################
2477 Image::Magick ref=NO_INIT
2515 PERL_UNUSED_VAR(ref);
2516 PERL_UNUSED_VAR(ix);
2517 exception=AcquireExceptionInfo();
2518 perl_exception=newSVpv("",0);
2522 if (sv_isobject(ST(0)) == 0)
2524 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2528 reference=SvRV(ST(0));
2529 hv=SvSTASH(reference);
2531 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2533 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2534 if (image == (Image *) NULL)
2536 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2540 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2545 for (i=2; i < items; i+=2)
2547 attribute=(char *) SvPV(ST(i-1),na);
2553 if (LocaleCompare(attribute,"stack") == 0)
2555 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2559 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2565 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2571 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2577 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2578 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2580 for ( ; image; image=image->next)
2582 AddImageToRegistry(sv,image);
2584 av_push(av,sv_bless(rv,hv));
2587 exception=DestroyExceptionInfo(exception);
2589 SvREFCNT_dec(perl_exception);
2593 InheritPerlException(exception,perl_exception);
2594 exception=DestroyExceptionInfo(exception);
2595 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2596 SvPOK_on(perl_exception);
2597 ST(0)=sv_2mortal(perl_exception);
2602 ###############################################################################
2610 ###############################################################################
2615 Image::Magick ref=NO_INIT
2646 PERL_UNUSED_VAR(ref);
2647 PERL_UNUSED_VAR(ix);
2648 exception=AcquireExceptionInfo();
2649 perl_exception=newSVpv("",0);
2651 if (sv_isobject(ST(0)) == 0)
2653 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2657 reference=SvRV(ST(0));
2658 hv=SvSTASH(reference);
2659 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2660 if (image == (Image *) NULL)
2662 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2666 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2667 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2670 Create blessed Perl array for the returned image.
2673 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2675 AddImageToRegistry(sv,image);
2677 av_push(av,sv_bless(rv,hv));
2679 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2680 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2681 "average-%.*s",(int) (MaxTextExtent-9),
2682 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2683 (void) CopyMagickString(image->filename,info->image_info->filename,
2685 SetImageInfo(info->image_info,0,exception);
2686 exception=DestroyExceptionInfo(exception);
2687 SvREFCNT_dec(perl_exception);
2691 InheritPerlException(exception,perl_exception);
2692 exception=DestroyExceptionInfo(exception);
2693 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2694 SvPOK_on(perl_exception);
2695 ST(0)=sv_2mortal(perl_exception);
2700 ###############################################################################
2704 # B l o b T o I m a g e #
2708 ###############################################################################
2712 BlobToImage(ref,...)
2713 Image::Magick ref=NO_INIT
2759 PERL_UNUSED_VAR(ref);
2760 PERL_UNUSED_VAR(ix);
2761 exception=AcquireExceptionInfo();
2762 perl_exception=newSVpv("",0);
2765 ac=(items < 2) ? 1 : items-1;
2766 length=(STRLEN *) NULL;
2767 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2768 if (list == (char **) NULL)
2770 ThrowPerlException(exception,ResourceLimitError,
2771 "MemoryAllocationFailed",PackageName);
2774 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2775 if (length == (STRLEN *) NULL)
2777 ThrowPerlException(exception,ResourceLimitError,
2778 "MemoryAllocationFailed",PackageName);
2781 if (sv_isobject(ST(0)) == 0)
2783 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2787 reference=SvRV(ST(0));
2788 hv=SvSTASH(reference);
2789 if (SvTYPE(reference) != SVt_PVAV)
2791 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2795 av=(AV *) reference;
2796 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2801 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2804 for (n=0, i=0; i < ac; i++)
2806 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2807 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2809 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2814 list[n]=(char *) NULL;
2816 for (i=number_images=0; i < n; i++)
2818 image=BlobToImage(info->image_info,list[i],length[i],exception);
2819 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2821 for ( ; image; image=image->next)
2823 AddImageToRegistry(sv,image);
2825 av_push(av,sv_bless(rv,hv));
2833 for (i=0; i < n; i++)
2834 if (list[i] != (char *) NULL)
2835 for (p=keep; list[i] != *p++; )
2836 if (*p == (char *) NULL)
2838 list[i]=(char *) RelinquishMagickMemory(list[i]);
2844 list=(char **) RelinquishMagickMemory(list);
2846 length=(STRLEN *) RelinquishMagickMemory(length);
2847 InheritPerlException(exception,perl_exception);
2848 exception=DestroyExceptionInfo(exception);
2849 sv_setiv(perl_exception,(IV) number_images);
2850 SvPOK_on(perl_exception);
2851 ST(0)=sv_2mortal(perl_exception);
2856 ###############################################################################
2864 ###############################################################################
2869 Image::Magick ref=NO_INIT
2902 PERL_UNUSED_VAR(ref);
2903 PERL_UNUSED_VAR(ix);
2904 exception=AcquireExceptionInfo();
2905 perl_exception=newSVpv("",0);
2907 if (sv_isobject(ST(0)) == 0)
2909 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2913 reference=SvRV(ST(0));
2914 hv=SvSTASH(reference);
2915 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2916 if (image == (Image *) NULL)
2918 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2923 Create blessed Perl array for the returned image.
2926 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2928 for ( ; image; image=image->next)
2930 clone=CloneImage(image,0,0,MagickTrue,exception);
2931 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2933 AddImageToRegistry(sv,clone);
2935 av_push(av,sv_bless(rv,hv));
2938 exception=DestroyExceptionInfo(exception);
2939 SvREFCNT_dec(perl_exception);
2943 InheritPerlException(exception,perl_exception);
2944 exception=DestroyExceptionInfo(exception);
2945 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2946 SvPOK_on(perl_exception);
2947 ST(0)=sv_2mortal(perl_exception);
2952 ###############################################################################
2960 ###############################################################################
2968 PERL_UNUSED_VAR(ref);
2969 if (magick_registry != (SplayTreeInfo *) NULL)
2974 ResetSplayTreeIterator(magick_registry);
2975 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2976 while (p != (Image *) NULL)
2979 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2985 ###############################################################################
2993 ###############################################################################
2998 Image::Magick ref=NO_INIT
3027 PERL_UNUSED_VAR(ref);
3028 PERL_UNUSED_VAR(ix);
3029 exception=AcquireExceptionInfo();
3030 perl_exception=newSVpv("",0);
3032 if (sv_isobject(ST(0)) == 0)
3034 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3038 reference=SvRV(ST(0));
3039 hv=SvSTASH(reference);
3041 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3043 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3044 if (image == (Image *) NULL)
3046 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3050 image=CoalesceImages(image,exception);
3051 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3053 for ( ; image; image=image->next)
3055 AddImageToRegistry(sv,image);
3057 av_push(av,sv_bless(rv,hv));
3060 exception=DestroyExceptionInfo(exception);
3062 SvREFCNT_dec(perl_exception);
3066 InheritPerlException(exception,perl_exception);
3067 exception=DestroyExceptionInfo(exception);
3068 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3069 SvPOK_on(perl_exception);
3070 ST(0)=sv_2mortal(perl_exception);
3075 ###############################################################################
3083 ###############################################################################
3088 Image::Magick ref=NO_INIT
3134 PERL_UNUSED_VAR(ref);
3135 PERL_UNUSED_VAR(ix);
3136 exception=AcquireExceptionInfo();
3137 perl_exception=newSVpv("",0);
3141 if (sv_isobject(ST(0)) == 0)
3143 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3147 reference=SvRV(ST(0));
3148 hv=SvSTASH(reference);
3150 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3152 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3153 if (image == (Image *) NULL)
3155 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3159 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3163 reconstruct_image=image;
3164 metric=RootMeanSquaredErrorMetric;
3165 for (i=2; i < items; i+=2)
3167 attribute=(char *) SvPV(ST(i-1),na);
3173 if (LocaleCompare(attribute,"channel") == 0)
3178 option=ParseChannelOption(SvPV(ST(i),na));
3181 ThrowPerlException(exception,OptionError,
3182 "UnrecognizedType",SvPV(ST(i),na));
3185 SetPixelChannelMapMask(image,(ChannelType) option);
3188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3195 if (LocaleCompare(attribute,"fuzz") == 0)
3197 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3200 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3207 if (LocaleCompare(attribute,"image") == 0)
3209 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3210 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3213 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3220 if (LocaleCompare(attribute,"metric") == 0)
3222 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3226 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3230 metric=(MetricType) option;
3233 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3239 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3245 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3247 if (difference_image != (Image *) NULL)
3249 difference_image->error.mean_error_per_pixel=distortion;
3250 AddImageToRegistry(sv,difference_image);
3252 av_push(av,sv_bless(rv,hv));
3255 exception=DestroyExceptionInfo(exception);
3257 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3261 InheritPerlException(exception,perl_exception);
3262 exception=DestroyExceptionInfo(exception);
3263 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3264 SvPOK_on(perl_exception);
3265 ST(0)=sv_2mortal(perl_exception);
3270 ###############################################################################
3274 # C o m p a r e L a y e r s #
3278 ###############################################################################
3283 Image::Magick ref=NO_INIT
3285 CompareImagesLayers = 1
3287 compareimagelayers = 3
3324 PERL_UNUSED_VAR(ref);
3325 PERL_UNUSED_VAR(ix);
3326 exception=AcquireExceptionInfo();
3327 perl_exception=newSVpv("",0);
3329 if (sv_isobject(ST(0)) == 0)
3331 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3335 reference=SvRV(ST(0));
3336 hv=SvSTASH(reference);
3338 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3340 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3341 if (image == (Image *) NULL)
3343 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3347 method=CompareAnyLayer;
3348 for (i=2; i < items; i+=2)
3350 attribute=(char *) SvPV(ST(i-1),na);
3356 if (LocaleCompare(attribute,"method") == 0)
3358 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3362 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3366 method=(ImageLayerMethod) option;
3369 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3375 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3381 image=CompareImagesLayers(image,method,exception);
3382 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3384 for ( ; image; image=image->next)
3386 AddImageToRegistry(sv,image);
3388 av_push(av,sv_bless(rv,hv));
3391 exception=DestroyExceptionInfo(exception);
3393 SvREFCNT_dec(perl_exception);
3397 InheritPerlException(exception,perl_exception);
3398 exception=DestroyExceptionInfo(exception);
3399 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3400 SvPOK_on(perl_exception);
3401 ST(0)=sv_2mortal(perl_exception);
3406 ###############################################################################
3414 ###############################################################################
3419 Image::Magick ref=NO_INIT
3425 PERL_UNUSED_VAR(ref);
3426 if (sv_isobject(ST(0)) == 0)
3427 croak("ReferenceIsNotMyType");
3428 reference=SvRV(ST(0));
3429 switch (SvTYPE(reference))
3434 message[MaxTextExtent];
3452 Array (AV *) reference
3454 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3455 XS_VERSION,reference);
3456 hv=gv_stashpv(PackageName, FALSE);
3459 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3463 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3465 info=(struct PackageInfo *) SvIV(sv);
3466 DestroyPackageInfo(info);
3468 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3478 Blessed scalar = (Image *) SvIV(reference)
3480 image=(Image *) SvIV(reference);
3481 if (image != (Image *) NULL)
3482 DeleteImageFromRegistry(reference,image);
3491 ###############################################################################
3499 ###############################################################################
3504 Image::Magick ref=NO_INIT
3528 PERL_UNUSED_VAR(ref);
3529 PERL_UNUSED_VAR(ix);
3530 exception=AcquireExceptionInfo();
3531 perl_exception=newSVpv("",0);
3532 package_info=(struct PackageInfo *) NULL;
3533 if (sv_isobject(ST(0)) == 0)
3535 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3539 reference=SvRV(ST(0));
3540 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3541 if (image == (Image *) NULL)
3543 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3547 package_info=ClonePackageInfo(info,exception);
3549 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3552 for (i=2; i < items; i+=2)
3553 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3555 (void) DisplayImages(package_info->image_info,image,exception);
3556 (void) CatchImageException(image);
3559 if (package_info != (struct PackageInfo *) NULL)
3560 DestroyPackageInfo(package_info);
3561 InheritPerlException(exception,perl_exception);
3562 exception=DestroyExceptionInfo(exception);
3563 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3564 SvPOK_on(perl_exception);
3565 ST(0)=sv_2mortal(perl_exception);
3570 ###############################################################################
3574 # E v a l u a t e I m a g e s #
3578 ###############################################################################
3583 Image::Magick ref=NO_INIT
3605 MagickEvaluateOperator
3620 PERL_UNUSED_VAR(ref);
3621 PERL_UNUSED_VAR(ix);
3622 exception=AcquireExceptionInfo();
3623 perl_exception=newSVpv("",0);
3625 if (sv_isobject(ST(0)) == 0)
3627 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3631 reference=SvRV(ST(0));
3632 hv=SvSTASH(reference);
3633 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3634 if (image == (Image *) NULL)
3636 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3640 op=MeanEvaluateOperator;
3646 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3650 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3654 op=(MagickEvaluateOperator) in;
3657 for (i=2; i < items; i+=2)
3659 attribute=(char *) SvPV(ST(i-1),na);
3665 if (LocaleCompare(attribute,"operator") == 0)
3670 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3671 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3674 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3678 op=(MagickEvaluateOperator) in;
3681 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3687 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3693 image=EvaluateImages(image,op,exception);
3694 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3697 Create blessed Perl array for the returned image.
3700 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3702 AddImageToRegistry(sv,image);
3704 av_push(av,sv_bless(rv,hv));
3706 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3707 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3708 "evaluate-%.*s",(int) (MaxTextExtent-9),
3709 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3710 (void) CopyMagickString(image->filename,info->image_info->filename,
3712 SetImageInfo(info->image_info,0,exception);
3713 exception=DestroyExceptionInfo(exception);
3714 SvREFCNT_dec(perl_exception);
3718 InheritPerlException(exception,perl_exception);
3719 exception=DestroyExceptionInfo(exception);
3720 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3721 SvPOK_on(perl_exception);
3722 ST(0)=sv_2mortal(perl_exception);
3727 ###############################################################################
3735 ###############################################################################
3740 Image::Magick ref=NO_INIT
3747 #define ChannelFeatures(channel,direction) \
3749 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3750 channel_features[channel].angular_second_moment[direction]); \
3751 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3753 channel_features[channel].contrast[direction]); \
3754 PUSHs(sv_2mortal(newSVpv(message,0))); \
3755 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3756 channel_features[channel].contrast[direction]); \
3757 PUSHs(sv_2mortal(newSVpv(message,0))); \
3758 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3759 channel_features[channel].variance_sum_of_squares[direction]); \
3760 PUSHs(sv_2mortal(newSVpv(message,0))); \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].inverse_difference_moment[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].sum_average[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3767 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3768 channel_features[channel].sum_variance[direction]); \
3769 PUSHs(sv_2mortal(newSVpv(message,0))); \
3770 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3771 channel_features[channel].sum_entropy[direction]); \
3772 PUSHs(sv_2mortal(newSVpv(message,0))); \
3773 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3774 channel_features[channel].entropy[direction]); \
3775 PUSHs(sv_2mortal(newSVpv(message,0))); \
3776 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3777 channel_features[channel].difference_variance[direction]); \
3778 PUSHs(sv_2mortal(newSVpv(message,0))); \
3779 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3780 channel_features[channel].difference_entropy[direction]); \
3781 PUSHs(sv_2mortal(newSVpv(message,0))); \
3782 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3783 channel_features[channel].measure_of_correlation_1[direction]); \
3784 PUSHs(sv_2mortal(newSVpv(message,0))); \
3785 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3786 channel_features[channel].measure_of_correlation_2[direction]); \
3787 PUSHs(sv_2mortal(newSVpv(message,0))); \
3788 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3789 channel_features[channel].maximum_correlation_coefficient[direction]); \
3790 PUSHs(sv_2mortal(newSVpv(message,0))); \
3798 message[MaxTextExtent];
3825 PERL_UNUSED_VAR(ref);
3826 PERL_UNUSED_VAR(ix);
3827 exception=AcquireExceptionInfo();
3828 perl_exception=newSVpv("",0);
3830 if (sv_isobject(ST(0)) == 0)
3832 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3836 reference=SvRV(ST(0));
3839 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3840 if (image == (Image *) NULL)
3842 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3846 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3848 for (i=2; i < items; i+=2)
3850 attribute=(char *) SvPV(ST(i-1),na);
3856 if (LocaleCompare(attribute,"distance") == 0)
3858 distance=StringToLong((char *) SvPV(ST(1),na));
3861 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3867 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3874 for ( ; image; image=image->next)
3876 channel_features=GetImageFeatures(image,distance,exception);
3877 if (channel_features == (ChannelFeatures *) NULL)
3880 EXTEND(sp,75*count);
3881 for (i=0; i < 4; i++)
3883 ChannelFeatures(RedChannel,i);
3884 ChannelFeatures(GreenChannel,i);
3885 ChannelFeatures(BlueChannel,i);
3886 if (image->colorspace == CMYKColorspace)
3887 ChannelFeatures(BlackChannel,i);
3888 if (image->matte != MagickFalse)
3889 ChannelFeatures(AlphaChannel,i);
3891 channel_features=(ChannelFeatures *)
3892 RelinquishMagickMemory(channel_features);
3896 InheritPerlException(exception,perl_exception);
3897 exception=DestroyExceptionInfo(exception);
3898 SvREFCNT_dec(perl_exception);
3902 ###############################################################################
3910 ###############################################################################
3915 Image::Magick ref=NO_INIT
3953 PERL_UNUSED_VAR(ref);
3954 PERL_UNUSED_VAR(ix);
3955 exception=AcquireExceptionInfo();
3956 perl_exception=newSVpv("",0);
3958 if (sv_isobject(ST(0)) == 0)
3960 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3964 reference=SvRV(ST(0));
3965 hv=SvSTASH(reference);
3966 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3967 if (image == (Image *) NULL)
3969 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3973 background_color=image->background_color;
3975 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
3976 &background_color,exception);
3978 for (i=2; i < items; i+=2)
3980 attribute=(char *) SvPV(ST(i-1),na);
3986 if (LocaleCompare(attribute,"background") == 0)
3988 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
3989 AllCompliance,&background_color,exception);
3992 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3998 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4004 image->background_color=background_color;
4005 image=MergeImageLayers(image,FlattenLayer,exception);
4006 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4009 Create blessed Perl array for the returned image.
4012 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4014 AddImageToRegistry(sv,image);
4016 av_push(av,sv_bless(rv,hv));
4018 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4019 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4020 "flatten-%.*s",(int) (MaxTextExtent-9),
4021 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4022 (void) CopyMagickString(image->filename,info->image_info->filename,
4024 SetImageInfo(info->image_info,0,exception);
4025 exception=DestroyExceptionInfo(exception);
4026 SvREFCNT_dec(perl_exception);
4030 InheritPerlException(exception,perl_exception);
4031 exception=DestroyExceptionInfo(exception);
4032 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4033 SvPOK_on(perl_exception); /* return messages in string context */
4034 ST(0)=sv_2mortal(perl_exception);
4039 ###############################################################################
4047 ###############################################################################
4052 Image::Magick ref=NO_INIT
4064 expression[MaxTextExtent];
4092 PERL_UNUSED_VAR(ref);
4093 PERL_UNUSED_VAR(ix);
4094 exception=AcquireExceptionInfo();
4095 perl_exception=newSVpv("",0);
4099 if (sv_isobject(ST(0)) == 0)
4101 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4105 reference=SvRV(ST(0));
4106 hv=SvSTASH(reference);
4108 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4110 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4111 if (image == (Image *) NULL)
4113 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4117 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4121 channel=DefaultChannels;
4122 (void) CopyMagickString(expression,"u",MaxTextExtent);
4124 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4126 for (i=2; i < items; i+=2)
4128 attribute=(char *) SvPV(ST(i-1),na);
4134 if (LocaleCompare(attribute,"channel") == 0)
4139 option=ParseChannelOption(SvPV(ST(i),na));
4142 ThrowPerlException(exception,OptionError,
4143 "UnrecognizedType",SvPV(ST(i),na));
4146 channel=(ChannelType) option;
4149 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4156 if (LocaleCompare(attribute,"expression") == 0)
4158 (void) CopyMagickString(expression,SvPV(ST(i),na),
4162 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4168 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4174 channel_mask=SetPixelChannelMask(image,channel);
4175 image=FxImage(image,expression,exception);
4176 if (image != (Image *) NULL)
4177 (void) SetPixelChannelMask(image,channel_mask);
4178 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4180 for ( ; image; image=image->next)
4182 AddImageToRegistry(sv,image);
4184 av_push(av,sv_bless(rv,hv));
4187 exception=DestroyExceptionInfo(exception);
4189 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4193 InheritPerlException(exception,perl_exception);
4194 exception=DestroyExceptionInfo(exception);
4195 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4196 SvPOK_on(perl_exception);
4197 ST(0)=sv_2mortal(perl_exception);
4202 ###############################################################################
4210 ###############################################################################
4215 Image::Magick ref=NO_INIT
4226 color[MaxTextExtent];
4251 PERL_UNUSED_VAR(ref);
4252 PERL_UNUSED_VAR(ix);
4253 exception=AcquireExceptionInfo();
4254 perl_exception=newSVpv("",0);
4255 if (sv_isobject(ST(0)) == 0)
4257 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4261 reference=SvRV(ST(0));
4262 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4263 if (image == (Image *) NULL && !info)
4266 for (i=1; i < items; i++)
4268 attribute=(char *) SvPV(ST(i),na);
4275 if (LocaleCompare(attribute,"adjoin") == 0)
4278 s=newSViv((ssize_t) info->image_info->adjoin);
4279 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4282 if (LocaleCompare(attribute,"antialias") == 0)
4285 s=newSViv((ssize_t) info->image_info->antialias);
4286 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4289 if (LocaleCompare(attribute,"area") == 0)
4291 s=newSViv(GetMagickResource(AreaResource));
4292 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4295 if (LocaleCompare(attribute,"attenuate") == 0)
4300 value=GetImageProperty(image,attribute,exception);
4301 if (value != (const char *) NULL)
4303 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4306 if (LocaleCompare(attribute,"authenticate") == 0)
4313 option=GetImageOption(info->image_info,attribute);
4314 if (option != (const char *) NULL)
4315 s=newSVpv(option,0);
4317 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4320 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4327 if (LocaleCompare(attribute,"background") == 0)
4329 if (image == (Image *) NULL)
4331 (void) FormatLocaleString(color,MaxTextExtent,
4332 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4333 image->background_color.green,image->background_color.blue,
4334 image->background_color.alpha);
4336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4339 if (LocaleCompare(attribute,"base-columns") == 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,"base-filename") == 0)
4348 if (image != (Image *) NULL)
4349 s=newSVpv(image->magick_filename,0);
4350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4353 if (LocaleCompare(attribute,"base-height") == 0)
4355 if (image != (Image *) NULL)
4356 s=newSViv((ssize_t) image->magick_rows);
4357 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4360 if (LocaleCompare(attribute,"base-rows") == 0)
4362 if (image != (Image *) NULL)
4363 s=newSViv((ssize_t) image->magick_rows);
4364 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4367 if (LocaleCompare(attribute,"base-width") == 0)
4369 if (image != (Image *) NULL)
4370 s=newSViv((ssize_t) image->magick_columns);
4371 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4374 if (LocaleCompare(attribute,"bias") == 0)
4376 if (image != (Image *) NULL)
4377 s=newSVnv(image->bias);
4378 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4381 if (LocaleCompare(attribute,"blue-primary") == 0)
4383 if (image == (Image *) NULL)
4385 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4386 image->chromaticity.blue_primary.x,
4387 image->chromaticity.blue_primary.y);
4389 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4392 if (LocaleCompare(attribute,"bordercolor") == 0)
4394 if (image == (Image *) NULL)
4396 (void) FormatLocaleString(color,MaxTextExtent,
4397 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4398 image->border_color.green,image->border_color.blue,
4399 image->border_color.alpha);
4401 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4404 if (LocaleCompare(attribute,"bounding-box") == 0)
4407 geometry[MaxTextExtent];
4412 if (image == (Image *) NULL)
4414 page=GetImageBoundingBox(image,exception);
4415 (void) FormatLocaleString(geometry,MaxTextExtent,
4416 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4417 page.height,(double) page.x,(double) page.y);
4418 s=newSVpv(geometry,0);
4419 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4422 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4429 if (LocaleCompare(attribute,"class") == 0)
4431 if (image == (Image *) NULL)
4433 s=newSViv(image->storage_class);
4434 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4435 image->storage_class));
4437 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4440 if (LocaleCompare(attribute,"clip-mask") == 0)
4442 if (image != (Image *) NULL)
4448 if (image->mask == (Image *) NULL)
4449 ClipImage(image,exception);
4450 if (image->mask != (Image *) NULL)
4452 AddImageToRegistry(sv,image->mask);
4453 s=sv_bless(newRV(sv),SvSTASH(reference));
4456 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4459 if (LocaleCompare(attribute,"clip-path") == 0)
4461 if (image != (Image *) NULL)
4467 if (image->clip_mask == (Image *) NULL)
4468 ClipImage(image,exception);
4469 if (image->clip_mask != (Image *) NULL)
4471 AddImageToRegistry(sv,image->clip_mask);
4472 s=sv_bless(newRV(sv),SvSTASH(reference));
4475 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4478 if (LocaleCompare(attribute,"compression") == 0)
4480 j=info ? info->image_info->compression : image ?
4481 image->compression : UndefinedCompression;
4483 if (info->image_info->compression == UndefinedCompression)
4484 j=image->compression;
4486 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4489 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4492 if (LocaleCompare(attribute,"colorspace") == 0)
4494 j=image ? image->colorspace : RGBColorspace;
4496 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4499 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4502 if (LocaleCompare(attribute,"colors") == 0)
4504 if (image != (Image *) NULL)
4505 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4507 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4510 if (LocaleNCompare(attribute,"colormap",8) == 0)
4515 if (image == (Image *) NULL || !image->colormap)
4518 items=sscanf(attribute,"%*[^[][%ld",&j);
4520 if (j > (ssize_t) image->colors)
4522 (void) FormatLocaleString(color,MaxTextExtent,
4523 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4524 image->colormap[j].green,image->colormap[j].blue,
4525 image->colormap[j].alpha);
4527 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4530 if (LocaleCompare(attribute,"columns") == 0)
4532 if (image != (Image *) NULL)
4533 s=newSViv((ssize_t) image->columns);
4534 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4537 if (LocaleCompare(attribute,"comment") == 0)
4542 value=GetImageProperty(image,attribute,exception);
4543 if (value != (const char *) NULL)
4545 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4548 if (LocaleCompare(attribute,"copyright") == 0)
4550 s=newSVpv(GetMagickCopyright(),0);
4551 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4554 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4561 if (LocaleCompare(attribute,"density") == 0)
4564 geometry[MaxTextExtent];
4566 if (image == (Image *) NULL)
4568 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4569 image->resolution.x,image->resolution.y);
4570 s=newSVpv(geometry,0);
4571 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4574 if (LocaleCompare(attribute,"delay") == 0)
4576 if (image != (Image *) NULL)
4577 s=newSViv((ssize_t) image->delay);
4578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4581 if (LocaleCompare(attribute,"depth") == 0)
4583 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4584 if (image != (Image *) NULL)
4585 s=newSViv((ssize_t) GetImageDepth(image,exception));
4586 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4589 if (LocaleCompare(attribute,"directory") == 0)
4591 if (image && image->directory)
4592 s=newSVpv(image->directory,0);
4593 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4596 if (LocaleCompare(attribute,"dispose") == 0)
4598 if (image == (Image *) NULL)
4601 s=newSViv(image->dispose);
4603 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4605 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4608 if (LocaleCompare(attribute,"disk") == 0)
4610 s=newSViv(GetMagickResource(DiskResource));
4611 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4614 if (LocaleCompare(attribute,"dither") == 0)
4617 s=newSViv((ssize_t) info->image_info->dither);
4618 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4621 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4623 if (info && info->image_info->server_name)
4624 s=newSVpv(info->image_info->server_name,0);
4625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4628 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4635 if (LocaleCompare(attribute,"elapsed-time") == 0)
4637 if (image != (Image *) NULL)
4638 s=newSVnv(GetElapsedTime(&image->timer));
4639 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4642 if (LocaleCompare(attribute,"endian") == 0)
4644 j=info ? info->image_info->endian : image ? image->endian :
4647 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4652 if (LocaleCompare(attribute,"error") == 0)
4654 if (image != (Image *) NULL)
4655 s=newSVnv(image->error.mean_error_per_pixel);
4656 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4666 if (LocaleCompare(attribute,"filesize") == 0)
4668 if (image != (Image *) NULL)
4669 s=newSViv((ssize_t) GetBlobSize(image));
4670 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4673 if (LocaleCompare(attribute,"filename") == 0)
4675 if (info && info->image_info->filename &&
4676 *info->image_info->filename)
4677 s=newSVpv(info->image_info->filename,0);
4678 if (image != (Image *) NULL)
4679 s=newSVpv(image->filename,0);
4680 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4683 if (LocaleCompare(attribute,"filter") == 0)
4685 s=image ? newSViv(image->filter) : newSViv(0);
4686 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4689 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4692 if (LocaleCompare(attribute,"font") == 0)
4694 if (info && info->image_info->font)
4695 s=newSVpv(info->image_info->font,0);
4696 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4699 if (LocaleCompare(attribute,"foreground") == 0)
4701 if (LocaleCompare(attribute,"format") == 0)
4706 magick_info=(const MagickInfo *) NULL;
4707 if (info && (*info->image_info->magick != '\0'))
4708 magick_info=GetMagickInfo(info->image_info->magick,exception);
4709 if (image != (Image *) NULL)
4710 magick_info=GetMagickInfo(image->magick,exception);
4711 if ((magick_info != (const MagickInfo *) NULL) &&
4712 (*magick_info->description != '\0'))
4713 s=newSVpv((char *) magick_info->description,0);
4714 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4717 if (LocaleCompare(attribute,"fuzz") == 0)
4720 s=newSVnv(info->image_info->fuzz);
4721 if (image != (Image *) NULL)
4722 s=newSVnv(image->fuzz);
4723 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4726 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4733 if (LocaleCompare(attribute,"gamma") == 0)
4735 if (image != (Image *) NULL)
4736 s=newSVnv(image->gamma);
4737 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4740 if (LocaleCompare(attribute,"geometry") == 0)
4742 if (image && image->geometry)
4743 s=newSVpv(image->geometry,0);
4744 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4747 if (LocaleCompare(attribute,"gravity") == 0)
4749 s=image ? newSViv(image->gravity) : newSViv(0);
4750 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4753 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4756 if (LocaleCompare(attribute,"green-primary") == 0)
4758 if (image == (Image *) NULL)
4760 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4761 image->chromaticity.green_primary.x,
4762 image->chromaticity.green_primary.y);
4764 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4767 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4774 if (LocaleCompare(attribute,"height") == 0)
4776 if (image != (Image *) NULL)
4777 s=newSViv((ssize_t) image->rows);
4778 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4781 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4788 if (LocaleCompare(attribute,"icc") == 0)
4790 if (image != (Image *) NULL)
4795 profile=GetImageProfile(image,"icc");
4796 if (profile != (StringInfo *) NULL)
4797 s=newSVpv((const char *) GetStringInfoDatum(profile),
4798 GetStringInfoLength(profile));
4800 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4803 if (LocaleCompare(attribute,"icm") == 0)
4805 if (image != (Image *) NULL)
4810 profile=GetImageProfile(image,"icm");
4811 if (profile != (const StringInfo *) NULL)
4812 s=newSVpv((const char *) GetStringInfoDatum(profile),
4813 GetStringInfoLength(profile));
4815 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4818 if (LocaleCompare(attribute,"id") == 0)
4820 if (image != (Image *) NULL)
4831 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4833 status=SetImageRegistry(ImageRegistryType,key,image,
4838 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4841 if (LocaleNCompare(attribute,"index",5) == 0)
4844 name[MaxTextExtent];
4853 register const Quantum
4859 if (image == (Image *) NULL)
4861 if (image->storage_class != PseudoClass)
4865 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4867 image_view=AcquireCacheView(image);
4868 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
4869 if (p != (const Quantum *) NULL)
4871 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4872 GetPixelIndex(image,p));
4874 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4876 image_view=DestroyCacheView(image_view);
4879 if (LocaleCompare(attribute,"iptc") == 0)
4881 if (image != (Image *) NULL)
4886 profile=GetImageProfile(image,"iptc");
4887 if (profile != (const StringInfo *) NULL)
4888 s=newSVpv((const char *) GetStringInfoDatum(profile),
4889 GetStringInfoLength(profile));
4891 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4894 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4896 if (image != (Image *) NULL)
4897 s=newSViv((ssize_t) image->iterations);
4898 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4901 if (LocaleCompare(attribute,"interlace") == 0)
4903 j=info ? info->image_info->interlace : image ? image->interlace :
4906 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4909 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4912 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4919 if (LocaleCompare(attribute,"label") == 0)
4924 if (image == (Image *) NULL)
4926 value=GetImageProperty(image,"Label",exception);
4927 if (value != (const char *) NULL)
4929 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4932 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4934 if (image != (Image *) NULL)
4935 s=newSViv((ssize_t) image->iterations);
4936 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4939 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4946 if (LocaleCompare(attribute,"magick") == 0)
4948 if (info && *info->image_info->magick)
4949 s=newSVpv(info->image_info->magick,0);
4950 if (image != (Image *) NULL)
4951 s=newSVpv(image->magick,0);
4952 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4955 if (LocaleCompare(attribute,"map") == 0)
4957 s=newSViv(GetMagickResource(MapResource));
4958 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4961 if (LocaleCompare(attribute,"maximum-error") == 0)
4963 if (image != (Image *) NULL)
4964 s=newSVnv(image->error.normalized_maximum_error);
4965 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4968 if (LocaleCompare(attribute,"memory") == 0)
4970 s=newSViv(GetMagickResource(MemoryResource));
4971 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4974 if (LocaleCompare(attribute,"mean-error") == 0)
4976 if (image != (Image *) NULL)
4977 s=newSVnv(image->error.normalized_mean_error);
4978 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4981 if (LocaleCompare(attribute,"mime") == 0)
4983 if (info && *info->image_info->magick)
4984 s=newSVpv(MagickToMime(info->image_info->magick),0);
4985 if (image != (Image *) NULL)
4986 s=newSVpv(MagickToMime(image->magick),0);
4987 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4990 if (LocaleCompare(attribute,"mattecolor") == 0)
4992 if (image == (Image *) NULL)
4994 (void) FormatLocaleString(color,MaxTextExtent,
4995 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
4996 image->matte_color.green,image->matte_color.blue,
4997 image->matte_color.alpha);
4999 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5002 if (LocaleCompare(attribute,"matte") == 0)
5004 if (image != (Image *) NULL)
5005 s=newSViv((ssize_t) image->matte);
5006 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5009 if (LocaleCompare(attribute,"mime") == 0)
5015 if (info && *info->image_info->magick)
5016 magick=info->image_info->magick;
5017 if (image != (Image *) NULL)
5018 magick=image->magick;
5024 mime=MagickToMime(magick);
5026 mime=(char *) RelinquishMagickMemory(mime);
5028 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5031 if (LocaleCompare(attribute,"monochrome") == 0)
5033 if (image == (Image *) NULL)
5035 j=info ? info->image_info->monochrome :
5036 IsImageMonochrome(image,exception);
5038 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5041 if (LocaleCompare(attribute,"montage") == 0)
5043 if (image && image->montage)
5044 s=newSVpv(image->montage,0);
5045 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5048 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5055 if (LocaleCompare(attribute,"orientation") == 0)
5057 j=info ? info->image_info->orientation : image ?
5058 image->orientation : UndefinedOrientation;
5060 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5063 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5066 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5073 if (LocaleCompare(attribute,"page") == 0)
5075 if (info && info->image_info->page)
5076 s=newSVpv(info->image_info->page,0);
5077 if (image != (Image *) NULL)
5080 geometry[MaxTextExtent];
5082 (void) FormatLocaleString(geometry,MaxTextExtent,
5083 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5084 (double) image->page.height,(double) image->page.x,(double)
5086 s=newSVpv(geometry,0);
5088 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5091 if (LocaleCompare(attribute,"page.x") == 0)
5093 if (image != (Image *) NULL)
5094 s=newSViv((ssize_t) image->page.x);
5095 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5098 if (LocaleCompare(attribute,"page.y") == 0)
5100 if (image != (Image *) NULL)
5101 s=newSViv((ssize_t) image->page.y);
5102 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5105 if (LocaleNCompare(attribute,"pixel",5) == 0)
5108 tuple[MaxTextExtent];
5117 register const Quantum
5120 if (image == (Image *) NULL)
5124 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5126 p=GetVirtualPixels(image,x,y,1,1,exception);
5127 if (image->colorspace != CMYKColorspace)
5128 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5129 QuantumFormat "," QuantumFormat "," QuantumFormat,
5130 GetPixelRed(image,p),GetPixelGreen(image,p),
5131 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5133 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5134 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5135 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5136 GetPixelBlue(image,p),GetPixelBlack(image,p),
5137 GetPixelAlpha(image,p));
5139 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5142 if (LocaleCompare(attribute,"pointsize") == 0)
5145 s=newSViv((ssize_t) info->image_info->pointsize);
5146 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5149 if (LocaleCompare(attribute,"preview") == 0)
5151 s=newSViv(info->image_info->preview_type);
5152 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5153 info->image_info->preview_type));
5155 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5158 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5165 if (LocaleCompare(attribute,"quality") == 0)
5168 s=newSViv((ssize_t) info->image_info->quality);
5169 if (image != (Image *) NULL)
5170 s=newSViv((ssize_t) image->quality);
5171 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5174 if (LocaleCompare(attribute,"quantum") == 0)
5177 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5178 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5181 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5188 if (LocaleCompare(attribute,"rendering-intent") == 0)
5190 s=newSViv(image->rendering_intent);
5191 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5192 image->rendering_intent));
5194 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5197 if (LocaleCompare(attribute,"red-primary") == 0)
5199 if (image == (Image *) NULL)
5201 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5202 image->chromaticity.red_primary.x,
5203 image->chromaticity.red_primary.y);
5205 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5208 if (LocaleCompare(attribute,"rows") == 0)
5210 if (image != (Image *) NULL)
5211 s=newSViv((ssize_t) image->rows);
5212 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5222 if (LocaleCompare(attribute,"sampling-factor") == 0)
5224 if (info && info->image_info->sampling_factor)
5225 s=newSVpv(info->image_info->sampling_factor,0);
5226 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5229 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5231 if (info && info->image_info->server_name)
5232 s=newSVpv(info->image_info->server_name,0);
5233 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5236 if (LocaleCompare(attribute,"size") == 0)
5238 if (info && info->image_info->size)
5239 s=newSVpv(info->image_info->size,0);
5240 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5243 if (LocaleCompare(attribute,"scene") == 0)
5245 if (image != (Image *) NULL)
5246 s=newSViv((ssize_t) image->scene);
5247 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5250 if (LocaleCompare(attribute,"scenes") == 0)
5252 if (image != (Image *) NULL)
5253 s=newSViv((ssize_t) info->image_info->number_scenes);
5254 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5257 if (LocaleCompare(attribute,"signature") == 0)
5262 if (image == (Image *) NULL)
5264 (void) SignatureImage(image,exception);
5265 value=GetImageProperty(image,"Signature",exception);
5266 if (value != (const char *) NULL)
5268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5271 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5278 if (LocaleCompare(attribute,"taint") == 0)
5280 if (image != (Image *) NULL)
5281 s=newSViv((ssize_t) IsTaintImage(image));
5282 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5285 if (LocaleCompare(attribute,"texture") == 0)
5287 if (info && info->image_info->texture)
5288 s=newSVpv(info->image_info->texture,0);
5289 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5292 if (LocaleCompare(attribute,"total-ink-density") == 0)
5294 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5295 if (image != (Image *) NULL)
5296 s=newSVnv(GetImageTotalInkDensity(image,exception));
5297 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5300 if (LocaleCompare(attribute,"transparent-color") == 0)
5302 if (image == (Image *) NULL)
5304 (void) FormatLocaleString(color,MaxTextExtent,
5305 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5306 image->transparent_color.green,image->transparent_color.blue,
5307 image->transparent_color.alpha);
5309 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5312 if (LocaleCompare(attribute,"type") == 0)
5314 if (image == (Image *) NULL)
5316 j=(ssize_t) GetImageType(image,exception);
5318 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5320 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5323 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5330 if (LocaleCompare(attribute,"units") == 0)
5332 j=info ? info->image_info->units : image ? image->units :
5333 UndefinedResolution;
5334 if (info && (info->image_info->units == UndefinedResolution))
5337 if (j == UndefinedResolution)
5338 s=newSVpv("undefined units",0);
5340 if (j == PixelsPerInchResolution)
5341 s=newSVpv("pixels / inch",0);
5343 s=newSVpv("pixels / centimeter",0);
5344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5347 if (LocaleCompare(attribute,"user-time") == 0)
5349 if (image != (Image *) NULL)
5350 s=newSVnv(GetUserTime(&image->timer));
5351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5354 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5361 if (LocaleCompare(attribute,"verbose") == 0)
5364 s=newSViv((ssize_t) info->image_info->verbose);
5365 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5368 if (LocaleCompare(attribute,"version") == 0)
5370 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5371 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5374 if (LocaleCompare(attribute,"view") == 0)
5376 if (info && info->image_info->view)
5377 s=newSVpv(info->image_info->view,0);
5378 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5381 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5383 if (image == (Image *) NULL)
5385 j=(ssize_t) GetImageVirtualPixelMethod(image);
5387 (void) sv_setpv(s,CommandOptionToMnemonic(
5388 MagickVirtualPixelOptions,j));
5390 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5393 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5400 if (LocaleCompare(attribute,"white-point") == 0)
5402 if (image == (Image *) NULL)
5404 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5405 image->chromaticity.white_point.x,
5406 image->chromaticity.white_point.y);
5408 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5411 if (LocaleCompare(attribute,"width") == 0)
5413 if (image != (Image *) NULL)
5414 s=newSViv((ssize_t) image->columns);
5415 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5425 if (LocaleCompare(attribute,"x-resolution") == 0)
5427 if (image != (Image *) NULL)
5428 s=newSVnv(image->resolution.x);
5429 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5432 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5439 if (LocaleCompare(attribute,"y-resolution") == 0)
5441 if (image != (Image *) NULL)
5442 s=newSVnv(image->resolution.y);
5443 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5446 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5453 if (image == (Image *) NULL)
5454 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5458 value=GetImageProperty(image,attribute,exception);
5459 if (value != (const char *) NULL)
5462 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5465 if (*attribute != '%')
5466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5473 meta=InterpretImageProperties(info ? info->image_info :
5474 (ImageInfo *) NULL,image,attribute,exception);
5476 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5477 meta=(char *) RelinquishMagickMemory(meta);
5481 exception=DestroyExceptionInfo(exception);
5482 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5486 ###############################################################################
5490 # G e t A u t h e n t i c P i x e l s #
5494 ###############################################################################
5498 GetAuthenticPixels(ref,...)
5499 Image::Magick ref = NO_INIT
5501 getauthenticpixels = 1
5531 PERL_UNUSED_VAR(ref);
5532 PERL_UNUSED_VAR(ix);
5533 exception=AcquireExceptionInfo();
5534 perl_exception=newSVpv("",0);
5535 if (sv_isobject(ST(0)) == 0)
5537 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5541 reference=SvRV(ST(0));
5543 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5544 if (image == (Image *) NULL)
5546 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5553 region.width=image->columns;
5556 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5557 for (i=2; i < items; i+=2)
5559 attribute=(char *) SvPV(ST(i-1),na);
5565 if (LocaleCompare(attribute,"geometry") == 0)
5567 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5570 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5577 if (LocaleCompare(attribute,"height") == 0)
5579 region.height=SvIV(ST(i));
5582 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5589 if (LocaleCompare(attribute,"x") == 0)
5591 region.x=SvIV(ST(i));
5594 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5601 if (LocaleCompare(attribute,"y") == 0)
5603 region.y=SvIV(ST(i));
5606 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5613 if (LocaleCompare(attribute,"width") == 0)
5615 region.width=SvIV(ST(i));
5618 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5624 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5625 region.height,exception);
5626 if (blob != (void *) NULL)
5630 InheritPerlException(exception,perl_exception);
5631 exception=DestroyExceptionInfo(exception);
5632 SvREFCNT_dec(perl_exception); /* throw away all errors */
5641 ###############################################################################
5645 # G e t V i r t u a l P i x e l s #
5649 ###############################################################################
5653 GetVirtualPixels(ref,...)
5654 Image::Magick ref = NO_INIT
5656 getvirtualpixels = 1
5657 AcquireImagePixels = 2
5658 acquireimagepixels = 3
5686 PERL_UNUSED_VAR(ref);
5687 PERL_UNUSED_VAR(ix);
5688 exception=AcquireExceptionInfo();
5689 perl_exception=newSVpv("",0);
5690 if (sv_isobject(ST(0)) == 0)
5692 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5696 reference=SvRV(ST(0));
5698 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5699 if (image == (Image *) NULL)
5701 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5708 region.width=image->columns;
5711 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5712 for (i=2; i < items; i+=2)
5714 attribute=(char *) SvPV(ST(i-1),na);
5720 if (LocaleCompare(attribute,"geometry") == 0)
5722 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5725 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5732 if (LocaleCompare(attribute,"height") == 0)
5734 region.height=SvIV(ST(i));
5737 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5744 if (LocaleCompare(attribute,"x") == 0)
5746 region.x=SvIV(ST(i));
5749 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5756 if (LocaleCompare(attribute,"y") == 0)
5758 region.y=SvIV(ST(i));
5761 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5768 if (LocaleCompare(attribute,"width") == 0)
5770 region.width=SvIV(ST(i));
5773 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5779 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5780 region.height,exception);
5781 if (blob != (void *) NULL)
5785 InheritPerlException(exception,perl_exception);
5786 exception=DestroyExceptionInfo(exception);
5787 SvREFCNT_dec(perl_exception); /* throw away all errors */
5790 RETVAL = (void *) blob;
5796 ###############################################################################
5800 # G e t A u t h e n t i c M e t a c o n t e n t #
5804 ###############################################################################
5808 GetAuthenticMetacontent(ref,...)
5809 Image::Magick ref = NO_INIT
5811 getauthenticmetacontent = 1
5832 PERL_UNUSED_VAR(ref);
5833 PERL_UNUSED_VAR(ix);
5834 exception=AcquireExceptionInfo();
5835 perl_exception=newSVpv("",0);
5836 if (sv_isobject(ST(0)) == 0)
5838 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5842 reference=SvRV(ST(0));
5844 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5845 if (image == (Image *) NULL)
5847 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5852 blob=(void *) GetAuthenticMetacontent(image);
5853 if (blob != (void *) NULL)
5857 InheritPerlException(exception,perl_exception);
5858 exception=DestroyExceptionInfo(exception);
5859 SvREFCNT_dec(perl_exception); /* throw away all errors */
5868 ###############################################################################
5872 # G e t V i r t u a l M e t a c o n t e n t #
5876 ###############################################################################
5880 GetVirtualMetacontent(ref,...)
5881 Image::Magick ref = NO_INIT
5883 getvirtualmetacontent = 1
5902 PERL_UNUSED_VAR(ref);
5903 PERL_UNUSED_VAR(ix);
5904 exception=AcquireExceptionInfo();
5905 perl_exception=newSVpv("",0);
5906 if (sv_isobject(ST(0)) == 0)
5908 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5912 reference=SvRV(ST(0));
5914 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5915 if (image == (Image *) NULL)
5917 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5922 blob=(void *) GetVirtualMetacontent(image);
5923 if (blob != (void *) NULL)
5927 InheritPerlException(exception,perl_exception);
5928 exception=DestroyExceptionInfo(exception);
5929 SvREFCNT_dec(perl_exception); /* throw away all errors */
5938 ###############################################################################
5942 # H i s t o g r a m #
5946 ###############################################################################
5951 Image::Magick ref=NO_INIT
5962 message[MaxTextExtent];
5989 PERL_UNUSED_VAR(ref);
5990 PERL_UNUSED_VAR(ix);
5991 exception=AcquireExceptionInfo();
5992 perl_exception=newSVpv("",0);
5994 if (sv_isobject(ST(0)) == 0)
5996 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6000 reference=SvRV(ST(0));
6003 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6004 if (image == (Image *) NULL)
6006 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6010 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6012 for ( ; image; image=image->next)
6014 histogram=GetImageHistogram(image,&number_colors,exception);
6015 if (histogram == (PixelInfo *) NULL)
6017 count+=(ssize_t) number_colors;
6019 for (i=0; i < (ssize_t) number_colors; i++)
6021 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6023 PUSHs(sv_2mortal(newSVpv(message,0)));
6024 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6025 histogram[i].green);
6026 PUSHs(sv_2mortal(newSVpv(message,0)));
6027 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6029 PUSHs(sv_2mortal(newSVpv(message,0)));
6030 if (image->colorspace == CMYKColorspace)
6032 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6033 histogram[i].black);
6034 PUSHs(sv_2mortal(newSVpv(message,0)));
6036 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6037 histogram[i].alpha);
6038 PUSHs(sv_2mortal(newSVpv(message,0)));
6039 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6040 histogram[i].count);
6041 PUSHs(sv_2mortal(newSVpv(message,0)));
6043 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6047 InheritPerlException(exception,perl_exception);
6048 exception=DestroyExceptionInfo(exception);
6049 SvREFCNT_dec(perl_exception);
6053 ###############################################################################
6061 ###############################################################################
6066 Image::Magick ref=NO_INIT
6090 register const Quantum
6104 *reference; /* reference is the SV* of ref=SvIV(reference) */
6106 PERL_UNUSED_VAR(ref);
6107 PERL_UNUSED_VAR(ix);
6108 exception=AcquireExceptionInfo();
6109 perl_exception=newSVpv("",0);
6110 reference=SvRV(ST(0));
6111 av=(AV *) reference;
6112 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6114 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6115 if (image == (Image *) NULL)
6117 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6121 normalize=MagickTrue;
6124 region.width=image->columns;
6127 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6128 for (i=2; i < items; i+=2)
6130 attribute=(char *) SvPV(ST(i-1),na);
6136 if (LocaleCompare(attribute,"channel") == 0)
6141 option=ParseChannelOption(SvPV(ST(i),na));
6144 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6148 SetPixelChannelMapMask(image,(ChannelType) option);
6151 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6158 if (LocaleCompare(attribute,"geometry") == 0)
6160 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6163 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6170 if (LocaleCompare(attribute,"normalize") == 0)
6172 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6176 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6180 normalize=option != 0 ? MagickTrue : MagickFalse;
6183 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6190 if (LocaleCompare(attribute,"x") == 0)
6192 region.x=SvIV(ST(i));
6195 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6202 if (LocaleCompare(attribute,"y") == 0)
6204 region.y=SvIV(ST(i));
6207 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6213 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6219 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6220 if (p == (const Quantum *) NULL)
6228 if (normalize != MagickFalse)
6229 scale=1.0/QuantumRange;
6230 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6231 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6232 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6233 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6234 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6235 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6236 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6237 (image->colorspace == CMYKColorspace))
6238 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6239 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6240 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6244 InheritPerlException(exception,perl_exception);
6245 exception=DestroyExceptionInfo(exception);
6246 SvREFCNT_dec(perl_exception);
6250 ###############################################################################
6254 # G e t P i x e l s #
6258 ###############################################################################
6263 Image::Magick ref=NO_INIT
6302 *reference; /* reference is the SV* of ref=SvIV(reference) */
6304 PERL_UNUSED_VAR(ref);
6305 PERL_UNUSED_VAR(ix);
6306 exception=AcquireExceptionInfo();
6307 perl_exception=newSVpv("",0);
6308 reference=SvRV(ST(0));
6309 av=(AV *) reference;
6310 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6312 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6313 if (image == (Image *) NULL)
6315 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6320 if (image->matte != MagickFalse)
6322 if (image->colorspace == CMYKColorspace)
6325 if (image->matte != MagickFalse)
6328 normalize=MagickFalse;
6331 region.width=image->columns;
6334 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6335 for (i=2; i < items; i+=2)
6337 attribute=(char *) SvPV(ST(i-1),na);
6343 if (LocaleCompare(attribute,"geometry") == 0)
6345 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6348 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6355 if (LocaleCompare(attribute,"height") == 0)
6357 region.height=SvIV(ST(i));
6360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6367 if (LocaleCompare(attribute,"map") == 0)
6372 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6379 if (LocaleCompare(attribute,"normalize") == 0)
6381 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6385 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6389 normalize=option != 0 ? MagickTrue : MagickFalse;
6392 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6399 if (LocaleCompare(attribute,"width") == 0)
6401 region.width=SvIV(ST(i));
6404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6411 if (LocaleCompare(attribute,"x") == 0)
6413 region.x=SvIV(ST(i));
6416 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6423 if (LocaleCompare(attribute,"y") == 0)
6425 region.y=SvIV(ST(i));
6428 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6434 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6440 if (normalize != MagickFalse)
6445 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6446 region.height*sizeof(*pixels));
6447 if (pixels == (float *) NULL)
6449 ThrowPerlException(exception,ResourceLimitError,
6450 "MemoryAllocationFailed",PackageName);
6453 status=ExportImagePixels(image,region.x,region.y,region.width,
6454 region.height,map,FloatPixel,pixels,exception);
6455 if (status == MagickFalse)
6459 EXTEND(sp,strlen(map)*region.width*region.height);
6460 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6461 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6463 pixels=(float *) RelinquishMagickMemory(pixels);
6470 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6471 region.height*sizeof(*pixels));
6472 if (pixels == (Quantum *) NULL)
6474 ThrowPerlException(exception,ResourceLimitError,
6475 "MemoryAllocationFailed",PackageName);
6478 status=ExportImagePixels(image,region.x,region.y,region.width,
6479 region.height,map,QuantumPixel,pixels,exception);
6480 if (status == MagickFalse)
6484 EXTEND(sp,strlen(map)*region.width*region.height);
6485 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6486 PUSHs(sv_2mortal(newSViv(pixels[i])));
6488 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6492 InheritPerlException(exception,perl_exception);
6493 exception=DestroyExceptionInfo(exception);
6494 SvREFCNT_dec(perl_exception);
6498 ###############################################################################
6502 # I m a g e T o B l o b #
6506 ###############################################################################
6510 ImageToBlob(ref,...)
6511 Image::Magick ref=NO_INIT
6520 filename[MaxTextExtent];
6549 PERL_UNUSED_VAR(ref);
6550 PERL_UNUSED_VAR(ix);
6551 exception=AcquireExceptionInfo();
6552 perl_exception=newSVpv("",0);
6553 package_info=(struct PackageInfo *) NULL;
6554 if (sv_isobject(ST(0)) == 0)
6556 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6560 reference=SvRV(ST(0));
6561 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6562 if (image == (Image *) NULL)
6564 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6568 package_info=ClonePackageInfo(info,exception);
6569 for (i=2; i < items; i+=2)
6570 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6571 (void) CopyMagickString(filename,package_info->image_info->filename,
6574 for (next=image; next; next=next->next)
6576 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6577 next->scene=scene++;
6579 SetImageInfo(package_info->image_info,(unsigned int)
6580 GetImageListLength(image),exception);
6581 EXTEND(sp,(ssize_t) GetImageListLength(image));
6582 for ( ; image; image=image->next)
6585 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6586 if (blob != (char *) NULL)
6588 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6589 blob=(unsigned char *) RelinquishMagickMemory(blob);
6591 if (package_info->image_info->adjoin)
6596 if (package_info != (struct PackageInfo *) NULL)
6597 DestroyPackageInfo(package_info);
6598 InheritPerlException(exception,perl_exception);
6599 exception=DestroyExceptionInfo(exception);
6600 SvREFCNT_dec(perl_exception); /* throw away all errors */
6604 ###############################################################################
6612 ###############################################################################
6617 Image::Magick ref=NO_INIT
6621 OptimizeImageLayers = 3
6623 optimizeimagelayers = 5
6665 PERL_UNUSED_VAR(ref);
6666 PERL_UNUSED_VAR(ix);
6667 exception=AcquireExceptionInfo();
6668 perl_exception=newSVpv("",0);
6670 if (sv_isobject(ST(0)) == 0)
6672 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6676 reference=SvRV(ST(0));
6677 hv=SvSTASH(reference);
6679 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6681 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6682 if (image == (Image *) NULL)
6684 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6688 compose=image->compose;
6689 method=OptimizeLayer;
6690 for (i=2; i < items; i+=2)
6692 attribute=(char *) SvPV(ST(i-1),na);
6698 if (LocaleCompare(attribute,"compose") == 0)
6700 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6701 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6704 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6708 compose=(CompositeOperator) sp;
6711 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6718 if (LocaleCompare(attribute,"method") == 0)
6720 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6724 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6728 method=(ImageLayerMethod) option;
6731 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6737 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6743 layers=(Image *) NULL;
6746 case CompareAnyLayer:
6747 case CompareClearLayer:
6748 case CompareOverlayLayer:
6751 layers=CompareImagesLayers(image,method,exception);
6758 layers=MergeImageLayers(image,method,exception);
6763 layers=DisposeImages(image,exception);
6766 case OptimizeImageLayer:
6768 layers=OptimizeImageLayers(image,exception);
6771 case OptimizePlusLayer:
6773 layers=OptimizePlusImageLayers(image,exception);
6776 case OptimizeTransLayer:
6778 OptimizeImageTransparency(image,exception);
6781 case RemoveDupsLayer:
6783 RemoveDuplicateLayers(&image,exception);
6786 case RemoveZeroLayer:
6788 RemoveZeroDelayLayers(&image,exception);
6797 General Purpose, GIF Animation Optimizer.
6799 layers=CoalesceImages(image,exception);
6800 if (layers == (Image *) NULL)
6803 layers=OptimizeImageLayers(image,exception);
6804 if (layers == (Image *) NULL)
6806 image=DestroyImageList(image);
6808 layers=(Image *) NULL;
6809 OptimizeImageTransparency(image,exception);
6810 quantize_info=AcquireQuantizeInfo(info->image_info);
6811 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6812 quantize_info=DestroyQuantizeInfo(quantize_info);
6815 case CompositeLayer:
6824 Split image sequence at the first 'NULL:' image.
6827 while (source != (Image *) NULL)
6829 source=GetNextImageInList(source);
6830 if ((source != (Image *) NULL) &&
6831 (LocaleCompare(source->magick,"NULL") == 0))
6834 if (source != (Image *) NULL)
6836 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6837 (GetNextImageInList(source) == (Image *) NULL))
6838 source=(Image *) NULL;
6842 Separate the two lists, junk the null: image.
6844 source=SplitImageList(source->previous);
6845 DeleteImageFromList(&source);
6848 if (source == (Image *) NULL)
6850 (void) ThrowMagickException(exception,GetMagickModule(),
6851 OptionError,"MissingNullSeparator","layers Composite");
6855 Adjust offset with gravity and virtual canvas.
6857 SetGeometry(image,&geometry);
6858 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6859 geometry.width=source->page.width != 0 ? source->page.width :
6861 geometry.height=source->page.height != 0 ? source->page.height :
6863 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6864 image->columns,image->page.height != 0 ? image->page.height :
6865 image->rows,image->gravity,&geometry);
6866 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6867 source=DestroyImageList(source);
6871 if (layers != (Image *) NULL)
6873 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6875 for ( ; image; image=image->next)
6877 AddImageToRegistry(sv,image);
6879 av_push(av,sv_bless(rv,hv));
6882 exception=DestroyExceptionInfo(exception);
6884 SvREFCNT_dec(perl_exception);
6888 InheritPerlException(exception,perl_exception);
6889 exception=DestroyExceptionInfo(exception);
6890 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6891 SvPOK_on(perl_exception);
6892 ST(0)=sv_2mortal(perl_exception);
6897 ###############################################################################
6901 # M a g i c k T o M i m e #
6905 ###############################################################################
6909 MagickToMime(ref,name)
6910 Image::Magick ref=NO_INIT
6919 PERL_UNUSED_VAR(ref);
6920 PERL_UNUSED_VAR(ix);
6921 mime=MagickToMime(name);
6922 RETVAL=newSVpv(mime,0);
6923 mime=(char *) RelinquishMagickMemory(mime);
6929 ###############################################################################
6937 ###############################################################################
6942 Image::Magick ref=NO_INIT
6979 MedianConvolveImage = 36
6985 ReduceNoiseImage = 42
7011 ColorFloodfillImage= 68
7017 CycleColormapImage = 74
7027 MatteFloodfillImage= 84
7035 NumberColorsImage = 92
7045 SignatureImage = 102
7055 TransparentImage = 112
7057 ThresholdImage = 114
7071 DeconstructImage = 130
7073 GaussianBlurImage = 132
7079 UnsharpMaskImage = 138
7081 MotionBlurImage = 140
7083 OrderedDitherImage = 142
7090 AffineTransform = 149
7091 AffineTransformImage = 150
7093 DifferenceImage = 152
7094 AdaptiveThreshold = 153
7095 AdaptiveThresholdImage = 154
7100 BlackThreshold = 159
7101 BlackThresholdImage= 160
7102 WhiteThreshold = 161
7103 WhiteThresholdImage= 162
7105 RadialBlurImage = 164
7107 ThumbnailImage = 166
7117 PosterizeImage = 176
7123 SepiaToneImage = 182
7124 SigmoidalContrast = 183
7125 SigmoidalContrastImage = 184
7130 ContrastStretch = 189
7131 ContrastStretchImage = 190
7136 AdaptiveSharpen = 195
7137 AdaptiveSharpenImage = 196
7139 TransposeImage = 198
7141 TransverseImage = 200
7143 AutoOrientImage = 202
7145 AdaptiveBlurImage = 204
7149 UniqueColorsImage = 208
7150 AdaptiveResize = 209
7151 AdaptiveResizeImage= 210
7155 LinearStretchImage = 214
7157 ColorMatrixImage = 216
7162 FloodfillPaint = 221
7163 FloodfillPaintImage= 222
7169 LiquidRescaleImage = 228
7179 SparseColorImage = 238
7183 SelectiveBlurImage = 242
7187 BlueShiftImage = 246
7188 ForwardFourierTransform = 247
7189 ForwardFourierTransformImage = 248
7190 InverseFourierTransform = 249
7191 InverseFourierTransformImage = 250
7192 ColorDecisionList = 251
7193 ColorDecisionListImage = 252
7195 AutoGammaImage = 254
7197 AutoLevelImage = 256
7199 LevelImageColors = 258
7202 BrightnessContrast = 261
7203 BrightnessContrastImage = 262
7205 MorphologyImage = 264
7211 StatisticImage = 270
7220 attribute_flag[MaxArguments],
7221 message[MaxTextExtent];
7282 argument_list[MaxArguments];
7284 PERL_UNUSED_VAR(ref);
7285 PERL_UNUSED_VAR(ix);
7286 exception=AcquireExceptionInfo();
7287 perl_exception=newSVpv("",0);
7288 reference_vector=NULL;
7292 if (sv_isobject(ST(0)) == 0)
7294 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7298 reference=SvRV(ST(0));
7299 region_info.width=0;
7300 region_info.height=0;
7303 region_image=(Image *) NULL;
7304 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7305 if (ix && (ix != 666))
7308 Called as Method(...)
7311 rp=(&Methods[ix-1]);
7317 Called as Mogrify("Method",...)
7319 attribute=(char *) SvPV(ST(1),na);
7322 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7323 attribute=(char *) SvPV(ST(2),na);
7326 for (rp=Methods; ; rp++)
7328 if (rp >= EndOf(Methods))
7330 ThrowPerlException(exception,OptionError,
7331 "UnrecognizedPerlMagickMethod",attribute);
7334 if (strEQcase(attribute,rp->name))
7340 if (image == (Image *) NULL)
7342 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7345 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7346 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7347 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7364 pp=(Arguments *) NULL;
7372 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7374 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7376 if (strEQcase(attribute,qq->method) > ssize_test)
7379 ssize_test=strEQcase(attribute,qq->method);
7382 if (pp == (Arguments *) NULL)
7384 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7386 goto continue_outer_loop;
7388 al=(&argument_list[pp-rp->arguments]);
7391 case ArrayReference:
7393 if (SvTYPE(sv) != SVt_RV)
7395 (void) FormatLocaleString(message,MaxTextExtent,
7396 "invalid %.60s value",pp->method);
7397 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7398 goto continue_outer_loop;
7400 al->array_reference=SvRV(sv);
7405 al->real_reference=SvNV(sv);
7410 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7413 case ImageReference:
7415 if (!sv_isobject(sv) ||
7416 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7417 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7419 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7425 case IntegerReference:
7427 al->integer_reference=SvIV(sv);
7430 case StringReference:
7432 al->string_reference=(char *) SvPV(sv,al->length);
7433 if (sv_isobject(sv))
7434 al->image_reference=SetupList(aTHX_ SvRV(sv),
7435 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7441 Is a string; look up name.
7443 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7445 al->string_reference=(char *) SvPV(sv,al->length);
7446 al->integer_reference=(-1);
7449 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7450 MagickFalse,SvPV(sv,na));
7451 if (pp->type == MagickChannelOptions)
7452 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7453 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7455 (void) FormatLocaleString(message,MaxTextExtent,
7456 "invalid %.60s value",pp->method);
7457 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7458 goto continue_outer_loop;
7463 attribute_flag[pp-rp->arguments]++;
7464 continue_outer_loop: ;
7466 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7467 pv=reference_vector;
7468 SetGeometryInfo(&geometry_info);
7469 channel=DefaultChannels;
7470 for (next=image; next; next=next->next)
7473 SetGeometry(image,&geometry);
7474 if ((region_info.width*region_info.height) != 0)
7477 image=CropImage(image,®ion_info,exception);
7483 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7484 ThrowPerlException(exception,OptionError,
7485 "UnrecognizedPerlMagickMethod",message);
7488 case 1: /* Comment */
7490 if (attribute_flag[0] == 0)
7491 argument_list[0].string_reference=(char *) NULL;
7492 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7493 info ? info->image_info : (ImageInfo *) NULL,image,
7494 argument_list[0].string_reference,exception),exception);
7499 if (attribute_flag[0] == 0)
7500 argument_list[0].string_reference=(char *) NULL;
7501 (void) SetImageProperty(image,"label",InterpretImageProperties(
7502 info ? info->image_info : (ImageInfo *) NULL,image,
7503 argument_list[0].string_reference,exception),exception);
7506 case 3: /* AddNoise */
7511 if (attribute_flag[0] == 0)
7512 argument_list[0].integer_reference=UniformNoise;
7514 if (attribute_flag[1] != 0)
7515 attenuate=argument_list[1].real_reference;
7516 if (attribute_flag[2] != 0)
7517 channel=(ChannelType) argument_list[2].integer_reference;
7518 channel_mask=SetPixelChannelMask(image,channel);
7519 image=AddNoiseImage(image,(NoiseType)
7520 argument_list[0].integer_reference,attenuate,exception);
7521 if (image != (Image *) NULL)
7522 (void) SetPixelChannelMask(image,channel_mask);
7525 case 4: /* Colorize */
7531 virtual_pixel[MaxPixelChannels];
7533 GetPixelInfo(image,&target);
7534 (void) GetOneVirtualPixel(image,0,0,virtual_pixel,exception);
7535 target.red=virtual_pixel[RedPixelChannel];
7536 target.green=virtual_pixel[GreenPixelChannel];
7537 target.blue=virtual_pixel[BluePixelChannel];
7538 target.alpha=virtual_pixel[AlphaPixelChannel];
7539 if (attribute_flag[0] != 0)
7540 (void) QueryColorCompliance(argument_list[0].string_reference,
7541 AllCompliance,&target,exception);
7542 if (attribute_flag[1] == 0)
7543 argument_list[1].string_reference="100%";
7544 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7548 case 5: /* Border */
7555 if (attribute_flag[0] != 0)
7557 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7558 &geometry,exception);
7559 if ((flags & HeightValue) == 0)
7560 geometry.height=geometry.width;
7562 if (attribute_flag[1] != 0)
7563 geometry.width=argument_list[1].integer_reference;
7564 if (attribute_flag[2] != 0)
7565 geometry.height=argument_list[2].integer_reference;
7566 if (attribute_flag[3] != 0)
7567 QueryColorCompliance(argument_list[3].string_reference,
7568 AllCompliance,&image->border_color,exception);
7569 if (attribute_flag[4] != 0)
7570 QueryColorCompliance(argument_list[4].string_reference,
7571 AllCompliance,&image->border_color,exception);
7572 if (attribute_flag[5] != 0)
7573 QueryColorCompliance(argument_list[5].string_reference,
7574 AllCompliance,&image->border_color,exception);
7575 compose=image->compose;
7576 if (attribute_flag[6] != 0)
7577 compose=(CompositeOperator) argument_list[6].integer_reference;
7578 image=BorderImage(image,&geometry,compose,exception);
7583 if (attribute_flag[0] != 0)
7585 flags=ParseGeometry(argument_list[0].string_reference,
7587 if ((flags & SigmaValue) == 0)
7588 geometry_info.sigma=1.0;
7590 if (attribute_flag[1] != 0)
7591 geometry_info.rho=argument_list[1].real_reference;
7592 if (attribute_flag[2] != 0)
7593 geometry_info.sigma=argument_list[2].real_reference;
7594 if (attribute_flag[3] != 0)
7595 geometry_info.xi=argument_list[3].real_reference;
7596 if (attribute_flag[4] != 0)
7597 channel=(ChannelType) argument_list[4].integer_reference;
7598 channel_mask=SetPixelChannelMask(image,channel);
7599 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7600 geometry_info.xi,exception);
7601 if (image != (Image *) NULL)
7602 (void) SetPixelChannelMask(image,channel_mask);
7607 if (attribute_flag[0] != 0)
7608 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7609 &geometry,exception);
7610 if (attribute_flag[1] != 0)
7611 geometry.width=argument_list[1].integer_reference;
7612 if (attribute_flag[2] != 0)
7613 geometry.height=argument_list[2].integer_reference;
7614 if (attribute_flag[3] != 0)
7615 geometry.x=argument_list[3].integer_reference;
7616 if (attribute_flag[4] != 0)
7617 geometry.y=argument_list[4].integer_reference;
7618 image=ChopImage(image,&geometry,exception);
7623 if (attribute_flag[6] != 0)
7624 image->gravity=(GravityType) argument_list[6].integer_reference;
7625 if (attribute_flag[0] != 0)
7626 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7627 &geometry,exception);
7628 if (attribute_flag[1] != 0)
7629 geometry.width=argument_list[1].integer_reference;
7630 if (attribute_flag[2] != 0)
7631 geometry.height=argument_list[2].integer_reference;
7632 if (attribute_flag[3] != 0)
7633 geometry.x=argument_list[3].integer_reference;
7634 if (attribute_flag[4] != 0)
7635 geometry.y=argument_list[4].integer_reference;
7636 if (attribute_flag[5] != 0)
7637 image->fuzz=StringToDoubleInterval(
7638 argument_list[5].string_reference,(double) QuantumRange+1.0);
7639 image=CropImage(image,&geometry,exception);
7642 case 9: /* Despeckle */
7644 image=DespeckleImage(image,exception);
7649 if (attribute_flag[0] != 0)
7650 geometry_info.rho=argument_list[0].real_reference;
7651 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7655 case 11: /* Emboss */
7657 if (attribute_flag[0] != 0)
7659 flags=ParseGeometry(argument_list[0].string_reference,
7661 if ((flags & SigmaValue) == 0)
7662 geometry_info.sigma=1.0;
7664 if (attribute_flag[1] != 0)
7665 geometry_info.rho=argument_list[1].real_reference;
7666 if (attribute_flag[2] != 0)
7667 geometry_info.sigma=argument_list[2].real_reference;
7668 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7672 case 12: /* Enhance */
7674 image=EnhanceImage(image,exception);
7679 image=FlipImage(image,exception);
7684 image=FlopImage(image,exception);
7687 case 15: /* Frame */
7695 if (attribute_flag[0] != 0)
7697 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7698 &geometry,exception);
7699 if ((flags & HeightValue) == 0)
7700 geometry.height=geometry.width;
7701 frame_info.width=geometry.width;
7702 frame_info.height=geometry.height;
7703 frame_info.outer_bevel=geometry.x;
7704 frame_info.inner_bevel=geometry.y;
7706 if (attribute_flag[1] != 0)
7707 frame_info.width=argument_list[1].integer_reference;
7708 if (attribute_flag[2] != 0)
7709 frame_info.height=argument_list[2].integer_reference;
7710 if (attribute_flag[3] != 0)
7711 frame_info.inner_bevel=argument_list[3].integer_reference;
7712 if (attribute_flag[4] != 0)
7713 frame_info.outer_bevel=argument_list[4].integer_reference;
7714 if (attribute_flag[5] != 0)
7715 QueryColorCompliance(argument_list[5].string_reference,
7716 AllCompliance,&fill_color,exception);
7717 if (attribute_flag[6] != 0)
7718 QueryColorCompliance(argument_list[6].string_reference,
7719 AllCompliance,&fill_color,exception);
7720 frame_info.x=(ssize_t) frame_info.width;
7721 frame_info.y=(ssize_t) frame_info.height;
7722 frame_info.width=image->columns+2*frame_info.x;
7723 frame_info.height=image->rows+2*frame_info.y;
7724 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7725 image->matte_color=fill_color;
7726 compose=image->compose;
7727 if (attribute_flag[7] != 0)
7728 compose=(CompositeOperator) argument_list[7].integer_reference;
7729 image=FrameImage(image,&frame_info,compose,exception);
7732 case 16: /* Implode */
7734 PixelInterpolateMethod
7737 if (attribute_flag[0] == 0)
7738 argument_list[0].real_reference=0.5;
7739 method=UndefinedInterpolatePixel;
7740 if (attribute_flag[1] != 0)
7741 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7742 image=ImplodeImage(image,argument_list[0].real_reference,
7746 case 17: /* Magnify */
7748 image=MagnifyImage(image,exception);
7751 case 18: /* MedianFilter */
7753 if (attribute_flag[0] != 0)
7755 flags=ParseGeometry(argument_list[0].string_reference,
7757 if ((flags & SigmaValue) == 0)
7758 geometry_info.sigma=geometry_info.rho;
7760 if (attribute_flag[1] != 0)
7761 geometry_info.rho=argument_list[1].real_reference;
7762 if (attribute_flag[2] != 0)
7763 geometry_info.sigma=argument_list[2].real_reference;
7764 if (attribute_flag[3] != 0)
7765 channel=(ChannelType) argument_list[3].integer_reference;
7766 channel_mask=SetPixelChannelMask(image,channel);
7767 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7768 (size_t) geometry_info.sigma,exception);
7769 if (image != (Image *) NULL)
7770 (void) SetPixelChannelMask(image,channel_mask);
7773 case 19: /* Minify */
7775 image=MinifyImage(image,exception);
7778 case 20: /* OilPaint */
7780 if (attribute_flag[0] == 0)
7781 argument_list[0].real_reference=0.0;
7782 if (attribute_flag[1] == 0)
7783 argument_list[1].real_reference=1.0;
7784 image=OilPaintImage(image,argument_list[0].real_reference,
7785 argument_list[1].real_reference,exception);
7788 case 21: /* ReduceNoise */
7790 if (attribute_flag[0] != 0)
7792 flags=ParseGeometry(argument_list[0].string_reference,
7794 if ((flags & SigmaValue) == 0)
7795 geometry_info.sigma=1.0;
7797 if (attribute_flag[1] != 0)
7798 geometry_info.rho=argument_list[1].real_reference;
7799 if (attribute_flag[2] != 0)
7800 geometry_info.sigma=argument_list[2].real_reference;
7801 if (attribute_flag[3] != 0)
7802 channel=(ChannelType) argument_list[3].integer_reference;
7803 channel_mask=SetPixelChannelMask(image,channel);
7804 image=StatisticImage(image,NonpeakStatistic,(size_t)
7805 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7806 if (image != (Image *) NULL)
7807 (void) SetPixelChannelMask(image,channel_mask);
7812 if (attribute_flag[0] != 0)
7813 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7814 &geometry,exception);
7815 if (attribute_flag[1] != 0)
7816 geometry.x=argument_list[1].integer_reference;
7817 if (attribute_flag[2] != 0)
7818 geometry.y=argument_list[2].integer_reference;
7819 image=RollImage(image,geometry.x,geometry.y,exception);
7822 case 23: /* Rotate */
7824 if (attribute_flag[0] == 0)
7825 argument_list[0].real_reference=90.0;
7826 if (attribute_flag[1] != 0)
7827 QueryColorCompliance(argument_list[1].string_reference,
7828 AllCompliance,&image->background_color,exception);
7829 if (attribute_flag[2] != 0)
7830 QueryColorCompliance(argument_list[2].string_reference,
7831 AllCompliance,&image->background_color,exception);
7832 if (attribute_flag[3] != 0)
7833 QueryColorCompliance(argument_list[3].string_reference,
7834 AllCompliance,&image->background_color,exception);
7835 image=RotateImage(image,argument_list[0].real_reference,exception);
7838 case 24: /* Sample */
7840 if (attribute_flag[0] != 0)
7841 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7842 &geometry,exception);
7843 if (attribute_flag[1] != 0)
7844 geometry.width=argument_list[1].integer_reference;
7845 if (attribute_flag[2] != 0)
7846 geometry.height=argument_list[2].integer_reference;
7847 image=SampleImage(image,geometry.width,geometry.height,exception);
7850 case 25: /* Scale */
7852 if (attribute_flag[0] != 0)
7853 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7854 &geometry,exception);
7855 if (attribute_flag[1] != 0)
7856 geometry.width=argument_list[1].integer_reference;
7857 if (attribute_flag[2] != 0)
7858 geometry.height=argument_list[2].integer_reference;
7859 image=ScaleImage(image,geometry.width,geometry.height,exception);
7862 case 26: /* Shade */
7864 if (attribute_flag[0] != 0)
7866 flags=ParseGeometry(argument_list[0].string_reference,
7868 if ((flags & SigmaValue) == 0)
7869 geometry_info.sigma=0.0;
7871 if (attribute_flag[1] != 0)
7872 geometry_info.rho=argument_list[1].real_reference;
7873 if (attribute_flag[2] != 0)
7874 geometry_info.sigma=argument_list[2].real_reference;
7875 image=ShadeImage(image,
7876 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7877 geometry_info.rho,geometry_info.sigma,exception);
7880 case 27: /* Sharpen */
7882 if (attribute_flag[0] != 0)
7884 flags=ParseGeometry(argument_list[0].string_reference,
7886 if ((flags & SigmaValue) == 0)
7887 geometry_info.sigma=1.0;
7889 if (attribute_flag[1] != 0)
7890 geometry_info.rho=argument_list[1].real_reference;
7891 if (attribute_flag[2] != 0)
7892 geometry_info.sigma=argument_list[2].real_reference;
7893 if (attribute_flag[3] != 0)
7894 geometry_info.xi=argument_list[3].real_reference;
7895 if (attribute_flag[4] != 0)
7896 channel=(ChannelType) argument_list[4].integer_reference;
7897 channel_mask=SetPixelChannelMask(image,channel);
7898 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7899 geometry_info.xi,exception);
7900 if (image != (Image *) NULL)
7901 (void) SetPixelChannelMask(image,channel_mask);
7904 case 28: /* Shear */
7906 if (attribute_flag[0] != 0)
7908 flags=ParseGeometry(argument_list[0].string_reference,
7910 if ((flags & SigmaValue) == 0)
7911 geometry_info.sigma=geometry_info.rho;
7913 if (attribute_flag[1] != 0)
7914 geometry_info.rho=argument_list[1].real_reference;
7915 if (attribute_flag[2] != 0)
7916 geometry_info.sigma=argument_list[2].real_reference;
7917 if (attribute_flag[3] != 0)
7918 QueryColorCompliance(argument_list[3].string_reference,
7919 AllCompliance,&image->background_color,exception);
7920 if (attribute_flag[4] != 0)
7921 QueryColorCompliance(argument_list[4].string_reference,
7922 AllCompliance,&image->background_color,exception);
7923 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7927 case 29: /* Spread */
7929 PixelInterpolateMethod
7932 if (attribute_flag[0] == 0)
7933 argument_list[0].real_reference=1.0;
7934 method=UndefinedInterpolatePixel;
7935 if (attribute_flag[1] != 0)
7936 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7937 image=SpreadImage(image,argument_list[0].real_reference,method,
7941 case 30: /* Swirl */
7943 PixelInterpolateMethod
7946 if (attribute_flag[0] == 0)
7947 argument_list[0].real_reference=50.0;
7948 method=UndefinedInterpolatePixel;
7949 if (attribute_flag[1] != 0)
7950 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7951 image=SwirlImage(image,argument_list[0].real_reference,
7955 case 31: /* Resize */
7958 if (attribute_flag[0] != 0)
7959 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7960 &geometry,exception);
7961 if (attribute_flag[1] != 0)
7962 geometry.width=argument_list[1].integer_reference;
7963 if (attribute_flag[2] != 0)
7964 geometry.height=argument_list[2].integer_reference;
7965 if (attribute_flag[3] == 0)
7966 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7967 if (attribute_flag[4] != 0)
7968 SetImageArtifact(image,"filter:support",
7969 argument_list[4].string_reference);
7970 if (attribute_flag[5] == 0)
7971 argument_list[5].real_reference=1.0;
7972 image=ResizeImage(image,geometry.width,geometry.height,
7973 (FilterTypes) argument_list[3].integer_reference,
7974 argument_list[5].real_reference,exception);
7977 case 33: /* Annotate */
7982 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7984 if (attribute_flag[0] != 0)
7989 text=InterpretImageProperties(info ? info->image_info :
7990 (ImageInfo *) NULL,image,argument_list[0].string_reference,
7992 (void) CloneString(&draw_info->text,text);
7993 text=DestroyString(text);
7995 if (attribute_flag[1] != 0)
7996 (void) CloneString(&draw_info->font,
7997 argument_list[1].string_reference);
7998 if (attribute_flag[2] != 0)
7999 draw_info->pointsize=argument_list[2].real_reference;
8000 if (attribute_flag[3] != 0)
8001 (void) CloneString(&draw_info->density,
8002 argument_list[3].string_reference);
8003 if (attribute_flag[4] != 0)
8004 (void) QueryColorCompliance(argument_list[4].string_reference,
8005 AllCompliance,&draw_info->undercolor,exception);
8006 if (attribute_flag[5] != 0)
8008 (void) QueryColorCompliance(argument_list[5].string_reference,
8009 AllCompliance,&draw_info->stroke,exception);
8010 if (argument_list[5].image_reference != (Image *) NULL)
8011 draw_info->stroke_pattern=CloneImage(
8012 argument_list[5].image_reference,0,0,MagickTrue,exception);
8014 if (attribute_flag[6] != 0)
8016 (void) QueryColorCompliance(argument_list[6].string_reference,
8017 AllCompliance,&draw_info->fill,exception);
8018 if (argument_list[6].image_reference != (Image *) NULL)
8019 draw_info->fill_pattern=CloneImage(
8020 argument_list[6].image_reference,0,0,MagickTrue,exception);
8022 if (attribute_flag[7] != 0)
8024 (void) CloneString(&draw_info->geometry,
8025 argument_list[7].string_reference);
8026 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8027 &geometry,exception);
8028 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8029 geometry_info.sigma=geometry_info.xi;
8031 if (attribute_flag[8] != 0)
8032 (void) QueryColorCompliance(argument_list[8].string_reference,
8033 AllCompliance,&draw_info->fill,exception);
8034 if (attribute_flag[11] != 0)
8035 draw_info->gravity=(GravityType)
8036 argument_list[11].integer_reference;
8037 if (attribute_flag[25] != 0)
8042 av=(AV *) argument_list[25].array_reference;
8043 if ((av_len(av) != 3) && (av_len(av) != 5))
8045 ThrowPerlException(exception,OptionError,
8046 "affine matrix must have 4 or 6 elements",PackageName);
8049 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8050 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8051 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8052 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8053 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8054 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8056 ThrowPerlException(exception,OptionError,
8057 "affine matrix is singular",PackageName);
8060 if (av_len(av) == 5)
8062 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8063 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8066 for (j=12; j < 17; j++)
8068 if (attribute_flag[j] == 0)
8070 value=argument_list[j].string_reference;
8071 angle=argument_list[j].real_reference;
8072 current=draw_info->affine;
8073 GetAffineMatrix(&affine);
8081 flags=ParseGeometry(value,&geometry_info);
8082 affine.tx=geometry_info.xi;
8083 affine.ty=geometry_info.psi;
8084 if ((flags & PsiValue) == 0)
8085 affine.ty=affine.tx;
8093 flags=ParseGeometry(value,&geometry_info);
8094 affine.sx=geometry_info.rho;
8095 affine.sy=geometry_info.sigma;
8096 if ((flags & SigmaValue) == 0)
8097 affine.sy=affine.sx;
8107 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8108 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8109 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8110 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8118 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8126 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8130 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8131 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8132 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8133 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8134 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8136 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8139 if (attribute_flag[9] == 0)
8140 argument_list[9].real_reference=0.0;
8141 if (attribute_flag[10] == 0)
8142 argument_list[10].real_reference=0.0;
8143 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8146 geometry[MaxTextExtent];
8148 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8149 (double) argument_list[9].real_reference+draw_info->affine.tx,
8150 (double) argument_list[10].real_reference+draw_info->affine.ty);
8151 (void) CloneString(&draw_info->geometry,geometry);
8153 if (attribute_flag[17] != 0)
8154 draw_info->stroke_width=argument_list[17].real_reference;
8155 if (attribute_flag[18] != 0)
8157 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8158 MagickTrue : MagickFalse;
8159 draw_info->stroke_antialias=draw_info->text_antialias;
8161 if (attribute_flag[19] != 0)
8162 (void) CloneString(&draw_info->family,
8163 argument_list[19].string_reference);
8164 if (attribute_flag[20] != 0)
8165 draw_info->style=(StyleType) argument_list[20].integer_reference;
8166 if (attribute_flag[21] != 0)
8167 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8168 if (attribute_flag[22] != 0)
8169 draw_info->weight=argument_list[22].integer_reference;
8170 if (attribute_flag[23] != 0)
8171 draw_info->align=(AlignType) argument_list[23].integer_reference;
8172 if (attribute_flag[24] != 0)
8173 (void) CloneString(&draw_info->encoding,
8174 argument_list[24].string_reference);
8175 if (attribute_flag[25] != 0)
8176 draw_info->fill_pattern=CloneImage(
8177 argument_list[25].image_reference,0,0,MagickTrue,exception);
8178 if (attribute_flag[26] != 0)
8179 draw_info->fill_pattern=CloneImage(
8180 argument_list[26].image_reference,0,0,MagickTrue,exception);
8181 if (attribute_flag[27] != 0)
8182 draw_info->stroke_pattern=CloneImage(
8183 argument_list[27].image_reference,0,0,MagickTrue,exception);
8184 if (attribute_flag[29] != 0)
8185 draw_info->kerning=argument_list[29].real_reference;
8186 if (attribute_flag[30] != 0)
8187 draw_info->interline_spacing=argument_list[30].real_reference;
8188 if (attribute_flag[31] != 0)
8189 draw_info->interword_spacing=argument_list[31].real_reference;
8190 if (attribute_flag[32] != 0)
8191 draw_info->direction=(DirectionType)
8192 argument_list[32].integer_reference;
8193 (void) AnnotateImage(image,draw_info,exception);
8194 draw_info=DestroyDrawInfo(draw_info);
8197 case 34: /* ColorFloodfill */
8209 virtual_pixel[MaxPixelChannels];
8211 draw_info=CloneDrawInfo(info ? info->image_info :
8212 (ImageInfo *) NULL,(DrawInfo *) NULL);
8213 if (attribute_flag[0] != 0)
8214 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8215 &geometry,exception);
8216 if (attribute_flag[1] != 0)
8217 geometry.x=argument_list[1].integer_reference;
8218 if (attribute_flag[2] != 0)
8219 geometry.y=argument_list[2].integer_reference;
8220 if (attribute_flag[3] != 0)
8221 (void) QueryColorCompliance(argument_list[3].string_reference,
8222 AllCompliance,&draw_info->fill,exception);
8223 (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
8225 target.red=virtual_pixel[RedPixelChannel];
8226 target.green=virtual_pixel[GreenPixelChannel];
8227 target.blue=virtual_pixel[BluePixelChannel];
8228 target.alpha=virtual_pixel[AlphaPixelChannel];
8230 if (attribute_flag[4] != 0)
8232 QueryColorCompliance(argument_list[4].string_reference,
8233 AllCompliance,&target,exception);
8236 if (attribute_flag[5] != 0)
8237 image->fuzz=StringToDoubleInterval(
8238 argument_list[5].string_reference,(double) QuantumRange+1.0);
8239 if (attribute_flag[6] != 0)
8240 invert=(MagickBooleanType) argument_list[6].integer_reference;
8241 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8242 geometry.y,invert,exception);
8243 draw_info=DestroyDrawInfo(draw_info);
8246 case 35: /* Composite */
8249 composite_geometry[MaxTextExtent];
8255 compose=OverCompositeOp;
8256 if (attribute_flag[0] != 0)
8257 composite_image=argument_list[0].image_reference;
8260 ThrowPerlException(exception,OptionError,
8261 "CompositeImageRequired",PackageName);
8265 Parameter Handling used for BOTH normal and tiled composition.
8267 if (attribute_flag[1] != 0) /* compose */
8268 compose=(CompositeOperator) argument_list[1].integer_reference;
8269 if (attribute_flag[6] != 0) /* opacity */
8271 if (compose != DissolveCompositeOp)
8272 (void) SetImageAlpha(composite_image,(Quantum)
8273 StringToDoubleInterval(argument_list[6].string_reference,
8274 (double) QuantumRange+1.0),exception);
8296 Handle dissolve composite operator (patch by
8299 (void) CloneString(&image->geometry,
8300 argument_list[6].string_reference);
8301 opacity=(Quantum) StringToDoubleInterval(
8302 argument_list[6].string_reference,(double) QuantumRange+
8304 if (composite_image->matte != MagickTrue)
8305 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8306 composite_view=AcquireCacheView(composite_image);
8307 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8309 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8310 composite_image->columns,1,exception);
8311 for (x=0; x < (ssize_t) composite_image->columns; x++)
8313 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8314 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8316 q+=GetPixelChannels(composite_image);
8318 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8319 if (sync == MagickFalse)
8322 composite_view=DestroyCacheView(composite_view);
8325 if (attribute_flag[9] != 0) /* "color=>" */
8326 QueryColorCompliance(argument_list[9].string_reference,
8327 AllCompliance,&composite_image->background_color,exception);
8328 if (attribute_flag[12] != 0) /* "interpolate=>" */
8329 image->interpolate=(PixelInterpolateMethod)
8330 argument_list[12].integer_reference;
8331 if (attribute_flag[13] != 0) /* "args=>" */
8332 (void) SetImageArtifact(composite_image,"compose:args",
8333 argument_list[13].string_reference);
8334 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8335 (void) SetImageArtifact(composite_image,"compose:args",
8336 argument_list[14].string_reference);
8338 Tiling Composition (with orthogonal rotate).
8340 rotate_image=(Image *) NULL;
8341 if (attribute_flag[8] != 0) /* "rotate=>" */
8346 rotate_image=RotateImage(composite_image,
8347 argument_list[8].real_reference,exception);
8348 if (rotate_image == (Image *) NULL)
8351 if ((attribute_flag[7] != 0) &&
8352 (argument_list[7].integer_reference != 0)) /* tile */
8359 Tile the composite image.
8361 if (attribute_flag[8] != 0) /* "tile=>" */
8362 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8365 (void) SetImageArtifact(composite_image,
8366 "compose:outside-overlay","false");
8367 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8368 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8370 if (attribute_flag[8] != 0) /* rotate */
8371 (void) CompositeImage(image,compose,rotate_image,x,y,
8374 (void) CompositeImage(image,compose,composite_image,x,y,
8377 if (attribute_flag[8] != 0) /* rotate */
8378 rotate_image=DestroyImage(rotate_image);
8382 Parameter Handling used used ONLY for normal composition.
8384 if (attribute_flag[5] != 0) /* gravity */
8385 image->gravity=(GravityType) argument_list[5].integer_reference;
8386 if (attribute_flag[2] != 0) /* geometry offset */
8388 SetGeometry(image,&geometry);
8389 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8391 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8394 if (attribute_flag[3] != 0) /* x offset */
8395 geometry.x=argument_list[3].integer_reference;
8396 if (attribute_flag[4] != 0) /* y offset */
8397 geometry.y=argument_list[4].integer_reference;
8398 if (attribute_flag[10] != 0) /* mask */
8400 if ((image->compose == DisplaceCompositeOp) ||
8401 (image->compose == DistortCompositeOp))
8404 Merge Y displacement into X displacement image.
8406 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8408 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8409 argument_list[10].image_reference,0,0,exception);
8414 Set a blending mask for the composition.
8416 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8417 MagickTrue,exception);
8418 (void) NegateImage(image->mask,MagickFalse,exception);
8421 if (attribute_flag[11] != 0) /* channel */
8422 channel=(ChannelType) argument_list[11].integer_reference;
8424 Composite two images (normal composition).
8426 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8427 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8428 (double) composite_image->rows,(double) geometry.x,(double)
8430 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8432 channel_mask=SetPixelChannelMask(image,channel);
8433 if (attribute_flag[8] == 0) /* no rotate */
8434 CompositeImage(image,compose,composite_image,geometry.x,geometry.y,
8439 Position adjust rotated image then composite.
8441 geometry.x-=(ssize_t) (rotate_image->columns-
8442 composite_image->columns)/2;
8443 geometry.y-=(ssize_t) (rotate_image->rows-
8444 composite_image->rows)/2;
8445 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y,
8447 rotate_image=DestroyImage(rotate_image);
8449 if (attribute_flag[10] != 0) /* mask */
8451 if ((image->compose == DisplaceCompositeOp) ||
8452 (image->compose == DistortCompositeOp))
8453 composite_image=DestroyImage(composite_image);
8455 image->mask=DestroyImage(image->mask);
8457 (void) SetPixelChannelMask(image,channel_mask);
8460 case 36: /* Contrast */
8462 if (attribute_flag[0] == 0)
8463 argument_list[0].integer_reference=0;
8464 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8465 MagickTrue : MagickFalse,exception);
8468 case 37: /* CycleColormap */
8470 if (attribute_flag[0] == 0)
8471 argument_list[0].integer_reference=6;
8472 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8481 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8483 (void) CloneString(&draw_info->primitive,"point");
8484 if (attribute_flag[0] != 0)
8486 if (argument_list[0].integer_reference < 0)
8487 (void) CloneString(&draw_info->primitive,
8488 argument_list[0].string_reference);
8490 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8491 MagickPrimitiveOptions,argument_list[0].integer_reference));
8493 if (attribute_flag[1] != 0)
8495 if (LocaleCompare(draw_info->primitive,"path") == 0)
8497 (void) ConcatenateString(&draw_info->primitive," '");
8498 ConcatenateString(&draw_info->primitive,
8499 argument_list[1].string_reference);
8500 (void) ConcatenateString(&draw_info->primitive,"'");
8504 (void) ConcatenateString(&draw_info->primitive," ");
8505 ConcatenateString(&draw_info->primitive,
8506 argument_list[1].string_reference);
8509 if (attribute_flag[2] != 0)
8511 (void) ConcatenateString(&draw_info->primitive," ");
8512 (void) ConcatenateString(&draw_info->primitive,
8513 CommandOptionToMnemonic(MagickMethodOptions,
8514 argument_list[2].integer_reference));
8516 if (attribute_flag[3] != 0)
8518 (void) QueryColorCompliance(argument_list[3].string_reference,
8519 AllCompliance,&draw_info->stroke,exception);
8520 if (argument_list[3].image_reference != (Image *) NULL)
8521 draw_info->stroke_pattern=CloneImage(
8522 argument_list[3].image_reference,0,0,MagickTrue,exception);
8524 if (attribute_flag[4] != 0)
8526 (void) QueryColorCompliance(argument_list[4].string_reference,
8527 AllCompliance,&draw_info->fill,exception);
8528 if (argument_list[4].image_reference != (Image *) NULL)
8529 draw_info->fill_pattern=CloneImage(
8530 argument_list[4].image_reference,0,0,MagickTrue,exception);
8532 if (attribute_flag[5] != 0)
8533 draw_info->stroke_width=argument_list[5].real_reference;
8534 if (attribute_flag[6] != 0)
8535 (void) CloneString(&draw_info->font,
8536 argument_list[6].string_reference);
8537 if (attribute_flag[7] != 0)
8538 (void) QueryColorCompliance(argument_list[7].string_reference,
8539 AllCompliance,&draw_info->border_color,exception);
8540 if (attribute_flag[8] != 0)
8541 draw_info->affine.tx=argument_list[8].real_reference;
8542 if (attribute_flag[9] != 0)
8543 draw_info->affine.ty=argument_list[9].real_reference;
8544 if (attribute_flag[20] != 0)
8549 av=(AV *) argument_list[20].array_reference;
8550 if ((av_len(av) != 3) && (av_len(av) != 5))
8552 ThrowPerlException(exception,OptionError,
8553 "affine matrix must have 4 or 6 elements",PackageName);
8556 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8557 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8558 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8559 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8560 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8561 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8563 ThrowPerlException(exception,OptionError,
8564 "affine matrix is singular",PackageName);
8567 if (av_len(av) == 5)
8569 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8570 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8573 for (j=10; j < 15; j++)
8575 if (attribute_flag[j] == 0)
8577 value=argument_list[j].string_reference;
8578 angle=argument_list[j].real_reference;
8579 current=draw_info->affine;
8580 GetAffineMatrix(&affine);
8588 flags=ParseGeometry(value,&geometry_info);
8589 affine.tx=geometry_info.xi;
8590 affine.ty=geometry_info.psi;
8591 if ((flags & PsiValue) == 0)
8592 affine.ty=affine.tx;
8600 flags=ParseGeometry(value,&geometry_info);
8601 affine.sx=geometry_info.rho;
8602 affine.sy=geometry_info.sigma;
8603 if ((flags & SigmaValue) == 0)
8604 affine.sy=affine.sx;
8614 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8615 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8616 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8617 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8625 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8633 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8637 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8638 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8639 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8640 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8641 draw_info->affine.tx=
8642 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8643 draw_info->affine.ty=
8644 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8646 if (attribute_flag[15] != 0)
8647 draw_info->fill_pattern=CloneImage(
8648 argument_list[15].image_reference,0,0,MagickTrue,exception);
8649 if (attribute_flag[16] != 0)
8650 draw_info->pointsize=argument_list[16].real_reference;
8651 if (attribute_flag[17] != 0)
8653 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8654 ? MagickTrue : MagickFalse;
8655 draw_info->text_antialias=draw_info->stroke_antialias;
8657 if (attribute_flag[18] != 0)
8658 (void) CloneString(&draw_info->density,
8659 argument_list[18].string_reference);
8660 if (attribute_flag[19] != 0)
8661 draw_info->stroke_width=argument_list[19].real_reference;
8662 if (attribute_flag[21] != 0)
8663 draw_info->dash_offset=argument_list[21].real_reference;
8664 if (attribute_flag[22] != 0)
8669 av=(AV *) argument_list[22].array_reference;
8670 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8671 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8672 if (draw_info->dash_pattern != (double *) NULL)
8674 for (i=0; i <= av_len(av); i++)
8675 draw_info->dash_pattern[i]=(double)
8676 SvNV(*(av_fetch(av,i,0)));
8677 draw_info->dash_pattern[i]=0.0;
8680 if (attribute_flag[23] != 0)
8681 image->interpolate=(PixelInterpolateMethod)
8682 argument_list[23].integer_reference;
8683 if ((attribute_flag[24] != 0) &&
8684 (draw_info->fill_pattern != (Image *) NULL))
8685 flags=ParsePageGeometry(draw_info->fill_pattern,
8686 argument_list[24].string_reference,
8687 &draw_info->fill_pattern->tile_offset,exception);
8688 if (attribute_flag[25] != 0)
8690 (void) ConcatenateString(&draw_info->primitive," '");
8691 (void) ConcatenateString(&draw_info->primitive,
8692 argument_list[25].string_reference);
8693 (void) ConcatenateString(&draw_info->primitive,"'");
8695 if (attribute_flag[26] != 0)
8696 draw_info->fill_pattern=CloneImage(
8697 argument_list[26].image_reference,0,0,MagickTrue,exception);
8698 if (attribute_flag[27] != 0)
8699 draw_info->stroke_pattern=CloneImage(
8700 argument_list[27].image_reference,0,0,MagickTrue,exception);
8701 if (attribute_flag[28] != 0)
8702 (void) CloneString(&draw_info->primitive,
8703 argument_list[28].string_reference);
8704 if (attribute_flag[29] != 0)
8705 draw_info->kerning=argument_list[29].real_reference;
8706 if (attribute_flag[30] != 0)
8707 draw_info->interline_spacing=argument_list[30].real_reference;
8708 if (attribute_flag[31] != 0)
8709 draw_info->interword_spacing=argument_list[31].real_reference;
8710 if (attribute_flag[32] != 0)
8711 draw_info->direction=(DirectionType)
8712 argument_list[32].integer_reference;
8713 DrawImage(image,draw_info,exception);
8714 draw_info=DestroyDrawInfo(draw_info);
8717 case 39: /* Equalize */
8719 if (attribute_flag[0] != 0)
8720 channel=(ChannelType) argument_list[0].integer_reference;
8721 channel_mask=SetPixelChannelMask(image,channel);
8722 EqualizeImage(image,exception);
8723 (void) SetPixelChannelMask(image,channel_mask);
8726 case 40: /* Gamma */
8728 if (attribute_flag[1] != 0)
8729 channel=(ChannelType) argument_list[1].integer_reference;
8730 if (attribute_flag[2] == 0)
8731 argument_list[2].real_reference=1.0;
8732 if (attribute_flag[3] == 0)
8733 argument_list[3].real_reference=1.0;
8734 if (attribute_flag[4] == 0)
8735 argument_list[4].real_reference=1.0;
8736 if (attribute_flag[0] == 0)
8738 (void) FormatLocaleString(message,MaxTextExtent,
8739 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8740 (double) argument_list[3].real_reference,
8741 (double) argument_list[4].real_reference);
8742 argument_list[0].string_reference=message;
8744 (void) GammaImage(image,StringToDouble(
8745 argument_list[0].string_reference,(char **) NULL),exception);
8753 if (attribute_flag[0] == 0)
8755 ThrowPerlException(exception,OptionError,"MapImageRequired",
8759 quantize_info=AcquireQuantizeInfo(info->image_info);
8760 if (attribute_flag[1] != 0)
8761 quantize_info->dither=(MagickBooleanType)
8762 argument_list[1].integer_reference;
8763 if (attribute_flag[2] != 0)
8764 quantize_info->dither_method=(DitherMethod)
8765 argument_list[2].integer_reference;
8766 (void) RemapImages(quantize_info,image,
8767 argument_list[0].image_reference,exception);
8768 quantize_info=DestroyQuantizeInfo(quantize_info);
8771 case 42: /* MatteFloodfill */
8783 virtual_pixel[MaxPixelChannels];
8785 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8787 if (attribute_flag[0] != 0)
8788 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8789 &geometry,exception);
8790 if (attribute_flag[1] != 0)
8791 geometry.x=argument_list[1].integer_reference;
8792 if (attribute_flag[2] != 0)
8793 geometry.y=argument_list[2].integer_reference;
8794 if (image->matte == MagickFalse)
8795 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8796 (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
8798 target.red=virtual_pixel[RedPixelChannel];
8799 target.green=virtual_pixel[GreenPixelChannel];
8800 target.blue=virtual_pixel[BluePixelChannel];
8801 target.alpha=virtual_pixel[AlphaPixelChannel];
8802 if (attribute_flag[4] != 0)
8803 QueryColorCompliance(argument_list[4].string_reference,
8804 AllCompliance,&target,exception);
8805 if (attribute_flag[3] != 0)
8806 target.alpha=StringToDoubleInterval(
8807 argument_list[3].string_reference,(double) (double) QuantumRange+
8809 if (attribute_flag[5] != 0)
8810 image->fuzz=StringToDoubleInterval(
8811 argument_list[5].string_reference,(double) QuantumRange+1.0);
8813 if (attribute_flag[6] != 0)
8814 invert=(MagickBooleanType) argument_list[6].integer_reference;
8815 channel_mask=SetPixelChannelMask(image,AlphaChannel);
8816 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8817 geometry.y,invert,exception);
8818 (void) SetPixelChannelMask(image,channel_mask);
8819 draw_info=DestroyDrawInfo(draw_info);
8822 case 43: /* Modulate */
8825 modulate[MaxTextExtent];
8827 geometry_info.rho=100.0;
8828 geometry_info.sigma=100.0;
8829 geometry_info.xi=100.0;
8830 if (attribute_flag[0] != 0)
8831 (void)ParseGeometry(argument_list[0].string_reference,
8833 if (attribute_flag[1] != 0)
8834 geometry_info.xi=argument_list[1].real_reference;
8835 if (attribute_flag[2] != 0)
8836 geometry_info.sigma=argument_list[2].real_reference;
8837 if (attribute_flag[3] != 0)
8839 geometry_info.sigma=argument_list[3].real_reference;
8840 SetImageArtifact(image,"modulate:colorspace","HWB");
8842 if (attribute_flag[4] != 0)
8844 geometry_info.rho=argument_list[4].real_reference;
8845 SetImageArtifact(image,"modulate:colorspace","HSB");
8847 if (attribute_flag[5] != 0)
8849 geometry_info.sigma=argument_list[5].real_reference;
8850 SetImageArtifact(image,"modulate:colorspace","HSL");
8852 if (attribute_flag[6] != 0)
8854 geometry_info.rho=argument_list[6].real_reference;
8855 SetImageArtifact(image,"modulate:colorspace","HWB");
8857 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8858 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8859 (void) ModulateImage(image,modulate,exception);
8862 case 44: /* Negate */
8864 if (attribute_flag[0] == 0)
8865 argument_list[0].integer_reference=0;
8866 if (attribute_flag[1] != 0)
8867 channel=(ChannelType) argument_list[1].integer_reference;
8868 channel_mask=SetPixelChannelMask(image,channel);
8869 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8870 MagickTrue : MagickFalse,exception);
8871 (void) SetPixelChannelMask(image,channel_mask);
8874 case 45: /* Normalize */
8876 if (attribute_flag[0] != 0)
8877 channel=(ChannelType) argument_list[0].integer_reference;
8878 channel_mask=SetPixelChannelMask(image,channel);
8879 NormalizeImage(image,exception);
8880 (void) SetPixelChannelMask(image,channel_mask);
8883 case 46: /* NumberColors */
8885 case 47: /* Opaque */
8894 (void) QueryColorCompliance("none",AllCompliance,&target,
8896 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
8898 if (attribute_flag[0] != 0)
8899 (void) QueryColorCompliance(argument_list[0].string_reference,
8900 AllCompliance,&target,exception);
8901 if (attribute_flag[1] != 0)
8902 (void) QueryColorCompliance(argument_list[1].string_reference,
8903 AllCompliance,&fill_color,exception);
8904 if (attribute_flag[2] != 0)
8905 image->fuzz=StringToDoubleInterval(
8906 argument_list[2].string_reference,(double) QuantumRange+1.0);
8907 if (attribute_flag[3] != 0)
8908 channel=(ChannelType) argument_list[3].integer_reference;
8910 if (attribute_flag[4] != 0)
8911 invert=(MagickBooleanType) argument_list[4].integer_reference;
8912 channel_mask=SetPixelChannelMask(image,channel);
8913 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
8914 (void) SetPixelChannelMask(image,channel_mask);
8917 case 48: /* Quantize */
8922 quantize_info=AcquireQuantizeInfo(info->image_info);
8923 if (attribute_flag[0] != 0)
8924 quantize_info->number_colors=(size_t)
8925 argument_list[0].integer_reference;
8926 if (attribute_flag[1] != 0)
8927 quantize_info->tree_depth=(size_t)
8928 argument_list[1].integer_reference;
8929 if (attribute_flag[2] != 0)
8930 quantize_info->colorspace=(ColorspaceType)
8931 argument_list[2].integer_reference;
8932 if (attribute_flag[3] != 0)
8933 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8934 MagickTrue : MagickFalse;
8935 if (attribute_flag[4] != 0)
8936 quantize_info->measure_error=
8937 argument_list[4].integer_reference != 0 ? MagickTrue :
8939 if (attribute_flag[5] != 0)
8940 (void) QueryColorCompliance(argument_list[5].string_reference,
8941 AllCompliance,&image->transparent_color,exception);
8942 if (attribute_flag[5] && argument_list[5].integer_reference)
8944 (void) QuantizeImages(quantize_info,image,exception);
8947 if (attribute_flag[6] != 0)
8948 quantize_info->dither_method=(DitherMethod)
8949 argument_list[6].integer_reference;
8950 if ((image->storage_class == DirectClass) ||
8951 (image->colors > quantize_info->number_colors) ||
8952 (quantize_info->colorspace == GRAYColorspace))
8953 (void) QuantizeImage(quantize_info,image,exception);
8955 CompressImageColormap(image,exception);
8956 quantize_info=DestroyQuantizeInfo(quantize_info);
8959 case 49: /* Raise */
8961 if (attribute_flag[0] != 0)
8962 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8963 &geometry,exception);
8964 if (attribute_flag[1] != 0)
8965 geometry.width=argument_list[1].integer_reference;
8966 if (attribute_flag[2] != 0)
8967 geometry.height=argument_list[2].integer_reference;
8968 if (attribute_flag[3] == 0)
8969 argument_list[3].integer_reference=1;
8970 (void) RaiseImage(image,&geometry,
8971 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8975 case 50: /* Segment */
8982 smoothing_threshold;
8987 cluster_threshold=1.0;
8988 smoothing_threshold=1.5;
8989 colorspace=RGBColorspace;
8990 verbose=MagickFalse;
8991 if (attribute_flag[0] != 0)
8993 flags=ParseGeometry(argument_list[0].string_reference,
8995 cluster_threshold=geometry_info.rho;
8996 if (flags & SigmaValue)
8997 smoothing_threshold=geometry_info.sigma;
8999 if (attribute_flag[1] != 0)
9000 cluster_threshold=argument_list[1].real_reference;
9001 if (attribute_flag[2] != 0)
9002 smoothing_threshold=argument_list[2].real_reference;
9003 if (attribute_flag[3] != 0)
9004 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9005 if (attribute_flag[4] != 0)
9006 verbose=argument_list[4].integer_reference != 0 ?
9007 MagickTrue : MagickFalse;
9008 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9009 smoothing_threshold,exception);
9012 case 51: /* Signature */
9014 (void) SignatureImage(image,exception);
9017 case 52: /* Solarize */
9019 geometry_info.rho=QuantumRange/2.0;
9020 if (attribute_flag[0] != 0)
9021 flags=ParseGeometry(argument_list[0].string_reference,
9023 if (attribute_flag[1] != 0)
9024 geometry_info.rho=StringToDoubleInterval(
9025 argument_list[1].string_reference,(double) QuantumRange+1.0);
9026 (void) SolarizeImage(image,geometry_info.rho,exception);
9031 (void) SyncImage(image,exception);
9034 case 54: /* Texture */
9036 if (attribute_flag[0] == 0)
9038 TextureImage(image,argument_list[0].image_reference,exception);
9041 case 55: /* Evalute */
9043 MagickEvaluateOperator
9046 op=SetEvaluateOperator;
9047 if (attribute_flag[0] == MagickFalse)
9048 argument_list[0].real_reference=0.0;
9049 if (attribute_flag[1] != MagickFalse)
9050 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9051 if (attribute_flag[2] != MagickFalse)
9052 channel=(ChannelType) argument_list[2].integer_reference;
9053 channel_mask=SetPixelChannelMask(image,channel);
9054 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9056 (void) SetPixelChannelMask(image,channel_mask);
9059 case 56: /* Transparent */
9070 (void) QueryColorCompliance("none",AllCompliance,&target,
9072 if (attribute_flag[0] != 0)
9073 (void) QueryColorCompliance(argument_list[0].string_reference,
9074 AllCompliance,&target,exception);
9075 opacity=TransparentAlpha;
9076 if (attribute_flag[1] != 0)
9077 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9078 (double) QuantumRange+1.0);
9079 if (attribute_flag[2] != 0)
9080 image->fuzz=StringToDoubleInterval(
9081 argument_list[2].string_reference,(double) QuantumRange+1.0);
9082 if (attribute_flag[3] == 0)
9083 argument_list[3].integer_reference=0;
9085 if (attribute_flag[3] != 0)
9086 invert=(MagickBooleanType) argument_list[3].integer_reference;
9087 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9091 case 57: /* Threshold */
9096 if (attribute_flag[0] == 0)
9097 argument_list[0].string_reference="50%";
9098 if (attribute_flag[1] != 0)
9099 channel=(ChannelType) argument_list[1].integer_reference;
9100 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9101 (double) QuantumRange+1.0);
9102 channel_mask=SetPixelChannelMask(image,channel);
9103 (void) BilevelImage(image,threshold,exception);
9104 (void) SetPixelChannelMask(image,channel_mask);
9107 case 58: /* Charcoal */
9109 if (attribute_flag[0] != 0)
9111 flags=ParseGeometry(argument_list[0].string_reference,
9113 if ((flags & SigmaValue) == 0)
9114 geometry_info.sigma=1.0;
9116 if (attribute_flag[1] != 0)
9117 geometry_info.rho=argument_list[1].real_reference;
9118 if (attribute_flag[2] != 0)
9119 geometry_info.sigma=argument_list[2].real_reference;
9120 if (attribute_flag[3] != 0)
9121 geometry_info.xi=argument_list[3].real_reference;
9122 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9123 geometry_info.xi,exception);
9128 if (attribute_flag[0] != 0)
9129 image->fuzz=StringToDoubleInterval(
9130 argument_list[0].string_reference,(double) QuantumRange+1.0);
9131 image=TrimImage(image,exception);
9136 PixelInterpolateMethod
9139 if (attribute_flag[0] != 0)
9141 flags=ParseGeometry(argument_list[0].string_reference,
9143 if ((flags & SigmaValue) == 0)
9144 geometry_info.sigma=1.0;
9146 if (attribute_flag[1] != 0)
9147 geometry_info.rho=argument_list[1].real_reference;
9148 if (attribute_flag[2] != 0)
9149 geometry_info.sigma=argument_list[2].real_reference;
9150 method=UndefinedInterpolatePixel;
9151 if (attribute_flag[3] != 0)
9152 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9153 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9157 case 61: /* Separate */
9159 if (attribute_flag[0] != 0)
9160 channel=(ChannelType) argument_list[0].integer_reference;
9161 channel_mask=SetPixelChannelMask(image,channel);
9162 (void) SeparateImage(image,exception);
9163 (void) SetPixelChannelMask(image,channel_mask);
9166 case 63: /* Stereo */
9168 if (attribute_flag[0] == 0)
9170 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9174 if (attribute_flag[1] != 0)
9175 geometry.x=argument_list[1].integer_reference;
9176 if (attribute_flag[2] != 0)
9177 geometry.y=argument_list[2].integer_reference;
9178 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9179 geometry.x,geometry.y,exception);
9182 case 64: /* Stegano */
9184 if (attribute_flag[0] == 0)
9186 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9190 if (attribute_flag[1] == 0)
9191 argument_list[1].integer_reference=0;
9192 image->offset=argument_list[1].integer_reference;
9193 image=SteganoImage(image,argument_list[0].image_reference,exception);
9196 case 65: /* Deconstruct */
9198 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9201 case 66: /* GaussianBlur */
9203 if (attribute_flag[0] != 0)
9205 flags=ParseGeometry(argument_list[0].string_reference,
9207 if ((flags & SigmaValue) == 0)
9208 geometry_info.sigma=1.0;
9210 if (attribute_flag[1] != 0)
9211 geometry_info.rho=argument_list[1].real_reference;
9212 if (attribute_flag[2] != 0)
9213 geometry_info.sigma=argument_list[2].real_reference;
9214 if (attribute_flag[3] != 0)
9215 geometry_info.xi=argument_list[3].real_reference;
9216 if (attribute_flag[4] != 0)
9217 channel=(ChannelType) argument_list[4].integer_reference;
9218 channel_mask=SetPixelChannelMask(image,channel);
9219 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9220 geometry_info.xi,exception);
9221 if (image != (Image *) NULL)
9222 (void) SetPixelChannelMask(image,channel_mask);
9225 case 67: /* Convolve */
9230 kernel=(KernelInfo *) NULL;
9231 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9233 if (attribute_flag[0] != 0)
9241 kernel=AcquireKernelInfo((const char *) NULL);
9242 if (kernel == (KernelInfo *) NULL)
9244 av=(AV *) argument_list[0].array_reference;
9245 order=(size_t) sqrt(av_len(av)+1);
9246 kernel->width=order;
9247 kernel->height=order;
9248 kernel->values=(double *) AcquireAlignedMemory(order,order*
9249 sizeof(*kernel->values));
9250 if (kernel->values == (double *) NULL)
9252 kernel=DestroyKernelInfo(kernel);
9253 ThrowPerlException(exception,ResourceLimitFatalError,
9254 "MemoryAllocationFailed",PackageName);
9257 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9258 kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
9259 for ( ; j < (ssize_t) (order*order); j++)
9260 kernel->values[j]=0.0;
9262 if (attribute_flag[1] != 0)
9263 channel=(ChannelType) argument_list[1].integer_reference;
9264 if (attribute_flag[2] != 0)
9265 image->bias=StringToDoubleInterval(
9266 argument_list[2].string_reference,(double) QuantumRange+1.0);
9267 if (attribute_flag[3] != 0)
9269 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9270 if (kernel == (KernelInfo *) NULL)
9273 channel_mask=SetPixelChannelMask(image,channel);
9274 kernel->bias=image->bias;
9275 image=ConvolveImage(image,kernel,exception);
9276 if (image != (Image *) NULL)
9277 (void) SetPixelChannelMask(image,channel_mask);
9278 kernel=DestroyKernelInfo(kernel);
9281 case 68: /* Profile */
9296 if (attribute_flag[0] != 0)
9297 name=argument_list[0].string_reference;
9298 if (attribute_flag[2] != 0)
9299 image->rendering_intent=(RenderingIntent)
9300 argument_list[2].integer_reference;
9301 if (attribute_flag[3] != 0)
9302 image->black_point_compensation=
9303 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9304 if (attribute_flag[1] != 0)
9306 if (argument_list[1].length == 0)
9309 Remove a profile from the image.
9311 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9316 Associate user supplied profile with the image.
9318 profile=AcquireStringInfo(argument_list[1].length);
9319 SetStringInfoDatum(profile,(const unsigned char *)
9320 argument_list[1].string_reference);
9321 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9322 (size_t) GetStringInfoLength(profile),exception);
9323 profile=DestroyStringInfo(profile);
9327 Associate a profile with the image.
9330 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9331 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9332 profile_image=ReadImages(profile_info,exception);
9333 if (profile_image == (Image *) NULL)
9335 ResetImageProfileIterator(profile_image);
9336 name=GetNextImageProfile(profile_image);
9337 while (name != (const char *) NULL)
9342 profile=GetImageProfile(profile_image,name);
9343 if (profile != (const StringInfo *) NULL)
9344 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9345 (size_t) GetStringInfoLength(profile),exception);
9346 name=GetNextImageProfile(profile_image);
9348 profile_image=DestroyImage(profile_image);
9349 profile_info=DestroyImageInfo(profile_info);
9352 case 69: /* UnsharpMask */
9354 if (attribute_flag[0] != 0)
9356 flags=ParseGeometry(argument_list[0].string_reference,
9358 if ((flags & SigmaValue) == 0)
9359 geometry_info.sigma=1.0;
9360 if ((flags & XiValue) == 0)
9361 geometry_info.xi=1.0;
9362 if ((flags & PsiValue) == 0)
9363 geometry_info.psi=0.5;
9365 if (attribute_flag[1] != 0)
9366 geometry_info.rho=argument_list[1].real_reference;
9367 if (attribute_flag[2] != 0)
9368 geometry_info.sigma=argument_list[2].real_reference;
9369 if (attribute_flag[3] != 0)
9370 geometry_info.xi=argument_list[3].real_reference;
9371 if (attribute_flag[4] != 0)
9372 geometry_info.psi=argument_list[4].real_reference;
9373 if (attribute_flag[5] != 0)
9374 channel=(ChannelType) argument_list[5].integer_reference;
9375 channel_mask=SetPixelChannelMask(image,channel);
9376 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9377 geometry_info.xi,geometry_info.psi,exception);
9378 if (image != (Image *) NULL)
9379 (void) SetPixelChannelMask(image,channel_mask);
9382 case 70: /* MotionBlur */
9384 if (attribute_flag[0] != 0)
9386 flags=ParseGeometry(argument_list[0].string_reference,
9388 if ((flags & SigmaValue) == 0)
9389 geometry_info.sigma=1.0;
9390 if ((flags & XiValue) == 0)
9391 geometry_info.xi=1.0;
9393 if (attribute_flag[1] != 0)
9394 geometry_info.rho=argument_list[1].real_reference;
9395 if (attribute_flag[2] != 0)
9396 geometry_info.sigma=argument_list[2].real_reference;
9397 if (attribute_flag[3] != 0)
9398 geometry_info.xi=argument_list[3].real_reference;
9399 if (attribute_flag[4] != 0)
9400 geometry_info.psi=argument_list[4].real_reference;
9401 if (attribute_flag[5] != 0)
9402 channel=(ChannelType) argument_list[5].integer_reference;
9403 channel_mask=SetPixelChannelMask(image,channel);
9404 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9405 geometry_info.xi,geometry_info.psi,exception);
9406 if (image != (Image *) NULL)
9407 (void) SetPixelChannelMask(image,channel_mask);
9410 case 71: /* OrderedDither */
9412 if (attribute_flag[0] == 0)
9413 argument_list[0].string_reference="o8x8";
9414 if (attribute_flag[1] != 0)
9415 channel=(ChannelType) argument_list[1].integer_reference;
9416 channel_mask=SetPixelChannelMask(image,channel);
9417 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9419 (void) SetPixelChannelMask(image,channel_mask);
9422 case 72: /* Shave */
9424 if (attribute_flag[0] != 0)
9425 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9426 &geometry,exception);
9427 if (attribute_flag[1] != 0)
9428 geometry.width=argument_list[1].integer_reference;
9429 if (attribute_flag[2] != 0)
9430 geometry.height=argument_list[2].integer_reference;
9431 image=ShaveImage(image,&geometry,exception);
9434 case 73: /* Level */
9442 white_point=(MagickRealType) image->columns*image->rows;
9444 if (attribute_flag[0] != 0)
9446 flags=ParseGeometry(argument_list[0].string_reference,
9448 black_point=geometry_info.rho;
9449 if ((flags & SigmaValue) != 0)
9450 white_point=geometry_info.sigma;
9451 if ((flags & XiValue) != 0)
9452 gamma=geometry_info.xi;
9453 if ((flags & PercentValue) != 0)
9455 black_point*=(double) (QuantumRange/100.0);
9456 white_point*=(double) (QuantumRange/100.0);
9458 if ((flags & SigmaValue) == 0)
9459 white_point=(double) QuantumRange-black_point;
9461 if (attribute_flag[1] != 0)
9462 black_point=argument_list[1].real_reference;
9463 if (attribute_flag[2] != 0)
9464 white_point=argument_list[2].real_reference;
9465 if (attribute_flag[3] != 0)
9466 gamma=argument_list[3].real_reference;
9467 if (attribute_flag[4] != 0)
9468 channel=(ChannelType) argument_list[4].integer_reference;
9469 if (attribute_flag[5] != 0)
9471 argument_list[0].real_reference=argument_list[5].real_reference;
9472 attribute_flag[0]=attribute_flag[5];
9474 channel_mask=SetPixelChannelMask(image,channel);
9475 (void) LevelImage(image,black_point,white_point,gamma,exception);
9476 (void) SetPixelChannelMask(image,channel_mask);
9481 if (attribute_flag[0] == 0)
9482 argument_list[0].string_reference="#1";
9483 if (attribute_flag[1] == 0)
9484 argument_list[1].integer_reference=MagickTrue;
9485 (void) ClipImagePath(image,argument_list[0].string_reference,
9486 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9490 case 75: /* AffineTransform */
9495 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9497 if (attribute_flag[0] != 0)
9502 av=(AV *) argument_list[0].array_reference;
9503 if ((av_len(av) != 3) && (av_len(av) != 5))
9505 ThrowPerlException(exception,OptionError,
9506 "affine matrix must have 4 or 6 elements",PackageName);
9509 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9510 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9511 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9512 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9513 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9514 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9516 ThrowPerlException(exception,OptionError,
9517 "affine matrix is singular",PackageName);
9520 if (av_len(av) == 5)
9522 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9523 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9526 for (j=1; j < 6; j++)
9528 if (attribute_flag[j] == 0)
9530 value=argument_list[j].string_reference;
9531 angle=argument_list[j].real_reference;
9532 current=draw_info->affine;
9533 GetAffineMatrix(&affine);
9541 flags=ParseGeometry(value,&geometry_info);
9542 affine.tx=geometry_info.xi;
9543 affine.ty=geometry_info.psi;
9544 if ((flags & PsiValue) == 0)
9545 affine.ty=affine.tx;
9553 flags=ParseGeometry(value,&geometry_info);
9554 affine.sx=geometry_info.rho;
9555 affine.sy=geometry_info.sigma;
9556 if ((flags & SigmaValue) == 0)
9557 affine.sy=affine.sx;
9567 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9568 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9569 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9570 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9578 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9586 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9590 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9591 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9592 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9593 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9594 draw_info->affine.tx=
9595 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9596 draw_info->affine.ty=
9597 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9599 if (attribute_flag[6] != 0)
9600 image->interpolate=(PixelInterpolateMethod)
9601 argument_list[6].integer_reference;
9602 if (attribute_flag[7] != 0)
9603 QueryColorCompliance(argument_list[7].string_reference,
9604 AllCompliance,&image->background_color,exception);
9605 image=AffineTransformImage(image,&draw_info->affine,exception);
9606 draw_info=DestroyDrawInfo(draw_info);
9609 case 76: /* Difference */
9611 if (attribute_flag[0] == 0)
9613 ThrowPerlException(exception,OptionError,
9614 "ReferenceImageRequired",PackageName);
9617 if (attribute_flag[1] != 0)
9618 image->fuzz=StringToDoubleInterval(
9619 argument_list[1].string_reference,(double) QuantumRange+1.0);
9620 (void) IsImagesEqual(image,argument_list[0].image_reference,
9624 case 77: /* AdaptiveThreshold */
9626 if (attribute_flag[0] != 0)
9628 flags=ParseGeometry(argument_list[0].string_reference,
9630 if ((flags & PercentValue) != 0)
9631 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9633 if (attribute_flag[1] != 0)
9634 geometry_info.rho=argument_list[1].integer_reference;
9635 if (attribute_flag[2] != 0)
9636 geometry_info.sigma=argument_list[2].integer_reference;
9637 if (attribute_flag[3] != 0)
9638 geometry_info.xi=argument_list[3].integer_reference;;
9639 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9640 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9643 case 78: /* Resample */
9649 if (attribute_flag[0] != 0)
9651 flags=ParseGeometry(argument_list[0].string_reference,
9653 if ((flags & SigmaValue) == 0)
9654 geometry_info.sigma=geometry_info.rho;
9656 if (attribute_flag[1] != 0)
9657 geometry_info.rho=argument_list[1].real_reference;
9658 if (attribute_flag[2] != 0)
9659 geometry_info.sigma=argument_list[2].real_reference;
9660 if (attribute_flag[3] == 0)
9661 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9662 if (attribute_flag[4] == 0)
9663 SetImageArtifact(image,"filter:support",
9664 argument_list[4].string_reference);
9665 if (attribute_flag[5] != 0)
9666 argument_list[5].real_reference=1.0;
9667 width=(size_t) (geometry_info.rho*image->columns/
9668 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9669 height=(size_t) (geometry_info.sigma*image->rows/
9670 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9671 image=ResizeImage(image,width,height,(FilterTypes)
9672 argument_list[3].integer_reference,argument_list[5].real_reference,
9674 if (image != (Image *) NULL)
9676 image->resolution.x=geometry_info.rho;
9677 image->resolution.y=geometry_info.sigma;
9681 case 79: /* Describe */
9683 if (attribute_flag[0] == 0)
9684 argument_list[0].file_reference=(FILE *) NULL;
9685 if (attribute_flag[1] != 0)
9686 (void) SetImageArtifact(image,"identify:features",
9687 argument_list[1].string_reference);
9688 (void) IdentifyImage(image,argument_list[0].file_reference,
9689 MagickTrue,exception);
9692 case 80: /* BlackThreshold */
9694 if (attribute_flag[0] == 0)
9695 argument_list[0].string_reference="50%";
9696 if (attribute_flag[2] != 0)
9697 channel=(ChannelType) argument_list[2].integer_reference;
9698 channel_mask=SetPixelChannelMask(image,channel);
9699 BlackThresholdImage(image,argument_list[0].string_reference,
9701 (void) SetPixelChannelMask(image,channel_mask);
9704 case 81: /* WhiteThreshold */
9706 if (attribute_flag[0] == 0)
9707 argument_list[0].string_reference="50%";
9708 if (attribute_flag[2] != 0)
9709 channel=(ChannelType) argument_list[2].integer_reference;
9710 channel_mask=SetPixelChannelMask(image,channel);
9711 WhiteThresholdImage(image,argument_list[0].string_reference,
9713 (void) SetPixelChannelMask(image,channel_mask);
9716 case 82: /* RadialBlur */
9718 if (attribute_flag[0] != 0)
9720 flags=ParseGeometry(argument_list[0].string_reference,
9723 if (attribute_flag[1] != 0)
9724 geometry_info.rho=argument_list[1].real_reference;
9725 if (attribute_flag[2] != 0)
9726 geometry_info.sigma=argument_list[2].real_reference;
9727 if (attribute_flag[3] != 0)
9728 channel=(ChannelType) argument_list[3].integer_reference;
9729 channel_mask=SetPixelChannelMask(image,channel);
9730 image=RadialBlurImage(image,geometry_info.rho,geometry_info.sigma,
9732 if (image != (Image *) NULL)
9733 (void) SetPixelChannelMask(image,channel_mask);
9736 case 83: /* Thumbnail */
9738 if (attribute_flag[0] != 0)
9739 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9740 &geometry,exception);
9741 if (attribute_flag[1] != 0)
9742 geometry.width=argument_list[1].integer_reference;
9743 if (attribute_flag[2] != 0)
9744 geometry.height=argument_list[2].integer_reference;
9745 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9748 case 84: /* Strip */
9750 (void) StripImage(image,exception);
9758 GetPixelInfo(image,&tint);
9759 if (attribute_flag[0] != 0)
9760 (void) QueryColorCompliance(argument_list[0].string_reference,
9761 AllCompliance,&tint,exception);
9762 if (attribute_flag[1] == 0)
9763 argument_list[1].string_reference="100";
9764 image=TintImage(image,argument_list[1].string_reference,&tint,
9768 case 86: /* Channel */
9770 if (attribute_flag[0] != 0)
9771 channel=(ChannelType) argument_list[0].integer_reference;
9772 channel_mask=SetPixelChannelMask(image,channel);
9773 (void) SeparateImage(image,exception);
9774 (void) SetPixelChannelMask(image,channel_mask);
9777 case 87: /* Splice */
9779 if (attribute_flag[0] != 0)
9780 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9781 &geometry,exception);
9782 if (attribute_flag[1] != 0)
9783 geometry.width=argument_list[1].integer_reference;
9784 if (attribute_flag[2] != 0)
9785 geometry.height=argument_list[2].integer_reference;
9786 if (attribute_flag[3] != 0)
9787 geometry.x=argument_list[3].integer_reference;
9788 if (attribute_flag[4] != 0)
9789 geometry.y=argument_list[4].integer_reference;
9790 if (attribute_flag[5] != 0)
9791 image->fuzz=StringToDoubleInterval(
9792 argument_list[5].string_reference,(double) QuantumRange+1.0);
9793 if (attribute_flag[6] != 0)
9794 (void) QueryColorCompliance(argument_list[6].string_reference,
9795 AllCompliance,&image->background_color,exception);
9796 if (attribute_flag[7] != 0)
9797 image->gravity=(GravityType) argument_list[7].integer_reference;
9798 image=SpliceImage(image,&geometry,exception);
9801 case 88: /* Posterize */
9803 if (attribute_flag[0] == 0)
9804 argument_list[0].integer_reference=3;
9805 if (attribute_flag[1] == 0)
9806 argument_list[1].integer_reference=0;
9807 (void) PosterizeImage(image,argument_list[0].integer_reference,
9808 argument_list[1].integer_reference ? MagickTrue : MagickFalse,
9812 case 89: /* Shadow */
9814 if (attribute_flag[0] != 0)
9816 flags=ParseGeometry(argument_list[0].string_reference,
9818 if ((flags & SigmaValue) == 0)
9819 geometry_info.sigma=1.0;
9820 if ((flags & XiValue) == 0)
9821 geometry_info.xi=4.0;
9822 if ((flags & PsiValue) == 0)
9823 geometry_info.psi=4.0;
9825 if (attribute_flag[1] != 0)
9826 geometry_info.rho=argument_list[1].real_reference;
9827 if (attribute_flag[2] != 0)
9828 geometry_info.sigma=argument_list[2].real_reference;
9829 if (attribute_flag[3] != 0)
9830 geometry_info.xi=argument_list[3].integer_reference;
9831 if (attribute_flag[4] != 0)
9832 geometry_info.psi=argument_list[4].integer_reference;
9833 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,0.0,
9834 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
9835 ceil(geometry_info.psi-0.5),exception);
9838 case 90: /* Identify */
9840 if (attribute_flag[0] == 0)
9841 argument_list[0].file_reference=(FILE *) NULL;
9842 if (attribute_flag[1] != 0)
9843 (void) SetImageArtifact(image,"identify:features",
9844 argument_list[1].string_reference);
9845 if ((attribute_flag[2] != 0) &&
9846 (argument_list[2].integer_reference != 0))
9847 (void) SetImageArtifact(image,"identify:unique","true");
9848 (void) IdentifyImage(image,argument_list[0].file_reference,
9849 MagickTrue,exception);
9852 case 91: /* SepiaTone */
9854 if (attribute_flag[0] == 0)
9855 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9856 image=SepiaToneImage(image,argument_list[0].real_reference,
9860 case 92: /* SigmoidalContrast */
9865 if (attribute_flag[0] != 0)
9867 flags=ParseGeometry(argument_list[0].string_reference,
9869 if ((flags & SigmaValue) == 0)
9870 geometry_info.sigma=QuantumRange/2.0;
9871 if ((flags & PercentValue) != 0)
9872 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9874 if (attribute_flag[1] != 0)
9875 geometry_info.rho=argument_list[1].real_reference;
9876 if (attribute_flag[2] != 0)
9877 geometry_info.sigma=argument_list[2].real_reference;
9878 if (attribute_flag[3] != 0)
9879 channel=(ChannelType) argument_list[3].integer_reference;
9881 if (attribute_flag[4] != 0)
9882 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9884 channel_mask=SetPixelChannelMask(image,channel);
9885 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9886 geometry_info.sigma,exception);
9887 (void) SetPixelChannelMask(image,channel_mask);
9890 case 93: /* Extent */
9892 if (attribute_flag[7] != 0)
9893 image->gravity=(GravityType) argument_list[7].integer_reference;
9894 if (attribute_flag[0] != 0)
9899 flags=ParseGravityGeometry(image,
9900 argument_list[0].string_reference,&geometry,exception);
9902 if (geometry.width == 0)
9903 geometry.width=image->columns;
9904 if (geometry.height == 0)
9905 geometry.height=image->rows;
9907 if (attribute_flag[1] != 0)
9908 geometry.width=argument_list[1].integer_reference;
9909 if (attribute_flag[2] != 0)
9910 geometry.height=argument_list[2].integer_reference;
9911 if (attribute_flag[3] != 0)
9912 geometry.x=argument_list[3].integer_reference;
9913 if (attribute_flag[4] != 0)
9914 geometry.y=argument_list[4].integer_reference;
9915 if (attribute_flag[5] != 0)
9916 image->fuzz=StringToDoubleInterval(
9917 argument_list[5].string_reference,(double) QuantumRange+1.0);
9918 if (attribute_flag[6] != 0)
9919 (void) QueryColorCompliance(argument_list[6].string_reference,
9920 AllCompliance,&image->background_color,exception);
9921 image=ExtentImage(image,&geometry,exception);
9924 case 94: /* Vignette */
9926 if (attribute_flag[0] != 0)
9928 flags=ParseGeometry(argument_list[0].string_reference,
9930 if ((flags & SigmaValue) == 0)
9931 geometry_info.sigma=1.0;
9932 if ((flags & XiValue) == 0)
9933 geometry_info.xi=0.1*image->columns;
9934 if ((flags & PsiValue) == 0)
9935 geometry_info.psi=0.1*image->rows;
9937 if (attribute_flag[1] != 0)
9938 geometry_info.rho=argument_list[1].real_reference;
9939 if (attribute_flag[2] != 0)
9940 geometry_info.sigma=argument_list[2].real_reference;
9941 if (attribute_flag[3] != 0)
9942 geometry_info.xi=argument_list[3].integer_reference;
9943 if (attribute_flag[4] != 0)
9944 geometry_info.psi=argument_list[4].integer_reference;
9945 if (attribute_flag[5] != 0)
9946 (void) QueryColorCompliance(argument_list[5].string_reference,
9947 AllCompliance,&image->background_color,exception);
9948 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,0.0,
9949 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
9950 ceil(geometry_info.psi-0.5),exception);
9953 case 95: /* ContrastStretch */
9960 white_point=(MagickRealType) image->columns*image->rows;
9961 if (attribute_flag[0] != 0)
9963 flags=ParseGeometry(argument_list[0].string_reference,
9965 black_point=geometry_info.rho;
9966 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9968 if ((flags & PercentValue) != 0)
9970 black_point*=(double) image->columns*image->rows/100.0;
9971 white_point*=(double) image->columns*image->rows/100.0;
9973 white_point=(MagickRealType) image->columns*image->rows-
9976 if (attribute_flag[1] != 0)
9977 black_point=argument_list[1].real_reference;
9978 if (attribute_flag[2] != 0)
9979 white_point=argument_list[2].real_reference;
9980 if (attribute_flag[4] != 0)
9981 channel=(ChannelType) argument_list[4].integer_reference;
9982 channel_mask=SetPixelChannelMask(image,channel);
9983 (void) ContrastStretchImage(image,black_point,white_point,exception);
9984 (void) SetPixelChannelMask(image,channel_mask);
9987 case 96: /* Sans0 */
9991 case 97: /* Sans1 */
9995 case 98: /* AdaptiveSharpen */
9997 if (attribute_flag[0] != 0)
9999 flags=ParseGeometry(argument_list[0].string_reference,
10001 if ((flags & SigmaValue) == 0)
10002 geometry_info.sigma=1.0;
10003 if ((flags & XiValue) == 0)
10004 geometry_info.xi=0.0;
10006 if (attribute_flag[1] != 0)
10007 geometry_info.rho=argument_list[1].real_reference;
10008 if (attribute_flag[2] != 0)
10009 geometry_info.sigma=argument_list[2].real_reference;
10010 if (attribute_flag[3] != 0)
10011 geometry_info.xi=argument_list[3].real_reference;
10012 if (attribute_flag[4] != 0)
10013 channel=(ChannelType) argument_list[4].integer_reference;
10014 channel_mask=SetPixelChannelMask(image,channel);
10015 image=AdaptiveSharpenImage(image,geometry_info.rho,
10016 geometry_info.sigma,geometry_info.xi,exception);
10017 if (image != (Image *) NULL)
10018 (void) SetPixelChannelMask(image,channel_mask);
10021 case 99: /* Transpose */
10023 image=TransposeImage(image,exception);
10026 case 100: /* Tranverse */
10028 image=TransverseImage(image,exception);
10031 case 101: /* AutoOrient */
10033 switch (image->orientation)
10035 case TopRightOrientation:
10037 image=FlopImage(image,exception);
10040 case BottomRightOrientation:
10042 image=RotateImage(image,180.0,exception);
10045 case BottomLeftOrientation:
10047 image=FlipImage(image,exception);
10050 case LeftTopOrientation:
10052 image=TransposeImage(image,exception);
10055 case RightTopOrientation:
10057 image=RotateImage(image,90.0,exception);
10060 case RightBottomOrientation:
10062 image=TransverseImage(image,exception);
10065 case LeftBottomOrientation:
10067 image=RotateImage(image,270.0,exception);
10075 case 102: /* AdaptiveBlur */
10077 if (attribute_flag[0] != 0)
10079 flags=ParseGeometry(argument_list[0].string_reference,
10081 if ((flags & SigmaValue) == 0)
10082 geometry_info.sigma=1.0;
10083 if ((flags & XiValue) == 0)
10084 geometry_info.xi=0.0;
10086 if (attribute_flag[1] != 0)
10087 geometry_info.rho=argument_list[1].real_reference;
10088 if (attribute_flag[2] != 0)
10089 geometry_info.sigma=argument_list[2].real_reference;
10090 if (attribute_flag[3] != 0)
10091 geometry_info.xi=argument_list[3].real_reference;
10092 if (attribute_flag[4] != 0)
10093 channel=(ChannelType) argument_list[4].integer_reference;
10094 channel_mask=SetPixelChannelMask(image,channel);
10095 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10096 geometry_info.xi,exception);
10097 if (image != (Image *) NULL)
10098 (void) SetPixelChannelMask(image,channel_mask);
10101 case 103: /* Sketch */
10103 if (attribute_flag[0] != 0)
10105 flags=ParseGeometry(argument_list[0].string_reference,
10107 if ((flags & SigmaValue) == 0)
10108 geometry_info.sigma=1.0;
10109 if ((flags & XiValue) == 0)
10110 geometry_info.xi=1.0;
10112 if (attribute_flag[1] != 0)
10113 geometry_info.rho=argument_list[1].real_reference;
10114 if (attribute_flag[2] != 0)
10115 geometry_info.sigma=argument_list[2].real_reference;
10116 if (attribute_flag[3] != 0)
10117 geometry_info.xi=argument_list[3].real_reference;
10118 if (attribute_flag[4] != 0)
10119 geometry_info.psi=argument_list[4].real_reference;
10120 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10121 geometry_info.xi,geometry_info.psi,exception);
10124 case 104: /* UniqueColors */
10126 image=UniqueImageColors(image,exception);
10129 case 105: /* AdaptiveResize */
10131 PixelInterpolateMethod
10134 if (attribute_flag[0] != 0)
10135 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10136 &geometry,exception);
10137 if (attribute_flag[1] != 0)
10138 geometry.width=argument_list[1].integer_reference;
10139 if (attribute_flag[2] != 0)
10140 geometry.height=argument_list[2].integer_reference;
10141 if (attribute_flag[3] != 0)
10142 image->filter=(FilterTypes) argument_list[4].integer_reference;
10143 if (attribute_flag[4] != 0)
10144 SetImageArtifact(image,"filter:support",
10145 argument_list[4].string_reference);
10146 if (attribute_flag[5] != 0)
10147 image->blur=argument_list[5].real_reference;
10148 method=UndefinedInterpolatePixel;
10149 if (attribute_flag[6] != 0)
10150 method=(PixelInterpolateMethod) argument_list[6].integer_reference;
10151 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10155 case 106: /* ClipMask */
10157 if (attribute_flag[0] == 0)
10159 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10161 goto PerlException;
10163 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10164 MagickTrue,exception);
10165 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10168 case 107: /* LinearStretch */
10175 white_point=(MagickRealType) image->columns*image->rows;
10176 if (attribute_flag[0] != 0)
10178 flags=ParseGeometry(argument_list[0].string_reference,
10180 if ((flags & SigmaValue) != 0)
10181 white_point=geometry_info.sigma;
10182 if ((flags & PercentValue) != 0)
10184 black_point*=(double) image->columns*image->rows/100.0;
10185 white_point*=(double) image->columns*image->rows/100.0;
10187 if ((flags & SigmaValue) == 0)
10188 white_point=(double) image->columns*image->rows-black_point;
10190 if (attribute_flag[1] != 0)
10191 black_point=argument_list[1].real_reference;
10192 if (attribute_flag[2] != 0)
10193 white_point=argument_list[2].real_reference;
10194 (void) LinearStretchImage(image,black_point,white_point,exception);
10197 case 108: /* ColorMatrix */
10211 if (attribute_flag[0] == 0)
10213 av=(AV *) argument_list[0].array_reference;
10214 order=(size_t) sqrt(av_len(av)+1);
10215 color_matrix=(double *) AcquireQuantumMemory(order,order*
10216 sizeof(*color_matrix));
10217 if (color_matrix == (double *) NULL)
10219 ThrowPerlException(exception,ResourceLimitFatalError,
10220 "MemoryAllocationFailed",PackageName);
10221 goto PerlException;
10223 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10224 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10225 for ( ; j < (ssize_t) (order*order); j++)
10226 color_matrix[j]=0.0;
10227 kernel_info=AcquireKernelInfo((const char *) NULL);
10228 if (kernel_info == (KernelInfo *) NULL)
10230 kernel_info->width=order;
10231 kernel_info->height=order;
10232 kernel_info->values=color_matrix;
10233 image=ColorMatrixImage(image,kernel_info,exception);
10234 kernel_info->values=(double *) NULL;
10235 kernel_info=DestroyKernelInfo(kernel_info);
10236 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10239 case 109: /* Mask */
10241 if (attribute_flag[0] == 0)
10243 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10245 goto PerlException;
10247 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10248 MagickTrue,exception);
10249 (void) NegateImage(image->mask,MagickFalse,exception);
10252 case 110: /* Polaroid */
10263 PixelInterpolateMethod
10266 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10267 (DrawInfo *) NULL);
10268 caption=(char *) NULL;
10269 if (attribute_flag[0] != 0)
10270 caption=InterpretImageProperties(info ? info->image_info :
10271 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10274 if (attribute_flag[1] != 0)
10275 angle=argument_list[1].real_reference;
10276 if (attribute_flag[2] != 0)
10277 (void) CloneString(&draw_info->font,
10278 argument_list[2].string_reference);
10279 if (attribute_flag[3] != 0)
10280 (void) QueryColorCompliance(argument_list[3].string_reference,
10281 AllCompliance,&draw_info->stroke,exception);
10282 if (attribute_flag[4] != 0)
10283 (void) QueryColorCompliance(argument_list[4].string_reference,
10284 AllCompliance,&draw_info->fill,exception);
10285 if (attribute_flag[5] != 0)
10286 draw_info->stroke_width=argument_list[5].real_reference;
10287 if (attribute_flag[6] != 0)
10288 draw_info->pointsize=argument_list[6].real_reference;
10289 if (attribute_flag[7] != 0)
10290 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10291 if (attribute_flag[8] != 0)
10292 (void) QueryColorCompliance(argument_list[8].string_reference,
10293 AllCompliance,&image->background_color,exception);
10294 method=UndefinedInterpolatePixel;
10295 if (attribute_flag[9] != 0)
10296 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10297 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10298 draw_info=DestroyDrawInfo(draw_info);
10299 if (caption != (char *) NULL)
10300 caption=DestroyString(caption);
10303 case 111: /* FloodfillPaint */
10315 virtual_pixel[MaxPixelChannels];
10317 draw_info=CloneDrawInfo(info ? info->image_info :
10318 (ImageInfo *) NULL,(DrawInfo *) NULL);
10319 if (attribute_flag[0] != 0)
10320 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10321 &geometry,exception);
10322 if (attribute_flag[1] != 0)
10323 geometry.x=argument_list[1].integer_reference;
10324 if (attribute_flag[2] != 0)
10325 geometry.y=argument_list[2].integer_reference;
10326 if (attribute_flag[3] != 0)
10327 (void) QueryColorCompliance(argument_list[3].string_reference,
10328 AllCompliance,&draw_info->fill,exception);
10329 (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
10331 target.red=virtual_pixel[RedPixelChannel];
10332 target.green=virtual_pixel[GreenPixelChannel];
10333 target.blue=virtual_pixel[BluePixelChannel];
10334 target.alpha=virtual_pixel[AlphaPixelChannel];
10335 if (attribute_flag[4] != 0)
10336 QueryColorCompliance(argument_list[4].string_reference,
10337 AllCompliance,&target,exception);
10338 if (attribute_flag[5] != 0)
10339 image->fuzz=StringToDoubleInterval(
10340 argument_list[5].string_reference,(double) QuantumRange+1.0);
10341 if (attribute_flag[6] != 0)
10342 channel=(ChannelType) argument_list[6].integer_reference;
10343 invert=MagickFalse;
10344 if (attribute_flag[7] != 0)
10345 invert=(MagickBooleanType) argument_list[7].integer_reference;
10346 channel_mask=SetPixelChannelMask(image,channel);
10347 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10348 geometry.y,invert,exception);
10349 (void) SetPixelChannelMask(image,channel_mask);
10350 draw_info=DestroyDrawInfo(draw_info);
10353 case 112: /* Distort */
10365 number_coordinates;
10370 if (attribute_flag[0] == 0)
10372 method=UndefinedDistortion;
10373 if (attribute_flag[1] != 0)
10374 method=(DistortImageMethod) argument_list[1].integer_reference;
10375 av=(AV *) argument_list[0].array_reference;
10376 number_coordinates=(size_t) av_len(av)+1;
10377 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10378 sizeof(*coordinates));
10379 if (coordinates == (double *) NULL)
10381 ThrowPerlException(exception,ResourceLimitFatalError,
10382 "MemoryAllocationFailed",PackageName);
10383 goto PerlException;
10385 for (j=0; j < (ssize_t) number_coordinates; j++)
10386 coordinates[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 image=DistortImage(image,method,number_coordinates,coordinates,
10392 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10394 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10395 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10396 coordinates=(double *) RelinquishMagickMemory(coordinates);
10399 case 113: /* Clut */
10401 PixelInterpolateMethod
10404 if (attribute_flag[0] == 0)
10406 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10408 goto PerlException;
10410 method=UndefinedInterpolatePixel;
10411 if (attribute_flag[1] != 0)
10412 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10413 if (attribute_flag[2] != 0)
10414 channel=(ChannelType) argument_list[2].integer_reference;
10415 channel_mask=SetPixelChannelMask(image,channel);
10416 (void) ClutImage(image,argument_list[0].image_reference,method,
10418 (void) SetPixelChannelMask(image,channel_mask);
10421 case 114: /* LiquidRescale */
10423 if (attribute_flag[0] != 0)
10424 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10425 &geometry,exception);
10426 if (attribute_flag[1] != 0)
10427 geometry.width=argument_list[1].integer_reference;
10428 if (attribute_flag[2] != 0)
10429 geometry.height=argument_list[2].integer_reference;
10430 if (attribute_flag[3] == 0)
10431 argument_list[3].real_reference=1.0;
10432 if (attribute_flag[4] == 0)
10433 argument_list[4].real_reference=0.0;
10434 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10435 argument_list[3].real_reference,argument_list[4].real_reference,
10439 case 115: /* EncipherImage */
10441 (void) EncipherImage(image,argument_list[0].string_reference,
10445 case 116: /* DecipherImage */
10447 (void) DecipherImage(image,argument_list[0].string_reference,
10451 case 117: /* Deskew */
10453 geometry_info.rho=QuantumRange/2.0;
10454 if (attribute_flag[0] != 0)
10455 flags=ParseGeometry(argument_list[0].string_reference,
10457 if (attribute_flag[1] != 0)
10458 geometry_info.rho=StringToDoubleInterval(
10459 argument_list[1].string_reference,(double) QuantumRange+1.0);
10460 image=DeskewImage(image,geometry_info.rho,exception);
10463 case 118: /* Remap */
10468 if (attribute_flag[0] == 0)
10470 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10472 goto PerlException;
10474 quantize_info=AcquireQuantizeInfo(info->image_info);
10475 if (attribute_flag[1] != 0)
10476 quantize_info->dither=(MagickBooleanType)
10477 argument_list[1].integer_reference;
10478 if (attribute_flag[2] != 0)
10479 quantize_info->dither_method=(DitherMethod)
10480 argument_list[2].integer_reference;
10481 (void) RemapImages(quantize_info,image,
10482 argument_list[0].image_reference,exception);
10483 quantize_info=DestroyQuantizeInfo(quantize_info);
10486 case 119: /* SparseColor */
10498 number_coordinates;
10503 if (attribute_flag[0] == 0)
10505 method=UndefinedColorInterpolate;
10506 if (attribute_flag[1] != 0)
10507 method=(SparseColorMethod) argument_list[1].integer_reference;
10508 av=(AV *) argument_list[0].array_reference;
10509 number_coordinates=(size_t) av_len(av)+1;
10510 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10511 sizeof(*coordinates));
10512 if (coordinates == (double *) NULL)
10514 ThrowPerlException(exception,ResourceLimitFatalError,
10515 "MemoryAllocationFailed",PackageName);
10516 goto PerlException;
10518 for (j=0; j < (ssize_t) number_coordinates; j++)
10519 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10520 virtual_pixel=UndefinedVirtualPixelMethod;
10521 if (attribute_flag[2] != 0)
10522 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10523 argument_list[2].integer_reference);
10524 if (attribute_flag[3] != 0)
10525 channel=(ChannelType) argument_list[3].integer_reference;
10526 channel_mask=SetPixelChannelMask(image,channel);
10527 image=SparseColorImage(image,method,number_coordinates,coordinates,
10529 if (image != (Image *) NULL)
10530 (void) SetPixelChannelMask(image,channel_mask);
10531 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10532 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10533 coordinates=(double *) RelinquishMagickMemory(coordinates);
10536 case 120: /* Function */
10553 if (attribute_flag[0] == 0)
10555 function=UndefinedFunction;
10556 if (attribute_flag[1] != 0)
10557 function=(MagickFunction) argument_list[1].integer_reference;
10558 av=(AV *) argument_list[0].array_reference;
10559 number_parameters=(size_t) av_len(av)+1;
10560 parameters=(double *) AcquireQuantumMemory(number_parameters,
10561 sizeof(*parameters));
10562 if (parameters == (double *) NULL)
10564 ThrowPerlException(exception,ResourceLimitFatalError,
10565 "MemoryAllocationFailed",PackageName);
10566 goto PerlException;
10568 for (j=0; j < (ssize_t) number_parameters; j++)
10569 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10570 virtual_pixel=UndefinedVirtualPixelMethod;
10571 if (attribute_flag[2] != 0)
10572 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10573 argument_list[2].integer_reference);
10574 (void) FunctionImage(image,function,number_parameters,parameters,
10576 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10577 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10578 parameters=(double *) RelinquishMagickMemory(parameters);
10581 case 121: /* SelectiveBlur */
10583 if (attribute_flag[0] != 0)
10585 flags=ParseGeometry(argument_list[0].string_reference,
10587 if ((flags & SigmaValue) == 0)
10588 geometry_info.sigma=1.0;
10589 if ((flags & PercentValue) != 0)
10590 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10592 if (attribute_flag[1] != 0)
10593 geometry_info.rho=argument_list[1].real_reference;
10594 if (attribute_flag[2] != 0)
10595 geometry_info.sigma=argument_list[2].real_reference;
10596 if (attribute_flag[3] != 0)
10597 geometry_info.xi=argument_list[3].integer_reference;;
10598 if (attribute_flag[4] != 0)
10599 geometry_info.psi=argument_list[4].integer_reference;;
10600 if (attribute_flag[5] != 0)
10601 channel=(ChannelType) argument_list[5].integer_reference;
10602 channel_mask=SetPixelChannelMask(image,channel);
10603 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10604 geometry_info.xi,geometry_info.psi,exception);
10605 if (image != (Image *) NULL)
10606 (void) SetPixelChannelMask(image,channel_mask);
10609 case 122: /* HaldClut */
10611 if (attribute_flag[0] == 0)
10613 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10615 goto PerlException;
10617 if (attribute_flag[1] != 0)
10618 channel=(ChannelType) argument_list[1].integer_reference;
10619 channel_mask=SetPixelChannelMask(image,channel);
10620 (void) HaldClutImage(image,argument_list[0].image_reference,
10622 (void) SetPixelChannelMask(image,channel_mask);
10625 case 123: /* BlueShift */
10627 if (attribute_flag[0] != 0)
10628 (void) ParseGeometry(argument_list[0].string_reference,
10630 image=BlueShiftImage(image,geometry_info.rho,exception);
10633 case 124: /* ForwardFourierTransformImage */
10635 image=ForwardFourierTransformImage(image,
10636 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10640 case 125: /* InverseFourierTransformImage */
10642 image=InverseFourierTransformImage(image,image->next,
10643 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10647 case 126: /* ColorDecisionList */
10649 if (attribute_flag[0] == 0)
10650 argument_list[0].string_reference=(char *) NULL;
10651 (void) ColorDecisionListImage(image,
10652 argument_list[0].string_reference,exception);
10655 case 127: /* AutoGamma */
10657 if (attribute_flag[0] != 0)
10658 channel=(ChannelType) argument_list[0].integer_reference;
10659 channel_mask=SetPixelChannelMask(image,channel);
10660 (void) AutoGammaImage(image,exception);
10661 (void) SetPixelChannelMask(image,channel_mask);
10664 case 128: /* AutoLevel */
10666 if (attribute_flag[0] != 0)
10667 channel=(ChannelType) argument_list[0].integer_reference;
10668 channel_mask=SetPixelChannelMask(image,channel);
10669 (void) AutoLevelImage(image,exception);
10670 (void) SetPixelChannelMask(image,channel_mask);
10673 case 129: /* LevelColors */
10679 (void) QueryColorCompliance("#000000",AllCompliance,
10680 &black_point,exception);
10681 (void) QueryColorCompliance("#ffffff",AllCompliance,
10682 &white_point,exception);
10683 if (attribute_flag[1] != 0)
10684 (void) QueryColorCompliance(
10685 argument_list[1].string_reference,AllCompliance,&black_point,
10687 if (attribute_flag[2] != 0)
10688 (void) QueryColorCompliance(
10689 argument_list[2].string_reference,AllCompliance,&white_point,
10691 if (attribute_flag[3] != 0)
10692 channel=(ChannelType) argument_list[3].integer_reference;
10693 channel_mask=SetPixelChannelMask(image,channel);
10694 (void) LevelImageColors(image,&black_point,&white_point,
10695 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10697 (void) SetPixelChannelMask(image,channel_mask);
10700 case 130: /* Clamp */
10702 if (attribute_flag[0] != 0)
10703 channel=(ChannelType) argument_list[0].integer_reference;
10704 channel_mask=SetPixelChannelMask(image,channel);
10705 (void) ClampImage(image,exception);
10706 (void) SetPixelChannelMask(image,channel_mask);
10709 case 131: /* BrightnessContrast */
10717 if (attribute_flag[0] != 0)
10719 flags=ParseGeometry(argument_list[0].string_reference,
10721 brightness=geometry_info.rho;
10722 if ((flags & SigmaValue) == 0)
10723 contrast=geometry_info.sigma;
10725 if (attribute_flag[1] != 0)
10726 brightness=argument_list[1].real_reference;
10727 if (attribute_flag[2] != 0)
10728 contrast=argument_list[2].real_reference;
10729 if (attribute_flag[4] != 0)
10730 channel=(ChannelType) argument_list[4].integer_reference;
10731 channel_mask=SetPixelChannelMask(image,channel);
10732 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10733 (void) SetPixelChannelMask(image,channel_mask);
10736 case 132: /* Morphology */
10747 if (attribute_flag[0] == 0)
10749 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10750 if (kernel == (KernelInfo *) NULL)
10752 if (attribute_flag[1] != 0)
10753 channel=(ChannelType) argument_list[1].integer_reference;
10754 method=UndefinedMorphology;
10755 if (attribute_flag[2] != 0)
10756 method=argument_list[2].integer_reference;
10758 if (attribute_flag[3] != 0)
10759 iterations=argument_list[3].integer_reference;
10760 channel_mask=SetPixelChannelMask(image,channel);
10761 image=MorphologyImage(image,method,iterations,kernel,exception);
10762 if (image != (Image *) NULL)
10763 (void) SetPixelChannelMask(image,channel_mask);
10764 kernel=DestroyKernelInfo(kernel);
10767 case 133: /* Mode */
10769 if (attribute_flag[0] != 0)
10771 flags=ParseGeometry(argument_list[0].string_reference,
10773 if ((flags & SigmaValue) == 0)
10774 geometry_info.sigma=1.0;
10776 if (attribute_flag[1] != 0)
10777 geometry_info.rho=argument_list[1].real_reference;
10778 if (attribute_flag[2] != 0)
10779 geometry_info.sigma=argument_list[2].real_reference;
10780 if (attribute_flag[3] != 0)
10781 channel=(ChannelType) argument_list[3].integer_reference;
10782 channel_mask=SetPixelChannelMask(image,channel);
10783 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10784 (size_t) geometry_info.sigma,exception);
10785 if (image != (Image *) NULL)
10786 (void) SetPixelChannelMask(image,channel_mask);
10789 case 134: /* Statistic */
10794 statistic=UndefinedStatistic;
10795 if (attribute_flag[0] != 0)
10797 flags=ParseGeometry(argument_list[0].string_reference,
10799 if ((flags & SigmaValue) == 0)
10800 geometry_info.sigma=1.0;
10802 if (attribute_flag[1] != 0)
10803 geometry_info.rho=argument_list[1].real_reference;
10804 if (attribute_flag[2] != 0)
10805 geometry_info.sigma=argument_list[2].real_reference;
10806 if (attribute_flag[3] != 0)
10807 channel=(ChannelType) argument_list[3].integer_reference;
10808 if (attribute_flag[4] != 0)
10809 statistic=(StatisticType) argument_list[4].integer_reference;
10810 channel_mask=SetPixelChannelMask(image,channel);
10811 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10812 (size_t) geometry_info.sigma,exception);
10813 if (image != (Image *) NULL)
10814 (void) SetPixelChannelMask(image,channel_mask);
10818 if (next != (Image *) NULL)
10819 (void) CatchImageException(next);
10820 if (region_image != (Image *) NULL)
10825 status=CompositeImage(region_image,CopyCompositeOp,image,
10826 region_info.x,region_info.y,exception);
10828 (void) CatchImageException(region_image);
10829 image=DestroyImage(image);
10830 image=region_image;
10832 if (image != (Image *) NULL)
10835 if (next && (next != image))
10837 image->next=next->next;
10838 if (image->next != (Image *) NULL)
10839 image->next->previous=image;
10840 DeleteImageFromRegistry(*pv,next);
10842 sv_setiv(*pv,(IV) image);
10850 if (reference_vector)
10851 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10852 InheritPerlException(exception,perl_exception);
10853 exception=DestroyExceptionInfo(exception);
10854 sv_setiv(perl_exception,(IV) number_images);
10855 SvPOK_on(perl_exception);
10856 ST(0)=sv_2mortal(perl_exception);
10861 ###############################################################################
10869 ###############################################################################
10874 Image::Magick ref=NO_INIT
10919 PERL_UNUSED_VAR(ref);
10920 PERL_UNUSED_VAR(ix);
10921 exception=AcquireExceptionInfo();
10922 perl_exception=newSVpv("",0);
10925 if (sv_isobject(ST(0)) == 0)
10927 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10929 goto PerlException;
10931 reference=SvRV(ST(0));
10932 hv=SvSTASH(reference);
10934 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10936 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10937 if (image == (Image *) NULL)
10939 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10941 goto PerlException;
10946 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10947 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10948 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
10950 for (i=2; i < items; i+=2)
10952 attribute=(char *) SvPV(ST(i-1),na);
10953 switch (*attribute)
10958 if (LocaleCompare(attribute,"background") == 0)
10960 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
10961 &montage_info->background_color,exception);
10962 for (next=image; next; next=next->next)
10963 next->background_color=montage_info->background_color;
10966 if (LocaleCompare(attribute,"border") == 0)
10968 montage_info->border_width=SvIV(ST(i));
10971 if (LocaleCompare(attribute,"bordercolor") == 0)
10973 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
10974 &montage_info->border_color,exception);
10975 for (next=image; next; next=next->next)
10976 next->border_color=montage_info->border_color;
10979 if (LocaleCompare(attribute,"borderwidth") == 0)
10981 montage_info->border_width=SvIV(ST(i));
10984 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10991 if (LocaleCompare(attribute,"compose") == 0)
10993 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10994 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10997 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11001 for (next=image; next; next=next->next)
11002 next->compose=(CompositeOperator) sp;
11005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11012 if (LocaleCompare(attribute,"fill") == 0)
11014 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11015 &montage_info->fill,exception);
11018 if (LocaleCompare(attribute,"font") == 0)
11020 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11023 if (LocaleCompare(attribute,"frame") == 0)
11029 if (IsGeometry(p) == MagickFalse)
11031 ThrowPerlException(exception,OptionError,"MissingGeometry",
11035 (void) CloneString(&montage_info->frame,p);
11037 montage_info->frame=(char *) NULL;
11040 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11047 if (LocaleCompare(attribute,"geometry") == 0)
11053 if (IsGeometry(p) == MagickFalse)
11055 ThrowPerlException(exception,OptionError,"MissingGeometry",
11059 (void) CloneString(&montage_info->geometry,p);
11061 montage_info->geometry=(char *) NULL;
11064 if (LocaleCompare(attribute,"gravity") == 0)
11069 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11070 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11073 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11077 montage_info->gravity=(GravityType) in;
11078 for (next=image; next; next=next->next)
11079 next->gravity=(GravityType) in;
11082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11089 if (LocaleCompare(attribute,"label") == 0)
11091 for (next=image; next; next=next->next)
11092 (void) SetImageProperty(next,"label",InterpretImageProperties(
11093 info ? info->image_info : (ImageInfo *) NULL,next,
11094 SvPV(ST(i),na),exception),exception);
11097 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11104 if (LocaleCompare(attribute,"mattecolor") == 0)
11106 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11107 &montage_info->matte_color,exception);
11108 for (next=image; next; next=next->next)
11109 next->matte_color=montage_info->matte_color;
11112 if (LocaleCompare(attribute,"mode") == 0)
11117 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11118 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11123 ThrowPerlException(exception,OptionError,
11124 "UnrecognizedModeType",SvPV(ST(i),na));
11129 (void) CloneString(&montage_info->frame,"15x15+3+3");
11130 montage_info->shadow=MagickTrue;
11135 montage_info->frame=(char *) NULL;
11136 montage_info->shadow=MagickFalse;
11137 montage_info->border_width=0;
11140 case ConcatenateMode:
11142 montage_info->frame=(char *) NULL;
11143 montage_info->shadow=MagickFalse;
11144 (void) CloneString(&montage_info->geometry,"+0+0");
11145 montage_info->border_width=0;
11150 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11157 if (LocaleCompare(attribute,"pointsize") == 0)
11159 montage_info->pointsize=SvIV(ST(i));
11162 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11169 if (LocaleCompare(attribute,"shadow") == 0)
11171 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11172 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11175 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11179 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11182 if (LocaleCompare(attribute,"stroke") == 0)
11184 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11185 &montage_info->stroke,exception);
11188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11195 if (LocaleCompare(attribute,"texture") == 0)
11197 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11200 if (LocaleCompare(attribute,"tile") == 0)
11202 char *p=SvPV(ST(i),na);
11203 if (IsGeometry(p) == MagickFalse)
11205 ThrowPerlException(exception,OptionError,"MissingGeometry",
11209 (void) CloneString(&montage_info->tile,p);
11211 montage_info->tile=(char *) NULL;
11214 if (LocaleCompare(attribute,"title") == 0)
11216 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11219 if (LocaleCompare(attribute,"transparent") == 0)
11224 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11225 &transparent_color,exception);
11226 for (next=image; next; next=next->next)
11227 (void) TransparentPaintImage(next,&transparent_color,
11228 TransparentAlpha,MagickFalse,exception);
11231 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11237 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11243 image=MontageImageList(info->image_info,montage_info,image,exception);
11244 montage_info=DestroyMontageInfo(montage_info);
11245 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11246 goto PerlException;
11247 if (transparent_color.alpha != TransparentAlpha)
11248 for (next=image; next; next=next->next)
11249 (void) TransparentPaintImage(next,&transparent_color,
11250 TransparentAlpha,MagickFalse,exception);
11251 for ( ; image; image=image->next)
11253 AddImageToRegistry(sv,image);
11255 av_push(av,sv_bless(rv,hv));
11258 exception=DestroyExceptionInfo(exception);
11259 ST(0)=av_reference;
11260 SvREFCNT_dec(perl_exception);
11264 InheritPerlException(exception,perl_exception);
11265 exception=DestroyExceptionInfo(exception);
11266 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11267 SvPOK_on(perl_exception);
11268 ST(0)=sv_2mortal(perl_exception);
11273 ###############################################################################
11281 ###############################################################################
11286 Image::Magick ref=NO_INIT
11324 PERL_UNUSED_VAR(ref);
11325 PERL_UNUSED_VAR(ix);
11326 exception=AcquireExceptionInfo();
11327 perl_exception=newSVpv("",0);
11331 if (sv_isobject(ST(0)) == 0)
11333 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11335 goto PerlException;
11337 reference=SvRV(ST(0));
11338 hv=SvSTASH(reference);
11340 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11342 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11343 if (image == (Image *) NULL)
11345 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11347 goto PerlException;
11349 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11354 for (i=2; i < items; i+=2)
11356 attribute=(char *) SvPV(ST(i-1),na);
11357 switch (*attribute)
11362 if (LocaleCompare(attribute,"frames") == 0)
11364 number_frames=SvIV(ST(i));
11367 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11373 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11379 image=MorphImages(image,number_frames,exception);
11380 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11381 goto PerlException;
11382 for ( ; image; image=image->next)
11384 AddImageToRegistry(sv,image);
11386 av_push(av,sv_bless(rv,hv));
11389 exception=DestroyExceptionInfo(exception);
11390 ST(0)=av_reference;
11391 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11395 InheritPerlException(exception,perl_exception);
11396 exception=DestroyExceptionInfo(exception);
11397 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11398 SvPOK_on(perl_exception);
11399 ST(0)=sv_2mortal(perl_exception);
11404 ###############################################################################
11412 ###############################################################################
11417 Image::Magick ref=NO_INIT
11445 PERL_UNUSED_VAR(ref);
11446 PERL_UNUSED_VAR(ix);
11447 exception=AcquireExceptionInfo();
11448 perl_exception=newSVpv("",0);
11450 if (sv_isobject(ST(0)) == 0)
11452 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11454 goto PerlException;
11456 reference=SvRV(ST(0));
11457 hv=SvSTASH(reference);
11458 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11459 if (image == (Image *) NULL)
11461 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11463 goto PerlException;
11465 image=MergeImageLayers(image,MosaicLayer,exception);
11467 Create blessed Perl array for the returned image.
11470 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11472 AddImageToRegistry(sv,image);
11474 av_push(av,sv_bless(rv,hv));
11476 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11477 (void) CopyMagickString(info->image_info->filename,image->filename,
11479 SetImageInfo(info->image_info,0,exception);
11480 exception=DestroyExceptionInfo(exception);
11481 SvREFCNT_dec(perl_exception);
11485 InheritPerlException(exception,perl_exception);
11486 exception=DestroyExceptionInfo(exception);
11487 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11488 SvPOK_on(perl_exception); /* return messages in string context */
11489 ST(0)=sv_2mortal(perl_exception);
11494 ###############################################################################
11502 ###############################################################################
11507 Image::Magick ref=NO_INIT
11557 PERL_UNUSED_VAR(ref);
11558 PERL_UNUSED_VAR(ix);
11559 exception=AcquireExceptionInfo();
11560 perl_exception=newSVpv("",0);
11561 package_info=(struct PackageInfo *) NULL;
11562 ac=(items < 2) ? 1 : items-1;
11563 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11565 length=(STRLEN *) NULL;
11566 if (list == (char **) NULL)
11568 ThrowPerlException(exception,ResourceLimitError,
11569 "MemoryAllocationFailed",PackageName);
11570 goto PerlException;
11573 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11574 if (length == (STRLEN *) NULL)
11576 ThrowPerlException(exception,ResourceLimitError,
11577 "MemoryAllocationFailed",PackageName);
11578 goto PerlException;
11580 if (sv_isobject(ST(0)) == 0)
11582 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11584 goto PerlException;
11586 reference=SvRV(ST(0));
11587 if (SvTYPE(reference) != SVt_PVAV)
11589 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11591 goto PerlException;
11593 av=(AV *) reference;
11594 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11596 package_info=ClonePackageInfo(info,exception);
11599 *list=(char *) (*package_info->image_info->filename ?
11600 package_info->image_info->filename : "XC:black");
11602 for (n=0, i=0; i < ac; i++)
11604 list[n]=(char *) SvPV(ST(i+1),length[n]);
11605 if ((items >= 3) && strEQcase(list[n],"blob"))
11611 blob=(void *) (SvPV(ST(i+1),length[n]));
11612 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11614 if ((items >= 3) && strEQcase(list[n],"filename"))
11616 if ((items >= 3) && strEQcase(list[n],"file"))
11625 io_info=IoIFP(sv_2io(ST(i+1)));
11626 if (io_info == (PerlIO *) NULL)
11628 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11632 file=PerlIO_findFILE(io_info);
11633 if (file == (FILE *) NULL)
11635 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11639 SetImageInfoFile(package_info->image_info,file);
11641 if ((items >= 3) && strEQcase(list[n],"magick"))
11645 list[n]=(char *) NULL;
11647 status=ExpandFilenames(&n,&list);
11648 if (status == MagickFalse)
11650 ThrowPerlException(exception,ResourceLimitError,
11651 "MemoryAllocationFailed",PackageName);
11652 goto PerlException;
11655 for (i=0; i < n; i++)
11657 (void) CopyMagickString(package_info->image_info->filename,list[i],
11659 image=PingImage(package_info->image_info,exception);
11660 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11662 if ((package_info->image_info->file != (FILE *) NULL) ||
11663 (package_info->image_info->blob != (void *) NULL))
11664 DisassociateImageStream(image);
11665 count+=GetImageListLength(image);
11666 EXTEND(sp,4*count);
11667 for (next=image; next; next=next->next)
11669 PUSHs(sv_2mortal(newSViv(next->columns)));
11670 PUSHs(sv_2mortal(newSViv(next->rows)));
11671 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11672 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11674 image=DestroyImageList(image);
11679 for (i=0; i < n; i++)
11680 if (list[i] != (char *) NULL)
11681 for (p=keep; list[i] != *p++; )
11684 list[i]=(char *) RelinquishMagickMemory(list[i]);
11689 if (package_info != (struct PackageInfo *) NULL)
11690 DestroyPackageInfo(package_info);
11691 if (list && (list != keep))
11692 list=(char **) RelinquishMagickMemory(list);
11694 keep=(char **) RelinquishMagickMemory(keep);
11696 length=(STRLEN *) RelinquishMagickMemory(length);
11697 InheritPerlException(exception,perl_exception);
11698 exception=DestroyExceptionInfo(exception);
11699 SvREFCNT_dec(perl_exception); /* throw away all errors */
11703 ###############################################################################
11711 ###############################################################################
11716 Image::Magick ref=NO_INIT
11749 PERL_UNUSED_VAR(ref);
11750 PERL_UNUSED_VAR(ix);
11751 exception=AcquireExceptionInfo();
11752 perl_exception=newSVpv("",0);
11755 if (sv_isobject(ST(0)) == 0)
11757 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11759 goto PerlException;
11761 reference=SvRV(ST(0));
11762 hv=SvSTASH(reference);
11764 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11766 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11767 if (image == (Image *) NULL)
11769 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11771 goto PerlException;
11773 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11774 preview_type=GammaPreview;
11776 preview_type=(PreviewType)
11777 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11778 for ( ; image; image=image->next)
11780 preview_image=PreviewImage(image,preview_type,exception);
11781 if (preview_image == (Image *) NULL)
11782 goto PerlException;
11783 AddImageToRegistry(sv,preview_image);
11785 av_push(av,sv_bless(rv,hv));
11788 exception=DestroyExceptionInfo(exception);
11789 ST(0)=av_reference;
11790 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11794 InheritPerlException(exception,perl_exception);
11795 exception=DestroyExceptionInfo(exception);
11796 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11797 SvPOK_on(perl_exception);
11798 ST(0)=sv_2mortal(perl_exception);
11803 ###############################################################################
11807 # Q u e r y C o l o r #
11811 ###############################################################################
11815 QueryColor(ref,...)
11816 Image::Magick ref=NO_INIT
11836 PERL_UNUSED_VAR(ref);
11837 PERL_UNUSED_VAR(ix);
11838 exception=AcquireExceptionInfo();
11839 perl_exception=newSVpv("",0);
11848 colorlist=GetColorInfoList("*",&colors,exception);
11850 for (i=0; i < (ssize_t) colors; i++)
11852 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11854 colorlist=(const ColorInfo **)
11855 RelinquishMagickMemory((ColorInfo **) colorlist);
11856 goto PerlException;
11858 EXTEND(sp,5*items);
11859 for (i=1; i < items; i++)
11861 name=(char *) SvPV(ST(i),na);
11862 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
11867 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11868 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11869 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11870 if (color.colorspace == CMYKColorspace)
11871 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11872 if (color.matte != MagickFalse)
11873 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11877 InheritPerlException(exception,perl_exception);
11878 exception=DestroyExceptionInfo(exception);
11879 SvREFCNT_dec(perl_exception);
11883 ###############################################################################
11887 # Q u e r y C o l o r N a m e #
11891 ###############################################################################
11895 QueryColorname(ref,...)
11896 Image::Magick ref=NO_INIT
11905 message[MaxTextExtent];
11924 *reference; /* reference is the SV* of ref=SvIV(reference) */
11926 PERL_UNUSED_VAR(ref);
11927 PERL_UNUSED_VAR(ix);
11928 exception=AcquireExceptionInfo();
11929 perl_exception=newSVpv("",0);
11930 reference=SvRV(ST(0));
11931 av=(AV *) reference;
11932 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11934 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11935 if (image == (Image *) NULL)
11937 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11939 goto PerlException;
11942 for (i=1; i < items; i++)
11944 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
11946 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11948 PUSHs(sv_2mortal(newSVpv(message,0)));
11952 InheritPerlException(exception,perl_exception);
11953 exception=DestroyExceptionInfo(exception);
11954 SvREFCNT_dec(perl_exception);
11958 ###############################################################################
11962 # Q u e r y F o n t #
11966 ###############################################################################
11971 Image::Magick ref=NO_INIT
11978 message[MaxTextExtent];
11989 volatile const TypeInfo
11992 PERL_UNUSED_VAR(ref);
11993 PERL_UNUSED_VAR(ix);
11994 exception=AcquireExceptionInfo();
11995 perl_exception=newSVpv("",0);
12004 typelist=GetTypeInfoList("*",&types,exception);
12006 for (i=0; i < (ssize_t) types; i++)
12008 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12010 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12012 goto PerlException;
12014 EXTEND(sp,10*items);
12015 for (i=1; i < items; i++)
12017 name=(char *) SvPV(ST(i),na);
12018 type_info=GetTypeInfo(name,exception);
12019 if (type_info == (TypeInfo *) NULL)
12024 if (type_info->name == (char *) NULL)
12027 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12028 if (type_info->description == (char *) NULL)
12031 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12032 if (type_info->family == (char *) NULL)
12035 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12036 if (type_info->style == UndefinedStyle)
12039 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12040 type_info->style),0)));
12041 if (type_info->stretch == UndefinedStretch)
12044 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12045 type_info->stretch),0)));
12046 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12047 type_info->weight);
12048 PUSHs(sv_2mortal(newSVpv(message,0)));
12049 if (type_info->encoding == (char *) NULL)
12052 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12053 if (type_info->foundry == (char *) NULL)
12056 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12057 if (type_info->format == (char *) NULL)
12060 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12061 if (type_info->metrics == (char *) NULL)
12064 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12065 if (type_info->glyphs == (char *) NULL)
12068 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12072 InheritPerlException(exception,perl_exception);
12073 exception=DestroyExceptionInfo(exception);
12074 SvREFCNT_dec(perl_exception);
12078 ###############################################################################
12082 # Q u e r y F o n t M e t r i c s #
12086 ###############################################################################
12090 QueryFontMetrics(ref,...)
12091 Image::Magick ref=NO_INIT
12093 queryfontmetrics = 1
12140 *reference; /* reference is the SV* of ref=SvIV(reference) */
12145 PERL_UNUSED_VAR(ref);
12146 PERL_UNUSED_VAR(ix);
12147 exception=AcquireExceptionInfo();
12148 package_info=(struct PackageInfo *) NULL;
12149 perl_exception=newSVpv("",0);
12150 reference=SvRV(ST(0));
12151 av=(AV *) reference;
12152 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12154 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12155 if (image == (Image *) NULL)
12157 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12159 goto PerlException;
12161 package_info=ClonePackageInfo(info,exception);
12162 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12163 CloneString(&draw_info->text,"");
12164 current=draw_info->affine;
12165 GetAffineMatrix(&affine);
12168 EXTEND(sp,7*items);
12169 for (i=2; i < items; i+=2)
12171 attribute=(char *) SvPV(ST(i-1),na);
12172 switch (*attribute)
12177 if (LocaleCompare(attribute,"antialias") == 0)
12179 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12183 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12187 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12190 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12197 if (LocaleCompare(attribute,"density") == 0)
12199 CloneString(&draw_info->density,SvPV(ST(i),na));
12202 if (LocaleCompare(attribute,"direction") == 0)
12204 draw_info->direction=(DirectionType) ParseCommandOption(
12205 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12208 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12215 if (LocaleCompare(attribute,"encoding") == 0)
12217 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12220 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12227 if (LocaleCompare(attribute,"family") == 0)
12229 CloneString(&draw_info->family,SvPV(ST(i),na));
12232 if (LocaleCompare(attribute,"fill") == 0)
12235 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12236 &draw_info->fill,exception);
12239 if (LocaleCompare(attribute,"font") == 0)
12241 CloneString(&draw_info->font,SvPV(ST(i),na));
12244 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12251 if (LocaleCompare(attribute,"geometry") == 0)
12253 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12256 if (LocaleCompare(attribute,"gravity") == 0)
12258 draw_info->gravity=(GravityType) ParseCommandOption(
12259 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12262 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12269 if (LocaleCompare(attribute,"interline-spacing") == 0)
12271 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12272 draw_info->interline_spacing=geometry_info.rho;
12275 if (LocaleCompare(attribute,"interword-spacing") == 0)
12277 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12278 draw_info->interword_spacing=geometry_info.rho;
12281 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12288 if (LocaleCompare(attribute,"kerning") == 0)
12290 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12291 draw_info->kerning=geometry_info.rho;
12294 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12301 if (LocaleCompare(attribute,"pointsize") == 0)
12303 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12304 draw_info->pointsize=geometry_info.rho;
12307 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12314 if (LocaleCompare(attribute,"rotate") == 0)
12316 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12317 affine.rx=geometry_info.rho;
12318 affine.ry=geometry_info.sigma;
12319 if ((flags & SigmaValue) == 0)
12320 affine.ry=affine.rx;
12323 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12330 if (LocaleCompare(attribute,"scale") == 0)
12332 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12333 affine.sx=geometry_info.rho;
12334 affine.sy=geometry_info.sigma;
12335 if ((flags & SigmaValue) == 0)
12336 affine.sy=affine.sx;
12339 if (LocaleCompare(attribute,"skew") == 0)
12345 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12346 x_angle=geometry_info.rho;
12347 y_angle=geometry_info.sigma;
12348 if ((flags & SigmaValue) == 0)
12350 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12351 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12354 if (LocaleCompare(attribute,"stroke") == 0)
12357 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12358 &draw_info->stroke,exception);
12361 if (LocaleCompare(attribute,"style") == 0)
12363 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12367 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12371 draw_info->style=(StyleType) type;
12374 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12381 if (LocaleCompare(attribute,"text") == 0)
12383 CloneString(&draw_info->text,SvPV(ST(i),na));
12386 if (LocaleCompare(attribute,"translate") == 0)
12388 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12389 affine.tx=geometry_info.rho;
12390 affine.ty=geometry_info.sigma;
12391 if ((flags & SigmaValue) == 0)
12392 affine.ty=affine.tx;
12395 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12402 if (LocaleCompare(attribute,"weight") == 0)
12404 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12405 draw_info->weight=(size_t) geometry_info.rho;
12408 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12415 if (LocaleCompare(attribute,"x") == 0)
12417 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12418 x=geometry_info.rho;
12421 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12428 if (LocaleCompare(attribute,"y") == 0)
12430 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12431 y=geometry_info.rho;
12434 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12440 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12446 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12447 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12448 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12449 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12450 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12451 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12452 if (draw_info->geometry == (char *) NULL)
12454 draw_info->geometry=AcquireString((char *) NULL);
12455 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12456 "%.15g,%.15g",x,y);
12458 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12459 (void) CatchImageException(image);
12460 if (status == MagickFalse)
12464 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12465 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12466 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12467 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12468 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12469 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12470 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12471 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12472 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12473 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12474 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12475 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12476 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12478 draw_info=DestroyDrawInfo(draw_info);
12481 if (package_info != (struct PackageInfo *) NULL)
12482 DestroyPackageInfo(package_info);
12483 InheritPerlException(exception,perl_exception);
12484 exception=DestroyExceptionInfo(exception);
12485 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12489 ###############################################################################
12493 # 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 #
12497 ###############################################################################
12501 QueryMultilineFontMetrics(ref,...)
12502 Image::Magick ref=NO_INIT
12504 querymultilinefontmetrics = 1
12551 *reference; /* reference is the SV* of ref=SvIV(reference) */
12556 PERL_UNUSED_VAR(ref);
12557 PERL_UNUSED_VAR(ix);
12558 exception=AcquireExceptionInfo();
12559 package_info=(struct PackageInfo *) NULL;
12560 perl_exception=newSVpv("",0);
12561 reference=SvRV(ST(0));
12562 av=(AV *) reference;
12563 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12565 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12566 if (image == (Image *) NULL)
12568 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12570 goto PerlException;
12572 package_info=ClonePackageInfo(info,exception);
12573 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12574 CloneString(&draw_info->text,"");
12575 current=draw_info->affine;
12576 GetAffineMatrix(&affine);
12579 EXTEND(sp,7*items);
12580 for (i=2; i < items; i+=2)
12582 attribute=(char *) SvPV(ST(i-1),na);
12583 switch (*attribute)
12588 if (LocaleCompare(attribute,"antialias") == 0)
12590 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12594 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12598 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12608 if (LocaleCompare(attribute,"density") == 0)
12610 CloneString(&draw_info->density,SvPV(ST(i),na));
12613 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12620 if (LocaleCompare(attribute,"encoding") == 0)
12622 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12632 if (LocaleCompare(attribute,"family") == 0)
12634 CloneString(&draw_info->family,SvPV(ST(i),na));
12637 if (LocaleCompare(attribute,"fill") == 0)
12640 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12641 &draw_info->fill,exception);
12644 if (LocaleCompare(attribute,"font") == 0)
12646 CloneString(&draw_info->font,SvPV(ST(i),na));
12649 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12656 if (LocaleCompare(attribute,"geometry") == 0)
12658 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12661 if (LocaleCompare(attribute,"gravity") == 0)
12663 draw_info->gravity=(GravityType) ParseCommandOption(
12664 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12667 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12674 if (LocaleCompare(attribute,"pointsize") == 0)
12676 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12677 draw_info->pointsize=geometry_info.rho;
12680 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12687 if (LocaleCompare(attribute,"rotate") == 0)
12689 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12690 affine.rx=geometry_info.rho;
12691 affine.ry=geometry_info.sigma;
12692 if ((flags & SigmaValue) == 0)
12693 affine.ry=affine.rx;
12696 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12703 if (LocaleCompare(attribute,"scale") == 0)
12705 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12706 affine.sx=geometry_info.rho;
12707 affine.sy=geometry_info.sigma;
12708 if ((flags & SigmaValue) == 0)
12709 affine.sy=affine.sx;
12712 if (LocaleCompare(attribute,"skew") == 0)
12718 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12719 x_angle=geometry_info.rho;
12720 y_angle=geometry_info.sigma;
12721 if ((flags & SigmaValue) == 0)
12723 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12724 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12727 if (LocaleCompare(attribute,"stroke") == 0)
12730 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12731 &draw_info->stroke,exception);
12734 if (LocaleCompare(attribute,"style") == 0)
12736 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12740 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12744 draw_info->style=(StyleType) type;
12747 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12754 if (LocaleCompare(attribute,"text") == 0)
12756 CloneString(&draw_info->text,SvPV(ST(i),na));
12759 if (LocaleCompare(attribute,"translate") == 0)
12761 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12762 affine.tx=geometry_info.rho;
12763 affine.ty=geometry_info.sigma;
12764 if ((flags & SigmaValue) == 0)
12765 affine.ty=affine.tx;
12768 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12775 if (LocaleCompare(attribute,"weight") == 0)
12777 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12778 draw_info->weight=(size_t) geometry_info.rho;
12781 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12788 if (LocaleCompare(attribute,"x") == 0)
12790 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12791 x=geometry_info.rho;
12794 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12801 if (LocaleCompare(attribute,"y") == 0)
12803 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12804 y=geometry_info.rho;
12807 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12813 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12819 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12820 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12821 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12822 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12823 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12824 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12825 if (draw_info->geometry == (char *) NULL)
12827 draw_info->geometry=AcquireString((char *) NULL);
12828 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12829 "%.15g,%.15g",x,y);
12831 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12832 (void) CatchException(exception);
12833 if (status == MagickFalse)
12837 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12838 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12839 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12840 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12841 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12842 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12843 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12844 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12845 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12846 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12847 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12848 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12849 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12851 draw_info=DestroyDrawInfo(draw_info);
12854 if (package_info != (struct PackageInfo *) NULL)
12855 DestroyPackageInfo(package_info);
12856 InheritPerlException(exception,perl_exception);
12857 exception=DestroyExceptionInfo(exception);
12858 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12862 ###############################################################################
12866 # Q u e r y F o r m a t #
12870 ###############################################################################
12874 QueryFormat(ref,...)
12875 Image::Magick ref=NO_INIT
12892 volatile const MagickInfo
12895 PERL_UNUSED_VAR(ref);
12896 PERL_UNUSED_VAR(ix);
12897 exception=AcquireExceptionInfo();
12898 perl_exception=newSVpv("",0);
12902 format[MaxTextExtent];
12910 format_list=GetMagickInfoList("*",&types,exception);
12912 for (i=0; i < (ssize_t) types; i++)
12914 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12915 LocaleLower(format);
12916 PUSHs(sv_2mortal(newSVpv(format,0)));
12918 format_list=(const MagickInfo **)
12919 RelinquishMagickMemory((MagickInfo *) format_list);
12920 goto PerlException;
12922 EXTEND(sp,8*items);
12923 for (i=1; i < items; i++)
12925 name=(char *) SvPV(ST(i),na);
12926 magick_info=GetMagickInfo(name,exception);
12927 if (magick_info == (const MagickInfo *) NULL)
12932 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12933 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12934 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12935 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12936 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12937 if (magick_info->description == (char *) NULL)
12940 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12941 if (magick_info->module == (char *) NULL)
12944 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12948 InheritPerlException(exception,perl_exception);
12949 exception=DestroyExceptionInfo(exception);
12950 SvREFCNT_dec(perl_exception);
12954 ###############################################################################
12958 # Q u e r y O p t i o n #
12962 ###############################################################################
12966 QueryOption(ref,...)
12967 Image::Magick ref=NO_INIT
12988 PERL_UNUSED_VAR(ref);
12989 PERL_UNUSED_VAR(ix);
12990 exception=AcquireExceptionInfo();
12991 perl_exception=newSVpv("",0);
12992 EXTEND(sp,8*items);
12993 for (i=1; i < items; i++)
12995 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12997 options=GetCommandOptions((CommandOption) option);
12998 if (options == (char **) NULL)
13002 for (j=0; options[j] != (char *) NULL; j++)
13003 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13004 options=DestroyStringList(options);
13008 InheritPerlException(exception,perl_exception);
13009 exception=DestroyExceptionInfo(exception);
13010 SvREFCNT_dec(perl_exception);
13014 ###############################################################################
13022 ###############################################################################
13027 Image::Magick ref=NO_INIT
13074 *perl_exception, /* Perl variable for storing messages */
13079 PERL_UNUSED_VAR(ref);
13080 PERL_UNUSED_VAR(ix);
13081 exception=AcquireExceptionInfo();
13082 perl_exception=newSVpv("",0);
13084 package_info=(struct PackageInfo *) NULL;
13086 ac=(items < 2) ? 1 : items-1;
13087 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13089 length=(STRLEN *) NULL;
13090 if (list == (char **) NULL)
13092 ThrowPerlException(exception,ResourceLimitError,
13093 "MemoryAllocationFailed",PackageName);
13094 goto PerlException;
13096 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13097 if (length == (STRLEN *) NULL)
13099 ThrowPerlException(exception,ResourceLimitError,
13100 "MemoryAllocationFailed",PackageName);
13101 goto PerlException;
13103 if (sv_isobject(ST(0)) == 0)
13105 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13107 goto PerlException;
13109 reference=SvRV(ST(0));
13110 hv=SvSTASH(reference);
13111 if (SvTYPE(reference) != SVt_PVAV)
13113 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13115 goto PerlException;
13117 av=(AV *) reference;
13118 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13120 package_info=ClonePackageInfo(info,exception);
13123 *list=(char *) (*package_info->image_info->filename ?
13124 package_info->image_info->filename : "XC:black");
13126 for (n=0, i=0; i < ac; i++)
13128 list[n]=(char *) SvPV(ST(i+1),length[n]);
13129 if ((items >= 3) && strEQcase(list[n],"blob"))
13135 blob=(void *) (SvPV(ST(i+1),length[n]));
13136 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13138 if ((items >= 3) && strEQcase(list[n],"filename"))
13140 if ((items >= 3) && strEQcase(list[n],"file"))
13149 io_info=IoIFP(sv_2io(ST(i+1)));
13150 if (io_info == (PerlIO *) NULL)
13152 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13156 file=PerlIO_findFILE(io_info);
13157 if (file == (FILE *) NULL)
13159 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13163 SetImageInfoFile(package_info->image_info,file);
13165 if ((items >= 3) && strEQcase(list[n],"magick"))
13169 list[n]=(char *) NULL;
13171 status=ExpandFilenames(&n,&list);
13172 if (status == MagickFalse)
13174 ThrowPerlException(exception,ResourceLimitError,
13175 "MemoryAllocationFailed",PackageName);
13176 goto PerlException;
13179 for (i=0; i < n; i++)
13181 if ((package_info->image_info->file != (FILE *) NULL) ||
13182 (package_info->image_info->blob != (void *) NULL))
13184 image=ReadImages(package_info->image_info,exception);
13185 if (image != (Image *) NULL)
13186 DisassociateImageStream(image);
13190 (void) CopyMagickString(package_info->image_info->filename,list[i],
13192 image=ReadImages(package_info->image_info,exception);
13194 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13196 for ( ; image; image=image->next)
13198 AddImageToRegistry(sv,image);
13200 av_push(av,sv_bless(rv,hv));
13208 for (i=0; i < n; i++)
13209 if (list[i] != (char *) NULL)
13210 for (p=keep; list[i] != *p++; )
13211 if (*p == (char *) NULL)
13213 list[i]=(char *) RelinquishMagickMemory(list[i]);
13218 if (package_info != (struct PackageInfo *) NULL)
13219 DestroyPackageInfo(package_info);
13220 if (list && (list != keep))
13221 list=(char **) RelinquishMagickMemory(list);
13223 keep=(char **) RelinquishMagickMemory(keep);
13225 length=(STRLEN *) RelinquishMagickMemory(length);
13226 InheritPerlException(exception,perl_exception);
13227 exception=DestroyExceptionInfo(exception);
13228 sv_setiv(perl_exception,(IV) number_images);
13229 SvPOK_on(perl_exception);
13230 ST(0)=sv_2mortal(perl_exception);
13235 ###############################################################################
13243 ###############################################################################
13248 Image::Magick ref=NO_INIT
13271 PERL_UNUSED_VAR(ref);
13272 PERL_UNUSED_VAR(ix);
13273 exception=AcquireExceptionInfo();
13274 perl_exception=newSVpv("",0);
13275 reference=SvRV(ST(0));
13276 av=(AV *) reference;
13277 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13279 for (i=1; i < items; i++)
13280 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13281 SvPV(ST(i),na),exception);
13282 InheritPerlException(exception,perl_exception);
13283 exception=DestroyExceptionInfo(exception);
13284 SvREFCNT_dec(perl_exception); /* throw away all errors */
13288 ###############################################################################
13296 ###############################################################################
13301 Image::Magick ref=NO_INIT
13324 *reference; /* reference is the SV* of ref=SvIV(reference) */
13326 PERL_UNUSED_VAR(ref);
13327 PERL_UNUSED_VAR(ix);
13328 exception=AcquireExceptionInfo();
13329 perl_exception=newSVpv("",0);
13330 if (sv_isobject(ST(0)) == 0)
13332 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13334 goto PerlException;
13336 reference=SvRV(ST(0));
13337 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13339 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13341 for (i=2; i < items; i+=2)
13342 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13345 InheritPerlException(exception,perl_exception);
13346 exception=DestroyExceptionInfo(exception);
13347 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13348 SvPOK_on(perl_exception);
13349 ST(0)=sv_2mortal(perl_exception);
13354 ###############################################################################
13358 # S e t P i x e l #
13362 ###############################################################################
13367 Image::Magick ref=NO_INIT
13409 *reference; /* reference is the SV* of ref=SvIV(reference) */
13411 PERL_UNUSED_VAR(ref);
13412 PERL_UNUSED_VAR(ix);
13413 exception=AcquireExceptionInfo();
13414 perl_exception=newSVpv("",0);
13415 reference=SvRV(ST(0));
13416 av=(AV *) reference;
13417 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13419 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13420 if (image == (Image *) NULL)
13422 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13424 goto PerlException;
13427 normalize=MagickTrue;
13430 region.width=image->columns;
13433 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13434 channel=DefaultChannels;
13435 for (i=2; i < items; i+=2)
13437 attribute=(char *) SvPV(ST(i-1),na);
13438 switch (*attribute)
13443 if (LocaleCompare(attribute,"channel") == 0)
13448 option=ParseChannelOption(SvPV(ST(i),na));
13451 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13455 channel=(ChannelType) option;
13458 if (LocaleCompare(attribute,"color") == 0)
13460 if (SvTYPE(ST(i)) != SVt_RV)
13463 message[MaxTextExtent];
13465 (void) FormatLocaleString(message,MaxTextExtent,
13466 "invalid %.60s value",attribute);
13467 ThrowPerlException(exception,OptionError,message,
13470 av=(AV *) SvRV(ST(i));
13473 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13480 if (LocaleCompare(attribute,"geometry") == 0)
13482 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13485 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13492 if (LocaleCompare(attribute,"normalize") == 0)
13494 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13498 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13502 normalize=option != 0 ? MagickTrue : MagickFalse;
13505 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13512 if (LocaleCompare(attribute,"x") == 0)
13514 region.x=SvIV(ST(i));
13517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13524 if (LocaleCompare(attribute,"y") == 0)
13526 region.y=SvIV(ST(i));
13529 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13535 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13541 (void) SetImageStorageClass(image,DirectClass,exception);
13542 channel_mask=SetPixelChannelMask(image,channel);
13543 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13544 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13545 (SvTYPE(av) != SVt_PVAV))
13557 if (normalize != MagickFalse)
13558 scale=QuantumRange;
13559 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13562 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13563 av_fetch(av,i,0)))),q);
13566 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13569 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13570 av_fetch(av,i,0)))),q);
13573 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13576 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13577 av_fetch(av,i,0)))),q);
13580 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13581 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13583 SetPixelBlack(image,ClampToQuantum(scale*
13584 SvNV(*(av_fetch(av,i,0)))),q);
13587 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13590 SetPixelAlpha(image,ClampToQuantum(scale*
13591 SvNV(*(av_fetch(av,i,0)))),q);
13594 (void) SyncAuthenticPixels(image,exception);
13596 (void) SetPixelChannelMask(image,channel_mask);
13599 InheritPerlException(exception,perl_exception);
13600 exception=DestroyExceptionInfo(exception);
13601 SvREFCNT_dec(perl_exception);
13605 ###############################################################################
13613 ###############################################################################
13618 Image::Magick ref=NO_INIT
13657 PERL_UNUSED_VAR(ref);
13658 PERL_UNUSED_VAR(ix);
13659 exception=AcquireExceptionInfo();
13660 perl_exception=newSVpv("",0);
13664 if (sv_isobject(ST(0)) == 0)
13666 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13668 goto PerlException;
13670 reference=SvRV(ST(0));
13671 hv=SvSTASH(reference);
13673 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13675 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13676 if (image == (Image *) NULL)
13678 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13680 goto PerlException;
13682 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13688 for (i=2; i < items; i+=2)
13690 attribute=(char *) SvPV(ST(i-1),na);
13691 switch (*attribute)
13696 if (LocaleCompare(attribute,"offset") == 0)
13698 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13708 if (LocaleCompare(attribute,"stack") == 0)
13710 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13714 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13720 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13726 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13732 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13734 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13735 goto PerlException;
13736 for ( ; image; image=image->next)
13738 AddImageToRegistry(sv,image);
13740 av_push(av,sv_bless(rv,hv));
13743 exception=DestroyExceptionInfo(exception);
13744 ST(0)=av_reference;
13745 SvREFCNT_dec(perl_exception);
13749 InheritPerlException(exception,perl_exception);
13750 exception=DestroyExceptionInfo(exception);
13751 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13752 SvPOK_on(perl_exception);
13753 ST(0)=sv_2mortal(perl_exception);
13758 ###############################################################################
13762 # S t a t i s t i c s #
13766 ###############################################################################
13770 Statistics(ref,...)
13771 Image::Magick ref=NO_INIT
13773 StatisticsImage = 1
13775 statisticsimage = 3
13778 #define ChannelStatistics(channel) \
13780 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13781 (double) channel_statistics[channel].depth); \
13782 PUSHs(sv_2mortal(newSVpv(message,0))); \
13783 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13784 channel_statistics[channel].minima/scale); \
13785 PUSHs(sv_2mortal(newSVpv(message,0))); \
13786 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13787 channel_statistics[channel].maxima/scale); \
13788 PUSHs(sv_2mortal(newSVpv(message,0))); \
13789 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13790 channel_statistics[channel].mean/scale); \
13791 PUSHs(sv_2mortal(newSVpv(message,0))); \
13792 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13793 channel_statistics[channel].standard_deviation/scale); \
13794 PUSHs(sv_2mortal(newSVpv(message,0))); \
13795 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13796 channel_statistics[channel].kurtosis); \
13797 PUSHs(sv_2mortal(newSVpv(message,0))); \
13798 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13799 channel_statistics[channel].skewness); \
13800 PUSHs(sv_2mortal(newSVpv(message,0))); \
13807 message[MaxTextExtent];
13810 *channel_statistics;
13831 PERL_UNUSED_VAR(ref);
13832 PERL_UNUSED_VAR(ix);
13833 exception=AcquireExceptionInfo();
13834 perl_exception=newSVpv("",0);
13836 if (sv_isobject(ST(0)) == 0)
13838 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13840 goto PerlException;
13842 reference=SvRV(ST(0));
13845 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13846 if (image == (Image *) NULL)
13848 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13850 goto PerlException;
13852 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13854 for ( ; image; image=image->next)
13856 channel_statistics=GetImageStatistics(image,exception);
13857 if (channel_statistics == (ChannelStatistics *) NULL)
13860 EXTEND(sp,35*count);
13861 scale=(double) QuantumRange;
13862 ChannelStatistics(RedChannel);
13863 ChannelStatistics(GreenChannel);
13864 ChannelStatistics(BlueChannel);
13865 if (image->colorspace == CMYKColorspace)
13866 ChannelStatistics(BlackChannel);
13867 if (image->matte != MagickFalse)
13868 ChannelStatistics(AlphaChannel);
13869 channel_statistics=(ChannelStatistics *)
13870 RelinquishMagickMemory(channel_statistics);
13874 InheritPerlException(exception,perl_exception);
13875 exception=DestroyExceptionInfo(exception);
13876 SvREFCNT_dec(perl_exception);
13880 ###############################################################################
13884 # S y n c A u t h e n t i c P i x e l s #
13888 ###############################################################################
13892 SyncAuthenticPixels(ref,...)
13893 Image::Magick ref = NO_INIT
13895 Syncauthenticpixels = 1
13896 SyncImagePixels = 2
13897 syncimagepixels = 3
13916 PERL_UNUSED_VAR(ref);
13917 PERL_UNUSED_VAR(ix);
13918 exception=AcquireExceptionInfo();
13919 perl_exception=newSVpv("",0);
13920 if (sv_isobject(ST(0)) == 0)
13922 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13924 goto PerlException;
13927 reference=SvRV(ST(0));
13928 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13929 if (image == (Image *) NULL)
13931 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13933 goto PerlException;
13936 status=SyncAuthenticPixels(image,exception);
13937 if (status != MagickFalse)
13941 InheritPerlException(exception,perl_exception);
13942 exception=DestroyExceptionInfo(exception);
13943 SvREFCNT_dec(perl_exception); /* throw away all errors */
13947 ###############################################################################
13951 # T r a n s f o r m #
13955 ###############################################################################
13960 Image::Magick ref=NO_INIT
13998 PERL_UNUSED_VAR(ref);
13999 PERL_UNUSED_VAR(ix);
14000 exception=AcquireExceptionInfo();
14001 perl_exception=newSVpv("",0);
14005 if (sv_isobject(ST(0)) == 0)
14007 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14009 goto PerlException;
14011 reference=SvRV(ST(0));
14012 hv=SvSTASH(reference);
14014 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14016 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14017 if (image == (Image *) NULL)
14019 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14021 goto PerlException;
14023 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14027 crop_geometry=(char *) NULL;
14028 geometry=(char *) NULL;
14029 for (i=2; i < items; i+=2)
14031 attribute=(char *) SvPV(ST(i-1),na);
14032 switch (*attribute)
14037 if (LocaleCompare(attribute,"crop") == 0)
14039 crop_geometry=SvPV(ST(i),na);
14042 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14049 if (LocaleCompare(attribute,"geometry") == 0)
14051 geometry=SvPV(ST(i),na);
14054 if (LocaleCompare(attribute,"gravity") == 0)
14062 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
14063 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
14066 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14070 for (next=image; next; next=next->next)
14071 next->gravity=(GravityType) in;
14074 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14080 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14086 for ( ; image; image=image->next)
14088 clone=CloneImage(image,0,0,MagickTrue,exception);
14089 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
14090 goto PerlException;
14091 TransformImage(&clone,crop_geometry,geometry,exception);
14092 for ( ; clone; clone=clone->next)
14094 AddImageToRegistry(sv,clone);
14096 av_push(av,sv_bless(rv,hv));
14100 exception=DestroyExceptionInfo(exception);
14101 ST(0)=av_reference;
14102 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14106 InheritPerlException(exception,perl_exception);
14107 exception=DestroyExceptionInfo(exception);
14108 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14109 SvPOK_on(perl_exception);
14110 ST(0)=sv_2mortal(perl_exception);
14115 ###############################################################################
14123 ###############################################################################
14128 Image::Magick ref=NO_INIT
14136 filename[MaxTextExtent];
14160 PERL_UNUSED_VAR(ref);
14161 PERL_UNUSED_VAR(ix);
14162 exception=AcquireExceptionInfo();
14163 perl_exception=newSVpv("",0);
14165 package_info=(struct PackageInfo *) NULL;
14166 if (sv_isobject(ST(0)) == 0)
14168 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14170 goto PerlException;
14172 reference=SvRV(ST(0));
14173 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14174 if (image == (Image *) NULL)
14176 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14178 goto PerlException;
14180 package_info=ClonePackageInfo(info,exception);
14182 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14185 for (i=2; i < items; i+=2)
14186 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14188 (void) CopyMagickString(filename,package_info->image_info->filename,
14191 for (next=image; next; next=next->next)
14193 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14194 next->scene=scene++;
14196 SetImageInfo(package_info->image_info,(unsigned int)
14197 GetImageListLength(image),exception);
14198 for (next=image; next; next=next->next)
14200 (void) WriteImage(package_info->image_info,next,exception);
14202 if (package_info->image_info->adjoin)
14207 if (package_info != (struct PackageInfo *) NULL)
14208 DestroyPackageInfo(package_info);
14209 InheritPerlException(exception,perl_exception);
14210 exception=DestroyExceptionInfo(exception);
14211 sv_setiv(perl_exception,(IV) number_images);
14212 SvPOK_on(perl_exception);
14213 ST(0)=sv_2mortal(perl_exception);