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-2015 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
56 #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[MagickPathExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MagickPathExtent,"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} } },
559 { "CopyPixels", { {"image", ImageReference}, {"geometry", StringReference},
560 {"width", IntegerReference}, {"height", IntegerReference},
561 {"x", IntegerReference}, {"y", IntegerReference},
562 {"gravity", MagickGravityOptions}, {"offset", StringReference},
563 {"dx", IntegerReference}, {"dy", IntegerReference} } },
567 *magick_registry = (SplayTreeInfo *) NULL;
570 Forward declarations.
573 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
576 strEQcase(const char *,const char *);
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
583 % C l o n e P a c k a g e I n f o %
587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
589 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
592 % The format of the ClonePackageInfo routine is:
594 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
597 % A description of each parameter follows:
599 % o info: a structure of type info.
601 % o exception: Return any errors or warnings in this structure.
604 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
605 ExceptionInfo *exception)
610 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
611 if (clone_info == (struct PackageInfo *) NULL)
613 ThrowPerlException(exception,ResourceLimitError,
614 "UnableToClonePackageInfo",PackageName);
615 return((struct PackageInfo *) NULL);
617 if (info == (struct PackageInfo *) NULL)
619 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
623 clone_info->image_info=CloneImageInfo(info->image_info);
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
636 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 % constant() returns a double value for the specified name.
640 % The format of the constant routine is:
642 % double constant(char *name,ssize_t sans)
644 % A description of each parameter follows:
646 % o value: Method constant returns a double value for the specified name.
648 % o name: The name of the constant.
650 % o sans: This integer value is not used.
653 static double constant(char *name,ssize_t sans)
661 if (strEQ(name,"BlobError"))
663 if (strEQ(name,"BlobWarning"))
669 if (strEQ(name,"CacheError"))
671 if (strEQ(name,"CacheWarning"))
672 return(CacheWarning);
673 if (strEQ(name,"CoderError"))
675 if (strEQ(name,"CoderWarning"))
676 return(CoderWarning);
677 if (strEQ(name,"ConfigureError"))
678 return(ConfigureError);
679 if (strEQ(name,"ConfigureWarning"))
680 return(ConfigureWarning);
681 if (strEQ(name,"CorruptImageError"))
682 return(CorruptImageError);
683 if (strEQ(name,"CorruptImageWarning"))
684 return(CorruptImageWarning);
689 if (strEQ(name,"DelegateError"))
690 return(DelegateError);
691 if (strEQ(name,"DelegateWarning"))
692 return(DelegateWarning);
693 if (strEQ(name,"DrawError"))
695 if (strEQ(name,"DrawWarning"))
701 if (strEQ(name,"ErrorException"))
702 return(ErrorException);
703 if (strEQ(name,"ExceptionError"))
705 if (strEQ(name,"ExceptionWarning"))
706 return(CoderWarning);
711 if (strEQ(name,"FatalErrorException"))
712 return(FatalErrorException);
713 if (strEQ(name,"FileOpenError"))
714 return(FileOpenError);
715 if (strEQ(name,"FileOpenWarning"))
716 return(FileOpenWarning);
721 if (strEQ(name,"ImageError"))
723 if (strEQ(name,"ImageWarning"))
724 return(ImageWarning);
729 if (strEQ(name,"MaxRGB"))
730 return(QuantumRange);
731 if (strEQ(name,"MissingDelegateError"))
732 return(MissingDelegateError);
733 if (strEQ(name,"MissingDelegateWarning"))
734 return(MissingDelegateWarning);
735 if (strEQ(name,"ModuleError"))
737 if (strEQ(name,"ModuleWarning"))
738 return(ModuleWarning);
743 if (strEQ(name,"Opaque"))
745 if (strEQ(name,"OptionError"))
747 if (strEQ(name,"OptionWarning"))
748 return(OptionWarning);
753 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
754 return(MAGICKCORE_QUANTUM_DEPTH);
755 if (strEQ(name,"QuantumDepth"))
756 return(MAGICKCORE_QUANTUM_DEPTH);
757 if (strEQ(name,"QuantumRange"))
758 return(QuantumRange);
763 if (strEQ(name,"ResourceLimitError"))
764 return(ResourceLimitError);
765 if (strEQ(name,"ResourceLimitWarning"))
766 return(ResourceLimitWarning);
767 if (strEQ(name,"RegistryError"))
768 return(RegistryError);
769 if (strEQ(name,"RegistryWarning"))
770 return(RegistryWarning);
775 if (strEQ(name,"StreamError"))
777 if (strEQ(name,"StreamWarning"))
778 return(StreamWarning);
779 if (strEQ(name,"Success"))
785 if (strEQ(name,"Transparent"))
786 return(TransparentAlpha);
787 if (strEQ(name,"TypeError"))
789 if (strEQ(name,"TypeWarning"))
795 if (strEQ(name,"WarningException"))
796 return(WarningException);
801 if (strEQ(name,"XServerError"))
802 return(XServerError);
803 if (strEQ(name,"XServerWarning"))
804 return(XServerWarning);
813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
817 % D e s t r o y P a c k a g e I n f o %
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
823 % Method DestroyPackageInfo frees a previously created info structure.
825 % The format of the DestroyPackageInfo routine is:
827 % DestroyPackageInfo(struct PackageInfo *info)
829 % A description of each parameter follows:
831 % o info: a structure of type info.
834 static void DestroyPackageInfo(struct PackageInfo *info)
836 info->image_info=DestroyImageInfo(info->image_info);
837 info=(struct PackageInfo *) RelinquishMagickMemory(info);
841 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
851 % Method GetList is recursively called by SetupList to traverse the
852 % Image__Magick reference. If building an reference_vector (see SetupList),
853 % *current is the current position in *reference_vector and *last is the final
854 % entry in *reference_vector.
856 % The format of the GetList routine is:
860 % A description of each parameter follows:
862 % o info: a structure of type info.
865 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
866 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
871 if (reference == (SV *) NULL)
873 switch (SvTYPE(reference))
893 previous=(Image *) NULL;
897 for (i=0; i <= n; i++)
903 if (rv && *rv && sv_isobject(*rv))
905 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
907 if (image == (Image *) NULL)
909 if (image == previous)
911 image=CloneImage(image,0,0,MagickTrue,exception);
912 if (image == (Image *) NULL)
915 image->previous=previous;
916 *(previous ? &previous->next : &head)=image;
917 for (previous=image; previous->next; previous=previous->next) ;
925 Blessed scalar, one image.
927 image=INT2PTR(Image *,SvIV(reference));
928 if (image == (Image *) NULL)
930 image->previous=(Image *) NULL;
931 image->next=(Image *) NULL;
932 if (reference_vector)
934 if (*current == *last)
937 if (*reference_vector == (SV **) NULL)
938 *reference_vector=(SV **) AcquireQuantumMemory(*last,
939 sizeof(*reference_vector));
941 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
942 *last,sizeof(*reference_vector));
944 if (*reference_vector == (SV **) NULL)
946 ThrowPerlException(exception,ResourceLimitError,
947 "MemoryAllocationFailed",PackageName);
948 return((Image *) NULL);
950 (*reference_vector)[*current]=reference;
951 (*reference_vector)[++(*current)]=NULL;
958 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
959 (double) SvTYPE(reference));
960 return((Image *) NULL);
964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 % G e t P a c k a g e I n f o %
972 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
974 % Method GetPackageInfo looks up or creates an info structure for the given
975 % Image__Magick reference. If it does create a new one, the information in
976 % package_info is used to initialize it.
978 % The format of the GetPackageInfo routine is:
980 % struct PackageInfo *GetPackageInfo(void *reference,
981 % struct PackageInfo *package_info,ExceptionInfo *exception)
983 % A description of each parameter follows:
985 % o info: a structure of type info.
987 % o exception: Return any errors or warnings in this structure.
990 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
991 struct PackageInfo *package_info,ExceptionInfo *exception)
994 message[MagickPathExtent];
1002 (void) FormatLocaleString(message,MagickPathExtent,"%s::package%s%p",
1003 PackageName,XS_VERSION,reference);
1004 sv=perl_get_sv(message,(TRUE | 0x02));
1005 if (sv == (SV *) NULL)
1007 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1009 return(package_info);
1011 if (SvREFCNT(sv) == 0)
1012 (void) SvREFCNT_inc(sv);
1013 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1015 clone_info=ClonePackageInfo(package_info,exception);
1016 sv_setiv(sv,PTR2IV(clone_info));
1021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1025 % S e t A t t r i b u t e %
1029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1031 % SetAttribute() sets the attribute to the value in sval. This can change
1032 % either or both of image or info.
1034 % The format of the SetAttribute routine is:
1036 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1037 % SV *sval,ExceptionInfo *exception)
1039 % A description of each parameter follows:
1041 % o list: a list of strings.
1043 % o string: a character string.
1047 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1055 value=InterpretSiPrefixValue(string,&q);
1057 value*=interval/100.0;
1061 static inline double StringToDouble(const char *string,char **sentinal)
1063 return(InterpretLocaleValue(string,sentinal));
1066 static double StringToDoubleInterval(const char *string,const double interval)
1074 value=InterpretLocaleValue(string,&q);
1076 value*=interval/100.0;
1080 static inline ssize_t StringToLong(const char *value)
1082 return(strtol(value,(char **) NULL,10));
1085 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1086 const char *attribute,SV *sval,ExceptionInfo *exception)
1113 if (LocaleCompare(attribute,"adjoin") == 0)
1115 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1116 SvPV(sval,na)) : SvIV(sval);
1119 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1124 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1127 if (LocaleCompare(attribute,"alpha") == 0)
1129 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1130 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1133 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1137 for ( ; image; image=image->next)
1138 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1142 if (LocaleCompare(attribute,"antialias") == 0)
1144 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1145 SvPV(sval,na)) : SvIV(sval);
1148 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1153 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1156 if (LocaleCompare(attribute,"area-limit") == 0)
1161 limit=MagickResourceInfinity;
1162 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1163 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1165 (void) SetMagickResourceLimit(AreaResource,limit);
1168 if (LocaleCompare(attribute,"attenuate") == 0)
1171 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1174 if (LocaleCompare(attribute,"authenticate") == 0)
1177 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1181 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1182 for ( ; image; image=image->next)
1183 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1189 if (LocaleCompare(attribute,"background") == 0)
1191 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1194 info->image_info->background_color=target_color;
1195 for ( ; image; image=image->next)
1196 image->background_color=target_color;
1199 if (LocaleCompare(attribute,"blue-primary") == 0)
1201 for ( ; image; image=image->next)
1203 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1204 image->chromaticity.blue_primary.x=geometry_info.rho;
1205 image->chromaticity.blue_primary.y=geometry_info.sigma;
1206 if ((flags & SigmaValue) == 0)
1207 image->chromaticity.blue_primary.y=
1208 image->chromaticity.blue_primary.x;
1212 if (LocaleCompare(attribute,"bordercolor") == 0)
1214 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1217 info->image_info->border_color=target_color;
1218 for ( ; image; image=image->next)
1219 image->border_color=target_color;
1223 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1224 for ( ; image; image=image->next)
1225 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1231 if (LocaleCompare(attribute,"cache-threshold") == 0)
1233 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1234 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1235 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1236 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1239 if (LocaleCompare(attribute,"clip-mask") == 0)
1244 clip_mask=(Image *) NULL;
1246 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1247 for ( ; image; image=image->next)
1248 SetImageMask(image,clip_mask,exception);
1251 if (LocaleNCompare(attribute,"colormap",8) == 0)
1253 for ( ; image; image=image->next)
1261 if (image->storage_class == DirectClass)
1264 items=sscanf(attribute,"%*[^[][%ld",&i);
1266 if (i > (ssize_t) image->colors)
1268 if ((strchr(SvPV(sval,na),',') == 0) ||
1269 (strchr(SvPV(sval,na),')') != 0))
1270 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1271 image->colormap+i,exception);
1274 color=image->colormap+i;
1275 pixel.red=color->red;
1276 pixel.green=color->green;
1277 pixel.blue=color->blue;
1278 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1279 pixel.red=geometry_info.rho;
1280 pixel.green=geometry_info.sigma;
1281 pixel.blue=geometry_info.xi;
1282 color->red=ClampToQuantum(pixel.red);
1283 color->green=ClampToQuantum(pixel.green);
1284 color->blue=ClampToQuantum(pixel.blue);
1289 if (LocaleCompare(attribute,"colorspace") == 0)
1291 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1292 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1295 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1299 for ( ; image; image=image->next)
1300 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1304 if (LocaleCompare(attribute,"comment") == 0)
1306 for ( ; image; image=image->next)
1307 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1308 info ? info->image_info : (ImageInfo *) NULL,image,
1309 SvPV(sval,na),exception),exception);
1312 if (LocaleCompare(attribute,"compression") == 0)
1314 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1315 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1318 ThrowPerlException(exception,OptionError,
1319 "UnrecognizedImageCompression",SvPV(sval,na));
1323 info->image_info->compression=(CompressionType) sp;
1324 for ( ; image; image=image->next)
1325 image->compression=(CompressionType) sp;
1329 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1330 for ( ; image; image=image->next)
1331 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1337 if (LocaleCompare(attribute,"debug") == 0)
1339 SetLogEventMask(SvPV(sval,na));
1342 if (LocaleCompare(attribute,"delay") == 0)
1344 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1345 for ( ; image; image=image->next)
1347 image->delay=(size_t) floor(geometry_info.rho+0.5);
1348 if ((flags & SigmaValue) != 0)
1349 image->ticks_per_second=(ssize_t)
1350 floor(geometry_info.sigma+0.5);
1354 if (LocaleCompare(attribute,"disk-limit") == 0)
1359 limit=MagickResourceInfinity;
1360 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1361 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1363 (void) SetMagickResourceLimit(DiskResource,limit);
1366 if (LocaleCompare(attribute,"density") == 0)
1368 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1370 ThrowPerlException(exception,OptionError,"MissingGeometry",
1375 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1376 for ( ; image; image=image->next)
1378 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1379 image->resolution.x=geometry_info.rho;
1380 image->resolution.y=geometry_info.sigma;
1381 if ((flags & SigmaValue) == 0)
1382 image->resolution.y=image->resolution.x;
1386 if (LocaleCompare(attribute,"depth") == 0)
1389 info->image_info->depth=SvIV(sval);
1390 for ( ; image; image=image->next)
1391 (void) SetImageDepth(image,SvIV(sval),exception);
1394 if (LocaleCompare(attribute,"dispose") == 0)
1396 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1397 SvPV(sval,na)) : SvIV(sval);
1400 ThrowPerlException(exception,OptionError,
1401 "UnrecognizedDisposeMethod",SvPV(sval,na));
1404 for ( ; image; image=image->next)
1405 image->dispose=(DisposeType) sp;
1408 if (LocaleCompare(attribute,"dither") == 0)
1412 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1413 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1416 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1420 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1424 if (LocaleCompare(attribute,"display") == 0)
1428 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1432 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1433 for ( ; image; image=image->next)
1434 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1440 if (LocaleCompare(attribute,"endian") == 0)
1442 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1443 SvPV(sval,na)) : SvIV(sval);
1446 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1451 info->image_info->endian=(EndianType) sp;
1452 for ( ; image; image=image->next)
1453 image->endian=(EndianType) sp;
1456 if (LocaleCompare(attribute,"extract") == 0)
1459 Set image extract geometry.
1461 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1465 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1466 for ( ; image; image=image->next)
1467 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1473 if (LocaleCompare(attribute,"filename") == 0)
1476 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1478 for ( ; image; image=image->next)
1479 (void) CopyMagickString(image->filename,SvPV(sval,na),
1483 if (LocaleCompare(attribute,"file") == 0)
1491 if (info == (struct PackageInfo *) NULL)
1493 io_info=IoIFP(sv_2io(sval));
1494 if (io_info == (PerlIO *) NULL)
1496 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1500 file=PerlIO_findFILE(io_info);
1501 if (file == (FILE *) NULL)
1503 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1507 SetImageInfoFile(info->image_info,file);
1510 if (LocaleCompare(attribute,"fill") == 0)
1513 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1516 if (LocaleCompare(attribute,"font") == 0)
1519 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1522 if (LocaleCompare(attribute,"foreground") == 0)
1524 if (LocaleCompare(attribute,"fuzz") == 0)
1527 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1529 for ( ; image; image=image->next)
1530 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1535 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1536 for ( ; image; image=image->next)
1537 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1543 if (LocaleCompare(attribute,"gamma") == 0)
1545 for ( ; image; image=image->next)
1546 image->gamma=SvNV(sval);
1549 if (LocaleCompare(attribute,"gravity") == 0)
1551 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1552 SvPV(sval,na)) : SvIV(sval);
1555 ThrowPerlException(exception,OptionError,
1556 "UnrecognizedGravityType",SvPV(sval,na));
1560 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1561 for ( ; image; image=image->next)
1562 image->gravity=(GravityType) sp;
1565 if (LocaleCompare(attribute,"green-primary") == 0)
1567 for ( ; image; image=image->next)
1569 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1570 image->chromaticity.green_primary.x=geometry_info.rho;
1571 image->chromaticity.green_primary.y=geometry_info.sigma;
1572 if ((flags & SigmaValue) == 0)
1573 image->chromaticity.green_primary.y=
1574 image->chromaticity.green_primary.x;
1579 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1580 for ( ; image; image=image->next)
1581 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1587 if (LocaleNCompare(attribute,"index",5) == 0)
1601 for ( ; image; image=image->next)
1603 if (image->storage_class != PseudoClass)
1607 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1609 image_view=AcquireAuthenticCacheView(image,exception);
1610 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1611 if (q != (Quantum *) NULL)
1613 items=sscanf(SvPV(sval,na),"%ld",&index);
1614 if ((index >= 0) && (index < (ssize_t) image->colors))
1615 SetPixelIndex(image,index,q);
1616 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1618 image_view=DestroyCacheView(image_view);
1622 if (LocaleCompare(attribute,"iterations") == 0)
1625 for ( ; image; image=image->next)
1626 image->iterations=SvIV(sval);
1629 if (LocaleCompare(attribute,"interlace") == 0)
1631 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1632 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1635 ThrowPerlException(exception,OptionError,
1636 "UnrecognizedInterlaceType",SvPV(sval,na));
1640 info->image_info->interlace=(InterlaceType) sp;
1641 for ( ; image; image=image->next)
1642 image->interlace=(InterlaceType) sp;
1646 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1647 for ( ; image; image=image->next)
1648 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1654 if (LocaleCompare(attribute,"label") == 0)
1656 for ( ; image; image=image->next)
1657 (void) SetImageProperty(image,"label",InterpretImageProperties(
1658 info ? info->image_info : (ImageInfo *) NULL,image,
1659 SvPV(sval,na),exception),exception);
1662 if (LocaleCompare(attribute,"loop") == 0)
1665 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1666 for ( ; image; image=image->next)
1667 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1673 if (LocaleCompare(attribute,"magick") == 0)
1676 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
1677 "%s:",SvPV(sval,na));
1678 for ( ; image; image=image->next)
1679 (void) CopyMagickString(image->magick,SvPV(sval,na),MagickPathExtent);
1682 if (LocaleCompare(attribute,"map-limit") == 0)
1687 limit=MagickResourceInfinity;
1688 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1689 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1691 (void) SetMagickResourceLimit(MapResource,limit);
1694 if (LocaleCompare(attribute,"mask") == 0)
1699 mask=(Image *) NULL;
1701 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1702 for ( ; image; image=image->next)
1703 SetImageMask(image,mask,exception);
1706 if (LocaleCompare(attribute,"mattecolor") == 0)
1708 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1711 info->image_info->matte_color=target_color;
1712 for ( ; image; image=image->next)
1713 image->matte_color=target_color;
1716 if (LocaleCompare(attribute,"matte") == 0)
1718 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1719 SvPV(sval,na)) : SvIV(sval);
1722 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1726 for ( ; image; image=image->next)
1727 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1730 if (LocaleCompare(attribute,"memory-limit") == 0)
1735 limit=MagickResourceInfinity;
1736 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1737 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1739 (void) SetMagickResourceLimit(MemoryResource,limit);
1742 if (LocaleCompare(attribute,"monochrome") == 0)
1744 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1745 SvPV(sval,na)) : SvIV(sval);
1748 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1753 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1754 for ( ; image; image=image->next)
1755 (void) SetImageType(image,BilevelType,exception);
1759 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1760 for ( ; image; image=image->next)
1761 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1767 if (LocaleCompare(attribute,"option") == 0)
1770 DefineImageOption(info->image_info,SvPV(sval,na));
1773 if (LocaleCompare(attribute,"orientation") == 0)
1775 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1776 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1779 ThrowPerlException(exception,OptionError,
1780 "UnrecognizedOrientationType",SvPV(sval,na));
1784 info->image_info->orientation=(OrientationType) sp;
1785 for ( ; image; image=image->next)
1786 image->orientation=(OrientationType) sp;
1790 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1791 for ( ; image; image=image->next)
1792 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1798 if (LocaleCompare(attribute,"page") == 0)
1803 geometry=GetPageGeometry(SvPV(sval,na));
1805 (void) CloneString(&info->image_info->page,geometry);
1806 for ( ; image; image=image->next)
1807 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1808 geometry=(char *) RelinquishMagickMemory(geometry);
1811 if (LocaleNCompare(attribute,"pixel",5) == 0)
1825 for ( ; image; image=image->next)
1827 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1831 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1833 image_view=AcquireVirtualCacheView(image,exception);
1834 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1835 if (q != (Quantum *) NULL)
1837 if ((strchr(SvPV(sval,na),',') == 0) ||
1838 (strchr(SvPV(sval,na),')') != 0))
1839 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1843 GetPixelInfo(image,&pixel);
1844 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1845 pixel.red=geometry_info.rho;
1846 if ((flags & SigmaValue) != 0)
1847 pixel.green=geometry_info.sigma;
1848 if ((flags & XiValue) != 0)
1849 pixel.blue=geometry_info.xi;
1850 if ((flags & PsiValue) != 0)
1851 pixel.alpha=geometry_info.psi;
1852 if ((flags & ChiValue) != 0)
1853 pixel.black=geometry_info.chi;
1855 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1856 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1857 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1858 if (image->colorspace == CMYKColorspace)
1859 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1860 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1861 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1863 image_view=DestroyCacheView(image_view);
1867 if (LocaleCompare(attribute,"pointsize") == 0)
1871 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1872 info->image_info->pointsize=geometry_info.rho;
1876 if (LocaleCompare(attribute,"preview") == 0)
1878 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1879 SvPV(sval,na)) : SvIV(sval);
1882 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1887 info->image_info->preview_type=(PreviewType) sp;
1891 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1892 for ( ; image; image=image->next)
1893 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1899 if (LocaleCompare(attribute,"quality") == 0)
1902 info->image_info->quality=SvIV(sval);
1903 for ( ; image; image=image->next)
1904 image->quality=SvIV(sval);
1908 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1909 for ( ; image; image=image->next)
1910 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1916 if (LocaleCompare(attribute,"red-primary") == 0)
1918 for ( ; image; image=image->next)
1920 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1921 image->chromaticity.red_primary.x=geometry_info.rho;
1922 image->chromaticity.red_primary.y=geometry_info.sigma;
1923 if ((flags & SigmaValue) == 0)
1924 image->chromaticity.red_primary.y=
1925 image->chromaticity.red_primary.x;
1929 if (LocaleCompare(attribute,"render") == 0)
1931 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1932 SvPV(sval,na)) : SvIV(sval);
1935 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1939 for ( ; image; image=image->next)
1940 image->rendering_intent=(RenderingIntent) sp;
1943 if (LocaleCompare(attribute,"repage") == 0)
1948 for ( ; image; image=image->next)
1950 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1951 if ((flags & WidthValue) != 0)
1953 if ((flags & HeightValue) == 0)
1954 geometry.height=geometry.width;
1955 image->page.width=geometry.width;
1956 image->page.height=geometry.height;
1958 if ((flags & AspectValue) != 0)
1960 if ((flags & XValue) != 0)
1961 image->page.x+=geometry.x;
1962 if ((flags & YValue) != 0)
1963 image->page.y+=geometry.y;
1967 if ((flags & XValue) != 0)
1969 image->page.x=geometry.x;
1970 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1971 image->page.width=image->columns+geometry.x;
1973 if ((flags & YValue) != 0)
1975 image->page.y=geometry.y;
1976 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1977 image->page.height=image->rows+geometry.y;
1984 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1985 for ( ; image; image=image->next)
1986 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1992 if (LocaleCompare(attribute,"sampling-factor") == 0)
1994 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1996 ThrowPerlException(exception,OptionError,"MissingGeometry",
2001 (void) CloneString(&info->image_info->sampling_factor,
2005 if (LocaleCompare(attribute,"scene") == 0)
2007 for ( ; image; image=image->next)
2008 image->scene=SvIV(sval);
2011 if (LocaleCompare(attribute,"server") == 0)
2013 if (LocaleCompare(attribute,"size") == 0)
2017 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2019 ThrowPerlException(exception,OptionError,"MissingGeometry",
2023 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2027 if (LocaleCompare(attribute,"stroke") == 0)
2030 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2034 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2035 for ( ; image; image=image->next)
2036 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2042 if (LocaleCompare(attribute,"texture") == 0)
2045 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2048 if (LocaleCompare(attribute,"thread-limit") == 0)
2053 limit=MagickResourceInfinity;
2054 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2055 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2057 (void) SetMagickResourceLimit(ThreadResource,limit);
2060 if (LocaleCompare(attribute,"tile-offset") == 0)
2065 geometry=GetPageGeometry(SvPV(sval,na));
2067 (void) CloneString(&info->image_info->page,geometry);
2068 for ( ; image; image=image->next)
2069 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2071 geometry=(char *) RelinquishMagickMemory(geometry);
2074 if (LocaleCompare(attribute,"time-limit") == 0)
2079 limit=MagickResourceInfinity;
2080 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2081 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2083 (void) SetMagickResourceLimit(TimeResource,limit);
2086 if (LocaleCompare(attribute,"transparent-color") == 0)
2088 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2091 info->image_info->transparent_color=target_color;
2092 for ( ; image; image=image->next)
2093 image->transparent_color=target_color;
2096 if (LocaleCompare(attribute,"type") == 0)
2098 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2099 SvPV(sval,na)) : SvIV(sval);
2102 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2107 info->image_info->type=(ImageType) sp;
2108 for ( ; image; image=image->next)
2109 SetImageType(image,(ImageType) sp,exception);
2113 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2114 for ( ; image; image=image->next)
2115 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2121 if (LocaleCompare(attribute,"units") == 0)
2123 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2124 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2127 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2132 info->image_info->units=(ResolutionType) sp;
2133 for ( ; image; image=image->next)
2138 units=(ResolutionType) sp;
2139 if (image->units != units)
2140 switch (image->units)
2142 case UndefinedResolution:
2143 case PixelsPerInchResolution:
2145 if (units == PixelsPerCentimeterResolution)
2147 image->resolution.x*=2.54;
2148 image->resolution.y*=2.54;
2152 case PixelsPerCentimeterResolution:
2154 if (units == PixelsPerInchResolution)
2156 image->resolution.x/=2.54;
2157 image->resolution.y/=2.54;
2167 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2168 for ( ; image; image=image->next)
2169 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2175 if (LocaleCompare(attribute,"verbose") == 0)
2177 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2178 SvPV(sval,na)) : SvIV(sval);
2181 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2186 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2189 if (LocaleCompare(attribute,"view") == 0)
2192 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2195 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2197 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2198 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2201 ThrowPerlException(exception,OptionError,
2202 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2205 for ( ; image; image=image->next)
2206 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2210 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2211 for ( ; image; image=image->next)
2212 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2218 if (LocaleCompare(attribute,"white-point") == 0)
2220 for ( ; image; image=image->next)
2222 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2223 image->chromaticity.white_point.x=geometry_info.rho;
2224 image->chromaticity.white_point.y=geometry_info.sigma;
2225 if ((flags & SigmaValue) == 0)
2226 image->chromaticity.white_point.y=
2227 image->chromaticity.white_point.x;
2232 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2233 for ( ; image; image=image->next)
2234 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2240 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2241 for ( ; image; image=image->next)
2242 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2249 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2253 % S e t u p L i s t %
2257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2259 % Method SetupList returns the list of all the images linked by their
2260 % image->next and image->previous link lists for use with ImageMagick. If
2261 % info is non-NULL, an info structure is returned in *info. If
2262 % reference_vector is non-NULL,an array of SV* are returned in
2263 % *reference_vector. Reference_vector is used when the images are going to be
2264 % replaced with new Image*'s.
2266 % The format of the SetupList routine is:
2268 % Image *SetupList(SV *reference,struct PackageInfo **info,
2269 % SV ***reference_vector,ExceptionInfo *exception)
2271 % A description of each parameter follows:
2273 % o list: a list of strings.
2275 % o string: a character string.
2277 % o exception: Return any errors or warnings in this structure.
2280 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2281 SV ***reference_vector,ExceptionInfo *exception)
2290 if (reference_vector)
2291 *reference_vector=NULL;
2296 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2297 if (info && (SvTYPE(reference) == SVt_PVAV))
2298 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2308 % s t r E Q c a s e %
2312 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2314 % strEQcase() compares two strings and returns 0 if they are the
2315 % same or if the second string runs out first. The comparison is case
2318 % The format of the strEQcase routine is:
2320 % ssize_t strEQcase(const char *p,const char *q)
2322 % A description of each parameter follows:
2324 % o p: a character string.
2326 % o q: a character string.
2330 static ssize_t strEQcase(const char *p,const char *q)
2338 for (i=0 ; (c=(*q)) != 0; i++)
2340 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2341 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2346 return(((*q == 0) && (*p == 0)) ? i : 0);
2350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2354 % I m a g e : : M a g i c k %
2358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2362 MODULE = Image::Magick PACKAGE = Image::Magick
2367 MagickCoreGenesis("PerlMagick",MagickFalse);
2368 SetWarningHandler(NULL);
2369 SetErrorHandler(NULL);
2370 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2371 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2377 if (magick_registry != (SplayTreeInfo *) NULL)
2378 magick_registry=DestroySplayTree(magick_registry);
2379 MagickCoreTerminus();
2383 constant(name,argument)
2388 ###############################################################################
2396 ###############################################################################
2401 Image::Magick ref=NO_INIT
2425 PERL_UNUSED_VAR(ref);
2426 PERL_UNUSED_VAR(ix);
2427 exception=AcquireExceptionInfo();
2428 perl_exception=newSVpv("",0);
2429 package_info=(struct PackageInfo *) NULL;
2430 if (sv_isobject(ST(0)) == 0)
2432 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2436 reference=SvRV(ST(0));
2437 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2438 if (image == (Image *) NULL)
2440 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2444 package_info=ClonePackageInfo(info,exception);
2446 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2449 for (i=2; i < items; i+=2)
2450 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2452 (void) AnimateImages(package_info->image_info,image,exception);
2453 (void) CatchImageException(image);
2456 if (package_info != (struct PackageInfo *) NULL)
2457 DestroyPackageInfo(package_info);
2458 InheritPerlException(exception,perl_exception);
2459 exception=DestroyExceptionInfo(exception);
2460 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2461 SvPOK_on(perl_exception);
2462 ST(0)=sv_2mortal(perl_exception);
2467 ###############################################################################
2475 ###############################################################################
2480 Image::Magick ref=NO_INIT
2518 PERL_UNUSED_VAR(ref);
2519 PERL_UNUSED_VAR(ix);
2520 exception=AcquireExceptionInfo();
2521 perl_exception=newSVpv("",0);
2525 if (sv_isobject(ST(0)) == 0)
2527 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2531 reference=SvRV(ST(0));
2532 hv=SvSTASH(reference);
2534 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2536 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2537 if (image == (Image *) NULL)
2539 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2543 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2548 for (i=2; i < items; i+=2)
2550 attribute=(char *) SvPV(ST(i-1),na);
2556 if (LocaleCompare(attribute,"stack") == 0)
2558 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2562 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2568 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2574 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2580 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2581 if (image == (Image *) NULL)
2583 for ( ; image; image=image->next)
2585 AddImageToRegistry(sv,image);
2587 av_push(av,sv_bless(rv,hv));
2590 exception=DestroyExceptionInfo(exception);
2592 SvREFCNT_dec(perl_exception);
2596 InheritPerlException(exception,perl_exception);
2597 exception=DestroyExceptionInfo(exception);
2598 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2599 SvPOK_on(perl_exception);
2600 ST(0)=sv_2mortal(perl_exception);
2605 ###############################################################################
2613 ###############################################################################
2618 Image::Magick ref=NO_INIT
2649 PERL_UNUSED_VAR(ref);
2650 PERL_UNUSED_VAR(ix);
2651 exception=AcquireExceptionInfo();
2652 perl_exception=newSVpv("",0);
2654 if (sv_isobject(ST(0)) == 0)
2656 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2660 reference=SvRV(ST(0));
2661 hv=SvSTASH(reference);
2662 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2663 if (image == (Image *) NULL)
2665 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2669 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2670 if (image == (Image *) NULL)
2673 Create blessed Perl array for the returned image.
2676 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2678 AddImageToRegistry(sv,image);
2680 av_push(av,sv_bless(rv,hv));
2682 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2683 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2684 "average-%.*s",(int) (MagickPathExtent-9),
2685 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2686 (void) CopyMagickString(image->filename,info->image_info->filename,
2688 SetImageInfo(info->image_info,0,exception);
2689 exception=DestroyExceptionInfo(exception);
2690 SvREFCNT_dec(perl_exception);
2694 InheritPerlException(exception,perl_exception);
2695 exception=DestroyExceptionInfo(exception);
2696 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2697 SvPOK_on(perl_exception);
2698 ST(0)=sv_2mortal(perl_exception);
2703 ###############################################################################
2707 # B l o b T o I m a g e #
2711 ###############################################################################
2715 BlobToImage(ref,...)
2716 Image::Magick ref=NO_INIT
2762 PERL_UNUSED_VAR(ref);
2763 PERL_UNUSED_VAR(ix);
2764 exception=AcquireExceptionInfo();
2765 perl_exception=newSVpv("",0);
2768 ac=(items < 2) ? 1 : items-1;
2769 length=(STRLEN *) NULL;
2770 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2771 if (list == (char **) NULL)
2773 ThrowPerlException(exception,ResourceLimitError,
2774 "MemoryAllocationFailed",PackageName);
2777 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2778 if (length == (STRLEN *) NULL)
2780 ThrowPerlException(exception,ResourceLimitError,
2781 "MemoryAllocationFailed",PackageName);
2784 if (sv_isobject(ST(0)) == 0)
2786 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2790 reference=SvRV(ST(0));
2791 hv=SvSTASH(reference);
2792 if (SvTYPE(reference) != SVt_PVAV)
2794 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2798 av=(AV *) reference;
2799 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2804 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2807 for (n=0, i=0; i < ac; i++)
2809 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2810 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2812 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2817 list[n]=(char *) NULL;
2819 for (i=number_images=0; i < n; i++)
2821 image=BlobToImage(info->image_info,list[i],length[i],exception);
2822 if (image == (Image *) NULL)
2824 for ( ; image; image=image->next)
2826 AddImageToRegistry(sv,image);
2828 av_push(av,sv_bless(rv,hv));
2836 for (i=0; i < n; i++)
2837 if (list[i] != (char *) NULL)
2838 for (p=keep; list[i] != *p++; )
2839 if (*p == (char *) NULL)
2841 list[i]=(char *) RelinquishMagickMemory(list[i]);
2847 list=(char **) RelinquishMagickMemory(list);
2849 length=(STRLEN *) RelinquishMagickMemory(length);
2850 InheritPerlException(exception,perl_exception);
2851 exception=DestroyExceptionInfo(exception);
2852 sv_setiv(perl_exception,(IV) number_images);
2853 SvPOK_on(perl_exception);
2854 ST(0)=sv_2mortal(perl_exception);
2859 ###############################################################################
2863 # C h a n n e l F x #
2867 ###############################################################################
2872 Image::Magick ref=NO_INIT
2884 expression[MagickPathExtent];
2912 PERL_UNUSED_VAR(ref);
2913 PERL_UNUSED_VAR(ix);
2914 exception=AcquireExceptionInfo();
2915 perl_exception=newSVpv("",0);
2919 if (sv_isobject(ST(0)) == 0)
2921 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2925 reference=SvRV(ST(0));
2926 hv=SvSTASH(reference);
2928 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2930 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2931 if (image == (Image *) NULL)
2933 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2937 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2941 channel=DefaultChannels;
2942 (void) CopyMagickString(expression,"u",MagickPathExtent);
2944 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
2946 for (i=2; i < items; i+=2)
2948 attribute=(char *) SvPV(ST(i-1),na);
2954 if (LocaleCompare(attribute,"channel") == 0)
2959 option=ParseChannelOption(SvPV(ST(i),na));
2962 ThrowPerlException(exception,OptionError,
2963 "UnrecognizedType",SvPV(ST(i),na));
2966 channel=(ChannelType) option;
2969 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2976 if (LocaleCompare(attribute,"expression") == 0)
2978 (void) CopyMagickString(expression,SvPV(ST(i),na),
2982 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2988 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2994 channel_mask=SetImageChannelMask(image,channel);
2995 image=ChannelFxImage(image,expression,exception);
2996 if (image != (Image *) NULL)
2997 (void) SetImageChannelMask(image,channel_mask);
2998 if (image == (Image *) NULL)
3000 for ( ; image; image=image->next)
3002 AddImageToRegistry(sv,image);
3004 av_push(av,sv_bless(rv,hv));
3007 exception=DestroyExceptionInfo(exception);
3009 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3013 InheritPerlException(exception,perl_exception);
3014 exception=DestroyExceptionInfo(exception);
3015 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3016 SvPOK_on(perl_exception);
3017 ST(0)=sv_2mortal(perl_exception);
3022 ###############################################################################
3030 ###############################################################################
3035 Image::Magick ref=NO_INIT
3068 PERL_UNUSED_VAR(ref);
3069 PERL_UNUSED_VAR(ix);
3070 exception=AcquireExceptionInfo();
3071 perl_exception=newSVpv("",0);
3073 if (sv_isobject(ST(0)) == 0)
3075 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3079 reference=SvRV(ST(0));
3080 hv=SvSTASH(reference);
3081 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3082 if (image == (Image *) NULL)
3084 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3089 Create blessed Perl array for the returned image.
3092 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3094 for ( ; image; image=image->next)
3096 clone=CloneImage(image,0,0,MagickTrue,exception);
3097 if (clone == (Image *) NULL)
3099 AddImageToRegistry(sv,clone);
3101 av_push(av,sv_bless(rv,hv));
3104 exception=DestroyExceptionInfo(exception);
3105 SvREFCNT_dec(perl_exception);
3109 InheritPerlException(exception,perl_exception);
3110 exception=DestroyExceptionInfo(exception);
3111 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3112 SvPOK_on(perl_exception);
3113 ST(0)=sv_2mortal(perl_exception);
3118 ###############################################################################
3126 ###############################################################################
3134 PERL_UNUSED_VAR(ref);
3135 if (magick_registry != (SplayTreeInfo *) NULL)
3140 ResetSplayTreeIterator(magick_registry);
3141 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3142 while (p != (Image *) NULL)
3145 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3151 ###############################################################################
3159 ###############################################################################
3164 Image::Magick ref=NO_INIT
3193 PERL_UNUSED_VAR(ref);
3194 PERL_UNUSED_VAR(ix);
3195 exception=AcquireExceptionInfo();
3196 perl_exception=newSVpv("",0);
3198 if (sv_isobject(ST(0)) == 0)
3200 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3204 reference=SvRV(ST(0));
3205 hv=SvSTASH(reference);
3207 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3209 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3210 if (image == (Image *) NULL)
3212 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3216 image=CoalesceImages(image,exception);
3217 if (image == (Image *) NULL)
3219 for ( ; image; image=image->next)
3221 AddImageToRegistry(sv,image);
3223 av_push(av,sv_bless(rv,hv));
3226 exception=DestroyExceptionInfo(exception);
3228 SvREFCNT_dec(perl_exception);
3232 InheritPerlException(exception,perl_exception);
3233 exception=DestroyExceptionInfo(exception);
3234 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3235 SvPOK_on(perl_exception);
3236 ST(0)=sv_2mortal(perl_exception);
3241 ###############################################################################
3249 ###############################################################################
3254 Image::Magick ref=NO_INIT
3300 PERL_UNUSED_VAR(ref);
3301 PERL_UNUSED_VAR(ix);
3302 exception=AcquireExceptionInfo();
3303 perl_exception=newSVpv("",0);
3307 if (sv_isobject(ST(0)) == 0)
3309 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3313 reference=SvRV(ST(0));
3314 hv=SvSTASH(reference);
3316 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3318 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3319 if (image == (Image *) NULL)
3321 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3325 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3329 reconstruct_image=image;
3330 metric=RootMeanSquaredErrorMetric;
3331 for (i=2; i < items; i+=2)
3333 attribute=(char *) SvPV(ST(i-1),na);
3339 if (LocaleCompare(attribute,"channel") == 0)
3344 option=ParseChannelOption(SvPV(ST(i),na));
3347 ThrowPerlException(exception,OptionError,
3348 "UnrecognizedType",SvPV(ST(i),na));
3351 (void) SetPixelChannelMask(image,(ChannelType) option);
3354 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3361 if (LocaleCompare(attribute,"fuzz") == 0)
3363 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3366 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3373 if (LocaleCompare(attribute,"image") == 0)
3375 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3376 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3379 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3386 if (LocaleCompare(attribute,"metric") == 0)
3388 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3392 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3396 metric=(MetricType) option;
3399 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3405 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3411 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3413 if (difference_image != (Image *) NULL)
3415 difference_image->error.mean_error_per_pixel=distortion;
3416 AddImageToRegistry(sv,difference_image);
3418 av_push(av,sv_bless(rv,hv));
3421 exception=DestroyExceptionInfo(exception);
3423 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3427 InheritPerlException(exception,perl_exception);
3428 exception=DestroyExceptionInfo(exception);
3429 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3430 SvPOK_on(perl_exception);
3431 ST(0)=sv_2mortal(perl_exception);
3436 ###############################################################################
3440 # C o m p l e x I m a g e s #
3444 ###############################################################################
3449 Image::Magick ref=NO_INIT
3486 PERL_UNUSED_VAR(ref);
3487 PERL_UNUSED_VAR(ix);
3488 exception=AcquireExceptionInfo();
3489 perl_exception=newSVpv("",0);
3491 if (sv_isobject(ST(0)) == 0)
3493 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3497 reference=SvRV(ST(0));
3498 hv=SvSTASH(reference);
3499 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3500 if (image == (Image *) NULL)
3502 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3506 op=UndefinedComplexOperator;
3512 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3516 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3520 op=(ComplexOperator) in;
3523 for (i=2; i < items; i+=2)
3525 attribute=(char *) SvPV(ST(i-1),na);
3531 if (LocaleCompare(attribute,"operator") == 0)
3536 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3537 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3540 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3544 op=(ComplexOperator) in;
3547 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3553 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3559 image=ComplexImages(image,op,exception);
3560 if (image == (Image *) NULL)
3563 Create blessed Perl array for the returned image.
3566 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3568 AddImageToRegistry(sv,image);
3570 av_push(av,sv_bless(rv,hv));
3572 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3573 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3574 "complex-%.*s",(int) (MagickPathExtent-9),
3575 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3576 (void) CopyMagickString(image->filename,info->image_info->filename,
3578 SetImageInfo(info->image_info,0,exception);
3579 exception=DestroyExceptionInfo(exception);
3580 SvREFCNT_dec(perl_exception);
3584 InheritPerlException(exception,perl_exception);
3585 exception=DestroyExceptionInfo(exception);
3586 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3587 SvPOK_on(perl_exception);
3588 ST(0)=sv_2mortal(perl_exception);
3593 ###############################################################################
3597 # C o m p a r e L a y e r s #
3601 ###############################################################################
3606 Image::Magick ref=NO_INIT
3608 CompareImagesLayers = 1
3610 compareimagelayers = 3
3647 PERL_UNUSED_VAR(ref);
3648 PERL_UNUSED_VAR(ix);
3649 exception=AcquireExceptionInfo();
3650 perl_exception=newSVpv("",0);
3652 if (sv_isobject(ST(0)) == 0)
3654 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3658 reference=SvRV(ST(0));
3659 hv=SvSTASH(reference);
3661 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3663 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3664 if (image == (Image *) NULL)
3666 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3670 method=CompareAnyLayer;
3671 for (i=2; i < items; i+=2)
3673 attribute=(char *) SvPV(ST(i-1),na);
3679 if (LocaleCompare(attribute,"method") == 0)
3681 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3685 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3689 method=(LayerMethod) option;
3692 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3704 image=CompareImagesLayers(image,method,exception);
3705 if (image == (Image *) NULL)
3707 for ( ; image; image=image->next)
3709 AddImageToRegistry(sv,image);
3711 av_push(av,sv_bless(rv,hv));
3714 exception=DestroyExceptionInfo(exception);
3716 SvREFCNT_dec(perl_exception);
3720 InheritPerlException(exception,perl_exception);
3721 exception=DestroyExceptionInfo(exception);
3722 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3723 SvPOK_on(perl_exception);
3724 ST(0)=sv_2mortal(perl_exception);
3729 ###############################################################################
3737 ###############################################################################
3742 Image::Magick ref=NO_INIT
3748 PERL_UNUSED_VAR(ref);
3749 if (sv_isobject(ST(0)) == 0)
3750 croak("ReferenceIsNotMyType");
3751 reference=SvRV(ST(0));
3752 switch (SvTYPE(reference))
3757 message[MagickPathExtent];
3775 Array (AV *) reference
3777 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3778 XS_VERSION,reference);
3779 hv=gv_stashpv(PackageName, FALSE);
3782 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3786 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3788 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3789 DestroyPackageInfo(info);
3791 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3801 Blessed scalar = (Image *) SvIV(reference)
3803 image=INT2PTR(Image *,SvIV(reference));
3804 if (image != (Image *) NULL)
3805 DeleteImageFromRegistry(reference,image);
3814 ###############################################################################
3822 ###############################################################################
3827 Image::Magick ref=NO_INIT
3851 PERL_UNUSED_VAR(ref);
3852 PERL_UNUSED_VAR(ix);
3853 exception=AcquireExceptionInfo();
3854 perl_exception=newSVpv("",0);
3855 package_info=(struct PackageInfo *) NULL;
3856 if (sv_isobject(ST(0)) == 0)
3858 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3862 reference=SvRV(ST(0));
3863 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3864 if (image == (Image *) NULL)
3866 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3870 package_info=ClonePackageInfo(info,exception);
3872 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3875 for (i=2; i < items; i+=2)
3876 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3878 (void) DisplayImages(package_info->image_info,image,exception);
3879 (void) CatchImageException(image);
3882 if (package_info != (struct PackageInfo *) NULL)
3883 DestroyPackageInfo(package_info);
3884 InheritPerlException(exception,perl_exception);
3885 exception=DestroyExceptionInfo(exception);
3886 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3887 SvPOK_on(perl_exception);
3888 ST(0)=sv_2mortal(perl_exception);
3893 ###############################################################################
3897 # E v a l u a t e I m a g e s #
3901 ###############################################################################
3906 Image::Magick ref=NO_INIT
3928 MagickEvaluateOperator
3943 PERL_UNUSED_VAR(ref);
3944 PERL_UNUSED_VAR(ix);
3945 exception=AcquireExceptionInfo();
3946 perl_exception=newSVpv("",0);
3948 if (sv_isobject(ST(0)) == 0)
3950 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3954 reference=SvRV(ST(0));
3955 hv=SvSTASH(reference);
3956 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3957 if (image == (Image *) NULL)
3959 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3963 op=MeanEvaluateOperator;
3969 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3973 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3977 op=(MagickEvaluateOperator) in;
3980 for (i=2; i < items; i+=2)
3982 attribute=(char *) SvPV(ST(i-1),na);
3988 if (LocaleCompare(attribute,"operator") == 0)
3993 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3994 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3997 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4001 op=(MagickEvaluateOperator) in;
4004 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4010 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4016 image=EvaluateImages(image,op,exception);
4017 if (image == (Image *) NULL)
4020 Create blessed Perl array for the returned image.
4023 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4025 AddImageToRegistry(sv,image);
4027 av_push(av,sv_bless(rv,hv));
4029 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4030 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4031 "evaluate-%.*s",(int) (MagickPathExtent-9),
4032 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4033 (void) CopyMagickString(image->filename,info->image_info->filename,
4035 SetImageInfo(info->image_info,0,exception);
4036 exception=DestroyExceptionInfo(exception);
4037 SvREFCNT_dec(perl_exception);
4041 InheritPerlException(exception,perl_exception);
4042 exception=DestroyExceptionInfo(exception);
4043 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4044 SvPOK_on(perl_exception);
4045 ST(0)=sv_2mortal(perl_exception);
4050 ###############################################################################
4058 ###############################################################################
4063 Image::Magick ref=NO_INIT
4070 #define ChannelFeatures(channel,direction) \
4072 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4073 channel_features[channel].angular_second_moment[direction]); \
4074 PUSHs(sv_2mortal(newSVpv(message,0))); \
4075 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4076 channel_features[channel].contrast[direction]); \
4077 PUSHs(sv_2mortal(newSVpv(message,0))); \
4078 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4079 channel_features[channel].contrast[direction]); \
4080 PUSHs(sv_2mortal(newSVpv(message,0))); \
4081 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4082 channel_features[channel].variance_sum_of_squares[direction]); \
4083 PUSHs(sv_2mortal(newSVpv(message,0))); \
4084 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4085 channel_features[channel].inverse_difference_moment[direction]); \
4086 PUSHs(sv_2mortal(newSVpv(message,0))); \
4087 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4088 channel_features[channel].sum_average[direction]); \
4089 PUSHs(sv_2mortal(newSVpv(message,0))); \
4090 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4091 channel_features[channel].sum_variance[direction]); \
4092 PUSHs(sv_2mortal(newSVpv(message,0))); \
4093 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4094 channel_features[channel].sum_entropy[direction]); \
4095 PUSHs(sv_2mortal(newSVpv(message,0))); \
4096 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4097 channel_features[channel].entropy[direction]); \
4098 PUSHs(sv_2mortal(newSVpv(message,0))); \
4099 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4100 channel_features[channel].difference_variance[direction]); \
4101 PUSHs(sv_2mortal(newSVpv(message,0))); \
4102 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4103 channel_features[channel].difference_entropy[direction]); \
4104 PUSHs(sv_2mortal(newSVpv(message,0))); \
4105 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4106 channel_features[channel].measure_of_correlation_1[direction]); \
4107 PUSHs(sv_2mortal(newSVpv(message,0))); \
4108 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4109 channel_features[channel].measure_of_correlation_2[direction]); \
4110 PUSHs(sv_2mortal(newSVpv(message,0))); \
4111 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4112 channel_features[channel].maximum_correlation_coefficient[direction]); \
4113 PUSHs(sv_2mortal(newSVpv(message,0))); \
4121 message[MagickPathExtent];
4148 PERL_UNUSED_VAR(ref);
4149 PERL_UNUSED_VAR(ix);
4150 exception=AcquireExceptionInfo();
4151 perl_exception=newSVpv("",0);
4153 if (sv_isobject(ST(0)) == 0)
4155 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4159 reference=SvRV(ST(0));
4162 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4163 if (image == (Image *) NULL)
4165 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4170 for (i=2; i < items; i+=2)
4172 attribute=(char *) SvPV(ST(i-1),na);
4178 if (LocaleCompare(attribute,"distance") == 0)
4180 distance=StringToLong((char *) SvPV(ST(1),na));
4183 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4196 for ( ; image; image=image->next)
4198 channel_features=GetImageFeatures(image,distance,exception);
4199 if (channel_features == (ChannelFeatures *) NULL)
4202 EXTEND(sp,280*count);
4203 for (i=0; i < 4; i++)
4205 ChannelFeatures(RedChannel,i);
4206 ChannelFeatures(GreenChannel,i);
4207 ChannelFeatures(BlueChannel,i);
4208 if (image->colorspace == CMYKColorspace)
4209 ChannelFeatures(BlackChannel,i);
4210 if (image->alpha_trait != UndefinedPixelTrait)
4211 ChannelFeatures(AlphaChannel,i);
4213 channel_features=(ChannelFeatures *)
4214 RelinquishMagickMemory(channel_features);
4218 InheritPerlException(exception,perl_exception);
4219 exception=DestroyExceptionInfo(exception);
4220 SvREFCNT_dec(perl_exception);
4224 ###############################################################################
4232 ###############################################################################
4237 Image::Magick ref=NO_INIT
4275 PERL_UNUSED_VAR(ref);
4276 PERL_UNUSED_VAR(ix);
4277 exception=AcquireExceptionInfo();
4278 perl_exception=newSVpv("",0);
4280 if (sv_isobject(ST(0)) == 0)
4282 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4286 reference=SvRV(ST(0));
4287 hv=SvSTASH(reference);
4288 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4289 if (image == (Image *) NULL)
4291 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4295 background_color=image->background_color;
4297 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4298 &background_color,exception);
4300 for (i=2; i < items; i+=2)
4302 attribute=(char *) SvPV(ST(i-1),na);
4308 if (LocaleCompare(attribute,"background") == 0)
4310 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4311 AllCompliance,&background_color,exception);
4314 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4320 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4326 image->background_color=background_color;
4327 image=MergeImageLayers(image,FlattenLayer,exception);
4328 if (image == (Image *) NULL)
4331 Create blessed Perl array for the returned image.
4334 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4336 AddImageToRegistry(sv,image);
4338 av_push(av,sv_bless(rv,hv));
4340 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4341 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4342 "flatten-%.*s",(int) (MagickPathExtent-9),
4343 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4344 (void) CopyMagickString(image->filename,info->image_info->filename,
4346 SetImageInfo(info->image_info,0,exception);
4347 exception=DestroyExceptionInfo(exception);
4348 SvREFCNT_dec(perl_exception);
4352 InheritPerlException(exception,perl_exception);
4353 exception=DestroyExceptionInfo(exception);
4354 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4355 SvPOK_on(perl_exception); /* return messages in string context */
4356 ST(0)=sv_2mortal(perl_exception);
4361 ###############################################################################
4369 ###############################################################################
4374 Image::Magick ref=NO_INIT
4386 expression[MagickPathExtent];
4414 PERL_UNUSED_VAR(ref);
4415 PERL_UNUSED_VAR(ix);
4416 exception=AcquireExceptionInfo();
4417 perl_exception=newSVpv("",0);
4421 if (sv_isobject(ST(0)) == 0)
4423 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4427 reference=SvRV(ST(0));
4428 hv=SvSTASH(reference);
4430 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4432 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4433 if (image == (Image *) NULL)
4435 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4439 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4443 channel=DefaultChannels;
4444 (void) CopyMagickString(expression,"u",MagickPathExtent);
4446 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4448 for (i=2; i < items; i+=2)
4450 attribute=(char *) SvPV(ST(i-1),na);
4456 if (LocaleCompare(attribute,"channel") == 0)
4461 option=ParseChannelOption(SvPV(ST(i),na));
4464 ThrowPerlException(exception,OptionError,
4465 "UnrecognizedType",SvPV(ST(i),na));
4468 channel=(ChannelType) option;
4471 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4478 if (LocaleCompare(attribute,"expression") == 0)
4480 (void) CopyMagickString(expression,SvPV(ST(i),na),
4484 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4490 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4496 channel_mask=SetImageChannelMask(image,channel);
4497 image=FxImage(image,expression,exception);
4498 if (image != (Image *) NULL)
4499 (void) SetImageChannelMask(image,channel_mask);
4500 if (image == (Image *) NULL)
4502 for ( ; image; image=image->next)
4504 AddImageToRegistry(sv,image);
4506 av_push(av,sv_bless(rv,hv));
4509 exception=DestroyExceptionInfo(exception);
4511 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4515 InheritPerlException(exception,perl_exception);
4516 exception=DestroyExceptionInfo(exception);
4517 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4518 SvPOK_on(perl_exception);
4519 ST(0)=sv_2mortal(perl_exception);
4524 ###############################################################################
4532 ###############################################################################
4537 Image::Magick ref=NO_INIT
4548 color[MagickPathExtent];
4573 PERL_UNUSED_VAR(ref);
4574 PERL_UNUSED_VAR(ix);
4575 exception=AcquireExceptionInfo();
4576 perl_exception=newSVpv("",0);
4577 if (sv_isobject(ST(0)) == 0)
4579 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4583 reference=SvRV(ST(0));
4584 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4585 if (image == (Image *) NULL && !info)
4588 for (i=1; i < items; i++)
4590 attribute=(char *) SvPV(ST(i),na);
4597 if (LocaleCompare(attribute,"adjoin") == 0)
4600 s=newSViv((ssize_t) info->image_info->adjoin);
4601 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4604 if (LocaleCompare(attribute,"antialias") == 0)
4607 s=newSViv((ssize_t) info->image_info->antialias);
4608 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4611 if (LocaleCompare(attribute,"area") == 0)
4613 s=newSViv(GetMagickResource(AreaResource));
4614 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4617 if (LocaleCompare(attribute,"attenuate") == 0)
4622 value=GetImageProperty(image,attribute,exception);
4623 if (value != (const char *) NULL)
4625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4628 if (LocaleCompare(attribute,"authenticate") == 0)
4635 option=GetImageOption(info->image_info,attribute);
4636 if (option != (const char *) NULL)
4637 s=newSVpv(option,0);
4639 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4642 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4649 if (LocaleCompare(attribute,"background") == 0)
4651 if (image == (Image *) NULL)
4653 (void) FormatLocaleString(color,MagickPathExtent,
4654 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4655 (double) image->background_color.green,
4656 (double) image->background_color.blue,
4657 (double) image->background_color.alpha);
4659 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4662 if (LocaleCompare(attribute,"base-columns") == 0)
4664 if (image != (Image *) NULL)
4665 s=newSViv((ssize_t) image->magick_columns);
4666 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4669 if (LocaleCompare(attribute,"base-filename") == 0)
4671 if (image != (Image *) NULL)
4672 s=newSVpv(image->magick_filename,0);
4673 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4676 if (LocaleCompare(attribute,"base-height") == 0)
4678 if (image != (Image *) NULL)
4679 s=newSViv((ssize_t) image->magick_rows);
4680 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4683 if (LocaleCompare(attribute,"base-rows") == 0)
4685 if (image != (Image *) NULL)
4686 s=newSViv((ssize_t) image->magick_rows);
4687 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4690 if (LocaleCompare(attribute,"base-width") == 0)
4692 if (image != (Image *) NULL)
4693 s=newSViv((ssize_t) image->magick_columns);
4694 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4697 if (LocaleCompare(attribute,"blue-primary") == 0)
4699 if (image == (Image *) NULL)
4701 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
4702 image->chromaticity.blue_primary.x,
4703 image->chromaticity.blue_primary.y);
4705 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4708 if (LocaleCompare(attribute,"bordercolor") == 0)
4710 if (image == (Image *) NULL)
4712 (void) FormatLocaleString(color,MagickPathExtent,
4713 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4714 (double) image->border_color.green,
4715 (double) image->border_color.blue,
4716 (double) image->border_color.alpha);
4718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4721 if (LocaleCompare(attribute,"bounding-box") == 0)
4724 geometry[MagickPathExtent];
4729 if (image == (Image *) NULL)
4731 page=GetImageBoundingBox(image,exception);
4732 (void) FormatLocaleString(geometry,MagickPathExtent,
4733 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4734 page.height,(double) page.x,(double) page.y);
4735 s=newSVpv(geometry,0);
4736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4746 if (LocaleCompare(attribute,"class") == 0)
4748 if (image == (Image *) NULL)
4750 s=newSViv(image->storage_class);
4751 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4752 image->storage_class));
4754 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4757 if (LocaleCompare(attribute,"clip-mask") == 0)
4759 if (image != (Image *) NULL)
4768 if (image->read_mask == MagickFalse)
4769 ClipImage(image,exception);
4770 mask_image=GetImageMask(image,exception);
4771 if (mask_image != (Image *) NULL)
4773 AddImageToRegistry(sv,mask_image);
4774 s=sv_bless(newRV(sv),SvSTASH(reference));
4777 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4780 if (LocaleCompare(attribute,"clip-path") == 0)
4782 if (image != (Image *) NULL)
4791 if (image->read_mask != MagickFalse)
4792 ClipImage(image,exception);
4793 mask_image=GetImageMask(image,exception);
4794 if (mask_image != (Image *) NULL)
4796 AddImageToRegistry(sv,mask_image);
4797 s=sv_bless(newRV(sv),SvSTASH(reference));
4800 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4803 if (LocaleCompare(attribute,"compression") == 0)
4805 j=info ? info->image_info->compression : image ?
4806 image->compression : UndefinedCompression;
4808 if (info->image_info->compression == UndefinedCompression)
4809 j=image->compression;
4811 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4814 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4817 if (LocaleCompare(attribute,"colorspace") == 0)
4819 j=image ? image->colorspace : RGBColorspace;
4821 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4824 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4827 if (LocaleCompare(attribute,"colors") == 0)
4829 if (image != (Image *) NULL)
4830 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4832 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4835 if (LocaleNCompare(attribute,"colormap",8) == 0)
4840 if (image == (Image *) NULL || !image->colormap)
4843 items=sscanf(attribute,"%*[^[][%ld",&j);
4845 if (j > (ssize_t) image->colors)
4847 (void) FormatLocaleString(color,MagickPathExtent,
4848 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4849 (double) image->colormap[j].green,
4850 (double) image->colormap[j].blue,
4851 (double) image->colormap[j].alpha);
4853 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4856 if (LocaleCompare(attribute,"columns") == 0)
4858 if (image != (Image *) NULL)
4859 s=newSViv((ssize_t) image->columns);
4860 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4863 if (LocaleCompare(attribute,"comment") == 0)
4868 value=GetImageProperty(image,attribute,exception);
4869 if (value != (const char *) NULL)
4871 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4874 if (LocaleCompare(attribute,"copyright") == 0)
4876 s=newSVpv(GetMagickCopyright(),0);
4877 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4880 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4887 if (LocaleCompare(attribute,"density") == 0)
4890 geometry[MagickPathExtent];
4892 if (image == (Image *) NULL)
4894 (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g",
4895 image->resolution.x,image->resolution.y);
4896 s=newSVpv(geometry,0);
4897 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4900 if (LocaleCompare(attribute,"delay") == 0)
4902 if (image != (Image *) NULL)
4903 s=newSViv((ssize_t) image->delay);
4904 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4907 if (LocaleCompare(attribute,"depth") == 0)
4909 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4910 if (image != (Image *) NULL)
4911 s=newSViv((ssize_t) GetImageDepth(image,exception));
4912 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4915 if (LocaleCompare(attribute,"directory") == 0)
4917 if (image && image->directory)
4918 s=newSVpv(image->directory,0);
4919 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4922 if (LocaleCompare(attribute,"dispose") == 0)
4924 if (image == (Image *) NULL)
4927 s=newSViv(image->dispose);
4929 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4931 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4934 if (LocaleCompare(attribute,"disk") == 0)
4936 s=newSViv(GetMagickResource(DiskResource));
4937 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4940 if (LocaleCompare(attribute,"dither") == 0)
4943 s=newSViv((ssize_t) info->image_info->dither);
4944 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4947 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4949 if (info && info->image_info->server_name)
4950 s=newSVpv(info->image_info->server_name,0);
4951 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4954 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4961 if (LocaleCompare(attribute,"elapsed-time") == 0)
4963 if (image != (Image *) NULL)
4964 s=newSVnv(GetElapsedTime(&image->timer));
4965 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4968 if (LocaleCompare(attribute,"endian") == 0)
4970 j=info ? info->image_info->endian : image ? image->endian :
4973 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4975 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4978 if (LocaleCompare(attribute,"error") == 0)
4980 if (image != (Image *) NULL)
4981 s=newSVnv(image->error.mean_error_per_pixel);
4982 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4985 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4992 if (LocaleCompare(attribute,"filesize") == 0)
4994 if (image != (Image *) NULL)
4995 s=newSViv((ssize_t) GetBlobSize(image));
4996 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4999 if (LocaleCompare(attribute,"filename") == 0)
5001 if (info && info->image_info->filename &&
5002 *info->image_info->filename)
5003 s=newSVpv(info->image_info->filename,0);
5004 if (image != (Image *) NULL)
5005 s=newSVpv(image->filename,0);
5006 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5009 if (LocaleCompare(attribute,"filter") == 0)
5011 s=image ? newSViv(image->filter) : newSViv(0);
5012 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5015 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5018 if (LocaleCompare(attribute,"font") == 0)
5020 if (info && info->image_info->font)
5021 s=newSVpv(info->image_info->font,0);
5022 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5025 if (LocaleCompare(attribute,"foreground") == 0)
5027 if (LocaleCompare(attribute,"format") == 0)
5032 magick_info=(const MagickInfo *) NULL;
5033 if (info && (*info->image_info->magick != '\0'))
5034 magick_info=GetMagickInfo(info->image_info->magick,exception);
5035 if (image != (Image *) NULL)
5036 magick_info=GetMagickInfo(image->magick,exception);
5037 if ((magick_info != (const MagickInfo *) NULL) &&
5038 (*magick_info->description != '\0'))
5039 s=newSVpv((char *) magick_info->description,0);
5040 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5043 if (LocaleCompare(attribute,"fuzz") == 0)
5046 s=newSVnv(info->image_info->fuzz);
5047 if (image != (Image *) NULL)
5048 s=newSVnv(image->fuzz);
5049 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5052 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5059 if (LocaleCompare(attribute,"gamma") == 0)
5061 if (image != (Image *) NULL)
5062 s=newSVnv(image->gamma);
5063 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5066 if (LocaleCompare(attribute,"geometry") == 0)
5068 if (image && image->geometry)
5069 s=newSVpv(image->geometry,0);
5070 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5073 if (LocaleCompare(attribute,"gravity") == 0)
5075 s=image ? newSViv(image->gravity) : newSViv(0);
5076 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5079 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5082 if (LocaleCompare(attribute,"green-primary") == 0)
5084 if (image == (Image *) NULL)
5086 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5087 image->chromaticity.green_primary.x,
5088 image->chromaticity.green_primary.y);
5090 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5093 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5100 if (LocaleCompare(attribute,"height") == 0)
5102 if (image != (Image *) NULL)
5103 s=newSViv((ssize_t) image->rows);
5104 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5107 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5114 if (LocaleCompare(attribute,"icc") == 0)
5116 if (image != (Image *) NULL)
5121 profile=GetImageProfile(image,"icc");
5122 if (profile != (StringInfo *) NULL)
5123 s=newSVpv((const char *) GetStringInfoDatum(profile),
5124 GetStringInfoLength(profile));
5126 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5129 if (LocaleCompare(attribute,"icm") == 0)
5131 if (image != (Image *) NULL)
5136 profile=GetImageProfile(image,"icm");
5137 if (profile != (const StringInfo *) NULL)
5138 s=newSVpv((const char *) GetStringInfoDatum(profile),
5139 GetStringInfoLength(profile));
5141 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5144 if (LocaleCompare(attribute,"id") == 0)
5146 if (image != (Image *) NULL)
5149 key[MagickPathExtent];
5157 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5159 status=SetImageRegistry(ImageRegistryType,key,image,
5164 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5167 if (LocaleNCompare(attribute,"index",5) == 0)
5170 name[MagickPathExtent];
5179 register const Quantum
5185 if (image == (Image *) NULL)
5187 if (image->storage_class != PseudoClass)
5191 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5193 image_view=AcquireVirtualCacheView(image,exception);
5194 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5195 if (p != (const Quantum *) NULL)
5197 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5198 GetPixelIndex(image,p));
5200 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5202 image_view=DestroyCacheView(image_view);
5205 if (LocaleCompare(attribute,"iptc") == 0)
5207 if (image != (Image *) NULL)
5212 profile=GetImageProfile(image,"iptc");
5213 if (profile != (const StringInfo *) NULL)
5214 s=newSVpv((const char *) GetStringInfoDatum(profile),
5215 GetStringInfoLength(profile));
5217 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5220 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5222 if (image != (Image *) NULL)
5223 s=newSViv((ssize_t) image->iterations);
5224 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5227 if (LocaleCompare(attribute,"interlace") == 0)
5229 j=info ? info->image_info->interlace : image ? image->interlace :
5232 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5235 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5238 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5245 if (LocaleCompare(attribute,"label") == 0)
5250 if (image == (Image *) NULL)
5252 value=GetImageProperty(image,"Label",exception);
5253 if (value != (const char *) NULL)
5255 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5258 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5260 if (image != (Image *) NULL)
5261 s=newSViv((ssize_t) image->iterations);
5262 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5265 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5272 if (LocaleCompare(attribute,"magick") == 0)
5274 if (info && *info->image_info->magick)
5275 s=newSVpv(info->image_info->magick,0);
5276 if (image != (Image *) NULL)
5277 s=newSVpv(image->magick,0);
5278 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5281 if (LocaleCompare(attribute,"map") == 0)
5283 s=newSViv(GetMagickResource(MapResource));
5284 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5287 if (LocaleCompare(attribute,"maximum-error") == 0)
5289 if (image != (Image *) NULL)
5290 s=newSVnv(image->error.normalized_maximum_error);
5291 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5294 if (LocaleCompare(attribute,"memory") == 0)
5296 s=newSViv(GetMagickResource(MemoryResource));
5297 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5300 if (LocaleCompare(attribute,"mean-error") == 0)
5302 if (image != (Image *) NULL)
5303 s=newSVnv(image->error.normalized_mean_error);
5304 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5307 if (LocaleCompare(attribute,"mime") == 0)
5309 if (info && *info->image_info->magick)
5310 s=newSVpv(MagickToMime(info->image_info->magick),0);
5311 if (image != (Image *) NULL)
5312 s=newSVpv(MagickToMime(image->magick),0);
5313 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5316 if (LocaleCompare(attribute,"mattecolor") == 0)
5318 if (image == (Image *) NULL)
5320 (void) FormatLocaleString(color,MagickPathExtent,
5321 "%.20g,%.20g,%.20g,%.20g",(double) image->matte_color.red,
5322 (double) image->matte_color.green,
5323 (double) image->matte_color.blue,
5324 (double) image->matte_color.alpha);
5326 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5329 if (LocaleCompare(attribute,"matte") == 0)
5331 if (image != (Image *) NULL)
5332 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5334 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5337 if (LocaleCompare(attribute,"mime") == 0)
5343 if (info && *info->image_info->magick)
5344 magick=info->image_info->magick;
5345 if (image != (Image *) NULL)
5346 magick=image->magick;
5352 mime=MagickToMime(magick);
5354 mime=(char *) RelinquishMagickMemory(mime);
5356 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5359 if (LocaleCompare(attribute,"monochrome") == 0)
5361 if (image == (Image *) NULL)
5363 j=info ? info->image_info->monochrome :
5364 SetImageMonochrome(image,exception);
5366 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5369 if (LocaleCompare(attribute,"montage") == 0)
5371 if (image && image->montage)
5372 s=newSVpv(image->montage,0);
5373 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5376 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5383 if (LocaleCompare(attribute,"orientation") == 0)
5385 j=info ? info->image_info->orientation : image ?
5386 image->orientation : UndefinedOrientation;
5388 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5391 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5401 if (LocaleCompare(attribute,"page") == 0)
5403 if (info && info->image_info->page)
5404 s=newSVpv(info->image_info->page,0);
5405 if (image != (Image *) NULL)
5408 geometry[MagickPathExtent];
5410 (void) FormatLocaleString(geometry,MagickPathExtent,
5411 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5412 (double) image->page.height,(double) image->page.x,(double)
5414 s=newSVpv(geometry,0);
5416 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5419 if (LocaleCompare(attribute,"page.x") == 0)
5421 if (image != (Image *) NULL)
5422 s=newSViv((ssize_t) image->page.x);
5423 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5426 if (LocaleCompare(attribute,"page.y") == 0)
5428 if (image != (Image *) NULL)
5429 s=newSViv((ssize_t) image->page.y);
5430 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5433 if (LocaleNCompare(attribute,"pixel",5) == 0)
5436 tuple[MagickPathExtent];
5445 register const Quantum
5448 if (image == (Image *) NULL)
5452 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5454 p=GetVirtualPixels(image,x,y,1,1,exception);
5455 if (image->colorspace != CMYKColorspace)
5456 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5457 QuantumFormat "," QuantumFormat "," QuantumFormat,
5458 GetPixelRed(image,p),GetPixelGreen(image,p),
5459 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5461 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5462 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5463 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5464 GetPixelBlue(image,p),GetPixelBlack(image,p),
5465 GetPixelAlpha(image,p));
5467 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5470 if (LocaleCompare(attribute,"pointsize") == 0)
5473 s=newSViv((ssize_t) info->image_info->pointsize);
5474 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5477 if (LocaleCompare(attribute,"preview") == 0)
5479 s=newSViv(info->image_info->preview_type);
5480 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5481 info->image_info->preview_type));
5483 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5486 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5493 if (LocaleCompare(attribute,"quality") == 0)
5496 s=newSViv((ssize_t) info->image_info->quality);
5497 if (image != (Image *) NULL)
5498 s=newSViv((ssize_t) image->quality);
5499 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5502 if (LocaleCompare(attribute,"quantum") == 0)
5505 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5506 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5509 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5516 if (LocaleCompare(attribute,"rendering-intent") == 0)
5518 s=newSViv(image->rendering_intent);
5519 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5520 image->rendering_intent));
5522 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5525 if (LocaleCompare(attribute,"red-primary") == 0)
5527 if (image == (Image *) NULL)
5529 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5530 image->chromaticity.red_primary.x,
5531 image->chromaticity.red_primary.y);
5533 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5536 if (LocaleCompare(attribute,"rows") == 0)
5538 if (image != (Image *) NULL)
5539 s=newSViv((ssize_t) image->rows);
5540 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5543 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5550 if (LocaleCompare(attribute,"sampling-factor") == 0)
5552 if (info && info->image_info->sampling_factor)
5553 s=newSVpv(info->image_info->sampling_factor,0);
5554 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5557 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5559 if (info && info->image_info->server_name)
5560 s=newSVpv(info->image_info->server_name,0);
5561 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5564 if (LocaleCompare(attribute,"size") == 0)
5566 if (info && info->image_info->size)
5567 s=newSVpv(info->image_info->size,0);
5568 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5571 if (LocaleCompare(attribute,"scene") == 0)
5573 if (image != (Image *) NULL)
5574 s=newSViv((ssize_t) image->scene);
5575 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5578 if (LocaleCompare(attribute,"scenes") == 0)
5580 if (image != (Image *) NULL)
5581 s=newSViv((ssize_t) info->image_info->number_scenes);
5582 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5585 if (LocaleCompare(attribute,"signature") == 0)
5590 if (image == (Image *) NULL)
5592 (void) SignatureImage(image,exception);
5593 value=GetImageProperty(image,"Signature",exception);
5594 if (value != (const char *) NULL)
5596 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5599 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5606 if (LocaleCompare(attribute,"taint") == 0)
5608 if (image != (Image *) NULL)
5609 s=newSViv((ssize_t) IsTaintImage(image));
5610 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5613 if (LocaleCompare(attribute,"texture") == 0)
5615 if (info && info->image_info->texture)
5616 s=newSVpv(info->image_info->texture,0);
5617 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5620 if (LocaleCompare(attribute,"total-ink-density") == 0)
5622 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5623 if (image != (Image *) NULL)
5624 s=newSVnv(GetImageTotalInkDensity(image,exception));
5625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5628 if (LocaleCompare(attribute,"transparent-color") == 0)
5630 if (image == (Image *) NULL)
5632 (void) FormatLocaleString(color,MagickPathExtent,
5633 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5634 (double) image->transparent_color.green,
5635 (double) image->transparent_color.blue,
5636 (double) image->transparent_color.alpha);
5638 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5641 if (LocaleCompare(attribute,"type") == 0)
5643 if (image == (Image *) NULL)
5645 j=(ssize_t) GetImageType(image,exception);
5647 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5652 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5659 if (LocaleCompare(attribute,"units") == 0)
5661 j=info ? info->image_info->units : image ? image->units :
5662 UndefinedResolution;
5663 if (info && (info->image_info->units == UndefinedResolution))
5666 if (j == UndefinedResolution)
5667 s=newSVpv("undefined units",0);
5669 if (j == PixelsPerInchResolution)
5670 s=newSVpv("pixels / inch",0);
5672 s=newSVpv("pixels / centimeter",0);
5673 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5676 if (LocaleCompare(attribute,"user-time") == 0)
5678 if (image != (Image *) NULL)
5679 s=newSVnv(GetUserTime(&image->timer));
5680 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5690 if (LocaleCompare(attribute,"verbose") == 0)
5693 s=newSViv((ssize_t) info->image_info->verbose);
5694 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5697 if (LocaleCompare(attribute,"version") == 0)
5699 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5700 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5703 if (LocaleCompare(attribute,"view") == 0)
5705 if (info && info->image_info->view)
5706 s=newSVpv(info->image_info->view,0);
5707 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5710 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5712 if (image == (Image *) NULL)
5714 j=(ssize_t) GetImageVirtualPixelMethod(image);
5716 (void) sv_setpv(s,CommandOptionToMnemonic(
5717 MagickVirtualPixelOptions,j));
5719 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5722 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5729 if (LocaleCompare(attribute,"white-point") == 0)
5731 if (image == (Image *) NULL)
5733 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5734 image->chromaticity.white_point.x,
5735 image->chromaticity.white_point.y);
5737 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5740 if (LocaleCompare(attribute,"width") == 0)
5742 if (image != (Image *) NULL)
5743 s=newSViv((ssize_t) image->columns);
5744 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5747 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5754 if (LocaleCompare(attribute,"x-resolution") == 0)
5756 if (image != (Image *) NULL)
5757 s=newSVnv(image->resolution.x);
5758 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5761 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5768 if (LocaleCompare(attribute,"y-resolution") == 0)
5770 if (image != (Image *) NULL)
5771 s=newSVnv(image->resolution.y);
5772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5775 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5782 if (image == (Image *) NULL)
5783 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5787 value=GetImageProperty(image,attribute,exception);
5788 if (value != (const char *) NULL)
5791 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5794 if (*attribute != '%')
5795 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5802 meta=InterpretImageProperties(info ? info->image_info :
5803 (ImageInfo *) NULL,image,attribute,exception);
5805 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5806 meta=(char *) RelinquishMagickMemory(meta);
5810 exception=DestroyExceptionInfo(exception);
5811 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5815 ###############################################################################
5819 # G e t A u t h e n t i c P i x e l s #
5823 ###############################################################################
5827 GetAuthenticPixels(ref,...)
5828 Image::Magick ref = NO_INIT
5830 getauthenticpixels = 1
5860 PERL_UNUSED_VAR(ref);
5861 PERL_UNUSED_VAR(ix);
5862 exception=AcquireExceptionInfo();
5863 perl_exception=newSVpv("",0);
5864 if (sv_isobject(ST(0)) == 0)
5866 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5870 reference=SvRV(ST(0));
5872 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5873 if (image == (Image *) NULL)
5875 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5882 region.width=image->columns;
5885 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5886 for (i=2; i < items; i+=2)
5888 attribute=(char *) SvPV(ST(i-1),na);
5894 if (LocaleCompare(attribute,"geometry") == 0)
5896 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5899 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5906 if (LocaleCompare(attribute,"height") == 0)
5908 region.height=SvIV(ST(i));
5911 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5918 if (LocaleCompare(attribute,"x") == 0)
5920 region.x=SvIV(ST(i));
5923 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5930 if (LocaleCompare(attribute,"y") == 0)
5932 region.y=SvIV(ST(i));
5935 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5942 if (LocaleCompare(attribute,"width") == 0)
5944 region.width=SvIV(ST(i));
5947 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5953 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5954 region.height,exception);
5955 if (blob != (void *) NULL)
5959 InheritPerlException(exception,perl_exception);
5960 exception=DestroyExceptionInfo(exception);
5961 SvREFCNT_dec(perl_exception); /* throw away all errors */
5970 ###############################################################################
5974 # G e t V i r t u a l P i x e l s #
5978 ###############################################################################
5982 GetVirtualPixels(ref,...)
5983 Image::Magick ref = NO_INIT
5985 getvirtualpixels = 1
5986 AcquireImagePixels = 2
5987 acquireimagepixels = 3
6015 PERL_UNUSED_VAR(ref);
6016 PERL_UNUSED_VAR(ix);
6017 exception=AcquireExceptionInfo();
6018 perl_exception=newSVpv("",0);
6019 if (sv_isobject(ST(0)) == 0)
6021 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6025 reference=SvRV(ST(0));
6027 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6028 if (image == (Image *) NULL)
6030 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6037 region.width=image->columns;
6040 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6041 for (i=2; i < items; i+=2)
6043 attribute=(char *) SvPV(ST(i-1),na);
6049 if (LocaleCompare(attribute,"geometry") == 0)
6051 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6054 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6061 if (LocaleCompare(attribute,"height") == 0)
6063 region.height=SvIV(ST(i));
6066 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6073 if (LocaleCompare(attribute,"x") == 0)
6075 region.x=SvIV(ST(i));
6078 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6085 if (LocaleCompare(attribute,"y") == 0)
6087 region.y=SvIV(ST(i));
6090 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6097 if (LocaleCompare(attribute,"width") == 0)
6099 region.width=SvIV(ST(i));
6102 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6108 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6109 region.height,exception);
6110 if (blob != (void *) NULL)
6114 InheritPerlException(exception,perl_exception);
6115 exception=DestroyExceptionInfo(exception);
6116 SvREFCNT_dec(perl_exception); /* throw away all errors */
6119 RETVAL = (void *) blob;
6125 ###############################################################################
6129 # G e t A u t h e n t i c M e t a c o n t e n t #
6133 ###############################################################################
6137 GetAuthenticMetacontent(ref,...)
6138 Image::Magick ref = NO_INIT
6140 getauthenticmetacontent = 1
6161 PERL_UNUSED_VAR(ref);
6162 PERL_UNUSED_VAR(ix);
6163 exception=AcquireExceptionInfo();
6164 perl_exception=newSVpv("",0);
6165 if (sv_isobject(ST(0)) == 0)
6167 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6171 reference=SvRV(ST(0));
6173 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6174 if (image == (Image *) NULL)
6176 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6181 blob=(void *) GetAuthenticMetacontent(image);
6182 if (blob != (void *) NULL)
6186 InheritPerlException(exception,perl_exception);
6187 exception=DestroyExceptionInfo(exception);
6188 SvREFCNT_dec(perl_exception); /* throw away all errors */
6197 ###############################################################################
6201 # G e t V i r t u a l M e t a c o n t e n t #
6205 ###############################################################################
6209 GetVirtualMetacontent(ref,...)
6210 Image::Magick ref = NO_INIT
6212 getvirtualmetacontent = 1
6231 PERL_UNUSED_VAR(ref);
6232 PERL_UNUSED_VAR(ix);
6233 exception=AcquireExceptionInfo();
6234 perl_exception=newSVpv("",0);
6235 if (sv_isobject(ST(0)) == 0)
6237 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6241 reference=SvRV(ST(0));
6243 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6244 if (image == (Image *) NULL)
6246 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6251 blob=(void *) GetVirtualMetacontent(image);
6252 if (blob != (void *) NULL)
6256 InheritPerlException(exception,perl_exception);
6257 exception=DestroyExceptionInfo(exception);
6258 SvREFCNT_dec(perl_exception); /* throw away all errors */
6267 ###############################################################################
6271 # H i s t o g r a m #
6275 ###############################################################################
6280 Image::Magick ref=NO_INIT
6291 message[MagickPathExtent];
6318 PERL_UNUSED_VAR(ref);
6319 PERL_UNUSED_VAR(ix);
6320 exception=AcquireExceptionInfo();
6321 perl_exception=newSVpv("",0);
6323 if (sv_isobject(ST(0)) == 0)
6325 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6329 reference=SvRV(ST(0));
6332 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6333 if (image == (Image *) NULL)
6335 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6340 for ( ; image; image=image->next)
6342 histogram=GetImageHistogram(image,&number_colors,exception);
6343 if (histogram == (PixelInfo *) NULL)
6345 count+=(ssize_t) number_colors;
6347 for (i=0; i < (ssize_t) number_colors; i++)
6349 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6351 PUSHs(sv_2mortal(newSVpv(message,0)));
6352 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6353 histogram[i].green);
6354 PUSHs(sv_2mortal(newSVpv(message,0)));
6355 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6357 PUSHs(sv_2mortal(newSVpv(message,0)));
6358 if (image->colorspace == CMYKColorspace)
6360 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6361 histogram[i].black);
6362 PUSHs(sv_2mortal(newSVpv(message,0)));
6364 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6365 histogram[i].alpha);
6366 PUSHs(sv_2mortal(newSVpv(message,0)));
6367 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6368 histogram[i].count);
6369 PUSHs(sv_2mortal(newSVpv(message,0)));
6371 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6375 InheritPerlException(exception,perl_exception);
6376 exception=DestroyExceptionInfo(exception);
6377 SvREFCNT_dec(perl_exception);
6381 ###############################################################################
6389 ###############################################################################
6394 Image::Magick ref=NO_INIT
6418 register const Quantum
6432 *reference; /* reference is the SV* of ref=SvIV(reference) */
6434 PERL_UNUSED_VAR(ref);
6435 PERL_UNUSED_VAR(ix);
6436 exception=AcquireExceptionInfo();
6437 perl_exception=newSVpv("",0);
6438 reference=SvRV(ST(0));
6439 av=(AV *) reference;
6440 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6442 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6443 if (image == (Image *) NULL)
6445 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6449 normalize=MagickTrue;
6452 region.width=image->columns;
6455 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6456 for (i=2; i < items; i+=2)
6458 attribute=(char *) SvPV(ST(i-1),na);
6464 if (LocaleCompare(attribute,"channel") == 0)
6469 option=ParseChannelOption(SvPV(ST(i),na));
6472 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6476 (void) SetPixelChannelMask(image,(ChannelType) option);
6479 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6486 if (LocaleCompare(attribute,"geometry") == 0)
6488 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6491 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6498 if (LocaleCompare(attribute,"normalize") == 0)
6500 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6504 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6508 normalize=option != 0 ? MagickTrue : MagickFalse;
6511 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6518 if (LocaleCompare(attribute,"x") == 0)
6520 region.x=SvIV(ST(i));
6523 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6530 if (LocaleCompare(attribute,"y") == 0)
6532 region.y=SvIV(ST(i));
6535 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6547 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6548 if (p == (const Quantum *) NULL)
6556 if (normalize != MagickFalse)
6557 scale=1.0/QuantumRange;
6558 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6559 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6560 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6561 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6562 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6563 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6564 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6565 (image->colorspace == CMYKColorspace))
6566 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6567 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6568 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6572 InheritPerlException(exception,perl_exception);
6573 exception=DestroyExceptionInfo(exception);
6574 SvREFCNT_dec(perl_exception);
6578 ###############################################################################
6582 # G e t P i x e l s #
6586 ###############################################################################
6591 Image::Magick ref=NO_INIT
6630 *reference; /* reference is the SV* of ref=SvIV(reference) */
6632 PERL_UNUSED_VAR(ref);
6633 PERL_UNUSED_VAR(ix);
6634 exception=AcquireExceptionInfo();
6635 perl_exception=newSVpv("",0);
6636 reference=SvRV(ST(0));
6637 av=(AV *) reference;
6638 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6640 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6641 if (image == (Image *) NULL)
6643 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6648 if (image->alpha_trait != UndefinedPixelTrait)
6650 if (image->colorspace == CMYKColorspace)
6653 if (image->alpha_trait != UndefinedPixelTrait)
6656 normalize=MagickFalse;
6659 region.width=image->columns;
6662 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6663 for (i=2; i < items; i+=2)
6665 attribute=(char *) SvPV(ST(i-1),na);
6671 if (LocaleCompare(attribute,"geometry") == 0)
6673 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6676 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6683 if (LocaleCompare(attribute,"height") == 0)
6685 region.height=SvIV(ST(i));
6688 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6695 if (LocaleCompare(attribute,"map") == 0)
6700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6707 if (LocaleCompare(attribute,"normalize") == 0)
6709 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6713 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6717 normalize=option != 0 ? MagickTrue : MagickFalse;
6720 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6727 if (LocaleCompare(attribute,"width") == 0)
6729 region.width=SvIV(ST(i));
6732 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6739 if (LocaleCompare(attribute,"x") == 0)
6741 region.x=SvIV(ST(i));
6744 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6751 if (LocaleCompare(attribute,"y") == 0)
6753 region.y=SvIV(ST(i));
6756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6762 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6768 if (normalize != MagickFalse)
6773 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6774 region.height*sizeof(*pixels));
6775 if (pixels == (float *) NULL)
6777 ThrowPerlException(exception,ResourceLimitError,
6778 "MemoryAllocationFailed",PackageName);
6781 status=ExportImagePixels(image,region.x,region.y,region.width,
6782 region.height,map,FloatPixel,pixels,exception);
6783 if (status == MagickFalse)
6787 EXTEND(sp,strlen(map)*region.width*region.height);
6788 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6789 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6791 pixels=(float *) RelinquishMagickMemory(pixels);
6798 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6799 region.height*sizeof(*pixels));
6800 if (pixels == (Quantum *) NULL)
6802 ThrowPerlException(exception,ResourceLimitError,
6803 "MemoryAllocationFailed",PackageName);
6806 status=ExportImagePixels(image,region.x,region.y,region.width,
6807 region.height,map,QuantumPixel,pixels,exception);
6808 if (status == MagickFalse)
6812 EXTEND(sp,strlen(map)*region.width*region.height);
6813 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6814 PUSHs(sv_2mortal(newSViv(pixels[i])));
6816 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6820 InheritPerlException(exception,perl_exception);
6821 exception=DestroyExceptionInfo(exception);
6822 SvREFCNT_dec(perl_exception);
6826 ###############################################################################
6830 # I m a g e T o B l o b #
6834 ###############################################################################
6838 ImageToBlob(ref,...)
6839 Image::Magick ref=NO_INIT
6848 filename[MagickPathExtent];
6877 PERL_UNUSED_VAR(ref);
6878 PERL_UNUSED_VAR(ix);
6879 exception=AcquireExceptionInfo();
6880 perl_exception=newSVpv("",0);
6881 package_info=(struct PackageInfo *) NULL;
6882 if (sv_isobject(ST(0)) == 0)
6884 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6888 reference=SvRV(ST(0));
6889 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6890 if (image == (Image *) NULL)
6892 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6896 package_info=ClonePackageInfo(info,exception);
6897 for (i=2; i < items; i+=2)
6898 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6899 (void) CopyMagickString(filename,package_info->image_info->filename,
6902 for (next=image; next; next=next->next)
6904 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6905 next->scene=scene++;
6907 SetImageInfo(package_info->image_info,(unsigned int)
6908 GetImageListLength(image),exception);
6909 EXTEND(sp,(ssize_t) GetImageListLength(image));
6910 for ( ; image; image=image->next)
6913 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6914 if (blob != (char *) NULL)
6916 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6917 blob=(unsigned char *) RelinquishMagickMemory(blob);
6919 if (package_info->image_info->adjoin)
6924 if (package_info != (struct PackageInfo *) NULL)
6925 DestroyPackageInfo(package_info);
6926 InheritPerlException(exception,perl_exception);
6927 exception=DestroyExceptionInfo(exception);
6928 SvREFCNT_dec(perl_exception); /* throw away all errors */
6932 ###############################################################################
6940 ###############################################################################
6945 Image::Magick ref=NO_INIT
6949 OptimizeImageLayers = 3
6951 optimizeimagelayers = 5
6993 PERL_UNUSED_VAR(ref);
6994 PERL_UNUSED_VAR(ix);
6995 exception=AcquireExceptionInfo();
6996 perl_exception=newSVpv("",0);
6998 if (sv_isobject(ST(0)) == 0)
7000 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7004 reference=SvRV(ST(0));
7005 hv=SvSTASH(reference);
7007 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7009 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7010 if (image == (Image *) NULL)
7012 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7016 compose=image->compose;
7017 method=OptimizeLayer;
7018 for (i=2; i < items; i+=2)
7020 attribute=(char *) SvPV(ST(i-1),na);
7026 if (LocaleCompare(attribute,"compose") == 0)
7028 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7029 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7032 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7036 compose=(CompositeOperator) sp;
7039 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7046 if (LocaleCompare(attribute,"method") == 0)
7048 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7052 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7056 method=(LayerMethod) option;
7059 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7065 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7071 layers=(Image *) NULL;
7074 case CompareAnyLayer:
7075 case CompareClearLayer:
7076 case CompareOverlayLayer:
7079 layers=CompareImagesLayers(image,method,exception);
7086 layers=MergeImageLayers(image,method,exception);
7091 layers=DisposeImages(image,exception);
7094 case OptimizeImageLayer:
7096 layers=OptimizeImageLayers(image,exception);
7099 case OptimizePlusLayer:
7101 layers=OptimizePlusImageLayers(image,exception);
7104 case OptimizeTransLayer:
7106 OptimizeImageTransparency(image,exception);
7109 case RemoveDupsLayer:
7111 RemoveDuplicateLayers(&image,exception);
7114 case RemoveZeroLayer:
7116 RemoveZeroDelayLayers(&image,exception);
7125 General Purpose, GIF Animation Optimizer.
7127 layers=CoalesceImages(image,exception);
7128 if (layers == (Image *) NULL)
7131 layers=OptimizeImageLayers(image,exception);
7132 if (layers == (Image *) NULL)
7134 image=DestroyImageList(image);
7136 layers=(Image *) NULL;
7137 OptimizeImageTransparency(image,exception);
7138 quantize_info=AcquireQuantizeInfo(info->image_info);
7139 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7140 quantize_info=DestroyQuantizeInfo(quantize_info);
7143 case CompositeLayer:
7152 Split image sequence at the first 'NULL:' image.
7155 while (source != (Image *) NULL)
7157 source=GetNextImageInList(source);
7158 if ((source != (Image *) NULL) &&
7159 (LocaleCompare(source->magick,"NULL") == 0))
7162 if (source != (Image *) NULL)
7164 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7165 (GetNextImageInList(source) == (Image *) NULL))
7166 source=(Image *) NULL;
7170 Separate the two lists, junk the null: image.
7172 source=SplitImageList(source->previous);
7173 DeleteImageFromList(&source);
7176 if (source == (Image *) NULL)
7178 (void) ThrowMagickException(exception,GetMagickModule(),
7179 OptionError,"MissingNullSeparator","layers Composite");
7183 Adjust offset with gravity and virtual canvas.
7185 SetGeometry(image,&geometry);
7186 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7187 geometry.width=source->page.width != 0 ? source->page.width :
7189 geometry.height=source->page.height != 0 ? source->page.height :
7191 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7192 image->columns,image->page.height != 0 ? image->page.height :
7193 image->rows,image->gravity,&geometry);
7194 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7195 source=DestroyImageList(source);
7199 if (layers != (Image *) NULL)
7202 image=CloneImage(image,0,0,MagickTrue,exception);
7203 if (image == (Image *) NULL)
7205 for ( ; image; image=image->next)
7207 AddImageToRegistry(sv,image);
7209 av_push(av,sv_bless(rv,hv));
7212 exception=DestroyExceptionInfo(exception);
7214 SvREFCNT_dec(perl_exception);
7218 InheritPerlException(exception,perl_exception);
7219 exception=DestroyExceptionInfo(exception);
7220 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7221 SvPOK_on(perl_exception);
7222 ST(0)=sv_2mortal(perl_exception);
7227 ###############################################################################
7231 # M a g i c k T o M i m e #
7235 ###############################################################################
7239 MagickToMime(ref,name)
7240 Image::Magick ref=NO_INIT
7249 PERL_UNUSED_VAR(ref);
7250 PERL_UNUSED_VAR(ix);
7251 mime=MagickToMime(name);
7252 RETVAL=newSVpv(mime,0);
7253 mime=(char *) RelinquishMagickMemory(mime);
7259 ###############################################################################
7267 ###############################################################################
7272 Image::Magick ref=NO_INIT
7309 MedianConvolveImage = 36
7315 ReduceNoiseImage = 42
7341 ColorFloodfillImage= 68
7347 CycleColormapImage = 74
7357 MatteFloodfillImage= 84
7365 NumberColorsImage = 92
7375 SignatureImage = 102
7385 TransparentImage = 112
7387 ThresholdImage = 114
7401 DeconstructImage = 130
7403 GaussianBlurImage = 132
7409 UnsharpMaskImage = 138
7411 MotionBlurImage = 140
7413 OrderedDitherImage = 142
7420 AffineTransform = 149
7421 AffineTransformImage = 150
7423 DifferenceImage = 152
7424 AdaptiveThreshold = 153
7425 AdaptiveThresholdImage = 154
7430 BlackThreshold = 159
7431 BlackThresholdImage= 160
7432 WhiteThreshold = 161
7433 WhiteThresholdImage= 162
7434 RotationalBlur = 163
7435 RotationalBlurImage= 164
7437 ThumbnailImage = 166
7447 PosterizeImage = 176
7453 SepiaToneImage = 182
7454 SigmoidalContrast = 183
7455 SigmoidalContrastImage = 184
7460 ContrastStretch = 189
7461 ContrastStretchImage = 190
7466 AdaptiveSharpen = 195
7467 AdaptiveSharpenImage = 196
7469 TransposeImage = 198
7471 TransverseImage = 200
7473 AutoOrientImage = 202
7475 AdaptiveBlurImage = 204
7479 UniqueColorsImage = 208
7480 AdaptiveResize = 209
7481 AdaptiveResizeImage= 210
7485 LinearStretchImage = 214
7487 ColorMatrixImage = 216
7492 FloodfillPaint = 221
7493 FloodfillPaintImage= 222
7499 LiquidRescaleImage = 228
7509 SparseColorImage = 238
7513 SelectiveBlurImage = 242
7517 BlueShiftImage = 246
7518 ForwardFourierTransform = 247
7519 ForwardFourierTransformImage = 248
7520 InverseFourierTransform = 249
7521 InverseFourierTransformImage = 250
7522 ColorDecisionList = 251
7523 ColorDecisionListImage = 252
7525 AutoGammaImage = 254
7527 AutoLevelImage = 256
7529 LevelImageColors = 258
7532 BrightnessContrast = 261
7533 BrightnessContrastImage = 262
7535 MorphologyImage = 264
7541 StatisticImage = 270
7543 PerceptibleImage = 272
7547 GrayscaleImage = 276
7549 CannyEdgeImage = 279
7551 HoughLineImage = 281
7553 MeanShiftImage = 283
7556 ConnectedComponent = 286
7557 ConnectedComponentImage = 287
7559 CopyImagePixels = 289
7568 attribute_flag[MaxArguments],
7569 message[MagickPathExtent];
7630 argument_list[MaxArguments];
7632 PERL_UNUSED_VAR(ref);
7633 PERL_UNUSED_VAR(ix);
7634 exception=AcquireExceptionInfo();
7635 perl_exception=newSVpv("",0);
7636 reference_vector=NULL;
7640 if (sv_isobject(ST(0)) == 0)
7642 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7646 reference=SvRV(ST(0));
7647 region_info.width=0;
7648 region_info.height=0;
7651 region_image=(Image *) NULL;
7652 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7653 if (ix && (ix != 666))
7656 Called as Method(...)
7659 rp=(&Methods[ix-1]);
7665 Called as Mogrify("Method",...)
7667 attribute=(char *) SvPV(ST(1),na);
7670 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7671 attribute=(char *) SvPV(ST(2),na);
7674 for (rp=Methods; ; rp++)
7676 if (rp >= EndOf(Methods))
7678 ThrowPerlException(exception,OptionError,
7679 "UnrecognizedPerlMagickMethod",attribute);
7682 if (strEQcase(attribute,rp->name))
7688 if (image == (Image *) NULL)
7690 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7693 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7694 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7695 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7712 pp=(Arguments *) NULL;
7720 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7722 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7724 if (strEQcase(attribute,qq->method) > ssize_test)
7727 ssize_test=strEQcase(attribute,qq->method);
7730 if (pp == (Arguments *) NULL)
7732 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7734 goto continue_outer_loop;
7736 al=(&argument_list[pp-rp->arguments]);
7739 case ArrayReference:
7741 if (SvTYPE(sv) != SVt_RV)
7743 (void) FormatLocaleString(message,MagickPathExtent,
7744 "invalid %.60s value",pp->method);
7745 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7746 goto continue_outer_loop;
7748 al->array_reference=SvRV(sv);
7753 al->real_reference=SvNV(sv);
7758 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7761 case ImageReference:
7763 if (!sv_isobject(sv) ||
7764 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7765 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7767 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7773 case IntegerReference:
7775 al->integer_reference=SvIV(sv);
7778 case StringReference:
7780 al->string_reference=(char *) SvPV(sv,al->length);
7781 if (sv_isobject(sv))
7782 al->image_reference=SetupList(aTHX_ SvRV(sv),
7783 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7789 Is a string; look up name.
7791 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7793 al->string_reference=(char *) SvPV(sv,al->length);
7794 al->integer_reference=(-1);
7797 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7798 MagickFalse,SvPV(sv,na));
7799 if (pp->type == MagickChannelOptions)
7800 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7801 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7803 (void) FormatLocaleString(message,MagickPathExtent,
7804 "invalid %.60s value",pp->method);
7805 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7806 goto continue_outer_loop;
7811 attribute_flag[pp-rp->arguments]++;
7812 continue_outer_loop: ;
7814 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7815 pv=reference_vector;
7816 SetGeometryInfo(&geometry_info);
7817 channel=DefaultChannels;
7818 for (next=image; next; next=next->next)
7821 SetGeometry(image,&geometry);
7822 if ((region_info.width*region_info.height) != 0)
7825 image=CropImage(image,®ion_info,exception);
7831 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) ix);
7832 ThrowPerlException(exception,OptionError,
7833 "UnrecognizedPerlMagickMethod",message);
7836 case 1: /* Comment */
7838 if (attribute_flag[0] == 0)
7839 argument_list[0].string_reference=(char *) NULL;
7840 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7841 info ? info->image_info : (ImageInfo *) NULL,image,
7842 argument_list[0].string_reference,exception),exception);
7847 if (attribute_flag[0] == 0)
7848 argument_list[0].string_reference=(char *) NULL;
7849 (void) SetImageProperty(image,"label",InterpretImageProperties(
7850 info ? info->image_info : (ImageInfo *) NULL,image,
7851 argument_list[0].string_reference,exception),exception);
7854 case 3: /* AddNoise */
7859 if (attribute_flag[0] == 0)
7860 argument_list[0].integer_reference=UniformNoise;
7862 if (attribute_flag[1] != 0)
7863 attenuate=argument_list[1].real_reference;
7864 if (attribute_flag[2] != 0)
7865 channel=(ChannelType) argument_list[2].integer_reference;
7866 channel_mask=SetImageChannelMask(image,channel);
7867 image=AddNoiseImage(image,(NoiseType)
7868 argument_list[0].integer_reference,attenuate,exception);
7869 if (image != (Image *) NULL)
7870 (void) SetImageChannelMask(image,channel_mask);
7873 case 4: /* Colorize */
7878 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7879 0,0,&target,exception);
7880 if (attribute_flag[0] != 0)
7881 (void) QueryColorCompliance(argument_list[0].string_reference,
7882 AllCompliance,&target,exception);
7883 if (attribute_flag[1] == 0)
7884 argument_list[1].string_reference="100%";
7885 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7889 case 5: /* Border */
7896 if (attribute_flag[0] != 0)
7897 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7898 &geometry,exception);
7899 if (attribute_flag[1] != 0)
7900 geometry.width=argument_list[1].integer_reference;
7901 if (attribute_flag[2] != 0)
7902 geometry.height=argument_list[2].integer_reference;
7903 if (attribute_flag[3] != 0)
7904 QueryColorCompliance(argument_list[3].string_reference,
7905 AllCompliance,&image->border_color,exception);
7906 if (attribute_flag[4] != 0)
7907 QueryColorCompliance(argument_list[4].string_reference,
7908 AllCompliance,&image->border_color,exception);
7909 if (attribute_flag[5] != 0)
7910 QueryColorCompliance(argument_list[5].string_reference,
7911 AllCompliance,&image->border_color,exception);
7912 compose=image->compose;
7913 if (attribute_flag[6] != 0)
7914 compose=(CompositeOperator) argument_list[6].integer_reference;
7915 image=BorderImage(image,&geometry,compose,exception);
7920 if (attribute_flag[0] != 0)
7922 flags=ParseGeometry(argument_list[0].string_reference,
7924 if ((flags & SigmaValue) == 0)
7925 geometry_info.sigma=1.0;
7927 if (attribute_flag[1] != 0)
7928 geometry_info.rho=argument_list[1].real_reference;
7929 if (attribute_flag[2] != 0)
7930 geometry_info.sigma=argument_list[2].real_reference;
7931 if (attribute_flag[3] != 0)
7932 channel=(ChannelType) argument_list[3].integer_reference;
7933 channel_mask=SetImageChannelMask(image,channel);
7934 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7936 if (image != (Image *) NULL)
7937 (void) SetImageChannelMask(image,channel_mask);
7942 if (attribute_flag[5] != 0)
7943 image->gravity=(GravityType) argument_list[5].integer_reference;
7944 if (attribute_flag[0] != 0)
7945 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7946 &geometry,exception);
7947 if (attribute_flag[1] != 0)
7948 geometry.width=argument_list[1].integer_reference;
7949 if (attribute_flag[2] != 0)
7950 geometry.height=argument_list[2].integer_reference;
7951 if (attribute_flag[3] != 0)
7952 geometry.x=argument_list[3].integer_reference;
7953 if (attribute_flag[4] != 0)
7954 geometry.y=argument_list[4].integer_reference;
7955 image=ChopImage(image,&geometry,exception);
7960 if (attribute_flag[6] != 0)
7961 image->gravity=(GravityType) argument_list[6].integer_reference;
7962 if (attribute_flag[0] != 0)
7963 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7964 &geometry,exception);
7965 if (attribute_flag[1] != 0)
7966 geometry.width=argument_list[1].integer_reference;
7967 if (attribute_flag[2] != 0)
7968 geometry.height=argument_list[2].integer_reference;
7969 if (attribute_flag[3] != 0)
7970 geometry.x=argument_list[3].integer_reference;
7971 if (attribute_flag[4] != 0)
7972 geometry.y=argument_list[4].integer_reference;
7973 if (attribute_flag[5] != 0)
7974 image->fuzz=StringToDoubleInterval(
7975 argument_list[5].string_reference,(double) QuantumRange+1.0);
7976 image=CropImage(image,&geometry,exception);
7979 case 9: /* Despeckle */
7981 image=DespeckleImage(image,exception);
7986 if (attribute_flag[0] != 0)
7987 geometry_info.rho=argument_list[0].real_reference;
7988 image=EdgeImage(image,geometry_info.rho,exception);
7991 case 11: /* Emboss */
7993 if (attribute_flag[0] != 0)
7995 flags=ParseGeometry(argument_list[0].string_reference,
7997 if ((flags & SigmaValue) == 0)
7998 geometry_info.sigma=1.0;
8000 if (attribute_flag[1] != 0)
8001 geometry_info.rho=argument_list[1].real_reference;
8002 if (attribute_flag[2] != 0)
8003 geometry_info.sigma=argument_list[2].real_reference;
8004 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8008 case 12: /* Enhance */
8010 image=EnhanceImage(image,exception);
8015 image=FlipImage(image,exception);
8020 image=FlopImage(image,exception);
8023 case 15: /* Frame */
8031 if (attribute_flag[0] != 0)
8033 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8034 &geometry,exception);
8035 frame_info.width=geometry.width;
8036 frame_info.height=geometry.height;
8037 frame_info.outer_bevel=geometry.x;
8038 frame_info.inner_bevel=geometry.y;
8040 if (attribute_flag[1] != 0)
8041 frame_info.width=argument_list[1].integer_reference;
8042 if (attribute_flag[2] != 0)
8043 frame_info.height=argument_list[2].integer_reference;
8044 if (attribute_flag[3] != 0)
8045 frame_info.inner_bevel=argument_list[3].integer_reference;
8046 if (attribute_flag[4] != 0)
8047 frame_info.outer_bevel=argument_list[4].integer_reference;
8048 if (attribute_flag[5] != 0)
8049 QueryColorCompliance(argument_list[5].string_reference,
8050 AllCompliance,&fill_color,exception);
8051 if (attribute_flag[6] != 0)
8052 QueryColorCompliance(argument_list[6].string_reference,
8053 AllCompliance,&fill_color,exception);
8054 frame_info.x=(ssize_t) frame_info.width;
8055 frame_info.y=(ssize_t) frame_info.height;
8056 frame_info.width=image->columns+2*frame_info.x;
8057 frame_info.height=image->rows+2*frame_info.y;
8058 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8059 image->matte_color=fill_color;
8060 compose=image->compose;
8061 if (attribute_flag[7] != 0)
8062 compose=(CompositeOperator) argument_list[7].integer_reference;
8063 image=FrameImage(image,&frame_info,compose,exception);
8066 case 16: /* Implode */
8068 PixelInterpolateMethod
8071 if (attribute_flag[0] == 0)
8072 argument_list[0].real_reference=0.5;
8073 method=UndefinedInterpolatePixel;
8074 if (attribute_flag[1] != 0)
8075 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8076 image=ImplodeImage(image,argument_list[0].real_reference,
8080 case 17: /* Magnify */
8082 image=MagnifyImage(image,exception);
8085 case 18: /* MedianFilter */
8087 if (attribute_flag[0] != 0)
8089 flags=ParseGeometry(argument_list[0].string_reference,
8091 if ((flags & SigmaValue) == 0)
8092 geometry_info.sigma=geometry_info.rho;
8094 if (attribute_flag[1] != 0)
8095 geometry_info.rho=argument_list[1].real_reference;
8096 if (attribute_flag[2] != 0)
8097 geometry_info.sigma=argument_list[2].real_reference;
8098 if (attribute_flag[3] != 0)
8099 channel=(ChannelType) argument_list[3].integer_reference;
8100 channel_mask=SetImageChannelMask(image,channel);
8101 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8102 (size_t) geometry_info.sigma,exception);
8103 if (image != (Image *) NULL)
8104 (void) SetImageChannelMask(image,channel_mask);
8107 case 19: /* Minify */
8109 image=MinifyImage(image,exception);
8112 case 20: /* OilPaint */
8114 if (attribute_flag[0] == 0)
8115 argument_list[0].real_reference=0.0;
8116 if (attribute_flag[1] == 0)
8117 argument_list[1].real_reference=1.0;
8118 image=OilPaintImage(image,argument_list[0].real_reference,
8119 argument_list[1].real_reference,exception);
8122 case 21: /* ReduceNoise */
8124 if (attribute_flag[0] != 0)
8126 flags=ParseGeometry(argument_list[0].string_reference,
8128 if ((flags & SigmaValue) == 0)
8129 geometry_info.sigma=1.0;
8131 if (attribute_flag[1] != 0)
8132 geometry_info.rho=argument_list[1].real_reference;
8133 if (attribute_flag[2] != 0)
8134 geometry_info.sigma=argument_list[2].real_reference;
8135 if (attribute_flag[3] != 0)
8136 channel=(ChannelType) argument_list[3].integer_reference;
8137 channel_mask=SetImageChannelMask(image,channel);
8138 image=StatisticImage(image,NonpeakStatistic,(size_t)
8139 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8140 if (image != (Image *) NULL)
8141 (void) SetImageChannelMask(image,channel_mask);
8146 if (attribute_flag[0] != 0)
8147 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8148 &geometry,exception);
8149 if (attribute_flag[1] != 0)
8150 geometry.x=argument_list[1].integer_reference;
8151 if (attribute_flag[2] != 0)
8152 geometry.y=argument_list[2].integer_reference;
8153 image=RollImage(image,geometry.x,geometry.y,exception);
8156 case 23: /* Rotate */
8158 if (attribute_flag[0] == 0)
8159 argument_list[0].real_reference=90.0;
8160 if (attribute_flag[1] != 0)
8162 QueryColorCompliance(argument_list[1].string_reference,
8163 AllCompliance,&image->background_color,exception);
8164 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8165 (image->alpha_trait == UndefinedPixelTrait))
8166 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8168 image=RotateImage(image,argument_list[0].real_reference,exception);
8171 case 24: /* Sample */
8173 if (attribute_flag[0] != 0)
8174 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8175 &geometry,exception);
8176 if (attribute_flag[1] != 0)
8177 geometry.width=argument_list[1].integer_reference;
8178 if (attribute_flag[2] != 0)
8179 geometry.height=argument_list[2].integer_reference;
8180 image=SampleImage(image,geometry.width,geometry.height,exception);
8183 case 25: /* Scale */
8185 if (attribute_flag[0] != 0)
8186 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8187 &geometry,exception);
8188 if (attribute_flag[1] != 0)
8189 geometry.width=argument_list[1].integer_reference;
8190 if (attribute_flag[2] != 0)
8191 geometry.height=argument_list[2].integer_reference;
8192 image=ScaleImage(image,geometry.width,geometry.height,exception);
8195 case 26: /* Shade */
8197 if (attribute_flag[0] != 0)
8199 flags=ParseGeometry(argument_list[0].string_reference,
8201 if ((flags & SigmaValue) == 0)
8202 geometry_info.sigma=0.0;
8204 if (attribute_flag[1] != 0)
8205 geometry_info.rho=argument_list[1].real_reference;
8206 if (attribute_flag[2] != 0)
8207 geometry_info.sigma=argument_list[2].real_reference;
8208 image=ShadeImage(image,
8209 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8210 geometry_info.rho,geometry_info.sigma,exception);
8213 case 27: /* Sharpen */
8215 if (attribute_flag[0] != 0)
8217 flags=ParseGeometry(argument_list[0].string_reference,
8219 if ((flags & SigmaValue) == 0)
8220 geometry_info.sigma=1.0;
8222 if (attribute_flag[1] != 0)
8223 geometry_info.rho=argument_list[1].real_reference;
8224 if (attribute_flag[2] != 0)
8225 geometry_info.sigma=argument_list[2].real_reference;
8226 if (attribute_flag[3] != 0)
8227 channel=(ChannelType) argument_list[3].integer_reference;
8228 channel_mask=SetImageChannelMask(image,channel);
8229 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8231 if (image != (Image *) NULL)
8232 (void) SetImageChannelMask(image,channel_mask);
8235 case 28: /* Shear */
8237 if (attribute_flag[0] != 0)
8239 flags=ParseGeometry(argument_list[0].string_reference,
8241 if ((flags & SigmaValue) == 0)
8242 geometry_info.sigma=geometry_info.rho;
8244 if (attribute_flag[1] != 0)
8245 geometry_info.rho=argument_list[1].real_reference;
8246 if (attribute_flag[2] != 0)
8247 geometry_info.sigma=argument_list[2].real_reference;
8248 if (attribute_flag[3] != 0)
8249 QueryColorCompliance(argument_list[3].string_reference,
8250 AllCompliance,&image->background_color,exception);
8251 if (attribute_flag[4] != 0)
8252 QueryColorCompliance(argument_list[4].string_reference,
8253 AllCompliance,&image->background_color,exception);
8254 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8258 case 29: /* Spread */
8260 PixelInterpolateMethod
8263 if (attribute_flag[0] == 0)
8264 argument_list[0].real_reference=1.0;
8265 method=UndefinedInterpolatePixel;
8266 if (attribute_flag[1] != 0)
8267 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8268 image=SpreadImage(image,argument_list[0].real_reference,method,
8272 case 30: /* Swirl */
8274 PixelInterpolateMethod
8277 if (attribute_flag[0] == 0)
8278 argument_list[0].real_reference=50.0;
8279 method=UndefinedInterpolatePixel;
8280 if (attribute_flag[1] != 0)
8281 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8282 image=SwirlImage(image,argument_list[0].real_reference,
8286 case 31: /* Resize */
8289 if (attribute_flag[0] != 0)
8290 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8291 &geometry,exception);
8292 if (attribute_flag[1] != 0)
8293 geometry.width=argument_list[1].integer_reference;
8294 if (attribute_flag[2] != 0)
8295 geometry.height=argument_list[2].integer_reference;
8296 if (attribute_flag[3] == 0)
8297 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8298 if (attribute_flag[4] != 0)
8299 SetImageArtifact(image,"filter:support",
8300 argument_list[4].string_reference);
8301 image=ResizeImage(image,geometry.width,geometry.height,
8302 (FilterTypes) argument_list[3].integer_reference,
8306 case 33: /* Annotate */
8311 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8313 if (attribute_flag[0] != 0)
8318 text=InterpretImageProperties(info ? info->image_info :
8319 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8321 (void) CloneString(&draw_info->text,text);
8322 text=DestroyString(text);
8324 if (attribute_flag[1] != 0)
8325 (void) CloneString(&draw_info->font,
8326 argument_list[1].string_reference);
8327 if (attribute_flag[2] != 0)
8328 draw_info->pointsize=argument_list[2].real_reference;
8329 if (attribute_flag[3] != 0)
8330 (void) CloneString(&draw_info->density,
8331 argument_list[3].string_reference);
8332 if (attribute_flag[4] != 0)
8333 (void) QueryColorCompliance(argument_list[4].string_reference,
8334 AllCompliance,&draw_info->undercolor,exception);
8335 if (attribute_flag[5] != 0)
8337 (void) QueryColorCompliance(argument_list[5].string_reference,
8338 AllCompliance,&draw_info->stroke,exception);
8339 if (argument_list[5].image_reference != (Image *) NULL)
8340 draw_info->stroke_pattern=CloneImage(
8341 argument_list[5].image_reference,0,0,MagickTrue,exception);
8343 if (attribute_flag[6] != 0)
8345 (void) QueryColorCompliance(argument_list[6].string_reference,
8346 AllCompliance,&draw_info->fill,exception);
8347 if (argument_list[6].image_reference != (Image *) NULL)
8348 draw_info->fill_pattern=CloneImage(
8349 argument_list[6].image_reference,0,0,MagickTrue,exception);
8351 if (attribute_flag[7] != 0)
8353 (void) CloneString(&draw_info->geometry,
8354 argument_list[7].string_reference);
8355 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8356 &geometry,exception);
8357 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8358 geometry_info.sigma=geometry_info.xi;
8360 if (attribute_flag[8] != 0)
8361 (void) QueryColorCompliance(argument_list[8].string_reference,
8362 AllCompliance,&draw_info->fill,exception);
8363 if (attribute_flag[11] != 0)
8364 draw_info->gravity=(GravityType)
8365 argument_list[11].integer_reference;
8366 if (attribute_flag[25] != 0)
8371 av=(AV *) argument_list[25].array_reference;
8372 if ((av_len(av) != 3) && (av_len(av) != 5))
8374 ThrowPerlException(exception,OptionError,
8375 "affine matrix must have 4 or 6 elements",PackageName);
8378 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8379 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8380 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8381 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8382 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8383 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8385 ThrowPerlException(exception,OptionError,
8386 "affine matrix is singular",PackageName);
8389 if (av_len(av) == 5)
8391 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8392 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8395 for (j=12; j < 17; j++)
8397 if (attribute_flag[j] == 0)
8399 value=argument_list[j].string_reference;
8400 angle=argument_list[j].real_reference;
8401 current=draw_info->affine;
8402 GetAffineMatrix(&affine);
8410 flags=ParseGeometry(value,&geometry_info);
8411 affine.tx=geometry_info.xi;
8412 affine.ty=geometry_info.psi;
8413 if ((flags & PsiValue) == 0)
8414 affine.ty=affine.tx;
8422 flags=ParseGeometry(value,&geometry_info);
8423 affine.sx=geometry_info.rho;
8424 affine.sy=geometry_info.sigma;
8425 if ((flags & SigmaValue) == 0)
8426 affine.sy=affine.sx;
8436 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8437 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8438 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8439 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8447 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8455 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8459 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8460 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8461 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8462 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8463 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8465 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8468 if (attribute_flag[9] == 0)
8469 argument_list[9].real_reference=0.0;
8470 if (attribute_flag[10] == 0)
8471 argument_list[10].real_reference=0.0;
8472 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8475 geometry[MagickPathExtent];
8477 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8478 (double) argument_list[9].real_reference+draw_info->affine.tx,
8479 (double) argument_list[10].real_reference+draw_info->affine.ty);
8480 (void) CloneString(&draw_info->geometry,geometry);
8482 if (attribute_flag[17] != 0)
8483 draw_info->stroke_width=argument_list[17].real_reference;
8484 if (attribute_flag[18] != 0)
8486 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8487 MagickTrue : MagickFalse;
8488 draw_info->stroke_antialias=draw_info->text_antialias;
8490 if (attribute_flag[19] != 0)
8491 (void) CloneString(&draw_info->family,
8492 argument_list[19].string_reference);
8493 if (attribute_flag[20] != 0)
8494 draw_info->style=(StyleType) argument_list[20].integer_reference;
8495 if (attribute_flag[21] != 0)
8496 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8497 if (attribute_flag[22] != 0)
8498 draw_info->weight=argument_list[22].integer_reference;
8499 if (attribute_flag[23] != 0)
8500 draw_info->align=(AlignType) argument_list[23].integer_reference;
8501 if (attribute_flag[24] != 0)
8502 (void) CloneString(&draw_info->encoding,
8503 argument_list[24].string_reference);
8504 if (attribute_flag[25] != 0)
8505 draw_info->fill_pattern=CloneImage(
8506 argument_list[25].image_reference,0,0,MagickTrue,exception);
8507 if (attribute_flag[26] != 0)
8508 draw_info->fill_pattern=CloneImage(
8509 argument_list[26].image_reference,0,0,MagickTrue,exception);
8510 if (attribute_flag[27] != 0)
8511 draw_info->stroke_pattern=CloneImage(
8512 argument_list[27].image_reference,0,0,MagickTrue,exception);
8513 if (attribute_flag[29] != 0)
8514 draw_info->kerning=argument_list[29].real_reference;
8515 if (attribute_flag[30] != 0)
8516 draw_info->interline_spacing=argument_list[30].real_reference;
8517 if (attribute_flag[31] != 0)
8518 draw_info->interword_spacing=argument_list[31].real_reference;
8519 if (attribute_flag[32] != 0)
8520 draw_info->direction=(DirectionType)
8521 argument_list[32].integer_reference;
8522 (void) AnnotateImage(image,draw_info,exception);
8523 draw_info=DestroyDrawInfo(draw_info);
8526 case 34: /* ColorFloodfill */
8537 draw_info=CloneDrawInfo(info ? info->image_info :
8538 (ImageInfo *) NULL,(DrawInfo *) NULL);
8539 if (attribute_flag[0] != 0)
8540 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8541 &geometry,exception);
8542 if (attribute_flag[1] != 0)
8543 geometry.x=argument_list[1].integer_reference;
8544 if (attribute_flag[2] != 0)
8545 geometry.y=argument_list[2].integer_reference;
8546 if (attribute_flag[3] != 0)
8547 (void) QueryColorCompliance(argument_list[3].string_reference,
8548 AllCompliance,&draw_info->fill,exception);
8549 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8550 geometry.x,geometry.y,&target,exception);
8552 if (attribute_flag[4] != 0)
8554 QueryColorCompliance(argument_list[4].string_reference,
8555 AllCompliance,&target,exception);
8558 if (attribute_flag[5] != 0)
8559 image->fuzz=StringToDoubleInterval(
8560 argument_list[5].string_reference,(double) QuantumRange+1.0);
8561 if (attribute_flag[6] != 0)
8562 invert=(MagickBooleanType) argument_list[6].integer_reference;
8563 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8564 geometry.y,invert,exception);
8565 draw_info=DestroyDrawInfo(draw_info);
8568 case 35: /* Composite */
8571 composite_geometry[MagickPathExtent];
8580 compose=OverCompositeOp;
8581 if (attribute_flag[0] != 0)
8582 composite_image=argument_list[0].image_reference;
8585 ThrowPerlException(exception,OptionError,
8586 "CompositeImageRequired",PackageName);
8590 Parameter Handling used for BOTH normal and tiled composition.
8592 if (attribute_flag[1] != 0) /* compose */
8593 compose=(CompositeOperator) argument_list[1].integer_reference;
8594 if (attribute_flag[6] != 0) /* opacity */
8596 if (compose != DissolveCompositeOp)
8597 (void) SetImageAlpha(composite_image,(Quantum)
8598 StringToDoubleInterval(argument_list[6].string_reference,
8599 (double) QuantumRange+1.0),exception);
8621 Handle dissolve composite operator (patch by
8624 (void) CloneString(&image->geometry,
8625 argument_list[6].string_reference);
8626 opacity=(Quantum) StringToDoubleInterval(
8627 argument_list[6].string_reference,(double) QuantumRange+
8629 if (composite_image->alpha_trait != UndefinedPixelTrait)
8630 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8631 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8632 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8634 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8635 composite_image->columns,1,exception);
8636 for (x=0; x < (ssize_t) composite_image->columns; x++)
8638 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8639 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8641 q+=GetPixelChannels(composite_image);
8643 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8644 if (sync == MagickFalse)
8647 composite_view=DestroyCacheView(composite_view);
8650 if (attribute_flag[9] != 0) /* "color=>" */
8651 QueryColorCompliance(argument_list[9].string_reference,
8652 AllCompliance,&composite_image->background_color,exception);
8653 if (attribute_flag[12] != 0) /* "interpolate=>" */
8654 image->interpolate=(PixelInterpolateMethod)
8655 argument_list[12].integer_reference;
8656 if (attribute_flag[13] != 0) /* "args=>" */
8657 (void) SetImageArtifact(composite_image,"compose:args",
8658 argument_list[13].string_reference);
8659 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8660 (void) SetImageArtifact(composite_image,"compose:args",
8661 argument_list[14].string_reference);
8662 clip_to_self=MagickTrue;
8663 if (attribute_flag[15] != 0)
8664 clip_to_self=(MagickBooleanType)
8665 argument_list[15].integer_reference;
8667 Tiling Composition (with orthogonal rotate).
8669 rotate_image=(Image *) NULL;
8670 if (attribute_flag[8] != 0) /* "rotate=>" */
8675 rotate_image=RotateImage(composite_image,
8676 argument_list[8].real_reference,exception);
8677 if (rotate_image == (Image *) NULL)
8680 if ((attribute_flag[7] != 0) &&
8681 (argument_list[7].integer_reference != 0)) /* tile */
8688 Tile the composite image.
8690 if (attribute_flag[8] != 0) /* "tile=>" */
8691 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8694 (void) SetImageArtifact(composite_image,
8695 "compose:outside-overlay","false");
8696 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8697 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8699 if (attribute_flag[8] != 0) /* rotate */
8700 (void) CompositeImage(image,rotate_image,compose,
8701 MagickTrue,x,y,exception);
8703 (void) CompositeImage(image,composite_image,compose,
8704 MagickTrue,x,y,exception);
8706 if (attribute_flag[8] != 0) /* rotate */
8707 rotate_image=DestroyImage(rotate_image);
8711 Parameter Handling used used ONLY for normal composition.
8713 if (attribute_flag[5] != 0) /* gravity */
8714 image->gravity=(GravityType) argument_list[5].integer_reference;
8715 if (attribute_flag[2] != 0) /* geometry offset */
8717 SetGeometry(image,&geometry);
8718 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8720 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8723 if (attribute_flag[3] != 0) /* x offset */
8724 geometry.x=argument_list[3].integer_reference;
8725 if (attribute_flag[4] != 0) /* y offset */
8726 geometry.y=argument_list[4].integer_reference;
8727 if (attribute_flag[10] != 0) /* mask */
8729 if ((image->compose == DisplaceCompositeOp) ||
8730 (image->compose == DistortCompositeOp))
8733 Merge Y displacement into X displacement image.
8735 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8737 (void) CompositeImage(composite_image,
8738 argument_list[10].image_reference,CopyGreenCompositeOp,
8739 MagickTrue,0,0,exception);
8747 Set a blending mask for the composition.
8749 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8750 MagickTrue,exception);
8751 (void) SetImageMask(composite_image,mask_image,exception);
8752 mask_image=DestroyImage(mask_image);
8755 if (attribute_flag[11] != 0) /* channel */
8756 channel=(ChannelType) argument_list[11].integer_reference;
8758 Composite two images (normal composition).
8760 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8761 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8762 (double) composite_image->rows,(double) geometry.x,(double)
8764 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8766 channel_mask=SetImageChannelMask(image,channel);
8767 if (attribute_flag[8] == 0) /* no rotate */
8768 CompositeImage(image,composite_image,compose,clip_to_self,
8769 geometry.x,geometry.y,exception);
8773 Position adjust rotated image then composite.
8775 geometry.x-=(ssize_t) (rotate_image->columns-
8776 composite_image->columns)/2;
8777 geometry.y-=(ssize_t) (rotate_image->rows-
8778 composite_image->rows)/2;
8779 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8780 geometry.y,exception);
8781 rotate_image=DestroyImage(rotate_image);
8783 if (attribute_flag[10] != 0) /* mask */
8785 if ((image->compose == DisplaceCompositeOp) ||
8786 (image->compose == DistortCompositeOp))
8787 composite_image=DestroyImage(composite_image);
8789 (void) SetImageMask(image,(Image *) NULL,exception);
8791 (void) SetImageChannelMask(image,channel_mask);
8794 case 36: /* Contrast */
8796 if (attribute_flag[0] == 0)
8797 argument_list[0].integer_reference=0;
8798 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8799 MagickTrue : MagickFalse,exception);
8802 case 37: /* CycleColormap */
8804 if (attribute_flag[0] == 0)
8805 argument_list[0].integer_reference=6;
8806 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8815 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8817 (void) CloneString(&draw_info->primitive,"point");
8818 if (attribute_flag[0] != 0)
8820 if (argument_list[0].integer_reference < 0)
8821 (void) CloneString(&draw_info->primitive,
8822 argument_list[0].string_reference);
8824 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8825 MagickPrimitiveOptions,argument_list[0].integer_reference));
8827 if (attribute_flag[1] != 0)
8829 if (LocaleCompare(draw_info->primitive,"path") == 0)
8831 (void) ConcatenateString(&draw_info->primitive," '");
8832 ConcatenateString(&draw_info->primitive,
8833 argument_list[1].string_reference);
8834 (void) ConcatenateString(&draw_info->primitive,"'");
8838 (void) ConcatenateString(&draw_info->primitive," ");
8839 ConcatenateString(&draw_info->primitive,
8840 argument_list[1].string_reference);
8843 if (attribute_flag[2] != 0)
8845 (void) ConcatenateString(&draw_info->primitive," ");
8846 (void) ConcatenateString(&draw_info->primitive,
8847 CommandOptionToMnemonic(MagickMethodOptions,
8848 argument_list[2].integer_reference));
8850 if (attribute_flag[3] != 0)
8852 (void) QueryColorCompliance(argument_list[3].string_reference,
8853 AllCompliance,&draw_info->stroke,exception);
8854 if (argument_list[3].image_reference != (Image *) NULL)
8855 draw_info->stroke_pattern=CloneImage(
8856 argument_list[3].image_reference,0,0,MagickTrue,exception);
8858 if (attribute_flag[4] != 0)
8860 (void) QueryColorCompliance(argument_list[4].string_reference,
8861 AllCompliance,&draw_info->fill,exception);
8862 if (argument_list[4].image_reference != (Image *) NULL)
8863 draw_info->fill_pattern=CloneImage(
8864 argument_list[4].image_reference,0,0,MagickTrue,exception);
8866 if (attribute_flag[5] != 0)
8867 draw_info->stroke_width=argument_list[5].real_reference;
8868 if (attribute_flag[6] != 0)
8869 (void) CloneString(&draw_info->font,
8870 argument_list[6].string_reference);
8871 if (attribute_flag[7] != 0)
8872 (void) QueryColorCompliance(argument_list[7].string_reference,
8873 AllCompliance,&draw_info->border_color,exception);
8874 if (attribute_flag[8] != 0)
8875 draw_info->affine.tx=argument_list[8].real_reference;
8876 if (attribute_flag[9] != 0)
8877 draw_info->affine.ty=argument_list[9].real_reference;
8878 if (attribute_flag[20] != 0)
8883 av=(AV *) argument_list[20].array_reference;
8884 if ((av_len(av) != 3) && (av_len(av) != 5))
8886 ThrowPerlException(exception,OptionError,
8887 "affine matrix must have 4 or 6 elements",PackageName);
8890 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8891 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8892 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8893 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8894 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8895 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8897 ThrowPerlException(exception,OptionError,
8898 "affine matrix is singular",PackageName);
8901 if (av_len(av) == 5)
8903 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8904 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8907 for (j=10; j < 15; j++)
8909 if (attribute_flag[j] == 0)
8911 value=argument_list[j].string_reference;
8912 angle=argument_list[j].real_reference;
8913 current=draw_info->affine;
8914 GetAffineMatrix(&affine);
8922 flags=ParseGeometry(value,&geometry_info);
8923 affine.tx=geometry_info.xi;
8924 affine.ty=geometry_info.psi;
8925 if ((flags & PsiValue) == 0)
8926 affine.ty=affine.tx;
8934 flags=ParseGeometry(value,&geometry_info);
8935 affine.sx=geometry_info.rho;
8936 affine.sy=geometry_info.sigma;
8937 if ((flags & SigmaValue) == 0)
8938 affine.sy=affine.sx;
8948 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8949 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8950 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8951 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8959 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8967 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8971 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8972 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8973 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8974 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8975 draw_info->affine.tx=
8976 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8977 draw_info->affine.ty=
8978 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8980 if (attribute_flag[15] != 0)
8981 draw_info->fill_pattern=CloneImage(
8982 argument_list[15].image_reference,0,0,MagickTrue,exception);
8983 if (attribute_flag[16] != 0)
8984 draw_info->pointsize=argument_list[16].real_reference;
8985 if (attribute_flag[17] != 0)
8987 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8988 ? MagickTrue : MagickFalse;
8989 draw_info->text_antialias=draw_info->stroke_antialias;
8991 if (attribute_flag[18] != 0)
8992 (void) CloneString(&draw_info->density,
8993 argument_list[18].string_reference);
8994 if (attribute_flag[19] != 0)
8995 draw_info->stroke_width=argument_list[19].real_reference;
8996 if (attribute_flag[21] != 0)
8997 draw_info->dash_offset=argument_list[21].real_reference;
8998 if (attribute_flag[22] != 0)
9003 av=(AV *) argument_list[22].array_reference;
9004 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9005 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9006 if (draw_info->dash_pattern != (double *) NULL)
9008 for (i=0; i <= av_len(av); i++)
9009 draw_info->dash_pattern[i]=(double)
9010 SvNV(*(av_fetch(av,i,0)));
9011 draw_info->dash_pattern[i]=0.0;
9014 if (attribute_flag[23] != 0)
9015 image->interpolate=(PixelInterpolateMethod)
9016 argument_list[23].integer_reference;
9017 if ((attribute_flag[24] != 0) &&
9018 (draw_info->fill_pattern != (Image *) NULL))
9019 flags=ParsePageGeometry(draw_info->fill_pattern,
9020 argument_list[24].string_reference,
9021 &draw_info->fill_pattern->tile_offset,exception);
9022 if (attribute_flag[25] != 0)
9024 (void) ConcatenateString(&draw_info->primitive," '");
9025 (void) ConcatenateString(&draw_info->primitive,
9026 argument_list[25].string_reference);
9027 (void) ConcatenateString(&draw_info->primitive,"'");
9029 if (attribute_flag[26] != 0)
9030 draw_info->fill_pattern=CloneImage(
9031 argument_list[26].image_reference,0,0,MagickTrue,exception);
9032 if (attribute_flag[27] != 0)
9033 draw_info->stroke_pattern=CloneImage(
9034 argument_list[27].image_reference,0,0,MagickTrue,exception);
9035 if (attribute_flag[28] != 0)
9036 (void) CloneString(&draw_info->primitive,
9037 argument_list[28].string_reference);
9038 if (attribute_flag[29] != 0)
9039 draw_info->kerning=argument_list[29].real_reference;
9040 if (attribute_flag[30] != 0)
9041 draw_info->interline_spacing=argument_list[30].real_reference;
9042 if (attribute_flag[31] != 0)
9043 draw_info->interword_spacing=argument_list[31].real_reference;
9044 if (attribute_flag[32] != 0)
9045 draw_info->direction=(DirectionType)
9046 argument_list[32].integer_reference;
9047 DrawImage(image,draw_info,exception);
9048 draw_info=DestroyDrawInfo(draw_info);
9051 case 39: /* Equalize */
9053 if (attribute_flag[0] != 0)
9054 channel=(ChannelType) argument_list[0].integer_reference;
9055 channel_mask=SetImageChannelMask(image,channel);
9056 EqualizeImage(image,exception);
9057 (void) SetImageChannelMask(image,channel_mask);
9060 case 40: /* Gamma */
9062 if (attribute_flag[1] != 0)
9063 channel=(ChannelType) argument_list[1].integer_reference;
9064 if (attribute_flag[2] == 0)
9065 argument_list[2].real_reference=1.0;
9066 if (attribute_flag[3] == 0)
9067 argument_list[3].real_reference=1.0;
9068 if (attribute_flag[4] == 0)
9069 argument_list[4].real_reference=1.0;
9070 if (attribute_flag[0] == 0)
9072 (void) FormatLocaleString(message,MagickPathExtent,
9073 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9074 (double) argument_list[3].real_reference,
9075 (double) argument_list[4].real_reference);
9076 argument_list[0].string_reference=message;
9078 (void) GammaImage(image,StringToDouble(
9079 argument_list[0].string_reference,(char **) NULL),exception);
9087 if (attribute_flag[0] == 0)
9089 ThrowPerlException(exception,OptionError,"MapImageRequired",
9093 quantize_info=AcquireQuantizeInfo(info->image_info);
9094 if (attribute_flag[1] != 0)
9095 quantize_info->dither_method=(DitherMethod)
9096 argument_list[1].integer_reference;
9097 (void) RemapImages(quantize_info,image,
9098 argument_list[0].image_reference,exception);
9099 quantize_info=DestroyQuantizeInfo(quantize_info);
9102 case 42: /* MatteFloodfill */
9113 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9115 if (attribute_flag[0] != 0)
9116 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9117 &geometry,exception);
9118 if (attribute_flag[1] != 0)
9119 geometry.x=argument_list[1].integer_reference;
9120 if (attribute_flag[2] != 0)
9121 geometry.y=argument_list[2].integer_reference;
9122 if (image->alpha_trait == UndefinedPixelTrait)
9123 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9124 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9125 geometry.x,geometry.y,&target,exception);
9126 if (attribute_flag[4] != 0)
9127 QueryColorCompliance(argument_list[4].string_reference,
9128 AllCompliance,&target,exception);
9129 if (attribute_flag[3] != 0)
9130 target.alpha=StringToDoubleInterval(
9131 argument_list[3].string_reference,(double) (double) QuantumRange+
9133 if (attribute_flag[5] != 0)
9134 image->fuzz=StringToDoubleInterval(
9135 argument_list[5].string_reference,(double) QuantumRange+1.0);
9137 if (attribute_flag[6] != 0)
9138 invert=(MagickBooleanType) argument_list[6].integer_reference;
9139 channel_mask=SetImageChannelMask(image,AlphaChannel);
9140 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9141 geometry.y,invert,exception);
9142 (void) SetImageChannelMask(image,channel_mask);
9143 draw_info=DestroyDrawInfo(draw_info);
9146 case 43: /* Modulate */
9149 modulate[MagickPathExtent];
9151 geometry_info.rho=100.0;
9152 geometry_info.sigma=100.0;
9153 geometry_info.xi=100.0;
9154 if (attribute_flag[0] != 0)
9155 (void)ParseGeometry(argument_list[0].string_reference,
9157 if (attribute_flag[1] != 0)
9158 geometry_info.xi=argument_list[1].real_reference;
9159 if (attribute_flag[2] != 0)
9160 geometry_info.sigma=argument_list[2].real_reference;
9161 if (attribute_flag[3] != 0)
9163 geometry_info.sigma=argument_list[3].real_reference;
9164 SetImageArtifact(image,"modulate:colorspace","HWB");
9166 if (attribute_flag[4] != 0)
9168 geometry_info.rho=argument_list[4].real_reference;
9169 SetImageArtifact(image,"modulate:colorspace","HSB");
9171 if (attribute_flag[5] != 0)
9173 geometry_info.sigma=argument_list[5].real_reference;
9174 SetImageArtifact(image,"modulate:colorspace","HSL");
9176 if (attribute_flag[6] != 0)
9178 geometry_info.rho=argument_list[6].real_reference;
9179 SetImageArtifact(image,"modulate:colorspace","HWB");
9181 (void) FormatLocaleString(modulate,MagickPathExtent,"%.15g,%.15g,%.15g",
9182 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9183 (void) ModulateImage(image,modulate,exception);
9186 case 44: /* Negate */
9188 if (attribute_flag[0] == 0)
9189 argument_list[0].integer_reference=0;
9190 if (attribute_flag[1] != 0)
9191 channel=(ChannelType) argument_list[1].integer_reference;
9192 channel_mask=SetImageChannelMask(image,channel);
9193 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9194 MagickTrue : MagickFalse,exception);
9195 (void) SetImageChannelMask(image,channel_mask);
9198 case 45: /* Normalize */
9200 if (attribute_flag[0] != 0)
9201 channel=(ChannelType) argument_list[0].integer_reference;
9202 channel_mask=SetImageChannelMask(image,channel);
9203 NormalizeImage(image,exception);
9204 (void) SetImageChannelMask(image,channel_mask);
9207 case 46: /* NumberColors */
9209 case 47: /* Opaque */
9218 (void) QueryColorCompliance("none",AllCompliance,&target,
9220 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9222 if (attribute_flag[0] != 0)
9223 (void) QueryColorCompliance(argument_list[0].string_reference,
9224 AllCompliance,&target,exception);
9225 if (attribute_flag[1] != 0)
9226 (void) QueryColorCompliance(argument_list[1].string_reference,
9227 AllCompliance,&fill_color,exception);
9228 if (attribute_flag[2] != 0)
9229 image->fuzz=StringToDoubleInterval(
9230 argument_list[2].string_reference,(double) QuantumRange+1.0);
9231 if (attribute_flag[3] != 0)
9232 channel=(ChannelType) argument_list[3].integer_reference;
9234 if (attribute_flag[4] != 0)
9235 invert=(MagickBooleanType) argument_list[4].integer_reference;
9236 channel_mask=SetImageChannelMask(image,channel);
9237 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9238 (void) SetImageChannelMask(image,channel_mask);
9241 case 48: /* Quantize */
9246 quantize_info=AcquireQuantizeInfo(info->image_info);
9247 if (attribute_flag[0] != 0)
9248 quantize_info->number_colors=(size_t)
9249 argument_list[0].integer_reference;
9250 if (attribute_flag[1] != 0)
9251 quantize_info->tree_depth=(size_t)
9252 argument_list[1].integer_reference;
9253 if (attribute_flag[2] != 0)
9254 quantize_info->colorspace=(ColorspaceType)
9255 argument_list[2].integer_reference;
9256 if (attribute_flag[3] != 0)
9257 quantize_info->dither_method=(DitherMethod)
9258 argument_list[3].integer_reference;
9259 if (attribute_flag[4] != 0)
9260 quantize_info->measure_error=
9261 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9262 if (attribute_flag[6] != 0)
9263 (void) QueryColorCompliance(argument_list[6].string_reference,
9264 AllCompliance,&image->transparent_color,exception);
9265 if (attribute_flag[7] != 0)
9266 quantize_info->dither_method=(DitherMethod)
9267 argument_list[7].integer_reference;
9268 if (attribute_flag[5] && argument_list[5].integer_reference)
9269 (void) QuantizeImages(quantize_info,image,exception);
9271 if ((image->storage_class == DirectClass) ||
9272 (image->colors > quantize_info->number_colors) ||
9273 (quantize_info->colorspace == GRAYColorspace))
9274 (void) QuantizeImage(quantize_info,image,exception);
9276 CompressImageColormap(image,exception);
9277 quantize_info=DestroyQuantizeInfo(quantize_info);
9280 case 49: /* Raise */
9282 if (attribute_flag[0] != 0)
9283 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9284 &geometry,exception);
9285 if (attribute_flag[1] != 0)
9286 geometry.width=argument_list[1].integer_reference;
9287 if (attribute_flag[2] != 0)
9288 geometry.height=argument_list[2].integer_reference;
9289 if (attribute_flag[3] == 0)
9290 argument_list[3].integer_reference=1;
9291 (void) RaiseImage(image,&geometry,
9292 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9296 case 50: /* Segment */
9303 smoothing_threshold;
9308 cluster_threshold=1.0;
9309 smoothing_threshold=1.5;
9310 colorspace=sRGBColorspace;
9311 verbose=MagickFalse;
9312 if (attribute_flag[0] != 0)
9314 flags=ParseGeometry(argument_list[0].string_reference,
9316 cluster_threshold=geometry_info.rho;
9317 if (flags & SigmaValue)
9318 smoothing_threshold=geometry_info.sigma;
9320 if (attribute_flag[1] != 0)
9321 cluster_threshold=argument_list[1].real_reference;
9322 if (attribute_flag[2] != 0)
9323 smoothing_threshold=argument_list[2].real_reference;
9324 if (attribute_flag[3] != 0)
9325 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9326 if (attribute_flag[4] != 0)
9327 verbose=argument_list[4].integer_reference != 0 ?
9328 MagickTrue : MagickFalse;
9329 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9330 smoothing_threshold,exception);
9333 case 51: /* Signature */
9335 (void) SignatureImage(image,exception);
9338 case 52: /* Solarize */
9340 geometry_info.rho=QuantumRange/2.0;
9341 if (attribute_flag[0] != 0)
9342 flags=ParseGeometry(argument_list[0].string_reference,
9344 if (attribute_flag[1] != 0)
9345 geometry_info.rho=StringToDoubleInterval(
9346 argument_list[1].string_reference,(double) QuantumRange+1.0);
9347 (void) SolarizeImage(image,geometry_info.rho,exception);
9352 (void) SyncImage(image,exception);
9355 case 54: /* Texture */
9357 if (attribute_flag[0] == 0)
9359 TextureImage(image,argument_list[0].image_reference,exception);
9362 case 55: /* Evalute */
9364 MagickEvaluateOperator
9367 op=SetEvaluateOperator;
9368 if (attribute_flag[0] == MagickFalse)
9369 argument_list[0].real_reference=0.0;
9370 if (attribute_flag[1] != MagickFalse)
9371 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9372 if (attribute_flag[2] != MagickFalse)
9373 channel=(ChannelType) argument_list[2].integer_reference;
9374 channel_mask=SetImageChannelMask(image,channel);
9375 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9377 (void) SetImageChannelMask(image,channel_mask);
9380 case 56: /* Transparent */
9391 (void) QueryColorCompliance("none",AllCompliance,&target,
9393 if (attribute_flag[0] != 0)
9394 (void) QueryColorCompliance(argument_list[0].string_reference,
9395 AllCompliance,&target,exception);
9396 opacity=TransparentAlpha;
9397 if (attribute_flag[1] != 0)
9398 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9399 (double) QuantumRange+1.0);
9400 if (attribute_flag[2] != 0)
9401 image->fuzz=StringToDoubleInterval(
9402 argument_list[2].string_reference,(double) QuantumRange+1.0);
9403 if (attribute_flag[3] == 0)
9404 argument_list[3].integer_reference=0;
9406 if (attribute_flag[3] != 0)
9407 invert=(MagickBooleanType) argument_list[3].integer_reference;
9408 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9412 case 57: /* Threshold */
9417 if (attribute_flag[0] == 0)
9418 argument_list[0].string_reference="50%";
9419 if (attribute_flag[1] != 0)
9420 channel=(ChannelType) argument_list[1].integer_reference;
9421 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9422 (double) QuantumRange+1.0);
9423 channel_mask=SetImageChannelMask(image,channel);
9424 (void) BilevelImage(image,threshold,exception);
9425 (void) SetImageChannelMask(image,channel_mask);
9428 case 58: /* Charcoal */
9430 if (attribute_flag[0] != 0)
9432 flags=ParseGeometry(argument_list[0].string_reference,
9434 if ((flags & SigmaValue) == 0)
9435 geometry_info.sigma=1.0;
9437 if (attribute_flag[1] != 0)
9438 geometry_info.rho=argument_list[1].real_reference;
9439 if (attribute_flag[2] != 0)
9440 geometry_info.sigma=argument_list[2].real_reference;
9441 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9447 if (attribute_flag[0] != 0)
9448 image->fuzz=StringToDoubleInterval(
9449 argument_list[0].string_reference,(double) QuantumRange+1.0);
9450 image=TrimImage(image,exception);
9455 PixelInterpolateMethod
9458 if (attribute_flag[0] != 0)
9460 flags=ParseGeometry(argument_list[0].string_reference,
9462 if ((flags & SigmaValue) == 0)
9463 geometry_info.sigma=1.0;
9465 if (attribute_flag[1] != 0)
9466 geometry_info.rho=argument_list[1].real_reference;
9467 if (attribute_flag[2] != 0)
9468 geometry_info.sigma=argument_list[2].real_reference;
9469 method=UndefinedInterpolatePixel;
9470 if (attribute_flag[3] != 0)
9471 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9472 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9476 case 61: /* Separate */
9478 if (attribute_flag[0] != 0)
9479 channel=(ChannelType) argument_list[0].integer_reference;
9480 image=SeparateImage(image,channel,exception);
9483 case 63: /* Stereo */
9485 if (attribute_flag[0] == 0)
9487 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9491 if (attribute_flag[1] != 0)
9492 geometry.x=argument_list[1].integer_reference;
9493 if (attribute_flag[2] != 0)
9494 geometry.y=argument_list[2].integer_reference;
9495 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9496 geometry.x,geometry.y,exception);
9499 case 64: /* Stegano */
9501 if (attribute_flag[0] == 0)
9503 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9507 if (attribute_flag[1] == 0)
9508 argument_list[1].integer_reference=0;
9509 image->offset=argument_list[1].integer_reference;
9510 image=SteganoImage(image,argument_list[0].image_reference,exception);
9513 case 65: /* Deconstruct */
9515 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9518 case 66: /* GaussianBlur */
9520 if (attribute_flag[0] != 0)
9522 flags=ParseGeometry(argument_list[0].string_reference,
9524 if ((flags & SigmaValue) == 0)
9525 geometry_info.sigma=1.0;
9527 if (attribute_flag[1] != 0)
9528 geometry_info.rho=argument_list[1].real_reference;
9529 if (attribute_flag[2] != 0)
9530 geometry_info.sigma=argument_list[2].real_reference;
9531 if (attribute_flag[3] != 0)
9532 channel=(ChannelType) argument_list[3].integer_reference;
9533 channel_mask=SetImageChannelMask(image,channel);
9534 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9536 if (image != (Image *) NULL)
9537 (void) SetImageChannelMask(image,channel_mask);
9540 case 67: /* Convolve */
9545 kernel=(KernelInfo *) NULL;
9546 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9548 if (attribute_flag[0] != 0)
9556 kernel=AcquireKernelInfo((const char *) NULL,exception);
9557 if (kernel == (KernelInfo *) NULL)
9559 av=(AV *) argument_list[0].array_reference;
9560 order=(size_t) sqrt(av_len(av)+1);
9561 kernel->width=order;
9562 kernel->height=order;
9563 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9564 order*sizeof(*kernel->values));
9565 if (kernel->values == (MagickRealType *) NULL)
9567 kernel=DestroyKernelInfo(kernel);
9568 ThrowPerlException(exception,ResourceLimitFatalError,
9569 "MemoryAllocationFailed",PackageName);
9572 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9573 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9574 for ( ; j < (ssize_t) (order*order); j++)
9575 kernel->values[j]=0.0;
9577 if (attribute_flag[1] != 0)
9578 channel=(ChannelType) argument_list[1].integer_reference;
9579 if (attribute_flag[2] != 0)
9580 SetImageArtifact(image,"filter:blur",
9581 argument_list[2].string_reference);
9582 if (attribute_flag[3] != 0)
9584 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9586 if (kernel == (KernelInfo *) NULL)
9589 channel_mask=SetImageChannelMask(image,channel);
9590 image=ConvolveImage(image,kernel,exception);
9591 if (image != (Image *) NULL)
9592 (void) SetImageChannelMask(image,channel_mask);
9593 kernel=DestroyKernelInfo(kernel);
9596 case 68: /* Profile */
9611 if (attribute_flag[0] != 0)
9612 name=argument_list[0].string_reference;
9613 if (attribute_flag[2] != 0)
9614 image->rendering_intent=(RenderingIntent)
9615 argument_list[2].integer_reference;
9616 if (attribute_flag[3] != 0)
9617 image->black_point_compensation=
9618 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9619 if (attribute_flag[1] != 0)
9621 if (argument_list[1].length == 0)
9624 Remove a profile from the image.
9626 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9631 Associate user supplied profile with the image.
9633 profile=AcquireStringInfo(argument_list[1].length);
9634 SetStringInfoDatum(profile,(const unsigned char *)
9635 argument_list[1].string_reference);
9636 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9637 (size_t) GetStringInfoLength(profile),exception);
9638 profile=DestroyStringInfo(profile);
9642 Associate a profile with the image.
9644 profile_info=CloneImageInfo(info ? info->image_info :
9645 (ImageInfo *) NULL);
9646 profile_image=ReadImages(profile_info,name,exception);
9647 if (profile_image == (Image *) NULL)
9649 ResetImageProfileIterator(profile_image);
9650 name=GetNextImageProfile(profile_image);
9651 while (name != (const char *) NULL)
9656 profile=GetImageProfile(profile_image,name);
9657 if (profile != (const StringInfo *) NULL)
9658 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9659 (size_t) GetStringInfoLength(profile),exception);
9660 name=GetNextImageProfile(profile_image);
9662 profile_image=DestroyImage(profile_image);
9663 profile_info=DestroyImageInfo(profile_info);
9666 case 69: /* UnsharpMask */
9668 if (attribute_flag[0] != 0)
9670 flags=ParseGeometry(argument_list[0].string_reference,
9672 if ((flags & SigmaValue) == 0)
9673 geometry_info.sigma=1.0;
9674 if ((flags & XiValue) == 0)
9675 geometry_info.xi=1.0;
9676 if ((flags & PsiValue) == 0)
9677 geometry_info.psi=0.5;
9679 if (attribute_flag[1] != 0)
9680 geometry_info.rho=argument_list[1].real_reference;
9681 if (attribute_flag[2] != 0)
9682 geometry_info.sigma=argument_list[2].real_reference;
9683 if (attribute_flag[3] != 0)
9684 geometry_info.xi=argument_list[3].real_reference;
9685 if (attribute_flag[4] != 0)
9686 geometry_info.psi=argument_list[4].real_reference;
9687 if (attribute_flag[5] != 0)
9688 channel=(ChannelType) argument_list[5].integer_reference;
9689 channel_mask=SetImageChannelMask(image,channel);
9690 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9691 geometry_info.xi,geometry_info.psi,exception);
9692 if (image != (Image *) NULL)
9693 (void) SetImageChannelMask(image,channel_mask);
9696 case 70: /* MotionBlur */
9698 if (attribute_flag[0] != 0)
9700 flags=ParseGeometry(argument_list[0].string_reference,
9702 if ((flags & SigmaValue) == 0)
9703 geometry_info.sigma=1.0;
9704 if ((flags & XiValue) == 0)
9705 geometry_info.xi=1.0;
9707 if (attribute_flag[1] != 0)
9708 geometry_info.rho=argument_list[1].real_reference;
9709 if (attribute_flag[2] != 0)
9710 geometry_info.sigma=argument_list[2].real_reference;
9711 if (attribute_flag[3] != 0)
9712 geometry_info.xi=argument_list[3].real_reference;
9713 if (attribute_flag[4] != 0)
9714 channel=(ChannelType) argument_list[4].integer_reference;
9715 channel_mask=SetImageChannelMask(image,channel);
9716 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9717 geometry_info.xi,exception);
9718 if (image != (Image *) NULL)
9719 (void) SetImageChannelMask(image,channel_mask);
9722 case 71: /* OrderedDither */
9724 if (attribute_flag[0] == 0)
9725 argument_list[0].string_reference="o8x8";
9726 if (attribute_flag[1] != 0)
9727 channel=(ChannelType) argument_list[1].integer_reference;
9728 channel_mask=SetImageChannelMask(image,channel);
9729 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9731 (void) SetImageChannelMask(image,channel_mask);
9734 case 72: /* Shave */
9736 if (attribute_flag[0] != 0)
9737 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9738 &geometry,exception);
9739 if (attribute_flag[1] != 0)
9740 geometry.width=argument_list[1].integer_reference;
9741 if (attribute_flag[2] != 0)
9742 geometry.height=argument_list[2].integer_reference;
9743 image=ShaveImage(image,&geometry,exception);
9746 case 73: /* Level */
9754 white_point=(double) image->columns*image->rows;
9756 if (attribute_flag[0] != 0)
9758 flags=ParseGeometry(argument_list[0].string_reference,
9760 black_point=geometry_info.rho;
9761 if ((flags & SigmaValue) != 0)
9762 white_point=geometry_info.sigma;
9763 if ((flags & XiValue) != 0)
9764 gamma=geometry_info.xi;
9765 if ((flags & PercentValue) != 0)
9767 black_point*=(double) (QuantumRange/100.0);
9768 white_point*=(double) (QuantumRange/100.0);
9770 if ((flags & SigmaValue) == 0)
9771 white_point=(double) QuantumRange-black_point;
9773 if (attribute_flag[1] != 0)
9774 black_point=argument_list[1].real_reference;
9775 if (attribute_flag[2] != 0)
9776 white_point=argument_list[2].real_reference;
9777 if (attribute_flag[3] != 0)
9778 gamma=argument_list[3].real_reference;
9779 if (attribute_flag[4] != 0)
9780 channel=(ChannelType) argument_list[4].integer_reference;
9781 if (attribute_flag[5] != 0)
9783 argument_list[0].real_reference=argument_list[5].real_reference;
9784 attribute_flag[0]=attribute_flag[5];
9786 channel_mask=SetImageChannelMask(image,channel);
9787 (void) LevelImage(image,black_point,white_point,gamma,exception);
9788 (void) SetImageChannelMask(image,channel_mask);
9793 if (attribute_flag[0] == 0)
9794 argument_list[0].string_reference="#1";
9795 if (attribute_flag[1] == 0)
9796 argument_list[1].integer_reference=MagickTrue;
9797 (void) ClipImagePath(image,argument_list[0].string_reference,
9798 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9802 case 75: /* AffineTransform */
9807 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9809 if (attribute_flag[0] != 0)
9814 av=(AV *) argument_list[0].array_reference;
9815 if ((av_len(av) != 3) && (av_len(av) != 5))
9817 ThrowPerlException(exception,OptionError,
9818 "affine matrix must have 4 or 6 elements",PackageName);
9821 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9822 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9823 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9824 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9825 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9826 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9828 ThrowPerlException(exception,OptionError,
9829 "affine matrix is singular",PackageName);
9832 if (av_len(av) == 5)
9834 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9835 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9838 for (j=1; j < 6; j++)
9840 if (attribute_flag[j] == 0)
9842 value=argument_list[j].string_reference;
9843 angle=argument_list[j].real_reference;
9844 current=draw_info->affine;
9845 GetAffineMatrix(&affine);
9853 flags=ParseGeometry(value,&geometry_info);
9854 affine.tx=geometry_info.xi;
9855 affine.ty=geometry_info.psi;
9856 if ((flags & PsiValue) == 0)
9857 affine.ty=affine.tx;
9865 flags=ParseGeometry(value,&geometry_info);
9866 affine.sx=geometry_info.rho;
9867 affine.sy=geometry_info.sigma;
9868 if ((flags & SigmaValue) == 0)
9869 affine.sy=affine.sx;
9879 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9880 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9881 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9882 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9890 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9898 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9902 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9903 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9904 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9905 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9906 draw_info->affine.tx=
9907 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9908 draw_info->affine.ty=
9909 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9911 if (attribute_flag[6] != 0)
9912 image->interpolate=(PixelInterpolateMethod)
9913 argument_list[6].integer_reference;
9914 if (attribute_flag[7] != 0)
9915 QueryColorCompliance(argument_list[7].string_reference,
9916 AllCompliance,&image->background_color,exception);
9917 image=AffineTransformImage(image,&draw_info->affine,exception);
9918 draw_info=DestroyDrawInfo(draw_info);
9921 case 76: /* Difference */
9923 if (attribute_flag[0] == 0)
9925 ThrowPerlException(exception,OptionError,
9926 "ReferenceImageRequired",PackageName);
9929 if (attribute_flag[1] != 0)
9930 image->fuzz=StringToDoubleInterval(
9931 argument_list[1].string_reference,(double) QuantumRange+1.0);
9932 (void) IsImagesEqual(image,argument_list[0].image_reference,
9936 case 77: /* AdaptiveThreshold */
9938 if (attribute_flag[0] != 0)
9940 flags=ParseGeometry(argument_list[0].string_reference,
9942 if ((flags & PercentValue) != 0)
9943 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9945 if (attribute_flag[1] != 0)
9946 geometry_info.rho=argument_list[1].integer_reference;
9947 if (attribute_flag[2] != 0)
9948 geometry_info.sigma=argument_list[2].integer_reference;
9949 if (attribute_flag[3] != 0)
9950 geometry_info.xi=argument_list[3].integer_reference;;
9951 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9952 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9955 case 78: /* Resample */
9961 if (attribute_flag[0] != 0)
9963 flags=ParseGeometry(argument_list[0].string_reference,
9965 if ((flags & SigmaValue) == 0)
9966 geometry_info.sigma=geometry_info.rho;
9968 if (attribute_flag[1] != 0)
9969 geometry_info.rho=argument_list[1].real_reference;
9970 if (attribute_flag[2] != 0)
9971 geometry_info.sigma=argument_list[2].real_reference;
9972 if (attribute_flag[3] == 0)
9973 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9974 if (attribute_flag[4] == 0)
9975 SetImageArtifact(image,"filter:support",
9976 argument_list[4].string_reference);
9977 width=(size_t) (geometry_info.rho*image->columns/
9978 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9979 height=(size_t) (geometry_info.sigma*image->rows/
9980 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9981 image=ResizeImage(image,width,height,(FilterTypes)
9982 argument_list[3].integer_reference,exception);
9983 if (image != (Image *) NULL)
9985 image->resolution.x=geometry_info.rho;
9986 image->resolution.y=geometry_info.sigma;
9990 case 79: /* Describe */
9992 if (attribute_flag[0] == 0)
9993 argument_list[0].file_reference=(FILE *) NULL;
9994 if (attribute_flag[1] != 0)
9995 (void) SetImageArtifact(image,"identify:features",
9996 argument_list[1].string_reference);
9997 (void) IdentifyImage(image,argument_list[0].file_reference,
9998 MagickTrue,exception);
10001 case 80: /* BlackThreshold */
10003 if (attribute_flag[0] == 0)
10004 argument_list[0].string_reference="50%";
10005 if (attribute_flag[2] != 0)
10006 channel=(ChannelType) argument_list[2].integer_reference;
10007 channel_mask=SetImageChannelMask(image,channel);
10008 BlackThresholdImage(image,argument_list[0].string_reference,
10010 (void) SetImageChannelMask(image,channel_mask);
10013 case 81: /* WhiteThreshold */
10015 if (attribute_flag[0] == 0)
10016 argument_list[0].string_reference="50%";
10017 if (attribute_flag[2] != 0)
10018 channel=(ChannelType) argument_list[2].integer_reference;
10019 channel_mask=SetImageChannelMask(image,channel);
10020 WhiteThresholdImage(image,argument_list[0].string_reference,
10022 (void) SetImageChannelMask(image,channel_mask);
10025 case 82: /* RotationalBlur */
10027 if (attribute_flag[0] != 0)
10029 flags=ParseGeometry(argument_list[0].string_reference,
10032 if (attribute_flag[1] != 0)
10033 geometry_info.rho=argument_list[1].real_reference;
10034 if (attribute_flag[2] != 0)
10035 channel=(ChannelType) argument_list[2].integer_reference;
10036 channel_mask=SetImageChannelMask(image,channel);
10037 image=RotationalBlurImage(image,geometry_info.rho,exception);
10038 if (image != (Image *) NULL)
10039 (void) SetImageChannelMask(image,channel_mask);
10042 case 83: /* Thumbnail */
10044 if (attribute_flag[0] != 0)
10045 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10046 &geometry,exception);
10047 if (attribute_flag[1] != 0)
10048 geometry.width=argument_list[1].integer_reference;
10049 if (attribute_flag[2] != 0)
10050 geometry.height=argument_list[2].integer_reference;
10051 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10054 case 84: /* Strip */
10056 (void) StripImage(image,exception);
10059 case 85: /* Tint */
10064 GetPixelInfo(image,&tint);
10065 if (attribute_flag[0] != 0)
10066 (void) QueryColorCompliance(argument_list[0].string_reference,
10067 AllCompliance,&tint,exception);
10068 if (attribute_flag[1] == 0)
10069 argument_list[1].string_reference="100";
10070 image=TintImage(image,argument_list[1].string_reference,&tint,
10074 case 86: /* Channel */
10076 if (attribute_flag[0] != 0)
10077 channel=(ChannelType) argument_list[0].integer_reference;
10078 image=SeparateImage(image,channel,exception);
10081 case 87: /* Splice */
10083 if (attribute_flag[7] != 0)
10084 image->gravity=(GravityType) argument_list[7].integer_reference;
10085 if (attribute_flag[0] != 0)
10086 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10087 &geometry,exception);
10088 if (attribute_flag[1] != 0)
10089 geometry.width=argument_list[1].integer_reference;
10090 if (attribute_flag[2] != 0)
10091 geometry.height=argument_list[2].integer_reference;
10092 if (attribute_flag[3] != 0)
10093 geometry.x=argument_list[3].integer_reference;
10094 if (attribute_flag[4] != 0)
10095 geometry.y=argument_list[4].integer_reference;
10096 if (attribute_flag[5] != 0)
10097 image->fuzz=StringToDoubleInterval(
10098 argument_list[5].string_reference,(double) QuantumRange+1.0);
10099 if (attribute_flag[6] != 0)
10100 (void) QueryColorCompliance(argument_list[6].string_reference,
10101 AllCompliance,&image->background_color,exception);
10102 image=SpliceImage(image,&geometry,exception);
10105 case 88: /* Posterize */
10107 if (attribute_flag[0] == 0)
10108 argument_list[0].integer_reference=3;
10109 if (attribute_flag[1] == 0)
10110 argument_list[1].integer_reference=0;
10111 (void) PosterizeImage(image,argument_list[0].integer_reference,
10112 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10113 NoDitherMethod,exception);
10116 case 89: /* Shadow */
10118 if (attribute_flag[0] != 0)
10120 flags=ParseGeometry(argument_list[0].string_reference,
10122 if ((flags & SigmaValue) == 0)
10123 geometry_info.sigma=1.0;
10124 if ((flags & XiValue) == 0)
10125 geometry_info.xi=4.0;
10126 if ((flags & PsiValue) == 0)
10127 geometry_info.psi=4.0;
10129 if (attribute_flag[1] != 0)
10130 geometry_info.rho=argument_list[1].real_reference;
10131 if (attribute_flag[2] != 0)
10132 geometry_info.sigma=argument_list[2].real_reference;
10133 if (attribute_flag[3] != 0)
10134 geometry_info.xi=argument_list[3].integer_reference;
10135 if (attribute_flag[4] != 0)
10136 geometry_info.psi=argument_list[4].integer_reference;
10137 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10138 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10139 ceil(geometry_info.psi-0.5),exception);
10142 case 90: /* Identify */
10144 if (attribute_flag[0] == 0)
10145 argument_list[0].file_reference=(FILE *) NULL;
10146 if (attribute_flag[1] != 0)
10147 (void) SetImageArtifact(image,"identify:features",
10148 argument_list[1].string_reference);
10149 if ((attribute_flag[2] != 0) &&
10150 (argument_list[2].integer_reference != 0))
10151 (void) SetImageArtifact(image,"identify:unique","true");
10152 (void) IdentifyImage(image,argument_list[0].file_reference,
10153 MagickTrue,exception);
10156 case 91: /* SepiaTone */
10158 if (attribute_flag[0] == 0)
10159 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10160 image=SepiaToneImage(image,argument_list[0].real_reference,
10164 case 92: /* SigmoidalContrast */
10169 if (attribute_flag[0] != 0)
10171 flags=ParseGeometry(argument_list[0].string_reference,
10173 if ((flags & SigmaValue) == 0)
10174 geometry_info.sigma=QuantumRange/2.0;
10175 if ((flags & PercentValue) != 0)
10176 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10178 if (attribute_flag[1] != 0)
10179 geometry_info.rho=argument_list[1].real_reference;
10180 if (attribute_flag[2] != 0)
10181 geometry_info.sigma=argument_list[2].real_reference;
10182 if (attribute_flag[3] != 0)
10183 channel=(ChannelType) argument_list[3].integer_reference;
10184 sharpen=MagickTrue;
10185 if (attribute_flag[4] != 0)
10186 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10188 channel_mask=SetImageChannelMask(image,channel);
10189 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10190 geometry_info.sigma,exception);
10191 (void) SetImageChannelMask(image,channel_mask);
10194 case 93: /* Extent */
10196 if (attribute_flag[7] != 0)
10197 image->gravity=(GravityType) argument_list[7].integer_reference;
10198 if (attribute_flag[0] != 0)
10203 flags=ParseGravityGeometry(image,
10204 argument_list[0].string_reference,&geometry,exception);
10206 if (geometry.width == 0)
10207 geometry.width=image->columns;
10208 if (geometry.height == 0)
10209 geometry.height=image->rows;
10211 if (attribute_flag[1] != 0)
10212 geometry.width=argument_list[1].integer_reference;
10213 if (attribute_flag[2] != 0)
10214 geometry.height=argument_list[2].integer_reference;
10215 if (attribute_flag[3] != 0)
10216 geometry.x=argument_list[3].integer_reference;
10217 if (attribute_flag[4] != 0)
10218 geometry.y=argument_list[4].integer_reference;
10219 if (attribute_flag[5] != 0)
10220 image->fuzz=StringToDoubleInterval(
10221 argument_list[5].string_reference,(double) QuantumRange+1.0);
10222 if (attribute_flag[6] != 0)
10223 (void) QueryColorCompliance(argument_list[6].string_reference,
10224 AllCompliance,&image->background_color,exception);
10225 image=ExtentImage(image,&geometry,exception);
10228 case 94: /* Vignette */
10230 if (attribute_flag[0] != 0)
10232 flags=ParseGeometry(argument_list[0].string_reference,
10234 if ((flags & SigmaValue) == 0)
10235 geometry_info.sigma=1.0;
10236 if ((flags & XiValue) == 0)
10237 geometry_info.xi=0.1*image->columns;
10238 if ((flags & PsiValue) == 0)
10239 geometry_info.psi=0.1*image->rows;
10241 if (attribute_flag[1] != 0)
10242 geometry_info.rho=argument_list[1].real_reference;
10243 if (attribute_flag[2] != 0)
10244 geometry_info.sigma=argument_list[2].real_reference;
10245 if (attribute_flag[3] != 0)
10246 geometry_info.xi=argument_list[3].integer_reference;
10247 if (attribute_flag[4] != 0)
10248 geometry_info.psi=argument_list[4].integer_reference;
10249 if (attribute_flag[5] != 0)
10250 (void) QueryColorCompliance(argument_list[5].string_reference,
10251 AllCompliance,&image->background_color,exception);
10252 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10253 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10254 ceil(geometry_info.psi-0.5),exception);
10257 case 95: /* ContrastStretch */
10264 white_point=(double) image->columns*image->rows;
10265 if (attribute_flag[0] != 0)
10267 flags=ParseGeometry(argument_list[0].string_reference,
10269 black_point=geometry_info.rho;
10270 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10272 if ((flags & PercentValue) != 0)
10274 black_point*=(double) image->columns*image->rows/100.0;
10275 white_point*=(double) image->columns*image->rows/100.0;
10277 white_point=(double) image->columns*image->rows-
10280 if (attribute_flag[1] != 0)
10281 black_point=argument_list[1].real_reference;
10282 if (attribute_flag[2] != 0)
10283 white_point=argument_list[2].real_reference;
10284 if (attribute_flag[4] != 0)
10285 channel=(ChannelType) argument_list[4].integer_reference;
10286 channel_mask=SetImageChannelMask(image,channel);
10287 (void) ContrastStretchImage(image,black_point,white_point,exception);
10288 (void) SetImageChannelMask(image,channel_mask);
10291 case 96: /* Sans0 */
10295 case 97: /* Sans1 */
10299 case 98: /* AdaptiveSharpen */
10301 if (attribute_flag[0] != 0)
10303 flags=ParseGeometry(argument_list[0].string_reference,
10305 if ((flags & SigmaValue) == 0)
10306 geometry_info.sigma=1.0;
10307 if ((flags & XiValue) == 0)
10308 geometry_info.xi=0.0;
10310 if (attribute_flag[1] != 0)
10311 geometry_info.rho=argument_list[1].real_reference;
10312 if (attribute_flag[2] != 0)
10313 geometry_info.sigma=argument_list[2].real_reference;
10314 if (attribute_flag[3] != 0)
10315 geometry_info.xi=argument_list[3].real_reference;
10316 if (attribute_flag[4] != 0)
10317 channel=(ChannelType) argument_list[4].integer_reference;
10318 channel_mask=SetImageChannelMask(image,channel);
10319 image=AdaptiveSharpenImage(image,geometry_info.rho,
10320 geometry_info.sigma,exception);
10321 if (image != (Image *) NULL)
10322 (void) SetImageChannelMask(image,channel_mask);
10325 case 99: /* Transpose */
10327 image=TransposeImage(image,exception);
10330 case 100: /* Tranverse */
10332 image=TransverseImage(image,exception);
10335 case 101: /* AutoOrient */
10337 image=AutoOrientImage(image,image->orientation,exception);
10340 case 102: /* AdaptiveBlur */
10342 if (attribute_flag[0] != 0)
10344 flags=ParseGeometry(argument_list[0].string_reference,
10346 if ((flags & SigmaValue) == 0)
10347 geometry_info.sigma=1.0;
10348 if ((flags & XiValue) == 0)
10349 geometry_info.xi=0.0;
10351 if (attribute_flag[1] != 0)
10352 geometry_info.rho=argument_list[1].real_reference;
10353 if (attribute_flag[2] != 0)
10354 geometry_info.sigma=argument_list[2].real_reference;
10355 if (attribute_flag[3] != 0)
10356 channel=(ChannelType) argument_list[3].integer_reference;
10357 channel_mask=SetImageChannelMask(image,channel);
10358 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10360 if (image != (Image *) NULL)
10361 (void) SetImageChannelMask(image,channel_mask);
10364 case 103: /* Sketch */
10366 if (attribute_flag[0] != 0)
10368 flags=ParseGeometry(argument_list[0].string_reference,
10370 if ((flags & SigmaValue) == 0)
10371 geometry_info.sigma=1.0;
10372 if ((flags & XiValue) == 0)
10373 geometry_info.xi=1.0;
10375 if (attribute_flag[1] != 0)
10376 geometry_info.rho=argument_list[1].real_reference;
10377 if (attribute_flag[2] != 0)
10378 geometry_info.sigma=argument_list[2].real_reference;
10379 if (attribute_flag[3] != 0)
10380 geometry_info.xi=argument_list[3].real_reference;
10381 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10382 geometry_info.xi,exception);
10385 case 104: /* UniqueColors */
10387 image=UniqueImageColors(image,exception);
10390 case 105: /* AdaptiveResize */
10392 if (attribute_flag[0] != 0)
10393 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10394 &geometry,exception);
10395 if (attribute_flag[1] != 0)
10396 geometry.width=argument_list[1].integer_reference;
10397 if (attribute_flag[2] != 0)
10398 geometry.height=argument_list[2].integer_reference;
10399 if (attribute_flag[3] != 0)
10400 image->filter=(FilterTypes) argument_list[4].integer_reference;
10401 if (attribute_flag[4] != 0)
10402 SetImageArtifact(image,"filter:support",
10403 argument_list[4].string_reference);
10404 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10408 case 106: /* ClipMask */
10413 if (attribute_flag[0] == 0)
10415 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10417 goto PerlException;
10419 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10421 (void) SetImageMask(image,mask_image,exception);
10422 mask_image=DestroyImage(mask_image);
10425 case 107: /* LinearStretch */
10432 white_point=(double) image->columns*image->rows;
10433 if (attribute_flag[0] != 0)
10435 flags=ParseGeometry(argument_list[0].string_reference,
10437 if ((flags & SigmaValue) != 0)
10438 white_point=geometry_info.sigma;
10439 if ((flags & PercentValue) != 0)
10441 black_point*=(double) image->columns*image->rows/100.0;
10442 white_point*=(double) image->columns*image->rows/100.0;
10444 if ((flags & SigmaValue) == 0)
10445 white_point=(double) image->columns*image->rows-black_point;
10447 if (attribute_flag[1] != 0)
10448 black_point=argument_list[1].real_reference;
10449 if (attribute_flag[2] != 0)
10450 white_point=argument_list[2].real_reference;
10451 (void) LinearStretchImage(image,black_point,white_point,exception);
10454 case 108: /* ColorMatrix */
10468 if (attribute_flag[0] == 0)
10470 av=(AV *) argument_list[0].array_reference;
10471 order=(size_t) sqrt(av_len(av)+1);
10472 color_matrix=(double *) AcquireQuantumMemory(order,order*
10473 sizeof(*color_matrix));
10474 if (color_matrix == (double *) NULL)
10476 ThrowPerlException(exception,ResourceLimitFatalError,
10477 "MemoryAllocationFailed",PackageName);
10478 goto PerlException;
10480 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10481 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10482 for ( ; j < (ssize_t) (order*order); j++)
10483 color_matrix[j]=0.0;
10484 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10485 if (kernel_info == (KernelInfo *) NULL)
10487 kernel_info->width=order;
10488 kernel_info->height=order;
10489 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10490 order*sizeof(*kernel_info->values));
10491 if (kernel_info->values != (MagickRealType *) NULL)
10493 for (i=0; i < (ssize_t) (order*order); i++)
10494 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10495 image=ColorMatrixImage(image,kernel_info,exception);
10497 kernel_info=DestroyKernelInfo(kernel_info);
10498 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10501 case 109: /* Mask */
10506 if (attribute_flag[0] == 0)
10508 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10510 goto PerlException;
10512 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10513 MagickTrue,exception);
10514 (void) SetImageMask(image,mask_image,exception);
10515 mask_image=DestroyImage(mask_image);
10518 case 110: /* Polaroid */
10529 PixelInterpolateMethod
10532 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10533 (DrawInfo *) NULL);
10534 caption=(char *) NULL;
10535 if (attribute_flag[0] != 0)
10536 caption=InterpretImageProperties(info ? info->image_info :
10537 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10540 if (attribute_flag[1] != 0)
10541 angle=argument_list[1].real_reference;
10542 if (attribute_flag[2] != 0)
10543 (void) CloneString(&draw_info->font,
10544 argument_list[2].string_reference);
10545 if (attribute_flag[3] != 0)
10546 (void) QueryColorCompliance(argument_list[3].string_reference,
10547 AllCompliance,&draw_info->stroke,exception);
10548 if (attribute_flag[4] != 0)
10549 (void) QueryColorCompliance(argument_list[4].string_reference,
10550 AllCompliance,&draw_info->fill,exception);
10551 if (attribute_flag[5] != 0)
10552 draw_info->stroke_width=argument_list[5].real_reference;
10553 if (attribute_flag[6] != 0)
10554 draw_info->pointsize=argument_list[6].real_reference;
10555 if (attribute_flag[7] != 0)
10556 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10557 if (attribute_flag[8] != 0)
10558 (void) QueryColorCompliance(argument_list[8].string_reference,
10559 AllCompliance,&image->background_color,exception);
10560 method=UndefinedInterpolatePixel;
10561 if (attribute_flag[9] != 0)
10562 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10563 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10564 draw_info=DestroyDrawInfo(draw_info);
10565 if (caption != (char *) NULL)
10566 caption=DestroyString(caption);
10569 case 111: /* FloodfillPaint */
10580 draw_info=CloneDrawInfo(info ? info->image_info :
10581 (ImageInfo *) NULL,(DrawInfo *) NULL);
10582 if (attribute_flag[0] != 0)
10583 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10584 &geometry,exception);
10585 if (attribute_flag[1] != 0)
10586 geometry.x=argument_list[1].integer_reference;
10587 if (attribute_flag[2] != 0)
10588 geometry.y=argument_list[2].integer_reference;
10589 if (attribute_flag[3] != 0)
10590 (void) QueryColorCompliance(argument_list[3].string_reference,
10591 AllCompliance,&draw_info->fill,exception);
10592 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10593 geometry.x,geometry.y,&target,exception);
10594 if (attribute_flag[4] != 0)
10595 QueryColorCompliance(argument_list[4].string_reference,
10596 AllCompliance,&target,exception);
10597 if (attribute_flag[5] != 0)
10598 image->fuzz=StringToDoubleInterval(
10599 argument_list[5].string_reference,(double) QuantumRange+1.0);
10600 if (attribute_flag[6] != 0)
10601 channel=(ChannelType) argument_list[6].integer_reference;
10602 invert=MagickFalse;
10603 if (attribute_flag[7] != 0)
10604 invert=(MagickBooleanType) argument_list[7].integer_reference;
10605 channel_mask=SetImageChannelMask(image,channel);
10606 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10607 geometry.y,invert,exception);
10608 (void) SetImageChannelMask(image,channel_mask);
10609 draw_info=DestroyDrawInfo(draw_info);
10612 case 112: /* Distort */
10624 number_coordinates;
10629 if (attribute_flag[0] == 0)
10631 method=UndefinedDistortion;
10632 if (attribute_flag[1] != 0)
10633 method=(DistortImageMethod) argument_list[1].integer_reference;
10634 av=(AV *) argument_list[0].array_reference;
10635 number_coordinates=(size_t) av_len(av)+1;
10636 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10637 sizeof(*coordinates));
10638 if (coordinates == (double *) NULL)
10640 ThrowPerlException(exception,ResourceLimitFatalError,
10641 "MemoryAllocationFailed",PackageName);
10642 goto PerlException;
10644 for (j=0; j < (ssize_t) number_coordinates; j++)
10645 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10646 virtual_pixel=UndefinedVirtualPixelMethod;
10647 if (attribute_flag[2] != 0)
10648 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10649 argument_list[2].integer_reference,exception);
10650 image=DistortImage(image,method,number_coordinates,coordinates,
10651 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10653 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10654 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10656 coordinates=(double *) RelinquishMagickMemory(coordinates);
10659 case 113: /* Clut */
10661 PixelInterpolateMethod
10664 if (attribute_flag[0] == 0)
10666 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10668 goto PerlException;
10670 method=UndefinedInterpolatePixel;
10671 if (attribute_flag[1] != 0)
10672 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10673 if (attribute_flag[2] != 0)
10674 channel=(ChannelType) argument_list[2].integer_reference;
10675 channel_mask=SetImageChannelMask(image,channel);
10676 (void) ClutImage(image,argument_list[0].image_reference,method,
10678 (void) SetImageChannelMask(image,channel_mask);
10681 case 114: /* LiquidRescale */
10683 if (attribute_flag[0] != 0)
10684 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10685 &geometry,exception);
10686 if (attribute_flag[1] != 0)
10687 geometry.width=argument_list[1].integer_reference;
10688 if (attribute_flag[2] != 0)
10689 geometry.height=argument_list[2].integer_reference;
10690 if (attribute_flag[3] == 0)
10691 argument_list[3].real_reference=1.0;
10692 if (attribute_flag[4] == 0)
10693 argument_list[4].real_reference=0.0;
10694 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10695 argument_list[3].real_reference,argument_list[4].real_reference,
10699 case 115: /* EncipherImage */
10701 (void) EncipherImage(image,argument_list[0].string_reference,
10705 case 116: /* DecipherImage */
10707 (void) DecipherImage(image,argument_list[0].string_reference,
10711 case 117: /* Deskew */
10713 geometry_info.rho=QuantumRange/2.0;
10714 if (attribute_flag[0] != 0)
10715 flags=ParseGeometry(argument_list[0].string_reference,
10717 if (attribute_flag[1] != 0)
10718 geometry_info.rho=StringToDoubleInterval(
10719 argument_list[1].string_reference,(double) QuantumRange+1.0);
10720 image=DeskewImage(image,geometry_info.rho,exception);
10723 case 118: /* Remap */
10728 if (attribute_flag[0] == 0)
10730 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10732 goto PerlException;
10734 quantize_info=AcquireQuantizeInfo(info->image_info);
10735 if (attribute_flag[1] != 0)
10736 quantize_info->dither_method=(DitherMethod)
10737 argument_list[1].integer_reference;
10738 (void) RemapImages(quantize_info,image,
10739 argument_list[0].image_reference,exception);
10740 quantize_info=DestroyQuantizeInfo(quantize_info);
10743 case 119: /* SparseColor */
10755 number_coordinates;
10760 if (attribute_flag[0] == 0)
10762 method=UndefinedColorInterpolate;
10763 if (attribute_flag[1] != 0)
10764 method=(SparseColorMethod) argument_list[1].integer_reference;
10765 av=(AV *) argument_list[0].array_reference;
10766 number_coordinates=(size_t) av_len(av)+1;
10767 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10768 sizeof(*coordinates));
10769 if (coordinates == (double *) NULL)
10771 ThrowPerlException(exception,ResourceLimitFatalError,
10772 "MemoryAllocationFailed",PackageName);
10773 goto PerlException;
10775 for (j=0; j < (ssize_t) number_coordinates; j++)
10776 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10777 virtual_pixel=UndefinedVirtualPixelMethod;
10778 if (attribute_flag[2] != 0)
10779 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10780 argument_list[2].integer_reference,exception);
10781 if (attribute_flag[3] != 0)
10782 channel=(ChannelType) argument_list[3].integer_reference;
10783 channel_mask=SetImageChannelMask(image,channel);
10784 image=SparseColorImage(image,method,number_coordinates,coordinates,
10786 if (image != (Image *) NULL)
10787 (void) SetImageChannelMask(image,channel_mask);
10788 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10789 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10791 coordinates=(double *) RelinquishMagickMemory(coordinates);
10794 case 120: /* Function */
10811 if (attribute_flag[0] == 0)
10813 function=UndefinedFunction;
10814 if (attribute_flag[1] != 0)
10815 function=(MagickFunction) argument_list[1].integer_reference;
10816 av=(AV *) argument_list[0].array_reference;
10817 number_parameters=(size_t) av_len(av)+1;
10818 parameters=(double *) AcquireQuantumMemory(number_parameters,
10819 sizeof(*parameters));
10820 if (parameters == (double *) NULL)
10822 ThrowPerlException(exception,ResourceLimitFatalError,
10823 "MemoryAllocationFailed",PackageName);
10824 goto PerlException;
10826 for (j=0; j < (ssize_t) number_parameters; j++)
10827 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10828 virtual_pixel=UndefinedVirtualPixelMethod;
10829 if (attribute_flag[2] != 0)
10830 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10831 argument_list[2].integer_reference,exception);
10832 (void) FunctionImage(image,function,number_parameters,parameters,
10834 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10835 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10837 parameters=(double *) RelinquishMagickMemory(parameters);
10840 case 121: /* SelectiveBlur */
10842 if (attribute_flag[0] != 0)
10844 flags=ParseGeometry(argument_list[0].string_reference,
10846 if ((flags & SigmaValue) == 0)
10847 geometry_info.sigma=1.0;
10848 if ((flags & PercentValue) != 0)
10849 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10851 if (attribute_flag[1] != 0)
10852 geometry_info.rho=argument_list[1].real_reference;
10853 if (attribute_flag[2] != 0)
10854 geometry_info.sigma=argument_list[2].real_reference;
10855 if (attribute_flag[3] != 0)
10856 geometry_info.xi=argument_list[3].integer_reference;;
10857 if (attribute_flag[5] != 0)
10858 channel=(ChannelType) argument_list[5].integer_reference;
10859 channel_mask=SetImageChannelMask(image,channel);
10860 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10861 geometry_info.xi,exception);
10862 if (image != (Image *) NULL)
10863 (void) SetImageChannelMask(image,channel_mask);
10866 case 122: /* HaldClut */
10868 if (attribute_flag[0] == 0)
10870 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10872 goto PerlException;
10874 if (attribute_flag[1] != 0)
10875 channel=(ChannelType) argument_list[1].integer_reference;
10876 channel_mask=SetImageChannelMask(image,channel);
10877 (void) HaldClutImage(image,argument_list[0].image_reference,
10879 (void) SetImageChannelMask(image,channel_mask);
10882 case 123: /* BlueShift */
10884 if (attribute_flag[0] != 0)
10885 (void) ParseGeometry(argument_list[0].string_reference,
10887 image=BlueShiftImage(image,geometry_info.rho,exception);
10890 case 124: /* ForwardFourierTransformImage */
10892 image=ForwardFourierTransformImage(image,
10893 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10897 case 125: /* InverseFourierTransformImage */
10899 image=InverseFourierTransformImage(image,image->next,
10900 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10904 case 126: /* ColorDecisionList */
10906 if (attribute_flag[0] == 0)
10907 argument_list[0].string_reference=(char *) NULL;
10908 (void) ColorDecisionListImage(image,
10909 argument_list[0].string_reference,exception);
10912 case 127: /* AutoGamma */
10914 if (attribute_flag[0] != 0)
10915 channel=(ChannelType) argument_list[0].integer_reference;
10916 channel_mask=SetImageChannelMask(image,channel);
10917 (void) AutoGammaImage(image,exception);
10918 (void) SetImageChannelMask(image,channel_mask);
10921 case 128: /* AutoLevel */
10923 if (attribute_flag[0] != 0)
10924 channel=(ChannelType) argument_list[0].integer_reference;
10925 channel_mask=SetImageChannelMask(image,channel);
10926 (void) AutoLevelImage(image,exception);
10927 (void) SetImageChannelMask(image,channel_mask);
10930 case 129: /* LevelColors */
10936 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10938 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10940 if (attribute_flag[1] != 0)
10941 (void) QueryColorCompliance(
10942 argument_list[1].string_reference,AllCompliance,&black_point,
10944 if (attribute_flag[2] != 0)
10945 (void) QueryColorCompliance(
10946 argument_list[2].string_reference,AllCompliance,&white_point,
10948 if (attribute_flag[3] != 0)
10949 channel=(ChannelType) argument_list[3].integer_reference;
10950 channel_mask=SetImageChannelMask(image,channel);
10951 (void) LevelImageColors(image,&black_point,&white_point,
10952 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10954 (void) SetImageChannelMask(image,channel_mask);
10957 case 130: /* Clamp */
10959 if (attribute_flag[0] != 0)
10960 channel=(ChannelType) argument_list[0].integer_reference;
10961 channel_mask=SetImageChannelMask(image,channel);
10962 (void) ClampImage(image,exception);
10963 (void) SetImageChannelMask(image,channel_mask);
10966 case 131: /* BrightnessContrast */
10974 if (attribute_flag[0] != 0)
10976 flags=ParseGeometry(argument_list[0].string_reference,
10978 brightness=geometry_info.rho;
10979 if ((flags & SigmaValue) == 0)
10980 contrast=geometry_info.sigma;
10982 if (attribute_flag[1] != 0)
10983 brightness=argument_list[1].real_reference;
10984 if (attribute_flag[2] != 0)
10985 contrast=argument_list[2].real_reference;
10986 if (attribute_flag[4] != 0)
10987 channel=(ChannelType) argument_list[4].integer_reference;
10988 channel_mask=SetImageChannelMask(image,channel);
10989 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10990 (void) SetImageChannelMask(image,channel_mask);
10993 case 132: /* Morphology */
11004 if (attribute_flag[0] == 0)
11006 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11007 if (kernel == (KernelInfo *) NULL)
11009 if (attribute_flag[1] != 0)
11010 channel=(ChannelType) argument_list[1].integer_reference;
11011 method=UndefinedMorphology;
11012 if (attribute_flag[2] != 0)
11013 method=argument_list[2].integer_reference;
11015 if (attribute_flag[3] != 0)
11016 iterations=argument_list[3].integer_reference;
11017 channel_mask=SetImageChannelMask(image,channel);
11018 image=MorphologyImage(image,method,iterations,kernel,exception);
11019 if (image != (Image *) NULL)
11020 (void) SetImageChannelMask(image,channel_mask);
11021 kernel=DestroyKernelInfo(kernel);
11024 case 133: /* Mode */
11026 if (attribute_flag[0] != 0)
11028 flags=ParseGeometry(argument_list[0].string_reference,
11030 if ((flags & SigmaValue) == 0)
11031 geometry_info.sigma=1.0;
11033 if (attribute_flag[1] != 0)
11034 geometry_info.rho=argument_list[1].real_reference;
11035 if (attribute_flag[2] != 0)
11036 geometry_info.sigma=argument_list[2].real_reference;
11037 if (attribute_flag[3] != 0)
11038 channel=(ChannelType) argument_list[3].integer_reference;
11039 channel_mask=SetImageChannelMask(image,channel);
11040 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11041 (size_t) geometry_info.sigma,exception);
11042 if (image != (Image *) NULL)
11043 (void) SetImageChannelMask(image,channel_mask);
11046 case 134: /* Statistic */
11051 statistic=UndefinedStatistic;
11052 if (attribute_flag[0] != 0)
11054 flags=ParseGeometry(argument_list[0].string_reference,
11056 if ((flags & SigmaValue) == 0)
11057 geometry_info.sigma=1.0;
11059 if (attribute_flag[1] != 0)
11060 geometry_info.rho=argument_list[1].real_reference;
11061 if (attribute_flag[2] != 0)
11062 geometry_info.sigma=argument_list[2].real_reference;
11063 if (attribute_flag[3] != 0)
11064 channel=(ChannelType) argument_list[3].integer_reference;
11065 if (attribute_flag[4] != 0)
11066 statistic=(StatisticType) argument_list[4].integer_reference;
11067 channel_mask=SetImageChannelMask(image,channel);
11068 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11069 (size_t) geometry_info.sigma,exception);
11070 if (image != (Image *) NULL)
11071 (void) SetImageChannelMask(image,channel_mask);
11074 case 135: /* Perceptible */
11079 epsilon=MagickEpsilon;
11080 if (attribute_flag[0] != 0)
11081 epsilon=argument_list[0].real_reference;
11082 if (attribute_flag[1] != 0)
11083 channel=(ChannelType) argument_list[1].integer_reference;
11084 channel_mask=SetImageChannelMask(image,channel);
11085 (void) PerceptibleImage(image,epsilon,exception);
11086 (void) SetImageChannelMask(image,channel_mask);
11089 case 136: /* Poly */
11100 if (attribute_flag[0] == 0)
11102 if (attribute_flag[1] != 0)
11103 channel=(ChannelType) argument_list[1].integer_reference;
11104 av=(AV *) argument_list[0].array_reference;
11105 number_terms=(size_t) av_len(av);
11106 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11107 if (terms == (double *) NULL)
11109 ThrowPerlException(exception,ResourceLimitFatalError,
11110 "MemoryAllocationFailed",PackageName);
11111 goto PerlException;
11113 for (j=0; j < av_len(av); j++)
11114 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11115 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11116 terms=(double *) RelinquishMagickMemory(terms);
11119 case 137: /* Grayscale */
11121 PixelIntensityMethod
11124 method=UndefinedPixelIntensityMethod;
11125 if (attribute_flag[0] != 0)
11126 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11127 (void) GrayscaleImage(image,method,exception);
11130 case 138: /* Canny */
11132 if (attribute_flag[0] != 0)
11134 flags=ParseGeometry(argument_list[0].string_reference,
11136 if ((flags & SigmaValue) == 0)
11137 geometry_info.sigma=1.0;
11138 if ((flags & XiValue) == 0)
11139 geometry_info.xi=0.10;
11140 if ((flags & PsiValue) == 0)
11141 geometry_info.psi=0.30;
11142 if ((flags & PercentValue) != 0)
11144 geometry_info.xi/=100.0;
11145 geometry_info.psi/=100.0;
11148 if (attribute_flag[1] != 0)
11149 geometry_info.rho=argument_list[1].real_reference;
11150 if (attribute_flag[2] != 0)
11151 geometry_info.sigma=argument_list[2].real_reference;
11152 if (attribute_flag[3] != 0)
11153 geometry_info.xi=argument_list[3].real_reference;
11154 if (attribute_flag[4] != 0)
11155 geometry_info.psi=argument_list[4].real_reference;
11156 if (attribute_flag[5] != 0)
11157 channel=(ChannelType) argument_list[5].integer_reference;
11158 channel_mask=SetImageChannelMask(image,channel);
11159 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11160 geometry_info.xi,geometry_info.psi,exception);
11161 if (image != (Image *) NULL)
11162 (void) SetImageChannelMask(image,channel_mask);
11165 case 139: /* HoughLine */
11167 if (attribute_flag[0] != 0)
11169 flags=ParseGeometry(argument_list[0].string_reference,
11171 if ((flags & SigmaValue) == 0)
11172 geometry_info.sigma=geometry_info.rho;
11173 if ((flags & XiValue) == 0)
11174 geometry_info.xi=40;
11176 if (attribute_flag[1] != 0)
11177 geometry_info.rho=(double) argument_list[1].integer_reference;
11178 if (attribute_flag[2] != 0)
11179 geometry_info.sigma=(double) argument_list[2].integer_reference;
11180 if (attribute_flag[3] != 0)
11181 geometry_info.xi=(double) argument_list[3].integer_reference;
11182 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11183 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11186 case 140: /* MeanShift */
11188 if (attribute_flag[0] != 0)
11190 flags=ParseGeometry(argument_list[0].string_reference,
11192 if ((flags & SigmaValue) == 0)
11193 geometry_info.sigma=geometry_info.rho;
11194 if ((flags & XiValue) == 0)
11195 geometry_info.xi=0.10*QuantumRange;
11196 if ((flags & PercentValue) != 0)
11197 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11199 if (attribute_flag[1] != 0)
11200 geometry_info.rho=(double) argument_list[1].integer_reference;
11201 if (attribute_flag[2] != 0)
11202 geometry_info.sigma=(double) argument_list[2].integer_reference;
11203 if (attribute_flag[3] != 0)
11204 geometry_info.xi=(double) argument_list[3].integer_reference;
11205 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11206 geometry_info.sigma,geometry_info.xi,exception);
11209 case 141: /* Kuwahara */
11211 if (attribute_flag[0] != 0)
11213 flags=ParseGeometry(argument_list[0].string_reference,
11215 if ((flags & SigmaValue) == 0)
11216 geometry_info.sigma=geometry_info.rho-0.5;
11218 if (attribute_flag[1] != 0)
11219 geometry_info.rho=argument_list[1].real_reference;
11220 if (attribute_flag[2] != 0)
11221 geometry_info.sigma=argument_list[2].real_reference;
11222 if (attribute_flag[3] != 0)
11223 channel=(ChannelType) argument_list[3].integer_reference;
11224 channel_mask=SetImageChannelMask(image,channel);
11225 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11227 if (image != (Image *) NULL)
11228 (void) SetImageChannelMask(image,channel_mask);
11231 case 142: /* ConnectedComponent */
11237 if (attribute_flag[0] != 0)
11238 connectivity=argument_list[0].integer_reference;
11239 image=ConnectedComponentsImage(image,connectivity,exception);
11242 case 143: /* Copy */
11253 source_image=image;
11254 if (attribute_flag[0] != 0)
11255 source_image=argument_list[0].image_reference;
11256 SetGeometry(source_image,&geometry);
11257 if (attribute_flag[1] != 0)
11258 flags=ParseGravityGeometry(source_image,
11259 argument_list[1].string_reference,&geometry,exception);
11260 if (attribute_flag[2] != 0)
11261 geometry.width=argument_list[2].integer_reference;
11262 if (attribute_flag[3] != 0)
11263 geometry.height=argument_list[3].integer_reference;
11264 if (attribute_flag[4] != 0)
11265 geometry.x=argument_list[4].integer_reference;
11266 if (attribute_flag[5] != 0)
11267 geometry.y=argument_list[5].integer_reference;
11268 if (attribute_flag[6] != 0)
11269 image->gravity=(GravityType) argument_list[6].integer_reference;
11270 SetGeometry(image,&offset_geometry);
11271 if (attribute_flag[7] != 0)
11272 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11273 &offset_geometry,exception);
11274 offset.x=offset_geometry.x;
11275 offset.y=offset_geometry.y;
11276 if (attribute_flag[8] != 0)
11277 offset.x=argument_list[8].integer_reference;
11278 if (attribute_flag[9] != 0)
11279 offset.y=argument_list[9].integer_reference;
11280 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11285 if (next != (Image *) NULL)
11286 (void) CatchImageException(next);
11287 if (region_image != (Image *) NULL)
11292 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11293 region_info.x,region_info.y,exception);
11295 (void) CatchImageException(region_image);
11296 image=DestroyImage(image);
11297 image=region_image;
11299 if (image != (Image *) NULL)
11302 if (next && (next != image))
11304 image->next=next->next;
11305 if (image->next != (Image *) NULL)
11306 image->next->previous=image;
11307 DeleteImageFromRegistry(*pv,next);
11309 sv_setiv(*pv,PTR2IV(image));
11317 if (reference_vector)
11318 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11319 InheritPerlException(exception,perl_exception);
11320 exception=DestroyExceptionInfo(exception);
11321 sv_setiv(perl_exception,(IV) number_images);
11322 SvPOK_on(perl_exception);
11323 ST(0)=sv_2mortal(perl_exception);
11328 ###############################################################################
11336 ###############################################################################
11341 Image::Magick ref=NO_INIT
11386 PERL_UNUSED_VAR(ref);
11387 PERL_UNUSED_VAR(ix);
11388 exception=AcquireExceptionInfo();
11389 perl_exception=newSVpv("",0);
11392 if (sv_isobject(ST(0)) == 0)
11394 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11396 goto PerlException;
11398 reference=SvRV(ST(0));
11399 hv=SvSTASH(reference);
11401 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11403 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11404 if (image == (Image *) NULL)
11406 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11408 goto PerlException;
11413 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11414 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11415 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11417 for (i=2; i < items; i+=2)
11419 attribute=(char *) SvPV(ST(i-1),na);
11420 switch (*attribute)
11425 if (LocaleCompare(attribute,"background") == 0)
11427 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11428 &montage_info->background_color,exception);
11429 for (next=image; next; next=next->next)
11430 next->background_color=montage_info->background_color;
11433 if (LocaleCompare(attribute,"border") == 0)
11435 montage_info->border_width=SvIV(ST(i));
11438 if (LocaleCompare(attribute,"bordercolor") == 0)
11440 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11441 &montage_info->border_color,exception);
11442 for (next=image; next; next=next->next)
11443 next->border_color=montage_info->border_color;
11446 if (LocaleCompare(attribute,"borderwidth") == 0)
11448 montage_info->border_width=SvIV(ST(i));
11451 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11458 if (LocaleCompare(attribute,"compose") == 0)
11460 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11461 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11464 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11468 for (next=image; next; next=next->next)
11469 next->compose=(CompositeOperator) sp;
11472 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11479 if (LocaleCompare(attribute,"fill") == 0)
11481 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11482 &montage_info->fill,exception);
11485 if (LocaleCompare(attribute,"font") == 0)
11487 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11490 if (LocaleCompare(attribute,"frame") == 0)
11496 if (IsGeometry(p) == MagickFalse)
11498 ThrowPerlException(exception,OptionError,"MissingGeometry",
11502 (void) CloneString(&montage_info->frame,p);
11504 montage_info->frame=(char *) NULL;
11507 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11514 if (LocaleCompare(attribute,"geometry") == 0)
11520 if (IsGeometry(p) == MagickFalse)
11522 ThrowPerlException(exception,OptionError,"MissingGeometry",
11526 (void) CloneString(&montage_info->geometry,p);
11528 montage_info->geometry=(char *) NULL;
11531 if (LocaleCompare(attribute,"gravity") == 0)
11536 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11537 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11540 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11544 montage_info->gravity=(GravityType) in;
11545 for (next=image; next; next=next->next)
11546 next->gravity=(GravityType) in;
11549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11556 if (LocaleCompare(attribute,"label") == 0)
11558 for (next=image; next; next=next->next)
11559 (void) SetImageProperty(next,"label",InterpretImageProperties(
11560 info ? info->image_info : (ImageInfo *) NULL,next,
11561 SvPV(ST(i),na),exception),exception);
11564 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11571 if (LocaleCompare(attribute,"mattecolor") == 0)
11573 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11574 &montage_info->matte_color,exception);
11575 for (next=image; next; next=next->next)
11576 next->matte_color=montage_info->matte_color;
11579 if (LocaleCompare(attribute,"mode") == 0)
11584 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11585 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11590 ThrowPerlException(exception,OptionError,
11591 "UnrecognizedModeType",SvPV(ST(i),na));
11596 (void) CloneString(&montage_info->frame,"15x15+3+3");
11597 montage_info->shadow=MagickTrue;
11602 montage_info->frame=(char *) NULL;
11603 montage_info->shadow=MagickFalse;
11604 montage_info->border_width=0;
11607 case ConcatenateMode:
11609 montage_info->frame=(char *) NULL;
11610 montage_info->shadow=MagickFalse;
11611 (void) CloneString(&montage_info->geometry,"+0+0");
11612 montage_info->border_width=0;
11617 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11624 if (LocaleCompare(attribute,"pointsize") == 0)
11626 montage_info->pointsize=SvIV(ST(i));
11629 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11636 if (LocaleCompare(attribute,"shadow") == 0)
11638 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11639 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11642 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11646 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11649 if (LocaleCompare(attribute,"stroke") == 0)
11651 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11652 &montage_info->stroke,exception);
11655 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11662 if (LocaleCompare(attribute,"texture") == 0)
11664 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11667 if (LocaleCompare(attribute,"tile") == 0)
11669 char *p=SvPV(ST(i),na);
11670 if (IsGeometry(p) == MagickFalse)
11672 ThrowPerlException(exception,OptionError,"MissingGeometry",
11676 (void) CloneString(&montage_info->tile,p);
11678 montage_info->tile=(char *) NULL;
11681 if (LocaleCompare(attribute,"title") == 0)
11683 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11686 if (LocaleCompare(attribute,"transparent") == 0)
11691 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11692 &transparent_color,exception);
11693 for (next=image; next; next=next->next)
11694 (void) TransparentPaintImage(next,&transparent_color,
11695 TransparentAlpha,MagickFalse,exception);
11698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11704 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11710 image=MontageImageList(info->image_info,montage_info,image,exception);
11711 montage_info=DestroyMontageInfo(montage_info);
11712 if (image == (Image *) NULL)
11713 goto PerlException;
11714 if (transparent_color.alpha != TransparentAlpha)
11715 for (next=image; next; next=next->next)
11716 (void) TransparentPaintImage(next,&transparent_color,
11717 TransparentAlpha,MagickFalse,exception);
11718 for ( ; image; image=image->next)
11720 AddImageToRegistry(sv,image);
11722 av_push(av,sv_bless(rv,hv));
11725 exception=DestroyExceptionInfo(exception);
11726 ST(0)=av_reference;
11727 SvREFCNT_dec(perl_exception);
11731 InheritPerlException(exception,perl_exception);
11732 exception=DestroyExceptionInfo(exception);
11733 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11734 SvPOK_on(perl_exception);
11735 ST(0)=sv_2mortal(perl_exception);
11740 ###############################################################################
11748 ###############################################################################
11753 Image::Magick ref=NO_INIT
11791 PERL_UNUSED_VAR(ref);
11792 PERL_UNUSED_VAR(ix);
11793 exception=AcquireExceptionInfo();
11794 perl_exception=newSVpv("",0);
11798 if (sv_isobject(ST(0)) == 0)
11800 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11802 goto PerlException;
11804 reference=SvRV(ST(0));
11805 hv=SvSTASH(reference);
11807 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11809 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11810 if (image == (Image *) NULL)
11812 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11814 goto PerlException;
11816 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11821 for (i=2; i < items; i+=2)
11823 attribute=(char *) SvPV(ST(i-1),na);
11824 switch (*attribute)
11829 if (LocaleCompare(attribute,"frames") == 0)
11831 number_frames=SvIV(ST(i));
11834 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11840 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11846 image=MorphImages(image,number_frames,exception);
11847 if (image == (Image *) NULL)
11848 goto PerlException;
11849 for ( ; image; image=image->next)
11851 AddImageToRegistry(sv,image);
11853 av_push(av,sv_bless(rv,hv));
11856 exception=DestroyExceptionInfo(exception);
11857 ST(0)=av_reference;
11858 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11862 InheritPerlException(exception,perl_exception);
11863 exception=DestroyExceptionInfo(exception);
11864 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11865 SvPOK_on(perl_exception);
11866 ST(0)=sv_2mortal(perl_exception);
11871 ###############################################################################
11879 ###############################################################################
11884 Image::Magick ref=NO_INIT
11912 PERL_UNUSED_VAR(ref);
11913 PERL_UNUSED_VAR(ix);
11914 exception=AcquireExceptionInfo();
11915 perl_exception=newSVpv("",0);
11917 if (sv_isobject(ST(0)) == 0)
11919 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11921 goto PerlException;
11923 reference=SvRV(ST(0));
11924 hv=SvSTASH(reference);
11925 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11926 if (image == (Image *) NULL)
11928 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11930 goto PerlException;
11932 image=MergeImageLayers(image,MosaicLayer,exception);
11934 Create blessed Perl array for the returned image.
11937 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11939 AddImageToRegistry(sv,image);
11941 av_push(av,sv_bless(rv,hv));
11943 (void) CopyMagickString(info->image_info->filename,image->filename,
11945 SetImageInfo(info->image_info,0,exception);
11946 exception=DestroyExceptionInfo(exception);
11947 SvREFCNT_dec(perl_exception);
11951 InheritPerlException(exception,perl_exception);
11952 exception=DestroyExceptionInfo(exception);
11953 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11954 SvPOK_on(perl_exception); /* return messages in string context */
11955 ST(0)=sv_2mortal(perl_exception);
11960 ###############################################################################
11968 ###############################################################################
11973 Image::Magick ref=NO_INIT
12023 PERL_UNUSED_VAR(ref);
12024 PERL_UNUSED_VAR(ix);
12025 exception=AcquireExceptionInfo();
12026 perl_exception=newSVpv("",0);
12027 package_info=(struct PackageInfo *) NULL;
12028 ac=(items < 2) ? 1 : items-1;
12029 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12031 length=(STRLEN *) NULL;
12032 if (list == (char **) NULL)
12034 ThrowPerlException(exception,ResourceLimitError,
12035 "MemoryAllocationFailed",PackageName);
12036 goto PerlException;
12039 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12040 if (length == (STRLEN *) NULL)
12042 ThrowPerlException(exception,ResourceLimitError,
12043 "MemoryAllocationFailed",PackageName);
12044 goto PerlException;
12046 if (sv_isobject(ST(0)) == 0)
12048 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12050 goto PerlException;
12052 reference=SvRV(ST(0));
12053 if (SvTYPE(reference) != SVt_PVAV)
12055 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12057 goto PerlException;
12059 av=(AV *) reference;
12060 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12062 package_info=ClonePackageInfo(info,exception);
12065 *list=(char *) (*package_info->image_info->filename ?
12066 package_info->image_info->filename : "XC:black");
12068 for (n=0, i=0; i < ac; i++)
12070 list[n]=(char *) SvPV(ST(i+1),length[n]);
12071 if ((items >= 3) && strEQcase(list[n],"blob"))
12077 blob=(void *) (SvPV(ST(i+1),length[n]));
12078 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12080 if ((items >= 3) && strEQcase(list[n],"filename"))
12082 if ((items >= 3) && strEQcase(list[n],"file"))
12091 io_info=IoIFP(sv_2io(ST(i+1)));
12092 if (io_info == (PerlIO *) NULL)
12094 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12098 file=PerlIO_findFILE(io_info);
12099 if (file == (FILE *) NULL)
12101 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12105 SetImageInfoFile(package_info->image_info,file);
12107 if ((items >= 3) && strEQcase(list[n],"magick"))
12111 list[n]=(char *) NULL;
12113 status=ExpandFilenames(&n,&list);
12114 if (status == MagickFalse)
12116 ThrowPerlException(exception,ResourceLimitError,
12117 "MemoryAllocationFailed",PackageName);
12118 goto PerlException;
12121 for (i=0; i < n; i++)
12123 (void) CopyMagickString(package_info->image_info->filename,list[i],
12125 image=PingImage(package_info->image_info,exception);
12126 if (image == (Image *) NULL)
12128 if ((package_info->image_info->file != (FILE *) NULL) ||
12129 (package_info->image_info->blob != (void *) NULL))
12130 DisassociateImageStream(image);
12131 count+=GetImageListLength(image);
12132 EXTEND(sp,4*count);
12133 for (next=image; next; next=next->next)
12135 PUSHs(sv_2mortal(newSViv(next->columns)));
12136 PUSHs(sv_2mortal(newSViv(next->rows)));
12137 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12138 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12140 image=DestroyImageList(image);
12145 for (i=0; i < n; i++)
12146 if (list[i] != (char *) NULL)
12147 for (p=keep; list[i] != *p++; )
12150 list[i]=(char *) RelinquishMagickMemory(list[i]);
12155 if (package_info != (struct PackageInfo *) NULL)
12156 DestroyPackageInfo(package_info);
12157 if (list && (list != keep))
12158 list=(char **) RelinquishMagickMemory(list);
12160 keep=(char **) RelinquishMagickMemory(keep);
12162 length=(STRLEN *) RelinquishMagickMemory(length);
12163 InheritPerlException(exception,perl_exception);
12164 exception=DestroyExceptionInfo(exception);
12165 SvREFCNT_dec(perl_exception); /* throw away all errors */
12169 ###############################################################################
12177 ###############################################################################
12182 Image::Magick ref=NO_INIT
12215 PERL_UNUSED_VAR(ref);
12216 PERL_UNUSED_VAR(ix);
12217 exception=AcquireExceptionInfo();
12218 perl_exception=newSVpv("",0);
12221 if (sv_isobject(ST(0)) == 0)
12223 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12225 goto PerlException;
12227 reference=SvRV(ST(0));
12228 hv=SvSTASH(reference);
12230 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12232 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12233 if (image == (Image *) NULL)
12235 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12237 goto PerlException;
12239 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12240 preview_type=GammaPreview;
12242 preview_type=(PreviewType)
12243 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12244 for ( ; image; image=image->next)
12246 preview_image=PreviewImage(image,preview_type,exception);
12247 if (preview_image == (Image *) NULL)
12248 goto PerlException;
12249 AddImageToRegistry(sv,preview_image);
12251 av_push(av,sv_bless(rv,hv));
12254 exception=DestroyExceptionInfo(exception);
12255 ST(0)=av_reference;
12256 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12260 InheritPerlException(exception,perl_exception);
12261 exception=DestroyExceptionInfo(exception);
12262 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12263 SvPOK_on(perl_exception);
12264 ST(0)=sv_2mortal(perl_exception);
12269 ###############################################################################
12273 # Q u e r y C o l o r #
12277 ###############################################################################
12281 QueryColor(ref,...)
12282 Image::Magick ref=NO_INIT
12302 PERL_UNUSED_VAR(ref);
12303 PERL_UNUSED_VAR(ix);
12304 exception=AcquireExceptionInfo();
12305 perl_exception=newSVpv("",0);
12314 colorlist=GetColorInfoList("*",&colors,exception);
12316 for (i=0; i < (ssize_t) colors; i++)
12318 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12320 colorlist=(const ColorInfo **)
12321 RelinquishMagickMemory((ColorInfo **) colorlist);
12322 goto PerlException;
12324 EXTEND(sp,5*items);
12325 for (i=1; i < items; i++)
12327 name=(char *) SvPV(ST(i),na);
12328 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12333 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12334 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12335 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12336 if (color.colorspace == CMYKColorspace)
12337 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12338 if (color.alpha_trait != UndefinedPixelTrait)
12339 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12343 InheritPerlException(exception,perl_exception);
12344 exception=DestroyExceptionInfo(exception);
12345 SvREFCNT_dec(perl_exception);
12349 ###############################################################################
12353 # Q u e r y C o l o r N a m e #
12357 ###############################################################################
12361 QueryColorname(ref,...)
12362 Image::Magick ref=NO_INIT
12371 message[MagickPathExtent];
12390 *reference; /* reference is the SV* of ref=SvIV(reference) */
12392 PERL_UNUSED_VAR(ref);
12393 PERL_UNUSED_VAR(ix);
12394 exception=AcquireExceptionInfo();
12395 perl_exception=newSVpv("",0);
12396 reference=SvRV(ST(0));
12397 av=(AV *) reference;
12398 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12400 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12401 if (image == (Image *) NULL)
12403 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12405 goto PerlException;
12408 for (i=1; i < items; i++)
12410 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12412 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12414 PUSHs(sv_2mortal(newSVpv(message,0)));
12418 InheritPerlException(exception,perl_exception);
12419 exception=DestroyExceptionInfo(exception);
12420 SvREFCNT_dec(perl_exception);
12424 ###############################################################################
12428 # Q u e r y F o n t #
12432 ###############################################################################
12437 Image::Magick ref=NO_INIT
12444 message[MagickPathExtent];
12455 volatile const TypeInfo
12458 PERL_UNUSED_VAR(ref);
12459 PERL_UNUSED_VAR(ix);
12460 exception=AcquireExceptionInfo();
12461 perl_exception=newSVpv("",0);
12470 typelist=GetTypeInfoList("*",&types,exception);
12472 for (i=0; i < (ssize_t) types; i++)
12474 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12476 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12478 goto PerlException;
12480 EXTEND(sp,10*items);
12481 for (i=1; i < items; i++)
12483 name=(char *) SvPV(ST(i),na);
12484 type_info=GetTypeInfo(name,exception);
12485 if (type_info == (TypeInfo *) NULL)
12490 if (type_info->name == (char *) NULL)
12493 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12494 if (type_info->description == (char *) NULL)
12497 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12498 if (type_info->family == (char *) NULL)
12501 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12502 if (type_info->style == UndefinedStyle)
12505 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12506 type_info->style),0)));
12507 if (type_info->stretch == UndefinedStretch)
12510 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12511 type_info->stretch),0)));
12512 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12513 type_info->weight);
12514 PUSHs(sv_2mortal(newSVpv(message,0)));
12515 if (type_info->encoding == (char *) NULL)
12518 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12519 if (type_info->foundry == (char *) NULL)
12522 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12523 if (type_info->format == (char *) NULL)
12526 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12527 if (type_info->metrics == (char *) NULL)
12530 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12531 if (type_info->glyphs == (char *) NULL)
12534 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12538 InheritPerlException(exception,perl_exception);
12539 exception=DestroyExceptionInfo(exception);
12540 SvREFCNT_dec(perl_exception);
12544 ###############################################################################
12548 # Q u e r y F o n t M e t r i c s #
12552 ###############################################################################
12556 QueryFontMetrics(ref,...)
12557 Image::Magick ref=NO_INIT
12559 queryfontmetrics = 1
12606 *reference; /* reference is the SV* of ref=SvIV(reference) */
12611 PERL_UNUSED_VAR(ref);
12612 PERL_UNUSED_VAR(ix);
12613 exception=AcquireExceptionInfo();
12614 package_info=(struct PackageInfo *) NULL;
12615 perl_exception=newSVpv("",0);
12616 reference=SvRV(ST(0));
12617 av=(AV *) reference;
12618 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12620 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12621 if (image == (Image *) NULL)
12623 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12625 goto PerlException;
12627 package_info=ClonePackageInfo(info,exception);
12628 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12629 CloneString(&draw_info->text,"");
12630 current=draw_info->affine;
12631 GetAffineMatrix(&affine);
12634 EXTEND(sp,7*items);
12635 for (i=2; i < items; i+=2)
12637 attribute=(char *) SvPV(ST(i-1),na);
12638 switch (*attribute)
12643 if (LocaleCompare(attribute,"antialias") == 0)
12645 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12649 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12653 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12656 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12663 if (LocaleCompare(attribute,"density") == 0)
12665 CloneString(&draw_info->density,SvPV(ST(i),na));
12668 if (LocaleCompare(attribute,"direction") == 0)
12670 draw_info->direction=(DirectionType) ParseCommandOption(
12671 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12674 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12681 if (LocaleCompare(attribute,"encoding") == 0)
12683 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12686 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12693 if (LocaleCompare(attribute,"family") == 0)
12695 CloneString(&draw_info->family,SvPV(ST(i),na));
12698 if (LocaleCompare(attribute,"fill") == 0)
12701 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12702 &draw_info->fill,exception);
12705 if (LocaleCompare(attribute,"font") == 0)
12707 CloneString(&draw_info->font,SvPV(ST(i),na));
12710 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12717 if (LocaleCompare(attribute,"geometry") == 0)
12719 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12722 if (LocaleCompare(attribute,"gravity") == 0)
12724 draw_info->gravity=(GravityType) ParseCommandOption(
12725 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12728 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12735 if (LocaleCompare(attribute,"interline-spacing") == 0)
12737 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12738 draw_info->interline_spacing=geometry_info.rho;
12741 if (LocaleCompare(attribute,"interword-spacing") == 0)
12743 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12744 draw_info->interword_spacing=geometry_info.rho;
12747 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12754 if (LocaleCompare(attribute,"kerning") == 0)
12756 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12757 draw_info->kerning=geometry_info.rho;
12760 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12767 if (LocaleCompare(attribute,"pointsize") == 0)
12769 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12770 draw_info->pointsize=geometry_info.rho;
12773 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12780 if (LocaleCompare(attribute,"rotate") == 0)
12782 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12783 affine.rx=geometry_info.rho;
12784 affine.ry=geometry_info.sigma;
12785 if ((flags & SigmaValue) == 0)
12786 affine.ry=affine.rx;
12789 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12796 if (LocaleCompare(attribute,"scale") == 0)
12798 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12799 affine.sx=geometry_info.rho;
12800 affine.sy=geometry_info.sigma;
12801 if ((flags & SigmaValue) == 0)
12802 affine.sy=affine.sx;
12805 if (LocaleCompare(attribute,"skew") == 0)
12811 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12812 x_angle=geometry_info.rho;
12813 y_angle=geometry_info.sigma;
12814 if ((flags & SigmaValue) == 0)
12816 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12817 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12820 if (LocaleCompare(attribute,"stroke") == 0)
12823 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12824 &draw_info->stroke,exception);
12827 if (LocaleCompare(attribute,"style") == 0)
12829 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12833 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12837 draw_info->style=(StyleType) type;
12840 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12847 if (LocaleCompare(attribute,"text") == 0)
12849 CloneString(&draw_info->text,SvPV(ST(i),na));
12852 if (LocaleCompare(attribute,"translate") == 0)
12854 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12855 affine.tx=geometry_info.rho;
12856 affine.ty=geometry_info.sigma;
12857 if ((flags & SigmaValue) == 0)
12858 affine.ty=affine.tx;
12861 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12868 if (LocaleCompare(attribute,"weight") == 0)
12870 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12871 draw_info->weight=(size_t) geometry_info.rho;
12874 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12881 if (LocaleCompare(attribute,"x") == 0)
12883 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12884 x=geometry_info.rho;
12887 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12894 if (LocaleCompare(attribute,"y") == 0)
12896 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12897 y=geometry_info.rho;
12900 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12906 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12912 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12913 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12914 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12915 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12916 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12917 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12918 if (draw_info->geometry == (char *) NULL)
12920 draw_info->geometry=AcquireString((char *) NULL);
12921 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12922 "%.15g,%.15g",x,y);
12924 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12925 (void) CatchImageException(image);
12926 if (status == MagickFalse)
12930 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12931 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12932 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12933 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12934 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12935 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12936 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12937 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12938 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12939 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12940 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12941 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12942 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12944 draw_info=DestroyDrawInfo(draw_info);
12947 if (package_info != (struct PackageInfo *) NULL)
12948 DestroyPackageInfo(package_info);
12949 InheritPerlException(exception,perl_exception);
12950 exception=DestroyExceptionInfo(exception);
12951 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12955 ###############################################################################
12959 # 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 #
12963 ###############################################################################
12967 QueryMultilineFontMetrics(ref,...)
12968 Image::Magick ref=NO_INIT
12970 querymultilinefontmetrics = 1
13017 *reference; /* reference is the SV* of ref=SvIV(reference) */
13022 PERL_UNUSED_VAR(ref);
13023 PERL_UNUSED_VAR(ix);
13024 exception=AcquireExceptionInfo();
13025 package_info=(struct PackageInfo *) NULL;
13026 perl_exception=newSVpv("",0);
13027 reference=SvRV(ST(0));
13028 av=(AV *) reference;
13029 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13031 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13032 if (image == (Image *) NULL)
13034 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13036 goto PerlException;
13038 package_info=ClonePackageInfo(info,exception);
13039 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13040 CloneString(&draw_info->text,"");
13041 current=draw_info->affine;
13042 GetAffineMatrix(&affine);
13045 EXTEND(sp,7*items);
13046 for (i=2; i < items; i+=2)
13048 attribute=(char *) SvPV(ST(i-1),na);
13049 switch (*attribute)
13054 if (LocaleCompare(attribute,"antialias") == 0)
13056 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13060 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13064 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13067 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13074 if (LocaleCompare(attribute,"density") == 0)
13076 CloneString(&draw_info->density,SvPV(ST(i),na));
13079 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13086 if (LocaleCompare(attribute,"encoding") == 0)
13088 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13091 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13098 if (LocaleCompare(attribute,"family") == 0)
13100 CloneString(&draw_info->family,SvPV(ST(i),na));
13103 if (LocaleCompare(attribute,"fill") == 0)
13106 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13107 &draw_info->fill,exception);
13110 if (LocaleCompare(attribute,"font") == 0)
13112 CloneString(&draw_info->font,SvPV(ST(i),na));
13115 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13122 if (LocaleCompare(attribute,"geometry") == 0)
13124 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13127 if (LocaleCompare(attribute,"gravity") == 0)
13129 draw_info->gravity=(GravityType) ParseCommandOption(
13130 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13133 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13140 if (LocaleCompare(attribute,"pointsize") == 0)
13142 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13143 draw_info->pointsize=geometry_info.rho;
13146 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13153 if (LocaleCompare(attribute,"rotate") == 0)
13155 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13156 affine.rx=geometry_info.rho;
13157 affine.ry=geometry_info.sigma;
13158 if ((flags & SigmaValue) == 0)
13159 affine.ry=affine.rx;
13162 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13169 if (LocaleCompare(attribute,"scale") == 0)
13171 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13172 affine.sx=geometry_info.rho;
13173 affine.sy=geometry_info.sigma;
13174 if ((flags & SigmaValue) == 0)
13175 affine.sy=affine.sx;
13178 if (LocaleCompare(attribute,"skew") == 0)
13184 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13185 x_angle=geometry_info.rho;
13186 y_angle=geometry_info.sigma;
13187 if ((flags & SigmaValue) == 0)
13189 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13190 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13193 if (LocaleCompare(attribute,"stroke") == 0)
13196 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13197 &draw_info->stroke,exception);
13200 if (LocaleCompare(attribute,"style") == 0)
13202 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13206 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13210 draw_info->style=(StyleType) type;
13213 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13220 if (LocaleCompare(attribute,"text") == 0)
13222 CloneString(&draw_info->text,SvPV(ST(i),na));
13225 if (LocaleCompare(attribute,"translate") == 0)
13227 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13228 affine.tx=geometry_info.rho;
13229 affine.ty=geometry_info.sigma;
13230 if ((flags & SigmaValue) == 0)
13231 affine.ty=affine.tx;
13234 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13241 if (LocaleCompare(attribute,"weight") == 0)
13243 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13244 draw_info->weight=(size_t) geometry_info.rho;
13247 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13254 if (LocaleCompare(attribute,"x") == 0)
13256 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13257 x=geometry_info.rho;
13260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13267 if (LocaleCompare(attribute,"y") == 0)
13269 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13270 y=geometry_info.rho;
13273 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13279 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13285 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13286 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13287 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13288 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13289 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13290 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13291 if (draw_info->geometry == (char *) NULL)
13293 draw_info->geometry=AcquireString((char *) NULL);
13294 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13295 "%.15g,%.15g",x,y);
13297 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13298 (void) CatchException(exception);
13299 if (status == MagickFalse)
13303 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13304 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13305 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13306 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13307 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13308 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13309 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13310 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13311 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13312 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13313 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13314 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13315 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13317 draw_info=DestroyDrawInfo(draw_info);
13320 if (package_info != (struct PackageInfo *) NULL)
13321 DestroyPackageInfo(package_info);
13322 InheritPerlException(exception,perl_exception);
13323 exception=DestroyExceptionInfo(exception);
13324 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13328 ###############################################################################
13332 # Q u e r y F o r m a t #
13336 ###############################################################################
13340 QueryFormat(ref,...)
13341 Image::Magick ref=NO_INIT
13358 volatile const MagickInfo
13361 PERL_UNUSED_VAR(ref);
13362 PERL_UNUSED_VAR(ix);
13363 exception=AcquireExceptionInfo();
13364 perl_exception=newSVpv("",0);
13368 format[MagickPathExtent];
13376 format_list=GetMagickInfoList("*",&types,exception);
13378 for (i=0; i < (ssize_t) types; i++)
13380 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13381 LocaleLower(format);
13382 PUSHs(sv_2mortal(newSVpv(format,0)));
13384 format_list=(const MagickInfo **)
13385 RelinquishMagickMemory((MagickInfo *) format_list);
13386 goto PerlException;
13388 EXTEND(sp,8*items);
13389 for (i=1; i < items; i++)
13391 name=(char *) SvPV(ST(i),na);
13392 magick_info=GetMagickInfo(name,exception);
13393 if (magick_info == (const MagickInfo *) NULL)
13398 if (magick_info->description == (char *) NULL)
13401 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13402 if (magick_info->module == (char *) NULL)
13405 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13409 InheritPerlException(exception,perl_exception);
13410 exception=DestroyExceptionInfo(exception);
13411 SvREFCNT_dec(perl_exception);
13415 ###############################################################################
13419 # Q u e r y O p t i o n #
13423 ###############################################################################
13427 QueryOption(ref,...)
13428 Image::Magick ref=NO_INIT
13449 PERL_UNUSED_VAR(ref);
13450 PERL_UNUSED_VAR(ix);
13451 exception=AcquireExceptionInfo();
13452 perl_exception=newSVpv("",0);
13453 EXTEND(sp,8*items);
13454 for (i=1; i < items; i++)
13456 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13458 options=GetCommandOptions((CommandOption) option);
13459 if (options == (char **) NULL)
13463 for (j=0; options[j] != (char *) NULL; j++)
13464 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13465 options=DestroyStringList(options);
13469 InheritPerlException(exception,perl_exception);
13470 exception=DestroyExceptionInfo(exception);
13471 SvREFCNT_dec(perl_exception);
13475 ###############################################################################
13483 ###############################################################################
13488 Image::Magick ref=NO_INIT
13535 *perl_exception, /* Perl variable for storing messages */
13540 PERL_UNUSED_VAR(ref);
13541 PERL_UNUSED_VAR(ix);
13542 exception=AcquireExceptionInfo();
13543 perl_exception=newSVpv("",0);
13545 package_info=(struct PackageInfo *) NULL;
13547 ac=(items < 2) ? 1 : items-1;
13548 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13550 length=(STRLEN *) NULL;
13551 if (list == (char **) NULL)
13553 ThrowPerlException(exception,ResourceLimitError,
13554 "MemoryAllocationFailed",PackageName);
13555 goto PerlException;
13557 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13558 if (length == (STRLEN *) NULL)
13560 ThrowPerlException(exception,ResourceLimitError,
13561 "MemoryAllocationFailed",PackageName);
13562 goto PerlException;
13564 if (sv_isobject(ST(0)) == 0)
13566 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13568 goto PerlException;
13570 reference=SvRV(ST(0));
13571 hv=SvSTASH(reference);
13572 if (SvTYPE(reference) != SVt_PVAV)
13574 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13576 goto PerlException;
13578 av=(AV *) reference;
13579 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13581 package_info=ClonePackageInfo(info,exception);
13584 *list=(char *) (*package_info->image_info->filename ?
13585 package_info->image_info->filename : "XC:black");
13587 for (n=0, i=0; i < ac; i++)
13589 list[n]=(char *) SvPV(ST(i+1),length[n]);
13590 if ((items >= 3) && strEQcase(list[n],"blob"))
13596 blob=(void *) (SvPV(ST(i+1),length[n]));
13597 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13599 if ((items >= 3) && strEQcase(list[n],"filename"))
13601 if ((items >= 3) && strEQcase(list[n],"file"))
13610 io_info=IoIFP(sv_2io(ST(i+1)));
13611 if (io_info == (PerlIO *) NULL)
13613 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13617 file=PerlIO_findFILE(io_info);
13618 if (file == (FILE *) NULL)
13620 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13624 SetImageInfoFile(package_info->image_info,file);
13626 if ((items >= 3) && strEQcase(list[n],"magick"))
13630 list[n]=(char *) NULL;
13632 status=ExpandFilenames(&n,&list);
13633 if (status == MagickFalse)
13635 ThrowPerlException(exception,ResourceLimitError,
13636 "MemoryAllocationFailed",PackageName);
13637 goto PerlException;
13640 for (i=0; i < n; i++)
13642 if ((package_info->image_info->file == (FILE *) NULL) &&
13643 (package_info->image_info->blob == (void *) NULL))
13644 image=ReadImages(package_info->image_info,list[i],exception);
13647 image=ReadImages(package_info->image_info,
13648 package_info->image_info->filename,exception);
13649 if (image != (Image *) NULL)
13650 DisassociateImageStream(image);
13652 if (image == (Image *) NULL)
13654 for ( ; image; image=image->next)
13656 AddImageToRegistry(sv,image);
13658 av_push(av,sv_bless(rv,hv));
13666 for (i=0; i < n; i++)
13667 if (list[i] != (char *) NULL)
13668 for (p=keep; list[i] != *p++; )
13669 if (*p == (char *) NULL)
13671 list[i]=(char *) RelinquishMagickMemory(list[i]);
13676 if (package_info != (struct PackageInfo *) NULL)
13677 DestroyPackageInfo(package_info);
13678 if (list && (list != keep))
13679 list=(char **) RelinquishMagickMemory(list);
13681 keep=(char **) RelinquishMagickMemory(keep);
13683 length=(STRLEN *) RelinquishMagickMemory(length);
13684 InheritPerlException(exception,perl_exception);
13685 exception=DestroyExceptionInfo(exception);
13686 sv_setiv(perl_exception,(IV) number_images);
13687 SvPOK_on(perl_exception);
13688 ST(0)=sv_2mortal(perl_exception);
13693 ###############################################################################
13701 ###############################################################################
13706 Image::Magick ref=NO_INIT
13729 PERL_UNUSED_VAR(ref);
13730 PERL_UNUSED_VAR(ix);
13731 exception=AcquireExceptionInfo();
13732 perl_exception=newSVpv("",0);
13733 reference=SvRV(ST(0));
13734 av=(AV *) reference;
13735 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13737 for (i=1; i < items; i++)
13738 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13739 SvPV(ST(i),na),exception);
13740 InheritPerlException(exception,perl_exception);
13741 exception=DestroyExceptionInfo(exception);
13742 SvREFCNT_dec(perl_exception); /* throw away all errors */
13746 ###############################################################################
13754 ###############################################################################
13759 Image::Magick ref=NO_INIT
13782 *reference; /* reference is the SV* of ref=SvIV(reference) */
13784 PERL_UNUSED_VAR(ref);
13785 PERL_UNUSED_VAR(ix);
13786 exception=AcquireExceptionInfo();
13787 perl_exception=newSVpv("",0);
13788 if (sv_isobject(ST(0)) == 0)
13790 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13792 goto PerlException;
13794 reference=SvRV(ST(0));
13795 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13797 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13799 for (i=2; i < items; i+=2)
13800 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13803 InheritPerlException(exception,perl_exception);
13804 exception=DestroyExceptionInfo(exception);
13805 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13806 SvPOK_on(perl_exception);
13807 ST(0)=sv_2mortal(perl_exception);
13812 ###############################################################################
13816 # S e t P i x e l #
13820 ###############################################################################
13825 Image::Magick ref=NO_INIT
13867 *reference; /* reference is the SV* of ref=SvIV(reference) */
13869 PERL_UNUSED_VAR(ref);
13870 PERL_UNUSED_VAR(ix);
13871 exception=AcquireExceptionInfo();
13872 perl_exception=newSVpv("",0);
13873 reference=SvRV(ST(0));
13874 av=(AV *) reference;
13875 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13877 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13878 if (image == (Image *) NULL)
13880 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13882 goto PerlException;
13885 normalize=MagickTrue;
13888 region.width=image->columns;
13891 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13892 channel=DefaultChannels;
13893 for (i=2; i < items; i+=2)
13895 attribute=(char *) SvPV(ST(i-1),na);
13896 switch (*attribute)
13901 if (LocaleCompare(attribute,"channel") == 0)
13906 option=ParseChannelOption(SvPV(ST(i),na));
13909 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13913 channel=(ChannelType) option;
13916 if (LocaleCompare(attribute,"color") == 0)
13918 if (SvTYPE(ST(i)) != SVt_RV)
13921 message[MagickPathExtent];
13923 (void) FormatLocaleString(message,MagickPathExtent,
13924 "invalid %.60s value",attribute);
13925 ThrowPerlException(exception,OptionError,message,
13928 av=(AV *) SvRV(ST(i));
13931 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13938 if (LocaleCompare(attribute,"geometry") == 0)
13940 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13943 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13950 if (LocaleCompare(attribute,"normalize") == 0)
13952 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13956 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13960 normalize=option != 0 ? MagickTrue : MagickFalse;
13963 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13970 if (LocaleCompare(attribute,"x") == 0)
13972 region.x=SvIV(ST(i));
13975 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13982 if (LocaleCompare(attribute,"y") == 0)
13984 region.y=SvIV(ST(i));
13987 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13993 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13999 (void) SetImageStorageClass(image,DirectClass,exception);
14000 channel_mask=SetImageChannelMask(image,channel);
14001 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14002 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14003 (SvTYPE(av) != SVt_PVAV))
14015 if (normalize != MagickFalse)
14016 scale=QuantumRange;
14017 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14020 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14021 av_fetch(av,i,0)))),q);
14024 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14027 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14028 av_fetch(av,i,0)))),q);
14031 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14034 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14035 av_fetch(av,i,0)))),q);
14038 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14039 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14041 SetPixelBlack(image,ClampToQuantum(scale*
14042 SvNV(*(av_fetch(av,i,0)))),q);
14045 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14048 SetPixelAlpha(image,ClampToQuantum(scale*
14049 SvNV(*(av_fetch(av,i,0)))),q);
14052 (void) SyncAuthenticPixels(image,exception);
14054 (void) SetImageChannelMask(image,channel_mask);
14057 InheritPerlException(exception,perl_exception);
14058 exception=DestroyExceptionInfo(exception);
14059 SvREFCNT_dec(perl_exception);
14063 ###############################################################################
14071 ###############################################################################
14076 Image::Magick ref=NO_INIT
14115 PERL_UNUSED_VAR(ref);
14116 PERL_UNUSED_VAR(ix);
14117 exception=AcquireExceptionInfo();
14118 perl_exception=newSVpv("",0);
14122 if (sv_isobject(ST(0)) == 0)
14124 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14126 goto PerlException;
14128 reference=SvRV(ST(0));
14129 hv=SvSTASH(reference);
14131 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14133 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14134 if (image == (Image *) NULL)
14136 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14138 goto PerlException;
14140 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14146 for (i=2; i < items; i+=2)
14148 attribute=(char *) SvPV(ST(i-1),na);
14149 switch (*attribute)
14154 if (LocaleCompare(attribute,"offset") == 0)
14156 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14159 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14166 if (LocaleCompare(attribute,"stack") == 0)
14168 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14172 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14178 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14184 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14190 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14192 if (image == (Image *) NULL)
14193 goto PerlException;
14194 for ( ; image; image=image->next)
14196 AddImageToRegistry(sv,image);
14198 av_push(av,sv_bless(rv,hv));
14201 exception=DestroyExceptionInfo(exception);
14202 ST(0)=av_reference;
14203 SvREFCNT_dec(perl_exception);
14207 InheritPerlException(exception,perl_exception);
14208 exception=DestroyExceptionInfo(exception);
14209 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14210 SvPOK_on(perl_exception);
14211 ST(0)=sv_2mortal(perl_exception);
14216 ###############################################################################
14220 # S t a t i s t i c s #
14224 ###############################################################################
14228 Statistics(ref,...)
14229 Image::Magick ref=NO_INIT
14231 StatisticsImage = 1
14233 statisticsimage = 3
14236 #define ChannelStatistics(channel) \
14238 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14239 (double) channel_statistics[channel].depth); \
14240 PUSHs(sv_2mortal(newSVpv(message,0))); \
14241 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14242 channel_statistics[channel].minima/scale); \
14243 PUSHs(sv_2mortal(newSVpv(message,0))); \
14244 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14245 channel_statistics[channel].maxima/scale); \
14246 PUSHs(sv_2mortal(newSVpv(message,0))); \
14247 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14248 channel_statistics[channel].mean/scale); \
14249 PUSHs(sv_2mortal(newSVpv(message,0))); \
14250 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14251 channel_statistics[channel].standard_deviation/scale); \
14252 PUSHs(sv_2mortal(newSVpv(message,0))); \
14253 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14254 channel_statistics[channel].kurtosis); \
14255 PUSHs(sv_2mortal(newSVpv(message,0))); \
14256 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14257 channel_statistics[channel].skewness); \
14258 PUSHs(sv_2mortal(newSVpv(message,0))); \
14259 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14260 channel_statistics[channel].entropy); \
14261 PUSHs(sv_2mortal(newSVpv(message,0))); \
14268 message[MagickPathExtent];
14271 *channel_statistics;
14292 PERL_UNUSED_VAR(ref);
14293 PERL_UNUSED_VAR(ix);
14294 exception=AcquireExceptionInfo();
14295 perl_exception=newSVpv("",0);
14297 if (sv_isobject(ST(0)) == 0)
14299 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14301 goto PerlException;
14303 reference=SvRV(ST(0));
14306 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14307 if (image == (Image *) NULL)
14309 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14311 goto PerlException;
14314 for ( ; image; image=image->next)
14316 channel_statistics=GetImageStatistics(image,exception);
14317 if (channel_statistics == (ChannelStatistics *) NULL)
14320 EXTEND(sp,35*count);
14321 scale=(double) QuantumRange;
14322 ChannelStatistics(RedChannel);
14323 ChannelStatistics(GreenChannel);
14324 ChannelStatistics(BlueChannel);
14325 if (image->colorspace == CMYKColorspace)
14326 ChannelStatistics(BlackChannel);
14327 if (image->alpha_trait != UndefinedPixelTrait)
14328 ChannelStatistics(AlphaChannel);
14329 channel_statistics=(ChannelStatistics *)
14330 RelinquishMagickMemory(channel_statistics);
14334 InheritPerlException(exception,perl_exception);
14335 exception=DestroyExceptionInfo(exception);
14336 SvREFCNT_dec(perl_exception);
14340 ###############################################################################
14344 # S y n c A u t h e n t i c P i x e l s #
14348 ###############################################################################
14352 SyncAuthenticPixels(ref,...)
14353 Image::Magick ref = NO_INIT
14355 Syncauthenticpixels = 1
14356 SyncImagePixels = 2
14357 syncimagepixels = 3
14376 PERL_UNUSED_VAR(ref);
14377 PERL_UNUSED_VAR(ix);
14378 exception=AcquireExceptionInfo();
14379 perl_exception=newSVpv("",0);
14380 if (sv_isobject(ST(0)) == 0)
14382 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14384 goto PerlException;
14387 reference=SvRV(ST(0));
14388 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14389 if (image == (Image *) NULL)
14391 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14393 goto PerlException;
14396 status=SyncAuthenticPixels(image,exception);
14397 if (status != MagickFalse)
14401 InheritPerlException(exception,perl_exception);
14402 exception=DestroyExceptionInfo(exception);
14403 SvREFCNT_dec(perl_exception); /* throw away all errors */
14407 ###############################################################################
14411 # T r a n s f o r m #
14415 ###############################################################################
14420 Image::Magick ref=NO_INIT
14458 PERL_UNUSED_VAR(ref);
14459 PERL_UNUSED_VAR(ix);
14460 exception=AcquireExceptionInfo();
14461 perl_exception=newSVpv("",0);
14465 if (sv_isobject(ST(0)) == 0)
14467 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14469 goto PerlException;
14471 reference=SvRV(ST(0));
14472 hv=SvSTASH(reference);
14474 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14476 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14477 if (image == (Image *) NULL)
14479 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14481 goto PerlException;
14483 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14487 crop_geometry=(char *) NULL;
14488 geometry=(char *) NULL;
14489 for (i=2; i < items; i+=2)
14491 attribute=(char *) SvPV(ST(i-1),na);
14492 switch (*attribute)
14497 if (LocaleCompare(attribute,"crop") == 0)
14499 crop_geometry=SvPV(ST(i),na);
14502 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14509 if (LocaleCompare(attribute,"geometry") == 0)
14511 geometry=SvPV(ST(i),na);
14514 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14520 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14526 for ( ; image; image=image->next)
14528 clone=CloneImage(image,0,0,MagickTrue,exception);
14529 if (clone == (Image *) NULL)
14530 goto PerlException;
14531 TransformImage(&clone,crop_geometry,geometry,exception);
14532 for ( ; clone; clone=clone->next)
14534 AddImageToRegistry(sv,clone);
14536 av_push(av,sv_bless(rv,hv));
14540 exception=DestroyExceptionInfo(exception);
14541 ST(0)=av_reference;
14542 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14546 InheritPerlException(exception,perl_exception);
14547 exception=DestroyExceptionInfo(exception);
14548 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14549 SvPOK_on(perl_exception);
14550 ST(0)=sv_2mortal(perl_exception);
14555 ###############################################################################
14563 ###############################################################################
14568 Image::Magick ref=NO_INIT
14576 filename[MagickPathExtent];
14600 PERL_UNUSED_VAR(ref);
14601 PERL_UNUSED_VAR(ix);
14602 exception=AcquireExceptionInfo();
14603 perl_exception=newSVpv("",0);
14605 package_info=(struct PackageInfo *) NULL;
14606 if (sv_isobject(ST(0)) == 0)
14608 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14610 goto PerlException;
14612 reference=SvRV(ST(0));
14613 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14614 if (image == (Image *) NULL)
14616 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14618 goto PerlException;
14620 package_info=ClonePackageInfo(info,exception);
14622 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14625 for (i=2; i < items; i+=2)
14626 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14628 (void) CopyMagickString(filename,package_info->image_info->filename,
14631 for (next=image; next; next=next->next)
14633 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14634 next->scene=scene++;
14636 *package_info->image_info->magick='\0';
14637 SetImageInfo(package_info->image_info,(unsigned int)
14638 GetImageListLength(image),exception);
14639 for (next=image; next; next=next->next)
14641 (void) WriteImage(package_info->image_info,next,exception);
14643 if (package_info->image_info->adjoin)
14648 if (package_info != (struct PackageInfo *) NULL)
14649 DestroyPackageInfo(package_info);
14650 InheritPerlException(exception,perl_exception);
14651 exception=DestroyExceptionInfo(exception);
14652 sv_setiv(perl_exception,(IV) number_images);
14653 SvPOK_on(perl_exception);
14654 ST(0)=sv_2mortal(perl_exception);