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-2016 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,ReadPixelMask,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,ReadPixelMask,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,"read-mask") == 0)
1921 mask=(Image *) NULL;
1923 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1924 for ( ; image; image=image->next)
1925 SetImageMask(image,ReadPixelMask,mask,exception);
1928 if (LocaleCompare(attribute,"red-primary") == 0)
1930 for ( ; image; image=image->next)
1932 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1933 image->chromaticity.red_primary.x=geometry_info.rho;
1934 image->chromaticity.red_primary.y=geometry_info.sigma;
1935 if ((flags & SigmaValue) == 0)
1936 image->chromaticity.red_primary.y=
1937 image->chromaticity.red_primary.x;
1941 if (LocaleCompare(attribute,"render") == 0)
1943 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1944 SvPV(sval,na)) : SvIV(sval);
1947 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1951 for ( ; image; image=image->next)
1952 image->rendering_intent=(RenderingIntent) sp;
1955 if (LocaleCompare(attribute,"repage") == 0)
1960 for ( ; image; image=image->next)
1962 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1963 if ((flags & WidthValue) != 0)
1965 if ((flags & HeightValue) == 0)
1966 geometry.height=geometry.width;
1967 image->page.width=geometry.width;
1968 image->page.height=geometry.height;
1970 if ((flags & AspectValue) != 0)
1972 if ((flags & XValue) != 0)
1973 image->page.x+=geometry.x;
1974 if ((flags & YValue) != 0)
1975 image->page.y+=geometry.y;
1979 if ((flags & XValue) != 0)
1981 image->page.x=geometry.x;
1982 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1983 image->page.width=image->columns+geometry.x;
1985 if ((flags & YValue) != 0)
1987 image->page.y=geometry.y;
1988 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1989 image->page.height=image->rows+geometry.y;
1996 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1997 for ( ; image; image=image->next)
1998 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2004 if (LocaleCompare(attribute,"sampling-factor") == 0)
2006 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2008 ThrowPerlException(exception,OptionError,"MissingGeometry",
2013 (void) CloneString(&info->image_info->sampling_factor,
2017 if (LocaleCompare(attribute,"scene") == 0)
2019 for ( ; image; image=image->next)
2020 image->scene=SvIV(sval);
2023 if (LocaleCompare(attribute,"server") == 0)
2025 if (LocaleCompare(attribute,"size") == 0)
2029 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2031 ThrowPerlException(exception,OptionError,"MissingGeometry",
2035 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2039 if (LocaleCompare(attribute,"stroke") == 0)
2042 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2046 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2047 for ( ; image; image=image->next)
2048 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2054 if (LocaleCompare(attribute,"texture") == 0)
2057 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2060 if (LocaleCompare(attribute,"thread-limit") == 0)
2065 limit=MagickResourceInfinity;
2066 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2067 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2069 (void) SetMagickResourceLimit(ThreadResource,limit);
2072 if (LocaleCompare(attribute,"tile-offset") == 0)
2077 geometry=GetPageGeometry(SvPV(sval,na));
2079 (void) CloneString(&info->image_info->page,geometry);
2080 for ( ; image; image=image->next)
2081 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2083 geometry=(char *) RelinquishMagickMemory(geometry);
2086 if (LocaleCompare(attribute,"time-limit") == 0)
2091 limit=MagickResourceInfinity;
2092 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2093 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2095 (void) SetMagickResourceLimit(TimeResource,limit);
2098 if (LocaleCompare(attribute,"transparent-color") == 0)
2100 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2103 info->image_info->transparent_color=target_color;
2104 for ( ; image; image=image->next)
2105 image->transparent_color=target_color;
2108 if (LocaleCompare(attribute,"type") == 0)
2110 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2111 SvPV(sval,na)) : SvIV(sval);
2114 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2119 info->image_info->type=(ImageType) sp;
2120 for ( ; image; image=image->next)
2121 SetImageType(image,(ImageType) sp,exception);
2125 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2126 for ( ; image; image=image->next)
2127 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2133 if (LocaleCompare(attribute,"units") == 0)
2135 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2136 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2139 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2144 info->image_info->units=(ResolutionType) sp;
2145 for ( ; image; image=image->next)
2150 units=(ResolutionType) sp;
2151 if (image->units != units)
2152 switch (image->units)
2154 case UndefinedResolution:
2155 case PixelsPerInchResolution:
2157 if (units == PixelsPerCentimeterResolution)
2159 image->resolution.x*=2.54;
2160 image->resolution.y*=2.54;
2164 case PixelsPerCentimeterResolution:
2166 if (units == PixelsPerInchResolution)
2168 image->resolution.x/=2.54;
2169 image->resolution.y/=2.54;
2179 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2180 for ( ; image; image=image->next)
2181 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2187 if (LocaleCompare(attribute,"verbose") == 0)
2189 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2190 SvPV(sval,na)) : SvIV(sval);
2193 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2198 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2201 if (LocaleCompare(attribute,"view") == 0)
2204 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2207 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2209 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2210 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2213 ThrowPerlException(exception,OptionError,
2214 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2217 for ( ; image; image=image->next)
2218 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2222 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2223 for ( ; image; image=image->next)
2224 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2230 if (LocaleCompare(attribute,"white-point") == 0)
2232 for ( ; image; image=image->next)
2234 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2235 image->chromaticity.white_point.x=geometry_info.rho;
2236 image->chromaticity.white_point.y=geometry_info.sigma;
2237 if ((flags & SigmaValue) == 0)
2238 image->chromaticity.white_point.y=
2239 image->chromaticity.white_point.x;
2243 if (LocaleCompare(attribute,"write-mask") == 0)
2248 mask=(Image *) NULL;
2250 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
2251 for ( ; image; image=image->next)
2252 SetImageMask(image,WritePixelMask,mask,exception);
2256 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2257 for ( ; image; image=image->next)
2258 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2264 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2265 for ( ; image; image=image->next)
2266 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2277 % S e t u p L i s t %
2281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2283 % Method SetupList returns the list of all the images linked by their
2284 % image->next and image->previous link lists for use with ImageMagick. If
2285 % info is non-NULL, an info structure is returned in *info. If
2286 % reference_vector is non-NULL,an array of SV* are returned in
2287 % *reference_vector. Reference_vector is used when the images are going to be
2288 % replaced with new Image*'s.
2290 % The format of the SetupList routine is:
2292 % Image *SetupList(SV *reference,struct PackageInfo **info,
2293 % SV ***reference_vector,ExceptionInfo *exception)
2295 % A description of each parameter follows:
2297 % o list: a list of strings.
2299 % o string: a character string.
2301 % o exception: Return any errors or warnings in this structure.
2304 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2305 SV ***reference_vector,ExceptionInfo *exception)
2314 if (reference_vector)
2315 *reference_vector=NULL;
2320 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2321 if (info && (SvTYPE(reference) == SVt_PVAV))
2322 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2332 % s t r E Q c a s e %
2336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2338 % strEQcase() compares two strings and returns 0 if they are the
2339 % same or if the second string runs out first. The comparison is case
2342 % The format of the strEQcase routine is:
2344 % ssize_t strEQcase(const char *p,const char *q)
2346 % A description of each parameter follows:
2348 % o p: a character string.
2350 % o q: a character string.
2354 static ssize_t strEQcase(const char *p,const char *q)
2362 for (i=0 ; (c=(*q)) != 0; i++)
2364 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2365 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2370 return(((*q == 0) && (*p == 0)) ? i : 0);
2374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2378 % I m a g e : : M a g i c k %
2382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2386 MODULE = Image::Magick PACKAGE = Image::Magick
2391 MagickCoreGenesis("PerlMagick",MagickFalse);
2392 SetWarningHandler(NULL);
2393 SetErrorHandler(NULL);
2394 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2395 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2401 if (magick_registry != (SplayTreeInfo *) NULL)
2402 magick_registry=DestroySplayTree(magick_registry);
2403 MagickCoreTerminus();
2407 constant(name,argument)
2412 ###############################################################################
2420 ###############################################################################
2425 Image::Magick ref=NO_INIT
2449 PERL_UNUSED_VAR(ref);
2450 PERL_UNUSED_VAR(ix);
2451 exception=AcquireExceptionInfo();
2452 perl_exception=newSVpv("",0);
2453 package_info=(struct PackageInfo *) NULL;
2454 if (sv_isobject(ST(0)) == 0)
2456 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2460 reference=SvRV(ST(0));
2461 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2462 if (image == (Image *) NULL)
2464 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2468 package_info=ClonePackageInfo(info,exception);
2470 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2473 for (i=2; i < items; i+=2)
2474 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2476 (void) AnimateImages(package_info->image_info,image,exception);
2477 (void) CatchImageException(image);
2480 if (package_info != (struct PackageInfo *) NULL)
2481 DestroyPackageInfo(package_info);
2482 InheritPerlException(exception,perl_exception);
2483 exception=DestroyExceptionInfo(exception);
2484 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2485 SvPOK_on(perl_exception);
2486 ST(0)=sv_2mortal(perl_exception);
2491 ###############################################################################
2499 ###############################################################################
2504 Image::Magick ref=NO_INIT
2542 PERL_UNUSED_VAR(ref);
2543 PERL_UNUSED_VAR(ix);
2544 exception=AcquireExceptionInfo();
2545 perl_exception=newSVpv("",0);
2549 if (sv_isobject(ST(0)) == 0)
2551 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2555 reference=SvRV(ST(0));
2556 hv=SvSTASH(reference);
2558 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2560 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2561 if (image == (Image *) NULL)
2563 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2567 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2572 for (i=2; i < items; i+=2)
2574 attribute=(char *) SvPV(ST(i-1),na);
2580 if (LocaleCompare(attribute,"stack") == 0)
2582 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2586 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2592 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2598 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2604 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2605 if (image == (Image *) NULL)
2607 for ( ; image; image=image->next)
2609 AddImageToRegistry(sv,image);
2611 av_push(av,sv_bless(rv,hv));
2614 exception=DestroyExceptionInfo(exception);
2616 SvREFCNT_dec(perl_exception);
2620 InheritPerlException(exception,perl_exception);
2621 exception=DestroyExceptionInfo(exception);
2622 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2623 SvPOK_on(perl_exception);
2624 ST(0)=sv_2mortal(perl_exception);
2629 ###############################################################################
2637 ###############################################################################
2642 Image::Magick ref=NO_INIT
2673 PERL_UNUSED_VAR(ref);
2674 PERL_UNUSED_VAR(ix);
2675 exception=AcquireExceptionInfo();
2676 perl_exception=newSVpv("",0);
2678 if (sv_isobject(ST(0)) == 0)
2680 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2684 reference=SvRV(ST(0));
2685 hv=SvSTASH(reference);
2686 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2687 if (image == (Image *) NULL)
2689 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2693 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2694 if (image == (Image *) NULL)
2697 Create blessed Perl array for the returned image.
2700 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2702 AddImageToRegistry(sv,image);
2704 av_push(av,sv_bless(rv,hv));
2706 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2707 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2708 "average-%.*s",(int) (MagickPathExtent-9),
2709 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2710 (void) CopyMagickString(image->filename,info->image_info->filename,
2712 SetImageInfo(info->image_info,0,exception);
2713 exception=DestroyExceptionInfo(exception);
2714 SvREFCNT_dec(perl_exception);
2718 InheritPerlException(exception,perl_exception);
2719 exception=DestroyExceptionInfo(exception);
2720 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2721 SvPOK_on(perl_exception);
2722 ST(0)=sv_2mortal(perl_exception);
2727 ###############################################################################
2731 # B l o b T o I m a g e #
2735 ###############################################################################
2739 BlobToImage(ref,...)
2740 Image::Magick ref=NO_INIT
2786 PERL_UNUSED_VAR(ref);
2787 PERL_UNUSED_VAR(ix);
2788 exception=AcquireExceptionInfo();
2789 perl_exception=newSVpv("",0);
2792 ac=(items < 2) ? 1 : items-1;
2793 length=(STRLEN *) NULL;
2794 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2795 if (list == (char **) NULL)
2797 ThrowPerlException(exception,ResourceLimitError,
2798 "MemoryAllocationFailed",PackageName);
2801 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2802 if (length == (STRLEN *) NULL)
2804 ThrowPerlException(exception,ResourceLimitError,
2805 "MemoryAllocationFailed",PackageName);
2808 if (sv_isobject(ST(0)) == 0)
2810 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2814 reference=SvRV(ST(0));
2815 hv=SvSTASH(reference);
2816 if (SvTYPE(reference) != SVt_PVAV)
2818 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2822 av=(AV *) reference;
2823 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2828 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2831 for (n=0, i=0; i < ac; i++)
2833 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2834 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2836 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2841 list[n]=(char *) NULL;
2843 for (i=number_images=0; i < n; i++)
2845 image=BlobToImage(info->image_info,list[i],length[i],exception);
2846 if (image == (Image *) NULL)
2848 for ( ; image; image=image->next)
2850 AddImageToRegistry(sv,image);
2852 av_push(av,sv_bless(rv,hv));
2860 for (i=0; i < n; i++)
2861 if (list[i] != (char *) NULL)
2862 for (p=keep; list[i] != *p++; )
2863 if (*p == (char *) NULL)
2865 list[i]=(char *) RelinquishMagickMemory(list[i]);
2871 list=(char **) RelinquishMagickMemory(list);
2873 length=(STRLEN *) RelinquishMagickMemory(length);
2874 InheritPerlException(exception,perl_exception);
2875 exception=DestroyExceptionInfo(exception);
2876 sv_setiv(perl_exception,(IV) number_images);
2877 SvPOK_on(perl_exception);
2878 ST(0)=sv_2mortal(perl_exception);
2883 ###############################################################################
2887 # C h a n n e l F x #
2891 ###############################################################################
2896 Image::Magick ref=NO_INIT
2908 expression[MagickPathExtent];
2936 PERL_UNUSED_VAR(ref);
2937 PERL_UNUSED_VAR(ix);
2938 exception=AcquireExceptionInfo();
2939 perl_exception=newSVpv("",0);
2943 if (sv_isobject(ST(0)) == 0)
2945 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2949 reference=SvRV(ST(0));
2950 hv=SvSTASH(reference);
2952 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2954 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2955 if (image == (Image *) NULL)
2957 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2961 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2965 channel=DefaultChannels;
2966 (void) CopyMagickString(expression,"u",MagickPathExtent);
2968 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
2970 for (i=2; i < items; i+=2)
2972 attribute=(char *) SvPV(ST(i-1),na);
2978 if (LocaleCompare(attribute,"channel") == 0)
2983 option=ParseChannelOption(SvPV(ST(i),na));
2986 ThrowPerlException(exception,OptionError,
2987 "UnrecognizedType",SvPV(ST(i),na));
2990 channel=(ChannelType) option;
2993 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3000 if (LocaleCompare(attribute,"expression") == 0)
3002 (void) CopyMagickString(expression,SvPV(ST(i),na),
3006 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3012 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3018 channel_mask=SetImageChannelMask(image,channel);
3019 image=ChannelFxImage(image,expression,exception);
3020 if (image != (Image *) NULL)
3021 (void) SetImageChannelMask(image,channel_mask);
3022 if (image == (Image *) NULL)
3024 for ( ; image; image=image->next)
3026 AddImageToRegistry(sv,image);
3028 av_push(av,sv_bless(rv,hv));
3031 exception=DestroyExceptionInfo(exception);
3033 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3037 InheritPerlException(exception,perl_exception);
3038 exception=DestroyExceptionInfo(exception);
3039 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3040 SvPOK_on(perl_exception);
3041 ST(0)=sv_2mortal(perl_exception);
3046 ###############################################################################
3054 ###############################################################################
3059 Image::Magick ref=NO_INIT
3092 PERL_UNUSED_VAR(ref);
3093 PERL_UNUSED_VAR(ix);
3094 exception=AcquireExceptionInfo();
3095 perl_exception=newSVpv("",0);
3097 if (sv_isobject(ST(0)) == 0)
3099 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3103 reference=SvRV(ST(0));
3104 hv=SvSTASH(reference);
3105 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3106 if (image == (Image *) NULL)
3108 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3113 Create blessed Perl array for the returned image.
3116 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3118 for ( ; image; image=image->next)
3120 clone=CloneImage(image,0,0,MagickTrue,exception);
3121 if (clone == (Image *) NULL)
3123 AddImageToRegistry(sv,clone);
3125 av_push(av,sv_bless(rv,hv));
3128 exception=DestroyExceptionInfo(exception);
3129 SvREFCNT_dec(perl_exception);
3133 InheritPerlException(exception,perl_exception);
3134 exception=DestroyExceptionInfo(exception);
3135 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3136 SvPOK_on(perl_exception);
3137 ST(0)=sv_2mortal(perl_exception);
3142 ###############################################################################
3150 ###############################################################################
3158 PERL_UNUSED_VAR(ref);
3159 if (magick_registry != (SplayTreeInfo *) NULL)
3164 ResetSplayTreeIterator(magick_registry);
3165 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3166 while (p != (Image *) NULL)
3169 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3175 ###############################################################################
3183 ###############################################################################
3188 Image::Magick ref=NO_INIT
3217 PERL_UNUSED_VAR(ref);
3218 PERL_UNUSED_VAR(ix);
3219 exception=AcquireExceptionInfo();
3220 perl_exception=newSVpv("",0);
3222 if (sv_isobject(ST(0)) == 0)
3224 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3228 reference=SvRV(ST(0));
3229 hv=SvSTASH(reference);
3231 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3233 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3234 if (image == (Image *) NULL)
3236 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3240 image=CoalesceImages(image,exception);
3241 if (image == (Image *) NULL)
3243 for ( ; image; image=image->next)
3245 AddImageToRegistry(sv,image);
3247 av_push(av,sv_bless(rv,hv));
3250 exception=DestroyExceptionInfo(exception);
3252 SvREFCNT_dec(perl_exception);
3256 InheritPerlException(exception,perl_exception);
3257 exception=DestroyExceptionInfo(exception);
3258 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3259 SvPOK_on(perl_exception);
3260 ST(0)=sv_2mortal(perl_exception);
3265 ###############################################################################
3273 ###############################################################################
3278 Image::Magick ref=NO_INIT
3324 PERL_UNUSED_VAR(ref);
3325 PERL_UNUSED_VAR(ix);
3326 exception=AcquireExceptionInfo();
3327 perl_exception=newSVpv("",0);
3331 if (sv_isobject(ST(0)) == 0)
3333 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3337 reference=SvRV(ST(0));
3338 hv=SvSTASH(reference);
3340 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3342 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3343 if (image == (Image *) NULL)
3345 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3349 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3353 reconstruct_image=image;
3354 metric=RootMeanSquaredErrorMetric;
3355 for (i=2; i < items; i+=2)
3357 attribute=(char *) SvPV(ST(i-1),na);
3363 if (LocaleCompare(attribute,"channel") == 0)
3368 option=ParseChannelOption(SvPV(ST(i),na));
3371 ThrowPerlException(exception,OptionError,
3372 "UnrecognizedType",SvPV(ST(i),na));
3375 (void) SetPixelChannelMask(image,(ChannelType) option);
3378 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3385 if (LocaleCompare(attribute,"fuzz") == 0)
3387 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3390 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3397 if (LocaleCompare(attribute,"image") == 0)
3399 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3400 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3403 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3410 if (LocaleCompare(attribute,"metric") == 0)
3412 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3416 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3420 metric=(MetricType) option;
3423 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3429 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3435 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3437 if (difference_image != (Image *) NULL)
3439 difference_image->error.mean_error_per_pixel=distortion;
3440 AddImageToRegistry(sv,difference_image);
3442 av_push(av,sv_bless(rv,hv));
3445 exception=DestroyExceptionInfo(exception);
3447 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3451 InheritPerlException(exception,perl_exception);
3452 exception=DestroyExceptionInfo(exception);
3453 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3454 SvPOK_on(perl_exception);
3455 ST(0)=sv_2mortal(perl_exception);
3460 ###############################################################################
3464 # C o m p l e x I m a g e s #
3468 ###############################################################################
3473 Image::Magick ref=NO_INIT
3510 PERL_UNUSED_VAR(ref);
3511 PERL_UNUSED_VAR(ix);
3512 exception=AcquireExceptionInfo();
3513 perl_exception=newSVpv("",0);
3515 if (sv_isobject(ST(0)) == 0)
3517 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3521 reference=SvRV(ST(0));
3522 hv=SvSTASH(reference);
3523 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3524 if (image == (Image *) NULL)
3526 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3530 op=UndefinedComplexOperator;
3536 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3540 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3544 op=(ComplexOperator) in;
3547 for (i=2; i < items; i+=2)
3549 attribute=(char *) SvPV(ST(i-1),na);
3555 if (LocaleCompare(attribute,"operator") == 0)
3560 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3561 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3564 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3568 op=(ComplexOperator) in;
3571 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3577 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3583 image=ComplexImages(image,op,exception);
3584 if (image == (Image *) NULL)
3587 Create blessed Perl array for the returned image.
3590 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3592 AddImageToRegistry(sv,image);
3594 av_push(av,sv_bless(rv,hv));
3596 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3597 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3598 "complex-%.*s",(int) (MagickPathExtent-9),
3599 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3600 (void) CopyMagickString(image->filename,info->image_info->filename,
3602 SetImageInfo(info->image_info,0,exception);
3603 exception=DestroyExceptionInfo(exception);
3604 SvREFCNT_dec(perl_exception);
3608 InheritPerlException(exception,perl_exception);
3609 exception=DestroyExceptionInfo(exception);
3610 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3611 SvPOK_on(perl_exception);
3612 ST(0)=sv_2mortal(perl_exception);
3617 ###############################################################################
3621 # C o m p a r e L a y e r s #
3625 ###############################################################################
3630 Image::Magick ref=NO_INIT
3632 CompareImagesLayers = 1
3634 compareimagelayers = 3
3671 PERL_UNUSED_VAR(ref);
3672 PERL_UNUSED_VAR(ix);
3673 exception=AcquireExceptionInfo();
3674 perl_exception=newSVpv("",0);
3676 if (sv_isobject(ST(0)) == 0)
3678 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3682 reference=SvRV(ST(0));
3683 hv=SvSTASH(reference);
3685 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3687 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3688 if (image == (Image *) NULL)
3690 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3694 method=CompareAnyLayer;
3695 for (i=2; i < items; i+=2)
3697 attribute=(char *) SvPV(ST(i-1),na);
3703 if (LocaleCompare(attribute,"method") == 0)
3705 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3709 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3713 method=(LayerMethod) option;
3716 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3722 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3728 image=CompareImagesLayers(image,method,exception);
3729 if (image == (Image *) NULL)
3731 for ( ; image; image=image->next)
3733 AddImageToRegistry(sv,image);
3735 av_push(av,sv_bless(rv,hv));
3738 exception=DestroyExceptionInfo(exception);
3740 SvREFCNT_dec(perl_exception);
3744 InheritPerlException(exception,perl_exception);
3745 exception=DestroyExceptionInfo(exception);
3746 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3747 SvPOK_on(perl_exception);
3748 ST(0)=sv_2mortal(perl_exception);
3753 ###############################################################################
3761 ###############################################################################
3766 Image::Magick ref=NO_INIT
3772 PERL_UNUSED_VAR(ref);
3773 if (sv_isobject(ST(0)) == 0)
3774 croak("ReferenceIsNotMyType");
3775 reference=SvRV(ST(0));
3776 switch (SvTYPE(reference))
3781 message[MagickPathExtent];
3799 Array (AV *) reference
3801 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3802 XS_VERSION,reference);
3803 hv=gv_stashpv(PackageName, FALSE);
3806 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3810 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3812 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3813 DestroyPackageInfo(info);
3815 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3825 Blessed scalar = (Image *) SvIV(reference)
3827 image=INT2PTR(Image *,SvIV(reference));
3828 if (image != (Image *) NULL)
3829 DeleteImageFromRegistry(reference,image);
3838 ###############################################################################
3846 ###############################################################################
3851 Image::Magick ref=NO_INIT
3875 PERL_UNUSED_VAR(ref);
3876 PERL_UNUSED_VAR(ix);
3877 exception=AcquireExceptionInfo();
3878 perl_exception=newSVpv("",0);
3879 package_info=(struct PackageInfo *) NULL;
3880 if (sv_isobject(ST(0)) == 0)
3882 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3886 reference=SvRV(ST(0));
3887 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3888 if (image == (Image *) NULL)
3890 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3894 package_info=ClonePackageInfo(info,exception);
3896 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3899 for (i=2; i < items; i+=2)
3900 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3902 (void) DisplayImages(package_info->image_info,image,exception);
3903 (void) CatchImageException(image);
3906 if (package_info != (struct PackageInfo *) NULL)
3907 DestroyPackageInfo(package_info);
3908 InheritPerlException(exception,perl_exception);
3909 exception=DestroyExceptionInfo(exception);
3910 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3911 SvPOK_on(perl_exception);
3912 ST(0)=sv_2mortal(perl_exception);
3917 ###############################################################################
3921 # E v a l u a t e I m a g e s #
3925 ###############################################################################
3930 Image::Magick ref=NO_INIT
3952 MagickEvaluateOperator
3967 PERL_UNUSED_VAR(ref);
3968 PERL_UNUSED_VAR(ix);
3969 exception=AcquireExceptionInfo();
3970 perl_exception=newSVpv("",0);
3972 if (sv_isobject(ST(0)) == 0)
3974 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3978 reference=SvRV(ST(0));
3979 hv=SvSTASH(reference);
3980 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3981 if (image == (Image *) NULL)
3983 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3987 op=MeanEvaluateOperator;
3993 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3997 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4001 op=(MagickEvaluateOperator) in;
4004 for (i=2; i < items; i+=2)
4006 attribute=(char *) SvPV(ST(i-1),na);
4012 if (LocaleCompare(attribute,"operator") == 0)
4017 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4018 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4021 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4025 op=(MagickEvaluateOperator) in;
4028 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4034 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4040 image=EvaluateImages(image,op,exception);
4041 if (image == (Image *) NULL)
4044 Create blessed Perl array for the returned image.
4047 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4049 AddImageToRegistry(sv,image);
4051 av_push(av,sv_bless(rv,hv));
4053 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4054 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4055 "evaluate-%.*s",(int) (MagickPathExtent-9),
4056 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4057 (void) CopyMagickString(image->filename,info->image_info->filename,
4059 SetImageInfo(info->image_info,0,exception);
4060 exception=DestroyExceptionInfo(exception);
4061 SvREFCNT_dec(perl_exception);
4065 InheritPerlException(exception,perl_exception);
4066 exception=DestroyExceptionInfo(exception);
4067 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4068 SvPOK_on(perl_exception);
4069 ST(0)=sv_2mortal(perl_exception);
4074 ###############################################################################
4082 ###############################################################################
4087 Image::Magick ref=NO_INIT
4094 #define ChannelFeatures(channel,direction) \
4096 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4097 channel_features[channel].angular_second_moment[direction]); \
4098 PUSHs(sv_2mortal(newSVpv(message,0))); \
4099 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4100 channel_features[channel].contrast[direction]); \
4101 PUSHs(sv_2mortal(newSVpv(message,0))); \
4102 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4103 channel_features[channel].contrast[direction]); \
4104 PUSHs(sv_2mortal(newSVpv(message,0))); \
4105 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4106 channel_features[channel].variance_sum_of_squares[direction]); \
4107 PUSHs(sv_2mortal(newSVpv(message,0))); \
4108 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4109 channel_features[channel].inverse_difference_moment[direction]); \
4110 PUSHs(sv_2mortal(newSVpv(message,0))); \
4111 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4112 channel_features[channel].sum_average[direction]); \
4113 PUSHs(sv_2mortal(newSVpv(message,0))); \
4114 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4115 channel_features[channel].sum_variance[direction]); \
4116 PUSHs(sv_2mortal(newSVpv(message,0))); \
4117 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4118 channel_features[channel].sum_entropy[direction]); \
4119 PUSHs(sv_2mortal(newSVpv(message,0))); \
4120 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4121 channel_features[channel].entropy[direction]); \
4122 PUSHs(sv_2mortal(newSVpv(message,0))); \
4123 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4124 channel_features[channel].difference_variance[direction]); \
4125 PUSHs(sv_2mortal(newSVpv(message,0))); \
4126 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4127 channel_features[channel].difference_entropy[direction]); \
4128 PUSHs(sv_2mortal(newSVpv(message,0))); \
4129 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4130 channel_features[channel].measure_of_correlation_1[direction]); \
4131 PUSHs(sv_2mortal(newSVpv(message,0))); \
4132 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4133 channel_features[channel].measure_of_correlation_2[direction]); \
4134 PUSHs(sv_2mortal(newSVpv(message,0))); \
4135 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4136 channel_features[channel].maximum_correlation_coefficient[direction]); \
4137 PUSHs(sv_2mortal(newSVpv(message,0))); \
4145 message[MagickPathExtent];
4172 PERL_UNUSED_VAR(ref);
4173 PERL_UNUSED_VAR(ix);
4174 exception=AcquireExceptionInfo();
4175 perl_exception=newSVpv("",0);
4177 if (sv_isobject(ST(0)) == 0)
4179 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4183 reference=SvRV(ST(0));
4186 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4187 if (image == (Image *) NULL)
4189 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4194 for (i=2; i < items; i+=2)
4196 attribute=(char *) SvPV(ST(i-1),na);
4202 if (LocaleCompare(attribute,"distance") == 0)
4204 distance=StringToLong((char *) SvPV(ST(1),na));
4207 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4213 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4220 for ( ; image; image=image->next)
4222 channel_features=GetImageFeatures(image,distance,exception);
4223 if (channel_features == (ChannelFeatures *) NULL)
4226 EXTEND(sp,280*count);
4227 for (i=0; i < 4; i++)
4229 ChannelFeatures(RedChannel,i);
4230 ChannelFeatures(GreenChannel,i);
4231 ChannelFeatures(BlueChannel,i);
4232 if (image->colorspace == CMYKColorspace)
4233 ChannelFeatures(BlackChannel,i);
4234 if (image->alpha_trait != UndefinedPixelTrait)
4235 ChannelFeatures(AlphaChannel,i);
4237 channel_features=(ChannelFeatures *)
4238 RelinquishMagickMemory(channel_features);
4242 InheritPerlException(exception,perl_exception);
4243 exception=DestroyExceptionInfo(exception);
4244 SvREFCNT_dec(perl_exception);
4248 ###############################################################################
4256 ###############################################################################
4261 Image::Magick ref=NO_INIT
4299 PERL_UNUSED_VAR(ref);
4300 PERL_UNUSED_VAR(ix);
4301 exception=AcquireExceptionInfo();
4302 perl_exception=newSVpv("",0);
4304 if (sv_isobject(ST(0)) == 0)
4306 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4310 reference=SvRV(ST(0));
4311 hv=SvSTASH(reference);
4312 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4313 if (image == (Image *) NULL)
4315 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4319 background_color=image->background_color;
4321 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4322 &background_color,exception);
4324 for (i=2; i < items; i+=2)
4326 attribute=(char *) SvPV(ST(i-1),na);
4332 if (LocaleCompare(attribute,"background") == 0)
4334 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4335 AllCompliance,&background_color,exception);
4338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4344 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4350 image->background_color=background_color;
4351 image=MergeImageLayers(image,FlattenLayer,exception);
4352 if (image == (Image *) NULL)
4355 Create blessed Perl array for the returned image.
4358 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4360 AddImageToRegistry(sv,image);
4362 av_push(av,sv_bless(rv,hv));
4364 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4365 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4366 "flatten-%.*s",(int) (MagickPathExtent-9),
4367 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4368 (void) CopyMagickString(image->filename,info->image_info->filename,
4370 SetImageInfo(info->image_info,0,exception);
4371 exception=DestroyExceptionInfo(exception);
4372 SvREFCNT_dec(perl_exception);
4376 InheritPerlException(exception,perl_exception);
4377 exception=DestroyExceptionInfo(exception);
4378 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4379 SvPOK_on(perl_exception); /* return messages in string context */
4380 ST(0)=sv_2mortal(perl_exception);
4385 ###############################################################################
4393 ###############################################################################
4398 Image::Magick ref=NO_INIT
4410 expression[MagickPathExtent];
4438 PERL_UNUSED_VAR(ref);
4439 PERL_UNUSED_VAR(ix);
4440 exception=AcquireExceptionInfo();
4441 perl_exception=newSVpv("",0);
4445 if (sv_isobject(ST(0)) == 0)
4447 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4451 reference=SvRV(ST(0));
4452 hv=SvSTASH(reference);
4454 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4456 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4457 if (image == (Image *) NULL)
4459 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4463 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4467 channel=DefaultChannels;
4468 (void) CopyMagickString(expression,"u",MagickPathExtent);
4470 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4472 for (i=2; i < items; i+=2)
4474 attribute=(char *) SvPV(ST(i-1),na);
4480 if (LocaleCompare(attribute,"channel") == 0)
4485 option=ParseChannelOption(SvPV(ST(i),na));
4488 ThrowPerlException(exception,OptionError,
4489 "UnrecognizedType",SvPV(ST(i),na));
4492 channel=(ChannelType) option;
4495 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4502 if (LocaleCompare(attribute,"expression") == 0)
4504 (void) CopyMagickString(expression,SvPV(ST(i),na),
4508 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4514 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4520 channel_mask=SetImageChannelMask(image,channel);
4521 image=FxImage(image,expression,exception);
4522 if (image != (Image *) NULL)
4523 (void) SetImageChannelMask(image,channel_mask);
4524 if (image == (Image *) NULL)
4526 for ( ; image; image=image->next)
4528 AddImageToRegistry(sv,image);
4530 av_push(av,sv_bless(rv,hv));
4533 exception=DestroyExceptionInfo(exception);
4535 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4539 InheritPerlException(exception,perl_exception);
4540 exception=DestroyExceptionInfo(exception);
4541 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4542 SvPOK_on(perl_exception);
4543 ST(0)=sv_2mortal(perl_exception);
4548 ###############################################################################
4556 ###############################################################################
4561 Image::Magick ref=NO_INIT
4572 color[MagickPathExtent];
4597 PERL_UNUSED_VAR(ref);
4598 PERL_UNUSED_VAR(ix);
4599 exception=AcquireExceptionInfo();
4600 perl_exception=newSVpv("",0);
4601 if (sv_isobject(ST(0)) == 0)
4603 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4607 reference=SvRV(ST(0));
4608 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4609 if (image == (Image *) NULL && !info)
4612 for (i=1; i < items; i++)
4614 attribute=(char *) SvPV(ST(i),na);
4621 if (LocaleCompare(attribute,"adjoin") == 0)
4624 s=newSViv((ssize_t) info->image_info->adjoin);
4625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4628 if (LocaleCompare(attribute,"antialias") == 0)
4631 s=newSViv((ssize_t) info->image_info->antialias);
4632 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4635 if (LocaleCompare(attribute,"area") == 0)
4637 s=newSViv(GetMagickResource(AreaResource));
4638 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4641 if (LocaleCompare(attribute,"attenuate") == 0)
4646 value=GetImageProperty(image,attribute,exception);
4647 if (value != (const char *) NULL)
4649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4652 if (LocaleCompare(attribute,"authenticate") == 0)
4659 option=GetImageOption(info->image_info,attribute);
4660 if (option != (const char *) NULL)
4661 s=newSVpv(option,0);
4663 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4666 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4673 if (LocaleCompare(attribute,"background") == 0)
4675 if (image == (Image *) NULL)
4677 (void) FormatLocaleString(color,MagickPathExtent,
4678 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4679 (double) image->background_color.green,
4680 (double) image->background_color.blue,
4681 (double) image->background_color.alpha);
4683 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4686 if (LocaleCompare(attribute,"base-columns") == 0)
4688 if (image != (Image *) NULL)
4689 s=newSViv((ssize_t) image->magick_columns);
4690 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4693 if (LocaleCompare(attribute,"base-filename") == 0)
4695 if (image != (Image *) NULL)
4696 s=newSVpv(image->magick_filename,0);
4697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4700 if (LocaleCompare(attribute,"base-height") == 0)
4702 if (image != (Image *) NULL)
4703 s=newSViv((ssize_t) image->magick_rows);
4704 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4707 if (LocaleCompare(attribute,"base-rows") == 0)
4709 if (image != (Image *) NULL)
4710 s=newSViv((ssize_t) image->magick_rows);
4711 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4714 if (LocaleCompare(attribute,"base-width") == 0)
4716 if (image != (Image *) NULL)
4717 s=newSViv((ssize_t) image->magick_columns);
4718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4721 if (LocaleCompare(attribute,"blue-primary") == 0)
4723 if (image == (Image *) NULL)
4725 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
4726 image->chromaticity.blue_primary.x,
4727 image->chromaticity.blue_primary.y);
4729 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4732 if (LocaleCompare(attribute,"bordercolor") == 0)
4734 if (image == (Image *) NULL)
4736 (void) FormatLocaleString(color,MagickPathExtent,
4737 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4738 (double) image->border_color.green,
4739 (double) image->border_color.blue,
4740 (double) image->border_color.alpha);
4742 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4745 if (LocaleCompare(attribute,"bounding-box") == 0)
4748 geometry[MagickPathExtent];
4753 if (image == (Image *) NULL)
4755 page=GetImageBoundingBox(image,exception);
4756 (void) FormatLocaleString(geometry,MagickPathExtent,
4757 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4758 page.height,(double) page.x,(double) page.y);
4759 s=newSVpv(geometry,0);
4760 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4763 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4770 if (LocaleCompare(attribute,"class") == 0)
4772 if (image == (Image *) NULL)
4774 s=newSViv(image->storage_class);
4775 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4776 image->storage_class));
4778 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4781 if (LocaleCompare(attribute,"clip-mask") == 0)
4783 if (image != (Image *) NULL)
4792 if (image->read_mask == MagickFalse)
4793 ClipImage(image,exception);
4794 mask_image=GetImageMask(image,exception);
4795 if (mask_image != (Image *) NULL)
4797 AddImageToRegistry(sv,mask_image);
4798 s=sv_bless(newRV(sv),SvSTASH(reference));
4801 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4804 if (LocaleCompare(attribute,"clip-path") == 0)
4806 if (image != (Image *) NULL)
4815 if (image->read_mask != MagickFalse)
4816 ClipImage(image,exception);
4817 mask_image=GetImageMask(image,exception);
4818 if (mask_image != (Image *) NULL)
4820 AddImageToRegistry(sv,mask_image);
4821 s=sv_bless(newRV(sv),SvSTASH(reference));
4824 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4827 if (LocaleCompare(attribute,"compression") == 0)
4829 j=info ? info->image_info->compression : image ?
4830 image->compression : UndefinedCompression;
4832 if (info->image_info->compression == UndefinedCompression)
4833 j=image->compression;
4835 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4838 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4841 if (LocaleCompare(attribute,"colorspace") == 0)
4843 j=image ? image->colorspace : RGBColorspace;
4845 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4848 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4851 if (LocaleCompare(attribute,"colors") == 0)
4853 if (image != (Image *) NULL)
4854 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4856 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4859 if (LocaleNCompare(attribute,"colormap",8) == 0)
4864 if (image == (Image *) NULL || !image->colormap)
4867 items=sscanf(attribute,"%*[^[][%ld",&j);
4869 if (j > (ssize_t) image->colors)
4871 (void) FormatLocaleString(color,MagickPathExtent,
4872 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4873 (double) image->colormap[j].green,
4874 (double) image->colormap[j].blue,
4875 (double) image->colormap[j].alpha);
4877 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4880 if (LocaleCompare(attribute,"columns") == 0)
4882 if (image != (Image *) NULL)
4883 s=newSViv((ssize_t) image->columns);
4884 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4887 if (LocaleCompare(attribute,"comment") == 0)
4892 value=GetImageProperty(image,attribute,exception);
4893 if (value != (const char *) NULL)
4895 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4898 if (LocaleCompare(attribute,"copyright") == 0)
4900 s=newSVpv(GetMagickCopyright(),0);
4901 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4904 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4911 if (LocaleCompare(attribute,"density") == 0)
4914 geometry[MagickPathExtent];
4916 if (image == (Image *) NULL)
4918 (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g",
4919 image->resolution.x,image->resolution.y);
4920 s=newSVpv(geometry,0);
4921 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4924 if (LocaleCompare(attribute,"delay") == 0)
4926 if (image != (Image *) NULL)
4927 s=newSViv((ssize_t) image->delay);
4928 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4931 if (LocaleCompare(attribute,"depth") == 0)
4933 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4934 if (image != (Image *) NULL)
4935 s=newSViv((ssize_t) GetImageDepth(image,exception));
4936 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4939 if (LocaleCompare(attribute,"directory") == 0)
4941 if (image && image->directory)
4942 s=newSVpv(image->directory,0);
4943 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4946 if (LocaleCompare(attribute,"dispose") == 0)
4948 if (image == (Image *) NULL)
4951 s=newSViv(image->dispose);
4953 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4955 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4958 if (LocaleCompare(attribute,"disk") == 0)
4960 s=newSViv(GetMagickResource(DiskResource));
4961 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4964 if (LocaleCompare(attribute,"dither") == 0)
4967 s=newSViv((ssize_t) info->image_info->dither);
4968 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4971 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4973 if (info && info->image_info->server_name)
4974 s=newSVpv(info->image_info->server_name,0);
4975 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4985 if (LocaleCompare(attribute,"elapsed-time") == 0)
4987 if (image != (Image *) NULL)
4988 s=newSVnv(GetElapsedTime(&image->timer));
4989 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4992 if (LocaleCompare(attribute,"endian") == 0)
4994 j=info ? info->image_info->endian : image ? image->endian :
4997 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4999 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5002 if (LocaleCompare(attribute,"error") == 0)
5004 if (image != (Image *) NULL)
5005 s=newSVnv(image->error.mean_error_per_pixel);
5006 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5009 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5016 if (LocaleCompare(attribute,"filesize") == 0)
5018 if (image != (Image *) NULL)
5019 s=newSViv((ssize_t) GetBlobSize(image));
5020 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5023 if (LocaleCompare(attribute,"filename") == 0)
5025 if (info && info->image_info->filename &&
5026 *info->image_info->filename)
5027 s=newSVpv(info->image_info->filename,0);
5028 if (image != (Image *) NULL)
5029 s=newSVpv(image->filename,0);
5030 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5033 if (LocaleCompare(attribute,"filter") == 0)
5035 s=image ? newSViv(image->filter) : newSViv(0);
5036 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5039 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5042 if (LocaleCompare(attribute,"font") == 0)
5044 if (info && info->image_info->font)
5045 s=newSVpv(info->image_info->font,0);
5046 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5049 if (LocaleCompare(attribute,"foreground") == 0)
5051 if (LocaleCompare(attribute,"format") == 0)
5056 magick_info=(const MagickInfo *) NULL;
5057 if (info && (*info->image_info->magick != '\0'))
5058 magick_info=GetMagickInfo(info->image_info->magick,exception);
5059 if (image != (Image *) NULL)
5060 magick_info=GetMagickInfo(image->magick,exception);
5061 if ((magick_info != (const MagickInfo *) NULL) &&
5062 (*magick_info->description != '\0'))
5063 s=newSVpv((char *) magick_info->description,0);
5064 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5067 if (LocaleCompare(attribute,"fuzz") == 0)
5070 s=newSVnv(info->image_info->fuzz);
5071 if (image != (Image *) NULL)
5072 s=newSVnv(image->fuzz);
5073 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5076 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5083 if (LocaleCompare(attribute,"gamma") == 0)
5085 if (image != (Image *) NULL)
5086 s=newSVnv(image->gamma);
5087 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5090 if (LocaleCompare(attribute,"geometry") == 0)
5092 if (image && image->geometry)
5093 s=newSVpv(image->geometry,0);
5094 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5097 if (LocaleCompare(attribute,"gravity") == 0)
5099 s=image ? newSViv(image->gravity) : newSViv(0);
5100 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5103 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5106 if (LocaleCompare(attribute,"green-primary") == 0)
5108 if (image == (Image *) NULL)
5110 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5111 image->chromaticity.green_primary.x,
5112 image->chromaticity.green_primary.y);
5114 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5117 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5124 if (LocaleCompare(attribute,"height") == 0)
5126 if (image != (Image *) NULL)
5127 s=newSViv((ssize_t) image->rows);
5128 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5131 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5138 if (LocaleCompare(attribute,"icc") == 0)
5140 if (image != (Image *) NULL)
5145 profile=GetImageProfile(image,"icc");
5146 if (profile != (StringInfo *) NULL)
5147 s=newSVpv((const char *) GetStringInfoDatum(profile),
5148 GetStringInfoLength(profile));
5150 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5153 if (LocaleCompare(attribute,"icm") == 0)
5155 if (image != (Image *) NULL)
5160 profile=GetImageProfile(image,"icm");
5161 if (profile != (const StringInfo *) NULL)
5162 s=newSVpv((const char *) GetStringInfoDatum(profile),
5163 GetStringInfoLength(profile));
5165 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5168 if (LocaleCompare(attribute,"id") == 0)
5170 if (image != (Image *) NULL)
5173 key[MagickPathExtent];
5181 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5183 status=SetImageRegistry(ImageRegistryType,key,image,
5188 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5191 if (LocaleNCompare(attribute,"index",5) == 0)
5194 name[MagickPathExtent];
5203 register const Quantum
5209 if (image == (Image *) NULL)
5211 if (image->storage_class != PseudoClass)
5215 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5217 image_view=AcquireVirtualCacheView(image,exception);
5218 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5219 if (p != (const Quantum *) NULL)
5221 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5222 GetPixelIndex(image,p));
5224 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5226 image_view=DestroyCacheView(image_view);
5229 if (LocaleCompare(attribute,"iptc") == 0)
5231 if (image != (Image *) NULL)
5236 profile=GetImageProfile(image,"iptc");
5237 if (profile != (const StringInfo *) NULL)
5238 s=newSVpv((const char *) GetStringInfoDatum(profile),
5239 GetStringInfoLength(profile));
5241 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5244 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5246 if (image != (Image *) NULL)
5247 s=newSViv((ssize_t) image->iterations);
5248 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5251 if (LocaleCompare(attribute,"interlace") == 0)
5253 j=info ? info->image_info->interlace : image ? image->interlace :
5256 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5259 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5262 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5269 if (LocaleCompare(attribute,"label") == 0)
5274 if (image == (Image *) NULL)
5276 value=GetImageProperty(image,"Label",exception);
5277 if (value != (const char *) NULL)
5279 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5282 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5284 if (image != (Image *) NULL)
5285 s=newSViv((ssize_t) image->iterations);
5286 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5289 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5296 if (LocaleCompare(attribute,"magick") == 0)
5298 if (info && *info->image_info->magick)
5299 s=newSVpv(info->image_info->magick,0);
5300 if (image != (Image *) NULL)
5301 s=newSVpv(image->magick,0);
5302 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5305 if (LocaleCompare(attribute,"map") == 0)
5307 s=newSViv(GetMagickResource(MapResource));
5308 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5311 if (LocaleCompare(attribute,"maximum-error") == 0)
5313 if (image != (Image *) NULL)
5314 s=newSVnv(image->error.normalized_maximum_error);
5315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5318 if (LocaleCompare(attribute,"memory") == 0)
5320 s=newSViv(GetMagickResource(MemoryResource));
5321 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5324 if (LocaleCompare(attribute,"mean-error") == 0)
5326 if (image != (Image *) NULL)
5327 s=newSVnv(image->error.normalized_mean_error);
5328 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5331 if (LocaleCompare(attribute,"mime") == 0)
5333 if (info && *info->image_info->magick)
5334 s=newSVpv(MagickToMime(info->image_info->magick),0);
5335 if (image != (Image *) NULL)
5336 s=newSVpv(MagickToMime(image->magick),0);
5337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5340 if (LocaleCompare(attribute,"mattecolor") == 0)
5342 if (image == (Image *) NULL)
5344 (void) FormatLocaleString(color,MagickPathExtent,
5345 "%.20g,%.20g,%.20g,%.20g",(double) image->matte_color.red,
5346 (double) image->matte_color.green,
5347 (double) image->matte_color.blue,
5348 (double) image->matte_color.alpha);
5350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5353 if (LocaleCompare(attribute,"matte") == 0)
5355 if (image != (Image *) NULL)
5356 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5358 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5361 if (LocaleCompare(attribute,"mime") == 0)
5367 if (info && *info->image_info->magick)
5368 magick=info->image_info->magick;
5369 if (image != (Image *) NULL)
5370 magick=image->magick;
5376 mime=MagickToMime(magick);
5378 mime=(char *) RelinquishMagickMemory(mime);
5380 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5383 if (LocaleCompare(attribute,"monochrome") == 0)
5385 if (image == (Image *) NULL)
5387 j=info ? info->image_info->monochrome :
5388 SetImageMonochrome(image,exception);
5390 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5393 if (LocaleCompare(attribute,"montage") == 0)
5395 if (image && image->montage)
5396 s=newSVpv(image->montage,0);
5397 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5407 if (LocaleCompare(attribute,"orientation") == 0)
5409 j=info ? info->image_info->orientation : image ?
5410 image->orientation : UndefinedOrientation;
5412 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5415 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5425 if (LocaleCompare(attribute,"page") == 0)
5427 if (info && info->image_info->page)
5428 s=newSVpv(info->image_info->page,0);
5429 if (image != (Image *) NULL)
5432 geometry[MagickPathExtent];
5434 (void) FormatLocaleString(geometry,MagickPathExtent,
5435 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5436 (double) image->page.height,(double) image->page.x,(double)
5438 s=newSVpv(geometry,0);
5440 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5443 if (LocaleCompare(attribute,"page.x") == 0)
5445 if (image != (Image *) NULL)
5446 s=newSViv((ssize_t) image->page.x);
5447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5450 if (LocaleCompare(attribute,"page.y") == 0)
5452 if (image != (Image *) NULL)
5453 s=newSViv((ssize_t) image->page.y);
5454 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5457 if (LocaleNCompare(attribute,"pixel",5) == 0)
5460 tuple[MagickPathExtent];
5469 register const Quantum
5472 if (image == (Image *) NULL)
5476 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5478 p=GetVirtualPixels(image,x,y,1,1,exception);
5479 if (image->colorspace != CMYKColorspace)
5480 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5481 QuantumFormat "," QuantumFormat "," QuantumFormat,
5482 GetPixelRed(image,p),GetPixelGreen(image,p),
5483 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5485 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5486 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5487 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5488 GetPixelBlue(image,p),GetPixelBlack(image,p),
5489 GetPixelAlpha(image,p));
5491 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5494 if (LocaleCompare(attribute,"pointsize") == 0)
5497 s=newSViv((ssize_t) info->image_info->pointsize);
5498 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5501 if (LocaleCompare(attribute,"preview") == 0)
5503 s=newSViv(info->image_info->preview_type);
5504 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5505 info->image_info->preview_type));
5507 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5510 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5517 if (LocaleCompare(attribute,"quality") == 0)
5520 s=newSViv((ssize_t) info->image_info->quality);
5521 if (image != (Image *) NULL)
5522 s=newSViv((ssize_t) image->quality);
5523 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5526 if (LocaleCompare(attribute,"quantum") == 0)
5529 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5530 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5533 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5540 if (LocaleCompare(attribute,"rendering-intent") == 0)
5542 s=newSViv(image->rendering_intent);
5543 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5544 image->rendering_intent));
5546 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5549 if (LocaleCompare(attribute,"red-primary") == 0)
5551 if (image == (Image *) NULL)
5553 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5554 image->chromaticity.red_primary.x,
5555 image->chromaticity.red_primary.y);
5557 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5560 if (LocaleCompare(attribute,"rows") == 0)
5562 if (image != (Image *) NULL)
5563 s=newSViv((ssize_t) image->rows);
5564 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5567 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5574 if (LocaleCompare(attribute,"sampling-factor") == 0)
5576 if (info && info->image_info->sampling_factor)
5577 s=newSVpv(info->image_info->sampling_factor,0);
5578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5581 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5583 if (info && info->image_info->server_name)
5584 s=newSVpv(info->image_info->server_name,0);
5585 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5588 if (LocaleCompare(attribute,"size") == 0)
5590 if (info && info->image_info->size)
5591 s=newSVpv(info->image_info->size,0);
5592 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5595 if (LocaleCompare(attribute,"scene") == 0)
5597 if (image != (Image *) NULL)
5598 s=newSViv((ssize_t) image->scene);
5599 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5602 if (LocaleCompare(attribute,"scenes") == 0)
5604 if (image != (Image *) NULL)
5605 s=newSViv((ssize_t) info->image_info->number_scenes);
5606 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5609 if (LocaleCompare(attribute,"signature") == 0)
5614 if (image == (Image *) NULL)
5616 (void) SignatureImage(image,exception);
5617 value=GetImageProperty(image,"Signature",exception);
5618 if (value != (const char *) NULL)
5620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5623 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5630 if (LocaleCompare(attribute,"taint") == 0)
5632 if (image != (Image *) NULL)
5633 s=newSViv((ssize_t) IsTaintImage(image));
5634 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5637 if (LocaleCompare(attribute,"texture") == 0)
5639 if (info && info->image_info->texture)
5640 s=newSVpv(info->image_info->texture,0);
5641 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5644 if (LocaleCompare(attribute,"total-ink-density") == 0)
5646 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5647 if (image != (Image *) NULL)
5648 s=newSVnv(GetImageTotalInkDensity(image,exception));
5649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5652 if (LocaleCompare(attribute,"transparent-color") == 0)
5654 if (image == (Image *) NULL)
5656 (void) FormatLocaleString(color,MagickPathExtent,
5657 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5658 (double) image->transparent_color.green,
5659 (double) image->transparent_color.blue,
5660 (double) image->transparent_color.alpha);
5662 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5665 if (LocaleCompare(attribute,"type") == 0)
5667 if (image == (Image *) NULL)
5669 j=(ssize_t) GetImageType(image);
5671 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5673 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5676 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5683 if (LocaleCompare(attribute,"units") == 0)
5685 j=info ? info->image_info->units : image ? image->units :
5686 UndefinedResolution;
5687 if (info && (info->image_info->units == UndefinedResolution))
5690 if (j == UndefinedResolution)
5691 s=newSVpv("undefined units",0);
5693 if (j == PixelsPerInchResolution)
5694 s=newSVpv("pixels / inch",0);
5696 s=newSVpv("pixels / centimeter",0);
5697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5700 if (LocaleCompare(attribute,"user-time") == 0)
5702 if (image != (Image *) NULL)
5703 s=newSVnv(GetUserTime(&image->timer));
5704 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5707 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5714 if (LocaleCompare(attribute,"verbose") == 0)
5717 s=newSViv((ssize_t) info->image_info->verbose);
5718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5721 if (LocaleCompare(attribute,"version") == 0)
5723 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5724 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5727 if (LocaleCompare(attribute,"view") == 0)
5729 if (info && info->image_info->view)
5730 s=newSVpv(info->image_info->view,0);
5731 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5734 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5736 if (image == (Image *) NULL)
5738 j=(ssize_t) GetImageVirtualPixelMethod(image);
5740 (void) sv_setpv(s,CommandOptionToMnemonic(
5741 MagickVirtualPixelOptions,j));
5743 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5746 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5753 if (LocaleCompare(attribute,"white-point") == 0)
5755 if (image == (Image *) NULL)
5757 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5758 image->chromaticity.white_point.x,
5759 image->chromaticity.white_point.y);
5761 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5764 if (LocaleCompare(attribute,"width") == 0)
5766 if (image != (Image *) NULL)
5767 s=newSViv((ssize_t) image->columns);
5768 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5771 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5778 if (LocaleCompare(attribute,"xmp") == 0)
5780 if (image != (Image *) NULL)
5785 profile=GetImageProfile(image,"xmp");
5786 if (profile != (StringInfo *) NULL)
5787 s=newSVpv((const char *) GetStringInfoDatum(profile),
5788 GetStringInfoLength(profile));
5790 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5793 if (LocaleCompare(attribute,"x-resolution") == 0)
5795 if (image != (Image *) NULL)
5796 s=newSVnv(image->resolution.x);
5797 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5800 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5807 if (LocaleCompare(attribute,"y-resolution") == 0)
5809 if (image != (Image *) NULL)
5810 s=newSVnv(image->resolution.y);
5811 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5814 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5821 if (image == (Image *) NULL)
5822 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5826 value=GetImageProperty(image,attribute,exception);
5827 if (value != (const char *) NULL)
5830 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5833 if (*attribute != '%')
5834 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5841 meta=InterpretImageProperties(info ? info->image_info :
5842 (ImageInfo *) NULL,image,attribute,exception);
5844 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5845 meta=(char *) RelinquishMagickMemory(meta);
5849 exception=DestroyExceptionInfo(exception);
5850 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5854 ###############################################################################
5858 # G e t A u t h e n t i c P i x e l s #
5862 ###############################################################################
5866 GetAuthenticPixels(ref,...)
5867 Image::Magick ref = NO_INIT
5869 getauthenticpixels = 1
5899 PERL_UNUSED_VAR(ref);
5900 PERL_UNUSED_VAR(ix);
5901 exception=AcquireExceptionInfo();
5902 perl_exception=newSVpv("",0);
5903 if (sv_isobject(ST(0)) == 0)
5905 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5909 reference=SvRV(ST(0));
5911 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5912 if (image == (Image *) NULL)
5914 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5921 region.width=image->columns;
5924 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5925 for (i=2; i < items; i+=2)
5927 attribute=(char *) SvPV(ST(i-1),na);
5933 if (LocaleCompare(attribute,"geometry") == 0)
5935 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5938 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5945 if (LocaleCompare(attribute,"height") == 0)
5947 region.height=SvIV(ST(i));
5950 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5957 if (LocaleCompare(attribute,"x") == 0)
5959 region.x=SvIV(ST(i));
5962 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5969 if (LocaleCompare(attribute,"y") == 0)
5971 region.y=SvIV(ST(i));
5974 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5981 if (LocaleCompare(attribute,"width") == 0)
5983 region.width=SvIV(ST(i));
5986 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5992 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5993 region.height,exception);
5994 if (blob != (void *) NULL)
5998 InheritPerlException(exception,perl_exception);
5999 exception=DestroyExceptionInfo(exception);
6000 SvREFCNT_dec(perl_exception); /* throw away all errors */
6009 ###############################################################################
6013 # G e t V i r t u a l P i x e l s #
6017 ###############################################################################
6021 GetVirtualPixels(ref,...)
6022 Image::Magick ref = NO_INIT
6024 getvirtualpixels = 1
6025 AcquireImagePixels = 2
6026 acquireimagepixels = 3
6054 PERL_UNUSED_VAR(ref);
6055 PERL_UNUSED_VAR(ix);
6056 exception=AcquireExceptionInfo();
6057 perl_exception=newSVpv("",0);
6058 if (sv_isobject(ST(0)) == 0)
6060 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6064 reference=SvRV(ST(0));
6066 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6067 if (image == (Image *) NULL)
6069 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6076 region.width=image->columns;
6079 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6080 for (i=2; i < items; i+=2)
6082 attribute=(char *) SvPV(ST(i-1),na);
6088 if (LocaleCompare(attribute,"geometry") == 0)
6090 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6093 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6100 if (LocaleCompare(attribute,"height") == 0)
6102 region.height=SvIV(ST(i));
6105 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6112 if (LocaleCompare(attribute,"x") == 0)
6114 region.x=SvIV(ST(i));
6117 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6124 if (LocaleCompare(attribute,"y") == 0)
6126 region.y=SvIV(ST(i));
6129 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6136 if (LocaleCompare(attribute,"width") == 0)
6138 region.width=SvIV(ST(i));
6141 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6147 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6148 region.height,exception);
6149 if (blob != (void *) NULL)
6153 InheritPerlException(exception,perl_exception);
6154 exception=DestroyExceptionInfo(exception);
6155 SvREFCNT_dec(perl_exception); /* throw away all errors */
6158 RETVAL = (void *) blob;
6164 ###############################################################################
6168 # G e t A u t h e n t i c M e t a c o n t e n t #
6172 ###############################################################################
6176 GetAuthenticMetacontent(ref,...)
6177 Image::Magick ref = NO_INIT
6179 getauthenticmetacontent = 1
6200 PERL_UNUSED_VAR(ref);
6201 PERL_UNUSED_VAR(ix);
6202 exception=AcquireExceptionInfo();
6203 perl_exception=newSVpv("",0);
6204 if (sv_isobject(ST(0)) == 0)
6206 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6210 reference=SvRV(ST(0));
6212 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6213 if (image == (Image *) NULL)
6215 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6220 blob=(void *) GetAuthenticMetacontent(image);
6221 if (blob != (void *) NULL)
6225 InheritPerlException(exception,perl_exception);
6226 exception=DestroyExceptionInfo(exception);
6227 SvREFCNT_dec(perl_exception); /* throw away all errors */
6236 ###############################################################################
6240 # G e t V i r t u a l M e t a c o n t e n t #
6244 ###############################################################################
6248 GetVirtualMetacontent(ref,...)
6249 Image::Magick ref = NO_INIT
6251 getvirtualmetacontent = 1
6270 PERL_UNUSED_VAR(ref);
6271 PERL_UNUSED_VAR(ix);
6272 exception=AcquireExceptionInfo();
6273 perl_exception=newSVpv("",0);
6274 if (sv_isobject(ST(0)) == 0)
6276 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6280 reference=SvRV(ST(0));
6282 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6283 if (image == (Image *) NULL)
6285 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6290 blob=(void *) GetVirtualMetacontent(image);
6291 if (blob != (void *) NULL)
6295 InheritPerlException(exception,perl_exception);
6296 exception=DestroyExceptionInfo(exception);
6297 SvREFCNT_dec(perl_exception); /* throw away all errors */
6306 ###############################################################################
6310 # H i s t o g r a m #
6314 ###############################################################################
6319 Image::Magick ref=NO_INIT
6330 message[MagickPathExtent];
6357 PERL_UNUSED_VAR(ref);
6358 PERL_UNUSED_VAR(ix);
6359 exception=AcquireExceptionInfo();
6360 perl_exception=newSVpv("",0);
6362 if (sv_isobject(ST(0)) == 0)
6364 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6368 reference=SvRV(ST(0));
6371 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6372 if (image == (Image *) NULL)
6374 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6379 for ( ; image; image=image->next)
6381 histogram=GetImageHistogram(image,&number_colors,exception);
6382 if (histogram == (PixelInfo *) NULL)
6384 count+=(ssize_t) number_colors;
6386 for (i=0; i < (ssize_t) number_colors; i++)
6388 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6390 PUSHs(sv_2mortal(newSVpv(message,0)));
6391 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6392 histogram[i].green);
6393 PUSHs(sv_2mortal(newSVpv(message,0)));
6394 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6396 PUSHs(sv_2mortal(newSVpv(message,0)));
6397 if (image->colorspace == CMYKColorspace)
6399 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6400 histogram[i].black);
6401 PUSHs(sv_2mortal(newSVpv(message,0)));
6403 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6404 histogram[i].alpha);
6405 PUSHs(sv_2mortal(newSVpv(message,0)));
6406 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6407 histogram[i].count);
6408 PUSHs(sv_2mortal(newSVpv(message,0)));
6410 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6414 InheritPerlException(exception,perl_exception);
6415 exception=DestroyExceptionInfo(exception);
6416 SvREFCNT_dec(perl_exception);
6420 ###############################################################################
6428 ###############################################################################
6433 Image::Magick ref=NO_INIT
6457 register const Quantum
6471 *reference; /* reference is the SV* of ref=SvIV(reference) */
6473 PERL_UNUSED_VAR(ref);
6474 PERL_UNUSED_VAR(ix);
6475 exception=AcquireExceptionInfo();
6476 perl_exception=newSVpv("",0);
6477 reference=SvRV(ST(0));
6478 av=(AV *) reference;
6479 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6481 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6482 if (image == (Image *) NULL)
6484 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6488 normalize=MagickTrue;
6491 region.width=image->columns;
6494 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6495 for (i=2; i < items; i+=2)
6497 attribute=(char *) SvPV(ST(i-1),na);
6503 if (LocaleCompare(attribute,"channel") == 0)
6508 option=ParseChannelOption(SvPV(ST(i),na));
6511 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6515 (void) SetPixelChannelMask(image,(ChannelType) option);
6518 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6525 if (LocaleCompare(attribute,"geometry") == 0)
6527 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6530 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6537 if (LocaleCompare(attribute,"normalize") == 0)
6539 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6543 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6547 normalize=option != 0 ? MagickTrue : MagickFalse;
6550 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6557 if (LocaleCompare(attribute,"x") == 0)
6559 region.x=SvIV(ST(i));
6562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6569 if (LocaleCompare(attribute,"y") == 0)
6571 region.y=SvIV(ST(i));
6574 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6580 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6586 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6587 if (p == (const Quantum *) NULL)
6595 if (normalize != MagickFalse)
6596 scale=1.0/QuantumRange;
6597 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6598 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6599 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6600 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6601 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6602 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6603 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6604 (image->colorspace == CMYKColorspace))
6605 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6606 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6607 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6611 InheritPerlException(exception,perl_exception);
6612 exception=DestroyExceptionInfo(exception);
6613 SvREFCNT_dec(perl_exception);
6617 ###############################################################################
6621 # G e t P i x e l s #
6625 ###############################################################################
6630 Image::Magick ref=NO_INIT
6669 *reference; /* reference is the SV* of ref=SvIV(reference) */
6671 PERL_UNUSED_VAR(ref);
6672 PERL_UNUSED_VAR(ix);
6673 exception=AcquireExceptionInfo();
6674 perl_exception=newSVpv("",0);
6675 reference=SvRV(ST(0));
6676 av=(AV *) reference;
6677 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6679 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6680 if (image == (Image *) NULL)
6682 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6687 if (image->alpha_trait != UndefinedPixelTrait)
6689 if (image->colorspace == CMYKColorspace)
6692 if (image->alpha_trait != UndefinedPixelTrait)
6695 normalize=MagickFalse;
6698 region.width=image->columns;
6701 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6702 for (i=2; i < items; i+=2)
6704 attribute=(char *) SvPV(ST(i-1),na);
6710 if (LocaleCompare(attribute,"geometry") == 0)
6712 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6715 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6722 if (LocaleCompare(attribute,"height") == 0)
6724 region.height=SvIV(ST(i));
6727 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6734 if (LocaleCompare(attribute,"map") == 0)
6739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6746 if (LocaleCompare(attribute,"normalize") == 0)
6748 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6752 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6756 normalize=option != 0 ? MagickTrue : MagickFalse;
6759 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6766 if (LocaleCompare(attribute,"width") == 0)
6768 region.width=SvIV(ST(i));
6771 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6778 if (LocaleCompare(attribute,"x") == 0)
6780 region.x=SvIV(ST(i));
6783 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6790 if (LocaleCompare(attribute,"y") == 0)
6792 region.y=SvIV(ST(i));
6795 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6801 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6807 if (normalize != MagickFalse)
6812 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6813 region.height*sizeof(*pixels));
6814 if (pixels == (float *) NULL)
6816 ThrowPerlException(exception,ResourceLimitError,
6817 "MemoryAllocationFailed",PackageName);
6820 status=ExportImagePixels(image,region.x,region.y,region.width,
6821 region.height,map,FloatPixel,pixels,exception);
6822 if (status == MagickFalse)
6826 EXTEND(sp,strlen(map)*region.width*region.height);
6827 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6828 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6830 pixels=(float *) RelinquishMagickMemory(pixels);
6837 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6838 region.height*sizeof(*pixels));
6839 if (pixels == (Quantum *) NULL)
6841 ThrowPerlException(exception,ResourceLimitError,
6842 "MemoryAllocationFailed",PackageName);
6845 status=ExportImagePixels(image,region.x,region.y,region.width,
6846 region.height,map,QuantumPixel,pixels,exception);
6847 if (status == MagickFalse)
6851 EXTEND(sp,strlen(map)*region.width*region.height);
6852 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6853 PUSHs(sv_2mortal(newSViv(pixels[i])));
6855 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6859 InheritPerlException(exception,perl_exception);
6860 exception=DestroyExceptionInfo(exception);
6861 SvREFCNT_dec(perl_exception);
6865 ###############################################################################
6869 # I m a g e T o B l o b #
6873 ###############################################################################
6877 ImageToBlob(ref,...)
6878 Image::Magick ref=NO_INIT
6887 filename[MagickPathExtent];
6916 PERL_UNUSED_VAR(ref);
6917 PERL_UNUSED_VAR(ix);
6918 exception=AcquireExceptionInfo();
6919 perl_exception=newSVpv("",0);
6920 package_info=(struct PackageInfo *) NULL;
6921 if (sv_isobject(ST(0)) == 0)
6923 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6927 reference=SvRV(ST(0));
6928 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6929 if (image == (Image *) NULL)
6931 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6935 package_info=ClonePackageInfo(info,exception);
6936 for (i=2; i < items; i+=2)
6937 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6938 (void) CopyMagickString(filename,package_info->image_info->filename,
6941 for (next=image; next; next=next->next)
6943 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6944 next->scene=scene++;
6946 SetImageInfo(package_info->image_info,(unsigned int)
6947 GetImageListLength(image),exception);
6948 EXTEND(sp,(ssize_t) GetImageListLength(image));
6949 for ( ; image; image=image->next)
6952 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6953 if (blob != (char *) NULL)
6955 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6956 blob=(unsigned char *) RelinquishMagickMemory(blob);
6958 if (package_info->image_info->adjoin)
6963 if (package_info != (struct PackageInfo *) NULL)
6964 DestroyPackageInfo(package_info);
6965 InheritPerlException(exception,perl_exception);
6966 exception=DestroyExceptionInfo(exception);
6967 SvREFCNT_dec(perl_exception); /* throw away all errors */
6971 ###############################################################################
6979 ###############################################################################
6984 Image::Magick ref=NO_INIT
6988 OptimizeImageLayers = 3
6990 optimizeimagelayers = 5
7032 PERL_UNUSED_VAR(ref);
7033 PERL_UNUSED_VAR(ix);
7034 exception=AcquireExceptionInfo();
7035 perl_exception=newSVpv("",0);
7037 if (sv_isobject(ST(0)) == 0)
7039 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7043 reference=SvRV(ST(0));
7044 hv=SvSTASH(reference);
7046 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7048 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7049 if (image == (Image *) NULL)
7051 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7055 compose=image->compose;
7056 method=OptimizeLayer;
7057 for (i=2; i < items; i+=2)
7059 attribute=(char *) SvPV(ST(i-1),na);
7065 if (LocaleCompare(attribute,"compose") == 0)
7067 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7068 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7071 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7075 compose=(CompositeOperator) sp;
7078 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7085 if (LocaleCompare(attribute,"method") == 0)
7087 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7091 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7095 method=(LayerMethod) option;
7098 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7104 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7110 layers=(Image *) NULL;
7113 case CompareAnyLayer:
7114 case CompareClearLayer:
7115 case CompareOverlayLayer:
7118 layers=CompareImagesLayers(image,method,exception);
7125 layers=MergeImageLayers(image,method,exception);
7130 layers=DisposeImages(image,exception);
7133 case OptimizeImageLayer:
7135 layers=OptimizeImageLayers(image,exception);
7138 case OptimizePlusLayer:
7140 layers=OptimizePlusImageLayers(image,exception);
7143 case OptimizeTransLayer:
7145 OptimizeImageTransparency(image,exception);
7148 case RemoveDupsLayer:
7150 RemoveDuplicateLayers(&image,exception);
7153 case RemoveZeroLayer:
7155 RemoveZeroDelayLayers(&image,exception);
7164 General Purpose, GIF Animation Optimizer.
7166 layers=CoalesceImages(image,exception);
7167 if (layers == (Image *) NULL)
7170 layers=OptimizeImageLayers(image,exception);
7171 if (layers == (Image *) NULL)
7173 image=DestroyImageList(image);
7175 layers=(Image *) NULL;
7176 OptimizeImageTransparency(image,exception);
7177 quantize_info=AcquireQuantizeInfo(info->image_info);
7178 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7179 quantize_info=DestroyQuantizeInfo(quantize_info);
7182 case CompositeLayer:
7191 Split image sequence at the first 'NULL:' image.
7194 while (source != (Image *) NULL)
7196 source=GetNextImageInList(source);
7197 if ((source != (Image *) NULL) &&
7198 (LocaleCompare(source->magick,"NULL") == 0))
7201 if (source != (Image *) NULL)
7203 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7204 (GetNextImageInList(source) == (Image *) NULL))
7205 source=(Image *) NULL;
7209 Separate the two lists, junk the null: image.
7211 source=SplitImageList(source->previous);
7212 DeleteImageFromList(&source);
7215 if (source == (Image *) NULL)
7217 (void) ThrowMagickException(exception,GetMagickModule(),
7218 OptionError,"MissingNullSeparator","layers Composite");
7222 Adjust offset with gravity and virtual canvas.
7224 SetGeometry(image,&geometry);
7225 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7226 geometry.width=source->page.width != 0 ? source->page.width :
7228 geometry.height=source->page.height != 0 ? source->page.height :
7230 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7231 image->columns,image->page.height != 0 ? image->page.height :
7232 image->rows,image->gravity,&geometry);
7233 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7234 source=DestroyImageList(source);
7238 if (layers != (Image *) NULL)
7241 image=CloneImage(image,0,0,MagickTrue,exception);
7242 if (image == (Image *) NULL)
7244 for ( ; image; image=image->next)
7246 AddImageToRegistry(sv,image);
7248 av_push(av,sv_bless(rv,hv));
7251 exception=DestroyExceptionInfo(exception);
7253 SvREFCNT_dec(perl_exception);
7257 InheritPerlException(exception,perl_exception);
7258 exception=DestroyExceptionInfo(exception);
7259 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7260 SvPOK_on(perl_exception);
7261 ST(0)=sv_2mortal(perl_exception);
7266 ###############################################################################
7270 # M a g i c k T o M i m e #
7274 ###############################################################################
7278 MagickToMime(ref,name)
7279 Image::Magick ref=NO_INIT
7288 PERL_UNUSED_VAR(ref);
7289 PERL_UNUSED_VAR(ix);
7290 mime=MagickToMime(name);
7291 RETVAL=newSVpv(mime,0);
7292 mime=(char *) RelinquishMagickMemory(mime);
7298 ###############################################################################
7306 ###############################################################################
7311 Image::Magick ref=NO_INIT
7348 MedianConvolveImage = 36
7354 ReduceNoiseImage = 42
7380 ColorFloodfillImage= 68
7386 CycleColormapImage = 74
7396 MatteFloodfillImage= 84
7404 NumberColorsImage = 92
7414 SignatureImage = 102
7424 TransparentImage = 112
7426 ThresholdImage = 114
7440 DeconstructImage = 130
7442 GaussianBlurImage = 132
7448 UnsharpMaskImage = 138
7450 MotionBlurImage = 140
7452 OrderedDitherImage = 142
7459 AffineTransform = 149
7460 AffineTransformImage = 150
7462 DifferenceImage = 152
7463 AdaptiveThreshold = 153
7464 AdaptiveThresholdImage = 154
7469 BlackThreshold = 159
7470 BlackThresholdImage= 160
7471 WhiteThreshold = 161
7472 WhiteThresholdImage= 162
7473 RotationalBlur = 163
7474 RotationalBlurImage= 164
7476 ThumbnailImage = 166
7486 PosterizeImage = 176
7492 SepiaToneImage = 182
7493 SigmoidalContrast = 183
7494 SigmoidalContrastImage = 184
7499 ContrastStretch = 189
7500 ContrastStretchImage = 190
7505 AdaptiveSharpen = 195
7506 AdaptiveSharpenImage = 196
7508 TransposeImage = 198
7510 TransverseImage = 200
7512 AutoOrientImage = 202
7514 AdaptiveBlurImage = 204
7518 UniqueColorsImage = 208
7519 AdaptiveResize = 209
7520 AdaptiveResizeImage= 210
7524 LinearStretchImage = 214
7526 ColorMatrixImage = 216
7531 FloodfillPaint = 221
7532 FloodfillPaintImage= 222
7538 LiquidRescaleImage = 228
7548 SparseColorImage = 238
7552 SelectiveBlurImage = 242
7556 BlueShiftImage = 246
7557 ForwardFourierTransform = 247
7558 ForwardFourierTransformImage = 248
7559 InverseFourierTransform = 249
7560 InverseFourierTransformImage = 250
7561 ColorDecisionList = 251
7562 ColorDecisionListImage = 252
7564 AutoGammaImage = 254
7566 AutoLevelImage = 256
7568 LevelImageColors = 258
7571 BrightnessContrast = 261
7572 BrightnessContrastImage = 262
7574 MorphologyImage = 264
7580 StatisticImage = 270
7582 PerceptibleImage = 272
7586 GrayscaleImage = 276
7588 CannyEdgeImage = 279
7590 HoughLineImage = 281
7592 MeanShiftImage = 283
7595 ConnectedComponent = 286
7596 ConnectedComponentImage = 287
7598 CopyImagePixels = 289
7607 attribute_flag[MaxArguments],
7608 message[MagickPathExtent];
7669 argument_list[MaxArguments];
7671 PERL_UNUSED_VAR(ref);
7672 PERL_UNUSED_VAR(ix);
7673 exception=AcquireExceptionInfo();
7674 perl_exception=newSVpv("",0);
7675 reference_vector=NULL;
7679 if (sv_isobject(ST(0)) == 0)
7681 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7685 reference=SvRV(ST(0));
7686 region_info.width=0;
7687 region_info.height=0;
7690 region_image=(Image *) NULL;
7691 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7692 if (ix && (ix != 666))
7695 Called as Method(...)
7698 rp=(&Methods[ix-1]);
7704 Called as Mogrify("Method",...)
7706 attribute=(char *) SvPV(ST(1),na);
7709 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7710 attribute=(char *) SvPV(ST(2),na);
7713 for (rp=Methods; ; rp++)
7715 if (rp >= EndOf(Methods))
7717 ThrowPerlException(exception,OptionError,
7718 "UnrecognizedPerlMagickMethod",attribute);
7721 if (strEQcase(attribute,rp->name))
7727 if (image == (Image *) NULL)
7729 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7732 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7733 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7734 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7751 pp=(Arguments *) NULL;
7759 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7761 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7763 if (strEQcase(attribute,qq->method) > ssize_test)
7766 ssize_test=strEQcase(attribute,qq->method);
7769 if (pp == (Arguments *) NULL)
7771 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7773 goto continue_outer_loop;
7775 al=(&argument_list[pp-rp->arguments]);
7778 case ArrayReference:
7780 if (SvTYPE(sv) != SVt_RV)
7782 (void) FormatLocaleString(message,MagickPathExtent,
7783 "invalid %.60s value",pp->method);
7784 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7785 goto continue_outer_loop;
7787 al->array_reference=SvRV(sv);
7792 al->real_reference=SvNV(sv);
7797 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7800 case ImageReference:
7802 if (!sv_isobject(sv) ||
7803 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7804 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7806 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7812 case IntegerReference:
7814 al->integer_reference=SvIV(sv);
7817 case StringReference:
7819 al->string_reference=(char *) SvPV(sv,al->length);
7820 if (sv_isobject(sv))
7821 al->image_reference=SetupList(aTHX_ SvRV(sv),
7822 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7828 Is a string; look up name.
7830 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7832 al->string_reference=(char *) SvPV(sv,al->length);
7833 al->integer_reference=(-1);
7836 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7837 MagickFalse,SvPV(sv,na));
7838 if (pp->type == MagickChannelOptions)
7839 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7840 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7842 (void) FormatLocaleString(message,MagickPathExtent,
7843 "invalid %.60s value",pp->method);
7844 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7845 goto continue_outer_loop;
7850 attribute_flag[pp-rp->arguments]++;
7851 continue_outer_loop: ;
7853 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7854 pv=reference_vector;
7855 SetGeometryInfo(&geometry_info);
7856 channel=DefaultChannels;
7857 for (next=image; next; next=next->next)
7860 SetGeometry(image,&geometry);
7861 if ((region_info.width*region_info.height) != 0)
7864 image=CropImage(image,®ion_info,exception);
7870 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) ix);
7871 ThrowPerlException(exception,OptionError,
7872 "UnrecognizedPerlMagickMethod",message);
7875 case 1: /* Comment */
7877 if (attribute_flag[0] == 0)
7878 argument_list[0].string_reference=(char *) NULL;
7879 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7880 info ? info->image_info : (ImageInfo *) NULL,image,
7881 argument_list[0].string_reference,exception),exception);
7886 if (attribute_flag[0] == 0)
7887 argument_list[0].string_reference=(char *) NULL;
7888 (void) SetImageProperty(image,"label",InterpretImageProperties(
7889 info ? info->image_info : (ImageInfo *) NULL,image,
7890 argument_list[0].string_reference,exception),exception);
7893 case 3: /* AddNoise */
7898 if (attribute_flag[0] == 0)
7899 argument_list[0].integer_reference=UniformNoise;
7901 if (attribute_flag[1] != 0)
7902 attenuate=argument_list[1].real_reference;
7903 if (attribute_flag[2] != 0)
7904 channel=(ChannelType) argument_list[2].integer_reference;
7905 channel_mask=SetImageChannelMask(image,channel);
7906 image=AddNoiseImage(image,(NoiseType)
7907 argument_list[0].integer_reference,attenuate,exception);
7908 if (image != (Image *) NULL)
7909 (void) SetImageChannelMask(image,channel_mask);
7912 case 4: /* Colorize */
7917 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7918 0,0,&target,exception);
7919 if (attribute_flag[0] != 0)
7920 (void) QueryColorCompliance(argument_list[0].string_reference,
7921 AllCompliance,&target,exception);
7922 if (attribute_flag[1] == 0)
7923 argument_list[1].string_reference="100%";
7924 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7928 case 5: /* Border */
7935 if (attribute_flag[0] != 0)
7936 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7937 &geometry,exception);
7938 if (attribute_flag[1] != 0)
7939 geometry.width=argument_list[1].integer_reference;
7940 if (attribute_flag[2] != 0)
7941 geometry.height=argument_list[2].integer_reference;
7942 if (attribute_flag[3] != 0)
7943 QueryColorCompliance(argument_list[3].string_reference,
7944 AllCompliance,&image->border_color,exception);
7945 if (attribute_flag[4] != 0)
7946 QueryColorCompliance(argument_list[4].string_reference,
7947 AllCompliance,&image->border_color,exception);
7948 if (attribute_flag[5] != 0)
7949 QueryColorCompliance(argument_list[5].string_reference,
7950 AllCompliance,&image->border_color,exception);
7951 compose=image->compose;
7952 if (attribute_flag[6] != 0)
7953 compose=(CompositeOperator) argument_list[6].integer_reference;
7954 image=BorderImage(image,&geometry,compose,exception);
7959 if (attribute_flag[0] != 0)
7961 flags=ParseGeometry(argument_list[0].string_reference,
7963 if ((flags & SigmaValue) == 0)
7964 geometry_info.sigma=1.0;
7966 if (attribute_flag[1] != 0)
7967 geometry_info.rho=argument_list[1].real_reference;
7968 if (attribute_flag[2] != 0)
7969 geometry_info.sigma=argument_list[2].real_reference;
7970 if (attribute_flag[3] != 0)
7971 channel=(ChannelType) argument_list[3].integer_reference;
7972 channel_mask=SetImageChannelMask(image,channel);
7973 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7975 if (image != (Image *) NULL)
7976 (void) SetImageChannelMask(image,channel_mask);
7981 if (attribute_flag[5] != 0)
7982 image->gravity=(GravityType) argument_list[5].integer_reference;
7983 if (attribute_flag[0] != 0)
7984 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7985 &geometry,exception);
7986 if (attribute_flag[1] != 0)
7987 geometry.width=argument_list[1].integer_reference;
7988 if (attribute_flag[2] != 0)
7989 geometry.height=argument_list[2].integer_reference;
7990 if (attribute_flag[3] != 0)
7991 geometry.x=argument_list[3].integer_reference;
7992 if (attribute_flag[4] != 0)
7993 geometry.y=argument_list[4].integer_reference;
7994 image=ChopImage(image,&geometry,exception);
7999 if (attribute_flag[6] != 0)
8000 image->gravity=(GravityType) argument_list[6].integer_reference;
8001 if (attribute_flag[0] != 0)
8002 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
8003 &geometry,exception);
8004 if (attribute_flag[1] != 0)
8005 geometry.width=argument_list[1].integer_reference;
8006 if (attribute_flag[2] != 0)
8007 geometry.height=argument_list[2].integer_reference;
8008 if (attribute_flag[3] != 0)
8009 geometry.x=argument_list[3].integer_reference;
8010 if (attribute_flag[4] != 0)
8011 geometry.y=argument_list[4].integer_reference;
8012 if (attribute_flag[5] != 0)
8013 image->fuzz=StringToDoubleInterval(
8014 argument_list[5].string_reference,(double) QuantumRange+1.0);
8015 image=CropImage(image,&geometry,exception);
8018 case 9: /* Despeckle */
8020 image=DespeckleImage(image,exception);
8025 if (attribute_flag[0] != 0)
8026 geometry_info.rho=argument_list[0].real_reference;
8027 image=EdgeImage(image,geometry_info.rho,exception);
8030 case 11: /* Emboss */
8032 if (attribute_flag[0] != 0)
8034 flags=ParseGeometry(argument_list[0].string_reference,
8036 if ((flags & SigmaValue) == 0)
8037 geometry_info.sigma=1.0;
8039 if (attribute_flag[1] != 0)
8040 geometry_info.rho=argument_list[1].real_reference;
8041 if (attribute_flag[2] != 0)
8042 geometry_info.sigma=argument_list[2].real_reference;
8043 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8047 case 12: /* Enhance */
8049 image=EnhanceImage(image,exception);
8054 image=FlipImage(image,exception);
8059 image=FlopImage(image,exception);
8062 case 15: /* Frame */
8070 if (attribute_flag[0] != 0)
8072 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8073 &geometry,exception);
8074 frame_info.width=geometry.width;
8075 frame_info.height=geometry.height;
8076 frame_info.outer_bevel=geometry.x;
8077 frame_info.inner_bevel=geometry.y;
8079 if (attribute_flag[1] != 0)
8080 frame_info.width=argument_list[1].integer_reference;
8081 if (attribute_flag[2] != 0)
8082 frame_info.height=argument_list[2].integer_reference;
8083 if (attribute_flag[3] != 0)
8084 frame_info.inner_bevel=argument_list[3].integer_reference;
8085 if (attribute_flag[4] != 0)
8086 frame_info.outer_bevel=argument_list[4].integer_reference;
8087 if (attribute_flag[5] != 0)
8088 QueryColorCompliance(argument_list[5].string_reference,
8089 AllCompliance,&fill_color,exception);
8090 if (attribute_flag[6] != 0)
8091 QueryColorCompliance(argument_list[6].string_reference,
8092 AllCompliance,&fill_color,exception);
8093 frame_info.x=(ssize_t) frame_info.width;
8094 frame_info.y=(ssize_t) frame_info.height;
8095 frame_info.width=image->columns+2*frame_info.x;
8096 frame_info.height=image->rows+2*frame_info.y;
8097 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8098 image->matte_color=fill_color;
8099 compose=image->compose;
8100 if (attribute_flag[7] != 0)
8101 compose=(CompositeOperator) argument_list[7].integer_reference;
8102 image=FrameImage(image,&frame_info,compose,exception);
8105 case 16: /* Implode */
8107 PixelInterpolateMethod
8110 if (attribute_flag[0] == 0)
8111 argument_list[0].real_reference=0.5;
8112 method=UndefinedInterpolatePixel;
8113 if (attribute_flag[1] != 0)
8114 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8115 image=ImplodeImage(image,argument_list[0].real_reference,
8119 case 17: /* Magnify */
8121 image=MagnifyImage(image,exception);
8124 case 18: /* MedianFilter */
8126 if (attribute_flag[0] != 0)
8128 flags=ParseGeometry(argument_list[0].string_reference,
8130 if ((flags & SigmaValue) == 0)
8131 geometry_info.sigma=geometry_info.rho;
8133 if (attribute_flag[1] != 0)
8134 geometry_info.rho=argument_list[1].real_reference;
8135 if (attribute_flag[2] != 0)
8136 geometry_info.sigma=argument_list[2].real_reference;
8137 if (attribute_flag[3] != 0)
8138 channel=(ChannelType) argument_list[3].integer_reference;
8139 channel_mask=SetImageChannelMask(image,channel);
8140 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8141 (size_t) geometry_info.sigma,exception);
8142 if (image != (Image *) NULL)
8143 (void) SetImageChannelMask(image,channel_mask);
8146 case 19: /* Minify */
8148 image=MinifyImage(image,exception);
8151 case 20: /* OilPaint */
8153 if (attribute_flag[0] == 0)
8154 argument_list[0].real_reference=0.0;
8155 if (attribute_flag[1] == 0)
8156 argument_list[1].real_reference=1.0;
8157 image=OilPaintImage(image,argument_list[0].real_reference,
8158 argument_list[1].real_reference,exception);
8161 case 21: /* ReduceNoise */
8163 if (attribute_flag[0] != 0)
8165 flags=ParseGeometry(argument_list[0].string_reference,
8167 if ((flags & SigmaValue) == 0)
8168 geometry_info.sigma=1.0;
8170 if (attribute_flag[1] != 0)
8171 geometry_info.rho=argument_list[1].real_reference;
8172 if (attribute_flag[2] != 0)
8173 geometry_info.sigma=argument_list[2].real_reference;
8174 if (attribute_flag[3] != 0)
8175 channel=(ChannelType) argument_list[3].integer_reference;
8176 channel_mask=SetImageChannelMask(image,channel);
8177 image=StatisticImage(image,NonpeakStatistic,(size_t)
8178 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8179 if (image != (Image *) NULL)
8180 (void) SetImageChannelMask(image,channel_mask);
8185 if (attribute_flag[0] != 0)
8186 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8187 &geometry,exception);
8188 if (attribute_flag[1] != 0)
8189 geometry.x=argument_list[1].integer_reference;
8190 if (attribute_flag[2] != 0)
8191 geometry.y=argument_list[2].integer_reference;
8192 image=RollImage(image,geometry.x,geometry.y,exception);
8195 case 23: /* Rotate */
8197 if (attribute_flag[0] == 0)
8198 argument_list[0].real_reference=90.0;
8199 if (attribute_flag[1] != 0)
8201 QueryColorCompliance(argument_list[1].string_reference,
8202 AllCompliance,&image->background_color,exception);
8203 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8204 (image->alpha_trait == UndefinedPixelTrait))
8205 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8207 image=RotateImage(image,argument_list[0].real_reference,exception);
8210 case 24: /* Sample */
8212 if (attribute_flag[0] != 0)
8213 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8214 &geometry,exception);
8215 if (attribute_flag[1] != 0)
8216 geometry.width=argument_list[1].integer_reference;
8217 if (attribute_flag[2] != 0)
8218 geometry.height=argument_list[2].integer_reference;
8219 image=SampleImage(image,geometry.width,geometry.height,exception);
8222 case 25: /* Scale */
8224 if (attribute_flag[0] != 0)
8225 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8226 &geometry,exception);
8227 if (attribute_flag[1] != 0)
8228 geometry.width=argument_list[1].integer_reference;
8229 if (attribute_flag[2] != 0)
8230 geometry.height=argument_list[2].integer_reference;
8231 image=ScaleImage(image,geometry.width,geometry.height,exception);
8234 case 26: /* Shade */
8236 if (attribute_flag[0] != 0)
8238 flags=ParseGeometry(argument_list[0].string_reference,
8240 if ((flags & SigmaValue) == 0)
8241 geometry_info.sigma=0.0;
8243 if (attribute_flag[1] != 0)
8244 geometry_info.rho=argument_list[1].real_reference;
8245 if (attribute_flag[2] != 0)
8246 geometry_info.sigma=argument_list[2].real_reference;
8247 image=ShadeImage(image,
8248 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8249 geometry_info.rho,geometry_info.sigma,exception);
8252 case 27: /* Sharpen */
8254 if (attribute_flag[0] != 0)
8256 flags=ParseGeometry(argument_list[0].string_reference,
8258 if ((flags & SigmaValue) == 0)
8259 geometry_info.sigma=1.0;
8261 if (attribute_flag[1] != 0)
8262 geometry_info.rho=argument_list[1].real_reference;
8263 if (attribute_flag[2] != 0)
8264 geometry_info.sigma=argument_list[2].real_reference;
8265 if (attribute_flag[3] != 0)
8266 channel=(ChannelType) argument_list[3].integer_reference;
8267 channel_mask=SetImageChannelMask(image,channel);
8268 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8270 if (image != (Image *) NULL)
8271 (void) SetImageChannelMask(image,channel_mask);
8274 case 28: /* Shear */
8276 if (attribute_flag[0] != 0)
8278 flags=ParseGeometry(argument_list[0].string_reference,
8280 if ((flags & SigmaValue) == 0)
8281 geometry_info.sigma=geometry_info.rho;
8283 if (attribute_flag[1] != 0)
8284 geometry_info.rho=argument_list[1].real_reference;
8285 if (attribute_flag[2] != 0)
8286 geometry_info.sigma=argument_list[2].real_reference;
8287 if (attribute_flag[3] != 0)
8288 QueryColorCompliance(argument_list[3].string_reference,
8289 AllCompliance,&image->background_color,exception);
8290 if (attribute_flag[4] != 0)
8291 QueryColorCompliance(argument_list[4].string_reference,
8292 AllCompliance,&image->background_color,exception);
8293 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8297 case 29: /* Spread */
8299 PixelInterpolateMethod
8302 if (attribute_flag[0] == 0)
8303 argument_list[0].real_reference=1.0;
8304 method=UndefinedInterpolatePixel;
8305 if (attribute_flag[1] != 0)
8306 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8307 image=SpreadImage(image,method,argument_list[0].real_reference,
8311 case 30: /* Swirl */
8313 PixelInterpolateMethod
8316 if (attribute_flag[0] == 0)
8317 argument_list[0].real_reference=50.0;
8318 method=UndefinedInterpolatePixel;
8319 if (attribute_flag[1] != 0)
8320 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8321 image=SwirlImage(image,argument_list[0].real_reference,
8325 case 31: /* Resize */
8328 if (attribute_flag[0] != 0)
8329 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8330 &geometry,exception);
8331 if (attribute_flag[1] != 0)
8332 geometry.width=argument_list[1].integer_reference;
8333 if (attribute_flag[2] != 0)
8334 geometry.height=argument_list[2].integer_reference;
8335 if (attribute_flag[3] == 0)
8336 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8337 if (attribute_flag[4] != 0)
8338 SetImageArtifact(image,"filter:support",
8339 argument_list[4].string_reference);
8340 image=ResizeImage(image,geometry.width,geometry.height,
8341 (FilterTypes) argument_list[3].integer_reference,
8345 case 33: /* Annotate */
8350 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8352 if (attribute_flag[0] != 0)
8357 text=InterpretImageProperties(info ? info->image_info :
8358 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8360 (void) CloneString(&draw_info->text,text);
8361 text=DestroyString(text);
8363 if (attribute_flag[1] != 0)
8364 (void) CloneString(&draw_info->font,
8365 argument_list[1].string_reference);
8366 if (attribute_flag[2] != 0)
8367 draw_info->pointsize=argument_list[2].real_reference;
8368 if (attribute_flag[3] != 0)
8369 (void) CloneString(&draw_info->density,
8370 argument_list[3].string_reference);
8371 if (attribute_flag[4] != 0)
8372 (void) QueryColorCompliance(argument_list[4].string_reference,
8373 AllCompliance,&draw_info->undercolor,exception);
8374 if (attribute_flag[5] != 0)
8376 (void) QueryColorCompliance(argument_list[5].string_reference,
8377 AllCompliance,&draw_info->stroke,exception);
8378 if (argument_list[5].image_reference != (Image *) NULL)
8379 draw_info->stroke_pattern=CloneImage(
8380 argument_list[5].image_reference,0,0,MagickTrue,exception);
8382 if (attribute_flag[6] != 0)
8384 (void) QueryColorCompliance(argument_list[6].string_reference,
8385 AllCompliance,&draw_info->fill,exception);
8386 if (argument_list[6].image_reference != (Image *) NULL)
8387 draw_info->fill_pattern=CloneImage(
8388 argument_list[6].image_reference,0,0,MagickTrue,exception);
8390 if (attribute_flag[7] != 0)
8392 (void) CloneString(&draw_info->geometry,
8393 argument_list[7].string_reference);
8394 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8395 &geometry,exception);
8396 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8397 geometry_info.sigma=geometry_info.xi;
8399 if (attribute_flag[8] != 0)
8400 (void) QueryColorCompliance(argument_list[8].string_reference,
8401 AllCompliance,&draw_info->fill,exception);
8402 if (attribute_flag[11] != 0)
8403 draw_info->gravity=(GravityType)
8404 argument_list[11].integer_reference;
8405 if (attribute_flag[25] != 0)
8410 av=(AV *) argument_list[25].array_reference;
8411 if ((av_len(av) != 3) && (av_len(av) != 5))
8413 ThrowPerlException(exception,OptionError,
8414 "affine matrix must have 4 or 6 elements",PackageName);
8417 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8418 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8419 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8420 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8421 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8422 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8424 ThrowPerlException(exception,OptionError,
8425 "affine matrix is singular",PackageName);
8428 if (av_len(av) == 5)
8430 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8431 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8434 for (j=12; j < 17; j++)
8436 if (attribute_flag[j] == 0)
8438 value=argument_list[j].string_reference;
8439 angle=argument_list[j].real_reference;
8440 current=draw_info->affine;
8441 GetAffineMatrix(&affine);
8449 flags=ParseGeometry(value,&geometry_info);
8450 affine.tx=geometry_info.xi;
8451 affine.ty=geometry_info.psi;
8452 if ((flags & PsiValue) == 0)
8453 affine.ty=affine.tx;
8461 flags=ParseGeometry(value,&geometry_info);
8462 affine.sx=geometry_info.rho;
8463 affine.sy=geometry_info.sigma;
8464 if ((flags & SigmaValue) == 0)
8465 affine.sy=affine.sx;
8475 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8476 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8477 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8478 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8486 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8494 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8498 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8499 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8500 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8501 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8502 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8504 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8507 if (attribute_flag[9] == 0)
8508 argument_list[9].real_reference=0.0;
8509 if (attribute_flag[10] == 0)
8510 argument_list[10].real_reference=0.0;
8511 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8514 geometry[MagickPathExtent];
8516 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8517 (double) argument_list[9].real_reference+draw_info->affine.tx,
8518 (double) argument_list[10].real_reference+draw_info->affine.ty);
8519 (void) CloneString(&draw_info->geometry,geometry);
8521 if (attribute_flag[17] != 0)
8522 draw_info->stroke_width=argument_list[17].real_reference;
8523 if (attribute_flag[18] != 0)
8525 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8526 MagickTrue : MagickFalse;
8527 draw_info->stroke_antialias=draw_info->text_antialias;
8529 if (attribute_flag[19] != 0)
8530 (void) CloneString(&draw_info->family,
8531 argument_list[19].string_reference);
8532 if (attribute_flag[20] != 0)
8533 draw_info->style=(StyleType) argument_list[20].integer_reference;
8534 if (attribute_flag[21] != 0)
8535 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8536 if (attribute_flag[22] != 0)
8537 draw_info->weight=argument_list[22].integer_reference;
8538 if (attribute_flag[23] != 0)
8539 draw_info->align=(AlignType) argument_list[23].integer_reference;
8540 if (attribute_flag[24] != 0)
8541 (void) CloneString(&draw_info->encoding,
8542 argument_list[24].string_reference);
8543 if (attribute_flag[25] != 0)
8544 draw_info->fill_pattern=CloneImage(
8545 argument_list[25].image_reference,0,0,MagickTrue,exception);
8546 if (attribute_flag[26] != 0)
8547 draw_info->fill_pattern=CloneImage(
8548 argument_list[26].image_reference,0,0,MagickTrue,exception);
8549 if (attribute_flag[27] != 0)
8550 draw_info->stroke_pattern=CloneImage(
8551 argument_list[27].image_reference,0,0,MagickTrue,exception);
8552 if (attribute_flag[29] != 0)
8553 draw_info->kerning=argument_list[29].real_reference;
8554 if (attribute_flag[30] != 0)
8555 draw_info->interline_spacing=argument_list[30].real_reference;
8556 if (attribute_flag[31] != 0)
8557 draw_info->interword_spacing=argument_list[31].real_reference;
8558 if (attribute_flag[32] != 0)
8559 draw_info->direction=(DirectionType)
8560 argument_list[32].integer_reference;
8561 (void) AnnotateImage(image,draw_info,exception);
8562 draw_info=DestroyDrawInfo(draw_info);
8565 case 34: /* ColorFloodfill */
8576 draw_info=CloneDrawInfo(info ? info->image_info :
8577 (ImageInfo *) NULL,(DrawInfo *) NULL);
8578 if (attribute_flag[0] != 0)
8579 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8580 &geometry,exception);
8581 if (attribute_flag[1] != 0)
8582 geometry.x=argument_list[1].integer_reference;
8583 if (attribute_flag[2] != 0)
8584 geometry.y=argument_list[2].integer_reference;
8585 if (attribute_flag[3] != 0)
8586 (void) QueryColorCompliance(argument_list[3].string_reference,
8587 AllCompliance,&draw_info->fill,exception);
8588 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8589 geometry.x,geometry.y,&target,exception);
8591 if (attribute_flag[4] != 0)
8593 QueryColorCompliance(argument_list[4].string_reference,
8594 AllCompliance,&target,exception);
8597 if (attribute_flag[5] != 0)
8598 image->fuzz=StringToDoubleInterval(
8599 argument_list[5].string_reference,(double) QuantumRange+1.0);
8600 if (attribute_flag[6] != 0)
8601 invert=(MagickBooleanType) argument_list[6].integer_reference;
8602 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8603 geometry.y,invert,exception);
8604 draw_info=DestroyDrawInfo(draw_info);
8607 case 35: /* Composite */
8610 composite_geometry[MagickPathExtent];
8619 compose=OverCompositeOp;
8620 if (attribute_flag[0] != 0)
8621 composite_image=argument_list[0].image_reference;
8624 ThrowPerlException(exception,OptionError,
8625 "CompositeImageRequired",PackageName);
8629 Parameter Handling used for BOTH normal and tiled composition.
8631 if (attribute_flag[1] != 0) /* compose */
8632 compose=(CompositeOperator) argument_list[1].integer_reference;
8633 if (attribute_flag[6] != 0) /* opacity */
8635 if (compose != DissolveCompositeOp)
8636 (void) SetImageAlpha(composite_image,(Quantum)
8637 StringToDoubleInterval(argument_list[6].string_reference,
8638 (double) QuantumRange+1.0),exception);
8660 Handle dissolve composite operator (patch by
8663 (void) CloneString(&image->geometry,
8664 argument_list[6].string_reference);
8665 opacity=(Quantum) StringToDoubleInterval(
8666 argument_list[6].string_reference,(double) QuantumRange+
8668 if (composite_image->alpha_trait != UndefinedPixelTrait)
8669 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8670 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8671 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8673 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8674 composite_image->columns,1,exception);
8675 for (x=0; x < (ssize_t) composite_image->columns; x++)
8677 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8678 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8680 q+=GetPixelChannels(composite_image);
8682 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8683 if (sync == MagickFalse)
8686 composite_view=DestroyCacheView(composite_view);
8689 if (attribute_flag[9] != 0) /* "color=>" */
8690 QueryColorCompliance(argument_list[9].string_reference,
8691 AllCompliance,&composite_image->background_color,exception);
8692 if (attribute_flag[12] != 0) /* "interpolate=>" */
8693 image->interpolate=(PixelInterpolateMethod)
8694 argument_list[12].integer_reference;
8695 if (attribute_flag[13] != 0) /* "args=>" */
8696 (void) SetImageArtifact(composite_image,"compose:args",
8697 argument_list[13].string_reference);
8698 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8699 (void) SetImageArtifact(composite_image,"compose:args",
8700 argument_list[14].string_reference);
8701 clip_to_self=MagickTrue;
8702 if (attribute_flag[15] != 0)
8703 clip_to_self=(MagickBooleanType)
8704 argument_list[15].integer_reference;
8706 Tiling Composition (with orthogonal rotate).
8708 rotate_image=(Image *) NULL;
8709 if (attribute_flag[8] != 0) /* "rotate=>" */
8714 rotate_image=RotateImage(composite_image,
8715 argument_list[8].real_reference,exception);
8716 if (rotate_image == (Image *) NULL)
8719 if ((attribute_flag[7] != 0) &&
8720 (argument_list[7].integer_reference != 0)) /* tile */
8727 Tile the composite image.
8729 if (attribute_flag[8] != 0) /* "tile=>" */
8730 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8733 (void) SetImageArtifact(composite_image,
8734 "compose:outside-overlay","false");
8735 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8736 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8738 if (attribute_flag[8] != 0) /* rotate */
8739 (void) CompositeImage(image,rotate_image,compose,
8740 MagickTrue,x,y,exception);
8742 (void) CompositeImage(image,composite_image,compose,
8743 MagickTrue,x,y,exception);
8745 if (attribute_flag[8] != 0) /* rotate */
8746 rotate_image=DestroyImage(rotate_image);
8750 Parameter Handling used used ONLY for normal composition.
8752 if (attribute_flag[5] != 0) /* gravity */
8753 image->gravity=(GravityType) argument_list[5].integer_reference;
8754 if (attribute_flag[2] != 0) /* geometry offset */
8756 SetGeometry(image,&geometry);
8757 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8759 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8762 if (attribute_flag[3] != 0) /* x offset */
8763 geometry.x=argument_list[3].integer_reference;
8764 if (attribute_flag[4] != 0) /* y offset */
8765 geometry.y=argument_list[4].integer_reference;
8766 if (attribute_flag[10] != 0) /* mask */
8768 if ((image->compose == DisplaceCompositeOp) ||
8769 (image->compose == DistortCompositeOp))
8772 Merge Y displacement into X displacement image.
8774 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8776 (void) CompositeImage(composite_image,
8777 argument_list[10].image_reference,CopyGreenCompositeOp,
8778 MagickTrue,0,0,exception);
8786 Set a blending mask for the composition.
8788 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8789 MagickTrue,exception);
8790 (void) SetImageMask(composite_image,ReadPixelMask,mask_image,
8792 mask_image=DestroyImage(mask_image);
8795 if (attribute_flag[11] != 0) /* channel */
8796 channel=(ChannelType) argument_list[11].integer_reference;
8798 Composite two images (normal composition).
8800 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8801 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8802 (double) composite_image->rows,(double) geometry.x,(double)
8804 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8806 channel_mask=SetImageChannelMask(image,channel);
8807 if (attribute_flag[8] == 0) /* no rotate */
8808 CompositeImage(image,composite_image,compose,clip_to_self,
8809 geometry.x,geometry.y,exception);
8813 Position adjust rotated image then composite.
8815 geometry.x-=(ssize_t) (rotate_image->columns-
8816 composite_image->columns)/2;
8817 geometry.y-=(ssize_t) (rotate_image->rows-
8818 composite_image->rows)/2;
8819 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8820 geometry.y,exception);
8821 rotate_image=DestroyImage(rotate_image);
8823 if (attribute_flag[10] != 0) /* mask */
8825 if ((image->compose == DisplaceCompositeOp) ||
8826 (image->compose == DistortCompositeOp))
8827 composite_image=DestroyImage(composite_image);
8829 (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
8832 (void) SetImageChannelMask(image,channel_mask);
8835 case 36: /* Contrast */
8837 if (attribute_flag[0] == 0)
8838 argument_list[0].integer_reference=0;
8839 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8840 MagickTrue : MagickFalse,exception);
8843 case 37: /* CycleColormap */
8845 if (attribute_flag[0] == 0)
8846 argument_list[0].integer_reference=6;
8847 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8856 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8858 (void) CloneString(&draw_info->primitive,"point");
8859 if (attribute_flag[0] != 0)
8861 if (argument_list[0].integer_reference < 0)
8862 (void) CloneString(&draw_info->primitive,
8863 argument_list[0].string_reference);
8865 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8866 MagickPrimitiveOptions,argument_list[0].integer_reference));
8868 if (attribute_flag[1] != 0)
8870 if (LocaleCompare(draw_info->primitive,"path") == 0)
8872 (void) ConcatenateString(&draw_info->primitive," '");
8873 ConcatenateString(&draw_info->primitive,
8874 argument_list[1].string_reference);
8875 (void) ConcatenateString(&draw_info->primitive,"'");
8879 (void) ConcatenateString(&draw_info->primitive," ");
8880 ConcatenateString(&draw_info->primitive,
8881 argument_list[1].string_reference);
8884 if (attribute_flag[2] != 0)
8886 (void) ConcatenateString(&draw_info->primitive," ");
8887 (void) ConcatenateString(&draw_info->primitive,
8888 CommandOptionToMnemonic(MagickMethodOptions,
8889 argument_list[2].integer_reference));
8891 if (attribute_flag[3] != 0)
8893 (void) QueryColorCompliance(argument_list[3].string_reference,
8894 AllCompliance,&draw_info->stroke,exception);
8895 if (argument_list[3].image_reference != (Image *) NULL)
8896 draw_info->stroke_pattern=CloneImage(
8897 argument_list[3].image_reference,0,0,MagickTrue,exception);
8899 if (attribute_flag[4] != 0)
8901 (void) QueryColorCompliance(argument_list[4].string_reference,
8902 AllCompliance,&draw_info->fill,exception);
8903 if (argument_list[4].image_reference != (Image *) NULL)
8904 draw_info->fill_pattern=CloneImage(
8905 argument_list[4].image_reference,0,0,MagickTrue,exception);
8907 if (attribute_flag[5] != 0)
8908 draw_info->stroke_width=argument_list[5].real_reference;
8909 if (attribute_flag[6] != 0)
8910 (void) CloneString(&draw_info->font,
8911 argument_list[6].string_reference);
8912 if (attribute_flag[7] != 0)
8913 (void) QueryColorCompliance(argument_list[7].string_reference,
8914 AllCompliance,&draw_info->border_color,exception);
8915 if (attribute_flag[8] != 0)
8916 draw_info->affine.tx=argument_list[8].real_reference;
8917 if (attribute_flag[9] != 0)
8918 draw_info->affine.ty=argument_list[9].real_reference;
8919 if (attribute_flag[20] != 0)
8924 av=(AV *) argument_list[20].array_reference;
8925 if ((av_len(av) != 3) && (av_len(av) != 5))
8927 ThrowPerlException(exception,OptionError,
8928 "affine matrix must have 4 or 6 elements",PackageName);
8931 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8932 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8933 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8934 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8935 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8936 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8938 ThrowPerlException(exception,OptionError,
8939 "affine matrix is singular",PackageName);
8942 if (av_len(av) == 5)
8944 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8945 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8948 for (j=10; j < 15; j++)
8950 if (attribute_flag[j] == 0)
8952 value=argument_list[j].string_reference;
8953 angle=argument_list[j].real_reference;
8954 current=draw_info->affine;
8955 GetAffineMatrix(&affine);
8963 flags=ParseGeometry(value,&geometry_info);
8964 affine.tx=geometry_info.xi;
8965 affine.ty=geometry_info.psi;
8966 if ((flags & PsiValue) == 0)
8967 affine.ty=affine.tx;
8975 flags=ParseGeometry(value,&geometry_info);
8976 affine.sx=geometry_info.rho;
8977 affine.sy=geometry_info.sigma;
8978 if ((flags & SigmaValue) == 0)
8979 affine.sy=affine.sx;
8989 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8990 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8991 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8992 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9000 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9008 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9012 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9013 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9014 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9015 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9016 draw_info->affine.tx=
9017 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9018 draw_info->affine.ty=
9019 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9021 if (attribute_flag[15] != 0)
9022 draw_info->fill_pattern=CloneImage(
9023 argument_list[15].image_reference,0,0,MagickTrue,exception);
9024 if (attribute_flag[16] != 0)
9025 draw_info->pointsize=argument_list[16].real_reference;
9026 if (attribute_flag[17] != 0)
9028 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
9029 ? MagickTrue : MagickFalse;
9030 draw_info->text_antialias=draw_info->stroke_antialias;
9032 if (attribute_flag[18] != 0)
9033 (void) CloneString(&draw_info->density,
9034 argument_list[18].string_reference);
9035 if (attribute_flag[19] != 0)
9036 draw_info->stroke_width=argument_list[19].real_reference;
9037 if (attribute_flag[21] != 0)
9038 draw_info->dash_offset=argument_list[21].real_reference;
9039 if (attribute_flag[22] != 0)
9044 av=(AV *) argument_list[22].array_reference;
9045 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9046 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9047 if (draw_info->dash_pattern != (double *) NULL)
9049 for (i=0; i <= av_len(av); i++)
9050 draw_info->dash_pattern[i]=(double)
9051 SvNV(*(av_fetch(av,i,0)));
9052 draw_info->dash_pattern[i]=0.0;
9055 if (attribute_flag[23] != 0)
9056 image->interpolate=(PixelInterpolateMethod)
9057 argument_list[23].integer_reference;
9058 if ((attribute_flag[24] != 0) &&
9059 (draw_info->fill_pattern != (Image *) NULL))
9060 flags=ParsePageGeometry(draw_info->fill_pattern,
9061 argument_list[24].string_reference,
9062 &draw_info->fill_pattern->tile_offset,exception);
9063 if (attribute_flag[25] != 0)
9065 (void) ConcatenateString(&draw_info->primitive," '");
9066 (void) ConcatenateString(&draw_info->primitive,
9067 argument_list[25].string_reference);
9068 (void) ConcatenateString(&draw_info->primitive,"'");
9070 if (attribute_flag[26] != 0)
9071 draw_info->fill_pattern=CloneImage(
9072 argument_list[26].image_reference,0,0,MagickTrue,exception);
9073 if (attribute_flag[27] != 0)
9074 draw_info->stroke_pattern=CloneImage(
9075 argument_list[27].image_reference,0,0,MagickTrue,exception);
9076 if (attribute_flag[28] != 0)
9077 (void) CloneString(&draw_info->primitive,
9078 argument_list[28].string_reference);
9079 if (attribute_flag[29] != 0)
9080 draw_info->kerning=argument_list[29].real_reference;
9081 if (attribute_flag[30] != 0)
9082 draw_info->interline_spacing=argument_list[30].real_reference;
9083 if (attribute_flag[31] != 0)
9084 draw_info->interword_spacing=argument_list[31].real_reference;
9085 if (attribute_flag[32] != 0)
9086 draw_info->direction=(DirectionType)
9087 argument_list[32].integer_reference;
9088 DrawImage(image,draw_info,exception);
9089 draw_info=DestroyDrawInfo(draw_info);
9092 case 39: /* Equalize */
9094 if (attribute_flag[0] != 0)
9095 channel=(ChannelType) argument_list[0].integer_reference;
9096 channel_mask=SetImageChannelMask(image,channel);
9097 EqualizeImage(image,exception);
9098 (void) SetImageChannelMask(image,channel_mask);
9101 case 40: /* Gamma */
9103 if (attribute_flag[1] != 0)
9104 channel=(ChannelType) argument_list[1].integer_reference;
9105 if (attribute_flag[2] == 0)
9106 argument_list[2].real_reference=1.0;
9107 if (attribute_flag[3] == 0)
9108 argument_list[3].real_reference=1.0;
9109 if (attribute_flag[4] == 0)
9110 argument_list[4].real_reference=1.0;
9111 if (attribute_flag[0] == 0)
9113 (void) FormatLocaleString(message,MagickPathExtent,
9114 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9115 (double) argument_list[3].real_reference,
9116 (double) argument_list[4].real_reference);
9117 argument_list[0].string_reference=message;
9119 (void) GammaImage(image,StringToDouble(
9120 argument_list[0].string_reference,(char **) NULL),exception);
9128 if (attribute_flag[0] == 0)
9130 ThrowPerlException(exception,OptionError,"MapImageRequired",
9134 quantize_info=AcquireQuantizeInfo(info->image_info);
9135 if (attribute_flag[1] != 0)
9136 quantize_info->dither_method=(DitherMethod)
9137 argument_list[1].integer_reference;
9138 (void) RemapImages(quantize_info,image,
9139 argument_list[0].image_reference,exception);
9140 quantize_info=DestroyQuantizeInfo(quantize_info);
9143 case 42: /* MatteFloodfill */
9154 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9156 if (attribute_flag[0] != 0)
9157 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9158 &geometry,exception);
9159 if (attribute_flag[1] != 0)
9160 geometry.x=argument_list[1].integer_reference;
9161 if (attribute_flag[2] != 0)
9162 geometry.y=argument_list[2].integer_reference;
9163 if (image->alpha_trait == UndefinedPixelTrait)
9164 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9165 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9166 geometry.x,geometry.y,&target,exception);
9167 if (attribute_flag[4] != 0)
9168 QueryColorCompliance(argument_list[4].string_reference,
9169 AllCompliance,&target,exception);
9170 if (attribute_flag[3] != 0)
9171 target.alpha=StringToDoubleInterval(
9172 argument_list[3].string_reference,(double) (double) QuantumRange+
9174 if (attribute_flag[5] != 0)
9175 image->fuzz=StringToDoubleInterval(
9176 argument_list[5].string_reference,(double) QuantumRange+1.0);
9178 if (attribute_flag[6] != 0)
9179 invert=(MagickBooleanType) argument_list[6].integer_reference;
9180 channel_mask=SetImageChannelMask(image,AlphaChannel);
9181 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9182 geometry.y,invert,exception);
9183 (void) SetImageChannelMask(image,channel_mask);
9184 draw_info=DestroyDrawInfo(draw_info);
9187 case 43: /* Modulate */
9190 modulate[MagickPathExtent];
9192 geometry_info.rho=100.0;
9193 geometry_info.sigma=100.0;
9194 geometry_info.xi=100.0;
9195 if (attribute_flag[0] != 0)
9196 (void)ParseGeometry(argument_list[0].string_reference,
9198 if (attribute_flag[1] != 0)
9199 geometry_info.xi=argument_list[1].real_reference;
9200 if (attribute_flag[2] != 0)
9201 geometry_info.sigma=argument_list[2].real_reference;
9202 if (attribute_flag[3] != 0)
9204 geometry_info.sigma=argument_list[3].real_reference;
9205 SetImageArtifact(image,"modulate:colorspace","HWB");
9207 if (attribute_flag[4] != 0)
9209 geometry_info.rho=argument_list[4].real_reference;
9210 SetImageArtifact(image,"modulate:colorspace","HSB");
9212 if (attribute_flag[5] != 0)
9214 geometry_info.sigma=argument_list[5].real_reference;
9215 SetImageArtifact(image,"modulate:colorspace","HSL");
9217 if (attribute_flag[6] != 0)
9219 geometry_info.rho=argument_list[6].real_reference;
9220 SetImageArtifact(image,"modulate:colorspace","HWB");
9222 (void) FormatLocaleString(modulate,MagickPathExtent,"%.15g,%.15g,%.15g",
9223 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9224 (void) ModulateImage(image,modulate,exception);
9227 case 44: /* Negate */
9229 if (attribute_flag[0] == 0)
9230 argument_list[0].integer_reference=0;
9231 if (attribute_flag[1] != 0)
9232 channel=(ChannelType) argument_list[1].integer_reference;
9233 channel_mask=SetImageChannelMask(image,channel);
9234 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9235 MagickTrue : MagickFalse,exception);
9236 (void) SetImageChannelMask(image,channel_mask);
9239 case 45: /* Normalize */
9241 if (attribute_flag[0] != 0)
9242 channel=(ChannelType) argument_list[0].integer_reference;
9243 channel_mask=SetImageChannelMask(image,channel);
9244 NormalizeImage(image,exception);
9245 (void) SetImageChannelMask(image,channel_mask);
9248 case 46: /* NumberColors */
9250 case 47: /* Opaque */
9259 (void) QueryColorCompliance("none",AllCompliance,&target,
9261 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9263 if (attribute_flag[0] != 0)
9264 (void) QueryColorCompliance(argument_list[0].string_reference,
9265 AllCompliance,&target,exception);
9266 if (attribute_flag[1] != 0)
9267 (void) QueryColorCompliance(argument_list[1].string_reference,
9268 AllCompliance,&fill_color,exception);
9269 if (attribute_flag[2] != 0)
9270 image->fuzz=StringToDoubleInterval(
9271 argument_list[2].string_reference,(double) QuantumRange+1.0);
9272 if (attribute_flag[3] != 0)
9273 channel=(ChannelType) argument_list[3].integer_reference;
9275 if (attribute_flag[4] != 0)
9276 invert=(MagickBooleanType) argument_list[4].integer_reference;
9277 channel_mask=SetImageChannelMask(image,channel);
9278 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9279 (void) SetImageChannelMask(image,channel_mask);
9282 case 48: /* Quantize */
9287 quantize_info=AcquireQuantizeInfo(info->image_info);
9288 if (attribute_flag[0] != 0)
9289 quantize_info->number_colors=(size_t)
9290 argument_list[0].integer_reference;
9291 if (attribute_flag[1] != 0)
9292 quantize_info->tree_depth=(size_t)
9293 argument_list[1].integer_reference;
9294 if (attribute_flag[2] != 0)
9295 quantize_info->colorspace=(ColorspaceType)
9296 argument_list[2].integer_reference;
9297 if (attribute_flag[3] != 0)
9298 quantize_info->dither_method=(DitherMethod)
9299 argument_list[3].integer_reference;
9300 if (attribute_flag[4] != 0)
9301 quantize_info->measure_error=
9302 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9303 if (attribute_flag[6] != 0)
9304 (void) QueryColorCompliance(argument_list[6].string_reference,
9305 AllCompliance,&image->transparent_color,exception);
9306 if (attribute_flag[7] != 0)
9307 quantize_info->dither_method=(DitherMethod)
9308 argument_list[7].integer_reference;
9309 if (attribute_flag[5] && argument_list[5].integer_reference)
9310 (void) QuantizeImages(quantize_info,image,exception);
9312 if ((image->storage_class == DirectClass) ||
9313 (image->colors > quantize_info->number_colors) ||
9314 (quantize_info->colorspace == GRAYColorspace))
9315 (void) QuantizeImage(quantize_info,image,exception);
9317 CompressImageColormap(image,exception);
9318 quantize_info=DestroyQuantizeInfo(quantize_info);
9321 case 49: /* Raise */
9323 if (attribute_flag[0] != 0)
9324 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9325 &geometry,exception);
9326 if (attribute_flag[1] != 0)
9327 geometry.width=argument_list[1].integer_reference;
9328 if (attribute_flag[2] != 0)
9329 geometry.height=argument_list[2].integer_reference;
9330 if (attribute_flag[3] == 0)
9331 argument_list[3].integer_reference=1;
9332 (void) RaiseImage(image,&geometry,
9333 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9337 case 50: /* Segment */
9344 smoothing_threshold;
9349 cluster_threshold=1.0;
9350 smoothing_threshold=1.5;
9351 colorspace=sRGBColorspace;
9352 verbose=MagickFalse;
9353 if (attribute_flag[0] != 0)
9355 flags=ParseGeometry(argument_list[0].string_reference,
9357 cluster_threshold=geometry_info.rho;
9358 if (flags & SigmaValue)
9359 smoothing_threshold=geometry_info.sigma;
9361 if (attribute_flag[1] != 0)
9362 cluster_threshold=argument_list[1].real_reference;
9363 if (attribute_flag[2] != 0)
9364 smoothing_threshold=argument_list[2].real_reference;
9365 if (attribute_flag[3] != 0)
9366 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9367 if (attribute_flag[4] != 0)
9368 verbose=argument_list[4].integer_reference != 0 ?
9369 MagickTrue : MagickFalse;
9370 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9371 smoothing_threshold,exception);
9374 case 51: /* Signature */
9376 (void) SignatureImage(image,exception);
9379 case 52: /* Solarize */
9381 geometry_info.rho=QuantumRange/2.0;
9382 if (attribute_flag[0] != 0)
9383 flags=ParseGeometry(argument_list[0].string_reference,
9385 if (attribute_flag[1] != 0)
9386 geometry_info.rho=StringToDoubleInterval(
9387 argument_list[1].string_reference,(double) QuantumRange+1.0);
9388 (void) SolarizeImage(image,geometry_info.rho,exception);
9393 (void) SyncImage(image,exception);
9396 case 54: /* Texture */
9398 if (attribute_flag[0] == 0)
9400 TextureImage(image,argument_list[0].image_reference,exception);
9403 case 55: /* Evalute */
9405 MagickEvaluateOperator
9408 op=SetEvaluateOperator;
9409 if (attribute_flag[0] == MagickFalse)
9410 argument_list[0].real_reference=0.0;
9411 if (attribute_flag[1] != MagickFalse)
9412 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9413 if (attribute_flag[2] != MagickFalse)
9414 channel=(ChannelType) argument_list[2].integer_reference;
9415 channel_mask=SetImageChannelMask(image,channel);
9416 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9418 (void) SetImageChannelMask(image,channel_mask);
9421 case 56: /* Transparent */
9432 (void) QueryColorCompliance("none",AllCompliance,&target,
9434 if (attribute_flag[0] != 0)
9435 (void) QueryColorCompliance(argument_list[0].string_reference,
9436 AllCompliance,&target,exception);
9437 opacity=TransparentAlpha;
9438 if (attribute_flag[1] != 0)
9439 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9440 (double) QuantumRange+1.0);
9441 if (attribute_flag[2] != 0)
9442 image->fuzz=StringToDoubleInterval(
9443 argument_list[2].string_reference,(double) QuantumRange+1.0);
9444 if (attribute_flag[3] == 0)
9445 argument_list[3].integer_reference=0;
9447 if (attribute_flag[3] != 0)
9448 invert=(MagickBooleanType) argument_list[3].integer_reference;
9449 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9453 case 57: /* Threshold */
9458 if (attribute_flag[0] == 0)
9459 argument_list[0].string_reference="50%";
9460 if (attribute_flag[1] != 0)
9461 channel=(ChannelType) argument_list[1].integer_reference;
9462 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9463 (double) QuantumRange+1.0);
9464 channel_mask=SetImageChannelMask(image,channel);
9465 (void) BilevelImage(image,threshold,exception);
9466 (void) SetImageChannelMask(image,channel_mask);
9469 case 58: /* Charcoal */
9471 if (attribute_flag[0] != 0)
9473 flags=ParseGeometry(argument_list[0].string_reference,
9475 if ((flags & SigmaValue) == 0)
9476 geometry_info.sigma=1.0;
9478 if (attribute_flag[1] != 0)
9479 geometry_info.rho=argument_list[1].real_reference;
9480 if (attribute_flag[2] != 0)
9481 geometry_info.sigma=argument_list[2].real_reference;
9482 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9488 if (attribute_flag[0] != 0)
9489 image->fuzz=StringToDoubleInterval(
9490 argument_list[0].string_reference,(double) QuantumRange+1.0);
9491 image=TrimImage(image,exception);
9496 PixelInterpolateMethod
9499 if (attribute_flag[0] != 0)
9501 flags=ParseGeometry(argument_list[0].string_reference,
9503 if ((flags & SigmaValue) == 0)
9504 geometry_info.sigma=1.0;
9506 if (attribute_flag[1] != 0)
9507 geometry_info.rho=argument_list[1].real_reference;
9508 if (attribute_flag[2] != 0)
9509 geometry_info.sigma=argument_list[2].real_reference;
9510 method=UndefinedInterpolatePixel;
9511 if (attribute_flag[3] != 0)
9512 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9513 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9517 case 61: /* Separate */
9519 if (attribute_flag[0] != 0)
9520 channel=(ChannelType) argument_list[0].integer_reference;
9521 image=SeparateImage(image,channel,exception);
9524 case 63: /* Stereo */
9526 if (attribute_flag[0] == 0)
9528 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9532 if (attribute_flag[1] != 0)
9533 geometry.x=argument_list[1].integer_reference;
9534 if (attribute_flag[2] != 0)
9535 geometry.y=argument_list[2].integer_reference;
9536 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9537 geometry.x,geometry.y,exception);
9540 case 64: /* Stegano */
9542 if (attribute_flag[0] == 0)
9544 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9548 if (attribute_flag[1] == 0)
9549 argument_list[1].integer_reference=0;
9550 image->offset=argument_list[1].integer_reference;
9551 image=SteganoImage(image,argument_list[0].image_reference,exception);
9554 case 65: /* Deconstruct */
9556 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9559 case 66: /* GaussianBlur */
9561 if (attribute_flag[0] != 0)
9563 flags=ParseGeometry(argument_list[0].string_reference,
9565 if ((flags & SigmaValue) == 0)
9566 geometry_info.sigma=1.0;
9568 if (attribute_flag[1] != 0)
9569 geometry_info.rho=argument_list[1].real_reference;
9570 if (attribute_flag[2] != 0)
9571 geometry_info.sigma=argument_list[2].real_reference;
9572 if (attribute_flag[3] != 0)
9573 channel=(ChannelType) argument_list[3].integer_reference;
9574 channel_mask=SetImageChannelMask(image,channel);
9575 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9577 if (image != (Image *) NULL)
9578 (void) SetImageChannelMask(image,channel_mask);
9581 case 67: /* Convolve */
9586 kernel=(KernelInfo *) NULL;
9587 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9589 if (attribute_flag[0] != 0)
9597 kernel=AcquireKernelInfo((const char *) NULL,exception);
9598 if (kernel == (KernelInfo *) NULL)
9600 av=(AV *) argument_list[0].array_reference;
9601 order=(size_t) sqrt(av_len(av)+1);
9602 kernel->width=order;
9603 kernel->height=order;
9604 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9605 order*sizeof(*kernel->values));
9606 if (kernel->values == (MagickRealType *) NULL)
9608 kernel=DestroyKernelInfo(kernel);
9609 ThrowPerlException(exception,ResourceLimitFatalError,
9610 "MemoryAllocationFailed",PackageName);
9613 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9614 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9615 for ( ; j < (ssize_t) (order*order); j++)
9616 kernel->values[j]=0.0;
9618 if (attribute_flag[1] != 0)
9619 channel=(ChannelType) argument_list[1].integer_reference;
9620 if (attribute_flag[2] != 0)
9621 SetImageArtifact(image,"filter:blur",
9622 argument_list[2].string_reference);
9623 if (attribute_flag[3] != 0)
9625 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9627 if (kernel == (KernelInfo *) NULL)
9630 channel_mask=SetImageChannelMask(image,channel);
9631 image=ConvolveImage(image,kernel,exception);
9632 if (image != (Image *) NULL)
9633 (void) SetImageChannelMask(image,channel_mask);
9634 kernel=DestroyKernelInfo(kernel);
9637 case 68: /* Profile */
9652 if (attribute_flag[0] != 0)
9653 name=argument_list[0].string_reference;
9654 if (attribute_flag[2] != 0)
9655 image->rendering_intent=(RenderingIntent)
9656 argument_list[2].integer_reference;
9657 if (attribute_flag[3] != 0)
9658 image->black_point_compensation=
9659 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9660 if (attribute_flag[1] != 0)
9662 if (argument_list[1].length == 0)
9665 Remove a profile from the image.
9667 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9672 Associate user supplied profile with the image.
9674 profile=AcquireStringInfo(argument_list[1].length);
9675 SetStringInfoDatum(profile,(const unsigned char *)
9676 argument_list[1].string_reference);
9677 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9678 (size_t) GetStringInfoLength(profile),exception);
9679 profile=DestroyStringInfo(profile);
9683 Associate a profile with the image.
9685 profile_info=CloneImageInfo(info ? info->image_info :
9686 (ImageInfo *) NULL);
9687 profile_image=ReadImages(profile_info,name,exception);
9688 if (profile_image == (Image *) NULL)
9690 ResetImageProfileIterator(profile_image);
9691 name=GetNextImageProfile(profile_image);
9692 while (name != (const char *) NULL)
9697 profile=GetImageProfile(profile_image,name);
9698 if (profile != (const StringInfo *) NULL)
9699 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9700 (size_t) GetStringInfoLength(profile),exception);
9701 name=GetNextImageProfile(profile_image);
9703 profile_image=DestroyImage(profile_image);
9704 profile_info=DestroyImageInfo(profile_info);
9707 case 69: /* UnsharpMask */
9709 if (attribute_flag[0] != 0)
9711 flags=ParseGeometry(argument_list[0].string_reference,
9713 if ((flags & SigmaValue) == 0)
9714 geometry_info.sigma=1.0;
9715 if ((flags & XiValue) == 0)
9716 geometry_info.xi=1.0;
9717 if ((flags & PsiValue) == 0)
9718 geometry_info.psi=0.5;
9720 if (attribute_flag[1] != 0)
9721 geometry_info.rho=argument_list[1].real_reference;
9722 if (attribute_flag[2] != 0)
9723 geometry_info.sigma=argument_list[2].real_reference;
9724 if (attribute_flag[3] != 0)
9725 geometry_info.xi=argument_list[3].real_reference;
9726 if (attribute_flag[4] != 0)
9727 geometry_info.psi=argument_list[4].real_reference;
9728 if (attribute_flag[5] != 0)
9729 channel=(ChannelType) argument_list[5].integer_reference;
9730 channel_mask=SetImageChannelMask(image,channel);
9731 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9732 geometry_info.xi,geometry_info.psi,exception);
9733 if (image != (Image *) NULL)
9734 (void) SetImageChannelMask(image,channel_mask);
9737 case 70: /* MotionBlur */
9739 if (attribute_flag[0] != 0)
9741 flags=ParseGeometry(argument_list[0].string_reference,
9743 if ((flags & SigmaValue) == 0)
9744 geometry_info.sigma=1.0;
9745 if ((flags & XiValue) == 0)
9746 geometry_info.xi=1.0;
9748 if (attribute_flag[1] != 0)
9749 geometry_info.rho=argument_list[1].real_reference;
9750 if (attribute_flag[2] != 0)
9751 geometry_info.sigma=argument_list[2].real_reference;
9752 if (attribute_flag[3] != 0)
9753 geometry_info.xi=argument_list[3].real_reference;
9754 if (attribute_flag[4] != 0)
9755 channel=(ChannelType) argument_list[4].integer_reference;
9756 channel_mask=SetImageChannelMask(image,channel);
9757 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9758 geometry_info.xi,exception);
9759 if (image != (Image *) NULL)
9760 (void) SetImageChannelMask(image,channel_mask);
9763 case 71: /* OrderedDither */
9765 if (attribute_flag[0] == 0)
9766 argument_list[0].string_reference="o8x8";
9767 if (attribute_flag[1] != 0)
9768 channel=(ChannelType) argument_list[1].integer_reference;
9769 channel_mask=SetImageChannelMask(image,channel);
9770 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9772 (void) SetImageChannelMask(image,channel_mask);
9775 case 72: /* Shave */
9777 if (attribute_flag[0] != 0)
9778 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9779 &geometry,exception);
9780 if (attribute_flag[1] != 0)
9781 geometry.width=argument_list[1].integer_reference;
9782 if (attribute_flag[2] != 0)
9783 geometry.height=argument_list[2].integer_reference;
9784 image=ShaveImage(image,&geometry,exception);
9787 case 73: /* Level */
9795 white_point=(double) image->columns*image->rows;
9797 if (attribute_flag[0] != 0)
9799 flags=ParseGeometry(argument_list[0].string_reference,
9801 black_point=geometry_info.rho;
9802 if ((flags & SigmaValue) != 0)
9803 white_point=geometry_info.sigma;
9804 if ((flags & XiValue) != 0)
9805 gamma=geometry_info.xi;
9806 if ((flags & PercentValue) != 0)
9808 black_point*=(double) (QuantumRange/100.0);
9809 white_point*=(double) (QuantumRange/100.0);
9811 if ((flags & SigmaValue) == 0)
9812 white_point=(double) QuantumRange-black_point;
9814 if (attribute_flag[1] != 0)
9815 black_point=argument_list[1].real_reference;
9816 if (attribute_flag[2] != 0)
9817 white_point=argument_list[2].real_reference;
9818 if (attribute_flag[3] != 0)
9819 gamma=argument_list[3].real_reference;
9820 if (attribute_flag[4] != 0)
9821 channel=(ChannelType) argument_list[4].integer_reference;
9822 if (attribute_flag[5] != 0)
9824 argument_list[0].real_reference=argument_list[5].real_reference;
9825 attribute_flag[0]=attribute_flag[5];
9827 channel_mask=SetImageChannelMask(image,channel);
9828 (void) LevelImage(image,black_point,white_point,gamma,exception);
9829 (void) SetImageChannelMask(image,channel_mask);
9834 if (attribute_flag[0] == 0)
9835 argument_list[0].string_reference="#1";
9836 if (attribute_flag[1] == 0)
9837 argument_list[1].integer_reference=MagickTrue;
9838 (void) ClipImagePath(image,argument_list[0].string_reference,
9839 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9843 case 75: /* AffineTransform */
9848 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9850 if (attribute_flag[0] != 0)
9855 av=(AV *) argument_list[0].array_reference;
9856 if ((av_len(av) != 3) && (av_len(av) != 5))
9858 ThrowPerlException(exception,OptionError,
9859 "affine matrix must have 4 or 6 elements",PackageName);
9862 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9863 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9864 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9865 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9866 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9867 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9869 ThrowPerlException(exception,OptionError,
9870 "affine matrix is singular",PackageName);
9873 if (av_len(av) == 5)
9875 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9876 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9879 for (j=1; j < 6; j++)
9881 if (attribute_flag[j] == 0)
9883 value=argument_list[j].string_reference;
9884 angle=argument_list[j].real_reference;
9885 current=draw_info->affine;
9886 GetAffineMatrix(&affine);
9894 flags=ParseGeometry(value,&geometry_info);
9895 affine.tx=geometry_info.xi;
9896 affine.ty=geometry_info.psi;
9897 if ((flags & PsiValue) == 0)
9898 affine.ty=affine.tx;
9906 flags=ParseGeometry(value,&geometry_info);
9907 affine.sx=geometry_info.rho;
9908 affine.sy=geometry_info.sigma;
9909 if ((flags & SigmaValue) == 0)
9910 affine.sy=affine.sx;
9920 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9921 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9922 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9923 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9931 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9939 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9943 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9944 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9945 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9946 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9947 draw_info->affine.tx=
9948 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9949 draw_info->affine.ty=
9950 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9952 if (attribute_flag[6] != 0)
9953 image->interpolate=(PixelInterpolateMethod)
9954 argument_list[6].integer_reference;
9955 if (attribute_flag[7] != 0)
9956 QueryColorCompliance(argument_list[7].string_reference,
9957 AllCompliance,&image->background_color,exception);
9958 image=AffineTransformImage(image,&draw_info->affine,exception);
9959 draw_info=DestroyDrawInfo(draw_info);
9962 case 76: /* Difference */
9964 if (attribute_flag[0] == 0)
9966 ThrowPerlException(exception,OptionError,
9967 "ReferenceImageRequired",PackageName);
9970 if (attribute_flag[1] != 0)
9971 image->fuzz=StringToDoubleInterval(
9972 argument_list[1].string_reference,(double) QuantumRange+1.0);
9973 (void) SetImageColorMetric(image,argument_list[0].image_reference,
9977 case 77: /* AdaptiveThreshold */
9979 if (attribute_flag[0] != 0)
9981 flags=ParseGeometry(argument_list[0].string_reference,
9983 if ((flags & PercentValue) != 0)
9984 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9986 if (attribute_flag[1] != 0)
9987 geometry_info.rho=argument_list[1].integer_reference;
9988 if (attribute_flag[2] != 0)
9989 geometry_info.sigma=argument_list[2].integer_reference;
9990 if (attribute_flag[3] != 0)
9991 geometry_info.xi=argument_list[3].integer_reference;;
9992 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9993 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9996 case 78: /* Resample */
10002 if (attribute_flag[0] != 0)
10004 flags=ParseGeometry(argument_list[0].string_reference,
10006 if ((flags & SigmaValue) == 0)
10007 geometry_info.sigma=geometry_info.rho;
10009 if (attribute_flag[1] != 0)
10010 geometry_info.rho=argument_list[1].real_reference;
10011 if (attribute_flag[2] != 0)
10012 geometry_info.sigma=argument_list[2].real_reference;
10013 if (attribute_flag[3] == 0)
10014 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
10015 if (attribute_flag[4] == 0)
10016 SetImageArtifact(image,"filter:support",
10017 argument_list[4].string_reference);
10018 width=(size_t) (geometry_info.rho*image->columns/
10019 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
10020 height=(size_t) (geometry_info.sigma*image->rows/
10021 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
10022 image=ResizeImage(image,width,height,(FilterTypes)
10023 argument_list[3].integer_reference,exception);
10024 if (image != (Image *) NULL)
10026 image->resolution.x=geometry_info.rho;
10027 image->resolution.y=geometry_info.sigma;
10031 case 79: /* Describe */
10033 if (attribute_flag[0] == 0)
10034 argument_list[0].file_reference=(FILE *) NULL;
10035 if (attribute_flag[1] != 0)
10036 (void) SetImageArtifact(image,"identify:features",
10037 argument_list[1].string_reference);
10038 (void) IdentifyImage(image,argument_list[0].file_reference,
10039 MagickTrue,exception);
10042 case 80: /* BlackThreshold */
10044 if (attribute_flag[0] == 0)
10045 argument_list[0].string_reference="50%";
10046 if (attribute_flag[2] != 0)
10047 channel=(ChannelType) argument_list[2].integer_reference;
10048 channel_mask=SetImageChannelMask(image,channel);
10049 BlackThresholdImage(image,argument_list[0].string_reference,
10051 (void) SetImageChannelMask(image,channel_mask);
10054 case 81: /* WhiteThreshold */
10056 if (attribute_flag[0] == 0)
10057 argument_list[0].string_reference="50%";
10058 if (attribute_flag[2] != 0)
10059 channel=(ChannelType) argument_list[2].integer_reference;
10060 channel_mask=SetImageChannelMask(image,channel);
10061 WhiteThresholdImage(image,argument_list[0].string_reference,
10063 (void) SetImageChannelMask(image,channel_mask);
10066 case 82: /* RotationalBlur */
10068 if (attribute_flag[0] != 0)
10070 flags=ParseGeometry(argument_list[0].string_reference,
10073 if (attribute_flag[1] != 0)
10074 geometry_info.rho=argument_list[1].real_reference;
10075 if (attribute_flag[2] != 0)
10076 channel=(ChannelType) argument_list[2].integer_reference;
10077 channel_mask=SetImageChannelMask(image,channel);
10078 image=RotationalBlurImage(image,geometry_info.rho,exception);
10079 if (image != (Image *) NULL)
10080 (void) SetImageChannelMask(image,channel_mask);
10083 case 83: /* Thumbnail */
10085 if (attribute_flag[0] != 0)
10086 flags=ParseRegionGeometry(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 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10095 case 84: /* Strip */
10097 (void) StripImage(image,exception);
10100 case 85: /* Tint */
10105 GetPixelInfo(image,&tint);
10106 if (attribute_flag[0] != 0)
10107 (void) QueryColorCompliance(argument_list[0].string_reference,
10108 AllCompliance,&tint,exception);
10109 if (attribute_flag[1] == 0)
10110 argument_list[1].string_reference="100";
10111 image=TintImage(image,argument_list[1].string_reference,&tint,
10115 case 86: /* Channel */
10117 if (attribute_flag[0] != 0)
10118 channel=(ChannelType) argument_list[0].integer_reference;
10119 image=SeparateImage(image,channel,exception);
10122 case 87: /* Splice */
10124 if (attribute_flag[7] != 0)
10125 image->gravity=(GravityType) argument_list[7].integer_reference;
10126 if (attribute_flag[0] != 0)
10127 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10128 &geometry,exception);
10129 if (attribute_flag[1] != 0)
10130 geometry.width=argument_list[1].integer_reference;
10131 if (attribute_flag[2] != 0)
10132 geometry.height=argument_list[2].integer_reference;
10133 if (attribute_flag[3] != 0)
10134 geometry.x=argument_list[3].integer_reference;
10135 if (attribute_flag[4] != 0)
10136 geometry.y=argument_list[4].integer_reference;
10137 if (attribute_flag[5] != 0)
10138 image->fuzz=StringToDoubleInterval(
10139 argument_list[5].string_reference,(double) QuantumRange+1.0);
10140 if (attribute_flag[6] != 0)
10141 (void) QueryColorCompliance(argument_list[6].string_reference,
10142 AllCompliance,&image->background_color,exception);
10143 image=SpliceImage(image,&geometry,exception);
10146 case 88: /* Posterize */
10148 if (attribute_flag[0] == 0)
10149 argument_list[0].integer_reference=3;
10150 if (attribute_flag[1] == 0)
10151 argument_list[1].integer_reference=0;
10152 (void) PosterizeImage(image,argument_list[0].integer_reference,
10153 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10154 NoDitherMethod,exception);
10157 case 89: /* Shadow */
10159 if (attribute_flag[0] != 0)
10161 flags=ParseGeometry(argument_list[0].string_reference,
10163 if ((flags & SigmaValue) == 0)
10164 geometry_info.sigma=1.0;
10165 if ((flags & XiValue) == 0)
10166 geometry_info.xi=4.0;
10167 if ((flags & PsiValue) == 0)
10168 geometry_info.psi=4.0;
10170 if (attribute_flag[1] != 0)
10171 geometry_info.rho=argument_list[1].real_reference;
10172 if (attribute_flag[2] != 0)
10173 geometry_info.sigma=argument_list[2].real_reference;
10174 if (attribute_flag[3] != 0)
10175 geometry_info.xi=argument_list[3].integer_reference;
10176 if (attribute_flag[4] != 0)
10177 geometry_info.psi=argument_list[4].integer_reference;
10178 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10179 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10180 ceil(geometry_info.psi-0.5),exception);
10183 case 90: /* Identify */
10185 if (attribute_flag[0] == 0)
10186 argument_list[0].file_reference=(FILE *) NULL;
10187 if (attribute_flag[1] != 0)
10188 (void) SetImageArtifact(image,"identify:features",
10189 argument_list[1].string_reference);
10190 if ((attribute_flag[2] != 0) &&
10191 (argument_list[2].integer_reference != 0))
10192 (void) SetImageArtifact(image,"identify:unique","true");
10193 (void) IdentifyImage(image,argument_list[0].file_reference,
10194 MagickTrue,exception);
10197 case 91: /* SepiaTone */
10199 if (attribute_flag[0] == 0)
10200 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10201 image=SepiaToneImage(image,argument_list[0].real_reference,
10205 case 92: /* SigmoidalContrast */
10210 if (attribute_flag[0] != 0)
10212 flags=ParseGeometry(argument_list[0].string_reference,
10214 if ((flags & SigmaValue) == 0)
10215 geometry_info.sigma=QuantumRange/2.0;
10216 if ((flags & PercentValue) != 0)
10217 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10219 if (attribute_flag[1] != 0)
10220 geometry_info.rho=argument_list[1].real_reference;
10221 if (attribute_flag[2] != 0)
10222 geometry_info.sigma=argument_list[2].real_reference;
10223 if (attribute_flag[3] != 0)
10224 channel=(ChannelType) argument_list[3].integer_reference;
10225 sharpen=MagickTrue;
10226 if (attribute_flag[4] != 0)
10227 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10229 channel_mask=SetImageChannelMask(image,channel);
10230 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10231 geometry_info.sigma,exception);
10232 (void) SetImageChannelMask(image,channel_mask);
10235 case 93: /* Extent */
10237 if (attribute_flag[7] != 0)
10238 image->gravity=(GravityType) argument_list[7].integer_reference;
10239 if (attribute_flag[0] != 0)
10244 flags=ParseGravityGeometry(image,
10245 argument_list[0].string_reference,&geometry,exception);
10247 if (geometry.width == 0)
10248 geometry.width=image->columns;
10249 if (geometry.height == 0)
10250 geometry.height=image->rows;
10252 if (attribute_flag[1] != 0)
10253 geometry.width=argument_list[1].integer_reference;
10254 if (attribute_flag[2] != 0)
10255 geometry.height=argument_list[2].integer_reference;
10256 if (attribute_flag[3] != 0)
10257 geometry.x=argument_list[3].integer_reference;
10258 if (attribute_flag[4] != 0)
10259 geometry.y=argument_list[4].integer_reference;
10260 if (attribute_flag[5] != 0)
10261 image->fuzz=StringToDoubleInterval(
10262 argument_list[5].string_reference,(double) QuantumRange+1.0);
10263 if (attribute_flag[6] != 0)
10264 (void) QueryColorCompliance(argument_list[6].string_reference,
10265 AllCompliance,&image->background_color,exception);
10266 image=ExtentImage(image,&geometry,exception);
10269 case 94: /* Vignette */
10271 if (attribute_flag[0] != 0)
10273 flags=ParseGeometry(argument_list[0].string_reference,
10275 if ((flags & SigmaValue) == 0)
10276 geometry_info.sigma=1.0;
10277 if ((flags & XiValue) == 0)
10278 geometry_info.xi=0.1*image->columns;
10279 if ((flags & PsiValue) == 0)
10280 geometry_info.psi=0.1*image->rows;
10282 if (attribute_flag[1] != 0)
10283 geometry_info.rho=argument_list[1].real_reference;
10284 if (attribute_flag[2] != 0)
10285 geometry_info.sigma=argument_list[2].real_reference;
10286 if (attribute_flag[3] != 0)
10287 geometry_info.xi=argument_list[3].integer_reference;
10288 if (attribute_flag[4] != 0)
10289 geometry_info.psi=argument_list[4].integer_reference;
10290 if (attribute_flag[5] != 0)
10291 (void) QueryColorCompliance(argument_list[5].string_reference,
10292 AllCompliance,&image->background_color,exception);
10293 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10294 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10295 ceil(geometry_info.psi-0.5),exception);
10298 case 95: /* ContrastStretch */
10305 white_point=(double) image->columns*image->rows;
10306 if (attribute_flag[0] != 0)
10308 flags=ParseGeometry(argument_list[0].string_reference,
10310 black_point=geometry_info.rho;
10311 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10313 if ((flags & PercentValue) != 0)
10315 black_point*=(double) image->columns*image->rows/100.0;
10316 white_point*=(double) image->columns*image->rows/100.0;
10318 white_point=(double) image->columns*image->rows-
10321 if (attribute_flag[1] != 0)
10322 black_point=argument_list[1].real_reference;
10323 if (attribute_flag[2] != 0)
10324 white_point=argument_list[2].real_reference;
10325 if (attribute_flag[4] != 0)
10326 channel=(ChannelType) argument_list[4].integer_reference;
10327 channel_mask=SetImageChannelMask(image,channel);
10328 (void) ContrastStretchImage(image,black_point,white_point,exception);
10329 (void) SetImageChannelMask(image,channel_mask);
10332 case 96: /* Sans0 */
10336 case 97: /* Sans1 */
10340 case 98: /* AdaptiveSharpen */
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 geometry_info.xi=argument_list[3].real_reference;
10357 if (attribute_flag[4] != 0)
10358 channel=(ChannelType) argument_list[4].integer_reference;
10359 channel_mask=SetImageChannelMask(image,channel);
10360 image=AdaptiveSharpenImage(image,geometry_info.rho,
10361 geometry_info.sigma,exception);
10362 if (image != (Image *) NULL)
10363 (void) SetImageChannelMask(image,channel_mask);
10366 case 99: /* Transpose */
10368 image=TransposeImage(image,exception);
10371 case 100: /* Tranverse */
10373 image=TransverseImage(image,exception);
10376 case 101: /* AutoOrient */
10378 image=AutoOrientImage(image,image->orientation,exception);
10381 case 102: /* AdaptiveBlur */
10383 if (attribute_flag[0] != 0)
10385 flags=ParseGeometry(argument_list[0].string_reference,
10387 if ((flags & SigmaValue) == 0)
10388 geometry_info.sigma=1.0;
10389 if ((flags & XiValue) == 0)
10390 geometry_info.xi=0.0;
10392 if (attribute_flag[1] != 0)
10393 geometry_info.rho=argument_list[1].real_reference;
10394 if (attribute_flag[2] != 0)
10395 geometry_info.sigma=argument_list[2].real_reference;
10396 if (attribute_flag[3] != 0)
10397 channel=(ChannelType) argument_list[3].integer_reference;
10398 channel_mask=SetImageChannelMask(image,channel);
10399 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10401 if (image != (Image *) NULL)
10402 (void) SetImageChannelMask(image,channel_mask);
10405 case 103: /* Sketch */
10407 if (attribute_flag[0] != 0)
10409 flags=ParseGeometry(argument_list[0].string_reference,
10411 if ((flags & SigmaValue) == 0)
10412 geometry_info.sigma=1.0;
10413 if ((flags & XiValue) == 0)
10414 geometry_info.xi=1.0;
10416 if (attribute_flag[1] != 0)
10417 geometry_info.rho=argument_list[1].real_reference;
10418 if (attribute_flag[2] != 0)
10419 geometry_info.sigma=argument_list[2].real_reference;
10420 if (attribute_flag[3] != 0)
10421 geometry_info.xi=argument_list[3].real_reference;
10422 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10423 geometry_info.xi,exception);
10426 case 104: /* UniqueColors */
10428 image=UniqueImageColors(image,exception);
10431 case 105: /* AdaptiveResize */
10433 if (attribute_flag[0] != 0)
10434 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10435 &geometry,exception);
10436 if (attribute_flag[1] != 0)
10437 geometry.width=argument_list[1].integer_reference;
10438 if (attribute_flag[2] != 0)
10439 geometry.height=argument_list[2].integer_reference;
10440 if (attribute_flag[3] != 0)
10441 image->filter=(FilterTypes) argument_list[4].integer_reference;
10442 if (attribute_flag[4] != 0)
10443 SetImageArtifact(image,"filter:support",
10444 argument_list[4].string_reference);
10445 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10449 case 106: /* ClipMask */
10454 if (attribute_flag[0] == 0)
10456 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10458 goto PerlException;
10460 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10462 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10463 mask_image=DestroyImage(mask_image);
10466 case 107: /* LinearStretch */
10473 white_point=(double) image->columns*image->rows;
10474 if (attribute_flag[0] != 0)
10476 flags=ParseGeometry(argument_list[0].string_reference,
10478 if ((flags & SigmaValue) != 0)
10479 white_point=geometry_info.sigma;
10480 if ((flags & PercentValue) != 0)
10482 black_point*=(double) image->columns*image->rows/100.0;
10483 white_point*=(double) image->columns*image->rows/100.0;
10485 if ((flags & SigmaValue) == 0)
10486 white_point=(double) image->columns*image->rows-black_point;
10488 if (attribute_flag[1] != 0)
10489 black_point=argument_list[1].real_reference;
10490 if (attribute_flag[2] != 0)
10491 white_point=argument_list[2].real_reference;
10492 (void) LinearStretchImage(image,black_point,white_point,exception);
10495 case 108: /* ColorMatrix */
10509 if (attribute_flag[0] == 0)
10511 av=(AV *) argument_list[0].array_reference;
10512 order=(size_t) sqrt(av_len(av)+1);
10513 color_matrix=(double *) AcquireQuantumMemory(order,order*
10514 sizeof(*color_matrix));
10515 if (color_matrix == (double *) NULL)
10517 ThrowPerlException(exception,ResourceLimitFatalError,
10518 "MemoryAllocationFailed",PackageName);
10519 goto PerlException;
10521 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10522 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10523 for ( ; j < (ssize_t) (order*order); j++)
10524 color_matrix[j]=0.0;
10525 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10526 if (kernel_info == (KernelInfo *) NULL)
10528 kernel_info->width=order;
10529 kernel_info->height=order;
10530 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10531 order*sizeof(*kernel_info->values));
10532 if (kernel_info->values != (MagickRealType *) NULL)
10534 for (i=0; i < (ssize_t) (order*order); i++)
10535 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10536 image=ColorMatrixImage(image,kernel_info,exception);
10538 kernel_info=DestroyKernelInfo(kernel_info);
10539 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10542 case 109: /* Mask */
10547 if (attribute_flag[0] == 0)
10549 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10551 goto PerlException;
10553 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10554 MagickTrue,exception);
10555 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10556 mask_image=DestroyImage(mask_image);
10559 case 110: /* Polaroid */
10570 PixelInterpolateMethod
10573 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10574 (DrawInfo *) NULL);
10575 caption=(char *) NULL;
10576 if (attribute_flag[0] != 0)
10577 caption=InterpretImageProperties(info ? info->image_info :
10578 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10581 if (attribute_flag[1] != 0)
10582 angle=argument_list[1].real_reference;
10583 if (attribute_flag[2] != 0)
10584 (void) CloneString(&draw_info->font,
10585 argument_list[2].string_reference);
10586 if (attribute_flag[3] != 0)
10587 (void) QueryColorCompliance(argument_list[3].string_reference,
10588 AllCompliance,&draw_info->stroke,exception);
10589 if (attribute_flag[4] != 0)
10590 (void) QueryColorCompliance(argument_list[4].string_reference,
10591 AllCompliance,&draw_info->fill,exception);
10592 if (attribute_flag[5] != 0)
10593 draw_info->stroke_width=argument_list[5].real_reference;
10594 if (attribute_flag[6] != 0)
10595 draw_info->pointsize=argument_list[6].real_reference;
10596 if (attribute_flag[7] != 0)
10597 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10598 if (attribute_flag[8] != 0)
10599 (void) QueryColorCompliance(argument_list[8].string_reference,
10600 AllCompliance,&image->background_color,exception);
10601 method=UndefinedInterpolatePixel;
10602 if (attribute_flag[9] != 0)
10603 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10604 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10605 draw_info=DestroyDrawInfo(draw_info);
10606 if (caption != (char *) NULL)
10607 caption=DestroyString(caption);
10610 case 111: /* FloodfillPaint */
10621 draw_info=CloneDrawInfo(info ? info->image_info :
10622 (ImageInfo *) NULL,(DrawInfo *) NULL);
10623 if (attribute_flag[0] != 0)
10624 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10625 &geometry,exception);
10626 if (attribute_flag[1] != 0)
10627 geometry.x=argument_list[1].integer_reference;
10628 if (attribute_flag[2] != 0)
10629 geometry.y=argument_list[2].integer_reference;
10630 if (attribute_flag[3] != 0)
10631 (void) QueryColorCompliance(argument_list[3].string_reference,
10632 AllCompliance,&draw_info->fill,exception);
10633 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10634 geometry.x,geometry.y,&target,exception);
10635 if (attribute_flag[4] != 0)
10636 QueryColorCompliance(argument_list[4].string_reference,
10637 AllCompliance,&target,exception);
10638 if (attribute_flag[5] != 0)
10639 image->fuzz=StringToDoubleInterval(
10640 argument_list[5].string_reference,(double) QuantumRange+1.0);
10641 if (attribute_flag[6] != 0)
10642 channel=(ChannelType) argument_list[6].integer_reference;
10643 invert=MagickFalse;
10644 if (attribute_flag[7] != 0)
10645 invert=(MagickBooleanType) argument_list[7].integer_reference;
10646 channel_mask=SetImageChannelMask(image,channel);
10647 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10648 geometry.y,invert,exception);
10649 (void) SetImageChannelMask(image,channel_mask);
10650 draw_info=DestroyDrawInfo(draw_info);
10653 case 112: /* Distort */
10665 number_coordinates;
10670 if (attribute_flag[0] == 0)
10672 method=UndefinedDistortion;
10673 if (attribute_flag[1] != 0)
10674 method=(DistortImageMethod) argument_list[1].integer_reference;
10675 av=(AV *) argument_list[0].array_reference;
10676 number_coordinates=(size_t) av_len(av)+1;
10677 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10678 sizeof(*coordinates));
10679 if (coordinates == (double *) NULL)
10681 ThrowPerlException(exception,ResourceLimitFatalError,
10682 "MemoryAllocationFailed",PackageName);
10683 goto PerlException;
10685 for (j=0; j < (ssize_t) number_coordinates; j++)
10686 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10687 virtual_pixel=UndefinedVirtualPixelMethod;
10688 if (attribute_flag[2] != 0)
10689 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10690 argument_list[2].integer_reference,exception);
10691 image=DistortImage(image,method,number_coordinates,coordinates,
10692 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10694 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10695 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10697 coordinates=(double *) RelinquishMagickMemory(coordinates);
10700 case 113: /* Clut */
10702 PixelInterpolateMethod
10705 if (attribute_flag[0] == 0)
10707 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10709 goto PerlException;
10711 method=UndefinedInterpolatePixel;
10712 if (attribute_flag[1] != 0)
10713 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10714 if (attribute_flag[2] != 0)
10715 channel=(ChannelType) argument_list[2].integer_reference;
10716 channel_mask=SetImageChannelMask(image,channel);
10717 (void) ClutImage(image,argument_list[0].image_reference,method,
10719 (void) SetImageChannelMask(image,channel_mask);
10722 case 114: /* LiquidRescale */
10724 if (attribute_flag[0] != 0)
10725 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10726 &geometry,exception);
10727 if (attribute_flag[1] != 0)
10728 geometry.width=argument_list[1].integer_reference;
10729 if (attribute_flag[2] != 0)
10730 geometry.height=argument_list[2].integer_reference;
10731 if (attribute_flag[3] == 0)
10732 argument_list[3].real_reference=1.0;
10733 if (attribute_flag[4] == 0)
10734 argument_list[4].real_reference=0.0;
10735 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10736 argument_list[3].real_reference,argument_list[4].real_reference,
10740 case 115: /* EncipherImage */
10742 (void) EncipherImage(image,argument_list[0].string_reference,
10746 case 116: /* DecipherImage */
10748 (void) DecipherImage(image,argument_list[0].string_reference,
10752 case 117: /* Deskew */
10754 geometry_info.rho=QuantumRange/2.0;
10755 if (attribute_flag[0] != 0)
10756 flags=ParseGeometry(argument_list[0].string_reference,
10758 if (attribute_flag[1] != 0)
10759 geometry_info.rho=StringToDoubleInterval(
10760 argument_list[1].string_reference,(double) QuantumRange+1.0);
10761 image=DeskewImage(image,geometry_info.rho,exception);
10764 case 118: /* Remap */
10769 if (attribute_flag[0] == 0)
10771 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10773 goto PerlException;
10775 quantize_info=AcquireQuantizeInfo(info->image_info);
10776 if (attribute_flag[1] != 0)
10777 quantize_info->dither_method=(DitherMethod)
10778 argument_list[1].integer_reference;
10779 (void) RemapImages(quantize_info,image,
10780 argument_list[0].image_reference,exception);
10781 quantize_info=DestroyQuantizeInfo(quantize_info);
10784 case 119: /* SparseColor */
10796 number_coordinates;
10801 if (attribute_flag[0] == 0)
10803 method=UndefinedColorInterpolate;
10804 if (attribute_flag[1] != 0)
10805 method=(SparseColorMethod) argument_list[1].integer_reference;
10806 av=(AV *) argument_list[0].array_reference;
10807 number_coordinates=(size_t) av_len(av)+1;
10808 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10809 sizeof(*coordinates));
10810 if (coordinates == (double *) NULL)
10812 ThrowPerlException(exception,ResourceLimitFatalError,
10813 "MemoryAllocationFailed",PackageName);
10814 goto PerlException;
10816 for (j=0; j < (ssize_t) number_coordinates; j++)
10817 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10818 virtual_pixel=UndefinedVirtualPixelMethod;
10819 if (attribute_flag[2] != 0)
10820 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10821 argument_list[2].integer_reference,exception);
10822 if (attribute_flag[3] != 0)
10823 channel=(ChannelType) argument_list[3].integer_reference;
10824 channel_mask=SetImageChannelMask(image,channel);
10825 image=SparseColorImage(image,method,number_coordinates,coordinates,
10827 if (image != (Image *) NULL)
10828 (void) SetImageChannelMask(image,channel_mask);
10829 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10830 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10832 coordinates=(double *) RelinquishMagickMemory(coordinates);
10835 case 120: /* Function */
10852 if (attribute_flag[0] == 0)
10854 function=UndefinedFunction;
10855 if (attribute_flag[1] != 0)
10856 function=(MagickFunction) argument_list[1].integer_reference;
10857 av=(AV *) argument_list[0].array_reference;
10858 number_parameters=(size_t) av_len(av)+1;
10859 parameters=(double *) AcquireQuantumMemory(number_parameters,
10860 sizeof(*parameters));
10861 if (parameters == (double *) NULL)
10863 ThrowPerlException(exception,ResourceLimitFatalError,
10864 "MemoryAllocationFailed",PackageName);
10865 goto PerlException;
10867 for (j=0; j < (ssize_t) number_parameters; j++)
10868 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10869 virtual_pixel=UndefinedVirtualPixelMethod;
10870 if (attribute_flag[2] != 0)
10871 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10872 argument_list[2].integer_reference,exception);
10873 (void) FunctionImage(image,function,number_parameters,parameters,
10875 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10876 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10878 parameters=(double *) RelinquishMagickMemory(parameters);
10881 case 121: /* SelectiveBlur */
10883 if (attribute_flag[0] != 0)
10885 flags=ParseGeometry(argument_list[0].string_reference,
10887 if ((flags & SigmaValue) == 0)
10888 geometry_info.sigma=1.0;
10889 if ((flags & PercentValue) != 0)
10890 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10892 if (attribute_flag[1] != 0)
10893 geometry_info.rho=argument_list[1].real_reference;
10894 if (attribute_flag[2] != 0)
10895 geometry_info.sigma=argument_list[2].real_reference;
10896 if (attribute_flag[3] != 0)
10897 geometry_info.xi=argument_list[3].integer_reference;;
10898 if (attribute_flag[5] != 0)
10899 channel=(ChannelType) argument_list[5].integer_reference;
10900 channel_mask=SetImageChannelMask(image,channel);
10901 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10902 geometry_info.xi,exception);
10903 if (image != (Image *) NULL)
10904 (void) SetImageChannelMask(image,channel_mask);
10907 case 122: /* HaldClut */
10909 if (attribute_flag[0] == 0)
10911 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10913 goto PerlException;
10915 if (attribute_flag[1] != 0)
10916 channel=(ChannelType) argument_list[1].integer_reference;
10917 channel_mask=SetImageChannelMask(image,channel);
10918 (void) HaldClutImage(image,argument_list[0].image_reference,
10920 (void) SetImageChannelMask(image,channel_mask);
10923 case 123: /* BlueShift */
10925 if (attribute_flag[0] != 0)
10926 (void) ParseGeometry(argument_list[0].string_reference,
10928 image=BlueShiftImage(image,geometry_info.rho,exception);
10931 case 124: /* ForwardFourierTransformImage */
10933 image=ForwardFourierTransformImage(image,
10934 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10938 case 125: /* InverseFourierTransformImage */
10940 image=InverseFourierTransformImage(image,image->next,
10941 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10945 case 126: /* ColorDecisionList */
10947 if (attribute_flag[0] == 0)
10948 argument_list[0].string_reference=(char *) NULL;
10949 (void) ColorDecisionListImage(image,
10950 argument_list[0].string_reference,exception);
10953 case 127: /* AutoGamma */
10955 if (attribute_flag[0] != 0)
10956 channel=(ChannelType) argument_list[0].integer_reference;
10957 channel_mask=SetImageChannelMask(image,channel);
10958 (void) AutoGammaImage(image,exception);
10959 (void) SetImageChannelMask(image,channel_mask);
10962 case 128: /* AutoLevel */
10964 if (attribute_flag[0] != 0)
10965 channel=(ChannelType) argument_list[0].integer_reference;
10966 channel_mask=SetImageChannelMask(image,channel);
10967 (void) AutoLevelImage(image,exception);
10968 (void) SetImageChannelMask(image,channel_mask);
10971 case 129: /* LevelColors */
10977 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10979 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10981 if (attribute_flag[1] != 0)
10982 (void) QueryColorCompliance(
10983 argument_list[1].string_reference,AllCompliance,&black_point,
10985 if (attribute_flag[2] != 0)
10986 (void) QueryColorCompliance(
10987 argument_list[2].string_reference,AllCompliance,&white_point,
10989 if (attribute_flag[3] != 0)
10990 channel=(ChannelType) argument_list[3].integer_reference;
10991 channel_mask=SetImageChannelMask(image,channel);
10992 (void) LevelImageColors(image,&black_point,&white_point,
10993 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10995 (void) SetImageChannelMask(image,channel_mask);
10998 case 130: /* Clamp */
11000 if (attribute_flag[0] != 0)
11001 channel=(ChannelType) argument_list[0].integer_reference;
11002 channel_mask=SetImageChannelMask(image,channel);
11003 (void) ClampImage(image,exception);
11004 (void) SetImageChannelMask(image,channel_mask);
11007 case 131: /* BrightnessContrast */
11015 if (attribute_flag[0] != 0)
11017 flags=ParseGeometry(argument_list[0].string_reference,
11019 brightness=geometry_info.rho;
11020 if ((flags & SigmaValue) == 0)
11021 contrast=geometry_info.sigma;
11023 if (attribute_flag[1] != 0)
11024 brightness=argument_list[1].real_reference;
11025 if (attribute_flag[2] != 0)
11026 contrast=argument_list[2].real_reference;
11027 if (attribute_flag[4] != 0)
11028 channel=(ChannelType) argument_list[4].integer_reference;
11029 channel_mask=SetImageChannelMask(image,channel);
11030 (void) BrightnessContrastImage(image,brightness,contrast,exception);
11031 (void) SetImageChannelMask(image,channel_mask);
11034 case 132: /* Morphology */
11045 if (attribute_flag[0] == 0)
11047 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11048 if (kernel == (KernelInfo *) NULL)
11050 if (attribute_flag[1] != 0)
11051 channel=(ChannelType) argument_list[1].integer_reference;
11052 method=UndefinedMorphology;
11053 if (attribute_flag[2] != 0)
11054 method=argument_list[2].integer_reference;
11056 if (attribute_flag[3] != 0)
11057 iterations=argument_list[3].integer_reference;
11058 channel_mask=SetImageChannelMask(image,channel);
11059 image=MorphologyImage(image,method,iterations,kernel,exception);
11060 if (image != (Image *) NULL)
11061 (void) SetImageChannelMask(image,channel_mask);
11062 kernel=DestroyKernelInfo(kernel);
11065 case 133: /* Mode */
11067 if (attribute_flag[0] != 0)
11069 flags=ParseGeometry(argument_list[0].string_reference,
11071 if ((flags & SigmaValue) == 0)
11072 geometry_info.sigma=1.0;
11074 if (attribute_flag[1] != 0)
11075 geometry_info.rho=argument_list[1].real_reference;
11076 if (attribute_flag[2] != 0)
11077 geometry_info.sigma=argument_list[2].real_reference;
11078 if (attribute_flag[3] != 0)
11079 channel=(ChannelType) argument_list[3].integer_reference;
11080 channel_mask=SetImageChannelMask(image,channel);
11081 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11082 (size_t) geometry_info.sigma,exception);
11083 if (image != (Image *) NULL)
11084 (void) SetImageChannelMask(image,channel_mask);
11087 case 134: /* Statistic */
11092 statistic=UndefinedStatistic;
11093 if (attribute_flag[0] != 0)
11095 flags=ParseGeometry(argument_list[0].string_reference,
11097 if ((flags & SigmaValue) == 0)
11098 geometry_info.sigma=1.0;
11100 if (attribute_flag[1] != 0)
11101 geometry_info.rho=argument_list[1].real_reference;
11102 if (attribute_flag[2] != 0)
11103 geometry_info.sigma=argument_list[2].real_reference;
11104 if (attribute_flag[3] != 0)
11105 channel=(ChannelType) argument_list[3].integer_reference;
11106 if (attribute_flag[4] != 0)
11107 statistic=(StatisticType) argument_list[4].integer_reference;
11108 channel_mask=SetImageChannelMask(image,channel);
11109 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11110 (size_t) geometry_info.sigma,exception);
11111 if (image != (Image *) NULL)
11112 (void) SetImageChannelMask(image,channel_mask);
11115 case 135: /* Perceptible */
11120 epsilon=MagickEpsilon;
11121 if (attribute_flag[0] != 0)
11122 epsilon=argument_list[0].real_reference;
11123 if (attribute_flag[1] != 0)
11124 channel=(ChannelType) argument_list[1].integer_reference;
11125 channel_mask=SetImageChannelMask(image,channel);
11126 (void) PerceptibleImage(image,epsilon,exception);
11127 (void) SetImageChannelMask(image,channel_mask);
11130 case 136: /* Poly */
11141 if (attribute_flag[0] == 0)
11143 if (attribute_flag[1] != 0)
11144 channel=(ChannelType) argument_list[1].integer_reference;
11145 av=(AV *) argument_list[0].array_reference;
11146 number_terms=(size_t) av_len(av);
11147 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11148 if (terms == (double *) NULL)
11150 ThrowPerlException(exception,ResourceLimitFatalError,
11151 "MemoryAllocationFailed",PackageName);
11152 goto PerlException;
11154 for (j=0; j < av_len(av); j++)
11155 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11156 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11157 terms=(double *) RelinquishMagickMemory(terms);
11160 case 137: /* Grayscale */
11162 PixelIntensityMethod
11165 method=UndefinedPixelIntensityMethod;
11166 if (attribute_flag[0] != 0)
11167 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11168 (void) GrayscaleImage(image,method,exception);
11171 case 138: /* Canny */
11173 if (attribute_flag[0] != 0)
11175 flags=ParseGeometry(argument_list[0].string_reference,
11177 if ((flags & SigmaValue) == 0)
11178 geometry_info.sigma=1.0;
11179 if ((flags & XiValue) == 0)
11180 geometry_info.xi=0.10;
11181 if ((flags & PsiValue) == 0)
11182 geometry_info.psi=0.30;
11183 if ((flags & PercentValue) != 0)
11185 geometry_info.xi/=100.0;
11186 geometry_info.psi/=100.0;
11189 if (attribute_flag[1] != 0)
11190 geometry_info.rho=argument_list[1].real_reference;
11191 if (attribute_flag[2] != 0)
11192 geometry_info.sigma=argument_list[2].real_reference;
11193 if (attribute_flag[3] != 0)
11194 geometry_info.xi=argument_list[3].real_reference;
11195 if (attribute_flag[4] != 0)
11196 geometry_info.psi=argument_list[4].real_reference;
11197 if (attribute_flag[5] != 0)
11198 channel=(ChannelType) argument_list[5].integer_reference;
11199 channel_mask=SetImageChannelMask(image,channel);
11200 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11201 geometry_info.xi,geometry_info.psi,exception);
11202 if (image != (Image *) NULL)
11203 (void) SetImageChannelMask(image,channel_mask);
11206 case 139: /* HoughLine */
11208 if (attribute_flag[0] != 0)
11210 flags=ParseGeometry(argument_list[0].string_reference,
11212 if ((flags & SigmaValue) == 0)
11213 geometry_info.sigma=geometry_info.rho;
11214 if ((flags & XiValue) == 0)
11215 geometry_info.xi=40;
11217 if (attribute_flag[1] != 0)
11218 geometry_info.rho=(double) argument_list[1].integer_reference;
11219 if (attribute_flag[2] != 0)
11220 geometry_info.sigma=(double) argument_list[2].integer_reference;
11221 if (attribute_flag[3] != 0)
11222 geometry_info.xi=(double) argument_list[3].integer_reference;
11223 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11224 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11227 case 140: /* MeanShift */
11229 if (attribute_flag[0] != 0)
11231 flags=ParseGeometry(argument_list[0].string_reference,
11233 if ((flags & SigmaValue) == 0)
11234 geometry_info.sigma=geometry_info.rho;
11235 if ((flags & XiValue) == 0)
11236 geometry_info.xi=0.10*QuantumRange;
11237 if ((flags & PercentValue) != 0)
11238 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11240 if (attribute_flag[1] != 0)
11241 geometry_info.rho=(double) argument_list[1].integer_reference;
11242 if (attribute_flag[2] != 0)
11243 geometry_info.sigma=(double) argument_list[2].integer_reference;
11244 if (attribute_flag[3] != 0)
11245 geometry_info.xi=(double) argument_list[3].integer_reference;
11246 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11247 geometry_info.sigma,geometry_info.xi,exception);
11250 case 141: /* Kuwahara */
11252 if (attribute_flag[0] != 0)
11254 flags=ParseGeometry(argument_list[0].string_reference,
11256 if ((flags & SigmaValue) == 0)
11257 geometry_info.sigma=geometry_info.rho-0.5;
11259 if (attribute_flag[1] != 0)
11260 geometry_info.rho=argument_list[1].real_reference;
11261 if (attribute_flag[2] != 0)
11262 geometry_info.sigma=argument_list[2].real_reference;
11263 if (attribute_flag[3] != 0)
11264 channel=(ChannelType) argument_list[3].integer_reference;
11265 channel_mask=SetImageChannelMask(image,channel);
11266 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11268 if (image != (Image *) NULL)
11269 (void) SetImageChannelMask(image,channel_mask);
11272 case 142: /* ConnectedComponent */
11278 if (attribute_flag[0] != 0)
11279 connectivity=argument_list[0].integer_reference;
11280 image=ConnectedComponentsImage(image,connectivity,
11281 (CCObjectInfo **) NULL,exception);
11284 case 143: /* Copy */
11295 source_image=image;
11296 if (attribute_flag[0] != 0)
11297 source_image=argument_list[0].image_reference;
11298 SetGeometry(source_image,&geometry);
11299 if (attribute_flag[1] != 0)
11300 flags=ParseGravityGeometry(source_image,
11301 argument_list[1].string_reference,&geometry,exception);
11302 if (attribute_flag[2] != 0)
11303 geometry.width=argument_list[2].integer_reference;
11304 if (attribute_flag[3] != 0)
11305 geometry.height=argument_list[3].integer_reference;
11306 if (attribute_flag[4] != 0)
11307 geometry.x=argument_list[4].integer_reference;
11308 if (attribute_flag[5] != 0)
11309 geometry.y=argument_list[5].integer_reference;
11310 if (attribute_flag[6] != 0)
11311 image->gravity=(GravityType) argument_list[6].integer_reference;
11312 SetGeometry(image,&offset_geometry);
11313 if (attribute_flag[7] != 0)
11314 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11315 &offset_geometry,exception);
11316 offset.x=offset_geometry.x;
11317 offset.y=offset_geometry.y;
11318 if (attribute_flag[8] != 0)
11319 offset.x=argument_list[8].integer_reference;
11320 if (attribute_flag[9] != 0)
11321 offset.y=argument_list[9].integer_reference;
11322 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11327 if (next != (Image *) NULL)
11328 (void) CatchImageException(next);
11329 if (region_image != (Image *) NULL)
11334 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11335 region_info.x,region_info.y,exception);
11337 (void) CatchImageException(region_image);
11338 image=DestroyImage(image);
11339 image=region_image;
11341 if (image != (Image *) NULL)
11344 if (next && (next != image))
11346 image->next=next->next;
11347 if (image->next != (Image *) NULL)
11348 image->next->previous=image;
11349 DeleteImageFromRegistry(*pv,next);
11351 sv_setiv(*pv,PTR2IV(image));
11359 if (reference_vector)
11360 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11361 InheritPerlException(exception,perl_exception);
11362 exception=DestroyExceptionInfo(exception);
11363 sv_setiv(perl_exception,(IV) number_images);
11364 SvPOK_on(perl_exception);
11365 ST(0)=sv_2mortal(perl_exception);
11370 ###############################################################################
11378 ###############################################################################
11383 Image::Magick ref=NO_INIT
11428 PERL_UNUSED_VAR(ref);
11429 PERL_UNUSED_VAR(ix);
11430 exception=AcquireExceptionInfo();
11431 perl_exception=newSVpv("",0);
11434 if (sv_isobject(ST(0)) == 0)
11436 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11438 goto PerlException;
11440 reference=SvRV(ST(0));
11441 hv=SvSTASH(reference);
11443 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11445 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11446 if (image == (Image *) NULL)
11448 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11450 goto PerlException;
11455 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11456 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11457 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11459 for (i=2; i < items; i+=2)
11461 attribute=(char *) SvPV(ST(i-1),na);
11462 switch (*attribute)
11467 if (LocaleCompare(attribute,"background") == 0)
11469 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11470 &montage_info->background_color,exception);
11471 for (next=image; next; next=next->next)
11472 next->background_color=montage_info->background_color;
11475 if (LocaleCompare(attribute,"border") == 0)
11477 montage_info->border_width=SvIV(ST(i));
11480 if (LocaleCompare(attribute,"bordercolor") == 0)
11482 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11483 &montage_info->border_color,exception);
11484 for (next=image; next; next=next->next)
11485 next->border_color=montage_info->border_color;
11488 if (LocaleCompare(attribute,"borderwidth") == 0)
11490 montage_info->border_width=SvIV(ST(i));
11493 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11500 if (LocaleCompare(attribute,"compose") == 0)
11502 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11503 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11506 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11510 for (next=image; next; next=next->next)
11511 next->compose=(CompositeOperator) sp;
11514 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11521 if (LocaleCompare(attribute,"fill") == 0)
11523 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11524 &montage_info->fill,exception);
11527 if (LocaleCompare(attribute,"font") == 0)
11529 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11532 if (LocaleCompare(attribute,"frame") == 0)
11538 if (IsGeometry(p) == MagickFalse)
11540 ThrowPerlException(exception,OptionError,"MissingGeometry",
11544 (void) CloneString(&montage_info->frame,p);
11546 montage_info->frame=(char *) NULL;
11549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11556 if (LocaleCompare(attribute,"geometry") == 0)
11562 if (IsGeometry(p) == MagickFalse)
11564 ThrowPerlException(exception,OptionError,"MissingGeometry",
11568 (void) CloneString(&montage_info->geometry,p);
11570 montage_info->geometry=(char *) NULL;
11573 if (LocaleCompare(attribute,"gravity") == 0)
11578 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11579 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11582 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11586 montage_info->gravity=(GravityType) in;
11587 for (next=image; next; next=next->next)
11588 next->gravity=(GravityType) in;
11591 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11598 if (LocaleCompare(attribute,"label") == 0)
11600 for (next=image; next; next=next->next)
11601 (void) SetImageProperty(next,"label",InterpretImageProperties(
11602 info ? info->image_info : (ImageInfo *) NULL,next,
11603 SvPV(ST(i),na),exception),exception);
11606 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11613 if (LocaleCompare(attribute,"mattecolor") == 0)
11615 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11616 &montage_info->matte_color,exception);
11617 for (next=image; next; next=next->next)
11618 next->matte_color=montage_info->matte_color;
11621 if (LocaleCompare(attribute,"mode") == 0)
11626 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11627 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11632 ThrowPerlException(exception,OptionError,
11633 "UnrecognizedModeType",SvPV(ST(i),na));
11638 (void) CloneString(&montage_info->frame,"15x15+3+3");
11639 montage_info->shadow=MagickTrue;
11644 montage_info->frame=(char *) NULL;
11645 montage_info->shadow=MagickFalse;
11646 montage_info->border_width=0;
11649 case ConcatenateMode:
11651 montage_info->frame=(char *) NULL;
11652 montage_info->shadow=MagickFalse;
11653 (void) CloneString(&montage_info->geometry,"+0+0");
11654 montage_info->border_width=0;
11659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11666 if (LocaleCompare(attribute,"pointsize") == 0)
11668 montage_info->pointsize=SvIV(ST(i));
11671 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11678 if (LocaleCompare(attribute,"shadow") == 0)
11680 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11681 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11684 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11688 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11691 if (LocaleCompare(attribute,"stroke") == 0)
11693 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11694 &montage_info->stroke,exception);
11697 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11704 if (LocaleCompare(attribute,"texture") == 0)
11706 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11709 if (LocaleCompare(attribute,"tile") == 0)
11711 char *p=SvPV(ST(i),na);
11712 if (IsGeometry(p) == MagickFalse)
11714 ThrowPerlException(exception,OptionError,"MissingGeometry",
11718 (void) CloneString(&montage_info->tile,p);
11720 montage_info->tile=(char *) NULL;
11723 if (LocaleCompare(attribute,"title") == 0)
11725 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11728 if (LocaleCompare(attribute,"transparent") == 0)
11733 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11734 &transparent_color,exception);
11735 for (next=image; next; next=next->next)
11736 (void) TransparentPaintImage(next,&transparent_color,
11737 TransparentAlpha,MagickFalse,exception);
11740 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11746 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11752 image=MontageImageList(info->image_info,montage_info,image,exception);
11753 montage_info=DestroyMontageInfo(montage_info);
11754 if (image == (Image *) NULL)
11755 goto PerlException;
11756 if (transparent_color.alpha != TransparentAlpha)
11757 for (next=image; next; next=next->next)
11758 (void) TransparentPaintImage(next,&transparent_color,
11759 TransparentAlpha,MagickFalse,exception);
11760 for ( ; image; image=image->next)
11762 AddImageToRegistry(sv,image);
11764 av_push(av,sv_bless(rv,hv));
11767 exception=DestroyExceptionInfo(exception);
11768 ST(0)=av_reference;
11769 SvREFCNT_dec(perl_exception);
11773 InheritPerlException(exception,perl_exception);
11774 exception=DestroyExceptionInfo(exception);
11775 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11776 SvPOK_on(perl_exception);
11777 ST(0)=sv_2mortal(perl_exception);
11782 ###############################################################################
11790 ###############################################################################
11795 Image::Magick ref=NO_INIT
11833 PERL_UNUSED_VAR(ref);
11834 PERL_UNUSED_VAR(ix);
11835 exception=AcquireExceptionInfo();
11836 perl_exception=newSVpv("",0);
11840 if (sv_isobject(ST(0)) == 0)
11842 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11844 goto PerlException;
11846 reference=SvRV(ST(0));
11847 hv=SvSTASH(reference);
11849 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11851 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11852 if (image == (Image *) NULL)
11854 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11856 goto PerlException;
11858 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11863 for (i=2; i < items; i+=2)
11865 attribute=(char *) SvPV(ST(i-1),na);
11866 switch (*attribute)
11871 if (LocaleCompare(attribute,"frames") == 0)
11873 number_frames=SvIV(ST(i));
11876 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11882 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11888 image=MorphImages(image,number_frames,exception);
11889 if (image == (Image *) NULL)
11890 goto PerlException;
11891 for ( ; image; image=image->next)
11893 AddImageToRegistry(sv,image);
11895 av_push(av,sv_bless(rv,hv));
11898 exception=DestroyExceptionInfo(exception);
11899 ST(0)=av_reference;
11900 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11904 InheritPerlException(exception,perl_exception);
11905 exception=DestroyExceptionInfo(exception);
11906 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11907 SvPOK_on(perl_exception);
11908 ST(0)=sv_2mortal(perl_exception);
11913 ###############################################################################
11921 ###############################################################################
11926 Image::Magick ref=NO_INIT
11954 PERL_UNUSED_VAR(ref);
11955 PERL_UNUSED_VAR(ix);
11956 exception=AcquireExceptionInfo();
11957 perl_exception=newSVpv("",0);
11959 if (sv_isobject(ST(0)) == 0)
11961 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11963 goto PerlException;
11965 reference=SvRV(ST(0));
11966 hv=SvSTASH(reference);
11967 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11968 if (image == (Image *) NULL)
11970 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11972 goto PerlException;
11974 image=MergeImageLayers(image,MosaicLayer,exception);
11976 Create blessed Perl array for the returned image.
11979 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11981 AddImageToRegistry(sv,image);
11983 av_push(av,sv_bless(rv,hv));
11985 (void) CopyMagickString(info->image_info->filename,image->filename,
11987 SetImageInfo(info->image_info,0,exception);
11988 exception=DestroyExceptionInfo(exception);
11989 SvREFCNT_dec(perl_exception);
11993 InheritPerlException(exception,perl_exception);
11994 exception=DestroyExceptionInfo(exception);
11995 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11996 SvPOK_on(perl_exception); /* return messages in string context */
11997 ST(0)=sv_2mortal(perl_exception);
12002 ###############################################################################
12010 ###############################################################################
12015 Image::Magick ref=NO_INIT
12065 PERL_UNUSED_VAR(ref);
12066 PERL_UNUSED_VAR(ix);
12067 exception=AcquireExceptionInfo();
12068 perl_exception=newSVpv("",0);
12069 package_info=(struct PackageInfo *) NULL;
12070 ac=(items < 2) ? 1 : items-1;
12071 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12073 length=(STRLEN *) NULL;
12074 if (list == (char **) NULL)
12076 ThrowPerlException(exception,ResourceLimitError,
12077 "MemoryAllocationFailed",PackageName);
12078 goto PerlException;
12081 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12082 if (length == (STRLEN *) NULL)
12084 ThrowPerlException(exception,ResourceLimitError,
12085 "MemoryAllocationFailed",PackageName);
12086 goto PerlException;
12088 if (sv_isobject(ST(0)) == 0)
12090 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12092 goto PerlException;
12094 reference=SvRV(ST(0));
12095 if (SvTYPE(reference) != SVt_PVAV)
12097 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12099 goto PerlException;
12101 av=(AV *) reference;
12102 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12104 package_info=ClonePackageInfo(info,exception);
12107 *list=(char *) (*package_info->image_info->filename ?
12108 package_info->image_info->filename : "XC:black");
12110 for (n=0, i=0; i < ac; i++)
12112 list[n]=(char *) SvPV(ST(i+1),length[n]);
12113 if ((items >= 3) && strEQcase(list[n],"blob"))
12119 blob=(void *) (SvPV(ST(i+1),length[n]));
12120 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12122 if ((items >= 3) && strEQcase(list[n],"filename"))
12124 if ((items >= 3) && strEQcase(list[n],"file"))
12133 io_info=IoIFP(sv_2io(ST(i+1)));
12134 if (io_info == (PerlIO *) NULL)
12136 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12140 file=PerlIO_findFILE(io_info);
12141 if (file == (FILE *) NULL)
12143 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12147 SetImageInfoFile(package_info->image_info,file);
12149 if ((items >= 3) && strEQcase(list[n],"magick"))
12153 list[n]=(char *) NULL;
12155 status=ExpandFilenames(&n,&list);
12156 if (status == MagickFalse)
12158 ThrowPerlException(exception,ResourceLimitError,
12159 "MemoryAllocationFailed",PackageName);
12160 goto PerlException;
12163 for (i=0; i < n; i++)
12165 (void) CopyMagickString(package_info->image_info->filename,list[i],
12167 image=PingImage(package_info->image_info,exception);
12168 if (image == (Image *) NULL)
12170 if ((package_info->image_info->file != (FILE *) NULL) ||
12171 (package_info->image_info->blob != (void *) NULL))
12172 DisassociateImageStream(image);
12173 count+=GetImageListLength(image);
12174 EXTEND(sp,4*count);
12175 for (next=image; next; next=next->next)
12177 PUSHs(sv_2mortal(newSViv(next->columns)));
12178 PUSHs(sv_2mortal(newSViv(next->rows)));
12179 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12180 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12182 image=DestroyImageList(image);
12187 for (i=0; i < n; i++)
12188 if (list[i] != (char *) NULL)
12189 for (p=keep; list[i] != *p++; )
12192 list[i]=(char *) RelinquishMagickMemory(list[i]);
12197 if (package_info != (struct PackageInfo *) NULL)
12198 DestroyPackageInfo(package_info);
12199 if (list && (list != keep))
12200 list=(char **) RelinquishMagickMemory(list);
12202 keep=(char **) RelinquishMagickMemory(keep);
12204 length=(STRLEN *) RelinquishMagickMemory(length);
12205 InheritPerlException(exception,perl_exception);
12206 exception=DestroyExceptionInfo(exception);
12207 SvREFCNT_dec(perl_exception); /* throw away all errors */
12211 ###############################################################################
12219 ###############################################################################
12224 Image::Magick ref=NO_INIT
12257 PERL_UNUSED_VAR(ref);
12258 PERL_UNUSED_VAR(ix);
12259 exception=AcquireExceptionInfo();
12260 perl_exception=newSVpv("",0);
12263 if (sv_isobject(ST(0)) == 0)
12265 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12267 goto PerlException;
12269 reference=SvRV(ST(0));
12270 hv=SvSTASH(reference);
12272 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12274 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12275 if (image == (Image *) NULL)
12277 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12279 goto PerlException;
12281 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12282 preview_type=GammaPreview;
12284 preview_type=(PreviewType)
12285 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12286 for ( ; image; image=image->next)
12288 preview_image=PreviewImage(image,preview_type,exception);
12289 if (preview_image == (Image *) NULL)
12290 goto PerlException;
12291 AddImageToRegistry(sv,preview_image);
12293 av_push(av,sv_bless(rv,hv));
12296 exception=DestroyExceptionInfo(exception);
12297 ST(0)=av_reference;
12298 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12302 InheritPerlException(exception,perl_exception);
12303 exception=DestroyExceptionInfo(exception);
12304 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12305 SvPOK_on(perl_exception);
12306 ST(0)=sv_2mortal(perl_exception);
12311 ###############################################################################
12315 # Q u e r y C o l o r #
12319 ###############################################################################
12323 QueryColor(ref,...)
12324 Image::Magick ref=NO_INIT
12344 PERL_UNUSED_VAR(ref);
12345 PERL_UNUSED_VAR(ix);
12346 exception=AcquireExceptionInfo();
12347 perl_exception=newSVpv("",0);
12356 colorlist=GetColorInfoList("*",&colors,exception);
12358 for (i=0; i < (ssize_t) colors; i++)
12360 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12362 colorlist=(const ColorInfo **)
12363 RelinquishMagickMemory((ColorInfo **) colorlist);
12364 goto PerlException;
12366 EXTEND(sp,5*items);
12367 for (i=1; i < items; i++)
12369 name=(char *) SvPV(ST(i),na);
12370 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12375 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12376 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12377 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12378 if (color.colorspace == CMYKColorspace)
12379 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12380 if (color.alpha_trait != UndefinedPixelTrait)
12381 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12385 InheritPerlException(exception,perl_exception);
12386 exception=DestroyExceptionInfo(exception);
12387 SvREFCNT_dec(perl_exception);
12391 ###############################################################################
12395 # Q u e r y C o l o r N a m e #
12399 ###############################################################################
12403 QueryColorname(ref,...)
12404 Image::Magick ref=NO_INIT
12413 message[MagickPathExtent];
12432 *reference; /* reference is the SV* of ref=SvIV(reference) */
12434 PERL_UNUSED_VAR(ref);
12435 PERL_UNUSED_VAR(ix);
12436 exception=AcquireExceptionInfo();
12437 perl_exception=newSVpv("",0);
12438 reference=SvRV(ST(0));
12439 av=(AV *) reference;
12440 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12442 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12443 if (image == (Image *) NULL)
12445 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12447 goto PerlException;
12450 for (i=1; i < items; i++)
12452 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12454 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12456 PUSHs(sv_2mortal(newSVpv(message,0)));
12460 InheritPerlException(exception,perl_exception);
12461 exception=DestroyExceptionInfo(exception);
12462 SvREFCNT_dec(perl_exception);
12466 ###############################################################################
12470 # Q u e r y F o n t #
12474 ###############################################################################
12479 Image::Magick ref=NO_INIT
12486 message[MagickPathExtent];
12497 volatile const TypeInfo
12500 PERL_UNUSED_VAR(ref);
12501 PERL_UNUSED_VAR(ix);
12502 exception=AcquireExceptionInfo();
12503 perl_exception=newSVpv("",0);
12512 typelist=GetTypeInfoList("*",&types,exception);
12514 for (i=0; i < (ssize_t) types; i++)
12516 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12518 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12520 goto PerlException;
12522 EXTEND(sp,10*items);
12523 for (i=1; i < items; i++)
12525 name=(char *) SvPV(ST(i),na);
12526 type_info=GetTypeInfo(name,exception);
12527 if (type_info == (TypeInfo *) NULL)
12532 if (type_info->name == (char *) NULL)
12535 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12536 if (type_info->description == (char *) NULL)
12539 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12540 if (type_info->family == (char *) NULL)
12543 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12544 if (type_info->style == UndefinedStyle)
12547 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12548 type_info->style),0)));
12549 if (type_info->stretch == UndefinedStretch)
12552 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12553 type_info->stretch),0)));
12554 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12555 type_info->weight);
12556 PUSHs(sv_2mortal(newSVpv(message,0)));
12557 if (type_info->encoding == (char *) NULL)
12560 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12561 if (type_info->foundry == (char *) NULL)
12564 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12565 if (type_info->format == (char *) NULL)
12568 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12569 if (type_info->metrics == (char *) NULL)
12572 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12573 if (type_info->glyphs == (char *) NULL)
12576 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12580 InheritPerlException(exception,perl_exception);
12581 exception=DestroyExceptionInfo(exception);
12582 SvREFCNT_dec(perl_exception);
12586 ###############################################################################
12590 # Q u e r y F o n t M e t r i c s #
12594 ###############################################################################
12598 QueryFontMetrics(ref,...)
12599 Image::Magick ref=NO_INIT
12601 queryfontmetrics = 1
12648 *reference; /* reference is the SV* of ref=SvIV(reference) */
12653 PERL_UNUSED_VAR(ref);
12654 PERL_UNUSED_VAR(ix);
12655 exception=AcquireExceptionInfo();
12656 package_info=(struct PackageInfo *) NULL;
12657 perl_exception=newSVpv("",0);
12658 reference=SvRV(ST(0));
12659 av=(AV *) reference;
12660 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12662 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12663 if (image == (Image *) NULL)
12665 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12667 goto PerlException;
12669 package_info=ClonePackageInfo(info,exception);
12670 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12671 CloneString(&draw_info->text,"");
12672 current=draw_info->affine;
12673 GetAffineMatrix(&affine);
12676 EXTEND(sp,7*items);
12677 for (i=2; i < items; i+=2)
12679 attribute=(char *) SvPV(ST(i-1),na);
12680 switch (*attribute)
12685 if (LocaleCompare(attribute,"antialias") == 0)
12687 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12691 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12695 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12698 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12705 if (LocaleCompare(attribute,"density") == 0)
12707 CloneString(&draw_info->density,SvPV(ST(i),na));
12710 if (LocaleCompare(attribute,"direction") == 0)
12712 draw_info->direction=(DirectionType) ParseCommandOption(
12713 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12716 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12723 if (LocaleCompare(attribute,"encoding") == 0)
12725 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12728 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12735 if (LocaleCompare(attribute,"family") == 0)
12737 CloneString(&draw_info->family,SvPV(ST(i),na));
12740 if (LocaleCompare(attribute,"fill") == 0)
12743 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12744 &draw_info->fill,exception);
12747 if (LocaleCompare(attribute,"font") == 0)
12749 CloneString(&draw_info->font,SvPV(ST(i),na));
12752 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12759 if (LocaleCompare(attribute,"geometry") == 0)
12761 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12764 if (LocaleCompare(attribute,"gravity") == 0)
12766 draw_info->gravity=(GravityType) ParseCommandOption(
12767 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12770 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12777 if (LocaleCompare(attribute,"interline-spacing") == 0)
12779 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12780 draw_info->interline_spacing=geometry_info.rho;
12783 if (LocaleCompare(attribute,"interword-spacing") == 0)
12785 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12786 draw_info->interword_spacing=geometry_info.rho;
12789 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12796 if (LocaleCompare(attribute,"kerning") == 0)
12798 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12799 draw_info->kerning=geometry_info.rho;
12802 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12809 if (LocaleCompare(attribute,"pointsize") == 0)
12811 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12812 draw_info->pointsize=geometry_info.rho;
12815 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12822 if (LocaleCompare(attribute,"rotate") == 0)
12824 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12825 affine.rx=geometry_info.rho;
12826 affine.ry=geometry_info.sigma;
12827 if ((flags & SigmaValue) == 0)
12828 affine.ry=affine.rx;
12831 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12838 if (LocaleCompare(attribute,"scale") == 0)
12840 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12841 affine.sx=geometry_info.rho;
12842 affine.sy=geometry_info.sigma;
12843 if ((flags & SigmaValue) == 0)
12844 affine.sy=affine.sx;
12847 if (LocaleCompare(attribute,"skew") == 0)
12853 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12854 x_angle=geometry_info.rho;
12855 y_angle=geometry_info.sigma;
12856 if ((flags & SigmaValue) == 0)
12858 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12859 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12862 if (LocaleCompare(attribute,"stroke") == 0)
12865 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12866 &draw_info->stroke,exception);
12869 if (LocaleCompare(attribute,"style") == 0)
12871 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12875 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12879 draw_info->style=(StyleType) type;
12882 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12889 if (LocaleCompare(attribute,"text") == 0)
12891 CloneString(&draw_info->text,SvPV(ST(i),na));
12894 if (LocaleCompare(attribute,"translate") == 0)
12896 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12897 affine.tx=geometry_info.rho;
12898 affine.ty=geometry_info.sigma;
12899 if ((flags & SigmaValue) == 0)
12900 affine.ty=affine.tx;
12903 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12910 if (LocaleCompare(attribute,"weight") == 0)
12912 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12913 draw_info->weight=(size_t) geometry_info.rho;
12916 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12923 if (LocaleCompare(attribute,"x") == 0)
12925 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12926 x=geometry_info.rho;
12929 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12936 if (LocaleCompare(attribute,"y") == 0)
12938 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12939 y=geometry_info.rho;
12942 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12948 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12954 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12955 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12956 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12957 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12958 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12959 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12960 if (draw_info->geometry == (char *) NULL)
12962 draw_info->geometry=AcquireString((char *) NULL);
12963 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12964 "%.15g,%.15g",x,y);
12966 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12967 (void) CatchImageException(image);
12968 if (status == MagickFalse)
12972 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12973 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12974 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12975 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12976 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12977 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12978 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12979 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12980 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12981 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12982 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12983 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12984 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12986 draw_info=DestroyDrawInfo(draw_info);
12989 if (package_info != (struct PackageInfo *) NULL)
12990 DestroyPackageInfo(package_info);
12991 InheritPerlException(exception,perl_exception);
12992 exception=DestroyExceptionInfo(exception);
12993 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12997 ###############################################################################
13001 # 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 #
13005 ###############################################################################
13009 QueryMultilineFontMetrics(ref,...)
13010 Image::Magick ref=NO_INIT
13012 querymultilinefontmetrics = 1
13059 *reference; /* reference is the SV* of ref=SvIV(reference) */
13064 PERL_UNUSED_VAR(ref);
13065 PERL_UNUSED_VAR(ix);
13066 exception=AcquireExceptionInfo();
13067 package_info=(struct PackageInfo *) NULL;
13068 perl_exception=newSVpv("",0);
13069 reference=SvRV(ST(0));
13070 av=(AV *) reference;
13071 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13073 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13074 if (image == (Image *) NULL)
13076 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13078 goto PerlException;
13080 package_info=ClonePackageInfo(info,exception);
13081 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13082 CloneString(&draw_info->text,"");
13083 current=draw_info->affine;
13084 GetAffineMatrix(&affine);
13087 EXTEND(sp,7*items);
13088 for (i=2; i < items; i+=2)
13090 attribute=(char *) SvPV(ST(i-1),na);
13091 switch (*attribute)
13096 if (LocaleCompare(attribute,"antialias") == 0)
13098 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13102 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13106 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13109 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13116 if (LocaleCompare(attribute,"density") == 0)
13118 CloneString(&draw_info->density,SvPV(ST(i),na));
13121 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13128 if (LocaleCompare(attribute,"encoding") == 0)
13130 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13133 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13140 if (LocaleCompare(attribute,"family") == 0)
13142 CloneString(&draw_info->family,SvPV(ST(i),na));
13145 if (LocaleCompare(attribute,"fill") == 0)
13148 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13149 &draw_info->fill,exception);
13152 if (LocaleCompare(attribute,"font") == 0)
13154 CloneString(&draw_info->font,SvPV(ST(i),na));
13157 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13164 if (LocaleCompare(attribute,"geometry") == 0)
13166 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13169 if (LocaleCompare(attribute,"gravity") == 0)
13171 draw_info->gravity=(GravityType) ParseCommandOption(
13172 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13175 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13182 if (LocaleCompare(attribute,"pointsize") == 0)
13184 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13185 draw_info->pointsize=geometry_info.rho;
13188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13195 if (LocaleCompare(attribute,"rotate") == 0)
13197 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13198 affine.rx=geometry_info.rho;
13199 affine.ry=geometry_info.sigma;
13200 if ((flags & SigmaValue) == 0)
13201 affine.ry=affine.rx;
13204 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13211 if (LocaleCompare(attribute,"scale") == 0)
13213 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13214 affine.sx=geometry_info.rho;
13215 affine.sy=geometry_info.sigma;
13216 if ((flags & SigmaValue) == 0)
13217 affine.sy=affine.sx;
13220 if (LocaleCompare(attribute,"skew") == 0)
13226 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13227 x_angle=geometry_info.rho;
13228 y_angle=geometry_info.sigma;
13229 if ((flags & SigmaValue) == 0)
13231 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13232 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13235 if (LocaleCompare(attribute,"stroke") == 0)
13238 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13239 &draw_info->stroke,exception);
13242 if (LocaleCompare(attribute,"style") == 0)
13244 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13248 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13252 draw_info->style=(StyleType) type;
13255 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13262 if (LocaleCompare(attribute,"text") == 0)
13264 CloneString(&draw_info->text,SvPV(ST(i),na));
13267 if (LocaleCompare(attribute,"translate") == 0)
13269 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13270 affine.tx=geometry_info.rho;
13271 affine.ty=geometry_info.sigma;
13272 if ((flags & SigmaValue) == 0)
13273 affine.ty=affine.tx;
13276 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13283 if (LocaleCompare(attribute,"weight") == 0)
13285 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13286 draw_info->weight=(size_t) geometry_info.rho;
13289 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13296 if (LocaleCompare(attribute,"x") == 0)
13298 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13299 x=geometry_info.rho;
13302 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13309 if (LocaleCompare(attribute,"y") == 0)
13311 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13312 y=geometry_info.rho;
13315 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13321 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13327 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13328 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13329 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13330 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13331 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13332 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13333 if (draw_info->geometry == (char *) NULL)
13335 draw_info->geometry=AcquireString((char *) NULL);
13336 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13337 "%.15g,%.15g",x,y);
13339 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13340 (void) CatchException(exception);
13341 if (status == MagickFalse)
13345 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13346 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13347 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13348 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13349 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13350 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13351 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13352 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13353 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13354 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13355 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13356 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13357 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13359 draw_info=DestroyDrawInfo(draw_info);
13362 if (package_info != (struct PackageInfo *) NULL)
13363 DestroyPackageInfo(package_info);
13364 InheritPerlException(exception,perl_exception);
13365 exception=DestroyExceptionInfo(exception);
13366 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13370 ###############################################################################
13374 # Q u e r y F o r m a t #
13378 ###############################################################################
13382 QueryFormat(ref,...)
13383 Image::Magick ref=NO_INIT
13400 volatile const MagickInfo
13403 PERL_UNUSED_VAR(ref);
13404 PERL_UNUSED_VAR(ix);
13405 exception=AcquireExceptionInfo();
13406 perl_exception=newSVpv("",0);
13410 format[MagickPathExtent];
13418 format_list=GetMagickInfoList("*",&types,exception);
13420 for (i=0; i < (ssize_t) types; i++)
13422 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13423 LocaleLower(format);
13424 PUSHs(sv_2mortal(newSVpv(format,0)));
13426 format_list=(const MagickInfo **)
13427 RelinquishMagickMemory((MagickInfo *) format_list);
13428 goto PerlException;
13430 EXTEND(sp,8*items);
13431 for (i=1; i < items; i++)
13433 name=(char *) SvPV(ST(i),na);
13434 magick_info=GetMagickInfo(name,exception);
13435 if (magick_info == (const MagickInfo *) NULL)
13440 if (magick_info->description == (char *) NULL)
13443 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13444 if (magick_info->module == (char *) NULL)
13447 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13451 InheritPerlException(exception,perl_exception);
13452 exception=DestroyExceptionInfo(exception);
13453 SvREFCNT_dec(perl_exception);
13457 ###############################################################################
13461 # Q u e r y O p t i o n #
13465 ###############################################################################
13469 QueryOption(ref,...)
13470 Image::Magick ref=NO_INIT
13491 PERL_UNUSED_VAR(ref);
13492 PERL_UNUSED_VAR(ix);
13493 exception=AcquireExceptionInfo();
13494 perl_exception=newSVpv("",0);
13495 EXTEND(sp,8*items);
13496 for (i=1; i < items; i++)
13498 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13500 options=GetCommandOptions((CommandOption) option);
13501 if (options == (char **) NULL)
13505 for (j=0; options[j] != (char *) NULL; j++)
13506 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13507 options=DestroyStringList(options);
13511 InheritPerlException(exception,perl_exception);
13512 exception=DestroyExceptionInfo(exception);
13513 SvREFCNT_dec(perl_exception);
13517 ###############################################################################
13525 ###############################################################################
13530 Image::Magick ref=NO_INIT
13577 *perl_exception, /* Perl variable for storing messages */
13582 PERL_UNUSED_VAR(ref);
13583 PERL_UNUSED_VAR(ix);
13584 exception=AcquireExceptionInfo();
13585 perl_exception=newSVpv("",0);
13587 package_info=(struct PackageInfo *) NULL;
13589 ac=(items < 2) ? 1 : items-1;
13590 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13592 length=(STRLEN *) NULL;
13593 if (list == (char **) NULL)
13595 ThrowPerlException(exception,ResourceLimitError,
13596 "MemoryAllocationFailed",PackageName);
13597 goto PerlException;
13599 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13600 if (length == (STRLEN *) NULL)
13602 ThrowPerlException(exception,ResourceLimitError,
13603 "MemoryAllocationFailed",PackageName);
13604 goto PerlException;
13606 if (sv_isobject(ST(0)) == 0)
13608 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13610 goto PerlException;
13612 reference=SvRV(ST(0));
13613 hv=SvSTASH(reference);
13614 if (SvTYPE(reference) != SVt_PVAV)
13616 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13618 goto PerlException;
13620 av=(AV *) reference;
13621 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13623 package_info=ClonePackageInfo(info,exception);
13626 *list=(char *) (*package_info->image_info->filename ?
13627 package_info->image_info->filename : "XC:black");
13629 for (n=0, i=0; i < ac; i++)
13631 list[n]=(char *) SvPV(ST(i+1),length[n]);
13632 if ((items >= 3) && strEQcase(list[n],"blob"))
13638 blob=(void *) (SvPV(ST(i+1),length[n]));
13639 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13641 if ((items >= 3) && strEQcase(list[n],"filename"))
13643 if ((items >= 3) && strEQcase(list[n],"file"))
13652 io_info=IoIFP(sv_2io(ST(i+1)));
13653 if (io_info == (PerlIO *) NULL)
13655 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13659 file=PerlIO_findFILE(io_info);
13660 if (file == (FILE *) NULL)
13662 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13666 SetImageInfoFile(package_info->image_info,file);
13668 if ((items >= 3) && strEQcase(list[n],"magick"))
13672 list[n]=(char *) NULL;
13674 status=ExpandFilenames(&n,&list);
13675 if (status == MagickFalse)
13677 ThrowPerlException(exception,ResourceLimitError,
13678 "MemoryAllocationFailed",PackageName);
13679 goto PerlException;
13682 for (i=0; i < n; i++)
13684 if ((package_info->image_info->file == (FILE *) NULL) &&
13685 (package_info->image_info->blob == (void *) NULL))
13686 image=ReadImages(package_info->image_info,list[i],exception);
13689 image=ReadImages(package_info->image_info,
13690 package_info->image_info->filename,exception);
13691 if (image != (Image *) NULL)
13692 DisassociateImageStream(image);
13694 if (image == (Image *) NULL)
13696 for ( ; image; image=image->next)
13698 AddImageToRegistry(sv,image);
13700 av_push(av,sv_bless(rv,hv));
13708 for (i=0; i < n; i++)
13709 if (list[i] != (char *) NULL)
13710 for (p=keep; list[i] != *p++; )
13711 if (*p == (char *) NULL)
13713 list[i]=(char *) RelinquishMagickMemory(list[i]);
13718 if (package_info != (struct PackageInfo *) NULL)
13719 DestroyPackageInfo(package_info);
13720 if (list && (list != keep))
13721 list=(char **) RelinquishMagickMemory(list);
13723 keep=(char **) RelinquishMagickMemory(keep);
13725 length=(STRLEN *) RelinquishMagickMemory(length);
13726 InheritPerlException(exception,perl_exception);
13727 exception=DestroyExceptionInfo(exception);
13728 sv_setiv(perl_exception,(IV) number_images);
13729 SvPOK_on(perl_exception);
13730 ST(0)=sv_2mortal(perl_exception);
13735 ###############################################################################
13743 ###############################################################################
13748 Image::Magick ref=NO_INIT
13771 PERL_UNUSED_VAR(ref);
13772 PERL_UNUSED_VAR(ix);
13773 exception=AcquireExceptionInfo();
13774 perl_exception=newSVpv("",0);
13775 reference=SvRV(ST(0));
13776 av=(AV *) reference;
13777 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13779 for (i=1; i < items; i++)
13780 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13781 SvPV(ST(i),na),exception);
13782 InheritPerlException(exception,perl_exception);
13783 exception=DestroyExceptionInfo(exception);
13784 SvREFCNT_dec(perl_exception); /* throw away all errors */
13788 ###############################################################################
13796 ###############################################################################
13801 Image::Magick ref=NO_INIT
13824 *reference; /* reference is the SV* of ref=SvIV(reference) */
13826 PERL_UNUSED_VAR(ref);
13827 PERL_UNUSED_VAR(ix);
13828 exception=AcquireExceptionInfo();
13829 perl_exception=newSVpv("",0);
13830 if (sv_isobject(ST(0)) == 0)
13832 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13834 goto PerlException;
13836 reference=SvRV(ST(0));
13837 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13839 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13841 for (i=2; i < items; i+=2)
13842 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13845 InheritPerlException(exception,perl_exception);
13846 exception=DestroyExceptionInfo(exception);
13847 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13848 SvPOK_on(perl_exception);
13849 ST(0)=sv_2mortal(perl_exception);
13854 ###############################################################################
13858 # S e t P i x e l #
13862 ###############################################################################
13867 Image::Magick ref=NO_INIT
13909 *reference; /* reference is the SV* of ref=SvIV(reference) */
13911 PERL_UNUSED_VAR(ref);
13912 PERL_UNUSED_VAR(ix);
13913 exception=AcquireExceptionInfo();
13914 perl_exception=newSVpv("",0);
13915 reference=SvRV(ST(0));
13916 av=(AV *) reference;
13917 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13919 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13920 if (image == (Image *) NULL)
13922 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13924 goto PerlException;
13927 normalize=MagickTrue;
13930 region.width=image->columns;
13933 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13934 channel=DefaultChannels;
13935 for (i=2; i < items; i+=2)
13937 attribute=(char *) SvPV(ST(i-1),na);
13938 switch (*attribute)
13943 if (LocaleCompare(attribute,"channel") == 0)
13948 option=ParseChannelOption(SvPV(ST(i),na));
13951 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13955 channel=(ChannelType) option;
13958 if (LocaleCompare(attribute,"color") == 0)
13960 if (SvTYPE(ST(i)) != SVt_RV)
13963 message[MagickPathExtent];
13965 (void) FormatLocaleString(message,MagickPathExtent,
13966 "invalid %.60s value",attribute);
13967 ThrowPerlException(exception,OptionError,message,
13970 av=(AV *) SvRV(ST(i));
13973 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13980 if (LocaleCompare(attribute,"geometry") == 0)
13982 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13985 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13992 if (LocaleCompare(attribute,"normalize") == 0)
13994 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13998 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14002 normalize=option != 0 ? MagickTrue : MagickFalse;
14005 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14012 if (LocaleCompare(attribute,"x") == 0)
14014 region.x=SvIV(ST(i));
14017 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14024 if (LocaleCompare(attribute,"y") == 0)
14026 region.y=SvIV(ST(i));
14029 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14035 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14041 (void) SetImageStorageClass(image,DirectClass,exception);
14042 channel_mask=SetImageChannelMask(image,channel);
14043 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14044 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14045 (SvTYPE(av) != SVt_PVAV))
14057 if (normalize != MagickFalse)
14058 scale=QuantumRange;
14059 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14062 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14063 av_fetch(av,i,0)))),q);
14066 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14069 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14070 av_fetch(av,i,0)))),q);
14073 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14076 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14077 av_fetch(av,i,0)))),q);
14080 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14081 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14083 SetPixelBlack(image,ClampToQuantum(scale*
14084 SvNV(*(av_fetch(av,i,0)))),q);
14087 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14090 SetPixelAlpha(image,ClampToQuantum(scale*
14091 SvNV(*(av_fetch(av,i,0)))),q);
14094 (void) SyncAuthenticPixels(image,exception);
14096 (void) SetImageChannelMask(image,channel_mask);
14099 InheritPerlException(exception,perl_exception);
14100 exception=DestroyExceptionInfo(exception);
14101 SvREFCNT_dec(perl_exception);
14105 ###############################################################################
14113 ###############################################################################
14118 Image::Magick ref=NO_INIT
14157 PERL_UNUSED_VAR(ref);
14158 PERL_UNUSED_VAR(ix);
14159 exception=AcquireExceptionInfo();
14160 perl_exception=newSVpv("",0);
14164 if (sv_isobject(ST(0)) == 0)
14166 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14168 goto PerlException;
14170 reference=SvRV(ST(0));
14171 hv=SvSTASH(reference);
14173 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14175 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14176 if (image == (Image *) NULL)
14178 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14180 goto PerlException;
14182 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14188 for (i=2; i < items; i+=2)
14190 attribute=(char *) SvPV(ST(i-1),na);
14191 switch (*attribute)
14196 if (LocaleCompare(attribute,"offset") == 0)
14198 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14201 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14208 if (LocaleCompare(attribute,"stack") == 0)
14210 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14214 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14220 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14226 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14232 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14234 if (image == (Image *) NULL)
14235 goto PerlException;
14236 for ( ; image; image=image->next)
14238 AddImageToRegistry(sv,image);
14240 av_push(av,sv_bless(rv,hv));
14243 exception=DestroyExceptionInfo(exception);
14244 ST(0)=av_reference;
14245 SvREFCNT_dec(perl_exception);
14249 InheritPerlException(exception,perl_exception);
14250 exception=DestroyExceptionInfo(exception);
14251 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14252 SvPOK_on(perl_exception);
14253 ST(0)=sv_2mortal(perl_exception);
14258 ###############################################################################
14262 # S t a t i s t i c s #
14266 ###############################################################################
14270 Statistics(ref,...)
14271 Image::Magick ref=NO_INIT
14273 StatisticsImage = 1
14275 statisticsimage = 3
14278 #define ChannelStatistics(channel) \
14280 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14281 (double) channel_statistics[channel].depth); \
14282 PUSHs(sv_2mortal(newSVpv(message,0))); \
14283 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14284 channel_statistics[channel].minima/scale); \
14285 PUSHs(sv_2mortal(newSVpv(message,0))); \
14286 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14287 channel_statistics[channel].maxima/scale); \
14288 PUSHs(sv_2mortal(newSVpv(message,0))); \
14289 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14290 channel_statistics[channel].mean/scale); \
14291 PUSHs(sv_2mortal(newSVpv(message,0))); \
14292 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14293 channel_statistics[channel].standard_deviation/scale); \
14294 PUSHs(sv_2mortal(newSVpv(message,0))); \
14295 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14296 channel_statistics[channel].kurtosis); \
14297 PUSHs(sv_2mortal(newSVpv(message,0))); \
14298 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14299 channel_statistics[channel].skewness); \
14300 PUSHs(sv_2mortal(newSVpv(message,0))); \
14301 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14302 channel_statistics[channel].entropy); \
14303 PUSHs(sv_2mortal(newSVpv(message,0))); \
14310 message[MagickPathExtent];
14313 *channel_statistics;
14334 PERL_UNUSED_VAR(ref);
14335 PERL_UNUSED_VAR(ix);
14336 exception=AcquireExceptionInfo();
14337 perl_exception=newSVpv("",0);
14339 if (sv_isobject(ST(0)) == 0)
14341 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14343 goto PerlException;
14345 reference=SvRV(ST(0));
14348 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14349 if (image == (Image *) NULL)
14351 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14353 goto PerlException;
14356 for ( ; image; image=image->next)
14358 channel_statistics=GetImageStatistics(image,exception);
14359 if (channel_statistics == (ChannelStatistics *) NULL)
14362 EXTEND(sp,35*count);
14363 scale=(double) QuantumRange;
14364 ChannelStatistics(RedChannel);
14365 ChannelStatistics(GreenChannel);
14366 ChannelStatistics(BlueChannel);
14367 if (image->colorspace == CMYKColorspace)
14368 ChannelStatistics(BlackChannel);
14369 if (image->alpha_trait != UndefinedPixelTrait)
14370 ChannelStatistics(AlphaChannel);
14371 channel_statistics=(ChannelStatistics *)
14372 RelinquishMagickMemory(channel_statistics);
14376 InheritPerlException(exception,perl_exception);
14377 exception=DestroyExceptionInfo(exception);
14378 SvREFCNT_dec(perl_exception);
14382 ###############################################################################
14386 # S y n c A u t h e n t i c P i x e l s #
14390 ###############################################################################
14394 SyncAuthenticPixels(ref,...)
14395 Image::Magick ref = NO_INIT
14397 Syncauthenticpixels = 1
14398 SyncImagePixels = 2
14399 syncimagepixels = 3
14418 PERL_UNUSED_VAR(ref);
14419 PERL_UNUSED_VAR(ix);
14420 exception=AcquireExceptionInfo();
14421 perl_exception=newSVpv("",0);
14422 if (sv_isobject(ST(0)) == 0)
14424 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14426 goto PerlException;
14429 reference=SvRV(ST(0));
14430 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14431 if (image == (Image *) NULL)
14433 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14435 goto PerlException;
14438 status=SyncAuthenticPixels(image,exception);
14439 if (status != MagickFalse)
14443 InheritPerlException(exception,perl_exception);
14444 exception=DestroyExceptionInfo(exception);
14445 SvREFCNT_dec(perl_exception); /* throw away all errors */
14449 ###############################################################################
14453 # T r a n s f o r m #
14457 ###############################################################################
14462 Image::Magick ref=NO_INIT
14500 PERL_UNUSED_VAR(ref);
14501 PERL_UNUSED_VAR(ix);
14502 exception=AcquireExceptionInfo();
14503 perl_exception=newSVpv("",0);
14507 if (sv_isobject(ST(0)) == 0)
14509 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14511 goto PerlException;
14513 reference=SvRV(ST(0));
14514 hv=SvSTASH(reference);
14516 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14518 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14519 if (image == (Image *) NULL)
14521 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14523 goto PerlException;
14525 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14529 crop_geometry=(char *) NULL;
14530 geometry=(char *) NULL;
14531 for (i=2; i < items; i+=2)
14533 attribute=(char *) SvPV(ST(i-1),na);
14534 switch (*attribute)
14539 if (LocaleCompare(attribute,"crop") == 0)
14541 crop_geometry=SvPV(ST(i),na);
14544 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14551 if (LocaleCompare(attribute,"geometry") == 0)
14553 geometry=SvPV(ST(i),na);
14556 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14568 for ( ; image; image=image->next)
14570 clone=CloneImage(image,0,0,MagickTrue,exception);
14571 if (clone == (Image *) NULL)
14572 goto PerlException;
14573 TransformImage(&clone,crop_geometry,geometry,exception);
14574 for ( ; clone; clone=clone->next)
14576 AddImageToRegistry(sv,clone);
14578 av_push(av,sv_bless(rv,hv));
14582 exception=DestroyExceptionInfo(exception);
14583 ST(0)=av_reference;
14584 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14588 InheritPerlException(exception,perl_exception);
14589 exception=DestroyExceptionInfo(exception);
14590 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14591 SvPOK_on(perl_exception);
14592 ST(0)=sv_2mortal(perl_exception);
14597 ###############################################################################
14605 ###############################################################################
14610 Image::Magick ref=NO_INIT
14618 filename[MagickPathExtent];
14642 PERL_UNUSED_VAR(ref);
14643 PERL_UNUSED_VAR(ix);
14644 exception=AcquireExceptionInfo();
14645 perl_exception=newSVpv("",0);
14647 package_info=(struct PackageInfo *) NULL;
14648 if (sv_isobject(ST(0)) == 0)
14650 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14652 goto PerlException;
14654 reference=SvRV(ST(0));
14655 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14656 if (image == (Image *) NULL)
14658 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14660 goto PerlException;
14662 package_info=ClonePackageInfo(info,exception);
14664 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14667 for (i=2; i < items; i+=2)
14668 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14670 (void) CopyMagickString(filename,package_info->image_info->filename,
14673 for (next=image; next; next=next->next)
14675 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14676 next->scene=scene++;
14678 *package_info->image_info->magick='\0';
14679 SetImageInfo(package_info->image_info,(unsigned int)
14680 GetImageListLength(image),exception);
14681 for (next=image; next; next=next->next)
14683 (void) WriteImage(package_info->image_info,next,exception);
14685 if (package_info->image_info->adjoin)
14690 if (package_info != (struct PackageInfo *) NULL)
14691 DestroyPackageInfo(package_info);
14692 InheritPerlException(exception,perl_exception);
14693 exception=DestroyExceptionInfo(exception);
14694 sv_setiv(perl_exception,(IV) number_images);
14695 SvPOK_on(perl_exception);
14696 ST(0)=sv_2mortal(perl_exception);