2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv((IV) image); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"opacity", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"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}, {"opacity", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
440 {"sigma", RealReference}, {"x", IntegerReference},
441 {"y", IntegerReference} } },
442 { "Identify", { {"file", FileReference}, {"features", StringReference},
443 {"unique", MagickBooleanOptions} } },
444 { "SepiaTone", { {"threshold", RealReference} } },
445 { "SigmoidalContrast", { {"geometry", StringReference},
446 {"contrast", RealReference}, {"mid-point", RealReference},
447 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
448 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
449 {"height", IntegerReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"fuzz", StringReference},
451 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
452 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
453 {"sigma", RealReference}, {"x", IntegerReference},
454 {"y", IntegerReference}, {"background", StringReference} } },
455 { "ContrastStretch", { {"levels", StringReference},
456 {"black-point", RealReference},{"white-point", RealReference},
457 {"channel", MagickChannelOptions} } },
460 { "AdaptiveSharpen", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"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 { "Recolor", { {"matrix", ArrayReference} } },
481 { "Mask", { {"mask", ImageReference} } },
482 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
483 {"font", StringReference}, {"stroke", StringReference},
484 {"fill", StringReference}, {"strokewidth", RealReference},
485 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
486 {"background", StringReference},
487 {"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 { "ColorMatrix", { {"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 SiPrefixToDouble(const char *string,const double interval)
1038 value=InterpretLocaleValue(string,&q);
1040 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1042 switch (tolower((int) ((unsigned char) *q)))
1044 case '%': value*=pow(scale,0)*interval/100.0; break;
1045 case 'k': value*=pow(scale,1); break;
1046 case 'm': value*=pow(scale,2); break;
1047 case 'g': value*=pow(scale,3); break;
1048 case 't': value*=pow(scale,4); break;
1049 case 'p': value*=pow(scale,5); break;
1050 case 'e': value*=pow(scale,6); break;
1051 case 'z': value*=pow(scale,7); break;
1052 case 'y': value*=pow(scale,8); break;
1058 static inline ssize_t StringToLong(const char *value)
1060 return(strtol(value,(char **) NULL,10));
1063 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1064 const char *attribute,SV *sval,ExceptionInfo *exception)
1091 if (LocaleCompare(attribute,"adjoin") == 0)
1093 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1094 SvPV(sval,na)) : SvIV(sval);
1097 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1102 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1105 if (LocaleCompare(attribute,"alpha") == 0)
1107 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1108 SvPV(sval,na)) : SvIV(sval);
1111 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1115 for ( ; image; image=image->next)
1116 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
1119 if (LocaleCompare(attribute,"antialias") == 0)
1121 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1122 SvPV(sval,na)) : SvIV(sval);
1125 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1130 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1133 if (LocaleCompare(attribute,"area-limit") == 0)
1138 limit=MagickResourceInfinity;
1139 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1140 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1141 (void) SetMagickResourceLimit(AreaResource,limit);
1144 if (LocaleCompare(attribute,"attenuate") == 0)
1147 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1150 if (LocaleCompare(attribute,"authenticate") == 0)
1153 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1157 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1158 for ( ; image; image=image->next)
1159 SetImageProperty(image,attribute,SvPV(sval,na));
1165 if (LocaleCompare(attribute,"background") == 0)
1167 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1169 info->image_info->background_color=target_color;
1170 for ( ; image; image=image->next)
1171 image->background_color=target_color;
1174 if (LocaleCompare(attribute,"bias") == 0)
1176 for ( ; image; image=image->next)
1177 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1180 if (LocaleCompare(attribute,"blue-primary") == 0)
1182 for ( ; image; image=image->next)
1184 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1185 image->chromaticity.blue_primary.x=geometry_info.rho;
1186 image->chromaticity.blue_primary.y=geometry_info.sigma;
1187 if ((flags & SigmaValue) == 0)
1188 image->chromaticity.blue_primary.y=
1189 image->chromaticity.blue_primary.x;
1193 if (LocaleCompare(attribute,"bordercolor") == 0)
1195 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1197 info->image_info->border_color=target_color;
1198 for ( ; image; image=image->next)
1199 image->border_color=target_color;
1203 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1204 for ( ; image; image=image->next)
1205 SetImageProperty(image,attribute,SvPV(sval,na));
1211 if (LocaleCompare(attribute,"cache-threshold") == 0)
1213 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1214 SiPrefixToDouble(SvPV(sval,na),100.0));
1215 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1216 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1219 if (LocaleCompare(attribute,"clip-mask") == 0)
1224 clip_mask=(Image *) NULL;
1226 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1227 for ( ; image; image=image->next)
1228 SetImageClipMask(image,clip_mask,exception);
1231 if (LocaleNCompare(attribute,"colormap",8) == 0)
1233 for ( ; image; image=image->next)
1241 if (image->storage_class == DirectClass)
1244 items=sscanf(attribute,"%*[^[][%ld",&i);
1246 if (i > (ssize_t) image->colors)
1248 if ((strchr(SvPV(sval,na),',') == 0) ||
1249 (strchr(SvPV(sval,na),')') != 0))
1250 QueryColorDatabase(SvPV(sval,na),image->colormap+i,exception);
1253 color=image->colormap+i;
1254 pixel.red=color->red;
1255 pixel.green=color->green;
1256 pixel.blue=color->blue;
1257 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1258 pixel.red=geometry_info.rho;
1259 pixel.green=geometry_info.sigma;
1260 pixel.blue=geometry_info.xi;
1261 color->red=ClampToQuantum(pixel.red);
1262 color->green=ClampToQuantum(pixel.green);
1263 color->blue=ClampToQuantum(pixel.blue);
1268 if (LocaleCompare(attribute,"colorspace") == 0)
1270 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1271 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1274 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1278 for ( ; image; image=image->next)
1279 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1282 if (LocaleCompare(attribute,"comment") == 0)
1284 for ( ; image; image=image->next)
1285 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1286 info ? info->image_info : (ImageInfo *) NULL,image,
1287 SvPV(sval,na),exception));
1290 if (LocaleCompare(attribute,"compression") == 0)
1292 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1293 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1296 ThrowPerlException(exception,OptionError,
1297 "UnrecognizedImageCompression",SvPV(sval,na));
1301 info->image_info->compression=(CompressionType) sp;
1302 for ( ; image; image=image->next)
1303 image->compression=(CompressionType) sp;
1307 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1308 for ( ; image; image=image->next)
1309 SetImageProperty(image,attribute,SvPV(sval,na));
1315 if (LocaleCompare(attribute,"debug") == 0)
1317 SetLogEventMask(SvPV(sval,na));
1320 if (LocaleCompare(attribute,"delay") == 0)
1322 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1323 for ( ; image; image=image->next)
1325 image->delay=(size_t) floor(geometry_info.rho+0.5);
1326 if ((flags & SigmaValue) != 0)
1327 image->ticks_per_second=(ssize_t)
1328 floor(geometry_info.sigma+0.5);
1332 if (LocaleCompare(attribute,"disk-limit") == 0)
1337 limit=MagickResourceInfinity;
1338 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1339 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1340 (void) SetMagickResourceLimit(DiskResource,limit);
1343 if (LocaleCompare(attribute,"density") == 0)
1345 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1347 ThrowPerlException(exception,OptionError,"MissingGeometry",
1352 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1353 for ( ; image; image=image->next)
1355 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1356 image->x_resolution=geometry_info.rho;
1357 image->y_resolution=geometry_info.sigma;
1358 if ((flags & SigmaValue) == 0)
1359 image->y_resolution=image->x_resolution;
1363 if (LocaleCompare(attribute,"depth") == 0)
1366 info->image_info->depth=SvIV(sval);
1367 for ( ; image; image=image->next)
1368 (void) SetImageDepth(image,SvIV(sval));
1371 if (LocaleCompare(attribute,"dispose") == 0)
1373 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1374 SvPV(sval,na)) : SvIV(sval);
1377 ThrowPerlException(exception,OptionError,
1378 "UnrecognizedDisposeMethod",SvPV(sval,na));
1381 for ( ; image; image=image->next)
1382 image->dispose=(DisposeType) sp;
1385 if (LocaleCompare(attribute,"dither") == 0)
1389 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1390 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1393 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1397 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1401 if (LocaleCompare(attribute,"display") == 0)
1405 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1409 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1410 for ( ; image; image=image->next)
1411 SetImageProperty(image,attribute,SvPV(sval,na));
1417 if (LocaleCompare(attribute,"endian") == 0)
1419 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1420 SvPV(sval,na)) : SvIV(sval);
1423 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1428 info->image_info->endian=(EndianType) sp;
1429 for ( ; image; image=image->next)
1430 image->endian=(EndianType) sp;
1433 if (LocaleCompare(attribute,"extract") == 0)
1436 Set image extract geometry.
1438 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1442 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1443 for ( ; image; image=image->next)
1444 SetImageProperty(image,attribute,SvPV(sval,na));
1450 if (LocaleCompare(attribute,"filename") == 0)
1453 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1455 for ( ; image; image=image->next)
1456 (void) CopyMagickString(image->filename,SvPV(sval,na),
1460 if (LocaleCompare(attribute,"file") == 0)
1468 if (info == (struct PackageInfo *) NULL)
1470 io_info=IoIFP(sv_2io(sval));
1471 if (io_info == (PerlIO *) NULL)
1473 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1477 file=PerlIO_findFILE(io_info);
1478 if (file == (FILE *) NULL)
1480 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1484 SetImageInfoFile(info->image_info,file);
1487 if (LocaleCompare(attribute,"fill") == 0)
1490 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1493 if (LocaleCompare(attribute,"font") == 0)
1496 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1499 if (LocaleCompare(attribute,"foreground") == 0)
1501 if (LocaleCompare(attribute,"fuzz") == 0)
1504 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1505 for ( ; image; image=image->next)
1506 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1510 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1511 for ( ; image; image=image->next)
1512 SetImageProperty(image,attribute,SvPV(sval,na));
1518 if (LocaleCompare(attribute,"gamma") == 0)
1520 for ( ; image; image=image->next)
1521 image->gamma=SvNV(sval);
1524 if (LocaleCompare(attribute,"gravity") == 0)
1526 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1527 SvPV(sval,na)) : SvIV(sval);
1530 ThrowPerlException(exception,OptionError,
1531 "UnrecognizedGravityType",SvPV(sval,na));
1535 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1536 for ( ; image; image=image->next)
1537 image->gravity=(GravityType) sp;
1540 if (LocaleCompare(attribute,"green-primary") == 0)
1542 for ( ; image; image=image->next)
1544 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1545 image->chromaticity.green_primary.x=geometry_info.rho;
1546 image->chromaticity.green_primary.y=geometry_info.sigma;
1547 if ((flags & SigmaValue) == 0)
1548 image->chromaticity.green_primary.y=
1549 image->chromaticity.green_primary.x;
1554 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1555 for ( ; image; image=image->next)
1556 SetImageProperty(image,attribute,SvPV(sval,na));
1562 if (LocaleNCompare(attribute,"index",5) == 0)
1576 for ( ; image; image=image->next)
1578 if (image->storage_class != PseudoClass)
1582 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1584 image_view=AcquireCacheView(image);
1585 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1586 if (q != (Quantum *) NULL)
1588 items=sscanf(SvPV(sval,na),"%ld",&index);
1589 if ((index >= 0) && (index < (ssize_t) image->colors))
1590 SetPixelIndex(image,index,q);
1591 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1593 image_view=DestroyCacheView(image_view);
1597 if (LocaleCompare(attribute,"iterations") == 0)
1600 for ( ; image; image=image->next)
1601 image->iterations=SvIV(sval);
1604 if (LocaleCompare(attribute,"interlace") == 0)
1606 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1607 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1610 ThrowPerlException(exception,OptionError,
1611 "UnrecognizedInterlaceType",SvPV(sval,na));
1615 info->image_info->interlace=(InterlaceType) sp;
1616 for ( ; image; image=image->next)
1617 image->interlace=(InterlaceType) sp;
1621 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1622 for ( ; image; image=image->next)
1623 SetImageProperty(image,attribute,SvPV(sval,na));
1629 if (LocaleCompare(attribute,"label") == 0)
1631 for ( ; image; image=image->next)
1632 (void) SetImageProperty(image,"label",InterpretImageProperties(
1633 info ? info->image_info : (ImageInfo *) NULL,image,
1634 SvPV(sval,na),exception));
1637 if (LocaleCompare(attribute,"loop") == 0)
1640 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1641 for ( ; image; image=image->next)
1642 SetImageProperty(image,attribute,SvPV(sval,na));
1648 if (LocaleCompare(attribute,"magick") == 0)
1651 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1652 "%s:",SvPV(sval,na));
1653 for ( ; image; image=image->next)
1654 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1657 if (LocaleCompare(attribute,"map-limit") == 0)
1662 limit=MagickResourceInfinity;
1663 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1664 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1665 (void) SetMagickResourceLimit(MapResource,limit);
1668 if (LocaleCompare(attribute,"mask") == 0)
1673 mask=(Image *) NULL;
1675 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1676 for ( ; image; image=image->next)
1677 SetImageMask(image,mask,exception);
1680 if (LocaleCompare(attribute,"mattecolor") == 0)
1682 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
1684 info->image_info->matte_color=target_color;
1685 for ( ; image; image=image->next)
1686 image->matte_color=target_color;
1689 if (LocaleCompare(attribute,"matte") == 0)
1691 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1692 SvPV(sval,na)) : SvIV(sval);
1695 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1699 for ( ; image; image=image->next)
1700 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1703 if (LocaleCompare(attribute,"memory-limit") == 0)
1708 limit=MagickResourceInfinity;
1709 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1710 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1711 (void) SetMagickResourceLimit(MemoryResource,limit);
1714 if (LocaleCompare(attribute,"monochrome") == 0)
1716 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1717 SvPV(sval,na)) : SvIV(sval);
1720 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1725 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1726 for ( ; image; image=image->next)
1727 (void) SetImageType(image,BilevelType,exception);
1731 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1732 for ( ; image; image=image->next)
1733 SetImageProperty(image,attribute,SvPV(sval,na));
1739 if (LocaleCompare(attribute,"option") == 0)
1742 DefineImageOption(info->image_info,SvPV(sval,na));
1745 if (LocaleCompare(attribute,"orientation") == 0)
1747 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1748 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1751 ThrowPerlException(exception,OptionError,
1752 "UnrecognizedOrientationType",SvPV(sval,na));
1756 info->image_info->orientation=(OrientationType) sp;
1757 for ( ; image; image=image->next)
1758 image->orientation=(OrientationType) sp;
1762 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1763 for ( ; image; image=image->next)
1764 SetImageProperty(image,attribute,SvPV(sval,na));
1770 if (LocaleCompare(attribute,"page") == 0)
1775 geometry=GetPageGeometry(SvPV(sval,na));
1777 (void) CloneString(&info->image_info->page,geometry);
1778 for ( ; image; image=image->next)
1779 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1780 geometry=(char *) RelinquishMagickMemory(geometry);
1783 if (LocaleCompare(attribute,"pen") == 0)
1786 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1789 if (LocaleNCompare(attribute,"pixel",5) == 0)
1803 for ( ; image; image=image->next)
1805 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1809 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1811 image_view=AcquireCacheView(image);
1812 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1813 if (q != (Quantum *) NULL)
1815 if ((strchr(SvPV(sval,na),',') == 0) ||
1816 (strchr(SvPV(sval,na),')') != 0))
1817 QueryMagickColor(SvPV(sval,na),&pixel,exception);
1820 GetPixelInfo(image,&pixel);
1821 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1822 pixel.red=geometry_info.rho;
1823 if ((flags & SigmaValue) != 0)
1824 pixel.green=geometry_info.sigma;
1825 if ((flags & XiValue) != 0)
1826 pixel.blue=geometry_info.xi;
1827 if ((flags & PsiValue) != 0)
1828 pixel.alpha=geometry_info.psi;
1829 if ((flags & ChiValue) != 0)
1830 pixel.black=geometry_info.chi;
1832 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1833 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1834 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1835 if (image->colorspace == CMYKColorspace)
1836 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1837 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1838 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1840 image_view=DestroyCacheView(image_view);
1844 if (LocaleCompare(attribute,"pointsize") == 0)
1848 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1849 info->image_info->pointsize=geometry_info.rho;
1853 if (LocaleCompare(attribute,"preview") == 0)
1855 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1856 SvPV(sval,na)) : SvIV(sval);
1859 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1864 info->image_info->preview_type=(PreviewType) sp;
1868 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1869 for ( ; image; image=image->next)
1870 SetImageProperty(image,attribute,SvPV(sval,na));
1876 if (LocaleCompare(attribute,"quality") == 0)
1879 info->image_info->quality=SvIV(sval);
1880 for ( ; image; image=image->next)
1881 image->quality=SvIV(sval);
1885 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1886 for ( ; image; image=image->next)
1887 SetImageProperty(image,attribute,SvPV(sval,na));
1893 if (LocaleCompare(attribute,"red-primary") == 0)
1895 for ( ; image; image=image->next)
1897 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1898 image->chromaticity.red_primary.x=geometry_info.rho;
1899 image->chromaticity.red_primary.y=geometry_info.sigma;
1900 if ((flags & SigmaValue) == 0)
1901 image->chromaticity.red_primary.y=
1902 image->chromaticity.red_primary.x;
1906 if (LocaleCompare(attribute,"render") == 0)
1908 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1909 SvPV(sval,na)) : SvIV(sval);
1912 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1916 for ( ; image; image=image->next)
1917 image->rendering_intent=(RenderingIntent) sp;
1920 if (LocaleCompare(attribute,"repage") == 0)
1925 for ( ; image; image=image->next)
1927 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1928 if ((flags & WidthValue) != 0)
1930 if ((flags & HeightValue) == 0)
1931 geometry.height=geometry.width;
1932 image->page.width=geometry.width;
1933 image->page.height=geometry.height;
1935 if ((flags & AspectValue) != 0)
1937 if ((flags & XValue) != 0)
1938 image->page.x+=geometry.x;
1939 if ((flags & YValue) != 0)
1940 image->page.y+=geometry.y;
1944 if ((flags & XValue) != 0)
1946 image->page.x=geometry.x;
1947 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1948 image->page.width=image->columns+geometry.x;
1950 if ((flags & YValue) != 0)
1952 image->page.y=geometry.y;
1953 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1954 image->page.height=image->rows+geometry.y;
1961 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1962 for ( ; image; image=image->next)
1963 SetImageProperty(image,attribute,SvPV(sval,na));
1969 if (LocaleCompare(attribute,"sampling-factor") == 0)
1971 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1973 ThrowPerlException(exception,OptionError,"MissingGeometry",
1978 (void) CloneString(&info->image_info->sampling_factor,
1982 if (LocaleCompare(attribute,"scene") == 0)
1984 for ( ; image; image=image->next)
1985 image->scene=SvIV(sval);
1988 if (LocaleCompare(attribute,"server") == 0)
1990 if (LocaleCompare(attribute,"size") == 0)
1994 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1996 ThrowPerlException(exception,OptionError,"MissingGeometry",
2000 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2004 if (LocaleCompare(attribute,"stroke") == 0)
2007 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2011 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2012 for ( ; image; image=image->next)
2013 SetImageProperty(image,attribute,SvPV(sval,na));
2019 if (LocaleCompare(attribute,"texture") == 0)
2022 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2025 if (LocaleCompare(attribute,"thread-limit") == 0)
2030 limit=MagickResourceInfinity;
2031 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2032 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2033 (void) SetMagickResourceLimit(ThreadResource,limit);
2036 if (LocaleCompare(attribute,"tile-offset") == 0)
2041 geometry=GetPageGeometry(SvPV(sval,na));
2043 (void) CloneString(&info->image_info->page,geometry);
2044 for ( ; image; image=image->next)
2045 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2047 geometry=(char *) RelinquishMagickMemory(geometry);
2050 if (LocaleCompare(attribute,"time-limit") == 0)
2055 limit=MagickResourceInfinity;
2056 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2057 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2058 (void) SetMagickResourceLimit(TimeResource,limit);
2061 if (LocaleCompare(attribute,"transparent-color") == 0)
2063 (void) QueryColorDatabase(SvPV(sval,na),&target_color,exception);
2065 info->image_info->transparent_color=target_color;
2066 for ( ; image; image=image->next)
2067 image->transparent_color=target_color;
2070 if (LocaleCompare(attribute,"type") == 0)
2072 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2073 SvPV(sval,na)) : SvIV(sval);
2076 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2081 info->image_info->type=(ImageType) sp;
2082 for ( ; image; image=image->next)
2083 SetImageType(image,(ImageType) sp,exception);
2087 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2088 for ( ; image; image=image->next)
2089 SetImageProperty(image,attribute,SvPV(sval,na));
2095 if (LocaleCompare(attribute,"units") == 0)
2097 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2098 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2101 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2106 info->image_info->units=(ResolutionType) sp;
2107 for ( ; image; image=image->next)
2112 units=(ResolutionType) sp;
2113 if (image->units != units)
2114 switch (image->units)
2116 case UndefinedResolution:
2117 case PixelsPerInchResolution:
2119 if (units == PixelsPerCentimeterResolution)
2121 image->x_resolution*=2.54;
2122 image->y_resolution*=2.54;
2126 case PixelsPerCentimeterResolution:
2128 if (units == PixelsPerInchResolution)
2130 image->x_resolution/=2.54;
2131 image->y_resolution/=2.54;
2141 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2142 for ( ; image; image=image->next)
2143 SetImageProperty(image,attribute,SvPV(sval,na));
2149 if (LocaleCompare(attribute,"verbose") == 0)
2151 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2152 SvPV(sval,na)) : SvIV(sval);
2155 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2160 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2163 if (LocaleCompare(attribute,"view") == 0)
2166 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2169 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2171 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2172 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2175 ThrowPerlException(exception,OptionError,
2176 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2180 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2181 for ( ; image; image=image->next)
2182 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2186 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2187 for ( ; image; image=image->next)
2188 SetImageProperty(image,attribute,SvPV(sval,na));
2194 if (LocaleCompare(attribute,"white-point") == 0)
2196 for ( ; image; image=image->next)
2198 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2199 image->chromaticity.white_point.x=geometry_info.rho;
2200 image->chromaticity.white_point.y=geometry_info.sigma;
2201 if ((flags & SigmaValue) == 0)
2202 image->chromaticity.white_point.y=
2203 image->chromaticity.white_point.x;
2208 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2209 for ( ; image; image=image->next)
2210 SetImageProperty(image,attribute,SvPV(sval,na));
2216 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2217 for ( ; image; image=image->next)
2218 SetImageProperty(image,attribute,SvPV(sval,na));
2225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2229 % S e t u p L i s t %
2233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2235 % Method SetupList returns the list of all the images linked by their
2236 % image->next and image->previous link lists for use with ImageMagick. If
2237 % info is non-NULL, an info structure is returned in *info. If
2238 % reference_vector is non-NULL,an array of SV* are returned in
2239 % *reference_vector. Reference_vector is used when the images are going to be
2240 % replaced with new Image*'s.
2242 % The format of the SetupList routine is:
2244 % Image *SetupList(SV *reference,struct PackageInfo **info,
2245 % SV ***reference_vector,ExceptionInfo *exception)
2247 % A description of each parameter follows:
2249 % o list: a list of strings.
2251 % o string: a character string.
2253 % o exception: Return any errors or warnings in this structure.
2256 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2257 SV ***reference_vector,ExceptionInfo *exception)
2266 if (reference_vector)
2267 *reference_vector=NULL;
2272 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2273 if (info && (SvTYPE(reference) == SVt_PVAV))
2274 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2280 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2284 % s t r E Q c a s e %
2288 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2290 % strEQcase() compares two strings and returns 0 if they are the
2291 % same or if the second string runs out first. The comparison is case
2294 % The format of the strEQcase routine is:
2296 % ssize_t strEQcase(const char *p,const char *q)
2298 % A description of each parameter follows:
2300 % o p: a character string.
2302 % o q: a character string.
2306 static ssize_t strEQcase(const char *p,const char *q)
2314 for (i=0 ; (c=(*q)) != 0; i++)
2316 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2317 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2322 return(((*q == 0) && (*p == 0)) ? i : 0);
2326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2330 % I m a g e : : M a g i c k %
2334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2338 MODULE = Image::Magick PACKAGE = Image::Magick
2343 MagickCoreGenesis("PerlMagick",MagickFalse);
2344 SetWarningHandler(NULL);
2345 SetErrorHandler(NULL);
2346 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2347 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2353 if (magick_registry != (SplayTreeInfo *) NULL)
2354 magick_registry=DestroySplayTree(magick_registry);
2355 MagickCoreTerminus();
2359 constant(name,argument)
2364 ###############################################################################
2372 ###############################################################################
2377 Image::Magick ref=NO_INIT
2401 PERL_UNUSED_VAR(ref);
2402 PERL_UNUSED_VAR(ix);
2403 exception=AcquireExceptionInfo();
2404 perl_exception=newSVpv("",0);
2405 package_info=(struct PackageInfo *) NULL;
2406 if (sv_isobject(ST(0)) == 0)
2408 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2412 reference=SvRV(ST(0));
2413 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2414 if (image == (Image *) NULL)
2416 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2420 package_info=ClonePackageInfo(info,exception);
2422 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2425 for (i=2; i < items; i+=2)
2426 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2428 (void) AnimateImages(package_info->image_info,image,exception);
2429 (void) CatchImageException(image);
2432 if (package_info != (struct PackageInfo *) NULL)
2433 DestroyPackageInfo(package_info);
2434 InheritPerlException(exception,perl_exception);
2435 exception=DestroyExceptionInfo(exception);
2436 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2437 SvPOK_on(perl_exception);
2438 ST(0)=sv_2mortal(perl_exception);
2443 ###############################################################################
2451 ###############################################################################
2456 Image::Magick ref=NO_INIT
2494 PERL_UNUSED_VAR(ref);
2495 PERL_UNUSED_VAR(ix);
2496 exception=AcquireExceptionInfo();
2497 perl_exception=newSVpv("",0);
2501 if (sv_isobject(ST(0)) == 0)
2503 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2507 reference=SvRV(ST(0));
2508 hv=SvSTASH(reference);
2510 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2512 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2513 if (image == (Image *) NULL)
2515 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2519 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2524 for (i=2; i < items; i+=2)
2526 attribute=(char *) SvPV(ST(i-1),na);
2532 if (LocaleCompare(attribute,"stack") == 0)
2534 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2538 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2556 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2557 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2559 for ( ; image; image=image->next)
2561 AddImageToRegistry(sv,image);
2563 av_push(av,sv_bless(rv,hv));
2566 exception=DestroyExceptionInfo(exception);
2568 SvREFCNT_dec(perl_exception);
2572 InheritPerlException(exception,perl_exception);
2573 exception=DestroyExceptionInfo(exception);
2574 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2575 SvPOK_on(perl_exception);
2576 ST(0)=sv_2mortal(perl_exception);
2581 ###############################################################################
2589 ###############################################################################
2594 Image::Magick ref=NO_INIT
2625 PERL_UNUSED_VAR(ref);
2626 PERL_UNUSED_VAR(ix);
2627 exception=AcquireExceptionInfo();
2628 perl_exception=newSVpv("",0);
2630 if (sv_isobject(ST(0)) == 0)
2632 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2636 reference=SvRV(ST(0));
2637 hv=SvSTASH(reference);
2638 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2639 if (image == (Image *) NULL)
2641 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2645 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2646 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2649 Create blessed Perl array for the returned image.
2652 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2654 AddImageToRegistry(sv,image);
2656 av_push(av,sv_bless(rv,hv));
2658 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2659 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2660 "average-%.*s",(int) (MaxTextExtent-9),
2661 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2662 (void) CopyMagickString(image->filename,info->image_info->filename,
2664 SetImageInfo(info->image_info,0,exception);
2665 exception=DestroyExceptionInfo(exception);
2666 SvREFCNT_dec(perl_exception);
2670 InheritPerlException(exception,perl_exception);
2671 exception=DestroyExceptionInfo(exception);
2672 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2673 SvPOK_on(perl_exception);
2674 ST(0)=sv_2mortal(perl_exception);
2679 ###############################################################################
2683 # B l o b T o I m a g e #
2687 ###############################################################################
2691 BlobToImage(ref,...)
2692 Image::Magick ref=NO_INIT
2738 PERL_UNUSED_VAR(ref);
2739 PERL_UNUSED_VAR(ix);
2740 exception=AcquireExceptionInfo();
2741 perl_exception=newSVpv("",0);
2744 ac=(items < 2) ? 1 : items-1;
2745 length=(STRLEN *) NULL;
2746 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2747 if (list == (char **) NULL)
2749 ThrowPerlException(exception,ResourceLimitError,
2750 "MemoryAllocationFailed",PackageName);
2753 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2754 if (length == (STRLEN *) NULL)
2756 ThrowPerlException(exception,ResourceLimitError,
2757 "MemoryAllocationFailed",PackageName);
2760 if (sv_isobject(ST(0)) == 0)
2762 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2766 reference=SvRV(ST(0));
2767 hv=SvSTASH(reference);
2768 if (SvTYPE(reference) != SVt_PVAV)
2770 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2774 av=(AV *) reference;
2775 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2780 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2783 for (n=0, i=0; i < ac; i++)
2785 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2786 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2788 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2793 list[n]=(char *) NULL;
2795 for (i=number_images=0; i < n; i++)
2797 image=BlobToImage(info->image_info,list[i],length[i],exception);
2798 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2800 for ( ; image; image=image->next)
2802 AddImageToRegistry(sv,image);
2804 av_push(av,sv_bless(rv,hv));
2812 for (i=0; i < n; i++)
2813 if (list[i] != (char *) NULL)
2814 for (p=keep; list[i] != *p++; )
2815 if (*p == (char *) NULL)
2817 list[i]=(char *) RelinquishMagickMemory(list[i]);
2823 list=(char **) RelinquishMagickMemory(list);
2825 length=(STRLEN *) RelinquishMagickMemory(length);
2826 InheritPerlException(exception,perl_exception);
2827 exception=DestroyExceptionInfo(exception);
2828 sv_setiv(perl_exception,(IV) number_images);
2829 SvPOK_on(perl_exception);
2830 ST(0)=sv_2mortal(perl_exception);
2835 ###############################################################################
2843 ###############################################################################
2848 Image::Magick ref=NO_INIT
2881 PERL_UNUSED_VAR(ref);
2882 PERL_UNUSED_VAR(ix);
2883 exception=AcquireExceptionInfo();
2884 perl_exception=newSVpv("",0);
2886 if (sv_isobject(ST(0)) == 0)
2888 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2892 reference=SvRV(ST(0));
2893 hv=SvSTASH(reference);
2894 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2895 if (image == (Image *) NULL)
2897 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2902 Create blessed Perl array for the returned image.
2905 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2907 for ( ; image; image=image->next)
2909 clone=CloneImage(image,0,0,MagickTrue,exception);
2910 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2912 AddImageToRegistry(sv,clone);
2914 av_push(av,sv_bless(rv,hv));
2917 exception=DestroyExceptionInfo(exception);
2918 SvREFCNT_dec(perl_exception);
2922 InheritPerlException(exception,perl_exception);
2923 exception=DestroyExceptionInfo(exception);
2924 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2925 SvPOK_on(perl_exception);
2926 ST(0)=sv_2mortal(perl_exception);
2931 ###############################################################################
2939 ###############################################################################
2947 PERL_UNUSED_VAR(ref);
2948 if (magick_registry != (SplayTreeInfo *) NULL)
2953 ResetSplayTreeIterator(magick_registry);
2954 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2955 while (p != (Image *) NULL)
2958 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2964 ###############################################################################
2972 ###############################################################################
2977 Image::Magick ref=NO_INIT
3006 PERL_UNUSED_VAR(ref);
3007 PERL_UNUSED_VAR(ix);
3008 exception=AcquireExceptionInfo();
3009 perl_exception=newSVpv("",0);
3011 if (sv_isobject(ST(0)) == 0)
3013 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3017 reference=SvRV(ST(0));
3018 hv=SvSTASH(reference);
3020 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3022 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3023 if (image == (Image *) NULL)
3025 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3029 image=CoalesceImages(image,exception);
3030 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3032 for ( ; image; image=image->next)
3034 AddImageToRegistry(sv,image);
3036 av_push(av,sv_bless(rv,hv));
3039 exception=DestroyExceptionInfo(exception);
3041 SvREFCNT_dec(perl_exception);
3045 InheritPerlException(exception,perl_exception);
3046 exception=DestroyExceptionInfo(exception);
3047 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3048 SvPOK_on(perl_exception);
3049 ST(0)=sv_2mortal(perl_exception);
3054 ###############################################################################
3062 ###############################################################################
3067 Image::Magick ref=NO_INIT
3113 PERL_UNUSED_VAR(ref);
3114 PERL_UNUSED_VAR(ix);
3115 exception=AcquireExceptionInfo();
3116 perl_exception=newSVpv("",0);
3120 if (sv_isobject(ST(0)) == 0)
3122 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3126 reference=SvRV(ST(0));
3127 hv=SvSTASH(reference);
3129 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3131 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3132 if (image == (Image *) NULL)
3134 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3138 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3142 reconstruct_image=image;
3143 metric=RootMeanSquaredErrorMetric;
3144 for (i=2; i < items; i+=2)
3146 attribute=(char *) SvPV(ST(i-1),na);
3152 if (LocaleCompare(attribute,"channel") == 0)
3157 option=ParseChannelOption(SvPV(ST(i),na));
3160 ThrowPerlException(exception,OptionError,
3161 "UnrecognizedType",SvPV(ST(i),na));
3164 SetPixelChannelMap(image,(ChannelType) option);
3167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3174 if (LocaleCompare(attribute,"fuzz") == 0)
3176 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3179 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3186 if (LocaleCompare(attribute,"image") == 0)
3188 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3189 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3192 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3199 if (LocaleCompare(attribute,"metric") == 0)
3201 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3205 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3209 metric=(MetricType) option;
3212 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3224 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3226 if (difference_image != (Image *) NULL)
3228 difference_image->error.mean_error_per_pixel=distortion;
3229 AddImageToRegistry(sv,difference_image);
3231 av_push(av,sv_bless(rv,hv));
3234 exception=DestroyExceptionInfo(exception);
3236 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3240 InheritPerlException(exception,perl_exception);
3241 exception=DestroyExceptionInfo(exception);
3242 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3243 SvPOK_on(perl_exception);
3244 ST(0)=sv_2mortal(perl_exception);
3249 ###############################################################################
3253 # C o m p a r e L a y e r s #
3257 ###############################################################################
3262 Image::Magick ref=NO_INIT
3264 CompareImagesLayers = 1
3266 compareimagelayers = 3
3303 PERL_UNUSED_VAR(ref);
3304 PERL_UNUSED_VAR(ix);
3305 exception=AcquireExceptionInfo();
3306 perl_exception=newSVpv("",0);
3308 if (sv_isobject(ST(0)) == 0)
3310 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3314 reference=SvRV(ST(0));
3315 hv=SvSTASH(reference);
3317 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3319 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3320 if (image == (Image *) NULL)
3322 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3326 method=CompareAnyLayer;
3327 for (i=2; i < items; i+=2)
3329 attribute=(char *) SvPV(ST(i-1),na);
3335 if (LocaleCompare(attribute,"method") == 0)
3337 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3341 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3345 method=(ImageLayerMethod) option;
3348 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3354 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3360 image=CompareImagesLayers(image,method,exception);
3361 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3363 for ( ; image; image=image->next)
3365 AddImageToRegistry(sv,image);
3367 av_push(av,sv_bless(rv,hv));
3370 exception=DestroyExceptionInfo(exception);
3372 SvREFCNT_dec(perl_exception);
3376 InheritPerlException(exception,perl_exception);
3377 exception=DestroyExceptionInfo(exception);
3378 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3379 SvPOK_on(perl_exception);
3380 ST(0)=sv_2mortal(perl_exception);
3385 ###############################################################################
3393 ###############################################################################
3398 Image::Magick ref=NO_INIT
3404 PERL_UNUSED_VAR(ref);
3405 if (sv_isobject(ST(0)) == 0)
3406 croak("ReferenceIsNotMyType");
3407 reference=SvRV(ST(0));
3408 switch (SvTYPE(reference))
3413 message[MaxTextExtent];
3431 Array (AV *) reference
3433 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3434 XS_VERSION,reference);
3435 hv=gv_stashpv(PackageName, FALSE);
3438 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3442 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3444 info=(struct PackageInfo *) SvIV(sv);
3445 DestroyPackageInfo(info);
3447 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3457 Blessed scalar = (Image *) SvIV(reference)
3459 image=(Image *) SvIV(reference);
3460 if (image != (Image *) NULL)
3461 DeleteImageFromRegistry(reference,image);
3470 ###############################################################################
3478 ###############################################################################
3483 Image::Magick ref=NO_INIT
3507 PERL_UNUSED_VAR(ref);
3508 PERL_UNUSED_VAR(ix);
3509 exception=AcquireExceptionInfo();
3510 perl_exception=newSVpv("",0);
3511 package_info=(struct PackageInfo *) NULL;
3512 if (sv_isobject(ST(0)) == 0)
3514 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3518 reference=SvRV(ST(0));
3519 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3520 if (image == (Image *) NULL)
3522 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3526 package_info=ClonePackageInfo(info,exception);
3528 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3531 for (i=2; i < items; i+=2)
3532 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3534 (void) DisplayImages(package_info->image_info,image,exception);
3535 (void) CatchImageException(image);
3538 if (package_info != (struct PackageInfo *) NULL)
3539 DestroyPackageInfo(package_info);
3540 InheritPerlException(exception,perl_exception);
3541 exception=DestroyExceptionInfo(exception);
3542 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3543 SvPOK_on(perl_exception);
3544 ST(0)=sv_2mortal(perl_exception);
3549 ###############################################################################
3553 # E v a l u a t e I m a g e s #
3557 ###############################################################################
3562 Image::Magick ref=NO_INIT
3584 MagickEvaluateOperator
3599 PERL_UNUSED_VAR(ref);
3600 PERL_UNUSED_VAR(ix);
3601 exception=AcquireExceptionInfo();
3602 perl_exception=newSVpv("",0);
3604 if (sv_isobject(ST(0)) == 0)
3606 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3610 reference=SvRV(ST(0));
3611 hv=SvSTASH(reference);
3612 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3613 if (image == (Image *) NULL)
3615 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3619 op=MeanEvaluateOperator;
3625 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3629 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3633 op=(MagickEvaluateOperator) in;
3636 for (i=2; i < items; i+=2)
3638 attribute=(char *) SvPV(ST(i-1),na);
3644 if (LocaleCompare(attribute,"operator") == 0)
3649 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3650 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3653 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3657 op=(MagickEvaluateOperator) in;
3660 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3666 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3672 image=EvaluateImages(image,op,exception);
3673 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3676 Create blessed Perl array for the returned image.
3679 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3681 AddImageToRegistry(sv,image);
3683 av_push(av,sv_bless(rv,hv));
3685 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3686 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3687 "evaluate-%.*s",(int) (MaxTextExtent-9),
3688 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3689 (void) CopyMagickString(image->filename,info->image_info->filename,
3691 SetImageInfo(info->image_info,0,exception);
3692 exception=DestroyExceptionInfo(exception);
3693 SvREFCNT_dec(perl_exception);
3697 InheritPerlException(exception,perl_exception);
3698 exception=DestroyExceptionInfo(exception);
3699 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3700 SvPOK_on(perl_exception);
3701 ST(0)=sv_2mortal(perl_exception);
3706 ###############################################################################
3714 ###############################################################################
3719 Image::Magick ref=NO_INIT
3726 #define ChannelFeatures(channel,direction) \
3728 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3729 channel_features[channel].angular_second_moment[direction]); \
3730 PUSHs(sv_2mortal(newSVpv(message,0))); \
3731 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3732 channel_features[channel].contrast[direction]); \
3733 PUSHs(sv_2mortal(newSVpv(message,0))); \
3734 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3735 channel_features[channel].contrast[direction]); \
3736 PUSHs(sv_2mortal(newSVpv(message,0))); \
3737 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3738 channel_features[channel].variance_sum_of_squares[direction]); \
3739 PUSHs(sv_2mortal(newSVpv(message,0))); \
3740 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3741 channel_features[channel].inverse_difference_moment[direction]); \
3742 PUSHs(sv_2mortal(newSVpv(message,0))); \
3743 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3744 channel_features[channel].sum_average[direction]); \
3745 PUSHs(sv_2mortal(newSVpv(message,0))); \
3746 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3747 channel_features[channel].sum_variance[direction]); \
3748 PUSHs(sv_2mortal(newSVpv(message,0))); \
3749 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3750 channel_features[channel].sum_entropy[direction]); \
3751 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3753 channel_features[channel].entropy[direction]); \
3754 PUSHs(sv_2mortal(newSVpv(message,0))); \
3755 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3756 channel_features[channel].difference_variance[direction]); \
3757 PUSHs(sv_2mortal(newSVpv(message,0))); \
3758 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3759 channel_features[channel].difference_entropy[direction]); \
3760 PUSHs(sv_2mortal(newSVpv(message,0))); \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].measure_of_correlation_1[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].measure_of_correlation_2[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3767 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3768 channel_features[channel].maximum_correlation_coefficient[direction]); \
3769 PUSHs(sv_2mortal(newSVpv(message,0))); \
3777 message[MaxTextExtent];
3804 PERL_UNUSED_VAR(ref);
3805 PERL_UNUSED_VAR(ix);
3806 exception=AcquireExceptionInfo();
3807 perl_exception=newSVpv("",0);
3809 if (sv_isobject(ST(0)) == 0)
3811 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3815 reference=SvRV(ST(0));
3818 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3819 if (image == (Image *) NULL)
3821 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3825 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3827 for (i=2; i < items; i+=2)
3829 attribute=(char *) SvPV(ST(i-1),na);
3835 if (LocaleCompare(attribute,"distance") == 0)
3837 distance=StringToLong((char *) SvPV(ST(1),na));
3840 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3846 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3853 for ( ; image; image=image->next)
3855 channel_features=GetImageFeatures(image,distance,
3857 if (channel_features == (ChannelFeatures *) NULL)
3860 EXTEND(sp,75*count);
3861 for (i=0; i < 4; i++)
3863 ChannelFeatures(RedChannel,i);
3864 ChannelFeatures(GreenChannel,i);
3865 ChannelFeatures(BlueChannel,i);
3866 if (image->colorspace == CMYKColorspace)
3867 ChannelFeatures(BlackChannel,i);
3868 if (image->matte != MagickFalse)
3869 ChannelFeatures(AlphaChannel,i);
3871 channel_features=(ChannelFeatures *)
3872 RelinquishMagickMemory(channel_features);
3876 InheritPerlException(exception,perl_exception);
3877 exception=DestroyExceptionInfo(exception);
3878 SvREFCNT_dec(perl_exception);
3882 ###############################################################################
3890 ###############################################################################
3895 Image::Magick ref=NO_INIT
3933 PERL_UNUSED_VAR(ref);
3934 PERL_UNUSED_VAR(ix);
3935 exception=AcquireExceptionInfo();
3936 perl_exception=newSVpv("",0);
3938 if (sv_isobject(ST(0)) == 0)
3940 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3944 reference=SvRV(ST(0));
3945 hv=SvSTASH(reference);
3946 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3947 if (image == (Image *) NULL)
3949 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3953 background_color=image->background_color;
3955 (void) QueryColorDatabase((char *) SvPV(ST(1),na),&background_color,
3958 for (i=2; i < items; i+=2)
3960 attribute=(char *) SvPV(ST(i-1),na);
3966 if (LocaleCompare(attribute,"background") == 0)
3968 (void) QueryColorDatabase((char *) SvPV(ST(1),na),
3969 &background_color,exception);
3972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3984 image->background_color=background_color;
3985 image=MergeImageLayers(image,FlattenLayer,exception);
3986 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3989 Create blessed Perl array for the returned image.
3992 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3994 AddImageToRegistry(sv,image);
3996 av_push(av,sv_bless(rv,hv));
3998 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3999 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4000 "flatten-%.*s",(int) (MaxTextExtent-9),
4001 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4002 (void) CopyMagickString(image->filename,info->image_info->filename,
4004 SetImageInfo(info->image_info,0,exception);
4005 exception=DestroyExceptionInfo(exception);
4006 SvREFCNT_dec(perl_exception);
4010 InheritPerlException(exception,perl_exception);
4011 exception=DestroyExceptionInfo(exception);
4012 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4013 SvPOK_on(perl_exception); /* return messages in string context */
4014 ST(0)=sv_2mortal(perl_exception);
4019 ###############################################################################
4027 ###############################################################################
4032 Image::Magick ref=NO_INIT
4044 expression[MaxTextExtent];
4072 PERL_UNUSED_VAR(ref);
4073 PERL_UNUSED_VAR(ix);
4074 exception=AcquireExceptionInfo();
4075 perl_exception=newSVpv("",0);
4079 if (sv_isobject(ST(0)) == 0)
4081 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4085 reference=SvRV(ST(0));
4086 hv=SvSTASH(reference);
4088 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4090 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4091 if (image == (Image *) NULL)
4093 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4097 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4101 channel=DefaultChannels;
4102 (void) CopyMagickString(expression,"u",MaxTextExtent);
4104 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4106 for (i=2; i < items; i+=2)
4108 attribute=(char *) SvPV(ST(i-1),na);
4114 if (LocaleCompare(attribute,"channel") == 0)
4119 option=ParseChannelOption(SvPV(ST(i),na));
4122 ThrowPerlException(exception,OptionError,
4123 "UnrecognizedType",SvPV(ST(i),na));
4126 channel=(ChannelType) option;
4129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4136 if (LocaleCompare(attribute,"expression") == 0)
4138 (void) CopyMagickString(expression,SvPV(ST(i),na),
4142 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4148 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4154 channel_mask=SetPixelChannelMask(image,channel);
4155 image=FxImage(image,expression,exception);
4156 if (image != (Image *) NULL)
4157 (void) SetPixelChannelMask(image,channel_mask);
4158 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4160 for ( ; image; image=image->next)
4162 AddImageToRegistry(sv,image);
4164 av_push(av,sv_bless(rv,hv));
4167 exception=DestroyExceptionInfo(exception);
4169 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4173 InheritPerlException(exception,perl_exception);
4174 exception=DestroyExceptionInfo(exception);
4175 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4176 SvPOK_on(perl_exception);
4177 ST(0)=sv_2mortal(perl_exception);
4182 ###############################################################################
4190 ###############################################################################
4195 Image::Magick ref=NO_INIT
4206 color[MaxTextExtent];
4231 PERL_UNUSED_VAR(ref);
4232 PERL_UNUSED_VAR(ix);
4233 exception=AcquireExceptionInfo();
4234 perl_exception=newSVpv("",0);
4235 if (sv_isobject(ST(0)) == 0)
4237 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4241 reference=SvRV(ST(0));
4242 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4243 if (image == (Image *) NULL && !info)
4246 for (i=1; i < items; i++)
4248 attribute=(char *) SvPV(ST(i),na);
4255 if (LocaleCompare(attribute,"adjoin") == 0)
4258 s=newSViv((ssize_t) info->image_info->adjoin);
4259 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4262 if (LocaleCompare(attribute,"antialias") == 0)
4265 s=newSViv((ssize_t) info->image_info->antialias);
4266 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4269 if (LocaleCompare(attribute,"area") == 0)
4271 s=newSViv(GetMagickResource(AreaResource));
4272 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4275 if (LocaleCompare(attribute,"attenuate") == 0)
4280 value=GetImageProperty(image,attribute);
4281 if (value != (const char *) NULL)
4283 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4286 if (LocaleCompare(attribute,"authenticate") == 0)
4289 s=newSVpv(info->image_info->authenticate,0);
4290 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4293 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4300 if (LocaleCompare(attribute,"background") == 0)
4302 if (image == (Image *) NULL)
4304 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4305 QuantumFormat "," QuantumFormat "," QuantumFormat,
4306 image->background_color.red,image->background_color.green,
4307 image->background_color.blue,image->background_color.alpha);
4309 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4312 if (LocaleCompare(attribute,"base-columns") == 0)
4314 if (image != (Image *) NULL)
4315 s=newSViv((ssize_t) image->magick_columns);
4316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4319 if (LocaleCompare(attribute,"base-filename") == 0)
4321 if (image != (Image *) NULL)
4322 s=newSVpv(image->magick_filename,0);
4323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4326 if (LocaleCompare(attribute,"base-height") == 0)
4328 if (image != (Image *) NULL)
4329 s=newSViv((ssize_t) image->magick_rows);
4330 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4333 if (LocaleCompare(attribute,"base-rows") == 0)
4335 if (image != (Image *) NULL)
4336 s=newSViv((ssize_t) image->magick_rows);
4337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4340 if (LocaleCompare(attribute,"base-width") == 0)
4342 if (image != (Image *) NULL)
4343 s=newSViv((ssize_t) image->magick_columns);
4344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4347 if (LocaleCompare(attribute,"bias") == 0)
4349 if (image != (Image *) NULL)
4350 s=newSVnv(image->bias);
4351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4354 if (LocaleCompare(attribute,"blue-primary") == 0)
4356 if (image == (Image *) NULL)
4358 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4359 image->chromaticity.blue_primary.x,
4360 image->chromaticity.blue_primary.y);
4362 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4365 if (LocaleCompare(attribute,"bordercolor") == 0)
4367 if (image == (Image *) NULL)
4369 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4370 QuantumFormat "," QuantumFormat "," QuantumFormat,
4371 image->border_color.red,image->border_color.green,
4372 image->border_color.blue,image->border_color.alpha);
4374 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4377 if (LocaleCompare(attribute,"bounding-box") == 0)
4380 geometry[MaxTextExtent];
4385 if (image == (Image *) NULL)
4387 page=GetImageBoundingBox(image,&image->exception);
4388 (void) FormatLocaleString(geometry,MaxTextExtent,
4389 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4390 page.height,(double) page.x,(double) page.y);
4391 s=newSVpv(geometry,0);
4392 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4395 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4402 if (LocaleCompare(attribute,"class") == 0)
4404 if (image == (Image *) NULL)
4406 s=newSViv(image->storage_class);
4407 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4408 image->storage_class));
4410 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4413 if (LocaleCompare(attribute,"clip-mask") == 0)
4415 if (image != (Image *) NULL)
4421 if (image->mask == (Image *) NULL)
4422 ClipImage(image,exception);
4423 if (image->mask != (Image *) NULL)
4425 AddImageToRegistry(sv,image->mask);
4426 s=sv_bless(newRV(sv),SvSTASH(reference));
4429 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4432 if (LocaleCompare(attribute,"clip-path") == 0)
4434 if (image != (Image *) NULL)
4440 if (image->clip_mask == (Image *) NULL)
4441 ClipImage(image,exception);
4442 if (image->clip_mask != (Image *) NULL)
4444 AddImageToRegistry(sv,image->clip_mask);
4445 s=sv_bless(newRV(sv),SvSTASH(reference));
4448 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4451 if (LocaleCompare(attribute,"compression") == 0)
4453 j=info ? info->image_info->compression : image ?
4454 image->compression : UndefinedCompression;
4456 if (info->image_info->compression == UndefinedCompression)
4457 j=image->compression;
4459 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4462 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4465 if (LocaleCompare(attribute,"colorspace") == 0)
4467 j=image ? image->colorspace : RGBColorspace;
4469 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4472 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4475 if (LocaleCompare(attribute,"colors") == 0)
4477 if (image != (Image *) NULL)
4478 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4479 &image->exception));
4480 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4483 if (LocaleNCompare(attribute,"colormap",8) == 0)
4488 if (image == (Image *) NULL || !image->colormap)
4491 items=sscanf(attribute,"%*[^[][%ld",&j);
4493 if (j > (ssize_t) image->colors)
4495 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4496 QuantumFormat "," QuantumFormat "," QuantumFormat,
4497 image->colormap[j].red,image->colormap[j].green,
4498 image->colormap[j].blue,image->colormap[j].alpha);
4500 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4503 if (LocaleCompare(attribute,"columns") == 0)
4505 if (image != (Image *) NULL)
4506 s=newSViv((ssize_t) image->columns);
4507 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4510 if (LocaleCompare(attribute,"comment") == 0)
4515 value=GetImageProperty(image,attribute);
4516 if (value != (const char *) NULL)
4518 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4521 if (LocaleCompare(attribute,"copyright") == 0)
4523 s=newSVpv(GetMagickCopyright(),0);
4524 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4527 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4534 if (LocaleCompare(attribute,"density") == 0)
4537 geometry[MaxTextExtent];
4539 if (image == (Image *) NULL)
4541 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4542 image->x_resolution,image->y_resolution);
4543 s=newSVpv(geometry,0);
4544 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4547 if (LocaleCompare(attribute,"delay") == 0)
4549 if (image != (Image *) NULL)
4550 s=newSViv((ssize_t) image->delay);
4551 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4554 if (LocaleCompare(attribute,"depth") == 0)
4556 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4557 if (image != (Image *) NULL)
4558 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4559 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4562 if (LocaleCompare(attribute,"directory") == 0)
4564 if (image && image->directory)
4565 s=newSVpv(image->directory,0);
4566 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4569 if (LocaleCompare(attribute,"dispose") == 0)
4571 if (image == (Image *) NULL)
4574 s=newSViv(image->dispose);
4576 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4581 if (LocaleCompare(attribute,"disk") == 0)
4583 s=newSViv(GetMagickResource(DiskResource));
4584 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4587 if (LocaleCompare(attribute,"dither") == 0)
4590 s=newSViv((ssize_t) info->image_info->dither);
4591 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4594 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4596 if (info && info->image_info->server_name)
4597 s=newSVpv(info->image_info->server_name,0);
4598 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4608 if (LocaleCompare(attribute,"elapsed-time") == 0)
4610 if (image != (Image *) NULL)
4611 s=newSVnv(GetElapsedTime(&image->timer));
4612 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4615 if (LocaleCompare(attribute,"endian") == 0)
4617 j=info ? info->image_info->endian : image ? image->endian :
4620 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4622 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4625 if (LocaleCompare(attribute,"error") == 0)
4627 if (image != (Image *) NULL)
4628 s=newSVnv(image->error.mean_error_per_pixel);
4629 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4632 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4639 if (LocaleCompare(attribute,"filesize") == 0)
4641 if (image != (Image *) NULL)
4642 s=newSViv((ssize_t) GetBlobSize(image));
4643 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4646 if (LocaleCompare(attribute,"filename") == 0)
4648 if (info && info->image_info->filename &&
4649 *info->image_info->filename)
4650 s=newSVpv(info->image_info->filename,0);
4651 if (image != (Image *) NULL)
4652 s=newSVpv(image->filename,0);
4653 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4656 if (LocaleCompare(attribute,"filter") == 0)
4658 s=image ? newSViv(image->filter) : newSViv(0);
4659 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4662 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4665 if (LocaleCompare(attribute,"font") == 0)
4667 if (info && info->image_info->font)
4668 s=newSVpv(info->image_info->font,0);
4669 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4672 if (LocaleCompare(attribute,"foreground") == 0)
4674 if (LocaleCompare(attribute,"format") == 0)
4679 magick_info=(const MagickInfo *) NULL;
4680 if (info && (*info->image_info->magick != '\0'))
4681 magick_info=GetMagickInfo(info->image_info->magick,exception);
4682 if (image != (Image *) NULL)
4683 magick_info=GetMagickInfo(image->magick,&image->exception);
4684 if ((magick_info != (const MagickInfo *) NULL) &&
4685 (*magick_info->description != '\0'))
4686 s=newSVpv((char *) magick_info->description,0);
4687 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4690 if (LocaleCompare(attribute,"fuzz") == 0)
4693 s=newSVnv(info->image_info->fuzz);
4694 if (image != (Image *) NULL)
4695 s=newSVnv(image->fuzz);
4696 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4699 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4706 if (LocaleCompare(attribute,"gamma") == 0)
4708 if (image != (Image *) NULL)
4709 s=newSVnv(image->gamma);
4710 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4713 if (LocaleCompare(attribute,"geometry") == 0)
4715 if (image && image->geometry)
4716 s=newSVpv(image->geometry,0);
4717 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4720 if (LocaleCompare(attribute,"gravity") == 0)
4722 s=image ? newSViv(image->gravity) : newSViv(0);
4723 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4726 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4729 if (LocaleCompare(attribute,"green-primary") == 0)
4731 if (image == (Image *) NULL)
4733 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4734 image->chromaticity.green_primary.x,
4735 image->chromaticity.green_primary.y);
4737 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4740 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4747 if (LocaleCompare(attribute,"height") == 0)
4749 if (image != (Image *) NULL)
4750 s=newSViv((ssize_t) image->rows);
4751 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4754 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4761 if (LocaleCompare(attribute,"icc") == 0)
4763 if (image != (Image *) NULL)
4768 profile=GetImageProfile(image,"icc");
4769 if (profile != (StringInfo *) NULL)
4770 s=newSVpv((const char *) GetStringInfoDatum(profile),
4771 GetStringInfoLength(profile));
4773 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4776 if (LocaleCompare(attribute,"icm") == 0)
4778 if (image != (Image *) NULL)
4783 profile=GetImageProfile(image,"icm");
4784 if (profile != (const StringInfo *) NULL)
4785 s=newSVpv((const char *) GetStringInfoDatum(profile),
4786 GetStringInfoLength(profile));
4788 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4791 if (LocaleCompare(attribute,"id") == 0)
4793 if (image != (Image *) NULL)
4804 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4806 status=SetImageRegistry(ImageRegistryType,key,image,
4811 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4814 if (LocaleNCompare(attribute,"index",5) == 0)
4817 name[MaxTextExtent];
4826 register const Quantum
4832 if (image == (Image *) NULL)
4834 if (image->storage_class != PseudoClass)
4838 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4840 image_view=AcquireCacheView(image);
4841 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4842 if (p != (const Quantum *) NULL)
4844 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4845 GetPixelIndex(image,p));
4847 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4849 image_view=DestroyCacheView(image_view);
4852 if (LocaleCompare(attribute,"iptc") == 0)
4854 if (image != (Image *) NULL)
4859 profile=GetImageProfile(image,"iptc");
4860 if (profile != (const StringInfo *) NULL)
4861 s=newSVpv((const char *) GetStringInfoDatum(profile),
4862 GetStringInfoLength(profile));
4864 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4867 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4869 if (image != (Image *) NULL)
4870 s=newSViv((ssize_t) image->iterations);
4871 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4874 if (LocaleCompare(attribute,"interlace") == 0)
4876 j=info ? info->image_info->interlace : image ? image->interlace :
4879 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4882 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4885 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4892 if (LocaleCompare(attribute,"label") == 0)
4897 if (image == (Image *) NULL)
4899 value=GetImageProperty(image,"Label");
4900 if (value != (const char *) NULL)
4902 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4905 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4907 if (image != (Image *) NULL)
4908 s=newSViv((ssize_t) image->iterations);
4909 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4912 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4919 if (LocaleCompare(attribute,"magick") == 0)
4921 if (info && *info->image_info->magick)
4922 s=newSVpv(info->image_info->magick,0);
4923 if (image != (Image *) NULL)
4924 s=newSVpv(image->magick,0);
4925 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4928 if (LocaleCompare(attribute,"map") == 0)
4930 s=newSViv(GetMagickResource(MapResource));
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 if (LocaleCompare(attribute,"maximum-error") == 0)
4936 if (image != (Image *) NULL)
4937 s=newSVnv(image->error.normalized_maximum_error);
4938 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4941 if (LocaleCompare(attribute,"memory") == 0)
4943 s=newSViv(GetMagickResource(MemoryResource));
4944 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4947 if (LocaleCompare(attribute,"mean-error") == 0)
4949 if (image != (Image *) NULL)
4950 s=newSVnv(image->error.normalized_mean_error);
4951 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4954 if (LocaleCompare(attribute,"mime") == 0)
4956 if (info && *info->image_info->magick)
4957 s=newSVpv(MagickToMime(info->image_info->magick),0);
4958 if (image != (Image *) NULL)
4959 s=newSVpv(MagickToMime(image->magick),0);
4960 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4963 if (LocaleCompare(attribute,"mattecolor") == 0)
4965 if (image == (Image *) NULL)
4967 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4968 QuantumFormat "," QuantumFormat "," QuantumFormat,
4969 image->matte_color.red,image->matte_color.green,
4970 image->matte_color.blue,image->matte_color.alpha);
4972 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4975 if (LocaleCompare(attribute,"matte") == 0)
4977 if (image != (Image *) NULL)
4978 s=newSViv((ssize_t) image->matte);
4979 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4982 if (LocaleCompare(attribute,"mime") == 0)
4988 if (info && *info->image_info->magick)
4989 magick=info->image_info->magick;
4990 if (image != (Image *) NULL)
4991 magick=image->magick;
4997 mime=MagickToMime(magick);
4999 mime=(char *) RelinquishMagickMemory(mime);
5001 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5004 if (LocaleCompare(attribute,"monochrome") == 0)
5006 if (image == (Image *) NULL)
5008 j=info ? info->image_info->monochrome :
5009 IsImageMonochrome(image,&image->exception);
5011 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5014 if (LocaleCompare(attribute,"montage") == 0)
5016 if (image && image->montage)
5017 s=newSVpv(image->montage,0);
5018 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5021 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5028 if (LocaleCompare(attribute,"orientation") == 0)
5030 j=info ? info->image_info->orientation : image ?
5031 image->orientation : UndefinedOrientation;
5033 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5036 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5039 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5046 if (LocaleCompare(attribute,"page") == 0)
5048 if (info && info->image_info->page)
5049 s=newSVpv(info->image_info->page,0);
5050 if (image != (Image *) NULL)
5053 geometry[MaxTextExtent];
5055 (void) FormatLocaleString(geometry,MaxTextExtent,
5056 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5057 (double) image->page.height,(double) image->page.x,(double)
5059 s=newSVpv(geometry,0);
5061 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5064 if (LocaleCompare(attribute,"page.x") == 0)
5066 if (image != (Image *) NULL)
5067 s=newSViv((ssize_t) image->page.x);
5068 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5071 if (LocaleCompare(attribute,"page.y") == 0)
5073 if (image != (Image *) NULL)
5074 s=newSViv((ssize_t) image->page.y);
5075 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5078 if (LocaleNCompare(attribute,"pixel",5) == 0)
5081 tuple[MaxTextExtent];
5090 register const Quantum
5093 if (image == (Image *) NULL)
5097 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5099 p=GetVirtualPixels(image,x,y,1,1,exception);
5100 if (image->colorspace != CMYKColorspace)
5101 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5102 QuantumFormat "," QuantumFormat "," QuantumFormat,
5103 GetPixelRed(image,p),GetPixelGreen(image,p),
5104 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5106 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5107 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5108 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5109 GetPixelBlue(image,p),GetPixelBlack(image,p),
5110 GetPixelAlpha(image,p));
5112 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5115 if (LocaleCompare(attribute,"pointsize") == 0)
5118 s=newSViv((ssize_t) info->image_info->pointsize);
5119 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5122 if (LocaleCompare(attribute,"preview") == 0)
5124 s=newSViv(info->image_info->preview_type);
5125 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5126 info->image_info->preview_type));
5128 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5131 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5138 if (LocaleCompare(attribute,"quality") == 0)
5141 s=newSViv((ssize_t) info->image_info->quality);
5142 if (image != (Image *) NULL)
5143 s=newSViv((ssize_t) image->quality);
5144 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5147 if (LocaleCompare(attribute,"quantum") == 0)
5150 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5151 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5154 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5161 if (LocaleCompare(attribute,"rendering-intent") == 0)
5163 s=newSViv(image->rendering_intent);
5164 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5165 image->rendering_intent));
5167 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5170 if (LocaleCompare(attribute,"red-primary") == 0)
5172 if (image == (Image *) NULL)
5174 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5175 image->chromaticity.red_primary.x,
5176 image->chromaticity.red_primary.y);
5178 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5181 if (LocaleCompare(attribute,"rows") == 0)
5183 if (image != (Image *) NULL)
5184 s=newSViv((ssize_t) image->rows);
5185 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5195 if (LocaleCompare(attribute,"sampling-factor") == 0)
5197 if (info && info->image_info->sampling_factor)
5198 s=newSVpv(info->image_info->sampling_factor,0);
5199 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5202 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5204 if (info && info->image_info->server_name)
5205 s=newSVpv(info->image_info->server_name,0);
5206 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5209 if (LocaleCompare(attribute,"size") == 0)
5211 if (info && info->image_info->size)
5212 s=newSVpv(info->image_info->size,0);
5213 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5216 if (LocaleCompare(attribute,"scene") == 0)
5218 if (image != (Image *) NULL)
5219 s=newSViv((ssize_t) image->scene);
5220 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5223 if (LocaleCompare(attribute,"scenes") == 0)
5225 if (image != (Image *) NULL)
5226 s=newSViv((ssize_t) info->image_info->number_scenes);
5227 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5230 if (LocaleCompare(attribute,"signature") == 0)
5235 if (image == (Image *) NULL)
5237 (void) SignatureImage(image,exception);
5238 value=GetImageProperty(image,"Signature");
5239 if (value != (const char *) NULL)
5241 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5244 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5251 if (LocaleCompare(attribute,"taint") == 0)
5253 if (image != (Image *) NULL)
5254 s=newSViv((ssize_t) IsTaintImage(image));
5255 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5258 if (LocaleCompare(attribute,"texture") == 0)
5260 if (info && info->image_info->texture)
5261 s=newSVpv(info->image_info->texture,0);
5262 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5265 if (LocaleCompare(attribute,"total-ink-density") == 0)
5267 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5268 if (image != (Image *) NULL)
5269 s=newSVnv(GetImageTotalInkDensity(image));
5270 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5273 if (LocaleCompare(attribute,"transparent-color") == 0)
5275 if (image == (Image *) NULL)
5277 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5278 QuantumFormat "," QuantumFormat "," QuantumFormat,
5279 image->transparent_color.red,image->transparent_color.green,
5280 image->transparent_color.blue,image->transparent_color.alpha);
5282 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5285 if (LocaleCompare(attribute,"type") == 0)
5287 if (image == (Image *) NULL)
5289 j=(ssize_t) GetImageType(image,&image->exception);
5291 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5293 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5296 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5303 if (LocaleCompare(attribute,"units") == 0)
5305 j=info ? info->image_info->units : image ? image->units :
5306 UndefinedResolution;
5307 if (info && (info->image_info->units == UndefinedResolution))
5310 if (j == UndefinedResolution)
5311 s=newSVpv("undefined units",0);
5313 if (j == PixelsPerInchResolution)
5314 s=newSVpv("pixels / inch",0);
5316 s=newSVpv("pixels / centimeter",0);
5317 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5320 if (LocaleCompare(attribute,"user-time") == 0)
5322 if (image != (Image *) NULL)
5323 s=newSVnv(GetUserTime(&image->timer));
5324 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5327 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5334 if (LocaleCompare(attribute,"verbose") == 0)
5337 s=newSViv((ssize_t) info->image_info->verbose);
5338 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5341 if (LocaleCompare(attribute,"version") == 0)
5343 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5347 if (LocaleCompare(attribute,"view") == 0)
5349 if (info && info->image_info->view)
5350 s=newSVpv(info->image_info->view,0);
5351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5354 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5356 if (image == (Image *) NULL)
5358 j=(ssize_t) GetImageVirtualPixelMethod(image);
5360 (void) sv_setpv(s,CommandOptionToMnemonic(
5361 MagickVirtualPixelOptions,j));
5363 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5366 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5373 if (LocaleCompare(attribute,"white-point") == 0)
5375 if (image == (Image *) NULL)
5377 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5378 image->chromaticity.white_point.x,
5379 image->chromaticity.white_point.y);
5381 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5384 if (LocaleCompare(attribute,"width") == 0)
5386 if (image != (Image *) NULL)
5387 s=newSViv((ssize_t) image->columns);
5388 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5391 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5398 if (LocaleCompare(attribute,"x-resolution") == 0)
5400 if (image != (Image *) NULL)
5401 s=newSVnv(image->x_resolution);
5402 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5405 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5412 if (LocaleCompare(attribute,"y-resolution") == 0)
5414 if (image != (Image *) NULL)
5415 s=newSVnv(image->y_resolution);
5416 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5419 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5426 if (image == (Image *) NULL)
5427 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5431 value=GetImageProperty(image,attribute);
5432 if (value != (const char *) NULL)
5435 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5438 if (*attribute != '%')
5439 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5446 meta=InterpretImageProperties(info ? info->image_info :
5447 (ImageInfo *) NULL,image,attribute,exception);
5449 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5450 meta=(char *) RelinquishMagickMemory(meta);
5454 exception=DestroyExceptionInfo(exception);
5455 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5459 ###############################################################################
5463 # G e t A u t h e n t i c P i x e l s #
5467 ###############################################################################
5471 GetAuthenticPixels(ref,...)
5472 Image::Magick ref = NO_INIT
5474 getauthenticpixels = 1
5504 PERL_UNUSED_VAR(ref);
5505 PERL_UNUSED_VAR(ix);
5506 exception=AcquireExceptionInfo();
5507 perl_exception=newSVpv("",0);
5508 if (sv_isobject(ST(0)) == 0)
5510 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5514 reference=SvRV(ST(0));
5516 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5517 if (image == (Image *) NULL)
5519 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5526 region.width=image->columns;
5529 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5530 for (i=2; i < items; i+=2)
5532 attribute=(char *) SvPV(ST(i-1),na);
5538 if (LocaleCompare(attribute,"geometry") == 0)
5540 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5550 if (LocaleCompare(attribute,"height") == 0)
5552 region.height=SvIV(ST(i));
5555 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5562 if (LocaleCompare(attribute,"x") == 0)
5564 region.x=SvIV(ST(i));
5567 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5574 if (LocaleCompare(attribute,"y") == 0)
5576 region.y=SvIV(ST(i));
5579 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5586 if (LocaleCompare(attribute,"width") == 0)
5588 region.width=SvIV(ST(i));
5591 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5597 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5598 region.height,exception);
5599 if (blob != (void *) NULL)
5603 InheritPerlException(exception,perl_exception);
5604 exception=DestroyExceptionInfo(exception);
5605 SvREFCNT_dec(perl_exception); /* throw away all errors */
5614 ###############################################################################
5618 # G e t V i r t u a l P i x e l s #
5622 ###############################################################################
5626 GetVirtualPixels(ref,...)
5627 Image::Magick ref = NO_INIT
5629 getvirtualpixels = 1
5630 AcquireImagePixels = 2
5631 acquireimagepixels = 3
5659 PERL_UNUSED_VAR(ref);
5660 PERL_UNUSED_VAR(ix);
5661 exception=AcquireExceptionInfo();
5662 perl_exception=newSVpv("",0);
5663 if (sv_isobject(ST(0)) == 0)
5665 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5669 reference=SvRV(ST(0));
5671 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5672 if (image == (Image *) NULL)
5674 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5681 region.width=image->columns;
5684 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5685 for (i=2; i < items; i+=2)
5687 attribute=(char *) SvPV(ST(i-1),na);
5693 if (LocaleCompare(attribute,"geometry") == 0)
5695 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5705 if (LocaleCompare(attribute,"height") == 0)
5707 region.height=SvIV(ST(i));
5710 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5717 if (LocaleCompare(attribute,"x") == 0)
5719 region.x=SvIV(ST(i));
5722 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5729 if (LocaleCompare(attribute,"y") == 0)
5731 region.y=SvIV(ST(i));
5734 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5741 if (LocaleCompare(attribute,"width") == 0)
5743 region.width=SvIV(ST(i));
5746 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5752 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5753 region.height,exception);
5754 if (blob != (void *) NULL)
5758 InheritPerlException(exception,perl_exception);
5759 exception=DestroyExceptionInfo(exception);
5760 SvREFCNT_dec(perl_exception); /* throw away all errors */
5763 RETVAL = (void *) blob;
5769 ###############################################################################
5773 # G e t A u t h e n t i c M e t a c o n t e n t #
5777 ###############################################################################
5781 GetAuthenticMetacontent(ref,...)
5782 Image::Magick ref = NO_INIT
5784 getauthenticmetacontent = 1
5805 PERL_UNUSED_VAR(ref);
5806 PERL_UNUSED_VAR(ix);
5807 exception=AcquireExceptionInfo();
5808 perl_exception=newSVpv("",0);
5809 if (sv_isobject(ST(0)) == 0)
5811 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5815 reference=SvRV(ST(0));
5817 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5818 if (image == (Image *) NULL)
5820 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5825 blob=(void *) GetAuthenticMetacontent(image);
5826 if (blob != (void *) NULL)
5830 InheritPerlException(exception,perl_exception);
5831 exception=DestroyExceptionInfo(exception);
5832 SvREFCNT_dec(perl_exception); /* throw away all errors */
5841 ###############################################################################
5845 # G e t V i r t u a l M e t a c o n t e n t #
5849 ###############################################################################
5853 GetVirtualMetacontent(ref,...)
5854 Image::Magick ref = NO_INIT
5856 getvirtualmetacontent = 1
5875 PERL_UNUSED_VAR(ref);
5876 PERL_UNUSED_VAR(ix);
5877 exception=AcquireExceptionInfo();
5878 perl_exception=newSVpv("",0);
5879 if (sv_isobject(ST(0)) == 0)
5881 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5885 reference=SvRV(ST(0));
5887 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5888 if (image == (Image *) NULL)
5890 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5895 blob=(void *) GetVirtualMetacontent(image);
5896 if (blob != (void *) NULL)
5900 InheritPerlException(exception,perl_exception);
5901 exception=DestroyExceptionInfo(exception);
5902 SvREFCNT_dec(perl_exception); /* throw away all errors */
5911 ###############################################################################
5915 # H i s t o g r a m #
5919 ###############################################################################
5924 Image::Magick ref=NO_INIT
5935 message[MaxTextExtent];
5962 PERL_UNUSED_VAR(ref);
5963 PERL_UNUSED_VAR(ix);
5964 exception=AcquireExceptionInfo();
5965 perl_exception=newSVpv("",0);
5967 if (sv_isobject(ST(0)) == 0)
5969 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5973 reference=SvRV(ST(0));
5976 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5977 if (image == (Image *) NULL)
5979 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5983 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5985 for ( ; image; image=image->next)
5987 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5988 if (histogram == (PixelPacket *) NULL)
5990 count+=(ssize_t) number_colors;
5992 for (i=0; i < (ssize_t) number_colors; i++)
5994 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5996 PUSHs(sv_2mortal(newSVpv(message,0)));
5997 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
5998 histogram[i].green);
5999 PUSHs(sv_2mortal(newSVpv(message,0)));
6000 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6002 PUSHs(sv_2mortal(newSVpv(message,0)));
6003 if (image->colorspace == CMYKColorspace)
6005 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6006 histogram[i].black);
6007 PUSHs(sv_2mortal(newSVpv(message,0)));
6009 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6010 histogram[i].alpha);
6011 PUSHs(sv_2mortal(newSVpv(message,0)));
6012 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6013 histogram[i].count);
6014 PUSHs(sv_2mortal(newSVpv(message,0)));
6016 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6020 InheritPerlException(exception,perl_exception);
6021 exception=DestroyExceptionInfo(exception);
6022 SvREFCNT_dec(perl_exception);
6026 ###############################################################################
6034 ###############################################################################
6039 Image::Magick ref=NO_INIT
6063 register const Quantum
6077 *reference; /* reference is the SV* of ref=SvIV(reference) */
6079 PERL_UNUSED_VAR(ref);
6080 PERL_UNUSED_VAR(ix);
6081 exception=AcquireExceptionInfo();
6082 perl_exception=newSVpv("",0);
6083 reference=SvRV(ST(0));
6084 av=(AV *) reference;
6085 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6087 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6088 if (image == (Image *) NULL)
6090 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6094 normalize=MagickTrue;
6097 region.width=image->columns;
6100 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6101 for (i=2; i < items; i+=2)
6103 attribute=(char *) SvPV(ST(i-1),na);
6109 if (LocaleCompare(attribute,"channel") == 0)
6114 option=ParseChannelOption(SvPV(ST(i),na));
6117 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6121 SetPixelChannelMap(image,(ChannelType) option);
6124 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6131 if (LocaleCompare(attribute,"geometry") == 0)
6133 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6136 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6143 if (LocaleCompare(attribute,"normalize") == 0)
6145 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6149 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6153 normalize=option != 0 ? MagickTrue : MagickFalse;
6156 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6163 if (LocaleCompare(attribute,"x") == 0)
6165 region.x=SvIV(ST(i));
6168 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6175 if (LocaleCompare(attribute,"y") == 0)
6177 region.y=SvIV(ST(i));
6180 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6186 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6192 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6193 if (p == (const Quantum *) NULL)
6201 if (normalize != MagickFalse)
6202 scale=1.0/QuantumRange;
6203 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6204 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6205 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6206 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6207 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6208 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6209 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6210 (image->colorspace == CMYKColorspace))
6211 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6212 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6213 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6217 InheritPerlException(exception,perl_exception);
6218 exception=DestroyExceptionInfo(exception);
6219 SvREFCNT_dec(perl_exception);
6223 ###############################################################################
6227 # G e t P i x e l s #
6231 ###############################################################################
6236 Image::Magick ref=NO_INIT
6275 *reference; /* reference is the SV* of ref=SvIV(reference) */
6277 PERL_UNUSED_VAR(ref);
6278 PERL_UNUSED_VAR(ix);
6279 exception=AcquireExceptionInfo();
6280 perl_exception=newSVpv("",0);
6281 reference=SvRV(ST(0));
6282 av=(AV *) reference;
6283 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6285 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6286 if (image == (Image *) NULL)
6288 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6293 if (image->matte != MagickFalse)
6295 if (image->colorspace == CMYKColorspace)
6298 if (image->matte != MagickFalse)
6301 normalize=MagickFalse;
6304 region.width=image->columns;
6307 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6308 for (i=2; i < items; i+=2)
6310 attribute=(char *) SvPV(ST(i-1),na);
6316 if (LocaleCompare(attribute,"geometry") == 0)
6318 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6321 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6328 if (LocaleCompare(attribute,"height") == 0)
6330 region.height=SvIV(ST(i));
6333 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6340 if (LocaleCompare(attribute,"map") == 0)
6345 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6352 if (LocaleCompare(attribute,"normalize") == 0)
6354 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6358 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6362 normalize=option != 0 ? MagickTrue : MagickFalse;
6365 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6372 if (LocaleCompare(attribute,"width") == 0)
6374 region.width=SvIV(ST(i));
6377 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6384 if (LocaleCompare(attribute,"x") == 0)
6386 region.x=SvIV(ST(i));
6389 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6396 if (LocaleCompare(attribute,"y") == 0)
6398 region.y=SvIV(ST(i));
6401 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6407 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6413 if (normalize != MagickFalse)
6418 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6419 region.height*sizeof(*pixels));
6420 if (pixels == (float *) NULL)
6422 ThrowPerlException(exception,ResourceLimitError,
6423 "MemoryAllocationFailed",PackageName);
6426 status=ExportImagePixels(image,region.x,region.y,region.width,
6427 region.height,map,FloatPixel,pixels,exception);
6428 if (status == MagickFalse)
6432 EXTEND(sp,strlen(map)*region.width*region.height);
6433 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6434 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6436 pixels=(float *) RelinquishMagickMemory(pixels);
6443 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6444 region.height*sizeof(*pixels));
6445 if (pixels == (Quantum *) NULL)
6447 ThrowPerlException(exception,ResourceLimitError,
6448 "MemoryAllocationFailed",PackageName);
6451 status=ExportImagePixels(image,region.x,region.y,region.width,
6452 region.height,map,QuantumPixel,pixels,exception);
6453 if (status == MagickFalse)
6457 EXTEND(sp,strlen(map)*region.width*region.height);
6458 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6459 PUSHs(sv_2mortal(newSViv(pixels[i])));
6461 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6465 InheritPerlException(exception,perl_exception);
6466 exception=DestroyExceptionInfo(exception);
6467 SvREFCNT_dec(perl_exception);
6471 ###############################################################################
6475 # I m a g e T o B l o b #
6479 ###############################################################################
6483 ImageToBlob(ref,...)
6484 Image::Magick ref=NO_INIT
6493 filename[MaxTextExtent];
6522 PERL_UNUSED_VAR(ref);
6523 PERL_UNUSED_VAR(ix);
6524 exception=AcquireExceptionInfo();
6525 perl_exception=newSVpv("",0);
6526 package_info=(struct PackageInfo *) NULL;
6527 if (sv_isobject(ST(0)) == 0)
6529 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6533 reference=SvRV(ST(0));
6534 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6535 if (image == (Image *) NULL)
6537 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6541 package_info=ClonePackageInfo(info,exception);
6542 for (i=2; i < items; i+=2)
6543 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6544 (void) CopyMagickString(filename,package_info->image_info->filename,
6547 for (next=image; next; next=next->next)
6549 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6550 next->scene=scene++;
6552 SetImageInfo(package_info->image_info,(unsigned int)
6553 GetImageListLength(image),&image->exception);
6554 EXTEND(sp,(ssize_t) GetImageListLength(image));
6555 for ( ; image; image=image->next)
6558 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6559 if (blob != (char *) NULL)
6561 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6562 blob=(unsigned char *) RelinquishMagickMemory(blob);
6564 if (package_info->image_info->adjoin)
6569 if (package_info != (struct PackageInfo *) NULL)
6570 DestroyPackageInfo(package_info);
6571 InheritPerlException(exception,perl_exception);
6572 exception=DestroyExceptionInfo(exception);
6573 SvREFCNT_dec(perl_exception); /* throw away all errors */
6577 ###############################################################################
6585 ###############################################################################
6590 Image::Magick ref=NO_INIT
6594 OptimizeImageLayers = 3
6596 optimizeimagelayers = 5
6638 PERL_UNUSED_VAR(ref);
6639 PERL_UNUSED_VAR(ix);
6640 exception=AcquireExceptionInfo();
6641 perl_exception=newSVpv("",0);
6643 if (sv_isobject(ST(0)) == 0)
6645 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6649 reference=SvRV(ST(0));
6650 hv=SvSTASH(reference);
6652 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6654 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6655 if (image == (Image *) NULL)
6657 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6661 compose=image->compose;
6662 method=OptimizeLayer;
6663 for (i=2; i < items; i+=2)
6665 attribute=(char *) SvPV(ST(i-1),na);
6671 if (LocaleCompare(attribute,"compose") == 0)
6673 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6674 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6677 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6681 compose=(CompositeOperator) sp;
6684 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6691 if (LocaleCompare(attribute,"method") == 0)
6693 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6697 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6701 method=(ImageLayerMethod) option;
6704 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6710 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6716 layers=(Image *) NULL;
6719 case CompareAnyLayer:
6720 case CompareClearLayer:
6721 case CompareOverlayLayer:
6724 layers=CompareImagesLayers(image,method,exception);
6731 layers=MergeImageLayers(image,method,exception);
6736 layers=DisposeImages(image,exception);
6739 case OptimizeImageLayer:
6741 layers=OptimizeImageLayers(image,exception);
6744 case OptimizePlusLayer:
6746 layers=OptimizePlusImageLayers(image,exception);
6749 case OptimizeTransLayer:
6751 OptimizeImageTransparency(image,exception);
6752 InheritException(&(image->exception),exception);
6755 case RemoveDupsLayer:
6757 RemoveDuplicateLayers(&image,exception);
6758 InheritException(&(image->exception),exception);
6761 case RemoveZeroLayer:
6763 RemoveZeroDelayLayers(&image,exception);
6764 InheritException(&(image->exception),exception);
6773 General Purpose, GIF Animation Optimizer.
6775 layers=CoalesceImages(image,exception);
6776 if (layers == (Image *) NULL)
6778 InheritException(&(layers->exception),exception);
6780 layers=OptimizeImageLayers(image,exception);
6781 if (layers == (Image *) NULL)
6783 InheritException(&(layers->exception),exception);
6784 image=DestroyImageList(image);
6786 layers=(Image *) NULL;
6787 OptimizeImageTransparency(image,exception);
6788 InheritException(&(image->exception),exception);
6789 quantize_info=AcquireQuantizeInfo(info->image_info);
6790 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6791 quantize_info=DestroyQuantizeInfo(quantize_info);
6794 case CompositeLayer:
6803 Split image sequence at the first 'NULL:' image.
6806 while (source != (Image *) NULL)
6808 source=GetNextImageInList(source);
6809 if ((source != (Image *) NULL) &&
6810 (LocaleCompare(source->magick,"NULL") == 0))
6813 if (source != (Image *) NULL)
6815 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6816 (GetNextImageInList(source) == (Image *) NULL))
6817 source=(Image *) NULL;
6821 Separate the two lists, junk the null: image.
6823 source=SplitImageList(source->previous);
6824 DeleteImageFromList(&source);
6827 if (source == (Image *) NULL)
6829 (void) ThrowMagickException(exception,GetMagickModule(),
6830 OptionError,"MissingNullSeparator","layers Composite");
6834 Adjust offset with gravity and virtual canvas.
6836 SetGeometry(image,&geometry);
6837 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6838 geometry.width=source->page.width != 0 ? source->page.width :
6840 geometry.height=source->page.height != 0 ? source->page.height :
6842 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6843 image->columns,image->page.height != 0 ? image->page.height :
6844 image->rows,image->gravity,&geometry);
6845 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6846 source=DestroyImageList(source);
6847 InheritException(&(image->exception),exception);
6851 if (layers != (Image *) NULL)
6853 InheritException(&(layers->exception),exception);
6856 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6858 for ( ; image; image=image->next)
6860 AddImageToRegistry(sv,image);
6862 av_push(av,sv_bless(rv,hv));
6865 exception=DestroyExceptionInfo(exception);
6867 SvREFCNT_dec(perl_exception);
6871 InheritPerlException(exception,perl_exception);
6872 exception=DestroyExceptionInfo(exception);
6873 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6874 SvPOK_on(perl_exception);
6875 ST(0)=sv_2mortal(perl_exception);
6880 ###############################################################################
6884 # M a g i c k T o M i m e #
6888 ###############################################################################
6892 MagickToMime(ref,name)
6893 Image::Magick ref=NO_INIT
6902 PERL_UNUSED_VAR(ref);
6903 PERL_UNUSED_VAR(ix);
6904 mime=MagickToMime(name);
6905 RETVAL=newSVpv(mime,0);
6906 mime=(char *) RelinquishMagickMemory(mime);
6912 ###############################################################################
6920 ###############################################################################
6925 Image::Magick ref=NO_INIT
6962 MedianConvolveImage = 36
6968 ReduceNoiseImage = 42
6994 ColorFloodfillImage= 68
7000 CycleColormapImage = 74
7010 MatteFloodfillImage= 84
7018 NumberColorsImage = 92
7028 SignatureImage = 102
7038 TransparentImage = 112
7040 ThresholdImage = 114
7054 DeconstructImage = 130
7056 GaussianBlurImage = 132
7062 UnsharpMaskImage = 138
7064 MotionBlurImage = 140
7066 OrderedDitherImage = 142
7073 AffineTransform = 149
7074 AffineTransformImage = 150
7076 DifferenceImage = 152
7077 AdaptiveThreshold = 153
7078 AdaptiveThresholdImage = 154
7083 BlackThreshold = 159
7084 BlackThresholdImage= 160
7085 WhiteThreshold = 161
7086 WhiteThresholdImage= 162
7088 RadialBlurImage = 164
7090 ThumbnailImage = 166
7100 PosterizeImage = 176
7106 SepiaToneImage = 182
7107 SigmoidalContrast = 183
7108 SigmoidalContrastImage = 184
7113 ContrastStretch = 189
7114 ContrastStretchImage = 190
7119 AdaptiveSharpen = 195
7120 AdaptiveSharpenImage = 196
7122 TransposeImage = 198
7124 TransverseImage = 200
7126 AutoOrientImage = 202
7128 AdaptiveBlurImage = 204
7132 UniqueColorsImage = 208
7133 AdaptiveResize = 209
7134 AdaptiveResizeImage= 210
7138 LinearStretchImage = 214
7145 FloodfillPaint = 221
7146 FloodfillPaintImage= 222
7152 LiquidRescaleImage = 228
7162 SparseColorImage = 238
7166 SelectiveBlurImage = 242
7170 BlueShiftImage = 246
7171 ForwardFourierTransform = 247
7172 ForwardFourierTransformImage = 248
7173 InverseFourierTransform = 249
7174 InverseFourierTransformImage = 250
7175 ColorDecisionList = 251
7176 ColorDecisionListImage = 252
7178 AutoGammaImage = 254
7180 AutoLevelImage = 256
7182 LevelImageColors = 258
7185 BrightnessContrast = 263
7186 BrightnessContrastImage = 264
7188 MorphologyImage = 266
7190 ColorMatrixImage = 268
7196 StatisticImage = 274
7205 attribute_flag[MaxArguments],
7206 message[MaxTextExtent];
7267 argument_list[MaxArguments];
7269 PERL_UNUSED_VAR(ref);
7270 PERL_UNUSED_VAR(ix);
7271 exception=AcquireExceptionInfo();
7272 perl_exception=newSVpv("",0);
7273 reference_vector=NULL;
7277 if (sv_isobject(ST(0)) == 0)
7279 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7283 reference=SvRV(ST(0));
7284 region_info.width=0;
7285 region_info.height=0;
7288 region_image=(Image *) NULL;
7289 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7290 if (ix && (ix != 666))
7293 Called as Method(...)
7296 rp=(&Methods[ix-1]);
7302 Called as Mogrify("Method",...)
7304 attribute=(char *) SvPV(ST(1),na);
7307 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7308 attribute=(char *) SvPV(ST(2),na);
7311 for (rp=Methods; ; rp++)
7313 if (rp >= EndOf(Methods))
7315 ThrowPerlException(exception,OptionError,
7316 "UnrecognizedPerlMagickMethod",attribute);
7319 if (strEQcase(attribute,rp->name))
7325 if (image == (Image *) NULL)
7327 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7330 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7331 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7332 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7349 pp=(Arguments *) NULL;
7357 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7359 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7361 if (strEQcase(attribute,qq->method) > ssize_test)
7364 ssize_test=strEQcase(attribute,qq->method);
7367 if (pp == (Arguments *) NULL)
7369 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7371 goto continue_outer_loop;
7373 al=(&argument_list[pp-rp->arguments]);
7376 case ArrayReference:
7378 if (SvTYPE(sv) != SVt_RV)
7380 (void) FormatLocaleString(message,MaxTextExtent,
7381 "invalid %.60s value",pp->method);
7382 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7383 goto continue_outer_loop;
7385 al->array_reference=SvRV(sv);
7390 al->real_reference=SvNV(sv);
7395 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7398 case ImageReference:
7400 if (!sv_isobject(sv) ||
7401 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7402 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7404 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7410 case IntegerReference:
7412 al->integer_reference=SvIV(sv);
7415 case StringReference:
7417 al->string_reference=(char *) SvPV(sv,al->length);
7418 if (sv_isobject(sv))
7419 al->image_reference=SetupList(aTHX_ SvRV(sv),
7420 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7426 Is a string; look up name.
7428 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7430 al->string_reference=(char *) SvPV(sv,al->length);
7431 al->integer_reference=(-1);
7434 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7435 MagickFalse,SvPV(sv,na));
7436 if (pp->type == MagickChannelOptions)
7437 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7438 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7440 (void) FormatLocaleString(message,MaxTextExtent,
7441 "invalid %.60s value",pp->method);
7442 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7443 goto continue_outer_loop;
7448 attribute_flag[pp-rp->arguments]++;
7449 continue_outer_loop: ;
7451 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7452 pv=reference_vector;
7453 SetGeometryInfo(&geometry_info);
7454 channel=DefaultChannels;
7455 for (next=image; next; next=next->next)
7458 SetGeometry(image,&geometry);
7459 if ((region_info.width*region_info.height) != 0)
7462 image=CropImage(image,®ion_info,exception);
7468 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7469 ThrowPerlException(exception,OptionError,
7470 "UnrecognizedPerlMagickMethod",message);
7473 case 1: /* Comment */
7475 if (attribute_flag[0] == 0)
7476 argument_list[0].string_reference=(char *) NULL;
7477 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7478 info ? info->image_info : (ImageInfo *) NULL,image,
7479 argument_list[0].string_reference,exception));
7484 if (attribute_flag[0] == 0)
7485 argument_list[0].string_reference=(char *) NULL;
7486 (void) SetImageProperty(image,"label",InterpretImageProperties(
7487 info ? info->image_info : (ImageInfo *) NULL,image,
7488 argument_list[0].string_reference,exception));
7491 case 3: /* AddNoise */
7493 if (attribute_flag[0] == 0)
7494 argument_list[0].integer_reference=UniformNoise;
7495 if (attribute_flag[1] != 0)
7496 channel=(ChannelType) argument_list[1].integer_reference;
7497 channel_mask=SetPixelChannelMask(image,channel);
7498 image=AddNoiseImage(image,(NoiseType)
7499 argument_list[0].integer_reference,exception);
7500 if (image != (Image *) NULL)
7501 (void) SetPixelChannelMask(image,channel_mask);
7504 case 4: /* Colorize */
7509 (void) GetOneVirtualPixel(image,0,0,&target,exception);
7510 if (attribute_flag[0] != 0)
7511 (void) QueryColorDatabase(argument_list[0].string_reference,&target,
7513 if (attribute_flag[1] == 0)
7514 argument_list[1].string_reference="100%";
7515 image=ColorizeImage(image,argument_list[1].string_reference,target,
7519 case 5: /* Border */
7526 if (attribute_flag[0] != 0)
7528 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7529 &geometry,exception);
7530 if ((flags & HeightValue) == 0)
7531 geometry.height=geometry.width;
7533 if (attribute_flag[1] != 0)
7534 geometry.width=argument_list[1].integer_reference;
7535 if (attribute_flag[2] != 0)
7536 geometry.height=argument_list[2].integer_reference;
7537 if (attribute_flag[3] != 0)
7538 QueryColorDatabase(argument_list[3].string_reference,
7539 &image->border_color,exception);
7540 if (attribute_flag[4] != 0)
7541 QueryColorDatabase(argument_list[4].string_reference,
7542 &image->border_color,exception);
7543 if (attribute_flag[5] != 0)
7544 QueryColorDatabase(argument_list[5].string_reference,
7545 &image->border_color,exception);
7546 compose=image->compose;
7547 if (attribute_flag[6] != 0)
7548 compose=(CompositeOperator) argument_list[6].integer_reference;
7549 image=BorderImage(image,&geometry,compose,exception);
7554 if (attribute_flag[0] != 0)
7556 flags=ParseGeometry(argument_list[0].string_reference,
7558 if ((flags & SigmaValue) == 0)
7559 geometry_info.sigma=1.0;
7561 if (attribute_flag[1] != 0)
7562 geometry_info.rho=argument_list[1].real_reference;
7563 if (attribute_flag[2] != 0)
7564 geometry_info.sigma=argument_list[2].real_reference;
7565 if (attribute_flag[3] != 0)
7566 geometry_info.xi=argument_list[3].real_reference;
7567 if (attribute_flag[4] != 0)
7568 channel=(ChannelType) argument_list[4].integer_reference;
7569 channel_mask=SetPixelChannelMask(image,channel);
7570 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7571 geometry_info.xi,exception);
7572 if (image != (Image *) NULL)
7573 (void) SetPixelChannelMask(image,channel_mask);
7578 if (attribute_flag[0] != 0)
7579 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7580 &geometry,exception);
7581 if (attribute_flag[1] != 0)
7582 geometry.width=argument_list[1].integer_reference;
7583 if (attribute_flag[2] != 0)
7584 geometry.height=argument_list[2].integer_reference;
7585 if (attribute_flag[3] != 0)
7586 geometry.x=argument_list[3].integer_reference;
7587 if (attribute_flag[4] != 0)
7588 geometry.y=argument_list[4].integer_reference;
7589 image=ChopImage(image,&geometry,exception);
7594 if (attribute_flag[6] != 0)
7595 image->gravity=(GravityType) argument_list[6].integer_reference;
7596 if (attribute_flag[0] != 0)
7597 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7598 &geometry,exception);
7599 if (attribute_flag[1] != 0)
7600 geometry.width=argument_list[1].integer_reference;
7601 if (attribute_flag[2] != 0)
7602 geometry.height=argument_list[2].integer_reference;
7603 if (attribute_flag[3] != 0)
7604 geometry.x=argument_list[3].integer_reference;
7605 if (attribute_flag[4] != 0)
7606 geometry.y=argument_list[4].integer_reference;
7607 if (attribute_flag[5] != 0)
7609 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7610 image=CropImage(image,&geometry,exception);
7613 case 9: /* Despeckle */
7615 image=DespeckleImage(image,exception);
7620 if (attribute_flag[0] != 0)
7621 geometry_info.rho=argument_list[0].real_reference;
7622 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7626 case 11: /* Emboss */
7628 if (attribute_flag[0] != 0)
7630 flags=ParseGeometry(argument_list[0].string_reference,
7632 if ((flags & SigmaValue) == 0)
7633 geometry_info.sigma=1.0;
7635 if (attribute_flag[1] != 0)
7636 geometry_info.rho=argument_list[1].real_reference;
7637 if (attribute_flag[2] != 0)
7638 geometry_info.sigma=argument_list[2].real_reference;
7639 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7643 case 12: /* Enhance */
7645 image=EnhanceImage(image,exception);
7650 image=FlipImage(image,exception);
7655 image=FlopImage(image,exception);
7658 case 15: /* Frame */
7666 if (attribute_flag[0] != 0)
7668 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7669 &geometry,exception);
7670 if ((flags & HeightValue) == 0)
7671 geometry.height=geometry.width;
7672 frame_info.width=geometry.width;
7673 frame_info.height=geometry.height;
7674 frame_info.outer_bevel=geometry.x;
7675 frame_info.inner_bevel=geometry.y;
7677 if (attribute_flag[1] != 0)
7678 frame_info.width=argument_list[1].integer_reference;
7679 if (attribute_flag[2] != 0)
7680 frame_info.height=argument_list[2].integer_reference;
7681 if (attribute_flag[3] != 0)
7682 frame_info.inner_bevel=argument_list[3].integer_reference;
7683 if (attribute_flag[4] != 0)
7684 frame_info.outer_bevel=argument_list[4].integer_reference;
7685 if (attribute_flag[5] != 0)
7686 QueryColorDatabase(argument_list[5].string_reference,&fill_color,
7688 if (attribute_flag[6] != 0)
7689 QueryColorDatabase(argument_list[6].string_reference,&fill_color,
7691 frame_info.x=(ssize_t) frame_info.width;
7692 frame_info.y=(ssize_t) frame_info.height;
7693 frame_info.width=image->columns+2*frame_info.x;
7694 frame_info.height=image->rows+2*frame_info.y;
7695 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7696 image->matte_color=fill_color;
7697 compose=image->compose;
7698 if (attribute_flag[7] != 0)
7699 compose=(CompositeOperator) argument_list[7].integer_reference;
7700 image=FrameImage(image,&frame_info,compose,exception);
7703 case 16: /* Implode */
7705 PixelInterpolateMethod
7708 if (attribute_flag[0] == 0)
7709 argument_list[0].real_reference=0.5;
7710 method=UndefinedInterpolatePixel;
7711 if (attribute_flag[1] != 0)
7712 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7713 image=ImplodeImage(image,argument_list[0].real_reference,
7717 case 17: /* Magnify */
7719 image=MagnifyImage(image,exception);
7722 case 18: /* MedianFilter */
7724 if (attribute_flag[0] != 0)
7726 flags=ParseGeometry(argument_list[0].string_reference,
7728 if ((flags & SigmaValue) == 0)
7729 geometry_info.sigma=geometry_info.rho;
7731 if (attribute_flag[1] != 0)
7732 geometry_info.rho=argument_list[1].real_reference;
7733 if (attribute_flag[2] != 0)
7734 geometry_info.sigma=argument_list[2].real_reference;
7735 if (attribute_flag[3] != 0)
7736 channel=(ChannelType) argument_list[3].integer_reference;
7737 channel_mask=SetPixelChannelMask(image,channel);
7738 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7739 (size_t) geometry_info.sigma,exception);
7740 if (image != (Image *) NULL)
7741 (void) SetPixelChannelMask(image,channel_mask);
7744 case 19: /* Minify */
7746 image=MinifyImage(image,exception);
7749 case 20: /* OilPaint */
7751 if (attribute_flag[0] == 0)
7752 argument_list[0].real_reference=0.0;
7753 if (attribute_flag[1] == 0)
7754 argument_list[1].real_reference=1.0;
7755 image=OilPaintImage(image,argument_list[0].real_reference,
7756 argument_list[1].real_reference,exception);
7759 case 21: /* ReduceNoise */
7761 if (attribute_flag[0] != 0)
7763 flags=ParseGeometry(argument_list[0].string_reference,
7765 if ((flags & SigmaValue) == 0)
7766 geometry_info.sigma=1.0;
7768 if (attribute_flag[1] != 0)
7769 geometry_info.rho=argument_list[1].real_reference;
7770 if (attribute_flag[2] != 0)
7771 geometry_info.sigma=argument_list[2].real_reference;
7772 if (attribute_flag[3] != 0)
7773 channel=(ChannelType) argument_list[3].integer_reference;
7774 channel_mask=SetPixelChannelMask(image,channel);
7775 image=StatisticImage(image,NonpeakStatistic,(size_t)
7776 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7777 if (image != (Image *) NULL)
7778 (void) SetPixelChannelMask(image,channel_mask);
7783 if (attribute_flag[0] != 0)
7784 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7785 &geometry,exception);
7786 if (attribute_flag[1] != 0)
7787 geometry.x=argument_list[1].integer_reference;
7788 if (attribute_flag[2] != 0)
7789 geometry.y=argument_list[2].integer_reference;
7790 image=RollImage(image,geometry.x,geometry.y,exception);
7793 case 23: /* Rotate */
7795 if (attribute_flag[0] == 0)
7796 argument_list[0].real_reference=90.0;
7797 if (attribute_flag[1] != 0)
7798 QueryColorDatabase(argument_list[1].string_reference,
7799 &image->background_color,exception);
7800 if (attribute_flag[2] != 0)
7801 QueryColorDatabase(argument_list[2].string_reference,
7802 &image->background_color,exception);
7803 if (attribute_flag[3] != 0)
7804 QueryColorDatabase(argument_list[3].string_reference,
7805 &image->background_color,exception);
7806 image=RotateImage(image,argument_list[0].real_reference,exception);
7809 case 24: /* Sample */
7811 if (attribute_flag[0] != 0)
7812 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7813 &geometry,exception);
7814 if (attribute_flag[1] != 0)
7815 geometry.width=argument_list[1].integer_reference;
7816 if (attribute_flag[2] != 0)
7817 geometry.height=argument_list[2].integer_reference;
7818 image=SampleImage(image,geometry.width,geometry.height,exception);
7821 case 25: /* Scale */
7823 if (attribute_flag[0] != 0)
7824 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7825 &geometry,exception);
7826 if (attribute_flag[1] != 0)
7827 geometry.width=argument_list[1].integer_reference;
7828 if (attribute_flag[2] != 0)
7829 geometry.height=argument_list[2].integer_reference;
7830 image=ScaleImage(image,geometry.width,geometry.height,exception);
7833 case 26: /* Shade */
7835 if (attribute_flag[0] != 0)
7837 flags=ParseGeometry(argument_list[0].string_reference,
7839 if ((flags & SigmaValue) == 0)
7840 geometry_info.sigma=0.0;
7842 if (attribute_flag[1] != 0)
7843 geometry_info.rho=argument_list[1].real_reference;
7844 if (attribute_flag[2] != 0)
7845 geometry_info.sigma=argument_list[2].real_reference;
7846 image=ShadeImage(image,
7847 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7848 geometry_info.rho,geometry_info.sigma,exception);
7851 case 27: /* Sharpen */
7853 if (attribute_flag[0] != 0)
7855 flags=ParseGeometry(argument_list[0].string_reference,
7857 if ((flags & SigmaValue) == 0)
7858 geometry_info.sigma=1.0;
7860 if (attribute_flag[1] != 0)
7861 geometry_info.rho=argument_list[1].real_reference;
7862 if (attribute_flag[2] != 0)
7863 geometry_info.sigma=argument_list[2].real_reference;
7864 if (attribute_flag[3] != 0)
7865 geometry_info.xi=argument_list[3].real_reference;
7866 if (attribute_flag[4] != 0)
7867 channel=(ChannelType) argument_list[4].integer_reference;
7868 channel_mask=SetPixelChannelMask(image,channel);
7869 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7870 geometry_info.xi,exception);
7871 if (image != (Image *) NULL)
7872 (void) SetPixelChannelMask(image,channel_mask);
7875 case 28: /* Shear */
7877 if (attribute_flag[0] != 0)
7879 flags=ParseGeometry(argument_list[0].string_reference,
7881 if ((flags & SigmaValue) == 0)
7882 geometry_info.sigma=geometry_info.rho;
7884 if (attribute_flag[1] != 0)
7885 geometry_info.rho=argument_list[1].real_reference;
7886 if (attribute_flag[2] != 0)
7887 geometry_info.sigma=argument_list[2].real_reference;
7888 if (attribute_flag[3] != 0)
7889 QueryColorDatabase(argument_list[3].string_reference,
7890 &image->background_color,exception);
7891 if (attribute_flag[4] != 0)
7892 QueryColorDatabase(argument_list[4].string_reference,
7893 &image->background_color,exception);
7894 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7898 case 29: /* Spread */
7900 PixelInterpolateMethod
7903 if (attribute_flag[0] == 0)
7904 argument_list[0].real_reference=1.0;
7905 method=UndefinedInterpolatePixel;
7906 if (attribute_flag[1] != 0)
7907 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7908 image=SpreadImage(image,argument_list[0].real_reference,method,
7912 case 30: /* Swirl */
7914 PixelInterpolateMethod
7917 if (attribute_flag[0] == 0)
7918 argument_list[0].real_reference=50.0;
7919 method=UndefinedInterpolatePixel;
7920 if (attribute_flag[1] != 0)
7921 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7922 image=SwirlImage(image,argument_list[0].real_reference,
7926 case 31: /* Resize */
7929 if (attribute_flag[0] != 0)
7930 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7931 &geometry,exception);
7932 if (attribute_flag[1] != 0)
7933 geometry.width=argument_list[1].integer_reference;
7934 if (attribute_flag[2] != 0)
7935 geometry.height=argument_list[2].integer_reference;
7936 if (attribute_flag[3] == 0)
7937 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7938 if (attribute_flag[4] != 0)
7939 SetImageArtifact(image,"filter:support",
7940 argument_list[4].string_reference);
7941 if (attribute_flag[5] == 0)
7942 argument_list[5].real_reference=1.0;
7943 image=ResizeImage(image,geometry.width,geometry.height,
7944 (FilterTypes) argument_list[3].integer_reference,
7945 argument_list[5].real_reference,exception);
7948 case 33: /* Annotate */
7953 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7955 if (attribute_flag[0] != 0)
7960 text=InterpretImageProperties(info ? info->image_info :
7961 (ImageInfo *) NULL,image,argument_list[0].string_reference,
7963 (void) CloneString(&draw_info->text,text);
7964 text=DestroyString(text);
7966 if (attribute_flag[1] != 0)
7967 (void) CloneString(&draw_info->font,
7968 argument_list[1].string_reference);
7969 if (attribute_flag[2] != 0)
7970 draw_info->pointsize=argument_list[2].real_reference;
7971 if (attribute_flag[3] != 0)
7972 (void) CloneString(&draw_info->density,
7973 argument_list[3].string_reference);
7974 if (attribute_flag[4] != 0)
7975 (void) QueryColorDatabase(argument_list[4].string_reference,
7976 &draw_info->undercolor,exception);
7977 if (attribute_flag[5] != 0)
7979 (void) QueryColorDatabase(argument_list[5].string_reference,
7980 &draw_info->stroke,exception);
7981 if (argument_list[5].image_reference != (Image *) NULL)
7982 draw_info->stroke_pattern=CloneImage(
7983 argument_list[5].image_reference,0,0,MagickTrue,exception);
7985 if (attribute_flag[6] != 0)
7987 (void) QueryColorDatabase(argument_list[6].string_reference,
7988 &draw_info->fill,exception);
7989 if (argument_list[6].image_reference != (Image *) NULL)
7990 draw_info->fill_pattern=CloneImage(
7991 argument_list[6].image_reference,0,0,MagickTrue,exception);
7993 if (attribute_flag[7] != 0)
7995 (void) CloneString(&draw_info->geometry,
7996 argument_list[7].string_reference);
7997 flags=ParsePageGeometry(image,argument_list[7].string_reference,
7998 &geometry,exception);
7999 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8000 geometry_info.sigma=geometry_info.xi;
8002 if (attribute_flag[8] != 0)
8003 (void) QueryColorDatabase(argument_list[8].string_reference,
8004 &draw_info->fill,exception);
8005 if (attribute_flag[11] != 0)
8006 draw_info->gravity=(GravityType) argument_list[11].integer_reference;
8007 if (attribute_flag[25] != 0)
8012 av=(AV *) argument_list[25].array_reference;
8013 if ((av_len(av) != 3) && (av_len(av) != 5))
8015 ThrowPerlException(exception,OptionError,
8016 "affine matrix must have 4 or 6 elements",PackageName);
8019 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8020 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8021 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8022 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8023 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8024 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8026 ThrowPerlException(exception,OptionError,
8027 "affine matrix is singular",PackageName);
8030 if (av_len(av) == 5)
8032 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8033 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8036 for (j=12; j < 17; j++)
8038 if (attribute_flag[j] == 0)
8040 value=argument_list[j].string_reference;
8041 angle=argument_list[j].real_reference;
8042 current=draw_info->affine;
8043 GetAffineMatrix(&affine);
8051 flags=ParseGeometry(value,&geometry_info);
8052 affine.tx=geometry_info.xi;
8053 affine.ty=geometry_info.psi;
8054 if ((flags & PsiValue) == 0)
8055 affine.ty=affine.tx;
8063 flags=ParseGeometry(value,&geometry_info);
8064 affine.sx=geometry_info.rho;
8065 affine.sy=geometry_info.sigma;
8066 if ((flags & SigmaValue) == 0)
8067 affine.sy=affine.sx;
8077 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8078 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8079 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8080 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8088 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8096 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8100 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8101 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8102 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8103 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8104 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8106 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8109 if (attribute_flag[9] == 0)
8110 argument_list[9].real_reference=0.0;
8111 if (attribute_flag[10] == 0)
8112 argument_list[10].real_reference=0.0;
8113 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8116 geometry[MaxTextExtent];
8118 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8119 (double) argument_list[9].real_reference+draw_info->affine.tx,
8120 (double) argument_list[10].real_reference+draw_info->affine.ty);
8121 (void) CloneString(&draw_info->geometry,geometry);
8123 if (attribute_flag[17] != 0)
8124 draw_info->stroke_width=argument_list[17].real_reference;
8125 if (attribute_flag[18] != 0)
8127 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8128 MagickTrue : MagickFalse;
8129 draw_info->stroke_antialias=draw_info->text_antialias;
8131 if (attribute_flag[19] != 0)
8132 (void) CloneString(&draw_info->family,
8133 argument_list[19].string_reference);
8134 if (attribute_flag[20] != 0)
8135 draw_info->style=(StyleType) argument_list[20].integer_reference;
8136 if (attribute_flag[21] != 0)
8137 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8138 if (attribute_flag[22] != 0)
8139 draw_info->weight=argument_list[22].integer_reference;
8140 if (attribute_flag[23] != 0)
8141 draw_info->align=(AlignType) argument_list[23].integer_reference;
8142 if (attribute_flag[24] != 0)
8143 (void) CloneString(&draw_info->encoding,
8144 argument_list[24].string_reference);
8145 if (attribute_flag[25] != 0)
8146 draw_info->fill_pattern=CloneImage(
8147 argument_list[25].image_reference,0,0,MagickTrue,exception);
8148 if (attribute_flag[26] != 0)
8149 draw_info->fill_pattern=CloneImage(
8150 argument_list[26].image_reference,0,0,MagickTrue,exception);
8151 if (attribute_flag[27] != 0)
8152 draw_info->stroke_pattern=CloneImage(
8153 argument_list[27].image_reference,0,0,MagickTrue,exception);
8154 if (attribute_flag[29] != 0)
8155 draw_info->kerning=argument_list[29].real_reference;
8156 if (attribute_flag[30] != 0)
8157 draw_info->interline_spacing=argument_list[30].real_reference;
8158 if (attribute_flag[31] != 0)
8159 draw_info->interword_spacing=argument_list[31].real_reference;
8160 if (attribute_flag[32] != 0)
8161 draw_info->direction=(DirectionType)
8162 argument_list[32].integer_reference;
8163 (void) AnnotateImage(image,draw_info,exception);
8164 draw_info=DestroyDrawInfo(draw_info);
8167 case 34: /* ColorFloodfill */
8178 draw_info=CloneDrawInfo(info ? info->image_info :
8179 (ImageInfo *) NULL,(DrawInfo *) NULL);
8180 if (attribute_flag[0] != 0)
8181 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8182 &geometry,exception);
8183 if (attribute_flag[1] != 0)
8184 geometry.x=argument_list[1].integer_reference;
8185 if (attribute_flag[2] != 0)
8186 geometry.y=argument_list[2].integer_reference;
8187 if (attribute_flag[3] != 0)
8188 (void) QueryColorDatabase(argument_list[3].string_reference,
8189 &draw_info->fill,exception);
8190 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8193 if (attribute_flag[4] != 0)
8195 QueryMagickColor(argument_list[4].string_reference,&target,
8199 if (attribute_flag[5] != 0)
8200 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8202 if (attribute_flag[6] != 0)
8203 invert=(MagickBooleanType) argument_list[6].integer_reference;
8204 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8205 geometry.y,invert,exception);
8206 draw_info=DestroyDrawInfo(draw_info);
8209 case 35: /* Composite */
8212 composite_geometry[MaxTextExtent];
8218 compose=OverCompositeOp;
8219 if (attribute_flag[0] != 0)
8220 composite_image=argument_list[0].image_reference;
8223 ThrowPerlException(exception,OptionError,
8224 "CompositeImageRequired",PackageName);
8228 Parameter Handling used for BOTH normal and tiled composition.
8230 if (attribute_flag[1] != 0) /* compose */
8231 compose=(CompositeOperator) argument_list[1].integer_reference;
8232 if (attribute_flag[6] != 0) /* opacity */
8234 if (compose != DissolveCompositeOp)
8235 (void) SetImageOpacity(composite_image,(Quantum)
8236 SiPrefixToDouble(argument_list[6].string_reference,
8259 Handle dissolve composite operator (patch by
8262 (void) CloneString(&image->geometry,
8263 argument_list[6].string_reference);
8264 opacity=(Quantum) SiPrefixToDouble(
8265 argument_list[6].string_reference,QuantumRange);
8266 if (composite_image->matte != MagickTrue)
8267 (void) SetImageOpacity(composite_image,OpaqueAlpha);
8268 composite_view=AcquireCacheView(composite_image);
8269 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8271 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8272 composite_image->columns,1,exception);
8273 for (x=0; x < (ssize_t) composite_image->columns; x++)
8275 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8276 SetPixelAlpha(composite_image,ClampToQuantum(opacity),q);
8277 q+=GetPixelChannels(composite_image);
8279 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8280 if (sync == MagickFalse)
8283 composite_view=DestroyCacheView(composite_view);
8286 if (attribute_flag[9] != 0) /* "color=>" */
8287 QueryColorDatabase(argument_list[9].string_reference,
8288 &composite_image->background_color,exception);
8289 if (attribute_flag[12] != 0) /* "interpolate=>" */
8290 image->interpolate=(PixelInterpolateMethod)
8291 argument_list[12].integer_reference;
8292 if (attribute_flag[13] != 0) /* "args=>" */
8293 (void) SetImageArtifact(composite_image,"compose:args",
8294 argument_list[13].string_reference);
8295 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8296 (void) SetImageArtifact(composite_image,"compose:args",
8297 argument_list[14].string_reference);
8299 Tiling Composition (with orthogonal rotate).
8301 rotate_image=(Image *) NULL;
8302 if (attribute_flag[8] != 0) /* "rotate=>" */
8307 rotate_image=RotateImage(composite_image,
8308 argument_list[8].real_reference,exception);
8309 if (rotate_image == (Image *) NULL)
8312 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8319 Tile the composite image.
8321 if (attribute_flag[8] != 0) /* "tile=>" */
8322 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8325 (void) SetImageArtifact(composite_image,
8326 "compose:outside-overlay","false");
8327 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8328 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8330 if (attribute_flag[8] != 0) /* rotate */
8331 (void) CompositeImage(image,compose,rotate_image,x,y);
8333 (void) CompositeImage(image,compose,composite_image,x,y);
8335 if (attribute_flag[8] != 0) /* rotate */
8336 rotate_image=DestroyImage(rotate_image);
8340 Parameter Handling used used ONLY for normal composition.
8342 if (attribute_flag[5] != 0) /* gravity */
8343 image->gravity=(GravityType) argument_list[5].integer_reference;
8344 if (attribute_flag[2] != 0) /* geometry offset */
8346 SetGeometry(image,&geometry);
8347 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8349 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8352 if (attribute_flag[3] != 0) /* x offset */
8353 geometry.x=argument_list[3].integer_reference;
8354 if (attribute_flag[4] != 0) /* y offset */
8355 geometry.y=argument_list[4].integer_reference;
8356 if (attribute_flag[10] != 0) /* mask */
8358 if ((image->compose == DisplaceCompositeOp) ||
8359 (image->compose == DistortCompositeOp))
8362 Merge Y displacement into X displacement image.
8364 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8366 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8367 argument_list[10].image_reference,0,0);
8372 Set a blending mask for the composition.
8374 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8375 MagickTrue,&image->exception);
8376 (void) NegateImage(image->mask,MagickFalse,exception);
8379 if (attribute_flag[11] != 0) /* channel */
8380 channel=(ChannelType) argument_list[11].integer_reference;
8382 Composite two images (normal composition).
8384 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8385 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8386 (double) composite_image->rows,(double) geometry.x,(double)
8388 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8390 channel_mask=SetPixelChannelMask(image,channel);
8391 if (attribute_flag[8] == 0) /* no rotate */
8392 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8396 Position adjust rotated image then composite.
8398 geometry.x-=(ssize_t) (rotate_image->columns-
8399 composite_image->columns)/2;
8400 geometry.y-=(ssize_t) (rotate_image->rows-
8401 composite_image->rows)/2;
8402 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8403 rotate_image=DestroyImage(rotate_image);
8405 if (attribute_flag[10] != 0) /* mask */
8407 if ((image->compose == DisplaceCompositeOp) ||
8408 (image->compose == DistortCompositeOp))
8409 composite_image=DestroyImage(composite_image);
8411 image->mask=DestroyImage(image->mask);
8413 (void) SetPixelChannelMask(image,channel_mask);
8416 case 36: /* Contrast */
8418 if (attribute_flag[0] == 0)
8419 argument_list[0].integer_reference=0;
8420 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8421 MagickTrue : MagickFalse,exception);
8424 case 37: /* CycleColormap */
8426 if (attribute_flag[0] == 0)
8427 argument_list[0].integer_reference=6;
8428 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8437 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8439 (void) CloneString(&draw_info->primitive,"point");
8440 if (attribute_flag[0] != 0)
8442 if (argument_list[0].integer_reference < 0)
8443 (void) CloneString(&draw_info->primitive,
8444 argument_list[0].string_reference);
8446 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8447 MagickPrimitiveOptions,argument_list[0].integer_reference));
8449 if (attribute_flag[1] != 0)
8451 if (LocaleCompare(draw_info->primitive,"path") == 0)
8453 (void) ConcatenateString(&draw_info->primitive," '");
8454 ConcatenateString(&draw_info->primitive,
8455 argument_list[1].string_reference);
8456 (void) ConcatenateString(&draw_info->primitive,"'");
8460 (void) ConcatenateString(&draw_info->primitive," ");
8461 ConcatenateString(&draw_info->primitive,
8462 argument_list[1].string_reference);
8465 if (attribute_flag[2] != 0)
8467 (void) ConcatenateString(&draw_info->primitive," ");
8468 (void) ConcatenateString(&draw_info->primitive,
8469 CommandOptionToMnemonic(MagickMethodOptions,
8470 argument_list[2].integer_reference));
8472 if (attribute_flag[3] != 0)
8474 (void) QueryColorDatabase(argument_list[3].string_reference,
8475 &draw_info->stroke,exception);
8476 if (argument_list[3].image_reference != (Image *) NULL)
8477 draw_info->stroke_pattern=CloneImage(
8478 argument_list[3].image_reference,0,0,MagickTrue,exception);
8480 if (attribute_flag[4] != 0)
8482 (void) QueryColorDatabase(argument_list[4].string_reference,
8483 &draw_info->fill,exception);
8484 if (argument_list[4].image_reference != (Image *) NULL)
8485 draw_info->fill_pattern=CloneImage(
8486 argument_list[4].image_reference,0,0,MagickTrue,exception);
8488 if (attribute_flag[5] != 0)
8489 draw_info->stroke_width=argument_list[5].real_reference;
8490 if (attribute_flag[6] != 0)
8491 (void) CloneString(&draw_info->font,
8492 argument_list[6].string_reference);
8493 if (attribute_flag[7] != 0)
8494 (void) QueryColorDatabase(argument_list[7].string_reference,
8495 &draw_info->border_color,exception);
8496 if (attribute_flag[8] != 0)
8497 draw_info->affine.tx=argument_list[8].real_reference;
8498 if (attribute_flag[9] != 0)
8499 draw_info->affine.ty=argument_list[9].real_reference;
8500 if (attribute_flag[20] != 0)
8505 av=(AV *) argument_list[20].array_reference;
8506 if ((av_len(av) != 3) && (av_len(av) != 5))
8508 ThrowPerlException(exception,OptionError,
8509 "affine matrix must have 4 or 6 elements",PackageName);
8512 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8513 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8514 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8515 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8516 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8517 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8519 ThrowPerlException(exception,OptionError,
8520 "affine matrix is singular",PackageName);
8523 if (av_len(av) == 5)
8525 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8526 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8529 for (j=10; j < 15; j++)
8531 if (attribute_flag[j] == 0)
8533 value=argument_list[j].string_reference;
8534 angle=argument_list[j].real_reference;
8535 current=draw_info->affine;
8536 GetAffineMatrix(&affine);
8544 flags=ParseGeometry(value,&geometry_info);
8545 affine.tx=geometry_info.xi;
8546 affine.ty=geometry_info.psi;
8547 if ((flags & PsiValue) == 0)
8548 affine.ty=affine.tx;
8556 flags=ParseGeometry(value,&geometry_info);
8557 affine.sx=geometry_info.rho;
8558 affine.sy=geometry_info.sigma;
8559 if ((flags & SigmaValue) == 0)
8560 affine.sy=affine.sx;
8570 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8571 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8572 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8573 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8581 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8589 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8593 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8594 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8595 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8596 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8597 draw_info->affine.tx=
8598 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8599 draw_info->affine.ty=
8600 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8602 if (attribute_flag[15] != 0)
8603 draw_info->fill_pattern=CloneImage(
8604 argument_list[15].image_reference,0,0,MagickTrue,exception);
8605 if (attribute_flag[16] != 0)
8606 draw_info->pointsize=argument_list[16].real_reference;
8607 if (attribute_flag[17] != 0)
8609 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8610 ? MagickTrue : MagickFalse;
8611 draw_info->text_antialias=draw_info->stroke_antialias;
8613 if (attribute_flag[18] != 0)
8614 (void) CloneString(&draw_info->density,
8615 argument_list[18].string_reference);
8616 if (attribute_flag[19] != 0)
8617 draw_info->stroke_width=argument_list[19].real_reference;
8618 if (attribute_flag[21] != 0)
8619 draw_info->dash_offset=argument_list[21].real_reference;
8620 if (attribute_flag[22] != 0)
8625 av=(AV *) argument_list[22].array_reference;
8626 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8627 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8628 if (draw_info->dash_pattern != (double *) NULL)
8630 for (i=0; i <= av_len(av); i++)
8631 draw_info->dash_pattern[i]=(double)
8632 SvNV(*(av_fetch(av,i,0)));
8633 draw_info->dash_pattern[i]=0.0;
8636 if (attribute_flag[23] != 0)
8637 image->interpolate=(PixelInterpolateMethod)
8638 argument_list[23].integer_reference;
8639 if ((attribute_flag[24] != 0) &&
8640 (draw_info->fill_pattern != (Image *) NULL))
8641 flags=ParsePageGeometry(draw_info->fill_pattern,
8642 argument_list[24].string_reference,
8643 &draw_info->fill_pattern->tile_offset,exception);
8644 if (attribute_flag[25] != 0)
8646 (void) ConcatenateString(&draw_info->primitive," '");
8647 (void) ConcatenateString(&draw_info->primitive,
8648 argument_list[25].string_reference);
8649 (void) ConcatenateString(&draw_info->primitive,"'");
8651 if (attribute_flag[26] != 0)
8652 draw_info->fill_pattern=CloneImage(
8653 argument_list[26].image_reference,0,0,MagickTrue,exception);
8654 if (attribute_flag[27] != 0)
8655 draw_info->stroke_pattern=CloneImage(
8656 argument_list[27].image_reference,0,0,MagickTrue,exception);
8657 if (attribute_flag[28] != 0)
8658 (void) CloneString(&draw_info->primitive,
8659 argument_list[28].string_reference);
8660 if (attribute_flag[29] != 0)
8661 draw_info->kerning=argument_list[29].real_reference;
8662 if (attribute_flag[30] != 0)
8663 draw_info->interline_spacing=argument_list[30].real_reference;
8664 if (attribute_flag[31] != 0)
8665 draw_info->interword_spacing=argument_list[31].real_reference;
8666 if (attribute_flag[32] != 0)
8667 draw_info->direction=(DirectionType)
8668 argument_list[32].integer_reference;
8669 DrawImage(image,draw_info,exception);
8670 draw_info=DestroyDrawInfo(draw_info);
8673 case 39: /* Equalize */
8675 if (attribute_flag[0] != 0)
8676 channel=(ChannelType) argument_list[0].integer_reference;
8677 channel_mask=SetPixelChannelMask(image,channel);
8678 EqualizeImage(image,exception);
8679 (void) SetPixelChannelMask(image,channel_mask);
8682 case 40: /* Gamma */
8684 if (attribute_flag[1] != 0)
8685 channel=(ChannelType) argument_list[1].integer_reference;
8686 if (attribute_flag[2] == 0)
8687 argument_list[2].real_reference=1.0;
8688 if (attribute_flag[3] == 0)
8689 argument_list[3].real_reference=1.0;
8690 if (attribute_flag[4] == 0)
8691 argument_list[4].real_reference=1.0;
8692 if (attribute_flag[0] == 0)
8694 (void) FormatLocaleString(message,MaxTextExtent,
8695 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8696 (double) argument_list[3].real_reference,
8697 (double) argument_list[4].real_reference);
8698 argument_list[0].string_reference=message;
8700 (void) GammaImage(image,InterpretLocaleValue(
8701 argument_list[0].string_reference,(char **) NULL),exception);
8709 if (attribute_flag[0] == 0)
8711 ThrowPerlException(exception,OptionError,"MapImageRequired",
8715 quantize_info=AcquireQuantizeInfo(info->image_info);
8716 if (attribute_flag[1] != 0)
8717 quantize_info->dither=(MagickBooleanType)
8718 argument_list[1].integer_reference;
8719 if (attribute_flag[2] != 0)
8720 quantize_info->dither_method=(DitherMethod)
8721 argument_list[2].integer_reference;
8722 (void) RemapImages(quantize_info,image,
8723 argument_list[0].image_reference,exception);
8724 quantize_info=DestroyQuantizeInfo(quantize_info);
8727 case 42: /* MatteFloodfill */
8738 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8740 if (attribute_flag[0] != 0)
8741 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8742 &geometry,exception);
8743 if (attribute_flag[1] != 0)
8744 geometry.x=argument_list[1].integer_reference;
8745 if (attribute_flag[2] != 0)
8746 geometry.y=argument_list[2].integer_reference;
8747 if (image->matte == MagickFalse)
8748 (void) SetImageOpacity(image,OpaqueAlpha);
8749 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
8751 if (attribute_flag[4] != 0)
8752 QueryMagickColor(argument_list[4].string_reference,&target,
8754 if (attribute_flag[3] != 0)
8755 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8757 if (attribute_flag[5] != 0)
8758 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8761 if (attribute_flag[6] != 0)
8762 invert=(MagickBooleanType) argument_list[6].integer_reference;
8763 channel_mask=SetPixelChannelMask(image,AlphaChannel);
8764 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8765 geometry.y,invert,exception);
8766 (void) SetPixelChannelMask(image,channel_mask);
8767 draw_info=DestroyDrawInfo(draw_info);
8770 case 43: /* Modulate */
8773 modulate[MaxTextExtent];
8775 geometry_info.rho=100.0;
8776 geometry_info.sigma=100.0;
8777 geometry_info.xi=100.0;
8778 if (attribute_flag[0] != 0)
8779 (void)ParseGeometry(argument_list[0].string_reference,
8781 if (attribute_flag[1] != 0)
8782 geometry_info.xi=argument_list[1].real_reference;
8783 if (attribute_flag[2] != 0)
8784 geometry_info.sigma=argument_list[2].real_reference;
8785 if (attribute_flag[3] != 0)
8787 geometry_info.sigma=argument_list[3].real_reference;
8788 SetImageArtifact(image,"modulate:colorspace","HWB");
8790 if (attribute_flag[4] != 0)
8792 geometry_info.rho=argument_list[4].real_reference;
8793 SetImageArtifact(image,"modulate:colorspace","HSB");
8795 if (attribute_flag[5] != 0)
8797 geometry_info.sigma=argument_list[5].real_reference;
8798 SetImageArtifact(image,"modulate:colorspace","HSL");
8800 if (attribute_flag[6] != 0)
8802 geometry_info.rho=argument_list[6].real_reference;
8803 SetImageArtifact(image,"modulate:colorspace","HWB");
8805 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8806 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8807 (void) ModulateImage(image,modulate,exception);
8810 case 44: /* Negate */
8812 if (attribute_flag[0] == 0)
8813 argument_list[0].integer_reference=0;
8814 if (attribute_flag[1] != 0)
8815 channel=(ChannelType) argument_list[1].integer_reference;
8816 channel_mask=SetPixelChannelMask(image,channel);
8817 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8818 MagickTrue : MagickFalse,exception);
8819 (void) SetPixelChannelMask(image,channel_mask);
8822 case 45: /* Normalize */
8824 if (attribute_flag[0] != 0)
8825 channel=(ChannelType) argument_list[0].integer_reference;
8826 channel_mask=SetPixelChannelMask(image,channel);
8827 NormalizeImage(image,exception);
8828 (void) SetPixelChannelMask(image,channel_mask);
8831 case 46: /* NumberColors */
8833 case 47: /* Opaque */
8842 (void) QueryMagickColor("none",&target,exception);
8843 (void) QueryMagickColor("none",&fill_color,exception);
8844 if (attribute_flag[0] != 0)
8845 (void) QueryMagickColor(argument_list[0].string_reference,
8847 if (attribute_flag[1] != 0)
8848 (void) QueryMagickColor(argument_list[1].string_reference,
8849 &fill_color,exception);
8850 if (attribute_flag[2] != 0)
8851 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8853 if (attribute_flag[3] != 0)
8854 channel=(ChannelType) argument_list[3].integer_reference;
8856 if (attribute_flag[4] != 0)
8857 invert=(MagickBooleanType) argument_list[4].integer_reference;
8858 channel_mask=SetPixelChannelMask(image,channel);
8859 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
8860 (void) SetPixelChannelMask(image,channel_mask);
8863 case 48: /* Quantize */
8868 quantize_info=AcquireQuantizeInfo(info->image_info);
8869 if (attribute_flag[0] != 0)
8870 quantize_info->number_colors=(size_t)
8871 argument_list[0].integer_reference;
8872 if (attribute_flag[1] != 0)
8873 quantize_info->tree_depth=(size_t)
8874 argument_list[1].integer_reference;
8875 if (attribute_flag[2] != 0)
8876 quantize_info->colorspace=(ColorspaceType)
8877 argument_list[2].integer_reference;
8878 if (attribute_flag[3] != 0)
8879 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8880 MagickTrue : MagickFalse;
8881 if (attribute_flag[4] != 0)
8882 quantize_info->measure_error=
8883 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
8884 if (attribute_flag[5] != 0)
8885 (void) QueryColorDatabase(argument_list[5].string_reference,
8886 &image->transparent_color,exception);
8887 if (attribute_flag[5] && argument_list[5].integer_reference)
8889 (void) QuantizeImages(quantize_info,image,exception);
8892 if (attribute_flag[6] != 0)
8893 quantize_info->dither_method=(DitherMethod)
8894 argument_list[6].integer_reference;
8895 if ((image->storage_class == DirectClass) ||
8896 (image->colors > quantize_info->number_colors) ||
8897 (quantize_info->colorspace == GRAYColorspace))
8898 (void) QuantizeImage(quantize_info,image,exception);
8900 CompressImageColormap(image,exception);
8901 quantize_info=DestroyQuantizeInfo(quantize_info);
8904 case 49: /* Raise */
8906 if (attribute_flag[0] != 0)
8907 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8908 &geometry,exception);
8909 if (attribute_flag[1] != 0)
8910 geometry.width=argument_list[1].integer_reference;
8911 if (attribute_flag[2] != 0)
8912 geometry.height=argument_list[2].integer_reference;
8913 if (attribute_flag[3] == 0)
8914 argument_list[3].integer_reference=1;
8915 (void) RaiseImage(image,&geometry,
8916 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8920 case 50: /* Segment */
8927 smoothing_threshold;
8932 cluster_threshold=1.0;
8933 smoothing_threshold=1.5;
8934 colorspace=RGBColorspace;
8935 verbose=MagickFalse;
8936 if (attribute_flag[0] != 0)
8938 flags=ParseGeometry(argument_list[0].string_reference,
8940 cluster_threshold=geometry_info.rho;
8941 if (flags & SigmaValue)
8942 smoothing_threshold=geometry_info.sigma;
8944 if (attribute_flag[1] != 0)
8945 cluster_threshold=argument_list[1].real_reference;
8946 if (attribute_flag[2] != 0)
8947 smoothing_threshold=argument_list[2].real_reference;
8948 if (attribute_flag[3] != 0)
8949 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8950 if (attribute_flag[4] != 0)
8951 verbose=argument_list[4].integer_reference != 0 ?
8952 MagickTrue : MagickFalse;
8953 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8954 smoothing_threshold,exception);
8957 case 51: /* Signature */
8959 (void) SignatureImage(image,exception);
8962 case 52: /* Solarize */
8964 geometry_info.rho=QuantumRange/2.0;
8965 if (attribute_flag[0] != 0)
8966 flags=ParseGeometry(argument_list[0].string_reference,
8968 if (attribute_flag[1] != 0)
8969 geometry_info.rho=SiPrefixToDouble(
8970 argument_list[1].string_reference,QuantumRange);
8971 (void) SolarizeImage(image,geometry_info.rho,exception);
8976 (void) SyncImage(image);
8979 case 54: /* Texture */
8981 if (attribute_flag[0] == 0)
8983 TextureImage(image,argument_list[0].image_reference);
8986 case 55: /* Evalute */
8988 MagickEvaluateOperator
8991 op=SetEvaluateOperator;
8992 if (attribute_flag[0] == MagickFalse)
8993 argument_list[0].real_reference=0.0;
8994 if (attribute_flag[1] != MagickFalse)
8995 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
8996 if (attribute_flag[2] != MagickFalse)
8997 channel=(ChannelType) argument_list[2].integer_reference;
8998 channel_mask=SetPixelChannelMask(image,channel);
8999 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9001 (void) SetPixelChannelMask(image,channel_mask);
9004 case 56: /* Transparent */
9015 (void) QueryMagickColor("none",&target,exception);
9016 if (attribute_flag[0] != 0)
9017 (void) QueryMagickColor(argument_list[0].string_reference,&target,
9019 opacity=TransparentAlpha;
9020 if (attribute_flag[1] != 0)
9021 opacity=SiPrefixToDouble(argument_list[1].string_reference,
9023 if (attribute_flag[2] != 0)
9024 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
9026 if (attribute_flag[3] == 0)
9027 argument_list[3].integer_reference=0;
9029 if (attribute_flag[3] != 0)
9030 invert=(MagickBooleanType) argument_list[3].integer_reference;
9031 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9035 case 57: /* Threshold */
9040 if (attribute_flag[0] == 0)
9041 argument_list[0].string_reference="50%";
9042 if (attribute_flag[1] != 0)
9043 channel=(ChannelType) argument_list[1].integer_reference;
9044 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9046 channel_mask=SetPixelChannelMask(image,channel);
9047 (void) BilevelImage(image,threshold);
9048 (void) SetPixelChannelMask(image,channel_mask);
9051 case 58: /* Charcoal */
9053 if (attribute_flag[0] != 0)
9055 flags=ParseGeometry(argument_list[0].string_reference,
9057 if ((flags & SigmaValue) == 0)
9058 geometry_info.sigma=1.0;
9060 if (attribute_flag[1] != 0)
9061 geometry_info.rho=argument_list[1].real_reference;
9062 if (attribute_flag[2] != 0)
9063 geometry_info.sigma=argument_list[2].real_reference;
9064 if (attribute_flag[3] != 0)
9065 geometry_info.xi=argument_list[3].real_reference;
9066 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9067 geometry_info.xi,exception);
9072 if (attribute_flag[0] != 0)
9073 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9075 image=TrimImage(image,exception);
9080 PixelInterpolateMethod
9083 if (attribute_flag[0] != 0)
9085 flags=ParseGeometry(argument_list[0].string_reference,
9087 if ((flags & SigmaValue) == 0)
9088 geometry_info.sigma=1.0;
9090 if (attribute_flag[1] != 0)
9091 geometry_info.rho=argument_list[1].real_reference;
9092 if (attribute_flag[2] != 0)
9093 geometry_info.sigma=argument_list[2].real_reference;
9094 method=UndefinedInterpolatePixel;
9095 if (attribute_flag[3] != 0)
9096 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9097 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9101 case 61: /* Separate */
9103 if (attribute_flag[0] != 0)
9104 channel=(ChannelType) argument_list[0].integer_reference;
9105 channel_mask=SetPixelChannelMask(image,channel);
9106 (void) SeparateImage(image);
9107 (void) SetPixelChannelMask(image,channel_mask);
9110 case 63: /* Stereo */
9112 if (attribute_flag[0] == 0)
9114 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9118 if (attribute_flag[1] != 0)
9119 geometry.x=argument_list[1].integer_reference;
9120 if (attribute_flag[2] != 0)
9121 geometry.y=argument_list[2].integer_reference;
9122 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9123 geometry.x,geometry.y,exception);
9126 case 64: /* Stegano */
9128 if (attribute_flag[0] == 0)
9130 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9134 if (attribute_flag[1] == 0)
9135 argument_list[1].integer_reference=0;
9136 image->offset=argument_list[1].integer_reference;
9137 image=SteganoImage(image,argument_list[0].image_reference,exception);
9140 case 65: /* Deconstruct */
9142 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9145 case 66: /* GaussianBlur */
9147 if (attribute_flag[0] != 0)
9149 flags=ParseGeometry(argument_list[0].string_reference,
9151 if ((flags & SigmaValue) == 0)
9152 geometry_info.sigma=1.0;
9154 if (attribute_flag[1] != 0)
9155 geometry_info.rho=argument_list[1].real_reference;
9156 if (attribute_flag[2] != 0)
9157 geometry_info.sigma=argument_list[2].real_reference;
9158 if (attribute_flag[3] != 0)
9159 geometry_info.xi=argument_list[3].real_reference;
9160 if (attribute_flag[4] != 0)
9161 channel=(ChannelType) argument_list[4].integer_reference;
9162 channel_mask=SetPixelChannelMask(image,channel);
9163 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9164 geometry_info.xi,exception);
9165 if (image != (Image *) NULL)
9166 (void) SetPixelChannelMask(image,channel_mask);
9169 case 67: /* Convolve */
9174 kernel=(KernelInfo *) NULL;
9175 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9177 if (attribute_flag[0] != 0)
9185 kernel=AcquireKernelInfo((const char *) NULL);
9186 if (kernel == (KernelInfo *) NULL)
9188 av=(AV *) argument_list[0].array_reference;
9189 order=(size_t) sqrt(av_len(av)+1);
9190 kernel->width=order;
9191 kernel->height=order;
9192 kernel->values=(double *) AcquireAlignedMemory(order,order*
9193 sizeof(*kernel->values));
9194 if (kernel->values == (double *) NULL)
9196 kernel=DestroyKernelInfo(kernel);
9197 ThrowPerlException(exception,ResourceLimitFatalError,
9198 "MemoryAllocationFailed",PackageName);
9201 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9202 kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
9203 for ( ; j < (ssize_t) (order*order); j++)
9204 kernel->values[j]=0.0;
9206 if (attribute_flag[1] != 0)
9207 channel=(ChannelType) argument_list[1].integer_reference;
9208 if (attribute_flag[2] != 0)
9209 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9211 if (attribute_flag[3] != 0)
9213 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9214 if (kernel == (KernelInfo *) NULL)
9217 channel_mask=SetPixelChannelMask(image,channel);
9218 kernel->bias=image->bias;
9219 image=ConvolveImage(image,kernel,exception);
9220 if (image != (Image *) NULL)
9221 (void) SetPixelChannelMask(image,channel_mask);
9222 kernel=DestroyKernelInfo(kernel);
9225 case 68: /* Profile */
9240 if (attribute_flag[0] != 0)
9241 name=argument_list[0].string_reference;
9242 if (attribute_flag[2] != 0)
9243 image->rendering_intent=(RenderingIntent)
9244 argument_list[2].integer_reference;
9245 if (attribute_flag[3] != 0)
9246 image->black_point_compensation=
9247 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9248 if (attribute_flag[1] != 0)
9250 if (argument_list[1].length == 0)
9253 Remove a profile from the image.
9255 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9260 Associate user supplied profile with the image.
9262 profile=AcquireStringInfo(argument_list[1].length);
9263 SetStringInfoDatum(profile,(const unsigned char *)
9264 argument_list[1].string_reference);
9265 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9266 (size_t) GetStringInfoLength(profile),MagickFalse);
9267 profile=DestroyStringInfo(profile);
9271 Associate a profile with the image.
9274 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9275 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9276 profile_image=ReadImages(profile_info,&image->exception);
9277 if (profile_image == (Image *) NULL)
9279 ResetImageProfileIterator(profile_image);
9280 name=GetNextImageProfile(profile_image);
9281 while (name != (const char *) NULL)
9286 profile=GetImageProfile(profile_image,name);
9287 if (profile != (const StringInfo *) NULL)
9288 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9289 (size_t) GetStringInfoLength(profile),MagickFalse);
9290 name=GetNextImageProfile(profile_image);
9292 profile_image=DestroyImage(profile_image);
9293 profile_info=DestroyImageInfo(profile_info);
9296 case 69: /* UnsharpMask */
9298 if (attribute_flag[0] != 0)
9300 flags=ParseGeometry(argument_list[0].string_reference,
9302 if ((flags & SigmaValue) == 0)
9303 geometry_info.sigma=1.0;
9304 if ((flags & XiValue) == 0)
9305 geometry_info.xi=1.0;
9306 if ((flags & PsiValue) == 0)
9307 geometry_info.psi=0.5;
9309 if (attribute_flag[1] != 0)
9310 geometry_info.rho=argument_list[1].real_reference;
9311 if (attribute_flag[2] != 0)
9312 geometry_info.sigma=argument_list[2].real_reference;
9313 if (attribute_flag[3] != 0)
9314 geometry_info.xi=argument_list[3].real_reference;
9315 if (attribute_flag[4] != 0)
9316 geometry_info.psi=argument_list[4].real_reference;
9317 if (attribute_flag[5] != 0)
9318 channel=(ChannelType) argument_list[5].integer_reference;
9319 channel_mask=SetPixelChannelMask(image,channel);
9320 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9321 geometry_info.xi,geometry_info.psi,exception);
9322 if (image != (Image *) NULL)
9323 (void) SetPixelChannelMask(image,channel_mask);
9326 case 70: /* MotionBlur */
9328 if (attribute_flag[0] != 0)
9330 flags=ParseGeometry(argument_list[0].string_reference,
9332 if ((flags & SigmaValue) == 0)
9333 geometry_info.sigma=1.0;
9334 if ((flags & XiValue) == 0)
9335 geometry_info.xi=1.0;
9337 if (attribute_flag[1] != 0)
9338 geometry_info.rho=argument_list[1].real_reference;
9339 if (attribute_flag[2] != 0)
9340 geometry_info.sigma=argument_list[2].real_reference;
9341 if (attribute_flag[3] != 0)
9342 geometry_info.xi=argument_list[3].real_reference;
9343 if (attribute_flag[4] != 0)
9344 geometry_info.psi=argument_list[4].real_reference;
9345 if (attribute_flag[5] != 0)
9346 channel=(ChannelType) argument_list[5].integer_reference;
9347 channel_mask=SetPixelChannelMask(image,channel);
9348 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9349 geometry_info.xi,geometry_info.psi,exception);
9350 if (image != (Image *) NULL)
9351 (void) SetPixelChannelMask(image,channel_mask);
9354 case 71: /* OrderedDither */
9356 if (attribute_flag[0] == 0)
9357 argument_list[0].string_reference="o8x8";
9358 if (attribute_flag[1] != 0)
9359 channel=(ChannelType) argument_list[1].integer_reference;
9360 channel_mask=SetPixelChannelMask(image,channel);
9361 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9363 (void) SetPixelChannelMask(image,channel_mask);
9366 case 72: /* Shave */
9368 if (attribute_flag[0] != 0)
9369 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9370 &geometry,exception);
9371 if (attribute_flag[1] != 0)
9372 geometry.width=argument_list[1].integer_reference;
9373 if (attribute_flag[2] != 0)
9374 geometry.height=argument_list[2].integer_reference;
9375 image=ShaveImage(image,&geometry,exception);
9378 case 73: /* Level */
9386 white_point=(MagickRealType) image->columns*image->rows;
9388 if (attribute_flag[0] != 0)
9390 flags=ParseGeometry(argument_list[0].string_reference,
9392 black_point=geometry_info.rho;
9393 if ((flags & SigmaValue) != 0)
9394 white_point=geometry_info.sigma;
9395 if ((flags & XiValue) != 0)
9396 gamma=geometry_info.xi;
9397 if ((flags & PercentValue) != 0)
9399 black_point*=(double) (QuantumRange/100.0);
9400 white_point*=(double) (QuantumRange/100.0);
9402 if ((flags & SigmaValue) == 0)
9403 white_point=(double) QuantumRange-black_point;
9405 if (attribute_flag[1] != 0)
9406 black_point=argument_list[1].real_reference;
9407 if (attribute_flag[2] != 0)
9408 white_point=argument_list[2].real_reference;
9409 if (attribute_flag[3] != 0)
9410 gamma=argument_list[3].real_reference;
9411 if (attribute_flag[4] != 0)
9412 channel=(ChannelType) argument_list[4].integer_reference;
9413 if (attribute_flag[5] != 0)
9415 argument_list[0].real_reference=argument_list[5].real_reference;
9416 attribute_flag[0]=attribute_flag[5];
9418 channel_mask=SetPixelChannelMask(image,channel);
9419 (void) LevelImage(image,black_point,white_point,gamma,exception);
9420 (void) SetPixelChannelMask(image,channel_mask);
9425 if (attribute_flag[0] == 0)
9426 argument_list[0].string_reference="#1";
9427 if (attribute_flag[1] == 0)
9428 argument_list[1].integer_reference=MagickTrue;
9429 (void) ClipImagePath(image,argument_list[0].string_reference,
9430 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9434 case 75: /* AffineTransform */
9439 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9441 if (attribute_flag[0] != 0)
9446 av=(AV *) argument_list[0].array_reference;
9447 if ((av_len(av) != 3) && (av_len(av) != 5))
9449 ThrowPerlException(exception,OptionError,
9450 "affine matrix must have 4 or 6 elements",PackageName);
9453 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9454 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9455 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9456 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9457 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9458 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9460 ThrowPerlException(exception,OptionError,
9461 "affine matrix is singular",PackageName);
9464 if (av_len(av) == 5)
9466 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9467 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9470 for (j=1; j < 6; j++)
9472 if (attribute_flag[j] == 0)
9474 value=argument_list[j].string_reference;
9475 angle=argument_list[j].real_reference;
9476 current=draw_info->affine;
9477 GetAffineMatrix(&affine);
9485 flags=ParseGeometry(value,&geometry_info);
9486 affine.tx=geometry_info.xi;
9487 affine.ty=geometry_info.psi;
9488 if ((flags & PsiValue) == 0)
9489 affine.ty=affine.tx;
9497 flags=ParseGeometry(value,&geometry_info);
9498 affine.sx=geometry_info.rho;
9499 affine.sy=geometry_info.sigma;
9500 if ((flags & SigmaValue) == 0)
9501 affine.sy=affine.sx;
9511 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9512 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9513 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9514 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9522 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9530 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9534 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9535 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9536 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9537 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9538 draw_info->affine.tx=
9539 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9540 draw_info->affine.ty=
9541 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9543 if (attribute_flag[6] != 0)
9544 image->interpolate=(PixelInterpolateMethod)
9545 argument_list[6].integer_reference;
9546 if (attribute_flag[7] != 0)
9547 QueryColorDatabase(argument_list[7].string_reference,
9548 &image->background_color,exception);
9549 image=AffineTransformImage(image,&draw_info->affine,exception);
9550 draw_info=DestroyDrawInfo(draw_info);
9553 case 76: /* Difference */
9555 if (attribute_flag[0] == 0)
9557 ThrowPerlException(exception,OptionError,
9558 "ReferenceImageRequired",PackageName);
9561 if (attribute_flag[1] != 0)
9562 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9564 (void) IsImagesEqual(image,argument_list[0].image_reference,
9568 case 77: /* AdaptiveThreshold */
9570 if (attribute_flag[0] != 0)
9572 flags=ParseGeometry(argument_list[0].string_reference,
9574 if ((flags & PercentValue) != 0)
9575 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9577 if (attribute_flag[1] != 0)
9578 geometry_info.rho=argument_list[1].integer_reference;
9579 if (attribute_flag[2] != 0)
9580 geometry_info.sigma=argument_list[2].integer_reference;
9581 if (attribute_flag[3] != 0)
9582 geometry_info.xi=argument_list[3].integer_reference;;
9583 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9584 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9587 case 78: /* Resample */
9593 if (attribute_flag[0] != 0)
9595 flags=ParseGeometry(argument_list[0].string_reference,
9597 if ((flags & SigmaValue) == 0)
9598 geometry_info.sigma=geometry_info.rho;
9600 if (attribute_flag[1] != 0)
9601 geometry_info.rho=argument_list[1].real_reference;
9602 if (attribute_flag[2] != 0)
9603 geometry_info.sigma=argument_list[2].real_reference;
9604 if (attribute_flag[3] == 0)
9605 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9606 if (attribute_flag[4] == 0)
9607 SetImageArtifact(image,"filter:support",
9608 argument_list[4].string_reference);
9609 if (attribute_flag[5] != 0)
9610 argument_list[5].real_reference=1.0;
9611 width=(size_t) (geometry_info.rho*image->columns/
9612 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9613 height=(size_t) (geometry_info.sigma*image->rows/
9614 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9615 image=ResizeImage(image,width,height,(FilterTypes)
9616 argument_list[3].integer_reference,argument_list[5].real_reference,
9618 if (image != (Image *) NULL)
9620 image->x_resolution=geometry_info.rho;
9621 image->y_resolution=geometry_info.sigma;
9625 case 79: /* Describe */
9627 if (attribute_flag[0] == 0)
9628 argument_list[0].file_reference=(FILE *) NULL;
9629 if (attribute_flag[1] != 0)
9630 (void) SetImageArtifact(image,"identify:features",
9631 argument_list[1].string_reference);
9632 (void) IdentifyImage(image,argument_list[0].file_reference,
9633 MagickTrue,exception);
9636 case 80: /* BlackThreshold */
9638 if (attribute_flag[0] == 0)
9639 argument_list[0].string_reference="50%";
9640 if (attribute_flag[2] != 0)
9641 channel=(ChannelType) argument_list[2].integer_reference;
9642 channel_mask=SetPixelChannelMask(image,channel);
9643 BlackThresholdImage(image,argument_list[0].string_reference,
9645 (void) SetPixelChannelMask(image,channel_mask);
9648 case 81: /* WhiteThreshold */
9650 if (attribute_flag[0] == 0)
9651 argument_list[0].string_reference="50%";
9652 if (attribute_flag[2] != 0)
9653 channel=(ChannelType) argument_list[2].integer_reference;
9654 channel_mask=SetPixelChannelMask(image,channel);
9655 WhiteThresholdImage(image,argument_list[0].string_reference,
9657 (void) SetPixelChannelMask(image,channel_mask);
9660 case 82: /* RadialBlur */
9662 if (attribute_flag[0] != 0)
9664 flags=ParseGeometry(argument_list[0].string_reference,
9667 if (attribute_flag[1] != 0)
9668 geometry_info.rho=argument_list[1].real_reference;
9669 if (attribute_flag[2] != 0)
9670 geometry_info.sigma=argument_list[2].real_reference;
9671 if (attribute_flag[3] != 0)
9672 channel=(ChannelType) argument_list[3].integer_reference;
9673 channel_mask=SetPixelChannelMask(image,channel);
9674 image=RadialBlurImage(image,geometry_info.rho,geometry_info.sigma,
9676 if (image != (Image *) NULL)
9677 (void) SetPixelChannelMask(image,channel_mask);
9680 case 83: /* Thumbnail */
9682 if (attribute_flag[0] != 0)
9683 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9684 &geometry,exception);
9685 if (attribute_flag[1] != 0)
9686 geometry.width=argument_list[1].integer_reference;
9687 if (attribute_flag[2] != 0)
9688 geometry.height=argument_list[2].integer_reference;
9689 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9692 case 84: /* Strip */
9694 (void) StripImage(image);
9702 GetPixelInfo(image,&tint);
9703 if (attribute_flag[0] != 0)
9704 (void) QueryMagickColor(argument_list[0].string_reference,&tint,
9706 if (attribute_flag[1] == 0)
9707 argument_list[1].string_reference="100";
9708 image=TintImage(image,argument_list[1].string_reference,&tint,
9712 case 86: /* Channel */
9714 if (attribute_flag[0] != 0)
9715 channel=(ChannelType) argument_list[0].integer_reference;
9716 channel_mask=SetPixelChannelMask(image,channel);
9717 (void) SeparateImage(image);
9718 (void) SetPixelChannelMask(image,channel_mask);
9721 case 87: /* Splice */
9723 if (attribute_flag[0] != 0)
9724 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9725 &geometry,exception);
9726 if (attribute_flag[1] != 0)
9727 geometry.width=argument_list[1].integer_reference;
9728 if (attribute_flag[2] != 0)
9729 geometry.height=argument_list[2].integer_reference;
9730 if (attribute_flag[3] != 0)
9731 geometry.x=argument_list[3].integer_reference;
9732 if (attribute_flag[4] != 0)
9733 geometry.y=argument_list[4].integer_reference;
9734 if (attribute_flag[5] != 0)
9735 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9737 if (attribute_flag[6] != 0)
9738 (void) QueryColorDatabase(argument_list[6].string_reference,
9739 &image->background_color,exception);
9740 if (attribute_flag[7] != 0)
9741 image->gravity=(GravityType) argument_list[7].integer_reference;
9742 image=SpliceImage(image,&geometry,exception);
9745 case 88: /* Posterize */
9747 if (attribute_flag[0] == 0)
9748 argument_list[0].integer_reference=3;
9749 if (attribute_flag[1] == 0)
9750 argument_list[1].integer_reference=0;
9751 (void) PosterizeImage(image,argument_list[0].integer_reference,
9752 argument_list[1].integer_reference ? MagickTrue : MagickFalse,
9756 case 89: /* Shadow */
9758 if (attribute_flag[0] != 0)
9760 flags=ParseGeometry(argument_list[0].string_reference,
9762 if ((flags & SigmaValue) == 0)
9763 geometry_info.sigma=1.0;
9764 if ((flags & XiValue) == 0)
9765 geometry_info.xi=4.0;
9766 if ((flags & PsiValue) == 0)
9767 geometry_info.psi=4.0;
9769 if (attribute_flag[1] != 0)
9770 geometry_info.rho=argument_list[1].real_reference;
9771 if (attribute_flag[2] != 0)
9772 geometry_info.sigma=argument_list[2].real_reference;
9773 if (attribute_flag[3] != 0)
9774 geometry_info.xi=argument_list[3].integer_reference;
9775 if (attribute_flag[4] != 0)
9776 geometry_info.psi=argument_list[4].integer_reference;
9777 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9778 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9782 case 90: /* Identify */
9784 if (attribute_flag[0] == 0)
9785 argument_list[0].file_reference=(FILE *) NULL;
9786 if (attribute_flag[1] != 0)
9787 (void) SetImageArtifact(image,"identify:features",
9788 argument_list[1].string_reference);
9789 if ((attribute_flag[2] != 0) &&
9790 (argument_list[2].integer_reference != 0))
9791 (void) SetImageArtifact(image,"identify:unique","true");
9792 (void) IdentifyImage(image,argument_list[0].file_reference,
9793 MagickTrue,exception);
9796 case 91: /* SepiaTone */
9798 if (attribute_flag[0] == 0)
9799 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9800 image=SepiaToneImage(image,argument_list[0].real_reference,
9804 case 92: /* SigmoidalContrast */
9809 if (attribute_flag[0] != 0)
9811 flags=ParseGeometry(argument_list[0].string_reference,
9813 if ((flags & SigmaValue) == 0)
9814 geometry_info.sigma=QuantumRange/2.0;
9815 if ((flags & PercentValue) != 0)
9816 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9818 if (attribute_flag[1] != 0)
9819 geometry_info.rho=argument_list[1].real_reference;
9820 if (attribute_flag[2] != 0)
9821 geometry_info.sigma=argument_list[2].real_reference;
9822 if (attribute_flag[3] != 0)
9823 channel=(ChannelType) argument_list[3].integer_reference;
9825 if (attribute_flag[4] != 0)
9826 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9828 channel_mask=SetPixelChannelMask(image,channel);
9829 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9830 geometry_info.sigma,exception);
9831 (void) SetPixelChannelMask(image,channel_mask);
9834 case 93: /* Extent */
9836 if (attribute_flag[7] != 0)
9837 image->gravity=(GravityType) argument_list[7].integer_reference;
9838 if (attribute_flag[0] != 0)
9843 flags=ParseGravityGeometry(image,
9844 argument_list[0].string_reference,&geometry,exception);
9846 if (geometry.width == 0)
9847 geometry.width=image->columns;
9848 if (geometry.height == 0)
9849 geometry.height=image->rows;
9851 if (attribute_flag[1] != 0)
9852 geometry.width=argument_list[1].integer_reference;
9853 if (attribute_flag[2] != 0)
9854 geometry.height=argument_list[2].integer_reference;
9855 if (attribute_flag[3] != 0)
9856 geometry.x=argument_list[3].integer_reference;
9857 if (attribute_flag[4] != 0)
9858 geometry.y=argument_list[4].integer_reference;
9859 if (attribute_flag[5] != 0)
9860 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9862 if (attribute_flag[6] != 0)
9863 (void) QueryColorDatabase(argument_list[6].string_reference,
9864 &image->background_color,exception);
9865 image=ExtentImage(image,&geometry,exception);
9868 case 94: /* Vignette */
9870 if (attribute_flag[0] != 0)
9872 flags=ParseGeometry(argument_list[0].string_reference,
9874 if ((flags & SigmaValue) == 0)
9875 geometry_info.sigma=1.0;
9876 if ((flags & XiValue) == 0)
9877 geometry_info.xi=0.1*image->columns;
9878 if ((flags & PsiValue) == 0)
9879 geometry_info.psi=0.1*image->rows;
9881 if (attribute_flag[1] != 0)
9882 geometry_info.rho=argument_list[1].real_reference;
9883 if (attribute_flag[2] != 0)
9884 geometry_info.sigma=argument_list[2].real_reference;
9885 if (attribute_flag[3] != 0)
9886 geometry_info.xi=argument_list[3].integer_reference;
9887 if (attribute_flag[4] != 0)
9888 geometry_info.psi=argument_list[4].integer_reference;
9889 if (attribute_flag[5] != 0)
9890 (void) QueryColorDatabase(argument_list[5].string_reference,
9891 &image->background_color,exception);
9892 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9893 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9897 case 95: /* ContrastStretch */
9904 white_point=(MagickRealType) image->columns*image->rows;
9905 if (attribute_flag[0] != 0)
9907 flags=ParseGeometry(argument_list[0].string_reference,
9909 black_point=geometry_info.rho;
9910 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9912 if ((flags & PercentValue) != 0)
9914 black_point*=(double) image->columns*image->rows/100.0;
9915 white_point*=(double) image->columns*image->rows/100.0;
9917 white_point=(MagickRealType) image->columns*image->rows-
9920 if (attribute_flag[1] != 0)
9921 black_point=argument_list[1].real_reference;
9922 if (attribute_flag[2] != 0)
9923 white_point=argument_list[2].real_reference;
9924 if (attribute_flag[4] != 0)
9925 channel=(ChannelType) argument_list[4].integer_reference;
9926 channel_mask=SetPixelChannelMask(image,channel);
9927 (void) ContrastStretchImage(image,black_point,white_point,exception);
9928 (void) SetPixelChannelMask(image,channel_mask);
9931 case 96: /* Sans0 */
9935 case 97: /* Sans1 */
9939 case 98: /* AdaptiveSharpen */
9941 if (attribute_flag[0] != 0)
9943 flags=ParseGeometry(argument_list[0].string_reference,
9945 if ((flags & SigmaValue) == 0)
9946 geometry_info.sigma=1.0;
9947 if ((flags & XiValue) == 0)
9948 geometry_info.xi=0.0;
9950 if (attribute_flag[1] != 0)
9951 geometry_info.rho=argument_list[1].real_reference;
9952 if (attribute_flag[2] != 0)
9953 geometry_info.sigma=argument_list[2].real_reference;
9954 if (attribute_flag[3] != 0)
9955 geometry_info.xi=argument_list[3].real_reference;
9956 if (attribute_flag[4] != 0)
9957 channel=(ChannelType) argument_list[4].integer_reference;
9958 channel_mask=SetPixelChannelMask(image,channel);
9959 image=AdaptiveSharpenImage(image,geometry_info.rho,
9960 geometry_info.sigma,geometry_info.xi,exception);
9961 if (image != (Image *) NULL)
9962 (void) SetPixelChannelMask(image,channel_mask);
9965 case 99: /* Transpose */
9967 image=TransposeImage(image,exception);
9970 case 100: /* Tranverse */
9972 image=TransverseImage(image,exception);
9975 case 101: /* AutoOrient */
9977 switch (image->orientation)
9979 case TopRightOrientation:
9981 image=FlopImage(image,exception);
9984 case BottomRightOrientation:
9986 image=RotateImage(image,180.0,exception);
9989 case BottomLeftOrientation:
9991 image=FlipImage(image,exception);
9994 case LeftTopOrientation:
9996 image=TransposeImage(image,exception);
9999 case RightTopOrientation:
10001 image=RotateImage(image,90.0,exception);
10004 case RightBottomOrientation:
10006 image=TransverseImage(image,exception);
10009 case LeftBottomOrientation:
10011 image=RotateImage(image,270.0,exception);
10019 case 102: /* AdaptiveBlur */
10021 if (attribute_flag[0] != 0)
10023 flags=ParseGeometry(argument_list[0].string_reference,
10025 if ((flags & SigmaValue) == 0)
10026 geometry_info.sigma=1.0;
10027 if ((flags & XiValue) == 0)
10028 geometry_info.xi=0.0;
10030 if (attribute_flag[1] != 0)
10031 geometry_info.rho=argument_list[1].real_reference;
10032 if (attribute_flag[2] != 0)
10033 geometry_info.sigma=argument_list[2].real_reference;
10034 if (attribute_flag[3] != 0)
10035 geometry_info.xi=argument_list[3].real_reference;
10036 if (attribute_flag[4] != 0)
10037 channel=(ChannelType) argument_list[4].integer_reference;
10038 channel_mask=SetPixelChannelMask(image,channel);
10039 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10040 geometry_info.xi,exception);
10041 if (image != (Image *) NULL)
10042 (void) SetPixelChannelMask(image,channel_mask);
10045 case 103: /* Sketch */
10047 if (attribute_flag[0] != 0)
10049 flags=ParseGeometry(argument_list[0].string_reference,
10051 if ((flags & SigmaValue) == 0)
10052 geometry_info.sigma=1.0;
10053 if ((flags & XiValue) == 0)
10054 geometry_info.xi=1.0;
10056 if (attribute_flag[1] != 0)
10057 geometry_info.rho=argument_list[1].real_reference;
10058 if (attribute_flag[2] != 0)
10059 geometry_info.sigma=argument_list[2].real_reference;
10060 if (attribute_flag[3] != 0)
10061 geometry_info.xi=argument_list[3].real_reference;
10062 if (attribute_flag[4] != 0)
10063 geometry_info.psi=argument_list[4].real_reference;
10064 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10065 geometry_info.xi,geometry_info.psi,exception);
10068 case 104: /* UniqueColors */
10070 image=UniqueImageColors(image,exception);
10073 case 105: /* AdaptiveResize */
10075 PixelInterpolateMethod
10078 if (attribute_flag[0] != 0)
10079 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10080 &geometry,exception);
10081 if (attribute_flag[1] != 0)
10082 geometry.width=argument_list[1].integer_reference;
10083 if (attribute_flag[2] != 0)
10084 geometry.height=argument_list[2].integer_reference;
10085 if (attribute_flag[3] != 0)
10086 image->filter=(FilterTypes) argument_list[4].integer_reference;
10087 if (attribute_flag[4] != 0)
10088 SetImageArtifact(image,"filter:support",
10089 argument_list[4].string_reference);
10090 if (attribute_flag[5] != 0)
10091 image->blur=argument_list[5].real_reference;
10092 method=UndefinedInterpolatePixel;
10093 if (attribute_flag[6] != 0)
10094 method=(PixelInterpolateMethod) argument_list[6].integer_reference;
10095 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10099 case 106: /* ClipMask */
10101 if (attribute_flag[0] == 0)
10103 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10105 goto PerlException;
10107 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10108 MagickTrue,exception);
10109 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10112 case 107: /* LinearStretch */
10119 white_point=(MagickRealType) image->columns*image->rows;
10120 if (attribute_flag[0] != 0)
10122 flags=ParseGeometry(argument_list[0].string_reference,
10124 if ((flags & SigmaValue) != 0)
10125 white_point=geometry_info.sigma;
10126 if ((flags & PercentValue) != 0)
10128 black_point*=(double) image->columns*image->rows/100.0;
10129 white_point*=(double) image->columns*image->rows/100.0;
10131 if ((flags & SigmaValue) == 0)
10132 white_point=(double) image->columns*image->rows-black_point;
10134 if (attribute_flag[1] != 0)
10135 black_point=argument_list[1].real_reference;
10136 if (attribute_flag[2] != 0)
10137 white_point=argument_list[2].real_reference;
10138 (void) LinearStretchImage(image,black_point,white_point,exception);
10141 case 109: /* Mask */
10143 if (attribute_flag[0] == 0)
10145 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10147 goto PerlException;
10149 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10150 MagickTrue,exception);
10151 (void) NegateImage(image->mask,MagickFalse,exception);
10154 case 110: /* Polaroid */
10162 PixelInterpolateMethod
10165 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10166 (DrawInfo *) NULL);
10167 if (attribute_flag[0] != 0)
10168 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10169 info ? info->image_info : (ImageInfo *) NULL,image,
10170 argument_list[0].string_reference,exception));
10172 if (attribute_flag[1] != 0)
10173 angle=argument_list[1].real_reference;
10174 if (attribute_flag[2] != 0)
10175 (void) CloneString(&draw_info->font,
10176 argument_list[2].string_reference);
10177 if (attribute_flag[3] != 0)
10178 (void) QueryColorDatabase(argument_list[3].string_reference,
10179 &draw_info->stroke,exception);
10180 if (attribute_flag[4] != 0)
10181 (void) QueryColorDatabase(argument_list[4].string_reference,
10182 &draw_info->fill,exception);
10183 if (attribute_flag[5] != 0)
10184 draw_info->stroke_width=argument_list[5].real_reference;
10185 if (attribute_flag[6] != 0)
10186 draw_info->pointsize=argument_list[6].real_reference;
10187 if (attribute_flag[7] != 0)
10188 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10189 if (attribute_flag[8] != 0)
10190 (void) QueryColorDatabase(argument_list[8].string_reference,
10191 &image->background_color,exception);
10192 method=UndefinedInterpolatePixel;
10193 if (attribute_flag[9] != 0)
10194 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10195 image=PolaroidImage(image,draw_info,angle,method,exception);
10196 draw_info=DestroyDrawInfo(draw_info);
10199 case 111: /* FloodfillPaint */
10210 draw_info=CloneDrawInfo(info ? info->image_info :
10211 (ImageInfo *) NULL,(DrawInfo *) NULL);
10212 if (attribute_flag[0] != 0)
10213 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10214 &geometry,exception);
10215 if (attribute_flag[1] != 0)
10216 geometry.x=argument_list[1].integer_reference;
10217 if (attribute_flag[2] != 0)
10218 geometry.y=argument_list[2].integer_reference;
10219 if (attribute_flag[3] != 0)
10220 (void) QueryColorDatabase(argument_list[3].string_reference,
10221 &draw_info->fill,exception);
10222 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,&target,
10224 if (attribute_flag[4] != 0)
10225 QueryMagickColor(argument_list[4].string_reference,&target,
10227 if (attribute_flag[5] != 0)
10228 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10230 if (attribute_flag[6] != 0)
10231 channel=(ChannelType) argument_list[6].integer_reference;
10232 invert=MagickFalse;
10233 if (attribute_flag[7] != 0)
10234 invert=(MagickBooleanType) argument_list[7].integer_reference;
10235 channel_mask=SetPixelChannelMask(image,channel);
10236 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10237 geometry.y,invert,exception);
10238 (void) SetPixelChannelMask(image,channel_mask);
10239 draw_info=DestroyDrawInfo(draw_info);
10242 case 112: /* Distort */
10254 number_coordinates;
10259 if (attribute_flag[0] == 0)
10261 method=UndefinedDistortion;
10262 if (attribute_flag[1] != 0)
10263 method=(DistortImageMethod) argument_list[1].integer_reference;
10264 av=(AV *) argument_list[0].array_reference;
10265 number_coordinates=(size_t) av_len(av)+1;
10266 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10267 sizeof(*coordinates));
10268 if (coordinates == (double *) NULL)
10270 ThrowPerlException(exception,ResourceLimitFatalError,
10271 "MemoryAllocationFailed",PackageName);
10272 goto PerlException;
10274 for (j=0; j < (ssize_t) number_coordinates; j++)
10275 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10276 virtual_pixel=UndefinedVirtualPixelMethod;
10277 if (attribute_flag[2] != 0)
10278 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10279 argument_list[2].integer_reference);
10280 image=DistortImage(image,method,number_coordinates,coordinates,
10281 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10283 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10284 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10285 coordinates=(double *) RelinquishMagickMemory(coordinates);
10288 case 113: /* Clut */
10290 PixelInterpolateMethod
10293 if (attribute_flag[0] == 0)
10295 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10297 goto PerlException;
10299 method=UndefinedInterpolatePixel;
10300 if (attribute_flag[1] != 0)
10301 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10302 if (attribute_flag[2] != 0)
10303 channel=(ChannelType) argument_list[2].integer_reference;
10304 channel_mask=SetPixelChannelMask(image,channel);
10305 (void) ClutImage(image,argument_list[0].image_reference,method,
10307 (void) SetPixelChannelMask(image,channel_mask);
10310 case 114: /* LiquidRescale */
10312 if (attribute_flag[0] != 0)
10313 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10314 &geometry,exception);
10315 if (attribute_flag[1] != 0)
10316 geometry.width=argument_list[1].integer_reference;
10317 if (attribute_flag[2] != 0)
10318 geometry.height=argument_list[2].integer_reference;
10319 if (attribute_flag[3] == 0)
10320 argument_list[3].real_reference=1.0;
10321 if (attribute_flag[4] == 0)
10322 argument_list[4].real_reference=0.0;
10323 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10324 argument_list[3].real_reference,argument_list[4].real_reference,
10328 case 115: /* EncipherImage */
10330 (void) EncipherImage(image,argument_list[0].string_reference,
10334 case 116: /* DecipherImage */
10336 (void) DecipherImage(image,argument_list[0].string_reference,
10340 case 117: /* Deskew */
10342 geometry_info.rho=QuantumRange/2.0;
10343 if (attribute_flag[0] != 0)
10344 flags=ParseGeometry(argument_list[0].string_reference,
10346 if (attribute_flag[1] != 0)
10347 geometry_info.rho=SiPrefixToDouble(
10348 argument_list[1].string_reference,QuantumRange);
10349 image=DeskewImage(image,geometry_info.rho,exception);
10352 case 118: /* Remap */
10357 if (attribute_flag[0] == 0)
10359 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10361 goto PerlException;
10363 quantize_info=AcquireQuantizeInfo(info->image_info);
10364 if (attribute_flag[1] != 0)
10365 quantize_info->dither=(MagickBooleanType)
10366 argument_list[1].integer_reference;
10367 if (attribute_flag[2] != 0)
10368 quantize_info->dither_method=(DitherMethod)
10369 argument_list[2].integer_reference;
10370 (void) RemapImages(quantize_info,image,
10371 argument_list[0].image_reference,exception);
10372 quantize_info=DestroyQuantizeInfo(quantize_info);
10375 case 119: /* SparseColor */
10387 number_coordinates;
10392 if (attribute_flag[0] == 0)
10394 method=UndefinedColorInterpolate;
10395 if (attribute_flag[1] != 0)
10396 method=(SparseColorMethod) argument_list[1].integer_reference;
10397 av=(AV *) argument_list[0].array_reference;
10398 number_coordinates=(size_t) av_len(av)+1;
10399 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10400 sizeof(*coordinates));
10401 if (coordinates == (double *) NULL)
10403 ThrowPerlException(exception,ResourceLimitFatalError,
10404 "MemoryAllocationFailed",PackageName);
10405 goto PerlException;
10407 for (j=0; j < (ssize_t) number_coordinates; j++)
10408 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10409 virtual_pixel=UndefinedVirtualPixelMethod;
10410 if (attribute_flag[2] != 0)
10411 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10412 argument_list[2].integer_reference);
10413 if (attribute_flag[3] != 0)
10414 channel=(ChannelType) argument_list[3].integer_reference;
10415 channel_mask=SetPixelChannelMask(image,channel);
10416 image=SparseColorImage(image,method,number_coordinates,coordinates,
10418 if (image != (Image *) NULL)
10419 (void) SetPixelChannelMask(image,channel_mask);
10420 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10421 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10422 coordinates=(double *) RelinquishMagickMemory(coordinates);
10425 case 120: /* Function */
10442 if (attribute_flag[0] == 0)
10444 function=UndefinedFunction;
10445 if (attribute_flag[1] != 0)
10446 function=(MagickFunction) argument_list[1].integer_reference;
10447 av=(AV *) argument_list[0].array_reference;
10448 number_parameters=(size_t) av_len(av)+1;
10449 parameters=(double *) AcquireQuantumMemory(number_parameters,
10450 sizeof(*parameters));
10451 if (parameters == (double *) NULL)
10453 ThrowPerlException(exception,ResourceLimitFatalError,
10454 "MemoryAllocationFailed",PackageName);
10455 goto PerlException;
10457 for (j=0; j < (ssize_t) number_parameters; j++)
10458 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10459 virtual_pixel=UndefinedVirtualPixelMethod;
10460 if (attribute_flag[2] != 0)
10461 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10462 argument_list[2].integer_reference);
10463 (void) FunctionImage(image,function,number_parameters,parameters,
10465 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10466 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10467 parameters=(double *) RelinquishMagickMemory(parameters);
10470 case 121: /* SelectiveBlur */
10472 if (attribute_flag[0] != 0)
10474 flags=ParseGeometry(argument_list[0].string_reference,
10476 if ((flags & SigmaValue) == 0)
10477 geometry_info.sigma=1.0;
10478 if ((flags & PercentValue) != 0)
10479 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10481 if (attribute_flag[1] != 0)
10482 geometry_info.rho=argument_list[1].real_reference;
10483 if (attribute_flag[2] != 0)
10484 geometry_info.sigma=argument_list[2].real_reference;
10485 if (attribute_flag[3] != 0)
10486 geometry_info.xi=argument_list[3].integer_reference;;
10487 if (attribute_flag[4] != 0)
10488 geometry_info.psi=argument_list[4].integer_reference;;
10489 if (attribute_flag[5] != 0)
10490 channel=(ChannelType) argument_list[5].integer_reference;
10491 channel_mask=SetPixelChannelMask(image,channel);
10492 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10493 geometry_info.xi,geometry_info.psi,exception);
10494 if (image != (Image *) NULL)
10495 (void) SetPixelChannelMask(image,channel_mask);
10498 case 122: /* HaldClut */
10500 if (attribute_flag[0] == 0)
10502 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10504 goto PerlException;
10506 if (attribute_flag[1] != 0)
10507 channel=(ChannelType) argument_list[1].integer_reference;
10508 channel_mask=SetPixelChannelMask(image,channel);
10509 (void) HaldClutImage(image,argument_list[0].image_reference,
10511 (void) SetPixelChannelMask(image,channel_mask);
10514 case 123: /* BlueShift */
10516 if (attribute_flag[0] != 0)
10517 (void) ParseGeometry(argument_list[0].string_reference,
10519 image=BlueShiftImage(image,geometry_info.rho,exception);
10522 case 124: /* ForwardFourierTransformImage */
10524 image=ForwardFourierTransformImage(image,
10525 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10529 case 125: /* InverseFourierTransformImage */
10531 image=InverseFourierTransformImage(image,image->next,
10532 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10536 case 126: /* ColorDecisionList */
10538 if (attribute_flag[0] == 0)
10539 argument_list[0].string_reference=(char *) NULL;
10540 (void) ColorDecisionListImage(image,
10541 argument_list[0].string_reference,exception);
10544 case 127: /* AutoGamma */
10546 if (attribute_flag[0] != 0)
10547 channel=(ChannelType) argument_list[0].integer_reference;
10548 channel_mask=SetPixelChannelMask(image,channel);
10549 (void) AutoGammaImage(image,exception);
10550 (void) SetPixelChannelMask(image,channel_mask);
10553 case 128: /* AutoLevel */
10555 if (attribute_flag[0] != 0)
10556 channel=(ChannelType) argument_list[0].integer_reference;
10557 channel_mask=SetPixelChannelMask(image,channel);
10558 (void) AutoLevelImage(image,exception);
10559 (void) SetPixelChannelMask(image,channel_mask);
10562 case 129: /* LevelColors */
10568 (void) QueryMagickColor("#000000",&black_point,exception);
10569 (void) QueryMagickColor("#ffffff",&white_point,exception);
10570 if (attribute_flag[1] != 0)
10571 (void) QueryMagickColor(argument_list[1].string_reference,
10572 &black_point,exception);
10573 if (attribute_flag[2] != 0)
10574 (void) QueryMagickColor(argument_list[2].string_reference,
10575 &white_point,exception);
10576 if (attribute_flag[3] != 0)
10577 channel=(ChannelType) argument_list[3].integer_reference;
10578 channel_mask=SetPixelChannelMask(image,channel);
10579 (void) LevelImageColors(image,&black_point,&white_point,
10580 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10582 (void) SetPixelChannelMask(image,channel_mask);
10585 case 130: /* Clamp */
10587 if (attribute_flag[0] != 0)
10588 channel=(ChannelType) argument_list[0].integer_reference;
10589 channel_mask=SetPixelChannelMask(image,channel);
10590 (void) ClampImage(image);
10591 (void) SetPixelChannelMask(image,channel_mask);
10594 case 132: /* BrightnessContrast */
10602 if (attribute_flag[0] != 0)
10604 flags=ParseGeometry(argument_list[0].string_reference,
10606 brightness=geometry_info.rho;
10607 if ((flags & SigmaValue) == 0)
10608 contrast=geometry_info.sigma;
10610 if (attribute_flag[1] != 0)
10611 brightness=argument_list[1].real_reference;
10612 if (attribute_flag[2] != 0)
10613 contrast=argument_list[2].real_reference;
10614 if (attribute_flag[4] != 0)
10615 channel=(ChannelType) argument_list[4].integer_reference;
10616 channel_mask=SetPixelChannelMask(image,channel);
10617 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10618 (void) SetPixelChannelMask(image,channel_mask);
10621 case 133: /* Morphology */
10632 if (attribute_flag[0] == 0)
10634 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10635 if (kernel == (KernelInfo *) NULL)
10637 if (attribute_flag[1] != 0)
10638 channel=(ChannelType) argument_list[1].integer_reference;
10639 method=UndefinedMorphology;
10640 if (attribute_flag[2] != 0)
10641 method=argument_list[2].integer_reference;
10643 if (attribute_flag[3] != 0)
10644 iterations=argument_list[4].integer_reference;
10645 channel_mask=SetPixelChannelMask(image,channel);
10646 image=MorphologyImage(image,method,iterations,kernel,exception);
10647 if (image != (Image *) NULL)
10648 (void) SetPixelChannelMask(image,channel_mask);
10649 kernel=DestroyKernelInfo(kernel);
10652 case 108: /* Recolor */
10653 case 134: /* ColorMatrix */
10667 if (attribute_flag[0] == 0)
10669 av=(AV *) argument_list[0].array_reference;
10670 if (av == (AV *) NULL)
10672 order=(size_t) sqrt(av_len(av)+1);
10673 color_matrix=(double *) AcquireQuantumMemory(order,order*
10674 sizeof(*color_matrix));
10675 if (color_matrix == (double *) NULL)
10677 ThrowPerlException(exception,ResourceLimitFatalError,
10678 "MemoryAllocationFailed",PackageName);
10679 goto PerlException;
10681 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10682 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10683 for ( ; j < (ssize_t) (order*order); j++)
10684 color_matrix[j]=0.0;
10685 kernel_info=AcquireKernelInfo((const char *) NULL);
10686 if (kernel_info == (KernelInfo *) NULL)
10688 kernel_info->width=order;
10689 kernel_info->height=order;
10690 kernel_info->values=color_matrix;
10691 image=ColorMatrixImage(image,kernel_info,exception);
10692 kernel_info->values=(double *) NULL;
10693 kernel_info=DestroyKernelInfo(kernel_info);
10694 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10697 case 135: /* Color */
10702 (void) QueryMagickColor("none",&color,exception);
10703 if (attribute_flag[0] != 0)
10704 (void) QueryMagickColor(argument_list[0].string_reference,
10706 (void) SetImageColor(image,&color);
10709 case 136: /* Mode */
10711 if (attribute_flag[0] != 0)
10713 flags=ParseGeometry(argument_list[0].string_reference,
10715 if ((flags & SigmaValue) == 0)
10716 geometry_info.sigma=1.0;
10718 if (attribute_flag[1] != 0)
10719 geometry_info.rho=argument_list[1].real_reference;
10720 if (attribute_flag[2] != 0)
10721 geometry_info.sigma=argument_list[2].real_reference;
10722 if (attribute_flag[3] != 0)
10723 channel=(ChannelType) argument_list[3].integer_reference;
10724 channel_mask=SetPixelChannelMask(image,channel);
10725 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10726 (size_t) geometry_info.sigma,exception);
10727 if (image != (Image *) NULL)
10728 (void) SetPixelChannelMask(image,channel_mask);
10731 case 137: /* Statistic */
10736 statistic=UndefinedStatistic;
10737 if (attribute_flag[0] != 0)
10739 flags=ParseGeometry(argument_list[0].string_reference,
10741 if ((flags & SigmaValue) == 0)
10742 geometry_info.sigma=1.0;
10744 if (attribute_flag[1] != 0)
10745 geometry_info.rho=argument_list[1].real_reference;
10746 if (attribute_flag[2] != 0)
10747 geometry_info.sigma=argument_list[2].real_reference;
10748 if (attribute_flag[3] != 0)
10749 channel=(ChannelType) argument_list[3].integer_reference;
10750 if (attribute_flag[4] != 0)
10751 statistic=(StatisticType) argument_list[4].integer_reference;
10752 channel_mask=SetPixelChannelMask(image,channel);
10753 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10754 (size_t) geometry_info.sigma,exception);
10755 if (image != (Image *) NULL)
10756 (void) SetPixelChannelMask(image,channel_mask);
10760 if (next != (Image *) NULL)
10761 (void) CatchImageException(next);
10762 if (region_image != (Image *) NULL)
10767 status=CompositeImage(region_image,CopyCompositeOp,image,
10768 region_info.x,region_info.y);
10770 (void) CatchImageException(region_image);
10771 image=DestroyImage(image);
10772 image=region_image;
10774 if (image != (Image *) NULL)
10777 if (next && (next != image))
10779 image->next=next->next;
10780 if (image->next != (Image *) NULL)
10781 image->next->previous=image;
10782 DeleteImageFromRegistry(*pv,next);
10784 sv_setiv(*pv,(IV) image);
10792 if (reference_vector)
10793 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10794 InheritPerlException(exception,perl_exception);
10795 exception=DestroyExceptionInfo(exception);
10796 sv_setiv(perl_exception,(IV) number_images);
10797 SvPOK_on(perl_exception);
10798 ST(0)=sv_2mortal(perl_exception);
10803 ###############################################################################
10811 ###############################################################################
10816 Image::Magick ref=NO_INIT
10861 PERL_UNUSED_VAR(ref);
10862 PERL_UNUSED_VAR(ix);
10863 exception=AcquireExceptionInfo();
10864 perl_exception=newSVpv("",0);
10867 if (sv_isobject(ST(0)) == 0)
10869 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10871 goto PerlException;
10873 reference=SvRV(ST(0));
10874 hv=SvSTASH(reference);
10876 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10878 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10879 if (image == (Image *) NULL)
10881 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10883 goto PerlException;
10888 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10889 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10890 (void) QueryMagickColor("none",&transparent_color,exception);
10891 for (i=2; i < items; i+=2)
10893 attribute=(char *) SvPV(ST(i-1),na);
10894 switch (*attribute)
10899 if (LocaleCompare(attribute,"background") == 0)
10901 (void) QueryColorDatabase(SvPV(ST(i),na),
10902 &montage_info->background_color,exception);
10903 for (next=image; next; next=next->next)
10904 next->background_color=montage_info->background_color;
10907 if (LocaleCompare(attribute,"border") == 0)
10909 montage_info->border_width=SvIV(ST(i));
10912 if (LocaleCompare(attribute,"bordercolor") == 0)
10914 (void) QueryColorDatabase(SvPV(ST(i),na),
10915 &montage_info->border_color,exception);
10916 for (next=image; next; next=next->next)
10917 next->border_color=montage_info->border_color;
10920 if (LocaleCompare(attribute,"borderwidth") == 0)
10922 montage_info->border_width=SvIV(ST(i));
10925 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10932 if (LocaleCompare(attribute,"compose") == 0)
10934 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10935 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10938 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10942 for (next=image; next; next=next->next)
10943 next->compose=(CompositeOperator) sp;
10946 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10953 if (LocaleCompare(attribute,"fill") == 0)
10955 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->fill,
10959 if (LocaleCompare(attribute,"font") == 0)
10961 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
10964 if (LocaleCompare(attribute,"frame") == 0)
10970 if (IsGeometry(p) == MagickFalse)
10972 ThrowPerlException(exception,OptionError,"MissingGeometry",
10976 (void) CloneString(&montage_info->frame,p);
10978 montage_info->frame=(char *) NULL;
10981 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10988 if (LocaleCompare(attribute,"geometry") == 0)
10994 if (IsGeometry(p) == MagickFalse)
10996 ThrowPerlException(exception,OptionError,"MissingGeometry",
11000 (void) CloneString(&montage_info->geometry,p);
11002 montage_info->geometry=(char *) NULL;
11005 if (LocaleCompare(attribute,"gravity") == 0)
11010 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11011 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11014 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11018 montage_info->gravity=(GravityType) in;
11019 for (next=image; next; next=next->next)
11020 next->gravity=(GravityType) in;
11023 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11030 if (LocaleCompare(attribute,"label") == 0)
11032 for (next=image; next; next=next->next)
11033 (void) SetImageProperty(next,"label",InterpretImageProperties(
11034 info ? info->image_info : (ImageInfo *) NULL,next,
11035 SvPV(ST(i),na),exception));
11038 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11045 if (LocaleCompare(attribute,"mattecolor") == 0)
11047 (void) QueryColorDatabase(SvPV(ST(i),na),
11048 &montage_info->matte_color,exception);
11049 for (next=image; next; next=next->next)
11050 next->matte_color=montage_info->matte_color;
11053 if (LocaleCompare(attribute,"mode") == 0)
11058 in=!SvPOK(ST(i)) ? SvIV(ST(i)) :
11059 ParseCommandOption(MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11064 ThrowPerlException(exception,OptionError,
11065 "UnrecognizedModeType",SvPV(ST(i),na));
11070 (void) CloneString(&montage_info->frame,"15x15+3+3");
11071 montage_info->shadow=MagickTrue;
11076 montage_info->frame=(char *) NULL;
11077 montage_info->shadow=MagickFalse;
11078 montage_info->border_width=0;
11081 case ConcatenateMode:
11083 montage_info->frame=(char *) NULL;
11084 montage_info->shadow=MagickFalse;
11085 (void) CloneString(&montage_info->geometry,"+0+0");
11086 montage_info->border_width=0;
11091 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11098 if (LocaleCompare(attribute,"pointsize") == 0)
11100 montage_info->pointsize=SvIV(ST(i));
11103 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11110 if (LocaleCompare(attribute,"shadow") == 0)
11112 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11113 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11116 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11120 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11123 if (LocaleCompare(attribute,"stroke") == 0)
11125 (void) QueryColorDatabase(SvPV(ST(i),na),&montage_info->stroke,
11129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11136 if (LocaleCompare(attribute,"texture") == 0)
11138 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11141 if (LocaleCompare(attribute,"tile") == 0)
11143 char *p=SvPV(ST(i),na);
11144 if (IsGeometry(p) == MagickFalse)
11146 ThrowPerlException(exception,OptionError,"MissingGeometry",
11150 (void) CloneString(&montage_info->tile,p);
11152 montage_info->tile=(char *) NULL;
11155 if (LocaleCompare(attribute,"title") == 0)
11157 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11160 if (LocaleCompare(attribute,"transparent") == 0)
11165 QueryMagickColor(SvPV(ST(i),na),&transparent_color,exception);
11166 for (next=image; next; next=next->next)
11167 (void) TransparentPaintImage(next,&transparent_color,
11168 TransparentAlpha,MagickFalse,exception);
11171 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11177 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11183 image=MontageImageList(info->image_info,montage_info,image,exception);
11184 montage_info=DestroyMontageInfo(montage_info);
11185 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11186 goto PerlException;
11187 if (transparent_color.alpha != TransparentAlpha)
11188 for (next=image; next; next=next->next)
11189 (void) TransparentPaintImage(next,&transparent_color,
11190 TransparentAlpha,MagickFalse,exception);
11191 for ( ; image; image=image->next)
11193 AddImageToRegistry(sv,image);
11195 av_push(av,sv_bless(rv,hv));
11198 exception=DestroyExceptionInfo(exception);
11199 ST(0)=av_reference;
11200 SvREFCNT_dec(perl_exception);
11204 InheritPerlException(exception,perl_exception);
11205 exception=DestroyExceptionInfo(exception);
11206 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11207 SvPOK_on(perl_exception);
11208 ST(0)=sv_2mortal(perl_exception);
11213 ###############################################################################
11221 ###############################################################################
11226 Image::Magick ref=NO_INIT
11264 PERL_UNUSED_VAR(ref);
11265 PERL_UNUSED_VAR(ix);
11266 exception=AcquireExceptionInfo();
11267 perl_exception=newSVpv("",0);
11271 if (sv_isobject(ST(0)) == 0)
11273 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11275 goto PerlException;
11277 reference=SvRV(ST(0));
11278 hv=SvSTASH(reference);
11280 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11282 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11283 if (image == (Image *) NULL)
11285 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11287 goto PerlException;
11289 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11294 for (i=2; i < items; i+=2)
11296 attribute=(char *) SvPV(ST(i-1),na);
11297 switch (*attribute)
11302 if (LocaleCompare(attribute,"frames") == 0)
11304 number_frames=SvIV(ST(i));
11307 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11313 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11319 image=MorphImages(image,number_frames,exception);
11320 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11321 goto PerlException;
11322 for ( ; image; image=image->next)
11324 AddImageToRegistry(sv,image);
11326 av_push(av,sv_bless(rv,hv));
11329 exception=DestroyExceptionInfo(exception);
11330 ST(0)=av_reference;
11331 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11335 InheritPerlException(exception,perl_exception);
11336 exception=DestroyExceptionInfo(exception);
11337 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11338 SvPOK_on(perl_exception);
11339 ST(0)=sv_2mortal(perl_exception);
11344 ###############################################################################
11352 ###############################################################################
11357 Image::Magick ref=NO_INIT
11385 PERL_UNUSED_VAR(ref);
11386 PERL_UNUSED_VAR(ix);
11387 exception=AcquireExceptionInfo();
11388 perl_exception=newSVpv("",0);
11390 if (sv_isobject(ST(0)) == 0)
11392 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11394 goto PerlException;
11396 reference=SvRV(ST(0));
11397 hv=SvSTASH(reference);
11398 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11399 if (image == (Image *) NULL)
11401 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11403 goto PerlException;
11405 image=MergeImageLayers(image,MosaicLayer,exception);
11407 Create blessed Perl array for the returned image.
11410 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11412 AddImageToRegistry(sv,image);
11414 av_push(av,sv_bless(rv,hv));
11416 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11417 (void) CopyMagickString(info->image_info->filename,image->filename,
11419 SetImageInfo(info->image_info,0,&image->exception);
11420 exception=DestroyExceptionInfo(exception);
11421 SvREFCNT_dec(perl_exception);
11425 InheritPerlException(exception,perl_exception);
11426 exception=DestroyExceptionInfo(exception);
11427 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11428 SvPOK_on(perl_exception); /* return messages in string context */
11429 ST(0)=sv_2mortal(perl_exception);
11434 ###############################################################################
11442 ###############################################################################
11447 Image::Magick ref=NO_INIT
11497 PERL_UNUSED_VAR(ref);
11498 PERL_UNUSED_VAR(ix);
11499 exception=AcquireExceptionInfo();
11500 perl_exception=newSVpv("",0);
11501 package_info=(struct PackageInfo *) NULL;
11502 ac=(items < 2) ? 1 : items-1;
11503 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11505 length=(STRLEN *) NULL;
11506 if (list == (char **) NULL)
11508 ThrowPerlException(exception,ResourceLimitError,
11509 "MemoryAllocationFailed",PackageName);
11510 goto PerlException;
11513 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11514 if (length == (STRLEN *) NULL)
11516 ThrowPerlException(exception,ResourceLimitError,
11517 "MemoryAllocationFailed",PackageName);
11518 goto PerlException;
11520 if (sv_isobject(ST(0)) == 0)
11522 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11524 goto PerlException;
11526 reference=SvRV(ST(0));
11527 if (SvTYPE(reference) != SVt_PVAV)
11529 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11531 goto PerlException;
11533 av=(AV *) reference;
11534 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11536 package_info=ClonePackageInfo(info,exception);
11539 *list=(char *) (*package_info->image_info->filename ?
11540 package_info->image_info->filename : "XC:black");
11542 for (n=0, i=0; i < ac; i++)
11544 list[n]=(char *) SvPV(ST(i+1),length[n]);
11545 if ((items >= 3) && strEQcase(list[n],"blob"))
11551 blob=(void *) (SvPV(ST(i+1),length[n]));
11552 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11554 if ((items >= 3) && strEQcase(list[n],"filename"))
11556 if ((items >= 3) && strEQcase(list[n],"file"))
11565 io_info=IoIFP(sv_2io(ST(i+1)));
11566 if (io_info == (PerlIO *) NULL)
11568 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11572 file=PerlIO_findFILE(io_info);
11573 if (file == (FILE *) NULL)
11575 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11579 SetImageInfoFile(package_info->image_info,file);
11581 if ((items >= 3) && strEQcase(list[n],"magick"))
11585 list[n]=(char *) NULL;
11587 status=ExpandFilenames(&n,&list);
11588 if (status == MagickFalse)
11590 ThrowPerlException(exception,ResourceLimitError,
11591 "MemoryAllocationFailed",PackageName);
11592 goto PerlException;
11595 for (i=0; i < n; i++)
11597 (void) CopyMagickString(package_info->image_info->filename,list[i],
11599 image=PingImage(package_info->image_info,exception);
11600 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11602 if ((package_info->image_info->file != (FILE *) NULL) ||
11603 (package_info->image_info->blob != (void *) NULL))
11604 DisassociateImageStream(image);
11605 count+=GetImageListLength(image);
11606 EXTEND(sp,4*count);
11607 for (next=image; next; next=next->next)
11609 PUSHs(sv_2mortal(newSViv(next->columns)));
11610 PUSHs(sv_2mortal(newSViv(next->rows)));
11611 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11612 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11614 image=DestroyImageList(image);
11619 for (i=0; i < n; i++)
11620 if (list[i] != (char *) NULL)
11621 for (p=keep; list[i] != *p++; )
11624 list[i]=(char *) RelinquishMagickMemory(list[i]);
11629 if (package_info != (struct PackageInfo *) NULL)
11630 DestroyPackageInfo(package_info);
11631 if (list && (list != keep))
11632 list=(char **) RelinquishMagickMemory(list);
11634 keep=(char **) RelinquishMagickMemory(keep);
11636 length=(STRLEN *) RelinquishMagickMemory(length);
11637 InheritPerlException(exception,perl_exception);
11638 exception=DestroyExceptionInfo(exception);
11639 SvREFCNT_dec(perl_exception); /* throw away all errors */
11643 ###############################################################################
11651 ###############################################################################
11656 Image::Magick ref=NO_INIT
11689 PERL_UNUSED_VAR(ref);
11690 PERL_UNUSED_VAR(ix);
11691 exception=AcquireExceptionInfo();
11692 perl_exception=newSVpv("",0);
11695 if (sv_isobject(ST(0)) == 0)
11697 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11699 goto PerlException;
11701 reference=SvRV(ST(0));
11702 hv=SvSTASH(reference);
11704 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11706 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11707 if (image == (Image *) NULL)
11709 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11711 goto PerlException;
11713 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11714 preview_type=GammaPreview;
11716 preview_type=(PreviewType)
11717 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11718 for ( ; image; image=image->next)
11720 preview_image=PreviewImage(image,preview_type,exception);
11721 if (preview_image == (Image *) NULL)
11722 goto PerlException;
11723 AddImageToRegistry(sv,preview_image);
11725 av_push(av,sv_bless(rv,hv));
11728 exception=DestroyExceptionInfo(exception);
11729 ST(0)=av_reference;
11730 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11734 InheritPerlException(exception,perl_exception);
11735 exception=DestroyExceptionInfo(exception);
11736 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11737 SvPOK_on(perl_exception);
11738 ST(0)=sv_2mortal(perl_exception);
11743 ###############################################################################
11747 # Q u e r y C o l o r #
11751 ###############################################################################
11755 QueryColor(ref,...)
11756 Image::Magick ref=NO_INIT
11776 PERL_UNUSED_VAR(ref);
11777 PERL_UNUSED_VAR(ix);
11778 exception=AcquireExceptionInfo();
11779 perl_exception=newSVpv("",0);
11788 colorlist=GetColorInfoList("*",&colors,exception);
11790 for (i=0; i < (ssize_t) colors; i++)
11792 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11794 colorlist=(const ColorInfo **)
11795 RelinquishMagickMemory((ColorInfo **) colorlist);
11796 goto PerlException;
11798 EXTEND(sp,5*items);
11799 for (i=1; i < items; i++)
11801 name=(char *) SvPV(ST(i),na);
11802 if (QueryMagickColor(name,&color,exception) == MagickFalse)
11807 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11808 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11809 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11810 if (color.colorspace == CMYKColorspace)
11811 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11812 if (color.matte != MagickFalse)
11813 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11817 InheritPerlException(exception,perl_exception);
11818 exception=DestroyExceptionInfo(exception);
11819 SvREFCNT_dec(perl_exception);
11823 ###############################################################################
11827 # Q u e r y C o l o r N a m e #
11831 ###############################################################################
11835 QueryColorname(ref,...)
11836 Image::Magick ref=NO_INIT
11845 message[MaxTextExtent];
11864 *reference; /* reference is the SV* of ref=SvIV(reference) */
11866 PERL_UNUSED_VAR(ref);
11867 PERL_UNUSED_VAR(ix);
11868 exception=AcquireExceptionInfo();
11869 perl_exception=newSVpv("",0);
11870 reference=SvRV(ST(0));
11871 av=(AV *) reference;
11872 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11874 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11875 if (image == (Image *) NULL)
11877 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11879 goto PerlException;
11882 for (i=1; i < items; i++)
11884 (void) QueryColorDatabase(SvPV(ST(i),na),&target_color,exception);
11885 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11887 PUSHs(sv_2mortal(newSVpv(message,0)));
11891 InheritPerlException(exception,perl_exception);
11892 exception=DestroyExceptionInfo(exception);
11893 SvREFCNT_dec(perl_exception);
11897 ###############################################################################
11901 # Q u e r y F o n t #
11905 ###############################################################################
11910 Image::Magick ref=NO_INIT
11917 message[MaxTextExtent];
11928 volatile const TypeInfo
11931 PERL_UNUSED_VAR(ref);
11932 PERL_UNUSED_VAR(ix);
11933 exception=AcquireExceptionInfo();
11934 perl_exception=newSVpv("",0);
11943 typelist=GetTypeInfoList("*",&types,exception);
11945 for (i=0; i < (ssize_t) types; i++)
11947 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11949 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
11951 goto PerlException;
11953 EXTEND(sp,10*items);
11954 for (i=1; i < items; i++)
11956 name=(char *) SvPV(ST(i),na);
11957 type_info=GetTypeInfo(name,exception);
11958 if (type_info == (TypeInfo *) NULL)
11963 if (type_info->name == (char *) NULL)
11966 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
11967 if (type_info->description == (char *) NULL)
11970 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
11971 if (type_info->family == (char *) NULL)
11974 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
11975 if (type_info->style == UndefinedStyle)
11978 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
11979 type_info->style),0)));
11980 if (type_info->stretch == UndefinedStretch)
11983 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
11984 type_info->stretch),0)));
11985 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
11986 type_info->weight);
11987 PUSHs(sv_2mortal(newSVpv(message,0)));
11988 if (type_info->encoding == (char *) NULL)
11991 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
11992 if (type_info->foundry == (char *) NULL)
11995 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
11996 if (type_info->format == (char *) NULL)
11999 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12000 if (type_info->metrics == (char *) NULL)
12003 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12004 if (type_info->glyphs == (char *) NULL)
12007 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12011 InheritPerlException(exception,perl_exception);
12012 exception=DestroyExceptionInfo(exception);
12013 SvREFCNT_dec(perl_exception);
12017 ###############################################################################
12021 # Q u e r y F o n t M e t r i c s #
12025 ###############################################################################
12029 QueryFontMetrics(ref,...)
12030 Image::Magick ref=NO_INIT
12032 queryfontmetrics = 1
12079 *reference; /* reference is the SV* of ref=SvIV(reference) */
12084 PERL_UNUSED_VAR(ref);
12085 PERL_UNUSED_VAR(ix);
12086 exception=AcquireExceptionInfo();
12087 package_info=(struct PackageInfo *) NULL;
12088 perl_exception=newSVpv("",0);
12089 reference=SvRV(ST(0));
12090 av=(AV *) reference;
12091 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12093 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12094 if (image == (Image *) NULL)
12096 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12098 goto PerlException;
12100 package_info=ClonePackageInfo(info,exception);
12101 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12102 CloneString(&draw_info->text,"");
12103 current=draw_info->affine;
12104 GetAffineMatrix(&affine);
12107 EXTEND(sp,7*items);
12108 for (i=2; i < items; i+=2)
12110 attribute=(char *) SvPV(ST(i-1),na);
12111 switch (*attribute)
12116 if (LocaleCompare(attribute,"antialias") == 0)
12118 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12122 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12126 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12129 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12136 if (LocaleCompare(attribute,"density") == 0)
12138 CloneString(&draw_info->density,SvPV(ST(i),na));
12141 if (LocaleCompare(attribute,"direction") == 0)
12143 draw_info->direction=(DirectionType) ParseCommandOption(
12144 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12154 if (LocaleCompare(attribute,"encoding") == 0)
12156 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12159 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12166 if (LocaleCompare(attribute,"family") == 0)
12168 CloneString(&draw_info->family,SvPV(ST(i),na));
12171 if (LocaleCompare(attribute,"fill") == 0)
12174 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12175 &image->exception);
12178 if (LocaleCompare(attribute,"font") == 0)
12180 CloneString(&draw_info->font,SvPV(ST(i),na));
12183 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12190 if (LocaleCompare(attribute,"geometry") == 0)
12192 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12195 if (LocaleCompare(attribute,"gravity") == 0)
12197 draw_info->gravity=(GravityType) ParseCommandOption(
12198 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12201 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12208 if (LocaleCompare(attribute,"interline-spacing") == 0)
12210 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12211 draw_info->interline_spacing=geometry_info.rho;
12214 if (LocaleCompare(attribute,"interword-spacing") == 0)
12216 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12217 draw_info->interword_spacing=geometry_info.rho;
12220 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12227 if (LocaleCompare(attribute,"kerning") == 0)
12229 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12230 draw_info->kerning=geometry_info.rho;
12233 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12240 if (LocaleCompare(attribute,"pointsize") == 0)
12242 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12243 draw_info->pointsize=geometry_info.rho;
12246 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12253 if (LocaleCompare(attribute,"rotate") == 0)
12255 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12256 affine.rx=geometry_info.rho;
12257 affine.ry=geometry_info.sigma;
12258 if ((flags & SigmaValue) == 0)
12259 affine.ry=affine.rx;
12262 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12269 if (LocaleCompare(attribute,"scale") == 0)
12271 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12272 affine.sx=geometry_info.rho;
12273 affine.sy=geometry_info.sigma;
12274 if ((flags & SigmaValue) == 0)
12275 affine.sy=affine.sx;
12278 if (LocaleCompare(attribute,"skew") == 0)
12284 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12285 x_angle=geometry_info.rho;
12286 y_angle=geometry_info.sigma;
12287 if ((flags & SigmaValue) == 0)
12289 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12290 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12293 if (LocaleCompare(attribute,"stroke") == 0)
12296 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12297 &image->exception);
12300 if (LocaleCompare(attribute,"style") == 0)
12302 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12306 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12310 draw_info->style=(StyleType) type;
12313 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12320 if (LocaleCompare(attribute,"text") == 0)
12322 CloneString(&draw_info->text,SvPV(ST(i),na));
12325 if (LocaleCompare(attribute,"translate") == 0)
12327 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12328 affine.tx=geometry_info.rho;
12329 affine.ty=geometry_info.sigma;
12330 if ((flags & SigmaValue) == 0)
12331 affine.ty=affine.tx;
12334 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12341 if (LocaleCompare(attribute,"weight") == 0)
12343 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12344 draw_info->weight=(size_t) geometry_info.rho;
12347 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12354 if (LocaleCompare(attribute,"x") == 0)
12356 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12357 x=geometry_info.rho;
12360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12367 if (LocaleCompare(attribute,"y") == 0)
12369 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12370 y=geometry_info.rho;
12373 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12379 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12385 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12386 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12387 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12388 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12389 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12390 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12391 if (draw_info->geometry == (char *) NULL)
12393 draw_info->geometry=AcquireString((char *) NULL);
12394 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12395 "%.15g,%.15g",x,y);
12397 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12398 (void) CatchImageException(image);
12399 if (status == MagickFalse)
12403 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12404 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12405 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12406 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12407 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12408 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12409 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12410 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12411 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12412 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12413 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12414 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12415 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12417 draw_info=DestroyDrawInfo(draw_info);
12420 if (package_info != (struct PackageInfo *) NULL)
12421 DestroyPackageInfo(package_info);
12422 InheritPerlException(exception,perl_exception);
12423 exception=DestroyExceptionInfo(exception);
12424 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12428 ###############################################################################
12432 # 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 #
12436 ###############################################################################
12440 QueryMultilineFontMetrics(ref,...)
12441 Image::Magick ref=NO_INIT
12443 querymultilinefontmetrics = 1
12490 *reference; /* reference is the SV* of ref=SvIV(reference) */
12495 PERL_UNUSED_VAR(ref);
12496 PERL_UNUSED_VAR(ix);
12497 exception=AcquireExceptionInfo();
12498 package_info=(struct PackageInfo *) NULL;
12499 perl_exception=newSVpv("",0);
12500 reference=SvRV(ST(0));
12501 av=(AV *) reference;
12502 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12504 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12505 if (image == (Image *) NULL)
12507 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12509 goto PerlException;
12511 package_info=ClonePackageInfo(info,exception);
12512 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12513 CloneString(&draw_info->text,"");
12514 current=draw_info->affine;
12515 GetAffineMatrix(&affine);
12518 EXTEND(sp,7*items);
12519 for (i=2; i < items; i+=2)
12521 attribute=(char *) SvPV(ST(i-1),na);
12522 switch (*attribute)
12527 if (LocaleCompare(attribute,"antialias") == 0)
12529 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12533 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12537 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12547 if (LocaleCompare(attribute,"density") == 0)
12549 CloneString(&draw_info->density,SvPV(ST(i),na));
12552 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12559 if (LocaleCompare(attribute,"encoding") == 0)
12561 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12564 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12571 if (LocaleCompare(attribute,"family") == 0)
12573 CloneString(&draw_info->family,SvPV(ST(i),na));
12576 if (LocaleCompare(attribute,"fill") == 0)
12579 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->fill,
12580 &image->exception);
12583 if (LocaleCompare(attribute,"font") == 0)
12585 CloneString(&draw_info->font,SvPV(ST(i),na));
12588 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12595 if (LocaleCompare(attribute,"geometry") == 0)
12597 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12600 if (LocaleCompare(attribute,"gravity") == 0)
12602 draw_info->gravity=(GravityType) ParseCommandOption(
12603 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12606 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12613 if (LocaleCompare(attribute,"pointsize") == 0)
12615 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12616 draw_info->pointsize=geometry_info.rho;
12619 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12626 if (LocaleCompare(attribute,"rotate") == 0)
12628 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12629 affine.rx=geometry_info.rho;
12630 affine.ry=geometry_info.sigma;
12631 if ((flags & SigmaValue) == 0)
12632 affine.ry=affine.rx;
12635 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12642 if (LocaleCompare(attribute,"scale") == 0)
12644 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12645 affine.sx=geometry_info.rho;
12646 affine.sy=geometry_info.sigma;
12647 if ((flags & SigmaValue) == 0)
12648 affine.sy=affine.sx;
12651 if (LocaleCompare(attribute,"skew") == 0)
12657 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12658 x_angle=geometry_info.rho;
12659 y_angle=geometry_info.sigma;
12660 if ((flags & SigmaValue) == 0)
12662 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12663 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12666 if (LocaleCompare(attribute,"stroke") == 0)
12669 (void) QueryColorDatabase(SvPV(ST(i),na),&draw_info->stroke,
12670 &image->exception);
12673 if (LocaleCompare(attribute,"style") == 0)
12675 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12679 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12683 draw_info->style=(StyleType) type;
12686 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12693 if (LocaleCompare(attribute,"text") == 0)
12695 CloneString(&draw_info->text,SvPV(ST(i),na));
12698 if (LocaleCompare(attribute,"translate") == 0)
12700 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12701 affine.tx=geometry_info.rho;
12702 affine.ty=geometry_info.sigma;
12703 if ((flags & SigmaValue) == 0)
12704 affine.ty=affine.tx;
12707 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12714 if (LocaleCompare(attribute,"weight") == 0)
12716 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12717 draw_info->weight=(size_t) geometry_info.rho;
12720 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12727 if (LocaleCompare(attribute,"x") == 0)
12729 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12730 x=geometry_info.rho;
12733 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12740 if (LocaleCompare(attribute,"y") == 0)
12742 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12743 y=geometry_info.rho;
12746 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12752 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12758 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12759 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12760 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12761 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12762 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12763 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12764 if (draw_info->geometry == (char *) NULL)
12766 draw_info->geometry=AcquireString((char *) NULL);
12767 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12768 "%.15g,%.15g",x,y);
12770 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12771 (void) CatchException(exception);
12772 if (status == MagickFalse)
12776 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12777 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12778 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12779 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12780 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12781 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12782 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12783 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12784 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12785 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12786 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12787 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12788 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12790 draw_info=DestroyDrawInfo(draw_info);
12793 if (package_info != (struct PackageInfo *) NULL)
12794 DestroyPackageInfo(package_info);
12795 InheritPerlException(exception,perl_exception);
12796 exception=DestroyExceptionInfo(exception);
12797 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12801 ###############################################################################
12805 # Q u e r y F o r m a t #
12809 ###############################################################################
12813 QueryFormat(ref,...)
12814 Image::Magick ref=NO_INIT
12831 volatile const MagickInfo
12834 PERL_UNUSED_VAR(ref);
12835 PERL_UNUSED_VAR(ix);
12836 exception=AcquireExceptionInfo();
12837 perl_exception=newSVpv("",0);
12841 format[MaxTextExtent];
12849 format_list=GetMagickInfoList("*",&types,exception);
12851 for (i=0; i < (ssize_t) types; i++)
12853 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12854 LocaleLower(format);
12855 PUSHs(sv_2mortal(newSVpv(format,0)));
12857 format_list=(const MagickInfo **)
12858 RelinquishMagickMemory((MagickInfo *) format_list);
12859 goto PerlException;
12861 EXTEND(sp,8*items);
12862 for (i=1; i < items; i++)
12864 name=(char *) SvPV(ST(i),na);
12865 magick_info=GetMagickInfo(name,exception);
12866 if (magick_info == (const MagickInfo *) NULL)
12871 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12872 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12873 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12874 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12875 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12876 if (magick_info->description == (char *) NULL)
12879 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12880 if (magick_info->module == (char *) NULL)
12883 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12887 InheritPerlException(exception,perl_exception);
12888 exception=DestroyExceptionInfo(exception);
12889 SvREFCNT_dec(perl_exception);
12893 ###############################################################################
12897 # Q u e r y O p t i o n #
12901 ###############################################################################
12905 QueryOption(ref,...)
12906 Image::Magick ref=NO_INIT
12927 PERL_UNUSED_VAR(ref);
12928 PERL_UNUSED_VAR(ix);
12929 exception=AcquireExceptionInfo();
12930 perl_exception=newSVpv("",0);
12931 EXTEND(sp,8*items);
12932 for (i=1; i < items; i++)
12934 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12936 options=GetCommandOptions((CommandOption) option);
12937 if (options == (char **) NULL)
12941 for (j=0; options[j] != (char *) NULL; j++)
12942 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12943 options=DestroyStringList(options);
12947 InheritPerlException(exception,perl_exception);
12948 exception=DestroyExceptionInfo(exception);
12949 SvREFCNT_dec(perl_exception);
12953 ###############################################################################
12961 ###############################################################################
12966 Image::Magick ref=NO_INIT
13013 *perl_exception, /* Perl variable for storing messages */
13018 PERL_UNUSED_VAR(ref);
13019 PERL_UNUSED_VAR(ix);
13020 exception=AcquireExceptionInfo();
13021 perl_exception=newSVpv("",0);
13023 package_info=(struct PackageInfo *) NULL;
13025 ac=(items < 2) ? 1 : items-1;
13026 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13028 length=(STRLEN *) NULL;
13029 if (list == (char **) NULL)
13031 ThrowPerlException(exception,ResourceLimitError,
13032 "MemoryAllocationFailed",PackageName);
13033 goto PerlException;
13035 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13036 if (length == (STRLEN *) NULL)
13038 ThrowPerlException(exception,ResourceLimitError,
13039 "MemoryAllocationFailed",PackageName);
13040 goto PerlException;
13042 if (sv_isobject(ST(0)) == 0)
13044 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13046 goto PerlException;
13048 reference=SvRV(ST(0));
13049 hv=SvSTASH(reference);
13050 if (SvTYPE(reference) != SVt_PVAV)
13052 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13054 goto PerlException;
13056 av=(AV *) reference;
13057 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13059 package_info=ClonePackageInfo(info,exception);
13062 *list=(char *) (*package_info->image_info->filename ?
13063 package_info->image_info->filename : "XC:black");
13065 for (n=0, i=0; i < ac; i++)
13067 list[n]=(char *) SvPV(ST(i+1),length[n]);
13068 if ((items >= 3) && strEQcase(list[n],"blob"))
13074 blob=(void *) (SvPV(ST(i+1),length[n]));
13075 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13077 if ((items >= 3) && strEQcase(list[n],"filename"))
13079 if ((items >= 3) && strEQcase(list[n],"file"))
13088 io_info=IoIFP(sv_2io(ST(i+1)));
13089 if (io_info == (PerlIO *) NULL)
13091 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13095 file=PerlIO_findFILE(io_info);
13096 if (file == (FILE *) NULL)
13098 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13102 SetImageInfoFile(package_info->image_info,file);
13104 if ((items >= 3) && strEQcase(list[n],"magick"))
13108 list[n]=(char *) NULL;
13110 status=ExpandFilenames(&n,&list);
13111 if (status == MagickFalse)
13113 ThrowPerlException(exception,ResourceLimitError,
13114 "MemoryAllocationFailed",PackageName);
13115 goto PerlException;
13118 for (i=0; i < n; i++)
13120 if ((package_info->image_info->file != (FILE *) NULL) ||
13121 (package_info->image_info->blob != (void *) NULL))
13123 image=ReadImages(package_info->image_info,exception);
13124 if (image != (Image *) NULL)
13125 DisassociateImageStream(image);
13129 (void) CopyMagickString(package_info->image_info->filename,list[i],
13131 image=ReadImages(package_info->image_info,exception);
13133 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13135 for ( ; image; image=image->next)
13137 AddImageToRegistry(sv,image);
13139 av_push(av,sv_bless(rv,hv));
13147 for (i=0; i < n; i++)
13148 if (list[i] != (char *) NULL)
13149 for (p=keep; list[i] != *p++; )
13150 if (*p == (char *) NULL)
13152 list[i]=(char *) RelinquishMagickMemory(list[i]);
13157 if (package_info != (struct PackageInfo *) NULL)
13158 DestroyPackageInfo(package_info);
13159 if (list && (list != keep))
13160 list=(char **) RelinquishMagickMemory(list);
13162 keep=(char **) RelinquishMagickMemory(keep);
13164 length=(STRLEN *) RelinquishMagickMemory(length);
13165 InheritPerlException(exception,perl_exception);
13166 exception=DestroyExceptionInfo(exception);
13167 sv_setiv(perl_exception,(IV) number_images);
13168 SvPOK_on(perl_exception);
13169 ST(0)=sv_2mortal(perl_exception);
13174 ###############################################################################
13182 ###############################################################################
13187 Image::Magick ref=NO_INIT
13210 PERL_UNUSED_VAR(ref);
13211 PERL_UNUSED_VAR(ix);
13212 exception=AcquireExceptionInfo();
13213 perl_exception=newSVpv("",0);
13214 reference=SvRV(ST(0));
13215 av=(AV *) reference;
13216 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13218 for (i=1; i < items; i++)
13219 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13220 SvPV(ST(i),na),exception);
13221 InheritPerlException(exception,perl_exception);
13222 exception=DestroyExceptionInfo(exception);
13223 SvREFCNT_dec(perl_exception); /* throw away all errors */
13227 ###############################################################################
13235 ###############################################################################
13240 Image::Magick ref=NO_INIT
13263 *reference; /* reference is the SV* of ref=SvIV(reference) */
13265 PERL_UNUSED_VAR(ref);
13266 PERL_UNUSED_VAR(ix);
13267 exception=AcquireExceptionInfo();
13268 perl_exception=newSVpv("",0);
13269 if (sv_isobject(ST(0)) == 0)
13271 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13273 goto PerlException;
13275 reference=SvRV(ST(0));
13276 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13278 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13280 for (i=2; i < items; i+=2)
13281 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13284 InheritPerlException(exception,perl_exception);
13285 exception=DestroyExceptionInfo(exception);
13286 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13287 SvPOK_on(perl_exception);
13288 ST(0)=sv_2mortal(perl_exception);
13293 ###############################################################################
13297 # S e t P i x e l #
13301 ###############################################################################
13306 Image::Magick ref=NO_INIT
13348 *reference; /* reference is the SV* of ref=SvIV(reference) */
13350 PERL_UNUSED_VAR(ref);
13351 PERL_UNUSED_VAR(ix);
13352 exception=AcquireExceptionInfo();
13353 perl_exception=newSVpv("",0);
13354 reference=SvRV(ST(0));
13355 av=(AV *) reference;
13356 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13358 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13359 if (image == (Image *) NULL)
13361 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13363 goto PerlException;
13366 normalize=MagickTrue;
13369 region.width=image->columns;
13372 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13373 channel=DefaultChannels;
13374 for (i=2; i < items; i+=2)
13376 attribute=(char *) SvPV(ST(i-1),na);
13377 switch (*attribute)
13382 if (LocaleCompare(attribute,"channel") == 0)
13387 option=ParseChannelOption(SvPV(ST(i),na));
13390 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13394 channel=(ChannelType) option;
13397 if (LocaleCompare(attribute,"color") == 0)
13399 if (SvTYPE(ST(i)) != SVt_RV)
13402 message[MaxTextExtent];
13404 (void) FormatLocaleString(message,MaxTextExtent,
13405 "invalid %.60s value",attribute);
13406 ThrowPerlException(exception,OptionError,message,
13409 av=(AV *) SvRV(ST(i));
13412 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13419 if (LocaleCompare(attribute,"geometry") == 0)
13421 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13424 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13431 if (LocaleCompare(attribute,"normalize") == 0)
13433 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13437 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13441 normalize=option != 0 ? MagickTrue : MagickFalse;
13444 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13451 if (LocaleCompare(attribute,"x") == 0)
13453 region.x=SvIV(ST(i));
13456 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13463 if (LocaleCompare(attribute,"y") == 0)
13465 region.y=SvIV(ST(i));
13468 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13474 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13480 (void) SetImageStorageClass(image,DirectClass,exception);
13481 channel_mask=SetPixelChannelMask(image,channel);
13482 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13483 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13484 (SvTYPE(av) != SVt_PVAV))
13496 if (normalize != MagickFalse)
13497 scale=QuantumRange;
13498 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13501 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13502 av_fetch(av,i,0)))),q);
13505 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13508 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13509 av_fetch(av,i,0)))),q);
13512 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13515 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13516 av_fetch(av,i,0)))),q);
13519 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13520 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13522 SetPixelBlack(image,ClampToQuantum(scale*
13523 SvNV(*(av_fetch(av,i,0)))),q);
13526 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13529 SetPixelAlpha(image,ClampToQuantum(scale*
13530 SvNV(*(av_fetch(av,i,0)))),q);
13533 (void) SyncAuthenticPixels(image,exception);
13535 (void) SetPixelChannelMask(image,channel_mask);
13538 InheritPerlException(exception,perl_exception);
13539 exception=DestroyExceptionInfo(exception);
13540 SvREFCNT_dec(perl_exception);
13544 ###############################################################################
13552 ###############################################################################
13557 Image::Magick ref=NO_INIT
13596 PERL_UNUSED_VAR(ref);
13597 PERL_UNUSED_VAR(ix);
13598 exception=AcquireExceptionInfo();
13599 perl_exception=newSVpv("",0);
13603 if (sv_isobject(ST(0)) == 0)
13605 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13607 goto PerlException;
13609 reference=SvRV(ST(0));
13610 hv=SvSTASH(reference);
13612 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13614 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13615 if (image == (Image *) NULL)
13617 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13619 goto PerlException;
13621 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13627 for (i=2; i < items; i+=2)
13629 attribute=(char *) SvPV(ST(i-1),na);
13630 switch (*attribute)
13635 if (LocaleCompare(attribute,"offset") == 0)
13637 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13640 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13647 if (LocaleCompare(attribute,"stack") == 0)
13649 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13653 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13665 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13671 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13673 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13674 goto PerlException;
13675 for ( ; image; image=image->next)
13677 AddImageToRegistry(sv,image);
13679 av_push(av,sv_bless(rv,hv));
13682 exception=DestroyExceptionInfo(exception);
13683 ST(0)=av_reference;
13684 SvREFCNT_dec(perl_exception);
13688 InheritPerlException(exception,perl_exception);
13689 exception=DestroyExceptionInfo(exception);
13690 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13691 SvPOK_on(perl_exception);
13692 ST(0)=sv_2mortal(perl_exception);
13697 ###############################################################################
13701 # S t a t i s t i c s #
13705 ###############################################################################
13709 Statistics(ref,...)
13710 Image::Magick ref=NO_INIT
13712 StatisticsImage = 1
13714 statisticsimage = 3
13717 #define ChannelStatistics(channel) \
13719 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13720 (double) channel_statistics[channel].depth); \
13721 PUSHs(sv_2mortal(newSVpv(message,0))); \
13722 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13723 channel_statistics[channel].minima/scale); \
13724 PUSHs(sv_2mortal(newSVpv(message,0))); \
13725 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13726 channel_statistics[channel].maxima/scale); \
13727 PUSHs(sv_2mortal(newSVpv(message,0))); \
13728 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13729 channel_statistics[channel].mean/scale); \
13730 PUSHs(sv_2mortal(newSVpv(message,0))); \
13731 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13732 channel_statistics[channel].standard_deviation/scale); \
13733 PUSHs(sv_2mortal(newSVpv(message,0))); \
13734 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13735 channel_statistics[channel].kurtosis); \
13736 PUSHs(sv_2mortal(newSVpv(message,0))); \
13737 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13738 channel_statistics[channel].skewness); \
13739 PUSHs(sv_2mortal(newSVpv(message,0))); \
13746 message[MaxTextExtent];
13749 *channel_statistics;
13770 PERL_UNUSED_VAR(ref);
13771 PERL_UNUSED_VAR(ix);
13772 exception=AcquireExceptionInfo();
13773 perl_exception=newSVpv("",0);
13775 if (sv_isobject(ST(0)) == 0)
13777 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13779 goto PerlException;
13781 reference=SvRV(ST(0));
13784 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13785 if (image == (Image *) NULL)
13787 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13789 goto PerlException;
13791 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13793 for ( ; image; image=image->next)
13795 channel_statistics=GetImageStatistics(image,&image->exception);
13796 if (channel_statistics == (ChannelStatistics *) NULL)
13799 EXTEND(sp,35*count);
13800 scale=(double) QuantumRange;
13801 ChannelStatistics(RedChannel);
13802 ChannelStatistics(GreenChannel);
13803 ChannelStatistics(BlueChannel);
13804 if (image->colorspace == CMYKColorspace)
13805 ChannelStatistics(BlackChannel);
13806 if (image->matte != MagickFalse)
13807 ChannelStatistics(AlphaChannel);
13808 channel_statistics=(ChannelStatistics *)
13809 RelinquishMagickMemory(channel_statistics);
13813 InheritPerlException(exception,perl_exception);
13814 exception=DestroyExceptionInfo(exception);
13815 SvREFCNT_dec(perl_exception);
13819 ###############################################################################
13823 # S y n c A u t h e n t i c P i x e l s #
13827 ###############################################################################
13831 SyncAuthenticPixels(ref,...)
13832 Image::Magick ref = NO_INIT
13834 Syncauthenticpixels = 1
13835 SyncImagePixels = 2
13836 syncimagepixels = 3
13855 PERL_UNUSED_VAR(ref);
13856 PERL_UNUSED_VAR(ix);
13857 exception=AcquireExceptionInfo();
13858 perl_exception=newSVpv("",0);
13859 if (sv_isobject(ST(0)) == 0)
13861 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13863 goto PerlException;
13866 reference=SvRV(ST(0));
13867 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13868 if (image == (Image *) NULL)
13870 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13872 goto PerlException;
13875 status=SyncAuthenticPixels(image,exception);
13876 if (status != MagickFalse)
13878 InheritException(exception,&image->exception);
13881 InheritPerlException(exception,perl_exception);
13882 exception=DestroyExceptionInfo(exception);
13883 SvREFCNT_dec(perl_exception); /* throw away all errors */
13887 ###############################################################################
13891 # T r a n s f o r m #
13895 ###############################################################################
13900 Image::Magick ref=NO_INIT
13938 PERL_UNUSED_VAR(ref);
13939 PERL_UNUSED_VAR(ix);
13940 exception=AcquireExceptionInfo();
13941 perl_exception=newSVpv("",0);
13945 if (sv_isobject(ST(0)) == 0)
13947 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13949 goto PerlException;
13951 reference=SvRV(ST(0));
13952 hv=SvSTASH(reference);
13954 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13956 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13957 if (image == (Image *) NULL)
13959 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13961 goto PerlException;
13963 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13967 crop_geometry=(char *) NULL;
13968 geometry=(char *) NULL;
13969 for (i=2; i < items; i+=2)
13971 attribute=(char *) SvPV(ST(i-1),na);
13972 switch (*attribute)
13977 if (LocaleCompare(attribute,"crop") == 0)
13979 crop_geometry=SvPV(ST(i),na);
13982 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13989 if (LocaleCompare(attribute,"geometry") == 0)
13991 geometry=SvPV(ST(i),na);
13994 if (LocaleCompare(attribute,"gravity") == 0)
14002 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
14003 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
14006 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14010 for (next=image; next; next=next->next)
14011 next->gravity=(GravityType) in;
14014 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14020 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14026 for ( ; image; image=image->next)
14028 clone=CloneImage(image,0,0,MagickTrue,exception);
14029 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
14030 goto PerlException;
14031 TransformImage(&clone,crop_geometry,geometry);
14032 for ( ; clone; clone=clone->next)
14034 AddImageToRegistry(sv,clone);
14036 av_push(av,sv_bless(rv,hv));
14040 exception=DestroyExceptionInfo(exception);
14041 ST(0)=av_reference;
14042 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14046 InheritPerlException(exception,perl_exception);
14047 exception=DestroyExceptionInfo(exception);
14048 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14049 SvPOK_on(perl_exception);
14050 ST(0)=sv_2mortal(perl_exception);
14055 ###############################################################################
14063 ###############################################################################
14068 Image::Magick ref=NO_INIT
14076 filename[MaxTextExtent];
14100 PERL_UNUSED_VAR(ref);
14101 PERL_UNUSED_VAR(ix);
14102 exception=AcquireExceptionInfo();
14103 perl_exception=newSVpv("",0);
14105 package_info=(struct PackageInfo *) NULL;
14106 if (sv_isobject(ST(0)) == 0)
14108 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14110 goto PerlException;
14112 reference=SvRV(ST(0));
14113 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14114 if (image == (Image *) NULL)
14116 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14118 goto PerlException;
14120 package_info=ClonePackageInfo(info,exception);
14122 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14125 for (i=2; i < items; i+=2)
14126 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14128 (void) CopyMagickString(filename,package_info->image_info->filename,
14131 for (next=image; next; next=next->next)
14133 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14134 next->scene=scene++;
14136 SetImageInfo(package_info->image_info,(unsigned int)
14137 GetImageListLength(image),&image->exception);
14138 for (next=image; next; next=next->next)
14140 (void) WriteImage(package_info->image_info,next,exception);
14142 if (package_info->image_info->adjoin)
14147 if (package_info != (struct PackageInfo *) NULL)
14148 DestroyPackageInfo(package_info);
14149 InheritPerlException(exception,perl_exception);
14150 exception=DestroyExceptionInfo(exception);
14151 sv_setiv(perl_exception,(IV) number_images);
14152 SvPOK_on(perl_exception);
14153 ST(0)=sv_2mortal(perl_exception);