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-2014 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(PTR2IV(image)); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick; /* data type for the Image::Magick package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
218 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
219 {"height", IntegerReference}, {"x", IntegerReference},
220 {"y", IntegerReference} } },
221 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
222 {"height", IntegerReference}, {"x", IntegerReference},
223 {"y", IntegerReference}, {"fuzz", StringReference},
224 {"gravity", MagickGravityOptions} } },
226 { "Edge", { {"radius", RealReference} } },
227 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
228 {"sigma", RealReference} } },
232 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
233 {"height", IntegerReference}, {"inner", IntegerReference},
234 {"outer", IntegerReference}, {"fill", StringReference},
235 {"color", StringReference}, {"compose", MagickComposeOptions} } },
236 { "Implode", { {"amount", RealReference},
237 {"interpolate", MagickInterpolateOptions} } },
239 { "MedianFilter", { {"geometry", StringReference},
240 {"width", IntegerReference}, {"height", IntegerReference},
241 {"channel", MagickChannelOptions} } },
243 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
244 { "ReduceNoise", { {"geometry", StringReference},
245 {"width", IntegerReference},{"height", IntegerReference},
246 {"channel", MagickChannelOptions} } },
247 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
248 {"y", IntegerReference} } },
249 { "Rotate", { {"degrees", RealReference},
250 {"background", StringReference} } },
251 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
252 {"height", IntegerReference} } },
253 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
254 {"height", IntegerReference} } },
255 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
256 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
257 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
258 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
259 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
260 {"y", RealReference}, { "fill", StringReference},
261 {"color", StringReference} } },
262 { "Spread", { {"radius", RealReference},
263 {"interpolate", MagickInterpolateOptions} } },
264 { "Swirl", { {"degrees", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
267 {"height", IntegerReference}, {"filter", MagickFilterOptions},
268 {"support", StringReference } } },
269 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", RealReference } } },
272 { "Annotate", { {"text", StringReference}, {"font", StringReference},
273 {"pointsize", RealReference}, {"density", StringReference},
274 {"undercolor", StringReference}, {"stroke", StringReference},
275 {"fill", StringReference}, {"geometry", StringReference},
276 {"sans", StringReference}, {"x", RealReference},
277 {"y", RealReference}, {"gravity", MagickGravityOptions},
278 {"translate", StringReference}, {"scale", StringReference},
279 {"rotate", RealReference}, {"skewX", RealReference},
280 {"skewY", RealReference}, {"strokewidth", RealReference},
281 {"antialias", MagickBooleanOptions}, {"family", StringReference},
282 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
283 {"weight", IntegerReference}, {"align", MagickAlignOptions},
284 {"encoding", StringReference}, {"affine", ArrayReference},
285 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
286 {"tile", ImageReference}, {"kerning", RealReference},
287 {"interline-spacing", RealReference},
288 {"interword-spacing", RealReference},
289 {"direction", MagickDirectionOptions} } },
290 { "ColorFloodfill", { {"geometry", StringReference},
291 {"x", IntegerReference}, {"y", IntegerReference},
292 {"fill", StringReference}, {"bordercolor", StringReference},
293 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
294 { "Composite", { {"image", ImageReference},
295 {"compose", MagickComposeOptions}, {"geometry", StringReference},
296 {"x", IntegerReference}, {"y", IntegerReference},
297 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
298 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
299 {"color", StringReference}, {"mask", ImageReference},
300 {"channel", MagickChannelOptions},
301 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
302 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
303 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
304 { "CycleColormap", { {"display", IntegerReference} } },
305 { "Draw", { {"primitive", MagickPrimitiveOptions},
306 {"points", StringReference}, {"method", MagickMethodOptions},
307 {"stroke", StringReference}, {"fill", StringReference},
308 {"strokewidth", RealReference}, {"font", StringReference},
309 {"bordercolor", StringReference}, {"x", RealReference},
310 {"y", RealReference}, {"translate", StringReference},
311 {"scale", StringReference}, {"rotate", RealReference},
312 {"skewX", RealReference}, {"skewY", RealReference},
313 {"tile", ImageReference}, {"pointsize", RealReference},
314 {"antialias", MagickBooleanOptions}, {"density", StringReference},
315 {"linewidth", RealReference}, {"affine", ArrayReference},
316 {"stroke-dashoffset", RealReference},
317 {"stroke-dasharray", ArrayReference},
318 {"interpolate", MagickInterpolateOptions},
319 {"origin", StringReference}, {"text", StringReference},
320 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
321 {"vector-graphics", StringReference}, {"kerning", RealReference},
322 {"interline-spacing", RealReference},
323 {"interword-spacing", RealReference},
324 {"direction", MagickDirectionOptions} } },
325 { "Equalize", { {"channel", MagickChannelOptions} } },
326 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
327 {"red", RealReference}, {"green", RealReference},
328 {"blue", RealReference} } },
329 { "Map", { {"image", ImageReference},
330 {"dither-method", MagickDitherOptions} } },
331 { "MatteFloodfill", { {"geometry", StringReference},
332 {"x", IntegerReference}, {"y", IntegerReference},
333 {"opacity", StringReference}, {"bordercolor", StringReference},
334 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
335 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
336 {"saturation", RealReference}, {"whiteness", RealReference},
337 {"brightness", RealReference}, {"lightness", RealReference},
338 {"blackness", RealReference} } },
339 { "Negate", { {"gray", MagickBooleanOptions},
340 {"channel", MagickChannelOptions} } },
341 { "Normalize", { {"channel", MagickChannelOptions} } },
343 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
344 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
345 {"invert", MagickBooleanOptions} } },
346 { "Quantize", { {"colors", IntegerReference},
347 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
348 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
349 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
350 {"dither-method", MagickDitherOptions} } },
351 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
352 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
353 { "Segment", { {"geometry", StringReference},
354 {"cluster-threshold", RealReference},
355 {"smoothing-threshold", RealReference},
356 {"colorspace", MagickColorspaceOptions},
357 {"verbose", MagickBooleanOptions} } },
359 { "Solarize", { {"geometry", StringReference},
360 {"threshold", StringReference} } },
362 { "Texture", { {"texture", ImageReference} } },
363 { "Evaluate", { {"value", RealReference},
364 {"operator", MagickEvaluateOptions},
365 {"channel", MagickChannelOptions} } },
366 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
367 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
368 { "Threshold", { {"threshold", StringReference},
369 {"channel", MagickChannelOptions} } },
370 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
371 {"sigma", RealReference} } },
372 { "Trim", { {"fuzz", StringReference} } },
373 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
374 {"wavelength", RealReference},
375 {"interpolate", MagickInterpolateOptions} } },
376 { "Separate", { {"channel", MagickChannelOptions} } },
378 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
379 {"y", IntegerReference} } },
380 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
382 { "GaussianBlur", { {"geometry", StringReference},
383 {"radius", RealReference}, {"sigma", RealReference},
384 {"channel", MagickChannelOptions} } },
385 { "Convolve", { {"coefficients", ArrayReference},
386 {"channel", MagickChannelOptions}, {"bias", StringReference},
387 {"kernel", StringReference} } },
388 { "Profile", { {"name", StringReference}, {"profile", StringReference},
389 { "rendering-intent", MagickIntentOptions},
390 { "black-point-compensation", MagickBooleanOptions} } },
391 { "UnsharpMask", { {"geometry", StringReference},
392 {"radius", RealReference}, {"sigma", RealReference},
393 {"gain", RealReference}, {"threshold", RealReference},
394 {"channel", MagickChannelOptions} } },
395 { "MotionBlur", { {"geometry", StringReference},
396 {"radius", RealReference}, {"sigma", RealReference},
397 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
398 { "OrderedDither", { {"threshold", StringReference},
399 {"channel", MagickChannelOptions} } },
400 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
401 {"height", IntegerReference} } },
402 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
403 {"white-point", RealReference}, {"gamma", RealReference},
404 {"channel", MagickChannelOptions}, {"level", StringReference} } },
405 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
406 { "AffineTransform", { {"affine", ArrayReference},
407 {"translate", StringReference}, {"scale", StringReference},
408 {"rotate", RealReference}, {"skewX", RealReference},
409 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
410 {"background", StringReference} } },
411 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
412 { "AdaptiveThreshold", { {"geometry", StringReference},
413 {"width", IntegerReference}, {"height", IntegerReference} } },
414 { "Resample", { {"density", StringReference}, {"x", RealReference},
415 {"y", RealReference}, {"filter", MagickFilterOptions},
416 {"support", RealReference } } },
417 { "Describe", { {"file", FileReference} } },
418 { "BlackThreshold", { {"threshold", StringReference},
419 {"channel", MagickChannelOptions} } },
420 { "WhiteThreshold", { {"threshold", StringReference},
421 {"channel", MagickChannelOptions} } },
422 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
423 {"channel", MagickChannelOptions} } },
424 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
425 {"height", IntegerReference} } },
427 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
428 { "Channel", { {"channel", MagickChannelOptions} } },
429 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
430 {"height", IntegerReference}, {"x", IntegerReference},
431 {"y", IntegerReference}, {"fuzz", StringReference},
432 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
433 { "Posterize", { {"levels", IntegerReference},
434 {"dither", MagickBooleanOptions} } },
435 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
436 {"sigma", RealReference}, {"x", IntegerReference},
437 {"y", IntegerReference} } },
438 { "Identify", { {"file", FileReference}, {"features", StringReference},
439 {"unique", MagickBooleanOptions} } },
440 { "SepiaTone", { {"threshold", RealReference} } },
441 { "SigmoidalContrast", { {"geometry", StringReference},
442 {"contrast", RealReference}, {"mid-point", RealReference},
443 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
444 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
445 {"height", IntegerReference}, {"x", IntegerReference},
446 {"y", IntegerReference}, {"fuzz", StringReference},
447 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
448 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
449 {"sigma", RealReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"background", StringReference} } },
451 { "ContrastStretch", { {"levels", StringReference},
452 {"black-point", RealReference},{"white-point", RealReference},
453 {"channel", MagickChannelOptions} } },
456 { "AdaptiveSharpen", { {"geometry", StringReference},
457 {"radius", RealReference}, {"sigma", RealReference},
458 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
462 { "AdaptiveBlur", { {"geometry", StringReference},
463 {"radius", RealReference}, {"sigma", RealReference},
464 {"channel", MagickChannelOptions} } },
465 { "Sketch", { {"geometry", StringReference},
466 {"radius", RealReference}, {"sigma", RealReference},
467 {"angle", RealReference} } },
469 { "AdaptiveResize", { {"geometry", StringReference},
470 {"width", IntegerReference}, {"height", IntegerReference},
471 {"filter", MagickFilterOptions}, {"support", StringReference },
472 {"blur", RealReference } } },
473 { "ClipMask", { {"mask", ImageReference} } },
474 { "LinearStretch", { {"levels", StringReference},
475 {"black-point", RealReference},{"white-point", RealReference} } },
476 { "ColorMatrix", { {"matrix", ArrayReference} } },
477 { "Mask", { {"mask", ImageReference} } },
478 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
479 {"font", StringReference}, {"stroke", StringReference},
480 {"fill", StringReference}, {"strokewidth", RealReference},
481 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
482 {"background", StringReference},
483 {"interpolate", MagickInterpolateOptions} } },
484 { "FloodfillPaint", { {"geometry", StringReference},
485 {"x", IntegerReference}, {"y", IntegerReference},
486 {"fill", StringReference}, {"bordercolor", StringReference},
487 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
488 {"invert", MagickBooleanOptions} } },
489 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
490 {"virtual-pixel", MagickVirtualPixelOptions},
491 {"best-fit", MagickBooleanOptions} } },
492 { "Clut", { {"image", ImageReference},
493 {"interpolate", MagickInterpolateOptions},
494 {"channel", MagickChannelOptions} } },
495 { "LiquidRescale", { {"geometry", StringReference},
496 {"width", IntegerReference}, {"height", IntegerReference},
497 {"delta-x", RealReference}, {"rigidity", RealReference } } },
498 { "Encipher", { {"passphrase", StringReference} } },
499 { "Decipher", { {"passphrase", StringReference} } },
500 { "Deskew", { {"geometry", StringReference},
501 {"threshold", StringReference} } },
502 { "Remap", { {"image", ImageReference},
503 {"dither-method", MagickDitherOptions} } },
504 { "SparseColor", { {"points", ArrayReference},
505 {"method", MagickSparseColorOptions},
506 {"virtual-pixel", MagickVirtualPixelOptions},
507 {"channel", MagickChannelOptions} } },
508 { "Function", { {"parameters", ArrayReference},
509 {"function", MagickFunctionOptions},
510 {"virtual-pixel", MagickVirtualPixelOptions} } },
511 { "SelectiveBlur", { {"geometry", StringReference},
512 {"radius", RealReference}, {"sigma", RealReference},
513 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
514 { "HaldClut", { {"image", ImageReference},
515 {"channel", MagickChannelOptions} } },
516 { "BlueShift", { {"factor", StringReference} } },
517 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
518 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "ColorDecisionList", {
520 {"color-correction-collection", StringReference} } },
521 { "AutoGamma", { {"channel", MagickChannelOptions} } },
522 { "AutoLevel", { {"channel", MagickChannelOptions} } },
523 { "LevelColors", { {"invert", MagickBooleanOptions},
524 {"black-point", StringReference}, {"white-point", StringReference},
525 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
526 { "Clamp", { {"channel", MagickChannelOptions} } },
527 { "BrightnessContrast", { {"levels", StringReference},
528 {"brightness", RealReference},{"contrast", RealReference},
529 {"channel", MagickChannelOptions} } },
530 { "Morphology", { {"kernel", StringReference},
531 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
532 {"iterations", IntegerReference} } },
533 { "Sans", { {"matrix", ArrayReference} } },
534 { "Color", { {"color", StringReference} } },
535 { "Mode", { {"geometry", StringReference},
536 {"width", IntegerReference},{"height", IntegerReference},
537 {"channel", MagickChannelOptions} } },
538 { "Statistic", { {"geometry", StringReference},
539 {"width", IntegerReference},{"height", IntegerReference},
540 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
541 { "Perceptible", { {"epsilon", RealReference},
542 {"channel", MagickChannelOptions} } },
543 { "Poly", { {"terms", ArrayReference},
544 {"channel", MagickChannelOptions} } },
545 { "Grayscale", { {"method", MagickNoiseOptions} } },
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=INT2PTR(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=INT2PTR(struct PackageInfo *,SvIV(sv))))
997 clone_info=ClonePackageInfo(package_info,exception);
998 sv_setiv(sv,PTR2IV(clone_info));
1003 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1007 % S e t A t t r i b u t e %
1011 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1013 % SetAttribute() sets the attribute to the value in sval. This can change
1014 % either or both of image or info.
1016 % The format of the SetAttribute routine is:
1018 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1019 % SV *sval,ExceptionInfo *exception)
1021 % A description of each parameter follows:
1023 % o list: a list of strings.
1025 % o string: a character string.
1029 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1037 value=InterpretSiPrefixValue(string,&q);
1039 value*=interval/100.0;
1043 static inline double StringToDouble(const char *string,char **sentinal)
1045 return(InterpretLocaleValue(string,sentinal));
1048 static double StringToDoubleInterval(const char *string,const double interval)
1056 value=InterpretLocaleValue(string,&q);
1058 value*=interval/100.0;
1062 static inline ssize_t StringToLong(const char *value)
1064 return(strtol(value,(char **) NULL,10));
1067 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1068 const char *attribute,SV *sval,ExceptionInfo *exception)
1095 if (LocaleCompare(attribute,"adjoin") == 0)
1097 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1098 SvPV(sval,na)) : SvIV(sval);
1101 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1106 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1109 if (LocaleCompare(attribute,"alpha") == 0)
1111 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1112 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1115 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1119 for ( ; image; image=image->next)
1120 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1124 if (LocaleCompare(attribute,"antialias") == 0)
1126 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1127 SvPV(sval,na)) : SvIV(sval);
1130 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1135 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1138 if (LocaleCompare(attribute,"area-limit") == 0)
1143 limit=MagickResourceInfinity;
1144 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1145 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1147 (void) SetMagickResourceLimit(AreaResource,limit);
1150 if (LocaleCompare(attribute,"attenuate") == 0)
1153 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1156 if (LocaleCompare(attribute,"authenticate") == 0)
1159 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1163 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1164 for ( ; image; image=image->next)
1165 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1171 if (LocaleCompare(attribute,"background") == 0)
1173 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1176 info->image_info->background_color=target_color;
1177 for ( ; image; image=image->next)
1178 image->background_color=target_color;
1181 if (LocaleCompare(attribute,"blue-primary") == 0)
1183 for ( ; image; image=image->next)
1185 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1186 image->chromaticity.blue_primary.x=geometry_info.rho;
1187 image->chromaticity.blue_primary.y=geometry_info.sigma;
1188 if ((flags & SigmaValue) == 0)
1189 image->chromaticity.blue_primary.y=
1190 image->chromaticity.blue_primary.x;
1194 if (LocaleCompare(attribute,"bordercolor") == 0)
1196 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1199 info->image_info->border_color=target_color;
1200 for ( ; image; image=image->next)
1201 image->border_color=target_color;
1205 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1206 for ( ; image; image=image->next)
1207 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1213 if (LocaleCompare(attribute,"cache-threshold") == 0)
1215 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1216 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1217 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1218 (2.0*SiPrefixToDoubleInterval(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 SetImageMask(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,
1286 if (LocaleCompare(attribute,"comment") == 0)
1288 for ( ; image; image=image->next)
1289 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1290 info ? info->image_info : (ImageInfo *) NULL,image,
1291 SvPV(sval,na),exception),exception);
1294 if (LocaleCompare(attribute,"compression") == 0)
1296 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1297 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1300 ThrowPerlException(exception,OptionError,
1301 "UnrecognizedImageCompression",SvPV(sval,na));
1305 info->image_info->compression=(CompressionType) sp;
1306 for ( ; image; image=image->next)
1307 image->compression=(CompressionType) sp;
1311 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1312 for ( ; image; image=image->next)
1313 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1319 if (LocaleCompare(attribute,"debug") == 0)
1321 SetLogEventMask(SvPV(sval,na));
1324 if (LocaleCompare(attribute,"delay") == 0)
1326 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1327 for ( ; image; image=image->next)
1329 image->delay=(size_t) floor(geometry_info.rho+0.5);
1330 if ((flags & SigmaValue) != 0)
1331 image->ticks_per_second=(ssize_t)
1332 floor(geometry_info.sigma+0.5);
1336 if (LocaleCompare(attribute,"disk-limit") == 0)
1341 limit=MagickResourceInfinity;
1342 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1343 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1345 (void) SetMagickResourceLimit(DiskResource,limit);
1348 if (LocaleCompare(attribute,"density") == 0)
1350 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1352 ThrowPerlException(exception,OptionError,"MissingGeometry",
1357 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1358 for ( ; image; image=image->next)
1360 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1361 image->resolution.x=geometry_info.rho;
1362 image->resolution.y=geometry_info.sigma;
1363 if ((flags & SigmaValue) == 0)
1364 image->resolution.y=image->resolution.x;
1368 if (LocaleCompare(attribute,"depth") == 0)
1371 info->image_info->depth=SvIV(sval);
1372 for ( ; image; image=image->next)
1373 (void) SetImageDepth(image,SvIV(sval),exception);
1376 if (LocaleCompare(attribute,"dispose") == 0)
1378 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1379 SvPV(sval,na)) : SvIV(sval);
1382 ThrowPerlException(exception,OptionError,
1383 "UnrecognizedDisposeMethod",SvPV(sval,na));
1386 for ( ; image; image=image->next)
1387 image->dispose=(DisposeType) sp;
1390 if (LocaleCompare(attribute,"dither") == 0)
1394 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1395 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1398 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1402 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1406 if (LocaleCompare(attribute,"display") == 0)
1410 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1414 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1415 for ( ; image; image=image->next)
1416 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1422 if (LocaleCompare(attribute,"endian") == 0)
1424 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1425 SvPV(sval,na)) : SvIV(sval);
1428 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1433 info->image_info->endian=(EndianType) sp;
1434 for ( ; image; image=image->next)
1435 image->endian=(EndianType) sp;
1438 if (LocaleCompare(attribute,"extract") == 0)
1441 Set image extract geometry.
1443 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1447 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1448 for ( ; image; image=image->next)
1449 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1455 if (LocaleCompare(attribute,"filename") == 0)
1458 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1460 for ( ; image; image=image->next)
1461 (void) CopyMagickString(image->filename,SvPV(sval,na),
1465 if (LocaleCompare(attribute,"file") == 0)
1473 if (info == (struct PackageInfo *) NULL)
1475 io_info=IoIFP(sv_2io(sval));
1476 if (io_info == (PerlIO *) NULL)
1478 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1482 file=PerlIO_findFILE(io_info);
1483 if (file == (FILE *) NULL)
1485 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1489 SetImageInfoFile(info->image_info,file);
1492 if (LocaleCompare(attribute,"fill") == 0)
1495 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1498 if (LocaleCompare(attribute,"font") == 0)
1501 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1504 if (LocaleCompare(attribute,"foreground") == 0)
1506 if (LocaleCompare(attribute,"fuzz") == 0)
1509 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1511 for ( ; image; image=image->next)
1512 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1517 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1518 for ( ; image; image=image->next)
1519 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1525 if (LocaleCompare(attribute,"gamma") == 0)
1527 for ( ; image; image=image->next)
1528 image->gamma=SvNV(sval);
1531 if (LocaleCompare(attribute,"gravity") == 0)
1533 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1534 SvPV(sval,na)) : SvIV(sval);
1537 ThrowPerlException(exception,OptionError,
1538 "UnrecognizedGravityType",SvPV(sval,na));
1542 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1543 for ( ; image; image=image->next)
1544 image->gravity=(GravityType) sp;
1547 if (LocaleCompare(attribute,"green-primary") == 0)
1549 for ( ; image; image=image->next)
1551 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1552 image->chromaticity.green_primary.x=geometry_info.rho;
1553 image->chromaticity.green_primary.y=geometry_info.sigma;
1554 if ((flags & SigmaValue) == 0)
1555 image->chromaticity.green_primary.y=
1556 image->chromaticity.green_primary.x;
1561 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1562 for ( ; image; image=image->next)
1563 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1569 if (LocaleNCompare(attribute,"index",5) == 0)
1583 for ( ; image; image=image->next)
1585 if (image->storage_class != PseudoClass)
1589 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1591 image_view=AcquireAuthenticCacheView(image,exception);
1592 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1593 if (q != (Quantum *) NULL)
1595 items=sscanf(SvPV(sval,na),"%ld",&index);
1596 if ((index >= 0) && (index < (ssize_t) image->colors))
1597 SetPixelIndex(image,index,q);
1598 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1600 image_view=DestroyCacheView(image_view);
1604 if (LocaleCompare(attribute,"iterations") == 0)
1607 for ( ; image; image=image->next)
1608 image->iterations=SvIV(sval);
1611 if (LocaleCompare(attribute,"interlace") == 0)
1613 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1614 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1617 ThrowPerlException(exception,OptionError,
1618 "UnrecognizedInterlaceType",SvPV(sval,na));
1622 info->image_info->interlace=(InterlaceType) sp;
1623 for ( ; image; image=image->next)
1624 image->interlace=(InterlaceType) sp;
1628 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1629 for ( ; image; image=image->next)
1630 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1636 if (LocaleCompare(attribute,"label") == 0)
1638 for ( ; image; image=image->next)
1639 (void) SetImageProperty(image,"label",InterpretImageProperties(
1640 info ? info->image_info : (ImageInfo *) NULL,image,
1641 SvPV(sval,na),exception),exception);
1644 if (LocaleCompare(attribute,"loop") == 0)
1647 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1648 for ( ; image; image=image->next)
1649 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1655 if (LocaleCompare(attribute,"magick") == 0)
1658 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1659 "%s:",SvPV(sval,na));
1660 for ( ; image; image=image->next)
1661 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1664 if (LocaleCompare(attribute,"map-limit") == 0)
1669 limit=MagickResourceInfinity;
1670 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1671 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1673 (void) SetMagickResourceLimit(MapResource,limit);
1676 if (LocaleCompare(attribute,"mask") == 0)
1681 mask=(Image *) NULL;
1683 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1684 for ( ; image; image=image->next)
1685 SetImageMask(image,mask,exception);
1688 if (LocaleCompare(attribute,"mattecolor") == 0)
1690 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1693 info->image_info->matte_color=target_color;
1694 for ( ; image; image=image->next)
1695 image->matte_color=target_color;
1698 if (LocaleCompare(attribute,"matte") == 0)
1700 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1701 SvPV(sval,na)) : SvIV(sval);
1704 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1708 for ( ; image; image=image->next)
1709 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1712 if (LocaleCompare(attribute,"memory-limit") == 0)
1717 limit=MagickResourceInfinity;
1718 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1719 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1721 (void) SetMagickResourceLimit(MemoryResource,limit);
1724 if (LocaleCompare(attribute,"monochrome") == 0)
1726 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1727 SvPV(sval,na)) : SvIV(sval);
1730 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1735 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1736 for ( ; image; image=image->next)
1737 (void) SetImageType(image,BilevelType,exception);
1741 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1742 for ( ; image; image=image->next)
1743 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1749 if (LocaleCompare(attribute,"option") == 0)
1752 DefineImageOption(info->image_info,SvPV(sval,na));
1755 if (LocaleCompare(attribute,"orientation") == 0)
1757 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1758 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1761 ThrowPerlException(exception,OptionError,
1762 "UnrecognizedOrientationType",SvPV(sval,na));
1766 info->image_info->orientation=(OrientationType) sp;
1767 for ( ; image; image=image->next)
1768 image->orientation=(OrientationType) sp;
1772 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1773 for ( ; image; image=image->next)
1774 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1780 if (LocaleCompare(attribute,"page") == 0)
1785 geometry=GetPageGeometry(SvPV(sval,na));
1787 (void) CloneString(&info->image_info->page,geometry);
1788 for ( ; image; image=image->next)
1789 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1790 geometry=(char *) RelinquishMagickMemory(geometry);
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=AcquireVirtualCacheView(image,exception);
1816 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1817 if (q != (Quantum *) NULL)
1819 if ((strchr(SvPV(sval,na),',') == 0) ||
1820 (strchr(SvPV(sval,na),')') != 0))
1821 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1825 GetPixelInfo(image,&pixel);
1826 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1827 pixel.red=geometry_info.rho;
1828 if ((flags & SigmaValue) != 0)
1829 pixel.green=geometry_info.sigma;
1830 if ((flags & XiValue) != 0)
1831 pixel.blue=geometry_info.xi;
1832 if ((flags & PsiValue) != 0)
1833 pixel.alpha=geometry_info.psi;
1834 if ((flags & ChiValue) != 0)
1835 pixel.black=geometry_info.chi;
1837 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1838 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1839 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1840 if (image->colorspace == CMYKColorspace)
1841 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1842 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1843 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1845 image_view=DestroyCacheView(image_view);
1849 if (LocaleCompare(attribute,"pointsize") == 0)
1853 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1854 info->image_info->pointsize=geometry_info.rho;
1858 if (LocaleCompare(attribute,"preview") == 0)
1860 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1861 SvPV(sval,na)) : SvIV(sval);
1864 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1869 info->image_info->preview_type=(PreviewType) sp;
1873 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1874 for ( ; image; image=image->next)
1875 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1881 if (LocaleCompare(attribute,"quality") == 0)
1884 info->image_info->quality=SvIV(sval);
1885 for ( ; image; image=image->next)
1886 image->quality=SvIV(sval);
1890 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1891 for ( ; image; image=image->next)
1892 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1898 if (LocaleCompare(attribute,"red-primary") == 0)
1900 for ( ; image; image=image->next)
1902 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1903 image->chromaticity.red_primary.x=geometry_info.rho;
1904 image->chromaticity.red_primary.y=geometry_info.sigma;
1905 if ((flags & SigmaValue) == 0)
1906 image->chromaticity.red_primary.y=
1907 image->chromaticity.red_primary.x;
1911 if (LocaleCompare(attribute,"render") == 0)
1913 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1914 SvPV(sval,na)) : SvIV(sval);
1917 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1921 for ( ; image; image=image->next)
1922 image->rendering_intent=(RenderingIntent) sp;
1925 if (LocaleCompare(attribute,"repage") == 0)
1930 for ( ; image; image=image->next)
1932 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1933 if ((flags & WidthValue) != 0)
1935 if ((flags & HeightValue) == 0)
1936 geometry.height=geometry.width;
1937 image->page.width=geometry.width;
1938 image->page.height=geometry.height;
1940 if ((flags & AspectValue) != 0)
1942 if ((flags & XValue) != 0)
1943 image->page.x+=geometry.x;
1944 if ((flags & YValue) != 0)
1945 image->page.y+=geometry.y;
1949 if ((flags & XValue) != 0)
1951 image->page.x=geometry.x;
1952 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1953 image->page.width=image->columns+geometry.x;
1955 if ((flags & YValue) != 0)
1957 image->page.y=geometry.y;
1958 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1959 image->page.height=image->rows+geometry.y;
1966 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1967 for ( ; image; image=image->next)
1968 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1974 if (LocaleCompare(attribute,"sampling-factor") == 0)
1976 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1978 ThrowPerlException(exception,OptionError,"MissingGeometry",
1983 (void) CloneString(&info->image_info->sampling_factor,
1987 if (LocaleCompare(attribute,"scene") == 0)
1989 for ( ; image; image=image->next)
1990 image->scene=SvIV(sval);
1993 if (LocaleCompare(attribute,"server") == 0)
1995 if (LocaleCompare(attribute,"size") == 0)
1999 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2001 ThrowPerlException(exception,OptionError,"MissingGeometry",
2005 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2009 if (LocaleCompare(attribute,"stroke") == 0)
2012 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2016 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2017 for ( ; image; image=image->next)
2018 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2024 if (LocaleCompare(attribute,"texture") == 0)
2027 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2030 if (LocaleCompare(attribute,"thread-limit") == 0)
2035 limit=MagickResourceInfinity;
2036 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2037 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2039 (void) SetMagickResourceLimit(ThreadResource,limit);
2042 if (LocaleCompare(attribute,"tile-offset") == 0)
2047 geometry=GetPageGeometry(SvPV(sval,na));
2049 (void) CloneString(&info->image_info->page,geometry);
2050 for ( ; image; image=image->next)
2051 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2053 geometry=(char *) RelinquishMagickMemory(geometry);
2056 if (LocaleCompare(attribute,"time-limit") == 0)
2061 limit=MagickResourceInfinity;
2062 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2063 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2065 (void) SetMagickResourceLimit(TimeResource,limit);
2068 if (LocaleCompare(attribute,"transparent-color") == 0)
2070 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2073 info->image_info->transparent_color=target_color;
2074 for ( ; image; image=image->next)
2075 image->transparent_color=target_color;
2078 if (LocaleCompare(attribute,"type") == 0)
2080 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2081 SvPV(sval,na)) : SvIV(sval);
2084 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2089 info->image_info->type=(ImageType) sp;
2090 for ( ; image; image=image->next)
2091 SetImageType(image,(ImageType) sp,exception);
2095 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2096 for ( ; image; image=image->next)
2097 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2103 if (LocaleCompare(attribute,"units") == 0)
2105 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2106 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2109 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2114 info->image_info->units=(ResolutionType) sp;
2115 for ( ; image; image=image->next)
2120 units=(ResolutionType) sp;
2121 if (image->units != units)
2122 switch (image->units)
2124 case UndefinedResolution:
2125 case PixelsPerInchResolution:
2127 if (units == PixelsPerCentimeterResolution)
2129 image->resolution.x*=2.54;
2130 image->resolution.y*=2.54;
2134 case PixelsPerCentimeterResolution:
2136 if (units == PixelsPerInchResolution)
2138 image->resolution.x/=2.54;
2139 image->resolution.y/=2.54;
2149 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2150 for ( ; image; image=image->next)
2151 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2157 if (LocaleCompare(attribute,"verbose") == 0)
2159 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2160 SvPV(sval,na)) : SvIV(sval);
2163 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2168 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2171 if (LocaleCompare(attribute,"view") == 0)
2174 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2177 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2179 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2180 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2183 ThrowPerlException(exception,OptionError,
2184 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2187 for ( ; image; image=image->next)
2188 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2192 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2193 for ( ; image; image=image->next)
2194 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2200 if (LocaleCompare(attribute,"white-point") == 0)
2202 for ( ; image; image=image->next)
2204 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2205 image->chromaticity.white_point.x=geometry_info.rho;
2206 image->chromaticity.white_point.y=geometry_info.sigma;
2207 if ((flags & SigmaValue) == 0)
2208 image->chromaticity.white_point.y=
2209 image->chromaticity.white_point.x;
2214 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2215 for ( ; image; image=image->next)
2216 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2222 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2223 for ( ; image; image=image->next)
2224 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2235 % S e t u p L i s t %
2239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2241 % Method SetupList returns the list of all the images linked by their
2242 % image->next and image->previous link lists for use with ImageMagick. If
2243 % info is non-NULL, an info structure is returned in *info. If
2244 % reference_vector is non-NULL,an array of SV* are returned in
2245 % *reference_vector. Reference_vector is used when the images are going to be
2246 % replaced with new Image*'s.
2248 % The format of the SetupList routine is:
2250 % Image *SetupList(SV *reference,struct PackageInfo **info,
2251 % SV ***reference_vector,ExceptionInfo *exception)
2253 % A description of each parameter follows:
2255 % o list: a list of strings.
2257 % o string: a character string.
2259 % o exception: Return any errors or warnings in this structure.
2262 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2263 SV ***reference_vector,ExceptionInfo *exception)
2272 if (reference_vector)
2273 *reference_vector=NULL;
2278 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2279 if (info && (SvTYPE(reference) == SVt_PVAV))
2280 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2290 % s t r E Q c a s e %
2294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2296 % strEQcase() compares two strings and returns 0 if they are the
2297 % same or if the second string runs out first. The comparison is case
2300 % The format of the strEQcase routine is:
2302 % ssize_t strEQcase(const char *p,const char *q)
2304 % A description of each parameter follows:
2306 % o p: a character string.
2308 % o q: a character string.
2312 static ssize_t strEQcase(const char *p,const char *q)
2320 for (i=0 ; (c=(*q)) != 0; i++)
2322 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2323 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2328 return(((*q == 0) && (*p == 0)) ? i : 0);
2332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2336 % I m a g e : : M a g i c k %
2340 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2344 MODULE = Image::Magick PACKAGE = Image::Magick
2349 MagickCoreGenesis("PerlMagick",MagickFalse);
2350 SetWarningHandler(NULL);
2351 SetErrorHandler(NULL);
2352 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2353 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2359 if (magick_registry != (SplayTreeInfo *) NULL)
2360 magick_registry=DestroySplayTree(magick_registry);
2361 MagickCoreTerminus();
2365 constant(name,argument)
2370 ###############################################################################
2378 ###############################################################################
2383 Image::Magick ref=NO_INIT
2407 PERL_UNUSED_VAR(ref);
2408 PERL_UNUSED_VAR(ix);
2409 exception=AcquireExceptionInfo();
2410 perl_exception=newSVpv("",0);
2411 package_info=(struct PackageInfo *) NULL;
2412 if (sv_isobject(ST(0)) == 0)
2414 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2418 reference=SvRV(ST(0));
2419 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2420 if (image == (Image *) NULL)
2422 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2426 package_info=ClonePackageInfo(info,exception);
2428 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2431 for (i=2; i < items; i+=2)
2432 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2434 (void) AnimateImages(package_info->image_info,image,exception);
2435 (void) CatchImageException(image);
2438 if (package_info != (struct PackageInfo *) NULL)
2439 DestroyPackageInfo(package_info);
2440 InheritPerlException(exception,perl_exception);
2441 exception=DestroyExceptionInfo(exception);
2442 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2443 SvPOK_on(perl_exception);
2444 ST(0)=sv_2mortal(perl_exception);
2449 ###############################################################################
2457 ###############################################################################
2462 Image::Magick ref=NO_INIT
2500 PERL_UNUSED_VAR(ref);
2501 PERL_UNUSED_VAR(ix);
2502 exception=AcquireExceptionInfo();
2503 perl_exception=newSVpv("",0);
2507 if (sv_isobject(ST(0)) == 0)
2509 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2513 reference=SvRV(ST(0));
2514 hv=SvSTASH(reference);
2516 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2519 if (image == (Image *) NULL)
2521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2525 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2530 for (i=2; i < items; i+=2)
2532 attribute=(char *) SvPV(ST(i-1),na);
2538 if (LocaleCompare(attribute,"stack") == 0)
2540 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2544 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2556 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2562 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2563 if (image == (Image *) NULL)
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)
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)
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 ###############################################################################
2845 # C h a n n e l F x #
2849 ###############################################################################
2854 Image::Magick ref=NO_INIT
2866 expression[MaxTextExtent];
2894 PERL_UNUSED_VAR(ref);
2895 PERL_UNUSED_VAR(ix);
2896 exception=AcquireExceptionInfo();
2897 perl_exception=newSVpv("",0);
2901 if (sv_isobject(ST(0)) == 0)
2903 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2907 reference=SvRV(ST(0));
2908 hv=SvSTASH(reference);
2910 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2912 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2913 if (image == (Image *) NULL)
2915 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2919 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2923 channel=DefaultChannels;
2924 (void) CopyMagickString(expression,"u",MaxTextExtent);
2926 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
2928 for (i=2; i < items; i+=2)
2930 attribute=(char *) SvPV(ST(i-1),na);
2936 if (LocaleCompare(attribute,"channel") == 0)
2941 option=ParseChannelOption(SvPV(ST(i),na));
2944 ThrowPerlException(exception,OptionError,
2945 "UnrecognizedType",SvPV(ST(i),na));
2948 channel=(ChannelType) option;
2951 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2958 if (LocaleCompare(attribute,"expression") == 0)
2960 (void) CopyMagickString(expression,SvPV(ST(i),na),
2964 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2970 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2976 channel_mask=SetImageChannelMask(image,channel);
2977 image=ChannelFxImage(image,expression,exception);
2978 if (image != (Image *) NULL)
2979 (void) SetImageChannelMask(image,channel_mask);
2980 if (image == (Image *) NULL)
2982 for ( ; image; image=image->next)
2984 AddImageToRegistry(sv,image);
2986 av_push(av,sv_bless(rv,hv));
2989 exception=DestroyExceptionInfo(exception);
2991 SvREFCNT_dec(perl_exception); /* can't return warning messages */
2995 InheritPerlException(exception,perl_exception);
2996 exception=DestroyExceptionInfo(exception);
2997 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2998 SvPOK_on(perl_exception);
2999 ST(0)=sv_2mortal(perl_exception);
3004 ###############################################################################
3012 ###############################################################################
3017 Image::Magick ref=NO_INIT
3050 PERL_UNUSED_VAR(ref);
3051 PERL_UNUSED_VAR(ix);
3052 exception=AcquireExceptionInfo();
3053 perl_exception=newSVpv("",0);
3055 if (sv_isobject(ST(0)) == 0)
3057 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3061 reference=SvRV(ST(0));
3062 hv=SvSTASH(reference);
3063 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3064 if (image == (Image *) NULL)
3066 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3071 Create blessed Perl array for the returned image.
3074 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3076 for ( ; image; image=image->next)
3078 clone=CloneImage(image,0,0,MagickTrue,exception);
3079 if (clone == (Image *) NULL)
3081 AddImageToRegistry(sv,clone);
3083 av_push(av,sv_bless(rv,hv));
3086 exception=DestroyExceptionInfo(exception);
3087 SvREFCNT_dec(perl_exception);
3091 InheritPerlException(exception,perl_exception);
3092 exception=DestroyExceptionInfo(exception);
3093 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3094 SvPOK_on(perl_exception);
3095 ST(0)=sv_2mortal(perl_exception);
3100 ###############################################################################
3108 ###############################################################################
3116 PERL_UNUSED_VAR(ref);
3117 if (magick_registry != (SplayTreeInfo *) NULL)
3122 ResetSplayTreeIterator(magick_registry);
3123 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3124 while (p != (Image *) NULL)
3127 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3133 ###############################################################################
3141 ###############################################################################
3146 Image::Magick ref=NO_INIT
3175 PERL_UNUSED_VAR(ref);
3176 PERL_UNUSED_VAR(ix);
3177 exception=AcquireExceptionInfo();
3178 perl_exception=newSVpv("",0);
3180 if (sv_isobject(ST(0)) == 0)
3182 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3186 reference=SvRV(ST(0));
3187 hv=SvSTASH(reference);
3189 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3191 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3192 if (image == (Image *) NULL)
3194 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3198 image=CoalesceImages(image,exception);
3199 if (image == (Image *) NULL)
3201 for ( ; image; image=image->next)
3203 AddImageToRegistry(sv,image);
3205 av_push(av,sv_bless(rv,hv));
3208 exception=DestroyExceptionInfo(exception);
3210 SvREFCNT_dec(perl_exception);
3214 InheritPerlException(exception,perl_exception);
3215 exception=DestroyExceptionInfo(exception);
3216 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3217 SvPOK_on(perl_exception);
3218 ST(0)=sv_2mortal(perl_exception);
3223 ###############################################################################
3231 ###############################################################################
3236 Image::Magick ref=NO_INIT
3282 PERL_UNUSED_VAR(ref);
3283 PERL_UNUSED_VAR(ix);
3284 exception=AcquireExceptionInfo();
3285 perl_exception=newSVpv("",0);
3289 if (sv_isobject(ST(0)) == 0)
3291 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3295 reference=SvRV(ST(0));
3296 hv=SvSTASH(reference);
3298 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3300 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3301 if (image == (Image *) NULL)
3303 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3307 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3311 reconstruct_image=image;
3312 metric=RootMeanSquaredErrorMetric;
3313 for (i=2; i < items; i+=2)
3315 attribute=(char *) SvPV(ST(i-1),na);
3321 if (LocaleCompare(attribute,"channel") == 0)
3326 option=ParseChannelOption(SvPV(ST(i),na));
3329 ThrowPerlException(exception,OptionError,
3330 "UnrecognizedType",SvPV(ST(i),na));
3333 SetPixelChannelMask(image,(ChannelType) option);
3336 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3343 if (LocaleCompare(attribute,"fuzz") == 0)
3345 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3348 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3355 if (LocaleCompare(attribute,"image") == 0)
3357 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3358 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3368 if (LocaleCompare(attribute,"metric") == 0)
3370 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3374 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3378 metric=(MetricType) option;
3381 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3387 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3393 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3395 if (difference_image != (Image *) NULL)
3397 difference_image->error.mean_error_per_pixel=distortion;
3398 AddImageToRegistry(sv,difference_image);
3400 av_push(av,sv_bless(rv,hv));
3403 exception=DestroyExceptionInfo(exception);
3405 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3409 InheritPerlException(exception,perl_exception);
3410 exception=DestroyExceptionInfo(exception);
3411 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3412 SvPOK_on(perl_exception);
3413 ST(0)=sv_2mortal(perl_exception);
3418 ###############################################################################
3422 # C o m p l e x I m a g e s #
3426 ###############################################################################
3431 Image::Magick ref=NO_INIT
3468 PERL_UNUSED_VAR(ref);
3469 PERL_UNUSED_VAR(ix);
3470 exception=AcquireExceptionInfo();
3471 perl_exception=newSVpv("",0);
3473 if (sv_isobject(ST(0)) == 0)
3475 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3479 reference=SvRV(ST(0));
3480 hv=SvSTASH(reference);
3481 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3482 if (image == (Image *) NULL)
3484 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3488 op=UndefinedComplexOperator;
3494 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3498 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3502 op=(ComplexOperator) in;
3505 for (i=2; i < items; i+=2)
3507 attribute=(char *) SvPV(ST(i-1),na);
3513 if (LocaleCompare(attribute,"operator") == 0)
3518 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3519 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3522 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3526 op=(ComplexOperator) in;
3529 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3535 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3541 image=ComplexImages(image,op,exception);
3542 if (image == (Image *) NULL)
3545 Create blessed Perl array for the returned image.
3548 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3550 AddImageToRegistry(sv,image);
3552 av_push(av,sv_bless(rv,hv));
3554 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3555 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3556 "complex-%.*s",(int) (MaxTextExtent-9),
3557 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3558 (void) CopyMagickString(image->filename,info->image_info->filename,
3560 SetImageInfo(info->image_info,0,exception);
3561 exception=DestroyExceptionInfo(exception);
3562 SvREFCNT_dec(perl_exception);
3566 InheritPerlException(exception,perl_exception);
3567 exception=DestroyExceptionInfo(exception);
3568 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3569 SvPOK_on(perl_exception);
3570 ST(0)=sv_2mortal(perl_exception);
3575 ###############################################################################
3579 # C o m p a r e L a y e r s #
3583 ###############################################################################
3588 Image::Magick ref=NO_INIT
3590 CompareImagesLayers = 1
3592 compareimagelayers = 3
3629 PERL_UNUSED_VAR(ref);
3630 PERL_UNUSED_VAR(ix);
3631 exception=AcquireExceptionInfo();
3632 perl_exception=newSVpv("",0);
3634 if (sv_isobject(ST(0)) == 0)
3636 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3640 reference=SvRV(ST(0));
3641 hv=SvSTASH(reference);
3643 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3645 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3646 if (image == (Image *) NULL)
3648 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3652 method=CompareAnyLayer;
3653 for (i=2; i < items; i+=2)
3655 attribute=(char *) SvPV(ST(i-1),na);
3661 if (LocaleCompare(attribute,"method") == 0)
3663 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3667 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3671 method=(LayerMethod) option;
3674 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3680 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3686 image=CompareImagesLayers(image,method,exception);
3687 if (image == (Image *) NULL)
3689 for ( ; image; image=image->next)
3691 AddImageToRegistry(sv,image);
3693 av_push(av,sv_bless(rv,hv));
3696 exception=DestroyExceptionInfo(exception);
3698 SvREFCNT_dec(perl_exception);
3702 InheritPerlException(exception,perl_exception);
3703 exception=DestroyExceptionInfo(exception);
3704 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3705 SvPOK_on(perl_exception);
3706 ST(0)=sv_2mortal(perl_exception);
3711 ###############################################################################
3719 ###############################################################################
3724 Image::Magick ref=NO_INIT
3730 PERL_UNUSED_VAR(ref);
3731 if (sv_isobject(ST(0)) == 0)
3732 croak("ReferenceIsNotMyType");
3733 reference=SvRV(ST(0));
3734 switch (SvTYPE(reference))
3739 message[MaxTextExtent];
3757 Array (AV *) reference
3759 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3760 XS_VERSION,reference);
3761 hv=gv_stashpv(PackageName, FALSE);
3764 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3768 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3770 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3771 DestroyPackageInfo(info);
3773 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3783 Blessed scalar = (Image *) SvIV(reference)
3785 image=INT2PTR(Image *,SvIV(reference));
3786 if (image != (Image *) NULL)
3787 DeleteImageFromRegistry(reference,image);
3796 ###############################################################################
3804 ###############################################################################
3809 Image::Magick ref=NO_INIT
3833 PERL_UNUSED_VAR(ref);
3834 PERL_UNUSED_VAR(ix);
3835 exception=AcquireExceptionInfo();
3836 perl_exception=newSVpv("",0);
3837 package_info=(struct PackageInfo *) NULL;
3838 if (sv_isobject(ST(0)) == 0)
3840 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3844 reference=SvRV(ST(0));
3845 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3846 if (image == (Image *) NULL)
3848 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3852 package_info=ClonePackageInfo(info,exception);
3854 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3857 for (i=2; i < items; i+=2)
3858 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3860 (void) DisplayImages(package_info->image_info,image,exception);
3861 (void) CatchImageException(image);
3864 if (package_info != (struct PackageInfo *) NULL)
3865 DestroyPackageInfo(package_info);
3866 InheritPerlException(exception,perl_exception);
3867 exception=DestroyExceptionInfo(exception);
3868 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3869 SvPOK_on(perl_exception);
3870 ST(0)=sv_2mortal(perl_exception);
3875 ###############################################################################
3879 # E v a l u a t e I m a g e s #
3883 ###############################################################################
3888 Image::Magick ref=NO_INIT
3910 MagickEvaluateOperator
3925 PERL_UNUSED_VAR(ref);
3926 PERL_UNUSED_VAR(ix);
3927 exception=AcquireExceptionInfo();
3928 perl_exception=newSVpv("",0);
3930 if (sv_isobject(ST(0)) == 0)
3932 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3936 reference=SvRV(ST(0));
3937 hv=SvSTASH(reference);
3938 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3939 if (image == (Image *) NULL)
3941 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3945 op=MeanEvaluateOperator;
3951 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3955 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3959 op=(MagickEvaluateOperator) in;
3962 for (i=2; i < items; i+=2)
3964 attribute=(char *) SvPV(ST(i-1),na);
3970 if (LocaleCompare(attribute,"operator") == 0)
3975 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3976 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3979 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3983 op=(MagickEvaluateOperator) in;
3986 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3992 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3998 image=EvaluateImages(image,op,exception);
3999 if (image == (Image *) NULL)
4002 Create blessed Perl array for the returned image.
4005 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4007 AddImageToRegistry(sv,image);
4009 av_push(av,sv_bless(rv,hv));
4011 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4012 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4013 "evaluate-%.*s",(int) (MaxTextExtent-9),
4014 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4015 (void) CopyMagickString(image->filename,info->image_info->filename,
4017 SetImageInfo(info->image_info,0,exception);
4018 exception=DestroyExceptionInfo(exception);
4019 SvREFCNT_dec(perl_exception);
4023 InheritPerlException(exception,perl_exception);
4024 exception=DestroyExceptionInfo(exception);
4025 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4026 SvPOK_on(perl_exception);
4027 ST(0)=sv_2mortal(perl_exception);
4032 ###############################################################################
4040 ###############################################################################
4045 Image::Magick ref=NO_INIT
4052 #define ChannelFeatures(channel,direction) \
4054 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4055 channel_features[channel].angular_second_moment[direction]); \
4056 PUSHs(sv_2mortal(newSVpv(message,0))); \
4057 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4058 channel_features[channel].contrast[direction]); \
4059 PUSHs(sv_2mortal(newSVpv(message,0))); \
4060 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4061 channel_features[channel].contrast[direction]); \
4062 PUSHs(sv_2mortal(newSVpv(message,0))); \
4063 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4064 channel_features[channel].variance_sum_of_squares[direction]); \
4065 PUSHs(sv_2mortal(newSVpv(message,0))); \
4066 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4067 channel_features[channel].inverse_difference_moment[direction]); \
4068 PUSHs(sv_2mortal(newSVpv(message,0))); \
4069 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4070 channel_features[channel].sum_average[direction]); \
4071 PUSHs(sv_2mortal(newSVpv(message,0))); \
4072 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4073 channel_features[channel].sum_variance[direction]); \
4074 PUSHs(sv_2mortal(newSVpv(message,0))); \
4075 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4076 channel_features[channel].sum_entropy[direction]); \
4077 PUSHs(sv_2mortal(newSVpv(message,0))); \
4078 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4079 channel_features[channel].entropy[direction]); \
4080 PUSHs(sv_2mortal(newSVpv(message,0))); \
4081 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4082 channel_features[channel].difference_variance[direction]); \
4083 PUSHs(sv_2mortal(newSVpv(message,0))); \
4084 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4085 channel_features[channel].difference_entropy[direction]); \
4086 PUSHs(sv_2mortal(newSVpv(message,0))); \
4087 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4088 channel_features[channel].measure_of_correlation_1[direction]); \
4089 PUSHs(sv_2mortal(newSVpv(message,0))); \
4090 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4091 channel_features[channel].measure_of_correlation_2[direction]); \
4092 PUSHs(sv_2mortal(newSVpv(message,0))); \
4093 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4094 channel_features[channel].maximum_correlation_coefficient[direction]); \
4095 PUSHs(sv_2mortal(newSVpv(message,0))); \
4103 message[MaxTextExtent];
4130 PERL_UNUSED_VAR(ref);
4131 PERL_UNUSED_VAR(ix);
4132 exception=AcquireExceptionInfo();
4133 perl_exception=newSVpv("",0);
4135 if (sv_isobject(ST(0)) == 0)
4137 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4141 reference=SvRV(ST(0));
4144 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4145 if (image == (Image *) NULL)
4147 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4151 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4153 for (i=2; i < items; i+=2)
4155 attribute=(char *) SvPV(ST(i-1),na);
4161 if (LocaleCompare(attribute,"distance") == 0)
4163 distance=StringToLong((char *) SvPV(ST(1),na));
4166 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4172 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4179 for ( ; image; image=image->next)
4181 channel_features=GetImageFeatures(image,distance,exception);
4182 if (channel_features == (ChannelFeatures *) NULL)
4185 EXTEND(sp,75*count);
4186 for (i=0; i < 4; i++)
4188 ChannelFeatures(RedChannel,i);
4189 ChannelFeatures(GreenChannel,i);
4190 ChannelFeatures(BlueChannel,i);
4191 if (image->colorspace == CMYKColorspace)
4192 ChannelFeatures(BlackChannel,i);
4193 if (image->alpha_trait == BlendPixelTrait)
4194 ChannelFeatures(AlphaChannel,i);
4196 channel_features=(ChannelFeatures *)
4197 RelinquishMagickMemory(channel_features);
4201 InheritPerlException(exception,perl_exception);
4202 exception=DestroyExceptionInfo(exception);
4203 SvREFCNT_dec(perl_exception);
4207 ###############################################################################
4215 ###############################################################################
4220 Image::Magick ref=NO_INIT
4258 PERL_UNUSED_VAR(ref);
4259 PERL_UNUSED_VAR(ix);
4260 exception=AcquireExceptionInfo();
4261 perl_exception=newSVpv("",0);
4263 if (sv_isobject(ST(0)) == 0)
4265 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4269 reference=SvRV(ST(0));
4270 hv=SvSTASH(reference);
4271 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4272 if (image == (Image *) NULL)
4274 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4278 background_color=image->background_color;
4280 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4281 &background_color,exception);
4283 for (i=2; i < items; i+=2)
4285 attribute=(char *) SvPV(ST(i-1),na);
4291 if (LocaleCompare(attribute,"background") == 0)
4293 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4294 AllCompliance,&background_color,exception);
4297 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4303 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4309 image->background_color=background_color;
4310 image=MergeImageLayers(image,FlattenLayer,exception);
4311 if (image == (Image *) NULL)
4314 Create blessed Perl array for the returned image.
4317 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4319 AddImageToRegistry(sv,image);
4321 av_push(av,sv_bless(rv,hv));
4323 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4324 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4325 "flatten-%.*s",(int) (MaxTextExtent-9),
4326 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4327 (void) CopyMagickString(image->filename,info->image_info->filename,
4329 SetImageInfo(info->image_info,0,exception);
4330 exception=DestroyExceptionInfo(exception);
4331 SvREFCNT_dec(perl_exception);
4335 InheritPerlException(exception,perl_exception);
4336 exception=DestroyExceptionInfo(exception);
4337 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4338 SvPOK_on(perl_exception); /* return messages in string context */
4339 ST(0)=sv_2mortal(perl_exception);
4344 ###############################################################################
4352 ###############################################################################
4357 Image::Magick ref=NO_INIT
4369 expression[MaxTextExtent];
4397 PERL_UNUSED_VAR(ref);
4398 PERL_UNUSED_VAR(ix);
4399 exception=AcquireExceptionInfo();
4400 perl_exception=newSVpv("",0);
4404 if (sv_isobject(ST(0)) == 0)
4406 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4410 reference=SvRV(ST(0));
4411 hv=SvSTASH(reference);
4413 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4415 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4416 if (image == (Image *) NULL)
4418 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4422 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4426 channel=DefaultChannels;
4427 (void) CopyMagickString(expression,"u",MaxTextExtent);
4429 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4431 for (i=2; i < items; i+=2)
4433 attribute=(char *) SvPV(ST(i-1),na);
4439 if (LocaleCompare(attribute,"channel") == 0)
4444 option=ParseChannelOption(SvPV(ST(i),na));
4447 ThrowPerlException(exception,OptionError,
4448 "UnrecognizedType",SvPV(ST(i),na));
4451 channel=(ChannelType) option;
4454 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4461 if (LocaleCompare(attribute,"expression") == 0)
4463 (void) CopyMagickString(expression,SvPV(ST(i),na),
4467 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4473 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4479 channel_mask=SetImageChannelMask(image,channel);
4480 image=FxImage(image,expression,exception);
4481 if (image != (Image *) NULL)
4482 (void) SetImageChannelMask(image,channel_mask);
4483 if (image == (Image *) NULL)
4485 for ( ; image; image=image->next)
4487 AddImageToRegistry(sv,image);
4489 av_push(av,sv_bless(rv,hv));
4492 exception=DestroyExceptionInfo(exception);
4494 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4498 InheritPerlException(exception,perl_exception);
4499 exception=DestroyExceptionInfo(exception);
4500 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4501 SvPOK_on(perl_exception);
4502 ST(0)=sv_2mortal(perl_exception);
4507 ###############################################################################
4515 ###############################################################################
4520 Image::Magick ref=NO_INIT
4531 color[MaxTextExtent];
4556 PERL_UNUSED_VAR(ref);
4557 PERL_UNUSED_VAR(ix);
4558 exception=AcquireExceptionInfo();
4559 perl_exception=newSVpv("",0);
4560 if (sv_isobject(ST(0)) == 0)
4562 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4566 reference=SvRV(ST(0));
4567 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4568 if (image == (Image *) NULL && !info)
4571 for (i=1; i < items; i++)
4573 attribute=(char *) SvPV(ST(i),na);
4580 if (LocaleCompare(attribute,"adjoin") == 0)
4583 s=newSViv((ssize_t) info->image_info->adjoin);
4584 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4587 if (LocaleCompare(attribute,"antialias") == 0)
4590 s=newSViv((ssize_t) info->image_info->antialias);
4591 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4594 if (LocaleCompare(attribute,"area") == 0)
4596 s=newSViv(GetMagickResource(AreaResource));
4597 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4600 if (LocaleCompare(attribute,"attenuate") == 0)
4605 value=GetImageProperty(image,attribute,exception);
4606 if (value != (const char *) NULL)
4608 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4611 if (LocaleCompare(attribute,"authenticate") == 0)
4618 option=GetImageOption(info->image_info,attribute);
4619 if (option != (const char *) NULL)
4620 s=newSVpv(option,0);
4622 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4632 if (LocaleCompare(attribute,"background") == 0)
4634 if (image == (Image *) NULL)
4636 (void) FormatLocaleString(color,MaxTextExtent,
4637 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4638 image->background_color.green,image->background_color.blue,
4639 image->background_color.alpha);
4641 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4644 if (LocaleCompare(attribute,"base-columns") == 0)
4646 if (image != (Image *) NULL)
4647 s=newSViv((ssize_t) image->magick_columns);
4648 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4651 if (LocaleCompare(attribute,"base-filename") == 0)
4653 if (image != (Image *) NULL)
4654 s=newSVpv(image->magick_filename,0);
4655 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4658 if (LocaleCompare(attribute,"base-height") == 0)
4660 if (image != (Image *) NULL)
4661 s=newSViv((ssize_t) image->magick_rows);
4662 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4665 if (LocaleCompare(attribute,"base-rows") == 0)
4667 if (image != (Image *) NULL)
4668 s=newSViv((ssize_t) image->magick_rows);
4669 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4672 if (LocaleCompare(attribute,"base-width") == 0)
4674 if (image != (Image *) NULL)
4675 s=newSViv((ssize_t) image->magick_columns);
4676 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4679 if (LocaleCompare(attribute,"blue-primary") == 0)
4681 if (image == (Image *) NULL)
4683 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4684 image->chromaticity.blue_primary.x,
4685 image->chromaticity.blue_primary.y);
4687 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4690 if (LocaleCompare(attribute,"bordercolor") == 0)
4692 if (image == (Image *) NULL)
4694 (void) FormatLocaleString(color,MaxTextExtent,
4695 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4696 image->border_color.green,image->border_color.blue,
4697 image->border_color.alpha);
4699 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4702 if (LocaleCompare(attribute,"bounding-box") == 0)
4705 geometry[MaxTextExtent];
4710 if (image == (Image *) NULL)
4712 page=GetImageBoundingBox(image,exception);
4713 (void) FormatLocaleString(geometry,MaxTextExtent,
4714 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4715 page.height,(double) page.x,(double) page.y);
4716 s=newSVpv(geometry,0);
4717 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4720 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4727 if (LocaleCompare(attribute,"class") == 0)
4729 if (image == (Image *) NULL)
4731 s=newSViv(image->storage_class);
4732 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4733 image->storage_class));
4735 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4738 if (LocaleCompare(attribute,"clip-mask") == 0)
4740 if (image != (Image *) NULL)
4749 if (image->read_mask == MagickFalse)
4750 ClipImage(image,exception);
4751 mask_image=GetImageMask(image,exception);
4752 if (mask_image != (Image *) NULL)
4754 AddImageToRegistry(sv,mask_image);
4755 s=sv_bless(newRV(sv),SvSTASH(reference));
4758 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4761 if (LocaleCompare(attribute,"clip-path") == 0)
4763 if (image != (Image *) NULL)
4772 if (image->read_mask != MagickFalse)
4773 ClipImage(image,exception);
4774 mask_image=GetImageMask(image,exception);
4775 if (mask_image != (Image *) NULL)
4777 AddImageToRegistry(sv,mask_image);
4778 s=sv_bless(newRV(sv),SvSTASH(reference));
4781 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4784 if (LocaleCompare(attribute,"compression") == 0)
4786 j=info ? info->image_info->compression : image ?
4787 image->compression : UndefinedCompression;
4789 if (info->image_info->compression == UndefinedCompression)
4790 j=image->compression;
4792 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4795 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4798 if (LocaleCompare(attribute,"colorspace") == 0)
4800 j=image ? image->colorspace : RGBColorspace;
4802 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4805 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4808 if (LocaleCompare(attribute,"colors") == 0)
4810 if (image != (Image *) NULL)
4811 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4813 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4816 if (LocaleNCompare(attribute,"colormap",8) == 0)
4821 if (image == (Image *) NULL || !image->colormap)
4824 items=sscanf(attribute,"%*[^[][%ld",&j);
4826 if (j > (ssize_t) image->colors)
4828 (void) FormatLocaleString(color,MaxTextExtent,
4829 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4830 image->colormap[j].green,image->colormap[j].blue,
4831 image->colormap[j].alpha);
4833 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4836 if (LocaleCompare(attribute,"columns") == 0)
4838 if (image != (Image *) NULL)
4839 s=newSViv((ssize_t) image->columns);
4840 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4843 if (LocaleCompare(attribute,"comment") == 0)
4848 value=GetImageProperty(image,attribute,exception);
4849 if (value != (const char *) NULL)
4851 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4854 if (LocaleCompare(attribute,"copyright") == 0)
4856 s=newSVpv(GetMagickCopyright(),0);
4857 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4860 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4867 if (LocaleCompare(attribute,"density") == 0)
4870 geometry[MaxTextExtent];
4872 if (image == (Image *) NULL)
4874 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4875 image->resolution.x,image->resolution.y);
4876 s=newSVpv(geometry,0);
4877 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4880 if (LocaleCompare(attribute,"delay") == 0)
4882 if (image != (Image *) NULL)
4883 s=newSViv((ssize_t) image->delay);
4884 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4887 if (LocaleCompare(attribute,"depth") == 0)
4889 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4890 if (image != (Image *) NULL)
4891 s=newSViv((ssize_t) GetImageDepth(image,exception));
4892 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4895 if (LocaleCompare(attribute,"directory") == 0)
4897 if (image && image->directory)
4898 s=newSVpv(image->directory,0);
4899 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4902 if (LocaleCompare(attribute,"dispose") == 0)
4904 if (image == (Image *) NULL)
4907 s=newSViv(image->dispose);
4909 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4911 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4914 if (LocaleCompare(attribute,"disk") == 0)
4916 s=newSViv(GetMagickResource(DiskResource));
4917 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4920 if (LocaleCompare(attribute,"dither") == 0)
4923 s=newSViv((ssize_t) info->image_info->dither);
4924 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4927 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4929 if (info && info->image_info->server_name)
4930 s=newSVpv(info->image_info->server_name,0);
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4941 if (LocaleCompare(attribute,"elapsed-time") == 0)
4943 if (image != (Image *) NULL)
4944 s=newSVnv(GetElapsedTime(&image->timer));
4945 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4948 if (LocaleCompare(attribute,"endian") == 0)
4950 j=info ? info->image_info->endian : image ? image->endian :
4953 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4955 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4958 if (LocaleCompare(attribute,"error") == 0)
4960 if (image != (Image *) NULL)
4961 s=newSVnv(image->error.mean_error_per_pixel);
4962 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4965 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4972 if (LocaleCompare(attribute,"filesize") == 0)
4974 if (image != (Image *) NULL)
4975 s=newSViv((ssize_t) GetBlobSize(image));
4976 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4979 if (LocaleCompare(attribute,"filename") == 0)
4981 if (info && info->image_info->filename &&
4982 *info->image_info->filename)
4983 s=newSVpv(info->image_info->filename,0);
4984 if (image != (Image *) NULL)
4985 s=newSVpv(image->filename,0);
4986 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4989 if (LocaleCompare(attribute,"filter") == 0)
4991 s=image ? newSViv(image->filter) : newSViv(0);
4992 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4995 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4998 if (LocaleCompare(attribute,"font") == 0)
5000 if (info && info->image_info->font)
5001 s=newSVpv(info->image_info->font,0);
5002 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5005 if (LocaleCompare(attribute,"foreground") == 0)
5007 if (LocaleCompare(attribute,"format") == 0)
5012 magick_info=(const MagickInfo *) NULL;
5013 if (info && (*info->image_info->magick != '\0'))
5014 magick_info=GetMagickInfo(info->image_info->magick,exception);
5015 if (image != (Image *) NULL)
5016 magick_info=GetMagickInfo(image->magick,exception);
5017 if ((magick_info != (const MagickInfo *) NULL) &&
5018 (*magick_info->description != '\0'))
5019 s=newSVpv((char *) magick_info->description,0);
5020 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5023 if (LocaleCompare(attribute,"fuzz") == 0)
5026 s=newSVnv(info->image_info->fuzz);
5027 if (image != (Image *) NULL)
5028 s=newSVnv(image->fuzz);
5029 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5032 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5039 if (LocaleCompare(attribute,"gamma") == 0)
5041 if (image != (Image *) NULL)
5042 s=newSVnv(image->gamma);
5043 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5046 if (LocaleCompare(attribute,"geometry") == 0)
5048 if (image && image->geometry)
5049 s=newSVpv(image->geometry,0);
5050 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5053 if (LocaleCompare(attribute,"gravity") == 0)
5055 s=image ? newSViv(image->gravity) : newSViv(0);
5056 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5059 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5062 if (LocaleCompare(attribute,"green-primary") == 0)
5064 if (image == (Image *) NULL)
5066 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5067 image->chromaticity.green_primary.x,
5068 image->chromaticity.green_primary.y);
5070 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5073 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5080 if (LocaleCompare(attribute,"height") == 0)
5082 if (image != (Image *) NULL)
5083 s=newSViv((ssize_t) image->rows);
5084 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5087 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5094 if (LocaleCompare(attribute,"icc") == 0)
5096 if (image != (Image *) NULL)
5101 profile=GetImageProfile(image,"icc");
5102 if (profile != (StringInfo *) NULL)
5103 s=newSVpv((const char *) GetStringInfoDatum(profile),
5104 GetStringInfoLength(profile));
5106 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5109 if (LocaleCompare(attribute,"icm") == 0)
5111 if (image != (Image *) NULL)
5116 profile=GetImageProfile(image,"icm");
5117 if (profile != (const StringInfo *) NULL)
5118 s=newSVpv((const char *) GetStringInfoDatum(profile),
5119 GetStringInfoLength(profile));
5121 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5124 if (LocaleCompare(attribute,"id") == 0)
5126 if (image != (Image *) NULL)
5137 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
5139 status=SetImageRegistry(ImageRegistryType,key,image,
5144 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5147 if (LocaleNCompare(attribute,"index",5) == 0)
5150 name[MaxTextExtent];
5159 register const Quantum
5165 if (image == (Image *) NULL)
5167 if (image->storage_class != PseudoClass)
5171 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5173 image_view=AcquireVirtualCacheView(image,exception);
5174 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5175 if (p != (const Quantum *) NULL)
5177 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5178 GetPixelIndex(image,p));
5180 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5182 image_view=DestroyCacheView(image_view);
5185 if (LocaleCompare(attribute,"iptc") == 0)
5187 if (image != (Image *) NULL)
5192 profile=GetImageProfile(image,"iptc");
5193 if (profile != (const StringInfo *) NULL)
5194 s=newSVpv((const char *) GetStringInfoDatum(profile),
5195 GetStringInfoLength(profile));
5197 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5200 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5202 if (image != (Image *) NULL)
5203 s=newSViv((ssize_t) image->iterations);
5204 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5207 if (LocaleCompare(attribute,"interlace") == 0)
5209 j=info ? info->image_info->interlace : image ? image->interlace :
5212 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5215 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5218 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5225 if (LocaleCompare(attribute,"label") == 0)
5230 if (image == (Image *) NULL)
5232 value=GetImageProperty(image,"Label",exception);
5233 if (value != (const char *) NULL)
5235 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5238 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5240 if (image != (Image *) NULL)
5241 s=newSViv((ssize_t) image->iterations);
5242 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5245 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5252 if (LocaleCompare(attribute,"magick") == 0)
5254 if (info && *info->image_info->magick)
5255 s=newSVpv(info->image_info->magick,0);
5256 if (image != (Image *) NULL)
5257 s=newSVpv(image->magick,0);
5258 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5261 if (LocaleCompare(attribute,"map") == 0)
5263 s=newSViv(GetMagickResource(MapResource));
5264 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5267 if (LocaleCompare(attribute,"maximum-error") == 0)
5269 if (image != (Image *) NULL)
5270 s=newSVnv(image->error.normalized_maximum_error);
5271 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5274 if (LocaleCompare(attribute,"memory") == 0)
5276 s=newSViv(GetMagickResource(MemoryResource));
5277 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5280 if (LocaleCompare(attribute,"mean-error") == 0)
5282 if (image != (Image *) NULL)
5283 s=newSVnv(image->error.normalized_mean_error);
5284 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5287 if (LocaleCompare(attribute,"mime") == 0)
5289 if (info && *info->image_info->magick)
5290 s=newSVpv(MagickToMime(info->image_info->magick),0);
5291 if (image != (Image *) NULL)
5292 s=newSVpv(MagickToMime(image->magick),0);
5293 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5296 if (LocaleCompare(attribute,"mattecolor") == 0)
5298 if (image == (Image *) NULL)
5300 (void) FormatLocaleString(color,MaxTextExtent,
5301 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
5302 image->matte_color.green,image->matte_color.blue,
5303 image->matte_color.alpha);
5305 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5308 if (LocaleCompare(attribute,"matte") == 0)
5310 if (image != (Image *) NULL)
5311 s=newSViv((ssize_t) image->alpha_trait == BlendPixelTrait ?
5313 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5316 if (LocaleCompare(attribute,"mime") == 0)
5322 if (info && *info->image_info->magick)
5323 magick=info->image_info->magick;
5324 if (image != (Image *) NULL)
5325 magick=image->magick;
5331 mime=MagickToMime(magick);
5333 mime=(char *) RelinquishMagickMemory(mime);
5335 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5338 if (LocaleCompare(attribute,"monochrome") == 0)
5340 if (image == (Image *) NULL)
5342 j=info ? info->image_info->monochrome :
5343 IsImageMonochrome(image,exception);
5345 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5348 if (LocaleCompare(attribute,"montage") == 0)
5350 if (image && image->montage)
5351 s=newSVpv(image->montage,0);
5352 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5355 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5362 if (LocaleCompare(attribute,"orientation") == 0)
5364 j=info ? info->image_info->orientation : image ?
5365 image->orientation : UndefinedOrientation;
5367 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5370 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5373 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5380 if (LocaleCompare(attribute,"page") == 0)
5382 if (info && info->image_info->page)
5383 s=newSVpv(info->image_info->page,0);
5384 if (image != (Image *) NULL)
5387 geometry[MaxTextExtent];
5389 (void) FormatLocaleString(geometry,MaxTextExtent,
5390 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5391 (double) image->page.height,(double) image->page.x,(double)
5393 s=newSVpv(geometry,0);
5395 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5398 if (LocaleCompare(attribute,"page.x") == 0)
5400 if (image != (Image *) NULL)
5401 s=newSViv((ssize_t) image->page.x);
5402 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5405 if (LocaleCompare(attribute,"page.y") == 0)
5407 if (image != (Image *) NULL)
5408 s=newSViv((ssize_t) image->page.y);
5409 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5412 if (LocaleNCompare(attribute,"pixel",5) == 0)
5415 tuple[MaxTextExtent];
5424 register const Quantum
5427 if (image == (Image *) NULL)
5431 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5433 p=GetVirtualPixels(image,x,y,1,1,exception);
5434 if (image->colorspace != CMYKColorspace)
5435 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5436 QuantumFormat "," QuantumFormat "," QuantumFormat,
5437 GetPixelRed(image,p),GetPixelGreen(image,p),
5438 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5440 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5441 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5442 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5443 GetPixelBlue(image,p),GetPixelBlack(image,p),
5444 GetPixelAlpha(image,p));
5446 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5449 if (LocaleCompare(attribute,"pointsize") == 0)
5452 s=newSViv((ssize_t) info->image_info->pointsize);
5453 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5456 if (LocaleCompare(attribute,"preview") == 0)
5458 s=newSViv(info->image_info->preview_type);
5459 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5460 info->image_info->preview_type));
5462 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5465 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5472 if (LocaleCompare(attribute,"quality") == 0)
5475 s=newSViv((ssize_t) info->image_info->quality);
5476 if (image != (Image *) NULL)
5477 s=newSViv((ssize_t) image->quality);
5478 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5481 if (LocaleCompare(attribute,"quantum") == 0)
5484 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5485 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5488 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5495 if (LocaleCompare(attribute,"rendering-intent") == 0)
5497 s=newSViv(image->rendering_intent);
5498 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5499 image->rendering_intent));
5501 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5504 if (LocaleCompare(attribute,"red-primary") == 0)
5506 if (image == (Image *) NULL)
5508 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5509 image->chromaticity.red_primary.x,
5510 image->chromaticity.red_primary.y);
5512 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5515 if (LocaleCompare(attribute,"rows") == 0)
5517 if (image != (Image *) NULL)
5518 s=newSViv((ssize_t) image->rows);
5519 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5522 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5529 if (LocaleCompare(attribute,"sampling-factor") == 0)
5531 if (info && info->image_info->sampling_factor)
5532 s=newSVpv(info->image_info->sampling_factor,0);
5533 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5536 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5538 if (info && info->image_info->server_name)
5539 s=newSVpv(info->image_info->server_name,0);
5540 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5543 if (LocaleCompare(attribute,"size") == 0)
5545 if (info && info->image_info->size)
5546 s=newSVpv(info->image_info->size,0);
5547 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5550 if (LocaleCompare(attribute,"scene") == 0)
5552 if (image != (Image *) NULL)
5553 s=newSViv((ssize_t) image->scene);
5554 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5557 if (LocaleCompare(attribute,"scenes") == 0)
5559 if (image != (Image *) NULL)
5560 s=newSViv((ssize_t) info->image_info->number_scenes);
5561 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5564 if (LocaleCompare(attribute,"signature") == 0)
5569 if (image == (Image *) NULL)
5571 (void) SignatureImage(image,exception);
5572 value=GetImageProperty(image,"Signature",exception);
5573 if (value != (const char *) NULL)
5575 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5578 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5585 if (LocaleCompare(attribute,"taint") == 0)
5587 if (image != (Image *) NULL)
5588 s=newSViv((ssize_t) IsTaintImage(image));
5589 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5592 if (LocaleCompare(attribute,"texture") == 0)
5594 if (info && info->image_info->texture)
5595 s=newSVpv(info->image_info->texture,0);
5596 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5599 if (LocaleCompare(attribute,"total-ink-density") == 0)
5601 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5602 if (image != (Image *) NULL)
5603 s=newSVnv(GetImageTotalInkDensity(image,exception));
5604 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5607 if (LocaleCompare(attribute,"transparent-color") == 0)
5609 if (image == (Image *) NULL)
5611 (void) FormatLocaleString(color,MaxTextExtent,
5612 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5613 image->transparent_color.green,image->transparent_color.blue,
5614 image->transparent_color.alpha);
5616 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5619 if (LocaleCompare(attribute,"type") == 0)
5621 if (image == (Image *) NULL)
5623 j=(ssize_t) GetImageType(image,exception);
5625 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5627 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5630 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5637 if (LocaleCompare(attribute,"units") == 0)
5639 j=info ? info->image_info->units : image ? image->units :
5640 UndefinedResolution;
5641 if (info && (info->image_info->units == UndefinedResolution))
5644 if (j == UndefinedResolution)
5645 s=newSVpv("undefined units",0);
5647 if (j == PixelsPerInchResolution)
5648 s=newSVpv("pixels / inch",0);
5650 s=newSVpv("pixels / centimeter",0);
5651 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5654 if (LocaleCompare(attribute,"user-time") == 0)
5656 if (image != (Image *) NULL)
5657 s=newSVnv(GetUserTime(&image->timer));
5658 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5661 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5668 if (LocaleCompare(attribute,"verbose") == 0)
5671 s=newSViv((ssize_t) info->image_info->verbose);
5672 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5675 if (LocaleCompare(attribute,"version") == 0)
5677 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5678 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5681 if (LocaleCompare(attribute,"view") == 0)
5683 if (info && info->image_info->view)
5684 s=newSVpv(info->image_info->view,0);
5685 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5688 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5690 if (image == (Image *) NULL)
5692 j=(ssize_t) GetImageVirtualPixelMethod(image);
5694 (void) sv_setpv(s,CommandOptionToMnemonic(
5695 MagickVirtualPixelOptions,j));
5697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5707 if (LocaleCompare(attribute,"white-point") == 0)
5709 if (image == (Image *) NULL)
5711 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5712 image->chromaticity.white_point.x,
5713 image->chromaticity.white_point.y);
5715 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5718 if (LocaleCompare(attribute,"width") == 0)
5720 if (image != (Image *) NULL)
5721 s=newSViv((ssize_t) image->columns);
5722 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5725 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5732 if (LocaleCompare(attribute,"x-resolution") == 0)
5734 if (image != (Image *) NULL)
5735 s=newSVnv(image->resolution.x);
5736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5746 if (LocaleCompare(attribute,"y-resolution") == 0)
5748 if (image != (Image *) NULL)
5749 s=newSVnv(image->resolution.y);
5750 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5753 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5760 if (image == (Image *) NULL)
5761 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5765 value=GetImageProperty(image,attribute,exception);
5766 if (value != (const char *) NULL)
5769 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5772 if (*attribute != '%')
5773 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5780 meta=InterpretImageProperties(info ? info->image_info :
5781 (ImageInfo *) NULL,image,attribute,exception);
5783 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5784 meta=(char *) RelinquishMagickMemory(meta);
5788 exception=DestroyExceptionInfo(exception);
5789 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5793 ###############################################################################
5797 # G e t A u t h e n t i c P i x e l s #
5801 ###############################################################################
5805 GetAuthenticPixels(ref,...)
5806 Image::Magick ref = NO_INIT
5808 getauthenticpixels = 1
5838 PERL_UNUSED_VAR(ref);
5839 PERL_UNUSED_VAR(ix);
5840 exception=AcquireExceptionInfo();
5841 perl_exception=newSVpv("",0);
5842 if (sv_isobject(ST(0)) == 0)
5844 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5848 reference=SvRV(ST(0));
5850 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5851 if (image == (Image *) NULL)
5853 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5860 region.width=image->columns;
5863 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5864 for (i=2; i < items; i+=2)
5866 attribute=(char *) SvPV(ST(i-1),na);
5872 if (LocaleCompare(attribute,"geometry") == 0)
5874 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5877 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5884 if (LocaleCompare(attribute,"height") == 0)
5886 region.height=SvIV(ST(i));
5889 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5896 if (LocaleCompare(attribute,"x") == 0)
5898 region.x=SvIV(ST(i));
5901 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5908 if (LocaleCompare(attribute,"y") == 0)
5910 region.y=SvIV(ST(i));
5913 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5920 if (LocaleCompare(attribute,"width") == 0)
5922 region.width=SvIV(ST(i));
5925 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5931 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5932 region.height,exception);
5933 if (blob != (void *) NULL)
5937 InheritPerlException(exception,perl_exception);
5938 exception=DestroyExceptionInfo(exception);
5939 SvREFCNT_dec(perl_exception); /* throw away all errors */
5948 ###############################################################################
5952 # G e t V i r t u a l P i x e l s #
5956 ###############################################################################
5960 GetVirtualPixels(ref,...)
5961 Image::Magick ref = NO_INIT
5963 getvirtualpixels = 1
5964 AcquireImagePixels = 2
5965 acquireimagepixels = 3
5993 PERL_UNUSED_VAR(ref);
5994 PERL_UNUSED_VAR(ix);
5995 exception=AcquireExceptionInfo();
5996 perl_exception=newSVpv("",0);
5997 if (sv_isobject(ST(0)) == 0)
5999 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6003 reference=SvRV(ST(0));
6005 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6006 if (image == (Image *) NULL)
6008 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6015 region.width=image->columns;
6018 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6019 for (i=2; i < items; i+=2)
6021 attribute=(char *) SvPV(ST(i-1),na);
6027 if (LocaleCompare(attribute,"geometry") == 0)
6029 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6032 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6039 if (LocaleCompare(attribute,"height") == 0)
6041 region.height=SvIV(ST(i));
6044 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6051 if (LocaleCompare(attribute,"x") == 0)
6053 region.x=SvIV(ST(i));
6056 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6063 if (LocaleCompare(attribute,"y") == 0)
6065 region.y=SvIV(ST(i));
6068 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6075 if (LocaleCompare(attribute,"width") == 0)
6077 region.width=SvIV(ST(i));
6080 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6086 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6087 region.height,exception);
6088 if (blob != (void *) NULL)
6092 InheritPerlException(exception,perl_exception);
6093 exception=DestroyExceptionInfo(exception);
6094 SvREFCNT_dec(perl_exception); /* throw away all errors */
6097 RETVAL = (void *) blob;
6103 ###############################################################################
6107 # G e t A u t h e n t i c M e t a c o n t e n t #
6111 ###############################################################################
6115 GetAuthenticMetacontent(ref,...)
6116 Image::Magick ref = NO_INIT
6118 getauthenticmetacontent = 1
6139 PERL_UNUSED_VAR(ref);
6140 PERL_UNUSED_VAR(ix);
6141 exception=AcquireExceptionInfo();
6142 perl_exception=newSVpv("",0);
6143 if (sv_isobject(ST(0)) == 0)
6145 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6149 reference=SvRV(ST(0));
6151 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6152 if (image == (Image *) NULL)
6154 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6159 blob=(void *) GetAuthenticMetacontent(image);
6160 if (blob != (void *) NULL)
6164 InheritPerlException(exception,perl_exception);
6165 exception=DestroyExceptionInfo(exception);
6166 SvREFCNT_dec(perl_exception); /* throw away all errors */
6175 ###############################################################################
6179 # G e t V i r t u a l M e t a c o n t e n t #
6183 ###############################################################################
6187 GetVirtualMetacontent(ref,...)
6188 Image::Magick ref = NO_INIT
6190 getvirtualmetacontent = 1
6209 PERL_UNUSED_VAR(ref);
6210 PERL_UNUSED_VAR(ix);
6211 exception=AcquireExceptionInfo();
6212 perl_exception=newSVpv("",0);
6213 if (sv_isobject(ST(0)) == 0)
6215 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6219 reference=SvRV(ST(0));
6221 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6222 if (image == (Image *) NULL)
6224 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6229 blob=(void *) GetVirtualMetacontent(image);
6230 if (blob != (void *) NULL)
6234 InheritPerlException(exception,perl_exception);
6235 exception=DestroyExceptionInfo(exception);
6236 SvREFCNT_dec(perl_exception); /* throw away all errors */
6245 ###############################################################################
6249 # H i s t o g r a m #
6253 ###############################################################################
6258 Image::Magick ref=NO_INIT
6269 message[MaxTextExtent];
6296 PERL_UNUSED_VAR(ref);
6297 PERL_UNUSED_VAR(ix);
6298 exception=AcquireExceptionInfo();
6299 perl_exception=newSVpv("",0);
6301 if (sv_isobject(ST(0)) == 0)
6303 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6307 reference=SvRV(ST(0));
6310 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6311 if (image == (Image *) NULL)
6313 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6317 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6319 for ( ; image; image=image->next)
6321 histogram=GetImageHistogram(image,&number_colors,exception);
6322 if (histogram == (PixelInfo *) NULL)
6324 count+=(ssize_t) number_colors;
6326 for (i=0; i < (ssize_t) number_colors; i++)
6328 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6330 PUSHs(sv_2mortal(newSVpv(message,0)));
6331 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6332 histogram[i].green);
6333 PUSHs(sv_2mortal(newSVpv(message,0)));
6334 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6336 PUSHs(sv_2mortal(newSVpv(message,0)));
6337 if (image->colorspace == CMYKColorspace)
6339 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6340 histogram[i].black);
6341 PUSHs(sv_2mortal(newSVpv(message,0)));
6343 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6344 histogram[i].alpha);
6345 PUSHs(sv_2mortal(newSVpv(message,0)));
6346 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6347 histogram[i].count);
6348 PUSHs(sv_2mortal(newSVpv(message,0)));
6350 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6354 InheritPerlException(exception,perl_exception);
6355 exception=DestroyExceptionInfo(exception);
6356 SvREFCNT_dec(perl_exception);
6360 ###############################################################################
6368 ###############################################################################
6373 Image::Magick ref=NO_INIT
6397 register const Quantum
6411 *reference; /* reference is the SV* of ref=SvIV(reference) */
6413 PERL_UNUSED_VAR(ref);
6414 PERL_UNUSED_VAR(ix);
6415 exception=AcquireExceptionInfo();
6416 perl_exception=newSVpv("",0);
6417 reference=SvRV(ST(0));
6418 av=(AV *) reference;
6419 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6421 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6422 if (image == (Image *) NULL)
6424 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6428 normalize=MagickTrue;
6431 region.width=image->columns;
6434 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6435 for (i=2; i < items; i+=2)
6437 attribute=(char *) SvPV(ST(i-1),na);
6443 if (LocaleCompare(attribute,"channel") == 0)
6448 option=ParseChannelOption(SvPV(ST(i),na));
6451 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6455 SetPixelChannelMask(image,(ChannelType) option);
6458 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6465 if (LocaleCompare(attribute,"geometry") == 0)
6467 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6470 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6477 if (LocaleCompare(attribute,"normalize") == 0)
6479 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6483 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6487 normalize=option != 0 ? MagickTrue : MagickFalse;
6490 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6497 if (LocaleCompare(attribute,"x") == 0)
6499 region.x=SvIV(ST(i));
6502 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6509 if (LocaleCompare(attribute,"y") == 0)
6511 region.y=SvIV(ST(i));
6514 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6520 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6526 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6527 if (p == (const Quantum *) NULL)
6535 if (normalize != MagickFalse)
6536 scale=1.0/QuantumRange;
6537 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6538 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6539 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6540 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6541 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6542 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6543 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6544 (image->colorspace == CMYKColorspace))
6545 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6546 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6547 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6551 InheritPerlException(exception,perl_exception);
6552 exception=DestroyExceptionInfo(exception);
6553 SvREFCNT_dec(perl_exception);
6557 ###############################################################################
6561 # G e t P i x e l s #
6565 ###############################################################################
6570 Image::Magick ref=NO_INIT
6609 *reference; /* reference is the SV* of ref=SvIV(reference) */
6611 PERL_UNUSED_VAR(ref);
6612 PERL_UNUSED_VAR(ix);
6613 exception=AcquireExceptionInfo();
6614 perl_exception=newSVpv("",0);
6615 reference=SvRV(ST(0));
6616 av=(AV *) reference;
6617 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6619 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6620 if (image == (Image *) NULL)
6622 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6627 if (image->alpha_trait == BlendPixelTrait)
6629 if (image->colorspace == CMYKColorspace)
6632 if (image->alpha_trait == BlendPixelTrait)
6635 normalize=MagickFalse;
6638 region.width=image->columns;
6641 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6642 for (i=2; i < items; i+=2)
6644 attribute=(char *) SvPV(ST(i-1),na);
6650 if (LocaleCompare(attribute,"geometry") == 0)
6652 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6655 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6662 if (LocaleCompare(attribute,"height") == 0)
6664 region.height=SvIV(ST(i));
6667 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6674 if (LocaleCompare(attribute,"map") == 0)
6679 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6686 if (LocaleCompare(attribute,"normalize") == 0)
6688 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6692 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6696 normalize=option != 0 ? MagickTrue : MagickFalse;
6699 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6706 if (LocaleCompare(attribute,"width") == 0)
6708 region.width=SvIV(ST(i));
6711 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6718 if (LocaleCompare(attribute,"x") == 0)
6720 region.x=SvIV(ST(i));
6723 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6730 if (LocaleCompare(attribute,"y") == 0)
6732 region.y=SvIV(ST(i));
6735 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6741 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6747 if (normalize != MagickFalse)
6752 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6753 region.height*sizeof(*pixels));
6754 if (pixels == (float *) NULL)
6756 ThrowPerlException(exception,ResourceLimitError,
6757 "MemoryAllocationFailed",PackageName);
6760 status=ExportImagePixels(image,region.x,region.y,region.width,
6761 region.height,map,FloatPixel,pixels,exception);
6762 if (status == MagickFalse)
6766 EXTEND(sp,strlen(map)*region.width*region.height);
6767 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6768 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6770 pixels=(float *) RelinquishMagickMemory(pixels);
6777 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6778 region.height*sizeof(*pixels));
6779 if (pixels == (Quantum *) NULL)
6781 ThrowPerlException(exception,ResourceLimitError,
6782 "MemoryAllocationFailed",PackageName);
6785 status=ExportImagePixels(image,region.x,region.y,region.width,
6786 region.height,map,QuantumPixel,pixels,exception);
6787 if (status == MagickFalse)
6791 EXTEND(sp,strlen(map)*region.width*region.height);
6792 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6793 PUSHs(sv_2mortal(newSViv(pixels[i])));
6795 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6799 InheritPerlException(exception,perl_exception);
6800 exception=DestroyExceptionInfo(exception);
6801 SvREFCNT_dec(perl_exception);
6805 ###############################################################################
6809 # I m a g e T o B l o b #
6813 ###############################################################################
6817 ImageToBlob(ref,...)
6818 Image::Magick ref=NO_INIT
6827 filename[MaxTextExtent];
6856 PERL_UNUSED_VAR(ref);
6857 PERL_UNUSED_VAR(ix);
6858 exception=AcquireExceptionInfo();
6859 perl_exception=newSVpv("",0);
6860 package_info=(struct PackageInfo *) NULL;
6861 if (sv_isobject(ST(0)) == 0)
6863 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6867 reference=SvRV(ST(0));
6868 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6869 if (image == (Image *) NULL)
6871 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6875 package_info=ClonePackageInfo(info,exception);
6876 for (i=2; i < items; i+=2)
6877 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6878 (void) CopyMagickString(filename,package_info->image_info->filename,
6881 for (next=image; next; next=next->next)
6883 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6884 next->scene=scene++;
6886 SetImageInfo(package_info->image_info,(unsigned int)
6887 GetImageListLength(image),exception);
6888 EXTEND(sp,(ssize_t) GetImageListLength(image));
6889 for ( ; image; image=image->next)
6892 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6893 if (blob != (char *) NULL)
6895 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6896 blob=(unsigned char *) RelinquishMagickMemory(blob);
6898 if (package_info->image_info->adjoin)
6903 if (package_info != (struct PackageInfo *) NULL)
6904 DestroyPackageInfo(package_info);
6905 InheritPerlException(exception,perl_exception);
6906 exception=DestroyExceptionInfo(exception);
6907 SvREFCNT_dec(perl_exception); /* throw away all errors */
6911 ###############################################################################
6919 ###############################################################################
6924 Image::Magick ref=NO_INIT
6928 OptimizeImageLayers = 3
6930 optimizeimagelayers = 5
6972 PERL_UNUSED_VAR(ref);
6973 PERL_UNUSED_VAR(ix);
6974 exception=AcquireExceptionInfo();
6975 perl_exception=newSVpv("",0);
6977 if (sv_isobject(ST(0)) == 0)
6979 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6983 reference=SvRV(ST(0));
6984 hv=SvSTASH(reference);
6986 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6988 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6989 if (image == (Image *) NULL)
6991 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6995 compose=image->compose;
6996 method=OptimizeLayer;
6997 for (i=2; i < items; i+=2)
6999 attribute=(char *) SvPV(ST(i-1),na);
7005 if (LocaleCompare(attribute,"compose") == 0)
7007 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7008 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7011 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7015 compose=(CompositeOperator) sp;
7018 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7025 if (LocaleCompare(attribute,"method") == 0)
7027 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7031 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7035 method=(LayerMethod) option;
7038 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7044 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7050 layers=(Image *) NULL;
7053 case CompareAnyLayer:
7054 case CompareClearLayer:
7055 case CompareOverlayLayer:
7058 layers=CompareImagesLayers(image,method,exception);
7065 layers=MergeImageLayers(image,method,exception);
7070 layers=DisposeImages(image,exception);
7073 case OptimizeImageLayer:
7075 layers=OptimizeImageLayers(image,exception);
7078 case OptimizePlusLayer:
7080 layers=OptimizePlusImageLayers(image,exception);
7083 case OptimizeTransLayer:
7085 OptimizeImageTransparency(image,exception);
7088 case RemoveDupsLayer:
7090 RemoveDuplicateLayers(&image,exception);
7093 case RemoveZeroLayer:
7095 RemoveZeroDelayLayers(&image,exception);
7104 General Purpose, GIF Animation Optimizer.
7106 layers=CoalesceImages(image,exception);
7107 if (layers == (Image *) NULL)
7110 layers=OptimizeImageLayers(image,exception);
7111 if (layers == (Image *) NULL)
7113 image=DestroyImageList(image);
7115 layers=(Image *) NULL;
7116 OptimizeImageTransparency(image,exception);
7117 quantize_info=AcquireQuantizeInfo(info->image_info);
7118 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7119 quantize_info=DestroyQuantizeInfo(quantize_info);
7122 case CompositeLayer:
7131 Split image sequence at the first 'NULL:' image.
7134 while (source != (Image *) NULL)
7136 source=GetNextImageInList(source);
7137 if ((source != (Image *) NULL) &&
7138 (LocaleCompare(source->magick,"NULL") == 0))
7141 if (source != (Image *) NULL)
7143 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7144 (GetNextImageInList(source) == (Image *) NULL))
7145 source=(Image *) NULL;
7149 Separate the two lists, junk the null: image.
7151 source=SplitImageList(source->previous);
7152 DeleteImageFromList(&source);
7155 if (source == (Image *) NULL)
7157 (void) ThrowMagickException(exception,GetMagickModule(),
7158 OptionError,"MissingNullSeparator","layers Composite");
7162 Adjust offset with gravity and virtual canvas.
7164 SetGeometry(image,&geometry);
7165 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7166 geometry.width=source->page.width != 0 ? source->page.width :
7168 geometry.height=source->page.height != 0 ? source->page.height :
7170 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7171 image->columns,image->page.height != 0 ? image->page.height :
7172 image->rows,image->gravity,&geometry);
7173 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7174 source=DestroyImageList(source);
7178 if (layers != (Image *) NULL)
7181 image=CloneImage(image,0,0,MagickTrue,exception);
7182 if (image == (Image *) NULL)
7184 for ( ; image; image=image->next)
7186 AddImageToRegistry(sv,image);
7188 av_push(av,sv_bless(rv,hv));
7191 exception=DestroyExceptionInfo(exception);
7193 SvREFCNT_dec(perl_exception);
7197 InheritPerlException(exception,perl_exception);
7198 exception=DestroyExceptionInfo(exception);
7199 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7200 SvPOK_on(perl_exception);
7201 ST(0)=sv_2mortal(perl_exception);
7206 ###############################################################################
7210 # M a g i c k T o M i m e #
7214 ###############################################################################
7218 MagickToMime(ref,name)
7219 Image::Magick ref=NO_INIT
7228 PERL_UNUSED_VAR(ref);
7229 PERL_UNUSED_VAR(ix);
7230 mime=MagickToMime(name);
7231 RETVAL=newSVpv(mime,0);
7232 mime=(char *) RelinquishMagickMemory(mime);
7238 ###############################################################################
7246 ###############################################################################
7251 Image::Magick ref=NO_INIT
7288 MedianConvolveImage = 36
7294 ReduceNoiseImage = 42
7320 ColorFloodfillImage= 68
7326 CycleColormapImage = 74
7336 MatteFloodfillImage= 84
7344 NumberColorsImage = 92
7354 SignatureImage = 102
7364 TransparentImage = 112
7366 ThresholdImage = 114
7380 DeconstructImage = 130
7382 GaussianBlurImage = 132
7388 UnsharpMaskImage = 138
7390 MotionBlurImage = 140
7392 OrderedDitherImage = 142
7399 AffineTransform = 149
7400 AffineTransformImage = 150
7402 DifferenceImage = 152
7403 AdaptiveThreshold = 153
7404 AdaptiveThresholdImage = 154
7409 BlackThreshold = 159
7410 BlackThresholdImage= 160
7411 WhiteThreshold = 161
7412 WhiteThresholdImage= 162
7414 RadialBlurImage = 164
7416 ThumbnailImage = 166
7426 PosterizeImage = 176
7432 SepiaToneImage = 182
7433 SigmoidalContrast = 183
7434 SigmoidalContrastImage = 184
7439 ContrastStretch = 189
7440 ContrastStretchImage = 190
7445 AdaptiveSharpen = 195
7446 AdaptiveSharpenImage = 196
7448 TransposeImage = 198
7450 TransverseImage = 200
7452 AutoOrientImage = 202
7454 AdaptiveBlurImage = 204
7458 UniqueColorsImage = 208
7459 AdaptiveResize = 209
7460 AdaptiveResizeImage= 210
7464 LinearStretchImage = 214
7466 ColorMatrixImage = 216
7471 FloodfillPaint = 221
7472 FloodfillPaintImage= 222
7478 LiquidRescaleImage = 228
7488 SparseColorImage = 238
7492 SelectiveBlurImage = 242
7496 BlueShiftImage = 246
7497 ForwardFourierTransform = 247
7498 ForwardFourierTransformImage = 248
7499 InverseFourierTransform = 249
7500 InverseFourierTransformImage = 250
7501 ColorDecisionList = 251
7502 ColorDecisionListImage = 252
7504 AutoGammaImage = 254
7506 AutoLevelImage = 256
7508 LevelImageColors = 258
7511 BrightnessContrast = 261
7512 BrightnessContrastImage = 262
7514 MorphologyImage = 264
7520 StatisticImage = 270
7522 PerceptibleImage = 272
7526 GrayscaleImage = 276
7535 attribute_flag[MaxArguments],
7536 message[MaxTextExtent];
7597 argument_list[MaxArguments];
7599 PERL_UNUSED_VAR(ref);
7600 PERL_UNUSED_VAR(ix);
7601 exception=AcquireExceptionInfo();
7602 perl_exception=newSVpv("",0);
7603 reference_vector=NULL;
7607 if (sv_isobject(ST(0)) == 0)
7609 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7613 reference=SvRV(ST(0));
7614 region_info.width=0;
7615 region_info.height=0;
7618 region_image=(Image *) NULL;
7619 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7620 if (ix && (ix != 666))
7623 Called as Method(...)
7626 rp=(&Methods[ix-1]);
7632 Called as Mogrify("Method",...)
7634 attribute=(char *) SvPV(ST(1),na);
7637 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7638 attribute=(char *) SvPV(ST(2),na);
7641 for (rp=Methods; ; rp++)
7643 if (rp >= EndOf(Methods))
7645 ThrowPerlException(exception,OptionError,
7646 "UnrecognizedPerlMagickMethod",attribute);
7649 if (strEQcase(attribute,rp->name))
7655 if (image == (Image *) NULL)
7657 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7660 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7661 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7662 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7679 pp=(Arguments *) NULL;
7687 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7689 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7691 if (strEQcase(attribute,qq->method) > ssize_test)
7694 ssize_test=strEQcase(attribute,qq->method);
7697 if (pp == (Arguments *) NULL)
7699 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7701 goto continue_outer_loop;
7703 al=(&argument_list[pp-rp->arguments]);
7706 case ArrayReference:
7708 if (SvTYPE(sv) != SVt_RV)
7710 (void) FormatLocaleString(message,MaxTextExtent,
7711 "invalid %.60s value",pp->method);
7712 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7713 goto continue_outer_loop;
7715 al->array_reference=SvRV(sv);
7720 al->real_reference=SvNV(sv);
7725 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7728 case ImageReference:
7730 if (!sv_isobject(sv) ||
7731 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7732 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7734 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7740 case IntegerReference:
7742 al->integer_reference=SvIV(sv);
7745 case StringReference:
7747 al->string_reference=(char *) SvPV(sv,al->length);
7748 if (sv_isobject(sv))
7749 al->image_reference=SetupList(aTHX_ SvRV(sv),
7750 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7756 Is a string; look up name.
7758 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7760 al->string_reference=(char *) SvPV(sv,al->length);
7761 al->integer_reference=(-1);
7764 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7765 MagickFalse,SvPV(sv,na));
7766 if (pp->type == MagickChannelOptions)
7767 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7768 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7770 (void) FormatLocaleString(message,MaxTextExtent,
7771 "invalid %.60s value",pp->method);
7772 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7773 goto continue_outer_loop;
7778 attribute_flag[pp-rp->arguments]++;
7779 continue_outer_loop: ;
7781 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7782 pv=reference_vector;
7783 SetGeometryInfo(&geometry_info);
7784 channel=DefaultChannels;
7785 for (next=image; next; next=next->next)
7788 SetGeometry(image,&geometry);
7789 if ((region_info.width*region_info.height) != 0)
7792 image=CropImage(image,®ion_info,exception);
7798 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7799 ThrowPerlException(exception,OptionError,
7800 "UnrecognizedPerlMagickMethod",message);
7803 case 1: /* Comment */
7805 if (attribute_flag[0] == 0)
7806 argument_list[0].string_reference=(char *) NULL;
7807 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7808 info ? info->image_info : (ImageInfo *) NULL,image,
7809 argument_list[0].string_reference,exception),exception);
7814 if (attribute_flag[0] == 0)
7815 argument_list[0].string_reference=(char *) NULL;
7816 (void) SetImageProperty(image,"label",InterpretImageProperties(
7817 info ? info->image_info : (ImageInfo *) NULL,image,
7818 argument_list[0].string_reference,exception),exception);
7821 case 3: /* AddNoise */
7826 if (attribute_flag[0] == 0)
7827 argument_list[0].integer_reference=UniformNoise;
7829 if (attribute_flag[1] != 0)
7830 attenuate=argument_list[1].real_reference;
7831 if (attribute_flag[2] != 0)
7832 channel=(ChannelType) argument_list[2].integer_reference;
7833 channel_mask=SetImageChannelMask(image,channel);
7834 image=AddNoiseImage(image,(NoiseType)
7835 argument_list[0].integer_reference,attenuate,exception);
7836 if (image != (Image *) NULL)
7837 (void) SetImageChannelMask(image,channel_mask);
7840 case 4: /* Colorize */
7845 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7846 0,0,&target,exception);
7847 if (attribute_flag[0] != 0)
7848 (void) QueryColorCompliance(argument_list[0].string_reference,
7849 AllCompliance,&target,exception);
7850 if (attribute_flag[1] == 0)
7851 argument_list[1].string_reference="100%";
7852 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7856 case 5: /* Border */
7863 if (attribute_flag[0] != 0)
7864 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7865 &geometry,exception);
7866 if (attribute_flag[1] != 0)
7867 geometry.width=argument_list[1].integer_reference;
7868 if (attribute_flag[2] != 0)
7869 geometry.height=argument_list[2].integer_reference;
7870 if (attribute_flag[3] != 0)
7871 QueryColorCompliance(argument_list[3].string_reference,
7872 AllCompliance,&image->border_color,exception);
7873 if (attribute_flag[4] != 0)
7874 QueryColorCompliance(argument_list[4].string_reference,
7875 AllCompliance,&image->border_color,exception);
7876 if (attribute_flag[5] != 0)
7877 QueryColorCompliance(argument_list[5].string_reference,
7878 AllCompliance,&image->border_color,exception);
7879 compose=image->compose;
7880 if (attribute_flag[6] != 0)
7881 compose=(CompositeOperator) argument_list[6].integer_reference;
7882 image=BorderImage(image,&geometry,compose,exception);
7887 if (attribute_flag[0] != 0)
7889 flags=ParseGeometry(argument_list[0].string_reference,
7891 if ((flags & SigmaValue) == 0)
7892 geometry_info.sigma=1.0;
7894 if (attribute_flag[1] != 0)
7895 geometry_info.rho=argument_list[1].real_reference;
7896 if (attribute_flag[2] != 0)
7897 geometry_info.sigma=argument_list[2].real_reference;
7898 if (attribute_flag[3] != 0)
7899 channel=(ChannelType) argument_list[3].integer_reference;
7900 channel_mask=SetImageChannelMask(image,channel);
7901 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7903 if (image != (Image *) NULL)
7904 (void) SetImageChannelMask(image,channel_mask);
7909 if (attribute_flag[0] != 0)
7910 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7911 &geometry,exception);
7912 if (attribute_flag[1] != 0)
7913 geometry.width=argument_list[1].integer_reference;
7914 if (attribute_flag[2] != 0)
7915 geometry.height=argument_list[2].integer_reference;
7916 if (attribute_flag[3] != 0)
7917 geometry.x=argument_list[3].integer_reference;
7918 if (attribute_flag[4] != 0)
7919 geometry.y=argument_list[4].integer_reference;
7920 image=ChopImage(image,&geometry,exception);
7925 if (attribute_flag[6] != 0)
7926 image->gravity=(GravityType) argument_list[6].integer_reference;
7927 if (attribute_flag[0] != 0)
7928 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7929 &geometry,exception);
7930 if (attribute_flag[1] != 0)
7931 geometry.width=argument_list[1].integer_reference;
7932 if (attribute_flag[2] != 0)
7933 geometry.height=argument_list[2].integer_reference;
7934 if (attribute_flag[3] != 0)
7935 geometry.x=argument_list[3].integer_reference;
7936 if (attribute_flag[4] != 0)
7937 geometry.y=argument_list[4].integer_reference;
7938 if (attribute_flag[5] != 0)
7939 image->fuzz=StringToDoubleInterval(
7940 argument_list[5].string_reference,(double) QuantumRange+1.0);
7941 image=CropImage(image,&geometry,exception);
7944 case 9: /* Despeckle */
7946 image=DespeckleImage(image,exception);
7951 if (attribute_flag[0] != 0)
7952 geometry_info.rho=argument_list[0].real_reference;
7953 image=EdgeImage(image,geometry_info.rho,exception);
7956 case 11: /* Emboss */
7958 if (attribute_flag[0] != 0)
7960 flags=ParseGeometry(argument_list[0].string_reference,
7962 if ((flags & SigmaValue) == 0)
7963 geometry_info.sigma=1.0;
7965 if (attribute_flag[1] != 0)
7966 geometry_info.rho=argument_list[1].real_reference;
7967 if (attribute_flag[2] != 0)
7968 geometry_info.sigma=argument_list[2].real_reference;
7969 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7973 case 12: /* Enhance */
7975 image=EnhanceImage(image,exception);
7980 image=FlipImage(image,exception);
7985 image=FlopImage(image,exception);
7988 case 15: /* Frame */
7996 if (attribute_flag[0] != 0)
7998 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7999 &geometry,exception);
8000 frame_info.width=geometry.width;
8001 frame_info.height=geometry.height;
8002 frame_info.outer_bevel=geometry.x;
8003 frame_info.inner_bevel=geometry.y;
8005 if (attribute_flag[1] != 0)
8006 frame_info.width=argument_list[1].integer_reference;
8007 if (attribute_flag[2] != 0)
8008 frame_info.height=argument_list[2].integer_reference;
8009 if (attribute_flag[3] != 0)
8010 frame_info.inner_bevel=argument_list[3].integer_reference;
8011 if (attribute_flag[4] != 0)
8012 frame_info.outer_bevel=argument_list[4].integer_reference;
8013 if (attribute_flag[5] != 0)
8014 QueryColorCompliance(argument_list[5].string_reference,
8015 AllCompliance,&fill_color,exception);
8016 if (attribute_flag[6] != 0)
8017 QueryColorCompliance(argument_list[6].string_reference,
8018 AllCompliance,&fill_color,exception);
8019 frame_info.x=(ssize_t) frame_info.width;
8020 frame_info.y=(ssize_t) frame_info.height;
8021 frame_info.width=image->columns+2*frame_info.x;
8022 frame_info.height=image->rows+2*frame_info.y;
8023 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8024 image->matte_color=fill_color;
8025 compose=image->compose;
8026 if (attribute_flag[7] != 0)
8027 compose=(CompositeOperator) argument_list[7].integer_reference;
8028 image=FrameImage(image,&frame_info,compose,exception);
8031 case 16: /* Implode */
8033 PixelInterpolateMethod
8036 if (attribute_flag[0] == 0)
8037 argument_list[0].real_reference=0.5;
8038 method=UndefinedInterpolatePixel;
8039 if (attribute_flag[1] != 0)
8040 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8041 image=ImplodeImage(image,argument_list[0].real_reference,
8045 case 17: /* Magnify */
8047 image=MagnifyImage(image,exception);
8050 case 18: /* MedianFilter */
8052 if (attribute_flag[0] != 0)
8054 flags=ParseGeometry(argument_list[0].string_reference,
8056 if ((flags & SigmaValue) == 0)
8057 geometry_info.sigma=geometry_info.rho;
8059 if (attribute_flag[1] != 0)
8060 geometry_info.rho=argument_list[1].real_reference;
8061 if (attribute_flag[2] != 0)
8062 geometry_info.sigma=argument_list[2].real_reference;
8063 if (attribute_flag[3] != 0)
8064 channel=(ChannelType) argument_list[3].integer_reference;
8065 channel_mask=SetImageChannelMask(image,channel);
8066 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8067 (size_t) geometry_info.sigma,exception);
8068 if (image != (Image *) NULL)
8069 (void) SetImageChannelMask(image,channel_mask);
8072 case 19: /* Minify */
8074 image=MinifyImage(image,exception);
8077 case 20: /* OilPaint */
8079 if (attribute_flag[0] == 0)
8080 argument_list[0].real_reference=0.0;
8081 if (attribute_flag[1] == 0)
8082 argument_list[1].real_reference=1.0;
8083 image=OilPaintImage(image,argument_list[0].real_reference,
8084 argument_list[1].real_reference,exception);
8087 case 21: /* ReduceNoise */
8089 if (attribute_flag[0] != 0)
8091 flags=ParseGeometry(argument_list[0].string_reference,
8093 if ((flags & SigmaValue) == 0)
8094 geometry_info.sigma=1.0;
8096 if (attribute_flag[1] != 0)
8097 geometry_info.rho=argument_list[1].real_reference;
8098 if (attribute_flag[2] != 0)
8099 geometry_info.sigma=argument_list[2].real_reference;
8100 if (attribute_flag[3] != 0)
8101 channel=(ChannelType) argument_list[3].integer_reference;
8102 channel_mask=SetImageChannelMask(image,channel);
8103 image=StatisticImage(image,NonpeakStatistic,(size_t)
8104 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8105 if (image != (Image *) NULL)
8106 (void) SetImageChannelMask(image,channel_mask);
8111 if (attribute_flag[0] != 0)
8112 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8113 &geometry,exception);
8114 if (attribute_flag[1] != 0)
8115 geometry.x=argument_list[1].integer_reference;
8116 if (attribute_flag[2] != 0)
8117 geometry.y=argument_list[2].integer_reference;
8118 image=RollImage(image,geometry.x,geometry.y,exception);
8121 case 23: /* Rotate */
8123 if (attribute_flag[0] == 0)
8124 argument_list[0].real_reference=90.0;
8125 if (attribute_flag[1] != 0)
8127 QueryColorCompliance(argument_list[1].string_reference,
8128 AllCompliance,&image->background_color,exception);
8129 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
8130 (image->alpha_trait != BlendPixelTrait))
8131 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8133 image=RotateImage(image,argument_list[0].real_reference,exception);
8136 case 24: /* Sample */
8138 if (attribute_flag[0] != 0)
8139 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8140 &geometry,exception);
8141 if (attribute_flag[1] != 0)
8142 geometry.width=argument_list[1].integer_reference;
8143 if (attribute_flag[2] != 0)
8144 geometry.height=argument_list[2].integer_reference;
8145 image=SampleImage(image,geometry.width,geometry.height,exception);
8148 case 25: /* Scale */
8150 if (attribute_flag[0] != 0)
8151 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8152 &geometry,exception);
8153 if (attribute_flag[1] != 0)
8154 geometry.width=argument_list[1].integer_reference;
8155 if (attribute_flag[2] != 0)
8156 geometry.height=argument_list[2].integer_reference;
8157 image=ScaleImage(image,geometry.width,geometry.height,exception);
8160 case 26: /* Shade */
8162 if (attribute_flag[0] != 0)
8164 flags=ParseGeometry(argument_list[0].string_reference,
8166 if ((flags & SigmaValue) == 0)
8167 geometry_info.sigma=0.0;
8169 if (attribute_flag[1] != 0)
8170 geometry_info.rho=argument_list[1].real_reference;
8171 if (attribute_flag[2] != 0)
8172 geometry_info.sigma=argument_list[2].real_reference;
8173 image=ShadeImage(image,
8174 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8175 geometry_info.rho,geometry_info.sigma,exception);
8178 case 27: /* Sharpen */
8180 if (attribute_flag[0] != 0)
8182 flags=ParseGeometry(argument_list[0].string_reference,
8184 if ((flags & SigmaValue) == 0)
8185 geometry_info.sigma=1.0;
8187 if (attribute_flag[1] != 0)
8188 geometry_info.rho=argument_list[1].real_reference;
8189 if (attribute_flag[2] != 0)
8190 geometry_info.sigma=argument_list[2].real_reference;
8191 if (attribute_flag[3] != 0)
8192 channel=(ChannelType) argument_list[3].integer_reference;
8193 channel_mask=SetImageChannelMask(image,channel);
8194 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8196 if (image != (Image *) NULL)
8197 (void) SetImageChannelMask(image,channel_mask);
8200 case 28: /* Shear */
8202 if (attribute_flag[0] != 0)
8204 flags=ParseGeometry(argument_list[0].string_reference,
8206 if ((flags & SigmaValue) == 0)
8207 geometry_info.sigma=geometry_info.rho;
8209 if (attribute_flag[1] != 0)
8210 geometry_info.rho=argument_list[1].real_reference;
8211 if (attribute_flag[2] != 0)
8212 geometry_info.sigma=argument_list[2].real_reference;
8213 if (attribute_flag[3] != 0)
8214 QueryColorCompliance(argument_list[3].string_reference,
8215 AllCompliance,&image->background_color,exception);
8216 if (attribute_flag[4] != 0)
8217 QueryColorCompliance(argument_list[4].string_reference,
8218 AllCompliance,&image->background_color,exception);
8219 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8223 case 29: /* Spread */
8225 PixelInterpolateMethod
8228 if (attribute_flag[0] == 0)
8229 argument_list[0].real_reference=1.0;
8230 method=UndefinedInterpolatePixel;
8231 if (attribute_flag[1] != 0)
8232 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8233 image=SpreadImage(image,argument_list[0].real_reference,method,
8237 case 30: /* Swirl */
8239 PixelInterpolateMethod
8242 if (attribute_flag[0] == 0)
8243 argument_list[0].real_reference=50.0;
8244 method=UndefinedInterpolatePixel;
8245 if (attribute_flag[1] != 0)
8246 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8247 image=SwirlImage(image,argument_list[0].real_reference,
8251 case 31: /* Resize */
8254 if (attribute_flag[0] != 0)
8255 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8256 &geometry,exception);
8257 if (attribute_flag[1] != 0)
8258 geometry.width=argument_list[1].integer_reference;
8259 if (attribute_flag[2] != 0)
8260 geometry.height=argument_list[2].integer_reference;
8261 if (attribute_flag[3] == 0)
8262 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8263 if (attribute_flag[4] != 0)
8264 SetImageArtifact(image,"filter:support",
8265 argument_list[4].string_reference);
8266 image=ResizeImage(image,geometry.width,geometry.height,
8267 (FilterTypes) argument_list[3].integer_reference,
8271 case 33: /* Annotate */
8276 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8278 if (attribute_flag[0] != 0)
8283 text=InterpretImageProperties(info ? info->image_info :
8284 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8286 (void) CloneString(&draw_info->text,text);
8287 text=DestroyString(text);
8289 if (attribute_flag[1] != 0)
8290 (void) CloneString(&draw_info->font,
8291 argument_list[1].string_reference);
8292 if (attribute_flag[2] != 0)
8293 draw_info->pointsize=argument_list[2].real_reference;
8294 if (attribute_flag[3] != 0)
8295 (void) CloneString(&draw_info->density,
8296 argument_list[3].string_reference);
8297 if (attribute_flag[4] != 0)
8298 (void) QueryColorCompliance(argument_list[4].string_reference,
8299 AllCompliance,&draw_info->undercolor,exception);
8300 if (attribute_flag[5] != 0)
8302 (void) QueryColorCompliance(argument_list[5].string_reference,
8303 AllCompliance,&draw_info->stroke,exception);
8304 if (argument_list[5].image_reference != (Image *) NULL)
8305 draw_info->stroke_pattern=CloneImage(
8306 argument_list[5].image_reference,0,0,MagickTrue,exception);
8308 if (attribute_flag[6] != 0)
8310 (void) QueryColorCompliance(argument_list[6].string_reference,
8311 AllCompliance,&draw_info->fill,exception);
8312 if (argument_list[6].image_reference != (Image *) NULL)
8313 draw_info->fill_pattern=CloneImage(
8314 argument_list[6].image_reference,0,0,MagickTrue,exception);
8316 if (attribute_flag[7] != 0)
8318 (void) CloneString(&draw_info->geometry,
8319 argument_list[7].string_reference);
8320 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8321 &geometry,exception);
8322 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8323 geometry_info.sigma=geometry_info.xi;
8325 if (attribute_flag[8] != 0)
8326 (void) QueryColorCompliance(argument_list[8].string_reference,
8327 AllCompliance,&draw_info->fill,exception);
8328 if (attribute_flag[11] != 0)
8329 draw_info->gravity=(GravityType)
8330 argument_list[11].integer_reference;
8331 if (attribute_flag[25] != 0)
8336 av=(AV *) argument_list[25].array_reference;
8337 if ((av_len(av) != 3) && (av_len(av) != 5))
8339 ThrowPerlException(exception,OptionError,
8340 "affine matrix must have 4 or 6 elements",PackageName);
8343 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8344 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8345 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8346 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8347 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8348 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8350 ThrowPerlException(exception,OptionError,
8351 "affine matrix is singular",PackageName);
8354 if (av_len(av) == 5)
8356 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8357 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8360 for (j=12; j < 17; j++)
8362 if (attribute_flag[j] == 0)
8364 value=argument_list[j].string_reference;
8365 angle=argument_list[j].real_reference;
8366 current=draw_info->affine;
8367 GetAffineMatrix(&affine);
8375 flags=ParseGeometry(value,&geometry_info);
8376 affine.tx=geometry_info.xi;
8377 affine.ty=geometry_info.psi;
8378 if ((flags & PsiValue) == 0)
8379 affine.ty=affine.tx;
8387 flags=ParseGeometry(value,&geometry_info);
8388 affine.sx=geometry_info.rho;
8389 affine.sy=geometry_info.sigma;
8390 if ((flags & SigmaValue) == 0)
8391 affine.sy=affine.sx;
8401 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8402 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8403 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8404 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8412 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8420 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8424 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8425 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8426 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8427 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8428 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8430 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8433 if (attribute_flag[9] == 0)
8434 argument_list[9].real_reference=0.0;
8435 if (attribute_flag[10] == 0)
8436 argument_list[10].real_reference=0.0;
8437 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8440 geometry[MaxTextExtent];
8442 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8443 (double) argument_list[9].real_reference+draw_info->affine.tx,
8444 (double) argument_list[10].real_reference+draw_info->affine.ty);
8445 (void) CloneString(&draw_info->geometry,geometry);
8447 if (attribute_flag[17] != 0)
8448 draw_info->stroke_width=argument_list[17].real_reference;
8449 if (attribute_flag[18] != 0)
8451 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8452 MagickTrue : MagickFalse;
8453 draw_info->stroke_antialias=draw_info->text_antialias;
8455 if (attribute_flag[19] != 0)
8456 (void) CloneString(&draw_info->family,
8457 argument_list[19].string_reference);
8458 if (attribute_flag[20] != 0)
8459 draw_info->style=(StyleType) argument_list[20].integer_reference;
8460 if (attribute_flag[21] != 0)
8461 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8462 if (attribute_flag[22] != 0)
8463 draw_info->weight=argument_list[22].integer_reference;
8464 if (attribute_flag[23] != 0)
8465 draw_info->align=(AlignType) argument_list[23].integer_reference;
8466 if (attribute_flag[24] != 0)
8467 (void) CloneString(&draw_info->encoding,
8468 argument_list[24].string_reference);
8469 if (attribute_flag[25] != 0)
8470 draw_info->fill_pattern=CloneImage(
8471 argument_list[25].image_reference,0,0,MagickTrue,exception);
8472 if (attribute_flag[26] != 0)
8473 draw_info->fill_pattern=CloneImage(
8474 argument_list[26].image_reference,0,0,MagickTrue,exception);
8475 if (attribute_flag[27] != 0)
8476 draw_info->stroke_pattern=CloneImage(
8477 argument_list[27].image_reference,0,0,MagickTrue,exception);
8478 if (attribute_flag[29] != 0)
8479 draw_info->kerning=argument_list[29].real_reference;
8480 if (attribute_flag[30] != 0)
8481 draw_info->interline_spacing=argument_list[30].real_reference;
8482 if (attribute_flag[31] != 0)
8483 draw_info->interword_spacing=argument_list[31].real_reference;
8484 if (attribute_flag[32] != 0)
8485 draw_info->direction=(DirectionType)
8486 argument_list[32].integer_reference;
8487 (void) AnnotateImage(image,draw_info,exception);
8488 draw_info=DestroyDrawInfo(draw_info);
8491 case 34: /* ColorFloodfill */
8502 draw_info=CloneDrawInfo(info ? info->image_info :
8503 (ImageInfo *) NULL,(DrawInfo *) NULL);
8504 if (attribute_flag[0] != 0)
8505 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8506 &geometry,exception);
8507 if (attribute_flag[1] != 0)
8508 geometry.x=argument_list[1].integer_reference;
8509 if (attribute_flag[2] != 0)
8510 geometry.y=argument_list[2].integer_reference;
8511 if (attribute_flag[3] != 0)
8512 (void) QueryColorCompliance(argument_list[3].string_reference,
8513 AllCompliance,&draw_info->fill,exception);
8514 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8515 geometry.x,geometry.y,&target,exception);
8517 if (attribute_flag[4] != 0)
8519 QueryColorCompliance(argument_list[4].string_reference,
8520 AllCompliance,&target,exception);
8523 if (attribute_flag[5] != 0)
8524 image->fuzz=StringToDoubleInterval(
8525 argument_list[5].string_reference,(double) QuantumRange+1.0);
8526 if (attribute_flag[6] != 0)
8527 invert=(MagickBooleanType) argument_list[6].integer_reference;
8528 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8529 geometry.y,invert,exception);
8530 draw_info=DestroyDrawInfo(draw_info);
8533 case 35: /* Composite */
8536 composite_geometry[MaxTextExtent];
8545 compose=OverCompositeOp;
8546 if (attribute_flag[0] != 0)
8547 composite_image=argument_list[0].image_reference;
8550 ThrowPerlException(exception,OptionError,
8551 "CompositeImageRequired",PackageName);
8555 Parameter Handling used for BOTH normal and tiled composition.
8557 if (attribute_flag[1] != 0) /* compose */
8558 compose=(CompositeOperator) argument_list[1].integer_reference;
8559 if (attribute_flag[6] != 0) /* opacity */
8561 if (compose != DissolveCompositeOp)
8562 (void) SetImageAlpha(composite_image,(Quantum)
8563 StringToDoubleInterval(argument_list[6].string_reference,
8564 (double) QuantumRange+1.0),exception);
8586 Handle dissolve composite operator (patch by
8589 (void) CloneString(&image->geometry,
8590 argument_list[6].string_reference);
8591 opacity=(Quantum) StringToDoubleInterval(
8592 argument_list[6].string_reference,(double) QuantumRange+
8594 if (composite_image->alpha_trait == BlendPixelTrait)
8595 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8596 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8597 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8599 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8600 composite_image->columns,1,exception);
8601 for (x=0; x < (ssize_t) composite_image->columns; x++)
8603 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8604 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8606 q+=GetPixelChannels(composite_image);
8608 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8609 if (sync == MagickFalse)
8612 composite_view=DestroyCacheView(composite_view);
8615 if (attribute_flag[9] != 0) /* "color=>" */
8616 QueryColorCompliance(argument_list[9].string_reference,
8617 AllCompliance,&composite_image->background_color,exception);
8618 if (attribute_flag[12] != 0) /* "interpolate=>" */
8619 image->interpolate=(PixelInterpolateMethod)
8620 argument_list[12].integer_reference;
8621 if (attribute_flag[13] != 0) /* "args=>" */
8622 (void) SetImageArtifact(composite_image,"compose:args",
8623 argument_list[13].string_reference);
8624 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8625 (void) SetImageArtifact(composite_image,"compose:args",
8626 argument_list[14].string_reference);
8627 clip_to_self=MagickTrue;
8628 if (attribute_flag[15] != 0)
8629 clip_to_self=(MagickBooleanType)
8630 argument_list[15].integer_reference;
8632 Tiling Composition (with orthogonal rotate).
8634 rotate_image=(Image *) NULL;
8635 if (attribute_flag[8] != 0) /* "rotate=>" */
8640 rotate_image=RotateImage(composite_image,
8641 argument_list[8].real_reference,exception);
8642 if (rotate_image == (Image *) NULL)
8645 if ((attribute_flag[7] != 0) &&
8646 (argument_list[7].integer_reference != 0)) /* tile */
8653 Tile the composite image.
8655 if (attribute_flag[8] != 0) /* "tile=>" */
8656 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8659 (void) SetImageArtifact(composite_image,
8660 "compose:outside-overlay","false");
8661 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8662 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8664 if (attribute_flag[8] != 0) /* rotate */
8665 (void) CompositeImage(image,rotate_image,compose,
8666 MagickTrue,x,y,exception);
8668 (void) CompositeImage(image,composite_image,compose,
8669 MagickTrue,x,y,exception);
8671 if (attribute_flag[8] != 0) /* rotate */
8672 rotate_image=DestroyImage(rotate_image);
8676 Parameter Handling used used ONLY for normal composition.
8678 if (attribute_flag[5] != 0) /* gravity */
8679 image->gravity=(GravityType) argument_list[5].integer_reference;
8680 if (attribute_flag[2] != 0) /* geometry offset */
8682 SetGeometry(image,&geometry);
8683 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8685 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8688 if (attribute_flag[3] != 0) /* x offset */
8689 geometry.x=argument_list[3].integer_reference;
8690 if (attribute_flag[4] != 0) /* y offset */
8691 geometry.y=argument_list[4].integer_reference;
8692 if (attribute_flag[10] != 0) /* mask */
8694 if ((image->compose == DisplaceCompositeOp) ||
8695 (image->compose == DistortCompositeOp))
8698 Merge Y displacement into X displacement image.
8700 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8702 (void) CompositeImage(composite_image,
8703 argument_list[10].image_reference,CopyGreenCompositeOp,
8704 MagickTrue,0,0,exception);
8712 Set a blending mask for the composition.
8714 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8715 MagickTrue,exception);
8716 (void) SetImageMask(composite_image,mask_image,exception);
8717 mask_image=DestroyImage(mask_image);
8720 if (attribute_flag[11] != 0) /* channel */
8721 channel=(ChannelType) argument_list[11].integer_reference;
8723 Composite two images (normal composition).
8725 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8726 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8727 (double) composite_image->rows,(double) geometry.x,(double)
8729 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8731 channel_mask=SetImageChannelMask(image,channel);
8732 if (attribute_flag[8] == 0) /* no rotate */
8733 CompositeImage(image,composite_image,compose,clip_to_self,
8734 geometry.x,geometry.y,exception);
8738 Position adjust rotated image then composite.
8740 geometry.x-=(ssize_t) (rotate_image->columns-
8741 composite_image->columns)/2;
8742 geometry.y-=(ssize_t) (rotate_image->rows-
8743 composite_image->rows)/2;
8744 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8745 geometry.y,exception);
8746 rotate_image=DestroyImage(rotate_image);
8748 if (attribute_flag[10] != 0) /* mask */
8750 if ((image->compose == DisplaceCompositeOp) ||
8751 (image->compose == DistortCompositeOp))
8752 composite_image=DestroyImage(composite_image);
8754 (void) SetImageMask(image,(Image *) NULL,exception);
8756 (void) SetImageChannelMask(image,channel_mask);
8759 case 36: /* Contrast */
8761 if (attribute_flag[0] == 0)
8762 argument_list[0].integer_reference=0;
8763 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8764 MagickTrue : MagickFalse,exception);
8767 case 37: /* CycleColormap */
8769 if (attribute_flag[0] == 0)
8770 argument_list[0].integer_reference=6;
8771 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8780 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8782 (void) CloneString(&draw_info->primitive,"point");
8783 if (attribute_flag[0] != 0)
8785 if (argument_list[0].integer_reference < 0)
8786 (void) CloneString(&draw_info->primitive,
8787 argument_list[0].string_reference);
8789 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8790 MagickPrimitiveOptions,argument_list[0].integer_reference));
8792 if (attribute_flag[1] != 0)
8794 if (LocaleCompare(draw_info->primitive,"path") == 0)
8796 (void) ConcatenateString(&draw_info->primitive," '");
8797 ConcatenateString(&draw_info->primitive,
8798 argument_list[1].string_reference);
8799 (void) ConcatenateString(&draw_info->primitive,"'");
8803 (void) ConcatenateString(&draw_info->primitive," ");
8804 ConcatenateString(&draw_info->primitive,
8805 argument_list[1].string_reference);
8808 if (attribute_flag[2] != 0)
8810 (void) ConcatenateString(&draw_info->primitive," ");
8811 (void) ConcatenateString(&draw_info->primitive,
8812 CommandOptionToMnemonic(MagickMethodOptions,
8813 argument_list[2].integer_reference));
8815 if (attribute_flag[3] != 0)
8817 (void) QueryColorCompliance(argument_list[3].string_reference,
8818 AllCompliance,&draw_info->stroke,exception);
8819 if (argument_list[3].image_reference != (Image *) NULL)
8820 draw_info->stroke_pattern=CloneImage(
8821 argument_list[3].image_reference,0,0,MagickTrue,exception);
8823 if (attribute_flag[4] != 0)
8825 (void) QueryColorCompliance(argument_list[4].string_reference,
8826 AllCompliance,&draw_info->fill,exception);
8827 if (argument_list[4].image_reference != (Image *) NULL)
8828 draw_info->fill_pattern=CloneImage(
8829 argument_list[4].image_reference,0,0,MagickTrue,exception);
8831 if (attribute_flag[5] != 0)
8832 draw_info->stroke_width=argument_list[5].real_reference;
8833 if (attribute_flag[6] != 0)
8834 (void) CloneString(&draw_info->font,
8835 argument_list[6].string_reference);
8836 if (attribute_flag[7] != 0)
8837 (void) QueryColorCompliance(argument_list[7].string_reference,
8838 AllCompliance,&draw_info->border_color,exception);
8839 if (attribute_flag[8] != 0)
8840 draw_info->affine.tx=argument_list[8].real_reference;
8841 if (attribute_flag[9] != 0)
8842 draw_info->affine.ty=argument_list[9].real_reference;
8843 if (attribute_flag[20] != 0)
8848 av=(AV *) argument_list[20].array_reference;
8849 if ((av_len(av) != 3) && (av_len(av) != 5))
8851 ThrowPerlException(exception,OptionError,
8852 "affine matrix must have 4 or 6 elements",PackageName);
8855 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8856 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8857 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8858 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8859 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8860 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8862 ThrowPerlException(exception,OptionError,
8863 "affine matrix is singular",PackageName);
8866 if (av_len(av) == 5)
8868 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8869 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8872 for (j=10; j < 15; j++)
8874 if (attribute_flag[j] == 0)
8876 value=argument_list[j].string_reference;
8877 angle=argument_list[j].real_reference;
8878 current=draw_info->affine;
8879 GetAffineMatrix(&affine);
8887 flags=ParseGeometry(value,&geometry_info);
8888 affine.tx=geometry_info.xi;
8889 affine.ty=geometry_info.psi;
8890 if ((flags & PsiValue) == 0)
8891 affine.ty=affine.tx;
8899 flags=ParseGeometry(value,&geometry_info);
8900 affine.sx=geometry_info.rho;
8901 affine.sy=geometry_info.sigma;
8902 if ((flags & SigmaValue) == 0)
8903 affine.sy=affine.sx;
8913 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8914 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8915 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8916 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8924 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8932 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8936 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8937 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8938 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8939 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8940 draw_info->affine.tx=
8941 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8942 draw_info->affine.ty=
8943 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8945 if (attribute_flag[15] != 0)
8946 draw_info->fill_pattern=CloneImage(
8947 argument_list[15].image_reference,0,0,MagickTrue,exception);
8948 if (attribute_flag[16] != 0)
8949 draw_info->pointsize=argument_list[16].real_reference;
8950 if (attribute_flag[17] != 0)
8952 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8953 ? MagickTrue : MagickFalse;
8954 draw_info->text_antialias=draw_info->stroke_antialias;
8956 if (attribute_flag[18] != 0)
8957 (void) CloneString(&draw_info->density,
8958 argument_list[18].string_reference);
8959 if (attribute_flag[19] != 0)
8960 draw_info->stroke_width=argument_list[19].real_reference;
8961 if (attribute_flag[21] != 0)
8962 draw_info->dash_offset=argument_list[21].real_reference;
8963 if (attribute_flag[22] != 0)
8968 av=(AV *) argument_list[22].array_reference;
8969 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8970 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8971 if (draw_info->dash_pattern != (double *) NULL)
8973 for (i=0; i <= av_len(av); i++)
8974 draw_info->dash_pattern[i]=(double)
8975 SvNV(*(av_fetch(av,i,0)));
8976 draw_info->dash_pattern[i]=0.0;
8979 if (attribute_flag[23] != 0)
8980 image->interpolate=(PixelInterpolateMethod)
8981 argument_list[23].integer_reference;
8982 if ((attribute_flag[24] != 0) &&
8983 (draw_info->fill_pattern != (Image *) NULL))
8984 flags=ParsePageGeometry(draw_info->fill_pattern,
8985 argument_list[24].string_reference,
8986 &draw_info->fill_pattern->tile_offset,exception);
8987 if (attribute_flag[25] != 0)
8989 (void) ConcatenateString(&draw_info->primitive," '");
8990 (void) ConcatenateString(&draw_info->primitive,
8991 argument_list[25].string_reference);
8992 (void) ConcatenateString(&draw_info->primitive,"'");
8994 if (attribute_flag[26] != 0)
8995 draw_info->fill_pattern=CloneImage(
8996 argument_list[26].image_reference,0,0,MagickTrue,exception);
8997 if (attribute_flag[27] != 0)
8998 draw_info->stroke_pattern=CloneImage(
8999 argument_list[27].image_reference,0,0,MagickTrue,exception);
9000 if (attribute_flag[28] != 0)
9001 (void) CloneString(&draw_info->primitive,
9002 argument_list[28].string_reference);
9003 if (attribute_flag[29] != 0)
9004 draw_info->kerning=argument_list[29].real_reference;
9005 if (attribute_flag[30] != 0)
9006 draw_info->interline_spacing=argument_list[30].real_reference;
9007 if (attribute_flag[31] != 0)
9008 draw_info->interword_spacing=argument_list[31].real_reference;
9009 if (attribute_flag[32] != 0)
9010 draw_info->direction=(DirectionType)
9011 argument_list[32].integer_reference;
9012 DrawImage(image,draw_info,exception);
9013 draw_info=DestroyDrawInfo(draw_info);
9016 case 39: /* Equalize */
9018 if (attribute_flag[0] != 0)
9019 channel=(ChannelType) argument_list[0].integer_reference;
9020 channel_mask=SetImageChannelMask(image,channel);
9021 EqualizeImage(image,exception);
9022 (void) SetImageChannelMask(image,channel_mask);
9025 case 40: /* Gamma */
9027 if (attribute_flag[1] != 0)
9028 channel=(ChannelType) argument_list[1].integer_reference;
9029 if (attribute_flag[2] == 0)
9030 argument_list[2].real_reference=1.0;
9031 if (attribute_flag[3] == 0)
9032 argument_list[3].real_reference=1.0;
9033 if (attribute_flag[4] == 0)
9034 argument_list[4].real_reference=1.0;
9035 if (attribute_flag[0] == 0)
9037 (void) FormatLocaleString(message,MaxTextExtent,
9038 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9039 (double) argument_list[3].real_reference,
9040 (double) argument_list[4].real_reference);
9041 argument_list[0].string_reference=message;
9043 (void) GammaImage(image,StringToDouble(
9044 argument_list[0].string_reference,(char **) NULL),exception);
9052 if (attribute_flag[0] == 0)
9054 ThrowPerlException(exception,OptionError,"MapImageRequired",
9058 quantize_info=AcquireQuantizeInfo(info->image_info);
9059 if (attribute_flag[1] != 0)
9060 quantize_info->dither_method=(DitherMethod)
9061 argument_list[1].integer_reference;
9062 (void) RemapImages(quantize_info,image,
9063 argument_list[0].image_reference,exception);
9064 quantize_info=DestroyQuantizeInfo(quantize_info);
9067 case 42: /* MatteFloodfill */
9078 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9080 if (attribute_flag[0] != 0)
9081 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9082 &geometry,exception);
9083 if (attribute_flag[1] != 0)
9084 geometry.x=argument_list[1].integer_reference;
9085 if (attribute_flag[2] != 0)
9086 geometry.y=argument_list[2].integer_reference;
9087 if (image->alpha_trait != BlendPixelTrait)
9088 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9089 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9090 geometry.x,geometry.y,&target,exception);
9091 if (attribute_flag[4] != 0)
9092 QueryColorCompliance(argument_list[4].string_reference,
9093 AllCompliance,&target,exception);
9094 if (attribute_flag[3] != 0)
9095 target.alpha=StringToDoubleInterval(
9096 argument_list[3].string_reference,(double) (double) QuantumRange+
9098 if (attribute_flag[5] != 0)
9099 image->fuzz=StringToDoubleInterval(
9100 argument_list[5].string_reference,(double) QuantumRange+1.0);
9102 if (attribute_flag[6] != 0)
9103 invert=(MagickBooleanType) argument_list[6].integer_reference;
9104 channel_mask=SetImageChannelMask(image,AlphaChannel);
9105 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9106 geometry.y,invert,exception);
9107 (void) SetImageChannelMask(image,channel_mask);
9108 draw_info=DestroyDrawInfo(draw_info);
9111 case 43: /* Modulate */
9114 modulate[MaxTextExtent];
9116 geometry_info.rho=100.0;
9117 geometry_info.sigma=100.0;
9118 geometry_info.xi=100.0;
9119 if (attribute_flag[0] != 0)
9120 (void)ParseGeometry(argument_list[0].string_reference,
9122 if (attribute_flag[1] != 0)
9123 geometry_info.xi=argument_list[1].real_reference;
9124 if (attribute_flag[2] != 0)
9125 geometry_info.sigma=argument_list[2].real_reference;
9126 if (attribute_flag[3] != 0)
9128 geometry_info.sigma=argument_list[3].real_reference;
9129 SetImageArtifact(image,"modulate:colorspace","HWB");
9131 if (attribute_flag[4] != 0)
9133 geometry_info.rho=argument_list[4].real_reference;
9134 SetImageArtifact(image,"modulate:colorspace","HSB");
9136 if (attribute_flag[5] != 0)
9138 geometry_info.sigma=argument_list[5].real_reference;
9139 SetImageArtifact(image,"modulate:colorspace","HSL");
9141 if (attribute_flag[6] != 0)
9143 geometry_info.rho=argument_list[6].real_reference;
9144 SetImageArtifact(image,"modulate:colorspace","HWB");
9146 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
9147 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9148 (void) ModulateImage(image,modulate,exception);
9151 case 44: /* Negate */
9153 if (attribute_flag[0] == 0)
9154 argument_list[0].integer_reference=0;
9155 if (attribute_flag[1] != 0)
9156 channel=(ChannelType) argument_list[1].integer_reference;
9157 channel_mask=SetImageChannelMask(image,channel);
9158 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9159 MagickTrue : MagickFalse,exception);
9160 (void) SetImageChannelMask(image,channel_mask);
9163 case 45: /* Normalize */
9165 if (attribute_flag[0] != 0)
9166 channel=(ChannelType) argument_list[0].integer_reference;
9167 channel_mask=SetImageChannelMask(image,channel);
9168 NormalizeImage(image,exception);
9169 (void) SetImageChannelMask(image,channel_mask);
9172 case 46: /* NumberColors */
9174 case 47: /* Opaque */
9183 (void) QueryColorCompliance("none",AllCompliance,&target,
9185 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9187 if (attribute_flag[0] != 0)
9188 (void) QueryColorCompliance(argument_list[0].string_reference,
9189 AllCompliance,&target,exception);
9190 if (attribute_flag[1] != 0)
9191 (void) QueryColorCompliance(argument_list[1].string_reference,
9192 AllCompliance,&fill_color,exception);
9193 if (attribute_flag[2] != 0)
9194 image->fuzz=StringToDoubleInterval(
9195 argument_list[2].string_reference,(double) QuantumRange+1.0);
9196 if (attribute_flag[3] != 0)
9197 channel=(ChannelType) argument_list[3].integer_reference;
9199 if (attribute_flag[4] != 0)
9200 invert=(MagickBooleanType) argument_list[4].integer_reference;
9201 channel_mask=SetImageChannelMask(image,channel);
9202 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9203 (void) SetImageChannelMask(image,channel_mask);
9206 case 48: /* Quantize */
9211 quantize_info=AcquireQuantizeInfo(info->image_info);
9212 if (attribute_flag[0] != 0)
9213 quantize_info->number_colors=(size_t)
9214 argument_list[0].integer_reference;
9215 if (attribute_flag[1] != 0)
9216 quantize_info->tree_depth=(size_t)
9217 argument_list[1].integer_reference;
9218 if (attribute_flag[2] != 0)
9219 quantize_info->colorspace=(ColorspaceType)
9220 argument_list[2].integer_reference;
9221 if (attribute_flag[3] != 0)
9222 quantize_info->dither_method=(DitherMethod)
9223 argument_list[3].integer_reference;
9224 if (attribute_flag[4] != 0)
9225 quantize_info->measure_error=argument_list[4].integer_reference !=
9226 0 ? MagickTrue : MagickFalse;
9227 if (attribute_flag[5] != 0)
9228 (void) QueryColorCompliance(argument_list[5].string_reference,
9229 AllCompliance,&image->transparent_color,exception);
9230 if (attribute_flag[5] && argument_list[5].integer_reference)
9232 (void) QuantizeImages(quantize_info,image,exception);
9235 if (attribute_flag[6] != 0)
9236 quantize_info->dither_method=(DitherMethod)
9237 argument_list[6].integer_reference;
9238 if ((image->storage_class == DirectClass) ||
9239 (image->colors > quantize_info->number_colors) ||
9240 (quantize_info->colorspace == GRAYColorspace))
9241 (void) QuantizeImage(quantize_info,image,exception);
9243 CompressImageColormap(image,exception);
9244 quantize_info=DestroyQuantizeInfo(quantize_info);
9247 case 49: /* Raise */
9249 if (attribute_flag[0] != 0)
9250 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9251 &geometry,exception);
9252 if (attribute_flag[1] != 0)
9253 geometry.width=argument_list[1].integer_reference;
9254 if (attribute_flag[2] != 0)
9255 geometry.height=argument_list[2].integer_reference;
9256 if (attribute_flag[3] == 0)
9257 argument_list[3].integer_reference=1;
9258 (void) RaiseImage(image,&geometry,
9259 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9263 case 50: /* Segment */
9270 smoothing_threshold;
9275 cluster_threshold=1.0;
9276 smoothing_threshold=1.5;
9277 colorspace=sRGBColorspace;
9278 verbose=MagickFalse;
9279 if (attribute_flag[0] != 0)
9281 flags=ParseGeometry(argument_list[0].string_reference,
9283 cluster_threshold=geometry_info.rho;
9284 if (flags & SigmaValue)
9285 smoothing_threshold=geometry_info.sigma;
9287 if (attribute_flag[1] != 0)
9288 cluster_threshold=argument_list[1].real_reference;
9289 if (attribute_flag[2] != 0)
9290 smoothing_threshold=argument_list[2].real_reference;
9291 if (attribute_flag[3] != 0)
9292 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9293 if (attribute_flag[4] != 0)
9294 verbose=argument_list[4].integer_reference != 0 ?
9295 MagickTrue : MagickFalse;
9296 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9297 smoothing_threshold,exception);
9300 case 51: /* Signature */
9302 (void) SignatureImage(image,exception);
9305 case 52: /* Solarize */
9307 geometry_info.rho=QuantumRange/2.0;
9308 if (attribute_flag[0] != 0)
9309 flags=ParseGeometry(argument_list[0].string_reference,
9311 if (attribute_flag[1] != 0)
9312 geometry_info.rho=StringToDoubleInterval(
9313 argument_list[1].string_reference,(double) QuantumRange+1.0);
9314 (void) SolarizeImage(image,geometry_info.rho,exception);
9319 (void) SyncImage(image,exception);
9322 case 54: /* Texture */
9324 if (attribute_flag[0] == 0)
9326 TextureImage(image,argument_list[0].image_reference,exception);
9329 case 55: /* Evalute */
9331 MagickEvaluateOperator
9334 op=SetEvaluateOperator;
9335 if (attribute_flag[0] == MagickFalse)
9336 argument_list[0].real_reference=0.0;
9337 if (attribute_flag[1] != MagickFalse)
9338 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9339 if (attribute_flag[2] != MagickFalse)
9340 channel=(ChannelType) argument_list[2].integer_reference;
9341 channel_mask=SetImageChannelMask(image,channel);
9342 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9344 (void) SetImageChannelMask(image,channel_mask);
9347 case 56: /* Transparent */
9358 (void) QueryColorCompliance("none",AllCompliance,&target,
9360 if (attribute_flag[0] != 0)
9361 (void) QueryColorCompliance(argument_list[0].string_reference,
9362 AllCompliance,&target,exception);
9363 opacity=TransparentAlpha;
9364 if (attribute_flag[1] != 0)
9365 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9366 (double) QuantumRange+1.0);
9367 if (attribute_flag[2] != 0)
9368 image->fuzz=StringToDoubleInterval(
9369 argument_list[2].string_reference,(double) QuantumRange+1.0);
9370 if (attribute_flag[3] == 0)
9371 argument_list[3].integer_reference=0;
9373 if (attribute_flag[3] != 0)
9374 invert=(MagickBooleanType) argument_list[3].integer_reference;
9375 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9379 case 57: /* Threshold */
9384 if (attribute_flag[0] == 0)
9385 argument_list[0].string_reference="50%";
9386 if (attribute_flag[1] != 0)
9387 channel=(ChannelType) argument_list[1].integer_reference;
9388 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9389 (double) QuantumRange+1.0);
9390 channel_mask=SetImageChannelMask(image,channel);
9391 (void) BilevelImage(image,threshold,exception);
9392 (void) SetImageChannelMask(image,channel_mask);
9395 case 58: /* Charcoal */
9397 if (attribute_flag[0] != 0)
9399 flags=ParseGeometry(argument_list[0].string_reference,
9401 if ((flags & SigmaValue) == 0)
9402 geometry_info.sigma=1.0;
9404 if (attribute_flag[1] != 0)
9405 geometry_info.rho=argument_list[1].real_reference;
9406 if (attribute_flag[2] != 0)
9407 geometry_info.sigma=argument_list[2].real_reference;
9408 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9414 if (attribute_flag[0] != 0)
9415 image->fuzz=StringToDoubleInterval(
9416 argument_list[0].string_reference,(double) QuantumRange+1.0);
9417 image=TrimImage(image,exception);
9422 PixelInterpolateMethod
9425 if (attribute_flag[0] != 0)
9427 flags=ParseGeometry(argument_list[0].string_reference,
9429 if ((flags & SigmaValue) == 0)
9430 geometry_info.sigma=1.0;
9432 if (attribute_flag[1] != 0)
9433 geometry_info.rho=argument_list[1].real_reference;
9434 if (attribute_flag[2] != 0)
9435 geometry_info.sigma=argument_list[2].real_reference;
9436 method=UndefinedInterpolatePixel;
9437 if (attribute_flag[3] != 0)
9438 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9439 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9443 case 61: /* Separate */
9445 if (attribute_flag[0] != 0)
9446 channel=(ChannelType) argument_list[0].integer_reference;
9447 image=SeparateImage(image,channel,exception);
9450 case 63: /* Stereo */
9452 if (attribute_flag[0] == 0)
9454 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9458 if (attribute_flag[1] != 0)
9459 geometry.x=argument_list[1].integer_reference;
9460 if (attribute_flag[2] != 0)
9461 geometry.y=argument_list[2].integer_reference;
9462 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9463 geometry.x,geometry.y,exception);
9466 case 64: /* Stegano */
9468 if (attribute_flag[0] == 0)
9470 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9474 if (attribute_flag[1] == 0)
9475 argument_list[1].integer_reference=0;
9476 image->offset=argument_list[1].integer_reference;
9477 image=SteganoImage(image,argument_list[0].image_reference,exception);
9480 case 65: /* Deconstruct */
9482 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9485 case 66: /* GaussianBlur */
9487 if (attribute_flag[0] != 0)
9489 flags=ParseGeometry(argument_list[0].string_reference,
9491 if ((flags & SigmaValue) == 0)
9492 geometry_info.sigma=1.0;
9494 if (attribute_flag[1] != 0)
9495 geometry_info.rho=argument_list[1].real_reference;
9496 if (attribute_flag[2] != 0)
9497 geometry_info.sigma=argument_list[2].real_reference;
9498 if (attribute_flag[3] != 0)
9499 channel=(ChannelType) argument_list[3].integer_reference;
9500 channel_mask=SetImageChannelMask(image,channel);
9501 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9503 if (image != (Image *) NULL)
9504 (void) SetImageChannelMask(image,channel_mask);
9507 case 67: /* Convolve */
9512 kernel=(KernelInfo *) NULL;
9513 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9515 if (attribute_flag[0] != 0)
9523 kernel=AcquireKernelInfo((const char *) NULL);
9524 if (kernel == (KernelInfo *) NULL)
9526 av=(AV *) argument_list[0].array_reference;
9527 order=(size_t) sqrt(av_len(av)+1);
9528 kernel->width=order;
9529 kernel->height=order;
9530 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9531 order*sizeof(*kernel->values));
9532 if (kernel->values == (MagickRealType *) NULL)
9534 kernel=DestroyKernelInfo(kernel);
9535 ThrowPerlException(exception,ResourceLimitFatalError,
9536 "MemoryAllocationFailed",PackageName);
9539 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9540 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9541 for ( ; j < (ssize_t) (order*order); j++)
9542 kernel->values[j]=0.0;
9544 if (attribute_flag[1] != 0)
9545 channel=(ChannelType) argument_list[1].integer_reference;
9546 if (attribute_flag[2] != 0)
9547 SetImageArtifact(image,"filter:blur",
9548 argument_list[2].string_reference);
9549 if (attribute_flag[3] != 0)
9551 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9552 if (kernel == (KernelInfo *) NULL)
9555 channel_mask=SetImageChannelMask(image,channel);
9556 image=ConvolveImage(image,kernel,exception);
9557 if (image != (Image *) NULL)
9558 (void) SetImageChannelMask(image,channel_mask);
9559 kernel=DestroyKernelInfo(kernel);
9562 case 68: /* Profile */
9577 if (attribute_flag[0] != 0)
9578 name=argument_list[0].string_reference;
9579 if (attribute_flag[2] != 0)
9580 image->rendering_intent=(RenderingIntent)
9581 argument_list[2].integer_reference;
9582 if (attribute_flag[3] != 0)
9583 image->black_point_compensation=
9584 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9585 if (attribute_flag[1] != 0)
9587 if (argument_list[1].length == 0)
9590 Remove a profile from the image.
9592 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9597 Associate user supplied profile with the image.
9599 profile=AcquireStringInfo(argument_list[1].length);
9600 SetStringInfoDatum(profile,(const unsigned char *)
9601 argument_list[1].string_reference);
9602 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9603 (size_t) GetStringInfoLength(profile),exception);
9604 profile=DestroyStringInfo(profile);
9608 Associate a profile with the image.
9610 profile_info=CloneImageInfo(info ? info->image_info :
9611 (ImageInfo *) NULL);
9612 profile_image=ReadImages(profile_info,name,exception);
9613 if (profile_image == (Image *) NULL)
9615 ResetImageProfileIterator(profile_image);
9616 name=GetNextImageProfile(profile_image);
9617 while (name != (const char *) NULL)
9622 profile=GetImageProfile(profile_image,name);
9623 if (profile != (const StringInfo *) NULL)
9624 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9625 (size_t) GetStringInfoLength(profile),exception);
9626 name=GetNextImageProfile(profile_image);
9628 profile_image=DestroyImage(profile_image);
9629 profile_info=DestroyImageInfo(profile_info);
9632 case 69: /* UnsharpMask */
9634 if (attribute_flag[0] != 0)
9636 flags=ParseGeometry(argument_list[0].string_reference,
9638 if ((flags & SigmaValue) == 0)
9639 geometry_info.sigma=1.0;
9640 if ((flags & XiValue) == 0)
9641 geometry_info.xi=1.0;
9642 if ((flags & PsiValue) == 0)
9643 geometry_info.psi=0.5;
9645 if (attribute_flag[1] != 0)
9646 geometry_info.rho=argument_list[1].real_reference;
9647 if (attribute_flag[2] != 0)
9648 geometry_info.sigma=argument_list[2].real_reference;
9649 if (attribute_flag[3] != 0)
9650 geometry_info.xi=argument_list[3].real_reference;
9651 if (attribute_flag[4] != 0)
9652 geometry_info.psi=argument_list[4].real_reference;
9653 if (attribute_flag[5] != 0)
9654 channel=(ChannelType) argument_list[5].integer_reference;
9655 channel_mask=SetImageChannelMask(image,channel);
9656 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9657 geometry_info.xi,geometry_info.psi,exception);
9658 if (image != (Image *) NULL)
9659 (void) SetImageChannelMask(image,channel_mask);
9662 case 70: /* MotionBlur */
9664 if (attribute_flag[0] != 0)
9666 flags=ParseGeometry(argument_list[0].string_reference,
9668 if ((flags & SigmaValue) == 0)
9669 geometry_info.sigma=1.0;
9670 if ((flags & XiValue) == 0)
9671 geometry_info.xi=1.0;
9673 if (attribute_flag[1] != 0)
9674 geometry_info.rho=argument_list[1].real_reference;
9675 if (attribute_flag[2] != 0)
9676 geometry_info.sigma=argument_list[2].real_reference;
9677 if (attribute_flag[3] != 0)
9678 geometry_info.xi=argument_list[3].real_reference;
9679 if (attribute_flag[4] != 0)
9680 channel=(ChannelType) argument_list[4].integer_reference;
9681 channel_mask=SetImageChannelMask(image,channel);
9682 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9683 geometry_info.xi,exception);
9684 if (image != (Image *) NULL)
9685 (void) SetImageChannelMask(image,channel_mask);
9688 case 71: /* OrderedDither */
9690 if (attribute_flag[0] == 0)
9691 argument_list[0].string_reference="o8x8";
9692 if (attribute_flag[1] != 0)
9693 channel=(ChannelType) argument_list[1].integer_reference;
9694 channel_mask=SetImageChannelMask(image,channel);
9695 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9697 (void) SetImageChannelMask(image,channel_mask);
9700 case 72: /* Shave */
9702 if (attribute_flag[0] != 0)
9703 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9704 &geometry,exception);
9705 if (attribute_flag[1] != 0)
9706 geometry.width=argument_list[1].integer_reference;
9707 if (attribute_flag[2] != 0)
9708 geometry.height=argument_list[2].integer_reference;
9709 image=ShaveImage(image,&geometry,exception);
9712 case 73: /* Level */
9720 white_point=(double) image->columns*image->rows;
9722 if (attribute_flag[0] != 0)
9724 flags=ParseGeometry(argument_list[0].string_reference,
9726 black_point=geometry_info.rho;
9727 if ((flags & SigmaValue) != 0)
9728 white_point=geometry_info.sigma;
9729 if ((flags & XiValue) != 0)
9730 gamma=geometry_info.xi;
9731 if ((flags & PercentValue) != 0)
9733 black_point*=(double) (QuantumRange/100.0);
9734 white_point*=(double) (QuantumRange/100.0);
9736 if ((flags & SigmaValue) == 0)
9737 white_point=(double) QuantumRange-black_point;
9739 if (attribute_flag[1] != 0)
9740 black_point=argument_list[1].real_reference;
9741 if (attribute_flag[2] != 0)
9742 white_point=argument_list[2].real_reference;
9743 if (attribute_flag[3] != 0)
9744 gamma=argument_list[3].real_reference;
9745 if (attribute_flag[4] != 0)
9746 channel=(ChannelType) argument_list[4].integer_reference;
9747 if (attribute_flag[5] != 0)
9749 argument_list[0].real_reference=argument_list[5].real_reference;
9750 attribute_flag[0]=attribute_flag[5];
9752 channel_mask=SetImageChannelMask(image,channel);
9753 (void) LevelImage(image,black_point,white_point,gamma,exception);
9754 (void) SetImageChannelMask(image,channel_mask);
9759 if (attribute_flag[0] == 0)
9760 argument_list[0].string_reference="#1";
9761 if (attribute_flag[1] == 0)
9762 argument_list[1].integer_reference=MagickTrue;
9763 (void) ClipImagePath(image,argument_list[0].string_reference,
9764 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9768 case 75: /* AffineTransform */
9773 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9775 if (attribute_flag[0] != 0)
9780 av=(AV *) argument_list[0].array_reference;
9781 if ((av_len(av) != 3) && (av_len(av) != 5))
9783 ThrowPerlException(exception,OptionError,
9784 "affine matrix must have 4 or 6 elements",PackageName);
9787 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9788 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9789 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9790 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9791 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9792 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9794 ThrowPerlException(exception,OptionError,
9795 "affine matrix is singular",PackageName);
9798 if (av_len(av) == 5)
9800 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9801 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9804 for (j=1; j < 6; j++)
9806 if (attribute_flag[j] == 0)
9808 value=argument_list[j].string_reference;
9809 angle=argument_list[j].real_reference;
9810 current=draw_info->affine;
9811 GetAffineMatrix(&affine);
9819 flags=ParseGeometry(value,&geometry_info);
9820 affine.tx=geometry_info.xi;
9821 affine.ty=geometry_info.psi;
9822 if ((flags & PsiValue) == 0)
9823 affine.ty=affine.tx;
9831 flags=ParseGeometry(value,&geometry_info);
9832 affine.sx=geometry_info.rho;
9833 affine.sy=geometry_info.sigma;
9834 if ((flags & SigmaValue) == 0)
9835 affine.sy=affine.sx;
9845 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9846 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9847 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9848 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9856 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9864 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9868 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9869 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9870 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9871 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9872 draw_info->affine.tx=
9873 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9874 draw_info->affine.ty=
9875 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9877 if (attribute_flag[6] != 0)
9878 image->interpolate=(PixelInterpolateMethod)
9879 argument_list[6].integer_reference;
9880 if (attribute_flag[7] != 0)
9881 QueryColorCompliance(argument_list[7].string_reference,
9882 AllCompliance,&image->background_color,exception);
9883 image=AffineTransformImage(image,&draw_info->affine,exception);
9884 draw_info=DestroyDrawInfo(draw_info);
9887 case 76: /* Difference */
9889 if (attribute_flag[0] == 0)
9891 ThrowPerlException(exception,OptionError,
9892 "ReferenceImageRequired",PackageName);
9895 if (attribute_flag[1] != 0)
9896 image->fuzz=StringToDoubleInterval(
9897 argument_list[1].string_reference,(double) QuantumRange+1.0);
9898 (void) IsImagesEqual(image,argument_list[0].image_reference,
9902 case 77: /* AdaptiveThreshold */
9904 if (attribute_flag[0] != 0)
9906 flags=ParseGeometry(argument_list[0].string_reference,
9908 if ((flags & PercentValue) != 0)
9909 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9911 if (attribute_flag[1] != 0)
9912 geometry_info.rho=argument_list[1].integer_reference;
9913 if (attribute_flag[2] != 0)
9914 geometry_info.sigma=argument_list[2].integer_reference;
9915 if (attribute_flag[3] != 0)
9916 geometry_info.xi=argument_list[3].integer_reference;;
9917 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9918 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9921 case 78: /* Resample */
9927 if (attribute_flag[0] != 0)
9929 flags=ParseGeometry(argument_list[0].string_reference,
9931 if ((flags & SigmaValue) == 0)
9932 geometry_info.sigma=geometry_info.rho;
9934 if (attribute_flag[1] != 0)
9935 geometry_info.rho=argument_list[1].real_reference;
9936 if (attribute_flag[2] != 0)
9937 geometry_info.sigma=argument_list[2].real_reference;
9938 if (attribute_flag[3] == 0)
9939 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9940 if (attribute_flag[4] == 0)
9941 SetImageArtifact(image,"filter:support",
9942 argument_list[4].string_reference);
9943 width=(size_t) (geometry_info.rho*image->columns/
9944 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9945 height=(size_t) (geometry_info.sigma*image->rows/
9946 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9947 image=ResizeImage(image,width,height,(FilterTypes)
9948 argument_list[3].integer_reference,exception);
9949 if (image != (Image *) NULL)
9951 image->resolution.x=geometry_info.rho;
9952 image->resolution.y=geometry_info.sigma;
9956 case 79: /* Describe */
9958 if (attribute_flag[0] == 0)
9959 argument_list[0].file_reference=(FILE *) NULL;
9960 if (attribute_flag[1] != 0)
9961 (void) SetImageArtifact(image,"identify:features",
9962 argument_list[1].string_reference);
9963 (void) IdentifyImage(image,argument_list[0].file_reference,
9964 MagickTrue,exception);
9967 case 80: /* BlackThreshold */
9969 if (attribute_flag[0] == 0)
9970 argument_list[0].string_reference="50%";
9971 if (attribute_flag[2] != 0)
9972 channel=(ChannelType) argument_list[2].integer_reference;
9973 channel_mask=SetImageChannelMask(image,channel);
9974 BlackThresholdImage(image,argument_list[0].string_reference,
9976 (void) SetImageChannelMask(image,channel_mask);
9979 case 81: /* WhiteThreshold */
9981 if (attribute_flag[0] == 0)
9982 argument_list[0].string_reference="50%";
9983 if (attribute_flag[2] != 0)
9984 channel=(ChannelType) argument_list[2].integer_reference;
9985 channel_mask=SetImageChannelMask(image,channel);
9986 WhiteThresholdImage(image,argument_list[0].string_reference,
9988 (void) SetImageChannelMask(image,channel_mask);
9991 case 82: /* RadialBlur */
9993 if (attribute_flag[0] != 0)
9995 flags=ParseGeometry(argument_list[0].string_reference,
9998 if (attribute_flag[1] != 0)
9999 geometry_info.rho=argument_list[1].real_reference;
10000 if (attribute_flag[2] != 0)
10001 channel=(ChannelType) argument_list[2].integer_reference;
10002 channel_mask=SetImageChannelMask(image,channel);
10003 image=RadialBlurImage(image,geometry_info.rho,exception);
10004 if (image != (Image *) NULL)
10005 (void) SetImageChannelMask(image,channel_mask);
10008 case 83: /* Thumbnail */
10010 if (attribute_flag[0] != 0)
10011 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10012 &geometry,exception);
10013 if (attribute_flag[1] != 0)
10014 geometry.width=argument_list[1].integer_reference;
10015 if (attribute_flag[2] != 0)
10016 geometry.height=argument_list[2].integer_reference;
10017 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10020 case 84: /* Strip */
10022 (void) StripImage(image,exception);
10025 case 85: /* Tint */
10030 GetPixelInfo(image,&tint);
10031 if (attribute_flag[0] != 0)
10032 (void) QueryColorCompliance(argument_list[0].string_reference,
10033 AllCompliance,&tint,exception);
10034 if (attribute_flag[1] == 0)
10035 argument_list[1].string_reference="100";
10036 image=TintImage(image,argument_list[1].string_reference,&tint,
10040 case 86: /* Channel */
10042 if (attribute_flag[0] != 0)
10043 channel=(ChannelType) argument_list[0].integer_reference;
10044 image=SeparateImage(image,channel,exception);
10047 case 87: /* Splice */
10049 if (attribute_flag[0] != 0)
10050 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10051 &geometry,exception);
10052 if (attribute_flag[1] != 0)
10053 geometry.width=argument_list[1].integer_reference;
10054 if (attribute_flag[2] != 0)
10055 geometry.height=argument_list[2].integer_reference;
10056 if (attribute_flag[3] != 0)
10057 geometry.x=argument_list[3].integer_reference;
10058 if (attribute_flag[4] != 0)
10059 geometry.y=argument_list[4].integer_reference;
10060 if (attribute_flag[5] != 0)
10061 image->fuzz=StringToDoubleInterval(
10062 argument_list[5].string_reference,(double) QuantumRange+1.0);
10063 if (attribute_flag[6] != 0)
10064 (void) QueryColorCompliance(argument_list[6].string_reference,
10065 AllCompliance,&image->background_color,exception);
10066 if (attribute_flag[7] != 0)
10067 image->gravity=(GravityType) argument_list[7].integer_reference;
10068 image=SpliceImage(image,&geometry,exception);
10071 case 88: /* Posterize */
10073 if (attribute_flag[0] == 0)
10074 argument_list[0].integer_reference=3;
10075 if (attribute_flag[1] == 0)
10076 argument_list[1].integer_reference=0;
10077 (void) PosterizeImage(image,argument_list[0].integer_reference,
10078 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10079 NoDitherMethod,exception);
10082 case 89: /* Shadow */
10084 if (attribute_flag[0] != 0)
10086 flags=ParseGeometry(argument_list[0].string_reference,
10088 if ((flags & SigmaValue) == 0)
10089 geometry_info.sigma=1.0;
10090 if ((flags & XiValue) == 0)
10091 geometry_info.xi=4.0;
10092 if ((flags & PsiValue) == 0)
10093 geometry_info.psi=4.0;
10095 if (attribute_flag[1] != 0)
10096 geometry_info.rho=argument_list[1].real_reference;
10097 if (attribute_flag[2] != 0)
10098 geometry_info.sigma=argument_list[2].real_reference;
10099 if (attribute_flag[3] != 0)
10100 geometry_info.xi=argument_list[3].integer_reference;
10101 if (attribute_flag[4] != 0)
10102 geometry_info.psi=argument_list[4].integer_reference;
10103 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10104 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10105 ceil(geometry_info.psi-0.5),exception);
10108 case 90: /* Identify */
10110 if (attribute_flag[0] == 0)
10111 argument_list[0].file_reference=(FILE *) NULL;
10112 if (attribute_flag[1] != 0)
10113 (void) SetImageArtifact(image,"identify:features",
10114 argument_list[1].string_reference);
10115 if ((attribute_flag[2] != 0) &&
10116 (argument_list[2].integer_reference != 0))
10117 (void) SetImageArtifact(image,"identify:unique","true");
10118 (void) IdentifyImage(image,argument_list[0].file_reference,
10119 MagickTrue,exception);
10122 case 91: /* SepiaTone */
10124 if (attribute_flag[0] == 0)
10125 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10126 image=SepiaToneImage(image,argument_list[0].real_reference,
10130 case 92: /* SigmoidalContrast */
10135 if (attribute_flag[0] != 0)
10137 flags=ParseGeometry(argument_list[0].string_reference,
10139 if ((flags & SigmaValue) == 0)
10140 geometry_info.sigma=QuantumRange/2.0;
10141 if ((flags & PercentValue) != 0)
10142 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10144 if (attribute_flag[1] != 0)
10145 geometry_info.rho=argument_list[1].real_reference;
10146 if (attribute_flag[2] != 0)
10147 geometry_info.sigma=argument_list[2].real_reference;
10148 if (attribute_flag[3] != 0)
10149 channel=(ChannelType) argument_list[3].integer_reference;
10150 sharpen=MagickTrue;
10151 if (attribute_flag[4] != 0)
10152 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10154 channel_mask=SetImageChannelMask(image,channel);
10155 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10156 geometry_info.sigma,exception);
10157 (void) SetImageChannelMask(image,channel_mask);
10160 case 93: /* Extent */
10162 if (attribute_flag[7] != 0)
10163 image->gravity=(GravityType) argument_list[7].integer_reference;
10164 if (attribute_flag[0] != 0)
10169 flags=ParseGravityGeometry(image,
10170 argument_list[0].string_reference,&geometry,exception);
10172 if (geometry.width == 0)
10173 geometry.width=image->columns;
10174 if (geometry.height == 0)
10175 geometry.height=image->rows;
10177 if (attribute_flag[1] != 0)
10178 geometry.width=argument_list[1].integer_reference;
10179 if (attribute_flag[2] != 0)
10180 geometry.height=argument_list[2].integer_reference;
10181 if (attribute_flag[3] != 0)
10182 geometry.x=argument_list[3].integer_reference;
10183 if (attribute_flag[4] != 0)
10184 geometry.y=argument_list[4].integer_reference;
10185 if (attribute_flag[5] != 0)
10186 image->fuzz=StringToDoubleInterval(
10187 argument_list[5].string_reference,(double) QuantumRange+1.0);
10188 if (attribute_flag[6] != 0)
10189 (void) QueryColorCompliance(argument_list[6].string_reference,
10190 AllCompliance,&image->background_color,exception);
10191 image=ExtentImage(image,&geometry,exception);
10194 case 94: /* Vignette */
10196 if (attribute_flag[0] != 0)
10198 flags=ParseGeometry(argument_list[0].string_reference,
10200 if ((flags & SigmaValue) == 0)
10201 geometry_info.sigma=1.0;
10202 if ((flags & XiValue) == 0)
10203 geometry_info.xi=0.1*image->columns;
10204 if ((flags & PsiValue) == 0)
10205 geometry_info.psi=0.1*image->rows;
10207 if (attribute_flag[1] != 0)
10208 geometry_info.rho=argument_list[1].real_reference;
10209 if (attribute_flag[2] != 0)
10210 geometry_info.sigma=argument_list[2].real_reference;
10211 if (attribute_flag[3] != 0)
10212 geometry_info.xi=argument_list[3].integer_reference;
10213 if (attribute_flag[4] != 0)
10214 geometry_info.psi=argument_list[4].integer_reference;
10215 if (attribute_flag[5] != 0)
10216 (void) QueryColorCompliance(argument_list[5].string_reference,
10217 AllCompliance,&image->background_color,exception);
10218 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10219 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10220 ceil(geometry_info.psi-0.5),exception);
10223 case 95: /* ContrastStretch */
10230 white_point=(double) image->columns*image->rows;
10231 if (attribute_flag[0] != 0)
10233 flags=ParseGeometry(argument_list[0].string_reference,
10235 black_point=geometry_info.rho;
10236 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10238 if ((flags & PercentValue) != 0)
10240 black_point*=(double) image->columns*image->rows/100.0;
10241 white_point*=(double) image->columns*image->rows/100.0;
10243 white_point=(double) image->columns*image->rows-
10246 if (attribute_flag[1] != 0)
10247 black_point=argument_list[1].real_reference;
10248 if (attribute_flag[2] != 0)
10249 white_point=argument_list[2].real_reference;
10250 if (attribute_flag[4] != 0)
10251 channel=(ChannelType) argument_list[4].integer_reference;
10252 channel_mask=SetImageChannelMask(image,channel);
10253 (void) ContrastStretchImage(image,black_point,white_point,exception);
10254 (void) SetImageChannelMask(image,channel_mask);
10257 case 96: /* Sans0 */
10261 case 97: /* Sans1 */
10265 case 98: /* AdaptiveSharpen */
10267 if (attribute_flag[0] != 0)
10269 flags=ParseGeometry(argument_list[0].string_reference,
10271 if ((flags & SigmaValue) == 0)
10272 geometry_info.sigma=1.0;
10273 if ((flags & XiValue) == 0)
10274 geometry_info.xi=0.0;
10276 if (attribute_flag[1] != 0)
10277 geometry_info.rho=argument_list[1].real_reference;
10278 if (attribute_flag[2] != 0)
10279 geometry_info.sigma=argument_list[2].real_reference;
10280 if (attribute_flag[3] != 0)
10281 geometry_info.xi=argument_list[3].real_reference;
10282 if (attribute_flag[4] != 0)
10283 channel=(ChannelType) argument_list[4].integer_reference;
10284 channel_mask=SetImageChannelMask(image,channel);
10285 image=AdaptiveSharpenImage(image,geometry_info.rho,
10286 geometry_info.sigma,exception);
10287 if (image != (Image *) NULL)
10288 (void) SetImageChannelMask(image,channel_mask);
10291 case 99: /* Transpose */
10293 image=TransposeImage(image,exception);
10296 case 100: /* Tranverse */
10298 image=TransverseImage(image,exception);
10301 case 101: /* AutoOrient */
10303 image=AutoOrientImage(image,image->orientation,exception);
10306 case 102: /* AdaptiveBlur */
10308 if (attribute_flag[0] != 0)
10310 flags=ParseGeometry(argument_list[0].string_reference,
10312 if ((flags & SigmaValue) == 0)
10313 geometry_info.sigma=1.0;
10314 if ((flags & XiValue) == 0)
10315 geometry_info.xi=0.0;
10317 if (attribute_flag[1] != 0)
10318 geometry_info.rho=argument_list[1].real_reference;
10319 if (attribute_flag[2] != 0)
10320 geometry_info.sigma=argument_list[2].real_reference;
10321 if (attribute_flag[3] != 0)
10322 channel=(ChannelType) argument_list[3].integer_reference;
10323 channel_mask=SetImageChannelMask(image,channel);
10324 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10326 if (image != (Image *) NULL)
10327 (void) SetImageChannelMask(image,channel_mask);
10330 case 103: /* Sketch */
10332 if (attribute_flag[0] != 0)
10334 flags=ParseGeometry(argument_list[0].string_reference,
10336 if ((flags & SigmaValue) == 0)
10337 geometry_info.sigma=1.0;
10338 if ((flags & XiValue) == 0)
10339 geometry_info.xi=1.0;
10341 if (attribute_flag[1] != 0)
10342 geometry_info.rho=argument_list[1].real_reference;
10343 if (attribute_flag[2] != 0)
10344 geometry_info.sigma=argument_list[2].real_reference;
10345 if (attribute_flag[3] != 0)
10346 geometry_info.xi=argument_list[3].real_reference;
10347 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10348 geometry_info.xi,exception);
10351 case 104: /* UniqueColors */
10353 image=UniqueImageColors(image,exception);
10356 case 105: /* AdaptiveResize */
10358 if (attribute_flag[0] != 0)
10359 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10360 &geometry,exception);
10361 if (attribute_flag[1] != 0)
10362 geometry.width=argument_list[1].integer_reference;
10363 if (attribute_flag[2] != 0)
10364 geometry.height=argument_list[2].integer_reference;
10365 if (attribute_flag[3] != 0)
10366 image->filter=(FilterTypes) argument_list[4].integer_reference;
10367 if (attribute_flag[4] != 0)
10368 SetImageArtifact(image,"filter:support",
10369 argument_list[4].string_reference);
10370 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10374 case 106: /* ClipMask */
10379 if (attribute_flag[0] == 0)
10381 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10383 goto PerlException;
10385 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10387 (void) SetImageMask(image,mask_image,exception);
10388 mask_image=DestroyImage(mask_image);
10391 case 107: /* LinearStretch */
10398 white_point=(double) image->columns*image->rows;
10399 if (attribute_flag[0] != 0)
10401 flags=ParseGeometry(argument_list[0].string_reference,
10403 if ((flags & SigmaValue) != 0)
10404 white_point=geometry_info.sigma;
10405 if ((flags & PercentValue) != 0)
10407 black_point*=(double) image->columns*image->rows/100.0;
10408 white_point*=(double) image->columns*image->rows/100.0;
10410 if ((flags & SigmaValue) == 0)
10411 white_point=(double) image->columns*image->rows-black_point;
10413 if (attribute_flag[1] != 0)
10414 black_point=argument_list[1].real_reference;
10415 if (attribute_flag[2] != 0)
10416 white_point=argument_list[2].real_reference;
10417 (void) LinearStretchImage(image,black_point,white_point,exception);
10420 case 108: /* ColorMatrix */
10434 if (attribute_flag[0] == 0)
10436 av=(AV *) argument_list[0].array_reference;
10437 order=(size_t) sqrt(av_len(av)+1);
10438 color_matrix=(double *) AcquireQuantumMemory(order,order*
10439 sizeof(*color_matrix));
10440 if (color_matrix == (double *) NULL)
10442 ThrowPerlException(exception,ResourceLimitFatalError,
10443 "MemoryAllocationFailed",PackageName);
10444 goto PerlException;
10446 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10447 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10448 for ( ; j < (ssize_t) (order*order); j++)
10449 color_matrix[j]=0.0;
10450 kernel_info=AcquireKernelInfo((const char *) NULL);
10451 if (kernel_info == (KernelInfo *) NULL)
10453 kernel_info->width=order;
10454 kernel_info->height=order;
10455 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10456 order*sizeof(*kernel_info->values));
10457 if (kernel_info->values != (MagickRealType *) NULL)
10459 for (i=0; i < (ssize_t) (order*order); i++)
10460 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10461 image=ColorMatrixImage(image,kernel_info,exception);
10463 kernel_info=DestroyKernelInfo(kernel_info);
10464 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10467 case 109: /* Mask */
10472 if (attribute_flag[0] == 0)
10474 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10476 goto PerlException;
10478 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10479 MagickTrue,exception);
10480 (void) SetImageMask(image,mask_image,exception);
10481 mask_image=DestroyImage(mask_image);
10484 case 110: /* Polaroid */
10495 PixelInterpolateMethod
10498 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10499 (DrawInfo *) NULL);
10500 caption=(char *) NULL;
10501 if (attribute_flag[0] != 0)
10502 caption=InterpretImageProperties(info ? info->image_info :
10503 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10506 if (attribute_flag[1] != 0)
10507 angle=argument_list[1].real_reference;
10508 if (attribute_flag[2] != 0)
10509 (void) CloneString(&draw_info->font,
10510 argument_list[2].string_reference);
10511 if (attribute_flag[3] != 0)
10512 (void) QueryColorCompliance(argument_list[3].string_reference,
10513 AllCompliance,&draw_info->stroke,exception);
10514 if (attribute_flag[4] != 0)
10515 (void) QueryColorCompliance(argument_list[4].string_reference,
10516 AllCompliance,&draw_info->fill,exception);
10517 if (attribute_flag[5] != 0)
10518 draw_info->stroke_width=argument_list[5].real_reference;
10519 if (attribute_flag[6] != 0)
10520 draw_info->pointsize=argument_list[6].real_reference;
10521 if (attribute_flag[7] != 0)
10522 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10523 if (attribute_flag[8] != 0)
10524 (void) QueryColorCompliance(argument_list[8].string_reference,
10525 AllCompliance,&image->background_color,exception);
10526 method=UndefinedInterpolatePixel;
10527 if (attribute_flag[9] != 0)
10528 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10529 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10530 draw_info=DestroyDrawInfo(draw_info);
10531 if (caption != (char *) NULL)
10532 caption=DestroyString(caption);
10535 case 111: /* FloodfillPaint */
10546 draw_info=CloneDrawInfo(info ? info->image_info :
10547 (ImageInfo *) NULL,(DrawInfo *) NULL);
10548 if (attribute_flag[0] != 0)
10549 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10550 &geometry,exception);
10551 if (attribute_flag[1] != 0)
10552 geometry.x=argument_list[1].integer_reference;
10553 if (attribute_flag[2] != 0)
10554 geometry.y=argument_list[2].integer_reference;
10555 if (attribute_flag[3] != 0)
10556 (void) QueryColorCompliance(argument_list[3].string_reference,
10557 AllCompliance,&draw_info->fill,exception);
10558 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10559 geometry.x,geometry.y,&target,exception);
10560 if (attribute_flag[4] != 0)
10561 QueryColorCompliance(argument_list[4].string_reference,
10562 AllCompliance,&target,exception);
10563 if (attribute_flag[5] != 0)
10564 image->fuzz=StringToDoubleInterval(
10565 argument_list[5].string_reference,(double) QuantumRange+1.0);
10566 if (attribute_flag[6] != 0)
10567 channel=(ChannelType) argument_list[6].integer_reference;
10568 invert=MagickFalse;
10569 if (attribute_flag[7] != 0)
10570 invert=(MagickBooleanType) argument_list[7].integer_reference;
10571 channel_mask=SetImageChannelMask(image,channel);
10572 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10573 geometry.y,invert,exception);
10574 (void) SetImageChannelMask(image,channel_mask);
10575 draw_info=DestroyDrawInfo(draw_info);
10578 case 112: /* Distort */
10590 number_coordinates;
10595 if (attribute_flag[0] == 0)
10597 method=UndefinedDistortion;
10598 if (attribute_flag[1] != 0)
10599 method=(DistortImageMethod) argument_list[1].integer_reference;
10600 av=(AV *) argument_list[0].array_reference;
10601 number_coordinates=(size_t) av_len(av)+1;
10602 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10603 sizeof(*coordinates));
10604 if (coordinates == (double *) NULL)
10606 ThrowPerlException(exception,ResourceLimitFatalError,
10607 "MemoryAllocationFailed",PackageName);
10608 goto PerlException;
10610 for (j=0; j < (ssize_t) number_coordinates; j++)
10611 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10612 virtual_pixel=UndefinedVirtualPixelMethod;
10613 if (attribute_flag[2] != 0)
10614 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10615 argument_list[2].integer_reference,exception);
10616 image=DistortImage(image,method,number_coordinates,coordinates,
10617 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10619 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10620 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10622 coordinates=(double *) RelinquishMagickMemory(coordinates);
10625 case 113: /* Clut */
10627 PixelInterpolateMethod
10630 if (attribute_flag[0] == 0)
10632 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10634 goto PerlException;
10636 method=UndefinedInterpolatePixel;
10637 if (attribute_flag[1] != 0)
10638 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10639 if (attribute_flag[2] != 0)
10640 channel=(ChannelType) argument_list[2].integer_reference;
10641 channel_mask=SetImageChannelMask(image,channel);
10642 (void) ClutImage(image,argument_list[0].image_reference,method,
10644 (void) SetImageChannelMask(image,channel_mask);
10647 case 114: /* LiquidRescale */
10649 if (attribute_flag[0] != 0)
10650 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10651 &geometry,exception);
10652 if (attribute_flag[1] != 0)
10653 geometry.width=argument_list[1].integer_reference;
10654 if (attribute_flag[2] != 0)
10655 geometry.height=argument_list[2].integer_reference;
10656 if (attribute_flag[3] == 0)
10657 argument_list[3].real_reference=1.0;
10658 if (attribute_flag[4] == 0)
10659 argument_list[4].real_reference=0.0;
10660 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10661 argument_list[3].real_reference,argument_list[4].real_reference,
10665 case 115: /* EncipherImage */
10667 (void) EncipherImage(image,argument_list[0].string_reference,
10671 case 116: /* DecipherImage */
10673 (void) DecipherImage(image,argument_list[0].string_reference,
10677 case 117: /* Deskew */
10679 geometry_info.rho=QuantumRange/2.0;
10680 if (attribute_flag[0] != 0)
10681 flags=ParseGeometry(argument_list[0].string_reference,
10683 if (attribute_flag[1] != 0)
10684 geometry_info.rho=StringToDoubleInterval(
10685 argument_list[1].string_reference,(double) QuantumRange+1.0);
10686 image=DeskewImage(image,geometry_info.rho,exception);
10689 case 118: /* Remap */
10694 if (attribute_flag[0] == 0)
10696 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10698 goto PerlException;
10700 quantize_info=AcquireQuantizeInfo(info->image_info);
10701 if (attribute_flag[1] != 0)
10702 quantize_info->dither_method=(DitherMethod)
10703 argument_list[1].integer_reference;
10704 (void) RemapImages(quantize_info,image,
10705 argument_list[0].image_reference,exception);
10706 quantize_info=DestroyQuantizeInfo(quantize_info);
10709 case 119: /* SparseColor */
10721 number_coordinates;
10726 if (attribute_flag[0] == 0)
10728 method=UndefinedColorInterpolate;
10729 if (attribute_flag[1] != 0)
10730 method=(SparseColorMethod) argument_list[1].integer_reference;
10731 av=(AV *) argument_list[0].array_reference;
10732 number_coordinates=(size_t) av_len(av)+1;
10733 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10734 sizeof(*coordinates));
10735 if (coordinates == (double *) NULL)
10737 ThrowPerlException(exception,ResourceLimitFatalError,
10738 "MemoryAllocationFailed",PackageName);
10739 goto PerlException;
10741 for (j=0; j < (ssize_t) number_coordinates; j++)
10742 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10743 virtual_pixel=UndefinedVirtualPixelMethod;
10744 if (attribute_flag[2] != 0)
10745 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10746 argument_list[2].integer_reference,exception);
10747 if (attribute_flag[3] != 0)
10748 channel=(ChannelType) argument_list[3].integer_reference;
10749 channel_mask=SetImageChannelMask(image,channel);
10750 image=SparseColorImage(image,method,number_coordinates,coordinates,
10752 if (image != (Image *) NULL)
10753 (void) SetImageChannelMask(image,channel_mask);
10754 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10755 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10757 coordinates=(double *) RelinquishMagickMemory(coordinates);
10760 case 120: /* Function */
10777 if (attribute_flag[0] == 0)
10779 function=UndefinedFunction;
10780 if (attribute_flag[1] != 0)
10781 function=(MagickFunction) argument_list[1].integer_reference;
10782 av=(AV *) argument_list[0].array_reference;
10783 number_parameters=(size_t) av_len(av)+1;
10784 parameters=(double *) AcquireQuantumMemory(number_parameters,
10785 sizeof(*parameters));
10786 if (parameters == (double *) NULL)
10788 ThrowPerlException(exception,ResourceLimitFatalError,
10789 "MemoryAllocationFailed",PackageName);
10790 goto PerlException;
10792 for (j=0; j < (ssize_t) number_parameters; j++)
10793 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10794 virtual_pixel=UndefinedVirtualPixelMethod;
10795 if (attribute_flag[2] != 0)
10796 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10797 argument_list[2].integer_reference,exception);
10798 (void) FunctionImage(image,function,number_parameters,parameters,
10800 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10801 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10803 parameters=(double *) RelinquishMagickMemory(parameters);
10806 case 121: /* SelectiveBlur */
10808 if (attribute_flag[0] != 0)
10810 flags=ParseGeometry(argument_list[0].string_reference,
10812 if ((flags & SigmaValue) == 0)
10813 geometry_info.sigma=1.0;
10814 if ((flags & PercentValue) != 0)
10815 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10817 if (attribute_flag[1] != 0)
10818 geometry_info.rho=argument_list[1].real_reference;
10819 if (attribute_flag[2] != 0)
10820 geometry_info.sigma=argument_list[2].real_reference;
10821 if (attribute_flag[3] != 0)
10822 geometry_info.xi=argument_list[3].integer_reference;;
10823 if (attribute_flag[5] != 0)
10824 channel=(ChannelType) argument_list[5].integer_reference;
10825 channel_mask=SetImageChannelMask(image,channel);
10826 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10827 geometry_info.xi,exception);
10828 if (image != (Image *) NULL)
10829 (void) SetImageChannelMask(image,channel_mask);
10832 case 122: /* HaldClut */
10834 if (attribute_flag[0] == 0)
10836 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10838 goto PerlException;
10840 if (attribute_flag[1] != 0)
10841 channel=(ChannelType) argument_list[1].integer_reference;
10842 channel_mask=SetImageChannelMask(image,channel);
10843 (void) HaldClutImage(image,argument_list[0].image_reference,
10845 (void) SetImageChannelMask(image,channel_mask);
10848 case 123: /* BlueShift */
10850 if (attribute_flag[0] != 0)
10851 (void) ParseGeometry(argument_list[0].string_reference,
10853 image=BlueShiftImage(image,geometry_info.rho,exception);
10856 case 124: /* ForwardFourierTransformImage */
10858 image=ForwardFourierTransformImage(image,
10859 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10863 case 125: /* InverseFourierTransformImage */
10865 image=InverseFourierTransformImage(image,image->next,
10866 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10870 case 126: /* ColorDecisionList */
10872 if (attribute_flag[0] == 0)
10873 argument_list[0].string_reference=(char *) NULL;
10874 (void) ColorDecisionListImage(image,
10875 argument_list[0].string_reference,exception);
10878 case 127: /* AutoGamma */
10880 if (attribute_flag[0] != 0)
10881 channel=(ChannelType) argument_list[0].integer_reference;
10882 channel_mask=SetImageChannelMask(image,channel);
10883 (void) AutoGammaImage(image,exception);
10884 (void) SetImageChannelMask(image,channel_mask);
10887 case 128: /* AutoLevel */
10889 if (attribute_flag[0] != 0)
10890 channel=(ChannelType) argument_list[0].integer_reference;
10891 channel_mask=SetImageChannelMask(image,channel);
10892 (void) AutoLevelImage(image,exception);
10893 (void) SetImageChannelMask(image,channel_mask);
10896 case 129: /* LevelColors */
10902 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10904 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10906 if (attribute_flag[1] != 0)
10907 (void) QueryColorCompliance(
10908 argument_list[1].string_reference,AllCompliance,&black_point,
10910 if (attribute_flag[2] != 0)
10911 (void) QueryColorCompliance(
10912 argument_list[2].string_reference,AllCompliance,&white_point,
10914 if (attribute_flag[3] != 0)
10915 channel=(ChannelType) argument_list[3].integer_reference;
10916 channel_mask=SetImageChannelMask(image,channel);
10917 (void) LevelImageColors(image,&black_point,&white_point,
10918 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10920 (void) SetImageChannelMask(image,channel_mask);
10923 case 130: /* Clamp */
10925 if (attribute_flag[0] != 0)
10926 channel=(ChannelType) argument_list[0].integer_reference;
10927 channel_mask=SetImageChannelMask(image,channel);
10928 (void) ClampImage(image,exception);
10929 (void) SetImageChannelMask(image,channel_mask);
10932 case 131: /* BrightnessContrast */
10940 if (attribute_flag[0] != 0)
10942 flags=ParseGeometry(argument_list[0].string_reference,
10944 brightness=geometry_info.rho;
10945 if ((flags & SigmaValue) == 0)
10946 contrast=geometry_info.sigma;
10948 if (attribute_flag[1] != 0)
10949 brightness=argument_list[1].real_reference;
10950 if (attribute_flag[2] != 0)
10951 contrast=argument_list[2].real_reference;
10952 if (attribute_flag[4] != 0)
10953 channel=(ChannelType) argument_list[4].integer_reference;
10954 channel_mask=SetImageChannelMask(image,channel);
10955 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10956 (void) SetImageChannelMask(image,channel_mask);
10959 case 132: /* Morphology */
10970 if (attribute_flag[0] == 0)
10972 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10973 if (kernel == (KernelInfo *) NULL)
10975 if (attribute_flag[1] != 0)
10976 channel=(ChannelType) argument_list[1].integer_reference;
10977 method=UndefinedMorphology;
10978 if (attribute_flag[2] != 0)
10979 method=argument_list[2].integer_reference;
10981 if (attribute_flag[3] != 0)
10982 iterations=argument_list[3].integer_reference;
10983 channel_mask=SetImageChannelMask(image,channel);
10984 image=MorphologyImage(image,method,iterations,kernel,exception);
10985 if (image != (Image *) NULL)
10986 (void) SetImageChannelMask(image,channel_mask);
10987 kernel=DestroyKernelInfo(kernel);
10990 case 133: /* Mode */
10992 if (attribute_flag[0] != 0)
10994 flags=ParseGeometry(argument_list[0].string_reference,
10996 if ((flags & SigmaValue) == 0)
10997 geometry_info.sigma=1.0;
10999 if (attribute_flag[1] != 0)
11000 geometry_info.rho=argument_list[1].real_reference;
11001 if (attribute_flag[2] != 0)
11002 geometry_info.sigma=argument_list[2].real_reference;
11003 if (attribute_flag[3] != 0)
11004 channel=(ChannelType) argument_list[3].integer_reference;
11005 channel_mask=SetImageChannelMask(image,channel);
11006 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11007 (size_t) geometry_info.sigma,exception);
11008 if (image != (Image *) NULL)
11009 (void) SetImageChannelMask(image,channel_mask);
11012 case 134: /* Statistic */
11017 statistic=UndefinedStatistic;
11018 if (attribute_flag[0] != 0)
11020 flags=ParseGeometry(argument_list[0].string_reference,
11022 if ((flags & SigmaValue) == 0)
11023 geometry_info.sigma=1.0;
11025 if (attribute_flag[1] != 0)
11026 geometry_info.rho=argument_list[1].real_reference;
11027 if (attribute_flag[2] != 0)
11028 geometry_info.sigma=argument_list[2].real_reference;
11029 if (attribute_flag[3] != 0)
11030 channel=(ChannelType) argument_list[3].integer_reference;
11031 if (attribute_flag[4] != 0)
11032 statistic=(StatisticType) argument_list[4].integer_reference;
11033 channel_mask=SetImageChannelMask(image,channel);
11034 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11035 (size_t) geometry_info.sigma,exception);
11036 if (image != (Image *) NULL)
11037 (void) SetImageChannelMask(image,channel_mask);
11040 case 135: /* Perceptible */
11045 epsilon=MagickEpsilon;
11046 if (attribute_flag[0] != 0)
11047 epsilon=argument_list[0].real_reference;
11048 if (attribute_flag[1] != 0)
11049 channel=(ChannelType) argument_list[1].integer_reference;
11050 channel_mask=SetImageChannelMask(image,channel);
11051 (void) PerceptibleImage(image,epsilon,exception);
11052 (void) SetImageChannelMask(image,channel_mask);
11055 case 136: /* Poly */
11066 if (attribute_flag[0] == 0)
11068 if (attribute_flag[1] != 0)
11069 channel=(ChannelType) argument_list[1].integer_reference;
11070 av=(AV *) argument_list[0].array_reference;
11071 number_terms=(size_t) av_len(av);
11072 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11073 if (terms == (double *) NULL)
11075 ThrowPerlException(exception,ResourceLimitFatalError,
11076 "MemoryAllocationFailed",PackageName);
11077 goto PerlException;
11079 for (j=0; j < av_len(av); j++)
11080 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11081 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11082 terms=(double *) RelinquishMagickMemory(terms);
11085 case 137: /* Grayscale */
11087 PixelIntensityMethod
11090 method=UndefinedPixelIntensityMethod;
11091 if (attribute_flag[0] != 0)
11092 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11093 (void) GrayscaleImage(image,method,exception);
11097 if (next != (Image *) NULL)
11098 (void) CatchImageException(next);
11099 if (region_image != (Image *) NULL)
11104 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11105 region_info.x,region_info.y,exception);
11107 (void) CatchImageException(region_image);
11108 image=DestroyImage(image);
11109 image=region_image;
11111 if (image != (Image *) NULL)
11114 if (next && (next != image))
11116 image->next=next->next;
11117 if (image->next != (Image *) NULL)
11118 image->next->previous=image;
11119 DeleteImageFromRegistry(*pv,next);
11121 sv_setiv(*pv,PTR2IV(image));
11129 if (reference_vector)
11130 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11131 InheritPerlException(exception,perl_exception);
11132 exception=DestroyExceptionInfo(exception);
11133 sv_setiv(perl_exception,(IV) number_images);
11134 SvPOK_on(perl_exception);
11135 ST(0)=sv_2mortal(perl_exception);
11140 ###############################################################################
11148 ###############################################################################
11153 Image::Magick ref=NO_INIT
11198 PERL_UNUSED_VAR(ref);
11199 PERL_UNUSED_VAR(ix);
11200 exception=AcquireExceptionInfo();
11201 perl_exception=newSVpv("",0);
11204 if (sv_isobject(ST(0)) == 0)
11206 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11208 goto PerlException;
11210 reference=SvRV(ST(0));
11211 hv=SvSTASH(reference);
11213 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11215 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11216 if (image == (Image *) NULL)
11218 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11220 goto PerlException;
11225 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11226 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11227 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11229 for (i=2; i < items; i+=2)
11231 attribute=(char *) SvPV(ST(i-1),na);
11232 switch (*attribute)
11237 if (LocaleCompare(attribute,"background") == 0)
11239 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11240 &montage_info->background_color,exception);
11241 for (next=image; next; next=next->next)
11242 next->background_color=montage_info->background_color;
11245 if (LocaleCompare(attribute,"border") == 0)
11247 montage_info->border_width=SvIV(ST(i));
11250 if (LocaleCompare(attribute,"bordercolor") == 0)
11252 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11253 &montage_info->border_color,exception);
11254 for (next=image; next; next=next->next)
11255 next->border_color=montage_info->border_color;
11258 if (LocaleCompare(attribute,"borderwidth") == 0)
11260 montage_info->border_width=SvIV(ST(i));
11263 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11270 if (LocaleCompare(attribute,"compose") == 0)
11272 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11273 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11276 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11280 for (next=image; next; next=next->next)
11281 next->compose=(CompositeOperator) sp;
11284 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11291 if (LocaleCompare(attribute,"fill") == 0)
11293 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11294 &montage_info->fill,exception);
11297 if (LocaleCompare(attribute,"font") == 0)
11299 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11302 if (LocaleCompare(attribute,"frame") == 0)
11308 if (IsGeometry(p) == MagickFalse)
11310 ThrowPerlException(exception,OptionError,"MissingGeometry",
11314 (void) CloneString(&montage_info->frame,p);
11316 montage_info->frame=(char *) NULL;
11319 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11326 if (LocaleCompare(attribute,"geometry") == 0)
11332 if (IsGeometry(p) == MagickFalse)
11334 ThrowPerlException(exception,OptionError,"MissingGeometry",
11338 (void) CloneString(&montage_info->geometry,p);
11340 montage_info->geometry=(char *) NULL;
11343 if (LocaleCompare(attribute,"gravity") == 0)
11348 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11349 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11352 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11356 montage_info->gravity=(GravityType) in;
11357 for (next=image; next; next=next->next)
11358 next->gravity=(GravityType) in;
11361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11368 if (LocaleCompare(attribute,"label") == 0)
11370 for (next=image; next; next=next->next)
11371 (void) SetImageProperty(next,"label",InterpretImageProperties(
11372 info ? info->image_info : (ImageInfo *) NULL,next,
11373 SvPV(ST(i),na),exception),exception);
11376 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11383 if (LocaleCompare(attribute,"mattecolor") == 0)
11385 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11386 &montage_info->matte_color,exception);
11387 for (next=image; next; next=next->next)
11388 next->matte_color=montage_info->matte_color;
11391 if (LocaleCompare(attribute,"mode") == 0)
11396 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11397 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11402 ThrowPerlException(exception,OptionError,
11403 "UnrecognizedModeType",SvPV(ST(i),na));
11408 (void) CloneString(&montage_info->frame,"15x15+3+3");
11409 montage_info->shadow=MagickTrue;
11414 montage_info->frame=(char *) NULL;
11415 montage_info->shadow=MagickFalse;
11416 montage_info->border_width=0;
11419 case ConcatenateMode:
11421 montage_info->frame=(char *) NULL;
11422 montage_info->shadow=MagickFalse;
11423 (void) CloneString(&montage_info->geometry,"+0+0");
11424 montage_info->border_width=0;
11429 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11436 if (LocaleCompare(attribute,"pointsize") == 0)
11438 montage_info->pointsize=SvIV(ST(i));
11441 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11448 if (LocaleCompare(attribute,"shadow") == 0)
11450 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11451 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11454 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11458 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11461 if (LocaleCompare(attribute,"stroke") == 0)
11463 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11464 &montage_info->stroke,exception);
11467 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11474 if (LocaleCompare(attribute,"texture") == 0)
11476 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11479 if (LocaleCompare(attribute,"tile") == 0)
11481 char *p=SvPV(ST(i),na);
11482 if (IsGeometry(p) == MagickFalse)
11484 ThrowPerlException(exception,OptionError,"MissingGeometry",
11488 (void) CloneString(&montage_info->tile,p);
11490 montage_info->tile=(char *) NULL;
11493 if (LocaleCompare(attribute,"title") == 0)
11495 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11498 if (LocaleCompare(attribute,"transparent") == 0)
11503 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11504 &transparent_color,exception);
11505 for (next=image; next; next=next->next)
11506 (void) TransparentPaintImage(next,&transparent_color,
11507 TransparentAlpha,MagickFalse,exception);
11510 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11516 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11522 image=MontageImageList(info->image_info,montage_info,image,exception);
11523 montage_info=DestroyMontageInfo(montage_info);
11524 if (image == (Image *) NULL)
11525 goto PerlException;
11526 if (transparent_color.alpha != TransparentAlpha)
11527 for (next=image; next; next=next->next)
11528 (void) TransparentPaintImage(next,&transparent_color,
11529 TransparentAlpha,MagickFalse,exception);
11530 for ( ; image; image=image->next)
11532 AddImageToRegistry(sv,image);
11534 av_push(av,sv_bless(rv,hv));
11537 exception=DestroyExceptionInfo(exception);
11538 ST(0)=av_reference;
11539 SvREFCNT_dec(perl_exception);
11543 InheritPerlException(exception,perl_exception);
11544 exception=DestroyExceptionInfo(exception);
11545 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11546 SvPOK_on(perl_exception);
11547 ST(0)=sv_2mortal(perl_exception);
11552 ###############################################################################
11560 ###############################################################################
11565 Image::Magick ref=NO_INIT
11603 PERL_UNUSED_VAR(ref);
11604 PERL_UNUSED_VAR(ix);
11605 exception=AcquireExceptionInfo();
11606 perl_exception=newSVpv("",0);
11610 if (sv_isobject(ST(0)) == 0)
11612 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11614 goto PerlException;
11616 reference=SvRV(ST(0));
11617 hv=SvSTASH(reference);
11619 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11621 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11622 if (image == (Image *) NULL)
11624 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11626 goto PerlException;
11628 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11633 for (i=2; i < items; i+=2)
11635 attribute=(char *) SvPV(ST(i-1),na);
11636 switch (*attribute)
11641 if (LocaleCompare(attribute,"frames") == 0)
11643 number_frames=SvIV(ST(i));
11646 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11652 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11658 image=MorphImages(image,number_frames,exception);
11659 if (image == (Image *) NULL)
11660 goto PerlException;
11661 for ( ; image; image=image->next)
11663 AddImageToRegistry(sv,image);
11665 av_push(av,sv_bless(rv,hv));
11668 exception=DestroyExceptionInfo(exception);
11669 ST(0)=av_reference;
11670 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11674 InheritPerlException(exception,perl_exception);
11675 exception=DestroyExceptionInfo(exception);
11676 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11677 SvPOK_on(perl_exception);
11678 ST(0)=sv_2mortal(perl_exception);
11683 ###############################################################################
11691 ###############################################################################
11696 Image::Magick ref=NO_INIT
11724 PERL_UNUSED_VAR(ref);
11725 PERL_UNUSED_VAR(ix);
11726 exception=AcquireExceptionInfo();
11727 perl_exception=newSVpv("",0);
11729 if (sv_isobject(ST(0)) == 0)
11731 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11733 goto PerlException;
11735 reference=SvRV(ST(0));
11736 hv=SvSTASH(reference);
11737 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11738 if (image == (Image *) NULL)
11740 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11742 goto PerlException;
11744 image=MergeImageLayers(image,MosaicLayer,exception);
11746 Create blessed Perl array for the returned image.
11749 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11751 AddImageToRegistry(sv,image);
11753 av_push(av,sv_bless(rv,hv));
11755 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11756 (void) CopyMagickString(info->image_info->filename,image->filename,
11758 SetImageInfo(info->image_info,0,exception);
11759 exception=DestroyExceptionInfo(exception);
11760 SvREFCNT_dec(perl_exception);
11764 InheritPerlException(exception,perl_exception);
11765 exception=DestroyExceptionInfo(exception);
11766 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11767 SvPOK_on(perl_exception); /* return messages in string context */
11768 ST(0)=sv_2mortal(perl_exception);
11773 ###############################################################################
11781 ###############################################################################
11786 Image::Magick ref=NO_INIT
11836 PERL_UNUSED_VAR(ref);
11837 PERL_UNUSED_VAR(ix);
11838 exception=AcquireExceptionInfo();
11839 perl_exception=newSVpv("",0);
11840 package_info=(struct PackageInfo *) NULL;
11841 ac=(items < 2) ? 1 : items-1;
11842 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11844 length=(STRLEN *) NULL;
11845 if (list == (char **) NULL)
11847 ThrowPerlException(exception,ResourceLimitError,
11848 "MemoryAllocationFailed",PackageName);
11849 goto PerlException;
11852 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11853 if (length == (STRLEN *) NULL)
11855 ThrowPerlException(exception,ResourceLimitError,
11856 "MemoryAllocationFailed",PackageName);
11857 goto PerlException;
11859 if (sv_isobject(ST(0)) == 0)
11861 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11863 goto PerlException;
11865 reference=SvRV(ST(0));
11866 if (SvTYPE(reference) != SVt_PVAV)
11868 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11870 goto PerlException;
11872 av=(AV *) reference;
11873 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11875 package_info=ClonePackageInfo(info,exception);
11878 *list=(char *) (*package_info->image_info->filename ?
11879 package_info->image_info->filename : "XC:black");
11881 for (n=0, i=0; i < ac; i++)
11883 list[n]=(char *) SvPV(ST(i+1),length[n]);
11884 if ((items >= 3) && strEQcase(list[n],"blob"))
11890 blob=(void *) (SvPV(ST(i+1),length[n]));
11891 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11893 if ((items >= 3) && strEQcase(list[n],"filename"))
11895 if ((items >= 3) && strEQcase(list[n],"file"))
11904 io_info=IoIFP(sv_2io(ST(i+1)));
11905 if (io_info == (PerlIO *) NULL)
11907 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11911 file=PerlIO_findFILE(io_info);
11912 if (file == (FILE *) NULL)
11914 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11918 SetImageInfoFile(package_info->image_info,file);
11920 if ((items >= 3) && strEQcase(list[n],"magick"))
11924 list[n]=(char *) NULL;
11926 status=ExpandFilenames(&n,&list);
11927 if (status == MagickFalse)
11929 ThrowPerlException(exception,ResourceLimitError,
11930 "MemoryAllocationFailed",PackageName);
11931 goto PerlException;
11934 for (i=0; i < n; i++)
11936 (void) CopyMagickString(package_info->image_info->filename,list[i],
11938 image=PingImage(package_info->image_info,exception);
11939 if (image == (Image *) NULL)
11941 if ((package_info->image_info->file != (FILE *) NULL) ||
11942 (package_info->image_info->blob != (void *) NULL))
11943 DisassociateImageStream(image);
11944 count+=GetImageListLength(image);
11945 EXTEND(sp,4*count);
11946 for (next=image; next; next=next->next)
11948 PUSHs(sv_2mortal(newSViv(next->columns)));
11949 PUSHs(sv_2mortal(newSViv(next->rows)));
11950 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11951 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11953 image=DestroyImageList(image);
11958 for (i=0; i < n; i++)
11959 if (list[i] != (char *) NULL)
11960 for (p=keep; list[i] != *p++; )
11963 list[i]=(char *) RelinquishMagickMemory(list[i]);
11968 if (package_info != (struct PackageInfo *) NULL)
11969 DestroyPackageInfo(package_info);
11970 if (list && (list != keep))
11971 list=(char **) RelinquishMagickMemory(list);
11973 keep=(char **) RelinquishMagickMemory(keep);
11975 length=(STRLEN *) RelinquishMagickMemory(length);
11976 InheritPerlException(exception,perl_exception);
11977 exception=DestroyExceptionInfo(exception);
11978 SvREFCNT_dec(perl_exception); /* throw away all errors */
11982 ###############################################################################
11990 ###############################################################################
11995 Image::Magick ref=NO_INIT
12028 PERL_UNUSED_VAR(ref);
12029 PERL_UNUSED_VAR(ix);
12030 exception=AcquireExceptionInfo();
12031 perl_exception=newSVpv("",0);
12034 if (sv_isobject(ST(0)) == 0)
12036 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12038 goto PerlException;
12040 reference=SvRV(ST(0));
12041 hv=SvSTASH(reference);
12043 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12045 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12046 if (image == (Image *) NULL)
12048 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12050 goto PerlException;
12052 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12053 preview_type=GammaPreview;
12055 preview_type=(PreviewType)
12056 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12057 for ( ; image; image=image->next)
12059 preview_image=PreviewImage(image,preview_type,exception);
12060 if (preview_image == (Image *) NULL)
12061 goto PerlException;
12062 AddImageToRegistry(sv,preview_image);
12064 av_push(av,sv_bless(rv,hv));
12067 exception=DestroyExceptionInfo(exception);
12068 ST(0)=av_reference;
12069 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12073 InheritPerlException(exception,perl_exception);
12074 exception=DestroyExceptionInfo(exception);
12075 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12076 SvPOK_on(perl_exception);
12077 ST(0)=sv_2mortal(perl_exception);
12082 ###############################################################################
12086 # Q u e r y C o l o r #
12090 ###############################################################################
12094 QueryColor(ref,...)
12095 Image::Magick ref=NO_INIT
12115 PERL_UNUSED_VAR(ref);
12116 PERL_UNUSED_VAR(ix);
12117 exception=AcquireExceptionInfo();
12118 perl_exception=newSVpv("",0);
12127 colorlist=GetColorInfoList("*",&colors,exception);
12129 for (i=0; i < (ssize_t) colors; i++)
12131 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12133 colorlist=(const ColorInfo **)
12134 RelinquishMagickMemory((ColorInfo **) colorlist);
12135 goto PerlException;
12137 EXTEND(sp,5*items);
12138 for (i=1; i < items; i++)
12140 name=(char *) SvPV(ST(i),na);
12141 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12146 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12147 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12148 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12149 if (color.colorspace == CMYKColorspace)
12150 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12151 if (color.alpha_trait == BlendPixelTrait)
12152 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12156 InheritPerlException(exception,perl_exception);
12157 exception=DestroyExceptionInfo(exception);
12158 SvREFCNT_dec(perl_exception);
12162 ###############################################################################
12166 # Q u e r y C o l o r N a m e #
12170 ###############################################################################
12174 QueryColorname(ref,...)
12175 Image::Magick ref=NO_INIT
12184 message[MaxTextExtent];
12203 *reference; /* reference is the SV* of ref=SvIV(reference) */
12205 PERL_UNUSED_VAR(ref);
12206 PERL_UNUSED_VAR(ix);
12207 exception=AcquireExceptionInfo();
12208 perl_exception=newSVpv("",0);
12209 reference=SvRV(ST(0));
12210 av=(AV *) reference;
12211 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12213 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12214 if (image == (Image *) NULL)
12216 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12218 goto PerlException;
12221 for (i=1; i < items; i++)
12223 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12225 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12227 PUSHs(sv_2mortal(newSVpv(message,0)));
12231 InheritPerlException(exception,perl_exception);
12232 exception=DestroyExceptionInfo(exception);
12233 SvREFCNT_dec(perl_exception);
12237 ###############################################################################
12241 # Q u e r y F o n t #
12245 ###############################################################################
12250 Image::Magick ref=NO_INIT
12257 message[MaxTextExtent];
12268 volatile const TypeInfo
12271 PERL_UNUSED_VAR(ref);
12272 PERL_UNUSED_VAR(ix);
12273 exception=AcquireExceptionInfo();
12274 perl_exception=newSVpv("",0);
12283 typelist=GetTypeInfoList("*",&types,exception);
12285 for (i=0; i < (ssize_t) types; i++)
12287 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12289 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12291 goto PerlException;
12293 EXTEND(sp,10*items);
12294 for (i=1; i < items; i++)
12296 name=(char *) SvPV(ST(i),na);
12297 type_info=GetTypeInfo(name,exception);
12298 if (type_info == (TypeInfo *) NULL)
12303 if (type_info->name == (char *) NULL)
12306 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12307 if (type_info->description == (char *) NULL)
12310 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12311 if (type_info->family == (char *) NULL)
12314 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12315 if (type_info->style == UndefinedStyle)
12318 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12319 type_info->style),0)));
12320 if (type_info->stretch == UndefinedStretch)
12323 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12324 type_info->stretch),0)));
12325 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12326 type_info->weight);
12327 PUSHs(sv_2mortal(newSVpv(message,0)));
12328 if (type_info->encoding == (char *) NULL)
12331 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12332 if (type_info->foundry == (char *) NULL)
12335 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12336 if (type_info->format == (char *) NULL)
12339 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12340 if (type_info->metrics == (char *) NULL)
12343 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12344 if (type_info->glyphs == (char *) NULL)
12347 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12351 InheritPerlException(exception,perl_exception);
12352 exception=DestroyExceptionInfo(exception);
12353 SvREFCNT_dec(perl_exception);
12357 ###############################################################################
12361 # Q u e r y F o n t M e t r i c s #
12365 ###############################################################################
12369 QueryFontMetrics(ref,...)
12370 Image::Magick ref=NO_INIT
12372 queryfontmetrics = 1
12419 *reference; /* reference is the SV* of ref=SvIV(reference) */
12424 PERL_UNUSED_VAR(ref);
12425 PERL_UNUSED_VAR(ix);
12426 exception=AcquireExceptionInfo();
12427 package_info=(struct PackageInfo *) NULL;
12428 perl_exception=newSVpv("",0);
12429 reference=SvRV(ST(0));
12430 av=(AV *) reference;
12431 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12433 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12434 if (image == (Image *) NULL)
12436 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12438 goto PerlException;
12440 package_info=ClonePackageInfo(info,exception);
12441 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12442 CloneString(&draw_info->text,"");
12443 current=draw_info->affine;
12444 GetAffineMatrix(&affine);
12447 EXTEND(sp,7*items);
12448 for (i=2; i < items; i+=2)
12450 attribute=(char *) SvPV(ST(i-1),na);
12451 switch (*attribute)
12456 if (LocaleCompare(attribute,"antialias") == 0)
12458 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12462 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12466 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12469 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12476 if (LocaleCompare(attribute,"density") == 0)
12478 CloneString(&draw_info->density,SvPV(ST(i),na));
12481 if (LocaleCompare(attribute,"direction") == 0)
12483 draw_info->direction=(DirectionType) ParseCommandOption(
12484 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12487 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12494 if (LocaleCompare(attribute,"encoding") == 0)
12496 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12499 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12506 if (LocaleCompare(attribute,"family") == 0)
12508 CloneString(&draw_info->family,SvPV(ST(i),na));
12511 if (LocaleCompare(attribute,"fill") == 0)
12514 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12515 &draw_info->fill,exception);
12518 if (LocaleCompare(attribute,"font") == 0)
12520 CloneString(&draw_info->font,SvPV(ST(i),na));
12523 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12530 if (LocaleCompare(attribute,"geometry") == 0)
12532 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12535 if (LocaleCompare(attribute,"gravity") == 0)
12537 draw_info->gravity=(GravityType) ParseCommandOption(
12538 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12548 if (LocaleCompare(attribute,"interline-spacing") == 0)
12550 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12551 draw_info->interline_spacing=geometry_info.rho;
12554 if (LocaleCompare(attribute,"interword-spacing") == 0)
12556 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12557 draw_info->interword_spacing=geometry_info.rho;
12560 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12567 if (LocaleCompare(attribute,"kerning") == 0)
12569 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12570 draw_info->kerning=geometry_info.rho;
12573 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12580 if (LocaleCompare(attribute,"pointsize") == 0)
12582 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12583 draw_info->pointsize=geometry_info.rho;
12586 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12593 if (LocaleCompare(attribute,"rotate") == 0)
12595 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12596 affine.rx=geometry_info.rho;
12597 affine.ry=geometry_info.sigma;
12598 if ((flags & SigmaValue) == 0)
12599 affine.ry=affine.rx;
12602 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12609 if (LocaleCompare(attribute,"scale") == 0)
12611 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12612 affine.sx=geometry_info.rho;
12613 affine.sy=geometry_info.sigma;
12614 if ((flags & SigmaValue) == 0)
12615 affine.sy=affine.sx;
12618 if (LocaleCompare(attribute,"skew") == 0)
12624 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12625 x_angle=geometry_info.rho;
12626 y_angle=geometry_info.sigma;
12627 if ((flags & SigmaValue) == 0)
12629 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12630 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12633 if (LocaleCompare(attribute,"stroke") == 0)
12636 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12637 &draw_info->stroke,exception);
12640 if (LocaleCompare(attribute,"style") == 0)
12642 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12646 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12650 draw_info->style=(StyleType) type;
12653 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12660 if (LocaleCompare(attribute,"text") == 0)
12662 CloneString(&draw_info->text,SvPV(ST(i),na));
12665 if (LocaleCompare(attribute,"translate") == 0)
12667 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12668 affine.tx=geometry_info.rho;
12669 affine.ty=geometry_info.sigma;
12670 if ((flags & SigmaValue) == 0)
12671 affine.ty=affine.tx;
12674 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12681 if (LocaleCompare(attribute,"weight") == 0)
12683 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12684 draw_info->weight=(size_t) geometry_info.rho;
12687 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12694 if (LocaleCompare(attribute,"x") == 0)
12696 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12697 x=geometry_info.rho;
12700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12707 if (LocaleCompare(attribute,"y") == 0)
12709 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12710 y=geometry_info.rho;
12713 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12719 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12725 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12726 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12727 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12728 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12729 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12730 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12731 if (draw_info->geometry == (char *) NULL)
12733 draw_info->geometry=AcquireString((char *) NULL);
12734 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12735 "%.15g,%.15g",x,y);
12737 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12738 (void) CatchImageException(image);
12739 if (status == MagickFalse)
12743 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12744 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12745 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12746 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12747 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12748 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12749 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12750 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12751 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12752 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12753 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12754 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12755 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12757 draw_info=DestroyDrawInfo(draw_info);
12760 if (package_info != (struct PackageInfo *) NULL)
12761 DestroyPackageInfo(package_info);
12762 InheritPerlException(exception,perl_exception);
12763 exception=DestroyExceptionInfo(exception);
12764 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12768 ###############################################################################
12772 # 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 #
12776 ###############################################################################
12780 QueryMultilineFontMetrics(ref,...)
12781 Image::Magick ref=NO_INIT
12783 querymultilinefontmetrics = 1
12830 *reference; /* reference is the SV* of ref=SvIV(reference) */
12835 PERL_UNUSED_VAR(ref);
12836 PERL_UNUSED_VAR(ix);
12837 exception=AcquireExceptionInfo();
12838 package_info=(struct PackageInfo *) NULL;
12839 perl_exception=newSVpv("",0);
12840 reference=SvRV(ST(0));
12841 av=(AV *) reference;
12842 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12844 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12845 if (image == (Image *) NULL)
12847 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12849 goto PerlException;
12851 package_info=ClonePackageInfo(info,exception);
12852 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12853 CloneString(&draw_info->text,"");
12854 current=draw_info->affine;
12855 GetAffineMatrix(&affine);
12858 EXTEND(sp,7*items);
12859 for (i=2; i < items; i+=2)
12861 attribute=(char *) SvPV(ST(i-1),na);
12862 switch (*attribute)
12867 if (LocaleCompare(attribute,"antialias") == 0)
12869 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12873 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12877 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12880 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12887 if (LocaleCompare(attribute,"density") == 0)
12889 CloneString(&draw_info->density,SvPV(ST(i),na));
12892 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12899 if (LocaleCompare(attribute,"encoding") == 0)
12901 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12904 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12911 if (LocaleCompare(attribute,"family") == 0)
12913 CloneString(&draw_info->family,SvPV(ST(i),na));
12916 if (LocaleCompare(attribute,"fill") == 0)
12919 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12920 &draw_info->fill,exception);
12923 if (LocaleCompare(attribute,"font") == 0)
12925 CloneString(&draw_info->font,SvPV(ST(i),na));
12928 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12935 if (LocaleCompare(attribute,"geometry") == 0)
12937 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12940 if (LocaleCompare(attribute,"gravity") == 0)
12942 draw_info->gravity=(GravityType) ParseCommandOption(
12943 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12946 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12953 if (LocaleCompare(attribute,"pointsize") == 0)
12955 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12956 draw_info->pointsize=geometry_info.rho;
12959 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12966 if (LocaleCompare(attribute,"rotate") == 0)
12968 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12969 affine.rx=geometry_info.rho;
12970 affine.ry=geometry_info.sigma;
12971 if ((flags & SigmaValue) == 0)
12972 affine.ry=affine.rx;
12975 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12982 if (LocaleCompare(attribute,"scale") == 0)
12984 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12985 affine.sx=geometry_info.rho;
12986 affine.sy=geometry_info.sigma;
12987 if ((flags & SigmaValue) == 0)
12988 affine.sy=affine.sx;
12991 if (LocaleCompare(attribute,"skew") == 0)
12997 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12998 x_angle=geometry_info.rho;
12999 y_angle=geometry_info.sigma;
13000 if ((flags & SigmaValue) == 0)
13002 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13003 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13006 if (LocaleCompare(attribute,"stroke") == 0)
13009 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13010 &draw_info->stroke,exception);
13013 if (LocaleCompare(attribute,"style") == 0)
13015 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13019 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13023 draw_info->style=(StyleType) type;
13026 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13033 if (LocaleCompare(attribute,"text") == 0)
13035 CloneString(&draw_info->text,SvPV(ST(i),na));
13038 if (LocaleCompare(attribute,"translate") == 0)
13040 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13041 affine.tx=geometry_info.rho;
13042 affine.ty=geometry_info.sigma;
13043 if ((flags & SigmaValue) == 0)
13044 affine.ty=affine.tx;
13047 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13054 if (LocaleCompare(attribute,"weight") == 0)
13056 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13057 draw_info->weight=(size_t) geometry_info.rho;
13060 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13067 if (LocaleCompare(attribute,"x") == 0)
13069 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13070 x=geometry_info.rho;
13073 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13080 if (LocaleCompare(attribute,"y") == 0)
13082 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13083 y=geometry_info.rho;
13086 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13092 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13098 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13099 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13100 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13101 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13102 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13103 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13104 if (draw_info->geometry == (char *) NULL)
13106 draw_info->geometry=AcquireString((char *) NULL);
13107 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
13108 "%.15g,%.15g",x,y);
13110 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13111 (void) CatchException(exception);
13112 if (status == MagickFalse)
13116 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13117 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13118 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13119 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13120 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13121 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13122 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13123 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13124 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13125 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13126 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13127 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13128 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13130 draw_info=DestroyDrawInfo(draw_info);
13133 if (package_info != (struct PackageInfo *) NULL)
13134 DestroyPackageInfo(package_info);
13135 InheritPerlException(exception,perl_exception);
13136 exception=DestroyExceptionInfo(exception);
13137 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13141 ###############################################################################
13145 # Q u e r y F o r m a t #
13149 ###############################################################################
13153 QueryFormat(ref,...)
13154 Image::Magick ref=NO_INIT
13171 volatile const MagickInfo
13174 PERL_UNUSED_VAR(ref);
13175 PERL_UNUSED_VAR(ix);
13176 exception=AcquireExceptionInfo();
13177 perl_exception=newSVpv("",0);
13181 format[MaxTextExtent];
13189 format_list=GetMagickInfoList("*",&types,exception);
13191 for (i=0; i < (ssize_t) types; i++)
13193 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13194 LocaleLower(format);
13195 PUSHs(sv_2mortal(newSVpv(format,0)));
13197 format_list=(const MagickInfo **)
13198 RelinquishMagickMemory((MagickInfo *) format_list);
13199 goto PerlException;
13201 EXTEND(sp,8*items);
13202 for (i=1; i < items; i++)
13204 name=(char *) SvPV(ST(i),na);
13205 magick_info=GetMagickInfo(name,exception);
13206 if (magick_info == (const MagickInfo *) NULL)
13211 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13212 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13213 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13214 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13215 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13216 if (magick_info->description == (char *) NULL)
13219 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13220 if (magick_info->module == (char *) NULL)
13223 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13227 InheritPerlException(exception,perl_exception);
13228 exception=DestroyExceptionInfo(exception);
13229 SvREFCNT_dec(perl_exception);
13233 ###############################################################################
13237 # Q u e r y O p t i o n #
13241 ###############################################################################
13245 QueryOption(ref,...)
13246 Image::Magick ref=NO_INIT
13267 PERL_UNUSED_VAR(ref);
13268 PERL_UNUSED_VAR(ix);
13269 exception=AcquireExceptionInfo();
13270 perl_exception=newSVpv("",0);
13271 EXTEND(sp,8*items);
13272 for (i=1; i < items; i++)
13274 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13276 options=GetCommandOptions((CommandOption) option);
13277 if (options == (char **) NULL)
13281 for (j=0; options[j] != (char *) NULL; j++)
13282 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13283 options=DestroyStringList(options);
13287 InheritPerlException(exception,perl_exception);
13288 exception=DestroyExceptionInfo(exception);
13289 SvREFCNT_dec(perl_exception);
13293 ###############################################################################
13301 ###############################################################################
13306 Image::Magick ref=NO_INIT
13353 *perl_exception, /* Perl variable for storing messages */
13358 PERL_UNUSED_VAR(ref);
13359 PERL_UNUSED_VAR(ix);
13360 exception=AcquireExceptionInfo();
13361 perl_exception=newSVpv("",0);
13363 package_info=(struct PackageInfo *) NULL;
13365 ac=(items < 2) ? 1 : items-1;
13366 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13368 length=(STRLEN *) NULL;
13369 if (list == (char **) NULL)
13371 ThrowPerlException(exception,ResourceLimitError,
13372 "MemoryAllocationFailed",PackageName);
13373 goto PerlException;
13375 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13376 if (length == (STRLEN *) NULL)
13378 ThrowPerlException(exception,ResourceLimitError,
13379 "MemoryAllocationFailed",PackageName);
13380 goto PerlException;
13382 if (sv_isobject(ST(0)) == 0)
13384 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13386 goto PerlException;
13388 reference=SvRV(ST(0));
13389 hv=SvSTASH(reference);
13390 if (SvTYPE(reference) != SVt_PVAV)
13392 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13394 goto PerlException;
13396 av=(AV *) reference;
13397 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13399 package_info=ClonePackageInfo(info,exception);
13402 *list=(char *) (*package_info->image_info->filename ?
13403 package_info->image_info->filename : "XC:black");
13405 for (n=0, i=0; i < ac; i++)
13407 list[n]=(char *) SvPV(ST(i+1),length[n]);
13408 if ((items >= 3) && strEQcase(list[n],"blob"))
13414 blob=(void *) (SvPV(ST(i+1),length[n]));
13415 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13417 if ((items >= 3) && strEQcase(list[n],"filename"))
13419 if ((items >= 3) && strEQcase(list[n],"file"))
13428 io_info=IoIFP(sv_2io(ST(i+1)));
13429 if (io_info == (PerlIO *) NULL)
13431 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13435 file=PerlIO_findFILE(io_info);
13436 if (file == (FILE *) NULL)
13438 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13442 SetImageInfoFile(package_info->image_info,file);
13444 if ((items >= 3) && strEQcase(list[n],"magick"))
13448 list[n]=(char *) NULL;
13450 status=ExpandFilenames(&n,&list);
13451 if (status == MagickFalse)
13453 ThrowPerlException(exception,ResourceLimitError,
13454 "MemoryAllocationFailed",PackageName);
13455 goto PerlException;
13458 for (i=0; i < n; i++)
13460 if ((package_info->image_info->file == (FILE *) NULL) &&
13461 (package_info->image_info->blob == (void *) NULL))
13462 image=ReadImages(package_info->image_info,list[i],exception);
13465 image=ReadImages(package_info->image_info,
13466 package_info->image_info->filename,exception);
13467 if (image != (Image *) NULL)
13468 DisassociateImageStream(image);
13470 if (image == (Image *) NULL)
13472 for ( ; image; image=image->next)
13474 AddImageToRegistry(sv,image);
13476 av_push(av,sv_bless(rv,hv));
13484 for (i=0; i < n; i++)
13485 if (list[i] != (char *) NULL)
13486 for (p=keep; list[i] != *p++; )
13487 if (*p == (char *) NULL)
13489 list[i]=(char *) RelinquishMagickMemory(list[i]);
13494 if (package_info != (struct PackageInfo *) NULL)
13495 DestroyPackageInfo(package_info);
13496 if (list && (list != keep))
13497 list=(char **) RelinquishMagickMemory(list);
13499 keep=(char **) RelinquishMagickMemory(keep);
13501 length=(STRLEN *) RelinquishMagickMemory(length);
13502 InheritPerlException(exception,perl_exception);
13503 exception=DestroyExceptionInfo(exception);
13504 sv_setiv(perl_exception,(IV) number_images);
13505 SvPOK_on(perl_exception);
13506 ST(0)=sv_2mortal(perl_exception);
13511 ###############################################################################
13519 ###############################################################################
13524 Image::Magick ref=NO_INIT
13547 PERL_UNUSED_VAR(ref);
13548 PERL_UNUSED_VAR(ix);
13549 exception=AcquireExceptionInfo();
13550 perl_exception=newSVpv("",0);
13551 reference=SvRV(ST(0));
13552 av=(AV *) reference;
13553 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13555 for (i=1; i < items; i++)
13556 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13557 SvPV(ST(i),na),exception);
13558 InheritPerlException(exception,perl_exception);
13559 exception=DestroyExceptionInfo(exception);
13560 SvREFCNT_dec(perl_exception); /* throw away all errors */
13564 ###############################################################################
13572 ###############################################################################
13577 Image::Magick ref=NO_INIT
13600 *reference; /* reference is the SV* of ref=SvIV(reference) */
13602 PERL_UNUSED_VAR(ref);
13603 PERL_UNUSED_VAR(ix);
13604 exception=AcquireExceptionInfo();
13605 perl_exception=newSVpv("",0);
13606 if (sv_isobject(ST(0)) == 0)
13608 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13610 goto PerlException;
13612 reference=SvRV(ST(0));
13613 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13615 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13617 for (i=2; i < items; i+=2)
13618 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13621 InheritPerlException(exception,perl_exception);
13622 exception=DestroyExceptionInfo(exception);
13623 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13624 SvPOK_on(perl_exception);
13625 ST(0)=sv_2mortal(perl_exception);
13630 ###############################################################################
13634 # S e t P i x e l #
13638 ###############################################################################
13643 Image::Magick ref=NO_INIT
13685 *reference; /* reference is the SV* of ref=SvIV(reference) */
13687 PERL_UNUSED_VAR(ref);
13688 PERL_UNUSED_VAR(ix);
13689 exception=AcquireExceptionInfo();
13690 perl_exception=newSVpv("",0);
13691 reference=SvRV(ST(0));
13692 av=(AV *) reference;
13693 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13695 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13696 if (image == (Image *) NULL)
13698 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13700 goto PerlException;
13703 normalize=MagickTrue;
13706 region.width=image->columns;
13709 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13710 channel=DefaultChannels;
13711 for (i=2; i < items; i+=2)
13713 attribute=(char *) SvPV(ST(i-1),na);
13714 switch (*attribute)
13719 if (LocaleCompare(attribute,"channel") == 0)
13724 option=ParseChannelOption(SvPV(ST(i),na));
13727 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13731 channel=(ChannelType) option;
13734 if (LocaleCompare(attribute,"color") == 0)
13736 if (SvTYPE(ST(i)) != SVt_RV)
13739 message[MaxTextExtent];
13741 (void) FormatLocaleString(message,MaxTextExtent,
13742 "invalid %.60s value",attribute);
13743 ThrowPerlException(exception,OptionError,message,
13746 av=(AV *) SvRV(ST(i));
13749 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13756 if (LocaleCompare(attribute,"geometry") == 0)
13758 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13761 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13768 if (LocaleCompare(attribute,"normalize") == 0)
13770 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13774 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13778 normalize=option != 0 ? MagickTrue : MagickFalse;
13781 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13788 if (LocaleCompare(attribute,"x") == 0)
13790 region.x=SvIV(ST(i));
13793 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13800 if (LocaleCompare(attribute,"y") == 0)
13802 region.y=SvIV(ST(i));
13805 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13811 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13817 (void) SetImageStorageClass(image,DirectClass,exception);
13818 channel_mask=SetImageChannelMask(image,channel);
13819 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13820 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13821 (SvTYPE(av) != SVt_PVAV))
13833 if (normalize != MagickFalse)
13834 scale=QuantumRange;
13835 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13838 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13839 av_fetch(av,i,0)))),q);
13842 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13845 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13846 av_fetch(av,i,0)))),q);
13849 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13852 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13853 av_fetch(av,i,0)))),q);
13856 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13857 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13859 SetPixelBlack(image,ClampToQuantum(scale*
13860 SvNV(*(av_fetch(av,i,0)))),q);
13863 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13866 SetPixelAlpha(image,ClampToQuantum(scale*
13867 SvNV(*(av_fetch(av,i,0)))),q);
13870 (void) SyncAuthenticPixels(image,exception);
13872 (void) SetImageChannelMask(image,channel_mask);
13875 InheritPerlException(exception,perl_exception);
13876 exception=DestroyExceptionInfo(exception);
13877 SvREFCNT_dec(perl_exception);
13881 ###############################################################################
13889 ###############################################################################
13894 Image::Magick ref=NO_INIT
13933 PERL_UNUSED_VAR(ref);
13934 PERL_UNUSED_VAR(ix);
13935 exception=AcquireExceptionInfo();
13936 perl_exception=newSVpv("",0);
13940 if (sv_isobject(ST(0)) == 0)
13942 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13944 goto PerlException;
13946 reference=SvRV(ST(0));
13947 hv=SvSTASH(reference);
13949 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13951 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13952 if (image == (Image *) NULL)
13954 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13956 goto PerlException;
13958 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13964 for (i=2; i < items; i+=2)
13966 attribute=(char *) SvPV(ST(i-1),na);
13967 switch (*attribute)
13972 if (LocaleCompare(attribute,"offset") == 0)
13974 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13977 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13984 if (LocaleCompare(attribute,"stack") == 0)
13986 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13990 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13996 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14002 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14008 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14010 if (image == (Image *) NULL)
14011 goto PerlException;
14012 for ( ; image; image=image->next)
14014 AddImageToRegistry(sv,image);
14016 av_push(av,sv_bless(rv,hv));
14019 exception=DestroyExceptionInfo(exception);
14020 ST(0)=av_reference;
14021 SvREFCNT_dec(perl_exception);
14025 InheritPerlException(exception,perl_exception);
14026 exception=DestroyExceptionInfo(exception);
14027 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14028 SvPOK_on(perl_exception);
14029 ST(0)=sv_2mortal(perl_exception);
14034 ###############################################################################
14038 # S t a t i s t i c s #
14042 ###############################################################################
14046 Statistics(ref,...)
14047 Image::Magick ref=NO_INIT
14049 StatisticsImage = 1
14051 statisticsimage = 3
14054 #define ChannelStatistics(channel) \
14056 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
14057 (double) channel_statistics[channel].depth); \
14058 PUSHs(sv_2mortal(newSVpv(message,0))); \
14059 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14060 channel_statistics[channel].minima/scale); \
14061 PUSHs(sv_2mortal(newSVpv(message,0))); \
14062 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14063 channel_statistics[channel].maxima/scale); \
14064 PUSHs(sv_2mortal(newSVpv(message,0))); \
14065 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14066 channel_statistics[channel].mean/scale); \
14067 PUSHs(sv_2mortal(newSVpv(message,0))); \
14068 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14069 channel_statistics[channel].standard_deviation/scale); \
14070 PUSHs(sv_2mortal(newSVpv(message,0))); \
14071 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14072 channel_statistics[channel].kurtosis); \
14073 PUSHs(sv_2mortal(newSVpv(message,0))); \
14074 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14075 channel_statistics[channel].skewness); \
14076 PUSHs(sv_2mortal(newSVpv(message,0))); \
14083 message[MaxTextExtent];
14086 *channel_statistics;
14107 PERL_UNUSED_VAR(ref);
14108 PERL_UNUSED_VAR(ix);
14109 exception=AcquireExceptionInfo();
14110 perl_exception=newSVpv("",0);
14112 if (sv_isobject(ST(0)) == 0)
14114 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14116 goto PerlException;
14118 reference=SvRV(ST(0));
14121 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14122 if (image == (Image *) NULL)
14124 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14126 goto PerlException;
14128 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14130 for ( ; image; image=image->next)
14132 channel_statistics=GetImageStatistics(image,exception);
14133 if (channel_statistics == (ChannelStatistics *) NULL)
14136 EXTEND(sp,35*count);
14137 scale=(double) QuantumRange;
14138 ChannelStatistics(RedChannel);
14139 ChannelStatistics(GreenChannel);
14140 ChannelStatistics(BlueChannel);
14141 if (image->colorspace == CMYKColorspace)
14142 ChannelStatistics(BlackChannel);
14143 if (image->alpha_trait == BlendPixelTrait)
14144 ChannelStatistics(AlphaChannel);
14145 channel_statistics=(ChannelStatistics *)
14146 RelinquishMagickMemory(channel_statistics);
14150 InheritPerlException(exception,perl_exception);
14151 exception=DestroyExceptionInfo(exception);
14152 SvREFCNT_dec(perl_exception);
14156 ###############################################################################
14160 # S y n c A u t h e n t i c P i x e l s #
14164 ###############################################################################
14168 SyncAuthenticPixels(ref,...)
14169 Image::Magick ref = NO_INIT
14171 Syncauthenticpixels = 1
14172 SyncImagePixels = 2
14173 syncimagepixels = 3
14192 PERL_UNUSED_VAR(ref);
14193 PERL_UNUSED_VAR(ix);
14194 exception=AcquireExceptionInfo();
14195 perl_exception=newSVpv("",0);
14196 if (sv_isobject(ST(0)) == 0)
14198 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14200 goto PerlException;
14203 reference=SvRV(ST(0));
14204 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14205 if (image == (Image *) NULL)
14207 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14209 goto PerlException;
14212 status=SyncAuthenticPixels(image,exception);
14213 if (status != MagickFalse)
14217 InheritPerlException(exception,perl_exception);
14218 exception=DestroyExceptionInfo(exception);
14219 SvREFCNT_dec(perl_exception); /* throw away all errors */
14223 ###############################################################################
14227 # T r a n s f o r m #
14231 ###############################################################################
14236 Image::Magick ref=NO_INIT
14274 PERL_UNUSED_VAR(ref);
14275 PERL_UNUSED_VAR(ix);
14276 exception=AcquireExceptionInfo();
14277 perl_exception=newSVpv("",0);
14281 if (sv_isobject(ST(0)) == 0)
14283 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14285 goto PerlException;
14287 reference=SvRV(ST(0));
14288 hv=SvSTASH(reference);
14290 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14292 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14293 if (image == (Image *) NULL)
14295 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14297 goto PerlException;
14299 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14303 crop_geometry=(char *) NULL;
14304 geometry=(char *) NULL;
14305 for (i=2; i < items; i+=2)
14307 attribute=(char *) SvPV(ST(i-1),na);
14308 switch (*attribute)
14313 if (LocaleCompare(attribute,"crop") == 0)
14315 crop_geometry=SvPV(ST(i),na);
14318 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14325 if (LocaleCompare(attribute,"geometry") == 0)
14327 geometry=SvPV(ST(i),na);
14330 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14336 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14342 for ( ; image; image=image->next)
14344 clone=CloneImage(image,0,0,MagickTrue,exception);
14345 if (clone == (Image *) NULL)
14346 goto PerlException;
14347 TransformImage(&clone,crop_geometry,geometry,exception);
14348 for ( ; clone; clone=clone->next)
14350 AddImageToRegistry(sv,clone);
14352 av_push(av,sv_bless(rv,hv));
14356 exception=DestroyExceptionInfo(exception);
14357 ST(0)=av_reference;
14358 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14362 InheritPerlException(exception,perl_exception);
14363 exception=DestroyExceptionInfo(exception);
14364 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14365 SvPOK_on(perl_exception);
14366 ST(0)=sv_2mortal(perl_exception);
14371 ###############################################################################
14379 ###############################################################################
14384 Image::Magick ref=NO_INIT
14392 filename[MaxTextExtent];
14416 PERL_UNUSED_VAR(ref);
14417 PERL_UNUSED_VAR(ix);
14418 exception=AcquireExceptionInfo();
14419 perl_exception=newSVpv("",0);
14421 package_info=(struct PackageInfo *) NULL;
14422 if (sv_isobject(ST(0)) == 0)
14424 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14426 goto PerlException;
14428 reference=SvRV(ST(0));
14429 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14430 if (image == (Image *) NULL)
14432 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14434 goto PerlException;
14436 package_info=ClonePackageInfo(info,exception);
14438 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14441 for (i=2; i < items; i+=2)
14442 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14444 (void) CopyMagickString(filename,package_info->image_info->filename,
14447 for (next=image; next; next=next->next)
14449 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14450 next->scene=scene++;
14452 SetImageInfo(package_info->image_info,(unsigned int)
14453 GetImageListLength(image),exception);
14454 for (next=image; next; next=next->next)
14456 (void) WriteImage(package_info->image_info,next,exception);
14458 if (package_info->image_info->adjoin)
14463 if (package_info != (struct PackageInfo *) NULL)
14464 DestroyPackageInfo(package_info);
14465 InheritPerlException(exception,perl_exception);
14466 exception=DestroyExceptionInfo(exception);
14467 sv_setiv(perl_exception,(IV) number_images);
14468 SvPOK_on(perl_exception);
14469 ST(0)=sv_2mortal(perl_exception);