2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv((IV) image); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"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}, {"opacity", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"opacity", RealReference},
440 {"sigma", RealReference}, {"x", IntegerReference},
441 {"y", IntegerReference} } },
442 { "Identify", { {"file", FileReference}, {"features", StringReference},
443 {"unique", MagickBooleanOptions} } },
444 { "SepiaTone", { {"threshold", RealReference} } },
445 { "SigmoidalContrast", { {"geometry", StringReference},
446 {"contrast", RealReference}, {"mid-point", RealReference},
447 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
448 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
449 {"height", IntegerReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"fuzz", StringReference},
451 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
452 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
453 {"sigma", RealReference}, {"x", IntegerReference},
454 {"y", IntegerReference}, {"background", StringReference} } },
455 { "ContrastStretch", { {"levels", StringReference},
456 {"black-point", RealReference},{"white-point", RealReference},
457 {"channel", MagickChannelOptions} } },
460 { "AdaptiveSharpen", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
466 { "AdaptiveBlur", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
469 { "Sketch", { {"geometry", StringReference},
470 {"radius", RealReference}, {"sigma", RealReference},
471 {"angle", RealReference}, {"bias", RealReference} } },
473 { "AdaptiveResize", { {"geometry", StringReference},
474 {"width", IntegerReference}, {"height", IntegerReference},
475 {"filter", MagickFilterOptions}, {"support", StringReference },
476 {"blur", RealReference }, {"interpolate", MagickInterpolateOptions} } },
477 { "ClipMask", { {"mask", ImageReference} } },
478 { "LinearStretch", { {"levels", StringReference},
479 {"black-point", RealReference},{"white-point", RealReference} } },
480 { "Recolor", { {"matrix", ArrayReference} } },
481 { "Mask", { {"mask", ImageReference} } },
482 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
483 {"font", StringReference}, {"stroke", StringReference},
484 {"fill", StringReference}, {"strokewidth", RealReference},
485 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
486 {"background", StringReference},
487 {"interpolate", MagickInterpolateOptions} } },
488 { "FloodfillPaint", { {"geometry", StringReference},
489 {"x", IntegerReference}, {"y", IntegerReference},
490 {"fill", StringReference}, {"bordercolor", StringReference},
491 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
492 {"invert", MagickBooleanOptions} } },
493 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
494 {"virtual-pixel", MagickVirtualPixelOptions},
495 {"best-fit", MagickBooleanOptions} } },
496 { "Clut", { {"image", ImageReference},
497 {"interpolate", MagickInterpolateOptions},
498 {"channel", MagickChannelOptions} } },
499 { "LiquidRescale", { {"geometry", StringReference},
500 {"width", IntegerReference}, {"height", IntegerReference},
501 {"delta-x", RealReference}, {"rigidity", RealReference } } },
502 { "Encipher", { {"passphrase", StringReference} } },
503 { "Decipher", { {"passphrase", StringReference} } },
504 { "Deskew", { {"geometry", StringReference},
505 {"threshold", StringReference} } },
506 { "Remap", { {"image", ImageReference}, {"dither", MagickBooleanOptions},
507 {"dither-method", MagickDitherOptions} } },
508 { "SparseColor", { {"points", ArrayReference},
509 {"method", MagickSparseColorOptions},
510 {"virtual-pixel", MagickVirtualPixelOptions},
511 {"channel", MagickChannelOptions} } },
512 { "Function", { {"parameters", ArrayReference},
513 {"function", MagickFunctionOptions},
514 {"virtual-pixel", MagickVirtualPixelOptions} } },
515 { "SelectiveBlur", { {"geometry", StringReference},
516 {"radius", RealReference}, {"sigma", RealReference},
517 {"threshold", RealReference}, {"bias", RealReference},
518 {"channel", MagickChannelOptions} } },
519 { "HaldClut", { {"image", ImageReference},
520 {"channel", MagickChannelOptions} } },
521 { "BlueShift", { {"factor", StringReference} } },
522 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
523 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
524 { "ColorDecisionList", {
525 {"color-correction-collection", StringReference} } },
526 { "AutoGamma", { {"channel", MagickChannelOptions} } },
527 { "AutoLevel", { {"channel", MagickChannelOptions} } },
528 { "LevelColors", { {"invert", MagickBooleanOptions},
529 {"black-point", StringReference}, {"white-point", StringReference},
530 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
531 { "Clamp", { {"channel", MagickChannelOptions} } },
532 { "BrightnessContrast", { {"levels", StringReference},
533 {"brightness", RealReference},{"contrast", RealReference},
534 {"channel", MagickChannelOptions} } },
535 { "Morphology", { {"kernel", StringReference},
536 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
537 {"iterations", IntegerReference} } },
538 { "ColorMatrix", { {"matrix", ArrayReference} } },
539 { "Color", { {"color", StringReference} } },
540 { "Mode", { {"geometry", StringReference},
541 {"width", IntegerReference},{"height", IntegerReference},
542 {"channel", MagickChannelOptions} } },
543 { "Statistic", { {"geometry", StringReference},
544 {"width", IntegerReference},{"height", IntegerReference},
545 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } }
549 *magick_registry = (SplayTreeInfo *) NULL;
552 Forward declarations.
555 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
558 strEQcase(const char *,const char *);
561 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
565 % C l o n e P a c k a g e I n f o %
569 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
571 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
574 % The format of the ClonePackageInfo routine is:
576 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
579 % A description of each parameter follows:
581 % o info: a structure of type info.
583 % o exception: Return any errors or warnings in this structure.
586 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
587 ExceptionInfo *exception)
592 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
593 if (clone_info == (struct PackageInfo *) NULL)
595 ThrowPerlException(exception,ResourceLimitError,
596 "UnableToClonePackageInfo",PackageName);
597 return((struct PackageInfo *) NULL);
599 if (info == (struct PackageInfo *) NULL)
601 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
605 clone_info->image_info=CloneImageInfo(info->image_info);
610 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
620 % constant() returns a double value for the specified name.
622 % The format of the constant routine is:
624 % double constant(char *name,ssize_t sans)
626 % A description of each parameter follows:
628 % o value: Method constant returns a double value for the specified name.
630 % o name: The name of the constant.
632 % o sans: This integer value is not used.
635 static double constant(char *name,ssize_t sans)
643 if (strEQ(name,"BlobError"))
645 if (strEQ(name,"BlobWarning"))
651 if (strEQ(name,"CacheError"))
653 if (strEQ(name,"CacheWarning"))
654 return(CacheWarning);
655 if (strEQ(name,"CoderError"))
657 if (strEQ(name,"CoderWarning"))
658 return(CoderWarning);
659 if (strEQ(name,"ConfigureError"))
660 return(ConfigureError);
661 if (strEQ(name,"ConfigureWarning"))
662 return(ConfigureWarning);
663 if (strEQ(name,"CorruptImageError"))
664 return(CorruptImageError);
665 if (strEQ(name,"CorruptImageWarning"))
666 return(CorruptImageWarning);
671 if (strEQ(name,"DelegateError"))
672 return(DelegateError);
673 if (strEQ(name,"DelegateWarning"))
674 return(DelegateWarning);
675 if (strEQ(name,"DrawError"))
677 if (strEQ(name,"DrawWarning"))
683 if (strEQ(name,"ErrorException"))
684 return(ErrorException);
685 if (strEQ(name,"ExceptionError"))
687 if (strEQ(name,"ExceptionWarning"))
688 return(CoderWarning);
693 if (strEQ(name,"FatalErrorException"))
694 return(FatalErrorException);
695 if (strEQ(name,"FileOpenError"))
696 return(FileOpenError);
697 if (strEQ(name,"FileOpenWarning"))
698 return(FileOpenWarning);
703 if (strEQ(name,"ImageError"))
705 if (strEQ(name,"ImageWarning"))
706 return(ImageWarning);
711 if (strEQ(name,"MaxRGB"))
712 return(QuantumRange);
713 if (strEQ(name,"MissingDelegateError"))
714 return(MissingDelegateError);
715 if (strEQ(name,"MissingDelegateWarning"))
716 return(MissingDelegateWarning);
717 if (strEQ(name,"ModuleError"))
719 if (strEQ(name,"ModuleWarning"))
720 return(ModuleWarning);
725 if (strEQ(name,"Opaque"))
727 if (strEQ(name,"OptionError"))
729 if (strEQ(name,"OptionWarning"))
730 return(OptionWarning);
735 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
736 return(MAGICKCORE_QUANTUM_DEPTH);
737 if (strEQ(name,"QuantumDepth"))
738 return(MAGICKCORE_QUANTUM_DEPTH);
739 if (strEQ(name,"QuantumRange"))
740 return(QuantumRange);
745 if (strEQ(name,"ResourceLimitError"))
746 return(ResourceLimitError);
747 if (strEQ(name,"ResourceLimitWarning"))
748 return(ResourceLimitWarning);
749 if (strEQ(name,"RegistryError"))
750 return(RegistryError);
751 if (strEQ(name,"RegistryWarning"))
752 return(RegistryWarning);
757 if (strEQ(name,"StreamError"))
759 if (strEQ(name,"StreamWarning"))
760 return(StreamWarning);
761 if (strEQ(name,"Success"))
767 if (strEQ(name,"Transparent"))
768 return(TransparentAlpha);
769 if (strEQ(name,"TypeError"))
771 if (strEQ(name,"TypeWarning"))
777 if (strEQ(name,"WarningException"))
778 return(WarningException);
783 if (strEQ(name,"XServerError"))
784 return(XServerError);
785 if (strEQ(name,"XServerWarning"))
786 return(XServerWarning);
795 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
799 % D e s t r o y P a c k a g e I n f o %
803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
805 % Method DestroyPackageInfo frees a previously created info structure.
807 % The format of the DestroyPackageInfo routine is:
809 % DestroyPackageInfo(struct PackageInfo *info)
811 % A description of each parameter follows:
813 % o info: a structure of type info.
816 static void DestroyPackageInfo(struct PackageInfo *info)
818 info->image_info=DestroyImageInfo(info->image_info);
819 info=(struct PackageInfo *) RelinquishMagickMemory(info);
823 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
831 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
833 % Method GetList is recursively called by SetupList to traverse the
834 % Image__Magick reference. If building an reference_vector (see SetupList),
835 % *current is the current position in *reference_vector and *last is the final
836 % entry in *reference_vector.
838 % The format of the GetList routine is:
842 % A description of each parameter follows:
844 % o info: a structure of type info.
847 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
848 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
853 if (reference == (SV *) NULL)
855 switch (SvTYPE(reference))
875 previous=(Image *) NULL;
879 for (i=0; i <= n; i++)
885 if (rv && *rv && sv_isobject(*rv))
887 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
889 if (image == (Image *) NULL)
891 if (image == previous)
893 image=CloneImage(image,0,0,MagickTrue,exception);
894 if (image == (Image *) NULL)
897 image->previous=previous;
898 *(previous ? &previous->next : &head)=image;
899 for (previous=image; previous->next; previous=previous->next) ;
907 Blessed scalar, one image.
909 image=(Image *) SvIV(reference);
910 if (image == (Image *) NULL)
912 image->previous=(Image *) NULL;
913 image->next=(Image *) NULL;
914 if (reference_vector)
916 if (*current == *last)
919 if (*reference_vector == (SV **) NULL)
920 *reference_vector=(SV **) AcquireQuantumMemory(*last,
921 sizeof(*reference_vector));
923 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
924 *last,sizeof(*reference_vector));
926 if (*reference_vector == (SV **) NULL)
928 ThrowPerlException(exception,ResourceLimitError,
929 "MemoryAllocationFailed",PackageName);
930 return((Image *) NULL);
932 (*reference_vector)[*current]=reference;
933 (*reference_vector)[++(*current)]=NULL;
940 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
941 (double) SvTYPE(reference));
942 return((Image *) NULL);
946 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
950 % G e t P a c k a g e I n f o %
954 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
956 % Method GetPackageInfo looks up or creates an info structure for the given
957 % Image__Magick reference. If it does create a new one, the information in
958 % package_info is used to initialize it.
960 % The format of the GetPackageInfo routine is:
962 % struct PackageInfo *GetPackageInfo(void *reference,
963 % struct PackageInfo *package_info,ExceptionInfo *exception)
965 % A description of each parameter follows:
967 % o info: a structure of type info.
969 % o exception: Return any errors or warnings in this structure.
972 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
973 struct PackageInfo *package_info,ExceptionInfo *exception)
976 message[MaxTextExtent];
984 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
985 PackageName,XS_VERSION,reference);
986 sv=perl_get_sv(message,(TRUE | 0x02));
987 if (sv == (SV *) NULL)
989 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
991 return(package_info);
993 if (SvREFCNT(sv) == 0)
994 (void) SvREFCNT_inc(sv);
995 if (SvIOKp(sv) && (clone_info=(struct PackageInfo *) SvIV(sv)))
997 clone_info=ClonePackageInfo(package_info,exception);
998 sv_setiv(sv,(IV) clone_info);
1003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 % S e t A t t r i b u t e %
1011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1013 % SetAttribute() sets the attribute to the value in sval. This can change
1014 % either or both of image or info.
1016 % The format of the SetAttribute routine is:
1018 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1019 % SV *sval,ExceptionInfo *exception)
1021 % A description of each parameter follows:
1023 % o list: a list of strings.
1025 % o string: a character string.
1029 static double SiPrefixToDouble(const char *string,const double interval)
1038 value=InterpretLocaleValue(string,&q);
1040 if ((*q != '\0') && (tolower((int) ((unsigned char) *(q+1))) == 'i'))
1042 switch (tolower((int) ((unsigned char) *q)))
1044 case '%': value*=pow(scale,0)*interval/100.0; break;
1045 case 'k': value*=pow(scale,1); break;
1046 case 'm': value*=pow(scale,2); break;
1047 case 'g': value*=pow(scale,3); break;
1048 case 't': value*=pow(scale,4); break;
1049 case 'p': value*=pow(scale,5); break;
1050 case 'e': value*=pow(scale,6); break;
1051 case 'z': value*=pow(scale,7); break;
1052 case 'y': value*=pow(scale,8); break;
1058 static inline ssize_t StringToLong(const char *value)
1060 return(strtol(value,(char **) NULL,10));
1063 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1064 const char *attribute,SV *sval,ExceptionInfo *exception)
1091 if (LocaleCompare(attribute,"adjoin") == 0)
1093 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1094 SvPV(sval,na)) : SvIV(sval);
1097 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1102 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1105 if (LocaleCompare(attribute,"alpha") == 0)
1107 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaOptions,MagickFalse,
1108 SvPV(sval,na)) : SvIV(sval);
1111 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1115 for ( ; image; image=image->next)
1116 (void) SetImageAlphaChannel(image,(AlphaChannelType) sp,exception);
1119 if (LocaleCompare(attribute,"antialias") == 0)
1121 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1122 SvPV(sval,na)) : SvIV(sval);
1125 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1130 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1133 if (LocaleCompare(attribute,"area-limit") == 0)
1138 limit=MagickResourceInfinity;
1139 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1140 limit=(MagickSizeType) SiPrefixToDouble(SvPV(sval,na),100.0);
1141 (void) SetMagickResourceLimit(AreaResource,limit);
1144 if (LocaleCompare(attribute,"attenuate") == 0)
1147 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1150 if (LocaleCompare(attribute,"authenticate") == 0)
1153 (void) CloneString(&info->image_info->authenticate,SvPV(sval,na));
1157 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1158 for ( ; image; image=image->next)
1159 SetImageProperty(image,attribute,SvPV(sval,na));
1165 if (LocaleCompare(attribute,"background") == 0)
1167 (void) 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));
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));
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));
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));
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));
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));
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));
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));
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));
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));
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));
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));
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 QueryMagickColorCompliance(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));
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));
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));
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));
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));
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));
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));
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));
2222 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2223 for ( ; image; image=image->next)
2224 SetImageProperty(image,attribute,SvPV(sval,na));
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);
4287 if (value != (const char *) NULL)
4289 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4292 if (LocaleCompare(attribute,"authenticate") == 0)
4295 s=newSVpv(info->image_info->authenticate,0);
4296 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4299 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4306 if (LocaleCompare(attribute,"background") == 0)
4308 if (image == (Image *) NULL)
4310 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4311 QuantumFormat "," QuantumFormat "," QuantumFormat,
4312 image->background_color.red,image->background_color.green,
4313 image->background_color.blue,image->background_color.alpha);
4315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4318 if (LocaleCompare(attribute,"base-columns") == 0)
4320 if (image != (Image *) NULL)
4321 s=newSViv((ssize_t) image->magick_columns);
4322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4325 if (LocaleCompare(attribute,"base-filename") == 0)
4327 if (image != (Image *) NULL)
4328 s=newSVpv(image->magick_filename,0);
4329 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4332 if (LocaleCompare(attribute,"base-height") == 0)
4334 if (image != (Image *) NULL)
4335 s=newSViv((ssize_t) image->magick_rows);
4336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4339 if (LocaleCompare(attribute,"base-rows") == 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-width") == 0)
4348 if (image != (Image *) NULL)
4349 s=newSViv((ssize_t) image->magick_columns);
4350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4353 if (LocaleCompare(attribute,"bias") == 0)
4355 if (image != (Image *) NULL)
4356 s=newSVnv(image->bias);
4357 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4360 if (LocaleCompare(attribute,"blue-primary") == 0)
4362 if (image == (Image *) NULL)
4364 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4365 image->chromaticity.blue_primary.x,
4366 image->chromaticity.blue_primary.y);
4368 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4371 if (LocaleCompare(attribute,"bordercolor") == 0)
4373 if (image == (Image *) NULL)
4375 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4376 QuantumFormat "," QuantumFormat "," QuantumFormat,
4377 image->border_color.red,image->border_color.green,
4378 image->border_color.blue,image->border_color.alpha);
4380 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4383 if (LocaleCompare(attribute,"bounding-box") == 0)
4386 geometry[MaxTextExtent];
4391 if (image == (Image *) NULL)
4393 page=GetImageBoundingBox(image,&image->exception);
4394 (void) FormatLocaleString(geometry,MaxTextExtent,
4395 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4396 page.height,(double) page.x,(double) page.y);
4397 s=newSVpv(geometry,0);
4398 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4401 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4408 if (LocaleCompare(attribute,"class") == 0)
4410 if (image == (Image *) NULL)
4412 s=newSViv(image->storage_class);
4413 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4414 image->storage_class));
4416 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4419 if (LocaleCompare(attribute,"clip-mask") == 0)
4421 if (image != (Image *) NULL)
4427 if (image->mask == (Image *) NULL)
4428 ClipImage(image,exception);
4429 if (image->mask != (Image *) NULL)
4431 AddImageToRegistry(sv,image->mask);
4432 s=sv_bless(newRV(sv),SvSTASH(reference));
4435 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4438 if (LocaleCompare(attribute,"clip-path") == 0)
4440 if (image != (Image *) NULL)
4446 if (image->clip_mask == (Image *) NULL)
4447 ClipImage(image,exception);
4448 if (image->clip_mask != (Image *) NULL)
4450 AddImageToRegistry(sv,image->clip_mask);
4451 s=sv_bless(newRV(sv),SvSTASH(reference));
4454 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4457 if (LocaleCompare(attribute,"compression") == 0)
4459 j=info ? info->image_info->compression : image ?
4460 image->compression : UndefinedCompression;
4462 if (info->image_info->compression == UndefinedCompression)
4463 j=image->compression;
4465 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4468 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4471 if (LocaleCompare(attribute,"colorspace") == 0)
4473 j=image ? image->colorspace : RGBColorspace;
4475 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4478 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4481 if (LocaleCompare(attribute,"colors") == 0)
4483 if (image != (Image *) NULL)
4484 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4485 &image->exception));
4486 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4489 if (LocaleNCompare(attribute,"colormap",8) == 0)
4494 if (image == (Image *) NULL || !image->colormap)
4497 items=sscanf(attribute,"%*[^[][%ld",&j);
4499 if (j > (ssize_t) image->colors)
4501 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4502 QuantumFormat "," QuantumFormat "," QuantumFormat,
4503 image->colormap[j].red,image->colormap[j].green,
4504 image->colormap[j].blue,image->colormap[j].alpha);
4506 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4509 if (LocaleCompare(attribute,"columns") == 0)
4511 if (image != (Image *) NULL)
4512 s=newSViv((ssize_t) image->columns);
4513 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4516 if (LocaleCompare(attribute,"comment") == 0)
4521 value=GetImageProperty(image,attribute);
4522 if (value != (const char *) NULL)
4524 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4527 if (LocaleCompare(attribute,"copyright") == 0)
4529 s=newSVpv(GetMagickCopyright(),0);
4530 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4533 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4540 if (LocaleCompare(attribute,"density") == 0)
4543 geometry[MaxTextExtent];
4545 if (image == (Image *) NULL)
4547 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4548 image->x_resolution,image->y_resolution);
4549 s=newSVpv(geometry,0);
4550 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4553 if (LocaleCompare(attribute,"delay") == 0)
4555 if (image != (Image *) NULL)
4556 s=newSViv((ssize_t) image->delay);
4557 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4560 if (LocaleCompare(attribute,"depth") == 0)
4562 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4563 if (image != (Image *) NULL)
4564 s=newSViv((ssize_t) GetImageDepth(image,&image->exception));
4565 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4568 if (LocaleCompare(attribute,"directory") == 0)
4570 if (image && image->directory)
4571 s=newSVpv(image->directory,0);
4572 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4575 if (LocaleCompare(attribute,"dispose") == 0)
4577 if (image == (Image *) NULL)
4580 s=newSViv(image->dispose);
4582 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4584 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4587 if (LocaleCompare(attribute,"disk") == 0)
4589 s=newSViv(GetMagickResource(DiskResource));
4590 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4593 if (LocaleCompare(attribute,"dither") == 0)
4596 s=newSViv((ssize_t) info->image_info->dither);
4597 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4600 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4602 if (info && info->image_info->server_name)
4603 s=newSVpv(info->image_info->server_name,0);
4604 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4607 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4614 if (LocaleCompare(attribute,"elapsed-time") == 0)
4616 if (image != (Image *) NULL)
4617 s=newSVnv(GetElapsedTime(&image->timer));
4618 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4621 if (LocaleCompare(attribute,"endian") == 0)
4623 j=info ? info->image_info->endian : image ? image->endian :
4626 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4628 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4631 if (LocaleCompare(attribute,"error") == 0)
4633 if (image != (Image *) NULL)
4634 s=newSVnv(image->error.mean_error_per_pixel);
4635 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4638 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4645 if (LocaleCompare(attribute,"filesize") == 0)
4647 if (image != (Image *) NULL)
4648 s=newSViv((ssize_t) GetBlobSize(image));
4649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4652 if (LocaleCompare(attribute,"filename") == 0)
4654 if (info && info->image_info->filename &&
4655 *info->image_info->filename)
4656 s=newSVpv(info->image_info->filename,0);
4657 if (image != (Image *) NULL)
4658 s=newSVpv(image->filename,0);
4659 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4662 if (LocaleCompare(attribute,"filter") == 0)
4664 s=image ? newSViv(image->filter) : newSViv(0);
4665 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4668 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4671 if (LocaleCompare(attribute,"font") == 0)
4673 if (info && info->image_info->font)
4674 s=newSVpv(info->image_info->font,0);
4675 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4678 if (LocaleCompare(attribute,"foreground") == 0)
4680 if (LocaleCompare(attribute,"format") == 0)
4685 magick_info=(const MagickInfo *) NULL;
4686 if (info && (*info->image_info->magick != '\0'))
4687 magick_info=GetMagickInfo(info->image_info->magick,exception);
4688 if (image != (Image *) NULL)
4689 magick_info=GetMagickInfo(image->magick,&image->exception);
4690 if ((magick_info != (const MagickInfo *) NULL) &&
4691 (*magick_info->description != '\0'))
4692 s=newSVpv((char *) magick_info->description,0);
4693 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4696 if (LocaleCompare(attribute,"fuzz") == 0)
4699 s=newSVnv(info->image_info->fuzz);
4700 if (image != (Image *) NULL)
4701 s=newSVnv(image->fuzz);
4702 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4705 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4712 if (LocaleCompare(attribute,"gamma") == 0)
4714 if (image != (Image *) NULL)
4715 s=newSVnv(image->gamma);
4716 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4719 if (LocaleCompare(attribute,"geometry") == 0)
4721 if (image && image->geometry)
4722 s=newSVpv(image->geometry,0);
4723 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4726 if (LocaleCompare(attribute,"gravity") == 0)
4728 s=image ? newSViv(image->gravity) : newSViv(0);
4729 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4732 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4735 if (LocaleCompare(attribute,"green-primary") == 0)
4737 if (image == (Image *) NULL)
4739 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4740 image->chromaticity.green_primary.x,
4741 image->chromaticity.green_primary.y);
4743 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4746 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4753 if (LocaleCompare(attribute,"height") == 0)
4755 if (image != (Image *) NULL)
4756 s=newSViv((ssize_t) image->rows);
4757 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4760 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4767 if (LocaleCompare(attribute,"icc") == 0)
4769 if (image != (Image *) NULL)
4774 profile=GetImageProfile(image,"icc");
4775 if (profile != (StringInfo *) NULL)
4776 s=newSVpv((const char *) GetStringInfoDatum(profile),
4777 GetStringInfoLength(profile));
4779 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4782 if (LocaleCompare(attribute,"icm") == 0)
4784 if (image != (Image *) NULL)
4789 profile=GetImageProfile(image,"icm");
4790 if (profile != (const StringInfo *) NULL)
4791 s=newSVpv((const char *) GetStringInfoDatum(profile),
4792 GetStringInfoLength(profile));
4794 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4797 if (LocaleCompare(attribute,"id") == 0)
4799 if (image != (Image *) NULL)
4810 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4812 status=SetImageRegistry(ImageRegistryType,key,image,
4817 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4820 if (LocaleNCompare(attribute,"index",5) == 0)
4823 name[MaxTextExtent];
4832 register const Quantum
4838 if (image == (Image *) NULL)
4840 if (image->storage_class != PseudoClass)
4844 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
4846 image_view=AcquireCacheView(image);
4847 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,&image->exception);
4848 if (p != (const Quantum *) NULL)
4850 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
4851 GetPixelIndex(image,p));
4853 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4855 image_view=DestroyCacheView(image_view);
4858 if (LocaleCompare(attribute,"iptc") == 0)
4860 if (image != (Image *) NULL)
4865 profile=GetImageProfile(image,"iptc");
4866 if (profile != (const StringInfo *) NULL)
4867 s=newSVpv((const char *) GetStringInfoDatum(profile),
4868 GetStringInfoLength(profile));
4870 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4873 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
4875 if (image != (Image *) NULL)
4876 s=newSViv((ssize_t) image->iterations);
4877 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4880 if (LocaleCompare(attribute,"interlace") == 0)
4882 j=info ? info->image_info->interlace : image ? image->interlace :
4885 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
4888 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4891 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4898 if (LocaleCompare(attribute,"label") == 0)
4903 if (image == (Image *) NULL)
4905 value=GetImageProperty(image,"Label");
4906 if (value != (const char *) NULL)
4908 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4911 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
4913 if (image != (Image *) NULL)
4914 s=newSViv((ssize_t) image->iterations);
4915 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4918 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4925 if (LocaleCompare(attribute,"magick") == 0)
4927 if (info && *info->image_info->magick)
4928 s=newSVpv(info->image_info->magick,0);
4929 if (image != (Image *) NULL)
4930 s=newSVpv(image->magick,0);
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 if (LocaleCompare(attribute,"map") == 0)
4936 s=newSViv(GetMagickResource(MapResource));
4937 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4940 if (LocaleCompare(attribute,"maximum-error") == 0)
4942 if (image != (Image *) NULL)
4943 s=newSVnv(image->error.normalized_maximum_error);
4944 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4947 if (LocaleCompare(attribute,"memory") == 0)
4949 s=newSViv(GetMagickResource(MemoryResource));
4950 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4953 if (LocaleCompare(attribute,"mean-error") == 0)
4955 if (image != (Image *) NULL)
4956 s=newSVnv(image->error.normalized_mean_error);
4957 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4960 if (LocaleCompare(attribute,"mime") == 0)
4962 if (info && *info->image_info->magick)
4963 s=newSVpv(MagickToMime(info->image_info->magick),0);
4964 if (image != (Image *) NULL)
4965 s=newSVpv(MagickToMime(image->magick),0);
4966 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4969 if (LocaleCompare(attribute,"mattecolor") == 0)
4971 if (image == (Image *) NULL)
4973 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
4974 QuantumFormat "," QuantumFormat "," QuantumFormat,
4975 image->matte_color.red,image->matte_color.green,
4976 image->matte_color.blue,image->matte_color.alpha);
4978 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4981 if (LocaleCompare(attribute,"matte") == 0)
4983 if (image != (Image *) NULL)
4984 s=newSViv((ssize_t) image->matte);
4985 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4988 if (LocaleCompare(attribute,"mime") == 0)
4994 if (info && *info->image_info->magick)
4995 magick=info->image_info->magick;
4996 if (image != (Image *) NULL)
4997 magick=image->magick;
5003 mime=MagickToMime(magick);
5005 mime=(char *) RelinquishMagickMemory(mime);
5007 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5010 if (LocaleCompare(attribute,"monochrome") == 0)
5012 if (image == (Image *) NULL)
5014 j=info ? info->image_info->monochrome :
5015 IsImageMonochrome(image,&image->exception);
5017 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5020 if (LocaleCompare(attribute,"montage") == 0)
5022 if (image && image->montage)
5023 s=newSVpv(image->montage,0);
5024 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5027 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5034 if (LocaleCompare(attribute,"orientation") == 0)
5036 j=info ? info->image_info->orientation : image ?
5037 image->orientation : UndefinedOrientation;
5039 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5042 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5045 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5052 if (LocaleCompare(attribute,"page") == 0)
5054 if (info && info->image_info->page)
5055 s=newSVpv(info->image_info->page,0);
5056 if (image != (Image *) NULL)
5059 geometry[MaxTextExtent];
5061 (void) FormatLocaleString(geometry,MaxTextExtent,
5062 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5063 (double) image->page.height,(double) image->page.x,(double)
5065 s=newSVpv(geometry,0);
5067 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5070 if (LocaleCompare(attribute,"page.x") == 0)
5072 if (image != (Image *) NULL)
5073 s=newSViv((ssize_t) image->page.x);
5074 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5077 if (LocaleCompare(attribute,"page.y") == 0)
5079 if (image != (Image *) NULL)
5080 s=newSViv((ssize_t) image->page.y);
5081 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5084 if (LocaleNCompare(attribute,"pixel",5) == 0)
5087 tuple[MaxTextExtent];
5096 register const Quantum
5099 if (image == (Image *) NULL)
5103 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5105 p=GetVirtualPixels(image,x,y,1,1,exception);
5106 if (image->colorspace != CMYKColorspace)
5107 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5108 QuantumFormat "," QuantumFormat "," QuantumFormat,
5109 GetPixelRed(image,p),GetPixelGreen(image,p),
5110 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5112 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5113 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5114 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5115 GetPixelBlue(image,p),GetPixelBlack(image,p),
5116 GetPixelAlpha(image,p));
5118 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5121 if (LocaleCompare(attribute,"pointsize") == 0)
5124 s=newSViv((ssize_t) info->image_info->pointsize);
5125 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5128 if (LocaleCompare(attribute,"preview") == 0)
5130 s=newSViv(info->image_info->preview_type);
5131 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5132 info->image_info->preview_type));
5134 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5137 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5144 if (LocaleCompare(attribute,"quality") == 0)
5147 s=newSViv((ssize_t) info->image_info->quality);
5148 if (image != (Image *) NULL)
5149 s=newSViv((ssize_t) image->quality);
5150 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5153 if (LocaleCompare(attribute,"quantum") == 0)
5156 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5157 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5160 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5167 if (LocaleCompare(attribute,"rendering-intent") == 0)
5169 s=newSViv(image->rendering_intent);
5170 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5171 image->rendering_intent));
5173 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5176 if (LocaleCompare(attribute,"red-primary") == 0)
5178 if (image == (Image *) NULL)
5180 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5181 image->chromaticity.red_primary.x,
5182 image->chromaticity.red_primary.y);
5184 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5187 if (LocaleCompare(attribute,"rows") == 0)
5189 if (image != (Image *) NULL)
5190 s=newSViv((ssize_t) image->rows);
5191 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5194 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5201 if (LocaleCompare(attribute,"sampling-factor") == 0)
5203 if (info && info->image_info->sampling_factor)
5204 s=newSVpv(info->image_info->sampling_factor,0);
5205 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5208 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5210 if (info && info->image_info->server_name)
5211 s=newSVpv(info->image_info->server_name,0);
5212 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5215 if (LocaleCompare(attribute,"size") == 0)
5217 if (info && info->image_info->size)
5218 s=newSVpv(info->image_info->size,0);
5219 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5222 if (LocaleCompare(attribute,"scene") == 0)
5224 if (image != (Image *) NULL)
5225 s=newSViv((ssize_t) image->scene);
5226 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5229 if (LocaleCompare(attribute,"scenes") == 0)
5231 if (image != (Image *) NULL)
5232 s=newSViv((ssize_t) info->image_info->number_scenes);
5233 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5236 if (LocaleCompare(attribute,"signature") == 0)
5241 if (image == (Image *) NULL)
5243 (void) SignatureImage(image,exception);
5244 value=GetImageProperty(image,"Signature");
5245 if (value != (const char *) NULL)
5247 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5250 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5257 if (LocaleCompare(attribute,"taint") == 0)
5259 if (image != (Image *) NULL)
5260 s=newSViv((ssize_t) IsTaintImage(image));
5261 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5264 if (LocaleCompare(attribute,"texture") == 0)
5266 if (info && info->image_info->texture)
5267 s=newSVpv(info->image_info->texture,0);
5268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5271 if (LocaleCompare(attribute,"total-ink-density") == 0)
5273 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5274 if (image != (Image *) NULL)
5275 s=newSVnv(GetImageTotalInkDensity(image));
5276 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5279 if (LocaleCompare(attribute,"transparent-color") == 0)
5281 if (image == (Image *) NULL)
5283 (void) FormatLocaleString(color,MaxTextExtent,QuantumFormat ","
5284 QuantumFormat "," QuantumFormat "," QuantumFormat,
5285 image->transparent_color.red,image->transparent_color.green,
5286 image->transparent_color.blue,image->transparent_color.alpha);
5288 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5291 if (LocaleCompare(attribute,"type") == 0)
5293 if (image == (Image *) NULL)
5295 j=(ssize_t) GetImageType(image,&image->exception);
5297 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5299 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5302 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5309 if (LocaleCompare(attribute,"units") == 0)
5311 j=info ? info->image_info->units : image ? image->units :
5312 UndefinedResolution;
5313 if (info && (info->image_info->units == UndefinedResolution))
5316 if (j == UndefinedResolution)
5317 s=newSVpv("undefined units",0);
5319 if (j == PixelsPerInchResolution)
5320 s=newSVpv("pixels / inch",0);
5322 s=newSVpv("pixels / centimeter",0);
5323 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5326 if (LocaleCompare(attribute,"user-time") == 0)
5328 if (image != (Image *) NULL)
5329 s=newSVnv(GetUserTime(&image->timer));
5330 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5333 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5340 if (LocaleCompare(attribute,"verbose") == 0)
5343 s=newSViv((ssize_t) info->image_info->verbose);
5344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5347 if (LocaleCompare(attribute,"version") == 0)
5349 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5353 if (LocaleCompare(attribute,"view") == 0)
5355 if (info && info->image_info->view)
5356 s=newSVpv(info->image_info->view,0);
5357 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5360 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5362 if (image == (Image *) NULL)
5364 j=(ssize_t) GetImageVirtualPixelMethod(image);
5366 (void) sv_setpv(s,CommandOptionToMnemonic(
5367 MagickVirtualPixelOptions,j));
5369 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5372 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5379 if (LocaleCompare(attribute,"white-point") == 0)
5381 if (image == (Image *) NULL)
5383 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5384 image->chromaticity.white_point.x,
5385 image->chromaticity.white_point.y);
5387 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5390 if (LocaleCompare(attribute,"width") == 0)
5392 if (image != (Image *) NULL)
5393 s=newSViv((ssize_t) image->columns);
5394 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5397 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5404 if (LocaleCompare(attribute,"x-resolution") == 0)
5406 if (image != (Image *) NULL)
5407 s=newSVnv(image->x_resolution);
5408 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5411 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5418 if (LocaleCompare(attribute,"y-resolution") == 0)
5420 if (image != (Image *) NULL)
5421 s=newSVnv(image->y_resolution);
5422 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5425 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5432 if (image == (Image *) NULL)
5433 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5437 value=GetImageProperty(image,attribute);
5438 if (value != (const char *) NULL)
5441 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5444 if (*attribute != '%')
5445 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5452 meta=InterpretImageProperties(info ? info->image_info :
5453 (ImageInfo *) NULL,image,attribute,exception);
5455 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5456 meta=(char *) RelinquishMagickMemory(meta);
5460 exception=DestroyExceptionInfo(exception);
5461 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5465 ###############################################################################
5469 # G e t A u t h e n t i c P i x e l s #
5473 ###############################################################################
5477 GetAuthenticPixels(ref,...)
5478 Image::Magick ref = NO_INIT
5480 getauthenticpixels = 1
5510 PERL_UNUSED_VAR(ref);
5511 PERL_UNUSED_VAR(ix);
5512 exception=AcquireExceptionInfo();
5513 perl_exception=newSVpv("",0);
5514 if (sv_isobject(ST(0)) == 0)
5516 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5520 reference=SvRV(ST(0));
5522 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5523 if (image == (Image *) NULL)
5525 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5532 region.width=image->columns;
5535 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5536 for (i=2; i < items; i+=2)
5538 attribute=(char *) SvPV(ST(i-1),na);
5544 if (LocaleCompare(attribute,"geometry") == 0)
5546 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5556 if (LocaleCompare(attribute,"height") == 0)
5558 region.height=SvIV(ST(i));
5561 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5568 if (LocaleCompare(attribute,"x") == 0)
5570 region.x=SvIV(ST(i));
5573 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5580 if (LocaleCompare(attribute,"y") == 0)
5582 region.y=SvIV(ST(i));
5585 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5592 if (LocaleCompare(attribute,"width") == 0)
5594 region.width=SvIV(ST(i));
5597 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5603 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5604 region.height,exception);
5605 if (blob != (void *) NULL)
5609 InheritPerlException(exception,perl_exception);
5610 exception=DestroyExceptionInfo(exception);
5611 SvREFCNT_dec(perl_exception); /* throw away all errors */
5620 ###############################################################################
5624 # G e t V i r t u a l P i x e l s #
5628 ###############################################################################
5632 GetVirtualPixels(ref,...)
5633 Image::Magick ref = NO_INIT
5635 getvirtualpixels = 1
5636 AcquireImagePixels = 2
5637 acquireimagepixels = 3
5665 PERL_UNUSED_VAR(ref);
5666 PERL_UNUSED_VAR(ix);
5667 exception=AcquireExceptionInfo();
5668 perl_exception=newSVpv("",0);
5669 if (sv_isobject(ST(0)) == 0)
5671 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5675 reference=SvRV(ST(0));
5677 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5678 if (image == (Image *) NULL)
5680 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5687 region.width=image->columns;
5690 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5691 for (i=2; i < items; i+=2)
5693 attribute=(char *) SvPV(ST(i-1),na);
5699 if (LocaleCompare(attribute,"geometry") == 0)
5701 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5704 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5711 if (LocaleCompare(attribute,"height") == 0)
5713 region.height=SvIV(ST(i));
5716 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5723 if (LocaleCompare(attribute,"x") == 0)
5725 region.x=SvIV(ST(i));
5728 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5735 if (LocaleCompare(attribute,"y") == 0)
5737 region.y=SvIV(ST(i));
5740 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5747 if (LocaleCompare(attribute,"width") == 0)
5749 region.width=SvIV(ST(i));
5752 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5758 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5759 region.height,exception);
5760 if (blob != (void *) NULL)
5764 InheritPerlException(exception,perl_exception);
5765 exception=DestroyExceptionInfo(exception);
5766 SvREFCNT_dec(perl_exception); /* throw away all errors */
5769 RETVAL = (void *) blob;
5775 ###############################################################################
5779 # G e t A u t h e n t i c M e t a c o n t e n t #
5783 ###############################################################################
5787 GetAuthenticMetacontent(ref,...)
5788 Image::Magick ref = NO_INIT
5790 getauthenticmetacontent = 1
5811 PERL_UNUSED_VAR(ref);
5812 PERL_UNUSED_VAR(ix);
5813 exception=AcquireExceptionInfo();
5814 perl_exception=newSVpv("",0);
5815 if (sv_isobject(ST(0)) == 0)
5817 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5821 reference=SvRV(ST(0));
5823 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5824 if (image == (Image *) NULL)
5826 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5831 blob=(void *) GetAuthenticMetacontent(image);
5832 if (blob != (void *) NULL)
5836 InheritPerlException(exception,perl_exception);
5837 exception=DestroyExceptionInfo(exception);
5838 SvREFCNT_dec(perl_exception); /* throw away all errors */
5847 ###############################################################################
5851 # G e t V i r t u a l M e t a c o n t e n t #
5855 ###############################################################################
5859 GetVirtualMetacontent(ref,...)
5860 Image::Magick ref = NO_INIT
5862 getvirtualmetacontent = 1
5881 PERL_UNUSED_VAR(ref);
5882 PERL_UNUSED_VAR(ix);
5883 exception=AcquireExceptionInfo();
5884 perl_exception=newSVpv("",0);
5885 if (sv_isobject(ST(0)) == 0)
5887 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5891 reference=SvRV(ST(0));
5893 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5894 if (image == (Image *) NULL)
5896 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5901 blob=(void *) GetVirtualMetacontent(image);
5902 if (blob != (void *) NULL)
5906 InheritPerlException(exception,perl_exception);
5907 exception=DestroyExceptionInfo(exception);
5908 SvREFCNT_dec(perl_exception); /* throw away all errors */
5917 ###############################################################################
5921 # H i s t o g r a m #
5925 ###############################################################################
5930 Image::Magick ref=NO_INIT
5941 message[MaxTextExtent];
5968 PERL_UNUSED_VAR(ref);
5969 PERL_UNUSED_VAR(ix);
5970 exception=AcquireExceptionInfo();
5971 perl_exception=newSVpv("",0);
5973 if (sv_isobject(ST(0)) == 0)
5975 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5979 reference=SvRV(ST(0));
5982 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5983 if (image == (Image *) NULL)
5985 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5989 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
5991 for ( ; image; image=image->next)
5993 histogram=GetImageHistogram(image,&number_colors,&image->exception);
5994 if (histogram == (PixelPacket *) NULL)
5996 count+=(ssize_t) number_colors;
5998 for (i=0; i < (ssize_t) number_colors; i++)
6000 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6002 PUSHs(sv_2mortal(newSVpv(message,0)));
6003 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6004 histogram[i].green);
6005 PUSHs(sv_2mortal(newSVpv(message,0)));
6006 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6008 PUSHs(sv_2mortal(newSVpv(message,0)));
6009 if (image->colorspace == CMYKColorspace)
6011 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6012 histogram[i].black);
6013 PUSHs(sv_2mortal(newSVpv(message,0)));
6015 (void) FormatLocaleString(message,MaxTextExtent,QuantumFormat,
6016 histogram[i].alpha);
6017 PUSHs(sv_2mortal(newSVpv(message,0)));
6018 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6019 histogram[i].count);
6020 PUSHs(sv_2mortal(newSVpv(message,0)));
6022 histogram=(PixelPacket *) RelinquishMagickMemory(histogram);
6026 InheritPerlException(exception,perl_exception);
6027 exception=DestroyExceptionInfo(exception);
6028 SvREFCNT_dec(perl_exception);
6032 ###############################################################################
6040 ###############################################################################
6045 Image::Magick ref=NO_INIT
6069 register const Quantum
6083 *reference; /* reference is the SV* of ref=SvIV(reference) */
6085 PERL_UNUSED_VAR(ref);
6086 PERL_UNUSED_VAR(ix);
6087 exception=AcquireExceptionInfo();
6088 perl_exception=newSVpv("",0);
6089 reference=SvRV(ST(0));
6090 av=(AV *) reference;
6091 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6093 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6094 if (image == (Image *) NULL)
6096 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6100 normalize=MagickTrue;
6103 region.width=image->columns;
6106 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6107 for (i=2; i < items; i+=2)
6109 attribute=(char *) SvPV(ST(i-1),na);
6115 if (LocaleCompare(attribute,"channel") == 0)
6120 option=ParseChannelOption(SvPV(ST(i),na));
6123 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6127 SetPixelChannelMap(image,(ChannelType) option);
6130 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6137 if (LocaleCompare(attribute,"geometry") == 0)
6139 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6142 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6149 if (LocaleCompare(attribute,"normalize") == 0)
6151 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6155 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6159 normalize=option != 0 ? MagickTrue : MagickFalse;
6162 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6169 if (LocaleCompare(attribute,"x") == 0)
6171 region.x=SvIV(ST(i));
6174 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6181 if (LocaleCompare(attribute,"y") == 0)
6183 region.y=SvIV(ST(i));
6186 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6192 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6198 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6199 if (p == (const Quantum *) NULL)
6207 if (normalize != MagickFalse)
6208 scale=1.0/QuantumRange;
6209 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6210 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6211 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6212 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6213 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6214 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6215 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6216 (image->colorspace == CMYKColorspace))
6217 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6218 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6219 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6223 InheritPerlException(exception,perl_exception);
6224 exception=DestroyExceptionInfo(exception);
6225 SvREFCNT_dec(perl_exception);
6229 ###############################################################################
6233 # G e t P i x e l s #
6237 ###############################################################################
6242 Image::Magick ref=NO_INIT
6281 *reference; /* reference is the SV* of ref=SvIV(reference) */
6283 PERL_UNUSED_VAR(ref);
6284 PERL_UNUSED_VAR(ix);
6285 exception=AcquireExceptionInfo();
6286 perl_exception=newSVpv("",0);
6287 reference=SvRV(ST(0));
6288 av=(AV *) reference;
6289 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6291 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6292 if (image == (Image *) NULL)
6294 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6299 if (image->matte != MagickFalse)
6301 if (image->colorspace == CMYKColorspace)
6304 if (image->matte != MagickFalse)
6307 normalize=MagickFalse;
6310 region.width=image->columns;
6313 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6314 for (i=2; i < items; i+=2)
6316 attribute=(char *) SvPV(ST(i-1),na);
6322 if (LocaleCompare(attribute,"geometry") == 0)
6324 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6327 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6334 if (LocaleCompare(attribute,"height") == 0)
6336 region.height=SvIV(ST(i));
6339 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6346 if (LocaleCompare(attribute,"map") == 0)
6351 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6358 if (LocaleCompare(attribute,"normalize") == 0)
6360 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6364 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6368 normalize=option != 0 ? MagickTrue : MagickFalse;
6371 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6378 if (LocaleCompare(attribute,"width") == 0)
6380 region.width=SvIV(ST(i));
6383 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6390 if (LocaleCompare(attribute,"x") == 0)
6392 region.x=SvIV(ST(i));
6395 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6402 if (LocaleCompare(attribute,"y") == 0)
6404 region.y=SvIV(ST(i));
6407 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6413 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6419 if (normalize != MagickFalse)
6424 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6425 region.height*sizeof(*pixels));
6426 if (pixels == (float *) NULL)
6428 ThrowPerlException(exception,ResourceLimitError,
6429 "MemoryAllocationFailed",PackageName);
6432 status=ExportImagePixels(image,region.x,region.y,region.width,
6433 region.height,map,FloatPixel,pixels,exception);
6434 if (status == MagickFalse)
6438 EXTEND(sp,strlen(map)*region.width*region.height);
6439 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6440 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6442 pixels=(float *) RelinquishMagickMemory(pixels);
6449 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6450 region.height*sizeof(*pixels));
6451 if (pixels == (Quantum *) NULL)
6453 ThrowPerlException(exception,ResourceLimitError,
6454 "MemoryAllocationFailed",PackageName);
6457 status=ExportImagePixels(image,region.x,region.y,region.width,
6458 region.height,map,QuantumPixel,pixels,exception);
6459 if (status == MagickFalse)
6463 EXTEND(sp,strlen(map)*region.width*region.height);
6464 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6465 PUSHs(sv_2mortal(newSViv(pixels[i])));
6467 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6471 InheritPerlException(exception,perl_exception);
6472 exception=DestroyExceptionInfo(exception);
6473 SvREFCNT_dec(perl_exception);
6477 ###############################################################################
6481 # I m a g e T o B l o b #
6485 ###############################################################################
6489 ImageToBlob(ref,...)
6490 Image::Magick ref=NO_INIT
6499 filename[MaxTextExtent];
6528 PERL_UNUSED_VAR(ref);
6529 PERL_UNUSED_VAR(ix);
6530 exception=AcquireExceptionInfo();
6531 perl_exception=newSVpv("",0);
6532 package_info=(struct PackageInfo *) NULL;
6533 if (sv_isobject(ST(0)) == 0)
6535 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6539 reference=SvRV(ST(0));
6540 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6541 if (image == (Image *) NULL)
6543 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6547 package_info=ClonePackageInfo(info,exception);
6548 for (i=2; i < items; i+=2)
6549 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6550 (void) CopyMagickString(filename,package_info->image_info->filename,
6553 for (next=image; next; next=next->next)
6555 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6556 next->scene=scene++;
6558 SetImageInfo(package_info->image_info,(unsigned int)
6559 GetImageListLength(image),&image->exception);
6560 EXTEND(sp,(ssize_t) GetImageListLength(image));
6561 for ( ; image; image=image->next)
6564 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6565 if (blob != (char *) NULL)
6567 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6568 blob=(unsigned char *) RelinquishMagickMemory(blob);
6570 if (package_info->image_info->adjoin)
6575 if (package_info != (struct PackageInfo *) NULL)
6576 DestroyPackageInfo(package_info);
6577 InheritPerlException(exception,perl_exception);
6578 exception=DestroyExceptionInfo(exception);
6579 SvREFCNT_dec(perl_exception); /* throw away all errors */
6583 ###############################################################################
6591 ###############################################################################
6596 Image::Magick ref=NO_INIT
6600 OptimizeImageLayers = 3
6602 optimizeimagelayers = 5
6644 PERL_UNUSED_VAR(ref);
6645 PERL_UNUSED_VAR(ix);
6646 exception=AcquireExceptionInfo();
6647 perl_exception=newSVpv("",0);
6649 if (sv_isobject(ST(0)) == 0)
6651 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6655 reference=SvRV(ST(0));
6656 hv=SvSTASH(reference);
6658 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6660 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6661 if (image == (Image *) NULL)
6663 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6667 compose=image->compose;
6668 method=OptimizeLayer;
6669 for (i=2; i < items; i+=2)
6671 attribute=(char *) SvPV(ST(i-1),na);
6677 if (LocaleCompare(attribute,"compose") == 0)
6679 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6680 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6683 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6687 compose=(CompositeOperator) sp;
6690 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6697 if (LocaleCompare(attribute,"method") == 0)
6699 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6703 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6707 method=(ImageLayerMethod) option;
6710 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6716 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6722 layers=(Image *) NULL;
6725 case CompareAnyLayer:
6726 case CompareClearLayer:
6727 case CompareOverlayLayer:
6730 layers=CompareImagesLayers(image,method,exception);
6737 layers=MergeImageLayers(image,method,exception);
6742 layers=DisposeImages(image,exception);
6745 case OptimizeImageLayer:
6747 layers=OptimizeImageLayers(image,exception);
6750 case OptimizePlusLayer:
6752 layers=OptimizePlusImageLayers(image,exception);
6755 case OptimizeTransLayer:
6757 OptimizeImageTransparency(image,exception);
6758 InheritException(&(image->exception),exception);
6761 case RemoveDupsLayer:
6763 RemoveDuplicateLayers(&image,exception);
6764 InheritException(&(image->exception),exception);
6767 case RemoveZeroLayer:
6769 RemoveZeroDelayLayers(&image,exception);
6770 InheritException(&(image->exception),exception);
6779 General Purpose, GIF Animation Optimizer.
6781 layers=CoalesceImages(image,exception);
6782 if (layers == (Image *) NULL)
6784 InheritException(&(layers->exception),exception);
6786 layers=OptimizeImageLayers(image,exception);
6787 if (layers == (Image *) NULL)
6789 InheritException(&(layers->exception),exception);
6790 image=DestroyImageList(image);
6792 layers=(Image *) NULL;
6793 OptimizeImageTransparency(image,exception);
6794 InheritException(&(image->exception),exception);
6795 quantize_info=AcquireQuantizeInfo(info->image_info);
6796 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6797 quantize_info=DestroyQuantizeInfo(quantize_info);
6800 case CompositeLayer:
6809 Split image sequence at the first 'NULL:' image.
6812 while (source != (Image *) NULL)
6814 source=GetNextImageInList(source);
6815 if ((source != (Image *) NULL) &&
6816 (LocaleCompare(source->magick,"NULL") == 0))
6819 if (source != (Image *) NULL)
6821 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6822 (GetNextImageInList(source) == (Image *) NULL))
6823 source=(Image *) NULL;
6827 Separate the two lists, junk the null: image.
6829 source=SplitImageList(source->previous);
6830 DeleteImageFromList(&source);
6833 if (source == (Image *) NULL)
6835 (void) ThrowMagickException(exception,GetMagickModule(),
6836 OptionError,"MissingNullSeparator","layers Composite");
6840 Adjust offset with gravity and virtual canvas.
6842 SetGeometry(image,&geometry);
6843 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
6844 geometry.width=source->page.width != 0 ? source->page.width :
6846 geometry.height=source->page.height != 0 ? source->page.height :
6848 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
6849 image->columns,image->page.height != 0 ? image->page.height :
6850 image->rows,image->gravity,&geometry);
6851 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
6852 source=DestroyImageList(source);
6853 InheritException(&(image->exception),exception);
6857 if (layers != (Image *) NULL)
6859 InheritException(&(layers->exception),exception);
6862 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
6864 for ( ; image; image=image->next)
6866 AddImageToRegistry(sv,image);
6868 av_push(av,sv_bless(rv,hv));
6871 exception=DestroyExceptionInfo(exception);
6873 SvREFCNT_dec(perl_exception);
6877 InheritPerlException(exception,perl_exception);
6878 exception=DestroyExceptionInfo(exception);
6879 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
6880 SvPOK_on(perl_exception);
6881 ST(0)=sv_2mortal(perl_exception);
6886 ###############################################################################
6890 # M a g i c k T o M i m e #
6894 ###############################################################################
6898 MagickToMime(ref,name)
6899 Image::Magick ref=NO_INIT
6908 PERL_UNUSED_VAR(ref);
6909 PERL_UNUSED_VAR(ix);
6910 mime=MagickToMime(name);
6911 RETVAL=newSVpv(mime,0);
6912 mime=(char *) RelinquishMagickMemory(mime);
6918 ###############################################################################
6926 ###############################################################################
6931 Image::Magick ref=NO_INIT
6968 MedianConvolveImage = 36
6974 ReduceNoiseImage = 42
7000 ColorFloodfillImage= 68
7006 CycleColormapImage = 74
7016 MatteFloodfillImage= 84
7024 NumberColorsImage = 92
7034 SignatureImage = 102
7044 TransparentImage = 112
7046 ThresholdImage = 114
7060 DeconstructImage = 130
7062 GaussianBlurImage = 132
7068 UnsharpMaskImage = 138
7070 MotionBlurImage = 140
7072 OrderedDitherImage = 142
7079 AffineTransform = 149
7080 AffineTransformImage = 150
7082 DifferenceImage = 152
7083 AdaptiveThreshold = 153
7084 AdaptiveThresholdImage = 154
7089 BlackThreshold = 159
7090 BlackThresholdImage= 160
7091 WhiteThreshold = 161
7092 WhiteThresholdImage= 162
7094 RadialBlurImage = 164
7096 ThumbnailImage = 166
7106 PosterizeImage = 176
7112 SepiaToneImage = 182
7113 SigmoidalContrast = 183
7114 SigmoidalContrastImage = 184
7119 ContrastStretch = 189
7120 ContrastStretchImage = 190
7125 AdaptiveSharpen = 195
7126 AdaptiveSharpenImage = 196
7128 TransposeImage = 198
7130 TransverseImage = 200
7132 AutoOrientImage = 202
7134 AdaptiveBlurImage = 204
7138 UniqueColorsImage = 208
7139 AdaptiveResize = 209
7140 AdaptiveResizeImage= 210
7144 LinearStretchImage = 214
7151 FloodfillPaint = 221
7152 FloodfillPaintImage= 222
7158 LiquidRescaleImage = 228
7168 SparseColorImage = 238
7172 SelectiveBlurImage = 242
7176 BlueShiftImage = 246
7177 ForwardFourierTransform = 247
7178 ForwardFourierTransformImage = 248
7179 InverseFourierTransform = 249
7180 InverseFourierTransformImage = 250
7181 ColorDecisionList = 251
7182 ColorDecisionListImage = 252
7184 AutoGammaImage = 254
7186 AutoLevelImage = 256
7188 LevelImageColors = 258
7191 BrightnessContrast = 263
7192 BrightnessContrastImage = 264
7194 MorphologyImage = 266
7196 ColorMatrixImage = 268
7202 StatisticImage = 274
7211 attribute_flag[MaxArguments],
7212 message[MaxTextExtent];
7273 argument_list[MaxArguments];
7275 PERL_UNUSED_VAR(ref);
7276 PERL_UNUSED_VAR(ix);
7277 exception=AcquireExceptionInfo();
7278 perl_exception=newSVpv("",0);
7279 reference_vector=NULL;
7283 if (sv_isobject(ST(0)) == 0)
7285 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7289 reference=SvRV(ST(0));
7290 region_info.width=0;
7291 region_info.height=0;
7294 region_image=(Image *) NULL;
7295 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7296 if (ix && (ix != 666))
7299 Called as Method(...)
7302 rp=(&Methods[ix-1]);
7308 Called as Mogrify("Method",...)
7310 attribute=(char *) SvPV(ST(1),na);
7313 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7314 attribute=(char *) SvPV(ST(2),na);
7317 for (rp=Methods; ; rp++)
7319 if (rp >= EndOf(Methods))
7321 ThrowPerlException(exception,OptionError,
7322 "UnrecognizedPerlMagickMethod",attribute);
7325 if (strEQcase(attribute,rp->name))
7331 if (image == (Image *) NULL)
7333 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7336 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7337 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7338 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7355 pp=(Arguments *) NULL;
7363 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7365 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7367 if (strEQcase(attribute,qq->method) > ssize_test)
7370 ssize_test=strEQcase(attribute,qq->method);
7373 if (pp == (Arguments *) NULL)
7375 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7377 goto continue_outer_loop;
7379 al=(&argument_list[pp-rp->arguments]);
7382 case ArrayReference:
7384 if (SvTYPE(sv) != SVt_RV)
7386 (void) FormatLocaleString(message,MaxTextExtent,
7387 "invalid %.60s value",pp->method);
7388 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7389 goto continue_outer_loop;
7391 al->array_reference=SvRV(sv);
7396 al->real_reference=SvNV(sv);
7401 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7404 case ImageReference:
7406 if (!sv_isobject(sv) ||
7407 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7408 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7410 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7416 case IntegerReference:
7418 al->integer_reference=SvIV(sv);
7421 case StringReference:
7423 al->string_reference=(char *) SvPV(sv,al->length);
7424 if (sv_isobject(sv))
7425 al->image_reference=SetupList(aTHX_ SvRV(sv),
7426 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7432 Is a string; look up name.
7434 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7436 al->string_reference=(char *) SvPV(sv,al->length);
7437 al->integer_reference=(-1);
7440 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7441 MagickFalse,SvPV(sv,na));
7442 if (pp->type == MagickChannelOptions)
7443 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7444 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7446 (void) FormatLocaleString(message,MaxTextExtent,
7447 "invalid %.60s value",pp->method);
7448 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7449 goto continue_outer_loop;
7454 attribute_flag[pp-rp->arguments]++;
7455 continue_outer_loop: ;
7457 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7458 pv=reference_vector;
7459 SetGeometryInfo(&geometry_info);
7460 channel=DefaultChannels;
7461 for (next=image; next; next=next->next)
7464 SetGeometry(image,&geometry);
7465 if ((region_info.width*region_info.height) != 0)
7468 image=CropImage(image,®ion_info,exception);
7474 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7475 ThrowPerlException(exception,OptionError,
7476 "UnrecognizedPerlMagickMethod",message);
7479 case 1: /* Comment */
7481 if (attribute_flag[0] == 0)
7482 argument_list[0].string_reference=(char *) NULL;
7483 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7484 info ? info->image_info : (ImageInfo *) NULL,image,
7485 argument_list[0].string_reference,exception));
7490 if (attribute_flag[0] == 0)
7491 argument_list[0].string_reference=(char *) NULL;
7492 (void) SetImageProperty(image,"label",InterpretImageProperties(
7493 info ? info->image_info : (ImageInfo *) NULL,image,
7494 argument_list[0].string_reference,exception));
7497 case 3: /* AddNoise */
7499 if (attribute_flag[0] == 0)
7500 argument_list[0].integer_reference=UniformNoise;
7501 if (attribute_flag[1] != 0)
7502 channel=(ChannelType) argument_list[1].integer_reference;
7503 channel_mask=SetPixelChannelMask(image,channel);
7504 image=AddNoiseImage(image,(NoiseType)
7505 argument_list[0].integer_reference,exception);
7506 if (image != (Image *) NULL)
7507 (void) SetPixelChannelMask(image,channel_mask);
7510 case 4: /* Colorize */
7516 virtual_pixel[MaxPixelChannels];
7518 GetPixelInfo(image,&target);
7519 (void) GetOneVirtualPixel(image,0,0,virtual_pixel,exception);
7520 target.red=virtual_pixel[RedPixelChannel];
7521 target.green=virtual_pixel[GreenPixelChannel];
7522 target.blue=virtual_pixel[BluePixelChannel];
7523 target.alpha=virtual_pixel[AlphaPixelChannel];
7524 if (attribute_flag[0] != 0)
7525 (void) QueryColorCompliance(argument_list[0].string_reference,
7526 AllCompliance,&target,exception);
7527 if (attribute_flag[1] == 0)
7528 argument_list[1].string_reference="100%";
7529 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7533 case 5: /* Border */
7540 if (attribute_flag[0] != 0)
7542 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7543 &geometry,exception);
7544 if ((flags & HeightValue) == 0)
7545 geometry.height=geometry.width;
7547 if (attribute_flag[1] != 0)
7548 geometry.width=argument_list[1].integer_reference;
7549 if (attribute_flag[2] != 0)
7550 geometry.height=argument_list[2].integer_reference;
7551 if (attribute_flag[3] != 0)
7552 QueryColorCompliance(argument_list[3].string_reference,
7553 AllCompliance,&image->border_color,exception);
7554 if (attribute_flag[4] != 0)
7555 QueryColorCompliance(argument_list[4].string_reference,
7556 AllCompliance,&image->border_color,exception);
7557 if (attribute_flag[5] != 0)
7558 QueryColorCompliance(argument_list[5].string_reference,
7559 AllCompliance,&image->border_color,exception);
7560 compose=image->compose;
7561 if (attribute_flag[6] != 0)
7562 compose=(CompositeOperator) argument_list[6].integer_reference;
7563 image=BorderImage(image,&geometry,compose,exception);
7568 if (attribute_flag[0] != 0)
7570 flags=ParseGeometry(argument_list[0].string_reference,
7572 if ((flags & SigmaValue) == 0)
7573 geometry_info.sigma=1.0;
7575 if (attribute_flag[1] != 0)
7576 geometry_info.rho=argument_list[1].real_reference;
7577 if (attribute_flag[2] != 0)
7578 geometry_info.sigma=argument_list[2].real_reference;
7579 if (attribute_flag[3] != 0)
7580 geometry_info.xi=argument_list[3].real_reference;
7581 if (attribute_flag[4] != 0)
7582 channel=(ChannelType) argument_list[4].integer_reference;
7583 channel_mask=SetPixelChannelMask(image,channel);
7584 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7585 geometry_info.xi,exception);
7586 if (image != (Image *) NULL)
7587 (void) SetPixelChannelMask(image,channel_mask);
7592 if (attribute_flag[0] != 0)
7593 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7594 &geometry,exception);
7595 if (attribute_flag[1] != 0)
7596 geometry.width=argument_list[1].integer_reference;
7597 if (attribute_flag[2] != 0)
7598 geometry.height=argument_list[2].integer_reference;
7599 if (attribute_flag[3] != 0)
7600 geometry.x=argument_list[3].integer_reference;
7601 if (attribute_flag[4] != 0)
7602 geometry.y=argument_list[4].integer_reference;
7603 image=ChopImage(image,&geometry,exception);
7608 if (attribute_flag[6] != 0)
7609 image->gravity=(GravityType) argument_list[6].integer_reference;
7610 if (attribute_flag[0] != 0)
7611 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7612 &geometry,exception);
7613 if (attribute_flag[1] != 0)
7614 geometry.width=argument_list[1].integer_reference;
7615 if (attribute_flag[2] != 0)
7616 geometry.height=argument_list[2].integer_reference;
7617 if (attribute_flag[3] != 0)
7618 geometry.x=argument_list[3].integer_reference;
7619 if (attribute_flag[4] != 0)
7620 geometry.y=argument_list[4].integer_reference;
7621 if (attribute_flag[5] != 0)
7623 SiPrefixToDouble(argument_list[5].string_reference,QuantumRange);
7624 image=CropImage(image,&geometry,exception);
7627 case 9: /* Despeckle */
7629 image=DespeckleImage(image,exception);
7634 if (attribute_flag[0] != 0)
7635 geometry_info.rho=argument_list[0].real_reference;
7636 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7640 case 11: /* Emboss */
7642 if (attribute_flag[0] != 0)
7644 flags=ParseGeometry(argument_list[0].string_reference,
7646 if ((flags & SigmaValue) == 0)
7647 geometry_info.sigma=1.0;
7649 if (attribute_flag[1] != 0)
7650 geometry_info.rho=argument_list[1].real_reference;
7651 if (attribute_flag[2] != 0)
7652 geometry_info.sigma=argument_list[2].real_reference;
7653 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7657 case 12: /* Enhance */
7659 image=EnhanceImage(image,exception);
7664 image=FlipImage(image,exception);
7669 image=FlopImage(image,exception);
7672 case 15: /* Frame */
7680 if (attribute_flag[0] != 0)
7682 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7683 &geometry,exception);
7684 if ((flags & HeightValue) == 0)
7685 geometry.height=geometry.width;
7686 frame_info.width=geometry.width;
7687 frame_info.height=geometry.height;
7688 frame_info.outer_bevel=geometry.x;
7689 frame_info.inner_bevel=geometry.y;
7691 if (attribute_flag[1] != 0)
7692 frame_info.width=argument_list[1].integer_reference;
7693 if (attribute_flag[2] != 0)
7694 frame_info.height=argument_list[2].integer_reference;
7695 if (attribute_flag[3] != 0)
7696 frame_info.inner_bevel=argument_list[3].integer_reference;
7697 if (attribute_flag[4] != 0)
7698 frame_info.outer_bevel=argument_list[4].integer_reference;
7699 if (attribute_flag[5] != 0)
7700 QueryColorCompliance(argument_list[5].string_reference,
7701 AllCompliance,&fill_color,exception);
7702 if (attribute_flag[6] != 0)
7703 QueryColorCompliance(argument_list[6].string_reference,
7704 AllCompliance,&fill_color,exception);
7705 frame_info.x=(ssize_t) frame_info.width;
7706 frame_info.y=(ssize_t) frame_info.height;
7707 frame_info.width=image->columns+2*frame_info.x;
7708 frame_info.height=image->rows+2*frame_info.y;
7709 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7710 image->matte_color=fill_color;
7711 compose=image->compose;
7712 if (attribute_flag[7] != 0)
7713 compose=(CompositeOperator) argument_list[7].integer_reference;
7714 image=FrameImage(image,&frame_info,compose,exception);
7717 case 16: /* Implode */
7719 PixelInterpolateMethod
7722 if (attribute_flag[0] == 0)
7723 argument_list[0].real_reference=0.5;
7724 method=UndefinedInterpolatePixel;
7725 if (attribute_flag[1] != 0)
7726 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7727 image=ImplodeImage(image,argument_list[0].real_reference,
7731 case 17: /* Magnify */
7733 image=MagnifyImage(image,exception);
7736 case 18: /* MedianFilter */
7738 if (attribute_flag[0] != 0)
7740 flags=ParseGeometry(argument_list[0].string_reference,
7742 if ((flags & SigmaValue) == 0)
7743 geometry_info.sigma=geometry_info.rho;
7745 if (attribute_flag[1] != 0)
7746 geometry_info.rho=argument_list[1].real_reference;
7747 if (attribute_flag[2] != 0)
7748 geometry_info.sigma=argument_list[2].real_reference;
7749 if (attribute_flag[3] != 0)
7750 channel=(ChannelType) argument_list[3].integer_reference;
7751 channel_mask=SetPixelChannelMask(image,channel);
7752 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7753 (size_t) geometry_info.sigma,exception);
7754 if (image != (Image *) NULL)
7755 (void) SetPixelChannelMask(image,channel_mask);
7758 case 19: /* Minify */
7760 image=MinifyImage(image,exception);
7763 case 20: /* OilPaint */
7765 if (attribute_flag[0] == 0)
7766 argument_list[0].real_reference=0.0;
7767 if (attribute_flag[1] == 0)
7768 argument_list[1].real_reference=1.0;
7769 image=OilPaintImage(image,argument_list[0].real_reference,
7770 argument_list[1].real_reference,exception);
7773 case 21: /* ReduceNoise */
7775 if (attribute_flag[0] != 0)
7777 flags=ParseGeometry(argument_list[0].string_reference,
7779 if ((flags & SigmaValue) == 0)
7780 geometry_info.sigma=1.0;
7782 if (attribute_flag[1] != 0)
7783 geometry_info.rho=argument_list[1].real_reference;
7784 if (attribute_flag[2] != 0)
7785 geometry_info.sigma=argument_list[2].real_reference;
7786 if (attribute_flag[3] != 0)
7787 channel=(ChannelType) argument_list[3].integer_reference;
7788 channel_mask=SetPixelChannelMask(image,channel);
7789 image=StatisticImage(image,NonpeakStatistic,(size_t)
7790 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7791 if (image != (Image *) NULL)
7792 (void) SetPixelChannelMask(image,channel_mask);
7797 if (attribute_flag[0] != 0)
7798 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7799 &geometry,exception);
7800 if (attribute_flag[1] != 0)
7801 geometry.x=argument_list[1].integer_reference;
7802 if (attribute_flag[2] != 0)
7803 geometry.y=argument_list[2].integer_reference;
7804 image=RollImage(image,geometry.x,geometry.y,exception);
7807 case 23: /* Rotate */
7809 if (attribute_flag[0] == 0)
7810 argument_list[0].real_reference=90.0;
7811 if (attribute_flag[1] != 0)
7812 QueryColorCompliance(argument_list[1].string_reference,
7813 AllCompliance,&image->background_color,exception);
7814 if (attribute_flag[2] != 0)
7815 QueryColorCompliance(argument_list[2].string_reference,
7816 AllCompliance,&image->background_color,exception);
7817 if (attribute_flag[3] != 0)
7818 QueryColorCompliance(argument_list[3].string_reference,
7819 AllCompliance,&image->background_color,exception);
7820 image=RotateImage(image,argument_list[0].real_reference,exception);
7823 case 24: /* Sample */
7825 if (attribute_flag[0] != 0)
7826 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7827 &geometry,exception);
7828 if (attribute_flag[1] != 0)
7829 geometry.width=argument_list[1].integer_reference;
7830 if (attribute_flag[2] != 0)
7831 geometry.height=argument_list[2].integer_reference;
7832 image=SampleImage(image,geometry.width,geometry.height,exception);
7835 case 25: /* Scale */
7837 if (attribute_flag[0] != 0)
7838 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7839 &geometry,exception);
7840 if (attribute_flag[1] != 0)
7841 geometry.width=argument_list[1].integer_reference;
7842 if (attribute_flag[2] != 0)
7843 geometry.height=argument_list[2].integer_reference;
7844 image=ScaleImage(image,geometry.width,geometry.height,exception);
7847 case 26: /* Shade */
7849 if (attribute_flag[0] != 0)
7851 flags=ParseGeometry(argument_list[0].string_reference,
7853 if ((flags & SigmaValue) == 0)
7854 geometry_info.sigma=0.0;
7856 if (attribute_flag[1] != 0)
7857 geometry_info.rho=argument_list[1].real_reference;
7858 if (attribute_flag[2] != 0)
7859 geometry_info.sigma=argument_list[2].real_reference;
7860 image=ShadeImage(image,
7861 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
7862 geometry_info.rho,geometry_info.sigma,exception);
7865 case 27: /* Sharpen */
7867 if (attribute_flag[0] != 0)
7869 flags=ParseGeometry(argument_list[0].string_reference,
7871 if ((flags & SigmaValue) == 0)
7872 geometry_info.sigma=1.0;
7874 if (attribute_flag[1] != 0)
7875 geometry_info.rho=argument_list[1].real_reference;
7876 if (attribute_flag[2] != 0)
7877 geometry_info.sigma=argument_list[2].real_reference;
7878 if (attribute_flag[3] != 0)
7879 geometry_info.xi=argument_list[3].real_reference;
7880 if (attribute_flag[4] != 0)
7881 channel=(ChannelType) argument_list[4].integer_reference;
7882 channel_mask=SetPixelChannelMask(image,channel);
7883 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
7884 geometry_info.xi,exception);
7885 if (image != (Image *) NULL)
7886 (void) SetPixelChannelMask(image,channel_mask);
7889 case 28: /* Shear */
7891 if (attribute_flag[0] != 0)
7893 flags=ParseGeometry(argument_list[0].string_reference,
7895 if ((flags & SigmaValue) == 0)
7896 geometry_info.sigma=geometry_info.rho;
7898 if (attribute_flag[1] != 0)
7899 geometry_info.rho=argument_list[1].real_reference;
7900 if (attribute_flag[2] != 0)
7901 geometry_info.sigma=argument_list[2].real_reference;
7902 if (attribute_flag[3] != 0)
7903 QueryColorCompliance(argument_list[3].string_reference,
7904 AllCompliance,&image->background_color,exception);
7905 if (attribute_flag[4] != 0)
7906 QueryColorCompliance(argument_list[4].string_reference,
7907 AllCompliance,&image->background_color,exception);
7908 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
7912 case 29: /* Spread */
7914 PixelInterpolateMethod
7917 if (attribute_flag[0] == 0)
7918 argument_list[0].real_reference=1.0;
7919 method=UndefinedInterpolatePixel;
7920 if (attribute_flag[1] != 0)
7921 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7922 image=SpreadImage(image,argument_list[0].real_reference,method,
7926 case 30: /* Swirl */
7928 PixelInterpolateMethod
7931 if (attribute_flag[0] == 0)
7932 argument_list[0].real_reference=50.0;
7933 method=UndefinedInterpolatePixel;
7934 if (attribute_flag[1] != 0)
7935 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7936 image=SwirlImage(image,argument_list[0].real_reference,
7940 case 31: /* Resize */
7943 if (attribute_flag[0] != 0)
7944 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7945 &geometry,exception);
7946 if (attribute_flag[1] != 0)
7947 geometry.width=argument_list[1].integer_reference;
7948 if (attribute_flag[2] != 0)
7949 geometry.height=argument_list[2].integer_reference;
7950 if (attribute_flag[3] == 0)
7951 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
7952 if (attribute_flag[4] != 0)
7953 SetImageArtifact(image,"filter:support",
7954 argument_list[4].string_reference);
7955 if (attribute_flag[5] == 0)
7956 argument_list[5].real_reference=1.0;
7957 image=ResizeImage(image,geometry.width,geometry.height,
7958 (FilterTypes) argument_list[3].integer_reference,
7959 argument_list[5].real_reference,exception);
7962 case 33: /* Annotate */
7967 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
7969 if (attribute_flag[0] != 0)
7974 text=InterpretImageProperties(info ? info->image_info :
7975 (ImageInfo *) NULL,image,argument_list[0].string_reference,
7977 (void) CloneString(&draw_info->text,text);
7978 text=DestroyString(text);
7980 if (attribute_flag[1] != 0)
7981 (void) CloneString(&draw_info->font,
7982 argument_list[1].string_reference);
7983 if (attribute_flag[2] != 0)
7984 draw_info->pointsize=argument_list[2].real_reference;
7985 if (attribute_flag[3] != 0)
7986 (void) CloneString(&draw_info->density,
7987 argument_list[3].string_reference);
7988 if (attribute_flag[4] != 0)
7989 (void) QueryColorCompliance(argument_list[4].string_reference,
7990 AllCompliance,&draw_info->undercolor,exception);
7991 if (attribute_flag[5] != 0)
7993 (void) QueryColorCompliance(argument_list[5].string_reference,
7994 AllCompliance,&draw_info->stroke,exception);
7995 if (argument_list[5].image_reference != (Image *) NULL)
7996 draw_info->stroke_pattern=CloneImage(
7997 argument_list[5].image_reference,0,0,MagickTrue,exception);
7999 if (attribute_flag[6] != 0)
8001 (void) QueryColorCompliance(argument_list[6].string_reference,
8002 AllCompliance,&draw_info->fill,exception);
8003 if (argument_list[6].image_reference != (Image *) NULL)
8004 draw_info->fill_pattern=CloneImage(
8005 argument_list[6].image_reference,0,0,MagickTrue,exception);
8007 if (attribute_flag[7] != 0)
8009 (void) CloneString(&draw_info->geometry,
8010 argument_list[7].string_reference);
8011 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8012 &geometry,exception);
8013 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8014 geometry_info.sigma=geometry_info.xi;
8016 if (attribute_flag[8] != 0)
8017 (void) QueryColorCompliance(argument_list[8].string_reference,
8018 AllCompliance,&draw_info->fill,exception);
8019 if (attribute_flag[11] != 0)
8020 draw_info->gravity=(GravityType)
8021 argument_list[11].integer_reference;
8022 if (attribute_flag[25] != 0)
8027 av=(AV *) argument_list[25].array_reference;
8028 if ((av_len(av) != 3) && (av_len(av) != 5))
8030 ThrowPerlException(exception,OptionError,
8031 "affine matrix must have 4 or 6 elements",PackageName);
8034 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8035 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8036 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8037 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8038 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8039 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8041 ThrowPerlException(exception,OptionError,
8042 "affine matrix is singular",PackageName);
8045 if (av_len(av) == 5)
8047 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8048 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8051 for (j=12; j < 17; j++)
8053 if (attribute_flag[j] == 0)
8055 value=argument_list[j].string_reference;
8056 angle=argument_list[j].real_reference;
8057 current=draw_info->affine;
8058 GetAffineMatrix(&affine);
8066 flags=ParseGeometry(value,&geometry_info);
8067 affine.tx=geometry_info.xi;
8068 affine.ty=geometry_info.psi;
8069 if ((flags & PsiValue) == 0)
8070 affine.ty=affine.tx;
8078 flags=ParseGeometry(value,&geometry_info);
8079 affine.sx=geometry_info.rho;
8080 affine.sy=geometry_info.sigma;
8081 if ((flags & SigmaValue) == 0)
8082 affine.sy=affine.sx;
8092 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8093 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8094 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8095 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8103 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8111 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8115 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8116 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8117 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8118 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8119 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8121 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8124 if (attribute_flag[9] == 0)
8125 argument_list[9].real_reference=0.0;
8126 if (attribute_flag[10] == 0)
8127 argument_list[10].real_reference=0.0;
8128 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8131 geometry[MaxTextExtent];
8133 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8134 (double) argument_list[9].real_reference+draw_info->affine.tx,
8135 (double) argument_list[10].real_reference+draw_info->affine.ty);
8136 (void) CloneString(&draw_info->geometry,geometry);
8138 if (attribute_flag[17] != 0)
8139 draw_info->stroke_width=argument_list[17].real_reference;
8140 if (attribute_flag[18] != 0)
8142 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8143 MagickTrue : MagickFalse;
8144 draw_info->stroke_antialias=draw_info->text_antialias;
8146 if (attribute_flag[19] != 0)
8147 (void) CloneString(&draw_info->family,
8148 argument_list[19].string_reference);
8149 if (attribute_flag[20] != 0)
8150 draw_info->style=(StyleType) argument_list[20].integer_reference;
8151 if (attribute_flag[21] != 0)
8152 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8153 if (attribute_flag[22] != 0)
8154 draw_info->weight=argument_list[22].integer_reference;
8155 if (attribute_flag[23] != 0)
8156 draw_info->align=(AlignType) argument_list[23].integer_reference;
8157 if (attribute_flag[24] != 0)
8158 (void) CloneString(&draw_info->encoding,
8159 argument_list[24].string_reference);
8160 if (attribute_flag[25] != 0)
8161 draw_info->fill_pattern=CloneImage(
8162 argument_list[25].image_reference,0,0,MagickTrue,exception);
8163 if (attribute_flag[26] != 0)
8164 draw_info->fill_pattern=CloneImage(
8165 argument_list[26].image_reference,0,0,MagickTrue,exception);
8166 if (attribute_flag[27] != 0)
8167 draw_info->stroke_pattern=CloneImage(
8168 argument_list[27].image_reference,0,0,MagickTrue,exception);
8169 if (attribute_flag[29] != 0)
8170 draw_info->kerning=argument_list[29].real_reference;
8171 if (attribute_flag[30] != 0)
8172 draw_info->interline_spacing=argument_list[30].real_reference;
8173 if (attribute_flag[31] != 0)
8174 draw_info->interword_spacing=argument_list[31].real_reference;
8175 if (attribute_flag[32] != 0)
8176 draw_info->direction=(DirectionType)
8177 argument_list[32].integer_reference;
8178 (void) AnnotateImage(image,draw_info,exception);
8179 draw_info=DestroyDrawInfo(draw_info);
8182 case 34: /* ColorFloodfill */
8194 virtual_pixel[MaxPixelChannels];
8196 draw_info=CloneDrawInfo(info ? info->image_info :
8197 (ImageInfo *) NULL,(DrawInfo *) NULL);
8198 if (attribute_flag[0] != 0)
8199 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8200 &geometry,exception);
8201 if (attribute_flag[1] != 0)
8202 geometry.x=argument_list[1].integer_reference;
8203 if (attribute_flag[2] != 0)
8204 geometry.y=argument_list[2].integer_reference;
8205 if (attribute_flag[3] != 0)
8206 (void) QueryColorCompliance(argument_list[3].string_reference,
8207 AllCompliance,&draw_info->fill,exception);
8208 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,
8209 virtual_pixel,exception);
8210 target.red=virtual_pixel[RedPixelChannel];
8211 target.green=virtual_pixel[GreenPixelChannel];
8212 target.blue=virtual_pixel[BluePixelChannel];
8213 target.alpha=virtual_pixel[AlphaPixelChannel];
8215 if (attribute_flag[4] != 0)
8217 QueryMagickColorCompliance(argument_list[4].string_reference,
8218 AllCompliance,&target,exception);
8221 if (attribute_flag[5] != 0)
8222 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8224 if (attribute_flag[6] != 0)
8225 invert=(MagickBooleanType) argument_list[6].integer_reference;
8226 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8227 geometry.y,invert,exception);
8228 draw_info=DestroyDrawInfo(draw_info);
8231 case 35: /* Composite */
8234 composite_geometry[MaxTextExtent];
8240 compose=OverCompositeOp;
8241 if (attribute_flag[0] != 0)
8242 composite_image=argument_list[0].image_reference;
8245 ThrowPerlException(exception,OptionError,
8246 "CompositeImageRequired",PackageName);
8250 Parameter Handling used for BOTH normal and tiled composition.
8252 if (attribute_flag[1] != 0) /* compose */
8253 compose=(CompositeOperator) argument_list[1].integer_reference;
8254 if (attribute_flag[6] != 0) /* opacity */
8256 if (compose != DissolveCompositeOp)
8257 (void) SetImageAlpha(composite_image,(Quantum)
8258 SiPrefixToDouble(argument_list[6].string_reference,
8281 Handle dissolve composite operator (patch by
8284 (void) CloneString(&image->geometry,
8285 argument_list[6].string_reference);
8286 opacity=(Quantum) SiPrefixToDouble(
8287 argument_list[6].string_reference,QuantumRange);
8288 if (composite_image->matte != MagickTrue)
8289 (void) SetImageAlpha(composite_image,OpaqueAlpha);
8290 composite_view=AcquireCacheView(composite_image);
8291 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8293 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8294 composite_image->columns,1,exception);
8295 for (x=0; x < (ssize_t) composite_image->columns; x++)
8297 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8298 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8300 q+=GetPixelChannels(composite_image);
8302 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8303 if (sync == MagickFalse)
8306 composite_view=DestroyCacheView(composite_view);
8309 if (attribute_flag[9] != 0) /* "color=>" */
8310 QueryColorCompliance(argument_list[9].string_reference,
8311 AllCompliance,&composite_image->background_color,exception);
8312 if (attribute_flag[12] != 0) /* "interpolate=>" */
8313 image->interpolate=(PixelInterpolateMethod)
8314 argument_list[12].integer_reference;
8315 if (attribute_flag[13] != 0) /* "args=>" */
8316 (void) SetImageArtifact(composite_image,"compose:args",
8317 argument_list[13].string_reference);
8318 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8319 (void) SetImageArtifact(composite_image,"compose:args",
8320 argument_list[14].string_reference);
8322 Tiling Composition (with orthogonal rotate).
8324 rotate_image=(Image *) NULL;
8325 if (attribute_flag[8] != 0) /* "rotate=>" */
8330 rotate_image=RotateImage(composite_image,
8331 argument_list[8].real_reference,exception);
8332 if (rotate_image == (Image *) NULL)
8335 if (attribute_flag[7] && argument_list[7].integer_reference) /* tile */
8342 Tile the composite image.
8344 if (attribute_flag[8] != 0) /* "tile=>" */
8345 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8348 (void) SetImageArtifact(composite_image,
8349 "compose:outside-overlay","false");
8350 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8351 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8353 if (attribute_flag[8] != 0) /* rotate */
8354 (void) CompositeImage(image,compose,rotate_image,x,y);
8356 (void) CompositeImage(image,compose,composite_image,x,y);
8358 if (attribute_flag[8] != 0) /* rotate */
8359 rotate_image=DestroyImage(rotate_image);
8363 Parameter Handling used used ONLY for normal composition.
8365 if (attribute_flag[5] != 0) /* gravity */
8366 image->gravity=(GravityType) argument_list[5].integer_reference;
8367 if (attribute_flag[2] != 0) /* geometry offset */
8369 SetGeometry(image,&geometry);
8370 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8372 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8375 if (attribute_flag[3] != 0) /* x offset */
8376 geometry.x=argument_list[3].integer_reference;
8377 if (attribute_flag[4] != 0) /* y offset */
8378 geometry.y=argument_list[4].integer_reference;
8379 if (attribute_flag[10] != 0) /* mask */
8381 if ((image->compose == DisplaceCompositeOp) ||
8382 (image->compose == DistortCompositeOp))
8385 Merge Y displacement into X displacement image.
8387 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8389 (void) CompositeImage(composite_image,CopyGreenCompositeOp,
8390 argument_list[10].image_reference,0,0);
8395 Set a blending mask for the composition.
8397 image->mask=CloneImage(argument_list[10].image_reference,0,0,
8398 MagickTrue,&image->exception);
8399 (void) NegateImage(image->mask,MagickFalse,exception);
8402 if (attribute_flag[11] != 0) /* channel */
8403 channel=(ChannelType) argument_list[11].integer_reference;
8405 Composite two images (normal composition).
8407 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8408 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8409 (double) composite_image->rows,(double) geometry.x,(double)
8411 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8413 channel_mask=SetPixelChannelMask(image,channel);
8414 if (attribute_flag[8] == 0) /* no rotate */
8415 CompositeImage(image,compose,composite_image,geometry.x,geometry.y);
8419 Position adjust rotated image then composite.
8421 geometry.x-=(ssize_t) (rotate_image->columns-
8422 composite_image->columns)/2;
8423 geometry.y-=(ssize_t) (rotate_image->rows-
8424 composite_image->rows)/2;
8425 CompositeImage(image,compose,rotate_image,geometry.x,geometry.y);
8426 rotate_image=DestroyImage(rotate_image);
8428 if (attribute_flag[10] != 0) /* mask */
8430 if ((image->compose == DisplaceCompositeOp) ||
8431 (image->compose == DistortCompositeOp))
8432 composite_image=DestroyImage(composite_image);
8434 image->mask=DestroyImage(image->mask);
8436 (void) SetPixelChannelMask(image,channel_mask);
8439 case 36: /* Contrast */
8441 if (attribute_flag[0] == 0)
8442 argument_list[0].integer_reference=0;
8443 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8444 MagickTrue : MagickFalse,exception);
8447 case 37: /* CycleColormap */
8449 if (attribute_flag[0] == 0)
8450 argument_list[0].integer_reference=6;
8451 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8460 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8462 (void) CloneString(&draw_info->primitive,"point");
8463 if (attribute_flag[0] != 0)
8465 if (argument_list[0].integer_reference < 0)
8466 (void) CloneString(&draw_info->primitive,
8467 argument_list[0].string_reference);
8469 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8470 MagickPrimitiveOptions,argument_list[0].integer_reference));
8472 if (attribute_flag[1] != 0)
8474 if (LocaleCompare(draw_info->primitive,"path") == 0)
8476 (void) ConcatenateString(&draw_info->primitive," '");
8477 ConcatenateString(&draw_info->primitive,
8478 argument_list[1].string_reference);
8479 (void) ConcatenateString(&draw_info->primitive,"'");
8483 (void) ConcatenateString(&draw_info->primitive," ");
8484 ConcatenateString(&draw_info->primitive,
8485 argument_list[1].string_reference);
8488 if (attribute_flag[2] != 0)
8490 (void) ConcatenateString(&draw_info->primitive," ");
8491 (void) ConcatenateString(&draw_info->primitive,
8492 CommandOptionToMnemonic(MagickMethodOptions,
8493 argument_list[2].integer_reference));
8495 if (attribute_flag[3] != 0)
8497 (void) QueryColorCompliance(argument_list[3].string_reference,
8498 AllCompliance,&draw_info->stroke,exception);
8499 if (argument_list[3].image_reference != (Image *) NULL)
8500 draw_info->stroke_pattern=CloneImage(
8501 argument_list[3].image_reference,0,0,MagickTrue,exception);
8503 if (attribute_flag[4] != 0)
8505 (void) QueryColorCompliance(argument_list[4].string_reference,
8506 AllCompliance,&draw_info->fill,exception);
8507 if (argument_list[4].image_reference != (Image *) NULL)
8508 draw_info->fill_pattern=CloneImage(
8509 argument_list[4].image_reference,0,0,MagickTrue,exception);
8511 if (attribute_flag[5] != 0)
8512 draw_info->stroke_width=argument_list[5].real_reference;
8513 if (attribute_flag[6] != 0)
8514 (void) CloneString(&draw_info->font,
8515 argument_list[6].string_reference);
8516 if (attribute_flag[7] != 0)
8517 (void) QueryColorCompliance(argument_list[7].string_reference,
8518 AllCompliance,&draw_info->border_color,exception);
8519 if (attribute_flag[8] != 0)
8520 draw_info->affine.tx=argument_list[8].real_reference;
8521 if (attribute_flag[9] != 0)
8522 draw_info->affine.ty=argument_list[9].real_reference;
8523 if (attribute_flag[20] != 0)
8528 av=(AV *) argument_list[20].array_reference;
8529 if ((av_len(av) != 3) && (av_len(av) != 5))
8531 ThrowPerlException(exception,OptionError,
8532 "affine matrix must have 4 or 6 elements",PackageName);
8535 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8536 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8537 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8538 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8539 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8540 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8542 ThrowPerlException(exception,OptionError,
8543 "affine matrix is singular",PackageName);
8546 if (av_len(av) == 5)
8548 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8549 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8552 for (j=10; j < 15; j++)
8554 if (attribute_flag[j] == 0)
8556 value=argument_list[j].string_reference;
8557 angle=argument_list[j].real_reference;
8558 current=draw_info->affine;
8559 GetAffineMatrix(&affine);
8567 flags=ParseGeometry(value,&geometry_info);
8568 affine.tx=geometry_info.xi;
8569 affine.ty=geometry_info.psi;
8570 if ((flags & PsiValue) == 0)
8571 affine.ty=affine.tx;
8579 flags=ParseGeometry(value,&geometry_info);
8580 affine.sx=geometry_info.rho;
8581 affine.sy=geometry_info.sigma;
8582 if ((flags & SigmaValue) == 0)
8583 affine.sy=affine.sx;
8593 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8594 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8595 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8596 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8604 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8612 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8616 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8617 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8618 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8619 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8620 draw_info->affine.tx=
8621 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8622 draw_info->affine.ty=
8623 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8625 if (attribute_flag[15] != 0)
8626 draw_info->fill_pattern=CloneImage(
8627 argument_list[15].image_reference,0,0,MagickTrue,exception);
8628 if (attribute_flag[16] != 0)
8629 draw_info->pointsize=argument_list[16].real_reference;
8630 if (attribute_flag[17] != 0)
8632 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8633 ? MagickTrue : MagickFalse;
8634 draw_info->text_antialias=draw_info->stroke_antialias;
8636 if (attribute_flag[18] != 0)
8637 (void) CloneString(&draw_info->density,
8638 argument_list[18].string_reference);
8639 if (attribute_flag[19] != 0)
8640 draw_info->stroke_width=argument_list[19].real_reference;
8641 if (attribute_flag[21] != 0)
8642 draw_info->dash_offset=argument_list[21].real_reference;
8643 if (attribute_flag[22] != 0)
8648 av=(AV *) argument_list[22].array_reference;
8649 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8650 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8651 if (draw_info->dash_pattern != (double *) NULL)
8653 for (i=0; i <= av_len(av); i++)
8654 draw_info->dash_pattern[i]=(double)
8655 SvNV(*(av_fetch(av,i,0)));
8656 draw_info->dash_pattern[i]=0.0;
8659 if (attribute_flag[23] != 0)
8660 image->interpolate=(PixelInterpolateMethod)
8661 argument_list[23].integer_reference;
8662 if ((attribute_flag[24] != 0) &&
8663 (draw_info->fill_pattern != (Image *) NULL))
8664 flags=ParsePageGeometry(draw_info->fill_pattern,
8665 argument_list[24].string_reference,
8666 &draw_info->fill_pattern->tile_offset,exception);
8667 if (attribute_flag[25] != 0)
8669 (void) ConcatenateString(&draw_info->primitive," '");
8670 (void) ConcatenateString(&draw_info->primitive,
8671 argument_list[25].string_reference);
8672 (void) ConcatenateString(&draw_info->primitive,"'");
8674 if (attribute_flag[26] != 0)
8675 draw_info->fill_pattern=CloneImage(
8676 argument_list[26].image_reference,0,0,MagickTrue,exception);
8677 if (attribute_flag[27] != 0)
8678 draw_info->stroke_pattern=CloneImage(
8679 argument_list[27].image_reference,0,0,MagickTrue,exception);
8680 if (attribute_flag[28] != 0)
8681 (void) CloneString(&draw_info->primitive,
8682 argument_list[28].string_reference);
8683 if (attribute_flag[29] != 0)
8684 draw_info->kerning=argument_list[29].real_reference;
8685 if (attribute_flag[30] != 0)
8686 draw_info->interline_spacing=argument_list[30].real_reference;
8687 if (attribute_flag[31] != 0)
8688 draw_info->interword_spacing=argument_list[31].real_reference;
8689 if (attribute_flag[32] != 0)
8690 draw_info->direction=(DirectionType)
8691 argument_list[32].integer_reference;
8692 DrawImage(image,draw_info,exception);
8693 draw_info=DestroyDrawInfo(draw_info);
8696 case 39: /* Equalize */
8698 if (attribute_flag[0] != 0)
8699 channel=(ChannelType) argument_list[0].integer_reference;
8700 channel_mask=SetPixelChannelMask(image,channel);
8701 EqualizeImage(image,exception);
8702 (void) SetPixelChannelMask(image,channel_mask);
8705 case 40: /* Gamma */
8707 if (attribute_flag[1] != 0)
8708 channel=(ChannelType) argument_list[1].integer_reference;
8709 if (attribute_flag[2] == 0)
8710 argument_list[2].real_reference=1.0;
8711 if (attribute_flag[3] == 0)
8712 argument_list[3].real_reference=1.0;
8713 if (attribute_flag[4] == 0)
8714 argument_list[4].real_reference=1.0;
8715 if (attribute_flag[0] == 0)
8717 (void) FormatLocaleString(message,MaxTextExtent,
8718 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8719 (double) argument_list[3].real_reference,
8720 (double) argument_list[4].real_reference);
8721 argument_list[0].string_reference=message;
8723 (void) GammaImage(image,InterpretLocaleValue(
8724 argument_list[0].string_reference,(char **) NULL),exception);
8732 if (attribute_flag[0] == 0)
8734 ThrowPerlException(exception,OptionError,"MapImageRequired",
8738 quantize_info=AcquireQuantizeInfo(info->image_info);
8739 if (attribute_flag[1] != 0)
8740 quantize_info->dither=(MagickBooleanType)
8741 argument_list[1].integer_reference;
8742 if (attribute_flag[2] != 0)
8743 quantize_info->dither_method=(DitherMethod)
8744 argument_list[2].integer_reference;
8745 (void) RemapImages(quantize_info,image,
8746 argument_list[0].image_reference,exception);
8747 quantize_info=DestroyQuantizeInfo(quantize_info);
8750 case 42: /* MatteFloodfill */
8762 virtual_pixel[MaxPixelChannels];
8764 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8766 if (attribute_flag[0] != 0)
8767 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8768 &geometry,exception);
8769 if (attribute_flag[1] != 0)
8770 geometry.x=argument_list[1].integer_reference;
8771 if (attribute_flag[2] != 0)
8772 geometry.y=argument_list[2].integer_reference;
8773 if (image->matte == MagickFalse)
8774 (void) SetImageAlpha(image,OpaqueAlpha);
8775 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,
8776 virtual_pixel,exception);
8777 target.red=virtual_pixel[RedPixelChannel];
8778 target.green=virtual_pixel[GreenPixelChannel];
8779 target.blue=virtual_pixel[BluePixelChannel];
8780 target.alpha=virtual_pixel[AlphaPixelChannel];
8781 if (attribute_flag[4] != 0)
8782 QueryMagickColorCompliance(argument_list[4].string_reference,
8783 AllCompliance,&target,exception);
8784 if (attribute_flag[3] != 0)
8785 target.alpha=SiPrefixToDouble(argument_list[3].string_reference,
8787 if (attribute_flag[5] != 0)
8788 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
8791 if (attribute_flag[6] != 0)
8792 invert=(MagickBooleanType) argument_list[6].integer_reference;
8793 channel_mask=SetPixelChannelMask(image,AlphaChannel);
8794 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8795 geometry.y,invert,exception);
8796 (void) SetPixelChannelMask(image,channel_mask);
8797 draw_info=DestroyDrawInfo(draw_info);
8800 case 43: /* Modulate */
8803 modulate[MaxTextExtent];
8805 geometry_info.rho=100.0;
8806 geometry_info.sigma=100.0;
8807 geometry_info.xi=100.0;
8808 if (attribute_flag[0] != 0)
8809 (void)ParseGeometry(argument_list[0].string_reference,
8811 if (attribute_flag[1] != 0)
8812 geometry_info.xi=argument_list[1].real_reference;
8813 if (attribute_flag[2] != 0)
8814 geometry_info.sigma=argument_list[2].real_reference;
8815 if (attribute_flag[3] != 0)
8817 geometry_info.sigma=argument_list[3].real_reference;
8818 SetImageArtifact(image,"modulate:colorspace","HWB");
8820 if (attribute_flag[4] != 0)
8822 geometry_info.rho=argument_list[4].real_reference;
8823 SetImageArtifact(image,"modulate:colorspace","HSB");
8825 if (attribute_flag[5] != 0)
8827 geometry_info.sigma=argument_list[5].real_reference;
8828 SetImageArtifact(image,"modulate:colorspace","HSL");
8830 if (attribute_flag[6] != 0)
8832 geometry_info.rho=argument_list[6].real_reference;
8833 SetImageArtifact(image,"modulate:colorspace","HWB");
8835 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8836 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8837 (void) ModulateImage(image,modulate,exception);
8840 case 44: /* Negate */
8842 if (attribute_flag[0] == 0)
8843 argument_list[0].integer_reference=0;
8844 if (attribute_flag[1] != 0)
8845 channel=(ChannelType) argument_list[1].integer_reference;
8846 channel_mask=SetPixelChannelMask(image,channel);
8847 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8848 MagickTrue : MagickFalse,exception);
8849 (void) SetPixelChannelMask(image,channel_mask);
8852 case 45: /* Normalize */
8854 if (attribute_flag[0] != 0)
8855 channel=(ChannelType) argument_list[0].integer_reference;
8856 channel_mask=SetPixelChannelMask(image,channel);
8857 NormalizeImage(image,exception);
8858 (void) SetPixelChannelMask(image,channel_mask);
8861 case 46: /* NumberColors */
8863 case 47: /* Opaque */
8872 (void) QueryMagickColorCompliance("none",AllCompliance,&target,
8874 (void) QueryMagickColorCompliance("none",AllCompliance,&fill_color,
8876 if (attribute_flag[0] != 0)
8877 (void) QueryMagickColorCompliance(argument_list[0].string_reference,
8878 AllCompliance,&target,exception);
8879 if (attribute_flag[1] != 0)
8880 (void) QueryMagickColorCompliance(argument_list[1].string_reference,
8881 AllCompliance,&fill_color,exception);
8882 if (attribute_flag[2] != 0)
8883 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
8885 if (attribute_flag[3] != 0)
8886 channel=(ChannelType) argument_list[3].integer_reference;
8888 if (attribute_flag[4] != 0)
8889 invert=(MagickBooleanType) argument_list[4].integer_reference;
8890 channel_mask=SetPixelChannelMask(image,channel);
8891 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
8892 (void) SetPixelChannelMask(image,channel_mask);
8895 case 48: /* Quantize */
8900 quantize_info=AcquireQuantizeInfo(info->image_info);
8901 if (attribute_flag[0] != 0)
8902 quantize_info->number_colors=(size_t)
8903 argument_list[0].integer_reference;
8904 if (attribute_flag[1] != 0)
8905 quantize_info->tree_depth=(size_t)
8906 argument_list[1].integer_reference;
8907 if (attribute_flag[2] != 0)
8908 quantize_info->colorspace=(ColorspaceType)
8909 argument_list[2].integer_reference;
8910 if (attribute_flag[3] != 0)
8911 quantize_info->dither=argument_list[3].integer_reference != 0 ?
8912 MagickTrue : MagickFalse;
8913 if (attribute_flag[4] != 0)
8914 quantize_info->measure_error=
8915 argument_list[4].integer_reference != 0 ? MagickTrue :
8917 if (attribute_flag[5] != 0)
8918 (void) QueryColorCompliance(argument_list[5].string_reference,
8919 AllCompliance,&image->transparent_color,exception);
8920 if (attribute_flag[5] && argument_list[5].integer_reference)
8922 (void) QuantizeImages(quantize_info,image,exception);
8925 if (attribute_flag[6] != 0)
8926 quantize_info->dither_method=(DitherMethod)
8927 argument_list[6].integer_reference;
8928 if ((image->storage_class == DirectClass) ||
8929 (image->colors > quantize_info->number_colors) ||
8930 (quantize_info->colorspace == GRAYColorspace))
8931 (void) QuantizeImage(quantize_info,image,exception);
8933 CompressImageColormap(image,exception);
8934 quantize_info=DestroyQuantizeInfo(quantize_info);
8937 case 49: /* Raise */
8939 if (attribute_flag[0] != 0)
8940 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8941 &geometry,exception);
8942 if (attribute_flag[1] != 0)
8943 geometry.width=argument_list[1].integer_reference;
8944 if (attribute_flag[2] != 0)
8945 geometry.height=argument_list[2].integer_reference;
8946 if (attribute_flag[3] == 0)
8947 argument_list[3].integer_reference=1;
8948 (void) RaiseImage(image,&geometry,
8949 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8953 case 50: /* Segment */
8960 smoothing_threshold;
8965 cluster_threshold=1.0;
8966 smoothing_threshold=1.5;
8967 colorspace=RGBColorspace;
8968 verbose=MagickFalse;
8969 if (attribute_flag[0] != 0)
8971 flags=ParseGeometry(argument_list[0].string_reference,
8973 cluster_threshold=geometry_info.rho;
8974 if (flags & SigmaValue)
8975 smoothing_threshold=geometry_info.sigma;
8977 if (attribute_flag[1] != 0)
8978 cluster_threshold=argument_list[1].real_reference;
8979 if (attribute_flag[2] != 0)
8980 smoothing_threshold=argument_list[2].real_reference;
8981 if (attribute_flag[3] != 0)
8982 colorspace=(ColorspaceType) argument_list[3].integer_reference;
8983 if (attribute_flag[4] != 0)
8984 verbose=argument_list[4].integer_reference != 0 ?
8985 MagickTrue : MagickFalse;
8986 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
8987 smoothing_threshold,exception);
8990 case 51: /* Signature */
8992 (void) SignatureImage(image,exception);
8995 case 52: /* Solarize */
8997 geometry_info.rho=QuantumRange/2.0;
8998 if (attribute_flag[0] != 0)
8999 flags=ParseGeometry(argument_list[0].string_reference,
9001 if (attribute_flag[1] != 0)
9002 geometry_info.rho=SiPrefixToDouble(
9003 argument_list[1].string_reference,QuantumRange);
9004 (void) SolarizeImage(image,geometry_info.rho,exception);
9009 (void) SyncImage(image);
9012 case 54: /* Texture */
9014 if (attribute_flag[0] == 0)
9016 TextureImage(image,argument_list[0].image_reference);
9019 case 55: /* Evalute */
9021 MagickEvaluateOperator
9024 op=SetEvaluateOperator;
9025 if (attribute_flag[0] == MagickFalse)
9026 argument_list[0].real_reference=0.0;
9027 if (attribute_flag[1] != MagickFalse)
9028 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9029 if (attribute_flag[2] != MagickFalse)
9030 channel=(ChannelType) argument_list[2].integer_reference;
9031 channel_mask=SetPixelChannelMask(image,channel);
9032 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9034 (void) SetPixelChannelMask(image,channel_mask);
9037 case 56: /* Transparent */
9048 (void) QueryMagickColorCompliance("none",AllCompliance,&target,
9050 if (attribute_flag[0] != 0)
9051 (void) QueryMagickColorCompliance(argument_list[0].string_reference,
9052 AllCompliance,&target,exception);
9053 opacity=TransparentAlpha;
9054 if (attribute_flag[1] != 0)
9055 opacity=SiPrefixToDouble(argument_list[1].string_reference,
9057 if (attribute_flag[2] != 0)
9058 image->fuzz=SiPrefixToDouble(argument_list[2].string_reference,
9060 if (attribute_flag[3] == 0)
9061 argument_list[3].integer_reference=0;
9063 if (attribute_flag[3] != 0)
9064 invert=(MagickBooleanType) argument_list[3].integer_reference;
9065 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9069 case 57: /* Threshold */
9074 if (attribute_flag[0] == 0)
9075 argument_list[0].string_reference="50%";
9076 if (attribute_flag[1] != 0)
9077 channel=(ChannelType) argument_list[1].integer_reference;
9078 threshold=SiPrefixToDouble(argument_list[0].string_reference,
9080 channel_mask=SetPixelChannelMask(image,channel);
9081 (void) BilevelImage(image,threshold);
9082 (void) SetPixelChannelMask(image,channel_mask);
9085 case 58: /* Charcoal */
9087 if (attribute_flag[0] != 0)
9089 flags=ParseGeometry(argument_list[0].string_reference,
9091 if ((flags & SigmaValue) == 0)
9092 geometry_info.sigma=1.0;
9094 if (attribute_flag[1] != 0)
9095 geometry_info.rho=argument_list[1].real_reference;
9096 if (attribute_flag[2] != 0)
9097 geometry_info.sigma=argument_list[2].real_reference;
9098 if (attribute_flag[3] != 0)
9099 geometry_info.xi=argument_list[3].real_reference;
9100 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9101 geometry_info.xi,exception);
9106 if (attribute_flag[0] != 0)
9107 image->fuzz=SiPrefixToDouble(argument_list[0].string_reference,
9109 image=TrimImage(image,exception);
9114 PixelInterpolateMethod
9117 if (attribute_flag[0] != 0)
9119 flags=ParseGeometry(argument_list[0].string_reference,
9121 if ((flags & SigmaValue) == 0)
9122 geometry_info.sigma=1.0;
9124 if (attribute_flag[1] != 0)
9125 geometry_info.rho=argument_list[1].real_reference;
9126 if (attribute_flag[2] != 0)
9127 geometry_info.sigma=argument_list[2].real_reference;
9128 method=UndefinedInterpolatePixel;
9129 if (attribute_flag[3] != 0)
9130 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9131 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9135 case 61: /* Separate */
9137 if (attribute_flag[0] != 0)
9138 channel=(ChannelType) argument_list[0].integer_reference;
9139 channel_mask=SetPixelChannelMask(image,channel);
9140 (void) SeparateImage(image);
9141 (void) SetPixelChannelMask(image,channel_mask);
9144 case 63: /* Stereo */
9146 if (attribute_flag[0] == 0)
9148 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9152 if (attribute_flag[1] != 0)
9153 geometry.x=argument_list[1].integer_reference;
9154 if (attribute_flag[2] != 0)
9155 geometry.y=argument_list[2].integer_reference;
9156 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9157 geometry.x,geometry.y,exception);
9160 case 64: /* Stegano */
9162 if (attribute_flag[0] == 0)
9164 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9168 if (attribute_flag[1] == 0)
9169 argument_list[1].integer_reference=0;
9170 image->offset=argument_list[1].integer_reference;
9171 image=SteganoImage(image,argument_list[0].image_reference,exception);
9174 case 65: /* Deconstruct */
9176 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9179 case 66: /* GaussianBlur */
9181 if (attribute_flag[0] != 0)
9183 flags=ParseGeometry(argument_list[0].string_reference,
9185 if ((flags & SigmaValue) == 0)
9186 geometry_info.sigma=1.0;
9188 if (attribute_flag[1] != 0)
9189 geometry_info.rho=argument_list[1].real_reference;
9190 if (attribute_flag[2] != 0)
9191 geometry_info.sigma=argument_list[2].real_reference;
9192 if (attribute_flag[3] != 0)
9193 geometry_info.xi=argument_list[3].real_reference;
9194 if (attribute_flag[4] != 0)
9195 channel=(ChannelType) argument_list[4].integer_reference;
9196 channel_mask=SetPixelChannelMask(image,channel);
9197 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9198 geometry_info.xi,exception);
9199 if (image != (Image *) NULL)
9200 (void) SetPixelChannelMask(image,channel_mask);
9203 case 67: /* Convolve */
9208 kernel=(KernelInfo *) NULL;
9209 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9211 if (attribute_flag[0] != 0)
9219 kernel=AcquireKernelInfo((const char *) NULL);
9220 if (kernel == (KernelInfo *) NULL)
9222 av=(AV *) argument_list[0].array_reference;
9223 order=(size_t) sqrt(av_len(av)+1);
9224 kernel->width=order;
9225 kernel->height=order;
9226 kernel->values=(double *) AcquireAlignedMemory(order,order*
9227 sizeof(*kernel->values));
9228 if (kernel->values == (double *) NULL)
9230 kernel=DestroyKernelInfo(kernel);
9231 ThrowPerlException(exception,ResourceLimitFatalError,
9232 "MemoryAllocationFailed",PackageName);
9235 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9236 kernel->values[j]=(double) SvNV(*(av_fetch(av,j,0)));
9237 for ( ; j < (ssize_t) (order*order); j++)
9238 kernel->values[j]=0.0;
9240 if (attribute_flag[1] != 0)
9241 channel=(ChannelType) argument_list[1].integer_reference;
9242 if (attribute_flag[2] != 0)
9243 image->bias=SiPrefixToDouble(argument_list[2].string_reference,
9245 if (attribute_flag[3] != 0)
9247 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9248 if (kernel == (KernelInfo *) NULL)
9251 channel_mask=SetPixelChannelMask(image,channel);
9252 kernel->bias=image->bias;
9253 image=ConvolveImage(image,kernel,exception);
9254 if (image != (Image *) NULL)
9255 (void) SetPixelChannelMask(image,channel_mask);
9256 kernel=DestroyKernelInfo(kernel);
9259 case 68: /* Profile */
9274 if (attribute_flag[0] != 0)
9275 name=argument_list[0].string_reference;
9276 if (attribute_flag[2] != 0)
9277 image->rendering_intent=(RenderingIntent)
9278 argument_list[2].integer_reference;
9279 if (attribute_flag[3] != 0)
9280 image->black_point_compensation=
9281 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9282 if (attribute_flag[1] != 0)
9284 if (argument_list[1].length == 0)
9287 Remove a profile from the image.
9289 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9294 Associate user supplied profile with the image.
9296 profile=AcquireStringInfo(argument_list[1].length);
9297 SetStringInfoDatum(profile,(const unsigned char *)
9298 argument_list[1].string_reference);
9299 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9300 (size_t) GetStringInfoLength(profile),MagickFalse);
9301 profile=DestroyStringInfo(profile);
9305 Associate a profile with the image.
9308 CloneImageInfo(info ? info->image_info : (ImageInfo *) NULL);
9309 (void) CopyMagickString(profile_info->filename,name,MaxTextExtent);
9310 profile_image=ReadImages(profile_info,&image->exception);
9311 if (profile_image == (Image *) NULL)
9313 ResetImageProfileIterator(profile_image);
9314 name=GetNextImageProfile(profile_image);
9315 while (name != (const char *) NULL)
9320 profile=GetImageProfile(profile_image,name);
9321 if (profile != (const StringInfo *) NULL)
9322 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9323 (size_t) GetStringInfoLength(profile),MagickFalse);
9324 name=GetNextImageProfile(profile_image);
9326 profile_image=DestroyImage(profile_image);
9327 profile_info=DestroyImageInfo(profile_info);
9330 case 69: /* UnsharpMask */
9332 if (attribute_flag[0] != 0)
9334 flags=ParseGeometry(argument_list[0].string_reference,
9336 if ((flags & SigmaValue) == 0)
9337 geometry_info.sigma=1.0;
9338 if ((flags & XiValue) == 0)
9339 geometry_info.xi=1.0;
9340 if ((flags & PsiValue) == 0)
9341 geometry_info.psi=0.5;
9343 if (attribute_flag[1] != 0)
9344 geometry_info.rho=argument_list[1].real_reference;
9345 if (attribute_flag[2] != 0)
9346 geometry_info.sigma=argument_list[2].real_reference;
9347 if (attribute_flag[3] != 0)
9348 geometry_info.xi=argument_list[3].real_reference;
9349 if (attribute_flag[4] != 0)
9350 geometry_info.psi=argument_list[4].real_reference;
9351 if (attribute_flag[5] != 0)
9352 channel=(ChannelType) argument_list[5].integer_reference;
9353 channel_mask=SetPixelChannelMask(image,channel);
9354 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9355 geometry_info.xi,geometry_info.psi,exception);
9356 if (image != (Image *) NULL)
9357 (void) SetPixelChannelMask(image,channel_mask);
9360 case 70: /* MotionBlur */
9362 if (attribute_flag[0] != 0)
9364 flags=ParseGeometry(argument_list[0].string_reference,
9366 if ((flags & SigmaValue) == 0)
9367 geometry_info.sigma=1.0;
9368 if ((flags & XiValue) == 0)
9369 geometry_info.xi=1.0;
9371 if (attribute_flag[1] != 0)
9372 geometry_info.rho=argument_list[1].real_reference;
9373 if (attribute_flag[2] != 0)
9374 geometry_info.sigma=argument_list[2].real_reference;
9375 if (attribute_flag[3] != 0)
9376 geometry_info.xi=argument_list[3].real_reference;
9377 if (attribute_flag[4] != 0)
9378 geometry_info.psi=argument_list[4].real_reference;
9379 if (attribute_flag[5] != 0)
9380 channel=(ChannelType) argument_list[5].integer_reference;
9381 channel_mask=SetPixelChannelMask(image,channel);
9382 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9383 geometry_info.xi,geometry_info.psi,exception);
9384 if (image != (Image *) NULL)
9385 (void) SetPixelChannelMask(image,channel_mask);
9388 case 71: /* OrderedDither */
9390 if (attribute_flag[0] == 0)
9391 argument_list[0].string_reference="o8x8";
9392 if (attribute_flag[1] != 0)
9393 channel=(ChannelType) argument_list[1].integer_reference;
9394 channel_mask=SetPixelChannelMask(image,channel);
9395 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9397 (void) SetPixelChannelMask(image,channel_mask);
9400 case 72: /* Shave */
9402 if (attribute_flag[0] != 0)
9403 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9404 &geometry,exception);
9405 if (attribute_flag[1] != 0)
9406 geometry.width=argument_list[1].integer_reference;
9407 if (attribute_flag[2] != 0)
9408 geometry.height=argument_list[2].integer_reference;
9409 image=ShaveImage(image,&geometry,exception);
9412 case 73: /* Level */
9420 white_point=(MagickRealType) image->columns*image->rows;
9422 if (attribute_flag[0] != 0)
9424 flags=ParseGeometry(argument_list[0].string_reference,
9426 black_point=geometry_info.rho;
9427 if ((flags & SigmaValue) != 0)
9428 white_point=geometry_info.sigma;
9429 if ((flags & XiValue) != 0)
9430 gamma=geometry_info.xi;
9431 if ((flags & PercentValue) != 0)
9433 black_point*=(double) (QuantumRange/100.0);
9434 white_point*=(double) (QuantumRange/100.0);
9436 if ((flags & SigmaValue) == 0)
9437 white_point=(double) QuantumRange-black_point;
9439 if (attribute_flag[1] != 0)
9440 black_point=argument_list[1].real_reference;
9441 if (attribute_flag[2] != 0)
9442 white_point=argument_list[2].real_reference;
9443 if (attribute_flag[3] != 0)
9444 gamma=argument_list[3].real_reference;
9445 if (attribute_flag[4] != 0)
9446 channel=(ChannelType) argument_list[4].integer_reference;
9447 if (attribute_flag[5] != 0)
9449 argument_list[0].real_reference=argument_list[5].real_reference;
9450 attribute_flag[0]=attribute_flag[5];
9452 channel_mask=SetPixelChannelMask(image,channel);
9453 (void) LevelImage(image,black_point,white_point,gamma,exception);
9454 (void) SetPixelChannelMask(image,channel_mask);
9459 if (attribute_flag[0] == 0)
9460 argument_list[0].string_reference="#1";
9461 if (attribute_flag[1] == 0)
9462 argument_list[1].integer_reference=MagickTrue;
9463 (void) ClipImagePath(image,argument_list[0].string_reference,
9464 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9468 case 75: /* AffineTransform */
9473 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9475 if (attribute_flag[0] != 0)
9480 av=(AV *) argument_list[0].array_reference;
9481 if ((av_len(av) != 3) && (av_len(av) != 5))
9483 ThrowPerlException(exception,OptionError,
9484 "affine matrix must have 4 or 6 elements",PackageName);
9487 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9488 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9489 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9490 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9491 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9492 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9494 ThrowPerlException(exception,OptionError,
9495 "affine matrix is singular",PackageName);
9498 if (av_len(av) == 5)
9500 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9501 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9504 for (j=1; j < 6; j++)
9506 if (attribute_flag[j] == 0)
9508 value=argument_list[j].string_reference;
9509 angle=argument_list[j].real_reference;
9510 current=draw_info->affine;
9511 GetAffineMatrix(&affine);
9519 flags=ParseGeometry(value,&geometry_info);
9520 affine.tx=geometry_info.xi;
9521 affine.ty=geometry_info.psi;
9522 if ((flags & PsiValue) == 0)
9523 affine.ty=affine.tx;
9531 flags=ParseGeometry(value,&geometry_info);
9532 affine.sx=geometry_info.rho;
9533 affine.sy=geometry_info.sigma;
9534 if ((flags & SigmaValue) == 0)
9535 affine.sy=affine.sx;
9545 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9546 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9547 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9548 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9556 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9564 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9568 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9569 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9570 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9571 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9572 draw_info->affine.tx=
9573 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9574 draw_info->affine.ty=
9575 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9577 if (attribute_flag[6] != 0)
9578 image->interpolate=(PixelInterpolateMethod)
9579 argument_list[6].integer_reference;
9580 if (attribute_flag[7] != 0)
9581 QueryColorCompliance(argument_list[7].string_reference,
9582 AllCompliance,&image->background_color,exception);
9583 image=AffineTransformImage(image,&draw_info->affine,exception);
9584 draw_info=DestroyDrawInfo(draw_info);
9587 case 76: /* Difference */
9589 if (attribute_flag[0] == 0)
9591 ThrowPerlException(exception,OptionError,
9592 "ReferenceImageRequired",PackageName);
9595 if (attribute_flag[1] != 0)
9596 image->fuzz=SiPrefixToDouble(argument_list[1].string_reference,
9598 (void) IsImagesEqual(image,argument_list[0].image_reference,
9602 case 77: /* AdaptiveThreshold */
9604 if (attribute_flag[0] != 0)
9606 flags=ParseGeometry(argument_list[0].string_reference,
9608 if ((flags & PercentValue) != 0)
9609 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9611 if (attribute_flag[1] != 0)
9612 geometry_info.rho=argument_list[1].integer_reference;
9613 if (attribute_flag[2] != 0)
9614 geometry_info.sigma=argument_list[2].integer_reference;
9615 if (attribute_flag[3] != 0)
9616 geometry_info.xi=argument_list[3].integer_reference;;
9617 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9618 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9621 case 78: /* Resample */
9627 if (attribute_flag[0] != 0)
9629 flags=ParseGeometry(argument_list[0].string_reference,
9631 if ((flags & SigmaValue) == 0)
9632 geometry_info.sigma=geometry_info.rho;
9634 if (attribute_flag[1] != 0)
9635 geometry_info.rho=argument_list[1].real_reference;
9636 if (attribute_flag[2] != 0)
9637 geometry_info.sigma=argument_list[2].real_reference;
9638 if (attribute_flag[3] == 0)
9639 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9640 if (attribute_flag[4] == 0)
9641 SetImageArtifact(image,"filter:support",
9642 argument_list[4].string_reference);
9643 if (attribute_flag[5] != 0)
9644 argument_list[5].real_reference=1.0;
9645 width=(size_t) (geometry_info.rho*image->columns/
9646 (image->x_resolution == 0.0 ? 72.0 : image->x_resolution)+0.5);
9647 height=(size_t) (geometry_info.sigma*image->rows/
9648 (image->y_resolution == 0.0 ? 72.0 : image->y_resolution)+0.5);
9649 image=ResizeImage(image,width,height,(FilterTypes)
9650 argument_list[3].integer_reference,argument_list[5].real_reference,
9652 if (image != (Image *) NULL)
9654 image->x_resolution=geometry_info.rho;
9655 image->y_resolution=geometry_info.sigma;
9659 case 79: /* Describe */
9661 if (attribute_flag[0] == 0)
9662 argument_list[0].file_reference=(FILE *) NULL;
9663 if (attribute_flag[1] != 0)
9664 (void) SetImageArtifact(image,"identify:features",
9665 argument_list[1].string_reference);
9666 (void) IdentifyImage(image,argument_list[0].file_reference,
9667 MagickTrue,exception);
9670 case 80: /* BlackThreshold */
9672 if (attribute_flag[0] == 0)
9673 argument_list[0].string_reference="50%";
9674 if (attribute_flag[2] != 0)
9675 channel=(ChannelType) argument_list[2].integer_reference;
9676 channel_mask=SetPixelChannelMask(image,channel);
9677 BlackThresholdImage(image,argument_list[0].string_reference,
9679 (void) SetPixelChannelMask(image,channel_mask);
9682 case 81: /* WhiteThreshold */
9684 if (attribute_flag[0] == 0)
9685 argument_list[0].string_reference="50%";
9686 if (attribute_flag[2] != 0)
9687 channel=(ChannelType) argument_list[2].integer_reference;
9688 channel_mask=SetPixelChannelMask(image,channel);
9689 WhiteThresholdImage(image,argument_list[0].string_reference,
9691 (void) SetPixelChannelMask(image,channel_mask);
9694 case 82: /* RadialBlur */
9696 if (attribute_flag[0] != 0)
9698 flags=ParseGeometry(argument_list[0].string_reference,
9701 if (attribute_flag[1] != 0)
9702 geometry_info.rho=argument_list[1].real_reference;
9703 if (attribute_flag[2] != 0)
9704 geometry_info.sigma=argument_list[2].real_reference;
9705 if (attribute_flag[3] != 0)
9706 channel=(ChannelType) argument_list[3].integer_reference;
9707 channel_mask=SetPixelChannelMask(image,channel);
9708 image=RadialBlurImage(image,geometry_info.rho,geometry_info.sigma,
9710 if (image != (Image *) NULL)
9711 (void) SetPixelChannelMask(image,channel_mask);
9714 case 83: /* Thumbnail */
9716 if (attribute_flag[0] != 0)
9717 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9718 &geometry,exception);
9719 if (attribute_flag[1] != 0)
9720 geometry.width=argument_list[1].integer_reference;
9721 if (attribute_flag[2] != 0)
9722 geometry.height=argument_list[2].integer_reference;
9723 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9726 case 84: /* Strip */
9728 (void) StripImage(image);
9736 GetPixelInfo(image,&tint);
9737 if (attribute_flag[0] != 0)
9738 (void) QueryMagickColorCompliance(argument_list[0].string_reference,
9739 AllCompliance,&tint,exception);
9740 if (attribute_flag[1] == 0)
9741 argument_list[1].string_reference="100";
9742 image=TintImage(image,argument_list[1].string_reference,&tint,
9746 case 86: /* Channel */
9748 if (attribute_flag[0] != 0)
9749 channel=(ChannelType) argument_list[0].integer_reference;
9750 channel_mask=SetPixelChannelMask(image,channel);
9751 (void) SeparateImage(image);
9752 (void) SetPixelChannelMask(image,channel_mask);
9755 case 87: /* Splice */
9757 if (attribute_flag[0] != 0)
9758 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9759 &geometry,exception);
9760 if (attribute_flag[1] != 0)
9761 geometry.width=argument_list[1].integer_reference;
9762 if (attribute_flag[2] != 0)
9763 geometry.height=argument_list[2].integer_reference;
9764 if (attribute_flag[3] != 0)
9765 geometry.x=argument_list[3].integer_reference;
9766 if (attribute_flag[4] != 0)
9767 geometry.y=argument_list[4].integer_reference;
9768 if (attribute_flag[5] != 0)
9769 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9771 if (attribute_flag[6] != 0)
9772 (void) QueryColorCompliance(argument_list[6].string_reference,
9773 AllCompliance,&image->background_color,exception);
9774 if (attribute_flag[7] != 0)
9775 image->gravity=(GravityType) argument_list[7].integer_reference;
9776 image=SpliceImage(image,&geometry,exception);
9779 case 88: /* Posterize */
9781 if (attribute_flag[0] == 0)
9782 argument_list[0].integer_reference=3;
9783 if (attribute_flag[1] == 0)
9784 argument_list[1].integer_reference=0;
9785 (void) PosterizeImage(image,argument_list[0].integer_reference,
9786 argument_list[1].integer_reference ? MagickTrue : MagickFalse,
9790 case 89: /* Shadow */
9792 if (attribute_flag[0] != 0)
9794 flags=ParseGeometry(argument_list[0].string_reference,
9796 if ((flags & SigmaValue) == 0)
9797 geometry_info.sigma=1.0;
9798 if ((flags & XiValue) == 0)
9799 geometry_info.xi=4.0;
9800 if ((flags & PsiValue) == 0)
9801 geometry_info.psi=4.0;
9803 if (attribute_flag[1] != 0)
9804 geometry_info.rho=argument_list[1].real_reference;
9805 if (attribute_flag[2] != 0)
9806 geometry_info.sigma=argument_list[2].real_reference;
9807 if (attribute_flag[3] != 0)
9808 geometry_info.xi=argument_list[3].integer_reference;
9809 if (attribute_flag[4] != 0)
9810 geometry_info.psi=argument_list[4].integer_reference;
9811 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9812 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9816 case 90: /* Identify */
9818 if (attribute_flag[0] == 0)
9819 argument_list[0].file_reference=(FILE *) NULL;
9820 if (attribute_flag[1] != 0)
9821 (void) SetImageArtifact(image,"identify:features",
9822 argument_list[1].string_reference);
9823 if ((attribute_flag[2] != 0) &&
9824 (argument_list[2].integer_reference != 0))
9825 (void) SetImageArtifact(image,"identify:unique","true");
9826 (void) IdentifyImage(image,argument_list[0].file_reference,
9827 MagickTrue,exception);
9830 case 91: /* SepiaTone */
9832 if (attribute_flag[0] == 0)
9833 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9834 image=SepiaToneImage(image,argument_list[0].real_reference,
9838 case 92: /* SigmoidalContrast */
9843 if (attribute_flag[0] != 0)
9845 flags=ParseGeometry(argument_list[0].string_reference,
9847 if ((flags & SigmaValue) == 0)
9848 geometry_info.sigma=QuantumRange/2.0;
9849 if ((flags & PercentValue) != 0)
9850 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9852 if (attribute_flag[1] != 0)
9853 geometry_info.rho=argument_list[1].real_reference;
9854 if (attribute_flag[2] != 0)
9855 geometry_info.sigma=argument_list[2].real_reference;
9856 if (attribute_flag[3] != 0)
9857 channel=(ChannelType) argument_list[3].integer_reference;
9859 if (attribute_flag[4] != 0)
9860 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9862 channel_mask=SetPixelChannelMask(image,channel);
9863 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9864 geometry_info.sigma,exception);
9865 (void) SetPixelChannelMask(image,channel_mask);
9868 case 93: /* Extent */
9870 if (attribute_flag[7] != 0)
9871 image->gravity=(GravityType) argument_list[7].integer_reference;
9872 if (attribute_flag[0] != 0)
9877 flags=ParseGravityGeometry(image,
9878 argument_list[0].string_reference,&geometry,exception);
9880 if (geometry.width == 0)
9881 geometry.width=image->columns;
9882 if (geometry.height == 0)
9883 geometry.height=image->rows;
9885 if (attribute_flag[1] != 0)
9886 geometry.width=argument_list[1].integer_reference;
9887 if (attribute_flag[2] != 0)
9888 geometry.height=argument_list[2].integer_reference;
9889 if (attribute_flag[3] != 0)
9890 geometry.x=argument_list[3].integer_reference;
9891 if (attribute_flag[4] != 0)
9892 geometry.y=argument_list[4].integer_reference;
9893 if (attribute_flag[5] != 0)
9894 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
9896 if (attribute_flag[6] != 0)
9897 (void) QueryColorCompliance(argument_list[6].string_reference,
9898 AllCompliance,&image->background_color,exception);
9899 image=ExtentImage(image,&geometry,exception);
9902 case 94: /* Vignette */
9904 if (attribute_flag[0] != 0)
9906 flags=ParseGeometry(argument_list[0].string_reference,
9908 if ((flags & SigmaValue) == 0)
9909 geometry_info.sigma=1.0;
9910 if ((flags & XiValue) == 0)
9911 geometry_info.xi=0.1*image->columns;
9912 if ((flags & PsiValue) == 0)
9913 geometry_info.psi=0.1*image->rows;
9915 if (attribute_flag[1] != 0)
9916 geometry_info.rho=argument_list[1].real_reference;
9917 if (attribute_flag[2] != 0)
9918 geometry_info.sigma=argument_list[2].real_reference;
9919 if (attribute_flag[3] != 0)
9920 geometry_info.xi=argument_list[3].integer_reference;
9921 if (attribute_flag[4] != 0)
9922 geometry_info.psi=argument_list[4].integer_reference;
9923 if (attribute_flag[5] != 0)
9924 (void) QueryColorCompliance(argument_list[5].string_reference,
9925 AllCompliance,&image->background_color,exception);
9926 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
9927 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t) ceil(geometry_info.psi-
9931 case 95: /* ContrastStretch */
9938 white_point=(MagickRealType) image->columns*image->rows;
9939 if (attribute_flag[0] != 0)
9941 flags=ParseGeometry(argument_list[0].string_reference,
9943 black_point=geometry_info.rho;
9944 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
9946 if ((flags & PercentValue) != 0)
9948 black_point*=(double) image->columns*image->rows/100.0;
9949 white_point*=(double) image->columns*image->rows/100.0;
9951 white_point=(MagickRealType) image->columns*image->rows-
9954 if (attribute_flag[1] != 0)
9955 black_point=argument_list[1].real_reference;
9956 if (attribute_flag[2] != 0)
9957 white_point=argument_list[2].real_reference;
9958 if (attribute_flag[4] != 0)
9959 channel=(ChannelType) argument_list[4].integer_reference;
9960 channel_mask=SetPixelChannelMask(image,channel);
9961 (void) ContrastStretchImage(image,black_point,white_point,exception);
9962 (void) SetPixelChannelMask(image,channel_mask);
9965 case 96: /* Sans0 */
9969 case 97: /* Sans1 */
9973 case 98: /* AdaptiveSharpen */
9975 if (attribute_flag[0] != 0)
9977 flags=ParseGeometry(argument_list[0].string_reference,
9979 if ((flags & SigmaValue) == 0)
9980 geometry_info.sigma=1.0;
9981 if ((flags & XiValue) == 0)
9982 geometry_info.xi=0.0;
9984 if (attribute_flag[1] != 0)
9985 geometry_info.rho=argument_list[1].real_reference;
9986 if (attribute_flag[2] != 0)
9987 geometry_info.sigma=argument_list[2].real_reference;
9988 if (attribute_flag[3] != 0)
9989 geometry_info.xi=argument_list[3].real_reference;
9990 if (attribute_flag[4] != 0)
9991 channel=(ChannelType) argument_list[4].integer_reference;
9992 channel_mask=SetPixelChannelMask(image,channel);
9993 image=AdaptiveSharpenImage(image,geometry_info.rho,
9994 geometry_info.sigma,geometry_info.xi,exception);
9995 if (image != (Image *) NULL)
9996 (void) SetPixelChannelMask(image,channel_mask);
9999 case 99: /* Transpose */
10001 image=TransposeImage(image,exception);
10004 case 100: /* Tranverse */
10006 image=TransverseImage(image,exception);
10009 case 101: /* AutoOrient */
10011 switch (image->orientation)
10013 case TopRightOrientation:
10015 image=FlopImage(image,exception);
10018 case BottomRightOrientation:
10020 image=RotateImage(image,180.0,exception);
10023 case BottomLeftOrientation:
10025 image=FlipImage(image,exception);
10028 case LeftTopOrientation:
10030 image=TransposeImage(image,exception);
10033 case RightTopOrientation:
10035 image=RotateImage(image,90.0,exception);
10038 case RightBottomOrientation:
10040 image=TransverseImage(image,exception);
10043 case LeftBottomOrientation:
10045 image=RotateImage(image,270.0,exception);
10053 case 102: /* AdaptiveBlur */
10055 if (attribute_flag[0] != 0)
10057 flags=ParseGeometry(argument_list[0].string_reference,
10059 if ((flags & SigmaValue) == 0)
10060 geometry_info.sigma=1.0;
10061 if ((flags & XiValue) == 0)
10062 geometry_info.xi=0.0;
10064 if (attribute_flag[1] != 0)
10065 geometry_info.rho=argument_list[1].real_reference;
10066 if (attribute_flag[2] != 0)
10067 geometry_info.sigma=argument_list[2].real_reference;
10068 if (attribute_flag[3] != 0)
10069 geometry_info.xi=argument_list[3].real_reference;
10070 if (attribute_flag[4] != 0)
10071 channel=(ChannelType) argument_list[4].integer_reference;
10072 channel_mask=SetPixelChannelMask(image,channel);
10073 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10074 geometry_info.xi,exception);
10075 if (image != (Image *) NULL)
10076 (void) SetPixelChannelMask(image,channel_mask);
10079 case 103: /* Sketch */
10081 if (attribute_flag[0] != 0)
10083 flags=ParseGeometry(argument_list[0].string_reference,
10085 if ((flags & SigmaValue) == 0)
10086 geometry_info.sigma=1.0;
10087 if ((flags & XiValue) == 0)
10088 geometry_info.xi=1.0;
10090 if (attribute_flag[1] != 0)
10091 geometry_info.rho=argument_list[1].real_reference;
10092 if (attribute_flag[2] != 0)
10093 geometry_info.sigma=argument_list[2].real_reference;
10094 if (attribute_flag[3] != 0)
10095 geometry_info.xi=argument_list[3].real_reference;
10096 if (attribute_flag[4] != 0)
10097 geometry_info.psi=argument_list[4].real_reference;
10098 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10099 geometry_info.xi,geometry_info.psi,exception);
10102 case 104: /* UniqueColors */
10104 image=UniqueImageColors(image,exception);
10107 case 105: /* AdaptiveResize */
10109 PixelInterpolateMethod
10112 if (attribute_flag[0] != 0)
10113 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10114 &geometry,exception);
10115 if (attribute_flag[1] != 0)
10116 geometry.width=argument_list[1].integer_reference;
10117 if (attribute_flag[2] != 0)
10118 geometry.height=argument_list[2].integer_reference;
10119 if (attribute_flag[3] != 0)
10120 image->filter=(FilterTypes) argument_list[4].integer_reference;
10121 if (attribute_flag[4] != 0)
10122 SetImageArtifact(image,"filter:support",
10123 argument_list[4].string_reference);
10124 if (attribute_flag[5] != 0)
10125 image->blur=argument_list[5].real_reference;
10126 method=UndefinedInterpolatePixel;
10127 if (attribute_flag[6] != 0)
10128 method=(PixelInterpolateMethod) argument_list[6].integer_reference;
10129 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10133 case 106: /* ClipMask */
10135 if (attribute_flag[0] == 0)
10137 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10139 goto PerlException;
10141 image->clip_mask=CloneImage(argument_list[0].image_reference,0,0,
10142 MagickTrue,exception);
10143 (void) NegateImage(image->clip_mask,MagickFalse,exception);
10146 case 107: /* LinearStretch */
10153 white_point=(MagickRealType) image->columns*image->rows;
10154 if (attribute_flag[0] != 0)
10156 flags=ParseGeometry(argument_list[0].string_reference,
10158 if ((flags & SigmaValue) != 0)
10159 white_point=geometry_info.sigma;
10160 if ((flags & PercentValue) != 0)
10162 black_point*=(double) image->columns*image->rows/100.0;
10163 white_point*=(double) image->columns*image->rows/100.0;
10165 if ((flags & SigmaValue) == 0)
10166 white_point=(double) image->columns*image->rows-black_point;
10168 if (attribute_flag[1] != 0)
10169 black_point=argument_list[1].real_reference;
10170 if (attribute_flag[2] != 0)
10171 white_point=argument_list[2].real_reference;
10172 (void) LinearStretchImage(image,black_point,white_point,exception);
10175 case 109: /* Mask */
10177 if (attribute_flag[0] == 0)
10179 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10181 goto PerlException;
10183 image->mask=CloneImage(argument_list[0].image_reference,0,0,
10184 MagickTrue,exception);
10185 (void) NegateImage(image->mask,MagickFalse,exception);
10188 case 110: /* Polaroid */
10196 PixelInterpolateMethod
10199 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10200 (DrawInfo *) NULL);
10201 if (attribute_flag[0] != 0)
10202 (void) SetImageProperty(image,"caption",InterpretImageProperties(
10203 info ? info->image_info : (ImageInfo *) NULL,image,
10204 argument_list[0].string_reference,exception));
10206 if (attribute_flag[1] != 0)
10207 angle=argument_list[1].real_reference;
10208 if (attribute_flag[2] != 0)
10209 (void) CloneString(&draw_info->font,
10210 argument_list[2].string_reference);
10211 if (attribute_flag[3] != 0)
10212 (void) QueryColorCompliance(argument_list[3].string_reference,
10213 AllCompliance,&draw_info->stroke,exception);
10214 if (attribute_flag[4] != 0)
10215 (void) QueryColorCompliance(argument_list[4].string_reference,
10216 AllCompliance,&draw_info->fill,exception);
10217 if (attribute_flag[5] != 0)
10218 draw_info->stroke_width=argument_list[5].real_reference;
10219 if (attribute_flag[6] != 0)
10220 draw_info->pointsize=argument_list[6].real_reference;
10221 if (attribute_flag[7] != 0)
10222 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10223 if (attribute_flag[8] != 0)
10224 (void) QueryColorCompliance(argument_list[8].string_reference,
10225 AllCompliance,&image->background_color,exception);
10226 method=UndefinedInterpolatePixel;
10227 if (attribute_flag[9] != 0)
10228 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10229 image=PolaroidImage(image,draw_info,angle,method,exception);
10230 draw_info=DestroyDrawInfo(draw_info);
10233 case 111: /* FloodfillPaint */
10245 virtual_pixel[MaxPixelChannels];
10247 draw_info=CloneDrawInfo(info ? info->image_info :
10248 (ImageInfo *) NULL,(DrawInfo *) NULL);
10249 if (attribute_flag[0] != 0)
10250 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10251 &geometry,exception);
10252 if (attribute_flag[1] != 0)
10253 geometry.x=argument_list[1].integer_reference;
10254 if (attribute_flag[2] != 0)
10255 geometry.y=argument_list[2].integer_reference;
10256 if (attribute_flag[3] != 0)
10257 (void) QueryColorCompliance(argument_list[3].string_reference,
10258 AllCompliance,&draw_info->fill,exception);
10259 (void) GetOneVirtualMagickPixel(image,geometry.x,geometry.y,
10260 virtual_pixel,exception);
10261 target.red=virtual_pixel[RedPixelChannel];
10262 target.green=virtual_pixel[GreenPixelChannel];
10263 target.blue=virtual_pixel[BluePixelChannel];
10264 target.alpha=virtual_pixel[AlphaPixelChannel];
10265 if (attribute_flag[4] != 0)
10266 QueryMagickColorCompliance(argument_list[4].string_reference,
10267 AllCompliance,&target,exception);
10268 if (attribute_flag[5] != 0)
10269 image->fuzz=SiPrefixToDouble(argument_list[5].string_reference,
10271 if (attribute_flag[6] != 0)
10272 channel=(ChannelType) argument_list[6].integer_reference;
10273 invert=MagickFalse;
10274 if (attribute_flag[7] != 0)
10275 invert=(MagickBooleanType) argument_list[7].integer_reference;
10276 channel_mask=SetPixelChannelMask(image,channel);
10277 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10278 geometry.y,invert,exception);
10279 (void) SetPixelChannelMask(image,channel_mask);
10280 draw_info=DestroyDrawInfo(draw_info);
10283 case 112: /* Distort */
10295 number_coordinates;
10300 if (attribute_flag[0] == 0)
10302 method=UndefinedDistortion;
10303 if (attribute_flag[1] != 0)
10304 method=(DistortImageMethod) argument_list[1].integer_reference;
10305 av=(AV *) argument_list[0].array_reference;
10306 number_coordinates=(size_t) av_len(av)+1;
10307 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10308 sizeof(*coordinates));
10309 if (coordinates == (double *) NULL)
10311 ThrowPerlException(exception,ResourceLimitFatalError,
10312 "MemoryAllocationFailed",PackageName);
10313 goto PerlException;
10315 for (j=0; j < (ssize_t) number_coordinates; j++)
10316 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10317 virtual_pixel=UndefinedVirtualPixelMethod;
10318 if (attribute_flag[2] != 0)
10319 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10320 argument_list[2].integer_reference);
10321 image=DistortImage(image,method,number_coordinates,coordinates,
10322 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10324 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10325 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10326 coordinates=(double *) RelinquishMagickMemory(coordinates);
10329 case 113: /* Clut */
10331 PixelInterpolateMethod
10334 if (attribute_flag[0] == 0)
10336 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10338 goto PerlException;
10340 method=UndefinedInterpolatePixel;
10341 if (attribute_flag[1] != 0)
10342 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10343 if (attribute_flag[2] != 0)
10344 channel=(ChannelType) argument_list[2].integer_reference;
10345 channel_mask=SetPixelChannelMask(image,channel);
10346 (void) ClutImage(image,argument_list[0].image_reference,method,
10348 (void) SetPixelChannelMask(image,channel_mask);
10351 case 114: /* LiquidRescale */
10353 if (attribute_flag[0] != 0)
10354 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10355 &geometry,exception);
10356 if (attribute_flag[1] != 0)
10357 geometry.width=argument_list[1].integer_reference;
10358 if (attribute_flag[2] != 0)
10359 geometry.height=argument_list[2].integer_reference;
10360 if (attribute_flag[3] == 0)
10361 argument_list[3].real_reference=1.0;
10362 if (attribute_flag[4] == 0)
10363 argument_list[4].real_reference=0.0;
10364 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10365 argument_list[3].real_reference,argument_list[4].real_reference,
10369 case 115: /* EncipherImage */
10371 (void) EncipherImage(image,argument_list[0].string_reference,
10375 case 116: /* DecipherImage */
10377 (void) DecipherImage(image,argument_list[0].string_reference,
10381 case 117: /* Deskew */
10383 geometry_info.rho=QuantumRange/2.0;
10384 if (attribute_flag[0] != 0)
10385 flags=ParseGeometry(argument_list[0].string_reference,
10387 if (attribute_flag[1] != 0)
10388 geometry_info.rho=SiPrefixToDouble(
10389 argument_list[1].string_reference,QuantumRange);
10390 image=DeskewImage(image,geometry_info.rho,exception);
10393 case 118: /* Remap */
10398 if (attribute_flag[0] == 0)
10400 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10402 goto PerlException;
10404 quantize_info=AcquireQuantizeInfo(info->image_info);
10405 if (attribute_flag[1] != 0)
10406 quantize_info->dither=(MagickBooleanType)
10407 argument_list[1].integer_reference;
10408 if (attribute_flag[2] != 0)
10409 quantize_info->dither_method=(DitherMethod)
10410 argument_list[2].integer_reference;
10411 (void) RemapImages(quantize_info,image,
10412 argument_list[0].image_reference,exception);
10413 quantize_info=DestroyQuantizeInfo(quantize_info);
10416 case 119: /* SparseColor */
10428 number_coordinates;
10433 if (attribute_flag[0] == 0)
10435 method=UndefinedColorInterpolate;
10436 if (attribute_flag[1] != 0)
10437 method=(SparseColorMethod) argument_list[1].integer_reference;
10438 av=(AV *) argument_list[0].array_reference;
10439 number_coordinates=(size_t) av_len(av)+1;
10440 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10441 sizeof(*coordinates));
10442 if (coordinates == (double *) NULL)
10444 ThrowPerlException(exception,ResourceLimitFatalError,
10445 "MemoryAllocationFailed",PackageName);
10446 goto PerlException;
10448 for (j=0; j < (ssize_t) number_coordinates; j++)
10449 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10450 virtual_pixel=UndefinedVirtualPixelMethod;
10451 if (attribute_flag[2] != 0)
10452 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10453 argument_list[2].integer_reference);
10454 if (attribute_flag[3] != 0)
10455 channel=(ChannelType) argument_list[3].integer_reference;
10456 channel_mask=SetPixelChannelMask(image,channel);
10457 image=SparseColorImage(image,method,number_coordinates,coordinates,
10459 if (image != (Image *) NULL)
10460 (void) SetPixelChannelMask(image,channel_mask);
10461 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10462 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10463 coordinates=(double *) RelinquishMagickMemory(coordinates);
10466 case 120: /* Function */
10483 if (attribute_flag[0] == 0)
10485 function=UndefinedFunction;
10486 if (attribute_flag[1] != 0)
10487 function=(MagickFunction) argument_list[1].integer_reference;
10488 av=(AV *) argument_list[0].array_reference;
10489 number_parameters=(size_t) av_len(av)+1;
10490 parameters=(double *) AcquireQuantumMemory(number_parameters,
10491 sizeof(*parameters));
10492 if (parameters == (double *) NULL)
10494 ThrowPerlException(exception,ResourceLimitFatalError,
10495 "MemoryAllocationFailed",PackageName);
10496 goto PerlException;
10498 for (j=0; j < (ssize_t) number_parameters; j++)
10499 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10500 virtual_pixel=UndefinedVirtualPixelMethod;
10501 if (attribute_flag[2] != 0)
10502 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10503 argument_list[2].integer_reference);
10504 (void) FunctionImage(image,function,number_parameters,parameters,
10506 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10507 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel);
10508 parameters=(double *) RelinquishMagickMemory(parameters);
10511 case 121: /* SelectiveBlur */
10513 if (attribute_flag[0] != 0)
10515 flags=ParseGeometry(argument_list[0].string_reference,
10517 if ((flags & SigmaValue) == 0)
10518 geometry_info.sigma=1.0;
10519 if ((flags & PercentValue) != 0)
10520 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10522 if (attribute_flag[1] != 0)
10523 geometry_info.rho=argument_list[1].real_reference;
10524 if (attribute_flag[2] != 0)
10525 geometry_info.sigma=argument_list[2].real_reference;
10526 if (attribute_flag[3] != 0)
10527 geometry_info.xi=argument_list[3].integer_reference;;
10528 if (attribute_flag[4] != 0)
10529 geometry_info.psi=argument_list[4].integer_reference;;
10530 if (attribute_flag[5] != 0)
10531 channel=(ChannelType) argument_list[5].integer_reference;
10532 channel_mask=SetPixelChannelMask(image,channel);
10533 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10534 geometry_info.xi,geometry_info.psi,exception);
10535 if (image != (Image *) NULL)
10536 (void) SetPixelChannelMask(image,channel_mask);
10539 case 122: /* HaldClut */
10541 if (attribute_flag[0] == 0)
10543 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10545 goto PerlException;
10547 if (attribute_flag[1] != 0)
10548 channel=(ChannelType) argument_list[1].integer_reference;
10549 channel_mask=SetPixelChannelMask(image,channel);
10550 (void) HaldClutImage(image,argument_list[0].image_reference,
10552 (void) SetPixelChannelMask(image,channel_mask);
10555 case 123: /* BlueShift */
10557 if (attribute_flag[0] != 0)
10558 (void) ParseGeometry(argument_list[0].string_reference,
10560 image=BlueShiftImage(image,geometry_info.rho,exception);
10563 case 124: /* ForwardFourierTransformImage */
10565 image=ForwardFourierTransformImage(image,
10566 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10570 case 125: /* InverseFourierTransformImage */
10572 image=InverseFourierTransformImage(image,image->next,
10573 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10577 case 126: /* ColorDecisionList */
10579 if (attribute_flag[0] == 0)
10580 argument_list[0].string_reference=(char *) NULL;
10581 (void) ColorDecisionListImage(image,
10582 argument_list[0].string_reference,exception);
10585 case 127: /* AutoGamma */
10587 if (attribute_flag[0] != 0)
10588 channel=(ChannelType) argument_list[0].integer_reference;
10589 channel_mask=SetPixelChannelMask(image,channel);
10590 (void) AutoGammaImage(image,exception);
10591 (void) SetPixelChannelMask(image,channel_mask);
10594 case 128: /* AutoLevel */
10596 if (attribute_flag[0] != 0)
10597 channel=(ChannelType) argument_list[0].integer_reference;
10598 channel_mask=SetPixelChannelMask(image,channel);
10599 (void) AutoLevelImage(image,exception);
10600 (void) SetPixelChannelMask(image,channel_mask);
10603 case 129: /* LevelColors */
10609 (void) QueryMagickColorCompliance("#000000",AllCompliance,
10610 &black_point,exception);
10611 (void) QueryMagickColorCompliance("#ffffff",AllCompliance,
10612 &white_point,exception);
10613 if (attribute_flag[1] != 0)
10614 (void) QueryMagickColorCompliance(
10615 argument_list[1].string_reference,AllCompliance,&black_point,
10617 if (attribute_flag[2] != 0)
10618 (void) QueryMagickColorCompliance(
10619 argument_list[2].string_reference,AllCompliance,&white_point,
10621 if (attribute_flag[3] != 0)
10622 channel=(ChannelType) argument_list[3].integer_reference;
10623 channel_mask=SetPixelChannelMask(image,channel);
10624 (void) LevelImageColors(image,&black_point,&white_point,
10625 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10627 (void) SetPixelChannelMask(image,channel_mask);
10630 case 130: /* Clamp */
10632 if (attribute_flag[0] != 0)
10633 channel=(ChannelType) argument_list[0].integer_reference;
10634 channel_mask=SetPixelChannelMask(image,channel);
10635 (void) ClampImage(image);
10636 (void) SetPixelChannelMask(image,channel_mask);
10639 case 132: /* BrightnessContrast */
10647 if (attribute_flag[0] != 0)
10649 flags=ParseGeometry(argument_list[0].string_reference,
10651 brightness=geometry_info.rho;
10652 if ((flags & SigmaValue) == 0)
10653 contrast=geometry_info.sigma;
10655 if (attribute_flag[1] != 0)
10656 brightness=argument_list[1].real_reference;
10657 if (attribute_flag[2] != 0)
10658 contrast=argument_list[2].real_reference;
10659 if (attribute_flag[4] != 0)
10660 channel=(ChannelType) argument_list[4].integer_reference;
10661 channel_mask=SetPixelChannelMask(image,channel);
10662 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10663 (void) SetPixelChannelMask(image,channel_mask);
10666 case 133: /* Morphology */
10677 if (attribute_flag[0] == 0)
10679 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10680 if (kernel == (KernelInfo *) NULL)
10682 if (attribute_flag[1] != 0)
10683 channel=(ChannelType) argument_list[1].integer_reference;
10684 method=UndefinedMorphology;
10685 if (attribute_flag[2] != 0)
10686 method=argument_list[2].integer_reference;
10688 if (attribute_flag[3] != 0)
10689 iterations=argument_list[4].integer_reference;
10690 channel_mask=SetPixelChannelMask(image,channel);
10691 image=MorphologyImage(image,method,iterations,kernel,exception);
10692 if (image != (Image *) NULL)
10693 (void) SetPixelChannelMask(image,channel_mask);
10694 kernel=DestroyKernelInfo(kernel);
10697 case 108: /* Recolor */
10698 case 134: /* ColorMatrix */
10712 if (attribute_flag[0] == 0)
10714 av=(AV *) argument_list[0].array_reference;
10715 if (av == (AV *) NULL)
10717 order=(size_t) sqrt(av_len(av)+1);
10718 color_matrix=(double *) AcquireQuantumMemory(order,order*
10719 sizeof(*color_matrix));
10720 if (color_matrix == (double *) NULL)
10722 ThrowPerlException(exception,ResourceLimitFatalError,
10723 "MemoryAllocationFailed",PackageName);
10724 goto PerlException;
10726 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10727 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10728 for ( ; j < (ssize_t) (order*order); j++)
10729 color_matrix[j]=0.0;
10730 kernel_info=AcquireKernelInfo((const char *) NULL);
10731 if (kernel_info == (KernelInfo *) NULL)
10733 kernel_info->width=order;
10734 kernel_info->height=order;
10735 kernel_info->values=color_matrix;
10736 image=ColorMatrixImage(image,kernel_info,exception);
10737 kernel_info->values=(double *) NULL;
10738 kernel_info=DestroyKernelInfo(kernel_info);
10739 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10742 case 135: /* Color */
10747 (void) QueryMagickColorCompliance("none",AllCompliance,&color,
10749 if (attribute_flag[0] != 0)
10750 (void) QueryMagickColorCompliance(argument_list[0].string_reference,
10751 AllCompliance,&color,exception);
10752 (void) SetImageColor(image,&color);
10755 case 136: /* Mode */
10757 if (attribute_flag[0] != 0)
10759 flags=ParseGeometry(argument_list[0].string_reference,
10761 if ((flags & SigmaValue) == 0)
10762 geometry_info.sigma=1.0;
10764 if (attribute_flag[1] != 0)
10765 geometry_info.rho=argument_list[1].real_reference;
10766 if (attribute_flag[2] != 0)
10767 geometry_info.sigma=argument_list[2].real_reference;
10768 if (attribute_flag[3] != 0)
10769 channel=(ChannelType) argument_list[3].integer_reference;
10770 channel_mask=SetPixelChannelMask(image,channel);
10771 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10772 (size_t) geometry_info.sigma,exception);
10773 if (image != (Image *) NULL)
10774 (void) SetPixelChannelMask(image,channel_mask);
10777 case 137: /* Statistic */
10782 statistic=UndefinedStatistic;
10783 if (attribute_flag[0] != 0)
10785 flags=ParseGeometry(argument_list[0].string_reference,
10787 if ((flags & SigmaValue) == 0)
10788 geometry_info.sigma=1.0;
10790 if (attribute_flag[1] != 0)
10791 geometry_info.rho=argument_list[1].real_reference;
10792 if (attribute_flag[2] != 0)
10793 geometry_info.sigma=argument_list[2].real_reference;
10794 if (attribute_flag[3] != 0)
10795 channel=(ChannelType) argument_list[3].integer_reference;
10796 if (attribute_flag[4] != 0)
10797 statistic=(StatisticType) argument_list[4].integer_reference;
10798 channel_mask=SetPixelChannelMask(image,channel);
10799 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10800 (size_t) geometry_info.sigma,exception);
10801 if (image != (Image *) NULL)
10802 (void) SetPixelChannelMask(image,channel_mask);
10806 if (next != (Image *) NULL)
10807 (void) CatchImageException(next);
10808 if (region_image != (Image *) NULL)
10813 status=CompositeImage(region_image,CopyCompositeOp,image,
10814 region_info.x,region_info.y);
10816 (void) CatchImageException(region_image);
10817 image=DestroyImage(image);
10818 image=region_image;
10820 if (image != (Image *) NULL)
10823 if (next && (next != image))
10825 image->next=next->next;
10826 if (image->next != (Image *) NULL)
10827 image->next->previous=image;
10828 DeleteImageFromRegistry(*pv,next);
10830 sv_setiv(*pv,(IV) image);
10838 if (reference_vector)
10839 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10840 InheritPerlException(exception,perl_exception);
10841 exception=DestroyExceptionInfo(exception);
10842 sv_setiv(perl_exception,(IV) number_images);
10843 SvPOK_on(perl_exception);
10844 ST(0)=sv_2mortal(perl_exception);
10849 ###############################################################################
10857 ###############################################################################
10862 Image::Magick ref=NO_INIT
10907 PERL_UNUSED_VAR(ref);
10908 PERL_UNUSED_VAR(ix);
10909 exception=AcquireExceptionInfo();
10910 perl_exception=newSVpv("",0);
10913 if (sv_isobject(ST(0)) == 0)
10915 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
10917 goto PerlException;
10919 reference=SvRV(ST(0));
10920 hv=SvSTASH(reference);
10922 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
10924 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
10925 if (image == (Image *) NULL)
10927 ThrowPerlException(exception,OptionError,"NoImagesDefined",
10929 goto PerlException;
10934 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
10935 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
10936 (void) QueryMagickColorCompliance("none",AllCompliance,&transparent_color,
10938 for (i=2; i < items; i+=2)
10940 attribute=(char *) SvPV(ST(i-1),na);
10941 switch (*attribute)
10946 if (LocaleCompare(attribute,"background") == 0)
10948 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
10949 &montage_info->background_color,exception);
10950 for (next=image; next; next=next->next)
10951 next->background_color=montage_info->background_color;
10954 if (LocaleCompare(attribute,"border") == 0)
10956 montage_info->border_width=SvIV(ST(i));
10959 if (LocaleCompare(attribute,"bordercolor") == 0)
10961 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
10962 &montage_info->border_color,exception);
10963 for (next=image; next; next=next->next)
10964 next->border_color=montage_info->border_color;
10967 if (LocaleCompare(attribute,"borderwidth") == 0)
10969 montage_info->border_width=SvIV(ST(i));
10972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
10979 if (LocaleCompare(attribute,"compose") == 0)
10981 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
10982 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
10985 ThrowPerlException(exception,OptionError,"UnrecognizedType",
10989 for (next=image; next; next=next->next)
10990 next->compose=(CompositeOperator) sp;
10993 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11000 if (LocaleCompare(attribute,"fill") == 0)
11002 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11003 &montage_info->fill,exception);
11006 if (LocaleCompare(attribute,"font") == 0)
11008 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11011 if (LocaleCompare(attribute,"frame") == 0)
11017 if (IsGeometry(p) == MagickFalse)
11019 ThrowPerlException(exception,OptionError,"MissingGeometry",
11023 (void) CloneString(&montage_info->frame,p);
11025 montage_info->frame=(char *) NULL;
11028 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11035 if (LocaleCompare(attribute,"geometry") == 0)
11041 if (IsGeometry(p) == MagickFalse)
11043 ThrowPerlException(exception,OptionError,"MissingGeometry",
11047 (void) CloneString(&montage_info->geometry,p);
11049 montage_info->geometry=(char *) NULL;
11052 if (LocaleCompare(attribute,"gravity") == 0)
11057 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11058 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11061 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11065 montage_info->gravity=(GravityType) in;
11066 for (next=image; next; next=next->next)
11067 next->gravity=(GravityType) in;
11070 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11077 if (LocaleCompare(attribute,"label") == 0)
11079 for (next=image; next; next=next->next)
11080 (void) SetImageProperty(next,"label",InterpretImageProperties(
11081 info ? info->image_info : (ImageInfo *) NULL,next,
11082 SvPV(ST(i),na),exception));
11085 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11092 if (LocaleCompare(attribute,"mattecolor") == 0)
11094 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11095 &montage_info->matte_color,exception);
11096 for (next=image; next; next=next->next)
11097 next->matte_color=montage_info->matte_color;
11100 if (LocaleCompare(attribute,"mode") == 0)
11105 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11106 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11111 ThrowPerlException(exception,OptionError,
11112 "UnrecognizedModeType",SvPV(ST(i),na));
11117 (void) CloneString(&montage_info->frame,"15x15+3+3");
11118 montage_info->shadow=MagickTrue;
11123 montage_info->frame=(char *) NULL;
11124 montage_info->shadow=MagickFalse;
11125 montage_info->border_width=0;
11128 case ConcatenateMode:
11130 montage_info->frame=(char *) NULL;
11131 montage_info->shadow=MagickFalse;
11132 (void) CloneString(&montage_info->geometry,"+0+0");
11133 montage_info->border_width=0;
11138 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11145 if (LocaleCompare(attribute,"pointsize") == 0)
11147 montage_info->pointsize=SvIV(ST(i));
11150 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11157 if (LocaleCompare(attribute,"shadow") == 0)
11159 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11160 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11163 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11167 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11170 if (LocaleCompare(attribute,"stroke") == 0)
11172 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11173 &montage_info->stroke,exception);
11176 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11183 if (LocaleCompare(attribute,"texture") == 0)
11185 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11188 if (LocaleCompare(attribute,"tile") == 0)
11190 char *p=SvPV(ST(i),na);
11191 if (IsGeometry(p) == MagickFalse)
11193 ThrowPerlException(exception,OptionError,"MissingGeometry",
11197 (void) CloneString(&montage_info->tile,p);
11199 montage_info->tile=(char *) NULL;
11202 if (LocaleCompare(attribute,"title") == 0)
11204 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11207 if (LocaleCompare(attribute,"transparent") == 0)
11212 QueryMagickColorCompliance(SvPV(ST(i),na),AllCompliance,
11213 &transparent_color,exception);
11214 for (next=image; next; next=next->next)
11215 (void) TransparentPaintImage(next,&transparent_color,
11216 TransparentAlpha,MagickFalse,exception);
11219 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11225 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11231 image=MontageImageList(info->image_info,montage_info,image,exception);
11232 montage_info=DestroyMontageInfo(montage_info);
11233 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11234 goto PerlException;
11235 if (transparent_color.alpha != TransparentAlpha)
11236 for (next=image; next; next=next->next)
11237 (void) TransparentPaintImage(next,&transparent_color,
11238 TransparentAlpha,MagickFalse,exception);
11239 for ( ; image; image=image->next)
11241 AddImageToRegistry(sv,image);
11243 av_push(av,sv_bless(rv,hv));
11246 exception=DestroyExceptionInfo(exception);
11247 ST(0)=av_reference;
11248 SvREFCNT_dec(perl_exception);
11252 InheritPerlException(exception,perl_exception);
11253 exception=DestroyExceptionInfo(exception);
11254 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11255 SvPOK_on(perl_exception);
11256 ST(0)=sv_2mortal(perl_exception);
11261 ###############################################################################
11269 ###############################################################################
11274 Image::Magick ref=NO_INIT
11312 PERL_UNUSED_VAR(ref);
11313 PERL_UNUSED_VAR(ix);
11314 exception=AcquireExceptionInfo();
11315 perl_exception=newSVpv("",0);
11319 if (sv_isobject(ST(0)) == 0)
11321 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11323 goto PerlException;
11325 reference=SvRV(ST(0));
11326 hv=SvSTASH(reference);
11328 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11330 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11331 if (image == (Image *) NULL)
11333 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11335 goto PerlException;
11337 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11342 for (i=2; i < items; i+=2)
11344 attribute=(char *) SvPV(ST(i-1),na);
11345 switch (*attribute)
11350 if (LocaleCompare(attribute,"frames") == 0)
11352 number_frames=SvIV(ST(i));
11355 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11367 image=MorphImages(image,number_frames,exception);
11368 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11369 goto PerlException;
11370 for ( ; image; image=image->next)
11372 AddImageToRegistry(sv,image);
11374 av_push(av,sv_bless(rv,hv));
11377 exception=DestroyExceptionInfo(exception);
11378 ST(0)=av_reference;
11379 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11383 InheritPerlException(exception,perl_exception);
11384 exception=DestroyExceptionInfo(exception);
11385 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11386 SvPOK_on(perl_exception);
11387 ST(0)=sv_2mortal(perl_exception);
11392 ###############################################################################
11400 ###############################################################################
11405 Image::Magick ref=NO_INIT
11433 PERL_UNUSED_VAR(ref);
11434 PERL_UNUSED_VAR(ix);
11435 exception=AcquireExceptionInfo();
11436 perl_exception=newSVpv("",0);
11438 if (sv_isobject(ST(0)) == 0)
11440 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11442 goto PerlException;
11444 reference=SvRV(ST(0));
11445 hv=SvSTASH(reference);
11446 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11447 if (image == (Image *) NULL)
11449 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11451 goto PerlException;
11453 image=MergeImageLayers(image,MosaicLayer,exception);
11455 Create blessed Perl array for the returned image.
11458 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11460 AddImageToRegistry(sv,image);
11462 av_push(av,sv_bless(rv,hv));
11464 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11465 (void) CopyMagickString(info->image_info->filename,image->filename,
11467 SetImageInfo(info->image_info,0,&image->exception);
11468 exception=DestroyExceptionInfo(exception);
11469 SvREFCNT_dec(perl_exception);
11473 InheritPerlException(exception,perl_exception);
11474 exception=DestroyExceptionInfo(exception);
11475 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11476 SvPOK_on(perl_exception); /* return messages in string context */
11477 ST(0)=sv_2mortal(perl_exception);
11482 ###############################################################################
11490 ###############################################################################
11495 Image::Magick ref=NO_INIT
11545 PERL_UNUSED_VAR(ref);
11546 PERL_UNUSED_VAR(ix);
11547 exception=AcquireExceptionInfo();
11548 perl_exception=newSVpv("",0);
11549 package_info=(struct PackageInfo *) NULL;
11550 ac=(items < 2) ? 1 : items-1;
11551 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11553 length=(STRLEN *) NULL;
11554 if (list == (char **) NULL)
11556 ThrowPerlException(exception,ResourceLimitError,
11557 "MemoryAllocationFailed",PackageName);
11558 goto PerlException;
11561 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11562 if (length == (STRLEN *) NULL)
11564 ThrowPerlException(exception,ResourceLimitError,
11565 "MemoryAllocationFailed",PackageName);
11566 goto PerlException;
11568 if (sv_isobject(ST(0)) == 0)
11570 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11572 goto PerlException;
11574 reference=SvRV(ST(0));
11575 if (SvTYPE(reference) != SVt_PVAV)
11577 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11579 goto PerlException;
11581 av=(AV *) reference;
11582 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11584 package_info=ClonePackageInfo(info,exception);
11587 *list=(char *) (*package_info->image_info->filename ?
11588 package_info->image_info->filename : "XC:black");
11590 for (n=0, i=0; i < ac; i++)
11592 list[n]=(char *) SvPV(ST(i+1),length[n]);
11593 if ((items >= 3) && strEQcase(list[n],"blob"))
11599 blob=(void *) (SvPV(ST(i+1),length[n]));
11600 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11602 if ((items >= 3) && strEQcase(list[n],"filename"))
11604 if ((items >= 3) && strEQcase(list[n],"file"))
11613 io_info=IoIFP(sv_2io(ST(i+1)));
11614 if (io_info == (PerlIO *) NULL)
11616 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11620 file=PerlIO_findFILE(io_info);
11621 if (file == (FILE *) NULL)
11623 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11627 SetImageInfoFile(package_info->image_info,file);
11629 if ((items >= 3) && strEQcase(list[n],"magick"))
11633 list[n]=(char *) NULL;
11635 status=ExpandFilenames(&n,&list);
11636 if (status == MagickFalse)
11638 ThrowPerlException(exception,ResourceLimitError,
11639 "MemoryAllocationFailed",PackageName);
11640 goto PerlException;
11643 for (i=0; i < n; i++)
11645 (void) CopyMagickString(package_info->image_info->filename,list[i],
11647 image=PingImage(package_info->image_info,exception);
11648 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
11650 if ((package_info->image_info->file != (FILE *) NULL) ||
11651 (package_info->image_info->blob != (void *) NULL))
11652 DisassociateImageStream(image);
11653 count+=GetImageListLength(image);
11654 EXTEND(sp,4*count);
11655 for (next=image; next; next=next->next)
11657 PUSHs(sv_2mortal(newSViv(next->columns)));
11658 PUSHs(sv_2mortal(newSViv(next->rows)));
11659 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11660 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11662 image=DestroyImageList(image);
11667 for (i=0; i < n; i++)
11668 if (list[i] != (char *) NULL)
11669 for (p=keep; list[i] != *p++; )
11672 list[i]=(char *) RelinquishMagickMemory(list[i]);
11677 if (package_info != (struct PackageInfo *) NULL)
11678 DestroyPackageInfo(package_info);
11679 if (list && (list != keep))
11680 list=(char **) RelinquishMagickMemory(list);
11682 keep=(char **) RelinquishMagickMemory(keep);
11684 length=(STRLEN *) RelinquishMagickMemory(length);
11685 InheritPerlException(exception,perl_exception);
11686 exception=DestroyExceptionInfo(exception);
11687 SvREFCNT_dec(perl_exception); /* throw away all errors */
11691 ###############################################################################
11699 ###############################################################################
11704 Image::Magick ref=NO_INIT
11737 PERL_UNUSED_VAR(ref);
11738 PERL_UNUSED_VAR(ix);
11739 exception=AcquireExceptionInfo();
11740 perl_exception=newSVpv("",0);
11743 if (sv_isobject(ST(0)) == 0)
11745 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11747 goto PerlException;
11749 reference=SvRV(ST(0));
11750 hv=SvSTASH(reference);
11752 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11754 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11755 if (image == (Image *) NULL)
11757 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11759 goto PerlException;
11761 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11762 preview_type=GammaPreview;
11764 preview_type=(PreviewType)
11765 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11766 for ( ; image; image=image->next)
11768 preview_image=PreviewImage(image,preview_type,exception);
11769 if (preview_image == (Image *) NULL)
11770 goto PerlException;
11771 AddImageToRegistry(sv,preview_image);
11773 av_push(av,sv_bless(rv,hv));
11776 exception=DestroyExceptionInfo(exception);
11777 ST(0)=av_reference;
11778 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11782 InheritPerlException(exception,perl_exception);
11783 exception=DestroyExceptionInfo(exception);
11784 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11785 SvPOK_on(perl_exception);
11786 ST(0)=sv_2mortal(perl_exception);
11791 ###############################################################################
11795 # Q u e r y C o l o r #
11799 ###############################################################################
11803 QueryColor(ref,...)
11804 Image::Magick ref=NO_INIT
11824 PERL_UNUSED_VAR(ref);
11825 PERL_UNUSED_VAR(ix);
11826 exception=AcquireExceptionInfo();
11827 perl_exception=newSVpv("",0);
11836 colorlist=GetColorInfoList("*",&colors,exception);
11838 for (i=0; i < (ssize_t) colors; i++)
11840 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11842 colorlist=(const ColorInfo **)
11843 RelinquishMagickMemory((ColorInfo **) colorlist);
11844 goto PerlException;
11846 EXTEND(sp,5*items);
11847 for (i=1; i < items; i++)
11849 name=(char *) SvPV(ST(i),na);
11850 if (QueryMagickColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
11855 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11856 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11857 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11858 if (color.colorspace == CMYKColorspace)
11859 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11860 if (color.matte != MagickFalse)
11861 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11865 InheritPerlException(exception,perl_exception);
11866 exception=DestroyExceptionInfo(exception);
11867 SvREFCNT_dec(perl_exception);
11871 ###############################################################################
11875 # Q u e r y C o l o r N a m e #
11879 ###############################################################################
11883 QueryColorname(ref,...)
11884 Image::Magick ref=NO_INIT
11893 message[MaxTextExtent];
11912 *reference; /* reference is the SV* of ref=SvIV(reference) */
11914 PERL_UNUSED_VAR(ref);
11915 PERL_UNUSED_VAR(ix);
11916 exception=AcquireExceptionInfo();
11917 perl_exception=newSVpv("",0);
11918 reference=SvRV(ST(0));
11919 av=(AV *) reference;
11920 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11922 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11923 if (image == (Image *) NULL)
11925 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11927 goto PerlException;
11930 for (i=1; i < items; i++)
11932 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
11934 (void) QueryColorname(image,&target_color,SVGCompliance,message,
11936 PUSHs(sv_2mortal(newSVpv(message,0)));
11940 InheritPerlException(exception,perl_exception);
11941 exception=DestroyExceptionInfo(exception);
11942 SvREFCNT_dec(perl_exception);
11946 ###############################################################################
11950 # Q u e r y F o n t #
11954 ###############################################################################
11959 Image::Magick ref=NO_INIT
11966 message[MaxTextExtent];
11977 volatile const TypeInfo
11980 PERL_UNUSED_VAR(ref);
11981 PERL_UNUSED_VAR(ix);
11982 exception=AcquireExceptionInfo();
11983 perl_exception=newSVpv("",0);
11992 typelist=GetTypeInfoList("*",&types,exception);
11994 for (i=0; i < (ssize_t) types; i++)
11996 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
11998 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12000 goto PerlException;
12002 EXTEND(sp,10*items);
12003 for (i=1; i < items; i++)
12005 name=(char *) SvPV(ST(i),na);
12006 type_info=GetTypeInfo(name,exception);
12007 if (type_info == (TypeInfo *) NULL)
12012 if (type_info->name == (char *) NULL)
12015 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12016 if (type_info->description == (char *) NULL)
12019 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12020 if (type_info->family == (char *) NULL)
12023 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12024 if (type_info->style == UndefinedStyle)
12027 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12028 type_info->style),0)));
12029 if (type_info->stretch == UndefinedStretch)
12032 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12033 type_info->stretch),0)));
12034 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12035 type_info->weight);
12036 PUSHs(sv_2mortal(newSVpv(message,0)));
12037 if (type_info->encoding == (char *) NULL)
12040 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12041 if (type_info->foundry == (char *) NULL)
12044 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12045 if (type_info->format == (char *) NULL)
12048 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12049 if (type_info->metrics == (char *) NULL)
12052 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12053 if (type_info->glyphs == (char *) NULL)
12056 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12060 InheritPerlException(exception,perl_exception);
12061 exception=DestroyExceptionInfo(exception);
12062 SvREFCNT_dec(perl_exception);
12066 ###############################################################################
12070 # Q u e r y F o n t M e t r i c s #
12074 ###############################################################################
12078 QueryFontMetrics(ref,...)
12079 Image::Magick ref=NO_INIT
12081 queryfontmetrics = 1
12128 *reference; /* reference is the SV* of ref=SvIV(reference) */
12133 PERL_UNUSED_VAR(ref);
12134 PERL_UNUSED_VAR(ix);
12135 exception=AcquireExceptionInfo();
12136 package_info=(struct PackageInfo *) NULL;
12137 perl_exception=newSVpv("",0);
12138 reference=SvRV(ST(0));
12139 av=(AV *) reference;
12140 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12142 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12143 if (image == (Image *) NULL)
12145 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12147 goto PerlException;
12149 package_info=ClonePackageInfo(info,exception);
12150 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12151 CloneString(&draw_info->text,"");
12152 current=draw_info->affine;
12153 GetAffineMatrix(&affine);
12156 EXTEND(sp,7*items);
12157 for (i=2; i < items; i+=2)
12159 attribute=(char *) SvPV(ST(i-1),na);
12160 switch (*attribute)
12165 if (LocaleCompare(attribute,"antialias") == 0)
12167 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12171 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12175 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12185 if (LocaleCompare(attribute,"density") == 0)
12187 CloneString(&draw_info->density,SvPV(ST(i),na));
12190 if (LocaleCompare(attribute,"direction") == 0)
12192 draw_info->direction=(DirectionType) ParseCommandOption(
12193 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12196 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12203 if (LocaleCompare(attribute,"encoding") == 0)
12205 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12208 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12215 if (LocaleCompare(attribute,"family") == 0)
12217 CloneString(&draw_info->family,SvPV(ST(i),na));
12220 if (LocaleCompare(attribute,"fill") == 0)
12223 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12224 &draw_info->fill,&image->exception);
12227 if (LocaleCompare(attribute,"font") == 0)
12229 CloneString(&draw_info->font,SvPV(ST(i),na));
12232 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12239 if (LocaleCompare(attribute,"geometry") == 0)
12241 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12244 if (LocaleCompare(attribute,"gravity") == 0)
12246 draw_info->gravity=(GravityType) ParseCommandOption(
12247 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12250 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12257 if (LocaleCompare(attribute,"interline-spacing") == 0)
12259 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12260 draw_info->interline_spacing=geometry_info.rho;
12263 if (LocaleCompare(attribute,"interword-spacing") == 0)
12265 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12266 draw_info->interword_spacing=geometry_info.rho;
12269 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12276 if (LocaleCompare(attribute,"kerning") == 0)
12278 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12279 draw_info->kerning=geometry_info.rho;
12282 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12289 if (LocaleCompare(attribute,"pointsize") == 0)
12291 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12292 draw_info->pointsize=geometry_info.rho;
12295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12302 if (LocaleCompare(attribute,"rotate") == 0)
12304 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12305 affine.rx=geometry_info.rho;
12306 affine.ry=geometry_info.sigma;
12307 if ((flags & SigmaValue) == 0)
12308 affine.ry=affine.rx;
12311 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12318 if (LocaleCompare(attribute,"scale") == 0)
12320 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12321 affine.sx=geometry_info.rho;
12322 affine.sy=geometry_info.sigma;
12323 if ((flags & SigmaValue) == 0)
12324 affine.sy=affine.sx;
12327 if (LocaleCompare(attribute,"skew") == 0)
12333 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12334 x_angle=geometry_info.rho;
12335 y_angle=geometry_info.sigma;
12336 if ((flags & SigmaValue) == 0)
12338 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12339 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12342 if (LocaleCompare(attribute,"stroke") == 0)
12345 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12346 &draw_info->stroke,&image->exception);
12349 if (LocaleCompare(attribute,"style") == 0)
12351 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12355 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12359 draw_info->style=(StyleType) type;
12362 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12369 if (LocaleCompare(attribute,"text") == 0)
12371 CloneString(&draw_info->text,SvPV(ST(i),na));
12374 if (LocaleCompare(attribute,"translate") == 0)
12376 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12377 affine.tx=geometry_info.rho;
12378 affine.ty=geometry_info.sigma;
12379 if ((flags & SigmaValue) == 0)
12380 affine.ty=affine.tx;
12383 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12390 if (LocaleCompare(attribute,"weight") == 0)
12392 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12393 draw_info->weight=(size_t) geometry_info.rho;
12396 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12403 if (LocaleCompare(attribute,"x") == 0)
12405 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12406 x=geometry_info.rho;
12409 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12416 if (LocaleCompare(attribute,"y") == 0)
12418 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12419 y=geometry_info.rho;
12422 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12428 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12434 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12435 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12436 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12437 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12438 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12439 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12440 if (draw_info->geometry == (char *) NULL)
12442 draw_info->geometry=AcquireString((char *) NULL);
12443 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12444 "%.15g,%.15g",x,y);
12446 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12447 (void) CatchImageException(image);
12448 if (status == MagickFalse)
12452 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12453 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12454 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12455 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12456 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12457 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12458 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12459 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12460 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12461 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12462 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12463 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12464 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12466 draw_info=DestroyDrawInfo(draw_info);
12469 if (package_info != (struct PackageInfo *) NULL)
12470 DestroyPackageInfo(package_info);
12471 InheritPerlException(exception,perl_exception);
12472 exception=DestroyExceptionInfo(exception);
12473 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12477 ###############################################################################
12481 # 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 #
12485 ###############################################################################
12489 QueryMultilineFontMetrics(ref,...)
12490 Image::Magick ref=NO_INIT
12492 querymultilinefontmetrics = 1
12539 *reference; /* reference is the SV* of ref=SvIV(reference) */
12544 PERL_UNUSED_VAR(ref);
12545 PERL_UNUSED_VAR(ix);
12546 exception=AcquireExceptionInfo();
12547 package_info=(struct PackageInfo *) NULL;
12548 perl_exception=newSVpv("",0);
12549 reference=SvRV(ST(0));
12550 av=(AV *) reference;
12551 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12553 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12554 if (image == (Image *) NULL)
12556 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12558 goto PerlException;
12560 package_info=ClonePackageInfo(info,exception);
12561 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12562 CloneString(&draw_info->text,"");
12563 current=draw_info->affine;
12564 GetAffineMatrix(&affine);
12567 EXTEND(sp,7*items);
12568 for (i=2; i < items; i+=2)
12570 attribute=(char *) SvPV(ST(i-1),na);
12571 switch (*attribute)
12576 if (LocaleCompare(attribute,"antialias") == 0)
12578 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12582 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12586 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12589 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12596 if (LocaleCompare(attribute,"density") == 0)
12598 CloneString(&draw_info->density,SvPV(ST(i),na));
12601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12608 if (LocaleCompare(attribute,"encoding") == 0)
12610 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12613 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12620 if (LocaleCompare(attribute,"family") == 0)
12622 CloneString(&draw_info->family,SvPV(ST(i),na));
12625 if (LocaleCompare(attribute,"fill") == 0)
12628 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12629 &draw_info->fill,&image->exception);
12632 if (LocaleCompare(attribute,"font") == 0)
12634 CloneString(&draw_info->font,SvPV(ST(i),na));
12637 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12644 if (LocaleCompare(attribute,"geometry") == 0)
12646 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12649 if (LocaleCompare(attribute,"gravity") == 0)
12651 draw_info->gravity=(GravityType) ParseCommandOption(
12652 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12655 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12662 if (LocaleCompare(attribute,"pointsize") == 0)
12664 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12665 draw_info->pointsize=geometry_info.rho;
12668 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12675 if (LocaleCompare(attribute,"rotate") == 0)
12677 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12678 affine.rx=geometry_info.rho;
12679 affine.ry=geometry_info.sigma;
12680 if ((flags & SigmaValue) == 0)
12681 affine.ry=affine.rx;
12684 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12691 if (LocaleCompare(attribute,"scale") == 0)
12693 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12694 affine.sx=geometry_info.rho;
12695 affine.sy=geometry_info.sigma;
12696 if ((flags & SigmaValue) == 0)
12697 affine.sy=affine.sx;
12700 if (LocaleCompare(attribute,"skew") == 0)
12706 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12707 x_angle=geometry_info.rho;
12708 y_angle=geometry_info.sigma;
12709 if ((flags & SigmaValue) == 0)
12711 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12712 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12715 if (LocaleCompare(attribute,"stroke") == 0)
12718 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12719 &draw_info->stroke,&image->exception);
12722 if (LocaleCompare(attribute,"style") == 0)
12724 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12728 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12732 draw_info->style=(StyleType) type;
12735 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12742 if (LocaleCompare(attribute,"text") == 0)
12744 CloneString(&draw_info->text,SvPV(ST(i),na));
12747 if (LocaleCompare(attribute,"translate") == 0)
12749 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12750 affine.tx=geometry_info.rho;
12751 affine.ty=geometry_info.sigma;
12752 if ((flags & SigmaValue) == 0)
12753 affine.ty=affine.tx;
12756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12763 if (LocaleCompare(attribute,"weight") == 0)
12765 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12766 draw_info->weight=(size_t) geometry_info.rho;
12769 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12776 if (LocaleCompare(attribute,"x") == 0)
12778 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12779 x=geometry_info.rho;
12782 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12789 if (LocaleCompare(attribute,"y") == 0)
12791 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12792 y=geometry_info.rho;
12795 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12801 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12807 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12808 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12809 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12810 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12811 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12812 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12813 if (draw_info->geometry == (char *) NULL)
12815 draw_info->geometry=AcquireString((char *) NULL);
12816 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12817 "%.15g,%.15g",x,y);
12819 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12820 (void) CatchException(exception);
12821 if (status == MagickFalse)
12825 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12826 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12827 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12828 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12829 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12830 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12831 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12832 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12833 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12834 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12835 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12836 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12837 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12839 draw_info=DestroyDrawInfo(draw_info);
12842 if (package_info != (struct PackageInfo *) NULL)
12843 DestroyPackageInfo(package_info);
12844 InheritPerlException(exception,perl_exception);
12845 exception=DestroyExceptionInfo(exception);
12846 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12850 ###############################################################################
12854 # Q u e r y F o r m a t #
12858 ###############################################################################
12862 QueryFormat(ref,...)
12863 Image::Magick ref=NO_INIT
12880 volatile const MagickInfo
12883 PERL_UNUSED_VAR(ref);
12884 PERL_UNUSED_VAR(ix);
12885 exception=AcquireExceptionInfo();
12886 perl_exception=newSVpv("",0);
12890 format[MaxTextExtent];
12898 format_list=GetMagickInfoList("*",&types,exception);
12900 for (i=0; i < (ssize_t) types; i++)
12902 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
12903 LocaleLower(format);
12904 PUSHs(sv_2mortal(newSVpv(format,0)));
12906 format_list=(const MagickInfo **)
12907 RelinquishMagickMemory((MagickInfo *) format_list);
12908 goto PerlException;
12910 EXTEND(sp,8*items);
12911 for (i=1; i < items; i++)
12913 name=(char *) SvPV(ST(i),na);
12914 magick_info=GetMagickInfo(name,exception);
12915 if (magick_info == (const MagickInfo *) NULL)
12920 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
12921 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
12922 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
12923 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
12924 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
12925 if (magick_info->description == (char *) NULL)
12928 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
12929 if (magick_info->module == (char *) NULL)
12932 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
12936 InheritPerlException(exception,perl_exception);
12937 exception=DestroyExceptionInfo(exception);
12938 SvREFCNT_dec(perl_exception);
12942 ###############################################################################
12946 # Q u e r y O p t i o n #
12950 ###############################################################################
12954 QueryOption(ref,...)
12955 Image::Magick ref=NO_INIT
12976 PERL_UNUSED_VAR(ref);
12977 PERL_UNUSED_VAR(ix);
12978 exception=AcquireExceptionInfo();
12979 perl_exception=newSVpv("",0);
12980 EXTEND(sp,8*items);
12981 for (i=1; i < items; i++)
12983 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
12985 options=GetCommandOptions((CommandOption) option);
12986 if (options == (char **) NULL)
12990 for (j=0; options[j] != (char *) NULL; j++)
12991 PUSHs(sv_2mortal(newSVpv(options[j],0)));
12992 options=DestroyStringList(options);
12996 InheritPerlException(exception,perl_exception);
12997 exception=DestroyExceptionInfo(exception);
12998 SvREFCNT_dec(perl_exception);
13002 ###############################################################################
13010 ###############################################################################
13015 Image::Magick ref=NO_INIT
13062 *perl_exception, /* Perl variable for storing messages */
13067 PERL_UNUSED_VAR(ref);
13068 PERL_UNUSED_VAR(ix);
13069 exception=AcquireExceptionInfo();
13070 perl_exception=newSVpv("",0);
13072 package_info=(struct PackageInfo *) NULL;
13074 ac=(items < 2) ? 1 : items-1;
13075 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13077 length=(STRLEN *) NULL;
13078 if (list == (char **) NULL)
13080 ThrowPerlException(exception,ResourceLimitError,
13081 "MemoryAllocationFailed",PackageName);
13082 goto PerlException;
13084 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13085 if (length == (STRLEN *) NULL)
13087 ThrowPerlException(exception,ResourceLimitError,
13088 "MemoryAllocationFailed",PackageName);
13089 goto PerlException;
13091 if (sv_isobject(ST(0)) == 0)
13093 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13095 goto PerlException;
13097 reference=SvRV(ST(0));
13098 hv=SvSTASH(reference);
13099 if (SvTYPE(reference) != SVt_PVAV)
13101 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13103 goto PerlException;
13105 av=(AV *) reference;
13106 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13108 package_info=ClonePackageInfo(info,exception);
13111 *list=(char *) (*package_info->image_info->filename ?
13112 package_info->image_info->filename : "XC:black");
13114 for (n=0, i=0; i < ac; i++)
13116 list[n]=(char *) SvPV(ST(i+1),length[n]);
13117 if ((items >= 3) && strEQcase(list[n],"blob"))
13123 blob=(void *) (SvPV(ST(i+1),length[n]));
13124 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13126 if ((items >= 3) && strEQcase(list[n],"filename"))
13128 if ((items >= 3) && strEQcase(list[n],"file"))
13137 io_info=IoIFP(sv_2io(ST(i+1)));
13138 if (io_info == (PerlIO *) NULL)
13140 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13144 file=PerlIO_findFILE(io_info);
13145 if (file == (FILE *) NULL)
13147 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13151 SetImageInfoFile(package_info->image_info,file);
13153 if ((items >= 3) && strEQcase(list[n],"magick"))
13157 list[n]=(char *) NULL;
13159 status=ExpandFilenames(&n,&list);
13160 if (status == MagickFalse)
13162 ThrowPerlException(exception,ResourceLimitError,
13163 "MemoryAllocationFailed",PackageName);
13164 goto PerlException;
13167 for (i=0; i < n; i++)
13169 if ((package_info->image_info->file != (FILE *) NULL) ||
13170 (package_info->image_info->blob != (void *) NULL))
13172 image=ReadImages(package_info->image_info,exception);
13173 if (image != (Image *) NULL)
13174 DisassociateImageStream(image);
13178 (void) CopyMagickString(package_info->image_info->filename,list[i],
13180 image=ReadImages(package_info->image_info,exception);
13182 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13184 for ( ; image; image=image->next)
13186 AddImageToRegistry(sv,image);
13188 av_push(av,sv_bless(rv,hv));
13196 for (i=0; i < n; i++)
13197 if (list[i] != (char *) NULL)
13198 for (p=keep; list[i] != *p++; )
13199 if (*p == (char *) NULL)
13201 list[i]=(char *) RelinquishMagickMemory(list[i]);
13206 if (package_info != (struct PackageInfo *) NULL)
13207 DestroyPackageInfo(package_info);
13208 if (list && (list != keep))
13209 list=(char **) RelinquishMagickMemory(list);
13211 keep=(char **) RelinquishMagickMemory(keep);
13213 length=(STRLEN *) RelinquishMagickMemory(length);
13214 InheritPerlException(exception,perl_exception);
13215 exception=DestroyExceptionInfo(exception);
13216 sv_setiv(perl_exception,(IV) number_images);
13217 SvPOK_on(perl_exception);
13218 ST(0)=sv_2mortal(perl_exception);
13223 ###############################################################################
13231 ###############################################################################
13236 Image::Magick ref=NO_INIT
13259 PERL_UNUSED_VAR(ref);
13260 PERL_UNUSED_VAR(ix);
13261 exception=AcquireExceptionInfo();
13262 perl_exception=newSVpv("",0);
13263 reference=SvRV(ST(0));
13264 av=(AV *) reference;
13265 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13267 for (i=1; i < items; i++)
13268 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13269 SvPV(ST(i),na),exception);
13270 InheritPerlException(exception,perl_exception);
13271 exception=DestroyExceptionInfo(exception);
13272 SvREFCNT_dec(perl_exception); /* throw away all errors */
13276 ###############################################################################
13284 ###############################################################################
13289 Image::Magick ref=NO_INIT
13312 *reference; /* reference is the SV* of ref=SvIV(reference) */
13314 PERL_UNUSED_VAR(ref);
13315 PERL_UNUSED_VAR(ix);
13316 exception=AcquireExceptionInfo();
13317 perl_exception=newSVpv("",0);
13318 if (sv_isobject(ST(0)) == 0)
13320 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13322 goto PerlException;
13324 reference=SvRV(ST(0));
13325 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13327 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13329 for (i=2; i < items; i+=2)
13330 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13333 InheritPerlException(exception,perl_exception);
13334 exception=DestroyExceptionInfo(exception);
13335 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13336 SvPOK_on(perl_exception);
13337 ST(0)=sv_2mortal(perl_exception);
13342 ###############################################################################
13346 # S e t P i x e l #
13350 ###############################################################################
13355 Image::Magick ref=NO_INIT
13397 *reference; /* reference is the SV* of ref=SvIV(reference) */
13399 PERL_UNUSED_VAR(ref);
13400 PERL_UNUSED_VAR(ix);
13401 exception=AcquireExceptionInfo();
13402 perl_exception=newSVpv("",0);
13403 reference=SvRV(ST(0));
13404 av=(AV *) reference;
13405 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13407 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13408 if (image == (Image *) NULL)
13410 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13412 goto PerlException;
13415 normalize=MagickTrue;
13418 region.width=image->columns;
13421 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13422 channel=DefaultChannels;
13423 for (i=2; i < items; i+=2)
13425 attribute=(char *) SvPV(ST(i-1),na);
13426 switch (*attribute)
13431 if (LocaleCompare(attribute,"channel") == 0)
13436 option=ParseChannelOption(SvPV(ST(i),na));
13439 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13443 channel=(ChannelType) option;
13446 if (LocaleCompare(attribute,"color") == 0)
13448 if (SvTYPE(ST(i)) != SVt_RV)
13451 message[MaxTextExtent];
13453 (void) FormatLocaleString(message,MaxTextExtent,
13454 "invalid %.60s value",attribute);
13455 ThrowPerlException(exception,OptionError,message,
13458 av=(AV *) SvRV(ST(i));
13461 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13468 if (LocaleCompare(attribute,"geometry") == 0)
13470 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13473 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13480 if (LocaleCompare(attribute,"normalize") == 0)
13482 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13486 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13490 normalize=option != 0 ? MagickTrue : MagickFalse;
13493 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13500 if (LocaleCompare(attribute,"x") == 0)
13502 region.x=SvIV(ST(i));
13505 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13512 if (LocaleCompare(attribute,"y") == 0)
13514 region.y=SvIV(ST(i));
13517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13523 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13529 (void) SetImageStorageClass(image,DirectClass,exception);
13530 channel_mask=SetPixelChannelMask(image,channel);
13531 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13532 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13533 (SvTYPE(av) != SVt_PVAV))
13545 if (normalize != MagickFalse)
13546 scale=QuantumRange;
13547 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13550 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13551 av_fetch(av,i,0)))),q);
13554 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13557 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13558 av_fetch(av,i,0)))),q);
13561 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13564 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13565 av_fetch(av,i,0)))),q);
13568 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13569 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13571 SetPixelBlack(image,ClampToQuantum(scale*
13572 SvNV(*(av_fetch(av,i,0)))),q);
13575 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13578 SetPixelAlpha(image,ClampToQuantum(scale*
13579 SvNV(*(av_fetch(av,i,0)))),q);
13582 (void) SyncAuthenticPixels(image,exception);
13584 (void) SetPixelChannelMask(image,channel_mask);
13587 InheritPerlException(exception,perl_exception);
13588 exception=DestroyExceptionInfo(exception);
13589 SvREFCNT_dec(perl_exception);
13593 ###############################################################################
13601 ###############################################################################
13606 Image::Magick ref=NO_INIT
13645 PERL_UNUSED_VAR(ref);
13646 PERL_UNUSED_VAR(ix);
13647 exception=AcquireExceptionInfo();
13648 perl_exception=newSVpv("",0);
13652 if (sv_isobject(ST(0)) == 0)
13654 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13656 goto PerlException;
13658 reference=SvRV(ST(0));
13659 hv=SvSTASH(reference);
13661 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13663 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13664 if (image == (Image *) NULL)
13666 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13668 goto PerlException;
13670 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13676 for (i=2; i < items; i+=2)
13678 attribute=(char *) SvPV(ST(i-1),na);
13679 switch (*attribute)
13684 if (LocaleCompare(attribute,"offset") == 0)
13686 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13689 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13696 if (LocaleCompare(attribute,"stack") == 0)
13698 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13702 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13708 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13714 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13720 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13722 if ((image == (Image *) NULL) || (exception->severity >= ErrorException))
13723 goto PerlException;
13724 for ( ; image; image=image->next)
13726 AddImageToRegistry(sv,image);
13728 av_push(av,sv_bless(rv,hv));
13731 exception=DestroyExceptionInfo(exception);
13732 ST(0)=av_reference;
13733 SvREFCNT_dec(perl_exception);
13737 InheritPerlException(exception,perl_exception);
13738 exception=DestroyExceptionInfo(exception);
13739 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13740 SvPOK_on(perl_exception);
13741 ST(0)=sv_2mortal(perl_exception);
13746 ###############################################################################
13750 # S t a t i s t i c s #
13754 ###############################################################################
13758 Statistics(ref,...)
13759 Image::Magick ref=NO_INIT
13761 StatisticsImage = 1
13763 statisticsimage = 3
13766 #define ChannelStatistics(channel) \
13768 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13769 (double) channel_statistics[channel].depth); \
13770 PUSHs(sv_2mortal(newSVpv(message,0))); \
13771 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13772 channel_statistics[channel].minima/scale); \
13773 PUSHs(sv_2mortal(newSVpv(message,0))); \
13774 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13775 channel_statistics[channel].maxima/scale); \
13776 PUSHs(sv_2mortal(newSVpv(message,0))); \
13777 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13778 channel_statistics[channel].mean/scale); \
13779 PUSHs(sv_2mortal(newSVpv(message,0))); \
13780 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13781 channel_statistics[channel].standard_deviation/scale); \
13782 PUSHs(sv_2mortal(newSVpv(message,0))); \
13783 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13784 channel_statistics[channel].kurtosis); \
13785 PUSHs(sv_2mortal(newSVpv(message,0))); \
13786 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13787 channel_statistics[channel].skewness); \
13788 PUSHs(sv_2mortal(newSVpv(message,0))); \
13795 message[MaxTextExtent];
13798 *channel_statistics;
13819 PERL_UNUSED_VAR(ref);
13820 PERL_UNUSED_VAR(ix);
13821 exception=AcquireExceptionInfo();
13822 perl_exception=newSVpv("",0);
13824 if (sv_isobject(ST(0)) == 0)
13826 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13828 goto PerlException;
13830 reference=SvRV(ST(0));
13833 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13834 if (image == (Image *) NULL)
13836 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13838 goto PerlException;
13840 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13842 for ( ; image; image=image->next)
13844 channel_statistics=GetImageStatistics(image,&image->exception);
13845 if (channel_statistics == (ChannelStatistics *) NULL)
13848 EXTEND(sp,35*count);
13849 scale=(double) QuantumRange;
13850 ChannelStatistics(RedChannel);
13851 ChannelStatistics(GreenChannel);
13852 ChannelStatistics(BlueChannel);
13853 if (image->colorspace == CMYKColorspace)
13854 ChannelStatistics(BlackChannel);
13855 if (image->matte != MagickFalse)
13856 ChannelStatistics(AlphaChannel);
13857 channel_statistics=(ChannelStatistics *)
13858 RelinquishMagickMemory(channel_statistics);
13862 InheritPerlException(exception,perl_exception);
13863 exception=DestroyExceptionInfo(exception);
13864 SvREFCNT_dec(perl_exception);
13868 ###############################################################################
13872 # S y n c A u t h e n t i c P i x e l s #
13876 ###############################################################################
13880 SyncAuthenticPixels(ref,...)
13881 Image::Magick ref = NO_INIT
13883 Syncauthenticpixels = 1
13884 SyncImagePixels = 2
13885 syncimagepixels = 3
13904 PERL_UNUSED_VAR(ref);
13905 PERL_UNUSED_VAR(ix);
13906 exception=AcquireExceptionInfo();
13907 perl_exception=newSVpv("",0);
13908 if (sv_isobject(ST(0)) == 0)
13910 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13912 goto PerlException;
13915 reference=SvRV(ST(0));
13916 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13917 if (image == (Image *) NULL)
13919 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13921 goto PerlException;
13924 status=SyncAuthenticPixels(image,exception);
13925 if (status != MagickFalse)
13927 InheritException(exception,&image->exception);
13930 InheritPerlException(exception,perl_exception);
13931 exception=DestroyExceptionInfo(exception);
13932 SvREFCNT_dec(perl_exception); /* throw away all errors */
13936 ###############################################################################
13940 # T r a n s f o r m #
13944 ###############################################################################
13949 Image::Magick ref=NO_INIT
13987 PERL_UNUSED_VAR(ref);
13988 PERL_UNUSED_VAR(ix);
13989 exception=AcquireExceptionInfo();
13990 perl_exception=newSVpv("",0);
13994 if (sv_isobject(ST(0)) == 0)
13996 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13998 goto PerlException;
14000 reference=SvRV(ST(0));
14001 hv=SvSTASH(reference);
14003 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14005 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14006 if (image == (Image *) NULL)
14008 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14010 goto PerlException;
14012 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14016 crop_geometry=(char *) NULL;
14017 geometry=(char *) NULL;
14018 for (i=2; i < items; i+=2)
14020 attribute=(char *) SvPV(ST(i-1),na);
14021 switch (*attribute)
14026 if (LocaleCompare(attribute,"crop") == 0)
14028 crop_geometry=SvPV(ST(i),na);
14031 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14038 if (LocaleCompare(attribute,"geometry") == 0)
14040 geometry=SvPV(ST(i),na);
14043 if (LocaleCompare(attribute,"gravity") == 0)
14051 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
14052 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
14055 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14059 for (next=image; next; next=next->next)
14060 next->gravity=(GravityType) in;
14063 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14069 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14075 for ( ; image; image=image->next)
14077 clone=CloneImage(image,0,0,MagickTrue,exception);
14078 if ((clone == (Image *) NULL) || (exception->severity >= ErrorException))
14079 goto PerlException;
14080 TransformImage(&clone,crop_geometry,geometry);
14081 for ( ; clone; clone=clone->next)
14083 AddImageToRegistry(sv,clone);
14085 av_push(av,sv_bless(rv,hv));
14089 exception=DestroyExceptionInfo(exception);
14090 ST(0)=av_reference;
14091 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14095 InheritPerlException(exception,perl_exception);
14096 exception=DestroyExceptionInfo(exception);
14097 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14098 SvPOK_on(perl_exception);
14099 ST(0)=sv_2mortal(perl_exception);
14104 ###############################################################################
14112 ###############################################################################
14117 Image::Magick ref=NO_INIT
14125 filename[MaxTextExtent];
14149 PERL_UNUSED_VAR(ref);
14150 PERL_UNUSED_VAR(ix);
14151 exception=AcquireExceptionInfo();
14152 perl_exception=newSVpv("",0);
14154 package_info=(struct PackageInfo *) NULL;
14155 if (sv_isobject(ST(0)) == 0)
14157 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14159 goto PerlException;
14161 reference=SvRV(ST(0));
14162 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14163 if (image == (Image *) NULL)
14165 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14167 goto PerlException;
14169 package_info=ClonePackageInfo(info,exception);
14171 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14174 for (i=2; i < items; i+=2)
14175 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14177 (void) CopyMagickString(filename,package_info->image_info->filename,
14180 for (next=image; next; next=next->next)
14182 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14183 next->scene=scene++;
14185 SetImageInfo(package_info->image_info,(unsigned int)
14186 GetImageListLength(image),&image->exception);
14187 for (next=image; next; next=next->next)
14189 (void) WriteImage(package_info->image_info,next,exception);
14191 if (package_info->image_info->adjoin)
14196 if (package_info != (struct PackageInfo *) NULL)
14197 DestroyPackageInfo(package_info);
14198 InheritPerlException(exception,perl_exception);
14199 exception=DestroyExceptionInfo(exception);
14200 sv_setiv(perl_exception,(IV) number_images);
14201 SvPOK_on(perl_exception);
14202 ST(0)=sv_2mortal(perl_exception);