2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv((IV) image); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"bias", RealReference},
218 {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference} } },
222 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference}, {"fuzz", StringReference},
225 {"gravity", MagickGravityOptions} } },
227 { "Edge", { {"radius", RealReference} } },
228 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
229 {"sigma", RealReference} } },
233 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
234 {"height", IntegerReference}, {"inner", IntegerReference},
235 {"outer", IntegerReference}, {"fill", StringReference},
236 {"color", StringReference}, {"compose", MagickComposeOptions} } },
237 { "Implode", { {"amount", RealReference},
238 {"interpolate", MagickInterpolateOptions} } },
240 { "MedianFilter", { {"geometry", StringReference},
241 {"width", IntegerReference}, {"height", IntegerReference},
242 {"channel", MagickChannelOptions} } },
244 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
245 { "ReduceNoise", { {"geometry", StringReference},
246 {"width", IntegerReference},{"height", IntegerReference},
247 {"channel", MagickChannelOptions} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference}, {"fill", StringReference},
251 {"color", StringReference}, {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"bias", RealReference},
260 {"channel", MagickChannelOptions} } },
261 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
262 {"y", RealReference}, { "fill", StringReference},
263 {"color", StringReference} } },
264 { "Spread", { {"radius", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Swirl", { {"degrees", RealReference},
267 {"interpolate", MagickInterpolateOptions} } },
268 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
269 {"height", IntegerReference}, {"filter", MagickFilterOptions},
270 {"support", StringReference }, {"blur", RealReference } } },
271 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
272 {"height", IntegerReference}, {"filter", MagickFilterOptions},
273 {"support", RealReference }, {"blur", RealReference } } },
274 { "Annotate", { {"text", StringReference}, {"font", StringReference},
275 {"pointsize", RealReference}, {"density", StringReference},
276 {"undercolor", StringReference}, {"stroke", StringReference},
277 {"fill", StringReference}, {"geometry", StringReference},
278 {"pen", StringReference}, {"x", RealReference},
279 {"y", RealReference}, {"gravity", MagickGravityOptions},
280 {"translate", StringReference}, {"scale", StringReference},
281 {"rotate", RealReference}, {"skewX", RealReference},
282 {"skewY", RealReference}, {"strokewidth", RealReference},
283 {"antialias", MagickBooleanOptions}, {"family", StringReference},
284 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
285 {"weight", IntegerReference}, {"align", MagickAlignOptions},
286 {"encoding", StringReference}, {"affine", ArrayReference},
287 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
288 {"tile", ImageReference}, {"kerning", RealReference},
289 {"interline-spacing", RealReference},
290 {"interword-spacing", RealReference},
291 {"direction", MagickDirectionOptions} } },
292 { "ColorFloodfill", { {"geometry", StringReference},
293 {"x", IntegerReference}, {"y", IntegerReference},
294 {"fill", StringReference}, {"bordercolor", StringReference},
295 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
296 { "Composite", { {"image", ImageReference},
297 {"compose", MagickComposeOptions}, {"geometry", StringReference},
298 {"x", IntegerReference}, {"y", IntegerReference},
299 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
300 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
301 {"color", StringReference}, {"mask", ImageReference},
302 {"channel", MagickChannelOptions},
303 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
304 {"blend", StringReference} } },
305 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
306 { "CycleColormap", { {"display", IntegerReference} } },
307 { "Draw", { {"primitive", MagickPrimitiveOptions},
308 {"points", StringReference}, {"method", MagickMethodOptions},
309 {"stroke", StringReference}, {"fill", StringReference},
310 {"strokewidth", RealReference}, {"font", StringReference},
311 {"bordercolor", StringReference}, {"x", RealReference},
312 {"y", RealReference}, {"translate", StringReference},
313 {"scale", StringReference}, {"rotate", RealReference},
314 {"skewX", RealReference}, {"skewY", RealReference},
315 {"tile", ImageReference}, {"pointsize", RealReference},
316 {"antialias", MagickBooleanOptions}, {"density", StringReference},
317 {"linewidth", RealReference}, {"affine", ArrayReference},
318 {"stroke-dashoffset", RealReference},
319 {"stroke-dasharray", ArrayReference},
320 {"interpolate", MagickInterpolateOptions},
321 {"origin", StringReference}, {"text", StringReference},
322 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
323 {"vector-graphics", StringReference}, {"kerning", RealReference},
324 {"interline-spacing", RealReference},
325 {"interword-spacing", RealReference},
326 {"direction", MagickDirectionOptions} } },
327 { "Equalize", { {"channel", MagickChannelOptions} } },
328 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
329 {"red", RealReference}, {"green", RealReference},
330 {"blue", RealReference} } },
331 { "Map", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
332 {"dither-method", MagickDitherOptions} } },
333 { "MatteFloodfill", { {"geometry", StringReference},
334 {"x", IntegerReference}, {"y", IntegerReference},
335 {"opacity", StringReference}, {"bordercolor", StringReference},
336 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
337 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
338 {"saturation", RealReference}, {"whiteness", RealReference},
339 {"brightness", RealReference}, {"lightness", RealReference},
340 {"blackness", RealReference} } },
341 { "Negate", { {"gray", MagickBooleanOptions},
342 {"channel", MagickChannelOptions} } },
343 { "Normalize", { {"channel", MagickChannelOptions} } },
345 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
346 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
347 {"invert", MagickBooleanOptions} } },
348 { "Quantize", { {"colors", IntegerReference},
349 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
350 {"dither", MagickBooleanOptions}, {"measure", MagickBooleanOptions},
351 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
352 {"dither-method", MagickDitherOptions} } },
353 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
354 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
355 { "Segment", { {"geometry", StringReference},
356 {"cluster-threshold", RealReference},
357 {"smoothing-threshold", RealReference},
358 {"colorspace", MagickColorspaceOptions},
359 {"verbose", MagickBooleanOptions} } },
361 { "Solarize", { {"geometry", StringReference},
362 {"threshold", StringReference} } },
364 { "Texture", { {"texture", ImageReference} } },
365 { "Evaluate", { {"value", RealReference},
366 {"operator", MagickEvaluateOptions},
367 {"channel", MagickChannelOptions} } },
368 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
369 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
370 { "Threshold", { {"threshold", StringReference},
371 {"channel", MagickChannelOptions} } },
372 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
373 {"sigma", RealReference}, {"biabias", RealReference} } },
374 { "Trim", { {"fuzz", StringReference} } },
375 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
376 {"wavelength", RealReference},
377 {"interpolate", MagickInterpolateOptions} } },
378 { "Separate", { {"channel", MagickChannelOptions} } },
380 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
381 {"y", IntegerReference} } },
382 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
384 { "GaussianBlur", { {"geometry", StringReference},
385 {"radius", RealReference}, {"sigma", RealReference},
386 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
387 { "Convolve", { {"coefficients", ArrayReference},
388 {"channel", MagickChannelOptions}, {"bias", StringReference},
389 {"kernel", StringReference} } },
390 { "Profile", { {"name", StringReference}, {"profile", StringReference},
391 { "rendering-intent", MagickIntentOptions},
392 { "black-point-compensation", MagickBooleanOptions} } },
393 { "UnsharpMask", { {"geometry", StringReference},
394 {"radius", RealReference}, {"sigma", RealReference},
395 {"amount", RealReference}, {"threshold", RealReference},
396 {"channel", MagickChannelOptions} } },
397 { "MotionBlur", { {"geometry", StringReference},
398 {"radius", RealReference}, {"sigma", RealReference},
399 {"angle", RealReference}, {"bias", RealReference},
400 {"channel", MagickChannelOptions} } },
401 { "OrderedDither", { {"threshold", StringReference},
402 {"channel", MagickChannelOptions} } },
403 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
404 {"height", IntegerReference} } },
405 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
406 {"white-point", RealReference}, {"gamma", RealReference},
407 {"channel", MagickChannelOptions}, {"level", StringReference} } },
408 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
409 { "AffineTransform", { {"affine", ArrayReference},
410 {"translate", StringReference}, {"scale", StringReference},
411 {"rotate", RealReference}, {"skewX", RealReference},
412 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
413 {"background", StringReference} } },
414 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
415 { "AdaptiveThreshold", { {"geometry", StringReference},
416 {"width", IntegerReference}, {"height", IntegerReference},
417 {"bias", RealReference} } },
418 { "Resample", { {"density", StringReference}, {"x", RealReference},
419 {"y", RealReference}, {"filter", MagickFilterOptions},
420 {"support", RealReference }, {"blur", RealReference } } },
421 { "Describe", { {"file", FileReference} } },
422 { "BlackThreshold", { {"threshold", StringReference},
423 {"channel", MagickChannelOptions} } },
424 { "WhiteThreshold", { {"threshold", StringReference},
425 {"channel", MagickChannelOptions} } },
426 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
427 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
428 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference} } },
431 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"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 SetImageOption(info->image_info,attribute,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),exception);
1165 if (LocaleCompare(attribute,"background") == 0)
1167 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1170 info->image_info->background_color=target_color;
1171 for ( ; image; image=image->next)
1172 image->background_color=target_color;
1175 if (LocaleCompare(attribute,"bias") == 0)
1177 for ( ; image; image=image->next)
1178 image->bias=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1181 if (LocaleCompare(attribute,"blue-primary") == 0)
1183 for ( ; image; image=image->next)
1185 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1186 image->chromaticity.blue_primary.x=geometry_info.rho;
1187 image->chromaticity.blue_primary.y=geometry_info.sigma;
1188 if ((flags & SigmaValue) == 0)
1189 image->chromaticity.blue_primary.y=
1190 image->chromaticity.blue_primary.x;
1194 if (LocaleCompare(attribute,"bordercolor") == 0)
1196 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1199 info->image_info->border_color=target_color;
1200 for ( ; image; image=image->next)
1201 image->border_color=target_color;
1205 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1206 for ( ; image; image=image->next)
1207 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1213 if (LocaleCompare(attribute,"cache-threshold") == 0)
1215 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1216 SiPrefixToDouble(SvPV(sval,na),100.0));
1217 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1218 (2*SiPrefixToDouble(SvPV(sval,na),100.0)));
1221 if (LocaleCompare(attribute,"clip-mask") == 0)
1226 clip_mask=(Image *) NULL;
1228 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1229 for ( ; image; image=image->next)
1230 SetImageClipMask(image,clip_mask,exception);
1233 if (LocaleNCompare(attribute,"colormap",8) == 0)
1235 for ( ; image; image=image->next)
1243 if (image->storage_class == DirectClass)
1246 items=sscanf(attribute,"%*[^[][%ld",&i);
1248 if (i > (ssize_t) image->colors)
1250 if ((strchr(SvPV(sval,na),',') == 0) ||
1251 (strchr(SvPV(sval,na),')') != 0))
1252 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1253 image->colormap+i,exception);
1256 color=image->colormap+i;
1257 pixel.red=color->red;
1258 pixel.green=color->green;
1259 pixel.blue=color->blue;
1260 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1261 pixel.red=geometry_info.rho;
1262 pixel.green=geometry_info.sigma;
1263 pixel.blue=geometry_info.xi;
1264 color->red=ClampToQuantum(pixel.red);
1265 color->green=ClampToQuantum(pixel.green);
1266 color->blue=ClampToQuantum(pixel.blue);
1271 if (LocaleCompare(attribute,"colorspace") == 0)
1273 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1274 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1277 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1281 for ( ; image; image=image->next)
1282 (void) TransformImageColorspace(image,(ColorspaceType) sp);
1285 if (LocaleCompare(attribute,"comment") == 0)
1287 for ( ; image; image=image->next)
1288 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1289 info ? info->image_info : (ImageInfo *) NULL,image,
1290 SvPV(sval,na),exception),exception);
1293 if (LocaleCompare(attribute,"compression") == 0)
1295 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1296 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1299 ThrowPerlException(exception,OptionError,
1300 "UnrecognizedImageCompression",SvPV(sval,na));
1304 info->image_info->compression=(CompressionType) sp;
1305 for ( ; image; image=image->next)
1306 image->compression=(CompressionType) sp;
1310 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1311 for ( ; image; image=image->next)
1312 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1318 if (LocaleCompare(attribute,"debug") == 0)
1320 SetLogEventMask(SvPV(sval,na));
1323 if (LocaleCompare(attribute,"delay") == 0)
1325 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1326 for ( ; image; image=image->next)
1328 image->delay=(size_t) floor(geometry_info.rho+0.5);
1329 if ((flags & SigmaValue) != 0)
1330 image->ticks_per_second=(ssize_t)
1331 floor(geometry_info.sigma+0.5);
1335 if (LocaleCompare(attribute,"disk-limit") == 0)
1340 limit=MagickResourceInfinity;
1341 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1342 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1343 (void) SetMagickResourceLimit(DiskResource,limit);
1346 if (LocaleCompare(attribute,"density") == 0)
1348 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1350 ThrowPerlException(exception,OptionError,"MissingGeometry",
1355 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1356 for ( ; image; image=image->next)
1358 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1359 image->x_resolution=geometry_info.rho;
1360 image->y_resolution=geometry_info.sigma;
1361 if ((flags & SigmaValue) == 0)
1362 image->y_resolution=image->x_resolution;
1366 if (LocaleCompare(attribute,"depth") == 0)
1369 info->image_info->depth=SvIV(sval);
1370 for ( ; image; image=image->next)
1371 (void) SetImageDepth(image,SvIV(sval));
1374 if (LocaleCompare(attribute,"dispose") == 0)
1376 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1377 SvPV(sval,na)) : SvIV(sval);
1380 ThrowPerlException(exception,OptionError,
1381 "UnrecognizedDisposeMethod",SvPV(sval,na));
1384 for ( ; image; image=image->next)
1385 image->dispose=(DisposeType) sp;
1388 if (LocaleCompare(attribute,"dither") == 0)
1392 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1393 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1396 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1400 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1404 if (LocaleCompare(attribute,"display") == 0)
1408 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1412 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1413 for ( ; image; image=image->next)
1414 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1420 if (LocaleCompare(attribute,"endian") == 0)
1422 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1423 SvPV(sval,na)) : SvIV(sval);
1426 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1431 info->image_info->endian=(EndianType) sp;
1432 for ( ; image; image=image->next)
1433 image->endian=(EndianType) sp;
1436 if (LocaleCompare(attribute,"extract") == 0)
1439 Set image extract geometry.
1441 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1445 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1446 for ( ; image; image=image->next)
1447 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1453 if (LocaleCompare(attribute,"filename") == 0)
1456 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1458 for ( ; image; image=image->next)
1459 (void) CopyMagickString(image->filename,SvPV(sval,na),
1463 if (LocaleCompare(attribute,"file") == 0)
1471 if (info == (struct PackageInfo *) NULL)
1473 io_info=IoIFP(sv_2io(sval));
1474 if (io_info == (PerlIO *) NULL)
1476 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1480 file=PerlIO_findFILE(io_info);
1481 if (file == (FILE *) NULL)
1483 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1487 SetImageInfoFile(info->image_info,file);
1490 if (LocaleCompare(attribute,"fill") == 0)
1493 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1496 if (LocaleCompare(attribute,"font") == 0)
1499 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1502 if (LocaleCompare(attribute,"foreground") == 0)
1504 if (LocaleCompare(attribute,"fuzz") == 0)
1507 info->image_info->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1508 for ( ; image; image=image->next)
1509 image->fuzz=SiPrefixToDouble(SvPV(sval,na),QuantumRange);
1513 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1514 for ( ; image; image=image->next)
1515 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1521 if (LocaleCompare(attribute,"gamma") == 0)
1523 for ( ; image; image=image->next)
1524 image->gamma=SvNV(sval);
1527 if (LocaleCompare(attribute,"gravity") == 0)
1529 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1530 SvPV(sval,na)) : SvIV(sval);
1533 ThrowPerlException(exception,OptionError,
1534 "UnrecognizedGravityType",SvPV(sval,na));
1538 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1539 for ( ; image; image=image->next)
1540 image->gravity=(GravityType) sp;
1543 if (LocaleCompare(attribute,"green-primary") == 0)
1545 for ( ; image; image=image->next)
1547 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1548 image->chromaticity.green_primary.x=geometry_info.rho;
1549 image->chromaticity.green_primary.y=geometry_info.sigma;
1550 if ((flags & SigmaValue) == 0)
1551 image->chromaticity.green_primary.y=
1552 image->chromaticity.green_primary.x;
1557 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1558 for ( ; image; image=image->next)
1559 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1565 if (LocaleNCompare(attribute,"index",5) == 0)
1579 for ( ; image; image=image->next)
1581 if (image->storage_class != PseudoClass)
1585 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1587 image_view=AcquireCacheView(image);
1588 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1589 if (q != (Quantum *) NULL)
1591 items=sscanf(SvPV(sval,na),"%ld",&index);
1592 if ((index >= 0) && (index < (ssize_t) image->colors))
1593 SetPixelIndex(image,index,q);
1594 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1596 image_view=DestroyCacheView(image_view);
1600 if (LocaleCompare(attribute,"iterations") == 0)
1603 for ( ; image; image=image->next)
1604 image->iterations=SvIV(sval);
1607 if (LocaleCompare(attribute,"interlace") == 0)
1609 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1610 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1613 ThrowPerlException(exception,OptionError,
1614 "UnrecognizedInterlaceType",SvPV(sval,na));
1618 info->image_info->interlace=(InterlaceType) sp;
1619 for ( ; image; image=image->next)
1620 image->interlace=(InterlaceType) sp;
1624 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1625 for ( ; image; image=image->next)
1626 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1632 if (LocaleCompare(attribute,"label") == 0)
1634 for ( ; image; image=image->next)
1635 (void) SetImageProperty(image,"label",InterpretImageProperties(
1636 info ? info->image_info : (ImageInfo *) NULL,image,
1637 SvPV(sval,na),exception),exception);
1640 if (LocaleCompare(attribute,"loop") == 0)
1643 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1644 for ( ; image; image=image->next)
1645 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1651 if (LocaleCompare(attribute,"magick") == 0)
1654 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1655 "%s:",SvPV(sval,na));
1656 for ( ; image; image=image->next)
1657 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1660 if (LocaleCompare(attribute,"map-limit") == 0)
1665 limit=MagickResourceInfinity;
1666 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1667 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1668 (void) SetMagickResourceLimit(MapResource,limit);
1671 if (LocaleCompare(attribute,"mask") == 0)
1676 mask=(Image *) NULL;
1678 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1679 for ( ; image; image=image->next)
1680 SetImageMask(image,mask,exception);
1683 if (LocaleCompare(attribute,"mattecolor") == 0)
1685 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1688 info->image_info->matte_color=target_color;
1689 for ( ; image; image=image->next)
1690 image->matte_color=target_color;
1693 if (LocaleCompare(attribute,"matte") == 0)
1695 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1696 SvPV(sval,na)) : SvIV(sval);
1699 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1703 for ( ; image; image=image->next)
1704 image->matte=sp != 0 ? MagickTrue : MagickFalse;
1707 if (LocaleCompare(attribute,"memory-limit") == 0)
1712 limit=MagickResourceInfinity;
1713 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1714 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1715 (void) SetMagickResourceLimit(MemoryResource,limit);
1718 if (LocaleCompare(attribute,"monochrome") == 0)
1720 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1721 SvPV(sval,na)) : SvIV(sval);
1724 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1729 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1730 for ( ; image; image=image->next)
1731 (void) SetImageType(image,BilevelType,exception);
1735 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1736 for ( ; image; image=image->next)
1737 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1743 if (LocaleCompare(attribute,"option") == 0)
1746 DefineImageOption(info->image_info,SvPV(sval,na));
1749 if (LocaleCompare(attribute,"orientation") == 0)
1751 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1752 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1755 ThrowPerlException(exception,OptionError,
1756 "UnrecognizedOrientationType",SvPV(sval,na));
1760 info->image_info->orientation=(OrientationType) sp;
1761 for ( ; image; image=image->next)
1762 image->orientation=(OrientationType) sp;
1766 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1767 for ( ; image; image=image->next)
1768 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1774 if (LocaleCompare(attribute,"page") == 0)
1779 geometry=GetPageGeometry(SvPV(sval,na));
1781 (void) CloneString(&info->image_info->page,geometry);
1782 for ( ; image; image=image->next)
1783 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1784 geometry=(char *) RelinquishMagickMemory(geometry);
1787 if (LocaleCompare(attribute,"pen") == 0)
1790 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1793 if (LocaleNCompare(attribute,"pixel",5) == 0)
1807 for ( ; image; image=image->next)
1809 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1813 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1815 image_view=AcquireCacheView(image);
1816 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1817 if (q != (Quantum *) NULL)
1819 if ((strchr(SvPV(sval,na),',') == 0) ||
1820 (strchr(SvPV(sval,na),')') != 0))
1821 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1825 GetPixelInfo(image,&pixel);
1826 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1827 pixel.red=geometry_info.rho;
1828 if ((flags & SigmaValue) != 0)
1829 pixel.green=geometry_info.sigma;
1830 if ((flags & XiValue) != 0)
1831 pixel.blue=geometry_info.xi;
1832 if ((flags & PsiValue) != 0)
1833 pixel.alpha=geometry_info.psi;
1834 if ((flags & ChiValue) != 0)
1835 pixel.black=geometry_info.chi;
1837 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1838 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1839 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1840 if (image->colorspace == CMYKColorspace)
1841 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1842 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1843 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1845 image_view=DestroyCacheView(image_view);
1849 if (LocaleCompare(attribute,"pointsize") == 0)
1853 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1854 info->image_info->pointsize=geometry_info.rho;
1858 if (LocaleCompare(attribute,"preview") == 0)
1860 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1861 SvPV(sval,na)) : SvIV(sval);
1864 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1869 info->image_info->preview_type=(PreviewType) sp;
1873 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1874 for ( ; image; image=image->next)
1875 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1881 if (LocaleCompare(attribute,"quality") == 0)
1884 info->image_info->quality=SvIV(sval);
1885 for ( ; image; image=image->next)
1886 image->quality=SvIV(sval);
1890 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1891 for ( ; image; image=image->next)
1892 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1898 if (LocaleCompare(attribute,"red-primary") == 0)
1900 for ( ; image; image=image->next)
1902 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1903 image->chromaticity.red_primary.x=geometry_info.rho;
1904 image->chromaticity.red_primary.y=geometry_info.sigma;
1905 if ((flags & SigmaValue) == 0)
1906 image->chromaticity.red_primary.y=
1907 image->chromaticity.red_primary.x;
1911 if (LocaleCompare(attribute,"render") == 0)
1913 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1914 SvPV(sval,na)) : SvIV(sval);
1917 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1921 for ( ; image; image=image->next)
1922 image->rendering_intent=(RenderingIntent) sp;
1925 if (LocaleCompare(attribute,"repage") == 0)
1930 for ( ; image; image=image->next)
1932 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1933 if ((flags & WidthValue) != 0)
1935 if ((flags & HeightValue) == 0)
1936 geometry.height=geometry.width;
1937 image->page.width=geometry.width;
1938 image->page.height=geometry.height;
1940 if ((flags & AspectValue) != 0)
1942 if ((flags & XValue) != 0)
1943 image->page.x+=geometry.x;
1944 if ((flags & YValue) != 0)
1945 image->page.y+=geometry.y;
1949 if ((flags & XValue) != 0)
1951 image->page.x=geometry.x;
1952 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1953 image->page.width=image->columns+geometry.x;
1955 if ((flags & YValue) != 0)
1957 image->page.y=geometry.y;
1958 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1959 image->page.height=image->rows+geometry.y;
1966 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1967 for ( ; image; image=image->next)
1968 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1974 if (LocaleCompare(attribute,"sampling-factor") == 0)
1976 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1978 ThrowPerlException(exception,OptionError,"MissingGeometry",
1983 (void) CloneString(&info->image_info->sampling_factor,
1987 if (LocaleCompare(attribute,"scene") == 0)
1989 for ( ; image; image=image->next)
1990 image->scene=SvIV(sval);
1993 if (LocaleCompare(attribute,"server") == 0)
1995 if (LocaleCompare(attribute,"size") == 0)
1999 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2001 ThrowPerlException(exception,OptionError,"MissingGeometry",
2005 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2009 if (LocaleCompare(attribute,"stroke") == 0)
2012 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2016 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2017 for ( ; image; image=image->next)
2018 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2024 if (LocaleCompare(attribute,"texture") == 0)
2027 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2030 if (LocaleCompare(attribute,"thread-limit") == 0)
2035 limit=MagickResourceInfinity;
2036 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2037 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2038 (void) SetMagickResourceLimit(ThreadResource,limit);
2041 if (LocaleCompare(attribute,"tile-offset") == 0)
2046 geometry=GetPageGeometry(SvPV(sval,na));
2048 (void) CloneString(&info->image_info->page,geometry);
2049 for ( ; image; image=image->next)
2050 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2052 geometry=(char *) RelinquishMagickMemory(geometry);
2055 if (LocaleCompare(attribute,"time-limit") == 0)
2060 limit=MagickResourceInfinity;
2061 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2062 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
2063 (void) SetMagickResourceLimit(TimeResource,limit);
2066 if (LocaleCompare(attribute,"transparent-color") == 0)
2068 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2071 info->image_info->transparent_color=target_color;
2072 for ( ; image; image=image->next)
2073 image->transparent_color=target_color;
2076 if (LocaleCompare(attribute,"type") == 0)
2078 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2079 SvPV(sval,na)) : SvIV(sval);
2082 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2087 info->image_info->type=(ImageType) sp;
2088 for ( ; image; image=image->next)
2089 SetImageType(image,(ImageType) sp,exception);
2093 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2094 for ( ; image; image=image->next)
2095 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2101 if (LocaleCompare(attribute,"units") == 0)
2103 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2104 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2107 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2112 info->image_info->units=(ResolutionType) sp;
2113 for ( ; image; image=image->next)
2118 units=(ResolutionType) sp;
2119 if (image->units != units)
2120 switch (image->units)
2122 case UndefinedResolution:
2123 case PixelsPerInchResolution:
2125 if (units == PixelsPerCentimeterResolution)
2127 image->x_resolution*=2.54;
2128 image->y_resolution*=2.54;
2132 case PixelsPerCentimeterResolution:
2134 if (units == PixelsPerInchResolution)
2136 image->x_resolution/=2.54;
2137 image->y_resolution/=2.54;
2147 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2148 for ( ; image; image=image->next)
2149 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2155 if (LocaleCompare(attribute,"verbose") == 0)
2157 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2158 SvPV(sval,na)) : SvIV(sval);
2161 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2166 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2169 if (LocaleCompare(attribute,"view") == 0)
2172 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2175 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2177 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2178 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2181 ThrowPerlException(exception,OptionError,
2182 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2186 info->image_info->virtual_pixel_method=(VirtualPixelMethod) sp;
2187 for ( ; image; image=image->next)
2188 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp);
2192 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2193 for ( ; image; image=image->next)
2194 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2200 if (LocaleCompare(attribute,"white-point") == 0)
2202 for ( ; image; image=image->next)
2204 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2205 image->chromaticity.white_point.x=geometry_info.rho;
2206 image->chromaticity.white_point.y=geometry_info.sigma;
2207 if ((flags & SigmaValue) == 0)
2208 image->chromaticity.white_point.y=
2209 image->chromaticity.white_point.x;
2214 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2215 for ( ; image; image=image->next)
2216 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2222 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2223 for ( ; image; image=image->next)
2224 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2235 % S e t u p L i s t %
2239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2241 % Method SetupList returns the list of all the images linked by their
2242 % image->next and image->previous link lists for use with ImageMagick. If
2243 % info is non-NULL, an info structure is returned in *info. If
2244 % reference_vector is non-NULL,an array of SV* are returned in
2245 % *reference_vector. Reference_vector is used when the images are going to be
2246 % replaced with new Image*'s.
2248 % The format of the SetupList routine is:
2250 % Image *SetupList(SV *reference,struct PackageInfo **info,
2251 % SV ***reference_vector,ExceptionInfo *exception)
2253 % A description of each parameter follows:
2255 % o list: a list of strings.
2257 % o string: a character string.
2259 % o exception: Return any errors or warnings in this structure.
2262 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2263 SV ***reference_vector,ExceptionInfo *exception)
2272 if (reference_vector)
2273 *reference_vector=NULL;
2278 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2279 if (info && (SvTYPE(reference) == SVt_PVAV))
2280 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2290 % s t r E Q c a s e %
2294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2296 % strEQcase() compares two strings and returns 0 if they are the
2297 % same or if the second string runs out first. The comparison is case
2300 % The format of the strEQcase routine is:
2302 % ssize_t strEQcase(const char *p,const char *q)
2304 % A description of each parameter follows:
2306 % o p: a character string.
2308 % o q: a character string.
2312 static ssize_t strEQcase(const char *p,const char *q)
2320 for (i=0 ; (c=(*q)) != 0; i++)
2322 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2323 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2328 return(((*q == 0) && (*p == 0)) ? i : 0);
2332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2336 % I m a g e : : M a g i c k %
2340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2344 MODULE = Image::Magick PACKAGE = Image::Magick
2349 MagickCoreGenesis("PerlMagick",MagickFalse);
2350 SetWarningHandler(NULL);
2351 SetErrorHandler(NULL);
2352 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2353 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2359 if (magick_registry != (SplayTreeInfo *) NULL)
2360 magick_registry=DestroySplayTree(magick_registry);
2361 MagickCoreTerminus();
2365 constant(name,argument)
2370 ###############################################################################
2378 ###############################################################################
2383 Image::Magick ref=NO_INIT
2407 PERL_UNUSED_VAR(ref);
2408 PERL_UNUSED_VAR(ix);
2409 exception=AcquireExceptionInfo();
2410 perl_exception=newSVpv("",0);
2411 package_info=(struct PackageInfo *) NULL;
2412 if (sv_isobject(ST(0)) == 0)
2414 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2418 reference=SvRV(ST(0));
2419 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2420 if (image == (Image *) NULL)
2422 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2426 package_info=ClonePackageInfo(info,exception);
2428 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2431 for (i=2; i < items; i+=2)
2432 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2434 (void) AnimateImages(package_info->image_info,image,exception);
2435 (void) CatchImageException(image);
2438 if (package_info != (struct PackageInfo *) NULL)
2439 DestroyPackageInfo(package_info);
2440 InheritPerlException(exception,perl_exception);
2441 exception=DestroyExceptionInfo(exception);
2442 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2443 SvPOK_on(perl_exception);
2444 ST(0)=sv_2mortal(perl_exception);
2449 ###############################################################################
2457 ###############################################################################
2462 Image::Magick ref=NO_INIT
2500 PERL_UNUSED_VAR(ref);
2501 PERL_UNUSED_VAR(ix);
2502 exception=AcquireExceptionInfo();
2503 perl_exception=newSVpv("",0);
2507 if (sv_isobject(ST(0)) == 0)
2509 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2513 reference=SvRV(ST(0));
2514 hv=SvSTASH(reference);
2516 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2519 if (image == (Image *) NULL)
2521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2525 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2530 for (i=2; i < items; i+=2)
2532 attribute=(char *) SvPV(ST(i-1),na);
2538 if (LocaleCompare(attribute,"stack") == 0)
2540 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2544 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2556 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2562 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2563 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2565 for ( ; image; image=image->next)
2567 AddImageToRegistry(sv,image);
2569 av_push(av,sv_bless(rv,hv));
2572 exception=DestroyExceptionInfo(exception);
2574 SvREFCNT_dec(perl_exception);
2578 InheritPerlException(exception,perl_exception);
2579 exception=DestroyExceptionInfo(exception);
2580 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2581 SvPOK_on(perl_exception);
2582 ST(0)=sv_2mortal(perl_exception);
2587 ###############################################################################
2595 ###############################################################################
2600 Image::Magick ref=NO_INIT
2631 PERL_UNUSED_VAR(ref);
2632 PERL_UNUSED_VAR(ix);
2633 exception=AcquireExceptionInfo();
2634 perl_exception=newSVpv("",0);
2636 if (sv_isobject(ST(0)) == 0)
2638 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2642 reference=SvRV(ST(0));
2643 hv=SvSTASH(reference);
2644 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2645 if (image == (Image *) NULL)
2647 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2651 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2652 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2655 Create blessed Perl array for the returned image.
2658 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2660 AddImageToRegistry(sv,image);
2662 av_push(av,sv_bless(rv,hv));
2664 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2665 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2666 "average-%.*s",(int) (MaxTextExtent-9),
2667 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2668 (void) CopyMagickString(image->filename,info->image_info->filename,
2670 SetImageInfo(info->image_info,0,exception);
2671 exception=DestroyExceptionInfo(exception);
2672 SvREFCNT_dec(perl_exception);
2676 InheritPerlException(exception,perl_exception);
2677 exception=DestroyExceptionInfo(exception);
2678 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2679 SvPOK_on(perl_exception);
2680 ST(0)=sv_2mortal(perl_exception);
2685 ###############################################################################
2689 # B l o b T o I m a g e #
2693 ###############################################################################
2697 BlobToImage(ref,...)
2698 Image::Magick ref=NO_INIT
2744 PERL_UNUSED_VAR(ref);
2745 PERL_UNUSED_VAR(ix);
2746 exception=AcquireExceptionInfo();
2747 perl_exception=newSVpv("",0);
2750 ac=(items < 2) ? 1 : items-1;
2751 length=(STRLEN *) NULL;
2752 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2753 if (list == (char **) NULL)
2755 ThrowPerlException(exception,ResourceLimitError,
2756 "MemoryAllocationFailed",PackageName);
2759 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2760 if (length == (STRLEN *) NULL)
2762 ThrowPerlException(exception,ResourceLimitError,
2763 "MemoryAllocationFailed",PackageName);
2766 if (sv_isobject(ST(0)) == 0)
2768 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2772 reference=SvRV(ST(0));
2773 hv=SvSTASH(reference);
2774 if (SvTYPE(reference) != SVt_PVAV)
2776 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2780 av=(AV *) reference;
2781 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2786 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2789 for (n=0, i=0; i < ac; i++)
2791 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2792 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2794 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2799 list[n]=(char *) NULL;
2801 for (i=number_images=0; i < n; i++)
2803 image=BlobToImage(info->image_info,list[i],length[i],exception);
2804 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
2806 for ( ; image; image=image->next)
2808 AddImageToRegistry(sv,image);
2810 av_push(av,sv_bless(rv,hv));
2818 for (i=0; i < n; i++)
2819 if (list[i] != (char *) NULL)
2820 for (p=keep; list[i] != *p++; )
2821 if (*p == (char *) NULL)
2823 list[i]=(char *) RelinquishMagickMemory(list[i]);
2829 list=(char **) RelinquishMagickMemory(list);
2831 length=(STRLEN *) RelinquishMagickMemory(length);
2832 InheritPerlException(exception,perl_exception);
2833 exception=DestroyExceptionInfo(exception);
2834 sv_setiv(perl_exception,(IV) number_images);
2835 SvPOK_on(perl_exception);
2836 ST(0)=sv_2mortal(perl_exception);
2841 ###############################################################################
2849 ###############################################################################
2854 Image::Magick ref=NO_INIT
2887 PERL_UNUSED_VAR(ref);
2888 PERL_UNUSED_VAR(ix);
2889 exception=AcquireExceptionInfo();
2890 perl_exception=newSVpv("",0);
2892 if (sv_isobject(ST(0)) == 0)
2894 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2898 reference=SvRV(ST(0));
2899 hv=SvSTASH(reference);
2900 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2901 if (image == (Image *) NULL)
2903 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2908 Create blessed Perl array for the returned image.
2911 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2913 for ( ; image; image=image->next)
2915 clone=CloneImage(image,0,0,MagickTrue,exception);
2916 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
2918 AddImageToRegistry(sv,clone);
2920 av_push(av,sv_bless(rv,hv));
2923 exception=DestroyExceptionInfo(exception);
2924 SvREFCNT_dec(perl_exception);
2928 InheritPerlException(exception,perl_exception);
2929 exception=DestroyExceptionInfo(exception);
2930 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2931 SvPOK_on(perl_exception);
2932 ST(0)=sv_2mortal(perl_exception);
2937 ###############################################################################
2945 ###############################################################################
2953 PERL_UNUSED_VAR(ref);
2954 if (magick_registry != (SplayTreeInfo *) NULL)
2959 ResetSplayTreeIterator(magick_registry);
2960 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2961 while (p != (Image *) NULL)
2964 p=(Image *) GetNextKeyInSplayTree(magick_registry);
2970 ###############################################################################
2978 ###############################################################################
2983 Image::Magick ref=NO_INIT
3012 PERL_UNUSED_VAR(ref);
3013 PERL_UNUSED_VAR(ix);
3014 exception=AcquireExceptionInfo();
3015 perl_exception=newSVpv("",0);
3017 if (sv_isobject(ST(0)) == 0)
3019 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3023 reference=SvRV(ST(0));
3024 hv=SvSTASH(reference);
3026 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3028 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3029 if (image == (Image *) NULL)
3031 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3035 image=CoalesceImages(image,exception);
3036 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3038 for ( ; image; image=image->next)
3040 AddImageToRegistry(sv,image);
3042 av_push(av,sv_bless(rv,hv));
3045 exception=DestroyExceptionInfo(exception);
3047 SvREFCNT_dec(perl_exception);
3051 InheritPerlException(exception,perl_exception);
3052 exception=DestroyExceptionInfo(exception);
3053 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3054 SvPOK_on(perl_exception);
3055 ST(0)=sv_2mortal(perl_exception);
3060 ###############################################################################
3068 ###############################################################################
3073 Image::Magick ref=NO_INIT
3119 PERL_UNUSED_VAR(ref);
3120 PERL_UNUSED_VAR(ix);
3121 exception=AcquireExceptionInfo();
3122 perl_exception=newSVpv("",0);
3126 if (sv_isobject(ST(0)) == 0)
3128 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3132 reference=SvRV(ST(0));
3133 hv=SvSTASH(reference);
3135 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3137 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3138 if (image == (Image *) NULL)
3140 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3144 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3148 reconstruct_image=image;
3149 metric=RootMeanSquaredErrorMetric;
3150 for (i=2; i < items; i+=2)
3152 attribute=(char *) SvPV(ST(i-1),na);
3158 if (LocaleCompare(attribute,"channel") == 0)
3163 option=ParseChannelOption(SvPV(ST(i),na));
3166 ThrowPerlException(exception,OptionError,
3167 "UnrecognizedType",SvPV(ST(i),na));
3170 SetPixelChannelMap(image,(ChannelType) option);
3173 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3180 if (LocaleCompare(attribute,"fuzz") == 0)
3182 image->fuzz=SiPrefixToDouble(SvPV(ST(i),na),100.0);
3185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3192 if (LocaleCompare(attribute,"image") == 0)
3194 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3195 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3198 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3205 if (LocaleCompare(attribute,"metric") == 0)
3207 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3211 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3215 metric=(MetricType) option;
3218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3224 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3230 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3232 if (difference_image != (Image *) NULL)
3234 difference_image->error.mean_error_per_pixel=distortion;
3235 AddImageToRegistry(sv,difference_image);
3237 av_push(av,sv_bless(rv,hv));
3240 exception=DestroyExceptionInfo(exception);
3242 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3246 InheritPerlException(exception,perl_exception);
3247 exception=DestroyExceptionInfo(exception);
3248 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3249 SvPOK_on(perl_exception);
3250 ST(0)=sv_2mortal(perl_exception);
3255 ###############################################################################
3259 # C o m p a r e L a y e r s #
3263 ###############################################################################
3268 Image::Magick ref=NO_INIT
3270 CompareImagesLayers = 1
3272 compareimagelayers = 3
3309 PERL_UNUSED_VAR(ref);
3310 PERL_UNUSED_VAR(ix);
3311 exception=AcquireExceptionInfo();
3312 perl_exception=newSVpv("",0);
3314 if (sv_isobject(ST(0)) == 0)
3316 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3320 reference=SvRV(ST(0));
3321 hv=SvSTASH(reference);
3323 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3325 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3326 if (image == (Image *) NULL)
3328 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3332 method=CompareAnyLayer;
3333 for (i=2; i < items; i+=2)
3335 attribute=(char *) SvPV(ST(i-1),na);
3341 if (LocaleCompare(attribute,"method") == 0)
3343 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3347 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3351 method=(ImageLayerMethod) option;
3354 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3360 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3366 image=CompareImagesLayers(image,method,exception);
3367 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3369 for ( ; image; image=image->next)
3371 AddImageToRegistry(sv,image);
3373 av_push(av,sv_bless(rv,hv));
3376 exception=DestroyExceptionInfo(exception);
3378 SvREFCNT_dec(perl_exception);
3382 InheritPerlException(exception,perl_exception);
3383 exception=DestroyExceptionInfo(exception);
3384 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3385 SvPOK_on(perl_exception);
3386 ST(0)=sv_2mortal(perl_exception);
3391 ###############################################################################
3399 ###############################################################################
3404 Image::Magick ref=NO_INIT
3410 PERL_UNUSED_VAR(ref);
3411 if (sv_isobject(ST(0)) == 0)
3412 croak("ReferenceIsNotMyType");
3413 reference=SvRV(ST(0));
3414 switch (SvTYPE(reference))
3419 message[MaxTextExtent];
3437 Array (AV *) reference
3439 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3440 XS_VERSION,reference);
3441 hv=gv_stashpv(PackageName, FALSE);
3444 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3448 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3450 info=(struct PackageInfo *) SvIV(sv);
3451 DestroyPackageInfo(info);
3453 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3463 Blessed scalar = (Image *) SvIV(reference)
3465 image=(Image *) SvIV(reference);
3466 if (image != (Image *) NULL)
3467 DeleteImageFromRegistry(reference,image);
3476 ###############################################################################
3484 ###############################################################################
3489 Image::Magick ref=NO_INIT
3513 PERL_UNUSED_VAR(ref);
3514 PERL_UNUSED_VAR(ix);
3515 exception=AcquireExceptionInfo();
3516 perl_exception=newSVpv("",0);
3517 package_info=(struct PackageInfo *) NULL;
3518 if (sv_isobject(ST(0)) == 0)
3520 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3524 reference=SvRV(ST(0));
3525 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3526 if (image == (Image *) NULL)
3528 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3532 package_info=ClonePackageInfo(info,exception);
3534 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3537 for (i=2; i < items; i+=2)
3538 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3540 (void) DisplayImages(package_info->image_info,image,exception);
3541 (void) CatchImageException(image);
3544 if (package_info != (struct PackageInfo *) NULL)
3545 DestroyPackageInfo(package_info);
3546 InheritPerlException(exception,perl_exception);
3547 exception=DestroyExceptionInfo(exception);
3548 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3549 SvPOK_on(perl_exception);
3550 ST(0)=sv_2mortal(perl_exception);
3555 ###############################################################################
3559 # E v a l u a t e I m a g e s #
3563 ###############################################################################
3568 Image::Magick ref=NO_INIT
3590 MagickEvaluateOperator
3605 PERL_UNUSED_VAR(ref);
3606 PERL_UNUSED_VAR(ix);
3607 exception=AcquireExceptionInfo();
3608 perl_exception=newSVpv("",0);
3610 if (sv_isobject(ST(0)) == 0)
3612 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3616 reference=SvRV(ST(0));
3617 hv=SvSTASH(reference);
3618 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3619 if (image == (Image *) NULL)
3621 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3625 op=MeanEvaluateOperator;
3631 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3635 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3639 op=(MagickEvaluateOperator) in;
3642 for (i=2; i < items; i+=2)
3644 attribute=(char *) SvPV(ST(i-1),na);
3650 if (LocaleCompare(attribute,"operator") == 0)
3655 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3656 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3659 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3663 op=(MagickEvaluateOperator) in;
3666 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3672 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3678 image=EvaluateImages(image,op,exception);
3679 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3682 Create blessed Perl array for the returned image.
3685 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3687 AddImageToRegistry(sv,image);
3689 av_push(av,sv_bless(rv,hv));
3691 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3692 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3693 "evaluate-%.*s",(int) (MaxTextExtent-9),
3694 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3695 (void) CopyMagickString(image->filename,info->image_info->filename,
3697 SetImageInfo(info->image_info,0,exception);
3698 exception=DestroyExceptionInfo(exception);
3699 SvREFCNT_dec(perl_exception);
3703 InheritPerlException(exception,perl_exception);
3704 exception=DestroyExceptionInfo(exception);
3705 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3706 SvPOK_on(perl_exception);
3707 ST(0)=sv_2mortal(perl_exception);
3712 ###############################################################################
3720 ###############################################################################
3725 Image::Magick ref=NO_INIT
3732 #define ChannelFeatures(channel,direction) \
3734 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3735 channel_features[channel].angular_second_moment[direction]); \
3736 PUSHs(sv_2mortal(newSVpv(message,0))); \
3737 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3738 channel_features[channel].contrast[direction]); \
3739 PUSHs(sv_2mortal(newSVpv(message,0))); \
3740 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3741 channel_features[channel].contrast[direction]); \
3742 PUSHs(sv_2mortal(newSVpv(message,0))); \
3743 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3744 channel_features[channel].variance_sum_of_squares[direction]); \
3745 PUSHs(sv_2mortal(newSVpv(message,0))); \
3746 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3747 channel_features[channel].inverse_difference_moment[direction]); \
3748 PUSHs(sv_2mortal(newSVpv(message,0))); \
3749 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3750 channel_features[channel].sum_average[direction]); \
3751 PUSHs(sv_2mortal(newSVpv(message,0))); \
3752 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3753 channel_features[channel].sum_variance[direction]); \
3754 PUSHs(sv_2mortal(newSVpv(message,0))); \
3755 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3756 channel_features[channel].sum_entropy[direction]); \
3757 PUSHs(sv_2mortal(newSVpv(message,0))); \
3758 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3759 channel_features[channel].entropy[direction]); \
3760 PUSHs(sv_2mortal(newSVpv(message,0))); \
3761 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3762 channel_features[channel].difference_variance[direction]); \
3763 PUSHs(sv_2mortal(newSVpv(message,0))); \
3764 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3765 channel_features[channel].difference_entropy[direction]); \
3766 PUSHs(sv_2mortal(newSVpv(message,0))); \
3767 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3768 channel_features[channel].measure_of_correlation_1[direction]); \
3769 PUSHs(sv_2mortal(newSVpv(message,0))); \
3770 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3771 channel_features[channel].measure_of_correlation_2[direction]); \
3772 PUSHs(sv_2mortal(newSVpv(message,0))); \
3773 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3774 channel_features[channel].maximum_correlation_coefficient[direction]); \
3775 PUSHs(sv_2mortal(newSVpv(message,0))); \
3783 message[MaxTextExtent];
3810 PERL_UNUSED_VAR(ref);
3811 PERL_UNUSED_VAR(ix);
3812 exception=AcquireExceptionInfo();
3813 perl_exception=newSVpv("",0);
3815 if (sv_isobject(ST(0)) == 0)
3817 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3821 reference=SvRV(ST(0));
3824 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3825 if (image == (Image *) NULL)
3827 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3831 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3833 for (i=2; i < items; i+=2)
3835 attribute=(char *) SvPV(ST(i-1),na);
3841 if (LocaleCompare(attribute,"distance") == 0)
3843 distance=StringToLong((char *) SvPV(ST(1),na));
3846 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3852 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3859 for ( ; image; image=image->next)
3861 channel_features=GetImageFeatures(image,distance,
3863 if (channel_features == (ChannelFeatures *) NULL)
3866 EXTEND(sp,75*count);
3867 for (i=0; i < 4; i++)
3869 ChannelFeatures(RedChannel,i);
3870 ChannelFeatures(GreenChannel,i);
3871 ChannelFeatures(BlueChannel,i);
3872 if (image->colorspace == CMYKColorspace)
3873 ChannelFeatures(BlackChannel,i);
3874 if (image->matte != MagickFalse)
3875 ChannelFeatures(AlphaChannel,i);
3877 channel_features=(ChannelFeatures *)
3878 RelinquishMagickMemory(channel_features);
3882 InheritPerlException(exception,perl_exception);
3883 exception=DestroyExceptionInfo(exception);
3884 SvREFCNT_dec(perl_exception);
3888 ###############################################################################
3896 ###############################################################################
3901 Image::Magick ref=NO_INIT
3939 PERL_UNUSED_VAR(ref);
3940 PERL_UNUSED_VAR(ix);
3941 exception=AcquireExceptionInfo();
3942 perl_exception=newSVpv("",0);
3944 if (sv_isobject(ST(0)) == 0)
3946 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3950 reference=SvRV(ST(0));
3951 hv=SvSTASH(reference);
3952 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3953 if (image == (Image *) NULL)
3955 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3959 background_color=image->background_color;
3961 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
3962 &background_color,exception);
3964 for (i=2; i < items; i+=2)
3966 attribute=(char *) SvPV(ST(i-1),na);
3972 if (LocaleCompare(attribute,"background") == 0)
3974 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
3975 AllCompliance,&background_color,exception);
3978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3984 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3990 image->background_color=background_color;
3991 image=MergeImageLayers(image,FlattenLayer,exception);
3992 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
3995 Create blessed Perl array for the returned image.
3998 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4000 AddImageToRegistry(sv,image);
4002 av_push(av,sv_bless(rv,hv));
4004 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4005 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4006 "flatten-%.*s",(int) (MaxTextExtent-9),
4007 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4008 (void) CopyMagickString(image->filename,info->image_info->filename,
4010 SetImageInfo(info->image_info,0,exception);
4011 exception=DestroyExceptionInfo(exception);
4012 SvREFCNT_dec(perl_exception);
4016 InheritPerlException(exception,perl_exception);
4017 exception=DestroyExceptionInfo(exception);
4018 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4019 SvPOK_on(perl_exception); /* return messages in string context */
4020 ST(0)=sv_2mortal(perl_exception);
4025 ###############################################################################
4033 ###############################################################################
4038 Image::Magick ref=NO_INIT
4050 expression[MaxTextExtent];
4078 PERL_UNUSED_VAR(ref);
4079 PERL_UNUSED_VAR(ix);
4080 exception=AcquireExceptionInfo();
4081 perl_exception=newSVpv("",0);
4085 if (sv_isobject(ST(0)) == 0)
4087 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4091 reference=SvRV(ST(0));
4092 hv=SvSTASH(reference);
4094 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4096 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4097 if (image == (Image *) NULL)
4099 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4103 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4107 channel=DefaultChannels;
4108 (void) CopyMagickString(expression,"u",MaxTextExtent);
4110 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4112 for (i=2; i < items; i+=2)
4114 attribute=(char *) SvPV(ST(i-1),na);
4120 if (LocaleCompare(attribute,"channel") == 0)
4125 option=ParseChannelOption(SvPV(ST(i),na));
4128 ThrowPerlException(exception,OptionError,
4129 "UnrecognizedType",SvPV(ST(i),na));
4132 channel=(ChannelType) option;
4135 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4142 if (LocaleCompare(attribute,"expression") == 0)
4144 (void) CopyMagickString(expression,SvPV(ST(i),na),
4148 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4154 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4160 channel_mask=SetPixelChannelMask(image,channel);
4161 image=FxImage(image,expression,exception);
4162 if (image != (Image *) NULL)
4163 (void) SetPixelChannelMask(image,channel_mask);
4164 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
4166 for ( ; image; image=image->next)
4168 AddImageToRegistry(sv,image);
4170 av_push(av,sv_bless(rv,hv));
4173 exception=DestroyExceptionInfo(exception);
4175 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4179 InheritPerlException(exception,perl_exception);
4180 exception=DestroyExceptionInfo(exception);
4181 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4182 SvPOK_on(perl_exception);
4183 ST(0)=sv_2mortal(perl_exception);
4188 ###############################################################################
4196 ###############################################################################
4201 Image::Magick ref=NO_INIT
4212 color[MaxTextExtent];
4237 PERL_UNUSED_VAR(ref);
4238 PERL_UNUSED_VAR(ix);
4239 exception=AcquireExceptionInfo();
4240 perl_exception=newSVpv("",0);
4241 if (sv_isobject(ST(0)) == 0)
4243 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4247 reference=SvRV(ST(0));
4248 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4249 if (image == (Image *) NULL && !info)
4252 for (i=1; i < items; i++)
4254 attribute=(char *) SvPV(ST(i),na);
4261 if (LocaleCompare(attribute,"adjoin") == 0)
4264 s=newSViv((ssize_t) info->image_info->adjoin);
4265 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4268 if (LocaleCompare(attribute,"antialias") == 0)
4271 s=newSViv((ssize_t) info->image_info->antialias);
4272 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4275 if (LocaleCompare(attribute,"area") == 0)
4277 s=newSViv(GetMagickResource(AreaResource));
4278 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4281 if (LocaleCompare(attribute,"attenuate") == 0)
4286 value=GetImageProperty(image,attribute,exception);
4287 if (value != (const char *) NULL)
4289 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4292 if (LocaleCompare(attribute,"authenticate") == 0)
4299 option=GetImageOption(info->image_info,attribute);
4300 if (option != (const char *) NULL)
4301 s=newSVpv(option,0);
4303 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4306 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4313 if (LocaleCompare(attribute,"background") == 0)
4315 if (image == (Image *) NULL)
4317 (void) FormatLocaleString(color,MaxTextExtent,
4318 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4319 image->background_color.green,image->background_color.blue,
4320 image->background_color.alpha);
4322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4325 if (LocaleCompare(attribute,"base-columns") == 0)
4327 if (image != (Image *) NULL)
4328 s=newSViv((ssize_t) image->magick_columns);
4329 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4332 if (LocaleCompare(attribute,"base-filename") == 0)
4334 if (image != (Image *) NULL)
4335 s=newSVpv(image->magick_filename,0);
4336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4339 if (LocaleCompare(attribute,"base-height") == 0)
4341 if (image != (Image *) NULL)
4342 s=newSViv((ssize_t) image->magick_rows);
4343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4346 if (LocaleCompare(attribute,"base-rows") == 0)
4348 if (image != (Image *) NULL)
4349 s=newSViv((ssize_t) image->magick_rows);
4350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4353 if (LocaleCompare(attribute,"base-width") == 0)
4355 if (image != (Image *) NULL)
4356 s=newSViv((ssize_t) image->magick_columns);
4357 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4360 if (LocaleCompare(attribute,"bias") == 0)
4362 if (image != (Image *) NULL)
4363 s=newSVnv(image->bias);
4364 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4367 if (LocaleCompare(attribute,"blue-primary") == 0)
4369 if (image == (Image *) NULL)
4371 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4372 image->chromaticity.blue_primary.x,
4373 image->chromaticity.blue_primary.y);
4375 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4378 if (LocaleCompare(attribute,"bordercolor") == 0)
4380 if (image == (Image *) NULL)
4382 (void) FormatLocaleString(color,MaxTextExtent,
4383 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4384 image->border_color.green,image->border_color.blue,
4385 image->border_color.alpha);
4387 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4390 if (LocaleCompare(attribute,"bounding-box") == 0)
4393 geometry[MaxTextExtent];
4398 if (image == (Image *) NULL)
4400 page=GetImageBoundingBox(image,&image->exception);
4401 (void) FormatLocaleString(geometry,MaxTextExtent,
4402 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4403 page.height,(double) page.x,(double) page.y);
4404 s=newSVpv(geometry,0);
4405 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4408 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4415 if (LocaleCompare(attribute,"class") == 0)
4417 if (image == (Image *) NULL)
4419 s=newSViv(image->storage_class);
4420 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4421 image->storage_class));
4423 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4426 if (LocaleCompare(attribute,"clip-mask") == 0)
4428 if (image != (Image *) NULL)
4434 if (image->mask == (Image *) NULL)
4435 ClipImage(image,exception);
4436 if (image->mask != (Image *) NULL)
4438 AddImageToRegistry(sv,image->mask);
4439 s=sv_bless(newRV(sv),SvSTASH(reference));
4442 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4445 if (LocaleCompare(attribute,"clip-path") == 0)
4447 if (image != (Image *) NULL)
4453 if (image->clip_mask == (Image *) NULL)
4454 ClipImage(image,exception);
4455 if (image->clip_mask != (Image *) NULL)
4457 AddImageToRegistry(sv,image->clip_mask);
4458 s=sv_bless(newRV(sv),SvSTASH(reference));
4461 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4464 if (LocaleCompare(attribute,"compression") == 0)
4466 j=info ? info->image_info->compression : image ?
4467 image->compression : UndefinedCompression;
4469 if (info->image_info->compression == UndefinedCompression)
4470 j=image->compression;
4472 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4475 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4478 if (LocaleCompare(attribute,"colorspace") == 0)
4480 j=image ? image->colorspace : RGBColorspace;
4482 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4485 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4488 if (LocaleCompare(attribute,"colors") == 0)
4490 if (image != (Image *) NULL)
4491 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4492 &image->exception));
4493 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4496 if (LocaleNCompare(attribute,"colormap",8) == 0)
4501 if (image == (Image *) NULL || !image->colormap)
4504 items=sscanf(attribute,"%*[^[][%ld",&j);
4506 if (j > (ssize_t) image->colors)
4508 (void) FormatLocaleString(color,MaxTextExtent,
4509 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4510 image->colormap[j].green,image->colormap[j].blue,
4511 image->colormap[j].alpha);
4513 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4516 if (LocaleCompare(attribute,"columns") == 0)
4518 if (image != (Image *) NULL)
4519 s=newSViv((ssize_t) image->columns);
4520 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4523 if (LocaleCompare(attribute,"comment") == 0)
4528 value=GetImageProperty(image,attribute,exception);
4529 if (value != (const char *) NULL)
4531 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4534 if (LocaleCompare(attribute,"copyright") == 0)
4536 s=newSVpv(GetMagickCopyright(),0);
4537 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4547 if (LocaleCompare(attribute,"density") == 0)
4550 geometry[MaxTextExtent];
4552 if (image == (Image *) NULL)
4554 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4555 image->x_resolution,image->y_resolution);
4556 s=newSVpv(geometry,0);
4557 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4560 if (LocaleCompare(attribute,"delay") == 0)
4562 if (image != (Image *) NULL)
4563 s=newSViv((ssize_t) image->delay);
4564 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4567 if (LocaleCompare(attribute,"depth") == 0)
4569 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4570 if (image != (Image *) NULL)
4571 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4572 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4575 if (LocaleCompare(attribute,"directory") == 0)
4577 if (image && image->directory)
4578 s=newSVpv(image->directory,0);
4579 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4582 if (LocaleCompare(attribute,"dispose") == 0)
4584 if (image == (Image *) NULL)
4587 s=newSViv(image->dispose);
4589 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4591 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4594 if (LocaleCompare(attribute,"disk") == 0)
4596 s=newSViv(GetMagickResource(DiskResource));
4597 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4600 if (LocaleCompare(attribute,"dither") == 0)
4603 s=newSViv((ssize_t) info->image_info->dither);
4604 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4607 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4609 if (info && info->image_info->server_name)
4610 s=newSVpv(info->image_info->server_name,0);
4611 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4614 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4621 if (LocaleCompare(attribute,"elapsed-time") == 0)
4623 if (image != (Image *) NULL)
4624 s=newSVnv(GetElapsedTime(&image->timer));
4625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4628 if (LocaleCompare(attribute,"endian") == 0)
4630 j=info ? info->image_info->endian : image ? image->endian :
4633 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4635 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4638 if (LocaleCompare(attribute,"error") == 0)
4640 if (image != (Image *) NULL)
4641 s=newSVnv(image->error.mean_error_per_pixel);
4642 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4645 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4652 if (LocaleCompare(attribute,"filesize") == 0)
4654 if (image != (Image *) NULL)
4655 s=newSViv((ssize_t) GetBlobSize(image));
4656 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4659 if (LocaleCompare(attribute,"filename") == 0)
4661 if (info && info->image_info->filename &&
4662 *info->image_info->filename)
4663 s=newSVpv(info->image_info->filename,0);
4664 if (image != (Image *) NULL)
4665 s=newSVpv(image->filename,0);
4666 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4669 if (LocaleCompare(attribute,"filter") == 0)
4671 s=image ? newSViv(image->filter) : newSViv(0);
4672 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4675 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4678 if (LocaleCompare(attribute,"font") == 0)
4680 if (info && info->image_info->font)
4681 s=newSVpv(info->image_info->font,0);
4682 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4685 if (LocaleCompare(attribute,"foreground") == 0)
4687 if (LocaleCompare(attribute,"format") == 0)
4692 magick_info=(const MagickInfo *) NULL;
4693 if (info && (*info->image_info->magick != '\0'))
4694 magick_info=GetMagickInfo(info->image_info->magick,exception);
4695 if (image != (Image *) NULL)
4696 magick_info=GetMagickInfo(image->magick,&image->exception);
4697 if ((magick_info != (const MagickInfo *) NULL) &&
4698 (*magick_info->description != '\0'))
4699 s=newSVpv((char *) magick_info->description,0);
4700 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4703 if (LocaleCompare(attribute,"fuzz") == 0)
4706 s=newSVnv(info->image_info->fuzz);
4707 if (image != (Image *) NULL)
4708 s=newSVnv(image->fuzz);
4709 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4712 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4719 if (LocaleCompare(attribute,"gamma") == 0)
4721 if (image != (Image *) NULL)
4722 s=newSVnv(image->gamma);
4723 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4726 if (LocaleCompare(attribute,"geometry") == 0)
4728 if (image && image->geometry)
4729 s=newSVpv(image->geometry,0);
4730 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4733 if (LocaleCompare(attribute,"gravity") == 0)
4735 s=image ? newSViv(image->gravity) : newSViv(0);
4736 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4739 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4742 if (LocaleCompare(attribute,"green-primary") == 0)
4744 if (image == (Image *) NULL)
4746 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4747 image->chromaticity.green_primary.x,
4748 image->chromaticity.green_primary.y);
4750 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4753 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4760 if (LocaleCompare(attribute,"height") == 0)
4762 if (image != (Image *) NULL)
4763 s=newSViv((ssize_t) image->rows);
4764 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4767 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4774 if (LocaleCompare(attribute,"icc") == 0)
4776 if (image != (Image *) NULL)
4781 profile=GetImageProfile(image,"icc");
4782 if (profile != (StringInfo *) NULL)
4783 s=newSVpv((const char *) GetStringInfoDatum(profile),
4784 GetStringInfoLength(profile));
4786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4789 if (LocaleCompare(attribute,"icm") == 0)
4791 if (image != (Image *) NULL)
4796 profile=GetImageProfile(image,"icm");
4797 if (profile != (const StringInfo *) NULL)
4798 s=newSVpv((const char *) GetStringInfoDatum(profile),
4799 GetStringInfoLength(profile));
4801 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4804 if (LocaleCompare(attribute,"id") == 0)
4806 if (image != (Image *) NULL)
4817 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4819 status=SetImageRegistry(ImageRegistryType,key,image,
4824 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4827 if (LocaleNCompare(attribute,"index",5) == 0)
4830 name[MaxTextExtent];
4839 register const Quantum
4845 if (image == (Image *) NULL)
4847 if (image->storage_class != PseudoClass)
4851 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4853 image_view=AcquireCacheView(image);
4854 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4855 if (p != (const Quantum *) NULL)
4857 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4858 GetPixelIndex(image,p));
4860 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4862 image_view=DestroyCacheView(image_view);
4865 if (LocaleCompare(attribute,"iptc") == 0)
4867 if (image != (Image *) NULL)
4872 profile=GetImageProfile(image,"iptc");
4873 if (profile != (const StringInfo *) NULL)
4874 s=newSVpv((const char *) GetStringInfoDatum(profile),
4875 GetStringInfoLength(profile));
4877 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4880 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4882 if (image != (Image *) NULL)
4883 s=newSViv((ssize_t) image->iterations);
4884 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4887 if (LocaleCompare(attribute,"interlace") == 0)
4889 j=info ? info->image_info->interlace : image ? image->interlace :
4892 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4895 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4898 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4905 if (LocaleCompare(attribute,"label") == 0)
4910 if (image == (Image *) NULL)
4912 value=GetImageProperty(image,"Label",exception);
4913 if (value != (const char *) NULL)
4915 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4918 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4920 if (image != (Image *) NULL)
4921 s=newSViv((ssize_t) image->iterations);
4922 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4925 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4932 if (LocaleCompare(attribute,"magick") == 0)
4934 if (info && *info->image_info->magick)
4935 s=newSVpv(info->image_info->magick,0);
4936 if (image != (Image *) NULL)
4937 s=newSVpv(image->magick,0);
4938 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4941 if (LocaleCompare(attribute,"map") == 0)
4943 s=newSViv(GetMagickResource(MapResource));
4944 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4947 if (LocaleCompare(attribute,"maximum-error") == 0)
4949 if (image != (Image *) NULL)
4950 s=newSVnv(image->error.normalized_maximum_error);
4951 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4954 if (LocaleCompare(attribute,"memory") == 0)
4956 s=newSViv(GetMagickResource(MemoryResource));
4957 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4960 if (LocaleCompare(attribute,"mean-error") == 0)
4962 if (image != (Image *) NULL)
4963 s=newSVnv(image->error.normalized_mean_error);
4964 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4967 if (LocaleCompare(attribute,"mime") == 0)
4969 if (info && *info->image_info->magick)
4970 s=newSVpv(MagickToMime(info->image_info->magick),0);
4971 if (image != (Image *) NULL)
4972 s=newSVpv(MagickToMime(image->magick),0);
4973 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4976 if (LocaleCompare(attribute,"mattecolor") == 0)
4978 if (image == (Image *) NULL)
4980 (void) FormatLocaleString(color,MaxTextExtent,
4981 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
4982 image->matte_color.green,image->matte_color.blue,
4983 image->matte_color.alpha);
4985 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4988 if (LocaleCompare(attribute,"matte") == 0)
4990 if (image != (Image *) NULL)
4991 s=newSViv((ssize_t) image->matte);
4992 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4995 if (LocaleCompare(attribute,"mime") == 0)
5001 if (info && *info->image_info->magick)
5002 magick=info->image_info->magick;
5003 if (image != (Image *) NULL)
5004 magick=image->magick;
5010 mime=MagickToMime(magick);
5012 mime=(char *) RelinquishMagickMemory(mime);
5014 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5017 if (LocaleCompare(attribute,"monochrome") == 0)
5019 if (image == (Image *) NULL)
5021 j=info ? info->image_info->monochrome :
5022 IsImageMonochrome(image,&image->exception);
5024 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5027 if (LocaleCompare(attribute,"montage") == 0)
5029 if (image && image->montage)
5030 s=newSVpv(image->montage,0);
5031 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5034 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5041 if (LocaleCompare(attribute,"orientation") == 0)
5043 j=info ? info->image_info->orientation : image ?
5044 image->orientation : UndefinedOrientation;
5046 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5049 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5052 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5059 if (LocaleCompare(attribute,"page") == 0)
5061 if (info && info->image_info->page)
5062 s=newSVpv(info->image_info->page,0);
5063 if (image != (Image *) NULL)
5066 geometry[MaxTextExtent];
5068 (void) FormatLocaleString(geometry,MaxTextExtent,
5069 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5070 (double) image->page.height,(double) image->page.x,(double)
5072 s=newSVpv(geometry,0);
5074 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5077 if (LocaleCompare(attribute,"page.x") == 0)
5079 if (image != (Image *) NULL)
5080 s=newSViv((ssize_t) image->page.x);
5081 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5084 if (LocaleCompare(attribute,"page.y") == 0)
5086 if (image != (Image *) NULL)
5087 s=newSViv((ssize_t) image->page.y);
5088 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5091 if (LocaleNCompare(attribute,"pixel",5) == 0)
5094 tuple[MaxTextExtent];
5103 register const Quantum
5106 if (image == (Image *) NULL)
5110 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5112 p=GetVirtualPixels(image,x,y,1,1,exception);
5113 if (image->colorspace != CMYKColorspace)
5114 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5115 QuantumFormat "," QuantumFormat "," QuantumFormat,
5116 GetPixelRed(image,p),GetPixelGreen(image,p),
5117 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5119 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5120 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5121 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5122 GetPixelBlue(image,p),GetPixelBlack(image,p),
5123 GetPixelAlpha(image,p));
5125 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5128 if (LocaleCompare(attribute,"pointsize") == 0)
5131 s=newSViv((ssize_t) info->image_info->pointsize);
5132 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5135 if (LocaleCompare(attribute,"preview") == 0)
5137 s=newSViv(info->image_info->preview_type);
5138 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5139 info->image_info->preview_type));
5141 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5144 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5151 if (LocaleCompare(attribute,"quality") == 0)
5154 s=newSViv((ssize_t) info->image_info->quality);
5155 if (image != (Image *) NULL)
5156 s=newSViv((ssize_t) image->quality);
5157 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5160 if (LocaleCompare(attribute,"quantum") == 0)
5163 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5164 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5167 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5174 if (LocaleCompare(attribute,"rendering-intent") == 0)
5176 s=newSViv(image->rendering_intent);
5177 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5178 image->rendering_intent));
5180 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5183 if (LocaleCompare(attribute,"red-primary") == 0)
5185 if (image == (Image *) NULL)
5187 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5188 image->chromaticity.red_primary.x,
5189 image->chromaticity.red_primary.y);
5191 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5194 if (LocaleCompare(attribute,"rows") == 0)
5196 if (image != (Image *) NULL)
5197 s=newSViv((ssize_t) image->rows);
5198 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5201 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5208 if (LocaleCompare(attribute,"sampling-factor") == 0)
5210 if (info && info->image_info->sampling_factor)
5211 s=newSVpv(info->image_info->sampling_factor,0);
5212 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5215 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5217 if (info && info->image_info->server_name)
5218 s=newSVpv(info->image_info->server_name,0);
5219 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5222 if (LocaleCompare(attribute,"size") == 0)
5224 if (info && info->image_info->size)
5225 s=newSVpv(info->image_info->size,0);
5226 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5229 if (LocaleCompare(attribute,"scene") == 0)
5231 if (image != (Image *) NULL)
5232 s=newSViv((ssize_t) image->scene);
5233 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5236 if (LocaleCompare(attribute,"scenes") == 0)
5238 if (image != (Image *) NULL)
5239 s=newSViv((ssize_t) info->image_info->number_scenes);
5240 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5243 if (LocaleCompare(attribute,"signature") == 0)
5248 if (image == (Image *) NULL)
5250 (void) SignatureImage(image,exception);
5251 value=GetImageProperty(image,"Signature",exception);
5252 if (value != (const char *) NULL)
5254 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5257 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5264 if (LocaleCompare(attribute,"taint") == 0)
5266 if (image != (Image *) NULL)
5267 s=newSViv((ssize_t) IsTaintImage(image));
5268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5271 if (LocaleCompare(attribute,"texture") == 0)
5273 if (info && info->image_info->texture)
5274 s=newSVpv(info->image_info->texture,0);
5275 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5278 if (LocaleCompare(attribute,"total-ink-density") == 0)
5280 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5281 if (image != (Image *) NULL)
5282 s=newSVnv(GetImageTotalInkDensity(image));
5283 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5286 if (LocaleCompare(attribute,"transparent-color") == 0)
5288 if (image == (Image *) NULL)
5290 (void) FormatLocaleString(color,MaxTextExtent,
5291 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5292 image->transparent_color.green,image->transparent_color.blue,
5293 image->transparent_color.alpha);
5295 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5298 if (LocaleCompare(attribute,"type") == 0)
5300 if (image == (Image *) NULL)
5302 j=(ssize_t) GetImageType(image,&image->exception);
5304 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5306 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5309 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5316 if (LocaleCompare(attribute,"units") == 0)
5318 j=info ? info->image_info->units : image ? image->units :
5319 UndefinedResolution;
5320 if (info && (info->image_info->units == UndefinedResolution))
5323 if (j == UndefinedResolution)
5324 s=newSVpv("undefined units",0);
5326 if (j == PixelsPerInchResolution)
5327 s=newSVpv("pixels / inch",0);
5329 s=newSVpv("pixels / centimeter",0);
5330 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5333 if (LocaleCompare(attribute,"user-time") == 0)
5335 if (image != (Image *) NULL)
5336 s=newSVnv(GetUserTime(&image->timer));
5337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5340 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5347 if (LocaleCompare(attribute,"verbose") == 0)
5350 s=newSViv((ssize_t) info->image_info->verbose);
5351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5354 if (LocaleCompare(attribute,"version") == 0)
5356 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5357 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5360 if (LocaleCompare(attribute,"view") == 0)
5362 if (info && info->image_info->view)
5363 s=newSVpv(info->image_info->view,0);
5364 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5367 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5369 if (image == (Image *) NULL)
5371 j=(ssize_t) GetImageVirtualPixelMethod(image);
5373 (void) sv_setpv(s,CommandOptionToMnemonic(
5374 MagickVirtualPixelOptions,j));
5376 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5379 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5386 if (LocaleCompare(attribute,"white-point") == 0)
5388 if (image == (Image *) NULL)
5390 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5391 image->chromaticity.white_point.x,
5392 image->chromaticity.white_point.y);
5394 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5397 if (LocaleCompare(attribute,"width") == 0)
5399 if (image != (Image *) NULL)
5400 s=newSViv((ssize_t) image->columns);
5401 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5404 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5411 if (LocaleCompare(attribute,"x-resolution") == 0)
5413 if (image != (Image *) NULL)
5414 s=newSVnv(image->x_resolution);
5415 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5425 if (LocaleCompare(attribute,"y-resolution") == 0)
5427 if (image != (Image *) NULL)
5428 s=newSVnv(image->y_resolution);
5429 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5432 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5439 if (image == (Image *) NULL)
5440 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5444 value=GetImageProperty(image,attribute,exception);
5445 if (value != (const char *) NULL)
5448 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5451 if (*attribute != '%')
5452 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5459 meta=InterpretImageProperties(info ? info->image_info :
5460 (ImageInfo *) NULL,image,attribute,exception);
5462 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5463 meta=(char *) RelinquishMagickMemory(meta);
5467 exception=DestroyExceptionInfo(exception);
5468 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5472 ###############################################################################
5476 # G e t A u t h e n t i c P i x e l s #
5480 ###############################################################################
5484 GetAuthenticPixels(ref,...)
5485 Image::Magick ref = NO_INIT
5487 getauthenticpixels = 1
5517 PERL_UNUSED_VAR(ref);
5518 PERL_UNUSED_VAR(ix);
5519 exception=AcquireExceptionInfo();
5520 perl_exception=newSVpv("",0);
5521 if (sv_isobject(ST(0)) == 0)
5523 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5527 reference=SvRV(ST(0));
5529 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5530 if (image == (Image *) NULL)
5532 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5539 region.width=image->columns;
5542 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5543 for (i=2; i < items; i+=2)
5545 attribute=(char *) SvPV(ST(i-1),na);
5551 if (LocaleCompare(attribute,"geometry") == 0)
5553 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5556 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5563 if (LocaleCompare(attribute,"height") == 0)
5565 region.height=SvIV(ST(i));
5568 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5575 if (LocaleCompare(attribute,"x") == 0)
5577 region.x=SvIV(ST(i));
5580 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5587 if (LocaleCompare(attribute,"y") == 0)
5589 region.y=SvIV(ST(i));
5592 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5599 if (LocaleCompare(attribute,"width") == 0)
5601 region.width=SvIV(ST(i));
5604 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5610 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5611 region.height,exception);
5612 if (blob != (void *) NULL)
5616 InheritPerlException(exception,perl_exception);
5617 exception=DestroyExceptionInfo(exception);
5618 SvREFCNT_dec(perl_exception); /* throw away all errors */
5627 ###############################################################################
5631 # G e t V i r t u a l P i x e l s #
5635 ###############################################################################
5639 GetVirtualPixels(ref,...)
5640 Image::Magick ref = NO_INIT
5642 getvirtualpixels = 1
5643 AcquireImagePixels = 2
5644 acquireimagepixels = 3
5672 PERL_UNUSED_VAR(ref);
5673 PERL_UNUSED_VAR(ix);
5674 exception=AcquireExceptionInfo();
5675 perl_exception=newSVpv("",0);
5676 if (sv_isobject(ST(0)) == 0)
5678 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5682 reference=SvRV(ST(0));
5684 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5685 if (image == (Image *) NULL)
5687 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5694 region.width=image->columns;
5697 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5698 for (i=2; i < items; i+=2)
5700 attribute=(char *) SvPV(ST(i-1),na);
5706 if (LocaleCompare(attribute,"geometry") == 0)
5708 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5711 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5718 if (LocaleCompare(attribute,"height") == 0)
5720 region.height=SvIV(ST(i));
5723 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5730 if (LocaleCompare(attribute,"x") == 0)
5732 region.x=SvIV(ST(i));
5735 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5742 if (LocaleCompare(attribute,"y") == 0)
5744 region.y=SvIV(ST(i));
5747 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5754 if (LocaleCompare(attribute,"width") == 0)
5756 region.width=SvIV(ST(i));
5759 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5765 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5766 region.height,exception);
5767 if (blob != (void *) NULL)
5771 InheritPerlException(exception,perl_exception);
5772 exception=DestroyExceptionInfo(exception);
5773 SvREFCNT_dec(perl_exception); /* throw away all errors */
5776 RETVAL = (void *) blob;
5782 ###############################################################################
5786 # G e t A u t h e n t i c M e t a c o n t e n t #
5790 ###############################################################################
5794 GetAuthenticMetacontent(ref,...)
5795 Image::Magick ref = NO_INIT
5797 getauthenticmetacontent = 1
5818 PERL_UNUSED_VAR(ref);
5819 PERL_UNUSED_VAR(ix);
5820 exception=AcquireExceptionInfo();
5821 perl_exception=newSVpv("",0);
5822 if (sv_isobject(ST(0)) == 0)
5824 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5828 reference=SvRV(ST(0));
5830 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5831 if (image == (Image *) NULL)
5833 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5838 blob=(void *) GetAuthenticMetacontent(image);
5839 if (blob != (void *) NULL)
5843 InheritPerlException(exception,perl_exception);
5844 exception=DestroyExceptionInfo(exception);
5845 SvREFCNT_dec(perl_exception); /* throw away all errors */
5854 ###############################################################################
5858 # G e t V i r t u a l M e t a c o n t e n t #
5862 ###############################################################################
5866 GetVirtualMetacontent(ref,...)
5867 Image::Magick ref = NO_INIT
5869 getvirtualmetacontent = 1
5888 PERL_UNUSED_VAR(ref);
5889 PERL_UNUSED_VAR(ix);
5890 exception=AcquireExceptionInfo();
5891 perl_exception=newSVpv("",0);
5892 if (sv_isobject(ST(0)) == 0)
5894 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5898 reference=SvRV(ST(0));
5900 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5901 if (image == (Image *) NULL)
5903 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5908 blob=(void *) GetVirtualMetacontent(image);
5909 if (blob != (void *) NULL)
5913 InheritPerlException(exception,perl_exception);
5914 exception=DestroyExceptionInfo(exception);
5915 SvREFCNT_dec(perl_exception); /* throw away all errors */
5924 ###############################################################################
5928 # H i s t o g r a m #
5932 ###############################################################################
5937 Image::Magick ref=NO_INIT
5948 message[MaxTextExtent];
5975 PERL_UNUSED_VAR(ref);
5976 PERL_UNUSED_VAR(ix);
5977 exception=AcquireExceptionInfo();
5978 perl_exception=newSVpv("",0);
5980 if (sv_isobject(ST(0)) == 0)
5982 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5986 reference=SvRV(ST(0));
5989 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5990 if (image == (Image *) NULL)
5992 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5996 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5998 for ( ; image; image=image->next)
6000 histogram=GetImageHistogram(image,&number_colors,&image->exception);
6001 if (histogram == (PixelInfo *) NULL)
6003 count+=(ssize_t) number_colors;
6005 for (i=0; i < (ssize_t) number_colors; i++)
6007 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6009 PUSHs(sv_2mortal(newSVpv(message,0)));
6010 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6011 histogram[i].green);
6012 PUSHs(sv_2mortal(newSVpv(message,0)));
6013 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6015 PUSHs(sv_2mortal(newSVpv(message,0)));
6016 if (image->colorspace == CMYKColorspace)
6018 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6019 histogram[i].black);
6020 PUSHs(sv_2mortal(newSVpv(message,0)));
6022 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6023 histogram[i].alpha);
6024 PUSHs(sv_2mortal(newSVpv(message,0)));
6025 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6026 histogram[i].count);
6027 PUSHs(sv_2mortal(newSVpv(message,0)));
6029 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6033 InheritPerlException(exception,perl_exception);
6034 exception=DestroyExceptionInfo(exception);
6035 SvREFCNT_dec(perl_exception);
6039 ###############################################################################
6047 ###############################################################################
6052 Image::Magick ref=NO_INIT
6076 register const Quantum
6090 *reference; /* reference is the SV* of ref=SvIV(reference) */
6092 PERL_UNUSED_VAR(ref);
6093 PERL_UNUSED_VAR(ix);
6094 exception=AcquireExceptionInfo();
6095 perl_exception=newSVpv("",0);
6096 reference=SvRV(ST(0));
6097 av=(AV *) reference;
6098 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6100 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6101 if (image == (Image *) NULL)
6103 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6107 normalize=MagickTrue;
6110 region.width=image->columns;
6113 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6114 for (i=2; i < items; i+=2)
6116 attribute=(char *) SvPV(ST(i-1),na);
6122 if (LocaleCompare(attribute,"channel") == 0)
6127 option=ParseChannelOption(SvPV(ST(i),na));
6130 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6134 SetPixelChannelMap(image,(ChannelType) option);
6137 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6144 if (LocaleCompare(attribute,"geometry") == 0)
6146 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6149 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6156 if (LocaleCompare(attribute,"normalize") == 0)
6158 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6162 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6166 normalize=option != 0 ? MagickTrue : MagickFalse;
6169 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6176 if (LocaleCompare(attribute,"x") == 0)
6178 region.x=SvIV(ST(i));
6181 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6188 if (LocaleCompare(attribute,"y") == 0)
6190 region.y=SvIV(ST(i));
6193 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6199 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6205 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6206 if (p == (const Quantum *) NULL)
6214 if (normalize != MagickFalse)
6215 scale=1.0/QuantumRange;
6216 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6217 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6218 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6219 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6220 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6221 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6222 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6223 (image->colorspace == CMYKColorspace))
6224 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6225 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6226 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6230 InheritPerlException(exception,perl_exception);
6231 exception=DestroyExceptionInfo(exception);
6232 SvREFCNT_dec(perl_exception);
6236 ###############################################################################
6240 # G e t P i x e l s #
6244 ###############################################################################
6249 Image::Magick ref=NO_INIT
6288 *reference; /* reference is the SV* of ref=SvIV(reference) */
6290 PERL_UNUSED_VAR(ref);
6291 PERL_UNUSED_VAR(ix);
6292 exception=AcquireExceptionInfo();
6293 perl_exception=newSVpv("",0);
6294 reference=SvRV(ST(0));
6295 av=(AV *) reference;
6296 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6298 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6299 if (image == (Image *) NULL)
6301 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6306 if (image->matte != MagickFalse)
6308 if (image->colorspace == CMYKColorspace)
6311 if (image->matte != MagickFalse)
6314 normalize=MagickFalse;
6317 region.width=image->columns;
6320 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6321 for (i=2; i < items; i+=2)
6323 attribute=(char *) SvPV(ST(i-1),na);
6329 if (LocaleCompare(attribute,"geometry") == 0)
6331 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6334 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6341 if (LocaleCompare(attribute,"height") == 0)
6343 region.height=SvIV(ST(i));
6346 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6353 if (LocaleCompare(attribute,"map") == 0)
6358 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6365 if (LocaleCompare(attribute,"normalize") == 0)
6367 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6371 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6375 normalize=option != 0 ? MagickTrue : MagickFalse;
6378 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6385 if (LocaleCompare(attribute,"width") == 0)
6387 region.width=SvIV(ST(i));
6390 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6397 if (LocaleCompare(attribute,"x") == 0)
6399 region.x=SvIV(ST(i));
6402 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6409 if (LocaleCompare(attribute,"y") == 0)
6411 region.y=SvIV(ST(i));
6414 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6420 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6426 if (normalize != MagickFalse)
6431 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6432 region.height*sizeof(*pixels));
6433 if (pixels == (float *) NULL)
6435 ThrowPerlException(exception,ResourceLimitError,
6436 "MemoryAllocationFailed",PackageName);
6439 status=ExportImagePixels(image,region.x,region.y,region.width,
6440 region.height,map,FloatPixel,pixels,exception);
6441 if (status == MagickFalse)
6445 EXTEND(sp,strlen(map)*region.width*region.height);
6446 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6447 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6449 pixels=(float *) RelinquishMagickMemory(pixels);
6456 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6457 region.height*sizeof(*pixels));
6458 if (pixels == (Quantum *) NULL)
6460 ThrowPerlException(exception,ResourceLimitError,
6461 "MemoryAllocationFailed",PackageName);
6464 status=ExportImagePixels(image,region.x,region.y,region.width,
6465 region.height,map,QuantumPixel,pixels,exception);
6466 if (status == MagickFalse)
6470 EXTEND(sp,strlen(map)*region.width*region.height);
6471 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6472 PUSHs(sv_2mortal(newSViv(pixels[i])));
6474 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6478 InheritPerlException(exception,perl_exception);
6479 exception=DestroyExceptionInfo(exception);
6480 SvREFCNT_dec(perl_exception);
6484 ###############################################################################
6488 # I m a g e T o B l o b #
6492 ###############################################################################
6496 ImageToBlob(ref,...)
6497 Image::Magick ref=NO_INIT
6506 filename[MaxTextExtent];
6535 PERL_UNUSED_VAR(ref);
6536 PERL_UNUSED_VAR(ix);
6537 exception=AcquireExceptionInfo();
6538 perl_exception=newSVpv("",0);
6539 package_info=(struct PackageInfo *) NULL;
6540 if (sv_isobject(ST(0)) == 0)
6542 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6546 reference=SvRV(ST(0));
6547 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6548 if (image == (Image *) NULL)
6550 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6554 package_info=ClonePackageInfo(info,exception);
6555 for (i=2; i < items; i+=2)
6556 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6557 (void) CopyMagickString(filename,package_info->image_info->filename,
6560 for (next=image; next; next=next->next)
6562 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6563 next->scene=scene++;
6565 SetImageInfo(package_info->image_info,(unsigned int)
6566 GetImageListLength(image),&image->exception);
6567 EXTEND(sp,(ssize_t) GetImageListLength(image));
6568 for ( ; image; image=image->next)
6571 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6572 if (blob != (char *) NULL)
6574 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6575 blob=(unsigned char *) RelinquishMagickMemory(blob);
6577 if (package_info->image_info->adjoin)
6582 if (package_info != (struct PackageInfo *) NULL)
6583 DestroyPackageInfo(package_info);
6584 InheritPerlException(exception,perl_exception);
6585 exception=DestroyExceptionInfo(exception);
6586 SvREFCNT_dec(perl_exception); /* throw away all errors */
6590 ###############################################################################
6598 ###############################################################################
6603 Image::Magick ref=NO_INIT
6607 OptimizeImageLayers = 3
6609 optimizeimagelayers = 5
6651 PERL_UNUSED_VAR(ref);
6652 PERL_UNUSED_VAR(ix);
6653 exception=AcquireExceptionInfo();
6654 perl_exception=newSVpv("",0);
6656 if (sv_isobject(ST(0)) == 0)
6658 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6662 reference=SvRV(ST(0));
6663 hv=SvSTASH(reference);
6665 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6667 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6668 if (image == (Image *) NULL)
6670 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6674 compose=image->compose;
6675 method=OptimizeLayer;
6676 for (i=2; i < items; i+=2)
6678 attribute=(char *) SvPV(ST(i-1),na);
6684 if (LocaleCompare(attribute,"compose") == 0)
6686 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6687 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6690 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6694 compose=(CompositeOperator) sp;
6697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6704 if (LocaleCompare(attribute,"method") == 0)
6706 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6710 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6714 method=(ImageLayerMethod) option;
6717 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6723 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6729 layers=(Image *) NULL;
6732 case CompareAnyLayer:
6733 case CompareClearLayer:
6734 case CompareOverlayLayer:
6737 layers=CompareImagesLayers(image,method,exception);
6744 layers=MergeImageLayers(image,method,exception);
6749 layers=DisposeImages(image,exception);
6752 case OptimizeImageLayer:
6754 layers=OptimizeImageLayers(image,exception);
6757 case OptimizePlusLayer:
6759 layers=OptimizePlusImageLayers(image,exception);
6762 case OptimizeTransLayer:
6764 OptimizeImageTransparency(image,exception);
6765 InheritException(&(image->exception),exception);
6768 case RemoveDupsLayer:
6770 RemoveDuplicateLayers(&image,exception);
6771 InheritException(&(image->exception),exception);
6774 case RemoveZeroLayer:
6776 RemoveZeroDelayLayers(&image,exception);
6777 InheritException(&(image->exception),exception);
6786 General Purpose, GIF Animation Optimizer.
6788 layers=CoalesceImages(image,exception);
6789 if (layers == (Image *) NULL)
6791 InheritException(&(layers->exception),exception);
6793 layers=OptimizeImageLayers(image,exception);
6794 if (layers == (Image *) NULL)
6796 InheritException(&(layers->exception),exception);
6797 image=DestroyImageList(image);
6799 layers=(Image *) NULL;
6800 OptimizeImageTransparency(image,exception);
6801 InheritException(&(image->exception),exception);
6802 quantize_info=AcquireQuantizeInfo(info->image_info);
6803 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6804 quantize_info=DestroyQuantizeInfo(quantize_info);
6807 case CompositeLayer:
6816 Split image sequence at the first 'NULL:' image.
6819 while (source != (Image *) NULL)
6821 source=GetNextImageInList(source);
6822 if ((source != (Image *) NULL) &&
6823 (LocaleCompare(source->magick,"NULL") == 0))
6826 if (source != (Image *) NULL)
6828 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6829 (GetNextImageInList(source) == (Image *) NULL))
6830 source=(Image *) NULL;
6834 Separate the two lists, junk the null: image.
6836 source=SplitImageList(source->previous);
6837 DeleteImageFromList(&source);
6840 if (source == (Image *) NULL)
6842 (void) ThrowMagickException(exception,GetMagickModule(),
6843 OptionError,"MissingNullSeparator","layers Composite");
6847 Adjust offset with gravity and virtual canvas.
6849 SetGeometry(image,&geometry);
6850 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6851 geometry.width=source->page.width != 0 ? source->page.width :
6853 geometry.height=source->page.height != 0 ? source->page.height :
6855 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6856 image->columns,image->page.height != 0 ? image->page.height :
6857 image->rows,image->gravity,&geometry);
6858 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6859 source=DestroyImageList(source);
6860 InheritException(&(image->exception),exception);
6864 if (layers != (Image *) NULL)
6866 InheritException(&(layers->exception),exception);
6869 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6871 for ( ; image; image=image->next)
6873 AddImageToRegistry(sv,image);
6875 av_push(av,sv_bless(rv,hv));
6878 exception=DestroyExceptionInfo(exception);
6880 SvREFCNT_dec(perl_exception);
6884 InheritPerlException(exception,perl_exception);
6885 exception=DestroyExceptionInfo(exception);
6886 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6887 SvPOK_on(perl_exception);
6888 ST(0)=sv_2mortal(perl_exception);
6893 ###############################################################################
6897 # M a g i c k T o M i m e #
6901 ###############################################################################
6905 MagickToMime(ref,name)
6906 Image::Magick ref=NO_INIT
6915 PERL_UNUSED_VAR(ref);
6916 PERL_UNUSED_VAR(ix);
6917 mime=MagickToMime(name);
6918 RETVAL=newSVpv(mime,0);
6919 mime=(char *) RelinquishMagickMemory(mime);
6925 ###############################################################################
6933 ###############################################################################
6938 Image::Magick ref=NO_INIT
6975 MedianConvolveImage = 36
6981 ReduceNoiseImage = 42
7007 ColorFloodfillImage= 68
7013 CycleColormapImage = 74
7023 MatteFloodfillImage= 84
7031 NumberColorsImage = 92
7041 SignatureImage = 102
7051 TransparentImage = 112
7053 ThresholdImage = 114
7067 DeconstructImage = 130
7069 GaussianBlurImage = 132
7075 UnsharpMaskImage = 138
7077 MotionBlurImage = 140
7079 OrderedDitherImage = 142
7086 AffineTransform = 149
7087 AffineTransformImage = 150
7089 DifferenceImage = 152
7090 AdaptiveThreshold = 153
7091 AdaptiveThresholdImage = 154
7096 BlackThreshold = 159
7097 BlackThresholdImage= 160
7098 WhiteThreshold = 161
7099 WhiteThresholdImage= 162
7101 RadialBlurImage = 164
7103 ThumbnailImage = 166
7113 PosterizeImage = 176
7119 SepiaToneImage = 182
7120 SigmoidalContrast = 183
7121 SigmoidalContrastImage = 184
7126 ContrastStretch = 189
7127 ContrastStretchImage = 190
7132 AdaptiveSharpen = 195
7133 AdaptiveSharpenImage = 196
7135 TransposeImage = 198
7137 TransverseImage = 200
7139 AutoOrientImage = 202
7141 AdaptiveBlurImage = 204
7145 UniqueColorsImage = 208
7146 AdaptiveResize = 209
7147 AdaptiveResizeImage= 210
7151 LinearStretchImage = 214
7158 FloodfillPaint = 221
7159 FloodfillPaintImage= 222
7165 LiquidRescaleImage = 228
7175 SparseColorImage = 238
7179 SelectiveBlurImage = 242
7183 BlueShiftImage = 246
7184 ForwardFourierTransform = 247
7185 ForwardFourierTransformImage = 248
7186 InverseFourierTransform = 249
7187 InverseFourierTransformImage = 250
7188 ColorDecisionList = 251
7189 ColorDecisionListImage = 252
7191 AutoGammaImage = 254
7193 AutoLevelImage = 256
7195 LevelImageColors = 258
7198 BrightnessContrast = 263
7199 BrightnessContrastImage = 264
7201 MorphologyImage = 266
7203 ColorMatrixImage = 268
7209 StatisticImage = 274
7218 attribute_flag[MaxArguments],
7219 message[MaxTextExtent];
7280 argument_list[MaxArguments];
7282 PERL_UNUSED_VAR(ref);
7283 PERL_UNUSED_VAR(ix);
7284 exception=AcquireExceptionInfo();
7285 perl_exception=newSVpv("",0);
7286 reference_vector=NULL;
7290 if (sv_isobject(ST(0)) == 0)
7292 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7296 reference=SvRV(ST(0));
7297 region_info.width=0;
7298 region_info.height=0;
7301 region_image=(Image *) NULL;
7302 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7303 if (ix && (ix != 666))
7306 Called as Method(...)
7309 rp=(&Methods[ix-1]);
7315 Called as Mogrify("Method",...)
7317 attribute=(char *) SvPV(ST(1),na);
7320 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7321 attribute=(char *) SvPV(ST(2),na);
7324 for (rp=Methods; ; rp++)
7326 if (rp >= EndOf(Methods))
7328 ThrowPerlException(exception,OptionError,
7329 "UnrecognizedPerlMagickMethod",attribute);
7332 if (strEQcase(attribute,rp->name))
7338 if (image == (Image *) NULL)
7340 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7343 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7344 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7345 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7362 pp=(Arguments *) NULL;
7370 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7372 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7374 if (strEQcase(attribute,qq->method) > ssize_test)
7377 ssize_test=strEQcase(attribute,qq->method);
7380 if (pp == (Arguments *) NULL)
7382 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7384 goto continue_outer_loop;
7386 al=(&argument_list[pp-rp->arguments]);
7389 case ArrayReference:
7391 if (SvTYPE(sv) != SVt_RV)
7393 (void) FormatLocaleString(message,MaxTextExtent,
7394 "invalid %.60s value",pp->method);
7395 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7396 goto continue_outer_loop;
7398 al->array_reference=SvRV(sv);
7403 al->real_reference=SvNV(sv);
7408 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7411 case ImageReference:
7413 if (!sv_isobject(sv) ||
7414 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7415 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7417 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7423 case IntegerReference:
7425 al->integer_reference=SvIV(sv);
7428 case StringReference:
7430 al->string_reference=(char *) SvPV(sv,al->length);
7431 if (sv_isobject(sv))
7432 al->image_reference=SetupList(aTHX_ SvRV(sv),
7433 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7439 Is a string; look up name.
7441 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7443 al->string_reference=(char *) SvPV(sv,al->length);
7444 al->integer_reference=(-1);
7447 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7448 MagickFalse,SvPV(sv,na));
7449 if (pp->type == MagickChannelOptions)
7450 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7451 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7453 (void) FormatLocaleString(message,MaxTextExtent,
7454 "invalid %.60s value",pp->method);
7455 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7456 goto continue_outer_loop;
7461 attribute_flag[pp-rp->arguments]++;
7462 continue_outer_loop: ;
7464 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7465 pv=reference_vector;
7466 SetGeometryInfo(&geometry_info);
7467 channel=DefaultChannels;
7468 for (next=image; next; next=next->next)
7471 SetGeometry(image,&geometry);
7472 if ((region_info.width*region_info.height) != 0)
7475 image=CropImage(image,®ion_info,exception);
7481 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7482 ThrowPerlException(exception,OptionError,
7483 "UnrecognizedPerlMagickMethod",message);
7486 case 1: /* Comment */
7488 if (attribute_flag[0] == 0)
7489 argument_list[0].string_reference=(char *) NULL;
7490 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7491 info ? info->image_info : (ImageInfo *) NULL,image,
7492 argument_list[0].string_reference,exception),exception);
7497 if (attribute_flag[0] == 0)
7498 argument_list[0].string_reference=(char *) NULL;
7499 (void) SetImageProperty(image,"label",InterpretImageProperties(
7500 info ? info->image_info : (ImageInfo *) NULL,image,
7501 argument_list[0].string_reference,exception),exception);
7504 case 3: /* AddNoise */
7509 if (attribute_flag[0] == 0)
7510 argument_list[0].integer_reference=UniformNoise;
7512 if (attribute_flag[1] != 0)
7513 attenuate=argument_list[1].real_reference;
7514 if (attribute_flag[2] != 0)
7515 channel=(ChannelType) argument_list[2].integer_reference;
7516 channel_mask=SetPixelChannelMask(image,channel);
7517 image=AddNoiseImage(image,(NoiseType)
7518 argument_list[0].integer_reference,attenuate,exception);
7519 if (image != (Image *) NULL)
7520 (void) SetPixelChannelMask(image,channel_mask);
7523 case 4: /* Colorize */
7529 virtual_pixel[MaxPixelChannels];
7531 GetPixelInfo(image,&target);
7532 (void) GetOneVirtualPixel(image,0,0,virtual_pixel,exception);
7533 target.red=virtual_pixel[RedPixelChannel];
7534 target.green=virtual_pixel[GreenPixelChannel];
7535 target.blue=virtual_pixel[BluePixelChannel];
7536 target.alpha=virtual_pixel[AlphaPixelChannel];
7537 if (attribute_flag[0] != 0)
7538 (void) QueryColorCompliance(argument_list[0].string_reference,
7539 AllCompliance,&target,exception);
7540 if (attribute_flag[1] == 0)
7541 argument_list[1].string_reference="100%";
7542 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7546 case 5: /* Border */
7553 if (attribute_flag[0] != 0)
7555 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7556 &geometry,exception);
7557 if ((flags & HeightValue) == 0)
7558 geometry.height=geometry.width;
7560 if (attribute_flag[1] != 0)
7561 geometry.width=argument_list[1].integer_reference;
7562 if (attribute_flag[2] != 0)
7563 geometry.height=argument_list[2].integer_reference;
7564 if (attribute_flag[3] != 0)
7565 QueryColorCompliance(argument_list[3].string_reference,
7566 AllCompliance,&image->border_color,exception);
7567 if (attribute_flag[4] != 0)
7568 QueryColorCompliance(argument_list[4].string_reference,
7569 AllCompliance,&image->border_color,exception);
7570 if (attribute_flag[5] != 0)
7571 QueryColorCompliance(argument_list[5].string_reference,
7572 AllCompliance,&image->border_color,exception);
7573 compose=image->compose;
7574 if (attribute_flag[6] != 0)
7575 compose=(CompositeOperator) argument_list[6].integer_reference;
7576 image=BorderImage(image,&geometry,compose,exception);
7581 if (attribute_flag[0] != 0)
7583 flags=ParseGeometry(argument_list[0].string_reference,
7585 if ((flags & SigmaValue) == 0)
7586 geometry_info.sigma=1.0;
7588 if (attribute_flag[1] != 0)
7589 geometry_info.rho=argument_list[1].real_reference;
7590 if (attribute_flag[2] != 0)
7591 geometry_info.sigma=argument_list[2].real_reference;
7592 if (attribute_flag[3] != 0)
7593 geometry_info.xi=argument_list[3].real_reference;
7594 if (attribute_flag[4] != 0)
7595 channel=(ChannelType) argument_list[4].integer_reference;
7596 channel_mask=SetPixelChannelMask(image,channel);
7597 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7598 geometry_info.xi,exception);
7599 if (image != (Image *) NULL)
7600 (void) SetPixelChannelMask(image,channel_mask);
7605 if (attribute_flag[0] != 0)
7606 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7607 &geometry,exception);
7608 if (attribute_flag[1] != 0)
7609 geometry.width=argument_list[1].integer_reference;
7610 if (attribute_flag[2] != 0)
7611 geometry.height=argument_list[2].integer_reference;
7612 if (attribute_flag[3] != 0)
7613 geometry.x=argument_list[3].integer_reference;
7614 if (attribute_flag[4] != 0)
7615 geometry.y=argument_list[4].integer_reference;
7616 image=ChopImage(image,&geometry,exception);
7621 if (attribute_flag[6] != 0)
7622 image->gravity=(GravityType) argument_list[6].integer_reference;
7623 if (attribute_flag[0] != 0)
7624 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7625 &geometry,exception);
7626 if (attribute_flag[1] != 0)
7627 geometry.width=argument_list[1].integer_reference;
7628 if (attribute_flag[2] != 0)
7629 geometry.height=argument_list[2].integer_reference;
7630 if (attribute_flag[3] != 0)
7631 geometry.x=argument_list[3].integer_reference;
7632 if (attribute_flag[4] != 0)
7633 geometry.y=argument_list[4].integer_reference;
7634 if (attribute_flag[5] != 0)
7636 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7637 image=CropImage(image,&geometry,exception);
7640 case 9: /* Despeckle */
7642 image=DespeckleImage(image,exception);
7647 if (attribute_flag[0] != 0)
7648 geometry_info.rho=argument_list[0].real_reference;
7649 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7653 case 11: /* Emboss */
7655 if (attribute_flag[0] != 0)
7657 flags=ParseGeometry(argument_list[0].string_reference,
7659 if ((flags & SigmaValue) == 0)
7660 geometry_info.sigma=1.0;
7662 if (attribute_flag[1] != 0)
7663 geometry_info.rho=argument_list[1].real_reference;
7664 if (attribute_flag[2] != 0)
7665 geometry_info.sigma=argument_list[2].real_reference;
7666 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7670 case 12: /* Enhance */
7672 image=EnhanceImage(image,exception);
7677 image=FlipImage(image,exception);
7682 image=FlopImage(image,exception);
7685 case 15: /* Frame */
7693 if (attribute_flag[0] != 0)
7695 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7696 &geometry,exception);
7697 if ((flags & HeightValue) == 0)
7698 geometry.height=geometry.width;
7699 frame_info.width=geometry.width;
7700 frame_info.height=geometry.height;
7701 frame_info.outer_bevel=geometry.x;
7702 frame_info.inner_bevel=geometry.y;
7704 if (attribute_flag[1] != 0)
7705 frame_info.width=argument_list[1].integer_reference;
7706 if (attribute_flag[2] != 0)
7707 frame_info.height=argument_list[2].integer_reference;
7708 if (attribute_flag[3] != 0)
7709 frame_info.inner_bevel=argument_list[3].integer_reference;
7710 if (attribute_flag[4] != 0)
7711 frame_info.outer_bevel=argument_list[4].integer_reference;
7712 if (attribute_flag[5] != 0)
7713 QueryColorCompliance(argument_list[5].string_reference,
7714 AllCompliance,&fill_color,exception);
7715 if (attribute_flag[6] != 0)
7716 QueryColorCompliance(argument_list[6].string_reference,
7717 AllCompliance,&fill_color,exception);
7718 frame_info.x=(ssize_t) frame_info.width;
7719 frame_info.y=(ssize_t) frame_info.height;
7720 frame_info.width=image->columns+2*frame_info.x;
7721 frame_info.height=image->rows+2*frame_info.y;
7722 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7723 image->matte_color=fill_color;
7724 compose=image->compose;
7725 if (attribute_flag[7] != 0)
7726 compose=(CompositeOperator) argument_list[7].integer_reference;
7727 image=FrameImage(image,&frame_info,compose,exception);
7730 case 16: /* Implode */
7732 PixelInterpolateMethod
7735 if (attribute_flag[0] == 0)
7736 argument_list[0].real_reference=0.5;
7737 method=UndefinedInterpolatePixel;
7738 if (attribute_flag[1] != 0)
7739 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7740 image=ImplodeImage(image,argument_list[0].real_reference,
7744 case 17: /* Magnify */
7746 image=MagnifyImage(image,exception);
7749 case 18: /* MedianFilter */
7751 if (attribute_flag[0] != 0)
7753 flags=ParseGeometry(argument_list[0].string_reference,
7755 if ((flags & SigmaValue) == 0)
7756 geometry_info.sigma=geometry_info.rho;
7758 if (attribute_flag[1] != 0)
7759 geometry_info.rho=argument_list[1].real_reference;
7760 if (attribute_flag[2] != 0)
7761 geometry_info.sigma=argument_list[2].real_reference;
7762 if (attribute_flag[3] != 0)
7763 channel=(ChannelType) argument_list[3].integer_reference;
7764 channel_mask=SetPixelChannelMask(image,channel);
7765 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7766 (size_t) geometry_info.sigma,exception);
7767 if (image != (Image *) NULL)
7768 (void) SetPixelChannelMask(image,channel_mask);
7771 case 19: /* Minify */
7773 image=MinifyImage(image,exception);
7776 case 20: /* OilPaint */
7778 if (attribute_flag[0] == 0)
7779 argument_list[0].real_reference=0.0;
7780 if (attribute_flag[1] == 0)
7781 argument_list[1].real_reference=1.0;
7782 image=OilPaintImage(image,argument_list[0].real_reference,
7783 argument_list[1].real_reference,exception);
7786 case 21: /* ReduceNoise */
7788 if (attribute_flag[0] != 0)
7790 flags=ParseGeometry(argument_list[0].string_reference,
7792 if ((flags & SigmaValue) == 0)
7793 geometry_info.sigma=1.0;
7795 if (attribute_flag[1] != 0)
7796 geometry_info.rho=argument_list[1].real_reference;
7797 if (attribute_flag[2] != 0)
7798 geometry_info.sigma=argument_list[2].real_reference;
7799 if (attribute_flag[3] != 0)
7800 channel=(ChannelType) argument_list[3].integer_reference;
7801 channel_mask=SetPixelChannelMask(image,channel);
7802 image=StatisticImage(image,NonpeakStatistic,(size_t)
7803 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7804 if (image != (Image *) NULL)
7805 (void) SetPixelChannelMask(image,channel_mask);
7810 if (attribute_flag[0] != 0)
7811 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7812 &geometry,exception);
7813 if (attribute_flag[1] != 0)
7814 geometry.x=argument_list[1].integer_reference;
7815 if (attribute_flag[2] != 0)
7816 geometry.y=argument_list[2].integer_reference;
7817 image=RollImage(image,geometry.x,geometry.y,exception);
7820 case 23: /* Rotate */
7822 if (attribute_flag[0] == 0)
7823 argument_list[0].real_reference=90.0;
7824 if (attribute_flag[1] != 0)
7825 QueryColorCompliance(argument_list[1].string_reference,
7826 AllCompliance,&image->background_color,exception);
7827 if (attribute_flag[2] != 0)
7828 QueryColorCompliance(argument_list[2].string_reference,
7829 AllCompliance,&image->background_color,exception);
7830 if (attribute_flag[3] != 0)
7831 QueryColorCompliance(argument_list[3].string_reference,
7832 AllCompliance,&image->background_color,exception);
7833 image=RotateImage(image,argument_list[0].real_reference,exception);
7836 case 24: /* Sample */
7838 if (attribute_flag[0] != 0)
7839 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7840 &geometry,exception);
7841 if (attribute_flag[1] != 0)
7842 geometry.width=argument_list[1].integer_reference;
7843 if (attribute_flag[2] != 0)
7844 geometry.height=argument_list[2].integer_reference;
7845 image=SampleImage(image,geometry.width,geometry.height,exception);
7848 case 25: /* Scale */
7850 if (attribute_flag[0] != 0)
7851 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7852 &geometry,exception);
7853 if (attribute_flag[1] != 0)
7854 geometry.width=argument_list[1].integer_reference;
7855 if (attribute_flag[2] != 0)
7856 geometry.height=argument_list[2].integer_reference;
7857 image=ScaleImage(image,geometry.width,geometry.height,exception);
7860 case 26: /* Shade */
7862 if (attribute_flag[0] != 0)
7864 flags=ParseGeometry(argument_list[0].string_reference,
7866 if ((flags & SigmaValue) == 0)
7867 geometry_info.sigma=0.0;
7869 if (attribute_flag[1] != 0)
7870 geometry_info.rho=argument_list[1].real_reference;
7871 if (attribute_flag[2] != 0)
7872 geometry_info.sigma=argument_list[2].real_reference;
7873 image=ShadeImage(image,
7874 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7875 geometry_info.rho,geometry_info.sigma,exception);
7878 case 27: /* Sharpen */
7880 if (attribute_flag[0] != 0)
7882 flags=ParseGeometry(argument_list[0].string_reference,
7884 if ((flags & SigmaValue) == 0)
7885 geometry_info.sigma=1.0;
7887 if (attribute_flag[1] != 0)
7888 geometry_info.rho=argument_list[1].real_reference;
7889 if (attribute_flag[2] != 0)
7890 geometry_info.sigma=argument_list[2].real_reference;
7891 if (attribute_flag[3] != 0)
7892 geometry_info.xi=argument_list[3].real_reference;
7893 if (attribute_flag[4] != 0)
7894 channel=(ChannelType) argument_list[4].integer_reference;
7895 channel_mask=SetPixelChannelMask(image,channel);
7896 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7897 geometry_info.xi,exception);
7898 if (image != (Image *) NULL)
7899 (void) SetPixelChannelMask(image,channel_mask);
7902 case 28: /* Shear */
7904 if (attribute_flag[0] != 0)
7906 flags=ParseGeometry(argument_list[0].string_reference,
7908 if ((flags & SigmaValue) == 0)
7909 geometry_info.sigma=geometry_info.rho;
7911 if (attribute_flag[1] != 0)
7912 geometry_info.rho=argument_list[1].real_reference;
7913 if (attribute_flag[2] != 0)
7914 geometry_info.sigma=argument_list[2].real_reference;
7915 if (attribute_flag[3] != 0)
7916 QueryColorCompliance(argument_list[3].string_reference,
7917 AllCompliance,&image->background_color,exception);
7918 if (attribute_flag[4] != 0)
7919 QueryColorCompliance(argument_list[4].string_reference,
7920 AllCompliance,&image->background_color,exception);
7921 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7925 case 29: /* Spread */
7927 PixelInterpolateMethod
7930 if (attribute_flag[0] == 0)
7931 argument_list[0].real_reference=1.0;
7932 method=UndefinedInterpolatePixel;
7933 if (attribute_flag[1] != 0)
7934 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7935 image=SpreadImage(image,argument_list[0].real_reference,method,
7939 case 30: /* Swirl */
7941 PixelInterpolateMethod
7944 if (attribute_flag[0] == 0)
7945 argument_list[0].real_reference=50.0;
7946 method=UndefinedInterpolatePixel;
7947 if (attribute_flag[1] != 0)
7948 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7949 image=SwirlImage(image,argument_list[0].real_reference,
7953 case 31: /* Resize */
7956 if (attribute_flag[0] != 0)
7957 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7958 &geometry,exception);
7959 if (attribute_flag[1] != 0)
7960 geometry.width=argument_list[1].integer_reference;
7961 if (attribute_flag[2] != 0)
7962 geometry.height=argument_list[2].integer_reference;
7963 if (attribute_flag[3] == 0)
7964 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7965 if (attribute_flag[4] != 0)
7966 SetImageArtifact(image,"filter:support",
7967 argument_list[4].string_reference);
7968 if (attribute_flag[5] == 0)
7969 argument_list[5].real_reference=1.0;
7970 image=ResizeImage(image,geometry.width,geometry.height,
7971 (FilterTypes) argument_list[3].integer_reference,
7972 argument_list[5].real_reference,exception);
7975 case 33: /* Annotate */
7980 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7982 if (attribute_flag[0] != 0)
7987 text=InterpretImageProperties(info ? info->image_info :
7988 (ImageInfo *) NULL,image,argument_list[0].string_reference,
7990 (void) CloneString(&draw_info->text,text);
7991 text=DestroyString(text);
7993 if (attribute_flag[1] != 0)
7994 (void) CloneString(&draw_info->font,
7995 argument_list[1].string_reference);
7996 if (attribute_flag[2] != 0)
7997 draw_info->pointsize=argument_list[2].real_reference;
7998 if (attribute_flag[3] != 0)
7999 (void) CloneString(&draw_info->density,
8000 argument_list[3].string_reference);
8001 if (attribute_flag[4] != 0)
8002 (void) QueryColorCompliance(argument_list[4].string_reference,
8003 AllCompliance,&draw_info->undercolor,exception);
8004 if (attribute_flag[5] != 0)
8006 (void) QueryColorCompliance(argument_list[5].string_reference,
8007 AllCompliance,&draw_info->stroke,exception);
8008 if (argument_list[5].image_reference != (Image *) NULL)
8009 draw_info->stroke_pattern=CloneImage(
8010 argument_list[5].image_reference,0,0,MagickTrue,exception);
8012 if (attribute_flag[6] != 0)
8014 (void) QueryColorCompliance(argument_list[6].string_reference,
8015 AllCompliance,&draw_info->fill,exception);
8016 if (argument_list[6].image_reference != (Image *) NULL)
8017 draw_info->fill_pattern=CloneImage(
8018 argument_list[6].image_reference,0,0,MagickTrue,exception);
8020 if (attribute_flag[7] != 0)
8022 (void) CloneString(&draw_info->geometry,
8023 argument_list[7].string_reference);
8024 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8025 &geometry,exception);
8026 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8027 geometry_info.sigma=geometry_info.xi;
8029 if (attribute_flag[8] != 0)
8030 (void) QueryColorCompliance(argument_list[8].string_reference,
8031 AllCompliance,&draw_info->fill,exception);
8032 if (attribute_flag[11] != 0)
8033 draw_info->gravity=(GravityType)
8034 argument_list[11].integer_reference;
8035 if (attribute_flag[25] != 0)
8040 av=(AV *) argument_list[25].array_reference;
8041 if ((av_len(av) != 3) && (av_len(av) != 5))
8043 ThrowPerlException(exception,OptionError,
8044 "affine matrix must have 4 or 6 elements",PackageName);
8047 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8048 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8049 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8050 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8051 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8052 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8054 ThrowPerlException(exception,OptionError,
8055 "affine matrix is singular",PackageName);
8058 if (av_len(av) == 5)
8060 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8061 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8064 for (j=12; j < 17; j++)
8066 if (attribute_flag[j] == 0)
8068 value=argument_list[j].string_reference;
8069 angle=argument_list[j].real_reference;
8070 current=draw_info->affine;
8071 GetAffineMatrix(&affine);
8079 flags=ParseGeometry(value,&geometry_info);
8080 affine.tx=geometry_info.xi;
8081 affine.ty=geometry_info.psi;
8082 if ((flags & PsiValue) == 0)
8083 affine.ty=affine.tx;
8091 flags=ParseGeometry(value,&geometry_info);
8092 affine.sx=geometry_info.rho;
8093 affine.sy=geometry_info.sigma;
8094 if ((flags & SigmaValue) == 0)
8095 affine.sy=affine.sx;
8105 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8106 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8107 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8108 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8116 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8124 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8128 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8129 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8130 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8131 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8132 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8134 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8137 if (attribute_flag[9] == 0)
8138 argument_list[9].real_reference=0.0;
8139 if (attribute_flag[10] == 0)
8140 argument_list[10].real_reference=0.0;
8141 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8144 geometry[MaxTextExtent];
8146 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8147 (double) argument_list[9].real_reference+draw_info->affine.tx,
8148 (double) argument_list[10].real_reference+draw_info->affine.ty);
8149 (void) CloneString(&draw_info->geometry,geometry);
8151 if (attribute_flag[17] != 0)
8152 draw_info->stroke_width=argument_list[17].real_reference;
8153 if (attribute_flag[18] != 0)
8155 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8156 MagickTrue : MagickFalse;
8157 draw_info->stroke_antialias=draw_info->text_antialias;
8159 if (attribute_flag[19] != 0)
8160 (void) CloneString(&draw_info->family,
8161 argument_list[19].string_reference);
8162 if (attribute_flag[20] != 0)
8163 draw_info->style=(StyleType) argument_list[20].integer_reference;
8164 if (attribute_flag[21] != 0)
8165 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8166 if (attribute_flag[22] != 0)
8167 draw_info->weight=argument_list[22].integer_reference;
8168 if (attribute_flag[23] != 0)
8169 draw_info->align=(AlignType) argument_list[23].integer_reference;
8170 if (attribute_flag[24] != 0)
8171 (void) CloneString(&draw_info->encoding,
8172 argument_list[24].string_reference);
8173 if (attribute_flag[25] != 0)
8174 draw_info->fill_pattern=CloneImage(
8175 argument_list[25].image_reference,0,0,MagickTrue,exception);
8176 if (attribute_flag[26] != 0)
8177 draw_info->fill_pattern=CloneImage(
8178 argument_list[26].image_reference,0,0,MagickTrue,exception);
8179 if (attribute_flag[27] != 0)
8180 draw_info->stroke_pattern=CloneImage(
8181 argument_list[27].image_reference,0,0,MagickTrue,exception);
8182 if (attribute_flag[29] != 0)
8183 draw_info->kerning=argument_list[29].real_reference;
8184 if (attribute_flag[30] != 0)
8185 draw_info->interline_spacing=argument_list[30].real_reference;
8186 if (attribute_flag[31] != 0)
8187 draw_info->interword_spacing=argument_list[31].real_reference;
8188 if (attribute_flag[32] != 0)
8189 draw_info->direction=(DirectionType)
8190 argument_list[32].integer_reference;
8191 (void) AnnotateImage(image,draw_info,exception);
8192 draw_info=DestroyDrawInfo(draw_info);
8195 case 34: /* ColorFloodfill */
8207 virtual_pixel[MaxPixelChannels];
8209 draw_info=CloneDrawInfo(info ? info->image_info :
8210 (ImageInfo *) NULL,(DrawInfo *) NULL);
8211 if (attribute_flag[0] != 0)
8212 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8213 &geometry,exception);
8214 if (attribute_flag[1] != 0)
8215 geometry.x=argument_list[1].integer_reference;
8216 if (attribute_flag[2] != 0)
8217 geometry.y=argument_list[2].integer_reference;
8218 if (attribute_flag[3] != 0)
8219 (void) QueryColorCompliance(argument_list[3].string_reference,
8220 AllCompliance,&draw_info->fill,exception);
8221 (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
8223 target.red=virtual_pixel[RedPixelChannel];
8224 target.green=virtual_pixel[GreenPixelChannel];
8225 target.blue=virtual_pixel[BluePixelChannel];
8226 target.alpha=virtual_pixel[AlphaPixelChannel];
8228 if (attribute_flag[4] != 0)
8230 QueryColorCompliance(argument_list[4].string_reference,
8231 AllCompliance,&target,exception);
8234 if (attribute_flag[5] != 0)
8235 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8237 if (attribute_flag[6] != 0)
8238 invert=(MagickBooleanType) argument_list[6].integer_reference;
8239 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8240 geometry.y,invert,exception);
8241 draw_info=DestroyDrawInfo(draw_info);
8244 case 35: /* Composite */
8247 composite_geometry[MaxTextExtent];
8253 compose=OverCompositeOp;
8254 if (attribute_flag[0] != 0)
8255 composite_image=argument_list[0].image_reference;
8258 ThrowPerlException(exception,OptionError,
8259 "CompositeImageRequired",PackageName);
8263 Parameter Handling used for BOTH normal and tiled composition.
8265 if (attribute_flag[1] != 0) /* compose */
8266 compose=(CompositeOperator) argument_list[1].integer_reference;
8267 if (attribute_flag[6] != 0) /* opacity */
8269 if (compose != DissolveCompositeOp)
8270 (void) SetImageAlpha(composite_image,(Quantum)
8271 SiPrefixToDouble(argument_list[6].string_reference,
8294 Handle dissolve composite operator (patch by
8297 (void) CloneString(&image->geometry,
8298 argument_list[6].string_reference);
8299 opacity=(Quantum) SiPrefixToDouble(
8300 argument_list[6].string_reference,QuantumRange);
8301 if (composite_image->matte != MagickTrue)
8302 (void) SetImageAlpha(composite_image,OpaqueAlpha);
8303 composite_view=AcquireCacheView(composite_image);
8304 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8306 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8307 composite_image->columns,1,exception);
8308 for (x=0; x < (ssize_t) composite_image->columns; x++)
8310 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8311 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8313 q+=GetPixelChannels(composite_image);
8315 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8316 if (sync == MagickFalse)
8319 composite_view=DestroyCacheView(composite_view);
8322 if (attribute_flag[9] != 0) /* "color=>" */
8323 QueryColorCompliance(argument_list[9].string_reference,
8324 AllCompliance,&composite_image->background_color,exception);
8325 if (attribute_flag[12] != 0) /* "interpolate=>" */
8326 image->interpolate=(PixelInterpolateMethod)
8327 argument_list[12].integer_reference;
8328 if (attribute_flag[13] != 0) /* "args=>" */
8329 (void) SetImageArtifact(composite_image,"compose:args",
8330 argument_list[13].string_reference);
8331 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8332 (void) SetImageArtifact(composite_image,"compose:args",
8333 argument_list[14].string_reference);
8335 Tiling Composition (with orthogonal rotate).
8337 rotate_image=(Image *) NULL;
8338 if (attribute_flag[8] != 0) /* "rotate=>" */
8343 rotate_image=RotateImage(composite_image,
8344 argument_list[8].real_reference,exception);
8345 if (rotate_image == (Image *) NULL)
8348 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8355 Tile the composite image.
8357 if (attribute_flag[8] != 0) /* "tile=>" */
8358 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8361 (void) SetImageArtifact(composite_image,
8362 "compose:outside-overlay","false");
8363 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8364 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8366 if (attribute_flag[8] != 0) /* rotate */
8367 (void) CompositeImage(image,compose,rotate_image,x,y);
8369 (void) CompositeImage(image,compose,composite_image,x,y);
8371 if (attribute_flag[8] != 0) /* rotate */
8372 rotate_image=DestroyImage(rotate_image);
8376 Parameter Handling used used ONLY for normal composition.
8378 if (attribute_flag[5] != 0) /* gravity */
8379 image->gravity=(GravityType) argument_list[5].integer_reference;
8380 if (attribute_flag[2] != 0) /* geometry offset */
8382 SetGeometry(image,&geometry);
8383 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8385 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8388 if (attribute_flag[3] != 0) /* x offset */
8389 geometry.x=argument_list[3].integer_reference;
8390 if (attribute_flag[4] != 0) /* y offset */
8391 geometry.y=argument_list[4].integer_reference;
8392 if (attribute_flag[10] != 0) /* mask */
8394 if ((image->compose == DisplaceCompositeOp) ||
8395 (image->compose == DistortCompositeOp))
8398 Merge Y displacement into X displacement image.
8400 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8402 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8403 argument_list[10].image_reference,0,0);
8408 Set a blending mask for the composition.
8410 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8411 MagickTrue,&image->exception);
8412 (void) NegateImage(image->mask,MagickFalse,exception);
8415 if (attribute_flag[11] != 0) /* channel */
8416 channel=(ChannelType) argument_list[11].integer_reference;
8418 Composite two images (normal composition).
8420 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8421 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8422 (double) composite_image->rows,(double) geometry.x,(double)
8424 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8426 channel_mask=SetPixelChannelMask(image,channel);
8427 if (attribute_flag[8] == 0) /* no rotate */
8428 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8432 Position adjust rotated image then composite.
8434 geometry.x-=(ssize_t) (rotate_image->columns-
8435 composite_image->columns)/2;
8436 geometry.y-=(ssize_t) (rotate_image->rows-
8437 composite_image->rows)/2;
8438 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8439 rotate_image=DestroyImage(rotate_image);
8441 if (attribute_flag[10] != 0) /* mask */
8443 if ((image->compose == DisplaceCompositeOp) ||
8444 (image->compose == DistortCompositeOp))
8445 composite_image=DestroyImage(composite_image);
8447 image->mask=DestroyImage(image->mask);
8449 (void) SetPixelChannelMask(image,channel_mask);
8452 case 36: /* Contrast */
8454 if (attribute_flag[0] == 0)
8455 argument_list[0].integer_reference=0;
8456 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8457 MagickTrue : MagickFalse,exception);
8460 case 37: /* CycleColormap */
8462 if (attribute_flag[0] == 0)
8463 argument_list[0].integer_reference=6;
8464 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8473 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8475 (void) CloneString(&draw_info->primitive,"point");
8476 if (attribute_flag[0] != 0)
8478 if (argument_list[0].integer_reference < 0)
8479 (void) CloneString(&draw_info->primitive,
8480 argument_list[0].string_reference);
8482 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8483 MagickPrimitiveOptions,argument_list[0].integer_reference));
8485 if (attribute_flag[1] != 0)
8487 if (LocaleCompare(draw_info->primitive,"path") == 0)
8489 (void) ConcatenateString(&draw_info->primitive," '");
8490 ConcatenateString(&draw_info->primitive,
8491 argument_list[1].string_reference);
8492 (void) ConcatenateString(&draw_info->primitive,"'");
8496 (void) ConcatenateString(&draw_info->primitive," ");
8497 ConcatenateString(&draw_info->primitive,
8498 argument_list[1].string_reference);
8501 if (attribute_flag[2] != 0)
8503 (void) ConcatenateString(&draw_info->primitive," ");
8504 (void) ConcatenateString(&draw_info->primitive,
8505 CommandOptionToMnemonic(MagickMethodOptions,
8506 argument_list[2].integer_reference));
8508 if (attribute_flag[3] != 0)
8510 (void) QueryColorCompliance(argument_list[3].string_reference,
8511 AllCompliance,&draw_info->stroke,exception);
8512 if (argument_list[3].image_reference != (Image *) NULL)
8513 draw_info->stroke_pattern=CloneImage(
8514 argument_list[3].image_reference,0,0,MagickTrue,exception);
8516 if (attribute_flag[4] != 0)
8518 (void) QueryColorCompliance(argument_list[4].string_reference,
8519 AllCompliance,&draw_info->fill,exception);
8520 if (argument_list[4].image_reference != (Image *) NULL)
8521 draw_info->fill_pattern=CloneImage(
8522 argument_list[4].image_reference,0,0,MagickTrue,exception);
8524 if (attribute_flag[5] != 0)
8525 draw_info->stroke_width=argument_list[5].real_reference;
8526 if (attribute_flag[6] != 0)
8527 (void) CloneString(&draw_info->font,
8528 argument_list[6].string_reference);
8529 if (attribute_flag[7] != 0)
8530 (void) QueryColorCompliance(argument_list[7].string_reference,
8531 AllCompliance,&draw_info->border_color,exception);
8532 if (attribute_flag[8] != 0)
8533 draw_info->affine.tx=argument_list[8].real_reference;
8534 if (attribute_flag[9] != 0)
8535 draw_info->affine.ty=argument_list[9].real_reference;
8536 if (attribute_flag[20] != 0)
8541 av=(AV *) argument_list[20].array_reference;
8542 if ((av_len(av) != 3) && (av_len(av) != 5))
8544 ThrowPerlException(exception,OptionError,
8545 "affine matrix must have 4 or 6 elements",PackageName);
8548 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8549 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8550 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8551 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8552 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8553 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8555 ThrowPerlException(exception,OptionError,
8556 "affine matrix is singular",PackageName);
8559 if (av_len(av) == 5)
8561 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8562 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8565 for (j=10; j < 15; j++)
8567 if (attribute_flag[j] == 0)
8569 value=argument_list[j].string_reference;
8570 angle=argument_list[j].real_reference;
8571 current=draw_info->affine;
8572 GetAffineMatrix(&affine);
8580 flags=ParseGeometry(value,&geometry_info);
8581 affine.tx=geometry_info.xi;
8582 affine.ty=geometry_info.psi;
8583 if ((flags & PsiValue) == 0)
8584 affine.ty=affine.tx;
8592 flags=ParseGeometry(value,&geometry_info);
8593 affine.sx=geometry_info.rho;
8594 affine.sy=geometry_info.sigma;
8595 if ((flags & SigmaValue) == 0)
8596 affine.sy=affine.sx;
8606 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8607 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8608 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8609 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8617 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8625 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8629 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8630 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8631 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8632 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8633 draw_info->affine.tx=
8634 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8635 draw_info->affine.ty=
8636 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8638 if (attribute_flag[15] != 0)
8639 draw_info->fill_pattern=CloneImage(
8640 argument_list[15].image_reference,0,0,MagickTrue,exception);
8641 if (attribute_flag[16] != 0)
8642 draw_info->pointsize=argument_list[16].real_reference;
8643 if (attribute_flag[17] != 0)
8645 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8646 ? MagickTrue : MagickFalse;
8647 draw_info->text_antialias=draw_info->stroke_antialias;
8649 if (attribute_flag[18] != 0)
8650 (void) CloneString(&draw_info->density,
8651 argument_list[18].string_reference);
8652 if (attribute_flag[19] != 0)
8653 draw_info->stroke_width=argument_list[19].real_reference;
8654 if (attribute_flag[21] != 0)
8655 draw_info->dash_offset=argument_list[21].real_reference;
8656 if (attribute_flag[22] != 0)
8661 av=(AV *) argument_list[22].array_reference;
8662 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8663 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8664 if (draw_info->dash_pattern != (double *) NULL)
8666 for (i=0; i <= av_len(av); i++)
8667 draw_info->dash_pattern[i]=(double)
8668 SvNV(*(av_fetch(av,i,0)));
8669 draw_info->dash_pattern[i]=0.0;
8672 if (attribute_flag[23] != 0)
8673 image->interpolate=(PixelInterpolateMethod)
8674 argument_list[23].integer_reference;
8675 if ((attribute_flag[24] != 0) &&
8676 (draw_info->fill_pattern != (Image *) NULL))
8677 flags=ParsePageGeometry(draw_info->fill_pattern,
8678 argument_list[24].string_reference,
8679 &draw_info->fill_pattern->tile_offset,exception);
8680 if (attribute_flag[25] != 0)
8682 (void) ConcatenateString(&draw_info->primitive," '");
8683 (void) ConcatenateString(&draw_info->primitive,
8684 argument_list[25].string_reference);
8685 (void) ConcatenateString(&draw_info->primitive,"'");
8687 if (attribute_flag[26] != 0)
8688 draw_info->fill_pattern=CloneImage(
8689 argument_list[26].image_reference,0,0,MagickTrue,exception);
8690 if (attribute_flag[27] != 0)
8691 draw_info->stroke_pattern=CloneImage(
8692 argument_list[27].image_reference,0,0,MagickTrue,exception);
8693 if (attribute_flag[28] != 0)
8694 (void) CloneString(&draw_info->primitive,
8695 argument_list[28].string_reference);
8696 if (attribute_flag[29] != 0)
8697 draw_info->kerning=argument_list[29].real_reference;
8698 if (attribute_flag[30] != 0)
8699 draw_info->interline_spacing=argument_list[30].real_reference;
8700 if (attribute_flag[31] != 0)
8701 draw_info->interword_spacing=argument_list[31].real_reference;
8702 if (attribute_flag[32] != 0)
8703 draw_info->direction=(DirectionType)
8704 argument_list[32].integer_reference;
8705 DrawImage(image,draw_info,exception);
8706 draw_info=DestroyDrawInfo(draw_info);
8709 case 39: /* Equalize */
8711 if (attribute_flag[0] != 0)
8712 channel=(ChannelType) argument_list[0].integer_reference;
8713 channel_mask=SetPixelChannelMask(image,channel);
8714 EqualizeImage(image,exception);
8715 (void) SetPixelChannelMask(image,channel_mask);
8718 case 40: /* Gamma */
8720 if (attribute_flag[1] != 0)
8721 channel=(ChannelType) argument_list[1].integer_reference;
8722 if (attribute_flag[2] == 0)
8723 argument_list[2].real_reference=1.0;
8724 if (attribute_flag[3] == 0)
8725 argument_list[3].real_reference=1.0;
8726 if (attribute_flag[4] == 0)
8727 argument_list[4].real_reference=1.0;
8728 if (attribute_flag[0] == 0)
8730 (void) FormatLocaleString(message,MaxTextExtent,
8731 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8732 (double) argument_list[3].real_reference,
8733 (double) argument_list[4].real_reference);
8734 argument_list[0].string_reference=message;
8736 (void) GammaImage(image,InterpretLocaleValue(
8737 argument_list[0].string_reference,(char **) NULL),exception);
8745 if (attribute_flag[0] == 0)
8747 ThrowPerlException(exception,OptionError,"MapImageRequired",
8751 quantize_info=AcquireQuantizeInfo(info->image_info);
8752 if (attribute_flag[1] != 0)
8753 quantize_info->dither=(MagickBooleanType)
8754 argument_list[1].integer_reference;
8755 if (attribute_flag[2] != 0)
8756 quantize_info->dither_method=(DitherMethod)
8757 argument_list[2].integer_reference;
8758 (void) RemapImages(quantize_info,image,
8759 argument_list[0].image_reference,exception);
8760 quantize_info=DestroyQuantizeInfo(quantize_info);
8763 case 42: /* MatteFloodfill */
8775 virtual_pixel[MaxPixelChannels];
8777 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8779 if (attribute_flag[0] != 0)
8780 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8781 &geometry,exception);
8782 if (attribute_flag[1] != 0)
8783 geometry.x=argument_list[1].integer_reference;
8784 if (attribute_flag[2] != 0)
8785 geometry.y=argument_list[2].integer_reference;
8786 if (image->matte == MagickFalse)
8787 (void) SetImageAlpha(image,OpaqueAlpha);
8788 (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
8790 target.red=virtual_pixel[RedPixelChannel];
8791 target.green=virtual_pixel[GreenPixelChannel];
8792 target.blue=virtual_pixel[BluePixelChannel];
8793 target.alpha=virtual_pixel[AlphaPixelChannel];
8794 if (attribute_flag[4] != 0)
8795 QueryColorCompliance(argument_list[4].string_reference,
8796 AllCompliance,&target,exception);
8797 if (attribute_flag[3] != 0)
8798 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8800 if (attribute_flag[5] != 0)
8801 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8804 if (attribute_flag[6] != 0)
8805 invert=(MagickBooleanType) argument_list[6].integer_reference;
8806 channel_mask=SetPixelChannelMask(image,AlphaChannel);
8807 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8808 geometry.y,invert,exception);
8809 (void) SetPixelChannelMask(image,channel_mask);
8810 draw_info=DestroyDrawInfo(draw_info);
8813 case 43: /* Modulate */
8816 modulate[MaxTextExtent];
8818 geometry_info.rho=100.0;
8819 geometry_info.sigma=100.0;
8820 geometry_info.xi=100.0;
8821 if (attribute_flag[0] != 0)
8822 (void)ParseGeometry(argument_list[0].string_reference,
8824 if (attribute_flag[1] != 0)
8825 geometry_info.xi=argument_list[1].real_reference;
8826 if (attribute_flag[2] != 0)
8827 geometry_info.sigma=argument_list[2].real_reference;
8828 if (attribute_flag[3] != 0)
8830 geometry_info.sigma=argument_list[3].real_reference;
8831 SetImageArtifact(image,"modulate:colorspace","HWB");
8833 if (attribute_flag[4] != 0)
8835 geometry_info.rho=argument_list[4].real_reference;
8836 SetImageArtifact(image,"modulate:colorspace","HSB");
8838 if (attribute_flag[5] != 0)
8840 geometry_info.sigma=argument_list[5].real_reference;
8841 SetImageArtifact(image,"modulate:colorspace","HSL");
8843 if (attribute_flag[6] != 0)
8845 geometry_info.rho=argument_list[6].real_reference;
8846 SetImageArtifact(image,"modulate:colorspace","HWB");
8848 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8849 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8850 (void) ModulateImage(image,modulate,exception);
8853 case 44: /* Negate */
8855 if (attribute_flag[0] == 0)
8856 argument_list[0].integer_reference=0;
8857 if (attribute_flag[1] != 0)
8858 channel=(ChannelType) argument_list[1].integer_reference;
8859 channel_mask=SetPixelChannelMask(image,channel);
8860 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8861 MagickTrue : MagickFalse,exception);
8862 (void) SetPixelChannelMask(image,channel_mask);
8865 case 45: /* Normalize */
8867 if (attribute_flag[0] != 0)
8868 channel=(ChannelType) argument_list[0].integer_reference;
8869 channel_mask=SetPixelChannelMask(image,channel);
8870 NormalizeImage(image,exception);
8871 (void) SetPixelChannelMask(image,channel_mask);
8874 case 46: /* NumberColors */
8876 case 47: /* Opaque */
8885 (void) QueryColorCompliance("none",AllCompliance,&target,
8887 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
8889 if (attribute_flag[0] != 0)
8890 (void) QueryColorCompliance(argument_list[0].string_reference,
8891 AllCompliance,&target,exception);
8892 if (attribute_flag[1] != 0)
8893 (void) QueryColorCompliance(argument_list[1].string_reference,
8894 AllCompliance,&fill_color,exception);
8895 if (attribute_flag[2] != 0)
8896 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8898 if (attribute_flag[3] != 0)
8899 channel=(ChannelType) argument_list[3].integer_reference;
8901 if (attribute_flag[4] != 0)
8902 invert=(MagickBooleanType) argument_list[4].integer_reference;
8903 channel_mask=SetPixelChannelMask(image,channel);
8904 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
8905 (void) SetPixelChannelMask(image,channel_mask);
8908 case 48: /* Quantize */
8913 quantize_info=AcquireQuantizeInfo(info->image_info);
8914 if (attribute_flag[0] != 0)
8915 quantize_info->number_colors=(size_t)
8916 argument_list[0].integer_reference;
8917 if (attribute_flag[1] != 0)
8918 quantize_info->tree_depth=(size_t)
8919 argument_list[1].integer_reference;
8920 if (attribute_flag[2] != 0)
8921 quantize_info->colorspace=(ColorspaceType)
8922 argument_list[2].integer_reference;
8923 if (attribute_flag[3] != 0)
8924 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8925 MagickTrue : MagickFalse;
8926 if (attribute_flag[4] != 0)
8927 quantize_info->measure_error=
8928 argument_list[4].integer_reference != 0 ? MagickTrue :
8930 if (attribute_flag[5] != 0)
8931 (void) QueryColorCompliance(argument_list[5].string_reference,
8932 AllCompliance,&image->transparent_color,exception);
8933 if (attribute_flag[5] && argument_list[5].integer_reference)
8935 (void) QuantizeImages(quantize_info,image,exception);
8938 if (attribute_flag[6] != 0)
8939 quantize_info->dither_method=(DitherMethod)
8940 argument_list[6].integer_reference;
8941 if ((image->storage_class == DirectClass) ||
8942 (image->colors > quantize_info->number_colors) ||
8943 (quantize_info->colorspace == GRAYColorspace))
8944 (void) QuantizeImage(quantize_info,image,exception);
8946 CompressImageColormap(image,exception);
8947 quantize_info=DestroyQuantizeInfo(quantize_info);
8950 case 49: /* Raise */
8952 if (attribute_flag[0] != 0)
8953 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8954 &geometry,exception);
8955 if (attribute_flag[1] != 0)
8956 geometry.width=argument_list[1].integer_reference;
8957 if (attribute_flag[2] != 0)
8958 geometry.height=argument_list[2].integer_reference;
8959 if (attribute_flag[3] == 0)
8960 argument_list[3].integer_reference=1;
8961 (void) RaiseImage(image,&geometry,
8962 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8966 case 50: /* Segment */
8973 smoothing_threshold;
8978 cluster_threshold=1.0;
8979 smoothing_threshold=1.5;
8980 colorspace=RGBColorspace;
8981 verbose=MagickFalse;
8982 if (attribute_flag[0] != 0)
8984 flags=ParseGeometry(argument_list[0].string_reference,
8986 cluster_threshold=geometry_info.rho;
8987 if (flags & SigmaValue)
8988 smoothing_threshold=geometry_info.sigma;
8990 if (attribute_flag[1] != 0)
8991 cluster_threshold=argument_list[1].real_reference;
8992 if (attribute_flag[2] != 0)
8993 smoothing_threshold=argument_list[2].real_reference;
8994 if (attribute_flag[3] != 0)
8995 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8996 if (attribute_flag[4] != 0)
8997 verbose=argument_list[4].integer_reference != 0 ?
8998 MagickTrue : MagickFalse;
8999 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9000 smoothing_threshold,exception);
9003 case 51: /* Signature */
9005 (void) SignatureImage(image,exception);
9008 case 52: /* Solarize */
9010 geometry_info.rho=QuantumRange/2.0;
9011 if (attribute_flag[0] != 0)
9012 flags=ParseGeometry(argument_list[0].string_reference,
9014 if (attribute_flag[1] != 0)
9015 geometry_info.rho=SiPrefixToDouble(
9016 argument_list[1].string_reference,QuantumRange);
9017 (void) SolarizeImage(image,geometry_info.rho,exception);
9022 (void) SyncImage(image);
9025 case 54: /* Texture */
9027 if (attribute_flag[0] == 0)
9029 TextureImage(image,argument_list[0].image_reference);
9032 case 55: /* Evalute */
9034 MagickEvaluateOperator
9037 op=SetEvaluateOperator;
9038 if (attribute_flag[0] == MagickFalse)
9039 argument_list[0].real_reference=0.0;
9040 if (attribute_flag[1] != MagickFalse)
9041 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9042 if (attribute_flag[2] != MagickFalse)
9043 channel=(ChannelType) argument_list[2].integer_reference;
9044 channel_mask=SetPixelChannelMask(image,channel);
9045 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9047 (void) SetPixelChannelMask(image,channel_mask);
9050 case 56: /* Transparent */
9061 (void) QueryColorCompliance("none",AllCompliance,&target,
9063 if (attribute_flag[0] != 0)
9064 (void) QueryColorCompliance(argument_list[0].string_reference,
9065 AllCompliance,&target,exception);
9066 opacity=TransparentAlpha;
9067 if (attribute_flag[1] != 0)
9068 opacity=SiPrefixToDouble(argument_list[1].string_reference,
9070 if (attribute_flag[2] != 0)
9071 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
9073 if (attribute_flag[3] == 0)
9074 argument_list[3].integer_reference=0;
9076 if (attribute_flag[3] != 0)
9077 invert=(MagickBooleanType) argument_list[3].integer_reference;
9078 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9082 case 57: /* Threshold */
9087 if (attribute_flag[0] == 0)
9088 argument_list[0].string_reference="50%";
9089 if (attribute_flag[1] != 0)
9090 channel=(ChannelType) argument_list[1].integer_reference;
9091 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9093 channel_mask=SetPixelChannelMask(image,channel);
9094 (void) BilevelImage(image,threshold);
9095 (void) SetPixelChannelMask(image,channel_mask);
9098 case 58: /* Charcoal */
9100 if (attribute_flag[0] != 0)
9102 flags=ParseGeometry(argument_list[0].string_reference,
9104 if ((flags & SigmaValue) == 0)
9105 geometry_info.sigma=1.0;
9107 if (attribute_flag[1] != 0)
9108 geometry_info.rho=argument_list[1].real_reference;
9109 if (attribute_flag[2] != 0)
9110 geometry_info.sigma=argument_list[2].real_reference;
9111 if (attribute_flag[3] != 0)
9112 geometry_info.xi=argument_list[3].real_reference;
9113 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9114 geometry_info.xi,exception);
9119 if (attribute_flag[0] != 0)
9120 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9122 image=TrimImage(image,exception);
9127 PixelInterpolateMethod
9130 if (attribute_flag[0] != 0)
9132 flags=ParseGeometry(argument_list[0].string_reference,
9134 if ((flags & SigmaValue) == 0)
9135 geometry_info.sigma=1.0;
9137 if (attribute_flag[1] != 0)
9138 geometry_info.rho=argument_list[1].real_reference;
9139 if (attribute_flag[2] != 0)
9140 geometry_info.sigma=argument_list[2].real_reference;
9141 method=UndefinedInterpolatePixel;
9142 if (attribute_flag[3] != 0)
9143 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9144 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9148 case 61: /* Separate */
9150 if (attribute_flag[0] != 0)
9151 channel=(ChannelType) argument_list[0].integer_reference;
9152 channel_mask=SetPixelChannelMask(image,channel);
9153 (void) SeparateImage(image);
9154 (void) SetPixelChannelMask(image,channel_mask);
9157 case 63: /* Stereo */
9159 if (attribute_flag[0] == 0)
9161 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9165 if (attribute_flag[1] != 0)
9166 geometry.x=argument_list[1].integer_reference;
9167 if (attribute_flag[2] != 0)
9168 geometry.y=argument_list[2].integer_reference;
9169 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9170 geometry.x,geometry.y,exception);
9173 case 64: /* Stegano */
9175 if (attribute_flag[0] == 0)
9177 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9181 if (attribute_flag[1] == 0)
9182 argument_list[1].integer_reference=0;
9183 image->offset=argument_list[1].integer_reference;
9184 image=SteganoImage(image,argument_list[0].image_reference,exception);
9187 case 65: /* Deconstruct */
9189 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9192 case 66: /* GaussianBlur */
9194 if (attribute_flag[0] != 0)
9196 flags=ParseGeometry(argument_list[0].string_reference,
9198 if ((flags & SigmaValue) == 0)
9199 geometry_info.sigma=1.0;
9201 if (attribute_flag[1] != 0)
9202 geometry_info.rho=argument_list[1].real_reference;
9203 if (attribute_flag[2] != 0)
9204 geometry_info.sigma=argument_list[2].real_reference;
9205 if (attribute_flag[3] != 0)
9206 geometry_info.xi=argument_list[3].real_reference;
9207 if (attribute_flag[4] != 0)
9208 channel=(ChannelType) argument_list[4].integer_reference;
9209 channel_mask=SetPixelChannelMask(image,channel);
9210 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9211 geometry_info.xi,exception);
9212 if (image != (Image *) NULL)
9213 (void) SetPixelChannelMask(image,channel_mask);
9216 case 67: /* Convolve */
9221 kernel=(KernelInfo *) NULL;
9222 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9224 if (attribute_flag[0] != 0)
9232 kernel=AcquireKernelInfo((const char *) NULL);
9233 if (kernel == (KernelInfo *) NULL)
9235 av=(AV *) argument_list[0].array_reference;
9236 order=(size_t) sqrt(av_len(av)+1);
9237 kernel->width=order;
9238 kernel->height=order;
9239 kernel->values=(double *) AcquireAlignedMemory(order,order*
9240 sizeof(*kernel->values));
9241 if (kernel->values == (double *) NULL)
9243 kernel=DestroyKernelInfo(kernel);
9244 ThrowPerlException(exception,ResourceLimitFatalError,
9245 "MemoryAllocationFailed",PackageName);
9248 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9249 kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
9250 for ( ; j < (ssize_t) (order*order); j++)
9251 kernel->values[j]=0.0;
9253 if (attribute_flag[1] != 0)
9254 channel=(ChannelType) argument_list[1].integer_reference;
9255 if (attribute_flag[2] != 0)
9256 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9258 if (attribute_flag[3] != 0)
9260 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9261 if (kernel == (KernelInfo *) NULL)
9264 channel_mask=SetPixelChannelMask(image,channel);
9265 kernel->bias=image->bias;
9266 image=ConvolveImage(image,kernel,exception);
9267 if (image != (Image *) NULL)
9268 (void) SetPixelChannelMask(image,channel_mask);
9269 kernel=DestroyKernelInfo(kernel);
9272 case 68: /* Profile */
9287 if (attribute_flag[0] != 0)
9288 name=argument_list[0].string_reference;
9289 if (attribute_flag[2] != 0)
9290 image->rendering_intent=(RenderingIntent)
9291 argument_list[2].integer_reference;
9292 if (attribute_flag[3] != 0)
9293 image->black_point_compensation=
9294 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9295 if (attribute_flag[1] != 0)
9297 if (argument_list[1].length == 0)
9300 Remove a profile from the image.
9302 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9307 Associate user supplied profile with the image.
9309 profile=AcquireStringInfo(argument_list[1].length);
9310 SetStringInfoDatum(profile,(const unsigned char *)
9311 argument_list[1].string_reference);
9312 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9313 (size_t) GetStringInfoLength(profile),exception);
9314 profile=DestroyStringInfo(profile);
9318 Associate a profile with the image.
9321 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9322 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9323 profile_image=ReadImages(profile_info,&image->exception);
9324 if (profile_image == (Image *) NULL)
9326 ResetImageProfileIterator(profile_image);
9327 name=GetNextImageProfile(profile_image);
9328 while (name != (const char *) NULL)
9333 profile=GetImageProfile(profile_image,name);
9334 if (profile != (const StringInfo *) NULL)
9335 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9336 (size_t) GetStringInfoLength(profile),exception);
9337 name=GetNextImageProfile(profile_image);
9339 profile_image=DestroyImage(profile_image);
9340 profile_info=DestroyImageInfo(profile_info);
9343 case 69: /* UnsharpMask */
9345 if (attribute_flag[0] != 0)
9347 flags=ParseGeometry(argument_list[0].string_reference,
9349 if ((flags & SigmaValue) == 0)
9350 geometry_info.sigma=1.0;
9351 if ((flags & XiValue) == 0)
9352 geometry_info.xi=1.0;
9353 if ((flags & PsiValue) == 0)
9354 geometry_info.psi=0.5;
9356 if (attribute_flag[1] != 0)
9357 geometry_info.rho=argument_list[1].real_reference;
9358 if (attribute_flag[2] != 0)
9359 geometry_info.sigma=argument_list[2].real_reference;
9360 if (attribute_flag[3] != 0)
9361 geometry_info.xi=argument_list[3].real_reference;
9362 if (attribute_flag[4] != 0)
9363 geometry_info.psi=argument_list[4].real_reference;
9364 if (attribute_flag[5] != 0)
9365 channel=(ChannelType) argument_list[5].integer_reference;
9366 channel_mask=SetPixelChannelMask(image,channel);
9367 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9368 geometry_info.xi,geometry_info.psi,exception);
9369 if (image != (Image *) NULL)
9370 (void) SetPixelChannelMask(image,channel_mask);
9373 case 70: /* MotionBlur */
9375 if (attribute_flag[0] != 0)
9377 flags=ParseGeometry(argument_list[0].string_reference,
9379 if ((flags & SigmaValue) == 0)
9380 geometry_info.sigma=1.0;
9381 if ((flags & XiValue) == 0)
9382 geometry_info.xi=1.0;
9384 if (attribute_flag[1] != 0)
9385 geometry_info.rho=argument_list[1].real_reference;
9386 if (attribute_flag[2] != 0)
9387 geometry_info.sigma=argument_list[2].real_reference;
9388 if (attribute_flag[3] != 0)
9389 geometry_info.xi=argument_list[3].real_reference;
9390 if (attribute_flag[4] != 0)
9391 geometry_info.psi=argument_list[4].real_reference;
9392 if (attribute_flag[5] != 0)
9393 channel=(ChannelType) argument_list[5].integer_reference;
9394 channel_mask=SetPixelChannelMask(image,channel);
9395 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9396 geometry_info.xi,geometry_info.psi,exception);
9397 if (image != (Image *) NULL)
9398 (void) SetPixelChannelMask(image,channel_mask);
9401 case 71: /* OrderedDither */
9403 if (attribute_flag[0] == 0)
9404 argument_list[0].string_reference="o8x8";
9405 if (attribute_flag[1] != 0)
9406 channel=(ChannelType) argument_list[1].integer_reference;
9407 channel_mask=SetPixelChannelMask(image,channel);
9408 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9410 (void) SetPixelChannelMask(image,channel_mask);
9413 case 72: /* Shave */
9415 if (attribute_flag[0] != 0)
9416 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9417 &geometry,exception);
9418 if (attribute_flag[1] != 0)
9419 geometry.width=argument_list[1].integer_reference;
9420 if (attribute_flag[2] != 0)
9421 geometry.height=argument_list[2].integer_reference;
9422 image=ShaveImage(image,&geometry,exception);
9425 case 73: /* Level */
9433 white_point=(MagickRealType) image->columns*image->rows;
9435 if (attribute_flag[0] != 0)
9437 flags=ParseGeometry(argument_list[0].string_reference,
9439 black_point=geometry_info.rho;
9440 if ((flags & SigmaValue) != 0)
9441 white_point=geometry_info.sigma;
9442 if ((flags & XiValue) != 0)
9443 gamma=geometry_info.xi;
9444 if ((flags & PercentValue) != 0)
9446 black_point*=(double) (QuantumRange/100.0);
9447 white_point*=(double) (QuantumRange/100.0);
9449 if ((flags & SigmaValue) == 0)
9450 white_point=(double) QuantumRange-black_point;
9452 if (attribute_flag[1] != 0)
9453 black_point=argument_list[1].real_reference;
9454 if (attribute_flag[2] != 0)
9455 white_point=argument_list[2].real_reference;
9456 if (attribute_flag[3] != 0)
9457 gamma=argument_list[3].real_reference;
9458 if (attribute_flag[4] != 0)
9459 channel=(ChannelType) argument_list[4].integer_reference;
9460 if (attribute_flag[5] != 0)
9462 argument_list[0].real_reference=argument_list[5].real_reference;
9463 attribute_flag[0]=attribute_flag[5];
9465 channel_mask=SetPixelChannelMask(image,channel);
9466 (void) LevelImage(image,black_point,white_point,gamma,exception);
9467 (void) SetPixelChannelMask(image,channel_mask);
9472 if (attribute_flag[0] == 0)
9473 argument_list[0].string_reference="#1";
9474 if (attribute_flag[1] == 0)
9475 argument_list[1].integer_reference=MagickTrue;
9476 (void) ClipImagePath(image,argument_list[0].string_reference,
9477 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9481 case 75: /* AffineTransform */
9486 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9488 if (attribute_flag[0] != 0)
9493 av=(AV *) argument_list[0].array_reference;
9494 if ((av_len(av) != 3) && (av_len(av) != 5))
9496 ThrowPerlException(exception,OptionError,
9497 "affine matrix must have 4 or 6 elements",PackageName);
9500 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9501 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9502 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9503 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9504 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9505 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9507 ThrowPerlException(exception,OptionError,
9508 "affine matrix is singular",PackageName);
9511 if (av_len(av) == 5)
9513 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9514 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9517 for (j=1; j < 6; j++)
9519 if (attribute_flag[j] == 0)
9521 value=argument_list[j].string_reference;
9522 angle=argument_list[j].real_reference;
9523 current=draw_info->affine;
9524 GetAffineMatrix(&affine);
9532 flags=ParseGeometry(value,&geometry_info);
9533 affine.tx=geometry_info.xi;
9534 affine.ty=geometry_info.psi;
9535 if ((flags & PsiValue) == 0)
9536 affine.ty=affine.tx;
9544 flags=ParseGeometry(value,&geometry_info);
9545 affine.sx=geometry_info.rho;
9546 affine.sy=geometry_info.sigma;
9547 if ((flags & SigmaValue) == 0)
9548 affine.sy=affine.sx;
9558 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9559 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9560 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9561 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9569 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9577 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9581 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9582 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9583 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9584 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9585 draw_info->affine.tx=
9586 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9587 draw_info->affine.ty=
9588 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9590 if (attribute_flag[6] != 0)
9591 image->interpolate=(PixelInterpolateMethod)
9592 argument_list[6].integer_reference;
9593 if (attribute_flag[7] != 0)
9594 QueryColorCompliance(argument_list[7].string_reference,
9595 AllCompliance,&image->background_color,exception);
9596 image=AffineTransformImage(image,&draw_info->affine,exception);
9597 draw_info=DestroyDrawInfo(draw_info);
9600 case 76: /* Difference */
9602 if (attribute_flag[0] == 0)
9604 ThrowPerlException(exception,OptionError,
9605 "ReferenceImageRequired",PackageName);
9608 if (attribute_flag[1] != 0)
9609 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9611 (void) IsImagesEqual(image,argument_list[0].image_reference,
9615 case 77: /* AdaptiveThreshold */
9617 if (attribute_flag[0] != 0)
9619 flags=ParseGeometry(argument_list[0].string_reference,
9621 if ((flags & PercentValue) != 0)
9622 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9624 if (attribute_flag[1] != 0)
9625 geometry_info.rho=argument_list[1].integer_reference;
9626 if (attribute_flag[2] != 0)
9627 geometry_info.sigma=argument_list[2].integer_reference;
9628 if (attribute_flag[3] != 0)
9629 geometry_info.xi=argument_list[3].integer_reference;;
9630 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9631 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9634 case 78: /* Resample */
9640 if (attribute_flag[0] != 0)
9642 flags=ParseGeometry(argument_list[0].string_reference,
9644 if ((flags & SigmaValue) == 0)
9645 geometry_info.sigma=geometry_info.rho;
9647 if (attribute_flag[1] != 0)
9648 geometry_info.rho=argument_list[1].real_reference;
9649 if (attribute_flag[2] != 0)
9650 geometry_info.sigma=argument_list[2].real_reference;
9651 if (attribute_flag[3] == 0)
9652 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9653 if (attribute_flag[4] == 0)
9654 SetImageArtifact(image,"filter:support",
9655 argument_list[4].string_reference);
9656 if (attribute_flag[5] != 0)
9657 argument_list[5].real_reference=1.0;
9658 width=(size_t) (geometry_info.rho*image->columns/
9659 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9660 height=(size_t) (geometry_info.sigma*image->rows/
9661 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9662 image=ResizeImage(image,width,height,(FilterTypes)
9663 argument_list[3].integer_reference,argument_list[5].real_reference,
9665 if (image != (Image *) NULL)
9667 image->x_resolution=geometry_info.rho;
9668 image->y_resolution=geometry_info.sigma;
9672 case 79: /* Describe */
9674 if (attribute_flag[0] == 0)
9675 argument_list[0].file_reference=(FILE *) NULL;
9676 if (attribute_flag[1] != 0)
9677 (void) SetImageArtifact(image,"identify:features",
9678 argument_list[1].string_reference);
9679 (void) IdentifyImage(image,argument_list[0].file_reference,
9680 MagickTrue,exception);
9683 case 80: /* BlackThreshold */
9685 if (attribute_flag[0] == 0)
9686 argument_list[0].string_reference="50%";
9687 if (attribute_flag[2] != 0)
9688 channel=(ChannelType) argument_list[2].integer_reference;
9689 channel_mask=SetPixelChannelMask(image,channel);
9690 BlackThresholdImage(image,argument_list[0].string_reference,
9692 (void) SetPixelChannelMask(image,channel_mask);
9695 case 81: /* WhiteThreshold */
9697 if (attribute_flag[0] == 0)
9698 argument_list[0].string_reference="50%";
9699 if (attribute_flag[2] != 0)
9700 channel=(ChannelType) argument_list[2].integer_reference;
9701 channel_mask=SetPixelChannelMask(image,channel);
9702 WhiteThresholdImage(image,argument_list[0].string_reference,
9704 (void) SetPixelChannelMask(image,channel_mask);
9707 case 82: /* RadialBlur */
9709 if (attribute_flag[0] != 0)
9711 flags=ParseGeometry(argument_list[0].string_reference,
9714 if (attribute_flag[1] != 0)
9715 geometry_info.rho=argument_list[1].real_reference;
9716 if (attribute_flag[2] != 0)
9717 geometry_info.sigma=argument_list[2].real_reference;
9718 if (attribute_flag[3] != 0)
9719 channel=(ChannelType) argument_list[3].integer_reference;
9720 channel_mask=SetPixelChannelMask(image,channel);
9721 image=RadialBlurImage(image,geometry_info.rho,geometry_info.sigma,
9723 if (image != (Image *) NULL)
9724 (void) SetPixelChannelMask(image,channel_mask);
9727 case 83: /* Thumbnail */
9729 if (attribute_flag[0] != 0)
9730 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9731 &geometry,exception);
9732 if (attribute_flag[1] != 0)
9733 geometry.width=argument_list[1].integer_reference;
9734 if (attribute_flag[2] != 0)
9735 geometry.height=argument_list[2].integer_reference;
9736 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9739 case 84: /* Strip */
9741 (void) StripImage(image);
9749 GetPixelInfo(image,&tint);
9750 if (attribute_flag[0] != 0)
9751 (void) QueryColorCompliance(argument_list[0].string_reference,
9752 AllCompliance,&tint,exception);
9753 if (attribute_flag[1] == 0)
9754 argument_list[1].string_reference="100";
9755 image=TintImage(image,argument_list[1].string_reference,&tint,
9759 case 86: /* Channel */
9761 if (attribute_flag[0] != 0)
9762 channel=(ChannelType) argument_list[0].integer_reference;
9763 channel_mask=SetPixelChannelMask(image,channel);
9764 (void) SeparateImage(image);
9765 (void) SetPixelChannelMask(image,channel_mask);
9768 case 87: /* Splice */
9770 if (attribute_flag[0] != 0)
9771 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9772 &geometry,exception);
9773 if (attribute_flag[1] != 0)
9774 geometry.width=argument_list[1].integer_reference;
9775 if (attribute_flag[2] != 0)
9776 geometry.height=argument_list[2].integer_reference;
9777 if (attribute_flag[3] != 0)
9778 geometry.x=argument_list[3].integer_reference;
9779 if (attribute_flag[4] != 0)
9780 geometry.y=argument_list[4].integer_reference;
9781 if (attribute_flag[5] != 0)
9782 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9784 if (attribute_flag[6] != 0)
9785 (void) QueryColorCompliance(argument_list[6].string_reference,
9786 AllCompliance,&image->background_color,exception);
9787 if (attribute_flag[7] != 0)
9788 image->gravity=(GravityType) argument_list[7].integer_reference;
9789 image=SpliceImage(image,&geometry,exception);
9792 case 88: /* Posterize */
9794 if (attribute_flag[0] == 0)
9795 argument_list[0].integer_reference=3;
9796 if (attribute_flag[1] == 0)
9797 argument_list[1].integer_reference=0;
9798 (void) PosterizeImage(image,argument_list[0].integer_reference,
9799 argument_list[1].integer_reference ? MagickTrue : MagickFalse,
9803 case 89: /* Shadow */
9805 if (attribute_flag[0] != 0)
9807 flags=ParseGeometry(argument_list[0].string_reference,
9809 if ((flags & SigmaValue) == 0)
9810 geometry_info.sigma=1.0;
9811 if ((flags & XiValue) == 0)
9812 geometry_info.xi=4.0;
9813 if ((flags & PsiValue) == 0)
9814 geometry_info.psi=4.0;
9816 if (attribute_flag[1] != 0)
9817 geometry_info.rho=argument_list[1].real_reference;
9818 if (attribute_flag[2] != 0)
9819 geometry_info.sigma=argument_list[2].real_reference;
9820 if (attribute_flag[3] != 0)
9821 geometry_info.xi=argument_list[3].integer_reference;
9822 if (attribute_flag[4] != 0)
9823 geometry_info.psi=argument_list[4].integer_reference;
9824 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9825 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9829 case 90: /* Identify */
9831 if (attribute_flag[0] == 0)
9832 argument_list[0].file_reference=(FILE *) NULL;
9833 if (attribute_flag[1] != 0)
9834 (void) SetImageArtifact(image,"identify:features",
9835 argument_list[1].string_reference);
9836 if ((attribute_flag[2] != 0) &&
9837 (argument_list[2].integer_reference != 0))
9838 (void) SetImageArtifact(image,"identify:unique","true");
9839 (void) IdentifyImage(image,argument_list[0].file_reference,
9840 MagickTrue,exception);
9843 case 91: /* SepiaTone */
9845 if (attribute_flag[0] == 0)
9846 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9847 image=SepiaToneImage(image,argument_list[0].real_reference,
9851 case 92: /* SigmoidalContrast */
9856 if (attribute_flag[0] != 0)
9858 flags=ParseGeometry(argument_list[0].string_reference,
9860 if ((flags & SigmaValue) == 0)
9861 geometry_info.sigma=QuantumRange/2.0;
9862 if ((flags & PercentValue) != 0)
9863 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9865 if (attribute_flag[1] != 0)
9866 geometry_info.rho=argument_list[1].real_reference;
9867 if (attribute_flag[2] != 0)
9868 geometry_info.sigma=argument_list[2].real_reference;
9869 if (attribute_flag[3] != 0)
9870 channel=(ChannelType) argument_list[3].integer_reference;
9872 if (attribute_flag[4] != 0)
9873 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9875 channel_mask=SetPixelChannelMask(image,channel);
9876 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9877 geometry_info.sigma,exception);
9878 (void) SetPixelChannelMask(image,channel_mask);
9881 case 93: /* Extent */
9883 if (attribute_flag[7] != 0)
9884 image->gravity=(GravityType) argument_list[7].integer_reference;
9885 if (attribute_flag[0] != 0)
9890 flags=ParseGravityGeometry(image,
9891 argument_list[0].string_reference,&geometry,exception);
9893 if (geometry.width == 0)
9894 geometry.width=image->columns;
9895 if (geometry.height == 0)
9896 geometry.height=image->rows;
9898 if (attribute_flag[1] != 0)
9899 geometry.width=argument_list[1].integer_reference;
9900 if (attribute_flag[2] != 0)
9901 geometry.height=argument_list[2].integer_reference;
9902 if (attribute_flag[3] != 0)
9903 geometry.x=argument_list[3].integer_reference;
9904 if (attribute_flag[4] != 0)
9905 geometry.y=argument_list[4].integer_reference;
9906 if (attribute_flag[5] != 0)
9907 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9909 if (attribute_flag[6] != 0)
9910 (void) QueryColorCompliance(argument_list[6].string_reference,
9911 AllCompliance,&image->background_color,exception);
9912 image=ExtentImage(image,&geometry,exception);
9915 case 94: /* Vignette */
9917 if (attribute_flag[0] != 0)
9919 flags=ParseGeometry(argument_list[0].string_reference,
9921 if ((flags & SigmaValue) == 0)
9922 geometry_info.sigma=1.0;
9923 if ((flags & XiValue) == 0)
9924 geometry_info.xi=0.1*image->columns;
9925 if ((flags & PsiValue) == 0)
9926 geometry_info.psi=0.1*image->rows;
9928 if (attribute_flag[1] != 0)
9929 geometry_info.rho=argument_list[1].real_reference;
9930 if (attribute_flag[2] != 0)
9931 geometry_info.sigma=argument_list[2].real_reference;
9932 if (attribute_flag[3] != 0)
9933 geometry_info.xi=argument_list[3].integer_reference;
9934 if (attribute_flag[4] != 0)
9935 geometry_info.psi=argument_list[4].integer_reference;
9936 if (attribute_flag[5] != 0)
9937 (void) QueryColorCompliance(argument_list[5].string_reference,
9938 AllCompliance,&image->background_color,exception);
9939 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9940 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9944 case 95: /* ContrastStretch */
9951 white_point=(MagickRealType) image->columns*image->rows;
9952 if (attribute_flag[0] != 0)
9954 flags=ParseGeometry(argument_list[0].string_reference,
9956 black_point=geometry_info.rho;
9957 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9959 if ((flags & PercentValue) != 0)
9961 black_point*=(double) image->columns*image->rows/100.0;
9962 white_point*=(double) image->columns*image->rows/100.0;
9964 white_point=(MagickRealType) image->columns*image->rows-
9967 if (attribute_flag[1] != 0)
9968 black_point=argument_list[1].real_reference;
9969 if (attribute_flag[2] != 0)
9970 white_point=argument_list[2].real_reference;
9971 if (attribute_flag[4] != 0)
9972 channel=(ChannelType) argument_list[4].integer_reference;
9973 channel_mask=SetPixelChannelMask(image,channel);
9974 (void) ContrastStretchImage(image,black_point,white_point,exception);
9975 (void) SetPixelChannelMask(image,channel_mask);
9978 case 96: /* Sans0 */
9982 case 97: /* Sans1 */
9986 case 98: /* AdaptiveSharpen */
9988 if (attribute_flag[0] != 0)
9990 flags=ParseGeometry(argument_list[0].string_reference,
9992 if ((flags & SigmaValue) == 0)
9993 geometry_info.sigma=1.0;
9994 if ((flags & XiValue) == 0)
9995 geometry_info.xi=0.0;
9997 if (attribute_flag[1] != 0)
9998 geometry_info.rho=argument_list[1].real_reference;
9999 if (attribute_flag[2] != 0)
10000 geometry_info.sigma=argument_list[2].real_reference;
10001 if (attribute_flag[3] != 0)
10002 geometry_info.xi=argument_list[3].real_reference;
10003 if (attribute_flag[4] != 0)
10004 channel=(ChannelType) argument_list[4].integer_reference;
10005 channel_mask=SetPixelChannelMask(image,channel);
10006 image=AdaptiveSharpenImage(image,geometry_info.rho,
10007 geometry_info.sigma,geometry_info.xi,exception);
10008 if (image != (Image *) NULL)
10009 (void) SetPixelChannelMask(image,channel_mask);
10012 case 99: /* Transpose */
10014 image=TransposeImage(image,exception);
10017 case 100: /* Tranverse */
10019 image=TransverseImage(image,exception);
10022 case 101: /* AutoOrient */
10024 switch (image->orientation)
10026 case TopRightOrientation:
10028 image=FlopImage(image,exception);
10031 case BottomRightOrientation:
10033 image=RotateImage(image,180.0,exception);
10036 case BottomLeftOrientation:
10038 image=FlipImage(image,exception);
10041 case LeftTopOrientation:
10043 image=TransposeImage(image,exception);
10046 case RightTopOrientation:
10048 image=RotateImage(image,90.0,exception);
10051 case RightBottomOrientation:
10053 image=TransverseImage(image,exception);
10056 case LeftBottomOrientation:
10058 image=RotateImage(image,270.0,exception);
10066 case 102: /* AdaptiveBlur */
10068 if (attribute_flag[0] != 0)
10070 flags=ParseGeometry(argument_list[0].string_reference,
10072 if ((flags & SigmaValue) == 0)
10073 geometry_info.sigma=1.0;
10074 if ((flags & XiValue) == 0)
10075 geometry_info.xi=0.0;
10077 if (attribute_flag[1] != 0)
10078 geometry_info.rho=argument_list[1].real_reference;
10079 if (attribute_flag[2] != 0)
10080 geometry_info.sigma=argument_list[2].real_reference;
10081 if (attribute_flag[3] != 0)
10082 geometry_info.xi=argument_list[3].real_reference;
10083 if (attribute_flag[4] != 0)
10084 channel=(ChannelType) argument_list[4].integer_reference;
10085 channel_mask=SetPixelChannelMask(image,channel);
10086 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10087 geometry_info.xi,exception);
10088 if (image != (Image *) NULL)
10089 (void) SetPixelChannelMask(image,channel_mask);
10092 case 103: /* Sketch */
10094 if (attribute_flag[0] != 0)
10096 flags=ParseGeometry(argument_list[0].string_reference,
10098 if ((flags & SigmaValue) == 0)
10099 geometry_info.sigma=1.0;
10100 if ((flags & XiValue) == 0)
10101 geometry_info.xi=1.0;
10103 if (attribute_flag[1] != 0)
10104 geometry_info.rho=argument_list[1].real_reference;
10105 if (attribute_flag[2] != 0)
10106 geometry_info.sigma=argument_list[2].real_reference;
10107 if (attribute_flag[3] != 0)
10108 geometry_info.xi=argument_list[3].real_reference;
10109 if (attribute_flag[4] != 0)
10110 geometry_info.psi=argument_list[4].real_reference;
10111 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10112 geometry_info.xi,geometry_info.psi,exception);
10115 case 104: /* UniqueColors */
10117 image=UniqueImageColors(image,exception);
10120 case 105: /* AdaptiveResize */
10122 PixelInterpolateMethod
10125 if (attribute_flag[0] != 0)
10126 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10127 &geometry,exception);
10128 if (attribute_flag[1] != 0)
10129 geometry.width=argument_list[1].integer_reference;
10130 if (attribute_flag[2] != 0)
10131 geometry.height=argument_list[2].integer_reference;
10132 if (attribute_flag[3] != 0)
10133 image->filter=(FilterTypes) argument_list[4].integer_reference;
10134 if (attribute_flag[4] != 0)
10135 SetImageArtifact(image,"filter:support",
10136 argument_list[4].string_reference);
10137 if (attribute_flag[5] != 0)
10138 image->blur=argument_list[5].real_reference;
10139 method=UndefinedInterpolatePixel;
10140 if (attribute_flag[6] != 0)
10141 method=(PixelInterpolateMethod) argument_list[6].integer_reference;
10142 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10146 case 106: /* ClipMask */
10148 if (attribute_flag[0] == 0)
10150 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10152 goto PerlException;
10154 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10155 MagickTrue,exception);
10156 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10159 case 107: /* LinearStretch */
10166 white_point=(MagickRealType) image->columns*image->rows;
10167 if (attribute_flag[0] != 0)
10169 flags=ParseGeometry(argument_list[0].string_reference,
10171 if ((flags & SigmaValue) != 0)
10172 white_point=geometry_info.sigma;
10173 if ((flags & PercentValue) != 0)
10175 black_point*=(double) image->columns*image->rows/100.0;
10176 white_point*=(double) image->columns*image->rows/100.0;
10178 if ((flags & SigmaValue) == 0)
10179 white_point=(double) image->columns*image->rows-black_point;
10181 if (attribute_flag[1] != 0)
10182 black_point=argument_list[1].real_reference;
10183 if (attribute_flag[2] != 0)
10184 white_point=argument_list[2].real_reference;
10185 (void) LinearStretchImage(image,black_point,white_point,exception);
10188 case 109: /* Mask */
10190 if (attribute_flag[0] == 0)
10192 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10194 goto PerlException;
10196 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10197 MagickTrue,exception);
10198 (void) NegateImage(image->mask,MagickFalse,exception);
10201 case 110: /* Polaroid */
10209 PixelInterpolateMethod
10212 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10213 (DrawInfo *) NULL);
10214 if (attribute_flag[0] != 0)
10215 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10216 info ? info->image_info : (ImageInfo *) NULL,image,
10217 argument_list[0].string_reference,exception),exception);
10219 if (attribute_flag[1] != 0)
10220 angle=argument_list[1].real_reference;
10221 if (attribute_flag[2] != 0)
10222 (void) CloneString(&draw_info->font,
10223 argument_list[2].string_reference);
10224 if (attribute_flag[3] != 0)
10225 (void) QueryColorCompliance(argument_list[3].string_reference,
10226 AllCompliance,&draw_info->stroke,exception);
10227 if (attribute_flag[4] != 0)
10228 (void) QueryColorCompliance(argument_list[4].string_reference,
10229 AllCompliance,&draw_info->fill,exception);
10230 if (attribute_flag[5] != 0)
10231 draw_info->stroke_width=argument_list[5].real_reference;
10232 if (attribute_flag[6] != 0)
10233 draw_info->pointsize=argument_list[6].real_reference;
10234 if (attribute_flag[7] != 0)
10235 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10236 if (attribute_flag[8] != 0)
10237 (void) QueryColorCompliance(argument_list[8].string_reference,
10238 AllCompliance,&image->background_color,exception);
10239 method=UndefinedInterpolatePixel;
10240 if (attribute_flag[9] != 0)
10241 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10242 image=PolaroidImage(image,draw_info,angle,method,exception);
10243 draw_info=DestroyDrawInfo(draw_info);
10246 case 111: /* FloodfillPaint */
10258 virtual_pixel[MaxPixelChannels];
10260 draw_info=CloneDrawInfo(info ? info->image_info :
10261 (ImageInfo *) NULL,(DrawInfo *) NULL);
10262 if (attribute_flag[0] != 0)
10263 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10264 &geometry,exception);
10265 if (attribute_flag[1] != 0)
10266 geometry.x=argument_list[1].integer_reference;
10267 if (attribute_flag[2] != 0)
10268 geometry.y=argument_list[2].integer_reference;
10269 if (attribute_flag[3] != 0)
10270 (void) QueryColorCompliance(argument_list[3].string_reference,
10271 AllCompliance,&draw_info->fill,exception);
10272 (void) GetOneVirtualPixel(image,geometry.x,geometry.y,virtual_pixel,
10274 target.red=virtual_pixel[RedPixelChannel];
10275 target.green=virtual_pixel[GreenPixelChannel];
10276 target.blue=virtual_pixel[BluePixelChannel];
10277 target.alpha=virtual_pixel[AlphaPixelChannel];
10278 if (attribute_flag[4] != 0)
10279 QueryColorCompliance(argument_list[4].string_reference,
10280 AllCompliance,&target,exception);
10281 if (attribute_flag[5] != 0)
10282 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10284 if (attribute_flag[6] != 0)
10285 channel=(ChannelType) argument_list[6].integer_reference;
10286 invert=MagickFalse;
10287 if (attribute_flag[7] != 0)
10288 invert=(MagickBooleanType) argument_list[7].integer_reference;
10289 channel_mask=SetPixelChannelMask(image,channel);
10290 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10291 geometry.y,invert,exception);
10292 (void) SetPixelChannelMask(image,channel_mask);
10293 draw_info=DestroyDrawInfo(draw_info);
10296 case 112: /* Distort */
10308 number_coordinates;
10313 if (attribute_flag[0] == 0)
10315 method=UndefinedDistortion;
10316 if (attribute_flag[1] != 0)
10317 method=(DistortImageMethod) argument_list[1].integer_reference;
10318 av=(AV *) argument_list[0].array_reference;
10319 number_coordinates=(size_t) av_len(av)+1;
10320 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10321 sizeof(*coordinates));
10322 if (coordinates == (double *) NULL)
10324 ThrowPerlException(exception,ResourceLimitFatalError,
10325 "MemoryAllocationFailed",PackageName);
10326 goto PerlException;
10328 for (j=0; j < (ssize_t) number_coordinates; j++)
10329 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10330 virtual_pixel=UndefinedVirtualPixelMethod;
10331 if (attribute_flag[2] != 0)
10332 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10333 argument_list[2].integer_reference);
10334 image=DistortImage(image,method,number_coordinates,coordinates,
10335 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10337 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10338 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10339 coordinates=(double *) RelinquishMagickMemory(coordinates);
10342 case 113: /* Clut */
10344 PixelInterpolateMethod
10347 if (attribute_flag[0] == 0)
10349 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10351 goto PerlException;
10353 method=UndefinedInterpolatePixel;
10354 if (attribute_flag[1] != 0)
10355 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10356 if (attribute_flag[2] != 0)
10357 channel=(ChannelType) argument_list[2].integer_reference;
10358 channel_mask=SetPixelChannelMask(image,channel);
10359 (void) ClutImage(image,argument_list[0].image_reference,method,
10361 (void) SetPixelChannelMask(image,channel_mask);
10364 case 114: /* LiquidRescale */
10366 if (attribute_flag[0] != 0)
10367 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10368 &geometry,exception);
10369 if (attribute_flag[1] != 0)
10370 geometry.width=argument_list[1].integer_reference;
10371 if (attribute_flag[2] != 0)
10372 geometry.height=argument_list[2].integer_reference;
10373 if (attribute_flag[3] == 0)
10374 argument_list[3].real_reference=1.0;
10375 if (attribute_flag[4] == 0)
10376 argument_list[4].real_reference=0.0;
10377 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10378 argument_list[3].real_reference,argument_list[4].real_reference,
10382 case 115: /* EncipherImage */
10384 (void) EncipherImage(image,argument_list[0].string_reference,
10388 case 116: /* DecipherImage */
10390 (void) DecipherImage(image,argument_list[0].string_reference,
10394 case 117: /* Deskew */
10396 geometry_info.rho=QuantumRange/2.0;
10397 if (attribute_flag[0] != 0)
10398 flags=ParseGeometry(argument_list[0].string_reference,
10400 if (attribute_flag[1] != 0)
10401 geometry_info.rho=SiPrefixToDouble(
10402 argument_list[1].string_reference,QuantumRange);
10403 image=DeskewImage(image,geometry_info.rho,exception);
10406 case 118: /* Remap */
10411 if (attribute_flag[0] == 0)
10413 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10415 goto PerlException;
10417 quantize_info=AcquireQuantizeInfo(info->image_info);
10418 if (attribute_flag[1] != 0)
10419 quantize_info->dither=(MagickBooleanType)
10420 argument_list[1].integer_reference;
10421 if (attribute_flag[2] != 0)
10422 quantize_info->dither_method=(DitherMethod)
10423 argument_list[2].integer_reference;
10424 (void) RemapImages(quantize_info,image,
10425 argument_list[0].image_reference,exception);
10426 quantize_info=DestroyQuantizeInfo(quantize_info);
10429 case 119: /* SparseColor */
10441 number_coordinates;
10446 if (attribute_flag[0] == 0)
10448 method=UndefinedColorInterpolate;
10449 if (attribute_flag[1] != 0)
10450 method=(SparseColorMethod) argument_list[1].integer_reference;
10451 av=(AV *) argument_list[0].array_reference;
10452 number_coordinates=(size_t) av_len(av)+1;
10453 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10454 sizeof(*coordinates));
10455 if (coordinates == (double *) NULL)
10457 ThrowPerlException(exception,ResourceLimitFatalError,
10458 "MemoryAllocationFailed",PackageName);
10459 goto PerlException;
10461 for (j=0; j < (ssize_t) number_coordinates; j++)
10462 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10463 virtual_pixel=UndefinedVirtualPixelMethod;
10464 if (attribute_flag[2] != 0)
10465 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10466 argument_list[2].integer_reference);
10467 if (attribute_flag[3] != 0)
10468 channel=(ChannelType) argument_list[3].integer_reference;
10469 channel_mask=SetPixelChannelMask(image,channel);
10470 image=SparseColorImage(image,method,number_coordinates,coordinates,
10472 if (image != (Image *) NULL)
10473 (void) SetPixelChannelMask(image,channel_mask);
10474 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10475 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10476 coordinates=(double *) RelinquishMagickMemory(coordinates);
10479 case 120: /* Function */
10496 if (attribute_flag[0] == 0)
10498 function=UndefinedFunction;
10499 if (attribute_flag[1] != 0)
10500 function=(MagickFunction) argument_list[1].integer_reference;
10501 av=(AV *) argument_list[0].array_reference;
10502 number_parameters=(size_t) av_len(av)+1;
10503 parameters=(double *) AcquireQuantumMemory(number_parameters,
10504 sizeof(*parameters));
10505 if (parameters == (double *) NULL)
10507 ThrowPerlException(exception,ResourceLimitFatalError,
10508 "MemoryAllocationFailed",PackageName);
10509 goto PerlException;
10511 for (j=0; j < (ssize_t) number_parameters; j++)
10512 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10513 virtual_pixel=UndefinedVirtualPixelMethod;
10514 if (attribute_flag[2] != 0)
10515 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10516 argument_list[2].integer_reference);
10517 (void) FunctionImage(image,function,number_parameters,parameters,
10519 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10520 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10521 parameters=(double *) RelinquishMagickMemory(parameters);
10524 case 121: /* SelectiveBlur */
10526 if (attribute_flag[0] != 0)
10528 flags=ParseGeometry(argument_list[0].string_reference,
10530 if ((flags & SigmaValue) == 0)
10531 geometry_info.sigma=1.0;
10532 if ((flags & PercentValue) != 0)
10533 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10535 if (attribute_flag[1] != 0)
10536 geometry_info.rho=argument_list[1].real_reference;
10537 if (attribute_flag[2] != 0)
10538 geometry_info.sigma=argument_list[2].real_reference;
10539 if (attribute_flag[3] != 0)
10540 geometry_info.xi=argument_list[3].integer_reference;;
10541 if (attribute_flag[4] != 0)
10542 geometry_info.psi=argument_list[4].integer_reference;;
10543 if (attribute_flag[5] != 0)
10544 channel=(ChannelType) argument_list[5].integer_reference;
10545 channel_mask=SetPixelChannelMask(image,channel);
10546 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10547 geometry_info.xi,geometry_info.psi,exception);
10548 if (image != (Image *) NULL)
10549 (void) SetPixelChannelMask(image,channel_mask);
10552 case 122: /* HaldClut */
10554 if (attribute_flag[0] == 0)
10556 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10558 goto PerlException;
10560 if (attribute_flag[1] != 0)
10561 channel=(ChannelType) argument_list[1].integer_reference;
10562 channel_mask=SetPixelChannelMask(image,channel);
10563 (void) HaldClutImage(image,argument_list[0].image_reference,
10565 (void) SetPixelChannelMask(image,channel_mask);
10568 case 123: /* BlueShift */
10570 if (attribute_flag[0] != 0)
10571 (void) ParseGeometry(argument_list[0].string_reference,
10573 image=BlueShiftImage(image,geometry_info.rho,exception);
10576 case 124: /* ForwardFourierTransformImage */
10578 image=ForwardFourierTransformImage(image,
10579 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10583 case 125: /* InverseFourierTransformImage */
10585 image=InverseFourierTransformImage(image,image->next,
10586 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10590 case 126: /* ColorDecisionList */
10592 if (attribute_flag[0] == 0)
10593 argument_list[0].string_reference=(char *) NULL;
10594 (void) ColorDecisionListImage(image,
10595 argument_list[0].string_reference,exception);
10598 case 127: /* AutoGamma */
10600 if (attribute_flag[0] != 0)
10601 channel=(ChannelType) argument_list[0].integer_reference;
10602 channel_mask=SetPixelChannelMask(image,channel);
10603 (void) AutoGammaImage(image,exception);
10604 (void) SetPixelChannelMask(image,channel_mask);
10607 case 128: /* AutoLevel */
10609 if (attribute_flag[0] != 0)
10610 channel=(ChannelType) argument_list[0].integer_reference;
10611 channel_mask=SetPixelChannelMask(image,channel);
10612 (void) AutoLevelImage(image,exception);
10613 (void) SetPixelChannelMask(image,channel_mask);
10616 case 129: /* LevelColors */
10622 (void) QueryColorCompliance("#000000",AllCompliance,
10623 &black_point,exception);
10624 (void) QueryColorCompliance("#ffffff",AllCompliance,
10625 &white_point,exception);
10626 if (attribute_flag[1] != 0)
10627 (void) QueryColorCompliance(
10628 argument_list[1].string_reference,AllCompliance,&black_point,
10630 if (attribute_flag[2] != 0)
10631 (void) QueryColorCompliance(
10632 argument_list[2].string_reference,AllCompliance,&white_point,
10634 if (attribute_flag[3] != 0)
10635 channel=(ChannelType) argument_list[3].integer_reference;
10636 channel_mask=SetPixelChannelMask(image,channel);
10637 (void) LevelImageColors(image,&black_point,&white_point,
10638 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10640 (void) SetPixelChannelMask(image,channel_mask);
10643 case 130: /* Clamp */
10645 if (attribute_flag[0] != 0)
10646 channel=(ChannelType) argument_list[0].integer_reference;
10647 channel_mask=SetPixelChannelMask(image,channel);
10648 (void) ClampImage(image,exception);
10649 (void) SetPixelChannelMask(image,channel_mask);
10652 case 132: /* BrightnessContrast */
10660 if (attribute_flag[0] != 0)
10662 flags=ParseGeometry(argument_list[0].string_reference,
10664 brightness=geometry_info.rho;
10665 if ((flags & SigmaValue) == 0)
10666 contrast=geometry_info.sigma;
10668 if (attribute_flag[1] != 0)
10669 brightness=argument_list[1].real_reference;
10670 if (attribute_flag[2] != 0)
10671 contrast=argument_list[2].real_reference;
10672 if (attribute_flag[4] != 0)
10673 channel=(ChannelType) argument_list[4].integer_reference;
10674 channel_mask=SetPixelChannelMask(image,channel);
10675 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10676 (void) SetPixelChannelMask(image,channel_mask);
10679 case 133: /* Morphology */
10690 if (attribute_flag[0] == 0)
10692 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10693 if (kernel == (KernelInfo *) NULL)
10695 if (attribute_flag[1] != 0)
10696 channel=(ChannelType) argument_list[1].integer_reference;
10697 method=UndefinedMorphology;
10698 if (attribute_flag[2] != 0)
10699 method=argument_list[2].integer_reference;
10701 if (attribute_flag[3] != 0)
10702 iterations=argument_list[4].integer_reference;
10703 channel_mask=SetPixelChannelMask(image,channel);
10704 image=MorphologyImage(image,method,iterations,kernel,exception);
10705 if (image != (Image *) NULL)
10706 (void) SetPixelChannelMask(image,channel_mask);
10707 kernel=DestroyKernelInfo(kernel);
10710 case 108: /* Recolor */
10711 case 134: /* ColorMatrix */
10725 if (attribute_flag[0] == 0)
10727 av=(AV *) argument_list[0].array_reference;
10728 if (av == (AV *) NULL)
10730 order=(size_t) sqrt(av_len(av)+1);
10731 color_matrix=(double *) AcquireQuantumMemory(order,order*
10732 sizeof(*color_matrix));
10733 if (color_matrix == (double *) NULL)
10735 ThrowPerlException(exception,ResourceLimitFatalError,
10736 "MemoryAllocationFailed",PackageName);
10737 goto PerlException;
10739 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10740 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10741 for ( ; j < (ssize_t) (order*order); j++)
10742 color_matrix[j]=0.0;
10743 kernel_info=AcquireKernelInfo((const char *) NULL);
10744 if (kernel_info == (KernelInfo *) NULL)
10746 kernel_info->width=order;
10747 kernel_info->height=order;
10748 kernel_info->values=color_matrix;
10749 image=ColorMatrixImage(image,kernel_info,exception);
10750 kernel_info->values=(double *) NULL;
10751 kernel_info=DestroyKernelInfo(kernel_info);
10752 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10755 case 135: /* Color */
10760 (void) QueryColorCompliance("none",AllCompliance,&color,
10762 if (attribute_flag[0] != 0)
10763 (void) QueryColorCompliance(argument_list[0].string_reference,
10764 AllCompliance,&color,exception);
10765 (void) SetImageColor(image,&color);
10768 case 136: /* Mode */
10770 if (attribute_flag[0] != 0)
10772 flags=ParseGeometry(argument_list[0].string_reference,
10774 if ((flags & SigmaValue) == 0)
10775 geometry_info.sigma=1.0;
10777 if (attribute_flag[1] != 0)
10778 geometry_info.rho=argument_list[1].real_reference;
10779 if (attribute_flag[2] != 0)
10780 geometry_info.sigma=argument_list[2].real_reference;
10781 if (attribute_flag[3] != 0)
10782 channel=(ChannelType) argument_list[3].integer_reference;
10783 channel_mask=SetPixelChannelMask(image,channel);
10784 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10785 (size_t) geometry_info.sigma,exception);
10786 if (image != (Image *) NULL)
10787 (void) SetPixelChannelMask(image,channel_mask);
10790 case 137: /* Statistic */
10795 statistic=UndefinedStatistic;
10796 if (attribute_flag[0] != 0)
10798 flags=ParseGeometry(argument_list[0].string_reference,
10800 if ((flags & SigmaValue) == 0)
10801 geometry_info.sigma=1.0;
10803 if (attribute_flag[1] != 0)
10804 geometry_info.rho=argument_list[1].real_reference;
10805 if (attribute_flag[2] != 0)
10806 geometry_info.sigma=argument_list[2].real_reference;
10807 if (attribute_flag[3] != 0)
10808 channel=(ChannelType) argument_list[3].integer_reference;
10809 if (attribute_flag[4] != 0)
10810 statistic=(StatisticType) argument_list[4].integer_reference;
10811 channel_mask=SetPixelChannelMask(image,channel);
10812 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10813 (size_t) geometry_info.sigma,exception);
10814 if (image != (Image *) NULL)
10815 (void) SetPixelChannelMask(image,channel_mask);
10819 if (next != (Image *) NULL)
10820 (void) CatchImageException(next);
10821 if (region_image != (Image *) NULL)
10826 status=CompositeImage(region_image,CopyCompositeOp,image,
10827 region_info.x,region_info.y);
10829 (void) CatchImageException(region_image);
10830 image=DestroyImage(image);
10831 image=region_image;
10833 if (image != (Image *) NULL)
10836 if (next && (next != image))
10838 image->next=next->next;
10839 if (image->next != (Image *) NULL)
10840 image->next->previous=image;
10841 DeleteImageFromRegistry(*pv,next);
10843 sv_setiv(*pv,(IV) image);
10851 if (reference_vector)
10852 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10853 InheritPerlException(exception,perl_exception);
10854 exception=DestroyExceptionInfo(exception);
10855 sv_setiv(perl_exception,(IV) number_images);
10856 SvPOK_on(perl_exception);
10857 ST(0)=sv_2mortal(perl_exception);
10862 ###############################################################################
10870 ###############################################################################
10875 Image::Magick ref=NO_INIT
10920 PERL_UNUSED_VAR(ref);
10921 PERL_UNUSED_VAR(ix);
10922 exception=AcquireExceptionInfo();
10923 perl_exception=newSVpv("",0);
10926 if (sv_isobject(ST(0)) == 0)
10928 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10930 goto PerlException;
10932 reference=SvRV(ST(0));
10933 hv=SvSTASH(reference);
10935 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10937 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10938 if (image == (Image *) NULL)
10940 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10942 goto PerlException;
10947 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10948 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10949 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
10951 for (i=2; i < items; i+=2)
10953 attribute=(char *) SvPV(ST(i-1),na);
10954 switch (*attribute)
10959 if (LocaleCompare(attribute,"background") == 0)
10961 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
10962 &montage_info->background_color,exception);
10963 for (next=image; next; next=next->next)
10964 next->background_color=montage_info->background_color;
10967 if (LocaleCompare(attribute,"border") == 0)
10969 montage_info->border_width=SvIV(ST(i));
10972 if (LocaleCompare(attribute,"bordercolor") == 0)
10974 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
10975 &montage_info->border_color,exception);
10976 for (next=image; next; next=next->next)
10977 next->border_color=montage_info->border_color;
10980 if (LocaleCompare(attribute,"borderwidth") == 0)
10982 montage_info->border_width=SvIV(ST(i));
10985 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10992 if (LocaleCompare(attribute,"compose") == 0)
10994 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10995 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10998 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11002 for (next=image; next; next=next->next)
11003 next->compose=(CompositeOperator) sp;
11006 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11013 if (LocaleCompare(attribute,"fill") == 0)
11015 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11016 &montage_info->fill,exception);
11019 if (LocaleCompare(attribute,"font") == 0)
11021 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11024 if (LocaleCompare(attribute,"frame") == 0)
11030 if (IsGeometry(p) == MagickFalse)
11032 ThrowPerlException(exception,OptionError,"MissingGeometry",
11036 (void) CloneString(&montage_info->frame,p);
11038 montage_info->frame=(char *) NULL;
11041 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11048 if (LocaleCompare(attribute,"geometry") == 0)
11054 if (IsGeometry(p) == MagickFalse)
11056 ThrowPerlException(exception,OptionError,"MissingGeometry",
11060 (void) CloneString(&montage_info->geometry,p);
11062 montage_info->geometry=(char *) NULL;
11065 if (LocaleCompare(attribute,"gravity") == 0)
11070 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11071 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11074 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11078 montage_info->gravity=(GravityType) in;
11079 for (next=image; next; next=next->next)
11080 next->gravity=(GravityType) in;
11083 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11090 if (LocaleCompare(attribute,"label") == 0)
11092 for (next=image; next; next=next->next)
11093 (void) SetImageProperty(next,"label",InterpretImageProperties(
11094 info ? info->image_info : (ImageInfo *) NULL,next,
11095 SvPV(ST(i),na),exception),exception);
11098 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11105 if (LocaleCompare(attribute,"mattecolor") == 0)
11107 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11108 &montage_info->matte_color,exception);
11109 for (next=image; next; next=next->next)
11110 next->matte_color=montage_info->matte_color;
11113 if (LocaleCompare(attribute,"mode") == 0)
11118 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11119 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11124 ThrowPerlException(exception,OptionError,
11125 "UnrecognizedModeType",SvPV(ST(i),na));
11130 (void) CloneString(&montage_info->frame,"15x15+3+3");
11131 montage_info->shadow=MagickTrue;
11136 montage_info->frame=(char *) NULL;
11137 montage_info->shadow=MagickFalse;
11138 montage_info->border_width=0;
11141 case ConcatenateMode:
11143 montage_info->frame=(char *) NULL;
11144 montage_info->shadow=MagickFalse;
11145 (void) CloneString(&montage_info->geometry,"+0+0");
11146 montage_info->border_width=0;
11151 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11158 if (LocaleCompare(attribute,"pointsize") == 0)
11160 montage_info->pointsize=SvIV(ST(i));
11163 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11170 if (LocaleCompare(attribute,"shadow") == 0)
11172 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11173 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11176 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11180 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11183 if (LocaleCompare(attribute,"stroke") == 0)
11185 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11186 &montage_info->stroke,exception);
11189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11196 if (LocaleCompare(attribute,"texture") == 0)
11198 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11201 if (LocaleCompare(attribute,"tile") == 0)
11203 char *p=SvPV(ST(i),na);
11204 if (IsGeometry(p) == MagickFalse)
11206 ThrowPerlException(exception,OptionError,"MissingGeometry",
11210 (void) CloneString(&montage_info->tile,p);
11212 montage_info->tile=(char *) NULL;
11215 if (LocaleCompare(attribute,"title") == 0)
11217 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11220 if (LocaleCompare(attribute,"transparent") == 0)
11225 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11226 &transparent_color,exception);
11227 for (next=image; next; next=next->next)
11228 (void) TransparentPaintImage(next,&transparent_color,
11229 TransparentAlpha,MagickFalse,exception);
11232 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11238 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11244 image=MontageImageList(info->image_info,montage_info,image,exception);
11245 montage_info=DestroyMontageInfo(montage_info);
11246 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11247 goto PerlException;
11248 if (transparent_color.alpha != TransparentAlpha)
11249 for (next=image; next; next=next->next)
11250 (void) TransparentPaintImage(next,&transparent_color,
11251 TransparentAlpha,MagickFalse,exception);
11252 for ( ; image; image=image->next)
11254 AddImageToRegistry(sv,image);
11256 av_push(av,sv_bless(rv,hv));
11259 exception=DestroyExceptionInfo(exception);
11260 ST(0)=av_reference;
11261 SvREFCNT_dec(perl_exception);
11265 InheritPerlException(exception,perl_exception);
11266 exception=DestroyExceptionInfo(exception);
11267 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11268 SvPOK_on(perl_exception);
11269 ST(0)=sv_2mortal(perl_exception);
11274 ###############################################################################
11282 ###############################################################################
11287 Image::Magick ref=NO_INIT
11325 PERL_UNUSED_VAR(ref);
11326 PERL_UNUSED_VAR(ix);
11327 exception=AcquireExceptionInfo();
11328 perl_exception=newSVpv("",0);
11332 if (sv_isobject(ST(0)) == 0)
11334 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11336 goto PerlException;
11338 reference=SvRV(ST(0));
11339 hv=SvSTASH(reference);
11341 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11343 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11344 if (image == (Image *) NULL)
11346 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11348 goto PerlException;
11350 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11355 for (i=2; i < items; i+=2)
11357 attribute=(char *) SvPV(ST(i-1),na);
11358 switch (*attribute)
11363 if (LocaleCompare(attribute,"frames") == 0)
11365 number_frames=SvIV(ST(i));
11368 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11374 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11380 image=MorphImages(image,number_frames,exception);
11381 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11382 goto PerlException;
11383 for ( ; image; image=image->next)
11385 AddImageToRegistry(sv,image);
11387 av_push(av,sv_bless(rv,hv));
11390 exception=DestroyExceptionInfo(exception);
11391 ST(0)=av_reference;
11392 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11396 InheritPerlException(exception,perl_exception);
11397 exception=DestroyExceptionInfo(exception);
11398 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11399 SvPOK_on(perl_exception);
11400 ST(0)=sv_2mortal(perl_exception);
11405 ###############################################################################
11413 ###############################################################################
11418 Image::Magick ref=NO_INIT
11446 PERL_UNUSED_VAR(ref);
11447 PERL_UNUSED_VAR(ix);
11448 exception=AcquireExceptionInfo();
11449 perl_exception=newSVpv("",0);
11451 if (sv_isobject(ST(0)) == 0)
11453 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11455 goto PerlException;
11457 reference=SvRV(ST(0));
11458 hv=SvSTASH(reference);
11459 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11460 if (image == (Image *) NULL)
11462 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11464 goto PerlException;
11466 image=MergeImageLayers(image,MosaicLayer,exception);
11468 Create blessed Perl array for the returned image.
11471 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11473 AddImageToRegistry(sv,image);
11475 av_push(av,sv_bless(rv,hv));
11477 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11478 (void) CopyMagickString(info->image_info->filename,image->filename,
11480 SetImageInfo(info->image_info,0,&image->exception);
11481 exception=DestroyExceptionInfo(exception);
11482 SvREFCNT_dec(perl_exception);
11486 InheritPerlException(exception,perl_exception);
11487 exception=DestroyExceptionInfo(exception);
11488 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11489 SvPOK_on(perl_exception); /* return messages in string context */
11490 ST(0)=sv_2mortal(perl_exception);
11495 ###############################################################################
11503 ###############################################################################
11508 Image::Magick ref=NO_INIT
11558 PERL_UNUSED_VAR(ref);
11559 PERL_UNUSED_VAR(ix);
11560 exception=AcquireExceptionInfo();
11561 perl_exception=newSVpv("",0);
11562 package_info=(struct PackageInfo *) NULL;
11563 ac=(items < 2) ? 1 : items-1;
11564 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11566 length=(STRLEN *) NULL;
11567 if (list == (char **) NULL)
11569 ThrowPerlException(exception,ResourceLimitError,
11570 "MemoryAllocationFailed",PackageName);
11571 goto PerlException;
11574 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11575 if (length == (STRLEN *) NULL)
11577 ThrowPerlException(exception,ResourceLimitError,
11578 "MemoryAllocationFailed",PackageName);
11579 goto PerlException;
11581 if (sv_isobject(ST(0)) == 0)
11583 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11585 goto PerlException;
11587 reference=SvRV(ST(0));
11588 if (SvTYPE(reference) != SVt_PVAV)
11590 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11592 goto PerlException;
11594 av=(AV *) reference;
11595 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11597 package_info=ClonePackageInfo(info,exception);
11600 *list=(char *) (*package_info->image_info->filename ?
11601 package_info->image_info->filename : "XC:black");
11603 for (n=0, i=0; i < ac; i++)
11605 list[n]=(char *) SvPV(ST(i+1),length[n]);
11606 if ((items >= 3) && strEQcase(list[n],"blob"))
11612 blob=(void *) (SvPV(ST(i+1),length[n]));
11613 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11615 if ((items >= 3) && strEQcase(list[n],"filename"))
11617 if ((items >= 3) && strEQcase(list[n],"file"))
11626 io_info=IoIFP(sv_2io(ST(i+1)));
11627 if (io_info == (PerlIO *) NULL)
11629 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11633 file=PerlIO_findFILE(io_info);
11634 if (file == (FILE *) NULL)
11636 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11640 SetImageInfoFile(package_info->image_info,file);
11642 if ((items >= 3) && strEQcase(list[n],"magick"))
11646 list[n]=(char *) NULL;
11648 status=ExpandFilenames(&n,&list);
11649 if (status == MagickFalse)
11651 ThrowPerlException(exception,ResourceLimitError,
11652 "MemoryAllocationFailed",PackageName);
11653 goto PerlException;
11656 for (i=0; i < n; i++)
11658 (void) CopyMagickString(package_info->image_info->filename,list[i],
11660 image=PingImage(package_info->image_info,exception);
11661 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11663 if ((package_info->image_info->file != (FILE *) NULL) ||
11664 (package_info->image_info->blob != (void *) NULL))
11665 DisassociateImageStream(image);
11666 count+=GetImageListLength(image);
11667 EXTEND(sp,4*count);
11668 for (next=image; next; next=next->next)
11670 PUSHs(sv_2mortal(newSViv(next->columns)));
11671 PUSHs(sv_2mortal(newSViv(next->rows)));
11672 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11673 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11675 image=DestroyImageList(image);
11680 for (i=0; i < n; i++)
11681 if (list[i] != (char *) NULL)
11682 for (p=keep; list[i] != *p++; )
11685 list[i]=(char *) RelinquishMagickMemory(list[i]);
11690 if (package_info != (struct PackageInfo *) NULL)
11691 DestroyPackageInfo(package_info);
11692 if (list && (list != keep))
11693 list=(char **) RelinquishMagickMemory(list);
11695 keep=(char **) RelinquishMagickMemory(keep);
11697 length=(STRLEN *) RelinquishMagickMemory(length);
11698 InheritPerlException(exception,perl_exception);
11699 exception=DestroyExceptionInfo(exception);
11700 SvREFCNT_dec(perl_exception); /* throw away all errors */
11704 ###############################################################################
11712 ###############################################################################
11717 Image::Magick ref=NO_INIT
11750 PERL_UNUSED_VAR(ref);
11751 PERL_UNUSED_VAR(ix);
11752 exception=AcquireExceptionInfo();
11753 perl_exception=newSVpv("",0);
11756 if (sv_isobject(ST(0)) == 0)
11758 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11760 goto PerlException;
11762 reference=SvRV(ST(0));
11763 hv=SvSTASH(reference);
11765 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11767 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11768 if (image == (Image *) NULL)
11770 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11772 goto PerlException;
11774 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11775 preview_type=GammaPreview;
11777 preview_type=(PreviewType)
11778 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11779 for ( ; image; image=image->next)
11781 preview_image=PreviewImage(image,preview_type,exception);
11782 if (preview_image == (Image *) NULL)
11783 goto PerlException;
11784 AddImageToRegistry(sv,preview_image);
11786 av_push(av,sv_bless(rv,hv));
11789 exception=DestroyExceptionInfo(exception);
11790 ST(0)=av_reference;
11791 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11795 InheritPerlException(exception,perl_exception);
11796 exception=DestroyExceptionInfo(exception);
11797 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11798 SvPOK_on(perl_exception);
11799 ST(0)=sv_2mortal(perl_exception);
11804 ###############################################################################
11808 # Q u e r y C o l o r #
11812 ###############################################################################
11816 QueryColor(ref,...)
11817 Image::Magick ref=NO_INIT
11837 PERL_UNUSED_VAR(ref);
11838 PERL_UNUSED_VAR(ix);
11839 exception=AcquireExceptionInfo();
11840 perl_exception=newSVpv("",0);
11849 colorlist=GetColorInfoList("*",&colors,exception);
11851 for (i=0; i < (ssize_t) colors; i++)
11853 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11855 colorlist=(const ColorInfo **)
11856 RelinquishMagickMemory((ColorInfo **) colorlist);
11857 goto PerlException;
11859 EXTEND(sp,5*items);
11860 for (i=1; i < items; i++)
11862 name=(char *) SvPV(ST(i),na);
11863 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
11868 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11869 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11870 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11871 if (color.colorspace == CMYKColorspace)
11872 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11873 if (color.matte != MagickFalse)
11874 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11878 InheritPerlException(exception,perl_exception);
11879 exception=DestroyExceptionInfo(exception);
11880 SvREFCNT_dec(perl_exception);
11884 ###############################################################################
11888 # Q u e r y C o l o r N a m e #
11892 ###############################################################################
11896 QueryColorname(ref,...)
11897 Image::Magick ref=NO_INIT
11906 message[MaxTextExtent];
11925 *reference; /* reference is the SV* of ref=SvIV(reference) */
11927 PERL_UNUSED_VAR(ref);
11928 PERL_UNUSED_VAR(ix);
11929 exception=AcquireExceptionInfo();
11930 perl_exception=newSVpv("",0);
11931 reference=SvRV(ST(0));
11932 av=(AV *) reference;
11933 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11935 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11936 if (image == (Image *) NULL)
11938 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11940 goto PerlException;
11943 for (i=1; i < items; i++)
11945 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
11947 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11949 PUSHs(sv_2mortal(newSVpv(message,0)));
11953 InheritPerlException(exception,perl_exception);
11954 exception=DestroyExceptionInfo(exception);
11955 SvREFCNT_dec(perl_exception);
11959 ###############################################################################
11963 # Q u e r y F o n t #
11967 ###############################################################################
11972 Image::Magick ref=NO_INIT
11979 message[MaxTextExtent];
11990 volatile const TypeInfo
11993 PERL_UNUSED_VAR(ref);
11994 PERL_UNUSED_VAR(ix);
11995 exception=AcquireExceptionInfo();
11996 perl_exception=newSVpv("",0);
12005 typelist=GetTypeInfoList("*",&types,exception);
12007 for (i=0; i < (ssize_t) types; i++)
12009 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12011 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12013 goto PerlException;
12015 EXTEND(sp,10*items);
12016 for (i=1; i < items; i++)
12018 name=(char *) SvPV(ST(i),na);
12019 type_info=GetTypeInfo(name,exception);
12020 if (type_info == (TypeInfo *) NULL)
12025 if (type_info->name == (char *) NULL)
12028 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12029 if (type_info->description == (char *) NULL)
12032 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12033 if (type_info->family == (char *) NULL)
12036 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12037 if (type_info->style == UndefinedStyle)
12040 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12041 type_info->style),0)));
12042 if (type_info->stretch == UndefinedStretch)
12045 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12046 type_info->stretch),0)));
12047 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12048 type_info->weight);
12049 PUSHs(sv_2mortal(newSVpv(message,0)));
12050 if (type_info->encoding == (char *) NULL)
12053 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12054 if (type_info->foundry == (char *) NULL)
12057 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12058 if (type_info->format == (char *) NULL)
12061 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12062 if (type_info->metrics == (char *) NULL)
12065 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12066 if (type_info->glyphs == (char *) NULL)
12069 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12073 InheritPerlException(exception,perl_exception);
12074 exception=DestroyExceptionInfo(exception);
12075 SvREFCNT_dec(perl_exception);
12079 ###############################################################################
12083 # Q u e r y F o n t M e t r i c s #
12087 ###############################################################################
12091 QueryFontMetrics(ref,...)
12092 Image::Magick ref=NO_INIT
12094 queryfontmetrics = 1
12141 *reference; /* reference is the SV* of ref=SvIV(reference) */
12146 PERL_UNUSED_VAR(ref);
12147 PERL_UNUSED_VAR(ix);
12148 exception=AcquireExceptionInfo();
12149 package_info=(struct PackageInfo *) NULL;
12150 perl_exception=newSVpv("",0);
12151 reference=SvRV(ST(0));
12152 av=(AV *) reference;
12153 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12155 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12156 if (image == (Image *) NULL)
12158 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12160 goto PerlException;
12162 package_info=ClonePackageInfo(info,exception);
12163 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12164 CloneString(&draw_info->text,"");
12165 current=draw_info->affine;
12166 GetAffineMatrix(&affine);
12169 EXTEND(sp,7*items);
12170 for (i=2; i < items; i+=2)
12172 attribute=(char *) SvPV(ST(i-1),na);
12173 switch (*attribute)
12178 if (LocaleCompare(attribute,"antialias") == 0)
12180 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12184 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12188 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12191 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12198 if (LocaleCompare(attribute,"density") == 0)
12200 CloneString(&draw_info->density,SvPV(ST(i),na));
12203 if (LocaleCompare(attribute,"direction") == 0)
12205 draw_info->direction=(DirectionType) ParseCommandOption(
12206 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12209 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12216 if (LocaleCompare(attribute,"encoding") == 0)
12218 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12221 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12228 if (LocaleCompare(attribute,"family") == 0)
12230 CloneString(&draw_info->family,SvPV(ST(i),na));
12233 if (LocaleCompare(attribute,"fill") == 0)
12236 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12237 &draw_info->fill,&image->exception);
12240 if (LocaleCompare(attribute,"font") == 0)
12242 CloneString(&draw_info->font,SvPV(ST(i),na));
12245 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12252 if (LocaleCompare(attribute,"geometry") == 0)
12254 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12257 if (LocaleCompare(attribute,"gravity") == 0)
12259 draw_info->gravity=(GravityType) ParseCommandOption(
12260 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12263 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12270 if (LocaleCompare(attribute,"interline-spacing") == 0)
12272 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12273 draw_info->interline_spacing=geometry_info.rho;
12276 if (LocaleCompare(attribute,"interword-spacing") == 0)
12278 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12279 draw_info->interword_spacing=geometry_info.rho;
12282 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12289 if (LocaleCompare(attribute,"kerning") == 0)
12291 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12292 draw_info->kerning=geometry_info.rho;
12295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12302 if (LocaleCompare(attribute,"pointsize") == 0)
12304 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12305 draw_info->pointsize=geometry_info.rho;
12308 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12315 if (LocaleCompare(attribute,"rotate") == 0)
12317 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12318 affine.rx=geometry_info.rho;
12319 affine.ry=geometry_info.sigma;
12320 if ((flags & SigmaValue) == 0)
12321 affine.ry=affine.rx;
12324 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12331 if (LocaleCompare(attribute,"scale") == 0)
12333 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12334 affine.sx=geometry_info.rho;
12335 affine.sy=geometry_info.sigma;
12336 if ((flags & SigmaValue) == 0)
12337 affine.sy=affine.sx;
12340 if (LocaleCompare(attribute,"skew") == 0)
12346 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12347 x_angle=geometry_info.rho;
12348 y_angle=geometry_info.sigma;
12349 if ((flags & SigmaValue) == 0)
12351 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12352 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12355 if (LocaleCompare(attribute,"stroke") == 0)
12358 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12359 &draw_info->stroke,&image->exception);
12362 if (LocaleCompare(attribute,"style") == 0)
12364 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12368 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12372 draw_info->style=(StyleType) type;
12375 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12382 if (LocaleCompare(attribute,"text") == 0)
12384 CloneString(&draw_info->text,SvPV(ST(i),na));
12387 if (LocaleCompare(attribute,"translate") == 0)
12389 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12390 affine.tx=geometry_info.rho;
12391 affine.ty=geometry_info.sigma;
12392 if ((flags & SigmaValue) == 0)
12393 affine.ty=affine.tx;
12396 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12403 if (LocaleCompare(attribute,"weight") == 0)
12405 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12406 draw_info->weight=(size_t) geometry_info.rho;
12409 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12416 if (LocaleCompare(attribute,"x") == 0)
12418 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12419 x=geometry_info.rho;
12422 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12429 if (LocaleCompare(attribute,"y") == 0)
12431 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12432 y=geometry_info.rho;
12435 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12441 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12447 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12448 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12449 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12450 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12451 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12452 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12453 if (draw_info->geometry == (char *) NULL)
12455 draw_info->geometry=AcquireString((char *) NULL);
12456 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12457 "%.15g,%.15g",x,y);
12459 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12460 (void) CatchImageException(image);
12461 if (status == MagickFalse)
12465 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12466 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12467 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12468 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12469 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12470 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12471 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12472 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12473 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12474 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12475 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12476 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12477 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12479 draw_info=DestroyDrawInfo(draw_info);
12482 if (package_info != (struct PackageInfo *) NULL)
12483 DestroyPackageInfo(package_info);
12484 InheritPerlException(exception,perl_exception);
12485 exception=DestroyExceptionInfo(exception);
12486 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12490 ###############################################################################
12494 # 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 #
12498 ###############################################################################
12502 QueryMultilineFontMetrics(ref,...)
12503 Image::Magick ref=NO_INIT
12505 querymultilinefontmetrics = 1
12552 *reference; /* reference is the SV* of ref=SvIV(reference) */
12557 PERL_UNUSED_VAR(ref);
12558 PERL_UNUSED_VAR(ix);
12559 exception=AcquireExceptionInfo();
12560 package_info=(struct PackageInfo *) NULL;
12561 perl_exception=newSVpv("",0);
12562 reference=SvRV(ST(0));
12563 av=(AV *) reference;
12564 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12566 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12567 if (image == (Image *) NULL)
12569 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12571 goto PerlException;
12573 package_info=ClonePackageInfo(info,exception);
12574 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12575 CloneString(&draw_info->text,"");
12576 current=draw_info->affine;
12577 GetAffineMatrix(&affine);
12580 EXTEND(sp,7*items);
12581 for (i=2; i < items; i+=2)
12583 attribute=(char *) SvPV(ST(i-1),na);
12584 switch (*attribute)
12589 if (LocaleCompare(attribute,"antialias") == 0)
12591 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12595 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12599 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12602 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12609 if (LocaleCompare(attribute,"density") == 0)
12611 CloneString(&draw_info->density,SvPV(ST(i),na));
12614 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12621 if (LocaleCompare(attribute,"encoding") == 0)
12623 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12626 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12633 if (LocaleCompare(attribute,"family") == 0)
12635 CloneString(&draw_info->family,SvPV(ST(i),na));
12638 if (LocaleCompare(attribute,"fill") == 0)
12641 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12642 &draw_info->fill,&image->exception);
12645 if (LocaleCompare(attribute,"font") == 0)
12647 CloneString(&draw_info->font,SvPV(ST(i),na));
12650 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12657 if (LocaleCompare(attribute,"geometry") == 0)
12659 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12662 if (LocaleCompare(attribute,"gravity") == 0)
12664 draw_info->gravity=(GravityType) ParseCommandOption(
12665 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12668 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12675 if (LocaleCompare(attribute,"pointsize") == 0)
12677 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12678 draw_info->pointsize=geometry_info.rho;
12681 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12688 if (LocaleCompare(attribute,"rotate") == 0)
12690 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12691 affine.rx=geometry_info.rho;
12692 affine.ry=geometry_info.sigma;
12693 if ((flags & SigmaValue) == 0)
12694 affine.ry=affine.rx;
12697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12704 if (LocaleCompare(attribute,"scale") == 0)
12706 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12707 affine.sx=geometry_info.rho;
12708 affine.sy=geometry_info.sigma;
12709 if ((flags & SigmaValue) == 0)
12710 affine.sy=affine.sx;
12713 if (LocaleCompare(attribute,"skew") == 0)
12719 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12720 x_angle=geometry_info.rho;
12721 y_angle=geometry_info.sigma;
12722 if ((flags & SigmaValue) == 0)
12724 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12725 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12728 if (LocaleCompare(attribute,"stroke") == 0)
12731 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12732 &draw_info->stroke,&image->exception);
12735 if (LocaleCompare(attribute,"style") == 0)
12737 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12741 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12745 draw_info->style=(StyleType) type;
12748 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12755 if (LocaleCompare(attribute,"text") == 0)
12757 CloneString(&draw_info->text,SvPV(ST(i),na));
12760 if (LocaleCompare(attribute,"translate") == 0)
12762 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12763 affine.tx=geometry_info.rho;
12764 affine.ty=geometry_info.sigma;
12765 if ((flags & SigmaValue) == 0)
12766 affine.ty=affine.tx;
12769 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12776 if (LocaleCompare(attribute,"weight") == 0)
12778 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12779 draw_info->weight=(size_t) geometry_info.rho;
12782 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12789 if (LocaleCompare(attribute,"x") == 0)
12791 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12792 x=geometry_info.rho;
12795 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12802 if (LocaleCompare(attribute,"y") == 0)
12804 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12805 y=geometry_info.rho;
12808 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12814 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12820 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12821 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12822 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12823 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12824 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12825 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12826 if (draw_info->geometry == (char *) NULL)
12828 draw_info->geometry=AcquireString((char *) NULL);
12829 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12830 "%.15g,%.15g",x,y);
12832 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12833 (void) CatchException(exception);
12834 if (status == MagickFalse)
12838 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12839 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12840 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12841 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12842 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12843 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12844 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12845 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12846 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12847 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12848 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12849 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12850 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12852 draw_info=DestroyDrawInfo(draw_info);
12855 if (package_info != (struct PackageInfo *) NULL)
12856 DestroyPackageInfo(package_info);
12857 InheritPerlException(exception,perl_exception);
12858 exception=DestroyExceptionInfo(exception);
12859 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12863 ###############################################################################
12867 # Q u e r y F o r m a t #
12871 ###############################################################################
12875 QueryFormat(ref,...)
12876 Image::Magick ref=NO_INIT
12893 volatile const MagickInfo
12896 PERL_UNUSED_VAR(ref);
12897 PERL_UNUSED_VAR(ix);
12898 exception=AcquireExceptionInfo();
12899 perl_exception=newSVpv("",0);
12903 format[MaxTextExtent];
12911 format_list=GetMagickInfoList("*",&types,exception);
12913 for (i=0; i < (ssize_t) types; i++)
12915 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12916 LocaleLower(format);
12917 PUSHs(sv_2mortal(newSVpv(format,0)));
12919 format_list=(const MagickInfo **)
12920 RelinquishMagickMemory((MagickInfo *) format_list);
12921 goto PerlException;
12923 EXTEND(sp,8*items);
12924 for (i=1; i < items; i++)
12926 name=(char *) SvPV(ST(i),na);
12927 magick_info=GetMagickInfo(name,exception);
12928 if (magick_info == (const MagickInfo *) NULL)
12933 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12934 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12935 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12936 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12937 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12938 if (magick_info->description == (char *) NULL)
12941 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12942 if (magick_info->module == (char *) NULL)
12945 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12949 InheritPerlException(exception,perl_exception);
12950 exception=DestroyExceptionInfo(exception);
12951 SvREFCNT_dec(perl_exception);
12955 ###############################################################################
12959 # Q u e r y O p t i o n #
12963 ###############################################################################
12967 QueryOption(ref,...)
12968 Image::Magick ref=NO_INIT
12989 PERL_UNUSED_VAR(ref);
12990 PERL_UNUSED_VAR(ix);
12991 exception=AcquireExceptionInfo();
12992 perl_exception=newSVpv("",0);
12993 EXTEND(sp,8*items);
12994 for (i=1; i < items; i++)
12996 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12998 options=GetCommandOptions((CommandOption) option);
12999 if (options == (char **) NULL)
13003 for (j=0; options[j] != (char *) NULL; j++)
13004 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13005 options=DestroyStringList(options);
13009 InheritPerlException(exception,perl_exception);
13010 exception=DestroyExceptionInfo(exception);
13011 SvREFCNT_dec(perl_exception);
13015 ###############################################################################
13023 ###############################################################################
13028 Image::Magick ref=NO_INIT
13075 *perl_exception, /* Perl variable for storing messages */
13080 PERL_UNUSED_VAR(ref);
13081 PERL_UNUSED_VAR(ix);
13082 exception=AcquireExceptionInfo();
13083 perl_exception=newSVpv("",0);
13085 package_info=(struct PackageInfo *) NULL;
13087 ac=(items < 2) ? 1 : items-1;
13088 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13090 length=(STRLEN *) NULL;
13091 if (list == (char **) NULL)
13093 ThrowPerlException(exception,ResourceLimitError,
13094 "MemoryAllocationFailed",PackageName);
13095 goto PerlException;
13097 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13098 if (length == (STRLEN *) NULL)
13100 ThrowPerlException(exception,ResourceLimitError,
13101 "MemoryAllocationFailed",PackageName);
13102 goto PerlException;
13104 if (sv_isobject(ST(0)) == 0)
13106 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13108 goto PerlException;
13110 reference=SvRV(ST(0));
13111 hv=SvSTASH(reference);
13112 if (SvTYPE(reference) != SVt_PVAV)
13114 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13116 goto PerlException;
13118 av=(AV *) reference;
13119 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13121 package_info=ClonePackageInfo(info,exception);
13124 *list=(char *) (*package_info->image_info->filename ?
13125 package_info->image_info->filename : "XC:black");
13127 for (n=0, i=0; i < ac; i++)
13129 list[n]=(char *) SvPV(ST(i+1),length[n]);
13130 if ((items >= 3) && strEQcase(list[n],"blob"))
13136 blob=(void *) (SvPV(ST(i+1),length[n]));
13137 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13139 if ((items >= 3) && strEQcase(list[n],"filename"))
13141 if ((items >= 3) && strEQcase(list[n],"file"))
13150 io_info=IoIFP(sv_2io(ST(i+1)));
13151 if (io_info == (PerlIO *) NULL)
13153 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13157 file=PerlIO_findFILE(io_info);
13158 if (file == (FILE *) NULL)
13160 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13164 SetImageInfoFile(package_info->image_info,file);
13166 if ((items >= 3) && strEQcase(list[n],"magick"))
13170 list[n]=(char *) NULL;
13172 status=ExpandFilenames(&n,&list);
13173 if (status == MagickFalse)
13175 ThrowPerlException(exception,ResourceLimitError,
13176 "MemoryAllocationFailed",PackageName);
13177 goto PerlException;
13180 for (i=0; i < n; i++)
13182 if ((package_info->image_info->file != (FILE *) NULL) ||
13183 (package_info->image_info->blob != (void *) NULL))
13185 image=ReadImages(package_info->image_info,exception);
13186 if (image != (Image *) NULL)
13187 DisassociateImageStream(image);
13191 (void) CopyMagickString(package_info->image_info->filename,list[i],
13193 image=ReadImages(package_info->image_info,exception);
13195 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13197 for ( ; image; image=image->next)
13199 AddImageToRegistry(sv,image);
13201 av_push(av,sv_bless(rv,hv));
13209 for (i=0; i < n; i++)
13210 if (list[i] != (char *) NULL)
13211 for (p=keep; list[i] != *p++; )
13212 if (*p == (char *) NULL)
13214 list[i]=(char *) RelinquishMagickMemory(list[i]);
13219 if (package_info != (struct PackageInfo *) NULL)
13220 DestroyPackageInfo(package_info);
13221 if (list && (list != keep))
13222 list=(char **) RelinquishMagickMemory(list);
13224 keep=(char **) RelinquishMagickMemory(keep);
13226 length=(STRLEN *) RelinquishMagickMemory(length);
13227 InheritPerlException(exception,perl_exception);
13228 exception=DestroyExceptionInfo(exception);
13229 sv_setiv(perl_exception,(IV) number_images);
13230 SvPOK_on(perl_exception);
13231 ST(0)=sv_2mortal(perl_exception);
13236 ###############################################################################
13244 ###############################################################################
13249 Image::Magick ref=NO_INIT
13272 PERL_UNUSED_VAR(ref);
13273 PERL_UNUSED_VAR(ix);
13274 exception=AcquireExceptionInfo();
13275 perl_exception=newSVpv("",0);
13276 reference=SvRV(ST(0));
13277 av=(AV *) reference;
13278 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13280 for (i=1; i < items; i++)
13281 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13282 SvPV(ST(i),na),exception);
13283 InheritPerlException(exception,perl_exception);
13284 exception=DestroyExceptionInfo(exception);
13285 SvREFCNT_dec(perl_exception); /* throw away all errors */
13289 ###############################################################################
13297 ###############################################################################
13302 Image::Magick ref=NO_INIT
13325 *reference; /* reference is the SV* of ref=SvIV(reference) */
13327 PERL_UNUSED_VAR(ref);
13328 PERL_UNUSED_VAR(ix);
13329 exception=AcquireExceptionInfo();
13330 perl_exception=newSVpv("",0);
13331 if (sv_isobject(ST(0)) == 0)
13333 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13335 goto PerlException;
13337 reference=SvRV(ST(0));
13338 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13340 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13342 for (i=2; i < items; i+=2)
13343 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13346 InheritPerlException(exception,perl_exception);
13347 exception=DestroyExceptionInfo(exception);
13348 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13349 SvPOK_on(perl_exception);
13350 ST(0)=sv_2mortal(perl_exception);
13355 ###############################################################################
13359 # S e t P i x e l #
13363 ###############################################################################
13368 Image::Magick ref=NO_INIT
13410 *reference; /* reference is the SV* of ref=SvIV(reference) */
13412 PERL_UNUSED_VAR(ref);
13413 PERL_UNUSED_VAR(ix);
13414 exception=AcquireExceptionInfo();
13415 perl_exception=newSVpv("",0);
13416 reference=SvRV(ST(0));
13417 av=(AV *) reference;
13418 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13420 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13421 if (image == (Image *) NULL)
13423 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13425 goto PerlException;
13428 normalize=MagickTrue;
13431 region.width=image->columns;
13434 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13435 channel=DefaultChannels;
13436 for (i=2; i < items; i+=2)
13438 attribute=(char *) SvPV(ST(i-1),na);
13439 switch (*attribute)
13444 if (LocaleCompare(attribute,"channel") == 0)
13449 option=ParseChannelOption(SvPV(ST(i),na));
13452 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13456 channel=(ChannelType) option;
13459 if (LocaleCompare(attribute,"color") == 0)
13461 if (SvTYPE(ST(i)) != SVt_RV)
13464 message[MaxTextExtent];
13466 (void) FormatLocaleString(message,MaxTextExtent,
13467 "invalid %.60s value",attribute);
13468 ThrowPerlException(exception,OptionError,message,
13471 av=(AV *) SvRV(ST(i));
13474 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13481 if (LocaleCompare(attribute,"geometry") == 0)
13483 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13486 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13493 if (LocaleCompare(attribute,"normalize") == 0)
13495 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13499 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13503 normalize=option != 0 ? MagickTrue : MagickFalse;
13506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13513 if (LocaleCompare(attribute,"x") == 0)
13515 region.x=SvIV(ST(i));
13518 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13525 if (LocaleCompare(attribute,"y") == 0)
13527 region.y=SvIV(ST(i));
13530 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13536 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13542 (void) SetImageStorageClass(image,DirectClass,exception);
13543 channel_mask=SetPixelChannelMask(image,channel);
13544 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13545 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13546 (SvTYPE(av) != SVt_PVAV))
13558 if (normalize != MagickFalse)
13559 scale=QuantumRange;
13560 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13563 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13564 av_fetch(av,i,0)))),q);
13567 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13570 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13571 av_fetch(av,i,0)))),q);
13574 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13577 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13578 av_fetch(av,i,0)))),q);
13581 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13582 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13584 SetPixelBlack(image,ClampToQuantum(scale*
13585 SvNV(*(av_fetch(av,i,0)))),q);
13588 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13591 SetPixelAlpha(image,ClampToQuantum(scale*
13592 SvNV(*(av_fetch(av,i,0)))),q);
13595 (void) SyncAuthenticPixels(image,exception);
13597 (void) SetPixelChannelMask(image,channel_mask);
13600 InheritPerlException(exception,perl_exception);
13601 exception=DestroyExceptionInfo(exception);
13602 SvREFCNT_dec(perl_exception);
13606 ###############################################################################
13614 ###############################################################################
13619 Image::Magick ref=NO_INIT
13658 PERL_UNUSED_VAR(ref);
13659 PERL_UNUSED_VAR(ix);
13660 exception=AcquireExceptionInfo();
13661 perl_exception=newSVpv("",0);
13665 if (sv_isobject(ST(0)) == 0)
13667 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13669 goto PerlException;
13671 reference=SvRV(ST(0));
13672 hv=SvSTASH(reference);
13674 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13676 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13677 if (image == (Image *) NULL)
13679 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13681 goto PerlException;
13683 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13689 for (i=2; i < items; i+=2)
13691 attribute=(char *) SvPV(ST(i-1),na);
13692 switch (*attribute)
13697 if (LocaleCompare(attribute,"offset") == 0)
13699 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13709 if (LocaleCompare(attribute,"stack") == 0)
13711 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13715 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13721 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13727 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13733 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13735 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13736 goto PerlException;
13737 for ( ; image; image=image->next)
13739 AddImageToRegistry(sv,image);
13741 av_push(av,sv_bless(rv,hv));
13744 exception=DestroyExceptionInfo(exception);
13745 ST(0)=av_reference;
13746 SvREFCNT_dec(perl_exception);
13750 InheritPerlException(exception,perl_exception);
13751 exception=DestroyExceptionInfo(exception);
13752 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13753 SvPOK_on(perl_exception);
13754 ST(0)=sv_2mortal(perl_exception);
13759 ###############################################################################
13763 # S t a t i s t i c s #
13767 ###############################################################################
13771 Statistics(ref,...)
13772 Image::Magick ref=NO_INIT
13774 StatisticsImage = 1
13776 statisticsimage = 3
13779 #define ChannelStatistics(channel) \
13781 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13782 (double) channel_statistics[channel].depth); \
13783 PUSHs(sv_2mortal(newSVpv(message,0))); \
13784 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13785 channel_statistics[channel].minima/scale); \
13786 PUSHs(sv_2mortal(newSVpv(message,0))); \
13787 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13788 channel_statistics[channel].maxima/scale); \
13789 PUSHs(sv_2mortal(newSVpv(message,0))); \
13790 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13791 channel_statistics[channel].mean/scale); \
13792 PUSHs(sv_2mortal(newSVpv(message,0))); \
13793 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13794 channel_statistics[channel].standard_deviation/scale); \
13795 PUSHs(sv_2mortal(newSVpv(message,0))); \
13796 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13797 channel_statistics[channel].kurtosis); \
13798 PUSHs(sv_2mortal(newSVpv(message,0))); \
13799 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13800 channel_statistics[channel].skewness); \
13801 PUSHs(sv_2mortal(newSVpv(message,0))); \
13808 message[MaxTextExtent];
13811 *channel_statistics;
13832 PERL_UNUSED_VAR(ref);
13833 PERL_UNUSED_VAR(ix);
13834 exception=AcquireExceptionInfo();
13835 perl_exception=newSVpv("",0);
13837 if (sv_isobject(ST(0)) == 0)
13839 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13841 goto PerlException;
13843 reference=SvRV(ST(0));
13846 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13847 if (image == (Image *) NULL)
13849 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13851 goto PerlException;
13853 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13855 for ( ; image; image=image->next)
13857 channel_statistics=GetImageStatistics(image,&image->exception);
13858 if (channel_statistics == (ChannelStatistics *) NULL)
13861 EXTEND(sp,35*count);
13862 scale=(double) QuantumRange;
13863 ChannelStatistics(RedChannel);
13864 ChannelStatistics(GreenChannel);
13865 ChannelStatistics(BlueChannel);
13866 if (image->colorspace == CMYKColorspace)
13867 ChannelStatistics(BlackChannel);
13868 if (image->matte != MagickFalse)
13869 ChannelStatistics(AlphaChannel);
13870 channel_statistics=(ChannelStatistics *)
13871 RelinquishMagickMemory(channel_statistics);
13875 InheritPerlException(exception,perl_exception);
13876 exception=DestroyExceptionInfo(exception);
13877 SvREFCNT_dec(perl_exception);
13881 ###############################################################################
13885 # S y n c A u t h e n t i c P i x e l s #
13889 ###############################################################################
13893 SyncAuthenticPixels(ref,...)
13894 Image::Magick ref = NO_INIT
13896 Syncauthenticpixels = 1
13897 SyncImagePixels = 2
13898 syncimagepixels = 3
13917 PERL_UNUSED_VAR(ref);
13918 PERL_UNUSED_VAR(ix);
13919 exception=AcquireExceptionInfo();
13920 perl_exception=newSVpv("",0);
13921 if (sv_isobject(ST(0)) == 0)
13923 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13925 goto PerlException;
13928 reference=SvRV(ST(0));
13929 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13930 if (image == (Image *) NULL)
13932 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13934 goto PerlException;
13937 status=SyncAuthenticPixels(image,exception);
13938 if (status != MagickFalse)
13940 InheritException(exception,&image->exception);
13943 InheritPerlException(exception,perl_exception);
13944 exception=DestroyExceptionInfo(exception);
13945 SvREFCNT_dec(perl_exception); /* throw away all errors */
13949 ###############################################################################
13953 # T r a n s f o r m #
13957 ###############################################################################
13962 Image::Magick ref=NO_INIT
14000 PERL_UNUSED_VAR(ref);
14001 PERL_UNUSED_VAR(ix);
14002 exception=AcquireExceptionInfo();
14003 perl_exception=newSVpv("",0);
14007 if (sv_isobject(ST(0)) == 0)
14009 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14011 goto PerlException;
14013 reference=SvRV(ST(0));
14014 hv=SvSTASH(reference);
14016 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14018 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14019 if (image == (Image *) NULL)
14021 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14023 goto PerlException;
14025 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14029 crop_geometry=(char *) NULL;
14030 geometry=(char *) NULL;
14031 for (i=2; i < items; i+=2)
14033 attribute=(char *) SvPV(ST(i-1),na);
14034 switch (*attribute)
14039 if (LocaleCompare(attribute,"crop") == 0)
14041 crop_geometry=SvPV(ST(i),na);
14044 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14051 if (LocaleCompare(attribute,"geometry") == 0)
14053 geometry=SvPV(ST(i),na);
14056 if (LocaleCompare(attribute,"gravity") == 0)
14064 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
14065 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
14068 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14072 for (next=image; next; next=next->next)
14073 next->gravity=(GravityType) in;
14076 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14082 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14088 for ( ; image; image=image->next)
14090 clone=CloneImage(image,0,0,MagickTrue,exception);
14091 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
14092 goto PerlException;
14093 TransformImage(&clone,crop_geometry,geometry);
14094 for ( ; clone; clone=clone->next)
14096 AddImageToRegistry(sv,clone);
14098 av_push(av,sv_bless(rv,hv));
14102 exception=DestroyExceptionInfo(exception);
14103 ST(0)=av_reference;
14104 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14108 InheritPerlException(exception,perl_exception);
14109 exception=DestroyExceptionInfo(exception);
14110 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14111 SvPOK_on(perl_exception);
14112 ST(0)=sv_2mortal(perl_exception);
14117 ###############################################################################
14125 ###############################################################################
14130 Image::Magick ref=NO_INIT
14138 filename[MaxTextExtent];
14162 PERL_UNUSED_VAR(ref);
14163 PERL_UNUSED_VAR(ix);
14164 exception=AcquireExceptionInfo();
14165 perl_exception=newSVpv("",0);
14167 package_info=(struct PackageInfo *) NULL;
14168 if (sv_isobject(ST(0)) == 0)
14170 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14172 goto PerlException;
14174 reference=SvRV(ST(0));
14175 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14176 if (image == (Image *) NULL)
14178 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14180 goto PerlException;
14182 package_info=ClonePackageInfo(info,exception);
14184 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14187 for (i=2; i < items; i+=2)
14188 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14190 (void) CopyMagickString(filename,package_info->image_info->filename,
14193 for (next=image; next; next=next->next)
14195 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14196 next->scene=scene++;
14198 SetImageInfo(package_info->image_info,(unsigned int)
14199 GetImageListLength(image),&image->exception);
14200 for (next=image; next; next=next->next)
14202 (void) WriteImage(package_info->image_info,next,exception);
14204 if (package_info->image_info->adjoin)
14209 if (package_info != (struct PackageInfo *) NULL)
14210 DestroyPackageInfo(package_info);
14211 InheritPerlException(exception,perl_exception);
14212 exception=DestroyExceptionInfo(exception);
14213 sv_setiv(perl_exception,(IV) number_images);
14214 SvPOK_on(perl_exception);
14215 ST(0)=sv_2mortal(perl_exception);