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 MagickPI 3.14159265358979323846264338327950288419716939937510
78 #define MaxArguments 33
82 #define NumberOf(array) (sizeof(array)/sizeof(*array))
83 #define PackageName "Image::Magick"
86 #define PerlIO_importFILE(f, fl) (f)
87 #define PerlIO_findFILE(f) NULL
90 #define sv_undef PL_sv_undef
93 #define AddImageToRegistry(sv,image) \
95 if (magick_registry != (SplayTreeInfo *) NULL) \
97 (void) AddValueToSplayTree(magick_registry,image,image); \
98 (sv)=newSViv(PTR2IV(image)); \
102 #define DeleteImageFromRegistry(reference,image) \
104 if (magick_registry != (SplayTreeInfo *) NULL) \
106 if (GetImageReferenceCount(image) == 1) \
107 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
108 image=DestroyImage(image); \
109 sv_setiv(reference,0); \
113 #define InheritPerlException(exception,perl_exception) \
116 message[MaxTextExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
121 (exception)->severity, (exception)->reason ? \
122 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
123 "Unknown", (exception)->description ? " (" : "", \
124 (exception)->description ? GetLocaleExceptionMessage( \
125 (exception)->severity,(exception)->description) : "", \
126 (exception)->description ? ")" : ""); \
127 if ((perl_exception) != (SV *) NULL) \
129 if (SvCUR(perl_exception)) \
130 sv_catpv(perl_exception,"\n"); \
131 sv_catpv(perl_exception,message); \
136 #define ThrowPerlException(exception,severity,tag,reason) \
137 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
138 tag,"`%s'",reason); \
141 Typedef and structure declarations.
145 ArrayReference = (~0),
146 RealReference = (~0)-1,
147 FileReference = (~0)-2,
148 ImageReference = (~0)-3,
149 IntegerReference = (~0)-4,
150 StringReference = (~0)-5
153 typedef struct _Arguments
193 *Image__Magick; /* data type for the Image::Magick package */
205 arguments[MaxArguments];
208 { "Comment", { {"comment", StringReference} } },
209 { "Label", { {"label", StringReference} } },
210 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
211 {"channel", MagickChannelOptions} } },
212 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
213 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
214 {"height", IntegerReference}, {"fill", StringReference},
215 {"bordercolor", StringReference}, {"color", StringReference},
216 {"compose", MagickComposeOptions} } },
217 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
218 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference}, {"gravity", MagickGravityOptions} } },
222 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference}, {"fuzz", StringReference},
225 {"gravity", MagickGravityOptions} } },
227 { "Edge", { {"radius", RealReference} } },
228 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
229 {"sigma", RealReference} } },
233 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
234 {"height", IntegerReference}, {"inner", IntegerReference},
235 {"outer", IntegerReference}, {"fill", StringReference},
236 {"color", StringReference}, {"compose", MagickComposeOptions} } },
237 { "Implode", { {"amount", RealReference},
238 {"interpolate", MagickInterpolateOptions} } },
240 { "MedianFilter", { {"geometry", StringReference},
241 {"width", IntegerReference}, {"height", IntegerReference},
242 {"channel", MagickChannelOptions} } },
244 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
245 { "ReduceNoise", { {"geometry", StringReference},
246 {"width", IntegerReference},{"height", IntegerReference},
247 {"channel", MagickChannelOptions} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference},
251 {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
260 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
261 {"y", RealReference}, { "fill", StringReference},
262 {"color", StringReference} } },
263 { "Spread", { {"radius", RealReference},
264 {"interpolate", MagickInterpolateOptions} } },
265 { "Swirl", { {"degrees", RealReference},
266 {"interpolate", MagickInterpolateOptions} } },
267 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
268 {"height", IntegerReference}, {"filter", MagickFilterOptions},
269 {"support", StringReference } } },
270 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
271 {"height", IntegerReference}, {"filter", MagickFilterOptions},
272 {"support", RealReference } } },
273 { "Annotate", { {"text", StringReference}, {"font", StringReference},
274 {"pointsize", RealReference}, {"density", StringReference},
275 {"undercolor", StringReference}, {"stroke", StringReference},
276 {"fill", StringReference}, {"geometry", StringReference},
277 {"sans", StringReference}, {"x", RealReference},
278 {"y", RealReference}, {"gravity", MagickGravityOptions},
279 {"translate", StringReference}, {"scale", StringReference},
280 {"rotate", RealReference}, {"skewX", RealReference},
281 {"skewY", RealReference}, {"strokewidth", RealReference},
282 {"antialias", MagickBooleanOptions}, {"family", StringReference},
283 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
284 {"weight", IntegerReference}, {"align", MagickAlignOptions},
285 {"encoding", StringReference}, {"affine", ArrayReference},
286 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
287 {"tile", ImageReference}, {"kerning", RealReference},
288 {"interline-spacing", RealReference},
289 {"interword-spacing", RealReference},
290 {"direction", MagickDirectionOptions} } },
291 { "ColorFloodfill", { {"geometry", StringReference},
292 {"x", IntegerReference}, {"y", IntegerReference},
293 {"fill", StringReference}, {"bordercolor", StringReference},
294 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
295 { "Composite", { {"image", ImageReference},
296 {"compose", MagickComposeOptions}, {"geometry", StringReference},
297 {"x", IntegerReference}, {"y", IntegerReference},
298 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
299 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
300 {"color", StringReference}, {"mask", ImageReference},
301 {"channel", MagickChannelOptions},
302 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
303 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
304 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
305 { "CycleColormap", { {"display", IntegerReference} } },
306 { "Draw", { {"primitive", MagickPrimitiveOptions},
307 {"points", StringReference}, {"method", MagickMethodOptions},
308 {"stroke", StringReference}, {"fill", StringReference},
309 {"strokewidth", RealReference}, {"font", StringReference},
310 {"bordercolor", StringReference}, {"x", RealReference},
311 {"y", RealReference}, {"translate", StringReference},
312 {"scale", StringReference}, {"rotate", RealReference},
313 {"skewX", RealReference}, {"skewY", RealReference},
314 {"tile", ImageReference}, {"pointsize", RealReference},
315 {"antialias", MagickBooleanOptions}, {"density", StringReference},
316 {"linewidth", RealReference}, {"affine", ArrayReference},
317 {"stroke-dashoffset", RealReference},
318 {"stroke-dasharray", ArrayReference},
319 {"interpolate", MagickInterpolateOptions},
320 {"origin", StringReference}, {"text", StringReference},
321 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
322 {"vector-graphics", StringReference}, {"kerning", RealReference},
323 {"interline-spacing", RealReference},
324 {"interword-spacing", RealReference},
325 {"direction", MagickDirectionOptions} } },
326 { "Equalize", { {"channel", MagickChannelOptions} } },
327 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
328 {"red", RealReference}, {"green", RealReference},
329 {"blue", RealReference} } },
330 { "Map", { {"image", ImageReference},
331 {"dither-method", MagickDitherOptions} } },
332 { "MatteFloodfill", { {"geometry", StringReference},
333 {"x", IntegerReference}, {"y", IntegerReference},
334 {"opacity", StringReference}, {"bordercolor", StringReference},
335 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
336 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
337 {"saturation", RealReference}, {"whiteness", RealReference},
338 {"brightness", RealReference}, {"lightness", RealReference},
339 {"blackness", RealReference} } },
340 { "Negate", { {"gray", MagickBooleanOptions},
341 {"channel", MagickChannelOptions} } },
342 { "Normalize", { {"channel", MagickChannelOptions} } },
344 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
345 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
346 {"invert", MagickBooleanOptions} } },
347 { "Quantize", { {"colors", IntegerReference},
348 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
349 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
350 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
351 {"dither-method", MagickDitherOptions} } },
352 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
353 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
354 { "Segment", { {"geometry", StringReference},
355 {"cluster-threshold", RealReference},
356 {"smoothing-threshold", RealReference},
357 {"colorspace", MagickColorspaceOptions},
358 {"verbose", MagickBooleanOptions} } },
360 { "Solarize", { {"geometry", StringReference},
361 {"threshold", StringReference} } },
363 { "Texture", { {"texture", ImageReference} } },
364 { "Evaluate", { {"value", RealReference},
365 {"operator", MagickEvaluateOptions},
366 {"channel", MagickChannelOptions} } },
367 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
368 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
369 { "Threshold", { {"threshold", StringReference},
370 {"channel", MagickChannelOptions} } },
371 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
372 {"sigma", RealReference} } },
373 { "Trim", { {"fuzz", StringReference} } },
374 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
375 {"wavelength", RealReference},
376 {"interpolate", MagickInterpolateOptions} } },
377 { "Separate", { {"channel", MagickChannelOptions} } },
379 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
380 {"y", IntegerReference} } },
381 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
383 { "GaussianBlur", { {"geometry", StringReference},
384 {"radius", RealReference}, {"sigma", RealReference},
385 {"channel", MagickChannelOptions} } },
386 { "Convolve", { {"coefficients", ArrayReference},
387 {"channel", MagickChannelOptions}, {"bias", StringReference},
388 {"kernel", StringReference} } },
389 { "Profile", { {"name", StringReference}, {"profile", StringReference},
390 { "rendering-intent", MagickIntentOptions},
391 { "black-point-compensation", MagickBooleanOptions} } },
392 { "UnsharpMask", { {"geometry", StringReference},
393 {"radius", RealReference}, {"sigma", RealReference},
394 {"gain", RealReference}, {"threshold", RealReference},
395 {"channel", MagickChannelOptions} } },
396 { "MotionBlur", { {"geometry", StringReference},
397 {"radius", RealReference}, {"sigma", RealReference},
398 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
399 { "OrderedDither", { {"threshold", StringReference},
400 {"channel", MagickChannelOptions} } },
401 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
402 {"height", IntegerReference} } },
403 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
404 {"white-point", RealReference}, {"gamma", RealReference},
405 {"channel", MagickChannelOptions}, {"level", StringReference} } },
406 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
407 { "AffineTransform", { {"affine", ArrayReference},
408 {"translate", StringReference}, {"scale", StringReference},
409 {"rotate", RealReference}, {"skewX", RealReference},
410 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
411 {"background", StringReference} } },
412 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
413 { "AdaptiveThreshold", { {"geometry", StringReference},
414 {"width", IntegerReference}, {"height", IntegerReference} } },
415 { "Resample", { {"density", StringReference}, {"x", RealReference},
416 {"y", RealReference}, {"filter", MagickFilterOptions},
417 {"support", RealReference } } },
418 { "Describe", { {"file", FileReference} } },
419 { "BlackThreshold", { {"threshold", StringReference},
420 {"channel", MagickChannelOptions} } },
421 { "WhiteThreshold", { {"threshold", StringReference},
422 {"channel", MagickChannelOptions} } },
423 { "RotationalBlur", { {"geometry", StringReference},
424 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
425 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
426 {"height", IntegerReference} } },
428 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
429 { "Channel", { {"channel", MagickChannelOptions} } },
430 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
431 {"height", IntegerReference}, {"x", IntegerReference},
432 {"y", IntegerReference}, {"fuzz", StringReference},
433 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
434 { "Posterize", { {"levels", IntegerReference},
435 {"dither", MagickBooleanOptions} } },
436 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
437 {"sigma", RealReference}, {"x", IntegerReference},
438 {"y", IntegerReference} } },
439 { "Identify", { {"file", FileReference}, {"features", StringReference},
440 {"unique", MagickBooleanOptions} } },
441 { "SepiaTone", { {"threshold", RealReference} } },
442 { "SigmoidalContrast", { {"geometry", StringReference},
443 {"contrast", RealReference}, {"mid-point", RealReference},
444 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
445 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
446 {"height", IntegerReference}, {"x", IntegerReference},
447 {"y", IntegerReference}, {"fuzz", StringReference},
448 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
449 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
450 {"sigma", RealReference}, {"x", IntegerReference},
451 {"y", IntegerReference}, {"background", StringReference} } },
452 { "ContrastStretch", { {"levels", StringReference},
453 {"black-point", RealReference},{"white-point", RealReference},
454 {"channel", MagickChannelOptions} } },
457 { "AdaptiveSharpen", { {"geometry", StringReference},
458 {"radius", RealReference}, {"sigma", RealReference},
459 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
463 { "AdaptiveBlur", { {"geometry", StringReference},
464 {"radius", RealReference}, {"sigma", RealReference},
465 {"channel", MagickChannelOptions} } },
466 { "Sketch", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"angle", RealReference} } },
470 { "AdaptiveResize", { {"geometry", StringReference},
471 {"width", IntegerReference}, {"height", IntegerReference},
472 {"filter", MagickFilterOptions}, {"support", StringReference },
473 {"blur", RealReference } } },
474 { "ClipMask", { {"mask", ImageReference} } },
475 { "LinearStretch", { {"levels", StringReference},
476 {"black-point", RealReference},{"white-point", RealReference} } },
477 { "ColorMatrix", { {"matrix", ArrayReference} } },
478 { "Mask", { {"mask", ImageReference} } },
479 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
480 {"font", StringReference}, {"stroke", StringReference},
481 {"fill", StringReference}, {"strokewidth", RealReference},
482 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
483 {"background", StringReference},
484 {"interpolate", MagickInterpolateOptions} } },
485 { "FloodfillPaint", { {"geometry", StringReference},
486 {"x", IntegerReference}, {"y", IntegerReference},
487 {"fill", StringReference}, {"bordercolor", StringReference},
488 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
489 {"invert", MagickBooleanOptions} } },
490 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
491 {"virtual-pixel", MagickVirtualPixelOptions},
492 {"best-fit", MagickBooleanOptions} } },
493 { "Clut", { {"image", ImageReference},
494 {"interpolate", MagickInterpolateOptions},
495 {"channel", MagickChannelOptions} } },
496 { "LiquidRescale", { {"geometry", StringReference},
497 {"width", IntegerReference}, {"height", IntegerReference},
498 {"delta-x", RealReference}, {"rigidity", RealReference } } },
499 { "Encipher", { {"passphrase", StringReference} } },
500 { "Decipher", { {"passphrase", StringReference} } },
501 { "Deskew", { {"geometry", StringReference},
502 {"threshold", StringReference} } },
503 { "Remap", { {"image", ImageReference},
504 {"dither-method", MagickDitherOptions} } },
505 { "SparseColor", { {"points", ArrayReference},
506 {"method", MagickSparseColorOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions},
508 {"channel", MagickChannelOptions} } },
509 { "Function", { {"parameters", ArrayReference},
510 {"function", MagickFunctionOptions},
511 {"virtual-pixel", MagickVirtualPixelOptions} } },
512 { "SelectiveBlur", { {"geometry", StringReference},
513 {"radius", RealReference}, {"sigma", RealReference},
514 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
515 { "HaldClut", { {"image", ImageReference},
516 {"channel", MagickChannelOptions} } },
517 { "BlueShift", { {"factor", StringReference} } },
518 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "ColorDecisionList", {
521 {"color-correction-collection", StringReference} } },
522 { "AutoGamma", { {"channel", MagickChannelOptions} } },
523 { "AutoLevel", { {"channel", MagickChannelOptions} } },
524 { "LevelColors", { {"invert", MagickBooleanOptions},
525 {"black-point", StringReference}, {"white-point", StringReference},
526 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
527 { "Clamp", { {"channel", MagickChannelOptions} } },
528 { "BrightnessContrast", { {"levels", StringReference},
529 {"brightness", RealReference},{"contrast", RealReference},
530 {"channel", MagickChannelOptions} } },
531 { "Morphology", { {"kernel", StringReference},
532 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
533 {"iterations", IntegerReference} } },
534 { "Sans", { {"matrix", ArrayReference} } },
535 { "Color", { {"color", StringReference} } },
536 { "Mode", { {"geometry", StringReference},
537 {"width", IntegerReference},{"height", IntegerReference},
538 {"channel", MagickChannelOptions} } },
539 { "Statistic", { {"geometry", StringReference},
540 {"width", IntegerReference},{"height", IntegerReference},
541 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
542 { "Perceptible", { {"epsilon", RealReference},
543 {"channel", MagickChannelOptions} } },
544 { "Poly", { {"terms", ArrayReference},
545 {"channel", MagickChannelOptions} } },
546 { "Grayscale", { {"method", MagickNoiseOptions} } },
547 { "CannyEdge", { {"geometry", StringReference},
548 {"radius", RealReference}, {"sigma", RealReference},
549 {"lower-percent", RealReference}, {"upper-percent", RealReference} } },
550 { "HoughLine", { {"geometry", StringReference},
551 {"width", IntegerReference}, {"height", IntegerReference},
552 {"threshold", IntegerReference} } },
553 { "MeanShift", { {"geometry", StringReference},
554 {"width", IntegerReference}, {"height", IntegerReference},
555 {"distance", RealReference} } },
556 { "Kuwahara", { {"geometry", StringReference}, {"radius", RealReference},
557 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
558 { "ConnectedComponents", { {"connectivity", IntegerReference} } },
562 *magick_registry = (SplayTreeInfo *) NULL;
565 Forward declarations.
568 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
571 strEQcase(const char *,const char *);
574 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
578 % C l o n e P a c k a g e I n f o %
582 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
584 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
587 % The format of the ClonePackageInfo routine is:
589 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
592 % A description of each parameter follows:
594 % o info: a structure of type info.
596 % o exception: Return any errors or warnings in this structure.
599 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
600 ExceptionInfo *exception)
605 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
606 if (clone_info == (struct PackageInfo *) NULL)
608 ThrowPerlException(exception,ResourceLimitError,
609 "UnableToClonePackageInfo",PackageName);
610 return((struct PackageInfo *) NULL);
612 if (info == (struct PackageInfo *) NULL)
614 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
618 clone_info->image_info=CloneImageInfo(info->image_info);
623 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
633 % constant() returns a double value for the specified name.
635 % The format of the constant routine is:
637 % double constant(char *name,ssize_t sans)
639 % A description of each parameter follows:
641 % o value: Method constant returns a double value for the specified name.
643 % o name: The name of the constant.
645 % o sans: This integer value is not used.
648 static double constant(char *name,ssize_t sans)
656 if (strEQ(name,"BlobError"))
658 if (strEQ(name,"BlobWarning"))
664 if (strEQ(name,"CacheError"))
666 if (strEQ(name,"CacheWarning"))
667 return(CacheWarning);
668 if (strEQ(name,"CoderError"))
670 if (strEQ(name,"CoderWarning"))
671 return(CoderWarning);
672 if (strEQ(name,"ConfigureError"))
673 return(ConfigureError);
674 if (strEQ(name,"ConfigureWarning"))
675 return(ConfigureWarning);
676 if (strEQ(name,"CorruptImageError"))
677 return(CorruptImageError);
678 if (strEQ(name,"CorruptImageWarning"))
679 return(CorruptImageWarning);
684 if (strEQ(name,"DelegateError"))
685 return(DelegateError);
686 if (strEQ(name,"DelegateWarning"))
687 return(DelegateWarning);
688 if (strEQ(name,"DrawError"))
690 if (strEQ(name,"DrawWarning"))
696 if (strEQ(name,"ErrorException"))
697 return(ErrorException);
698 if (strEQ(name,"ExceptionError"))
700 if (strEQ(name,"ExceptionWarning"))
701 return(CoderWarning);
706 if (strEQ(name,"FatalErrorException"))
707 return(FatalErrorException);
708 if (strEQ(name,"FileOpenError"))
709 return(FileOpenError);
710 if (strEQ(name,"FileOpenWarning"))
711 return(FileOpenWarning);
716 if (strEQ(name,"ImageError"))
718 if (strEQ(name,"ImageWarning"))
719 return(ImageWarning);
724 if (strEQ(name,"MaxRGB"))
725 return(QuantumRange);
726 if (strEQ(name,"MissingDelegateError"))
727 return(MissingDelegateError);
728 if (strEQ(name,"MissingDelegateWarning"))
729 return(MissingDelegateWarning);
730 if (strEQ(name,"ModuleError"))
732 if (strEQ(name,"ModuleWarning"))
733 return(ModuleWarning);
738 if (strEQ(name,"Opaque"))
740 if (strEQ(name,"OptionError"))
742 if (strEQ(name,"OptionWarning"))
743 return(OptionWarning);
748 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
749 return(MAGICKCORE_QUANTUM_DEPTH);
750 if (strEQ(name,"QuantumDepth"))
751 return(MAGICKCORE_QUANTUM_DEPTH);
752 if (strEQ(name,"QuantumRange"))
753 return(QuantumRange);
758 if (strEQ(name,"ResourceLimitError"))
759 return(ResourceLimitError);
760 if (strEQ(name,"ResourceLimitWarning"))
761 return(ResourceLimitWarning);
762 if (strEQ(name,"RegistryError"))
763 return(RegistryError);
764 if (strEQ(name,"RegistryWarning"))
765 return(RegistryWarning);
770 if (strEQ(name,"StreamError"))
772 if (strEQ(name,"StreamWarning"))
773 return(StreamWarning);
774 if (strEQ(name,"Success"))
780 if (strEQ(name,"Transparent"))
781 return(TransparentAlpha);
782 if (strEQ(name,"TypeError"))
784 if (strEQ(name,"TypeWarning"))
790 if (strEQ(name,"WarningException"))
791 return(WarningException);
796 if (strEQ(name,"XServerError"))
797 return(XServerError);
798 if (strEQ(name,"XServerWarning"))
799 return(XServerWarning);
808 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
812 % D e s t r o y P a c k a g e I n f o %
816 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
818 % Method DestroyPackageInfo frees a previously created info structure.
820 % The format of the DestroyPackageInfo routine is:
822 % DestroyPackageInfo(struct PackageInfo *info)
824 % A description of each parameter follows:
826 % o info: a structure of type info.
829 static void DestroyPackageInfo(struct PackageInfo *info)
831 info->image_info=DestroyImageInfo(info->image_info);
832 info=(struct PackageInfo *) RelinquishMagickMemory(info);
836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
844 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
846 % Method GetList is recursively called by SetupList to traverse the
847 % Image__Magick reference. If building an reference_vector (see SetupList),
848 % *current is the current position in *reference_vector and *last is the final
849 % entry in *reference_vector.
851 % The format of the GetList routine is:
855 % A description of each parameter follows:
857 % o info: a structure of type info.
860 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
861 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
866 if (reference == (SV *) NULL)
868 switch (SvTYPE(reference))
888 previous=(Image *) NULL;
892 for (i=0; i <= n; i++)
898 if (rv && *rv && sv_isobject(*rv))
900 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
902 if (image == (Image *) NULL)
904 if (image == previous)
906 image=CloneImage(image,0,0,MagickTrue,exception);
907 if (image == (Image *) NULL)
910 image->previous=previous;
911 *(previous ? &previous->next : &head)=image;
912 for (previous=image; previous->next; previous=previous->next) ;
920 Blessed scalar, one image.
922 image=INT2PTR(Image *,SvIV(reference));
923 if (image == (Image *) NULL)
925 image->previous=(Image *) NULL;
926 image->next=(Image *) NULL;
927 if (reference_vector)
929 if (*current == *last)
932 if (*reference_vector == (SV **) NULL)
933 *reference_vector=(SV **) AcquireQuantumMemory(*last,
934 sizeof(*reference_vector));
936 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
937 *last,sizeof(*reference_vector));
939 if (*reference_vector == (SV **) NULL)
941 ThrowPerlException(exception,ResourceLimitError,
942 "MemoryAllocationFailed",PackageName);
943 return((Image *) NULL);
945 (*reference_vector)[*current]=reference;
946 (*reference_vector)[++(*current)]=NULL;
953 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
954 (double) SvTYPE(reference));
955 return((Image *) NULL);
959 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
963 % G e t P a c k a g e I n f o %
967 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
969 % Method GetPackageInfo looks up or creates an info structure for the given
970 % Image__Magick reference. If it does create a new one, the information in
971 % package_info is used to initialize it.
973 % The format of the GetPackageInfo routine is:
975 % struct PackageInfo *GetPackageInfo(void *reference,
976 % struct PackageInfo *package_info,ExceptionInfo *exception)
978 % A description of each parameter follows:
980 % o info: a structure of type info.
982 % o exception: Return any errors or warnings in this structure.
985 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
986 struct PackageInfo *package_info,ExceptionInfo *exception)
989 message[MaxTextExtent];
997 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
998 PackageName,XS_VERSION,reference);
999 sv=perl_get_sv(message,(TRUE | 0x02));
1000 if (sv == (SV *) NULL)
1002 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1004 return(package_info);
1006 if (SvREFCNT(sv) == 0)
1007 (void) SvREFCNT_inc(sv);
1008 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1010 clone_info=ClonePackageInfo(package_info,exception);
1011 sv_setiv(sv,PTR2IV(clone_info));
1016 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1020 % S e t A t t r i b u t e %
1024 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1026 % SetAttribute() sets the attribute to the value in sval. This can change
1027 % either or both of image or info.
1029 % The format of the SetAttribute routine is:
1031 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1032 % SV *sval,ExceptionInfo *exception)
1034 % A description of each parameter follows:
1036 % o list: a list of strings.
1038 % o string: a character string.
1042 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1050 value=InterpretSiPrefixValue(string,&q);
1052 value*=interval/100.0;
1056 static inline double StringToDouble(const char *string,char **sentinal)
1058 return(InterpretLocaleValue(string,sentinal));
1061 static double StringToDoubleInterval(const char *string,const double interval)
1069 value=InterpretLocaleValue(string,&q);
1071 value*=interval/100.0;
1075 static inline ssize_t StringToLong(const char *value)
1077 return(strtol(value,(char **) NULL,10));
1080 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1081 const char *attribute,SV *sval,ExceptionInfo *exception)
1108 if (LocaleCompare(attribute,"adjoin") == 0)
1110 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1111 SvPV(sval,na)) : SvIV(sval);
1114 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1119 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1122 if (LocaleCompare(attribute,"alpha") == 0)
1124 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1125 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1128 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1132 for ( ; image; image=image->next)
1133 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1137 if (LocaleCompare(attribute,"antialias") == 0)
1139 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1140 SvPV(sval,na)) : SvIV(sval);
1143 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1148 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1151 if (LocaleCompare(attribute,"area-limit") == 0)
1156 limit=MagickResourceInfinity;
1157 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1158 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1160 (void) SetMagickResourceLimit(AreaResource,limit);
1163 if (LocaleCompare(attribute,"attenuate") == 0)
1166 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1169 if (LocaleCompare(attribute,"authenticate") == 0)
1172 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1176 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1177 for ( ; image; image=image->next)
1178 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1184 if (LocaleCompare(attribute,"background") == 0)
1186 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1189 info->image_info->background_color=target_color;
1190 for ( ; image; image=image->next)
1191 image->background_color=target_color;
1194 if (LocaleCompare(attribute,"blue-primary") == 0)
1196 for ( ; image; image=image->next)
1198 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1199 image->chromaticity.blue_primary.x=geometry_info.rho;
1200 image->chromaticity.blue_primary.y=geometry_info.sigma;
1201 if ((flags & SigmaValue) == 0)
1202 image->chromaticity.blue_primary.y=
1203 image->chromaticity.blue_primary.x;
1207 if (LocaleCompare(attribute,"bordercolor") == 0)
1209 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1212 info->image_info->border_color=target_color;
1213 for ( ; image; image=image->next)
1214 image->border_color=target_color;
1218 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1219 for ( ; image; image=image->next)
1220 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1226 if (LocaleCompare(attribute,"cache-threshold") == 0)
1228 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1229 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1230 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1231 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1234 if (LocaleCompare(attribute,"clip-mask") == 0)
1239 clip_mask=(Image *) NULL;
1241 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1242 for ( ; image; image=image->next)
1243 SetImageMask(image,clip_mask,exception);
1246 if (LocaleNCompare(attribute,"colormap",8) == 0)
1248 for ( ; image; image=image->next)
1256 if (image->storage_class == DirectClass)
1259 items=sscanf(attribute,"%*[^[][%ld",&i);
1261 if (i > (ssize_t) image->colors)
1263 if ((strchr(SvPV(sval,na),',') == 0) ||
1264 (strchr(SvPV(sval,na),')') != 0))
1265 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1266 image->colormap+i,exception);
1269 color=image->colormap+i;
1270 pixel.red=color->red;
1271 pixel.green=color->green;
1272 pixel.blue=color->blue;
1273 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1274 pixel.red=geometry_info.rho;
1275 pixel.green=geometry_info.sigma;
1276 pixel.blue=geometry_info.xi;
1277 color->red=ClampToQuantum(pixel.red);
1278 color->green=ClampToQuantum(pixel.green);
1279 color->blue=ClampToQuantum(pixel.blue);
1284 if (LocaleCompare(attribute,"colorspace") == 0)
1286 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1287 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1290 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1294 for ( ; image; image=image->next)
1295 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1299 if (LocaleCompare(attribute,"comment") == 0)
1301 for ( ; image; image=image->next)
1302 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1303 info ? info->image_info : (ImageInfo *) NULL,image,
1304 SvPV(sval,na),exception),exception);
1307 if (LocaleCompare(attribute,"compression") == 0)
1309 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1310 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1313 ThrowPerlException(exception,OptionError,
1314 "UnrecognizedImageCompression",SvPV(sval,na));
1318 info->image_info->compression=(CompressionType) sp;
1319 for ( ; image; image=image->next)
1320 image->compression=(CompressionType) sp;
1324 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1325 for ( ; image; image=image->next)
1326 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1332 if (LocaleCompare(attribute,"debug") == 0)
1334 SetLogEventMask(SvPV(sval,na));
1337 if (LocaleCompare(attribute,"delay") == 0)
1339 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1340 for ( ; image; image=image->next)
1342 image->delay=(size_t) floor(geometry_info.rho+0.5);
1343 if ((flags & SigmaValue) != 0)
1344 image->ticks_per_second=(ssize_t)
1345 floor(geometry_info.sigma+0.5);
1349 if (LocaleCompare(attribute,"disk-limit") == 0)
1354 limit=MagickResourceInfinity;
1355 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1356 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1358 (void) SetMagickResourceLimit(DiskResource,limit);
1361 if (LocaleCompare(attribute,"density") == 0)
1363 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1365 ThrowPerlException(exception,OptionError,"MissingGeometry",
1370 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1371 for ( ; image; image=image->next)
1373 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1374 image->resolution.x=geometry_info.rho;
1375 image->resolution.y=geometry_info.sigma;
1376 if ((flags & SigmaValue) == 0)
1377 image->resolution.y=image->resolution.x;
1381 if (LocaleCompare(attribute,"depth") == 0)
1384 info->image_info->depth=SvIV(sval);
1385 for ( ; image; image=image->next)
1386 (void) SetImageDepth(image,SvIV(sval),exception);
1389 if (LocaleCompare(attribute,"dispose") == 0)
1391 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1392 SvPV(sval,na)) : SvIV(sval);
1395 ThrowPerlException(exception,OptionError,
1396 "UnrecognizedDisposeMethod",SvPV(sval,na));
1399 for ( ; image; image=image->next)
1400 image->dispose=(DisposeType) sp;
1403 if (LocaleCompare(attribute,"dither") == 0)
1407 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1408 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1411 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1415 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1419 if (LocaleCompare(attribute,"display") == 0)
1423 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1427 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1428 for ( ; image; image=image->next)
1429 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1435 if (LocaleCompare(attribute,"endian") == 0)
1437 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1438 SvPV(sval,na)) : SvIV(sval);
1441 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1446 info->image_info->endian=(EndianType) sp;
1447 for ( ; image; image=image->next)
1448 image->endian=(EndianType) sp;
1451 if (LocaleCompare(attribute,"extract") == 0)
1454 Set image extract geometry.
1456 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1460 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1461 for ( ; image; image=image->next)
1462 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1468 if (LocaleCompare(attribute,"filename") == 0)
1471 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1473 for ( ; image; image=image->next)
1474 (void) CopyMagickString(image->filename,SvPV(sval,na),
1478 if (LocaleCompare(attribute,"file") == 0)
1486 if (info == (struct PackageInfo *) NULL)
1488 io_info=IoIFP(sv_2io(sval));
1489 if (io_info == (PerlIO *) NULL)
1491 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1495 file=PerlIO_findFILE(io_info);
1496 if (file == (FILE *) NULL)
1498 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1502 SetImageInfoFile(info->image_info,file);
1505 if (LocaleCompare(attribute,"fill") == 0)
1508 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1511 if (LocaleCompare(attribute,"font") == 0)
1514 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1517 if (LocaleCompare(attribute,"foreground") == 0)
1519 if (LocaleCompare(attribute,"fuzz") == 0)
1522 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1524 for ( ; image; image=image->next)
1525 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1530 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1531 for ( ; image; image=image->next)
1532 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1538 if (LocaleCompare(attribute,"gamma") == 0)
1540 for ( ; image; image=image->next)
1541 image->gamma=SvNV(sval);
1544 if (LocaleCompare(attribute,"gravity") == 0)
1546 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1547 SvPV(sval,na)) : SvIV(sval);
1550 ThrowPerlException(exception,OptionError,
1551 "UnrecognizedGravityType",SvPV(sval,na));
1555 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1556 for ( ; image; image=image->next)
1557 image->gravity=(GravityType) sp;
1560 if (LocaleCompare(attribute,"green-primary") == 0)
1562 for ( ; image; image=image->next)
1564 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1565 image->chromaticity.green_primary.x=geometry_info.rho;
1566 image->chromaticity.green_primary.y=geometry_info.sigma;
1567 if ((flags & SigmaValue) == 0)
1568 image->chromaticity.green_primary.y=
1569 image->chromaticity.green_primary.x;
1574 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1575 for ( ; image; image=image->next)
1576 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1582 if (LocaleNCompare(attribute,"index",5) == 0)
1596 for ( ; image; image=image->next)
1598 if (image->storage_class != PseudoClass)
1602 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1604 image_view=AcquireAuthenticCacheView(image,exception);
1605 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1606 if (q != (Quantum *) NULL)
1608 items=sscanf(SvPV(sval,na),"%ld",&index);
1609 if ((index >= 0) && (index < (ssize_t) image->colors))
1610 SetPixelIndex(image,index,q);
1611 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1613 image_view=DestroyCacheView(image_view);
1617 if (LocaleCompare(attribute,"iterations") == 0)
1620 for ( ; image; image=image->next)
1621 image->iterations=SvIV(sval);
1624 if (LocaleCompare(attribute,"interlace") == 0)
1626 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1627 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1630 ThrowPerlException(exception,OptionError,
1631 "UnrecognizedInterlaceType",SvPV(sval,na));
1635 info->image_info->interlace=(InterlaceType) sp;
1636 for ( ; image; image=image->next)
1637 image->interlace=(InterlaceType) sp;
1641 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1642 for ( ; image; image=image->next)
1643 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1649 if (LocaleCompare(attribute,"label") == 0)
1651 for ( ; image; image=image->next)
1652 (void) SetImageProperty(image,"label",InterpretImageProperties(
1653 info ? info->image_info : (ImageInfo *) NULL,image,
1654 SvPV(sval,na),exception),exception);
1657 if (LocaleCompare(attribute,"loop") == 0)
1660 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1661 for ( ; image; image=image->next)
1662 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1668 if (LocaleCompare(attribute,"magick") == 0)
1671 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1672 "%s:",SvPV(sval,na));
1673 for ( ; image; image=image->next)
1674 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1677 if (LocaleCompare(attribute,"map-limit") == 0)
1682 limit=MagickResourceInfinity;
1683 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1684 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1686 (void) SetMagickResourceLimit(MapResource,limit);
1689 if (LocaleCompare(attribute,"mask") == 0)
1694 mask=(Image *) NULL;
1696 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1697 for ( ; image; image=image->next)
1698 SetImageMask(image,mask,exception);
1701 if (LocaleCompare(attribute,"mattecolor") == 0)
1703 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1706 info->image_info->matte_color=target_color;
1707 for ( ; image; image=image->next)
1708 image->matte_color=target_color;
1711 if (LocaleCompare(attribute,"matte") == 0)
1713 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1714 SvPV(sval,na)) : SvIV(sval);
1717 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1721 for ( ; image; image=image->next)
1722 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1725 if (LocaleCompare(attribute,"memory-limit") == 0)
1730 limit=MagickResourceInfinity;
1731 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1732 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1734 (void) SetMagickResourceLimit(MemoryResource,limit);
1737 if (LocaleCompare(attribute,"monochrome") == 0)
1739 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1740 SvPV(sval,na)) : SvIV(sval);
1743 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1748 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1749 for ( ; image; image=image->next)
1750 (void) SetImageType(image,BilevelType,exception);
1754 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1755 for ( ; image; image=image->next)
1756 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1762 if (LocaleCompare(attribute,"option") == 0)
1765 DefineImageOption(info->image_info,SvPV(sval,na));
1768 if (LocaleCompare(attribute,"orientation") == 0)
1770 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1771 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1774 ThrowPerlException(exception,OptionError,
1775 "UnrecognizedOrientationType",SvPV(sval,na));
1779 info->image_info->orientation=(OrientationType) sp;
1780 for ( ; image; image=image->next)
1781 image->orientation=(OrientationType) sp;
1785 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1786 for ( ; image; image=image->next)
1787 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1793 if (LocaleCompare(attribute,"page") == 0)
1798 geometry=GetPageGeometry(SvPV(sval,na));
1800 (void) CloneString(&info->image_info->page,geometry);
1801 for ( ; image; image=image->next)
1802 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1803 geometry=(char *) RelinquishMagickMemory(geometry);
1806 if (LocaleNCompare(attribute,"pixel",5) == 0)
1820 for ( ; image; image=image->next)
1822 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1826 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1828 image_view=AcquireVirtualCacheView(image,exception);
1829 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1830 if (q != (Quantum *) NULL)
1832 if ((strchr(SvPV(sval,na),',') == 0) ||
1833 (strchr(SvPV(sval,na),')') != 0))
1834 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1838 GetPixelInfo(image,&pixel);
1839 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1840 pixel.red=geometry_info.rho;
1841 if ((flags & SigmaValue) != 0)
1842 pixel.green=geometry_info.sigma;
1843 if ((flags & XiValue) != 0)
1844 pixel.blue=geometry_info.xi;
1845 if ((flags & PsiValue) != 0)
1846 pixel.alpha=geometry_info.psi;
1847 if ((flags & ChiValue) != 0)
1848 pixel.black=geometry_info.chi;
1850 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1851 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1852 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1853 if (image->colorspace == CMYKColorspace)
1854 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1855 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1856 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1858 image_view=DestroyCacheView(image_view);
1862 if (LocaleCompare(attribute,"pointsize") == 0)
1866 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1867 info->image_info->pointsize=geometry_info.rho;
1871 if (LocaleCompare(attribute,"preview") == 0)
1873 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1874 SvPV(sval,na)) : SvIV(sval);
1877 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1882 info->image_info->preview_type=(PreviewType) sp;
1886 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1887 for ( ; image; image=image->next)
1888 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1894 if (LocaleCompare(attribute,"quality") == 0)
1897 info->image_info->quality=SvIV(sval);
1898 for ( ; image; image=image->next)
1899 image->quality=SvIV(sval);
1903 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1904 for ( ; image; image=image->next)
1905 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1911 if (LocaleCompare(attribute,"red-primary") == 0)
1913 for ( ; image; image=image->next)
1915 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1916 image->chromaticity.red_primary.x=geometry_info.rho;
1917 image->chromaticity.red_primary.y=geometry_info.sigma;
1918 if ((flags & SigmaValue) == 0)
1919 image->chromaticity.red_primary.y=
1920 image->chromaticity.red_primary.x;
1924 if (LocaleCompare(attribute,"render") == 0)
1926 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1927 SvPV(sval,na)) : SvIV(sval);
1930 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1934 for ( ; image; image=image->next)
1935 image->rendering_intent=(RenderingIntent) sp;
1938 if (LocaleCompare(attribute,"repage") == 0)
1943 for ( ; image; image=image->next)
1945 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1946 if ((flags & WidthValue) != 0)
1948 if ((flags & HeightValue) == 0)
1949 geometry.height=geometry.width;
1950 image->page.width=geometry.width;
1951 image->page.height=geometry.height;
1953 if ((flags & AspectValue) != 0)
1955 if ((flags & XValue) != 0)
1956 image->page.x+=geometry.x;
1957 if ((flags & YValue) != 0)
1958 image->page.y+=geometry.y;
1962 if ((flags & XValue) != 0)
1964 image->page.x=geometry.x;
1965 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1966 image->page.width=image->columns+geometry.x;
1968 if ((flags & YValue) != 0)
1970 image->page.y=geometry.y;
1971 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1972 image->page.height=image->rows+geometry.y;
1979 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1980 for ( ; image; image=image->next)
1981 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1987 if (LocaleCompare(attribute,"sampling-factor") == 0)
1989 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1991 ThrowPerlException(exception,OptionError,"MissingGeometry",
1996 (void) CloneString(&info->image_info->sampling_factor,
2000 if (LocaleCompare(attribute,"scene") == 0)
2002 for ( ; image; image=image->next)
2003 image->scene=SvIV(sval);
2006 if (LocaleCompare(attribute,"server") == 0)
2008 if (LocaleCompare(attribute,"size") == 0)
2012 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2014 ThrowPerlException(exception,OptionError,"MissingGeometry",
2018 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2022 if (LocaleCompare(attribute,"stroke") == 0)
2025 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2029 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2030 for ( ; image; image=image->next)
2031 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2037 if (LocaleCompare(attribute,"texture") == 0)
2040 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2043 if (LocaleCompare(attribute,"thread-limit") == 0)
2048 limit=MagickResourceInfinity;
2049 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2050 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2052 (void) SetMagickResourceLimit(ThreadResource,limit);
2055 if (LocaleCompare(attribute,"tile-offset") == 0)
2060 geometry=GetPageGeometry(SvPV(sval,na));
2062 (void) CloneString(&info->image_info->page,geometry);
2063 for ( ; image; image=image->next)
2064 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2066 geometry=(char *) RelinquishMagickMemory(geometry);
2069 if (LocaleCompare(attribute,"time-limit") == 0)
2074 limit=MagickResourceInfinity;
2075 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2076 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2078 (void) SetMagickResourceLimit(TimeResource,limit);
2081 if (LocaleCompare(attribute,"transparent-color") == 0)
2083 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2086 info->image_info->transparent_color=target_color;
2087 for ( ; image; image=image->next)
2088 image->transparent_color=target_color;
2091 if (LocaleCompare(attribute,"type") == 0)
2093 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2094 SvPV(sval,na)) : SvIV(sval);
2097 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2102 info->image_info->type=(ImageType) sp;
2103 for ( ; image; image=image->next)
2104 SetImageType(image,(ImageType) sp,exception);
2108 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2109 for ( ; image; image=image->next)
2110 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2116 if (LocaleCompare(attribute,"units") == 0)
2118 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2119 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2122 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2127 info->image_info->units=(ResolutionType) sp;
2128 for ( ; image; image=image->next)
2133 units=(ResolutionType) sp;
2134 if (image->units != units)
2135 switch (image->units)
2137 case UndefinedResolution:
2138 case PixelsPerInchResolution:
2140 if (units == PixelsPerCentimeterResolution)
2142 image->resolution.x*=2.54;
2143 image->resolution.y*=2.54;
2147 case PixelsPerCentimeterResolution:
2149 if (units == PixelsPerInchResolution)
2151 image->resolution.x/=2.54;
2152 image->resolution.y/=2.54;
2162 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2163 for ( ; image; image=image->next)
2164 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2170 if (LocaleCompare(attribute,"verbose") == 0)
2172 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2173 SvPV(sval,na)) : SvIV(sval);
2176 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2181 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2184 if (LocaleCompare(attribute,"view") == 0)
2187 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2190 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2192 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2193 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2196 ThrowPerlException(exception,OptionError,
2197 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2200 for ( ; image; image=image->next)
2201 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2205 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2206 for ( ; image; image=image->next)
2207 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2213 if (LocaleCompare(attribute,"white-point") == 0)
2215 for ( ; image; image=image->next)
2217 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2218 image->chromaticity.white_point.x=geometry_info.rho;
2219 image->chromaticity.white_point.y=geometry_info.sigma;
2220 if ((flags & SigmaValue) == 0)
2221 image->chromaticity.white_point.y=
2222 image->chromaticity.white_point.x;
2227 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2228 for ( ; image; image=image->next)
2229 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2235 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2236 for ( ; image; image=image->next)
2237 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2244 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2248 % S e t u p L i s t %
2252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2254 % Method SetupList returns the list of all the images linked by their
2255 % image->next and image->previous link lists for use with ImageMagick. If
2256 % info is non-NULL, an info structure is returned in *info. If
2257 % reference_vector is non-NULL,an array of SV* are returned in
2258 % *reference_vector. Reference_vector is used when the images are going to be
2259 % replaced with new Image*'s.
2261 % The format of the SetupList routine is:
2263 % Image *SetupList(SV *reference,struct PackageInfo **info,
2264 % SV ***reference_vector,ExceptionInfo *exception)
2266 % A description of each parameter follows:
2268 % o list: a list of strings.
2270 % o string: a character string.
2272 % o exception: Return any errors or warnings in this structure.
2275 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2276 SV ***reference_vector,ExceptionInfo *exception)
2285 if (reference_vector)
2286 *reference_vector=NULL;
2291 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2292 if (info && (SvTYPE(reference) == SVt_PVAV))
2293 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2303 % s t r E Q c a s e %
2307 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2309 % strEQcase() compares two strings and returns 0 if they are the
2310 % same or if the second string runs out first. The comparison is case
2313 % The format of the strEQcase routine is:
2315 % ssize_t strEQcase(const char *p,const char *q)
2317 % A description of each parameter follows:
2319 % o p: a character string.
2321 % o q: a character string.
2325 static ssize_t strEQcase(const char *p,const char *q)
2333 for (i=0 ; (c=(*q)) != 0; i++)
2335 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2336 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2341 return(((*q == 0) && (*p == 0)) ? i : 0);
2345 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2349 % I m a g e : : M a g i c k %
2353 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2357 MODULE = Image::Magick PACKAGE = Image::Magick
2362 MagickCoreGenesis("PerlMagick",MagickFalse);
2363 SetWarningHandler(NULL);
2364 SetErrorHandler(NULL);
2365 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2366 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2372 if (magick_registry != (SplayTreeInfo *) NULL)
2373 magick_registry=DestroySplayTree(magick_registry);
2374 MagickCoreTerminus();
2378 constant(name,argument)
2383 ###############################################################################
2391 ###############################################################################
2396 Image::Magick ref=NO_INIT
2420 PERL_UNUSED_VAR(ref);
2421 PERL_UNUSED_VAR(ix);
2422 exception=AcquireExceptionInfo();
2423 perl_exception=newSVpv("",0);
2424 package_info=(struct PackageInfo *) NULL;
2425 if (sv_isobject(ST(0)) == 0)
2427 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2431 reference=SvRV(ST(0));
2432 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2433 if (image == (Image *) NULL)
2435 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2439 package_info=ClonePackageInfo(info,exception);
2441 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2444 for (i=2; i < items; i+=2)
2445 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2447 (void) AnimateImages(package_info->image_info,image,exception);
2448 (void) CatchImageException(image);
2451 if (package_info != (struct PackageInfo *) NULL)
2452 DestroyPackageInfo(package_info);
2453 InheritPerlException(exception,perl_exception);
2454 exception=DestroyExceptionInfo(exception);
2455 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2456 SvPOK_on(perl_exception);
2457 ST(0)=sv_2mortal(perl_exception);
2462 ###############################################################################
2470 ###############################################################################
2475 Image::Magick ref=NO_INIT
2513 PERL_UNUSED_VAR(ref);
2514 PERL_UNUSED_VAR(ix);
2515 exception=AcquireExceptionInfo();
2516 perl_exception=newSVpv("",0);
2520 if (sv_isobject(ST(0)) == 0)
2522 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2526 reference=SvRV(ST(0));
2527 hv=SvSTASH(reference);
2529 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2531 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2532 if (image == (Image *) NULL)
2534 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2538 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2543 for (i=2; i < items; i+=2)
2545 attribute=(char *) SvPV(ST(i-1),na);
2551 if (LocaleCompare(attribute,"stack") == 0)
2553 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2557 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2563 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2569 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2575 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2576 if (image == (Image *) NULL)
2578 for ( ; image; image=image->next)
2580 AddImageToRegistry(sv,image);
2582 av_push(av,sv_bless(rv,hv));
2585 exception=DestroyExceptionInfo(exception);
2587 SvREFCNT_dec(perl_exception);
2591 InheritPerlException(exception,perl_exception);
2592 exception=DestroyExceptionInfo(exception);
2593 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2594 SvPOK_on(perl_exception);
2595 ST(0)=sv_2mortal(perl_exception);
2600 ###############################################################################
2608 ###############################################################################
2613 Image::Magick ref=NO_INIT
2644 PERL_UNUSED_VAR(ref);
2645 PERL_UNUSED_VAR(ix);
2646 exception=AcquireExceptionInfo();
2647 perl_exception=newSVpv("",0);
2649 if (sv_isobject(ST(0)) == 0)
2651 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2655 reference=SvRV(ST(0));
2656 hv=SvSTASH(reference);
2657 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2658 if (image == (Image *) NULL)
2660 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2664 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2665 if (image == (Image *) NULL)
2668 Create blessed Perl array for the returned image.
2671 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2673 AddImageToRegistry(sv,image);
2675 av_push(av,sv_bless(rv,hv));
2677 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2678 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2679 "average-%.*s",(int) (MaxTextExtent-9),
2680 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2681 (void) CopyMagickString(image->filename,info->image_info->filename,
2683 SetImageInfo(info->image_info,0,exception);
2684 exception=DestroyExceptionInfo(exception);
2685 SvREFCNT_dec(perl_exception);
2689 InheritPerlException(exception,perl_exception);
2690 exception=DestroyExceptionInfo(exception);
2691 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2692 SvPOK_on(perl_exception);
2693 ST(0)=sv_2mortal(perl_exception);
2698 ###############################################################################
2702 # B l o b T o I m a g e #
2706 ###############################################################################
2710 BlobToImage(ref,...)
2711 Image::Magick ref=NO_INIT
2757 PERL_UNUSED_VAR(ref);
2758 PERL_UNUSED_VAR(ix);
2759 exception=AcquireExceptionInfo();
2760 perl_exception=newSVpv("",0);
2763 ac=(items < 2) ? 1 : items-1;
2764 length=(STRLEN *) NULL;
2765 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2766 if (list == (char **) NULL)
2768 ThrowPerlException(exception,ResourceLimitError,
2769 "MemoryAllocationFailed",PackageName);
2772 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2773 if (length == (STRLEN *) NULL)
2775 ThrowPerlException(exception,ResourceLimitError,
2776 "MemoryAllocationFailed",PackageName);
2779 if (sv_isobject(ST(0)) == 0)
2781 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2785 reference=SvRV(ST(0));
2786 hv=SvSTASH(reference);
2787 if (SvTYPE(reference) != SVt_PVAV)
2789 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2793 av=(AV *) reference;
2794 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2799 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2802 for (n=0, i=0; i < ac; i++)
2804 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2805 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2807 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2812 list[n]=(char *) NULL;
2814 for (i=number_images=0; i < n; i++)
2816 image=BlobToImage(info->image_info,list[i],length[i],exception);
2817 if (image == (Image *) NULL)
2819 for ( ; image; image=image->next)
2821 AddImageToRegistry(sv,image);
2823 av_push(av,sv_bless(rv,hv));
2831 for (i=0; i < n; i++)
2832 if (list[i] != (char *) NULL)
2833 for (p=keep; list[i] != *p++; )
2834 if (*p == (char *) NULL)
2836 list[i]=(char *) RelinquishMagickMemory(list[i]);
2842 list=(char **) RelinquishMagickMemory(list);
2844 length=(STRLEN *) RelinquishMagickMemory(length);
2845 InheritPerlException(exception,perl_exception);
2846 exception=DestroyExceptionInfo(exception);
2847 sv_setiv(perl_exception,(IV) number_images);
2848 SvPOK_on(perl_exception);
2849 ST(0)=sv_2mortal(perl_exception);
2854 ###############################################################################
2858 # C h a n n e l F x #
2862 ###############################################################################
2867 Image::Magick ref=NO_INIT
2879 expression[MaxTextExtent];
2907 PERL_UNUSED_VAR(ref);
2908 PERL_UNUSED_VAR(ix);
2909 exception=AcquireExceptionInfo();
2910 perl_exception=newSVpv("",0);
2914 if (sv_isobject(ST(0)) == 0)
2916 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2920 reference=SvRV(ST(0));
2921 hv=SvSTASH(reference);
2923 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2925 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2926 if (image == (Image *) NULL)
2928 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2932 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2936 channel=DefaultChannels;
2937 (void) CopyMagickString(expression,"u",MaxTextExtent);
2939 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
2941 for (i=2; i < items; i+=2)
2943 attribute=(char *) SvPV(ST(i-1),na);
2949 if (LocaleCompare(attribute,"channel") == 0)
2954 option=ParseChannelOption(SvPV(ST(i),na));
2957 ThrowPerlException(exception,OptionError,
2958 "UnrecognizedType",SvPV(ST(i),na));
2961 channel=(ChannelType) option;
2964 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2971 if (LocaleCompare(attribute,"expression") == 0)
2973 (void) CopyMagickString(expression,SvPV(ST(i),na),
2977 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2983 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2989 channel_mask=SetImageChannelMask(image,channel);
2990 image=ChannelFxImage(image,expression,exception);
2991 if (image != (Image *) NULL)
2992 (void) SetImageChannelMask(image,channel_mask);
2993 if (image == (Image *) NULL)
2995 for ( ; image; image=image->next)
2997 AddImageToRegistry(sv,image);
2999 av_push(av,sv_bless(rv,hv));
3002 exception=DestroyExceptionInfo(exception);
3004 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3008 InheritPerlException(exception,perl_exception);
3009 exception=DestroyExceptionInfo(exception);
3010 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3011 SvPOK_on(perl_exception);
3012 ST(0)=sv_2mortal(perl_exception);
3017 ###############################################################################
3025 ###############################################################################
3030 Image::Magick ref=NO_INIT
3063 PERL_UNUSED_VAR(ref);
3064 PERL_UNUSED_VAR(ix);
3065 exception=AcquireExceptionInfo();
3066 perl_exception=newSVpv("",0);
3068 if (sv_isobject(ST(0)) == 0)
3070 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3074 reference=SvRV(ST(0));
3075 hv=SvSTASH(reference);
3076 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3077 if (image == (Image *) NULL)
3079 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3084 Create blessed Perl array for the returned image.
3087 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3089 for ( ; image; image=image->next)
3091 clone=CloneImage(image,0,0,MagickTrue,exception);
3092 if (clone == (Image *) NULL)
3094 AddImageToRegistry(sv,clone);
3096 av_push(av,sv_bless(rv,hv));
3099 exception=DestroyExceptionInfo(exception);
3100 SvREFCNT_dec(perl_exception);
3104 InheritPerlException(exception,perl_exception);
3105 exception=DestroyExceptionInfo(exception);
3106 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3107 SvPOK_on(perl_exception);
3108 ST(0)=sv_2mortal(perl_exception);
3113 ###############################################################################
3121 ###############################################################################
3129 PERL_UNUSED_VAR(ref);
3130 if (magick_registry != (SplayTreeInfo *) NULL)
3135 ResetSplayTreeIterator(magick_registry);
3136 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3137 while (p != (Image *) NULL)
3140 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3146 ###############################################################################
3154 ###############################################################################
3159 Image::Magick ref=NO_INIT
3188 PERL_UNUSED_VAR(ref);
3189 PERL_UNUSED_VAR(ix);
3190 exception=AcquireExceptionInfo();
3191 perl_exception=newSVpv("",0);
3193 if (sv_isobject(ST(0)) == 0)
3195 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3199 reference=SvRV(ST(0));
3200 hv=SvSTASH(reference);
3202 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3204 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3205 if (image == (Image *) NULL)
3207 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3211 image=CoalesceImages(image,exception);
3212 if (image == (Image *) NULL)
3214 for ( ; image; image=image->next)
3216 AddImageToRegistry(sv,image);
3218 av_push(av,sv_bless(rv,hv));
3221 exception=DestroyExceptionInfo(exception);
3223 SvREFCNT_dec(perl_exception);
3227 InheritPerlException(exception,perl_exception);
3228 exception=DestroyExceptionInfo(exception);
3229 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3230 SvPOK_on(perl_exception);
3231 ST(0)=sv_2mortal(perl_exception);
3236 ###############################################################################
3244 ###############################################################################
3249 Image::Magick ref=NO_INIT
3295 PERL_UNUSED_VAR(ref);
3296 PERL_UNUSED_VAR(ix);
3297 exception=AcquireExceptionInfo();
3298 perl_exception=newSVpv("",0);
3302 if (sv_isobject(ST(0)) == 0)
3304 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3308 reference=SvRV(ST(0));
3309 hv=SvSTASH(reference);
3311 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3313 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3314 if (image == (Image *) NULL)
3316 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3320 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3324 reconstruct_image=image;
3325 metric=RootMeanSquaredErrorMetric;
3326 for (i=2; i < items; i+=2)
3328 attribute=(char *) SvPV(ST(i-1),na);
3334 if (LocaleCompare(attribute,"channel") == 0)
3339 option=ParseChannelOption(SvPV(ST(i),na));
3342 ThrowPerlException(exception,OptionError,
3343 "UnrecognizedType",SvPV(ST(i),na));
3346 SetPixelChannelMask(image,(ChannelType) option);
3349 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3356 if (LocaleCompare(attribute,"fuzz") == 0)
3358 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3368 if (LocaleCompare(attribute,"image") == 0)
3370 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3371 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3374 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3381 if (LocaleCompare(attribute,"metric") == 0)
3383 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3387 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3391 metric=(MetricType) option;
3394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3406 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3408 if (difference_image != (Image *) NULL)
3410 difference_image->error.mean_error_per_pixel=distortion;
3411 AddImageToRegistry(sv,difference_image);
3413 av_push(av,sv_bless(rv,hv));
3416 exception=DestroyExceptionInfo(exception);
3418 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3422 InheritPerlException(exception,perl_exception);
3423 exception=DestroyExceptionInfo(exception);
3424 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3425 SvPOK_on(perl_exception);
3426 ST(0)=sv_2mortal(perl_exception);
3431 ###############################################################################
3435 # C o m p l e x I m a g e s #
3439 ###############################################################################
3444 Image::Magick ref=NO_INIT
3481 PERL_UNUSED_VAR(ref);
3482 PERL_UNUSED_VAR(ix);
3483 exception=AcquireExceptionInfo();
3484 perl_exception=newSVpv("",0);
3486 if (sv_isobject(ST(0)) == 0)
3488 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3492 reference=SvRV(ST(0));
3493 hv=SvSTASH(reference);
3494 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3495 if (image == (Image *) NULL)
3497 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3501 op=UndefinedComplexOperator;
3507 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3511 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3515 op=(ComplexOperator) in;
3518 for (i=2; i < items; i+=2)
3520 attribute=(char *) SvPV(ST(i-1),na);
3526 if (LocaleCompare(attribute,"operator") == 0)
3531 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3532 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3535 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3539 op=(ComplexOperator) in;
3542 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3548 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3554 image=ComplexImages(image,op,exception);
3555 if (image == (Image *) NULL)
3558 Create blessed Perl array for the returned image.
3561 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3563 AddImageToRegistry(sv,image);
3565 av_push(av,sv_bless(rv,hv));
3567 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3568 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3569 "complex-%.*s",(int) (MaxTextExtent-9),
3570 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3571 (void) CopyMagickString(image->filename,info->image_info->filename,
3573 SetImageInfo(info->image_info,0,exception);
3574 exception=DestroyExceptionInfo(exception);
3575 SvREFCNT_dec(perl_exception);
3579 InheritPerlException(exception,perl_exception);
3580 exception=DestroyExceptionInfo(exception);
3581 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3582 SvPOK_on(perl_exception);
3583 ST(0)=sv_2mortal(perl_exception);
3588 ###############################################################################
3592 # C o m p a r e L a y e r s #
3596 ###############################################################################
3601 Image::Magick ref=NO_INIT
3603 CompareImagesLayers = 1
3605 compareimagelayers = 3
3642 PERL_UNUSED_VAR(ref);
3643 PERL_UNUSED_VAR(ix);
3644 exception=AcquireExceptionInfo();
3645 perl_exception=newSVpv("",0);
3647 if (sv_isobject(ST(0)) == 0)
3649 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3653 reference=SvRV(ST(0));
3654 hv=SvSTASH(reference);
3656 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3658 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3659 if (image == (Image *) NULL)
3661 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3665 method=CompareAnyLayer;
3666 for (i=2; i < items; i+=2)
3668 attribute=(char *) SvPV(ST(i-1),na);
3674 if (LocaleCompare(attribute,"method") == 0)
3676 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3680 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3684 method=(LayerMethod) option;
3687 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3693 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3699 image=CompareImagesLayers(image,method,exception);
3700 if (image == (Image *) NULL)
3702 for ( ; image; image=image->next)
3704 AddImageToRegistry(sv,image);
3706 av_push(av,sv_bless(rv,hv));
3709 exception=DestroyExceptionInfo(exception);
3711 SvREFCNT_dec(perl_exception);
3715 InheritPerlException(exception,perl_exception);
3716 exception=DestroyExceptionInfo(exception);
3717 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3718 SvPOK_on(perl_exception);
3719 ST(0)=sv_2mortal(perl_exception);
3724 ###############################################################################
3732 ###############################################################################
3737 Image::Magick ref=NO_INIT
3743 PERL_UNUSED_VAR(ref);
3744 if (sv_isobject(ST(0)) == 0)
3745 croak("ReferenceIsNotMyType");
3746 reference=SvRV(ST(0));
3747 switch (SvTYPE(reference))
3752 message[MaxTextExtent];
3770 Array (AV *) reference
3772 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3773 XS_VERSION,reference);
3774 hv=gv_stashpv(PackageName, FALSE);
3777 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3781 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3783 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3784 DestroyPackageInfo(info);
3786 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3796 Blessed scalar = (Image *) SvIV(reference)
3798 image=INT2PTR(Image *,SvIV(reference));
3799 if (image != (Image *) NULL)
3800 DeleteImageFromRegistry(reference,image);
3809 ###############################################################################
3817 ###############################################################################
3822 Image::Magick ref=NO_INIT
3846 PERL_UNUSED_VAR(ref);
3847 PERL_UNUSED_VAR(ix);
3848 exception=AcquireExceptionInfo();
3849 perl_exception=newSVpv("",0);
3850 package_info=(struct PackageInfo *) NULL;
3851 if (sv_isobject(ST(0)) == 0)
3853 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3857 reference=SvRV(ST(0));
3858 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3859 if (image == (Image *) NULL)
3861 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3865 package_info=ClonePackageInfo(info,exception);
3867 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3870 for (i=2; i < items; i+=2)
3871 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3873 (void) DisplayImages(package_info->image_info,image,exception);
3874 (void) CatchImageException(image);
3877 if (package_info != (struct PackageInfo *) NULL)
3878 DestroyPackageInfo(package_info);
3879 InheritPerlException(exception,perl_exception);
3880 exception=DestroyExceptionInfo(exception);
3881 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3882 SvPOK_on(perl_exception);
3883 ST(0)=sv_2mortal(perl_exception);
3888 ###############################################################################
3892 # E v a l u a t e I m a g e s #
3896 ###############################################################################
3901 Image::Magick ref=NO_INIT
3923 MagickEvaluateOperator
3938 PERL_UNUSED_VAR(ref);
3939 PERL_UNUSED_VAR(ix);
3940 exception=AcquireExceptionInfo();
3941 perl_exception=newSVpv("",0);
3943 if (sv_isobject(ST(0)) == 0)
3945 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3949 reference=SvRV(ST(0));
3950 hv=SvSTASH(reference);
3951 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3952 if (image == (Image *) NULL)
3954 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3958 op=MeanEvaluateOperator;
3964 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3968 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3972 op=(MagickEvaluateOperator) in;
3975 for (i=2; i < items; i+=2)
3977 attribute=(char *) SvPV(ST(i-1),na);
3983 if (LocaleCompare(attribute,"operator") == 0)
3988 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3989 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3992 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3996 op=(MagickEvaluateOperator) in;
3999 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4011 image=EvaluateImages(image,op,exception);
4012 if (image == (Image *) NULL)
4015 Create blessed Perl array for the returned image.
4018 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4020 AddImageToRegistry(sv,image);
4022 av_push(av,sv_bless(rv,hv));
4024 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4025 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4026 "evaluate-%.*s",(int) (MaxTextExtent-9),
4027 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4028 (void) CopyMagickString(image->filename,info->image_info->filename,
4030 SetImageInfo(info->image_info,0,exception);
4031 exception=DestroyExceptionInfo(exception);
4032 SvREFCNT_dec(perl_exception);
4036 InheritPerlException(exception,perl_exception);
4037 exception=DestroyExceptionInfo(exception);
4038 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4039 SvPOK_on(perl_exception);
4040 ST(0)=sv_2mortal(perl_exception);
4045 ###############################################################################
4053 ###############################################################################
4058 Image::Magick ref=NO_INIT
4065 #define ChannelFeatures(channel,direction) \
4067 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4068 channel_features[channel].angular_second_moment[direction]); \
4069 PUSHs(sv_2mortal(newSVpv(message,0))); \
4070 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4071 channel_features[channel].contrast[direction]); \
4072 PUSHs(sv_2mortal(newSVpv(message,0))); \
4073 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4074 channel_features[channel].contrast[direction]); \
4075 PUSHs(sv_2mortal(newSVpv(message,0))); \
4076 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4077 channel_features[channel].variance_sum_of_squares[direction]); \
4078 PUSHs(sv_2mortal(newSVpv(message,0))); \
4079 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4080 channel_features[channel].inverse_difference_moment[direction]); \
4081 PUSHs(sv_2mortal(newSVpv(message,0))); \
4082 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4083 channel_features[channel].sum_average[direction]); \
4084 PUSHs(sv_2mortal(newSVpv(message,0))); \
4085 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4086 channel_features[channel].sum_variance[direction]); \
4087 PUSHs(sv_2mortal(newSVpv(message,0))); \
4088 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4089 channel_features[channel].sum_entropy[direction]); \
4090 PUSHs(sv_2mortal(newSVpv(message,0))); \
4091 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4092 channel_features[channel].entropy[direction]); \
4093 PUSHs(sv_2mortal(newSVpv(message,0))); \
4094 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4095 channel_features[channel].difference_variance[direction]); \
4096 PUSHs(sv_2mortal(newSVpv(message,0))); \
4097 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4098 channel_features[channel].difference_entropy[direction]); \
4099 PUSHs(sv_2mortal(newSVpv(message,0))); \
4100 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4101 channel_features[channel].measure_of_correlation_1[direction]); \
4102 PUSHs(sv_2mortal(newSVpv(message,0))); \
4103 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4104 channel_features[channel].measure_of_correlation_2[direction]); \
4105 PUSHs(sv_2mortal(newSVpv(message,0))); \
4106 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4107 channel_features[channel].maximum_correlation_coefficient[direction]); \
4108 PUSHs(sv_2mortal(newSVpv(message,0))); \
4116 message[MaxTextExtent];
4143 PERL_UNUSED_VAR(ref);
4144 PERL_UNUSED_VAR(ix);
4145 exception=AcquireExceptionInfo();
4146 perl_exception=newSVpv("",0);
4148 if (sv_isobject(ST(0)) == 0)
4150 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4154 reference=SvRV(ST(0));
4157 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4158 if (image == (Image *) NULL)
4160 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4165 for (i=2; i < items; i+=2)
4167 attribute=(char *) SvPV(ST(i-1),na);
4173 if (LocaleCompare(attribute,"distance") == 0)
4175 distance=StringToLong((char *) SvPV(ST(1),na));
4178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4184 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4191 for ( ; image; image=image->next)
4193 channel_features=GetImageFeatures(image,distance,exception);
4194 if (channel_features == (ChannelFeatures *) NULL)
4197 EXTEND(sp,280*count);
4198 for (i=0; i < 4; i++)
4200 ChannelFeatures(RedChannel,i);
4201 ChannelFeatures(GreenChannel,i);
4202 ChannelFeatures(BlueChannel,i);
4203 if (image->colorspace == CMYKColorspace)
4204 ChannelFeatures(BlackChannel,i);
4205 if (image->alpha_trait == BlendPixelTrait)
4206 ChannelFeatures(AlphaChannel,i);
4208 channel_features=(ChannelFeatures *)
4209 RelinquishMagickMemory(channel_features);
4213 InheritPerlException(exception,perl_exception);
4214 exception=DestroyExceptionInfo(exception);
4215 SvREFCNT_dec(perl_exception);
4219 ###############################################################################
4227 ###############################################################################
4232 Image::Magick ref=NO_INIT
4270 PERL_UNUSED_VAR(ref);
4271 PERL_UNUSED_VAR(ix);
4272 exception=AcquireExceptionInfo();
4273 perl_exception=newSVpv("",0);
4275 if (sv_isobject(ST(0)) == 0)
4277 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4281 reference=SvRV(ST(0));
4282 hv=SvSTASH(reference);
4283 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4284 if (image == (Image *) NULL)
4286 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4290 background_color=image->background_color;
4292 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4293 &background_color,exception);
4295 for (i=2; i < items; i+=2)
4297 attribute=(char *) SvPV(ST(i-1),na);
4303 if (LocaleCompare(attribute,"background") == 0)
4305 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4306 AllCompliance,&background_color,exception);
4309 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4315 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4321 image->background_color=background_color;
4322 image=MergeImageLayers(image,FlattenLayer,exception);
4323 if (image == (Image *) NULL)
4326 Create blessed Perl array for the returned image.
4329 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4331 AddImageToRegistry(sv,image);
4333 av_push(av,sv_bless(rv,hv));
4335 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4336 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4337 "flatten-%.*s",(int) (MaxTextExtent-9),
4338 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4339 (void) CopyMagickString(image->filename,info->image_info->filename,
4341 SetImageInfo(info->image_info,0,exception);
4342 exception=DestroyExceptionInfo(exception);
4343 SvREFCNT_dec(perl_exception);
4347 InheritPerlException(exception,perl_exception);
4348 exception=DestroyExceptionInfo(exception);
4349 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4350 SvPOK_on(perl_exception); /* return messages in string context */
4351 ST(0)=sv_2mortal(perl_exception);
4356 ###############################################################################
4364 ###############################################################################
4369 Image::Magick ref=NO_INIT
4381 expression[MaxTextExtent];
4409 PERL_UNUSED_VAR(ref);
4410 PERL_UNUSED_VAR(ix);
4411 exception=AcquireExceptionInfo();
4412 perl_exception=newSVpv("",0);
4416 if (sv_isobject(ST(0)) == 0)
4418 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4422 reference=SvRV(ST(0));
4423 hv=SvSTASH(reference);
4425 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4427 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4428 if (image == (Image *) NULL)
4430 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4434 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4438 channel=DefaultChannels;
4439 (void) CopyMagickString(expression,"u",MaxTextExtent);
4441 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4443 for (i=2; i < items; i+=2)
4445 attribute=(char *) SvPV(ST(i-1),na);
4451 if (LocaleCompare(attribute,"channel") == 0)
4456 option=ParseChannelOption(SvPV(ST(i),na));
4459 ThrowPerlException(exception,OptionError,
4460 "UnrecognizedType",SvPV(ST(i),na));
4463 channel=(ChannelType) option;
4466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4473 if (LocaleCompare(attribute,"expression") == 0)
4475 (void) CopyMagickString(expression,SvPV(ST(i),na),
4479 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4485 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4491 channel_mask=SetImageChannelMask(image,channel);
4492 image=FxImage(image,expression,exception);
4493 if (image != (Image *) NULL)
4494 (void) SetImageChannelMask(image,channel_mask);
4495 if (image == (Image *) NULL)
4497 for ( ; image; image=image->next)
4499 AddImageToRegistry(sv,image);
4501 av_push(av,sv_bless(rv,hv));
4504 exception=DestroyExceptionInfo(exception);
4506 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4510 InheritPerlException(exception,perl_exception);
4511 exception=DestroyExceptionInfo(exception);
4512 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4513 SvPOK_on(perl_exception);
4514 ST(0)=sv_2mortal(perl_exception);
4519 ###############################################################################
4527 ###############################################################################
4532 Image::Magick ref=NO_INIT
4543 color[MaxTextExtent];
4568 PERL_UNUSED_VAR(ref);
4569 PERL_UNUSED_VAR(ix);
4570 exception=AcquireExceptionInfo();
4571 perl_exception=newSVpv("",0);
4572 if (sv_isobject(ST(0)) == 0)
4574 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4578 reference=SvRV(ST(0));
4579 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4580 if (image == (Image *) NULL && !info)
4583 for (i=1; i < items; i++)
4585 attribute=(char *) SvPV(ST(i),na);
4592 if (LocaleCompare(attribute,"adjoin") == 0)
4595 s=newSViv((ssize_t) info->image_info->adjoin);
4596 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4599 if (LocaleCompare(attribute,"antialias") == 0)
4602 s=newSViv((ssize_t) info->image_info->antialias);
4603 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4606 if (LocaleCompare(attribute,"area") == 0)
4608 s=newSViv(GetMagickResource(AreaResource));
4609 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4612 if (LocaleCompare(attribute,"attenuate") == 0)
4617 value=GetImageProperty(image,attribute,exception);
4618 if (value != (const char *) NULL)
4620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4623 if (LocaleCompare(attribute,"authenticate") == 0)
4630 option=GetImageOption(info->image_info,attribute);
4631 if (option != (const char *) NULL)
4632 s=newSVpv(option,0);
4634 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4637 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4644 if (LocaleCompare(attribute,"background") == 0)
4646 if (image == (Image *) NULL)
4648 (void) FormatLocaleString(color,MaxTextExtent,
4649 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4650 (double) image->background_color.green,
4651 (double) image->background_color.blue,
4652 (double) image->background_color.alpha);
4654 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4657 if (LocaleCompare(attribute,"base-columns") == 0)
4659 if (image != (Image *) NULL)
4660 s=newSViv((ssize_t) image->magick_columns);
4661 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4664 if (LocaleCompare(attribute,"base-filename") == 0)
4666 if (image != (Image *) NULL)
4667 s=newSVpv(image->magick_filename,0);
4668 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4671 if (LocaleCompare(attribute,"base-height") == 0)
4673 if (image != (Image *) NULL)
4674 s=newSViv((ssize_t) image->magick_rows);
4675 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4678 if (LocaleCompare(attribute,"base-rows") == 0)
4680 if (image != (Image *) NULL)
4681 s=newSViv((ssize_t) image->magick_rows);
4682 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4685 if (LocaleCompare(attribute,"base-width") == 0)
4687 if (image != (Image *) NULL)
4688 s=newSViv((ssize_t) image->magick_columns);
4689 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4692 if (LocaleCompare(attribute,"blue-primary") == 0)
4694 if (image == (Image *) NULL)
4696 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4697 image->chromaticity.blue_primary.x,
4698 image->chromaticity.blue_primary.y);
4700 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4703 if (LocaleCompare(attribute,"bordercolor") == 0)
4705 if (image == (Image *) NULL)
4707 (void) FormatLocaleString(color,MaxTextExtent,
4708 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4709 (double) image->border_color.green,
4710 (double) image->border_color.blue,
4711 (double) image->border_color.alpha);
4713 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4716 if (LocaleCompare(attribute,"bounding-box") == 0)
4719 geometry[MaxTextExtent];
4724 if (image == (Image *) NULL)
4726 page=GetImageBoundingBox(image,exception);
4727 (void) FormatLocaleString(geometry,MaxTextExtent,
4728 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4729 page.height,(double) page.x,(double) page.y);
4730 s=newSVpv(geometry,0);
4731 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4734 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4741 if (LocaleCompare(attribute,"class") == 0)
4743 if (image == (Image *) NULL)
4745 s=newSViv(image->storage_class);
4746 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4747 image->storage_class));
4749 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4752 if (LocaleCompare(attribute,"clip-mask") == 0)
4754 if (image != (Image *) NULL)
4763 if (image->read_mask == MagickFalse)
4764 ClipImage(image,exception);
4765 mask_image=GetImageMask(image,exception);
4766 if (mask_image != (Image *) NULL)
4768 AddImageToRegistry(sv,mask_image);
4769 s=sv_bless(newRV(sv),SvSTASH(reference));
4772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4775 if (LocaleCompare(attribute,"clip-path") == 0)
4777 if (image != (Image *) NULL)
4786 if (image->read_mask != MagickFalse)
4787 ClipImage(image,exception);
4788 mask_image=GetImageMask(image,exception);
4789 if (mask_image != (Image *) NULL)
4791 AddImageToRegistry(sv,mask_image);
4792 s=sv_bless(newRV(sv),SvSTASH(reference));
4795 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4798 if (LocaleCompare(attribute,"compression") == 0)
4800 j=info ? info->image_info->compression : image ?
4801 image->compression : UndefinedCompression;
4803 if (info->image_info->compression == UndefinedCompression)
4804 j=image->compression;
4806 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4809 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4812 if (LocaleCompare(attribute,"colorspace") == 0)
4814 j=image ? image->colorspace : RGBColorspace;
4816 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4819 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4822 if (LocaleCompare(attribute,"colors") == 0)
4824 if (image != (Image *) NULL)
4825 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4827 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4830 if (LocaleNCompare(attribute,"colormap",8) == 0)
4835 if (image == (Image *) NULL || !image->colormap)
4838 items=sscanf(attribute,"%*[^[][%ld",&j);
4840 if (j > (ssize_t) image->colors)
4842 (void) FormatLocaleString(color,MaxTextExtent,
4843 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4844 (double) image->colormap[j].green,
4845 (double) image->colormap[j].blue,
4846 (double) image->colormap[j].alpha);
4848 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4851 if (LocaleCompare(attribute,"columns") == 0)
4853 if (image != (Image *) NULL)
4854 s=newSViv((ssize_t) image->columns);
4855 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4858 if (LocaleCompare(attribute,"comment") == 0)
4863 value=GetImageProperty(image,attribute,exception);
4864 if (value != (const char *) NULL)
4866 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4869 if (LocaleCompare(attribute,"copyright") == 0)
4871 s=newSVpv(GetMagickCopyright(),0);
4872 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4875 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4882 if (LocaleCompare(attribute,"density") == 0)
4885 geometry[MaxTextExtent];
4887 if (image == (Image *) NULL)
4889 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4890 image->resolution.x,image->resolution.y);
4891 s=newSVpv(geometry,0);
4892 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4895 if (LocaleCompare(attribute,"delay") == 0)
4897 if (image != (Image *) NULL)
4898 s=newSViv((ssize_t) image->delay);
4899 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4902 if (LocaleCompare(attribute,"depth") == 0)
4904 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4905 if (image != (Image *) NULL)
4906 s=newSViv((ssize_t) GetImageDepth(image,exception));
4907 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4910 if (LocaleCompare(attribute,"directory") == 0)
4912 if (image && image->directory)
4913 s=newSVpv(image->directory,0);
4914 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4917 if (LocaleCompare(attribute,"dispose") == 0)
4919 if (image == (Image *) NULL)
4922 s=newSViv(image->dispose);
4924 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4926 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4929 if (LocaleCompare(attribute,"disk") == 0)
4931 s=newSViv(GetMagickResource(DiskResource));
4932 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4935 if (LocaleCompare(attribute,"dither") == 0)
4938 s=newSViv((ssize_t) info->image_info->dither);
4939 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4942 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4944 if (info && info->image_info->server_name)
4945 s=newSVpv(info->image_info->server_name,0);
4946 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4949 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4956 if (LocaleCompare(attribute,"elapsed-time") == 0)
4958 if (image != (Image *) NULL)
4959 s=newSVnv(GetElapsedTime(&image->timer));
4960 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4963 if (LocaleCompare(attribute,"endian") == 0)
4965 j=info ? info->image_info->endian : image ? image->endian :
4968 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4970 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4973 if (LocaleCompare(attribute,"error") == 0)
4975 if (image != (Image *) NULL)
4976 s=newSVnv(image->error.mean_error_per_pixel);
4977 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4980 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4987 if (LocaleCompare(attribute,"filesize") == 0)
4989 if (image != (Image *) NULL)
4990 s=newSViv((ssize_t) GetBlobSize(image));
4991 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4994 if (LocaleCompare(attribute,"filename") == 0)
4996 if (info && info->image_info->filename &&
4997 *info->image_info->filename)
4998 s=newSVpv(info->image_info->filename,0);
4999 if (image != (Image *) NULL)
5000 s=newSVpv(image->filename,0);
5001 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5004 if (LocaleCompare(attribute,"filter") == 0)
5006 s=image ? newSViv(image->filter) : newSViv(0);
5007 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5010 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5013 if (LocaleCompare(attribute,"font") == 0)
5015 if (info && info->image_info->font)
5016 s=newSVpv(info->image_info->font,0);
5017 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5020 if (LocaleCompare(attribute,"foreground") == 0)
5022 if (LocaleCompare(attribute,"format") == 0)
5027 magick_info=(const MagickInfo *) NULL;
5028 if (info && (*info->image_info->magick != '\0'))
5029 magick_info=GetMagickInfo(info->image_info->magick,exception);
5030 if (image != (Image *) NULL)
5031 magick_info=GetMagickInfo(image->magick,exception);
5032 if ((magick_info != (const MagickInfo *) NULL) &&
5033 (*magick_info->description != '\0'))
5034 s=newSVpv((char *) magick_info->description,0);
5035 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5038 if (LocaleCompare(attribute,"fuzz") == 0)
5041 s=newSVnv(info->image_info->fuzz);
5042 if (image != (Image *) NULL)
5043 s=newSVnv(image->fuzz);
5044 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5047 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5054 if (LocaleCompare(attribute,"gamma") == 0)
5056 if (image != (Image *) NULL)
5057 s=newSVnv(image->gamma);
5058 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5061 if (LocaleCompare(attribute,"geometry") == 0)
5063 if (image && image->geometry)
5064 s=newSVpv(image->geometry,0);
5065 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5068 if (LocaleCompare(attribute,"gravity") == 0)
5070 s=image ? newSViv(image->gravity) : newSViv(0);
5071 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5074 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5077 if (LocaleCompare(attribute,"green-primary") == 0)
5079 if (image == (Image *) NULL)
5081 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5082 image->chromaticity.green_primary.x,
5083 image->chromaticity.green_primary.y);
5085 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5088 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5095 if (LocaleCompare(attribute,"height") == 0)
5097 if (image != (Image *) NULL)
5098 s=newSViv((ssize_t) image->rows);
5099 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5102 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5109 if (LocaleCompare(attribute,"icc") == 0)
5111 if (image != (Image *) NULL)
5116 profile=GetImageProfile(image,"icc");
5117 if (profile != (StringInfo *) NULL)
5118 s=newSVpv((const char *) GetStringInfoDatum(profile),
5119 GetStringInfoLength(profile));
5121 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5124 if (LocaleCompare(attribute,"icm") == 0)
5126 if (image != (Image *) NULL)
5131 profile=GetImageProfile(image,"icm");
5132 if (profile != (const StringInfo *) NULL)
5133 s=newSVpv((const char *) GetStringInfoDatum(profile),
5134 GetStringInfoLength(profile));
5136 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5139 if (LocaleCompare(attribute,"id") == 0)
5141 if (image != (Image *) NULL)
5152 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
5154 status=SetImageRegistry(ImageRegistryType,key,image,
5159 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5162 if (LocaleNCompare(attribute,"index",5) == 0)
5165 name[MaxTextExtent];
5174 register const Quantum
5180 if (image == (Image *) NULL)
5182 if (image->storage_class != PseudoClass)
5186 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5188 image_view=AcquireVirtualCacheView(image,exception);
5189 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5190 if (p != (const Quantum *) NULL)
5192 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5193 GetPixelIndex(image,p));
5195 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5197 image_view=DestroyCacheView(image_view);
5200 if (LocaleCompare(attribute,"iptc") == 0)
5202 if (image != (Image *) NULL)
5207 profile=GetImageProfile(image,"iptc");
5208 if (profile != (const StringInfo *) NULL)
5209 s=newSVpv((const char *) GetStringInfoDatum(profile),
5210 GetStringInfoLength(profile));
5212 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5215 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5217 if (image != (Image *) NULL)
5218 s=newSViv((ssize_t) image->iterations);
5219 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5222 if (LocaleCompare(attribute,"interlace") == 0)
5224 j=info ? info->image_info->interlace : image ? image->interlace :
5227 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5230 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5233 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5240 if (LocaleCompare(attribute,"label") == 0)
5245 if (image == (Image *) NULL)
5247 value=GetImageProperty(image,"Label",exception);
5248 if (value != (const char *) NULL)
5250 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5253 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5255 if (image != (Image *) NULL)
5256 s=newSViv((ssize_t) image->iterations);
5257 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5267 if (LocaleCompare(attribute,"magick") == 0)
5269 if (info && *info->image_info->magick)
5270 s=newSVpv(info->image_info->magick,0);
5271 if (image != (Image *) NULL)
5272 s=newSVpv(image->magick,0);
5273 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5276 if (LocaleCompare(attribute,"map") == 0)
5278 s=newSViv(GetMagickResource(MapResource));
5279 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5282 if (LocaleCompare(attribute,"maximum-error") == 0)
5284 if (image != (Image *) NULL)
5285 s=newSVnv(image->error.normalized_maximum_error);
5286 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5289 if (LocaleCompare(attribute,"memory") == 0)
5291 s=newSViv(GetMagickResource(MemoryResource));
5292 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5295 if (LocaleCompare(attribute,"mean-error") == 0)
5297 if (image != (Image *) NULL)
5298 s=newSVnv(image->error.normalized_mean_error);
5299 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5302 if (LocaleCompare(attribute,"mime") == 0)
5304 if (info && *info->image_info->magick)
5305 s=newSVpv(MagickToMime(info->image_info->magick),0);
5306 if (image != (Image *) NULL)
5307 s=newSVpv(MagickToMime(image->magick),0);
5308 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5311 if (LocaleCompare(attribute,"mattecolor") == 0)
5313 if (image == (Image *) NULL)
5315 (void) FormatLocaleString(color,MaxTextExtent,
5316 "%.20g,%.20g,%.20g,%.20g",(double) image->matte_color.red,
5317 (double) image->matte_color.green,
5318 (double) image->matte_color.blue,
5319 (double) image->matte_color.alpha);
5321 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5324 if (LocaleCompare(attribute,"matte") == 0)
5326 if (image != (Image *) NULL)
5327 s=newSViv((ssize_t) image->alpha_trait == BlendPixelTrait ?
5329 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5332 if (LocaleCompare(attribute,"mime") == 0)
5338 if (info && *info->image_info->magick)
5339 magick=info->image_info->magick;
5340 if (image != (Image *) NULL)
5341 magick=image->magick;
5347 mime=MagickToMime(magick);
5349 mime=(char *) RelinquishMagickMemory(mime);
5351 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5354 if (LocaleCompare(attribute,"monochrome") == 0)
5356 if (image == (Image *) NULL)
5358 j=info ? info->image_info->monochrome :
5359 IsImageMonochrome(image,exception);
5361 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5364 if (LocaleCompare(attribute,"montage") == 0)
5366 if (image && image->montage)
5367 s=newSVpv(image->montage,0);
5368 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5371 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5378 if (LocaleCompare(attribute,"orientation") == 0)
5380 j=info ? info->image_info->orientation : image ?
5381 image->orientation : UndefinedOrientation;
5383 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5386 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5389 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5396 if (LocaleCompare(attribute,"page") == 0)
5398 if (info && info->image_info->page)
5399 s=newSVpv(info->image_info->page,0);
5400 if (image != (Image *) NULL)
5403 geometry[MaxTextExtent];
5405 (void) FormatLocaleString(geometry,MaxTextExtent,
5406 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5407 (double) image->page.height,(double) image->page.x,(double)
5409 s=newSVpv(geometry,0);
5411 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5414 if (LocaleCompare(attribute,"page.x") == 0)
5416 if (image != (Image *) NULL)
5417 s=newSViv((ssize_t) image->page.x);
5418 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5421 if (LocaleCompare(attribute,"page.y") == 0)
5423 if (image != (Image *) NULL)
5424 s=newSViv((ssize_t) image->page.y);
5425 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5428 if (LocaleNCompare(attribute,"pixel",5) == 0)
5431 tuple[MaxTextExtent];
5440 register const Quantum
5443 if (image == (Image *) NULL)
5447 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5449 p=GetVirtualPixels(image,x,y,1,1,exception);
5450 if (image->colorspace != CMYKColorspace)
5451 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5452 QuantumFormat "," QuantumFormat "," QuantumFormat,
5453 GetPixelRed(image,p),GetPixelGreen(image,p),
5454 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5456 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5457 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5458 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5459 GetPixelBlue(image,p),GetPixelBlack(image,p),
5460 GetPixelAlpha(image,p));
5462 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5465 if (LocaleCompare(attribute,"pointsize") == 0)
5468 s=newSViv((ssize_t) info->image_info->pointsize);
5469 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5472 if (LocaleCompare(attribute,"preview") == 0)
5474 s=newSViv(info->image_info->preview_type);
5475 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5476 info->image_info->preview_type));
5478 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5481 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5488 if (LocaleCompare(attribute,"quality") == 0)
5491 s=newSViv((ssize_t) info->image_info->quality);
5492 if (image != (Image *) NULL)
5493 s=newSViv((ssize_t) image->quality);
5494 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5497 if (LocaleCompare(attribute,"quantum") == 0)
5500 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5501 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5504 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5511 if (LocaleCompare(attribute,"rendering-intent") == 0)
5513 s=newSViv(image->rendering_intent);
5514 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5515 image->rendering_intent));
5517 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5520 if (LocaleCompare(attribute,"red-primary") == 0)
5522 if (image == (Image *) NULL)
5524 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5525 image->chromaticity.red_primary.x,
5526 image->chromaticity.red_primary.y);
5528 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5531 if (LocaleCompare(attribute,"rows") == 0)
5533 if (image != (Image *) NULL)
5534 s=newSViv((ssize_t) image->rows);
5535 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5538 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5545 if (LocaleCompare(attribute,"sampling-factor") == 0)
5547 if (info && info->image_info->sampling_factor)
5548 s=newSVpv(info->image_info->sampling_factor,0);
5549 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5552 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5554 if (info && info->image_info->server_name)
5555 s=newSVpv(info->image_info->server_name,0);
5556 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5559 if (LocaleCompare(attribute,"size") == 0)
5561 if (info && info->image_info->size)
5562 s=newSVpv(info->image_info->size,0);
5563 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5566 if (LocaleCompare(attribute,"scene") == 0)
5568 if (image != (Image *) NULL)
5569 s=newSViv((ssize_t) image->scene);
5570 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5573 if (LocaleCompare(attribute,"scenes") == 0)
5575 if (image != (Image *) NULL)
5576 s=newSViv((ssize_t) info->image_info->number_scenes);
5577 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5580 if (LocaleCompare(attribute,"signature") == 0)
5585 if (image == (Image *) NULL)
5587 (void) SignatureImage(image,exception);
5588 value=GetImageProperty(image,"Signature",exception);
5589 if (value != (const char *) NULL)
5591 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5594 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5601 if (LocaleCompare(attribute,"taint") == 0)
5603 if (image != (Image *) NULL)
5604 s=newSViv((ssize_t) IsTaintImage(image));
5605 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5608 if (LocaleCompare(attribute,"texture") == 0)
5610 if (info && info->image_info->texture)
5611 s=newSVpv(info->image_info->texture,0);
5612 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5615 if (LocaleCompare(attribute,"total-ink-density") == 0)
5617 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5618 if (image != (Image *) NULL)
5619 s=newSVnv(GetImageTotalInkDensity(image,exception));
5620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5623 if (LocaleCompare(attribute,"transparent-color") == 0)
5625 if (image == (Image *) NULL)
5627 (void) FormatLocaleString(color,MaxTextExtent,
5628 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5629 (double) image->transparent_color.green,
5630 (double) image->transparent_color.blue,
5631 (double) image->transparent_color.alpha);
5633 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5636 if (LocaleCompare(attribute,"type") == 0)
5638 if (image == (Image *) NULL)
5640 j=(ssize_t) GetImageType(image,exception);
5642 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5644 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5647 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5654 if (LocaleCompare(attribute,"units") == 0)
5656 j=info ? info->image_info->units : image ? image->units :
5657 UndefinedResolution;
5658 if (info && (info->image_info->units == UndefinedResolution))
5661 if (j == UndefinedResolution)
5662 s=newSVpv("undefined units",0);
5664 if (j == PixelsPerInchResolution)
5665 s=newSVpv("pixels / inch",0);
5667 s=newSVpv("pixels / centimeter",0);
5668 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5671 if (LocaleCompare(attribute,"user-time") == 0)
5673 if (image != (Image *) NULL)
5674 s=newSVnv(GetUserTime(&image->timer));
5675 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5678 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5685 if (LocaleCompare(attribute,"verbose") == 0)
5688 s=newSViv((ssize_t) info->image_info->verbose);
5689 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5692 if (LocaleCompare(attribute,"version") == 0)
5694 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5695 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5698 if (LocaleCompare(attribute,"view") == 0)
5700 if (info && info->image_info->view)
5701 s=newSVpv(info->image_info->view,0);
5702 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5705 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5707 if (image == (Image *) NULL)
5709 j=(ssize_t) GetImageVirtualPixelMethod(image);
5711 (void) sv_setpv(s,CommandOptionToMnemonic(
5712 MagickVirtualPixelOptions,j));
5714 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5717 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5724 if (LocaleCompare(attribute,"white-point") == 0)
5726 if (image == (Image *) NULL)
5728 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5729 image->chromaticity.white_point.x,
5730 image->chromaticity.white_point.y);
5732 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5735 if (LocaleCompare(attribute,"width") == 0)
5737 if (image != (Image *) NULL)
5738 s=newSViv((ssize_t) image->columns);
5739 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5742 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5749 if (LocaleCompare(attribute,"x-resolution") == 0)
5751 if (image != (Image *) NULL)
5752 s=newSVnv(image->resolution.x);
5753 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5763 if (LocaleCompare(attribute,"y-resolution") == 0)
5765 if (image != (Image *) NULL)
5766 s=newSVnv(image->resolution.y);
5767 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5770 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5777 if (image == (Image *) NULL)
5778 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5782 value=GetImageProperty(image,attribute,exception);
5783 if (value != (const char *) NULL)
5786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5789 if (*attribute != '%')
5790 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5797 meta=InterpretImageProperties(info ? info->image_info :
5798 (ImageInfo *) NULL,image,attribute,exception);
5800 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5801 meta=(char *) RelinquishMagickMemory(meta);
5805 exception=DestroyExceptionInfo(exception);
5806 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5810 ###############################################################################
5814 # G e t A u t h e n t i c P i x e l s #
5818 ###############################################################################
5822 GetAuthenticPixels(ref,...)
5823 Image::Magick ref = NO_INIT
5825 getauthenticpixels = 1
5855 PERL_UNUSED_VAR(ref);
5856 PERL_UNUSED_VAR(ix);
5857 exception=AcquireExceptionInfo();
5858 perl_exception=newSVpv("",0);
5859 if (sv_isobject(ST(0)) == 0)
5861 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5865 reference=SvRV(ST(0));
5867 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5868 if (image == (Image *) NULL)
5870 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5877 region.width=image->columns;
5880 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5881 for (i=2; i < items; i+=2)
5883 attribute=(char *) SvPV(ST(i-1),na);
5889 if (LocaleCompare(attribute,"geometry") == 0)
5891 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5894 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5901 if (LocaleCompare(attribute,"height") == 0)
5903 region.height=SvIV(ST(i));
5906 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5913 if (LocaleCompare(attribute,"x") == 0)
5915 region.x=SvIV(ST(i));
5918 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5925 if (LocaleCompare(attribute,"y") == 0)
5927 region.y=SvIV(ST(i));
5930 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5937 if (LocaleCompare(attribute,"width") == 0)
5939 region.width=SvIV(ST(i));
5942 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5948 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5949 region.height,exception);
5950 if (blob != (void *) NULL)
5954 InheritPerlException(exception,perl_exception);
5955 exception=DestroyExceptionInfo(exception);
5956 SvREFCNT_dec(perl_exception); /* throw away all errors */
5965 ###############################################################################
5969 # G e t V i r t u a l P i x e l s #
5973 ###############################################################################
5977 GetVirtualPixels(ref,...)
5978 Image::Magick ref = NO_INIT
5980 getvirtualpixels = 1
5981 AcquireImagePixels = 2
5982 acquireimagepixels = 3
6010 PERL_UNUSED_VAR(ref);
6011 PERL_UNUSED_VAR(ix);
6012 exception=AcquireExceptionInfo();
6013 perl_exception=newSVpv("",0);
6014 if (sv_isobject(ST(0)) == 0)
6016 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6020 reference=SvRV(ST(0));
6022 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6023 if (image == (Image *) NULL)
6025 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6032 region.width=image->columns;
6035 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6036 for (i=2; i < items; i+=2)
6038 attribute=(char *) SvPV(ST(i-1),na);
6044 if (LocaleCompare(attribute,"geometry") == 0)
6046 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6049 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6056 if (LocaleCompare(attribute,"height") == 0)
6058 region.height=SvIV(ST(i));
6061 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6068 if (LocaleCompare(attribute,"x") == 0)
6070 region.x=SvIV(ST(i));
6073 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6080 if (LocaleCompare(attribute,"y") == 0)
6082 region.y=SvIV(ST(i));
6085 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6092 if (LocaleCompare(attribute,"width") == 0)
6094 region.width=SvIV(ST(i));
6097 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6103 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6104 region.height,exception);
6105 if (blob != (void *) NULL)
6109 InheritPerlException(exception,perl_exception);
6110 exception=DestroyExceptionInfo(exception);
6111 SvREFCNT_dec(perl_exception); /* throw away all errors */
6114 RETVAL = (void *) blob;
6120 ###############################################################################
6124 # G e t A u t h e n t i c M e t a c o n t e n t #
6128 ###############################################################################
6132 GetAuthenticMetacontent(ref,...)
6133 Image::Magick ref = NO_INIT
6135 getauthenticmetacontent = 1
6156 PERL_UNUSED_VAR(ref);
6157 PERL_UNUSED_VAR(ix);
6158 exception=AcquireExceptionInfo();
6159 perl_exception=newSVpv("",0);
6160 if (sv_isobject(ST(0)) == 0)
6162 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6166 reference=SvRV(ST(0));
6168 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6169 if (image == (Image *) NULL)
6171 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6176 blob=(void *) GetAuthenticMetacontent(image);
6177 if (blob != (void *) NULL)
6181 InheritPerlException(exception,perl_exception);
6182 exception=DestroyExceptionInfo(exception);
6183 SvREFCNT_dec(perl_exception); /* throw away all errors */
6192 ###############################################################################
6196 # G e t V i r t u a l M e t a c o n t e n t #
6200 ###############################################################################
6204 GetVirtualMetacontent(ref,...)
6205 Image::Magick ref = NO_INIT
6207 getvirtualmetacontent = 1
6226 PERL_UNUSED_VAR(ref);
6227 PERL_UNUSED_VAR(ix);
6228 exception=AcquireExceptionInfo();
6229 perl_exception=newSVpv("",0);
6230 if (sv_isobject(ST(0)) == 0)
6232 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6236 reference=SvRV(ST(0));
6238 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6239 if (image == (Image *) NULL)
6241 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6246 blob=(void *) GetVirtualMetacontent(image);
6247 if (blob != (void *) NULL)
6251 InheritPerlException(exception,perl_exception);
6252 exception=DestroyExceptionInfo(exception);
6253 SvREFCNT_dec(perl_exception); /* throw away all errors */
6262 ###############################################################################
6266 # H i s t o g r a m #
6270 ###############################################################################
6275 Image::Magick ref=NO_INIT
6286 message[MaxTextExtent];
6313 PERL_UNUSED_VAR(ref);
6314 PERL_UNUSED_VAR(ix);
6315 exception=AcquireExceptionInfo();
6316 perl_exception=newSVpv("",0);
6318 if (sv_isobject(ST(0)) == 0)
6320 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6324 reference=SvRV(ST(0));
6327 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6328 if (image == (Image *) NULL)
6330 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6335 for ( ; image; image=image->next)
6337 histogram=GetImageHistogram(image,&number_colors,exception);
6338 if (histogram == (PixelInfo *) NULL)
6340 count+=(ssize_t) number_colors;
6342 for (i=0; i < (ssize_t) number_colors; i++)
6344 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6346 PUSHs(sv_2mortal(newSVpv(message,0)));
6347 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6348 histogram[i].green);
6349 PUSHs(sv_2mortal(newSVpv(message,0)));
6350 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6352 PUSHs(sv_2mortal(newSVpv(message,0)));
6353 if (image->colorspace == CMYKColorspace)
6355 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6356 histogram[i].black);
6357 PUSHs(sv_2mortal(newSVpv(message,0)));
6359 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6360 histogram[i].alpha);
6361 PUSHs(sv_2mortal(newSVpv(message,0)));
6362 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6363 histogram[i].count);
6364 PUSHs(sv_2mortal(newSVpv(message,0)));
6366 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6370 InheritPerlException(exception,perl_exception);
6371 exception=DestroyExceptionInfo(exception);
6372 SvREFCNT_dec(perl_exception);
6376 ###############################################################################
6384 ###############################################################################
6389 Image::Magick ref=NO_INIT
6413 register const Quantum
6427 *reference; /* reference is the SV* of ref=SvIV(reference) */
6429 PERL_UNUSED_VAR(ref);
6430 PERL_UNUSED_VAR(ix);
6431 exception=AcquireExceptionInfo();
6432 perl_exception=newSVpv("",0);
6433 reference=SvRV(ST(0));
6434 av=(AV *) reference;
6435 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6437 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6438 if (image == (Image *) NULL)
6440 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6444 normalize=MagickTrue;
6447 region.width=image->columns;
6450 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6451 for (i=2; i < items; i+=2)
6453 attribute=(char *) SvPV(ST(i-1),na);
6459 if (LocaleCompare(attribute,"channel") == 0)
6464 option=ParseChannelOption(SvPV(ST(i),na));
6467 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6471 SetPixelChannelMask(image,(ChannelType) option);
6474 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6481 if (LocaleCompare(attribute,"geometry") == 0)
6483 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6486 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6493 if (LocaleCompare(attribute,"normalize") == 0)
6495 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6499 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6503 normalize=option != 0 ? MagickTrue : MagickFalse;
6506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6513 if (LocaleCompare(attribute,"x") == 0)
6515 region.x=SvIV(ST(i));
6518 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6525 if (LocaleCompare(attribute,"y") == 0)
6527 region.y=SvIV(ST(i));
6530 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6536 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6542 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6543 if (p == (const Quantum *) NULL)
6551 if (normalize != MagickFalse)
6552 scale=1.0/QuantumRange;
6553 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6554 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6555 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6556 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6557 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6558 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6559 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6560 (image->colorspace == CMYKColorspace))
6561 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6562 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6563 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6567 InheritPerlException(exception,perl_exception);
6568 exception=DestroyExceptionInfo(exception);
6569 SvREFCNT_dec(perl_exception);
6573 ###############################################################################
6577 # G e t P i x e l s #
6581 ###############################################################################
6586 Image::Magick ref=NO_INIT
6625 *reference; /* reference is the SV* of ref=SvIV(reference) */
6627 PERL_UNUSED_VAR(ref);
6628 PERL_UNUSED_VAR(ix);
6629 exception=AcquireExceptionInfo();
6630 perl_exception=newSVpv("",0);
6631 reference=SvRV(ST(0));
6632 av=(AV *) reference;
6633 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6635 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6636 if (image == (Image *) NULL)
6638 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6643 if (image->alpha_trait == BlendPixelTrait)
6645 if (image->colorspace == CMYKColorspace)
6648 if (image->alpha_trait == BlendPixelTrait)
6651 normalize=MagickFalse;
6654 region.width=image->columns;
6657 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6658 for (i=2; i < items; i+=2)
6660 attribute=(char *) SvPV(ST(i-1),na);
6666 if (LocaleCompare(attribute,"geometry") == 0)
6668 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6671 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6678 if (LocaleCompare(attribute,"height") == 0)
6680 region.height=SvIV(ST(i));
6683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6690 if (LocaleCompare(attribute,"map") == 0)
6695 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6702 if (LocaleCompare(attribute,"normalize") == 0)
6704 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6708 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6712 normalize=option != 0 ? MagickTrue : MagickFalse;
6715 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6722 if (LocaleCompare(attribute,"width") == 0)
6724 region.width=SvIV(ST(i));
6727 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6734 if (LocaleCompare(attribute,"x") == 0)
6736 region.x=SvIV(ST(i));
6739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6746 if (LocaleCompare(attribute,"y") == 0)
6748 region.y=SvIV(ST(i));
6751 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6757 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6763 if (normalize != MagickFalse)
6768 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6769 region.height*sizeof(*pixels));
6770 if (pixels == (float *) NULL)
6772 ThrowPerlException(exception,ResourceLimitError,
6773 "MemoryAllocationFailed",PackageName);
6776 status=ExportImagePixels(image,region.x,region.y,region.width,
6777 region.height,map,FloatPixel,pixels,exception);
6778 if (status == MagickFalse)
6782 EXTEND(sp,strlen(map)*region.width*region.height);
6783 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6784 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6786 pixels=(float *) RelinquishMagickMemory(pixels);
6793 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6794 region.height*sizeof(*pixels));
6795 if (pixels == (Quantum *) NULL)
6797 ThrowPerlException(exception,ResourceLimitError,
6798 "MemoryAllocationFailed",PackageName);
6801 status=ExportImagePixels(image,region.x,region.y,region.width,
6802 region.height,map,QuantumPixel,pixels,exception);
6803 if (status == MagickFalse)
6807 EXTEND(sp,strlen(map)*region.width*region.height);
6808 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6809 PUSHs(sv_2mortal(newSViv(pixels[i])));
6811 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6815 InheritPerlException(exception,perl_exception);
6816 exception=DestroyExceptionInfo(exception);
6817 SvREFCNT_dec(perl_exception);
6821 ###############################################################################
6825 # I m a g e T o B l o b #
6829 ###############################################################################
6833 ImageToBlob(ref,...)
6834 Image::Magick ref=NO_INIT
6843 filename[MaxTextExtent];
6872 PERL_UNUSED_VAR(ref);
6873 PERL_UNUSED_VAR(ix);
6874 exception=AcquireExceptionInfo();
6875 perl_exception=newSVpv("",0);
6876 package_info=(struct PackageInfo *) NULL;
6877 if (sv_isobject(ST(0)) == 0)
6879 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6883 reference=SvRV(ST(0));
6884 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6885 if (image == (Image *) NULL)
6887 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6891 package_info=ClonePackageInfo(info,exception);
6892 for (i=2; i < items; i+=2)
6893 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6894 (void) CopyMagickString(filename,package_info->image_info->filename,
6897 for (next=image; next; next=next->next)
6899 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6900 next->scene=scene++;
6902 SetImageInfo(package_info->image_info,(unsigned int)
6903 GetImageListLength(image),exception);
6904 EXTEND(sp,(ssize_t) GetImageListLength(image));
6905 for ( ; image; image=image->next)
6908 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6909 if (blob != (char *) NULL)
6911 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6912 blob=(unsigned char *) RelinquishMagickMemory(blob);
6914 if (package_info->image_info->adjoin)
6919 if (package_info != (struct PackageInfo *) NULL)
6920 DestroyPackageInfo(package_info);
6921 InheritPerlException(exception,perl_exception);
6922 exception=DestroyExceptionInfo(exception);
6923 SvREFCNT_dec(perl_exception); /* throw away all errors */
6927 ###############################################################################
6935 ###############################################################################
6940 Image::Magick ref=NO_INIT
6944 OptimizeImageLayers = 3
6946 optimizeimagelayers = 5
6988 PERL_UNUSED_VAR(ref);
6989 PERL_UNUSED_VAR(ix);
6990 exception=AcquireExceptionInfo();
6991 perl_exception=newSVpv("",0);
6993 if (sv_isobject(ST(0)) == 0)
6995 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6999 reference=SvRV(ST(0));
7000 hv=SvSTASH(reference);
7002 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7004 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7005 if (image == (Image *) NULL)
7007 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7011 compose=image->compose;
7012 method=OptimizeLayer;
7013 for (i=2; i < items; i+=2)
7015 attribute=(char *) SvPV(ST(i-1),na);
7021 if (LocaleCompare(attribute,"compose") == 0)
7023 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7024 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7027 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7031 compose=(CompositeOperator) sp;
7034 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7041 if (LocaleCompare(attribute,"method") == 0)
7043 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7047 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7051 method=(LayerMethod) option;
7054 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7060 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7066 layers=(Image *) NULL;
7069 case CompareAnyLayer:
7070 case CompareClearLayer:
7071 case CompareOverlayLayer:
7074 layers=CompareImagesLayers(image,method,exception);
7081 layers=MergeImageLayers(image,method,exception);
7086 layers=DisposeImages(image,exception);
7089 case OptimizeImageLayer:
7091 layers=OptimizeImageLayers(image,exception);
7094 case OptimizePlusLayer:
7096 layers=OptimizePlusImageLayers(image,exception);
7099 case OptimizeTransLayer:
7101 OptimizeImageTransparency(image,exception);
7104 case RemoveDupsLayer:
7106 RemoveDuplicateLayers(&image,exception);
7109 case RemoveZeroLayer:
7111 RemoveZeroDelayLayers(&image,exception);
7120 General Purpose, GIF Animation Optimizer.
7122 layers=CoalesceImages(image,exception);
7123 if (layers == (Image *) NULL)
7126 layers=OptimizeImageLayers(image,exception);
7127 if (layers == (Image *) NULL)
7129 image=DestroyImageList(image);
7131 layers=(Image *) NULL;
7132 OptimizeImageTransparency(image,exception);
7133 quantize_info=AcquireQuantizeInfo(info->image_info);
7134 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7135 quantize_info=DestroyQuantizeInfo(quantize_info);
7138 case CompositeLayer:
7147 Split image sequence at the first 'NULL:' image.
7150 while (source != (Image *) NULL)
7152 source=GetNextImageInList(source);
7153 if ((source != (Image *) NULL) &&
7154 (LocaleCompare(source->magick,"NULL") == 0))
7157 if (source != (Image *) NULL)
7159 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7160 (GetNextImageInList(source) == (Image *) NULL))
7161 source=(Image *) NULL;
7165 Separate the two lists, junk the null: image.
7167 source=SplitImageList(source->previous);
7168 DeleteImageFromList(&source);
7171 if (source == (Image *) NULL)
7173 (void) ThrowMagickException(exception,GetMagickModule(),
7174 OptionError,"MissingNullSeparator","layers Composite");
7178 Adjust offset with gravity and virtual canvas.
7180 SetGeometry(image,&geometry);
7181 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7182 geometry.width=source->page.width != 0 ? source->page.width :
7184 geometry.height=source->page.height != 0 ? source->page.height :
7186 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7187 image->columns,image->page.height != 0 ? image->page.height :
7188 image->rows,image->gravity,&geometry);
7189 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7190 source=DestroyImageList(source);
7194 if (layers != (Image *) NULL)
7197 image=CloneImage(image,0,0,MagickTrue,exception);
7198 if (image == (Image *) NULL)
7200 for ( ; image; image=image->next)
7202 AddImageToRegistry(sv,image);
7204 av_push(av,sv_bless(rv,hv));
7207 exception=DestroyExceptionInfo(exception);
7209 SvREFCNT_dec(perl_exception);
7213 InheritPerlException(exception,perl_exception);
7214 exception=DestroyExceptionInfo(exception);
7215 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7216 SvPOK_on(perl_exception);
7217 ST(0)=sv_2mortal(perl_exception);
7222 ###############################################################################
7226 # M a g i c k T o M i m e #
7230 ###############################################################################
7234 MagickToMime(ref,name)
7235 Image::Magick ref=NO_INIT
7244 PERL_UNUSED_VAR(ref);
7245 PERL_UNUSED_VAR(ix);
7246 mime=MagickToMime(name);
7247 RETVAL=newSVpv(mime,0);
7248 mime=(char *) RelinquishMagickMemory(mime);
7254 ###############################################################################
7262 ###############################################################################
7267 Image::Magick ref=NO_INIT
7304 MedianConvolveImage = 36
7310 ReduceNoiseImage = 42
7336 ColorFloodfillImage= 68
7342 CycleColormapImage = 74
7352 MatteFloodfillImage= 84
7360 NumberColorsImage = 92
7370 SignatureImage = 102
7380 TransparentImage = 112
7382 ThresholdImage = 114
7396 DeconstructImage = 130
7398 GaussianBlurImage = 132
7404 UnsharpMaskImage = 138
7406 MotionBlurImage = 140
7408 OrderedDitherImage = 142
7415 AffineTransform = 149
7416 AffineTransformImage = 150
7418 DifferenceImage = 152
7419 AdaptiveThreshold = 153
7420 AdaptiveThresholdImage = 154
7425 BlackThreshold = 159
7426 BlackThresholdImage= 160
7427 WhiteThreshold = 161
7428 WhiteThresholdImage= 162
7429 RotationalBlur = 163
7430 RotationalBlurImage= 164
7432 ThumbnailImage = 166
7442 PosterizeImage = 176
7448 SepiaToneImage = 182
7449 SigmoidalContrast = 183
7450 SigmoidalContrastImage = 184
7455 ContrastStretch = 189
7456 ContrastStretchImage = 190
7461 AdaptiveSharpen = 195
7462 AdaptiveSharpenImage = 196
7464 TransposeImage = 198
7466 TransverseImage = 200
7468 AutoOrientImage = 202
7470 AdaptiveBlurImage = 204
7474 UniqueColorsImage = 208
7475 AdaptiveResize = 209
7476 AdaptiveResizeImage= 210
7480 LinearStretchImage = 214
7482 ColorMatrixImage = 216
7487 FloodfillPaint = 221
7488 FloodfillPaintImage= 222
7494 LiquidRescaleImage = 228
7504 SparseColorImage = 238
7508 SelectiveBlurImage = 242
7512 BlueShiftImage = 246
7513 ForwardFourierTransform = 247
7514 ForwardFourierTransformImage = 248
7515 InverseFourierTransform = 249
7516 InverseFourierTransformImage = 250
7517 ColorDecisionList = 251
7518 ColorDecisionListImage = 252
7520 AutoGammaImage = 254
7522 AutoLevelImage = 256
7524 LevelImageColors = 258
7527 BrightnessContrast = 261
7528 BrightnessContrastImage = 262
7530 MorphologyImage = 264
7536 StatisticImage = 270
7538 PerceptibleImage = 272
7542 GrayscaleImage = 276
7544 CannyEdgeImage = 279
7546 HoughLineImage = 281
7548 MeanShiftImage = 283
7551 ConnectedComponent = 286
7552 ConnectedComponentImage = 287
7561 attribute_flag[MaxArguments],
7562 message[MaxTextExtent];
7623 argument_list[MaxArguments];
7625 PERL_UNUSED_VAR(ref);
7626 PERL_UNUSED_VAR(ix);
7627 exception=AcquireExceptionInfo();
7628 perl_exception=newSVpv("",0);
7629 reference_vector=NULL;
7633 if (sv_isobject(ST(0)) == 0)
7635 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7639 reference=SvRV(ST(0));
7640 region_info.width=0;
7641 region_info.height=0;
7644 region_image=(Image *) NULL;
7645 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7646 if (ix && (ix != 666))
7649 Called as Method(...)
7652 rp=(&Methods[ix-1]);
7658 Called as Mogrify("Method",...)
7660 attribute=(char *) SvPV(ST(1),na);
7663 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7664 attribute=(char *) SvPV(ST(2),na);
7667 for (rp=Methods; ; rp++)
7669 if (rp >= EndOf(Methods))
7671 ThrowPerlException(exception,OptionError,
7672 "UnrecognizedPerlMagickMethod",attribute);
7675 if (strEQcase(attribute,rp->name))
7681 if (image == (Image *) NULL)
7683 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7686 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7687 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7688 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7705 pp=(Arguments *) NULL;
7713 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7715 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7717 if (strEQcase(attribute,qq->method) > ssize_test)
7720 ssize_test=strEQcase(attribute,qq->method);
7723 if (pp == (Arguments *) NULL)
7725 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7727 goto continue_outer_loop;
7729 al=(&argument_list[pp-rp->arguments]);
7732 case ArrayReference:
7734 if (SvTYPE(sv) != SVt_RV)
7736 (void) FormatLocaleString(message,MaxTextExtent,
7737 "invalid %.60s value",pp->method);
7738 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7739 goto continue_outer_loop;
7741 al->array_reference=SvRV(sv);
7746 al->real_reference=SvNV(sv);
7751 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7754 case ImageReference:
7756 if (!sv_isobject(sv) ||
7757 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7758 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7760 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7766 case IntegerReference:
7768 al->integer_reference=SvIV(sv);
7771 case StringReference:
7773 al->string_reference=(char *) SvPV(sv,al->length);
7774 if (sv_isobject(sv))
7775 al->image_reference=SetupList(aTHX_ SvRV(sv),
7776 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7782 Is a string; look up name.
7784 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7786 al->string_reference=(char *) SvPV(sv,al->length);
7787 al->integer_reference=(-1);
7790 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7791 MagickFalse,SvPV(sv,na));
7792 if (pp->type == MagickChannelOptions)
7793 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7794 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7796 (void) FormatLocaleString(message,MaxTextExtent,
7797 "invalid %.60s value",pp->method);
7798 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7799 goto continue_outer_loop;
7804 attribute_flag[pp-rp->arguments]++;
7805 continue_outer_loop: ;
7807 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7808 pv=reference_vector;
7809 SetGeometryInfo(&geometry_info);
7810 channel=DefaultChannels;
7811 for (next=image; next; next=next->next)
7814 SetGeometry(image,&geometry);
7815 if ((region_info.width*region_info.height) != 0)
7818 image=CropImage(image,®ion_info,exception);
7824 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7825 ThrowPerlException(exception,OptionError,
7826 "UnrecognizedPerlMagickMethod",message);
7829 case 1: /* Comment */
7831 if (attribute_flag[0] == 0)
7832 argument_list[0].string_reference=(char *) NULL;
7833 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7834 info ? info->image_info : (ImageInfo *) NULL,image,
7835 argument_list[0].string_reference,exception),exception);
7840 if (attribute_flag[0] == 0)
7841 argument_list[0].string_reference=(char *) NULL;
7842 (void) SetImageProperty(image,"label",InterpretImageProperties(
7843 info ? info->image_info : (ImageInfo *) NULL,image,
7844 argument_list[0].string_reference,exception),exception);
7847 case 3: /* AddNoise */
7852 if (attribute_flag[0] == 0)
7853 argument_list[0].integer_reference=UniformNoise;
7855 if (attribute_flag[1] != 0)
7856 attenuate=argument_list[1].real_reference;
7857 if (attribute_flag[2] != 0)
7858 channel=(ChannelType) argument_list[2].integer_reference;
7859 channel_mask=SetImageChannelMask(image,channel);
7860 image=AddNoiseImage(image,(NoiseType)
7861 argument_list[0].integer_reference,attenuate,exception);
7862 if (image != (Image *) NULL)
7863 (void) SetImageChannelMask(image,channel_mask);
7866 case 4: /* Colorize */
7871 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7872 0,0,&target,exception);
7873 if (attribute_flag[0] != 0)
7874 (void) QueryColorCompliance(argument_list[0].string_reference,
7875 AllCompliance,&target,exception);
7876 if (attribute_flag[1] == 0)
7877 argument_list[1].string_reference="100%";
7878 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7882 case 5: /* Border */
7889 if (attribute_flag[0] != 0)
7890 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7891 &geometry,exception);
7892 if (attribute_flag[1] != 0)
7893 geometry.width=argument_list[1].integer_reference;
7894 if (attribute_flag[2] != 0)
7895 geometry.height=argument_list[2].integer_reference;
7896 if (attribute_flag[3] != 0)
7897 QueryColorCompliance(argument_list[3].string_reference,
7898 AllCompliance,&image->border_color,exception);
7899 if (attribute_flag[4] != 0)
7900 QueryColorCompliance(argument_list[4].string_reference,
7901 AllCompliance,&image->border_color,exception);
7902 if (attribute_flag[5] != 0)
7903 QueryColorCompliance(argument_list[5].string_reference,
7904 AllCompliance,&image->border_color,exception);
7905 compose=image->compose;
7906 if (attribute_flag[6] != 0)
7907 compose=(CompositeOperator) argument_list[6].integer_reference;
7908 image=BorderImage(image,&geometry,compose,exception);
7913 if (attribute_flag[0] != 0)
7915 flags=ParseGeometry(argument_list[0].string_reference,
7917 if ((flags & SigmaValue) == 0)
7918 geometry_info.sigma=1.0;
7920 if (attribute_flag[1] != 0)
7921 geometry_info.rho=argument_list[1].real_reference;
7922 if (attribute_flag[2] != 0)
7923 geometry_info.sigma=argument_list[2].real_reference;
7924 if (attribute_flag[3] != 0)
7925 channel=(ChannelType) argument_list[3].integer_reference;
7926 channel_mask=SetImageChannelMask(image,channel);
7927 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7929 if (image != (Image *) NULL)
7930 (void) SetImageChannelMask(image,channel_mask);
7935 if (attribute_flag[5] != 0)
7936 image->gravity=(GravityType) argument_list[5].integer_reference;
7937 if (attribute_flag[0] != 0)
7938 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7939 &geometry,exception);
7940 if (attribute_flag[1] != 0)
7941 geometry.width=argument_list[1].integer_reference;
7942 if (attribute_flag[2] != 0)
7943 geometry.height=argument_list[2].integer_reference;
7944 if (attribute_flag[3] != 0)
7945 geometry.x=argument_list[3].integer_reference;
7946 if (attribute_flag[4] != 0)
7947 geometry.y=argument_list[4].integer_reference;
7948 image=ChopImage(image,&geometry,exception);
7953 if (attribute_flag[6] != 0)
7954 image->gravity=(GravityType) argument_list[6].integer_reference;
7955 if (attribute_flag[0] != 0)
7956 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7957 &geometry,exception);
7958 if (attribute_flag[1] != 0)
7959 geometry.width=argument_list[1].integer_reference;
7960 if (attribute_flag[2] != 0)
7961 geometry.height=argument_list[2].integer_reference;
7962 if (attribute_flag[3] != 0)
7963 geometry.x=argument_list[3].integer_reference;
7964 if (attribute_flag[4] != 0)
7965 geometry.y=argument_list[4].integer_reference;
7966 if (attribute_flag[5] != 0)
7967 image->fuzz=StringToDoubleInterval(
7968 argument_list[5].string_reference,(double) QuantumRange+1.0);
7969 image=CropImage(image,&geometry,exception);
7972 case 9: /* Despeckle */
7974 image=DespeckleImage(image,exception);
7979 if (attribute_flag[0] != 0)
7980 geometry_info.rho=argument_list[0].real_reference;
7981 image=EdgeImage(image,geometry_info.rho,exception);
7984 case 11: /* Emboss */
7986 if (attribute_flag[0] != 0)
7988 flags=ParseGeometry(argument_list[0].string_reference,
7990 if ((flags & SigmaValue) == 0)
7991 geometry_info.sigma=1.0;
7993 if (attribute_flag[1] != 0)
7994 geometry_info.rho=argument_list[1].real_reference;
7995 if (attribute_flag[2] != 0)
7996 geometry_info.sigma=argument_list[2].real_reference;
7997 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8001 case 12: /* Enhance */
8003 image=EnhanceImage(image,exception);
8008 image=FlipImage(image,exception);
8013 image=FlopImage(image,exception);
8016 case 15: /* Frame */
8024 if (attribute_flag[0] != 0)
8026 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8027 &geometry,exception);
8028 frame_info.width=geometry.width;
8029 frame_info.height=geometry.height;
8030 frame_info.outer_bevel=geometry.x;
8031 frame_info.inner_bevel=geometry.y;
8033 if (attribute_flag[1] != 0)
8034 frame_info.width=argument_list[1].integer_reference;
8035 if (attribute_flag[2] != 0)
8036 frame_info.height=argument_list[2].integer_reference;
8037 if (attribute_flag[3] != 0)
8038 frame_info.inner_bevel=argument_list[3].integer_reference;
8039 if (attribute_flag[4] != 0)
8040 frame_info.outer_bevel=argument_list[4].integer_reference;
8041 if (attribute_flag[5] != 0)
8042 QueryColorCompliance(argument_list[5].string_reference,
8043 AllCompliance,&fill_color,exception);
8044 if (attribute_flag[6] != 0)
8045 QueryColorCompliance(argument_list[6].string_reference,
8046 AllCompliance,&fill_color,exception);
8047 frame_info.x=(ssize_t) frame_info.width;
8048 frame_info.y=(ssize_t) frame_info.height;
8049 frame_info.width=image->columns+2*frame_info.x;
8050 frame_info.height=image->rows+2*frame_info.y;
8051 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8052 image->matte_color=fill_color;
8053 compose=image->compose;
8054 if (attribute_flag[7] != 0)
8055 compose=(CompositeOperator) argument_list[7].integer_reference;
8056 image=FrameImage(image,&frame_info,compose,exception);
8059 case 16: /* Implode */
8061 PixelInterpolateMethod
8064 if (attribute_flag[0] == 0)
8065 argument_list[0].real_reference=0.5;
8066 method=UndefinedInterpolatePixel;
8067 if (attribute_flag[1] != 0)
8068 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8069 image=ImplodeImage(image,argument_list[0].real_reference,
8073 case 17: /* Magnify */
8075 image=MagnifyImage(image,exception);
8078 case 18: /* MedianFilter */
8080 if (attribute_flag[0] != 0)
8082 flags=ParseGeometry(argument_list[0].string_reference,
8084 if ((flags & SigmaValue) == 0)
8085 geometry_info.sigma=geometry_info.rho;
8087 if (attribute_flag[1] != 0)
8088 geometry_info.rho=argument_list[1].real_reference;
8089 if (attribute_flag[2] != 0)
8090 geometry_info.sigma=argument_list[2].real_reference;
8091 if (attribute_flag[3] != 0)
8092 channel=(ChannelType) argument_list[3].integer_reference;
8093 channel_mask=SetImageChannelMask(image,channel);
8094 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8095 (size_t) geometry_info.sigma,exception);
8096 if (image != (Image *) NULL)
8097 (void) SetImageChannelMask(image,channel_mask);
8100 case 19: /* Minify */
8102 image=MinifyImage(image,exception);
8105 case 20: /* OilPaint */
8107 if (attribute_flag[0] == 0)
8108 argument_list[0].real_reference=0.0;
8109 if (attribute_flag[1] == 0)
8110 argument_list[1].real_reference=1.0;
8111 image=OilPaintImage(image,argument_list[0].real_reference,
8112 argument_list[1].real_reference,exception);
8115 case 21: /* ReduceNoise */
8117 if (attribute_flag[0] != 0)
8119 flags=ParseGeometry(argument_list[0].string_reference,
8121 if ((flags & SigmaValue) == 0)
8122 geometry_info.sigma=1.0;
8124 if (attribute_flag[1] != 0)
8125 geometry_info.rho=argument_list[1].real_reference;
8126 if (attribute_flag[2] != 0)
8127 geometry_info.sigma=argument_list[2].real_reference;
8128 if (attribute_flag[3] != 0)
8129 channel=(ChannelType) argument_list[3].integer_reference;
8130 channel_mask=SetImageChannelMask(image,channel);
8131 image=StatisticImage(image,NonpeakStatistic,(size_t)
8132 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8133 if (image != (Image *) NULL)
8134 (void) SetImageChannelMask(image,channel_mask);
8139 if (attribute_flag[0] != 0)
8140 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8141 &geometry,exception);
8142 if (attribute_flag[1] != 0)
8143 geometry.x=argument_list[1].integer_reference;
8144 if (attribute_flag[2] != 0)
8145 geometry.y=argument_list[2].integer_reference;
8146 image=RollImage(image,geometry.x,geometry.y,exception);
8149 case 23: /* Rotate */
8151 if (attribute_flag[0] == 0)
8152 argument_list[0].real_reference=90.0;
8153 if (attribute_flag[1] != 0)
8155 QueryColorCompliance(argument_list[1].string_reference,
8156 AllCompliance,&image->background_color,exception);
8157 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
8158 (image->alpha_trait != BlendPixelTrait))
8159 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8161 image=RotateImage(image,argument_list[0].real_reference,exception);
8164 case 24: /* Sample */
8166 if (attribute_flag[0] != 0)
8167 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8168 &geometry,exception);
8169 if (attribute_flag[1] != 0)
8170 geometry.width=argument_list[1].integer_reference;
8171 if (attribute_flag[2] != 0)
8172 geometry.height=argument_list[2].integer_reference;
8173 image=SampleImage(image,geometry.width,geometry.height,exception);
8176 case 25: /* Scale */
8178 if (attribute_flag[0] != 0)
8179 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8180 &geometry,exception);
8181 if (attribute_flag[1] != 0)
8182 geometry.width=argument_list[1].integer_reference;
8183 if (attribute_flag[2] != 0)
8184 geometry.height=argument_list[2].integer_reference;
8185 image=ScaleImage(image,geometry.width,geometry.height,exception);
8188 case 26: /* Shade */
8190 if (attribute_flag[0] != 0)
8192 flags=ParseGeometry(argument_list[0].string_reference,
8194 if ((flags & SigmaValue) == 0)
8195 geometry_info.sigma=0.0;
8197 if (attribute_flag[1] != 0)
8198 geometry_info.rho=argument_list[1].real_reference;
8199 if (attribute_flag[2] != 0)
8200 geometry_info.sigma=argument_list[2].real_reference;
8201 image=ShadeImage(image,
8202 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8203 geometry_info.rho,geometry_info.sigma,exception);
8206 case 27: /* Sharpen */
8208 if (attribute_flag[0] != 0)
8210 flags=ParseGeometry(argument_list[0].string_reference,
8212 if ((flags & SigmaValue) == 0)
8213 geometry_info.sigma=1.0;
8215 if (attribute_flag[1] != 0)
8216 geometry_info.rho=argument_list[1].real_reference;
8217 if (attribute_flag[2] != 0)
8218 geometry_info.sigma=argument_list[2].real_reference;
8219 if (attribute_flag[3] != 0)
8220 channel=(ChannelType) argument_list[3].integer_reference;
8221 channel_mask=SetImageChannelMask(image,channel);
8222 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8224 if (image != (Image *) NULL)
8225 (void) SetImageChannelMask(image,channel_mask);
8228 case 28: /* Shear */
8230 if (attribute_flag[0] != 0)
8232 flags=ParseGeometry(argument_list[0].string_reference,
8234 if ((flags & SigmaValue) == 0)
8235 geometry_info.sigma=geometry_info.rho;
8237 if (attribute_flag[1] != 0)
8238 geometry_info.rho=argument_list[1].real_reference;
8239 if (attribute_flag[2] != 0)
8240 geometry_info.sigma=argument_list[2].real_reference;
8241 if (attribute_flag[3] != 0)
8242 QueryColorCompliance(argument_list[3].string_reference,
8243 AllCompliance,&image->background_color,exception);
8244 if (attribute_flag[4] != 0)
8245 QueryColorCompliance(argument_list[4].string_reference,
8246 AllCompliance,&image->background_color,exception);
8247 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8251 case 29: /* Spread */
8253 PixelInterpolateMethod
8256 if (attribute_flag[0] == 0)
8257 argument_list[0].real_reference=1.0;
8258 method=UndefinedInterpolatePixel;
8259 if (attribute_flag[1] != 0)
8260 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8261 image=SpreadImage(image,argument_list[0].real_reference,method,
8265 case 30: /* Swirl */
8267 PixelInterpolateMethod
8270 if (attribute_flag[0] == 0)
8271 argument_list[0].real_reference=50.0;
8272 method=UndefinedInterpolatePixel;
8273 if (attribute_flag[1] != 0)
8274 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8275 image=SwirlImage(image,argument_list[0].real_reference,
8279 case 31: /* Resize */
8282 if (attribute_flag[0] != 0)
8283 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8284 &geometry,exception);
8285 if (attribute_flag[1] != 0)
8286 geometry.width=argument_list[1].integer_reference;
8287 if (attribute_flag[2] != 0)
8288 geometry.height=argument_list[2].integer_reference;
8289 if (attribute_flag[3] == 0)
8290 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8291 if (attribute_flag[4] != 0)
8292 SetImageArtifact(image,"filter:support",
8293 argument_list[4].string_reference);
8294 image=ResizeImage(image,geometry.width,geometry.height,
8295 (FilterTypes) argument_list[3].integer_reference,
8299 case 33: /* Annotate */
8304 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8306 if (attribute_flag[0] != 0)
8311 text=InterpretImageProperties(info ? info->image_info :
8312 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8314 (void) CloneString(&draw_info->text,text);
8315 text=DestroyString(text);
8317 if (attribute_flag[1] != 0)
8318 (void) CloneString(&draw_info->font,
8319 argument_list[1].string_reference);
8320 if (attribute_flag[2] != 0)
8321 draw_info->pointsize=argument_list[2].real_reference;
8322 if (attribute_flag[3] != 0)
8323 (void) CloneString(&draw_info->density,
8324 argument_list[3].string_reference);
8325 if (attribute_flag[4] != 0)
8326 (void) QueryColorCompliance(argument_list[4].string_reference,
8327 AllCompliance,&draw_info->undercolor,exception);
8328 if (attribute_flag[5] != 0)
8330 (void) QueryColorCompliance(argument_list[5].string_reference,
8331 AllCompliance,&draw_info->stroke,exception);
8332 if (argument_list[5].image_reference != (Image *) NULL)
8333 draw_info->stroke_pattern=CloneImage(
8334 argument_list[5].image_reference,0,0,MagickTrue,exception);
8336 if (attribute_flag[6] != 0)
8338 (void) QueryColorCompliance(argument_list[6].string_reference,
8339 AllCompliance,&draw_info->fill,exception);
8340 if (argument_list[6].image_reference != (Image *) NULL)
8341 draw_info->fill_pattern=CloneImage(
8342 argument_list[6].image_reference,0,0,MagickTrue,exception);
8344 if (attribute_flag[7] != 0)
8346 (void) CloneString(&draw_info->geometry,
8347 argument_list[7].string_reference);
8348 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8349 &geometry,exception);
8350 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8351 geometry_info.sigma=geometry_info.xi;
8353 if (attribute_flag[8] != 0)
8354 (void) QueryColorCompliance(argument_list[8].string_reference,
8355 AllCompliance,&draw_info->fill,exception);
8356 if (attribute_flag[11] != 0)
8357 draw_info->gravity=(GravityType)
8358 argument_list[11].integer_reference;
8359 if (attribute_flag[25] != 0)
8364 av=(AV *) argument_list[25].array_reference;
8365 if ((av_len(av) != 3) && (av_len(av) != 5))
8367 ThrowPerlException(exception,OptionError,
8368 "affine matrix must have 4 or 6 elements",PackageName);
8371 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8372 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8373 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8374 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8375 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8376 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8378 ThrowPerlException(exception,OptionError,
8379 "affine matrix is singular",PackageName);
8382 if (av_len(av) == 5)
8384 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8385 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8388 for (j=12; j < 17; j++)
8390 if (attribute_flag[j] == 0)
8392 value=argument_list[j].string_reference;
8393 angle=argument_list[j].real_reference;
8394 current=draw_info->affine;
8395 GetAffineMatrix(&affine);
8403 flags=ParseGeometry(value,&geometry_info);
8404 affine.tx=geometry_info.xi;
8405 affine.ty=geometry_info.psi;
8406 if ((flags & PsiValue) == 0)
8407 affine.ty=affine.tx;
8415 flags=ParseGeometry(value,&geometry_info);
8416 affine.sx=geometry_info.rho;
8417 affine.sy=geometry_info.sigma;
8418 if ((flags & SigmaValue) == 0)
8419 affine.sy=affine.sx;
8429 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8430 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8431 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8432 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8440 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8448 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8452 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8453 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8454 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8455 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8456 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8458 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8461 if (attribute_flag[9] == 0)
8462 argument_list[9].real_reference=0.0;
8463 if (attribute_flag[10] == 0)
8464 argument_list[10].real_reference=0.0;
8465 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8468 geometry[MaxTextExtent];
8470 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8471 (double) argument_list[9].real_reference+draw_info->affine.tx,
8472 (double) argument_list[10].real_reference+draw_info->affine.ty);
8473 (void) CloneString(&draw_info->geometry,geometry);
8475 if (attribute_flag[17] != 0)
8476 draw_info->stroke_width=argument_list[17].real_reference;
8477 if (attribute_flag[18] != 0)
8479 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8480 MagickTrue : MagickFalse;
8481 draw_info->stroke_antialias=draw_info->text_antialias;
8483 if (attribute_flag[19] != 0)
8484 (void) CloneString(&draw_info->family,
8485 argument_list[19].string_reference);
8486 if (attribute_flag[20] != 0)
8487 draw_info->style=(StyleType) argument_list[20].integer_reference;
8488 if (attribute_flag[21] != 0)
8489 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8490 if (attribute_flag[22] != 0)
8491 draw_info->weight=argument_list[22].integer_reference;
8492 if (attribute_flag[23] != 0)
8493 draw_info->align=(AlignType) argument_list[23].integer_reference;
8494 if (attribute_flag[24] != 0)
8495 (void) CloneString(&draw_info->encoding,
8496 argument_list[24].string_reference);
8497 if (attribute_flag[25] != 0)
8498 draw_info->fill_pattern=CloneImage(
8499 argument_list[25].image_reference,0,0,MagickTrue,exception);
8500 if (attribute_flag[26] != 0)
8501 draw_info->fill_pattern=CloneImage(
8502 argument_list[26].image_reference,0,0,MagickTrue,exception);
8503 if (attribute_flag[27] != 0)
8504 draw_info->stroke_pattern=CloneImage(
8505 argument_list[27].image_reference,0,0,MagickTrue,exception);
8506 if (attribute_flag[29] != 0)
8507 draw_info->kerning=argument_list[29].real_reference;
8508 if (attribute_flag[30] != 0)
8509 draw_info->interline_spacing=argument_list[30].real_reference;
8510 if (attribute_flag[31] != 0)
8511 draw_info->interword_spacing=argument_list[31].real_reference;
8512 if (attribute_flag[32] != 0)
8513 draw_info->direction=(DirectionType)
8514 argument_list[32].integer_reference;
8515 (void) AnnotateImage(image,draw_info,exception);
8516 draw_info=DestroyDrawInfo(draw_info);
8519 case 34: /* ColorFloodfill */
8530 draw_info=CloneDrawInfo(info ? info->image_info :
8531 (ImageInfo *) NULL,(DrawInfo *) NULL);
8532 if (attribute_flag[0] != 0)
8533 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8534 &geometry,exception);
8535 if (attribute_flag[1] != 0)
8536 geometry.x=argument_list[1].integer_reference;
8537 if (attribute_flag[2] != 0)
8538 geometry.y=argument_list[2].integer_reference;
8539 if (attribute_flag[3] != 0)
8540 (void) QueryColorCompliance(argument_list[3].string_reference,
8541 AllCompliance,&draw_info->fill,exception);
8542 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8543 geometry.x,geometry.y,&target,exception);
8545 if (attribute_flag[4] != 0)
8547 QueryColorCompliance(argument_list[4].string_reference,
8548 AllCompliance,&target,exception);
8551 if (attribute_flag[5] != 0)
8552 image->fuzz=StringToDoubleInterval(
8553 argument_list[5].string_reference,(double) QuantumRange+1.0);
8554 if (attribute_flag[6] != 0)
8555 invert=(MagickBooleanType) argument_list[6].integer_reference;
8556 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8557 geometry.y,invert,exception);
8558 draw_info=DestroyDrawInfo(draw_info);
8561 case 35: /* Composite */
8564 composite_geometry[MaxTextExtent];
8573 compose=OverCompositeOp;
8574 if (attribute_flag[0] != 0)
8575 composite_image=argument_list[0].image_reference;
8578 ThrowPerlException(exception,OptionError,
8579 "CompositeImageRequired",PackageName);
8583 Parameter Handling used for BOTH normal and tiled composition.
8585 if (attribute_flag[1] != 0) /* compose */
8586 compose=(CompositeOperator) argument_list[1].integer_reference;
8587 if (attribute_flag[6] != 0) /* opacity */
8589 if (compose != DissolveCompositeOp)
8590 (void) SetImageAlpha(composite_image,(Quantum)
8591 StringToDoubleInterval(argument_list[6].string_reference,
8592 (double) QuantumRange+1.0),exception);
8614 Handle dissolve composite operator (patch by
8617 (void) CloneString(&image->geometry,
8618 argument_list[6].string_reference);
8619 opacity=(Quantum) StringToDoubleInterval(
8620 argument_list[6].string_reference,(double) QuantumRange+
8622 if (composite_image->alpha_trait == BlendPixelTrait)
8623 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8624 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8625 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8627 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8628 composite_image->columns,1,exception);
8629 for (x=0; x < (ssize_t) composite_image->columns; x++)
8631 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8632 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8634 q+=GetPixelChannels(composite_image);
8636 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8637 if (sync == MagickFalse)
8640 composite_view=DestroyCacheView(composite_view);
8643 if (attribute_flag[9] != 0) /* "color=>" */
8644 QueryColorCompliance(argument_list[9].string_reference,
8645 AllCompliance,&composite_image->background_color,exception);
8646 if (attribute_flag[12] != 0) /* "interpolate=>" */
8647 image->interpolate=(PixelInterpolateMethod)
8648 argument_list[12].integer_reference;
8649 if (attribute_flag[13] != 0) /* "args=>" */
8650 (void) SetImageArtifact(composite_image,"compose:args",
8651 argument_list[13].string_reference);
8652 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8653 (void) SetImageArtifact(composite_image,"compose:args",
8654 argument_list[14].string_reference);
8655 clip_to_self=MagickTrue;
8656 if (attribute_flag[15] != 0)
8657 clip_to_self=(MagickBooleanType)
8658 argument_list[15].integer_reference;
8660 Tiling Composition (with orthogonal rotate).
8662 rotate_image=(Image *) NULL;
8663 if (attribute_flag[8] != 0) /* "rotate=>" */
8668 rotate_image=RotateImage(composite_image,
8669 argument_list[8].real_reference,exception);
8670 if (rotate_image == (Image *) NULL)
8673 if ((attribute_flag[7] != 0) &&
8674 (argument_list[7].integer_reference != 0)) /* tile */
8681 Tile the composite image.
8683 if (attribute_flag[8] != 0) /* "tile=>" */
8684 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8687 (void) SetImageArtifact(composite_image,
8688 "compose:outside-overlay","false");
8689 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8690 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8692 if (attribute_flag[8] != 0) /* rotate */
8693 (void) CompositeImage(image,rotate_image,compose,
8694 MagickTrue,x,y,exception);
8696 (void) CompositeImage(image,composite_image,compose,
8697 MagickTrue,x,y,exception);
8699 if (attribute_flag[8] != 0) /* rotate */
8700 rotate_image=DestroyImage(rotate_image);
8704 Parameter Handling used used ONLY for normal composition.
8706 if (attribute_flag[5] != 0) /* gravity */
8707 image->gravity=(GravityType) argument_list[5].integer_reference;
8708 if (attribute_flag[2] != 0) /* geometry offset */
8710 SetGeometry(image,&geometry);
8711 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8713 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8716 if (attribute_flag[3] != 0) /* x offset */
8717 geometry.x=argument_list[3].integer_reference;
8718 if (attribute_flag[4] != 0) /* y offset */
8719 geometry.y=argument_list[4].integer_reference;
8720 if (attribute_flag[10] != 0) /* mask */
8722 if ((image->compose == DisplaceCompositeOp) ||
8723 (image->compose == DistortCompositeOp))
8726 Merge Y displacement into X displacement image.
8728 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8730 (void) CompositeImage(composite_image,
8731 argument_list[10].image_reference,CopyGreenCompositeOp,
8732 MagickTrue,0,0,exception);
8740 Set a blending mask for the composition.
8742 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8743 MagickTrue,exception);
8744 (void) SetImageMask(composite_image,mask_image,exception);
8745 mask_image=DestroyImage(mask_image);
8748 if (attribute_flag[11] != 0) /* channel */
8749 channel=(ChannelType) argument_list[11].integer_reference;
8751 Composite two images (normal composition).
8753 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8754 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8755 (double) composite_image->rows,(double) geometry.x,(double)
8757 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8759 channel_mask=SetImageChannelMask(image,channel);
8760 if (attribute_flag[8] == 0) /* no rotate */
8761 CompositeImage(image,composite_image,compose,clip_to_self,
8762 geometry.x,geometry.y,exception);
8766 Position adjust rotated image then composite.
8768 geometry.x-=(ssize_t) (rotate_image->columns-
8769 composite_image->columns)/2;
8770 geometry.y-=(ssize_t) (rotate_image->rows-
8771 composite_image->rows)/2;
8772 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8773 geometry.y,exception);
8774 rotate_image=DestroyImage(rotate_image);
8776 if (attribute_flag[10] != 0) /* mask */
8778 if ((image->compose == DisplaceCompositeOp) ||
8779 (image->compose == DistortCompositeOp))
8780 composite_image=DestroyImage(composite_image);
8782 (void) SetImageMask(image,(Image *) NULL,exception);
8784 (void) SetImageChannelMask(image,channel_mask);
8787 case 36: /* Contrast */
8789 if (attribute_flag[0] == 0)
8790 argument_list[0].integer_reference=0;
8791 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8792 MagickTrue : MagickFalse,exception);
8795 case 37: /* CycleColormap */
8797 if (attribute_flag[0] == 0)
8798 argument_list[0].integer_reference=6;
8799 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8808 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8810 (void) CloneString(&draw_info->primitive,"point");
8811 if (attribute_flag[0] != 0)
8813 if (argument_list[0].integer_reference < 0)
8814 (void) CloneString(&draw_info->primitive,
8815 argument_list[0].string_reference);
8817 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8818 MagickPrimitiveOptions,argument_list[0].integer_reference));
8820 if (attribute_flag[1] != 0)
8822 if (LocaleCompare(draw_info->primitive,"path") == 0)
8824 (void) ConcatenateString(&draw_info->primitive," '");
8825 ConcatenateString(&draw_info->primitive,
8826 argument_list[1].string_reference);
8827 (void) ConcatenateString(&draw_info->primitive,"'");
8831 (void) ConcatenateString(&draw_info->primitive," ");
8832 ConcatenateString(&draw_info->primitive,
8833 argument_list[1].string_reference);
8836 if (attribute_flag[2] != 0)
8838 (void) ConcatenateString(&draw_info->primitive," ");
8839 (void) ConcatenateString(&draw_info->primitive,
8840 CommandOptionToMnemonic(MagickMethodOptions,
8841 argument_list[2].integer_reference));
8843 if (attribute_flag[3] != 0)
8845 (void) QueryColorCompliance(argument_list[3].string_reference,
8846 AllCompliance,&draw_info->stroke,exception);
8847 if (argument_list[3].image_reference != (Image *) NULL)
8848 draw_info->stroke_pattern=CloneImage(
8849 argument_list[3].image_reference,0,0,MagickTrue,exception);
8851 if (attribute_flag[4] != 0)
8853 (void) QueryColorCompliance(argument_list[4].string_reference,
8854 AllCompliance,&draw_info->fill,exception);
8855 if (argument_list[4].image_reference != (Image *) NULL)
8856 draw_info->fill_pattern=CloneImage(
8857 argument_list[4].image_reference,0,0,MagickTrue,exception);
8859 if (attribute_flag[5] != 0)
8860 draw_info->stroke_width=argument_list[5].real_reference;
8861 if (attribute_flag[6] != 0)
8862 (void) CloneString(&draw_info->font,
8863 argument_list[6].string_reference);
8864 if (attribute_flag[7] != 0)
8865 (void) QueryColorCompliance(argument_list[7].string_reference,
8866 AllCompliance,&draw_info->border_color,exception);
8867 if (attribute_flag[8] != 0)
8868 draw_info->affine.tx=argument_list[8].real_reference;
8869 if (attribute_flag[9] != 0)
8870 draw_info->affine.ty=argument_list[9].real_reference;
8871 if (attribute_flag[20] != 0)
8876 av=(AV *) argument_list[20].array_reference;
8877 if ((av_len(av) != 3) && (av_len(av) != 5))
8879 ThrowPerlException(exception,OptionError,
8880 "affine matrix must have 4 or 6 elements",PackageName);
8883 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8884 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8885 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8886 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8887 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8888 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8890 ThrowPerlException(exception,OptionError,
8891 "affine matrix is singular",PackageName);
8894 if (av_len(av) == 5)
8896 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8897 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8900 for (j=10; j < 15; j++)
8902 if (attribute_flag[j] == 0)
8904 value=argument_list[j].string_reference;
8905 angle=argument_list[j].real_reference;
8906 current=draw_info->affine;
8907 GetAffineMatrix(&affine);
8915 flags=ParseGeometry(value,&geometry_info);
8916 affine.tx=geometry_info.xi;
8917 affine.ty=geometry_info.psi;
8918 if ((flags & PsiValue) == 0)
8919 affine.ty=affine.tx;
8927 flags=ParseGeometry(value,&geometry_info);
8928 affine.sx=geometry_info.rho;
8929 affine.sy=geometry_info.sigma;
8930 if ((flags & SigmaValue) == 0)
8931 affine.sy=affine.sx;
8941 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8942 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8943 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8944 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8952 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8960 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8964 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8965 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8966 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8967 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8968 draw_info->affine.tx=
8969 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8970 draw_info->affine.ty=
8971 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8973 if (attribute_flag[15] != 0)
8974 draw_info->fill_pattern=CloneImage(
8975 argument_list[15].image_reference,0,0,MagickTrue,exception);
8976 if (attribute_flag[16] != 0)
8977 draw_info->pointsize=argument_list[16].real_reference;
8978 if (attribute_flag[17] != 0)
8980 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8981 ? MagickTrue : MagickFalse;
8982 draw_info->text_antialias=draw_info->stroke_antialias;
8984 if (attribute_flag[18] != 0)
8985 (void) CloneString(&draw_info->density,
8986 argument_list[18].string_reference);
8987 if (attribute_flag[19] != 0)
8988 draw_info->stroke_width=argument_list[19].real_reference;
8989 if (attribute_flag[21] != 0)
8990 draw_info->dash_offset=argument_list[21].real_reference;
8991 if (attribute_flag[22] != 0)
8996 av=(AV *) argument_list[22].array_reference;
8997 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8998 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8999 if (draw_info->dash_pattern != (double *) NULL)
9001 for (i=0; i <= av_len(av); i++)
9002 draw_info->dash_pattern[i]=(double)
9003 SvNV(*(av_fetch(av,i,0)));
9004 draw_info->dash_pattern[i]=0.0;
9007 if (attribute_flag[23] != 0)
9008 image->interpolate=(PixelInterpolateMethod)
9009 argument_list[23].integer_reference;
9010 if ((attribute_flag[24] != 0) &&
9011 (draw_info->fill_pattern != (Image *) NULL))
9012 flags=ParsePageGeometry(draw_info->fill_pattern,
9013 argument_list[24].string_reference,
9014 &draw_info->fill_pattern->tile_offset,exception);
9015 if (attribute_flag[25] != 0)
9017 (void) ConcatenateString(&draw_info->primitive," '");
9018 (void) ConcatenateString(&draw_info->primitive,
9019 argument_list[25].string_reference);
9020 (void) ConcatenateString(&draw_info->primitive,"'");
9022 if (attribute_flag[26] != 0)
9023 draw_info->fill_pattern=CloneImage(
9024 argument_list[26].image_reference,0,0,MagickTrue,exception);
9025 if (attribute_flag[27] != 0)
9026 draw_info->stroke_pattern=CloneImage(
9027 argument_list[27].image_reference,0,0,MagickTrue,exception);
9028 if (attribute_flag[28] != 0)
9029 (void) CloneString(&draw_info->primitive,
9030 argument_list[28].string_reference);
9031 if (attribute_flag[29] != 0)
9032 draw_info->kerning=argument_list[29].real_reference;
9033 if (attribute_flag[30] != 0)
9034 draw_info->interline_spacing=argument_list[30].real_reference;
9035 if (attribute_flag[31] != 0)
9036 draw_info->interword_spacing=argument_list[31].real_reference;
9037 if (attribute_flag[32] != 0)
9038 draw_info->direction=(DirectionType)
9039 argument_list[32].integer_reference;
9040 DrawImage(image,draw_info,exception);
9041 draw_info=DestroyDrawInfo(draw_info);
9044 case 39: /* Equalize */
9046 if (attribute_flag[0] != 0)
9047 channel=(ChannelType) argument_list[0].integer_reference;
9048 channel_mask=SetImageChannelMask(image,channel);
9049 EqualizeImage(image,exception);
9050 (void) SetImageChannelMask(image,channel_mask);
9053 case 40: /* Gamma */
9055 if (attribute_flag[1] != 0)
9056 channel=(ChannelType) argument_list[1].integer_reference;
9057 if (attribute_flag[2] == 0)
9058 argument_list[2].real_reference=1.0;
9059 if (attribute_flag[3] == 0)
9060 argument_list[3].real_reference=1.0;
9061 if (attribute_flag[4] == 0)
9062 argument_list[4].real_reference=1.0;
9063 if (attribute_flag[0] == 0)
9065 (void) FormatLocaleString(message,MaxTextExtent,
9066 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9067 (double) argument_list[3].real_reference,
9068 (double) argument_list[4].real_reference);
9069 argument_list[0].string_reference=message;
9071 (void) GammaImage(image,StringToDouble(
9072 argument_list[0].string_reference,(char **) NULL),exception);
9080 if (attribute_flag[0] == 0)
9082 ThrowPerlException(exception,OptionError,"MapImageRequired",
9086 quantize_info=AcquireQuantizeInfo(info->image_info);
9087 if (attribute_flag[1] != 0)
9088 quantize_info->dither_method=(DitherMethod)
9089 argument_list[1].integer_reference;
9090 (void) RemapImages(quantize_info,image,
9091 argument_list[0].image_reference,exception);
9092 quantize_info=DestroyQuantizeInfo(quantize_info);
9095 case 42: /* MatteFloodfill */
9106 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9108 if (attribute_flag[0] != 0)
9109 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9110 &geometry,exception);
9111 if (attribute_flag[1] != 0)
9112 geometry.x=argument_list[1].integer_reference;
9113 if (attribute_flag[2] != 0)
9114 geometry.y=argument_list[2].integer_reference;
9115 if (image->alpha_trait != BlendPixelTrait)
9116 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9117 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9118 geometry.x,geometry.y,&target,exception);
9119 if (attribute_flag[4] != 0)
9120 QueryColorCompliance(argument_list[4].string_reference,
9121 AllCompliance,&target,exception);
9122 if (attribute_flag[3] != 0)
9123 target.alpha=StringToDoubleInterval(
9124 argument_list[3].string_reference,(double) (double) QuantumRange+
9126 if (attribute_flag[5] != 0)
9127 image->fuzz=StringToDoubleInterval(
9128 argument_list[5].string_reference,(double) QuantumRange+1.0);
9130 if (attribute_flag[6] != 0)
9131 invert=(MagickBooleanType) argument_list[6].integer_reference;
9132 channel_mask=SetImageChannelMask(image,AlphaChannel);
9133 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9134 geometry.y,invert,exception);
9135 (void) SetImageChannelMask(image,channel_mask);
9136 draw_info=DestroyDrawInfo(draw_info);
9139 case 43: /* Modulate */
9142 modulate[MaxTextExtent];
9144 geometry_info.rho=100.0;
9145 geometry_info.sigma=100.0;
9146 geometry_info.xi=100.0;
9147 if (attribute_flag[0] != 0)
9148 (void)ParseGeometry(argument_list[0].string_reference,
9150 if (attribute_flag[1] != 0)
9151 geometry_info.xi=argument_list[1].real_reference;
9152 if (attribute_flag[2] != 0)
9153 geometry_info.sigma=argument_list[2].real_reference;
9154 if (attribute_flag[3] != 0)
9156 geometry_info.sigma=argument_list[3].real_reference;
9157 SetImageArtifact(image,"modulate:colorspace","HWB");
9159 if (attribute_flag[4] != 0)
9161 geometry_info.rho=argument_list[4].real_reference;
9162 SetImageArtifact(image,"modulate:colorspace","HSB");
9164 if (attribute_flag[5] != 0)
9166 geometry_info.sigma=argument_list[5].real_reference;
9167 SetImageArtifact(image,"modulate:colorspace","HSL");
9169 if (attribute_flag[6] != 0)
9171 geometry_info.rho=argument_list[6].real_reference;
9172 SetImageArtifact(image,"modulate:colorspace","HWB");
9174 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
9175 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9176 (void) ModulateImage(image,modulate,exception);
9179 case 44: /* Negate */
9181 if (attribute_flag[0] == 0)
9182 argument_list[0].integer_reference=0;
9183 if (attribute_flag[1] != 0)
9184 channel=(ChannelType) argument_list[1].integer_reference;
9185 channel_mask=SetImageChannelMask(image,channel);
9186 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9187 MagickTrue : MagickFalse,exception);
9188 (void) SetImageChannelMask(image,channel_mask);
9191 case 45: /* Normalize */
9193 if (attribute_flag[0] != 0)
9194 channel=(ChannelType) argument_list[0].integer_reference;
9195 channel_mask=SetImageChannelMask(image,channel);
9196 NormalizeImage(image,exception);
9197 (void) SetImageChannelMask(image,channel_mask);
9200 case 46: /* NumberColors */
9202 case 47: /* Opaque */
9211 (void) QueryColorCompliance("none",AllCompliance,&target,
9213 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9215 if (attribute_flag[0] != 0)
9216 (void) QueryColorCompliance(argument_list[0].string_reference,
9217 AllCompliance,&target,exception);
9218 if (attribute_flag[1] != 0)
9219 (void) QueryColorCompliance(argument_list[1].string_reference,
9220 AllCompliance,&fill_color,exception);
9221 if (attribute_flag[2] != 0)
9222 image->fuzz=StringToDoubleInterval(
9223 argument_list[2].string_reference,(double) QuantumRange+1.0);
9224 if (attribute_flag[3] != 0)
9225 channel=(ChannelType) argument_list[3].integer_reference;
9227 if (attribute_flag[4] != 0)
9228 invert=(MagickBooleanType) argument_list[4].integer_reference;
9229 channel_mask=SetImageChannelMask(image,channel);
9230 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9231 (void) SetImageChannelMask(image,channel_mask);
9234 case 48: /* Quantize */
9239 quantize_info=AcquireQuantizeInfo(info->image_info);
9240 if (attribute_flag[0] != 0)
9241 quantize_info->number_colors=(size_t)
9242 argument_list[0].integer_reference;
9243 if (attribute_flag[1] != 0)
9244 quantize_info->tree_depth=(size_t)
9245 argument_list[1].integer_reference;
9246 if (attribute_flag[2] != 0)
9247 quantize_info->colorspace=(ColorspaceType)
9248 argument_list[2].integer_reference;
9249 if (attribute_flag[3] != 0)
9250 quantize_info->dither_method=(DitherMethod)
9251 argument_list[3].integer_reference;
9252 if (attribute_flag[4] != 0)
9253 quantize_info->measure_error=
9254 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9255 if (attribute_flag[6] != 0)
9256 (void) QueryColorCompliance(argument_list[6].string_reference,
9257 AllCompliance,&image->transparent_color,exception);
9258 if (attribute_flag[7] != 0)
9259 quantize_info->dither_method=(DitherMethod)
9260 argument_list[7].integer_reference;
9261 if (attribute_flag[5] && argument_list[5].integer_reference)
9262 (void) QuantizeImages(quantize_info,image,exception);
9264 if ((image->storage_class == DirectClass) ||
9265 (image->colors > quantize_info->number_colors) ||
9266 (quantize_info->colorspace == GRAYColorspace))
9267 (void) QuantizeImage(quantize_info,image,exception);
9269 CompressImageColormap(image,exception);
9270 quantize_info=DestroyQuantizeInfo(quantize_info);
9273 case 49: /* Raise */
9275 if (attribute_flag[0] != 0)
9276 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9277 &geometry,exception);
9278 if (attribute_flag[1] != 0)
9279 geometry.width=argument_list[1].integer_reference;
9280 if (attribute_flag[2] != 0)
9281 geometry.height=argument_list[2].integer_reference;
9282 if (attribute_flag[3] == 0)
9283 argument_list[3].integer_reference=1;
9284 (void) RaiseImage(image,&geometry,
9285 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9289 case 50: /* Segment */
9296 smoothing_threshold;
9301 cluster_threshold=1.0;
9302 smoothing_threshold=1.5;
9303 colorspace=sRGBColorspace;
9304 verbose=MagickFalse;
9305 if (attribute_flag[0] != 0)
9307 flags=ParseGeometry(argument_list[0].string_reference,
9309 cluster_threshold=geometry_info.rho;
9310 if (flags & SigmaValue)
9311 smoothing_threshold=geometry_info.sigma;
9313 if (attribute_flag[1] != 0)
9314 cluster_threshold=argument_list[1].real_reference;
9315 if (attribute_flag[2] != 0)
9316 smoothing_threshold=argument_list[2].real_reference;
9317 if (attribute_flag[3] != 0)
9318 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9319 if (attribute_flag[4] != 0)
9320 verbose=argument_list[4].integer_reference != 0 ?
9321 MagickTrue : MagickFalse;
9322 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9323 smoothing_threshold,exception);
9326 case 51: /* Signature */
9328 (void) SignatureImage(image,exception);
9331 case 52: /* Solarize */
9333 geometry_info.rho=QuantumRange/2.0;
9334 if (attribute_flag[0] != 0)
9335 flags=ParseGeometry(argument_list[0].string_reference,
9337 if (attribute_flag[1] != 0)
9338 geometry_info.rho=StringToDoubleInterval(
9339 argument_list[1].string_reference,(double) QuantumRange+1.0);
9340 (void) SolarizeImage(image,geometry_info.rho,exception);
9345 (void) SyncImage(image,exception);
9348 case 54: /* Texture */
9350 if (attribute_flag[0] == 0)
9352 TextureImage(image,argument_list[0].image_reference,exception);
9355 case 55: /* Evalute */
9357 MagickEvaluateOperator
9360 op=SetEvaluateOperator;
9361 if (attribute_flag[0] == MagickFalse)
9362 argument_list[0].real_reference=0.0;
9363 if (attribute_flag[1] != MagickFalse)
9364 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9365 if (attribute_flag[2] != MagickFalse)
9366 channel=(ChannelType) argument_list[2].integer_reference;
9367 channel_mask=SetImageChannelMask(image,channel);
9368 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9370 (void) SetImageChannelMask(image,channel_mask);
9373 case 56: /* Transparent */
9384 (void) QueryColorCompliance("none",AllCompliance,&target,
9386 if (attribute_flag[0] != 0)
9387 (void) QueryColorCompliance(argument_list[0].string_reference,
9388 AllCompliance,&target,exception);
9389 opacity=TransparentAlpha;
9390 if (attribute_flag[1] != 0)
9391 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9392 (double) QuantumRange+1.0);
9393 if (attribute_flag[2] != 0)
9394 image->fuzz=StringToDoubleInterval(
9395 argument_list[2].string_reference,(double) QuantumRange+1.0);
9396 if (attribute_flag[3] == 0)
9397 argument_list[3].integer_reference=0;
9399 if (attribute_flag[3] != 0)
9400 invert=(MagickBooleanType) argument_list[3].integer_reference;
9401 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9405 case 57: /* Threshold */
9410 if (attribute_flag[0] == 0)
9411 argument_list[0].string_reference="50%";
9412 if (attribute_flag[1] != 0)
9413 channel=(ChannelType) argument_list[1].integer_reference;
9414 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9415 (double) QuantumRange+1.0);
9416 channel_mask=SetImageChannelMask(image,channel);
9417 (void) BilevelImage(image,threshold,exception);
9418 (void) SetImageChannelMask(image,channel_mask);
9421 case 58: /* Charcoal */
9423 if (attribute_flag[0] != 0)
9425 flags=ParseGeometry(argument_list[0].string_reference,
9427 if ((flags & SigmaValue) == 0)
9428 geometry_info.sigma=1.0;
9430 if (attribute_flag[1] != 0)
9431 geometry_info.rho=argument_list[1].real_reference;
9432 if (attribute_flag[2] != 0)
9433 geometry_info.sigma=argument_list[2].real_reference;
9434 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9440 if (attribute_flag[0] != 0)
9441 image->fuzz=StringToDoubleInterval(
9442 argument_list[0].string_reference,(double) QuantumRange+1.0);
9443 image=TrimImage(image,exception);
9448 PixelInterpolateMethod
9451 if (attribute_flag[0] != 0)
9453 flags=ParseGeometry(argument_list[0].string_reference,
9455 if ((flags & SigmaValue) == 0)
9456 geometry_info.sigma=1.0;
9458 if (attribute_flag[1] != 0)
9459 geometry_info.rho=argument_list[1].real_reference;
9460 if (attribute_flag[2] != 0)
9461 geometry_info.sigma=argument_list[2].real_reference;
9462 method=UndefinedInterpolatePixel;
9463 if (attribute_flag[3] != 0)
9464 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9465 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9469 case 61: /* Separate */
9471 if (attribute_flag[0] != 0)
9472 channel=(ChannelType) argument_list[0].integer_reference;
9473 image=SeparateImage(image,channel,exception);
9476 case 63: /* Stereo */
9478 if (attribute_flag[0] == 0)
9480 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9484 if (attribute_flag[1] != 0)
9485 geometry.x=argument_list[1].integer_reference;
9486 if (attribute_flag[2] != 0)
9487 geometry.y=argument_list[2].integer_reference;
9488 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9489 geometry.x,geometry.y,exception);
9492 case 64: /* Stegano */
9494 if (attribute_flag[0] == 0)
9496 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9500 if (attribute_flag[1] == 0)
9501 argument_list[1].integer_reference=0;
9502 image->offset=argument_list[1].integer_reference;
9503 image=SteganoImage(image,argument_list[0].image_reference,exception);
9506 case 65: /* Deconstruct */
9508 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9511 case 66: /* GaussianBlur */
9513 if (attribute_flag[0] != 0)
9515 flags=ParseGeometry(argument_list[0].string_reference,
9517 if ((flags & SigmaValue) == 0)
9518 geometry_info.sigma=1.0;
9520 if (attribute_flag[1] != 0)
9521 geometry_info.rho=argument_list[1].real_reference;
9522 if (attribute_flag[2] != 0)
9523 geometry_info.sigma=argument_list[2].real_reference;
9524 if (attribute_flag[3] != 0)
9525 channel=(ChannelType) argument_list[3].integer_reference;
9526 channel_mask=SetImageChannelMask(image,channel);
9527 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9529 if (image != (Image *) NULL)
9530 (void) SetImageChannelMask(image,channel_mask);
9533 case 67: /* Convolve */
9538 kernel=(KernelInfo *) NULL;
9539 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9541 if (attribute_flag[0] != 0)
9549 kernel=AcquireKernelInfo((const char *) NULL,exception);
9550 if (kernel == (KernelInfo *) NULL)
9552 av=(AV *) argument_list[0].array_reference;
9553 order=(size_t) sqrt(av_len(av)+1);
9554 kernel->width=order;
9555 kernel->height=order;
9556 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9557 order*sizeof(*kernel->values));
9558 if (kernel->values == (MagickRealType *) NULL)
9560 kernel=DestroyKernelInfo(kernel);
9561 ThrowPerlException(exception,ResourceLimitFatalError,
9562 "MemoryAllocationFailed",PackageName);
9565 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9566 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9567 for ( ; j < (ssize_t) (order*order); j++)
9568 kernel->values[j]=0.0;
9570 if (attribute_flag[1] != 0)
9571 channel=(ChannelType) argument_list[1].integer_reference;
9572 if (attribute_flag[2] != 0)
9573 SetImageArtifact(image,"filter:blur",
9574 argument_list[2].string_reference);
9575 if (attribute_flag[3] != 0)
9577 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9579 if (kernel == (KernelInfo *) NULL)
9582 channel_mask=SetImageChannelMask(image,channel);
9583 image=ConvolveImage(image,kernel,exception);
9584 if (image != (Image *) NULL)
9585 (void) SetImageChannelMask(image,channel_mask);
9586 kernel=DestroyKernelInfo(kernel);
9589 case 68: /* Profile */
9604 if (attribute_flag[0] != 0)
9605 name=argument_list[0].string_reference;
9606 if (attribute_flag[2] != 0)
9607 image->rendering_intent=(RenderingIntent)
9608 argument_list[2].integer_reference;
9609 if (attribute_flag[3] != 0)
9610 image->black_point_compensation=
9611 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9612 if (attribute_flag[1] != 0)
9614 if (argument_list[1].length == 0)
9617 Remove a profile from the image.
9619 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9624 Associate user supplied profile with the image.
9626 profile=AcquireStringInfo(argument_list[1].length);
9627 SetStringInfoDatum(profile,(const unsigned char *)
9628 argument_list[1].string_reference);
9629 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9630 (size_t) GetStringInfoLength(profile),exception);
9631 profile=DestroyStringInfo(profile);
9635 Associate a profile with the image.
9637 profile_info=CloneImageInfo(info ? info->image_info :
9638 (ImageInfo *) NULL);
9639 profile_image=ReadImages(profile_info,name,exception);
9640 if (profile_image == (Image *) NULL)
9642 ResetImageProfileIterator(profile_image);
9643 name=GetNextImageProfile(profile_image);
9644 while (name != (const char *) NULL)
9649 profile=GetImageProfile(profile_image,name);
9650 if (profile != (const StringInfo *) NULL)
9651 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9652 (size_t) GetStringInfoLength(profile),exception);
9653 name=GetNextImageProfile(profile_image);
9655 profile_image=DestroyImage(profile_image);
9656 profile_info=DestroyImageInfo(profile_info);
9659 case 69: /* UnsharpMask */
9661 if (attribute_flag[0] != 0)
9663 flags=ParseGeometry(argument_list[0].string_reference,
9665 if ((flags & SigmaValue) == 0)
9666 geometry_info.sigma=1.0;
9667 if ((flags & XiValue) == 0)
9668 geometry_info.xi=1.0;
9669 if ((flags & PsiValue) == 0)
9670 geometry_info.psi=0.5;
9672 if (attribute_flag[1] != 0)
9673 geometry_info.rho=argument_list[1].real_reference;
9674 if (attribute_flag[2] != 0)
9675 geometry_info.sigma=argument_list[2].real_reference;
9676 if (attribute_flag[3] != 0)
9677 geometry_info.xi=argument_list[3].real_reference;
9678 if (attribute_flag[4] != 0)
9679 geometry_info.psi=argument_list[4].real_reference;
9680 if (attribute_flag[5] != 0)
9681 channel=(ChannelType) argument_list[5].integer_reference;
9682 channel_mask=SetImageChannelMask(image,channel);
9683 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9684 geometry_info.xi,geometry_info.psi,exception);
9685 if (image != (Image *) NULL)
9686 (void) SetImageChannelMask(image,channel_mask);
9689 case 70: /* MotionBlur */
9691 if (attribute_flag[0] != 0)
9693 flags=ParseGeometry(argument_list[0].string_reference,
9695 if ((flags & SigmaValue) == 0)
9696 geometry_info.sigma=1.0;
9697 if ((flags & XiValue) == 0)
9698 geometry_info.xi=1.0;
9700 if (attribute_flag[1] != 0)
9701 geometry_info.rho=argument_list[1].real_reference;
9702 if (attribute_flag[2] != 0)
9703 geometry_info.sigma=argument_list[2].real_reference;
9704 if (attribute_flag[3] != 0)
9705 geometry_info.xi=argument_list[3].real_reference;
9706 if (attribute_flag[4] != 0)
9707 channel=(ChannelType) argument_list[4].integer_reference;
9708 channel_mask=SetImageChannelMask(image,channel);
9709 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9710 geometry_info.xi,exception);
9711 if (image != (Image *) NULL)
9712 (void) SetImageChannelMask(image,channel_mask);
9715 case 71: /* OrderedDither */
9717 if (attribute_flag[0] == 0)
9718 argument_list[0].string_reference="o8x8";
9719 if (attribute_flag[1] != 0)
9720 channel=(ChannelType) argument_list[1].integer_reference;
9721 channel_mask=SetImageChannelMask(image,channel);
9722 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9724 (void) SetImageChannelMask(image,channel_mask);
9727 case 72: /* Shave */
9729 if (attribute_flag[0] != 0)
9730 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9731 &geometry,exception);
9732 if (attribute_flag[1] != 0)
9733 geometry.width=argument_list[1].integer_reference;
9734 if (attribute_flag[2] != 0)
9735 geometry.height=argument_list[2].integer_reference;
9736 image=ShaveImage(image,&geometry,exception);
9739 case 73: /* Level */
9747 white_point=(double) image->columns*image->rows;
9749 if (attribute_flag[0] != 0)
9751 flags=ParseGeometry(argument_list[0].string_reference,
9753 black_point=geometry_info.rho;
9754 if ((flags & SigmaValue) != 0)
9755 white_point=geometry_info.sigma;
9756 if ((flags & XiValue) != 0)
9757 gamma=geometry_info.xi;
9758 if ((flags & PercentValue) != 0)
9760 black_point*=(double) (QuantumRange/100.0);
9761 white_point*=(double) (QuantumRange/100.0);
9763 if ((flags & SigmaValue) == 0)
9764 white_point=(double) QuantumRange-black_point;
9766 if (attribute_flag[1] != 0)
9767 black_point=argument_list[1].real_reference;
9768 if (attribute_flag[2] != 0)
9769 white_point=argument_list[2].real_reference;
9770 if (attribute_flag[3] != 0)
9771 gamma=argument_list[3].real_reference;
9772 if (attribute_flag[4] != 0)
9773 channel=(ChannelType) argument_list[4].integer_reference;
9774 if (attribute_flag[5] != 0)
9776 argument_list[0].real_reference=argument_list[5].real_reference;
9777 attribute_flag[0]=attribute_flag[5];
9779 channel_mask=SetImageChannelMask(image,channel);
9780 (void) LevelImage(image,black_point,white_point,gamma,exception);
9781 (void) SetImageChannelMask(image,channel_mask);
9786 if (attribute_flag[0] == 0)
9787 argument_list[0].string_reference="#1";
9788 if (attribute_flag[1] == 0)
9789 argument_list[1].integer_reference=MagickTrue;
9790 (void) ClipImagePath(image,argument_list[0].string_reference,
9791 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9795 case 75: /* AffineTransform */
9800 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9802 if (attribute_flag[0] != 0)
9807 av=(AV *) argument_list[0].array_reference;
9808 if ((av_len(av) != 3) && (av_len(av) != 5))
9810 ThrowPerlException(exception,OptionError,
9811 "affine matrix must have 4 or 6 elements",PackageName);
9814 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9815 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9816 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9817 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9818 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9819 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9821 ThrowPerlException(exception,OptionError,
9822 "affine matrix is singular",PackageName);
9825 if (av_len(av) == 5)
9827 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9828 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9831 for (j=1; j < 6; j++)
9833 if (attribute_flag[j] == 0)
9835 value=argument_list[j].string_reference;
9836 angle=argument_list[j].real_reference;
9837 current=draw_info->affine;
9838 GetAffineMatrix(&affine);
9846 flags=ParseGeometry(value,&geometry_info);
9847 affine.tx=geometry_info.xi;
9848 affine.ty=geometry_info.psi;
9849 if ((flags & PsiValue) == 0)
9850 affine.ty=affine.tx;
9858 flags=ParseGeometry(value,&geometry_info);
9859 affine.sx=geometry_info.rho;
9860 affine.sy=geometry_info.sigma;
9861 if ((flags & SigmaValue) == 0)
9862 affine.sy=affine.sx;
9872 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9873 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9874 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9875 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9883 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9891 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9895 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9896 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9897 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9898 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9899 draw_info->affine.tx=
9900 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9901 draw_info->affine.ty=
9902 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9904 if (attribute_flag[6] != 0)
9905 image->interpolate=(PixelInterpolateMethod)
9906 argument_list[6].integer_reference;
9907 if (attribute_flag[7] != 0)
9908 QueryColorCompliance(argument_list[7].string_reference,
9909 AllCompliance,&image->background_color,exception);
9910 image=AffineTransformImage(image,&draw_info->affine,exception);
9911 draw_info=DestroyDrawInfo(draw_info);
9914 case 76: /* Difference */
9916 if (attribute_flag[0] == 0)
9918 ThrowPerlException(exception,OptionError,
9919 "ReferenceImageRequired",PackageName);
9922 if (attribute_flag[1] != 0)
9923 image->fuzz=StringToDoubleInterval(
9924 argument_list[1].string_reference,(double) QuantumRange+1.0);
9925 (void) IsImagesEqual(image,argument_list[0].image_reference,
9929 case 77: /* AdaptiveThreshold */
9931 if (attribute_flag[0] != 0)
9933 flags=ParseGeometry(argument_list[0].string_reference,
9935 if ((flags & PercentValue) != 0)
9936 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9938 if (attribute_flag[1] != 0)
9939 geometry_info.rho=argument_list[1].integer_reference;
9940 if (attribute_flag[2] != 0)
9941 geometry_info.sigma=argument_list[2].integer_reference;
9942 if (attribute_flag[3] != 0)
9943 geometry_info.xi=argument_list[3].integer_reference;;
9944 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9945 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9948 case 78: /* Resample */
9954 if (attribute_flag[0] != 0)
9956 flags=ParseGeometry(argument_list[0].string_reference,
9958 if ((flags & SigmaValue) == 0)
9959 geometry_info.sigma=geometry_info.rho;
9961 if (attribute_flag[1] != 0)
9962 geometry_info.rho=argument_list[1].real_reference;
9963 if (attribute_flag[2] != 0)
9964 geometry_info.sigma=argument_list[2].real_reference;
9965 if (attribute_flag[3] == 0)
9966 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9967 if (attribute_flag[4] == 0)
9968 SetImageArtifact(image,"filter:support",
9969 argument_list[4].string_reference);
9970 width=(size_t) (geometry_info.rho*image->columns/
9971 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9972 height=(size_t) (geometry_info.sigma*image->rows/
9973 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9974 image=ResizeImage(image,width,height,(FilterTypes)
9975 argument_list[3].integer_reference,exception);
9976 if (image != (Image *) NULL)
9978 image->resolution.x=geometry_info.rho;
9979 image->resolution.y=geometry_info.sigma;
9983 case 79: /* Describe */
9985 if (attribute_flag[0] == 0)
9986 argument_list[0].file_reference=(FILE *) NULL;
9987 if (attribute_flag[1] != 0)
9988 (void) SetImageArtifact(image,"identify:features",
9989 argument_list[1].string_reference);
9990 (void) IdentifyImage(image,argument_list[0].file_reference,
9991 MagickTrue,exception);
9994 case 80: /* BlackThreshold */
9996 if (attribute_flag[0] == 0)
9997 argument_list[0].string_reference="50%";
9998 if (attribute_flag[2] != 0)
9999 channel=(ChannelType) argument_list[2].integer_reference;
10000 channel_mask=SetImageChannelMask(image,channel);
10001 BlackThresholdImage(image,argument_list[0].string_reference,
10003 (void) SetImageChannelMask(image,channel_mask);
10006 case 81: /* WhiteThreshold */
10008 if (attribute_flag[0] == 0)
10009 argument_list[0].string_reference="50%";
10010 if (attribute_flag[2] != 0)
10011 channel=(ChannelType) argument_list[2].integer_reference;
10012 channel_mask=SetImageChannelMask(image,channel);
10013 WhiteThresholdImage(image,argument_list[0].string_reference,
10015 (void) SetImageChannelMask(image,channel_mask);
10018 case 82: /* RotationalBlur */
10020 if (attribute_flag[0] != 0)
10022 flags=ParseGeometry(argument_list[0].string_reference,
10025 if (attribute_flag[1] != 0)
10026 geometry_info.rho=argument_list[1].real_reference;
10027 if (attribute_flag[2] != 0)
10028 channel=(ChannelType) argument_list[2].integer_reference;
10029 channel_mask=SetImageChannelMask(image,channel);
10030 image=RotationalBlurImage(image,geometry_info.rho,exception);
10031 if (image != (Image *) NULL)
10032 (void) SetImageChannelMask(image,channel_mask);
10035 case 83: /* Thumbnail */
10037 if (attribute_flag[0] != 0)
10038 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10039 &geometry,exception);
10040 if (attribute_flag[1] != 0)
10041 geometry.width=argument_list[1].integer_reference;
10042 if (attribute_flag[2] != 0)
10043 geometry.height=argument_list[2].integer_reference;
10044 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10047 case 84: /* Strip */
10049 (void) StripImage(image,exception);
10052 case 85: /* Tint */
10057 GetPixelInfo(image,&tint);
10058 if (attribute_flag[0] != 0)
10059 (void) QueryColorCompliance(argument_list[0].string_reference,
10060 AllCompliance,&tint,exception);
10061 if (attribute_flag[1] == 0)
10062 argument_list[1].string_reference="100";
10063 image=TintImage(image,argument_list[1].string_reference,&tint,
10067 case 86: /* Channel */
10069 if (attribute_flag[0] != 0)
10070 channel=(ChannelType) argument_list[0].integer_reference;
10071 image=SeparateImage(image,channel,exception);
10074 case 87: /* Splice */
10076 if (attribute_flag[7] != 0)
10077 image->gravity=(GravityType) argument_list[7].integer_reference;
10078 if (attribute_flag[0] != 0)
10079 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10080 &geometry,exception);
10081 if (attribute_flag[1] != 0)
10082 geometry.width=argument_list[1].integer_reference;
10083 if (attribute_flag[2] != 0)
10084 geometry.height=argument_list[2].integer_reference;
10085 if (attribute_flag[3] != 0)
10086 geometry.x=argument_list[3].integer_reference;
10087 if (attribute_flag[4] != 0)
10088 geometry.y=argument_list[4].integer_reference;
10089 if (attribute_flag[5] != 0)
10090 image->fuzz=StringToDoubleInterval(
10091 argument_list[5].string_reference,(double) QuantumRange+1.0);
10092 if (attribute_flag[6] != 0)
10093 (void) QueryColorCompliance(argument_list[6].string_reference,
10094 AllCompliance,&image->background_color,exception);
10095 image=SpliceImage(image,&geometry,exception);
10098 case 88: /* Posterize */
10100 if (attribute_flag[0] == 0)
10101 argument_list[0].integer_reference=3;
10102 if (attribute_flag[1] == 0)
10103 argument_list[1].integer_reference=0;
10104 (void) PosterizeImage(image,argument_list[0].integer_reference,
10105 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10106 NoDitherMethod,exception);
10109 case 89: /* Shadow */
10111 if (attribute_flag[0] != 0)
10113 flags=ParseGeometry(argument_list[0].string_reference,
10115 if ((flags & SigmaValue) == 0)
10116 geometry_info.sigma=1.0;
10117 if ((flags & XiValue) == 0)
10118 geometry_info.xi=4.0;
10119 if ((flags & PsiValue) == 0)
10120 geometry_info.psi=4.0;
10122 if (attribute_flag[1] != 0)
10123 geometry_info.rho=argument_list[1].real_reference;
10124 if (attribute_flag[2] != 0)
10125 geometry_info.sigma=argument_list[2].real_reference;
10126 if (attribute_flag[3] != 0)
10127 geometry_info.xi=argument_list[3].integer_reference;
10128 if (attribute_flag[4] != 0)
10129 geometry_info.psi=argument_list[4].integer_reference;
10130 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10131 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10132 ceil(geometry_info.psi-0.5),exception);
10135 case 90: /* Identify */
10137 if (attribute_flag[0] == 0)
10138 argument_list[0].file_reference=(FILE *) NULL;
10139 if (attribute_flag[1] != 0)
10140 (void) SetImageArtifact(image,"identify:features",
10141 argument_list[1].string_reference);
10142 if ((attribute_flag[2] != 0) &&
10143 (argument_list[2].integer_reference != 0))
10144 (void) SetImageArtifact(image,"identify:unique","true");
10145 (void) IdentifyImage(image,argument_list[0].file_reference,
10146 MagickTrue,exception);
10149 case 91: /* SepiaTone */
10151 if (attribute_flag[0] == 0)
10152 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10153 image=SepiaToneImage(image,argument_list[0].real_reference,
10157 case 92: /* SigmoidalContrast */
10162 if (attribute_flag[0] != 0)
10164 flags=ParseGeometry(argument_list[0].string_reference,
10166 if ((flags & SigmaValue) == 0)
10167 geometry_info.sigma=QuantumRange/2.0;
10168 if ((flags & PercentValue) != 0)
10169 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10171 if (attribute_flag[1] != 0)
10172 geometry_info.rho=argument_list[1].real_reference;
10173 if (attribute_flag[2] != 0)
10174 geometry_info.sigma=argument_list[2].real_reference;
10175 if (attribute_flag[3] != 0)
10176 channel=(ChannelType) argument_list[3].integer_reference;
10177 sharpen=MagickTrue;
10178 if (attribute_flag[4] != 0)
10179 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10181 channel_mask=SetImageChannelMask(image,channel);
10182 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10183 geometry_info.sigma,exception);
10184 (void) SetImageChannelMask(image,channel_mask);
10187 case 93: /* Extent */
10189 if (attribute_flag[7] != 0)
10190 image->gravity=(GravityType) argument_list[7].integer_reference;
10191 if (attribute_flag[0] != 0)
10196 flags=ParseGravityGeometry(image,
10197 argument_list[0].string_reference,&geometry,exception);
10199 if (geometry.width == 0)
10200 geometry.width=image->columns;
10201 if (geometry.height == 0)
10202 geometry.height=image->rows;
10204 if (attribute_flag[1] != 0)
10205 geometry.width=argument_list[1].integer_reference;
10206 if (attribute_flag[2] != 0)
10207 geometry.height=argument_list[2].integer_reference;
10208 if (attribute_flag[3] != 0)
10209 geometry.x=argument_list[3].integer_reference;
10210 if (attribute_flag[4] != 0)
10211 geometry.y=argument_list[4].integer_reference;
10212 if (attribute_flag[5] != 0)
10213 image->fuzz=StringToDoubleInterval(
10214 argument_list[5].string_reference,(double) QuantumRange+1.0);
10215 if (attribute_flag[6] != 0)
10216 (void) QueryColorCompliance(argument_list[6].string_reference,
10217 AllCompliance,&image->background_color,exception);
10218 image=ExtentImage(image,&geometry,exception);
10221 case 94: /* Vignette */
10223 if (attribute_flag[0] != 0)
10225 flags=ParseGeometry(argument_list[0].string_reference,
10227 if ((flags & SigmaValue) == 0)
10228 geometry_info.sigma=1.0;
10229 if ((flags & XiValue) == 0)
10230 geometry_info.xi=0.1*image->columns;
10231 if ((flags & PsiValue) == 0)
10232 geometry_info.psi=0.1*image->rows;
10234 if (attribute_flag[1] != 0)
10235 geometry_info.rho=argument_list[1].real_reference;
10236 if (attribute_flag[2] != 0)
10237 geometry_info.sigma=argument_list[2].real_reference;
10238 if (attribute_flag[3] != 0)
10239 geometry_info.xi=argument_list[3].integer_reference;
10240 if (attribute_flag[4] != 0)
10241 geometry_info.psi=argument_list[4].integer_reference;
10242 if (attribute_flag[5] != 0)
10243 (void) QueryColorCompliance(argument_list[5].string_reference,
10244 AllCompliance,&image->background_color,exception);
10245 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10246 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10247 ceil(geometry_info.psi-0.5),exception);
10250 case 95: /* ContrastStretch */
10257 white_point=(double) image->columns*image->rows;
10258 if (attribute_flag[0] != 0)
10260 flags=ParseGeometry(argument_list[0].string_reference,
10262 black_point=geometry_info.rho;
10263 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10265 if ((flags & PercentValue) != 0)
10267 black_point*=(double) image->columns*image->rows/100.0;
10268 white_point*=(double) image->columns*image->rows/100.0;
10270 white_point=(double) image->columns*image->rows-
10273 if (attribute_flag[1] != 0)
10274 black_point=argument_list[1].real_reference;
10275 if (attribute_flag[2] != 0)
10276 white_point=argument_list[2].real_reference;
10277 if (attribute_flag[4] != 0)
10278 channel=(ChannelType) argument_list[4].integer_reference;
10279 channel_mask=SetImageChannelMask(image,channel);
10280 (void) ContrastStretchImage(image,black_point,white_point,exception);
10281 (void) SetImageChannelMask(image,channel_mask);
10284 case 96: /* Sans0 */
10288 case 97: /* Sans1 */
10292 case 98: /* AdaptiveSharpen */
10294 if (attribute_flag[0] != 0)
10296 flags=ParseGeometry(argument_list[0].string_reference,
10298 if ((flags & SigmaValue) == 0)
10299 geometry_info.sigma=1.0;
10300 if ((flags & XiValue) == 0)
10301 geometry_info.xi=0.0;
10303 if (attribute_flag[1] != 0)
10304 geometry_info.rho=argument_list[1].real_reference;
10305 if (attribute_flag[2] != 0)
10306 geometry_info.sigma=argument_list[2].real_reference;
10307 if (attribute_flag[3] != 0)
10308 geometry_info.xi=argument_list[3].real_reference;
10309 if (attribute_flag[4] != 0)
10310 channel=(ChannelType) argument_list[4].integer_reference;
10311 channel_mask=SetImageChannelMask(image,channel);
10312 image=AdaptiveSharpenImage(image,geometry_info.rho,
10313 geometry_info.sigma,exception);
10314 if (image != (Image *) NULL)
10315 (void) SetImageChannelMask(image,channel_mask);
10318 case 99: /* Transpose */
10320 image=TransposeImage(image,exception);
10323 case 100: /* Tranverse */
10325 image=TransverseImage(image,exception);
10328 case 101: /* AutoOrient */
10330 image=AutoOrientImage(image,image->orientation,exception);
10333 case 102: /* AdaptiveBlur */
10335 if (attribute_flag[0] != 0)
10337 flags=ParseGeometry(argument_list[0].string_reference,
10339 if ((flags & SigmaValue) == 0)
10340 geometry_info.sigma=1.0;
10341 if ((flags & XiValue) == 0)
10342 geometry_info.xi=0.0;
10344 if (attribute_flag[1] != 0)
10345 geometry_info.rho=argument_list[1].real_reference;
10346 if (attribute_flag[2] != 0)
10347 geometry_info.sigma=argument_list[2].real_reference;
10348 if (attribute_flag[3] != 0)
10349 channel=(ChannelType) argument_list[3].integer_reference;
10350 channel_mask=SetImageChannelMask(image,channel);
10351 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10353 if (image != (Image *) NULL)
10354 (void) SetImageChannelMask(image,channel_mask);
10357 case 103: /* Sketch */
10359 if (attribute_flag[0] != 0)
10361 flags=ParseGeometry(argument_list[0].string_reference,
10363 if ((flags & SigmaValue) == 0)
10364 geometry_info.sigma=1.0;
10365 if ((flags & XiValue) == 0)
10366 geometry_info.xi=1.0;
10368 if (attribute_flag[1] != 0)
10369 geometry_info.rho=argument_list[1].real_reference;
10370 if (attribute_flag[2] != 0)
10371 geometry_info.sigma=argument_list[2].real_reference;
10372 if (attribute_flag[3] != 0)
10373 geometry_info.xi=argument_list[3].real_reference;
10374 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10375 geometry_info.xi,exception);
10378 case 104: /* UniqueColors */
10380 image=UniqueImageColors(image,exception);
10383 case 105: /* AdaptiveResize */
10385 if (attribute_flag[0] != 0)
10386 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10387 &geometry,exception);
10388 if (attribute_flag[1] != 0)
10389 geometry.width=argument_list[1].integer_reference;
10390 if (attribute_flag[2] != 0)
10391 geometry.height=argument_list[2].integer_reference;
10392 if (attribute_flag[3] != 0)
10393 image->filter=(FilterTypes) argument_list[4].integer_reference;
10394 if (attribute_flag[4] != 0)
10395 SetImageArtifact(image,"filter:support",
10396 argument_list[4].string_reference);
10397 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10401 case 106: /* ClipMask */
10406 if (attribute_flag[0] == 0)
10408 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10410 goto PerlException;
10412 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10414 (void) SetImageMask(image,mask_image,exception);
10415 mask_image=DestroyImage(mask_image);
10418 case 107: /* LinearStretch */
10425 white_point=(double) image->columns*image->rows;
10426 if (attribute_flag[0] != 0)
10428 flags=ParseGeometry(argument_list[0].string_reference,
10430 if ((flags & SigmaValue) != 0)
10431 white_point=geometry_info.sigma;
10432 if ((flags & PercentValue) != 0)
10434 black_point*=(double) image->columns*image->rows/100.0;
10435 white_point*=(double) image->columns*image->rows/100.0;
10437 if ((flags & SigmaValue) == 0)
10438 white_point=(double) image->columns*image->rows-black_point;
10440 if (attribute_flag[1] != 0)
10441 black_point=argument_list[1].real_reference;
10442 if (attribute_flag[2] != 0)
10443 white_point=argument_list[2].real_reference;
10444 (void) LinearStretchImage(image,black_point,white_point,exception);
10447 case 108: /* ColorMatrix */
10461 if (attribute_flag[0] == 0)
10463 av=(AV *) argument_list[0].array_reference;
10464 order=(size_t) sqrt(av_len(av)+1);
10465 color_matrix=(double *) AcquireQuantumMemory(order,order*
10466 sizeof(*color_matrix));
10467 if (color_matrix == (double *) NULL)
10469 ThrowPerlException(exception,ResourceLimitFatalError,
10470 "MemoryAllocationFailed",PackageName);
10471 goto PerlException;
10473 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10474 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10475 for ( ; j < (ssize_t) (order*order); j++)
10476 color_matrix[j]=0.0;
10477 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10478 if (kernel_info == (KernelInfo *) NULL)
10480 kernel_info->width=order;
10481 kernel_info->height=order;
10482 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10483 order*sizeof(*kernel_info->values));
10484 if (kernel_info->values != (MagickRealType *) NULL)
10486 for (i=0; i < (ssize_t) (order*order); i++)
10487 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10488 image=ColorMatrixImage(image,kernel_info,exception);
10490 kernel_info=DestroyKernelInfo(kernel_info);
10491 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10494 case 109: /* Mask */
10499 if (attribute_flag[0] == 0)
10501 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10503 goto PerlException;
10505 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10506 MagickTrue,exception);
10507 (void) SetImageMask(image,mask_image,exception);
10508 mask_image=DestroyImage(mask_image);
10511 case 110: /* Polaroid */
10522 PixelInterpolateMethod
10525 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10526 (DrawInfo *) NULL);
10527 caption=(char *) NULL;
10528 if (attribute_flag[0] != 0)
10529 caption=InterpretImageProperties(info ? info->image_info :
10530 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10533 if (attribute_flag[1] != 0)
10534 angle=argument_list[1].real_reference;
10535 if (attribute_flag[2] != 0)
10536 (void) CloneString(&draw_info->font,
10537 argument_list[2].string_reference);
10538 if (attribute_flag[3] != 0)
10539 (void) QueryColorCompliance(argument_list[3].string_reference,
10540 AllCompliance,&draw_info->stroke,exception);
10541 if (attribute_flag[4] != 0)
10542 (void) QueryColorCompliance(argument_list[4].string_reference,
10543 AllCompliance,&draw_info->fill,exception);
10544 if (attribute_flag[5] != 0)
10545 draw_info->stroke_width=argument_list[5].real_reference;
10546 if (attribute_flag[6] != 0)
10547 draw_info->pointsize=argument_list[6].real_reference;
10548 if (attribute_flag[7] != 0)
10549 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10550 if (attribute_flag[8] != 0)
10551 (void) QueryColorCompliance(argument_list[8].string_reference,
10552 AllCompliance,&image->background_color,exception);
10553 method=UndefinedInterpolatePixel;
10554 if (attribute_flag[9] != 0)
10555 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10556 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10557 draw_info=DestroyDrawInfo(draw_info);
10558 if (caption != (char *) NULL)
10559 caption=DestroyString(caption);
10562 case 111: /* FloodfillPaint */
10573 draw_info=CloneDrawInfo(info ? info->image_info :
10574 (ImageInfo *) NULL,(DrawInfo *) NULL);
10575 if (attribute_flag[0] != 0)
10576 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10577 &geometry,exception);
10578 if (attribute_flag[1] != 0)
10579 geometry.x=argument_list[1].integer_reference;
10580 if (attribute_flag[2] != 0)
10581 geometry.y=argument_list[2].integer_reference;
10582 if (attribute_flag[3] != 0)
10583 (void) QueryColorCompliance(argument_list[3].string_reference,
10584 AllCompliance,&draw_info->fill,exception);
10585 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10586 geometry.x,geometry.y,&target,exception);
10587 if (attribute_flag[4] != 0)
10588 QueryColorCompliance(argument_list[4].string_reference,
10589 AllCompliance,&target,exception);
10590 if (attribute_flag[5] != 0)
10591 image->fuzz=StringToDoubleInterval(
10592 argument_list[5].string_reference,(double) QuantumRange+1.0);
10593 if (attribute_flag[6] != 0)
10594 channel=(ChannelType) argument_list[6].integer_reference;
10595 invert=MagickFalse;
10596 if (attribute_flag[7] != 0)
10597 invert=(MagickBooleanType) argument_list[7].integer_reference;
10598 channel_mask=SetImageChannelMask(image,channel);
10599 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10600 geometry.y,invert,exception);
10601 (void) SetImageChannelMask(image,channel_mask);
10602 draw_info=DestroyDrawInfo(draw_info);
10605 case 112: /* Distort */
10617 number_coordinates;
10622 if (attribute_flag[0] == 0)
10624 method=UndefinedDistortion;
10625 if (attribute_flag[1] != 0)
10626 method=(DistortImageMethod) argument_list[1].integer_reference;
10627 av=(AV *) argument_list[0].array_reference;
10628 number_coordinates=(size_t) av_len(av)+1;
10629 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10630 sizeof(*coordinates));
10631 if (coordinates == (double *) NULL)
10633 ThrowPerlException(exception,ResourceLimitFatalError,
10634 "MemoryAllocationFailed",PackageName);
10635 goto PerlException;
10637 for (j=0; j < (ssize_t) number_coordinates; j++)
10638 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10639 virtual_pixel=UndefinedVirtualPixelMethod;
10640 if (attribute_flag[2] != 0)
10641 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10642 argument_list[2].integer_reference,exception);
10643 image=DistortImage(image,method,number_coordinates,coordinates,
10644 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10646 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10647 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10649 coordinates=(double *) RelinquishMagickMemory(coordinates);
10652 case 113: /* Clut */
10654 PixelInterpolateMethod
10657 if (attribute_flag[0] == 0)
10659 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10661 goto PerlException;
10663 method=UndefinedInterpolatePixel;
10664 if (attribute_flag[1] != 0)
10665 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10666 if (attribute_flag[2] != 0)
10667 channel=(ChannelType) argument_list[2].integer_reference;
10668 channel_mask=SetImageChannelMask(image,channel);
10669 (void) ClutImage(image,argument_list[0].image_reference,method,
10671 (void) SetImageChannelMask(image,channel_mask);
10674 case 114: /* LiquidRescale */
10676 if (attribute_flag[0] != 0)
10677 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10678 &geometry,exception);
10679 if (attribute_flag[1] != 0)
10680 geometry.width=argument_list[1].integer_reference;
10681 if (attribute_flag[2] != 0)
10682 geometry.height=argument_list[2].integer_reference;
10683 if (attribute_flag[3] == 0)
10684 argument_list[3].real_reference=1.0;
10685 if (attribute_flag[4] == 0)
10686 argument_list[4].real_reference=0.0;
10687 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10688 argument_list[3].real_reference,argument_list[4].real_reference,
10692 case 115: /* EncipherImage */
10694 (void) EncipherImage(image,argument_list[0].string_reference,
10698 case 116: /* DecipherImage */
10700 (void) DecipherImage(image,argument_list[0].string_reference,
10704 case 117: /* Deskew */
10706 geometry_info.rho=QuantumRange/2.0;
10707 if (attribute_flag[0] != 0)
10708 flags=ParseGeometry(argument_list[0].string_reference,
10710 if (attribute_flag[1] != 0)
10711 geometry_info.rho=StringToDoubleInterval(
10712 argument_list[1].string_reference,(double) QuantumRange+1.0);
10713 image=DeskewImage(image,geometry_info.rho,exception);
10716 case 118: /* Remap */
10721 if (attribute_flag[0] == 0)
10723 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10725 goto PerlException;
10727 quantize_info=AcquireQuantizeInfo(info->image_info);
10728 if (attribute_flag[1] != 0)
10729 quantize_info->dither_method=(DitherMethod)
10730 argument_list[1].integer_reference;
10731 (void) RemapImages(quantize_info,image,
10732 argument_list[0].image_reference,exception);
10733 quantize_info=DestroyQuantizeInfo(quantize_info);
10736 case 119: /* SparseColor */
10748 number_coordinates;
10753 if (attribute_flag[0] == 0)
10755 method=UndefinedColorInterpolate;
10756 if (attribute_flag[1] != 0)
10757 method=(SparseColorMethod) argument_list[1].integer_reference;
10758 av=(AV *) argument_list[0].array_reference;
10759 number_coordinates=(size_t) av_len(av)+1;
10760 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10761 sizeof(*coordinates));
10762 if (coordinates == (double *) NULL)
10764 ThrowPerlException(exception,ResourceLimitFatalError,
10765 "MemoryAllocationFailed",PackageName);
10766 goto PerlException;
10768 for (j=0; j < (ssize_t) number_coordinates; j++)
10769 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10770 virtual_pixel=UndefinedVirtualPixelMethod;
10771 if (attribute_flag[2] != 0)
10772 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10773 argument_list[2].integer_reference,exception);
10774 if (attribute_flag[3] != 0)
10775 channel=(ChannelType) argument_list[3].integer_reference;
10776 channel_mask=SetImageChannelMask(image,channel);
10777 image=SparseColorImage(image,method,number_coordinates,coordinates,
10779 if (image != (Image *) NULL)
10780 (void) SetImageChannelMask(image,channel_mask);
10781 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10782 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10784 coordinates=(double *) RelinquishMagickMemory(coordinates);
10787 case 120: /* Function */
10804 if (attribute_flag[0] == 0)
10806 function=UndefinedFunction;
10807 if (attribute_flag[1] != 0)
10808 function=(MagickFunction) argument_list[1].integer_reference;
10809 av=(AV *) argument_list[0].array_reference;
10810 number_parameters=(size_t) av_len(av)+1;
10811 parameters=(double *) AcquireQuantumMemory(number_parameters,
10812 sizeof(*parameters));
10813 if (parameters == (double *) NULL)
10815 ThrowPerlException(exception,ResourceLimitFatalError,
10816 "MemoryAllocationFailed",PackageName);
10817 goto PerlException;
10819 for (j=0; j < (ssize_t) number_parameters; j++)
10820 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10821 virtual_pixel=UndefinedVirtualPixelMethod;
10822 if (attribute_flag[2] != 0)
10823 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10824 argument_list[2].integer_reference,exception);
10825 (void) FunctionImage(image,function,number_parameters,parameters,
10827 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10828 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10830 parameters=(double *) RelinquishMagickMemory(parameters);
10833 case 121: /* SelectiveBlur */
10835 if (attribute_flag[0] != 0)
10837 flags=ParseGeometry(argument_list[0].string_reference,
10839 if ((flags & SigmaValue) == 0)
10840 geometry_info.sigma=1.0;
10841 if ((flags & PercentValue) != 0)
10842 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10844 if (attribute_flag[1] != 0)
10845 geometry_info.rho=argument_list[1].real_reference;
10846 if (attribute_flag[2] != 0)
10847 geometry_info.sigma=argument_list[2].real_reference;
10848 if (attribute_flag[3] != 0)
10849 geometry_info.xi=argument_list[3].integer_reference;;
10850 if (attribute_flag[5] != 0)
10851 channel=(ChannelType) argument_list[5].integer_reference;
10852 channel_mask=SetImageChannelMask(image,channel);
10853 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10854 geometry_info.xi,exception);
10855 if (image != (Image *) NULL)
10856 (void) SetImageChannelMask(image,channel_mask);
10859 case 122: /* HaldClut */
10861 if (attribute_flag[0] == 0)
10863 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10865 goto PerlException;
10867 if (attribute_flag[1] != 0)
10868 channel=(ChannelType) argument_list[1].integer_reference;
10869 channel_mask=SetImageChannelMask(image,channel);
10870 (void) HaldClutImage(image,argument_list[0].image_reference,
10872 (void) SetImageChannelMask(image,channel_mask);
10875 case 123: /* BlueShift */
10877 if (attribute_flag[0] != 0)
10878 (void) ParseGeometry(argument_list[0].string_reference,
10880 image=BlueShiftImage(image,geometry_info.rho,exception);
10883 case 124: /* ForwardFourierTransformImage */
10885 image=ForwardFourierTransformImage(image,
10886 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10890 case 125: /* InverseFourierTransformImage */
10892 image=InverseFourierTransformImage(image,image->next,
10893 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10897 case 126: /* ColorDecisionList */
10899 if (attribute_flag[0] == 0)
10900 argument_list[0].string_reference=(char *) NULL;
10901 (void) ColorDecisionListImage(image,
10902 argument_list[0].string_reference,exception);
10905 case 127: /* AutoGamma */
10907 if (attribute_flag[0] != 0)
10908 channel=(ChannelType) argument_list[0].integer_reference;
10909 channel_mask=SetImageChannelMask(image,channel);
10910 (void) AutoGammaImage(image,exception);
10911 (void) SetImageChannelMask(image,channel_mask);
10914 case 128: /* AutoLevel */
10916 if (attribute_flag[0] != 0)
10917 channel=(ChannelType) argument_list[0].integer_reference;
10918 channel_mask=SetImageChannelMask(image,channel);
10919 (void) AutoLevelImage(image,exception);
10920 (void) SetImageChannelMask(image,channel_mask);
10923 case 129: /* LevelColors */
10929 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10931 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10933 if (attribute_flag[1] != 0)
10934 (void) QueryColorCompliance(
10935 argument_list[1].string_reference,AllCompliance,&black_point,
10937 if (attribute_flag[2] != 0)
10938 (void) QueryColorCompliance(
10939 argument_list[2].string_reference,AllCompliance,&white_point,
10941 if (attribute_flag[3] != 0)
10942 channel=(ChannelType) argument_list[3].integer_reference;
10943 channel_mask=SetImageChannelMask(image,channel);
10944 (void) LevelImageColors(image,&black_point,&white_point,
10945 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10947 (void) SetImageChannelMask(image,channel_mask);
10950 case 130: /* Clamp */
10952 if (attribute_flag[0] != 0)
10953 channel=(ChannelType) argument_list[0].integer_reference;
10954 channel_mask=SetImageChannelMask(image,channel);
10955 (void) ClampImage(image,exception);
10956 (void) SetImageChannelMask(image,channel_mask);
10959 case 131: /* BrightnessContrast */
10967 if (attribute_flag[0] != 0)
10969 flags=ParseGeometry(argument_list[0].string_reference,
10971 brightness=geometry_info.rho;
10972 if ((flags & SigmaValue) == 0)
10973 contrast=geometry_info.sigma;
10975 if (attribute_flag[1] != 0)
10976 brightness=argument_list[1].real_reference;
10977 if (attribute_flag[2] != 0)
10978 contrast=argument_list[2].real_reference;
10979 if (attribute_flag[4] != 0)
10980 channel=(ChannelType) argument_list[4].integer_reference;
10981 channel_mask=SetImageChannelMask(image,channel);
10982 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10983 (void) SetImageChannelMask(image,channel_mask);
10986 case 132: /* Morphology */
10997 if (attribute_flag[0] == 0)
10999 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11000 if (kernel == (KernelInfo *) NULL)
11002 if (attribute_flag[1] != 0)
11003 channel=(ChannelType) argument_list[1].integer_reference;
11004 method=UndefinedMorphology;
11005 if (attribute_flag[2] != 0)
11006 method=argument_list[2].integer_reference;
11008 if (attribute_flag[3] != 0)
11009 iterations=argument_list[3].integer_reference;
11010 channel_mask=SetImageChannelMask(image,channel);
11011 image=MorphologyImage(image,method,iterations,kernel,exception);
11012 if (image != (Image *) NULL)
11013 (void) SetImageChannelMask(image,channel_mask);
11014 kernel=DestroyKernelInfo(kernel);
11017 case 133: /* Mode */
11019 if (attribute_flag[0] != 0)
11021 flags=ParseGeometry(argument_list[0].string_reference,
11023 if ((flags & SigmaValue) == 0)
11024 geometry_info.sigma=1.0;
11026 if (attribute_flag[1] != 0)
11027 geometry_info.rho=argument_list[1].real_reference;
11028 if (attribute_flag[2] != 0)
11029 geometry_info.sigma=argument_list[2].real_reference;
11030 if (attribute_flag[3] != 0)
11031 channel=(ChannelType) argument_list[3].integer_reference;
11032 channel_mask=SetImageChannelMask(image,channel);
11033 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11034 (size_t) geometry_info.sigma,exception);
11035 if (image != (Image *) NULL)
11036 (void) SetImageChannelMask(image,channel_mask);
11039 case 134: /* Statistic */
11044 statistic=UndefinedStatistic;
11045 if (attribute_flag[0] != 0)
11047 flags=ParseGeometry(argument_list[0].string_reference,
11049 if ((flags & SigmaValue) == 0)
11050 geometry_info.sigma=1.0;
11052 if (attribute_flag[1] != 0)
11053 geometry_info.rho=argument_list[1].real_reference;
11054 if (attribute_flag[2] != 0)
11055 geometry_info.sigma=argument_list[2].real_reference;
11056 if (attribute_flag[3] != 0)
11057 channel=(ChannelType) argument_list[3].integer_reference;
11058 if (attribute_flag[4] != 0)
11059 statistic=(StatisticType) argument_list[4].integer_reference;
11060 channel_mask=SetImageChannelMask(image,channel);
11061 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11062 (size_t) geometry_info.sigma,exception);
11063 if (image != (Image *) NULL)
11064 (void) SetImageChannelMask(image,channel_mask);
11067 case 135: /* Perceptible */
11072 epsilon=MagickEpsilon;
11073 if (attribute_flag[0] != 0)
11074 epsilon=argument_list[0].real_reference;
11075 if (attribute_flag[1] != 0)
11076 channel=(ChannelType) argument_list[1].integer_reference;
11077 channel_mask=SetImageChannelMask(image,channel);
11078 (void) PerceptibleImage(image,epsilon,exception);
11079 (void) SetImageChannelMask(image,channel_mask);
11082 case 136: /* Poly */
11093 if (attribute_flag[0] == 0)
11095 if (attribute_flag[1] != 0)
11096 channel=(ChannelType) argument_list[1].integer_reference;
11097 av=(AV *) argument_list[0].array_reference;
11098 number_terms=(size_t) av_len(av);
11099 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11100 if (terms == (double *) NULL)
11102 ThrowPerlException(exception,ResourceLimitFatalError,
11103 "MemoryAllocationFailed",PackageName);
11104 goto PerlException;
11106 for (j=0; j < av_len(av); j++)
11107 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11108 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11109 terms=(double *) RelinquishMagickMemory(terms);
11112 case 137: /* Grayscale */
11114 PixelIntensityMethod
11117 method=UndefinedPixelIntensityMethod;
11118 if (attribute_flag[0] != 0)
11119 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11120 (void) GrayscaleImage(image,method,exception);
11123 case 138: /* Canny */
11125 if (attribute_flag[0] != 0)
11127 flags=ParseGeometry(argument_list[0].string_reference,
11129 if ((flags & SigmaValue) == 0)
11130 geometry_info.sigma=1.0;
11131 if ((flags & XiValue) == 0)
11132 geometry_info.xi=0.10;
11133 if ((flags & PsiValue) == 0)
11134 geometry_info.psi=0.30;
11135 if ((flags & PercentValue) != 0)
11137 geometry_info.xi/=100.0;
11138 geometry_info.psi/=100.0;
11141 if (attribute_flag[1] != 0)
11142 geometry_info.rho=argument_list[1].real_reference;
11143 if (attribute_flag[2] != 0)
11144 geometry_info.sigma=argument_list[2].real_reference;
11145 if (attribute_flag[3] != 0)
11146 geometry_info.xi=argument_list[3].real_reference;
11147 if (attribute_flag[4] != 0)
11148 geometry_info.psi=argument_list[4].real_reference;
11149 if (attribute_flag[5] != 0)
11150 channel=(ChannelType) argument_list[5].integer_reference;
11151 channel_mask=SetImageChannelMask(image,channel);
11152 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11153 geometry_info.xi,geometry_info.psi,exception);
11154 if (image != (Image *) NULL)
11155 (void) SetImageChannelMask(image,channel_mask);
11158 case 139: /* HoughLine */
11160 if (attribute_flag[0] != 0)
11162 flags=ParseGeometry(argument_list[0].string_reference,
11164 if ((flags & SigmaValue) == 0)
11165 geometry_info.sigma=geometry_info.rho;
11166 if ((flags & XiValue) == 0)
11167 geometry_info.xi=40;
11169 if (attribute_flag[1] != 0)
11170 geometry_info.rho=(double) argument_list[1].integer_reference;
11171 if (attribute_flag[2] != 0)
11172 geometry_info.sigma=(double) argument_list[2].integer_reference;
11173 if (attribute_flag[3] != 0)
11174 geometry_info.xi=(double) argument_list[3].integer_reference;
11175 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11176 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11179 case 140: /* MeanShift */
11181 if (attribute_flag[0] != 0)
11183 flags=ParseGeometry(argument_list[0].string_reference,
11185 if ((flags & SigmaValue) == 0)
11186 geometry_info.sigma=geometry_info.rho;
11187 if ((flags & XiValue) == 0)
11188 geometry_info.xi=0.10*QuantumRange;
11189 if ((flags & PercentValue) != 0)
11190 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11192 if (attribute_flag[1] != 0)
11193 geometry_info.rho=(double) argument_list[1].integer_reference;
11194 if (attribute_flag[2] != 0)
11195 geometry_info.sigma=(double) argument_list[2].integer_reference;
11196 if (attribute_flag[3] != 0)
11197 geometry_info.xi=(double) argument_list[3].integer_reference;
11198 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11199 geometry_info.sigma,geometry_info.xi,exception);
11202 case 141: /* Kuwahara */
11204 if (attribute_flag[0] != 0)
11206 flags=ParseGeometry(argument_list[0].string_reference,
11208 if ((flags & SigmaValue) == 0)
11209 geometry_info.sigma=geometry_info.rho-0.5;
11211 if (attribute_flag[1] != 0)
11212 geometry_info.rho=argument_list[1].real_reference;
11213 if (attribute_flag[2] != 0)
11214 geometry_info.sigma=argument_list[2].real_reference;
11215 if (attribute_flag[3] != 0)
11216 channel=(ChannelType) argument_list[3].integer_reference;
11217 channel_mask=SetImageChannelMask(image,channel);
11218 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11220 if (image != (Image *) NULL)
11221 (void) SetImageChannelMask(image,channel_mask);
11224 case 142: /* ConnectedComponent */
11230 if (attribute_flag[0] != 0)
11231 connectivity=argument_list[0].integer_reference;
11232 image=ConnectedComponentsImage(image,connectivity,exception);
11236 if (next != (Image *) NULL)
11237 (void) CatchImageException(next);
11238 if (region_image != (Image *) NULL)
11243 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11244 region_info.x,region_info.y,exception);
11246 (void) CatchImageException(region_image);
11247 image=DestroyImage(image);
11248 image=region_image;
11250 if (image != (Image *) NULL)
11253 if (next && (next != image))
11255 image->next=next->next;
11256 if (image->next != (Image *) NULL)
11257 image->next->previous=image;
11258 DeleteImageFromRegistry(*pv,next);
11260 sv_setiv(*pv,PTR2IV(image));
11268 if (reference_vector)
11269 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11270 InheritPerlException(exception,perl_exception);
11271 exception=DestroyExceptionInfo(exception);
11272 sv_setiv(perl_exception,(IV) number_images);
11273 SvPOK_on(perl_exception);
11274 ST(0)=sv_2mortal(perl_exception);
11279 ###############################################################################
11287 ###############################################################################
11292 Image::Magick ref=NO_INIT
11337 PERL_UNUSED_VAR(ref);
11338 PERL_UNUSED_VAR(ix);
11339 exception=AcquireExceptionInfo();
11340 perl_exception=newSVpv("",0);
11343 if (sv_isobject(ST(0)) == 0)
11345 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11347 goto PerlException;
11349 reference=SvRV(ST(0));
11350 hv=SvSTASH(reference);
11352 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11354 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11355 if (image == (Image *) NULL)
11357 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11359 goto PerlException;
11364 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11365 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11366 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11368 for (i=2; i < items; i+=2)
11370 attribute=(char *) SvPV(ST(i-1),na);
11371 switch (*attribute)
11376 if (LocaleCompare(attribute,"background") == 0)
11378 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11379 &montage_info->background_color,exception);
11380 for (next=image; next; next=next->next)
11381 next->background_color=montage_info->background_color;
11384 if (LocaleCompare(attribute,"border") == 0)
11386 montage_info->border_width=SvIV(ST(i));
11389 if (LocaleCompare(attribute,"bordercolor") == 0)
11391 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11392 &montage_info->border_color,exception);
11393 for (next=image; next; next=next->next)
11394 next->border_color=montage_info->border_color;
11397 if (LocaleCompare(attribute,"borderwidth") == 0)
11399 montage_info->border_width=SvIV(ST(i));
11402 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11409 if (LocaleCompare(attribute,"compose") == 0)
11411 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11412 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11415 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11419 for (next=image; next; next=next->next)
11420 next->compose=(CompositeOperator) sp;
11423 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11430 if (LocaleCompare(attribute,"fill") == 0)
11432 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11433 &montage_info->fill,exception);
11436 if (LocaleCompare(attribute,"font") == 0)
11438 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11441 if (LocaleCompare(attribute,"frame") == 0)
11447 if (IsGeometry(p) == MagickFalse)
11449 ThrowPerlException(exception,OptionError,"MissingGeometry",
11453 (void) CloneString(&montage_info->frame,p);
11455 montage_info->frame=(char *) NULL;
11458 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11465 if (LocaleCompare(attribute,"geometry") == 0)
11471 if (IsGeometry(p) == MagickFalse)
11473 ThrowPerlException(exception,OptionError,"MissingGeometry",
11477 (void) CloneString(&montage_info->geometry,p);
11479 montage_info->geometry=(char *) NULL;
11482 if (LocaleCompare(attribute,"gravity") == 0)
11487 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11488 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11491 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11495 montage_info->gravity=(GravityType) in;
11496 for (next=image; next; next=next->next)
11497 next->gravity=(GravityType) in;
11500 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11507 if (LocaleCompare(attribute,"label") == 0)
11509 for (next=image; next; next=next->next)
11510 (void) SetImageProperty(next,"label",InterpretImageProperties(
11511 info ? info->image_info : (ImageInfo *) NULL,next,
11512 SvPV(ST(i),na),exception),exception);
11515 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11522 if (LocaleCompare(attribute,"mattecolor") == 0)
11524 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11525 &montage_info->matte_color,exception);
11526 for (next=image; next; next=next->next)
11527 next->matte_color=montage_info->matte_color;
11530 if (LocaleCompare(attribute,"mode") == 0)
11535 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11536 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11541 ThrowPerlException(exception,OptionError,
11542 "UnrecognizedModeType",SvPV(ST(i),na));
11547 (void) CloneString(&montage_info->frame,"15x15+3+3");
11548 montage_info->shadow=MagickTrue;
11553 montage_info->frame=(char *) NULL;
11554 montage_info->shadow=MagickFalse;
11555 montage_info->border_width=0;
11558 case ConcatenateMode:
11560 montage_info->frame=(char *) NULL;
11561 montage_info->shadow=MagickFalse;
11562 (void) CloneString(&montage_info->geometry,"+0+0");
11563 montage_info->border_width=0;
11568 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11575 if (LocaleCompare(attribute,"pointsize") == 0)
11577 montage_info->pointsize=SvIV(ST(i));
11580 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11587 if (LocaleCompare(attribute,"shadow") == 0)
11589 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11590 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11593 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11597 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11600 if (LocaleCompare(attribute,"stroke") == 0)
11602 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11603 &montage_info->stroke,exception);
11606 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11613 if (LocaleCompare(attribute,"texture") == 0)
11615 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11618 if (LocaleCompare(attribute,"tile") == 0)
11620 char *p=SvPV(ST(i),na);
11621 if (IsGeometry(p) == MagickFalse)
11623 ThrowPerlException(exception,OptionError,"MissingGeometry",
11627 (void) CloneString(&montage_info->tile,p);
11629 montage_info->tile=(char *) NULL;
11632 if (LocaleCompare(attribute,"title") == 0)
11634 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11637 if (LocaleCompare(attribute,"transparent") == 0)
11642 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11643 &transparent_color,exception);
11644 for (next=image; next; next=next->next)
11645 (void) TransparentPaintImage(next,&transparent_color,
11646 TransparentAlpha,MagickFalse,exception);
11649 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11655 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11661 image=MontageImageList(info->image_info,montage_info,image,exception);
11662 montage_info=DestroyMontageInfo(montage_info);
11663 if (image == (Image *) NULL)
11664 goto PerlException;
11665 if (transparent_color.alpha != TransparentAlpha)
11666 for (next=image; next; next=next->next)
11667 (void) TransparentPaintImage(next,&transparent_color,
11668 TransparentAlpha,MagickFalse,exception);
11669 for ( ; image; image=image->next)
11671 AddImageToRegistry(sv,image);
11673 av_push(av,sv_bless(rv,hv));
11676 exception=DestroyExceptionInfo(exception);
11677 ST(0)=av_reference;
11678 SvREFCNT_dec(perl_exception);
11682 InheritPerlException(exception,perl_exception);
11683 exception=DestroyExceptionInfo(exception);
11684 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11685 SvPOK_on(perl_exception);
11686 ST(0)=sv_2mortal(perl_exception);
11691 ###############################################################################
11699 ###############################################################################
11704 Image::Magick ref=NO_INIT
11742 PERL_UNUSED_VAR(ref);
11743 PERL_UNUSED_VAR(ix);
11744 exception=AcquireExceptionInfo();
11745 perl_exception=newSVpv("",0);
11749 if (sv_isobject(ST(0)) == 0)
11751 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11753 goto PerlException;
11755 reference=SvRV(ST(0));
11756 hv=SvSTASH(reference);
11758 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11760 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11761 if (image == (Image *) NULL)
11763 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11765 goto PerlException;
11767 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11772 for (i=2; i < items; i+=2)
11774 attribute=(char *) SvPV(ST(i-1),na);
11775 switch (*attribute)
11780 if (LocaleCompare(attribute,"frames") == 0)
11782 number_frames=SvIV(ST(i));
11785 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11791 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11797 image=MorphImages(image,number_frames,exception);
11798 if (image == (Image *) NULL)
11799 goto PerlException;
11800 for ( ; image; image=image->next)
11802 AddImageToRegistry(sv,image);
11804 av_push(av,sv_bless(rv,hv));
11807 exception=DestroyExceptionInfo(exception);
11808 ST(0)=av_reference;
11809 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11813 InheritPerlException(exception,perl_exception);
11814 exception=DestroyExceptionInfo(exception);
11815 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11816 SvPOK_on(perl_exception);
11817 ST(0)=sv_2mortal(perl_exception);
11822 ###############################################################################
11830 ###############################################################################
11835 Image::Magick ref=NO_INIT
11863 PERL_UNUSED_VAR(ref);
11864 PERL_UNUSED_VAR(ix);
11865 exception=AcquireExceptionInfo();
11866 perl_exception=newSVpv("",0);
11868 if (sv_isobject(ST(0)) == 0)
11870 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11872 goto PerlException;
11874 reference=SvRV(ST(0));
11875 hv=SvSTASH(reference);
11876 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11877 if (image == (Image *) NULL)
11879 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11881 goto PerlException;
11883 image=MergeImageLayers(image,MosaicLayer,exception);
11885 Create blessed Perl array for the returned image.
11888 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11890 AddImageToRegistry(sv,image);
11892 av_push(av,sv_bless(rv,hv));
11894 (void) CopyMagickString(info->image_info->filename,image->filename,
11896 SetImageInfo(info->image_info,0,exception);
11897 exception=DestroyExceptionInfo(exception);
11898 SvREFCNT_dec(perl_exception);
11902 InheritPerlException(exception,perl_exception);
11903 exception=DestroyExceptionInfo(exception);
11904 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11905 SvPOK_on(perl_exception); /* return messages in string context */
11906 ST(0)=sv_2mortal(perl_exception);
11911 ###############################################################################
11919 ###############################################################################
11924 Image::Magick ref=NO_INIT
11974 PERL_UNUSED_VAR(ref);
11975 PERL_UNUSED_VAR(ix);
11976 exception=AcquireExceptionInfo();
11977 perl_exception=newSVpv("",0);
11978 package_info=(struct PackageInfo *) NULL;
11979 ac=(items < 2) ? 1 : items-1;
11980 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11982 length=(STRLEN *) NULL;
11983 if (list == (char **) NULL)
11985 ThrowPerlException(exception,ResourceLimitError,
11986 "MemoryAllocationFailed",PackageName);
11987 goto PerlException;
11990 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11991 if (length == (STRLEN *) NULL)
11993 ThrowPerlException(exception,ResourceLimitError,
11994 "MemoryAllocationFailed",PackageName);
11995 goto PerlException;
11997 if (sv_isobject(ST(0)) == 0)
11999 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12001 goto PerlException;
12003 reference=SvRV(ST(0));
12004 if (SvTYPE(reference) != SVt_PVAV)
12006 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12008 goto PerlException;
12010 av=(AV *) reference;
12011 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12013 package_info=ClonePackageInfo(info,exception);
12016 *list=(char *) (*package_info->image_info->filename ?
12017 package_info->image_info->filename : "XC:black");
12019 for (n=0, i=0; i < ac; i++)
12021 list[n]=(char *) SvPV(ST(i+1),length[n]);
12022 if ((items >= 3) && strEQcase(list[n],"blob"))
12028 blob=(void *) (SvPV(ST(i+1),length[n]));
12029 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12031 if ((items >= 3) && strEQcase(list[n],"filename"))
12033 if ((items >= 3) && strEQcase(list[n],"file"))
12042 io_info=IoIFP(sv_2io(ST(i+1)));
12043 if (io_info == (PerlIO *) NULL)
12045 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12049 file=PerlIO_findFILE(io_info);
12050 if (file == (FILE *) NULL)
12052 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12056 SetImageInfoFile(package_info->image_info,file);
12058 if ((items >= 3) && strEQcase(list[n],"magick"))
12062 list[n]=(char *) NULL;
12064 status=ExpandFilenames(&n,&list);
12065 if (status == MagickFalse)
12067 ThrowPerlException(exception,ResourceLimitError,
12068 "MemoryAllocationFailed",PackageName);
12069 goto PerlException;
12072 for (i=0; i < n; i++)
12074 (void) CopyMagickString(package_info->image_info->filename,list[i],
12076 image=PingImage(package_info->image_info,exception);
12077 if (image == (Image *) NULL)
12079 if ((package_info->image_info->file != (FILE *) NULL) ||
12080 (package_info->image_info->blob != (void *) NULL))
12081 DisassociateImageStream(image);
12082 count+=GetImageListLength(image);
12083 EXTEND(sp,4*count);
12084 for (next=image; next; next=next->next)
12086 PUSHs(sv_2mortal(newSViv(next->columns)));
12087 PUSHs(sv_2mortal(newSViv(next->rows)));
12088 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12089 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12091 image=DestroyImageList(image);
12096 for (i=0; i < n; i++)
12097 if (list[i] != (char *) NULL)
12098 for (p=keep; list[i] != *p++; )
12101 list[i]=(char *) RelinquishMagickMemory(list[i]);
12106 if (package_info != (struct PackageInfo *) NULL)
12107 DestroyPackageInfo(package_info);
12108 if (list && (list != keep))
12109 list=(char **) RelinquishMagickMemory(list);
12111 keep=(char **) RelinquishMagickMemory(keep);
12113 length=(STRLEN *) RelinquishMagickMemory(length);
12114 InheritPerlException(exception,perl_exception);
12115 exception=DestroyExceptionInfo(exception);
12116 SvREFCNT_dec(perl_exception); /* throw away all errors */
12120 ###############################################################################
12128 ###############################################################################
12133 Image::Magick ref=NO_INIT
12166 PERL_UNUSED_VAR(ref);
12167 PERL_UNUSED_VAR(ix);
12168 exception=AcquireExceptionInfo();
12169 perl_exception=newSVpv("",0);
12172 if (sv_isobject(ST(0)) == 0)
12174 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12176 goto PerlException;
12178 reference=SvRV(ST(0));
12179 hv=SvSTASH(reference);
12181 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12183 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12184 if (image == (Image *) NULL)
12186 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12188 goto PerlException;
12190 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12191 preview_type=GammaPreview;
12193 preview_type=(PreviewType)
12194 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12195 for ( ; image; image=image->next)
12197 preview_image=PreviewImage(image,preview_type,exception);
12198 if (preview_image == (Image *) NULL)
12199 goto PerlException;
12200 AddImageToRegistry(sv,preview_image);
12202 av_push(av,sv_bless(rv,hv));
12205 exception=DestroyExceptionInfo(exception);
12206 ST(0)=av_reference;
12207 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12211 InheritPerlException(exception,perl_exception);
12212 exception=DestroyExceptionInfo(exception);
12213 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12214 SvPOK_on(perl_exception);
12215 ST(0)=sv_2mortal(perl_exception);
12220 ###############################################################################
12224 # Q u e r y C o l o r #
12228 ###############################################################################
12232 QueryColor(ref,...)
12233 Image::Magick ref=NO_INIT
12253 PERL_UNUSED_VAR(ref);
12254 PERL_UNUSED_VAR(ix);
12255 exception=AcquireExceptionInfo();
12256 perl_exception=newSVpv("",0);
12265 colorlist=GetColorInfoList("*",&colors,exception);
12267 for (i=0; i < (ssize_t) colors; i++)
12269 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12271 colorlist=(const ColorInfo **)
12272 RelinquishMagickMemory((ColorInfo **) colorlist);
12273 goto PerlException;
12275 EXTEND(sp,5*items);
12276 for (i=1; i < items; i++)
12278 name=(char *) SvPV(ST(i),na);
12279 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12284 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12285 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12286 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12287 if (color.colorspace == CMYKColorspace)
12288 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12289 if (color.alpha_trait == BlendPixelTrait)
12290 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12294 InheritPerlException(exception,perl_exception);
12295 exception=DestroyExceptionInfo(exception);
12296 SvREFCNT_dec(perl_exception);
12300 ###############################################################################
12304 # Q u e r y C o l o r N a m e #
12308 ###############################################################################
12312 QueryColorname(ref,...)
12313 Image::Magick ref=NO_INIT
12322 message[MaxTextExtent];
12341 *reference; /* reference is the SV* of ref=SvIV(reference) */
12343 PERL_UNUSED_VAR(ref);
12344 PERL_UNUSED_VAR(ix);
12345 exception=AcquireExceptionInfo();
12346 perl_exception=newSVpv("",0);
12347 reference=SvRV(ST(0));
12348 av=(AV *) reference;
12349 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12351 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12352 if (image == (Image *) NULL)
12354 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12356 goto PerlException;
12359 for (i=1; i < items; i++)
12361 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12363 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12365 PUSHs(sv_2mortal(newSVpv(message,0)));
12369 InheritPerlException(exception,perl_exception);
12370 exception=DestroyExceptionInfo(exception);
12371 SvREFCNT_dec(perl_exception);
12375 ###############################################################################
12379 # Q u e r y F o n t #
12383 ###############################################################################
12388 Image::Magick ref=NO_INIT
12395 message[MaxTextExtent];
12406 volatile const TypeInfo
12409 PERL_UNUSED_VAR(ref);
12410 PERL_UNUSED_VAR(ix);
12411 exception=AcquireExceptionInfo();
12412 perl_exception=newSVpv("",0);
12421 typelist=GetTypeInfoList("*",&types,exception);
12423 for (i=0; i < (ssize_t) types; i++)
12425 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12427 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12429 goto PerlException;
12431 EXTEND(sp,10*items);
12432 for (i=1; i < items; i++)
12434 name=(char *) SvPV(ST(i),na);
12435 type_info=GetTypeInfo(name,exception);
12436 if (type_info == (TypeInfo *) NULL)
12441 if (type_info->name == (char *) NULL)
12444 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12445 if (type_info->description == (char *) NULL)
12448 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12449 if (type_info->family == (char *) NULL)
12452 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12453 if (type_info->style == UndefinedStyle)
12456 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12457 type_info->style),0)));
12458 if (type_info->stretch == UndefinedStretch)
12461 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12462 type_info->stretch),0)));
12463 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12464 type_info->weight);
12465 PUSHs(sv_2mortal(newSVpv(message,0)));
12466 if (type_info->encoding == (char *) NULL)
12469 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12470 if (type_info->foundry == (char *) NULL)
12473 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12474 if (type_info->format == (char *) NULL)
12477 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12478 if (type_info->metrics == (char *) NULL)
12481 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12482 if (type_info->glyphs == (char *) NULL)
12485 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12489 InheritPerlException(exception,perl_exception);
12490 exception=DestroyExceptionInfo(exception);
12491 SvREFCNT_dec(perl_exception);
12495 ###############################################################################
12499 # Q u e r y F o n t M e t r i c s #
12503 ###############################################################################
12507 QueryFontMetrics(ref,...)
12508 Image::Magick ref=NO_INIT
12510 queryfontmetrics = 1
12557 *reference; /* reference is the SV* of ref=SvIV(reference) */
12562 PERL_UNUSED_VAR(ref);
12563 PERL_UNUSED_VAR(ix);
12564 exception=AcquireExceptionInfo();
12565 package_info=(struct PackageInfo *) NULL;
12566 perl_exception=newSVpv("",0);
12567 reference=SvRV(ST(0));
12568 av=(AV *) reference;
12569 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12571 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12572 if (image == (Image *) NULL)
12574 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12576 goto PerlException;
12578 package_info=ClonePackageInfo(info,exception);
12579 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12580 CloneString(&draw_info->text,"");
12581 current=draw_info->affine;
12582 GetAffineMatrix(&affine);
12585 EXTEND(sp,7*items);
12586 for (i=2; i < items; i+=2)
12588 attribute=(char *) SvPV(ST(i-1),na);
12589 switch (*attribute)
12594 if (LocaleCompare(attribute,"antialias") == 0)
12596 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12600 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12604 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12607 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12614 if (LocaleCompare(attribute,"density") == 0)
12616 CloneString(&draw_info->density,SvPV(ST(i),na));
12619 if (LocaleCompare(attribute,"direction") == 0)
12621 draw_info->direction=(DirectionType) ParseCommandOption(
12622 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12632 if (LocaleCompare(attribute,"encoding") == 0)
12634 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12637 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12644 if (LocaleCompare(attribute,"family") == 0)
12646 CloneString(&draw_info->family,SvPV(ST(i),na));
12649 if (LocaleCompare(attribute,"fill") == 0)
12652 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12653 &draw_info->fill,exception);
12656 if (LocaleCompare(attribute,"font") == 0)
12658 CloneString(&draw_info->font,SvPV(ST(i),na));
12661 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12668 if (LocaleCompare(attribute,"geometry") == 0)
12670 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12673 if (LocaleCompare(attribute,"gravity") == 0)
12675 draw_info->gravity=(GravityType) ParseCommandOption(
12676 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12679 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12686 if (LocaleCompare(attribute,"interline-spacing") == 0)
12688 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12689 draw_info->interline_spacing=geometry_info.rho;
12692 if (LocaleCompare(attribute,"interword-spacing") == 0)
12694 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12695 draw_info->interword_spacing=geometry_info.rho;
12698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12705 if (LocaleCompare(attribute,"kerning") == 0)
12707 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12708 draw_info->kerning=geometry_info.rho;
12711 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12718 if (LocaleCompare(attribute,"pointsize") == 0)
12720 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12721 draw_info->pointsize=geometry_info.rho;
12724 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12731 if (LocaleCompare(attribute,"rotate") == 0)
12733 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12734 affine.rx=geometry_info.rho;
12735 affine.ry=geometry_info.sigma;
12736 if ((flags & SigmaValue) == 0)
12737 affine.ry=affine.rx;
12740 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12747 if (LocaleCompare(attribute,"scale") == 0)
12749 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12750 affine.sx=geometry_info.rho;
12751 affine.sy=geometry_info.sigma;
12752 if ((flags & SigmaValue) == 0)
12753 affine.sy=affine.sx;
12756 if (LocaleCompare(attribute,"skew") == 0)
12762 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12763 x_angle=geometry_info.rho;
12764 y_angle=geometry_info.sigma;
12765 if ((flags & SigmaValue) == 0)
12767 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12768 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12771 if (LocaleCompare(attribute,"stroke") == 0)
12774 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12775 &draw_info->stroke,exception);
12778 if (LocaleCompare(attribute,"style") == 0)
12780 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12784 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12788 draw_info->style=(StyleType) type;
12791 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12798 if (LocaleCompare(attribute,"text") == 0)
12800 CloneString(&draw_info->text,SvPV(ST(i),na));
12803 if (LocaleCompare(attribute,"translate") == 0)
12805 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12806 affine.tx=geometry_info.rho;
12807 affine.ty=geometry_info.sigma;
12808 if ((flags & SigmaValue) == 0)
12809 affine.ty=affine.tx;
12812 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12819 if (LocaleCompare(attribute,"weight") == 0)
12821 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12822 draw_info->weight=(size_t) geometry_info.rho;
12825 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12832 if (LocaleCompare(attribute,"x") == 0)
12834 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12835 x=geometry_info.rho;
12838 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12845 if (LocaleCompare(attribute,"y") == 0)
12847 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12848 y=geometry_info.rho;
12851 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12857 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12863 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12864 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12865 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12866 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12867 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12868 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12869 if (draw_info->geometry == (char *) NULL)
12871 draw_info->geometry=AcquireString((char *) NULL);
12872 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12873 "%.15g,%.15g",x,y);
12875 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12876 (void) CatchImageException(image);
12877 if (status == MagickFalse)
12881 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12882 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12883 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12884 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12885 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12886 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12887 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12888 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12889 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12890 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12891 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12892 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12893 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12895 draw_info=DestroyDrawInfo(draw_info);
12898 if (package_info != (struct PackageInfo *) NULL)
12899 DestroyPackageInfo(package_info);
12900 InheritPerlException(exception,perl_exception);
12901 exception=DestroyExceptionInfo(exception);
12902 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12906 ###############################################################################
12910 # 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 #
12914 ###############################################################################
12918 QueryMultilineFontMetrics(ref,...)
12919 Image::Magick ref=NO_INIT
12921 querymultilinefontmetrics = 1
12968 *reference; /* reference is the SV* of ref=SvIV(reference) */
12973 PERL_UNUSED_VAR(ref);
12974 PERL_UNUSED_VAR(ix);
12975 exception=AcquireExceptionInfo();
12976 package_info=(struct PackageInfo *) NULL;
12977 perl_exception=newSVpv("",0);
12978 reference=SvRV(ST(0));
12979 av=(AV *) reference;
12980 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12982 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12983 if (image == (Image *) NULL)
12985 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12987 goto PerlException;
12989 package_info=ClonePackageInfo(info,exception);
12990 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12991 CloneString(&draw_info->text,"");
12992 current=draw_info->affine;
12993 GetAffineMatrix(&affine);
12996 EXTEND(sp,7*items);
12997 for (i=2; i < items; i+=2)
12999 attribute=(char *) SvPV(ST(i-1),na);
13000 switch (*attribute)
13005 if (LocaleCompare(attribute,"antialias") == 0)
13007 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13011 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13015 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13018 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13025 if (LocaleCompare(attribute,"density") == 0)
13027 CloneString(&draw_info->density,SvPV(ST(i),na));
13030 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13037 if (LocaleCompare(attribute,"encoding") == 0)
13039 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13042 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13049 if (LocaleCompare(attribute,"family") == 0)
13051 CloneString(&draw_info->family,SvPV(ST(i),na));
13054 if (LocaleCompare(attribute,"fill") == 0)
13057 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13058 &draw_info->fill,exception);
13061 if (LocaleCompare(attribute,"font") == 0)
13063 CloneString(&draw_info->font,SvPV(ST(i),na));
13066 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13073 if (LocaleCompare(attribute,"geometry") == 0)
13075 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13078 if (LocaleCompare(attribute,"gravity") == 0)
13080 draw_info->gravity=(GravityType) ParseCommandOption(
13081 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13084 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13091 if (LocaleCompare(attribute,"pointsize") == 0)
13093 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13094 draw_info->pointsize=geometry_info.rho;
13097 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13104 if (LocaleCompare(attribute,"rotate") == 0)
13106 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13107 affine.rx=geometry_info.rho;
13108 affine.ry=geometry_info.sigma;
13109 if ((flags & SigmaValue) == 0)
13110 affine.ry=affine.rx;
13113 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13120 if (LocaleCompare(attribute,"scale") == 0)
13122 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13123 affine.sx=geometry_info.rho;
13124 affine.sy=geometry_info.sigma;
13125 if ((flags & SigmaValue) == 0)
13126 affine.sy=affine.sx;
13129 if (LocaleCompare(attribute,"skew") == 0)
13135 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13136 x_angle=geometry_info.rho;
13137 y_angle=geometry_info.sigma;
13138 if ((flags & SigmaValue) == 0)
13140 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13141 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13144 if (LocaleCompare(attribute,"stroke") == 0)
13147 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13148 &draw_info->stroke,exception);
13151 if (LocaleCompare(attribute,"style") == 0)
13153 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13157 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13161 draw_info->style=(StyleType) type;
13164 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13171 if (LocaleCompare(attribute,"text") == 0)
13173 CloneString(&draw_info->text,SvPV(ST(i),na));
13176 if (LocaleCompare(attribute,"translate") == 0)
13178 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13179 affine.tx=geometry_info.rho;
13180 affine.ty=geometry_info.sigma;
13181 if ((flags & SigmaValue) == 0)
13182 affine.ty=affine.tx;
13185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13192 if (LocaleCompare(attribute,"weight") == 0)
13194 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13195 draw_info->weight=(size_t) geometry_info.rho;
13198 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13205 if (LocaleCompare(attribute,"x") == 0)
13207 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13208 x=geometry_info.rho;
13211 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13218 if (LocaleCompare(attribute,"y") == 0)
13220 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13221 y=geometry_info.rho;
13224 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13230 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13236 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13237 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13238 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13239 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13240 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13241 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13242 if (draw_info->geometry == (char *) NULL)
13244 draw_info->geometry=AcquireString((char *) NULL);
13245 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
13246 "%.15g,%.15g",x,y);
13248 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13249 (void) CatchException(exception);
13250 if (status == MagickFalse)
13254 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13255 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13256 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13257 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13258 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13259 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13260 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13261 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13262 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13263 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13264 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13265 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13266 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13268 draw_info=DestroyDrawInfo(draw_info);
13271 if (package_info != (struct PackageInfo *) NULL)
13272 DestroyPackageInfo(package_info);
13273 InheritPerlException(exception,perl_exception);
13274 exception=DestroyExceptionInfo(exception);
13275 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13279 ###############################################################################
13283 # Q u e r y F o r m a t #
13287 ###############################################################################
13291 QueryFormat(ref,...)
13292 Image::Magick ref=NO_INIT
13309 volatile const MagickInfo
13312 PERL_UNUSED_VAR(ref);
13313 PERL_UNUSED_VAR(ix);
13314 exception=AcquireExceptionInfo();
13315 perl_exception=newSVpv("",0);
13319 format[MaxTextExtent];
13327 format_list=GetMagickInfoList("*",&types,exception);
13329 for (i=0; i < (ssize_t) types; i++)
13331 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13332 LocaleLower(format);
13333 PUSHs(sv_2mortal(newSVpv(format,0)));
13335 format_list=(const MagickInfo **)
13336 RelinquishMagickMemory((MagickInfo *) format_list);
13337 goto PerlException;
13339 EXTEND(sp,8*items);
13340 for (i=1; i < items; i++)
13342 name=(char *) SvPV(ST(i),na);
13343 magick_info=GetMagickInfo(name,exception);
13344 if (magick_info == (const MagickInfo *) NULL)
13349 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13350 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13351 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13352 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13353 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13354 if (magick_info->description == (char *) NULL)
13357 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13358 if (magick_info->module == (char *) NULL)
13361 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13365 InheritPerlException(exception,perl_exception);
13366 exception=DestroyExceptionInfo(exception);
13367 SvREFCNT_dec(perl_exception);
13371 ###############################################################################
13375 # Q u e r y O p t i o n #
13379 ###############################################################################
13383 QueryOption(ref,...)
13384 Image::Magick ref=NO_INIT
13405 PERL_UNUSED_VAR(ref);
13406 PERL_UNUSED_VAR(ix);
13407 exception=AcquireExceptionInfo();
13408 perl_exception=newSVpv("",0);
13409 EXTEND(sp,8*items);
13410 for (i=1; i < items; i++)
13412 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13414 options=GetCommandOptions((CommandOption) option);
13415 if (options == (char **) NULL)
13419 for (j=0; options[j] != (char *) NULL; j++)
13420 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13421 options=DestroyStringList(options);
13425 InheritPerlException(exception,perl_exception);
13426 exception=DestroyExceptionInfo(exception);
13427 SvREFCNT_dec(perl_exception);
13431 ###############################################################################
13439 ###############################################################################
13444 Image::Magick ref=NO_INIT
13491 *perl_exception, /* Perl variable for storing messages */
13496 PERL_UNUSED_VAR(ref);
13497 PERL_UNUSED_VAR(ix);
13498 exception=AcquireExceptionInfo();
13499 perl_exception=newSVpv("",0);
13501 package_info=(struct PackageInfo *) NULL;
13503 ac=(items < 2) ? 1 : items-1;
13504 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13506 length=(STRLEN *) NULL;
13507 if (list == (char **) NULL)
13509 ThrowPerlException(exception,ResourceLimitError,
13510 "MemoryAllocationFailed",PackageName);
13511 goto PerlException;
13513 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13514 if (length == (STRLEN *) NULL)
13516 ThrowPerlException(exception,ResourceLimitError,
13517 "MemoryAllocationFailed",PackageName);
13518 goto PerlException;
13520 if (sv_isobject(ST(0)) == 0)
13522 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13524 goto PerlException;
13526 reference=SvRV(ST(0));
13527 hv=SvSTASH(reference);
13528 if (SvTYPE(reference) != SVt_PVAV)
13530 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13532 goto PerlException;
13534 av=(AV *) reference;
13535 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13537 package_info=ClonePackageInfo(info,exception);
13540 *list=(char *) (*package_info->image_info->filename ?
13541 package_info->image_info->filename : "XC:black");
13543 for (n=0, i=0; i < ac; i++)
13545 list[n]=(char *) SvPV(ST(i+1),length[n]);
13546 if ((items >= 3) && strEQcase(list[n],"blob"))
13552 blob=(void *) (SvPV(ST(i+1),length[n]));
13553 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13555 if ((items >= 3) && strEQcase(list[n],"filename"))
13557 if ((items >= 3) && strEQcase(list[n],"file"))
13566 io_info=IoIFP(sv_2io(ST(i+1)));
13567 if (io_info == (PerlIO *) NULL)
13569 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13573 file=PerlIO_findFILE(io_info);
13574 if (file == (FILE *) NULL)
13576 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13580 SetImageInfoFile(package_info->image_info,file);
13582 if ((items >= 3) && strEQcase(list[n],"magick"))
13586 list[n]=(char *) NULL;
13588 status=ExpandFilenames(&n,&list);
13589 if (status == MagickFalse)
13591 ThrowPerlException(exception,ResourceLimitError,
13592 "MemoryAllocationFailed",PackageName);
13593 goto PerlException;
13596 for (i=0; i < n; i++)
13598 if ((package_info->image_info->file == (FILE *) NULL) &&
13599 (package_info->image_info->blob == (void *) NULL))
13600 image=ReadImages(package_info->image_info,list[i],exception);
13603 image=ReadImages(package_info->image_info,
13604 package_info->image_info->filename,exception);
13605 if (image != (Image *) NULL)
13606 DisassociateImageStream(image);
13608 if (image == (Image *) NULL)
13610 for ( ; image; image=image->next)
13612 AddImageToRegistry(sv,image);
13614 av_push(av,sv_bless(rv,hv));
13622 for (i=0; i < n; i++)
13623 if (list[i] != (char *) NULL)
13624 for (p=keep; list[i] != *p++; )
13625 if (*p == (char *) NULL)
13627 list[i]=(char *) RelinquishMagickMemory(list[i]);
13632 if (package_info != (struct PackageInfo *) NULL)
13633 DestroyPackageInfo(package_info);
13634 if (list && (list != keep))
13635 list=(char **) RelinquishMagickMemory(list);
13637 keep=(char **) RelinquishMagickMemory(keep);
13639 length=(STRLEN *) RelinquishMagickMemory(length);
13640 InheritPerlException(exception,perl_exception);
13641 exception=DestroyExceptionInfo(exception);
13642 sv_setiv(perl_exception,(IV) number_images);
13643 SvPOK_on(perl_exception);
13644 ST(0)=sv_2mortal(perl_exception);
13649 ###############################################################################
13657 ###############################################################################
13662 Image::Magick ref=NO_INIT
13685 PERL_UNUSED_VAR(ref);
13686 PERL_UNUSED_VAR(ix);
13687 exception=AcquireExceptionInfo();
13688 perl_exception=newSVpv("",0);
13689 reference=SvRV(ST(0));
13690 av=(AV *) reference;
13691 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13693 for (i=1; i < items; i++)
13694 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13695 SvPV(ST(i),na),exception);
13696 InheritPerlException(exception,perl_exception);
13697 exception=DestroyExceptionInfo(exception);
13698 SvREFCNT_dec(perl_exception); /* throw away all errors */
13702 ###############################################################################
13710 ###############################################################################
13715 Image::Magick ref=NO_INIT
13738 *reference; /* reference is the SV* of ref=SvIV(reference) */
13740 PERL_UNUSED_VAR(ref);
13741 PERL_UNUSED_VAR(ix);
13742 exception=AcquireExceptionInfo();
13743 perl_exception=newSVpv("",0);
13744 if (sv_isobject(ST(0)) == 0)
13746 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13748 goto PerlException;
13750 reference=SvRV(ST(0));
13751 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13753 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13755 for (i=2; i < items; i+=2)
13756 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13759 InheritPerlException(exception,perl_exception);
13760 exception=DestroyExceptionInfo(exception);
13761 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13762 SvPOK_on(perl_exception);
13763 ST(0)=sv_2mortal(perl_exception);
13768 ###############################################################################
13772 # S e t P i x e l #
13776 ###############################################################################
13781 Image::Magick ref=NO_INIT
13823 *reference; /* reference is the SV* of ref=SvIV(reference) */
13825 PERL_UNUSED_VAR(ref);
13826 PERL_UNUSED_VAR(ix);
13827 exception=AcquireExceptionInfo();
13828 perl_exception=newSVpv("",0);
13829 reference=SvRV(ST(0));
13830 av=(AV *) reference;
13831 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13833 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13834 if (image == (Image *) NULL)
13836 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13838 goto PerlException;
13841 normalize=MagickTrue;
13844 region.width=image->columns;
13847 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13848 channel=DefaultChannels;
13849 for (i=2; i < items; i+=2)
13851 attribute=(char *) SvPV(ST(i-1),na);
13852 switch (*attribute)
13857 if (LocaleCompare(attribute,"channel") == 0)
13862 option=ParseChannelOption(SvPV(ST(i),na));
13865 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13869 channel=(ChannelType) option;
13872 if (LocaleCompare(attribute,"color") == 0)
13874 if (SvTYPE(ST(i)) != SVt_RV)
13877 message[MaxTextExtent];
13879 (void) FormatLocaleString(message,MaxTextExtent,
13880 "invalid %.60s value",attribute);
13881 ThrowPerlException(exception,OptionError,message,
13884 av=(AV *) SvRV(ST(i));
13887 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13894 if (LocaleCompare(attribute,"geometry") == 0)
13896 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13906 if (LocaleCompare(attribute,"normalize") == 0)
13908 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13912 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13916 normalize=option != 0 ? MagickTrue : MagickFalse;
13919 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13926 if (LocaleCompare(attribute,"x") == 0)
13928 region.x=SvIV(ST(i));
13931 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13938 if (LocaleCompare(attribute,"y") == 0)
13940 region.y=SvIV(ST(i));
13943 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13949 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13955 (void) SetImageStorageClass(image,DirectClass,exception);
13956 channel_mask=SetImageChannelMask(image,channel);
13957 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13958 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13959 (SvTYPE(av) != SVt_PVAV))
13971 if (normalize != MagickFalse)
13972 scale=QuantumRange;
13973 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13976 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13977 av_fetch(av,i,0)))),q);
13980 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13983 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13984 av_fetch(av,i,0)))),q);
13987 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13990 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13991 av_fetch(av,i,0)))),q);
13994 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13995 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13997 SetPixelBlack(image,ClampToQuantum(scale*
13998 SvNV(*(av_fetch(av,i,0)))),q);
14001 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14004 SetPixelAlpha(image,ClampToQuantum(scale*
14005 SvNV(*(av_fetch(av,i,0)))),q);
14008 (void) SyncAuthenticPixels(image,exception);
14010 (void) SetImageChannelMask(image,channel_mask);
14013 InheritPerlException(exception,perl_exception);
14014 exception=DestroyExceptionInfo(exception);
14015 SvREFCNT_dec(perl_exception);
14019 ###############################################################################
14027 ###############################################################################
14032 Image::Magick ref=NO_INIT
14071 PERL_UNUSED_VAR(ref);
14072 PERL_UNUSED_VAR(ix);
14073 exception=AcquireExceptionInfo();
14074 perl_exception=newSVpv("",0);
14078 if (sv_isobject(ST(0)) == 0)
14080 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14082 goto PerlException;
14084 reference=SvRV(ST(0));
14085 hv=SvSTASH(reference);
14087 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14089 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14090 if (image == (Image *) NULL)
14092 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14094 goto PerlException;
14096 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14102 for (i=2; i < items; i+=2)
14104 attribute=(char *) SvPV(ST(i-1),na);
14105 switch (*attribute)
14110 if (LocaleCompare(attribute,"offset") == 0)
14112 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14115 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14122 if (LocaleCompare(attribute,"stack") == 0)
14124 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14128 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14134 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14140 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14146 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14148 if (image == (Image *) NULL)
14149 goto PerlException;
14150 for ( ; image; image=image->next)
14152 AddImageToRegistry(sv,image);
14154 av_push(av,sv_bless(rv,hv));
14157 exception=DestroyExceptionInfo(exception);
14158 ST(0)=av_reference;
14159 SvREFCNT_dec(perl_exception);
14163 InheritPerlException(exception,perl_exception);
14164 exception=DestroyExceptionInfo(exception);
14165 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14166 SvPOK_on(perl_exception);
14167 ST(0)=sv_2mortal(perl_exception);
14172 ###############################################################################
14176 # S t a t i s t i c s #
14180 ###############################################################################
14184 Statistics(ref,...)
14185 Image::Magick ref=NO_INIT
14187 StatisticsImage = 1
14189 statisticsimage = 3
14192 #define ChannelStatistics(channel) \
14194 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
14195 (double) channel_statistics[channel].depth); \
14196 PUSHs(sv_2mortal(newSVpv(message,0))); \
14197 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14198 channel_statistics[channel].minima/scale); \
14199 PUSHs(sv_2mortal(newSVpv(message,0))); \
14200 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14201 channel_statistics[channel].maxima/scale); \
14202 PUSHs(sv_2mortal(newSVpv(message,0))); \
14203 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14204 channel_statistics[channel].mean/scale); \
14205 PUSHs(sv_2mortal(newSVpv(message,0))); \
14206 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14207 channel_statistics[channel].standard_deviation/scale); \
14208 PUSHs(sv_2mortal(newSVpv(message,0))); \
14209 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14210 channel_statistics[channel].kurtosis); \
14211 PUSHs(sv_2mortal(newSVpv(message,0))); \
14212 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14213 channel_statistics[channel].skewness); \
14214 PUSHs(sv_2mortal(newSVpv(message,0))); \
14215 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14216 channel_statistics[channel].entropy); \
14217 PUSHs(sv_2mortal(newSVpv(message,0))); \
14224 message[MaxTextExtent];
14227 *channel_statistics;
14248 PERL_UNUSED_VAR(ref);
14249 PERL_UNUSED_VAR(ix);
14250 exception=AcquireExceptionInfo();
14251 perl_exception=newSVpv("",0);
14253 if (sv_isobject(ST(0)) == 0)
14255 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14257 goto PerlException;
14259 reference=SvRV(ST(0));
14262 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14263 if (image == (Image *) NULL)
14265 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14267 goto PerlException;
14270 for ( ; image; image=image->next)
14272 channel_statistics=GetImageStatistics(image,exception);
14273 if (channel_statistics == (ChannelStatistics *) NULL)
14276 EXTEND(sp,35*count);
14277 scale=(double) QuantumRange;
14278 ChannelStatistics(RedChannel);
14279 ChannelStatistics(GreenChannel);
14280 ChannelStatistics(BlueChannel);
14281 if (image->colorspace == CMYKColorspace)
14282 ChannelStatistics(BlackChannel);
14283 if (image->alpha_trait == BlendPixelTrait)
14284 ChannelStatistics(AlphaChannel);
14285 channel_statistics=(ChannelStatistics *)
14286 RelinquishMagickMemory(channel_statistics);
14290 InheritPerlException(exception,perl_exception);
14291 exception=DestroyExceptionInfo(exception);
14292 SvREFCNT_dec(perl_exception);
14296 ###############################################################################
14300 # S y n c A u t h e n t i c P i x e l s #
14304 ###############################################################################
14308 SyncAuthenticPixels(ref,...)
14309 Image::Magick ref = NO_INIT
14311 Syncauthenticpixels = 1
14312 SyncImagePixels = 2
14313 syncimagepixels = 3
14332 PERL_UNUSED_VAR(ref);
14333 PERL_UNUSED_VAR(ix);
14334 exception=AcquireExceptionInfo();
14335 perl_exception=newSVpv("",0);
14336 if (sv_isobject(ST(0)) == 0)
14338 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14340 goto PerlException;
14343 reference=SvRV(ST(0));
14344 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14345 if (image == (Image *) NULL)
14347 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14349 goto PerlException;
14352 status=SyncAuthenticPixels(image,exception);
14353 if (status != MagickFalse)
14357 InheritPerlException(exception,perl_exception);
14358 exception=DestroyExceptionInfo(exception);
14359 SvREFCNT_dec(perl_exception); /* throw away all errors */
14363 ###############################################################################
14367 # T r a n s f o r m #
14371 ###############################################################################
14376 Image::Magick ref=NO_INIT
14414 PERL_UNUSED_VAR(ref);
14415 PERL_UNUSED_VAR(ix);
14416 exception=AcquireExceptionInfo();
14417 perl_exception=newSVpv("",0);
14421 if (sv_isobject(ST(0)) == 0)
14423 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14425 goto PerlException;
14427 reference=SvRV(ST(0));
14428 hv=SvSTASH(reference);
14430 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14432 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14433 if (image == (Image *) NULL)
14435 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14437 goto PerlException;
14439 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14443 crop_geometry=(char *) NULL;
14444 geometry=(char *) NULL;
14445 for (i=2; i < items; i+=2)
14447 attribute=(char *) SvPV(ST(i-1),na);
14448 switch (*attribute)
14453 if (LocaleCompare(attribute,"crop") == 0)
14455 crop_geometry=SvPV(ST(i),na);
14458 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14465 if (LocaleCompare(attribute,"geometry") == 0)
14467 geometry=SvPV(ST(i),na);
14470 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14476 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14482 for ( ; image; image=image->next)
14484 clone=CloneImage(image,0,0,MagickTrue,exception);
14485 if (clone == (Image *) NULL)
14486 goto PerlException;
14487 TransformImage(&clone,crop_geometry,geometry,exception);
14488 for ( ; clone; clone=clone->next)
14490 AddImageToRegistry(sv,clone);
14492 av_push(av,sv_bless(rv,hv));
14496 exception=DestroyExceptionInfo(exception);
14497 ST(0)=av_reference;
14498 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14502 InheritPerlException(exception,perl_exception);
14503 exception=DestroyExceptionInfo(exception);
14504 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14505 SvPOK_on(perl_exception);
14506 ST(0)=sv_2mortal(perl_exception);
14511 ###############################################################################
14519 ###############################################################################
14524 Image::Magick ref=NO_INIT
14532 filename[MaxTextExtent];
14556 PERL_UNUSED_VAR(ref);
14557 PERL_UNUSED_VAR(ix);
14558 exception=AcquireExceptionInfo();
14559 perl_exception=newSVpv("",0);
14561 package_info=(struct PackageInfo *) NULL;
14562 if (sv_isobject(ST(0)) == 0)
14564 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14566 goto PerlException;
14568 reference=SvRV(ST(0));
14569 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14570 if (image == (Image *) NULL)
14572 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14574 goto PerlException;
14576 package_info=ClonePackageInfo(info,exception);
14578 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14581 for (i=2; i < items; i+=2)
14582 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14584 (void) CopyMagickString(filename,package_info->image_info->filename,
14587 for (next=image; next; next=next->next)
14589 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14590 next->scene=scene++;
14592 SetImageInfo(package_info->image_info,(unsigned int)
14593 GetImageListLength(image),exception);
14594 for (next=image; next; next=next->next)
14596 (void) WriteImage(package_info->image_info,next,exception);
14598 if (package_info->image_info->adjoin)
14603 if (package_info != (struct PackageInfo *) NULL)
14604 DestroyPackageInfo(package_info);
14605 InheritPerlException(exception,perl_exception);
14606 exception=DestroyExceptionInfo(exception);
14607 sv_setiv(perl_exception,(IV) number_images);
14608 SvPOK_on(perl_exception);
14609 ST(0)=sv_2mortal(perl_exception);