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->alpha_color=target_color;
1712 for ( ; image; image=image->next)
1713 image->alpha_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,"virtual-pixel") == 0)
2203 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2204 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2207 ThrowPerlException(exception,OptionError,
2208 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2211 for ( ; image; image=image->next)
2212 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2216 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2217 for ( ; image; image=image->next)
2218 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2224 if (LocaleCompare(attribute,"white-point") == 0)
2226 for ( ; image; image=image->next)
2228 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2229 image->chromaticity.white_point.x=geometry_info.rho;
2230 image->chromaticity.white_point.y=geometry_info.sigma;
2231 if ((flags & SigmaValue) == 0)
2232 image->chromaticity.white_point.y=
2233 image->chromaticity.white_point.x;
2237 if (LocaleCompare(attribute,"write-mask") == 0)
2242 mask=(Image *) NULL;
2244 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
2245 for ( ; image; image=image->next)
2246 SetImageMask(image,WritePixelMask,mask,exception);
2250 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2251 for ( ; image; image=image->next)
2252 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2258 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2259 for ( ; image; image=image->next)
2260 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2271 % S e t u p L i s t %
2275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2277 % Method SetupList returns the list of all the images linked by their
2278 % image->next and image->previous link lists for use with ImageMagick. If
2279 % info is non-NULL, an info structure is returned in *info. If
2280 % reference_vector is non-NULL,an array of SV* are returned in
2281 % *reference_vector. Reference_vector is used when the images are going to be
2282 % replaced with new Image*'s.
2284 % The format of the SetupList routine is:
2286 % Image *SetupList(SV *reference,struct PackageInfo **info,
2287 % SV ***reference_vector,ExceptionInfo *exception)
2289 % A description of each parameter follows:
2291 % o list: a list of strings.
2293 % o string: a character string.
2295 % o exception: Return any errors or warnings in this structure.
2298 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2299 SV ***reference_vector,ExceptionInfo *exception)
2308 if (reference_vector)
2309 *reference_vector=NULL;
2314 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2315 if (info && (SvTYPE(reference) == SVt_PVAV))
2316 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2326 % s t r E Q c a s e %
2330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2332 % strEQcase() compares two strings and returns 0 if they are the
2333 % same or if the second string runs out first. The comparison is case
2336 % The format of the strEQcase routine is:
2338 % ssize_t strEQcase(const char *p,const char *q)
2340 % A description of each parameter follows:
2342 % o p: a character string.
2344 % o q: a character string.
2348 static ssize_t strEQcase(const char *p,const char *q)
2356 for (i=0 ; (c=(*q)) != 0; i++)
2358 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2359 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2364 return(((*q == 0) && (*p == 0)) ? i : 0);
2368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2372 % I m a g e : : M a g i c k %
2376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2380 MODULE = Image::Magick PACKAGE = Image::Magick
2385 MagickCoreGenesis("PerlMagick",MagickFalse);
2386 SetWarningHandler(NULL);
2387 SetErrorHandler(NULL);
2388 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2389 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2395 if (magick_registry != (SplayTreeInfo *) NULL)
2396 magick_registry=DestroySplayTree(magick_registry);
2397 MagickCoreTerminus();
2401 constant(name,argument)
2406 ###############################################################################
2414 ###############################################################################
2419 Image::Magick ref=NO_INIT
2443 PERL_UNUSED_VAR(ref);
2444 PERL_UNUSED_VAR(ix);
2445 exception=AcquireExceptionInfo();
2446 perl_exception=newSVpv("",0);
2447 package_info=(struct PackageInfo *) NULL;
2448 if (sv_isobject(ST(0)) == 0)
2450 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2454 reference=SvRV(ST(0));
2455 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2456 if (image == (Image *) NULL)
2458 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2462 package_info=ClonePackageInfo(info,exception);
2464 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2467 for (i=2; i < items; i+=2)
2468 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2470 (void) AnimateImages(package_info->image_info,image,exception);
2471 (void) CatchImageException(image);
2474 if (package_info != (struct PackageInfo *) NULL)
2475 DestroyPackageInfo(package_info);
2476 InheritPerlException(exception,perl_exception);
2477 exception=DestroyExceptionInfo(exception);
2478 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2479 SvPOK_on(perl_exception);
2480 ST(0)=sv_2mortal(perl_exception);
2485 ###############################################################################
2493 ###############################################################################
2498 Image::Magick ref=NO_INIT
2536 PERL_UNUSED_VAR(ref);
2537 PERL_UNUSED_VAR(ix);
2538 exception=AcquireExceptionInfo();
2539 perl_exception=newSVpv("",0);
2543 if (sv_isobject(ST(0)) == 0)
2545 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2549 reference=SvRV(ST(0));
2550 hv=SvSTASH(reference);
2552 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2554 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2555 if (image == (Image *) NULL)
2557 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2561 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2566 for (i=2; i < items; i+=2)
2568 attribute=(char *) SvPV(ST(i-1),na);
2574 if (LocaleCompare(attribute,"stack") == 0)
2576 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2580 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2586 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2592 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2598 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2599 if (image == (Image *) NULL)
2601 for ( ; image; image=image->next)
2603 AddImageToRegistry(sv,image);
2605 av_push(av,sv_bless(rv,hv));
2608 exception=DestroyExceptionInfo(exception);
2610 SvREFCNT_dec(perl_exception);
2614 InheritPerlException(exception,perl_exception);
2615 exception=DestroyExceptionInfo(exception);
2616 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2617 SvPOK_on(perl_exception);
2618 ST(0)=sv_2mortal(perl_exception);
2623 ###############################################################################
2631 ###############################################################################
2636 Image::Magick ref=NO_INIT
2667 PERL_UNUSED_VAR(ref);
2668 PERL_UNUSED_VAR(ix);
2669 exception=AcquireExceptionInfo();
2670 perl_exception=newSVpv("",0);
2672 if (sv_isobject(ST(0)) == 0)
2674 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2678 reference=SvRV(ST(0));
2679 hv=SvSTASH(reference);
2680 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2681 if (image == (Image *) NULL)
2683 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2687 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2688 if (image == (Image *) NULL)
2691 Create blessed Perl array for the returned image.
2694 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2696 AddImageToRegistry(sv,image);
2698 av_push(av,sv_bless(rv,hv));
2700 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2701 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2702 "average-%.*s",(int) (MagickPathExtent-9),
2703 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2704 (void) CopyMagickString(image->filename,info->image_info->filename,
2706 SetImageInfo(info->image_info,0,exception);
2707 exception=DestroyExceptionInfo(exception);
2708 SvREFCNT_dec(perl_exception);
2712 InheritPerlException(exception,perl_exception);
2713 exception=DestroyExceptionInfo(exception);
2714 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2715 SvPOK_on(perl_exception);
2716 ST(0)=sv_2mortal(perl_exception);
2721 ###############################################################################
2725 # B l o b T o I m a g e #
2729 ###############################################################################
2733 BlobToImage(ref,...)
2734 Image::Magick ref=NO_INIT
2780 PERL_UNUSED_VAR(ref);
2781 PERL_UNUSED_VAR(ix);
2782 exception=AcquireExceptionInfo();
2783 perl_exception=newSVpv("",0);
2786 ac=(items < 2) ? 1 : items-1;
2787 length=(STRLEN *) NULL;
2788 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2789 if (list == (char **) NULL)
2791 ThrowPerlException(exception,ResourceLimitError,
2792 "MemoryAllocationFailed",PackageName);
2795 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2796 if (length == (STRLEN *) NULL)
2798 ThrowPerlException(exception,ResourceLimitError,
2799 "MemoryAllocationFailed",PackageName);
2802 if (sv_isobject(ST(0)) == 0)
2804 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2808 reference=SvRV(ST(0));
2809 hv=SvSTASH(reference);
2810 if (SvTYPE(reference) != SVt_PVAV)
2812 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2816 av=(AV *) reference;
2817 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2822 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2825 for (n=0, i=0; i < ac; i++)
2827 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2828 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2830 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2835 list[n]=(char *) NULL;
2837 for (i=number_images=0; i < n; i++)
2839 image=BlobToImage(info->image_info,list[i],length[i],exception);
2840 if (image == (Image *) NULL)
2842 for ( ; image; image=image->next)
2844 AddImageToRegistry(sv,image);
2846 av_push(av,sv_bless(rv,hv));
2854 for (i=0; i < n; i++)
2855 if (list[i] != (char *) NULL)
2856 for (p=keep; list[i] != *p++; )
2857 if (*p == (char *) NULL)
2859 list[i]=(char *) RelinquishMagickMemory(list[i]);
2865 list=(char **) RelinquishMagickMemory(list);
2867 length=(STRLEN *) RelinquishMagickMemory(length);
2868 InheritPerlException(exception,perl_exception);
2869 exception=DestroyExceptionInfo(exception);
2870 sv_setiv(perl_exception,(IV) number_images);
2871 SvPOK_on(perl_exception);
2872 ST(0)=sv_2mortal(perl_exception);
2877 ###############################################################################
2881 # C h a n n e l F x #
2885 ###############################################################################
2890 Image::Magick ref=NO_INIT
2902 expression[MagickPathExtent];
2930 PERL_UNUSED_VAR(ref);
2931 PERL_UNUSED_VAR(ix);
2932 exception=AcquireExceptionInfo();
2933 perl_exception=newSVpv("",0);
2937 if (sv_isobject(ST(0)) == 0)
2939 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2943 reference=SvRV(ST(0));
2944 hv=SvSTASH(reference);
2946 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2948 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2949 if (image == (Image *) NULL)
2951 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2955 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2959 channel=DefaultChannels;
2960 (void) CopyMagickString(expression,"u",MagickPathExtent);
2962 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
2964 for (i=2; i < items; i+=2)
2966 attribute=(char *) SvPV(ST(i-1),na);
2972 if (LocaleCompare(attribute,"channel") == 0)
2977 option=ParseChannelOption(SvPV(ST(i),na));
2980 ThrowPerlException(exception,OptionError,
2981 "UnrecognizedType",SvPV(ST(i),na));
2984 channel=(ChannelType) option;
2987 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2994 if (LocaleCompare(attribute,"expression") == 0)
2996 (void) CopyMagickString(expression,SvPV(ST(i),na),
3000 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3006 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3012 channel_mask=SetImageChannelMask(image,channel);
3013 image=ChannelFxImage(image,expression,exception);
3014 if (image != (Image *) NULL)
3015 (void) SetImageChannelMask(image,channel_mask);
3016 if (image == (Image *) NULL)
3018 for ( ; image; image=image->next)
3020 AddImageToRegistry(sv,image);
3022 av_push(av,sv_bless(rv,hv));
3025 exception=DestroyExceptionInfo(exception);
3027 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3031 InheritPerlException(exception,perl_exception);
3032 exception=DestroyExceptionInfo(exception);
3033 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3034 SvPOK_on(perl_exception);
3035 ST(0)=sv_2mortal(perl_exception);
3040 ###############################################################################
3048 ###############################################################################
3053 Image::Magick ref=NO_INIT
3086 PERL_UNUSED_VAR(ref);
3087 PERL_UNUSED_VAR(ix);
3088 exception=AcquireExceptionInfo();
3089 perl_exception=newSVpv("",0);
3091 if (sv_isobject(ST(0)) == 0)
3093 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3097 reference=SvRV(ST(0));
3098 hv=SvSTASH(reference);
3099 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3100 if (image == (Image *) NULL)
3102 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3107 Create blessed Perl array for the returned image.
3110 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3112 for ( ; image; image=image->next)
3114 clone=CloneImage(image,0,0,MagickTrue,exception);
3115 if (clone == (Image *) NULL)
3117 AddImageToRegistry(sv,clone);
3119 av_push(av,sv_bless(rv,hv));
3122 exception=DestroyExceptionInfo(exception);
3123 SvREFCNT_dec(perl_exception);
3127 InheritPerlException(exception,perl_exception);
3128 exception=DestroyExceptionInfo(exception);
3129 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3130 SvPOK_on(perl_exception);
3131 ST(0)=sv_2mortal(perl_exception);
3136 ###############################################################################
3144 ###############################################################################
3152 PERL_UNUSED_VAR(ref);
3153 if (magick_registry != (SplayTreeInfo *) NULL)
3158 ResetSplayTreeIterator(magick_registry);
3159 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3160 while (p != (Image *) NULL)
3163 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3169 ###############################################################################
3177 ###############################################################################
3182 Image::Magick ref=NO_INIT
3211 PERL_UNUSED_VAR(ref);
3212 PERL_UNUSED_VAR(ix);
3213 exception=AcquireExceptionInfo();
3214 perl_exception=newSVpv("",0);
3216 if (sv_isobject(ST(0)) == 0)
3218 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3222 reference=SvRV(ST(0));
3223 hv=SvSTASH(reference);
3225 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3227 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3228 if (image == (Image *) NULL)
3230 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3234 image=CoalesceImages(image,exception);
3235 if (image == (Image *) NULL)
3237 for ( ; image; image=image->next)
3239 AddImageToRegistry(sv,image);
3241 av_push(av,sv_bless(rv,hv));
3244 exception=DestroyExceptionInfo(exception);
3246 SvREFCNT_dec(perl_exception);
3250 InheritPerlException(exception,perl_exception);
3251 exception=DestroyExceptionInfo(exception);
3252 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3253 SvPOK_on(perl_exception);
3254 ST(0)=sv_2mortal(perl_exception);
3259 ###############################################################################
3267 ###############################################################################
3272 Image::Magick ref=NO_INIT
3318 PERL_UNUSED_VAR(ref);
3319 PERL_UNUSED_VAR(ix);
3320 exception=AcquireExceptionInfo();
3321 perl_exception=newSVpv("",0);
3325 if (sv_isobject(ST(0)) == 0)
3327 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3331 reference=SvRV(ST(0));
3332 hv=SvSTASH(reference);
3334 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3336 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3337 if (image == (Image *) NULL)
3339 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3343 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3347 reconstruct_image=image;
3348 metric=RootMeanSquaredErrorMetric;
3349 for (i=2; i < items; i+=2)
3351 attribute=(char *) SvPV(ST(i-1),na);
3357 if (LocaleCompare(attribute,"channel") == 0)
3362 option=ParseChannelOption(SvPV(ST(i),na));
3365 ThrowPerlException(exception,OptionError,
3366 "UnrecognizedType",SvPV(ST(i),na));
3369 (void) SetPixelChannelMask(image,(ChannelType) option);
3372 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3379 if (LocaleCompare(attribute,"fuzz") == 0)
3381 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3384 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3391 if (LocaleCompare(attribute,"image") == 0)
3393 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3394 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3397 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3404 if (LocaleCompare(attribute,"metric") == 0)
3406 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3410 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3414 metric=(MetricType) option;
3417 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3423 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3429 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3431 if (difference_image != (Image *) NULL)
3433 difference_image->error.mean_error_per_pixel=distortion;
3434 AddImageToRegistry(sv,difference_image);
3436 av_push(av,sv_bless(rv,hv));
3439 exception=DestroyExceptionInfo(exception);
3441 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3445 InheritPerlException(exception,perl_exception);
3446 exception=DestroyExceptionInfo(exception);
3447 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3448 SvPOK_on(perl_exception);
3449 ST(0)=sv_2mortal(perl_exception);
3454 ###############################################################################
3458 # C o m p l e x I m a g e s #
3462 ###############################################################################
3467 Image::Magick ref=NO_INIT
3504 PERL_UNUSED_VAR(ref);
3505 PERL_UNUSED_VAR(ix);
3506 exception=AcquireExceptionInfo();
3507 perl_exception=newSVpv("",0);
3509 if (sv_isobject(ST(0)) == 0)
3511 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3515 reference=SvRV(ST(0));
3516 hv=SvSTASH(reference);
3517 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3518 if (image == (Image *) NULL)
3520 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3524 op=UndefinedComplexOperator;
3530 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3534 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3538 op=(ComplexOperator) in;
3541 for (i=2; i < items; i+=2)
3543 attribute=(char *) SvPV(ST(i-1),na);
3549 if (LocaleCompare(attribute,"operator") == 0)
3554 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3555 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3558 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3562 op=(ComplexOperator) in;
3565 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3571 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3577 image=ComplexImages(image,op,exception);
3578 if (image == (Image *) NULL)
3581 Create blessed Perl array for the returned image.
3584 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3586 AddImageToRegistry(sv,image);
3588 av_push(av,sv_bless(rv,hv));
3590 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3591 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3592 "complex-%.*s",(int) (MagickPathExtent-9),
3593 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3594 (void) CopyMagickString(image->filename,info->image_info->filename,
3596 SetImageInfo(info->image_info,0,exception);
3597 exception=DestroyExceptionInfo(exception);
3598 SvREFCNT_dec(perl_exception);
3602 InheritPerlException(exception,perl_exception);
3603 exception=DestroyExceptionInfo(exception);
3604 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3605 SvPOK_on(perl_exception);
3606 ST(0)=sv_2mortal(perl_exception);
3611 ###############################################################################
3615 # C o m p a r e L a y e r s #
3619 ###############################################################################
3624 Image::Magick ref=NO_INIT
3626 CompareImagesLayers = 1
3628 compareimagelayers = 3
3665 PERL_UNUSED_VAR(ref);
3666 PERL_UNUSED_VAR(ix);
3667 exception=AcquireExceptionInfo();
3668 perl_exception=newSVpv("",0);
3670 if (sv_isobject(ST(0)) == 0)
3672 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3676 reference=SvRV(ST(0));
3677 hv=SvSTASH(reference);
3679 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3681 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3682 if (image == (Image *) NULL)
3684 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3688 method=CompareAnyLayer;
3689 for (i=2; i < items; i+=2)
3691 attribute=(char *) SvPV(ST(i-1),na);
3697 if (LocaleCompare(attribute,"method") == 0)
3699 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3703 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3707 method=(LayerMethod) option;
3710 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3716 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3722 image=CompareImagesLayers(image,method,exception);
3723 if (image == (Image *) NULL)
3725 for ( ; image; image=image->next)
3727 AddImageToRegistry(sv,image);
3729 av_push(av,sv_bless(rv,hv));
3732 exception=DestroyExceptionInfo(exception);
3734 SvREFCNT_dec(perl_exception);
3738 InheritPerlException(exception,perl_exception);
3739 exception=DestroyExceptionInfo(exception);
3740 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3741 SvPOK_on(perl_exception);
3742 ST(0)=sv_2mortal(perl_exception);
3747 ###############################################################################
3755 ###############################################################################
3760 Image::Magick ref=NO_INIT
3766 PERL_UNUSED_VAR(ref);
3767 if (sv_isobject(ST(0)) == 0)
3768 croak("ReferenceIsNotMyType");
3769 reference=SvRV(ST(0));
3770 switch (SvTYPE(reference))
3775 message[MagickPathExtent];
3793 Array (AV *) reference
3795 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3796 XS_VERSION,reference);
3797 hv=gv_stashpv(PackageName, FALSE);
3800 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3804 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3806 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3807 DestroyPackageInfo(info);
3809 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3819 Blessed scalar = (Image *) SvIV(reference)
3821 image=INT2PTR(Image *,SvIV(reference));
3822 if (image != (Image *) NULL)
3823 DeleteImageFromRegistry(reference,image);
3832 ###############################################################################
3840 ###############################################################################
3845 Image::Magick ref=NO_INIT
3869 PERL_UNUSED_VAR(ref);
3870 PERL_UNUSED_VAR(ix);
3871 exception=AcquireExceptionInfo();
3872 perl_exception=newSVpv("",0);
3873 package_info=(struct PackageInfo *) NULL;
3874 if (sv_isobject(ST(0)) == 0)
3876 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3880 reference=SvRV(ST(0));
3881 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3882 if (image == (Image *) NULL)
3884 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3888 package_info=ClonePackageInfo(info,exception);
3890 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3893 for (i=2; i < items; i+=2)
3894 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3896 (void) DisplayImages(package_info->image_info,image,exception);
3897 (void) CatchImageException(image);
3900 if (package_info != (struct PackageInfo *) NULL)
3901 DestroyPackageInfo(package_info);
3902 InheritPerlException(exception,perl_exception);
3903 exception=DestroyExceptionInfo(exception);
3904 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3905 SvPOK_on(perl_exception);
3906 ST(0)=sv_2mortal(perl_exception);
3911 ###############################################################################
3915 # E v a l u a t e I m a g e s #
3919 ###############################################################################
3924 Image::Magick ref=NO_INIT
3946 MagickEvaluateOperator
3961 PERL_UNUSED_VAR(ref);
3962 PERL_UNUSED_VAR(ix);
3963 exception=AcquireExceptionInfo();
3964 perl_exception=newSVpv("",0);
3966 if (sv_isobject(ST(0)) == 0)
3968 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3972 reference=SvRV(ST(0));
3973 hv=SvSTASH(reference);
3974 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3975 if (image == (Image *) NULL)
3977 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3981 op=MeanEvaluateOperator;
3987 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3991 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3995 op=(MagickEvaluateOperator) in;
3998 for (i=2; i < items; i+=2)
4000 attribute=(char *) SvPV(ST(i-1),na);
4006 if (LocaleCompare(attribute,"operator") == 0)
4011 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4012 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4015 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4019 op=(MagickEvaluateOperator) in;
4022 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4028 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4034 image=EvaluateImages(image,op,exception);
4035 if (image == (Image *) NULL)
4038 Create blessed Perl array for the returned image.
4041 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4043 AddImageToRegistry(sv,image);
4045 av_push(av,sv_bless(rv,hv));
4047 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4048 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4049 "evaluate-%.*s",(int) (MagickPathExtent-9),
4050 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4051 (void) CopyMagickString(image->filename,info->image_info->filename,
4053 SetImageInfo(info->image_info,0,exception);
4054 exception=DestroyExceptionInfo(exception);
4055 SvREFCNT_dec(perl_exception);
4059 InheritPerlException(exception,perl_exception);
4060 exception=DestroyExceptionInfo(exception);
4061 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4062 SvPOK_on(perl_exception);
4063 ST(0)=sv_2mortal(perl_exception);
4068 ###############################################################################
4076 ###############################################################################
4081 Image::Magick ref=NO_INIT
4088 #define ChannelFeatures(channel,direction) \
4090 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4091 channel_features[channel].angular_second_moment[direction]); \
4092 PUSHs(sv_2mortal(newSVpv(message,0))); \
4093 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4094 channel_features[channel].contrast[direction]); \
4095 PUSHs(sv_2mortal(newSVpv(message,0))); \
4096 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4097 channel_features[channel].contrast[direction]); \
4098 PUSHs(sv_2mortal(newSVpv(message,0))); \
4099 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4100 channel_features[channel].variance_sum_of_squares[direction]); \
4101 PUSHs(sv_2mortal(newSVpv(message,0))); \
4102 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4103 channel_features[channel].inverse_difference_moment[direction]); \
4104 PUSHs(sv_2mortal(newSVpv(message,0))); \
4105 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4106 channel_features[channel].sum_average[direction]); \
4107 PUSHs(sv_2mortal(newSVpv(message,0))); \
4108 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4109 channel_features[channel].sum_variance[direction]); \
4110 PUSHs(sv_2mortal(newSVpv(message,0))); \
4111 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4112 channel_features[channel].sum_entropy[direction]); \
4113 PUSHs(sv_2mortal(newSVpv(message,0))); \
4114 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4115 channel_features[channel].entropy[direction]); \
4116 PUSHs(sv_2mortal(newSVpv(message,0))); \
4117 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4118 channel_features[channel].difference_variance[direction]); \
4119 PUSHs(sv_2mortal(newSVpv(message,0))); \
4120 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4121 channel_features[channel].difference_entropy[direction]); \
4122 PUSHs(sv_2mortal(newSVpv(message,0))); \
4123 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4124 channel_features[channel].measure_of_correlation_1[direction]); \
4125 PUSHs(sv_2mortal(newSVpv(message,0))); \
4126 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4127 channel_features[channel].measure_of_correlation_2[direction]); \
4128 PUSHs(sv_2mortal(newSVpv(message,0))); \
4129 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4130 channel_features[channel].maximum_correlation_coefficient[direction]); \
4131 PUSHs(sv_2mortal(newSVpv(message,0))); \
4139 message[MagickPathExtent];
4166 PERL_UNUSED_VAR(ref);
4167 PERL_UNUSED_VAR(ix);
4168 exception=AcquireExceptionInfo();
4169 perl_exception=newSVpv("",0);
4171 if (sv_isobject(ST(0)) == 0)
4173 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4177 reference=SvRV(ST(0));
4180 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4181 if (image == (Image *) NULL)
4183 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4188 for (i=2; i < items; i+=2)
4190 attribute=(char *) SvPV(ST(i-1),na);
4196 if (LocaleCompare(attribute,"distance") == 0)
4198 distance=StringToLong((char *) SvPV(ST(1),na));
4201 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4207 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4214 for ( ; image; image=image->next)
4216 channel_features=GetImageFeatures(image,distance,exception);
4217 if (channel_features == (ChannelFeatures *) NULL)
4220 EXTEND(sp,280*count);
4221 for (i=0; i < 4; i++)
4223 ChannelFeatures(RedChannel,i);
4224 ChannelFeatures(GreenChannel,i);
4225 ChannelFeatures(BlueChannel,i);
4226 if (image->colorspace == CMYKColorspace)
4227 ChannelFeatures(BlackChannel,i);
4228 if (image->alpha_trait != UndefinedPixelTrait)
4229 ChannelFeatures(AlphaChannel,i);
4231 channel_features=(ChannelFeatures *)
4232 RelinquishMagickMemory(channel_features);
4236 InheritPerlException(exception,perl_exception);
4237 exception=DestroyExceptionInfo(exception);
4238 SvREFCNT_dec(perl_exception);
4242 ###############################################################################
4250 ###############################################################################
4255 Image::Magick ref=NO_INIT
4293 PERL_UNUSED_VAR(ref);
4294 PERL_UNUSED_VAR(ix);
4295 exception=AcquireExceptionInfo();
4296 perl_exception=newSVpv("",0);
4298 if (sv_isobject(ST(0)) == 0)
4300 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4304 reference=SvRV(ST(0));
4305 hv=SvSTASH(reference);
4306 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4307 if (image == (Image *) NULL)
4309 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4313 background_color=image->background_color;
4315 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4316 &background_color,exception);
4318 for (i=2; i < items; i+=2)
4320 attribute=(char *) SvPV(ST(i-1),na);
4326 if (LocaleCompare(attribute,"background") == 0)
4328 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4329 AllCompliance,&background_color,exception);
4332 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4344 image->background_color=background_color;
4345 image=MergeImageLayers(image,FlattenLayer,exception);
4346 if (image == (Image *) NULL)
4349 Create blessed Perl array for the returned image.
4352 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4354 AddImageToRegistry(sv,image);
4356 av_push(av,sv_bless(rv,hv));
4358 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4359 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4360 "flatten-%.*s",(int) (MagickPathExtent-9),
4361 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4362 (void) CopyMagickString(image->filename,info->image_info->filename,
4364 SetImageInfo(info->image_info,0,exception);
4365 exception=DestroyExceptionInfo(exception);
4366 SvREFCNT_dec(perl_exception);
4370 InheritPerlException(exception,perl_exception);
4371 exception=DestroyExceptionInfo(exception);
4372 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4373 SvPOK_on(perl_exception); /* return messages in string context */
4374 ST(0)=sv_2mortal(perl_exception);
4379 ###############################################################################
4387 ###############################################################################
4392 Image::Magick ref=NO_INIT
4404 expression[MagickPathExtent];
4432 PERL_UNUSED_VAR(ref);
4433 PERL_UNUSED_VAR(ix);
4434 exception=AcquireExceptionInfo();
4435 perl_exception=newSVpv("",0);
4439 if (sv_isobject(ST(0)) == 0)
4441 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4445 reference=SvRV(ST(0));
4446 hv=SvSTASH(reference);
4448 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4450 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4451 if (image == (Image *) NULL)
4453 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4457 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4461 channel=DefaultChannels;
4462 (void) CopyMagickString(expression,"u",MagickPathExtent);
4464 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4466 for (i=2; i < items; i+=2)
4468 attribute=(char *) SvPV(ST(i-1),na);
4474 if (LocaleCompare(attribute,"channel") == 0)
4479 option=ParseChannelOption(SvPV(ST(i),na));
4482 ThrowPerlException(exception,OptionError,
4483 "UnrecognizedType",SvPV(ST(i),na));
4486 channel=(ChannelType) option;
4489 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4496 if (LocaleCompare(attribute,"expression") == 0)
4498 (void) CopyMagickString(expression,SvPV(ST(i),na),
4502 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4508 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4514 channel_mask=SetImageChannelMask(image,channel);
4515 image=FxImage(image,expression,exception);
4516 if (image != (Image *) NULL)
4517 (void) SetImageChannelMask(image,channel_mask);
4518 if (image == (Image *) NULL)
4520 for ( ; image; image=image->next)
4522 AddImageToRegistry(sv,image);
4524 av_push(av,sv_bless(rv,hv));
4527 exception=DestroyExceptionInfo(exception);
4529 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4533 InheritPerlException(exception,perl_exception);
4534 exception=DestroyExceptionInfo(exception);
4535 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4536 SvPOK_on(perl_exception);
4537 ST(0)=sv_2mortal(perl_exception);
4542 ###############################################################################
4550 ###############################################################################
4555 Image::Magick ref=NO_INIT
4566 color[MagickPathExtent];
4591 PERL_UNUSED_VAR(ref);
4592 PERL_UNUSED_VAR(ix);
4593 exception=AcquireExceptionInfo();
4594 perl_exception=newSVpv("",0);
4595 if (sv_isobject(ST(0)) == 0)
4597 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4601 reference=SvRV(ST(0));
4602 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4603 if (image == (Image *) NULL && !info)
4606 for (i=1; i < items; i++)
4608 attribute=(char *) SvPV(ST(i),na);
4615 if (LocaleCompare(attribute,"adjoin") == 0)
4618 s=newSViv((ssize_t) info->image_info->adjoin);
4619 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4622 if (LocaleCompare(attribute,"antialias") == 0)
4625 s=newSViv((ssize_t) info->image_info->antialias);
4626 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4629 if (LocaleCompare(attribute,"area") == 0)
4631 s=newSViv(GetMagickResource(AreaResource));
4632 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4635 if (LocaleCompare(attribute,"attenuate") == 0)
4640 value=GetImageProperty(image,attribute,exception);
4641 if (value != (const char *) NULL)
4643 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4646 if (LocaleCompare(attribute,"authenticate") == 0)
4653 option=GetImageOption(info->image_info,attribute);
4654 if (option != (const char *) NULL)
4655 s=newSVpv(option,0);
4657 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4660 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4667 if (LocaleCompare(attribute,"background") == 0)
4669 if (image == (Image *) NULL)
4671 (void) FormatLocaleString(color,MagickPathExtent,
4672 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4673 (double) image->background_color.green,
4674 (double) image->background_color.blue,
4675 (double) image->background_color.alpha);
4677 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4680 if (LocaleCompare(attribute,"base-columns") == 0)
4682 if (image != (Image *) NULL)
4683 s=newSViv((ssize_t) image->magick_columns);
4684 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4687 if (LocaleCompare(attribute,"base-filename") == 0)
4689 if (image != (Image *) NULL)
4690 s=newSVpv(image->magick_filename,0);
4691 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4694 if (LocaleCompare(attribute,"base-height") == 0)
4696 if (image != (Image *) NULL)
4697 s=newSViv((ssize_t) image->magick_rows);
4698 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4701 if (LocaleCompare(attribute,"base-rows") == 0)
4703 if (image != (Image *) NULL)
4704 s=newSViv((ssize_t) image->magick_rows);
4705 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4708 if (LocaleCompare(attribute,"base-width") == 0)
4710 if (image != (Image *) NULL)
4711 s=newSViv((ssize_t) image->magick_columns);
4712 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4715 if (LocaleCompare(attribute,"blue-primary") == 0)
4717 if (image == (Image *) NULL)
4719 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
4720 image->chromaticity.blue_primary.x,
4721 image->chromaticity.blue_primary.y);
4723 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4726 if (LocaleCompare(attribute,"bordercolor") == 0)
4728 if (image == (Image *) NULL)
4730 (void) FormatLocaleString(color,MagickPathExtent,
4731 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4732 (double) image->border_color.green,
4733 (double) image->border_color.blue,
4734 (double) image->border_color.alpha);
4736 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4739 if (LocaleCompare(attribute,"bounding-box") == 0)
4742 geometry[MagickPathExtent];
4747 if (image == (Image *) NULL)
4749 page=GetImageBoundingBox(image,exception);
4750 (void) FormatLocaleString(geometry,MagickPathExtent,
4751 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4752 page.height,(double) page.x,(double) page.y);
4753 s=newSVpv(geometry,0);
4754 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4757 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4764 if (LocaleCompare(attribute,"class") == 0)
4766 if (image == (Image *) NULL)
4768 s=newSViv(image->storage_class);
4769 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4770 image->storage_class));
4772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4775 if (LocaleCompare(attribute,"clip-mask") == 0)
4777 if (image != (Image *) NULL)
4786 if (image->read_mask == MagickFalse)
4787 ClipImage(image,exception);
4788 mask_image=GetImageMask(image,ReadPixelMask,exception);
4789 if (mask_image != (Image *) NULL)
4791 AddImageToRegistry(sv,mask_image);
4792 s=sv_bless(newRV(sv),SvSTASH(reference));
4795 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4798 if (LocaleCompare(attribute,"clip-path") == 0)
4800 if (image != (Image *) NULL)
4809 if (image->read_mask != MagickFalse)
4810 ClipImage(image,exception);
4811 mask_image=GetImageMask(image,ReadPixelMask,exception);
4812 if (mask_image != (Image *) NULL)
4814 AddImageToRegistry(sv,mask_image);
4815 s=sv_bless(newRV(sv),SvSTASH(reference));
4818 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4821 if (LocaleCompare(attribute,"compression") == 0)
4823 j=info ? info->image_info->compression : image ?
4824 image->compression : UndefinedCompression;
4826 if (info->image_info->compression == UndefinedCompression)
4827 j=image->compression;
4829 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4832 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4835 if (LocaleCompare(attribute,"colorspace") == 0)
4837 j=image ? image->colorspace : RGBColorspace;
4839 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4842 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4845 if (LocaleCompare(attribute,"colors") == 0)
4847 if (image != (Image *) NULL)
4848 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4850 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4853 if (LocaleNCompare(attribute,"colormap",8) == 0)
4858 if (image == (Image *) NULL || !image->colormap)
4861 items=sscanf(attribute,"%*[^[][%ld",&j);
4863 if (j > (ssize_t) image->colors)
4865 (void) FormatLocaleString(color,MagickPathExtent,
4866 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4867 (double) image->colormap[j].green,
4868 (double) image->colormap[j].blue,
4869 (double) image->colormap[j].alpha);
4871 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4874 if (LocaleCompare(attribute,"columns") == 0)
4876 if (image != (Image *) NULL)
4877 s=newSViv((ssize_t) image->columns);
4878 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4881 if (LocaleCompare(attribute,"comment") == 0)
4886 value=GetImageProperty(image,attribute,exception);
4887 if (value != (const char *) NULL)
4889 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4892 if (LocaleCompare(attribute,"copyright") == 0)
4894 s=newSVpv(GetMagickCopyright(),0);
4895 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4898 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4905 if (LocaleCompare(attribute,"density") == 0)
4908 geometry[MagickPathExtent];
4910 if (image == (Image *) NULL)
4912 (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g",
4913 image->resolution.x,image->resolution.y);
4914 s=newSVpv(geometry,0);
4915 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4918 if (LocaleCompare(attribute,"delay") == 0)
4920 if (image != (Image *) NULL)
4921 s=newSViv((ssize_t) image->delay);
4922 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4925 if (LocaleCompare(attribute,"depth") == 0)
4927 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4928 if (image != (Image *) NULL)
4929 s=newSViv((ssize_t) GetImageDepth(image,exception));
4930 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4933 if (LocaleCompare(attribute,"directory") == 0)
4935 if (image && image->directory)
4936 s=newSVpv(image->directory,0);
4937 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4940 if (LocaleCompare(attribute,"dispose") == 0)
4942 if (image == (Image *) NULL)
4945 s=newSViv(image->dispose);
4947 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4949 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4952 if (LocaleCompare(attribute,"disk") == 0)
4954 s=newSViv(GetMagickResource(DiskResource));
4955 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4958 if (LocaleCompare(attribute,"dither") == 0)
4961 s=newSViv((ssize_t) info->image_info->dither);
4962 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4965 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4967 if (info && info->image_info->server_name)
4968 s=newSVpv(info->image_info->server_name,0);
4969 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4972 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4979 if (LocaleCompare(attribute,"elapsed-time") == 0)
4981 if (image != (Image *) NULL)
4982 s=newSVnv(GetElapsedTime(&image->timer));
4983 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4986 if (LocaleCompare(attribute,"endian") == 0)
4988 j=info ? info->image_info->endian : image ? image->endian :
4991 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4993 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4996 if (LocaleCompare(attribute,"error") == 0)
4998 if (image != (Image *) NULL)
4999 s=newSVnv(image->error.mean_error_per_pixel);
5000 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5003 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5010 if (LocaleCompare(attribute,"filesize") == 0)
5012 if (image != (Image *) NULL)
5013 s=newSViv((ssize_t) GetBlobSize(image));
5014 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5017 if (LocaleCompare(attribute,"filename") == 0)
5019 if (info && info->image_info->filename &&
5020 *info->image_info->filename)
5021 s=newSVpv(info->image_info->filename,0);
5022 if (image != (Image *) NULL)
5023 s=newSVpv(image->filename,0);
5024 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5027 if (LocaleCompare(attribute,"filter") == 0)
5029 s=image ? newSViv(image->filter) : newSViv(0);
5030 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5033 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5036 if (LocaleCompare(attribute,"font") == 0)
5038 if (info && info->image_info->font)
5039 s=newSVpv(info->image_info->font,0);
5040 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5043 if (LocaleCompare(attribute,"foreground") == 0)
5045 if (LocaleCompare(attribute,"format") == 0)
5050 magick_info=(const MagickInfo *) NULL;
5051 if (info && (*info->image_info->magick != '\0'))
5052 magick_info=GetMagickInfo(info->image_info->magick,exception);
5053 if (image != (Image *) NULL)
5054 magick_info=GetMagickInfo(image->magick,exception);
5055 if ((magick_info != (const MagickInfo *) NULL) &&
5056 (*magick_info->description != '\0'))
5057 s=newSVpv((char *) magick_info->description,0);
5058 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5061 if (LocaleCompare(attribute,"fuzz") == 0)
5064 s=newSVnv(info->image_info->fuzz);
5065 if (image != (Image *) NULL)
5066 s=newSVnv(image->fuzz);
5067 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5070 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5077 if (LocaleCompare(attribute,"gamma") == 0)
5079 if (image != (Image *) NULL)
5080 s=newSVnv(image->gamma);
5081 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5084 if (LocaleCompare(attribute,"geometry") == 0)
5086 if (image && image->geometry)
5087 s=newSVpv(image->geometry,0);
5088 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5091 if (LocaleCompare(attribute,"gravity") == 0)
5093 s=image ? newSViv(image->gravity) : newSViv(0);
5094 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5097 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5100 if (LocaleCompare(attribute,"green-primary") == 0)
5102 if (image == (Image *) NULL)
5104 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5105 image->chromaticity.green_primary.x,
5106 image->chromaticity.green_primary.y);
5108 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5111 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5118 if (LocaleCompare(attribute,"height") == 0)
5120 if (image != (Image *) NULL)
5121 s=newSViv((ssize_t) image->rows);
5122 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5125 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5132 if (LocaleCompare(attribute,"icc") == 0)
5134 if (image != (Image *) NULL)
5139 profile=GetImageProfile(image,"icc");
5140 if (profile != (StringInfo *) NULL)
5141 s=newSVpv((const char *) GetStringInfoDatum(profile),
5142 GetStringInfoLength(profile));
5144 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5147 if (LocaleCompare(attribute,"icm") == 0)
5149 if (image != (Image *) NULL)
5154 profile=GetImageProfile(image,"icm");
5155 if (profile != (const StringInfo *) NULL)
5156 s=newSVpv((const char *) GetStringInfoDatum(profile),
5157 GetStringInfoLength(profile));
5159 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5162 if (LocaleCompare(attribute,"id") == 0)
5164 if (image != (Image *) NULL)
5167 key[MagickPathExtent];
5175 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5177 status=SetImageRegistry(ImageRegistryType,key,image,
5182 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5185 if (LocaleNCompare(attribute,"index",5) == 0)
5188 name[MagickPathExtent];
5197 register const Quantum
5203 if (image == (Image *) NULL)
5205 if (image->storage_class != PseudoClass)
5209 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5211 image_view=AcquireVirtualCacheView(image,exception);
5212 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5213 if (p != (const Quantum *) NULL)
5215 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5216 GetPixelIndex(image,p));
5218 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5220 image_view=DestroyCacheView(image_view);
5223 if (LocaleCompare(attribute,"iptc") == 0)
5225 if (image != (Image *) NULL)
5230 profile=GetImageProfile(image,"iptc");
5231 if (profile != (const StringInfo *) NULL)
5232 s=newSVpv((const char *) GetStringInfoDatum(profile),
5233 GetStringInfoLength(profile));
5235 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5238 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5240 if (image != (Image *) NULL)
5241 s=newSViv((ssize_t) image->iterations);
5242 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5245 if (LocaleCompare(attribute,"interlace") == 0)
5247 j=info ? info->image_info->interlace : image ? image->interlace :
5250 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5253 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5256 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5263 if (LocaleCompare(attribute,"label") == 0)
5268 if (image == (Image *) NULL)
5270 value=GetImageProperty(image,"Label",exception);
5271 if (value != (const char *) NULL)
5273 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5276 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5278 if (image != (Image *) NULL)
5279 s=newSViv((ssize_t) image->iterations);
5280 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5283 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5290 if (LocaleCompare(attribute,"magick") == 0)
5292 if (info && *info->image_info->magick)
5293 s=newSVpv(info->image_info->magick,0);
5294 if (image != (Image *) NULL)
5295 s=newSVpv(image->magick,0);
5296 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5299 if (LocaleCompare(attribute,"map") == 0)
5301 s=newSViv(GetMagickResource(MapResource));
5302 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5305 if (LocaleCompare(attribute,"maximum-error") == 0)
5307 if (image != (Image *) NULL)
5308 s=newSVnv(image->error.normalized_maximum_error);
5309 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5312 if (LocaleCompare(attribute,"memory") == 0)
5314 s=newSViv(GetMagickResource(MemoryResource));
5315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5318 if (LocaleCompare(attribute,"mean-error") == 0)
5320 if (image != (Image *) NULL)
5321 s=newSVnv(image->error.normalized_mean_error);
5322 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5325 if (LocaleCompare(attribute,"mime") == 0)
5327 if (info && *info->image_info->magick)
5328 s=newSVpv(MagickToMime(info->image_info->magick),0);
5329 if (image != (Image *) NULL)
5330 s=newSVpv(MagickToMime(image->magick),0);
5331 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5334 if (LocaleCompare(attribute,"mattecolor") == 0)
5336 if (image == (Image *) NULL)
5338 (void) FormatLocaleString(color,MagickPathExtent,
5339 "%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red,
5340 (double) image->alpha_color.green,
5341 (double) image->alpha_color.blue,
5342 (double) image->alpha_color.alpha);
5344 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5347 if (LocaleCompare(attribute,"matte") == 0)
5349 if (image != (Image *) NULL)
5350 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5352 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5355 if (LocaleCompare(attribute,"mime") == 0)
5361 if (info && *info->image_info->magick)
5362 magick=info->image_info->magick;
5363 if (image != (Image *) NULL)
5364 magick=image->magick;
5370 mime=MagickToMime(magick);
5372 mime=(char *) RelinquishMagickMemory(mime);
5374 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5377 if (LocaleCompare(attribute,"monochrome") == 0)
5379 if (image == (Image *) NULL)
5381 j=info ? info->image_info->monochrome :
5382 SetImageMonochrome(image,exception);
5384 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5387 if (LocaleCompare(attribute,"montage") == 0)
5389 if (image && image->montage)
5390 s=newSVpv(image->montage,0);
5391 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5401 if (LocaleCompare(attribute,"orientation") == 0)
5403 j=info ? info->image_info->orientation : image ?
5404 image->orientation : UndefinedOrientation;
5406 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5409 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5412 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5419 if (LocaleCompare(attribute,"page") == 0)
5421 if (info && info->image_info->page)
5422 s=newSVpv(info->image_info->page,0);
5423 if (image != (Image *) NULL)
5426 geometry[MagickPathExtent];
5428 (void) FormatLocaleString(geometry,MagickPathExtent,
5429 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5430 (double) image->page.height,(double) image->page.x,(double)
5432 s=newSVpv(geometry,0);
5434 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5437 if (LocaleCompare(attribute,"page.x") == 0)
5439 if (image != (Image *) NULL)
5440 s=newSViv((ssize_t) image->page.x);
5441 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5444 if (LocaleCompare(attribute,"page.y") == 0)
5446 if (image != (Image *) NULL)
5447 s=newSViv((ssize_t) image->page.y);
5448 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5451 if (LocaleNCompare(attribute,"pixel",5) == 0)
5454 tuple[MagickPathExtent];
5463 register const Quantum
5466 if (image == (Image *) NULL)
5470 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5472 p=GetVirtualPixels(image,x,y,1,1,exception);
5473 if (image->colorspace != CMYKColorspace)
5474 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5475 QuantumFormat "," QuantumFormat "," QuantumFormat,
5476 GetPixelRed(image,p),GetPixelGreen(image,p),
5477 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5479 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5480 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5481 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5482 GetPixelBlue(image,p),GetPixelBlack(image,p),
5483 GetPixelAlpha(image,p));
5485 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5488 if (LocaleCompare(attribute,"pointsize") == 0)
5491 s=newSViv((ssize_t) info->image_info->pointsize);
5492 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5495 if (LocaleCompare(attribute,"preview") == 0)
5497 s=newSViv(info->image_info->preview_type);
5498 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5499 info->image_info->preview_type));
5501 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5504 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5511 if (LocaleCompare(attribute,"quality") == 0)
5514 s=newSViv((ssize_t) info->image_info->quality);
5515 if (image != (Image *) NULL)
5516 s=newSViv((ssize_t) image->quality);
5517 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5520 if (LocaleCompare(attribute,"quantum") == 0)
5523 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5524 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5527 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5534 if (LocaleCompare(attribute,"rendering-intent") == 0)
5536 s=newSViv(image->rendering_intent);
5537 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5538 image->rendering_intent));
5540 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5543 if (LocaleCompare(attribute,"red-primary") == 0)
5545 if (image == (Image *) NULL)
5547 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5548 image->chromaticity.red_primary.x,
5549 image->chromaticity.red_primary.y);
5551 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5554 if (LocaleCompare(attribute,"rows") == 0)
5556 if (image != (Image *) NULL)
5557 s=newSViv((ssize_t) image->rows);
5558 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5561 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5568 if (LocaleCompare(attribute,"sampling-factor") == 0)
5570 if (info && info->image_info->sampling_factor)
5571 s=newSVpv(info->image_info->sampling_factor,0);
5572 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5575 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5577 if (info && info->image_info->server_name)
5578 s=newSVpv(info->image_info->server_name,0);
5579 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5582 if (LocaleCompare(attribute,"size") == 0)
5584 if (info && info->image_info->size)
5585 s=newSVpv(info->image_info->size,0);
5586 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5589 if (LocaleCompare(attribute,"scene") == 0)
5591 if (image != (Image *) NULL)
5592 s=newSViv((ssize_t) image->scene);
5593 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5596 if (LocaleCompare(attribute,"scenes") == 0)
5598 if (image != (Image *) NULL)
5599 s=newSViv((ssize_t) info->image_info->number_scenes);
5600 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5603 if (LocaleCompare(attribute,"signature") == 0)
5608 if (image == (Image *) NULL)
5610 (void) SignatureImage(image,exception);
5611 value=GetImageProperty(image,"Signature",exception);
5612 if (value != (const char *) NULL)
5614 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5617 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5624 if (LocaleCompare(attribute,"taint") == 0)
5626 if (image != (Image *) NULL)
5627 s=newSViv((ssize_t) IsTaintImage(image));
5628 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5631 if (LocaleCompare(attribute,"texture") == 0)
5633 if (info && info->image_info->texture)
5634 s=newSVpv(info->image_info->texture,0);
5635 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5638 if (LocaleCompare(attribute,"total-ink-density") == 0)
5640 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5641 if (image != (Image *) NULL)
5642 s=newSVnv(GetImageTotalInkDensity(image,exception));
5643 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5646 if (LocaleCompare(attribute,"transparent-color") == 0)
5648 if (image == (Image *) NULL)
5650 (void) FormatLocaleString(color,MagickPathExtent,
5651 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5652 (double) image->transparent_color.green,
5653 (double) image->transparent_color.blue,
5654 (double) image->transparent_color.alpha);
5656 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5659 if (LocaleCompare(attribute,"type") == 0)
5661 if (image == (Image *) NULL)
5663 j=(ssize_t) GetImageType(image);
5665 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5667 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5670 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5677 if (LocaleCompare(attribute,"units") == 0)
5679 j=info ? info->image_info->units : image ? image->units :
5680 UndefinedResolution;
5681 if (info && (info->image_info->units == UndefinedResolution))
5684 if (j == UndefinedResolution)
5685 s=newSVpv("undefined units",0);
5687 if (j == PixelsPerInchResolution)
5688 s=newSVpv("pixels / inch",0);
5690 s=newSVpv("pixels / centimeter",0);
5691 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5694 if (LocaleCompare(attribute,"user-time") == 0)
5696 if (image != (Image *) NULL)
5697 s=newSVnv(GetUserTime(&image->timer));
5698 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5708 if (LocaleCompare(attribute,"verbose") == 0)
5711 s=newSViv((ssize_t) info->image_info->verbose);
5712 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5715 if (LocaleCompare(attribute,"version") == 0)
5717 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5721 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5723 if (image == (Image *) NULL)
5725 j=(ssize_t) GetImageVirtualPixelMethod(image);
5727 (void) sv_setpv(s,CommandOptionToMnemonic(
5728 MagickVirtualPixelOptions,j));
5730 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5733 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5740 if (LocaleCompare(attribute,"white-point") == 0)
5742 if (image == (Image *) NULL)
5744 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5745 image->chromaticity.white_point.x,
5746 image->chromaticity.white_point.y);
5748 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5751 if (LocaleCompare(attribute,"width") == 0)
5753 if (image != (Image *) NULL)
5754 s=newSViv((ssize_t) image->columns);
5755 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5758 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5765 if (LocaleCompare(attribute,"xmp") == 0)
5767 if (image != (Image *) NULL)
5772 profile=GetImageProfile(image,"xmp");
5773 if (profile != (StringInfo *) NULL)
5774 s=newSVpv((const char *) GetStringInfoDatum(profile),
5775 GetStringInfoLength(profile));
5777 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5780 if (LocaleCompare(attribute,"x-resolution") == 0)
5782 if (image != (Image *) NULL)
5783 s=newSVnv(image->resolution.x);
5784 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5787 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5794 if (LocaleCompare(attribute,"y-resolution") == 0)
5796 if (image != (Image *) NULL)
5797 s=newSVnv(image->resolution.y);
5798 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5801 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5808 if (image == (Image *) NULL)
5809 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5813 value=GetImageProperty(image,attribute,exception);
5814 if (value != (const char *) NULL)
5817 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5820 if (*attribute != '%')
5821 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5828 meta=InterpretImageProperties(info ? info->image_info :
5829 (ImageInfo *) NULL,image,attribute,exception);
5831 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5832 meta=(char *) RelinquishMagickMemory(meta);
5836 exception=DestroyExceptionInfo(exception);
5837 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5841 ###############################################################################
5845 # G e t A u t h e n t i c P i x e l s #
5849 ###############################################################################
5853 GetAuthenticPixels(ref,...)
5854 Image::Magick ref = NO_INIT
5856 getauthenticpixels = 1
5886 PERL_UNUSED_VAR(ref);
5887 PERL_UNUSED_VAR(ix);
5888 exception=AcquireExceptionInfo();
5889 perl_exception=newSVpv("",0);
5890 if (sv_isobject(ST(0)) == 0)
5892 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5896 reference=SvRV(ST(0));
5898 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5899 if (image == (Image *) NULL)
5901 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5908 region.width=image->columns;
5911 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5912 for (i=2; i < items; i+=2)
5914 attribute=(char *) SvPV(ST(i-1),na);
5920 if (LocaleCompare(attribute,"geometry") == 0)
5922 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5925 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5932 if (LocaleCompare(attribute,"height") == 0)
5934 region.height=SvIV(ST(i));
5937 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5944 if (LocaleCompare(attribute,"x") == 0)
5946 region.x=SvIV(ST(i));
5949 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5956 if (LocaleCompare(attribute,"y") == 0)
5958 region.y=SvIV(ST(i));
5961 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5968 if (LocaleCompare(attribute,"width") == 0)
5970 region.width=SvIV(ST(i));
5973 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5979 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5980 region.height,exception);
5981 if (blob != (void *) NULL)
5985 InheritPerlException(exception,perl_exception);
5986 exception=DestroyExceptionInfo(exception);
5987 SvREFCNT_dec(perl_exception); /* throw away all errors */
5996 ###############################################################################
6000 # G e t V i r t u a l P i x e l s #
6004 ###############################################################################
6008 GetVirtualPixels(ref,...)
6009 Image::Magick ref = NO_INIT
6011 getvirtualpixels = 1
6012 AcquireImagePixels = 2
6013 acquireimagepixels = 3
6041 PERL_UNUSED_VAR(ref);
6042 PERL_UNUSED_VAR(ix);
6043 exception=AcquireExceptionInfo();
6044 perl_exception=newSVpv("",0);
6045 if (sv_isobject(ST(0)) == 0)
6047 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6051 reference=SvRV(ST(0));
6053 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6054 if (image == (Image *) NULL)
6056 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6063 region.width=image->columns;
6066 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6067 for (i=2; i < items; i+=2)
6069 attribute=(char *) SvPV(ST(i-1),na);
6075 if (LocaleCompare(attribute,"geometry") == 0)
6077 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6080 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6087 if (LocaleCompare(attribute,"height") == 0)
6089 region.height=SvIV(ST(i));
6092 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6099 if (LocaleCompare(attribute,"x") == 0)
6101 region.x=SvIV(ST(i));
6104 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6111 if (LocaleCompare(attribute,"y") == 0)
6113 region.y=SvIV(ST(i));
6116 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6123 if (LocaleCompare(attribute,"width") == 0)
6125 region.width=SvIV(ST(i));
6128 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6134 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6135 region.height,exception);
6136 if (blob != (void *) NULL)
6140 InheritPerlException(exception,perl_exception);
6141 exception=DestroyExceptionInfo(exception);
6142 SvREFCNT_dec(perl_exception); /* throw away all errors */
6145 RETVAL = (void *) blob;
6151 ###############################################################################
6155 # G e t A u t h e n t i c M e t a c o n t e n t #
6159 ###############################################################################
6163 GetAuthenticMetacontent(ref,...)
6164 Image::Magick ref = NO_INIT
6166 getauthenticmetacontent = 1
6187 PERL_UNUSED_VAR(ref);
6188 PERL_UNUSED_VAR(ix);
6189 exception=AcquireExceptionInfo();
6190 perl_exception=newSVpv("",0);
6191 if (sv_isobject(ST(0)) == 0)
6193 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6197 reference=SvRV(ST(0));
6199 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6200 if (image == (Image *) NULL)
6202 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6207 blob=(void *) GetAuthenticMetacontent(image);
6208 if (blob != (void *) NULL)
6212 InheritPerlException(exception,perl_exception);
6213 exception=DestroyExceptionInfo(exception);
6214 SvREFCNT_dec(perl_exception); /* throw away all errors */
6223 ###############################################################################
6227 # G e t V i r t u a l M e t a c o n t e n t #
6231 ###############################################################################
6235 GetVirtualMetacontent(ref,...)
6236 Image::Magick ref = NO_INIT
6238 getvirtualmetacontent = 1
6257 PERL_UNUSED_VAR(ref);
6258 PERL_UNUSED_VAR(ix);
6259 exception=AcquireExceptionInfo();
6260 perl_exception=newSVpv("",0);
6261 if (sv_isobject(ST(0)) == 0)
6263 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6267 reference=SvRV(ST(0));
6269 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6270 if (image == (Image *) NULL)
6272 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6277 blob=(void *) GetVirtualMetacontent(image);
6278 if (blob != (void *) NULL)
6282 InheritPerlException(exception,perl_exception);
6283 exception=DestroyExceptionInfo(exception);
6284 SvREFCNT_dec(perl_exception); /* throw away all errors */
6293 ###############################################################################
6297 # H i s t o g r a m #
6301 ###############################################################################
6306 Image::Magick ref=NO_INIT
6317 message[MagickPathExtent];
6344 PERL_UNUSED_VAR(ref);
6345 PERL_UNUSED_VAR(ix);
6346 exception=AcquireExceptionInfo();
6347 perl_exception=newSVpv("",0);
6349 if (sv_isobject(ST(0)) == 0)
6351 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6355 reference=SvRV(ST(0));
6358 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6359 if (image == (Image *) NULL)
6361 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6366 for ( ; image; image=image->next)
6368 histogram=GetImageHistogram(image,&number_colors,exception);
6369 if (histogram == (PixelInfo *) NULL)
6371 count+=(ssize_t) number_colors;
6373 for (i=0; i < (ssize_t) number_colors; i++)
6375 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6377 PUSHs(sv_2mortal(newSVpv(message,0)));
6378 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6379 histogram[i].green);
6380 PUSHs(sv_2mortal(newSVpv(message,0)));
6381 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6383 PUSHs(sv_2mortal(newSVpv(message,0)));
6384 if (image->colorspace == CMYKColorspace)
6386 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6387 histogram[i].black);
6388 PUSHs(sv_2mortal(newSVpv(message,0)));
6390 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6391 histogram[i].alpha);
6392 PUSHs(sv_2mortal(newSVpv(message,0)));
6393 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6394 histogram[i].count);
6395 PUSHs(sv_2mortal(newSVpv(message,0)));
6397 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6401 InheritPerlException(exception,perl_exception);
6402 exception=DestroyExceptionInfo(exception);
6403 SvREFCNT_dec(perl_exception);
6407 ###############################################################################
6415 ###############################################################################
6420 Image::Magick ref=NO_INIT
6444 register const Quantum
6458 *reference; /* reference is the SV* of ref=SvIV(reference) */
6460 PERL_UNUSED_VAR(ref);
6461 PERL_UNUSED_VAR(ix);
6462 exception=AcquireExceptionInfo();
6463 perl_exception=newSVpv("",0);
6464 reference=SvRV(ST(0));
6465 av=(AV *) reference;
6466 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6468 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6469 if (image == (Image *) NULL)
6471 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6475 normalize=MagickTrue;
6478 region.width=image->columns;
6481 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6482 for (i=2; i < items; i+=2)
6484 attribute=(char *) SvPV(ST(i-1),na);
6490 if (LocaleCompare(attribute,"channel") == 0)
6495 option=ParseChannelOption(SvPV(ST(i),na));
6498 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6502 (void) SetPixelChannelMask(image,(ChannelType) option);
6505 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6512 if (LocaleCompare(attribute,"geometry") == 0)
6514 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6517 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6524 if (LocaleCompare(attribute,"normalize") == 0)
6526 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6530 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6534 normalize=option != 0 ? MagickTrue : MagickFalse;
6537 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6544 if (LocaleCompare(attribute,"x") == 0)
6546 region.x=SvIV(ST(i));
6549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6556 if (LocaleCompare(attribute,"y") == 0)
6558 region.y=SvIV(ST(i));
6561 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6567 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6573 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6574 if (p == (const Quantum *) NULL)
6582 if (normalize != MagickFalse)
6583 scale=1.0/QuantumRange;
6584 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6585 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6586 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6587 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6588 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6589 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6590 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6591 (image->colorspace == CMYKColorspace))
6592 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6593 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6594 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6598 InheritPerlException(exception,perl_exception);
6599 exception=DestroyExceptionInfo(exception);
6600 SvREFCNT_dec(perl_exception);
6604 ###############################################################################
6608 # G e t P i x e l s #
6612 ###############################################################################
6617 Image::Magick ref=NO_INIT
6656 *reference; /* reference is the SV* of ref=SvIV(reference) */
6658 PERL_UNUSED_VAR(ref);
6659 PERL_UNUSED_VAR(ix);
6660 exception=AcquireExceptionInfo();
6661 perl_exception=newSVpv("",0);
6662 reference=SvRV(ST(0));
6663 av=(AV *) reference;
6664 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6666 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6667 if (image == (Image *) NULL)
6669 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6674 if (image->alpha_trait != UndefinedPixelTrait)
6676 if (image->colorspace == CMYKColorspace)
6679 if (image->alpha_trait != UndefinedPixelTrait)
6682 normalize=MagickFalse;
6685 region.width=image->columns;
6688 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6689 for (i=2; i < items; i+=2)
6691 attribute=(char *) SvPV(ST(i-1),na);
6697 if (LocaleCompare(attribute,"geometry") == 0)
6699 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6709 if (LocaleCompare(attribute,"height") == 0)
6711 region.height=SvIV(ST(i));
6714 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6721 if (LocaleCompare(attribute,"map") == 0)
6726 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6733 if (LocaleCompare(attribute,"normalize") == 0)
6735 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6739 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6743 normalize=option != 0 ? MagickTrue : MagickFalse;
6746 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6753 if (LocaleCompare(attribute,"width") == 0)
6755 region.width=SvIV(ST(i));
6758 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6765 if (LocaleCompare(attribute,"x") == 0)
6767 region.x=SvIV(ST(i));
6770 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6777 if (LocaleCompare(attribute,"y") == 0)
6779 region.y=SvIV(ST(i));
6782 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6788 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6794 if (normalize != MagickFalse)
6799 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6800 region.height*sizeof(*pixels));
6801 if (pixels == (float *) NULL)
6803 ThrowPerlException(exception,ResourceLimitError,
6804 "MemoryAllocationFailed",PackageName);
6807 status=ExportImagePixels(image,region.x,region.y,region.width,
6808 region.height,map,FloatPixel,pixels,exception);
6809 if (status == MagickFalse)
6813 EXTEND(sp,strlen(map)*region.width*region.height);
6814 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6815 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6817 pixels=(float *) RelinquishMagickMemory(pixels);
6824 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6825 region.height*sizeof(*pixels));
6826 if (pixels == (Quantum *) NULL)
6828 ThrowPerlException(exception,ResourceLimitError,
6829 "MemoryAllocationFailed",PackageName);
6832 status=ExportImagePixels(image,region.x,region.y,region.width,
6833 region.height,map,QuantumPixel,pixels,exception);
6834 if (status == MagickFalse)
6838 EXTEND(sp,strlen(map)*region.width*region.height);
6839 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6840 PUSHs(sv_2mortal(newSViv(pixels[i])));
6842 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6846 InheritPerlException(exception,perl_exception);
6847 exception=DestroyExceptionInfo(exception);
6848 SvREFCNT_dec(perl_exception);
6852 ###############################################################################
6856 # I m a g e T o B l o b #
6860 ###############################################################################
6864 ImageToBlob(ref,...)
6865 Image::Magick ref=NO_INIT
6874 filename[MagickPathExtent];
6903 PERL_UNUSED_VAR(ref);
6904 PERL_UNUSED_VAR(ix);
6905 exception=AcquireExceptionInfo();
6906 perl_exception=newSVpv("",0);
6907 package_info=(struct PackageInfo *) NULL;
6908 if (sv_isobject(ST(0)) == 0)
6910 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6914 reference=SvRV(ST(0));
6915 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6916 if (image == (Image *) NULL)
6918 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6922 package_info=ClonePackageInfo(info,exception);
6923 for (i=2; i < items; i+=2)
6924 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6925 (void) CopyMagickString(filename,package_info->image_info->filename,
6928 for (next=image; next; next=next->next)
6930 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6931 next->scene=scene++;
6933 SetImageInfo(package_info->image_info,(unsigned int)
6934 GetImageListLength(image),exception);
6935 EXTEND(sp,(ssize_t) GetImageListLength(image));
6936 for ( ; image; image=image->next)
6939 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6940 if (blob != (char *) NULL)
6942 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6943 blob=(unsigned char *) RelinquishMagickMemory(blob);
6945 if (package_info->image_info->adjoin)
6950 if (package_info != (struct PackageInfo *) NULL)
6951 DestroyPackageInfo(package_info);
6952 InheritPerlException(exception,perl_exception);
6953 exception=DestroyExceptionInfo(exception);
6954 SvREFCNT_dec(perl_exception); /* throw away all errors */
6958 ###############################################################################
6966 ###############################################################################
6971 Image::Magick ref=NO_INIT
6975 OptimizeImageLayers = 3
6977 optimizeimagelayers = 5
7019 PERL_UNUSED_VAR(ref);
7020 PERL_UNUSED_VAR(ix);
7021 exception=AcquireExceptionInfo();
7022 perl_exception=newSVpv("",0);
7024 if (sv_isobject(ST(0)) == 0)
7026 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7030 reference=SvRV(ST(0));
7031 hv=SvSTASH(reference);
7033 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7035 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7036 if (image == (Image *) NULL)
7038 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7042 compose=image->compose;
7043 method=OptimizeLayer;
7044 for (i=2; i < items; i+=2)
7046 attribute=(char *) SvPV(ST(i-1),na);
7052 if (LocaleCompare(attribute,"compose") == 0)
7054 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7055 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7058 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7062 compose=(CompositeOperator) sp;
7065 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7072 if (LocaleCompare(attribute,"method") == 0)
7074 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7078 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7082 method=(LayerMethod) option;
7085 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7091 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7097 layers=(Image *) NULL;
7100 case CompareAnyLayer:
7101 case CompareClearLayer:
7102 case CompareOverlayLayer:
7105 layers=CompareImagesLayers(image,method,exception);
7112 layers=MergeImageLayers(image,method,exception);
7117 layers=DisposeImages(image,exception);
7120 case OptimizeImageLayer:
7122 layers=OptimizeImageLayers(image,exception);
7125 case OptimizePlusLayer:
7127 layers=OptimizePlusImageLayers(image,exception);
7130 case OptimizeTransLayer:
7132 OptimizeImageTransparency(image,exception);
7135 case RemoveDupsLayer:
7137 RemoveDuplicateLayers(&image,exception);
7140 case RemoveZeroLayer:
7142 RemoveZeroDelayLayers(&image,exception);
7151 General Purpose, GIF Animation Optimizer.
7153 layers=CoalesceImages(image,exception);
7154 if (layers == (Image *) NULL)
7157 layers=OptimizeImageLayers(image,exception);
7158 if (layers == (Image *) NULL)
7160 image=DestroyImageList(image);
7162 layers=(Image *) NULL;
7163 OptimizeImageTransparency(image,exception);
7164 quantize_info=AcquireQuantizeInfo(info->image_info);
7165 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7166 quantize_info=DestroyQuantizeInfo(quantize_info);
7169 case CompositeLayer:
7178 Split image sequence at the first 'NULL:' image.
7181 while (source != (Image *) NULL)
7183 source=GetNextImageInList(source);
7184 if ((source != (Image *) NULL) &&
7185 (LocaleCompare(source->magick,"NULL") == 0))
7188 if (source != (Image *) NULL)
7190 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7191 (GetNextImageInList(source) == (Image *) NULL))
7192 source=(Image *) NULL;
7196 Separate the two lists, junk the null: image.
7198 source=SplitImageList(source->previous);
7199 DeleteImageFromList(&source);
7202 if (source == (Image *) NULL)
7204 (void) ThrowMagickException(exception,GetMagickModule(),
7205 OptionError,"MissingNullSeparator","layers Composite");
7209 Adjust offset with gravity and virtual canvas.
7211 SetGeometry(image,&geometry);
7212 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7213 geometry.width=source->page.width != 0 ? source->page.width :
7215 geometry.height=source->page.height != 0 ? source->page.height :
7217 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7218 image->columns,image->page.height != 0 ? image->page.height :
7219 image->rows,image->gravity,&geometry);
7220 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7221 source=DestroyImageList(source);
7225 if (layers != (Image *) NULL)
7228 image=CloneImage(image,0,0,MagickTrue,exception);
7229 if (image == (Image *) NULL)
7231 for ( ; image; image=image->next)
7233 AddImageToRegistry(sv,image);
7235 av_push(av,sv_bless(rv,hv));
7238 exception=DestroyExceptionInfo(exception);
7240 SvREFCNT_dec(perl_exception);
7244 InheritPerlException(exception,perl_exception);
7245 exception=DestroyExceptionInfo(exception);
7246 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7247 SvPOK_on(perl_exception);
7248 ST(0)=sv_2mortal(perl_exception);
7253 ###############################################################################
7257 # M a g i c k T o M i m e #
7261 ###############################################################################
7265 MagickToMime(ref,name)
7266 Image::Magick ref=NO_INIT
7275 PERL_UNUSED_VAR(ref);
7276 PERL_UNUSED_VAR(ix);
7277 mime=MagickToMime(name);
7278 RETVAL=newSVpv(mime,0);
7279 mime=(char *) RelinquishMagickMemory(mime);
7285 ###############################################################################
7293 ###############################################################################
7298 Image::Magick ref=NO_INIT
7335 MedianConvolveImage = 36
7341 ReduceNoiseImage = 42
7367 ColorFloodfillImage= 68
7373 CycleColormapImage = 74
7383 MatteFloodfillImage= 84
7391 NumberColorsImage = 92
7401 SignatureImage = 102
7411 TransparentImage = 112
7413 ThresholdImage = 114
7427 DeconstructImage = 130
7429 GaussianBlurImage = 132
7435 UnsharpMaskImage = 138
7437 MotionBlurImage = 140
7439 OrderedDitherImage = 142
7446 AffineTransform = 149
7447 AffineTransformImage = 150
7449 DifferenceImage = 152
7450 AdaptiveThreshold = 153
7451 AdaptiveThresholdImage = 154
7456 BlackThreshold = 159
7457 BlackThresholdImage= 160
7458 WhiteThreshold = 161
7459 WhiteThresholdImage= 162
7460 RotationalBlur = 163
7461 RotationalBlurImage= 164
7463 ThumbnailImage = 166
7473 PosterizeImage = 176
7479 SepiaToneImage = 182
7480 SigmoidalContrast = 183
7481 SigmoidalContrastImage = 184
7486 ContrastStretch = 189
7487 ContrastStretchImage = 190
7492 AdaptiveSharpen = 195
7493 AdaptiveSharpenImage = 196
7495 TransposeImage = 198
7497 TransverseImage = 200
7499 AutoOrientImage = 202
7501 AdaptiveBlurImage = 204
7505 UniqueColorsImage = 208
7506 AdaptiveResize = 209
7507 AdaptiveResizeImage= 210
7511 LinearStretchImage = 214
7513 ColorMatrixImage = 216
7518 FloodfillPaint = 221
7519 FloodfillPaintImage= 222
7525 LiquidRescaleImage = 228
7535 SparseColorImage = 238
7539 SelectiveBlurImage = 242
7543 BlueShiftImage = 246
7544 ForwardFourierTransform = 247
7545 ForwardFourierTransformImage = 248
7546 InverseFourierTransform = 249
7547 InverseFourierTransformImage = 250
7548 ColorDecisionList = 251
7549 ColorDecisionListImage = 252
7551 AutoGammaImage = 254
7553 AutoLevelImage = 256
7555 LevelImageColors = 258
7558 BrightnessContrast = 261
7559 BrightnessContrastImage = 262
7561 MorphologyImage = 264
7565 StatisticImage = 268
7567 PerceptibleImage = 270
7571 GrayscaleImage = 274
7573 CannyEdgeImage = 276
7575 HoughLineImage = 278
7577 MeanShiftImage = 280
7580 ConnectedComponent = 283
7581 ConnectedComponentImage = 284
7583 CopyImagePixels = 286
7592 attribute_flag[MaxArguments],
7593 message[MagickPathExtent];
7654 argument_list[MaxArguments];
7656 PERL_UNUSED_VAR(ref);
7657 PERL_UNUSED_VAR(ix);
7658 exception=AcquireExceptionInfo();
7659 perl_exception=newSVpv("",0);
7660 reference_vector=NULL;
7664 if (sv_isobject(ST(0)) == 0)
7666 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7670 reference=SvRV(ST(0));
7671 region_info.width=0;
7672 region_info.height=0;
7675 region_image=(Image *) NULL;
7676 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7677 if (ix && (ix != 666))
7680 Called as Method(...)
7683 rp=(&Methods[ix-1]);
7689 Called as Mogrify("Method",...)
7691 attribute=(char *) SvPV(ST(1),na);
7694 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7695 attribute=(char *) SvPV(ST(2),na);
7698 for (rp=Methods; ; rp++)
7700 if (rp >= EndOf(Methods))
7702 ThrowPerlException(exception,OptionError,
7703 "UnrecognizedPerlMagickMethod",attribute);
7706 if (strEQcase(attribute,rp->name))
7712 if (image == (Image *) NULL)
7714 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7717 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7718 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7719 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7736 pp=(Arguments *) NULL;
7744 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7746 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7748 if (strEQcase(attribute,qq->method) > ssize_test)
7751 ssize_test=strEQcase(attribute,qq->method);
7754 if (pp == (Arguments *) NULL)
7756 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7758 goto continue_outer_loop;
7760 al=(&argument_list[pp-rp->arguments]);
7763 case ArrayReference:
7765 if (SvTYPE(sv) != SVt_RV)
7767 (void) FormatLocaleString(message,MagickPathExtent,
7768 "invalid %.60s value",pp->method);
7769 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7770 goto continue_outer_loop;
7772 al->array_reference=SvRV(sv);
7777 al->real_reference=SvNV(sv);
7782 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7785 case ImageReference:
7787 if (!sv_isobject(sv) ||
7788 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7789 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7791 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7797 case IntegerReference:
7799 al->integer_reference=SvIV(sv);
7802 case StringReference:
7804 al->string_reference=(char *) SvPV(sv,al->length);
7805 if (sv_isobject(sv))
7806 al->image_reference=SetupList(aTHX_ SvRV(sv),
7807 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7813 Is a string; look up name.
7815 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7817 al->string_reference=(char *) SvPV(sv,al->length);
7818 al->integer_reference=(-1);
7821 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7822 MagickFalse,SvPV(sv,na));
7823 if (pp->type == MagickChannelOptions)
7824 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7825 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7827 (void) FormatLocaleString(message,MagickPathExtent,
7828 "invalid %.60s value",pp->method);
7829 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7830 goto continue_outer_loop;
7835 attribute_flag[pp-rp->arguments]++;
7836 continue_outer_loop: ;
7838 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7839 pv=reference_vector;
7840 SetGeometryInfo(&geometry_info);
7841 channel=DefaultChannels;
7842 for (next=image; next; next=next->next)
7845 SetGeometry(image,&geometry);
7846 if ((region_info.width*region_info.height) != 0)
7849 image=CropImage(image,®ion_info,exception);
7855 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double) ix);
7856 ThrowPerlException(exception,OptionError,
7857 "UnrecognizedPerlMagickMethod",message);
7860 case 1: /* Comment */
7862 if (attribute_flag[0] == 0)
7863 argument_list[0].string_reference=(char *) NULL;
7864 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7865 info ? info->image_info : (ImageInfo *) NULL,image,
7866 argument_list[0].string_reference,exception),exception);
7871 if (attribute_flag[0] == 0)
7872 argument_list[0].string_reference=(char *) NULL;
7873 (void) SetImageProperty(image,"label",InterpretImageProperties(
7874 info ? info->image_info : (ImageInfo *) NULL,image,
7875 argument_list[0].string_reference,exception),exception);
7878 case 3: /* AddNoise */
7883 if (attribute_flag[0] == 0)
7884 argument_list[0].integer_reference=UniformNoise;
7886 if (attribute_flag[1] != 0)
7887 attenuate=argument_list[1].real_reference;
7888 if (attribute_flag[2] != 0)
7889 channel=(ChannelType) argument_list[2].integer_reference;
7890 channel_mask=SetImageChannelMask(image,channel);
7891 image=AddNoiseImage(image,(NoiseType)
7892 argument_list[0].integer_reference,attenuate,exception);
7893 if (image != (Image *) NULL)
7894 (void) SetImageChannelMask(image,channel_mask);
7897 case 4: /* Colorize */
7902 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7903 0,0,&target,exception);
7904 if (attribute_flag[0] != 0)
7905 (void) QueryColorCompliance(argument_list[0].string_reference,
7906 AllCompliance,&target,exception);
7907 if (attribute_flag[1] == 0)
7908 argument_list[1].string_reference="100%";
7909 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7913 case 5: /* Border */
7920 if (attribute_flag[0] != 0)
7921 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7922 &geometry,exception);
7923 if (attribute_flag[1] != 0)
7924 geometry.width=argument_list[1].integer_reference;
7925 if (attribute_flag[2] != 0)
7926 geometry.height=argument_list[2].integer_reference;
7927 if (attribute_flag[3] != 0)
7928 QueryColorCompliance(argument_list[3].string_reference,
7929 AllCompliance,&image->border_color,exception);
7930 if (attribute_flag[4] != 0)
7931 QueryColorCompliance(argument_list[4].string_reference,
7932 AllCompliance,&image->border_color,exception);
7933 if (attribute_flag[5] != 0)
7934 QueryColorCompliance(argument_list[5].string_reference,
7935 AllCompliance,&image->border_color,exception);
7936 compose=image->compose;
7937 if (attribute_flag[6] != 0)
7938 compose=(CompositeOperator) argument_list[6].integer_reference;
7939 image=BorderImage(image,&geometry,compose,exception);
7944 if (attribute_flag[0] != 0)
7946 flags=ParseGeometry(argument_list[0].string_reference,
7948 if ((flags & SigmaValue) == 0)
7949 geometry_info.sigma=1.0;
7951 if (attribute_flag[1] != 0)
7952 geometry_info.rho=argument_list[1].real_reference;
7953 if (attribute_flag[2] != 0)
7954 geometry_info.sigma=argument_list[2].real_reference;
7955 if (attribute_flag[3] != 0)
7956 channel=(ChannelType) argument_list[3].integer_reference;
7957 channel_mask=SetImageChannelMask(image,channel);
7958 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7960 if (image != (Image *) NULL)
7961 (void) SetImageChannelMask(image,channel_mask);
7966 if (attribute_flag[5] != 0)
7967 image->gravity=(GravityType) argument_list[5].integer_reference;
7968 if (attribute_flag[0] != 0)
7969 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7970 &geometry,exception);
7971 if (attribute_flag[1] != 0)
7972 geometry.width=argument_list[1].integer_reference;
7973 if (attribute_flag[2] != 0)
7974 geometry.height=argument_list[2].integer_reference;
7975 if (attribute_flag[3] != 0)
7976 geometry.x=argument_list[3].integer_reference;
7977 if (attribute_flag[4] != 0)
7978 geometry.y=argument_list[4].integer_reference;
7979 image=ChopImage(image,&geometry,exception);
7984 if (attribute_flag[6] != 0)
7985 image->gravity=(GravityType) argument_list[6].integer_reference;
7986 if (attribute_flag[0] != 0)
7987 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7988 &geometry,exception);
7989 if (attribute_flag[1] != 0)
7990 geometry.width=argument_list[1].integer_reference;
7991 if (attribute_flag[2] != 0)
7992 geometry.height=argument_list[2].integer_reference;
7993 if (attribute_flag[3] != 0)
7994 geometry.x=argument_list[3].integer_reference;
7995 if (attribute_flag[4] != 0)
7996 geometry.y=argument_list[4].integer_reference;
7997 if (attribute_flag[5] != 0)
7998 image->fuzz=StringToDoubleInterval(
7999 argument_list[5].string_reference,(double) QuantumRange+1.0);
8000 image=CropImage(image,&geometry,exception);
8003 case 9: /* Despeckle */
8005 image=DespeckleImage(image,exception);
8010 if (attribute_flag[0] != 0)
8011 geometry_info.rho=argument_list[0].real_reference;
8012 image=EdgeImage(image,geometry_info.rho,exception);
8015 case 11: /* Emboss */
8017 if (attribute_flag[0] != 0)
8019 flags=ParseGeometry(argument_list[0].string_reference,
8021 if ((flags & SigmaValue) == 0)
8022 geometry_info.sigma=1.0;
8024 if (attribute_flag[1] != 0)
8025 geometry_info.rho=argument_list[1].real_reference;
8026 if (attribute_flag[2] != 0)
8027 geometry_info.sigma=argument_list[2].real_reference;
8028 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8032 case 12: /* Enhance */
8034 image=EnhanceImage(image,exception);
8039 image=FlipImage(image,exception);
8044 image=FlopImage(image,exception);
8047 case 15: /* Frame */
8055 if (attribute_flag[0] != 0)
8057 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8058 &geometry,exception);
8059 frame_info.width=geometry.width;
8060 frame_info.height=geometry.height;
8061 frame_info.outer_bevel=geometry.x;
8062 frame_info.inner_bevel=geometry.y;
8064 if (attribute_flag[1] != 0)
8065 frame_info.width=argument_list[1].integer_reference;
8066 if (attribute_flag[2] != 0)
8067 frame_info.height=argument_list[2].integer_reference;
8068 if (attribute_flag[3] != 0)
8069 frame_info.inner_bevel=argument_list[3].integer_reference;
8070 if (attribute_flag[4] != 0)
8071 frame_info.outer_bevel=argument_list[4].integer_reference;
8072 if (attribute_flag[5] != 0)
8073 QueryColorCompliance(argument_list[5].string_reference,
8074 AllCompliance,&fill_color,exception);
8075 if (attribute_flag[6] != 0)
8076 QueryColorCompliance(argument_list[6].string_reference,
8077 AllCompliance,&fill_color,exception);
8078 frame_info.x=(ssize_t) frame_info.width;
8079 frame_info.y=(ssize_t) frame_info.height;
8080 frame_info.width=image->columns+2*frame_info.x;
8081 frame_info.height=image->rows+2*frame_info.y;
8082 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8083 image->alpha_color=fill_color;
8084 compose=image->compose;
8085 if (attribute_flag[7] != 0)
8086 compose=(CompositeOperator) argument_list[7].integer_reference;
8087 image=FrameImage(image,&frame_info,compose,exception);
8090 case 16: /* Implode */
8092 PixelInterpolateMethod
8095 if (attribute_flag[0] == 0)
8096 argument_list[0].real_reference=0.5;
8097 method=UndefinedInterpolatePixel;
8098 if (attribute_flag[1] != 0)
8099 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8100 image=ImplodeImage(image,argument_list[0].real_reference,
8104 case 17: /* Magnify */
8106 image=MagnifyImage(image,exception);
8109 case 18: /* MedianFilter */
8111 if (attribute_flag[0] != 0)
8113 flags=ParseGeometry(argument_list[0].string_reference,
8115 if ((flags & SigmaValue) == 0)
8116 geometry_info.sigma=geometry_info.rho;
8118 if (attribute_flag[1] != 0)
8119 geometry_info.rho=argument_list[1].real_reference;
8120 if (attribute_flag[2] != 0)
8121 geometry_info.sigma=argument_list[2].real_reference;
8122 if (attribute_flag[3] != 0)
8123 channel=(ChannelType) argument_list[3].integer_reference;
8124 channel_mask=SetImageChannelMask(image,channel);
8125 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8126 (size_t) geometry_info.sigma,exception);
8127 if (image != (Image *) NULL)
8128 (void) SetImageChannelMask(image,channel_mask);
8131 case 19: /* Minify */
8133 image=MinifyImage(image,exception);
8136 case 20: /* OilPaint */
8138 if (attribute_flag[0] == 0)
8139 argument_list[0].real_reference=0.0;
8140 if (attribute_flag[1] == 0)
8141 argument_list[1].real_reference=1.0;
8142 image=OilPaintImage(image,argument_list[0].real_reference,
8143 argument_list[1].real_reference,exception);
8146 case 21: /* ReduceNoise */
8148 if (attribute_flag[0] != 0)
8150 flags=ParseGeometry(argument_list[0].string_reference,
8152 if ((flags & SigmaValue) == 0)
8153 geometry_info.sigma=1.0;
8155 if (attribute_flag[1] != 0)
8156 geometry_info.rho=argument_list[1].real_reference;
8157 if (attribute_flag[2] != 0)
8158 geometry_info.sigma=argument_list[2].real_reference;
8159 if (attribute_flag[3] != 0)
8160 channel=(ChannelType) argument_list[3].integer_reference;
8161 channel_mask=SetImageChannelMask(image,channel);
8162 image=StatisticImage(image,NonpeakStatistic,(size_t)
8163 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8164 if (image != (Image *) NULL)
8165 (void) SetImageChannelMask(image,channel_mask);
8170 if (attribute_flag[0] != 0)
8171 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8172 &geometry,exception);
8173 if (attribute_flag[1] != 0)
8174 geometry.x=argument_list[1].integer_reference;
8175 if (attribute_flag[2] != 0)
8176 geometry.y=argument_list[2].integer_reference;
8177 image=RollImage(image,geometry.x,geometry.y,exception);
8180 case 23: /* Rotate */
8182 if (attribute_flag[0] == 0)
8183 argument_list[0].real_reference=90.0;
8184 if (attribute_flag[1] != 0)
8186 QueryColorCompliance(argument_list[1].string_reference,
8187 AllCompliance,&image->background_color,exception);
8188 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8189 (image->alpha_trait == UndefinedPixelTrait))
8190 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8192 image=RotateImage(image,argument_list[0].real_reference,exception);
8195 case 24: /* Sample */
8197 if (attribute_flag[0] != 0)
8198 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8199 &geometry,exception);
8200 if (attribute_flag[1] != 0)
8201 geometry.width=argument_list[1].integer_reference;
8202 if (attribute_flag[2] != 0)
8203 geometry.height=argument_list[2].integer_reference;
8204 image=SampleImage(image,geometry.width,geometry.height,exception);
8207 case 25: /* Scale */
8209 if (attribute_flag[0] != 0)
8210 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8211 &geometry,exception);
8212 if (attribute_flag[1] != 0)
8213 geometry.width=argument_list[1].integer_reference;
8214 if (attribute_flag[2] != 0)
8215 geometry.height=argument_list[2].integer_reference;
8216 image=ScaleImage(image,geometry.width,geometry.height,exception);
8219 case 26: /* Shade */
8221 if (attribute_flag[0] != 0)
8223 flags=ParseGeometry(argument_list[0].string_reference,
8225 if ((flags & SigmaValue) == 0)
8226 geometry_info.sigma=0.0;
8228 if (attribute_flag[1] != 0)
8229 geometry_info.rho=argument_list[1].real_reference;
8230 if (attribute_flag[2] != 0)
8231 geometry_info.sigma=argument_list[2].real_reference;
8232 image=ShadeImage(image,
8233 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8234 geometry_info.rho,geometry_info.sigma,exception);
8237 case 27: /* Sharpen */
8239 if (attribute_flag[0] != 0)
8241 flags=ParseGeometry(argument_list[0].string_reference,
8243 if ((flags & SigmaValue) == 0)
8244 geometry_info.sigma=1.0;
8246 if (attribute_flag[1] != 0)
8247 geometry_info.rho=argument_list[1].real_reference;
8248 if (attribute_flag[2] != 0)
8249 geometry_info.sigma=argument_list[2].real_reference;
8250 if (attribute_flag[3] != 0)
8251 channel=(ChannelType) argument_list[3].integer_reference;
8252 channel_mask=SetImageChannelMask(image,channel);
8253 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8255 if (image != (Image *) NULL)
8256 (void) SetImageChannelMask(image,channel_mask);
8259 case 28: /* Shear */
8261 if (attribute_flag[0] != 0)
8263 flags=ParseGeometry(argument_list[0].string_reference,
8265 if ((flags & SigmaValue) == 0)
8266 geometry_info.sigma=geometry_info.rho;
8268 if (attribute_flag[1] != 0)
8269 geometry_info.rho=argument_list[1].real_reference;
8270 if (attribute_flag[2] != 0)
8271 geometry_info.sigma=argument_list[2].real_reference;
8272 if (attribute_flag[3] != 0)
8273 QueryColorCompliance(argument_list[3].string_reference,
8274 AllCompliance,&image->background_color,exception);
8275 if (attribute_flag[4] != 0)
8276 QueryColorCompliance(argument_list[4].string_reference,
8277 AllCompliance,&image->background_color,exception);
8278 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8282 case 29: /* Spread */
8284 PixelInterpolateMethod
8287 if (attribute_flag[0] == 0)
8288 argument_list[0].real_reference=1.0;
8289 method=UndefinedInterpolatePixel;
8290 if (attribute_flag[1] != 0)
8291 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8292 image=SpreadImage(image,method,argument_list[0].real_reference,
8296 case 30: /* Swirl */
8298 PixelInterpolateMethod
8301 if (attribute_flag[0] == 0)
8302 argument_list[0].real_reference=50.0;
8303 method=UndefinedInterpolatePixel;
8304 if (attribute_flag[1] != 0)
8305 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8306 image=SwirlImage(image,argument_list[0].real_reference,
8310 case 31: /* Resize */
8313 if (attribute_flag[0] != 0)
8314 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8315 &geometry,exception);
8316 if (attribute_flag[1] != 0)
8317 geometry.width=argument_list[1].integer_reference;
8318 if (attribute_flag[2] != 0)
8319 geometry.height=argument_list[2].integer_reference;
8320 if (attribute_flag[3] == 0)
8321 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8322 if (attribute_flag[4] != 0)
8323 SetImageArtifact(image,"filter:support",
8324 argument_list[4].string_reference);
8325 image=ResizeImage(image,geometry.width,geometry.height,
8326 (FilterType) argument_list[3].integer_reference,
8330 case 33: /* Annotate */
8335 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8337 if (attribute_flag[0] != 0)
8342 text=InterpretImageProperties(info ? info->image_info :
8343 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8345 (void) CloneString(&draw_info->text,text);
8346 text=DestroyString(text);
8348 if (attribute_flag[1] != 0)
8349 (void) CloneString(&draw_info->font,
8350 argument_list[1].string_reference);
8351 if (attribute_flag[2] != 0)
8352 draw_info->pointsize=argument_list[2].real_reference;
8353 if (attribute_flag[3] != 0)
8354 (void) CloneString(&draw_info->density,
8355 argument_list[3].string_reference);
8356 if (attribute_flag[4] != 0)
8357 (void) QueryColorCompliance(argument_list[4].string_reference,
8358 AllCompliance,&draw_info->undercolor,exception);
8359 if (attribute_flag[5] != 0)
8361 (void) QueryColorCompliance(argument_list[5].string_reference,
8362 AllCompliance,&draw_info->stroke,exception);
8363 if (argument_list[5].image_reference != (Image *) NULL)
8364 draw_info->stroke_pattern=CloneImage(
8365 argument_list[5].image_reference,0,0,MagickTrue,exception);
8367 if (attribute_flag[6] != 0)
8369 (void) QueryColorCompliance(argument_list[6].string_reference,
8370 AllCompliance,&draw_info->fill,exception);
8371 if (argument_list[6].image_reference != (Image *) NULL)
8372 draw_info->fill_pattern=CloneImage(
8373 argument_list[6].image_reference,0,0,MagickTrue,exception);
8375 if (attribute_flag[7] != 0)
8377 (void) CloneString(&draw_info->geometry,
8378 argument_list[7].string_reference);
8379 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8380 &geometry,exception);
8381 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8382 geometry_info.sigma=geometry_info.xi;
8384 if (attribute_flag[8] != 0)
8385 (void) QueryColorCompliance(argument_list[8].string_reference,
8386 AllCompliance,&draw_info->fill,exception);
8387 if (attribute_flag[11] != 0)
8388 draw_info->gravity=(GravityType)
8389 argument_list[11].integer_reference;
8390 if (attribute_flag[25] != 0)
8395 av=(AV *) argument_list[25].array_reference;
8396 if ((av_len(av) != 3) && (av_len(av) != 5))
8398 ThrowPerlException(exception,OptionError,
8399 "affine matrix must have 4 or 6 elements",PackageName);
8402 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8403 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8404 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8405 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8406 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8407 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8409 ThrowPerlException(exception,OptionError,
8410 "affine matrix is singular",PackageName);
8413 if (av_len(av) == 5)
8415 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8416 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8419 for (j=12; j < 17; j++)
8421 if (attribute_flag[j] == 0)
8423 value=argument_list[j].string_reference;
8424 angle=argument_list[j].real_reference;
8425 current=draw_info->affine;
8426 GetAffineMatrix(&affine);
8434 flags=ParseGeometry(value,&geometry_info);
8435 affine.tx=geometry_info.xi;
8436 affine.ty=geometry_info.psi;
8437 if ((flags & PsiValue) == 0)
8438 affine.ty=affine.tx;
8446 flags=ParseGeometry(value,&geometry_info);
8447 affine.sx=geometry_info.rho;
8448 affine.sy=geometry_info.sigma;
8449 if ((flags & SigmaValue) == 0)
8450 affine.sy=affine.sx;
8460 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8461 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8462 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8463 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8471 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8479 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8483 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8484 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8485 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8486 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8487 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8489 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8492 if (attribute_flag[9] == 0)
8493 argument_list[9].real_reference=0.0;
8494 if (attribute_flag[10] == 0)
8495 argument_list[10].real_reference=0.0;
8496 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8499 geometry[MagickPathExtent];
8501 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8502 (double) argument_list[9].real_reference+draw_info->affine.tx,
8503 (double) argument_list[10].real_reference+draw_info->affine.ty);
8504 (void) CloneString(&draw_info->geometry,geometry);
8506 if (attribute_flag[17] != 0)
8507 draw_info->stroke_width=argument_list[17].real_reference;
8508 if (attribute_flag[18] != 0)
8510 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8511 MagickTrue : MagickFalse;
8512 draw_info->stroke_antialias=draw_info->text_antialias;
8514 if (attribute_flag[19] != 0)
8515 (void) CloneString(&draw_info->family,
8516 argument_list[19].string_reference);
8517 if (attribute_flag[20] != 0)
8518 draw_info->style=(StyleType) argument_list[20].integer_reference;
8519 if (attribute_flag[21] != 0)
8520 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8521 if (attribute_flag[22] != 0)
8522 draw_info->weight=argument_list[22].integer_reference;
8523 if (attribute_flag[23] != 0)
8524 draw_info->align=(AlignType) argument_list[23].integer_reference;
8525 if (attribute_flag[24] != 0)
8526 (void) CloneString(&draw_info->encoding,
8527 argument_list[24].string_reference);
8528 if (attribute_flag[25] != 0)
8529 draw_info->fill_pattern=CloneImage(
8530 argument_list[25].image_reference,0,0,MagickTrue,exception);
8531 if (attribute_flag[26] != 0)
8532 draw_info->fill_pattern=CloneImage(
8533 argument_list[26].image_reference,0,0,MagickTrue,exception);
8534 if (attribute_flag[27] != 0)
8535 draw_info->stroke_pattern=CloneImage(
8536 argument_list[27].image_reference,0,0,MagickTrue,exception);
8537 if (attribute_flag[29] != 0)
8538 draw_info->kerning=argument_list[29].real_reference;
8539 if (attribute_flag[30] != 0)
8540 draw_info->interline_spacing=argument_list[30].real_reference;
8541 if (attribute_flag[31] != 0)
8542 draw_info->interword_spacing=argument_list[31].real_reference;
8543 if (attribute_flag[32] != 0)
8544 draw_info->direction=(DirectionType)
8545 argument_list[32].integer_reference;
8546 (void) AnnotateImage(image,draw_info,exception);
8547 draw_info=DestroyDrawInfo(draw_info);
8550 case 34: /* ColorFloodfill */
8561 draw_info=CloneDrawInfo(info ? info->image_info :
8562 (ImageInfo *) NULL,(DrawInfo *) NULL);
8563 if (attribute_flag[0] != 0)
8564 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8565 &geometry,exception);
8566 if (attribute_flag[1] != 0)
8567 geometry.x=argument_list[1].integer_reference;
8568 if (attribute_flag[2] != 0)
8569 geometry.y=argument_list[2].integer_reference;
8570 if (attribute_flag[3] != 0)
8571 (void) QueryColorCompliance(argument_list[3].string_reference,
8572 AllCompliance,&draw_info->fill,exception);
8573 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8574 geometry.x,geometry.y,&target,exception);
8576 if (attribute_flag[4] != 0)
8578 QueryColorCompliance(argument_list[4].string_reference,
8579 AllCompliance,&target,exception);
8582 if (attribute_flag[5] != 0)
8583 image->fuzz=StringToDoubleInterval(
8584 argument_list[5].string_reference,(double) QuantumRange+1.0);
8585 if (attribute_flag[6] != 0)
8586 invert=(MagickBooleanType) argument_list[6].integer_reference;
8587 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8588 geometry.y,invert,exception);
8589 draw_info=DestroyDrawInfo(draw_info);
8592 case 35: /* Composite */
8595 composite_geometry[MagickPathExtent];
8604 compose=OverCompositeOp;
8605 if (attribute_flag[0] != 0)
8606 composite_image=argument_list[0].image_reference;
8609 ThrowPerlException(exception,OptionError,
8610 "CompositeImageRequired",PackageName);
8614 Parameter Handling used for BOTH normal and tiled composition.
8616 if (attribute_flag[1] != 0) /* compose */
8617 compose=(CompositeOperator) argument_list[1].integer_reference;
8618 if (attribute_flag[6] != 0) /* opacity */
8620 if (compose != DissolveCompositeOp)
8621 (void) SetImageAlpha(composite_image,(Quantum)
8622 StringToDoubleInterval(argument_list[6].string_reference,
8623 (double) QuantumRange+1.0),exception);
8645 Handle dissolve composite operator (patch by
8648 (void) CloneString(&image->geometry,
8649 argument_list[6].string_reference);
8650 opacity=(Quantum) StringToDoubleInterval(
8651 argument_list[6].string_reference,(double) QuantumRange+
8653 if (composite_image->alpha_trait != UndefinedPixelTrait)
8654 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8655 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8656 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8658 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8659 composite_image->columns,1,exception);
8660 for (x=0; x < (ssize_t) composite_image->columns; x++)
8662 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8663 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8665 q+=GetPixelChannels(composite_image);
8667 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8668 if (sync == MagickFalse)
8671 composite_view=DestroyCacheView(composite_view);
8674 if (attribute_flag[9] != 0) /* "color=>" */
8675 QueryColorCompliance(argument_list[9].string_reference,
8676 AllCompliance,&composite_image->background_color,exception);
8677 if (attribute_flag[12] != 0) /* "interpolate=>" */
8678 image->interpolate=(PixelInterpolateMethod)
8679 argument_list[12].integer_reference;
8680 if (attribute_flag[13] != 0) /* "args=>" */
8681 (void) SetImageArtifact(composite_image,"compose:args",
8682 argument_list[13].string_reference);
8683 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8684 (void) SetImageArtifact(composite_image,"compose:args",
8685 argument_list[14].string_reference);
8686 clip_to_self=MagickTrue;
8687 if (attribute_flag[15] != 0)
8688 clip_to_self=(MagickBooleanType)
8689 argument_list[15].integer_reference;
8691 Tiling Composition (with orthogonal rotate).
8693 rotate_image=(Image *) NULL;
8694 if (attribute_flag[8] != 0) /* "rotate=>" */
8699 rotate_image=RotateImage(composite_image,
8700 argument_list[8].real_reference,exception);
8701 if (rotate_image == (Image *) NULL)
8704 if ((attribute_flag[7] != 0) &&
8705 (argument_list[7].integer_reference != 0)) /* tile */
8712 Tile the composite image.
8714 if (attribute_flag[8] != 0) /* "tile=>" */
8715 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8718 (void) SetImageArtifact(composite_image,
8719 "compose:outside-overlay","false");
8720 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8721 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8723 if (attribute_flag[8] != 0) /* rotate */
8724 (void) CompositeImage(image,rotate_image,compose,
8725 MagickTrue,x,y,exception);
8727 (void) CompositeImage(image,composite_image,compose,
8728 MagickTrue,x,y,exception);
8730 if (attribute_flag[8] != 0) /* rotate */
8731 rotate_image=DestroyImage(rotate_image);
8735 Parameter Handling used used ONLY for normal composition.
8737 if (attribute_flag[5] != 0) /* gravity */
8738 image->gravity=(GravityType) argument_list[5].integer_reference;
8739 if (attribute_flag[2] != 0) /* geometry offset */
8741 SetGeometry(image,&geometry);
8742 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8744 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8747 if (attribute_flag[3] != 0) /* x offset */
8748 geometry.x=argument_list[3].integer_reference;
8749 if (attribute_flag[4] != 0) /* y offset */
8750 geometry.y=argument_list[4].integer_reference;
8751 if (attribute_flag[10] != 0) /* mask */
8753 if ((image->compose == DisplaceCompositeOp) ||
8754 (image->compose == DistortCompositeOp))
8757 Merge Y displacement into X displacement image.
8759 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8761 (void) CompositeImage(composite_image,
8762 argument_list[10].image_reference,CopyGreenCompositeOp,
8763 MagickTrue,0,0,exception);
8771 Set a blending mask for the composition.
8773 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8774 MagickTrue,exception);
8775 (void) SetImageMask(composite_image,ReadPixelMask,mask_image,
8777 mask_image=DestroyImage(mask_image);
8780 if (attribute_flag[11] != 0) /* channel */
8781 channel=(ChannelType) argument_list[11].integer_reference;
8783 Composite two images (normal composition).
8785 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8786 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8787 (double) composite_image->rows,(double) geometry.x,(double)
8789 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8791 channel_mask=SetImageChannelMask(image,channel);
8792 if (attribute_flag[8] == 0) /* no rotate */
8793 CompositeImage(image,composite_image,compose,clip_to_self,
8794 geometry.x,geometry.y,exception);
8798 Position adjust rotated image then composite.
8800 geometry.x-=(ssize_t) (rotate_image->columns-
8801 composite_image->columns)/2;
8802 geometry.y-=(ssize_t) (rotate_image->rows-
8803 composite_image->rows)/2;
8804 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8805 geometry.y,exception);
8806 rotate_image=DestroyImage(rotate_image);
8808 if (attribute_flag[10] != 0) /* mask */
8810 if ((image->compose == DisplaceCompositeOp) ||
8811 (image->compose == DistortCompositeOp))
8812 composite_image=DestroyImage(composite_image);
8814 (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
8817 (void) SetImageChannelMask(image,channel_mask);
8820 case 36: /* Contrast */
8822 if (attribute_flag[0] == 0)
8823 argument_list[0].integer_reference=0;
8824 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8825 MagickTrue : MagickFalse,exception);
8828 case 37: /* CycleColormap */
8830 if (attribute_flag[0] == 0)
8831 argument_list[0].integer_reference=6;
8832 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8841 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8843 (void) CloneString(&draw_info->primitive,"point");
8844 if (attribute_flag[0] != 0)
8846 if (argument_list[0].integer_reference < 0)
8847 (void) CloneString(&draw_info->primitive,
8848 argument_list[0].string_reference);
8850 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8851 MagickPrimitiveOptions,argument_list[0].integer_reference));
8853 if (attribute_flag[1] != 0)
8855 if (LocaleCompare(draw_info->primitive,"path") == 0)
8857 (void) ConcatenateString(&draw_info->primitive," '");
8858 ConcatenateString(&draw_info->primitive,
8859 argument_list[1].string_reference);
8860 (void) ConcatenateString(&draw_info->primitive,"'");
8864 (void) ConcatenateString(&draw_info->primitive," ");
8865 ConcatenateString(&draw_info->primitive,
8866 argument_list[1].string_reference);
8869 if (attribute_flag[2] != 0)
8871 (void) ConcatenateString(&draw_info->primitive," ");
8872 (void) ConcatenateString(&draw_info->primitive,
8873 CommandOptionToMnemonic(MagickMethodOptions,
8874 argument_list[2].integer_reference));
8876 if (attribute_flag[3] != 0)
8878 (void) QueryColorCompliance(argument_list[3].string_reference,
8879 AllCompliance,&draw_info->stroke,exception);
8880 if (argument_list[3].image_reference != (Image *) NULL)
8881 draw_info->stroke_pattern=CloneImage(
8882 argument_list[3].image_reference,0,0,MagickTrue,exception);
8884 if (attribute_flag[4] != 0)
8886 (void) QueryColorCompliance(argument_list[4].string_reference,
8887 AllCompliance,&draw_info->fill,exception);
8888 if (argument_list[4].image_reference != (Image *) NULL)
8889 draw_info->fill_pattern=CloneImage(
8890 argument_list[4].image_reference,0,0,MagickTrue,exception);
8892 if (attribute_flag[5] != 0)
8893 draw_info->stroke_width=argument_list[5].real_reference;
8894 if (attribute_flag[6] != 0)
8895 (void) CloneString(&draw_info->font,
8896 argument_list[6].string_reference);
8897 if (attribute_flag[7] != 0)
8898 (void) QueryColorCompliance(argument_list[7].string_reference,
8899 AllCompliance,&draw_info->border_color,exception);
8900 if (attribute_flag[8] != 0)
8901 draw_info->affine.tx=argument_list[8].real_reference;
8902 if (attribute_flag[9] != 0)
8903 draw_info->affine.ty=argument_list[9].real_reference;
8904 if (attribute_flag[20] != 0)
8909 av=(AV *) argument_list[20].array_reference;
8910 if ((av_len(av) != 3) && (av_len(av) != 5))
8912 ThrowPerlException(exception,OptionError,
8913 "affine matrix must have 4 or 6 elements",PackageName);
8916 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8917 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8918 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8919 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8920 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8921 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8923 ThrowPerlException(exception,OptionError,
8924 "affine matrix is singular",PackageName);
8927 if (av_len(av) == 5)
8929 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8930 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8933 for (j=10; j < 15; j++)
8935 if (attribute_flag[j] == 0)
8937 value=argument_list[j].string_reference;
8938 angle=argument_list[j].real_reference;
8939 current=draw_info->affine;
8940 GetAffineMatrix(&affine);
8948 flags=ParseGeometry(value,&geometry_info);
8949 affine.tx=geometry_info.xi;
8950 affine.ty=geometry_info.psi;
8951 if ((flags & PsiValue) == 0)
8952 affine.ty=affine.tx;
8960 flags=ParseGeometry(value,&geometry_info);
8961 affine.sx=geometry_info.rho;
8962 affine.sy=geometry_info.sigma;
8963 if ((flags & SigmaValue) == 0)
8964 affine.sy=affine.sx;
8974 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8975 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8976 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8977 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8985 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8993 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8997 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8998 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8999 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9000 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9001 draw_info->affine.tx=
9002 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9003 draw_info->affine.ty=
9004 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9006 if (attribute_flag[15] != 0)
9007 draw_info->fill_pattern=CloneImage(
9008 argument_list[15].image_reference,0,0,MagickTrue,exception);
9009 if (attribute_flag[16] != 0)
9010 draw_info->pointsize=argument_list[16].real_reference;
9011 if (attribute_flag[17] != 0)
9013 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
9014 ? MagickTrue : MagickFalse;
9015 draw_info->text_antialias=draw_info->stroke_antialias;
9017 if (attribute_flag[18] != 0)
9018 (void) CloneString(&draw_info->density,
9019 argument_list[18].string_reference);
9020 if (attribute_flag[19] != 0)
9021 draw_info->stroke_width=argument_list[19].real_reference;
9022 if (attribute_flag[21] != 0)
9023 draw_info->dash_offset=argument_list[21].real_reference;
9024 if (attribute_flag[22] != 0)
9029 av=(AV *) argument_list[22].array_reference;
9030 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9031 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9032 if (draw_info->dash_pattern != (double *) NULL)
9034 for (i=0; i <= av_len(av); i++)
9035 draw_info->dash_pattern[i]=(double)
9036 SvNV(*(av_fetch(av,i,0)));
9037 draw_info->dash_pattern[i]=0.0;
9040 if (attribute_flag[23] != 0)
9041 image->interpolate=(PixelInterpolateMethod)
9042 argument_list[23].integer_reference;
9043 if ((attribute_flag[24] != 0) &&
9044 (draw_info->fill_pattern != (Image *) NULL))
9045 flags=ParsePageGeometry(draw_info->fill_pattern,
9046 argument_list[24].string_reference,
9047 &draw_info->fill_pattern->tile_offset,exception);
9048 if (attribute_flag[25] != 0)
9050 (void) ConcatenateString(&draw_info->primitive," '");
9051 (void) ConcatenateString(&draw_info->primitive,
9052 argument_list[25].string_reference);
9053 (void) ConcatenateString(&draw_info->primitive,"'");
9055 if (attribute_flag[26] != 0)
9056 draw_info->fill_pattern=CloneImage(
9057 argument_list[26].image_reference,0,0,MagickTrue,exception);
9058 if (attribute_flag[27] != 0)
9059 draw_info->stroke_pattern=CloneImage(
9060 argument_list[27].image_reference,0,0,MagickTrue,exception);
9061 if (attribute_flag[28] != 0)
9062 (void) CloneString(&draw_info->primitive,
9063 argument_list[28].string_reference);
9064 if (attribute_flag[29] != 0)
9065 draw_info->kerning=argument_list[29].real_reference;
9066 if (attribute_flag[30] != 0)
9067 draw_info->interline_spacing=argument_list[30].real_reference;
9068 if (attribute_flag[31] != 0)
9069 draw_info->interword_spacing=argument_list[31].real_reference;
9070 if (attribute_flag[32] != 0)
9071 draw_info->direction=(DirectionType)
9072 argument_list[32].integer_reference;
9073 DrawImage(image,draw_info,exception);
9074 draw_info=DestroyDrawInfo(draw_info);
9077 case 39: /* Equalize */
9079 if (attribute_flag[0] != 0)
9080 channel=(ChannelType) argument_list[0].integer_reference;
9081 channel_mask=SetImageChannelMask(image,channel);
9082 EqualizeImage(image,exception);
9083 (void) SetImageChannelMask(image,channel_mask);
9086 case 40: /* Gamma */
9088 if (attribute_flag[1] != 0)
9089 channel=(ChannelType) argument_list[1].integer_reference;
9090 if (attribute_flag[2] == 0)
9091 argument_list[2].real_reference=1.0;
9092 if (attribute_flag[3] == 0)
9093 argument_list[3].real_reference=1.0;
9094 if (attribute_flag[4] == 0)
9095 argument_list[4].real_reference=1.0;
9096 if (attribute_flag[0] == 0)
9098 (void) FormatLocaleString(message,MagickPathExtent,
9099 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9100 (double) argument_list[3].real_reference,
9101 (double) argument_list[4].real_reference);
9102 argument_list[0].string_reference=message;
9104 (void) GammaImage(image,StringToDouble(
9105 argument_list[0].string_reference,(char **) NULL),exception);
9113 if (attribute_flag[0] == 0)
9115 ThrowPerlException(exception,OptionError,"MapImageRequired",
9119 quantize_info=AcquireQuantizeInfo(info->image_info);
9120 if (attribute_flag[1] != 0)
9121 quantize_info->dither_method=(DitherMethod)
9122 argument_list[1].integer_reference;
9123 (void) RemapImages(quantize_info,image,
9124 argument_list[0].image_reference,exception);
9125 quantize_info=DestroyQuantizeInfo(quantize_info);
9128 case 42: /* MatteFloodfill */
9139 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9141 if (attribute_flag[0] != 0)
9142 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9143 &geometry,exception);
9144 if (attribute_flag[1] != 0)
9145 geometry.x=argument_list[1].integer_reference;
9146 if (attribute_flag[2] != 0)
9147 geometry.y=argument_list[2].integer_reference;
9148 if (image->alpha_trait == UndefinedPixelTrait)
9149 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9150 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9151 geometry.x,geometry.y,&target,exception);
9152 if (attribute_flag[4] != 0)
9153 QueryColorCompliance(argument_list[4].string_reference,
9154 AllCompliance,&target,exception);
9155 if (attribute_flag[3] != 0)
9156 target.alpha=StringToDoubleInterval(
9157 argument_list[3].string_reference,(double) (double) QuantumRange+
9159 if (attribute_flag[5] != 0)
9160 image->fuzz=StringToDoubleInterval(
9161 argument_list[5].string_reference,(double) QuantumRange+1.0);
9163 if (attribute_flag[6] != 0)
9164 invert=(MagickBooleanType) argument_list[6].integer_reference;
9165 channel_mask=SetImageChannelMask(image,AlphaChannel);
9166 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9167 geometry.y,invert,exception);
9168 (void) SetImageChannelMask(image,channel_mask);
9169 draw_info=DestroyDrawInfo(draw_info);
9172 case 43: /* Modulate */
9175 modulate[MagickPathExtent];
9177 geometry_info.rho=100.0;
9178 geometry_info.sigma=100.0;
9179 geometry_info.xi=100.0;
9180 if (attribute_flag[0] != 0)
9181 (void)ParseGeometry(argument_list[0].string_reference,
9183 if (attribute_flag[1] != 0)
9184 geometry_info.xi=argument_list[1].real_reference;
9185 if (attribute_flag[2] != 0)
9186 geometry_info.sigma=argument_list[2].real_reference;
9187 if (attribute_flag[3] != 0)
9189 geometry_info.sigma=argument_list[3].real_reference;
9190 SetImageArtifact(image,"modulate:colorspace","HWB");
9192 if (attribute_flag[4] != 0)
9194 geometry_info.rho=argument_list[4].real_reference;
9195 SetImageArtifact(image,"modulate:colorspace","HSB");
9197 if (attribute_flag[5] != 0)
9199 geometry_info.sigma=argument_list[5].real_reference;
9200 SetImageArtifact(image,"modulate:colorspace","HSL");
9202 if (attribute_flag[6] != 0)
9204 geometry_info.rho=argument_list[6].real_reference;
9205 SetImageArtifact(image,"modulate:colorspace","HWB");
9207 (void) FormatLocaleString(modulate,MagickPathExtent,"%.15g,%.15g,%.15g",
9208 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9209 (void) ModulateImage(image,modulate,exception);
9212 case 44: /* Negate */
9214 if (attribute_flag[0] == 0)
9215 argument_list[0].integer_reference=0;
9216 if (attribute_flag[1] != 0)
9217 channel=(ChannelType) argument_list[1].integer_reference;
9218 channel_mask=SetImageChannelMask(image,channel);
9219 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9220 MagickTrue : MagickFalse,exception);
9221 (void) SetImageChannelMask(image,channel_mask);
9224 case 45: /* Normalize */
9226 if (attribute_flag[0] != 0)
9227 channel=(ChannelType) argument_list[0].integer_reference;
9228 channel_mask=SetImageChannelMask(image,channel);
9229 NormalizeImage(image,exception);
9230 (void) SetImageChannelMask(image,channel_mask);
9233 case 46: /* NumberColors */
9235 case 47: /* Opaque */
9244 (void) QueryColorCompliance("none",AllCompliance,&target,
9246 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9248 if (attribute_flag[0] != 0)
9249 (void) QueryColorCompliance(argument_list[0].string_reference,
9250 AllCompliance,&target,exception);
9251 if (attribute_flag[1] != 0)
9252 (void) QueryColorCompliance(argument_list[1].string_reference,
9253 AllCompliance,&fill_color,exception);
9254 if (attribute_flag[2] != 0)
9255 image->fuzz=StringToDoubleInterval(
9256 argument_list[2].string_reference,(double) QuantumRange+1.0);
9257 if (attribute_flag[3] != 0)
9258 channel=(ChannelType) argument_list[3].integer_reference;
9260 if (attribute_flag[4] != 0)
9261 invert=(MagickBooleanType) argument_list[4].integer_reference;
9262 channel_mask=SetImageChannelMask(image,channel);
9263 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9264 (void) SetImageChannelMask(image,channel_mask);
9267 case 48: /* Quantize */
9272 quantize_info=AcquireQuantizeInfo(info->image_info);
9273 if (attribute_flag[0] != 0)
9274 quantize_info->number_colors=(size_t)
9275 argument_list[0].integer_reference;
9276 if (attribute_flag[1] != 0)
9277 quantize_info->tree_depth=(size_t)
9278 argument_list[1].integer_reference;
9279 if (attribute_flag[2] != 0)
9280 quantize_info->colorspace=(ColorspaceType)
9281 argument_list[2].integer_reference;
9282 if (attribute_flag[3] != 0)
9283 quantize_info->dither_method=(DitherMethod)
9284 argument_list[3].integer_reference;
9285 if (attribute_flag[4] != 0)
9286 quantize_info->measure_error=
9287 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9288 if (attribute_flag[6] != 0)
9289 (void) QueryColorCompliance(argument_list[6].string_reference,
9290 AllCompliance,&image->transparent_color,exception);
9291 if (attribute_flag[7] != 0)
9292 quantize_info->dither_method=(DitherMethod)
9293 argument_list[7].integer_reference;
9294 if (attribute_flag[5] && argument_list[5].integer_reference)
9295 (void) QuantizeImages(quantize_info,image,exception);
9297 if ((image->storage_class == DirectClass) ||
9298 (image->colors > quantize_info->number_colors) ||
9299 (quantize_info->colorspace == GRAYColorspace))
9300 (void) QuantizeImage(quantize_info,image,exception);
9302 CompressImageColormap(image,exception);
9303 quantize_info=DestroyQuantizeInfo(quantize_info);
9306 case 49: /* Raise */
9308 if (attribute_flag[0] != 0)
9309 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9310 &geometry,exception);
9311 if (attribute_flag[1] != 0)
9312 geometry.width=argument_list[1].integer_reference;
9313 if (attribute_flag[2] != 0)
9314 geometry.height=argument_list[2].integer_reference;
9315 if (attribute_flag[3] == 0)
9316 argument_list[3].integer_reference=1;
9317 (void) RaiseImage(image,&geometry,
9318 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9322 case 50: /* Segment */
9329 smoothing_threshold;
9334 cluster_threshold=1.0;
9335 smoothing_threshold=1.5;
9336 colorspace=sRGBColorspace;
9337 verbose=MagickFalse;
9338 if (attribute_flag[0] != 0)
9340 flags=ParseGeometry(argument_list[0].string_reference,
9342 cluster_threshold=geometry_info.rho;
9343 if (flags & SigmaValue)
9344 smoothing_threshold=geometry_info.sigma;
9346 if (attribute_flag[1] != 0)
9347 cluster_threshold=argument_list[1].real_reference;
9348 if (attribute_flag[2] != 0)
9349 smoothing_threshold=argument_list[2].real_reference;
9350 if (attribute_flag[3] != 0)
9351 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9352 if (attribute_flag[4] != 0)
9353 verbose=argument_list[4].integer_reference != 0 ?
9354 MagickTrue : MagickFalse;
9355 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9356 smoothing_threshold,exception);
9359 case 51: /* Signature */
9361 (void) SignatureImage(image,exception);
9364 case 52: /* Solarize */
9366 geometry_info.rho=QuantumRange/2.0;
9367 if (attribute_flag[0] != 0)
9368 flags=ParseGeometry(argument_list[0].string_reference,
9370 if (attribute_flag[1] != 0)
9371 geometry_info.rho=StringToDoubleInterval(
9372 argument_list[1].string_reference,(double) QuantumRange+1.0);
9373 (void) SolarizeImage(image,geometry_info.rho,exception);
9378 (void) SyncImage(image,exception);
9381 case 54: /* Texture */
9383 if (attribute_flag[0] == 0)
9385 TextureImage(image,argument_list[0].image_reference,exception);
9388 case 55: /* Evalute */
9390 MagickEvaluateOperator
9393 op=SetEvaluateOperator;
9394 if (attribute_flag[0] == MagickFalse)
9395 argument_list[0].real_reference=0.0;
9396 if (attribute_flag[1] != MagickFalse)
9397 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9398 if (attribute_flag[2] != MagickFalse)
9399 channel=(ChannelType) argument_list[2].integer_reference;
9400 channel_mask=SetImageChannelMask(image,channel);
9401 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9403 (void) SetImageChannelMask(image,channel_mask);
9406 case 56: /* Transparent */
9417 (void) QueryColorCompliance("none",AllCompliance,&target,
9419 if (attribute_flag[0] != 0)
9420 (void) QueryColorCompliance(argument_list[0].string_reference,
9421 AllCompliance,&target,exception);
9422 opacity=TransparentAlpha;
9423 if (attribute_flag[1] != 0)
9424 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9425 (double) QuantumRange+1.0);
9426 if (attribute_flag[2] != 0)
9427 image->fuzz=StringToDoubleInterval(
9428 argument_list[2].string_reference,(double) QuantumRange+1.0);
9429 if (attribute_flag[3] == 0)
9430 argument_list[3].integer_reference=0;
9432 if (attribute_flag[3] != 0)
9433 invert=(MagickBooleanType) argument_list[3].integer_reference;
9434 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9438 case 57: /* Threshold */
9443 if (attribute_flag[0] == 0)
9444 argument_list[0].string_reference="50%";
9445 if (attribute_flag[1] != 0)
9446 channel=(ChannelType) argument_list[1].integer_reference;
9447 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9448 (double) QuantumRange+1.0);
9449 channel_mask=SetImageChannelMask(image,channel);
9450 (void) BilevelImage(image,threshold,exception);
9451 (void) SetImageChannelMask(image,channel_mask);
9454 case 58: /* Charcoal */
9456 if (attribute_flag[0] != 0)
9458 flags=ParseGeometry(argument_list[0].string_reference,
9460 if ((flags & SigmaValue) == 0)
9461 geometry_info.sigma=1.0;
9463 if (attribute_flag[1] != 0)
9464 geometry_info.rho=argument_list[1].real_reference;
9465 if (attribute_flag[2] != 0)
9466 geometry_info.sigma=argument_list[2].real_reference;
9467 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9473 if (attribute_flag[0] != 0)
9474 image->fuzz=StringToDoubleInterval(
9475 argument_list[0].string_reference,(double) QuantumRange+1.0);
9476 image=TrimImage(image,exception);
9481 PixelInterpolateMethod
9484 if (attribute_flag[0] != 0)
9486 flags=ParseGeometry(argument_list[0].string_reference,
9488 if ((flags & SigmaValue) == 0)
9489 geometry_info.sigma=1.0;
9491 if (attribute_flag[1] != 0)
9492 geometry_info.rho=argument_list[1].real_reference;
9493 if (attribute_flag[2] != 0)
9494 geometry_info.sigma=argument_list[2].real_reference;
9495 method=UndefinedInterpolatePixel;
9496 if (attribute_flag[3] != 0)
9497 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9498 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9502 case 61: /* Separate */
9504 if (attribute_flag[0] != 0)
9505 channel=(ChannelType) argument_list[0].integer_reference;
9506 image=SeparateImage(image,channel,exception);
9509 case 63: /* Stereo */
9511 if (attribute_flag[0] == 0)
9513 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9517 if (attribute_flag[1] != 0)
9518 geometry.x=argument_list[1].integer_reference;
9519 if (attribute_flag[2] != 0)
9520 geometry.y=argument_list[2].integer_reference;
9521 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9522 geometry.x,geometry.y,exception);
9525 case 64: /* Stegano */
9527 if (attribute_flag[0] == 0)
9529 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9533 if (attribute_flag[1] == 0)
9534 argument_list[1].integer_reference=0;
9535 image->offset=argument_list[1].integer_reference;
9536 image=SteganoImage(image,argument_list[0].image_reference,exception);
9539 case 65: /* Deconstruct */
9541 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9544 case 66: /* GaussianBlur */
9546 if (attribute_flag[0] != 0)
9548 flags=ParseGeometry(argument_list[0].string_reference,
9550 if ((flags & SigmaValue) == 0)
9551 geometry_info.sigma=1.0;
9553 if (attribute_flag[1] != 0)
9554 geometry_info.rho=argument_list[1].real_reference;
9555 if (attribute_flag[2] != 0)
9556 geometry_info.sigma=argument_list[2].real_reference;
9557 if (attribute_flag[3] != 0)
9558 channel=(ChannelType) argument_list[3].integer_reference;
9559 channel_mask=SetImageChannelMask(image,channel);
9560 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9562 if (image != (Image *) NULL)
9563 (void) SetImageChannelMask(image,channel_mask);
9566 case 67: /* Convolve */
9571 kernel=(KernelInfo *) NULL;
9572 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9574 if (attribute_flag[0] != 0)
9582 kernel=AcquireKernelInfo((const char *) NULL,exception);
9583 if (kernel == (KernelInfo *) NULL)
9585 av=(AV *) argument_list[0].array_reference;
9586 order=(size_t) sqrt(av_len(av)+1);
9587 kernel->width=order;
9588 kernel->height=order;
9589 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9590 order*sizeof(*kernel->values));
9591 if (kernel->values == (MagickRealType *) NULL)
9593 kernel=DestroyKernelInfo(kernel);
9594 ThrowPerlException(exception,ResourceLimitFatalError,
9595 "MemoryAllocationFailed",PackageName);
9598 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9599 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9600 for ( ; j < (ssize_t) (order*order); j++)
9601 kernel->values[j]=0.0;
9603 if (attribute_flag[1] != 0)
9604 channel=(ChannelType) argument_list[1].integer_reference;
9605 if (attribute_flag[2] != 0)
9606 SetImageArtifact(image,"filter:blur",
9607 argument_list[2].string_reference);
9608 if (attribute_flag[3] != 0)
9610 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9612 if (kernel == (KernelInfo *) NULL)
9615 channel_mask=SetImageChannelMask(image,channel);
9616 image=ConvolveImage(image,kernel,exception);
9617 if (image != (Image *) NULL)
9618 (void) SetImageChannelMask(image,channel_mask);
9619 kernel=DestroyKernelInfo(kernel);
9622 case 68: /* Profile */
9637 if (attribute_flag[0] != 0)
9638 name=argument_list[0].string_reference;
9639 if (attribute_flag[2] != 0)
9640 image->rendering_intent=(RenderingIntent)
9641 argument_list[2].integer_reference;
9642 if (attribute_flag[3] != 0)
9643 image->black_point_compensation=
9644 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9645 if (attribute_flag[1] != 0)
9647 if (argument_list[1].length == 0)
9650 Remove a profile from the image.
9652 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9657 Associate user supplied profile with the image.
9659 profile=AcquireStringInfo(argument_list[1].length);
9660 SetStringInfoDatum(profile,(const unsigned char *)
9661 argument_list[1].string_reference);
9662 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9663 (size_t) GetStringInfoLength(profile),exception);
9664 profile=DestroyStringInfo(profile);
9668 Associate a profile with the image.
9670 profile_info=CloneImageInfo(info ? info->image_info :
9671 (ImageInfo *) NULL);
9672 profile_image=ReadImages(profile_info,name,exception);
9673 if (profile_image == (Image *) NULL)
9675 ResetImageProfileIterator(profile_image);
9676 name=GetNextImageProfile(profile_image);
9677 while (name != (const char *) NULL)
9682 profile=GetImageProfile(profile_image,name);
9683 if (profile != (const StringInfo *) NULL)
9684 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9685 (size_t) GetStringInfoLength(profile),exception);
9686 name=GetNextImageProfile(profile_image);
9688 profile_image=DestroyImage(profile_image);
9689 profile_info=DestroyImageInfo(profile_info);
9692 case 69: /* UnsharpMask */
9694 if (attribute_flag[0] != 0)
9696 flags=ParseGeometry(argument_list[0].string_reference,
9698 if ((flags & SigmaValue) == 0)
9699 geometry_info.sigma=1.0;
9700 if ((flags & XiValue) == 0)
9701 geometry_info.xi=1.0;
9702 if ((flags & PsiValue) == 0)
9703 geometry_info.psi=0.5;
9705 if (attribute_flag[1] != 0)
9706 geometry_info.rho=argument_list[1].real_reference;
9707 if (attribute_flag[2] != 0)
9708 geometry_info.sigma=argument_list[2].real_reference;
9709 if (attribute_flag[3] != 0)
9710 geometry_info.xi=argument_list[3].real_reference;
9711 if (attribute_flag[4] != 0)
9712 geometry_info.psi=argument_list[4].real_reference;
9713 if (attribute_flag[5] != 0)
9714 channel=(ChannelType) argument_list[5].integer_reference;
9715 channel_mask=SetImageChannelMask(image,channel);
9716 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9717 geometry_info.xi,geometry_info.psi,exception);
9718 if (image != (Image *) NULL)
9719 (void) SetImageChannelMask(image,channel_mask);
9722 case 70: /* MotionBlur */
9724 if (attribute_flag[0] != 0)
9726 flags=ParseGeometry(argument_list[0].string_reference,
9728 if ((flags & SigmaValue) == 0)
9729 geometry_info.sigma=1.0;
9730 if ((flags & XiValue) == 0)
9731 geometry_info.xi=1.0;
9733 if (attribute_flag[1] != 0)
9734 geometry_info.rho=argument_list[1].real_reference;
9735 if (attribute_flag[2] != 0)
9736 geometry_info.sigma=argument_list[2].real_reference;
9737 if (attribute_flag[3] != 0)
9738 geometry_info.xi=argument_list[3].real_reference;
9739 if (attribute_flag[4] != 0)
9740 channel=(ChannelType) argument_list[4].integer_reference;
9741 channel_mask=SetImageChannelMask(image,channel);
9742 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9743 geometry_info.xi,exception);
9744 if (image != (Image *) NULL)
9745 (void) SetImageChannelMask(image,channel_mask);
9748 case 71: /* OrderedDither */
9750 if (attribute_flag[0] == 0)
9751 argument_list[0].string_reference="o8x8";
9752 if (attribute_flag[1] != 0)
9753 channel=(ChannelType) argument_list[1].integer_reference;
9754 channel_mask=SetImageChannelMask(image,channel);
9755 (void) OrderedDitherImage(image,argument_list[0].string_reference,
9757 (void) SetImageChannelMask(image,channel_mask);
9760 case 72: /* Shave */
9762 if (attribute_flag[0] != 0)
9763 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9764 &geometry,exception);
9765 if (attribute_flag[1] != 0)
9766 geometry.width=argument_list[1].integer_reference;
9767 if (attribute_flag[2] != 0)
9768 geometry.height=argument_list[2].integer_reference;
9769 image=ShaveImage(image,&geometry,exception);
9772 case 73: /* Level */
9780 white_point=(double) image->columns*image->rows;
9782 if (attribute_flag[0] != 0)
9784 flags=ParseGeometry(argument_list[0].string_reference,
9786 black_point=geometry_info.rho;
9787 if ((flags & SigmaValue) != 0)
9788 white_point=geometry_info.sigma;
9789 if ((flags & XiValue) != 0)
9790 gamma=geometry_info.xi;
9791 if ((flags & PercentValue) != 0)
9793 black_point*=(double) (QuantumRange/100.0);
9794 white_point*=(double) (QuantumRange/100.0);
9796 if ((flags & SigmaValue) == 0)
9797 white_point=(double) QuantumRange-black_point;
9799 if (attribute_flag[1] != 0)
9800 black_point=argument_list[1].real_reference;
9801 if (attribute_flag[2] != 0)
9802 white_point=argument_list[2].real_reference;
9803 if (attribute_flag[3] != 0)
9804 gamma=argument_list[3].real_reference;
9805 if (attribute_flag[4] != 0)
9806 channel=(ChannelType) argument_list[4].integer_reference;
9807 if (attribute_flag[5] != 0)
9809 argument_list[0].real_reference=argument_list[5].real_reference;
9810 attribute_flag[0]=attribute_flag[5];
9812 channel_mask=SetImageChannelMask(image,channel);
9813 (void) LevelImage(image,black_point,white_point,gamma,exception);
9814 (void) SetImageChannelMask(image,channel_mask);
9819 if (attribute_flag[0] == 0)
9820 argument_list[0].string_reference="#1";
9821 if (attribute_flag[1] == 0)
9822 argument_list[1].integer_reference=MagickTrue;
9823 (void) ClipImagePath(image,argument_list[0].string_reference,
9824 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9828 case 75: /* AffineTransform */
9833 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9835 if (attribute_flag[0] != 0)
9840 av=(AV *) argument_list[0].array_reference;
9841 if ((av_len(av) != 3) && (av_len(av) != 5))
9843 ThrowPerlException(exception,OptionError,
9844 "affine matrix must have 4 or 6 elements",PackageName);
9847 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9848 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9849 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9850 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9851 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9852 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9854 ThrowPerlException(exception,OptionError,
9855 "affine matrix is singular",PackageName);
9858 if (av_len(av) == 5)
9860 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9861 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9864 for (j=1; j < 6; j++)
9866 if (attribute_flag[j] == 0)
9868 value=argument_list[j].string_reference;
9869 angle=argument_list[j].real_reference;
9870 current=draw_info->affine;
9871 GetAffineMatrix(&affine);
9879 flags=ParseGeometry(value,&geometry_info);
9880 affine.tx=geometry_info.xi;
9881 affine.ty=geometry_info.psi;
9882 if ((flags & PsiValue) == 0)
9883 affine.ty=affine.tx;
9891 flags=ParseGeometry(value,&geometry_info);
9892 affine.sx=geometry_info.rho;
9893 affine.sy=geometry_info.sigma;
9894 if ((flags & SigmaValue) == 0)
9895 affine.sy=affine.sx;
9905 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9906 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9907 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9908 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9916 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9924 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9928 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9929 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9930 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9931 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9932 draw_info->affine.tx=
9933 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9934 draw_info->affine.ty=
9935 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9937 if (attribute_flag[6] != 0)
9938 image->interpolate=(PixelInterpolateMethod)
9939 argument_list[6].integer_reference;
9940 if (attribute_flag[7] != 0)
9941 QueryColorCompliance(argument_list[7].string_reference,
9942 AllCompliance,&image->background_color,exception);
9943 image=AffineTransformImage(image,&draw_info->affine,exception);
9944 draw_info=DestroyDrawInfo(draw_info);
9947 case 76: /* Difference */
9949 if (attribute_flag[0] == 0)
9951 ThrowPerlException(exception,OptionError,
9952 "ReferenceImageRequired",PackageName);
9955 if (attribute_flag[1] != 0)
9956 image->fuzz=StringToDoubleInterval(
9957 argument_list[1].string_reference,(double) QuantumRange+1.0);
9958 (void) SetImageColorMetric(image,argument_list[0].image_reference,
9962 case 77: /* AdaptiveThreshold */
9964 if (attribute_flag[0] != 0)
9966 flags=ParseGeometry(argument_list[0].string_reference,
9968 if ((flags & PercentValue) != 0)
9969 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9971 if (attribute_flag[1] != 0)
9972 geometry_info.rho=argument_list[1].integer_reference;
9973 if (attribute_flag[2] != 0)
9974 geometry_info.sigma=argument_list[2].integer_reference;
9975 if (attribute_flag[3] != 0)
9976 geometry_info.xi=argument_list[3].integer_reference;;
9977 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9978 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9981 case 78: /* Resample */
9987 if (attribute_flag[0] != 0)
9989 flags=ParseGeometry(argument_list[0].string_reference,
9991 if ((flags & SigmaValue) == 0)
9992 geometry_info.sigma=geometry_info.rho;
9994 if (attribute_flag[1] != 0)
9995 geometry_info.rho=argument_list[1].real_reference;
9996 if (attribute_flag[2] != 0)
9997 geometry_info.sigma=argument_list[2].real_reference;
9998 if (attribute_flag[3] == 0)
9999 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
10000 if (attribute_flag[4] == 0)
10001 SetImageArtifact(image,"filter:support",
10002 argument_list[4].string_reference);
10003 width=(size_t) (geometry_info.rho*image->columns/
10004 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
10005 height=(size_t) (geometry_info.sigma*image->rows/
10006 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
10007 image=ResizeImage(image,width,height,(FilterType)
10008 argument_list[3].integer_reference,exception);
10009 if (image != (Image *) NULL)
10011 image->resolution.x=geometry_info.rho;
10012 image->resolution.y=geometry_info.sigma;
10016 case 79: /* Describe */
10018 if (attribute_flag[0] == 0)
10019 argument_list[0].file_reference=(FILE *) NULL;
10020 if (attribute_flag[1] != 0)
10021 (void) SetImageArtifact(image,"identify:features",
10022 argument_list[1].string_reference);
10023 (void) IdentifyImage(image,argument_list[0].file_reference,
10024 MagickTrue,exception);
10027 case 80: /* BlackThreshold */
10029 if (attribute_flag[0] == 0)
10030 argument_list[0].string_reference="50%";
10031 if (attribute_flag[2] != 0)
10032 channel=(ChannelType) argument_list[2].integer_reference;
10033 channel_mask=SetImageChannelMask(image,channel);
10034 BlackThresholdImage(image,argument_list[0].string_reference,
10036 (void) SetImageChannelMask(image,channel_mask);
10039 case 81: /* WhiteThreshold */
10041 if (attribute_flag[0] == 0)
10042 argument_list[0].string_reference="50%";
10043 if (attribute_flag[2] != 0)
10044 channel=(ChannelType) argument_list[2].integer_reference;
10045 channel_mask=SetImageChannelMask(image,channel);
10046 WhiteThresholdImage(image,argument_list[0].string_reference,
10048 (void) SetImageChannelMask(image,channel_mask);
10051 case 82: /* RotationalBlur */
10053 if (attribute_flag[0] != 0)
10055 flags=ParseGeometry(argument_list[0].string_reference,
10058 if (attribute_flag[1] != 0)
10059 geometry_info.rho=argument_list[1].real_reference;
10060 if (attribute_flag[2] != 0)
10061 channel=(ChannelType) argument_list[2].integer_reference;
10062 channel_mask=SetImageChannelMask(image,channel);
10063 image=RotationalBlurImage(image,geometry_info.rho,exception);
10064 if (image != (Image *) NULL)
10065 (void) SetImageChannelMask(image,channel_mask);
10068 case 83: /* Thumbnail */
10070 if (attribute_flag[0] != 0)
10071 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10072 &geometry,exception);
10073 if (attribute_flag[1] != 0)
10074 geometry.width=argument_list[1].integer_reference;
10075 if (attribute_flag[2] != 0)
10076 geometry.height=argument_list[2].integer_reference;
10077 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10080 case 84: /* Strip */
10082 (void) StripImage(image,exception);
10085 case 85: /* Tint */
10090 GetPixelInfo(image,&tint);
10091 if (attribute_flag[0] != 0)
10092 (void) QueryColorCompliance(argument_list[0].string_reference,
10093 AllCompliance,&tint,exception);
10094 if (attribute_flag[1] == 0)
10095 argument_list[1].string_reference="100";
10096 image=TintImage(image,argument_list[1].string_reference,&tint,
10100 case 86: /* Channel */
10102 if (attribute_flag[0] != 0)
10103 channel=(ChannelType) argument_list[0].integer_reference;
10104 image=SeparateImage(image,channel,exception);
10107 case 87: /* Splice */
10109 if (attribute_flag[7] != 0)
10110 image->gravity=(GravityType) argument_list[7].integer_reference;
10111 if (attribute_flag[0] != 0)
10112 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10113 &geometry,exception);
10114 if (attribute_flag[1] != 0)
10115 geometry.width=argument_list[1].integer_reference;
10116 if (attribute_flag[2] != 0)
10117 geometry.height=argument_list[2].integer_reference;
10118 if (attribute_flag[3] != 0)
10119 geometry.x=argument_list[3].integer_reference;
10120 if (attribute_flag[4] != 0)
10121 geometry.y=argument_list[4].integer_reference;
10122 if (attribute_flag[5] != 0)
10123 image->fuzz=StringToDoubleInterval(
10124 argument_list[5].string_reference,(double) QuantumRange+1.0);
10125 if (attribute_flag[6] != 0)
10126 (void) QueryColorCompliance(argument_list[6].string_reference,
10127 AllCompliance,&image->background_color,exception);
10128 image=SpliceImage(image,&geometry,exception);
10131 case 88: /* Posterize */
10133 if (attribute_flag[0] == 0)
10134 argument_list[0].integer_reference=3;
10135 if (attribute_flag[1] == 0)
10136 argument_list[1].integer_reference=0;
10137 (void) PosterizeImage(image,argument_list[0].integer_reference,
10138 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10139 NoDitherMethod,exception);
10142 case 89: /* Shadow */
10144 if (attribute_flag[0] != 0)
10146 flags=ParseGeometry(argument_list[0].string_reference,
10148 if ((flags & SigmaValue) == 0)
10149 geometry_info.sigma=1.0;
10150 if ((flags & XiValue) == 0)
10151 geometry_info.xi=4.0;
10152 if ((flags & PsiValue) == 0)
10153 geometry_info.psi=4.0;
10155 if (attribute_flag[1] != 0)
10156 geometry_info.rho=argument_list[1].real_reference;
10157 if (attribute_flag[2] != 0)
10158 geometry_info.sigma=argument_list[2].real_reference;
10159 if (attribute_flag[3] != 0)
10160 geometry_info.xi=argument_list[3].integer_reference;
10161 if (attribute_flag[4] != 0)
10162 geometry_info.psi=argument_list[4].integer_reference;
10163 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10164 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10165 ceil(geometry_info.psi-0.5),exception);
10168 case 90: /* Identify */
10170 if (attribute_flag[0] == 0)
10171 argument_list[0].file_reference=(FILE *) NULL;
10172 if (attribute_flag[1] != 0)
10173 (void) SetImageArtifact(image,"identify:features",
10174 argument_list[1].string_reference);
10175 if ((attribute_flag[2] != 0) &&
10176 (argument_list[2].integer_reference != 0))
10177 (void) SetImageArtifact(image,"identify:unique","true");
10178 (void) IdentifyImage(image,argument_list[0].file_reference,
10179 MagickTrue,exception);
10182 case 91: /* SepiaTone */
10184 if (attribute_flag[0] == 0)
10185 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10186 image=SepiaToneImage(image,argument_list[0].real_reference,
10190 case 92: /* SigmoidalContrast */
10195 if (attribute_flag[0] != 0)
10197 flags=ParseGeometry(argument_list[0].string_reference,
10199 if ((flags & SigmaValue) == 0)
10200 geometry_info.sigma=QuantumRange/2.0;
10201 if ((flags & PercentValue) != 0)
10202 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10204 if (attribute_flag[1] != 0)
10205 geometry_info.rho=argument_list[1].real_reference;
10206 if (attribute_flag[2] != 0)
10207 geometry_info.sigma=argument_list[2].real_reference;
10208 if (attribute_flag[3] != 0)
10209 channel=(ChannelType) argument_list[3].integer_reference;
10210 sharpen=MagickTrue;
10211 if (attribute_flag[4] != 0)
10212 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10214 channel_mask=SetImageChannelMask(image,channel);
10215 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10216 geometry_info.sigma,exception);
10217 (void) SetImageChannelMask(image,channel_mask);
10220 case 93: /* Extent */
10222 if (attribute_flag[7] != 0)
10223 image->gravity=(GravityType) argument_list[7].integer_reference;
10224 if (attribute_flag[0] != 0)
10229 flags=ParseGravityGeometry(image,
10230 argument_list[0].string_reference,&geometry,exception);
10232 if (geometry.width == 0)
10233 geometry.width=image->columns;
10234 if (geometry.height == 0)
10235 geometry.height=image->rows;
10237 if (attribute_flag[1] != 0)
10238 geometry.width=argument_list[1].integer_reference;
10239 if (attribute_flag[2] != 0)
10240 geometry.height=argument_list[2].integer_reference;
10241 if (attribute_flag[3] != 0)
10242 geometry.x=argument_list[3].integer_reference;
10243 if (attribute_flag[4] != 0)
10244 geometry.y=argument_list[4].integer_reference;
10245 if (attribute_flag[5] != 0)
10246 image->fuzz=StringToDoubleInterval(
10247 argument_list[5].string_reference,(double) QuantumRange+1.0);
10248 if (attribute_flag[6] != 0)
10249 (void) QueryColorCompliance(argument_list[6].string_reference,
10250 AllCompliance,&image->background_color,exception);
10251 image=ExtentImage(image,&geometry,exception);
10254 case 94: /* Vignette */
10256 if (attribute_flag[0] != 0)
10258 flags=ParseGeometry(argument_list[0].string_reference,
10260 if ((flags & SigmaValue) == 0)
10261 geometry_info.sigma=1.0;
10262 if ((flags & XiValue) == 0)
10263 geometry_info.xi=0.1*image->columns;
10264 if ((flags & PsiValue) == 0)
10265 geometry_info.psi=0.1*image->rows;
10267 if (attribute_flag[1] != 0)
10268 geometry_info.rho=argument_list[1].real_reference;
10269 if (attribute_flag[2] != 0)
10270 geometry_info.sigma=argument_list[2].real_reference;
10271 if (attribute_flag[3] != 0)
10272 geometry_info.xi=argument_list[3].integer_reference;
10273 if (attribute_flag[4] != 0)
10274 geometry_info.psi=argument_list[4].integer_reference;
10275 if (attribute_flag[5] != 0)
10276 (void) QueryColorCompliance(argument_list[5].string_reference,
10277 AllCompliance,&image->background_color,exception);
10278 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10279 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10280 ceil(geometry_info.psi-0.5),exception);
10283 case 95: /* ContrastStretch */
10290 white_point=(double) image->columns*image->rows;
10291 if (attribute_flag[0] != 0)
10293 flags=ParseGeometry(argument_list[0].string_reference,
10295 black_point=geometry_info.rho;
10296 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10298 if ((flags & PercentValue) != 0)
10300 black_point*=(double) image->columns*image->rows/100.0;
10301 white_point*=(double) image->columns*image->rows/100.0;
10303 white_point=(double) image->columns*image->rows-
10306 if (attribute_flag[1] != 0)
10307 black_point=argument_list[1].real_reference;
10308 if (attribute_flag[2] != 0)
10309 white_point=argument_list[2].real_reference;
10310 if (attribute_flag[4] != 0)
10311 channel=(ChannelType) argument_list[4].integer_reference;
10312 channel_mask=SetImageChannelMask(image,channel);
10313 (void) ContrastStretchImage(image,black_point,white_point,exception);
10314 (void) SetImageChannelMask(image,channel_mask);
10317 case 96: /* Sans0 */
10321 case 97: /* Sans1 */
10325 case 98: /* AdaptiveSharpen */
10327 if (attribute_flag[0] != 0)
10329 flags=ParseGeometry(argument_list[0].string_reference,
10331 if ((flags & SigmaValue) == 0)
10332 geometry_info.sigma=1.0;
10333 if ((flags & XiValue) == 0)
10334 geometry_info.xi=0.0;
10336 if (attribute_flag[1] != 0)
10337 geometry_info.rho=argument_list[1].real_reference;
10338 if (attribute_flag[2] != 0)
10339 geometry_info.sigma=argument_list[2].real_reference;
10340 if (attribute_flag[3] != 0)
10341 geometry_info.xi=argument_list[3].real_reference;
10342 if (attribute_flag[4] != 0)
10343 channel=(ChannelType) argument_list[4].integer_reference;
10344 channel_mask=SetImageChannelMask(image,channel);
10345 image=AdaptiveSharpenImage(image,geometry_info.rho,
10346 geometry_info.sigma,exception);
10347 if (image != (Image *) NULL)
10348 (void) SetImageChannelMask(image,channel_mask);
10351 case 99: /* Transpose */
10353 image=TransposeImage(image,exception);
10356 case 100: /* Tranverse */
10358 image=TransverseImage(image,exception);
10361 case 101: /* AutoOrient */
10363 image=AutoOrientImage(image,image->orientation,exception);
10366 case 102: /* AdaptiveBlur */
10368 if (attribute_flag[0] != 0)
10370 flags=ParseGeometry(argument_list[0].string_reference,
10372 if ((flags & SigmaValue) == 0)
10373 geometry_info.sigma=1.0;
10374 if ((flags & XiValue) == 0)
10375 geometry_info.xi=0.0;
10377 if (attribute_flag[1] != 0)
10378 geometry_info.rho=argument_list[1].real_reference;
10379 if (attribute_flag[2] != 0)
10380 geometry_info.sigma=argument_list[2].real_reference;
10381 if (attribute_flag[3] != 0)
10382 channel=(ChannelType) argument_list[3].integer_reference;
10383 channel_mask=SetImageChannelMask(image,channel);
10384 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10386 if (image != (Image *) NULL)
10387 (void) SetImageChannelMask(image,channel_mask);
10390 case 103: /* Sketch */
10392 if (attribute_flag[0] != 0)
10394 flags=ParseGeometry(argument_list[0].string_reference,
10396 if ((flags & SigmaValue) == 0)
10397 geometry_info.sigma=1.0;
10398 if ((flags & XiValue) == 0)
10399 geometry_info.xi=1.0;
10401 if (attribute_flag[1] != 0)
10402 geometry_info.rho=argument_list[1].real_reference;
10403 if (attribute_flag[2] != 0)
10404 geometry_info.sigma=argument_list[2].real_reference;
10405 if (attribute_flag[3] != 0)
10406 geometry_info.xi=argument_list[3].real_reference;
10407 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10408 geometry_info.xi,exception);
10411 case 104: /* UniqueColors */
10413 image=UniqueImageColors(image,exception);
10416 case 105: /* AdaptiveResize */
10418 if (attribute_flag[0] != 0)
10419 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10420 &geometry,exception);
10421 if (attribute_flag[1] != 0)
10422 geometry.width=argument_list[1].integer_reference;
10423 if (attribute_flag[2] != 0)
10424 geometry.height=argument_list[2].integer_reference;
10425 if (attribute_flag[3] != 0)
10426 image->filter=(FilterType) argument_list[4].integer_reference;
10427 if (attribute_flag[4] != 0)
10428 SetImageArtifact(image,"filter:support",
10429 argument_list[4].string_reference);
10430 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10434 case 106: /* ClipMask */
10439 if (attribute_flag[0] == 0)
10441 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10443 goto PerlException;
10445 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10447 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10448 mask_image=DestroyImage(mask_image);
10451 case 107: /* LinearStretch */
10458 white_point=(double) image->columns*image->rows;
10459 if (attribute_flag[0] != 0)
10461 flags=ParseGeometry(argument_list[0].string_reference,
10463 if ((flags & SigmaValue) != 0)
10464 white_point=geometry_info.sigma;
10465 if ((flags & PercentValue) != 0)
10467 black_point*=(double) image->columns*image->rows/100.0;
10468 white_point*=(double) image->columns*image->rows/100.0;
10470 if ((flags & SigmaValue) == 0)
10471 white_point=(double) image->columns*image->rows-black_point;
10473 if (attribute_flag[1] != 0)
10474 black_point=argument_list[1].real_reference;
10475 if (attribute_flag[2] != 0)
10476 white_point=argument_list[2].real_reference;
10477 (void) LinearStretchImage(image,black_point,white_point,exception);
10480 case 108: /* ColorMatrix */
10494 if (attribute_flag[0] == 0)
10496 av=(AV *) argument_list[0].array_reference;
10497 order=(size_t) sqrt(av_len(av)+1);
10498 color_matrix=(double *) AcquireQuantumMemory(order,order*
10499 sizeof(*color_matrix));
10500 if (color_matrix == (double *) NULL)
10502 ThrowPerlException(exception,ResourceLimitFatalError,
10503 "MemoryAllocationFailed",PackageName);
10504 goto PerlException;
10506 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10507 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10508 for ( ; j < (ssize_t) (order*order); j++)
10509 color_matrix[j]=0.0;
10510 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10511 if (kernel_info == (KernelInfo *) NULL)
10513 kernel_info->width=order;
10514 kernel_info->height=order;
10515 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10516 order*sizeof(*kernel_info->values));
10517 if (kernel_info->values != (MagickRealType *) NULL)
10519 for (i=0; i < (ssize_t) (order*order); i++)
10520 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10521 image=ColorMatrixImage(image,kernel_info,exception);
10523 kernel_info=DestroyKernelInfo(kernel_info);
10524 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10527 case 109: /* Mask */
10532 if (attribute_flag[0] == 0)
10534 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10536 goto PerlException;
10538 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10539 MagickTrue,exception);
10540 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10541 mask_image=DestroyImage(mask_image);
10544 case 110: /* Polaroid */
10555 PixelInterpolateMethod
10558 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10559 (DrawInfo *) NULL);
10560 caption=(char *) NULL;
10561 if (attribute_flag[0] != 0)
10562 caption=InterpretImageProperties(info ? info->image_info :
10563 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10566 if (attribute_flag[1] != 0)
10567 angle=argument_list[1].real_reference;
10568 if (attribute_flag[2] != 0)
10569 (void) CloneString(&draw_info->font,
10570 argument_list[2].string_reference);
10571 if (attribute_flag[3] != 0)
10572 (void) QueryColorCompliance(argument_list[3].string_reference,
10573 AllCompliance,&draw_info->stroke,exception);
10574 if (attribute_flag[4] != 0)
10575 (void) QueryColorCompliance(argument_list[4].string_reference,
10576 AllCompliance,&draw_info->fill,exception);
10577 if (attribute_flag[5] != 0)
10578 draw_info->stroke_width=argument_list[5].real_reference;
10579 if (attribute_flag[6] != 0)
10580 draw_info->pointsize=argument_list[6].real_reference;
10581 if (attribute_flag[7] != 0)
10582 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10583 if (attribute_flag[8] != 0)
10584 (void) QueryColorCompliance(argument_list[8].string_reference,
10585 AllCompliance,&image->background_color,exception);
10586 method=UndefinedInterpolatePixel;
10587 if (attribute_flag[9] != 0)
10588 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10589 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10590 draw_info=DestroyDrawInfo(draw_info);
10591 if (caption != (char *) NULL)
10592 caption=DestroyString(caption);
10595 case 111: /* FloodfillPaint */
10606 draw_info=CloneDrawInfo(info ? info->image_info :
10607 (ImageInfo *) NULL,(DrawInfo *) NULL);
10608 if (attribute_flag[0] != 0)
10609 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10610 &geometry,exception);
10611 if (attribute_flag[1] != 0)
10612 geometry.x=argument_list[1].integer_reference;
10613 if (attribute_flag[2] != 0)
10614 geometry.y=argument_list[2].integer_reference;
10615 if (attribute_flag[3] != 0)
10616 (void) QueryColorCompliance(argument_list[3].string_reference,
10617 AllCompliance,&draw_info->fill,exception);
10618 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10619 geometry.x,geometry.y,&target,exception);
10620 if (attribute_flag[4] != 0)
10621 QueryColorCompliance(argument_list[4].string_reference,
10622 AllCompliance,&target,exception);
10623 if (attribute_flag[5] != 0)
10624 image->fuzz=StringToDoubleInterval(
10625 argument_list[5].string_reference,(double) QuantumRange+1.0);
10626 if (attribute_flag[6] != 0)
10627 channel=(ChannelType) argument_list[6].integer_reference;
10628 invert=MagickFalse;
10629 if (attribute_flag[7] != 0)
10630 invert=(MagickBooleanType) argument_list[7].integer_reference;
10631 channel_mask=SetImageChannelMask(image,channel);
10632 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10633 geometry.y,invert,exception);
10634 (void) SetImageChannelMask(image,channel_mask);
10635 draw_info=DestroyDrawInfo(draw_info);
10638 case 112: /* Distort */
10650 number_coordinates;
10655 if (attribute_flag[0] == 0)
10657 method=UndefinedDistortion;
10658 if (attribute_flag[1] != 0)
10659 method=(DistortMethod) argument_list[1].integer_reference;
10660 av=(AV *) argument_list[0].array_reference;
10661 number_coordinates=(size_t) av_len(av)+1;
10662 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10663 sizeof(*coordinates));
10664 if (coordinates == (double *) NULL)
10666 ThrowPerlException(exception,ResourceLimitFatalError,
10667 "MemoryAllocationFailed",PackageName);
10668 goto PerlException;
10670 for (j=0; j < (ssize_t) number_coordinates; j++)
10671 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10672 virtual_pixel=UndefinedVirtualPixelMethod;
10673 if (attribute_flag[2] != 0)
10674 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10675 argument_list[2].integer_reference,exception);
10676 image=DistortImage(image,method,number_coordinates,coordinates,
10677 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10679 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10680 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10682 coordinates=(double *) RelinquishMagickMemory(coordinates);
10685 case 113: /* Clut */
10687 PixelInterpolateMethod
10690 if (attribute_flag[0] == 0)
10692 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10694 goto PerlException;
10696 method=UndefinedInterpolatePixel;
10697 if (attribute_flag[1] != 0)
10698 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10699 if (attribute_flag[2] != 0)
10700 channel=(ChannelType) argument_list[2].integer_reference;
10701 channel_mask=SetImageChannelMask(image,channel);
10702 (void) ClutImage(image,argument_list[0].image_reference,method,
10704 (void) SetImageChannelMask(image,channel_mask);
10707 case 114: /* LiquidRescale */
10709 if (attribute_flag[0] != 0)
10710 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10711 &geometry,exception);
10712 if (attribute_flag[1] != 0)
10713 geometry.width=argument_list[1].integer_reference;
10714 if (attribute_flag[2] != 0)
10715 geometry.height=argument_list[2].integer_reference;
10716 if (attribute_flag[3] == 0)
10717 argument_list[3].real_reference=1.0;
10718 if (attribute_flag[4] == 0)
10719 argument_list[4].real_reference=0.0;
10720 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10721 argument_list[3].real_reference,argument_list[4].real_reference,
10725 case 115: /* EncipherImage */
10727 (void) EncipherImage(image,argument_list[0].string_reference,
10731 case 116: /* DecipherImage */
10733 (void) DecipherImage(image,argument_list[0].string_reference,
10737 case 117: /* Deskew */
10739 geometry_info.rho=QuantumRange/2.0;
10740 if (attribute_flag[0] != 0)
10741 flags=ParseGeometry(argument_list[0].string_reference,
10743 if (attribute_flag[1] != 0)
10744 geometry_info.rho=StringToDoubleInterval(
10745 argument_list[1].string_reference,(double) QuantumRange+1.0);
10746 image=DeskewImage(image,geometry_info.rho,exception);
10749 case 118: /* Remap */
10754 if (attribute_flag[0] == 0)
10756 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10758 goto PerlException;
10760 quantize_info=AcquireQuantizeInfo(info->image_info);
10761 if (attribute_flag[1] != 0)
10762 quantize_info->dither_method=(DitherMethod)
10763 argument_list[1].integer_reference;
10764 (void) RemapImages(quantize_info,image,
10765 argument_list[0].image_reference,exception);
10766 quantize_info=DestroyQuantizeInfo(quantize_info);
10769 case 119: /* SparseColor */
10781 number_coordinates;
10786 if (attribute_flag[0] == 0)
10788 method=UndefinedColorInterpolate;
10789 if (attribute_flag[1] != 0)
10790 method=(SparseColorMethod) argument_list[1].integer_reference;
10791 av=(AV *) argument_list[0].array_reference;
10792 number_coordinates=(size_t) av_len(av)+1;
10793 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10794 sizeof(*coordinates));
10795 if (coordinates == (double *) NULL)
10797 ThrowPerlException(exception,ResourceLimitFatalError,
10798 "MemoryAllocationFailed",PackageName);
10799 goto PerlException;
10801 for (j=0; j < (ssize_t) number_coordinates; j++)
10802 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10803 virtual_pixel=UndefinedVirtualPixelMethod;
10804 if (attribute_flag[2] != 0)
10805 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10806 argument_list[2].integer_reference,exception);
10807 if (attribute_flag[3] != 0)
10808 channel=(ChannelType) argument_list[3].integer_reference;
10809 channel_mask=SetImageChannelMask(image,channel);
10810 image=SparseColorImage(image,method,number_coordinates,coordinates,
10812 if (image != (Image *) NULL)
10813 (void) SetImageChannelMask(image,channel_mask);
10814 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10815 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10817 coordinates=(double *) RelinquishMagickMemory(coordinates);
10820 case 120: /* Function */
10837 if (attribute_flag[0] == 0)
10839 function=UndefinedFunction;
10840 if (attribute_flag[1] != 0)
10841 function=(MagickFunction) argument_list[1].integer_reference;
10842 av=(AV *) argument_list[0].array_reference;
10843 number_parameters=(size_t) av_len(av)+1;
10844 parameters=(double *) AcquireQuantumMemory(number_parameters,
10845 sizeof(*parameters));
10846 if (parameters == (double *) NULL)
10848 ThrowPerlException(exception,ResourceLimitFatalError,
10849 "MemoryAllocationFailed",PackageName);
10850 goto PerlException;
10852 for (j=0; j < (ssize_t) number_parameters; j++)
10853 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10854 virtual_pixel=UndefinedVirtualPixelMethod;
10855 if (attribute_flag[2] != 0)
10856 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10857 argument_list[2].integer_reference,exception);
10858 (void) FunctionImage(image,function,number_parameters,parameters,
10860 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10861 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10863 parameters=(double *) RelinquishMagickMemory(parameters);
10866 case 121: /* SelectiveBlur */
10868 if (attribute_flag[0] != 0)
10870 flags=ParseGeometry(argument_list[0].string_reference,
10872 if ((flags & SigmaValue) == 0)
10873 geometry_info.sigma=1.0;
10874 if ((flags & PercentValue) != 0)
10875 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10877 if (attribute_flag[1] != 0)
10878 geometry_info.rho=argument_list[1].real_reference;
10879 if (attribute_flag[2] != 0)
10880 geometry_info.sigma=argument_list[2].real_reference;
10881 if (attribute_flag[3] != 0)
10882 geometry_info.xi=argument_list[3].integer_reference;;
10883 if (attribute_flag[5] != 0)
10884 channel=(ChannelType) argument_list[5].integer_reference;
10885 channel_mask=SetImageChannelMask(image,channel);
10886 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10887 geometry_info.xi,exception);
10888 if (image != (Image *) NULL)
10889 (void) SetImageChannelMask(image,channel_mask);
10892 case 122: /* HaldClut */
10894 if (attribute_flag[0] == 0)
10896 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10898 goto PerlException;
10900 if (attribute_flag[1] != 0)
10901 channel=(ChannelType) argument_list[1].integer_reference;
10902 channel_mask=SetImageChannelMask(image,channel);
10903 (void) HaldClutImage(image,argument_list[0].image_reference,
10905 (void) SetImageChannelMask(image,channel_mask);
10908 case 123: /* BlueShift */
10910 if (attribute_flag[0] != 0)
10911 (void) ParseGeometry(argument_list[0].string_reference,
10913 image=BlueShiftImage(image,geometry_info.rho,exception);
10916 case 124: /* ForwardFourierTransformImage */
10918 image=ForwardFourierTransformImage(image,
10919 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10923 case 125: /* InverseFourierTransformImage */
10925 image=InverseFourierTransformImage(image,image->next,
10926 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10930 case 126: /* ColorDecisionList */
10932 if (attribute_flag[0] == 0)
10933 argument_list[0].string_reference=(char *) NULL;
10934 (void) ColorDecisionListImage(image,
10935 argument_list[0].string_reference,exception);
10938 case 127: /* AutoGamma */
10940 if (attribute_flag[0] != 0)
10941 channel=(ChannelType) argument_list[0].integer_reference;
10942 channel_mask=SetImageChannelMask(image,channel);
10943 (void) AutoGammaImage(image,exception);
10944 (void) SetImageChannelMask(image,channel_mask);
10947 case 128: /* AutoLevel */
10949 if (attribute_flag[0] != 0)
10950 channel=(ChannelType) argument_list[0].integer_reference;
10951 channel_mask=SetImageChannelMask(image,channel);
10952 (void) AutoLevelImage(image,exception);
10953 (void) SetImageChannelMask(image,channel_mask);
10956 case 129: /* LevelColors */
10962 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10964 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10966 if (attribute_flag[1] != 0)
10967 (void) QueryColorCompliance(
10968 argument_list[1].string_reference,AllCompliance,&black_point,
10970 if (attribute_flag[2] != 0)
10971 (void) QueryColorCompliance(
10972 argument_list[2].string_reference,AllCompliance,&white_point,
10974 if (attribute_flag[3] != 0)
10975 channel=(ChannelType) argument_list[3].integer_reference;
10976 channel_mask=SetImageChannelMask(image,channel);
10977 (void) LevelImageColors(image,&black_point,&white_point,
10978 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10980 (void) SetImageChannelMask(image,channel_mask);
10983 case 130: /* Clamp */
10985 if (attribute_flag[0] != 0)
10986 channel=(ChannelType) argument_list[0].integer_reference;
10987 channel_mask=SetImageChannelMask(image,channel);
10988 (void) ClampImage(image,exception);
10989 (void) SetImageChannelMask(image,channel_mask);
10992 case 131: /* BrightnessContrast */
11000 if (attribute_flag[0] != 0)
11002 flags=ParseGeometry(argument_list[0].string_reference,
11004 brightness=geometry_info.rho;
11005 if ((flags & SigmaValue) == 0)
11006 contrast=geometry_info.sigma;
11008 if (attribute_flag[1] != 0)
11009 brightness=argument_list[1].real_reference;
11010 if (attribute_flag[2] != 0)
11011 contrast=argument_list[2].real_reference;
11012 if (attribute_flag[4] != 0)
11013 channel=(ChannelType) argument_list[4].integer_reference;
11014 channel_mask=SetImageChannelMask(image,channel);
11015 (void) BrightnessContrastImage(image,brightness,contrast,exception);
11016 (void) SetImageChannelMask(image,channel_mask);
11019 case 132: /* Morphology */
11030 if (attribute_flag[0] == 0)
11032 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11033 if (kernel == (KernelInfo *) NULL)
11035 if (attribute_flag[1] != 0)
11036 channel=(ChannelType) argument_list[1].integer_reference;
11037 method=UndefinedMorphology;
11038 if (attribute_flag[2] != 0)
11039 method=argument_list[2].integer_reference;
11041 if (attribute_flag[3] != 0)
11042 iterations=argument_list[3].integer_reference;
11043 channel_mask=SetImageChannelMask(image,channel);
11044 image=MorphologyImage(image,method,iterations,kernel,exception);
11045 if (image != (Image *) NULL)
11046 (void) SetImageChannelMask(image,channel_mask);
11047 kernel=DestroyKernelInfo(kernel);
11050 case 133: /* Mode */
11052 if (attribute_flag[0] != 0)
11054 flags=ParseGeometry(argument_list[0].string_reference,
11056 if ((flags & SigmaValue) == 0)
11057 geometry_info.sigma=1.0;
11059 if (attribute_flag[1] != 0)
11060 geometry_info.rho=argument_list[1].real_reference;
11061 if (attribute_flag[2] != 0)
11062 geometry_info.sigma=argument_list[2].real_reference;
11063 if (attribute_flag[3] != 0)
11064 channel=(ChannelType) argument_list[3].integer_reference;
11065 channel_mask=SetImageChannelMask(image,channel);
11066 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11067 (size_t) geometry_info.sigma,exception);
11068 if (image != (Image *) NULL)
11069 (void) SetImageChannelMask(image,channel_mask);
11072 case 134: /* Statistic */
11077 statistic=UndefinedStatistic;
11078 if (attribute_flag[0] != 0)
11080 flags=ParseGeometry(argument_list[0].string_reference,
11082 if ((flags & SigmaValue) == 0)
11083 geometry_info.sigma=1.0;
11085 if (attribute_flag[1] != 0)
11086 geometry_info.rho=argument_list[1].real_reference;
11087 if (attribute_flag[2] != 0)
11088 geometry_info.sigma=argument_list[2].real_reference;
11089 if (attribute_flag[3] != 0)
11090 channel=(ChannelType) argument_list[3].integer_reference;
11091 if (attribute_flag[4] != 0)
11092 statistic=(StatisticType) argument_list[4].integer_reference;
11093 channel_mask=SetImageChannelMask(image,channel);
11094 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11095 (size_t) geometry_info.sigma,exception);
11096 if (image != (Image *) NULL)
11097 (void) SetImageChannelMask(image,channel_mask);
11100 case 135: /* Perceptible */
11105 epsilon=MagickEpsilon;
11106 if (attribute_flag[0] != 0)
11107 epsilon=argument_list[0].real_reference;
11108 if (attribute_flag[1] != 0)
11109 channel=(ChannelType) argument_list[1].integer_reference;
11110 channel_mask=SetImageChannelMask(image,channel);
11111 (void) PerceptibleImage(image,epsilon,exception);
11112 (void) SetImageChannelMask(image,channel_mask);
11115 case 136: /* Poly */
11126 if (attribute_flag[0] == 0)
11128 if (attribute_flag[1] != 0)
11129 channel=(ChannelType) argument_list[1].integer_reference;
11130 av=(AV *) argument_list[0].array_reference;
11131 number_terms=(size_t) av_len(av);
11132 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11133 if (terms == (double *) NULL)
11135 ThrowPerlException(exception,ResourceLimitFatalError,
11136 "MemoryAllocationFailed",PackageName);
11137 goto PerlException;
11139 for (j=0; j < av_len(av); j++)
11140 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11141 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11142 terms=(double *) RelinquishMagickMemory(terms);
11145 case 137: /* Grayscale */
11147 PixelIntensityMethod
11150 method=UndefinedPixelIntensityMethod;
11151 if (attribute_flag[0] != 0)
11152 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11153 (void) GrayscaleImage(image,method,exception);
11156 case 138: /* Canny */
11158 if (attribute_flag[0] != 0)
11160 flags=ParseGeometry(argument_list[0].string_reference,
11162 if ((flags & SigmaValue) == 0)
11163 geometry_info.sigma=1.0;
11164 if ((flags & XiValue) == 0)
11165 geometry_info.xi=0.10;
11166 if ((flags & PsiValue) == 0)
11167 geometry_info.psi=0.30;
11168 if ((flags & PercentValue) != 0)
11170 geometry_info.xi/=100.0;
11171 geometry_info.psi/=100.0;
11174 if (attribute_flag[1] != 0)
11175 geometry_info.rho=argument_list[1].real_reference;
11176 if (attribute_flag[2] != 0)
11177 geometry_info.sigma=argument_list[2].real_reference;
11178 if (attribute_flag[3] != 0)
11179 geometry_info.xi=argument_list[3].real_reference;
11180 if (attribute_flag[4] != 0)
11181 geometry_info.psi=argument_list[4].real_reference;
11182 if (attribute_flag[5] != 0)
11183 channel=(ChannelType) argument_list[5].integer_reference;
11184 channel_mask=SetImageChannelMask(image,channel);
11185 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11186 geometry_info.xi,geometry_info.psi,exception);
11187 if (image != (Image *) NULL)
11188 (void) SetImageChannelMask(image,channel_mask);
11191 case 139: /* HoughLine */
11193 if (attribute_flag[0] != 0)
11195 flags=ParseGeometry(argument_list[0].string_reference,
11197 if ((flags & SigmaValue) == 0)
11198 geometry_info.sigma=geometry_info.rho;
11199 if ((flags & XiValue) == 0)
11200 geometry_info.xi=40;
11202 if (attribute_flag[1] != 0)
11203 geometry_info.rho=(double) argument_list[1].integer_reference;
11204 if (attribute_flag[2] != 0)
11205 geometry_info.sigma=(double) argument_list[2].integer_reference;
11206 if (attribute_flag[3] != 0)
11207 geometry_info.xi=(double) argument_list[3].integer_reference;
11208 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11209 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11212 case 140: /* MeanShift */
11214 if (attribute_flag[0] != 0)
11216 flags=ParseGeometry(argument_list[0].string_reference,
11218 if ((flags & SigmaValue) == 0)
11219 geometry_info.sigma=geometry_info.rho;
11220 if ((flags & XiValue) == 0)
11221 geometry_info.xi=0.10*QuantumRange;
11222 if ((flags & PercentValue) != 0)
11223 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11225 if (attribute_flag[1] != 0)
11226 geometry_info.rho=(double) argument_list[1].integer_reference;
11227 if (attribute_flag[2] != 0)
11228 geometry_info.sigma=(double) argument_list[2].integer_reference;
11229 if (attribute_flag[3] != 0)
11230 geometry_info.xi=(double) argument_list[3].integer_reference;
11231 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11232 geometry_info.sigma,geometry_info.xi,exception);
11235 case 141: /* Kuwahara */
11237 if (attribute_flag[0] != 0)
11239 flags=ParseGeometry(argument_list[0].string_reference,
11241 if ((flags & SigmaValue) == 0)
11242 geometry_info.sigma=geometry_info.rho-0.5;
11244 if (attribute_flag[1] != 0)
11245 geometry_info.rho=argument_list[1].real_reference;
11246 if (attribute_flag[2] != 0)
11247 geometry_info.sigma=argument_list[2].real_reference;
11248 if (attribute_flag[3] != 0)
11249 channel=(ChannelType) argument_list[3].integer_reference;
11250 channel_mask=SetImageChannelMask(image,channel);
11251 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11253 if (image != (Image *) NULL)
11254 (void) SetImageChannelMask(image,channel_mask);
11257 case 142: /* ConnectedComponent */
11263 if (attribute_flag[0] != 0)
11264 connectivity=argument_list[0].integer_reference;
11265 image=ConnectedComponentsImage(image,connectivity,
11266 (CCObjectInfo **) NULL,exception);
11269 case 143: /* Copy */
11280 source_image=image;
11281 if (attribute_flag[0] != 0)
11282 source_image=argument_list[0].image_reference;
11283 SetGeometry(source_image,&geometry);
11284 if (attribute_flag[1] != 0)
11285 flags=ParseGravityGeometry(source_image,
11286 argument_list[1].string_reference,&geometry,exception);
11287 if (attribute_flag[2] != 0)
11288 geometry.width=argument_list[2].integer_reference;
11289 if (attribute_flag[3] != 0)
11290 geometry.height=argument_list[3].integer_reference;
11291 if (attribute_flag[4] != 0)
11292 geometry.x=argument_list[4].integer_reference;
11293 if (attribute_flag[5] != 0)
11294 geometry.y=argument_list[5].integer_reference;
11295 if (attribute_flag[6] != 0)
11296 image->gravity=(GravityType) argument_list[6].integer_reference;
11297 SetGeometry(image,&offset_geometry);
11298 if (attribute_flag[7] != 0)
11299 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11300 &offset_geometry,exception);
11301 offset.x=offset_geometry.x;
11302 offset.y=offset_geometry.y;
11303 if (attribute_flag[8] != 0)
11304 offset.x=argument_list[8].integer_reference;
11305 if (attribute_flag[9] != 0)
11306 offset.y=argument_list[9].integer_reference;
11307 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11312 if (next != (Image *) NULL)
11313 (void) CatchImageException(next);
11314 if (region_image != (Image *) NULL)
11319 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11320 region_info.x,region_info.y,exception);
11322 (void) CatchImageException(region_image);
11323 image=DestroyImage(image);
11324 image=region_image;
11326 if (image != (Image *) NULL)
11329 if (next && (next != image))
11331 image->next=next->next;
11332 if (image->next != (Image *) NULL)
11333 image->next->previous=image;
11334 DeleteImageFromRegistry(*pv,next);
11336 sv_setiv(*pv,PTR2IV(image));
11344 if (reference_vector)
11345 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11346 InheritPerlException(exception,perl_exception);
11347 exception=DestroyExceptionInfo(exception);
11348 sv_setiv(perl_exception,(IV) number_images);
11349 SvPOK_on(perl_exception);
11350 ST(0)=sv_2mortal(perl_exception);
11355 ###############################################################################
11363 ###############################################################################
11368 Image::Magick ref=NO_INIT
11413 PERL_UNUSED_VAR(ref);
11414 PERL_UNUSED_VAR(ix);
11415 exception=AcquireExceptionInfo();
11416 perl_exception=newSVpv("",0);
11419 if (sv_isobject(ST(0)) == 0)
11421 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11423 goto PerlException;
11425 reference=SvRV(ST(0));
11426 hv=SvSTASH(reference);
11428 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11430 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11431 if (image == (Image *) NULL)
11433 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11435 goto PerlException;
11440 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11441 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11442 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11444 for (i=2; i < items; i+=2)
11446 attribute=(char *) SvPV(ST(i-1),na);
11447 switch (*attribute)
11452 if (LocaleCompare(attribute,"background") == 0)
11454 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11455 &montage_info->background_color,exception);
11456 for (next=image; next; next=next->next)
11457 next->background_color=montage_info->background_color;
11460 if (LocaleCompare(attribute,"border") == 0)
11462 montage_info->border_width=SvIV(ST(i));
11465 if (LocaleCompare(attribute,"bordercolor") == 0)
11467 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11468 &montage_info->border_color,exception);
11469 for (next=image; next; next=next->next)
11470 next->border_color=montage_info->border_color;
11473 if (LocaleCompare(attribute,"borderwidth") == 0)
11475 montage_info->border_width=SvIV(ST(i));
11478 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11485 if (LocaleCompare(attribute,"compose") == 0)
11487 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11488 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11491 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11495 for (next=image; next; next=next->next)
11496 next->compose=(CompositeOperator) sp;
11499 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11506 if (LocaleCompare(attribute,"fill") == 0)
11508 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11509 &montage_info->fill,exception);
11512 if (LocaleCompare(attribute,"font") == 0)
11514 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11517 if (LocaleCompare(attribute,"frame") == 0)
11523 if (IsGeometry(p) == MagickFalse)
11525 ThrowPerlException(exception,OptionError,"MissingGeometry",
11529 (void) CloneString(&montage_info->frame,p);
11531 montage_info->frame=(char *) NULL;
11534 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11541 if (LocaleCompare(attribute,"geometry") == 0)
11547 if (IsGeometry(p) == MagickFalse)
11549 ThrowPerlException(exception,OptionError,"MissingGeometry",
11553 (void) CloneString(&montage_info->geometry,p);
11555 montage_info->geometry=(char *) NULL;
11558 if (LocaleCompare(attribute,"gravity") == 0)
11563 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11564 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11567 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11571 montage_info->gravity=(GravityType) in;
11572 for (next=image; next; next=next->next)
11573 next->gravity=(GravityType) in;
11576 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11583 if (LocaleCompare(attribute,"label") == 0)
11585 for (next=image; next; next=next->next)
11586 (void) SetImageProperty(next,"label",InterpretImageProperties(
11587 info ? info->image_info : (ImageInfo *) NULL,next,
11588 SvPV(ST(i),na),exception),exception);
11591 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11598 if (LocaleCompare(attribute,"mattecolor") == 0)
11600 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11601 &montage_info->alpha_color,exception);
11602 for (next=image; next; next=next->next)
11603 next->alpha_color=montage_info->alpha_color;
11606 if (LocaleCompare(attribute,"mode") == 0)
11611 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11612 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11617 ThrowPerlException(exception,OptionError,
11618 "UnrecognizedModeType",SvPV(ST(i),na));
11623 (void) CloneString(&montage_info->frame,"15x15+3+3");
11624 montage_info->shadow=MagickTrue;
11629 montage_info->frame=(char *) NULL;
11630 montage_info->shadow=MagickFalse;
11631 montage_info->border_width=0;
11634 case ConcatenateMode:
11636 montage_info->frame=(char *) NULL;
11637 montage_info->shadow=MagickFalse;
11638 (void) CloneString(&montage_info->geometry,"+0+0");
11639 montage_info->border_width=0;
11644 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11651 if (LocaleCompare(attribute,"pointsize") == 0)
11653 montage_info->pointsize=SvIV(ST(i));
11656 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11663 if (LocaleCompare(attribute,"shadow") == 0)
11665 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11666 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11669 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11673 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11676 if (LocaleCompare(attribute,"stroke") == 0)
11678 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11679 &montage_info->stroke,exception);
11682 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11689 if (LocaleCompare(attribute,"texture") == 0)
11691 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11694 if (LocaleCompare(attribute,"tile") == 0)
11696 char *p=SvPV(ST(i),na);
11697 if (IsGeometry(p) == MagickFalse)
11699 ThrowPerlException(exception,OptionError,"MissingGeometry",
11703 (void) CloneString(&montage_info->tile,p);
11705 montage_info->tile=(char *) NULL;
11708 if (LocaleCompare(attribute,"title") == 0)
11710 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11713 if (LocaleCompare(attribute,"transparent") == 0)
11718 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11719 &transparent_color,exception);
11720 for (next=image; next; next=next->next)
11721 (void) TransparentPaintImage(next,&transparent_color,
11722 TransparentAlpha,MagickFalse,exception);
11725 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11731 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11737 image=MontageImageList(info->image_info,montage_info,image,exception);
11738 montage_info=DestroyMontageInfo(montage_info);
11739 if (image == (Image *) NULL)
11740 goto PerlException;
11741 if (transparent_color.alpha != TransparentAlpha)
11742 for (next=image; next; next=next->next)
11743 (void) TransparentPaintImage(next,&transparent_color,
11744 TransparentAlpha,MagickFalse,exception);
11745 for ( ; image; image=image->next)
11747 AddImageToRegistry(sv,image);
11749 av_push(av,sv_bless(rv,hv));
11752 exception=DestroyExceptionInfo(exception);
11753 ST(0)=av_reference;
11754 SvREFCNT_dec(perl_exception);
11758 InheritPerlException(exception,perl_exception);
11759 exception=DestroyExceptionInfo(exception);
11760 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11761 SvPOK_on(perl_exception);
11762 ST(0)=sv_2mortal(perl_exception);
11767 ###############################################################################
11775 ###############################################################################
11780 Image::Magick ref=NO_INIT
11818 PERL_UNUSED_VAR(ref);
11819 PERL_UNUSED_VAR(ix);
11820 exception=AcquireExceptionInfo();
11821 perl_exception=newSVpv("",0);
11825 if (sv_isobject(ST(0)) == 0)
11827 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11829 goto PerlException;
11831 reference=SvRV(ST(0));
11832 hv=SvSTASH(reference);
11834 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11836 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11837 if (image == (Image *) NULL)
11839 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11841 goto PerlException;
11843 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11848 for (i=2; i < items; i+=2)
11850 attribute=(char *) SvPV(ST(i-1),na);
11851 switch (*attribute)
11856 if (LocaleCompare(attribute,"frames") == 0)
11858 number_frames=SvIV(ST(i));
11861 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11867 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11873 image=MorphImages(image,number_frames,exception);
11874 if (image == (Image *) NULL)
11875 goto PerlException;
11876 for ( ; image; image=image->next)
11878 AddImageToRegistry(sv,image);
11880 av_push(av,sv_bless(rv,hv));
11883 exception=DestroyExceptionInfo(exception);
11884 ST(0)=av_reference;
11885 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11889 InheritPerlException(exception,perl_exception);
11890 exception=DestroyExceptionInfo(exception);
11891 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11892 SvPOK_on(perl_exception);
11893 ST(0)=sv_2mortal(perl_exception);
11898 ###############################################################################
11906 ###############################################################################
11911 Image::Magick ref=NO_INIT
11939 PERL_UNUSED_VAR(ref);
11940 PERL_UNUSED_VAR(ix);
11941 exception=AcquireExceptionInfo();
11942 perl_exception=newSVpv("",0);
11944 if (sv_isobject(ST(0)) == 0)
11946 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11948 goto PerlException;
11950 reference=SvRV(ST(0));
11951 hv=SvSTASH(reference);
11952 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11953 if (image == (Image *) NULL)
11955 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11957 goto PerlException;
11959 image=MergeImageLayers(image,MosaicLayer,exception);
11961 Create blessed Perl array for the returned image.
11964 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11966 AddImageToRegistry(sv,image);
11968 av_push(av,sv_bless(rv,hv));
11970 (void) CopyMagickString(info->image_info->filename,image->filename,
11972 SetImageInfo(info->image_info,0,exception);
11973 exception=DestroyExceptionInfo(exception);
11974 SvREFCNT_dec(perl_exception);
11978 InheritPerlException(exception,perl_exception);
11979 exception=DestroyExceptionInfo(exception);
11980 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11981 SvPOK_on(perl_exception); /* return messages in string context */
11982 ST(0)=sv_2mortal(perl_exception);
11987 ###############################################################################
11995 ###############################################################################
12000 Image::Magick ref=NO_INIT
12050 PERL_UNUSED_VAR(ref);
12051 PERL_UNUSED_VAR(ix);
12052 exception=AcquireExceptionInfo();
12053 perl_exception=newSVpv("",0);
12054 package_info=(struct PackageInfo *) NULL;
12055 ac=(items < 2) ? 1 : items-1;
12056 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12058 length=(STRLEN *) NULL;
12059 if (list == (char **) NULL)
12061 ThrowPerlException(exception,ResourceLimitError,
12062 "MemoryAllocationFailed",PackageName);
12063 goto PerlException;
12066 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12067 if (length == (STRLEN *) NULL)
12069 ThrowPerlException(exception,ResourceLimitError,
12070 "MemoryAllocationFailed",PackageName);
12071 goto PerlException;
12073 if (sv_isobject(ST(0)) == 0)
12075 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12077 goto PerlException;
12079 reference=SvRV(ST(0));
12080 if (SvTYPE(reference) != SVt_PVAV)
12082 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12084 goto PerlException;
12086 av=(AV *) reference;
12087 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12089 package_info=ClonePackageInfo(info,exception);
12092 *list=(char *) (*package_info->image_info->filename ?
12093 package_info->image_info->filename : "XC:black");
12095 for (n=0, i=0; i < ac; i++)
12097 list[n]=(char *) SvPV(ST(i+1),length[n]);
12098 if ((items >= 3) && strEQcase(list[n],"blob"))
12104 blob=(void *) (SvPV(ST(i+1),length[n]));
12105 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12107 if ((items >= 3) && strEQcase(list[n],"filename"))
12109 if ((items >= 3) && strEQcase(list[n],"file"))
12118 io_info=IoIFP(sv_2io(ST(i+1)));
12119 if (io_info == (PerlIO *) NULL)
12121 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12125 file=PerlIO_findFILE(io_info);
12126 if (file == (FILE *) NULL)
12128 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12132 SetImageInfoFile(package_info->image_info,file);
12134 if ((items >= 3) && strEQcase(list[n],"magick"))
12138 list[n]=(char *) NULL;
12140 status=ExpandFilenames(&n,&list);
12141 if (status == MagickFalse)
12143 ThrowPerlException(exception,ResourceLimitError,
12144 "MemoryAllocationFailed",PackageName);
12145 goto PerlException;
12148 for (i=0; i < n; i++)
12150 (void) CopyMagickString(package_info->image_info->filename,list[i],
12152 image=PingImage(package_info->image_info,exception);
12153 if (image == (Image *) NULL)
12155 if ((package_info->image_info->file != (FILE *) NULL) ||
12156 (package_info->image_info->blob != (void *) NULL))
12157 DisassociateImageStream(image);
12158 count+=GetImageListLength(image);
12159 EXTEND(sp,4*count);
12160 for (next=image; next; next=next->next)
12162 PUSHs(sv_2mortal(newSViv(next->columns)));
12163 PUSHs(sv_2mortal(newSViv(next->rows)));
12164 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12165 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12167 image=DestroyImageList(image);
12172 for (i=0; i < n; i++)
12173 if (list[i] != (char *) NULL)
12174 for (p=keep; list[i] != *p++; )
12177 list[i]=(char *) RelinquishMagickMemory(list[i]);
12182 if (package_info != (struct PackageInfo *) NULL)
12183 DestroyPackageInfo(package_info);
12184 if (list && (list != keep))
12185 list=(char **) RelinquishMagickMemory(list);
12187 keep=(char **) RelinquishMagickMemory(keep);
12189 length=(STRLEN *) RelinquishMagickMemory(length);
12190 InheritPerlException(exception,perl_exception);
12191 exception=DestroyExceptionInfo(exception);
12192 SvREFCNT_dec(perl_exception); /* throw away all errors */
12196 ###############################################################################
12204 ###############################################################################
12209 Image::Magick ref=NO_INIT
12242 PERL_UNUSED_VAR(ref);
12243 PERL_UNUSED_VAR(ix);
12244 exception=AcquireExceptionInfo();
12245 perl_exception=newSVpv("",0);
12248 if (sv_isobject(ST(0)) == 0)
12250 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12252 goto PerlException;
12254 reference=SvRV(ST(0));
12255 hv=SvSTASH(reference);
12257 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12259 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12260 if (image == (Image *) NULL)
12262 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12264 goto PerlException;
12266 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12267 preview_type=GammaPreview;
12269 preview_type=(PreviewType)
12270 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12271 for ( ; image; image=image->next)
12273 preview_image=PreviewImage(image,preview_type,exception);
12274 if (preview_image == (Image *) NULL)
12275 goto PerlException;
12276 AddImageToRegistry(sv,preview_image);
12278 av_push(av,sv_bless(rv,hv));
12281 exception=DestroyExceptionInfo(exception);
12282 ST(0)=av_reference;
12283 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12287 InheritPerlException(exception,perl_exception);
12288 exception=DestroyExceptionInfo(exception);
12289 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12290 SvPOK_on(perl_exception);
12291 ST(0)=sv_2mortal(perl_exception);
12296 ###############################################################################
12300 # Q u e r y C o l o r #
12304 ###############################################################################
12308 QueryColor(ref,...)
12309 Image::Magick ref=NO_INIT
12329 PERL_UNUSED_VAR(ref);
12330 PERL_UNUSED_VAR(ix);
12331 exception=AcquireExceptionInfo();
12332 perl_exception=newSVpv("",0);
12341 colorlist=GetColorInfoList("*",&colors,exception);
12343 for (i=0; i < (ssize_t) colors; i++)
12345 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12347 colorlist=(const ColorInfo **)
12348 RelinquishMagickMemory((ColorInfo **) colorlist);
12349 goto PerlException;
12351 EXTEND(sp,5*items);
12352 for (i=1; i < items; i++)
12354 name=(char *) SvPV(ST(i),na);
12355 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12360 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12361 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12362 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12363 if (color.colorspace == CMYKColorspace)
12364 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12365 if (color.alpha_trait != UndefinedPixelTrait)
12366 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12370 InheritPerlException(exception,perl_exception);
12371 exception=DestroyExceptionInfo(exception);
12372 SvREFCNT_dec(perl_exception);
12376 ###############################################################################
12380 # Q u e r y C o l o r N a m e #
12384 ###############################################################################
12388 QueryColorname(ref,...)
12389 Image::Magick ref=NO_INIT
12398 message[MagickPathExtent];
12417 *reference; /* reference is the SV* of ref=SvIV(reference) */
12419 PERL_UNUSED_VAR(ref);
12420 PERL_UNUSED_VAR(ix);
12421 exception=AcquireExceptionInfo();
12422 perl_exception=newSVpv("",0);
12423 reference=SvRV(ST(0));
12424 av=(AV *) reference;
12425 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12427 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12428 if (image == (Image *) NULL)
12430 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12432 goto PerlException;
12435 for (i=1; i < items; i++)
12437 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12439 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12441 PUSHs(sv_2mortal(newSVpv(message,0)));
12445 InheritPerlException(exception,perl_exception);
12446 exception=DestroyExceptionInfo(exception);
12447 SvREFCNT_dec(perl_exception);
12451 ###############################################################################
12455 # Q u e r y F o n t #
12459 ###############################################################################
12464 Image::Magick ref=NO_INIT
12471 message[MagickPathExtent];
12482 volatile const TypeInfo
12485 PERL_UNUSED_VAR(ref);
12486 PERL_UNUSED_VAR(ix);
12487 exception=AcquireExceptionInfo();
12488 perl_exception=newSVpv("",0);
12497 typelist=GetTypeInfoList("*",&types,exception);
12499 for (i=0; i < (ssize_t) types; i++)
12501 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12503 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12505 goto PerlException;
12507 EXTEND(sp,10*items);
12508 for (i=1; i < items; i++)
12510 name=(char *) SvPV(ST(i),na);
12511 type_info=GetTypeInfo(name,exception);
12512 if (type_info == (TypeInfo *) NULL)
12517 if (type_info->name == (char *) NULL)
12520 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12521 if (type_info->description == (char *) NULL)
12524 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12525 if (type_info->family == (char *) NULL)
12528 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12529 if (type_info->style == UndefinedStyle)
12532 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12533 type_info->style),0)));
12534 if (type_info->stretch == UndefinedStretch)
12537 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12538 type_info->stretch),0)));
12539 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12540 type_info->weight);
12541 PUSHs(sv_2mortal(newSVpv(message,0)));
12542 if (type_info->encoding == (char *) NULL)
12545 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12546 if (type_info->foundry == (char *) NULL)
12549 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12550 if (type_info->format == (char *) NULL)
12553 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12554 if (type_info->metrics == (char *) NULL)
12557 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12558 if (type_info->glyphs == (char *) NULL)
12561 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12565 InheritPerlException(exception,perl_exception);
12566 exception=DestroyExceptionInfo(exception);
12567 SvREFCNT_dec(perl_exception);
12571 ###############################################################################
12575 # Q u e r y F o n t M e t r i c s #
12579 ###############################################################################
12583 QueryFontMetrics(ref,...)
12584 Image::Magick ref=NO_INIT
12586 queryfontmetrics = 1
12633 *reference; /* reference is the SV* of ref=SvIV(reference) */
12638 PERL_UNUSED_VAR(ref);
12639 PERL_UNUSED_VAR(ix);
12640 exception=AcquireExceptionInfo();
12641 package_info=(struct PackageInfo *) NULL;
12642 perl_exception=newSVpv("",0);
12643 reference=SvRV(ST(0));
12644 av=(AV *) reference;
12645 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12647 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12648 if (image == (Image *) NULL)
12650 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12652 goto PerlException;
12654 package_info=ClonePackageInfo(info,exception);
12655 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12656 CloneString(&draw_info->text,"");
12657 current=draw_info->affine;
12658 GetAffineMatrix(&affine);
12661 EXTEND(sp,7*items);
12662 for (i=2; i < items; i+=2)
12664 attribute=(char *) SvPV(ST(i-1),na);
12665 switch (*attribute)
12670 if (LocaleCompare(attribute,"antialias") == 0)
12672 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12676 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12680 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12690 if (LocaleCompare(attribute,"density") == 0)
12692 CloneString(&draw_info->density,SvPV(ST(i),na));
12695 if (LocaleCompare(attribute,"direction") == 0)
12697 draw_info->direction=(DirectionType) ParseCommandOption(
12698 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12708 if (LocaleCompare(attribute,"encoding") == 0)
12710 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12713 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12720 if (LocaleCompare(attribute,"family") == 0)
12722 CloneString(&draw_info->family,SvPV(ST(i),na));
12725 if (LocaleCompare(attribute,"fill") == 0)
12728 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12729 &draw_info->fill,exception);
12732 if (LocaleCompare(attribute,"font") == 0)
12734 CloneString(&draw_info->font,SvPV(ST(i),na));
12737 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12744 if (LocaleCompare(attribute,"geometry") == 0)
12746 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12749 if (LocaleCompare(attribute,"gravity") == 0)
12751 draw_info->gravity=(GravityType) ParseCommandOption(
12752 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12755 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12762 if (LocaleCompare(attribute,"interline-spacing") == 0)
12764 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12765 draw_info->interline_spacing=geometry_info.rho;
12768 if (LocaleCompare(attribute,"interword-spacing") == 0)
12770 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12771 draw_info->interword_spacing=geometry_info.rho;
12774 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12781 if (LocaleCompare(attribute,"kerning") == 0)
12783 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12784 draw_info->kerning=geometry_info.rho;
12787 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12794 if (LocaleCompare(attribute,"pointsize") == 0)
12796 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12797 draw_info->pointsize=geometry_info.rho;
12800 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12807 if (LocaleCompare(attribute,"rotate") == 0)
12809 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12810 affine.rx=geometry_info.rho;
12811 affine.ry=geometry_info.sigma;
12812 if ((flags & SigmaValue) == 0)
12813 affine.ry=affine.rx;
12816 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12823 if (LocaleCompare(attribute,"scale") == 0)
12825 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12826 affine.sx=geometry_info.rho;
12827 affine.sy=geometry_info.sigma;
12828 if ((flags & SigmaValue) == 0)
12829 affine.sy=affine.sx;
12832 if (LocaleCompare(attribute,"skew") == 0)
12838 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12839 x_angle=geometry_info.rho;
12840 y_angle=geometry_info.sigma;
12841 if ((flags & SigmaValue) == 0)
12843 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12844 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12847 if (LocaleCompare(attribute,"stroke") == 0)
12850 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12851 &draw_info->stroke,exception);
12854 if (LocaleCompare(attribute,"style") == 0)
12856 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12860 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12864 draw_info->style=(StyleType) type;
12867 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12874 if (LocaleCompare(attribute,"text") == 0)
12876 CloneString(&draw_info->text,SvPV(ST(i),na));
12879 if (LocaleCompare(attribute,"translate") == 0)
12881 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12882 affine.tx=geometry_info.rho;
12883 affine.ty=geometry_info.sigma;
12884 if ((flags & SigmaValue) == 0)
12885 affine.ty=affine.tx;
12888 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12895 if (LocaleCompare(attribute,"weight") == 0)
12897 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12898 draw_info->weight=(size_t) geometry_info.rho;
12901 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12908 if (LocaleCompare(attribute,"x") == 0)
12910 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12911 x=geometry_info.rho;
12914 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12921 if (LocaleCompare(attribute,"y") == 0)
12923 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12924 y=geometry_info.rho;
12927 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12933 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12939 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12940 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12941 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12942 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12943 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12944 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12945 if (draw_info->geometry == (char *) NULL)
12947 draw_info->geometry=AcquireString((char *) NULL);
12948 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12949 "%.15g,%.15g",x,y);
12951 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12952 (void) CatchImageException(image);
12953 if (status == MagickFalse)
12957 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12958 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12959 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12960 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12961 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12962 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12963 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12964 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12965 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12966 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12967 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12968 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12969 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12971 draw_info=DestroyDrawInfo(draw_info);
12974 if (package_info != (struct PackageInfo *) NULL)
12975 DestroyPackageInfo(package_info);
12976 InheritPerlException(exception,perl_exception);
12977 exception=DestroyExceptionInfo(exception);
12978 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12982 ###############################################################################
12986 # 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 #
12990 ###############################################################################
12994 QueryMultilineFontMetrics(ref,...)
12995 Image::Magick ref=NO_INIT
12997 querymultilinefontmetrics = 1
13044 *reference; /* reference is the SV* of ref=SvIV(reference) */
13049 PERL_UNUSED_VAR(ref);
13050 PERL_UNUSED_VAR(ix);
13051 exception=AcquireExceptionInfo();
13052 package_info=(struct PackageInfo *) NULL;
13053 perl_exception=newSVpv("",0);
13054 reference=SvRV(ST(0));
13055 av=(AV *) reference;
13056 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13058 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13059 if (image == (Image *) NULL)
13061 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13063 goto PerlException;
13065 package_info=ClonePackageInfo(info,exception);
13066 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13067 CloneString(&draw_info->text,"");
13068 current=draw_info->affine;
13069 GetAffineMatrix(&affine);
13072 EXTEND(sp,7*items);
13073 for (i=2; i < items; i+=2)
13075 attribute=(char *) SvPV(ST(i-1),na);
13076 switch (*attribute)
13081 if (LocaleCompare(attribute,"antialias") == 0)
13083 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13087 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13091 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13094 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13101 if (LocaleCompare(attribute,"density") == 0)
13103 CloneString(&draw_info->density,SvPV(ST(i),na));
13106 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13113 if (LocaleCompare(attribute,"encoding") == 0)
13115 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13118 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13125 if (LocaleCompare(attribute,"family") == 0)
13127 CloneString(&draw_info->family,SvPV(ST(i),na));
13130 if (LocaleCompare(attribute,"fill") == 0)
13133 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13134 &draw_info->fill,exception);
13137 if (LocaleCompare(attribute,"font") == 0)
13139 CloneString(&draw_info->font,SvPV(ST(i),na));
13142 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13149 if (LocaleCompare(attribute,"geometry") == 0)
13151 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13154 if (LocaleCompare(attribute,"gravity") == 0)
13156 draw_info->gravity=(GravityType) ParseCommandOption(
13157 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13160 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13167 if (LocaleCompare(attribute,"pointsize") == 0)
13169 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13170 draw_info->pointsize=geometry_info.rho;
13173 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13180 if (LocaleCompare(attribute,"rotate") == 0)
13182 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13183 affine.rx=geometry_info.rho;
13184 affine.ry=geometry_info.sigma;
13185 if ((flags & SigmaValue) == 0)
13186 affine.ry=affine.rx;
13189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13196 if (LocaleCompare(attribute,"scale") == 0)
13198 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13199 affine.sx=geometry_info.rho;
13200 affine.sy=geometry_info.sigma;
13201 if ((flags & SigmaValue) == 0)
13202 affine.sy=affine.sx;
13205 if (LocaleCompare(attribute,"skew") == 0)
13211 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13212 x_angle=geometry_info.rho;
13213 y_angle=geometry_info.sigma;
13214 if ((flags & SigmaValue) == 0)
13216 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13217 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13220 if (LocaleCompare(attribute,"stroke") == 0)
13223 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13224 &draw_info->stroke,exception);
13227 if (LocaleCompare(attribute,"style") == 0)
13229 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13233 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13237 draw_info->style=(StyleType) type;
13240 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13247 if (LocaleCompare(attribute,"text") == 0)
13249 CloneString(&draw_info->text,SvPV(ST(i),na));
13252 if (LocaleCompare(attribute,"translate") == 0)
13254 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13255 affine.tx=geometry_info.rho;
13256 affine.ty=geometry_info.sigma;
13257 if ((flags & SigmaValue) == 0)
13258 affine.ty=affine.tx;
13261 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13268 if (LocaleCompare(attribute,"weight") == 0)
13270 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13271 draw_info->weight=(size_t) geometry_info.rho;
13274 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13281 if (LocaleCompare(attribute,"x") == 0)
13283 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13284 x=geometry_info.rho;
13287 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13294 if (LocaleCompare(attribute,"y") == 0)
13296 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13297 y=geometry_info.rho;
13300 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13306 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13312 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13313 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13314 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13315 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13316 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13317 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13318 if (draw_info->geometry == (char *) NULL)
13320 draw_info->geometry=AcquireString((char *) NULL);
13321 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13322 "%.15g,%.15g",x,y);
13324 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13325 (void) CatchException(exception);
13326 if (status == MagickFalse)
13330 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13331 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13332 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13333 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13334 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13335 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13336 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13337 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13338 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13339 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13340 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13341 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13342 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13344 draw_info=DestroyDrawInfo(draw_info);
13347 if (package_info != (struct PackageInfo *) NULL)
13348 DestroyPackageInfo(package_info);
13349 InheritPerlException(exception,perl_exception);
13350 exception=DestroyExceptionInfo(exception);
13351 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13355 ###############################################################################
13359 # Q u e r y F o r m a t #
13363 ###############################################################################
13367 QueryFormat(ref,...)
13368 Image::Magick ref=NO_INIT
13385 volatile const MagickInfo
13388 PERL_UNUSED_VAR(ref);
13389 PERL_UNUSED_VAR(ix);
13390 exception=AcquireExceptionInfo();
13391 perl_exception=newSVpv("",0);
13395 format[MagickPathExtent];
13403 format_list=GetMagickInfoList("*",&types,exception);
13405 for (i=0; i < (ssize_t) types; i++)
13407 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13408 LocaleLower(format);
13409 PUSHs(sv_2mortal(newSVpv(format,0)));
13411 format_list=(const MagickInfo **)
13412 RelinquishMagickMemory((MagickInfo *) format_list);
13413 goto PerlException;
13415 EXTEND(sp,8*items);
13416 for (i=1; i < items; i++)
13418 name=(char *) SvPV(ST(i),na);
13419 magick_info=GetMagickInfo(name,exception);
13420 if (magick_info == (const MagickInfo *) NULL)
13425 if (magick_info->description == (char *) NULL)
13428 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13429 if (magick_info->module == (char *) NULL)
13432 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13436 InheritPerlException(exception,perl_exception);
13437 exception=DestroyExceptionInfo(exception);
13438 SvREFCNT_dec(perl_exception);
13442 ###############################################################################
13446 # Q u e r y O p t i o n #
13450 ###############################################################################
13454 QueryOption(ref,...)
13455 Image::Magick ref=NO_INIT
13476 PERL_UNUSED_VAR(ref);
13477 PERL_UNUSED_VAR(ix);
13478 exception=AcquireExceptionInfo();
13479 perl_exception=newSVpv("",0);
13480 EXTEND(sp,8*items);
13481 for (i=1; i < items; i++)
13483 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13485 options=GetCommandOptions((CommandOption) option);
13486 if (options == (char **) NULL)
13490 for (j=0; options[j] != (char *) NULL; j++)
13491 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13492 options=DestroyStringList(options);
13496 InheritPerlException(exception,perl_exception);
13497 exception=DestroyExceptionInfo(exception);
13498 SvREFCNT_dec(perl_exception);
13502 ###############################################################################
13510 ###############################################################################
13515 Image::Magick ref=NO_INIT
13562 *perl_exception, /* Perl variable for storing messages */
13567 PERL_UNUSED_VAR(ref);
13568 PERL_UNUSED_VAR(ix);
13569 exception=AcquireExceptionInfo();
13570 perl_exception=newSVpv("",0);
13572 package_info=(struct PackageInfo *) NULL;
13574 ac=(items < 2) ? 1 : items-1;
13575 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13577 length=(STRLEN *) NULL;
13578 if (list == (char **) NULL)
13580 ThrowPerlException(exception,ResourceLimitError,
13581 "MemoryAllocationFailed",PackageName);
13582 goto PerlException;
13584 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13585 if (length == (STRLEN *) NULL)
13587 ThrowPerlException(exception,ResourceLimitError,
13588 "MemoryAllocationFailed",PackageName);
13589 goto PerlException;
13591 if (sv_isobject(ST(0)) == 0)
13593 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13595 goto PerlException;
13597 reference=SvRV(ST(0));
13598 hv=SvSTASH(reference);
13599 if (SvTYPE(reference) != SVt_PVAV)
13601 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13603 goto PerlException;
13605 av=(AV *) reference;
13606 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13608 package_info=ClonePackageInfo(info,exception);
13611 *list=(char *) (*package_info->image_info->filename ?
13612 package_info->image_info->filename : "XC:black");
13614 for (n=0, i=0; i < ac; i++)
13616 list[n]=(char *) SvPV(ST(i+1),length[n]);
13617 if ((items >= 3) && strEQcase(list[n],"blob"))
13623 blob=(void *) (SvPV(ST(i+1),length[n]));
13624 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13626 if ((items >= 3) && strEQcase(list[n],"filename"))
13628 if ((items >= 3) && strEQcase(list[n],"file"))
13637 io_info=IoIFP(sv_2io(ST(i+1)));
13638 if (io_info == (PerlIO *) NULL)
13640 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13644 file=PerlIO_findFILE(io_info);
13645 if (file == (FILE *) NULL)
13647 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13651 SetImageInfoFile(package_info->image_info,file);
13653 if ((items >= 3) && strEQcase(list[n],"magick"))
13657 list[n]=(char *) NULL;
13659 status=ExpandFilenames(&n,&list);
13660 if (status == MagickFalse)
13662 ThrowPerlException(exception,ResourceLimitError,
13663 "MemoryAllocationFailed",PackageName);
13664 goto PerlException;
13667 for (i=0; i < n; i++)
13669 if ((package_info->image_info->file == (FILE *) NULL) &&
13670 (package_info->image_info->blob == (void *) NULL))
13671 image=ReadImages(package_info->image_info,list[i],exception);
13674 image=ReadImages(package_info->image_info,
13675 package_info->image_info->filename,exception);
13676 if (image != (Image *) NULL)
13677 DisassociateImageStream(image);
13679 if (image == (Image *) NULL)
13681 for ( ; image; image=image->next)
13683 AddImageToRegistry(sv,image);
13685 av_push(av,sv_bless(rv,hv));
13693 for (i=0; i < n; i++)
13694 if (list[i] != (char *) NULL)
13695 for (p=keep; list[i] != *p++; )
13696 if (*p == (char *) NULL)
13698 list[i]=(char *) RelinquishMagickMemory(list[i]);
13703 if (package_info != (struct PackageInfo *) NULL)
13704 DestroyPackageInfo(package_info);
13705 if (list && (list != keep))
13706 list=(char **) RelinquishMagickMemory(list);
13708 keep=(char **) RelinquishMagickMemory(keep);
13710 length=(STRLEN *) RelinquishMagickMemory(length);
13711 InheritPerlException(exception,perl_exception);
13712 exception=DestroyExceptionInfo(exception);
13713 sv_setiv(perl_exception,(IV) number_images);
13714 SvPOK_on(perl_exception);
13715 ST(0)=sv_2mortal(perl_exception);
13720 ###############################################################################
13728 ###############################################################################
13733 Image::Magick ref=NO_INIT
13756 PERL_UNUSED_VAR(ref);
13757 PERL_UNUSED_VAR(ix);
13758 exception=AcquireExceptionInfo();
13759 perl_exception=newSVpv("",0);
13760 reference=SvRV(ST(0));
13761 av=(AV *) reference;
13762 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13764 for (i=1; i < items; i++)
13765 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13766 SvPV(ST(i),na),exception);
13767 InheritPerlException(exception,perl_exception);
13768 exception=DestroyExceptionInfo(exception);
13769 SvREFCNT_dec(perl_exception); /* throw away all errors */
13773 ###############################################################################
13781 ###############################################################################
13786 Image::Magick ref=NO_INIT
13809 *reference; /* reference is the SV* of ref=SvIV(reference) */
13811 PERL_UNUSED_VAR(ref);
13812 PERL_UNUSED_VAR(ix);
13813 exception=AcquireExceptionInfo();
13814 perl_exception=newSVpv("",0);
13815 if (sv_isobject(ST(0)) == 0)
13817 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13819 goto PerlException;
13821 reference=SvRV(ST(0));
13822 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13824 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13826 for (i=2; i < items; i+=2)
13827 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13830 InheritPerlException(exception,perl_exception);
13831 exception=DestroyExceptionInfo(exception);
13832 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13833 SvPOK_on(perl_exception);
13834 ST(0)=sv_2mortal(perl_exception);
13839 ###############################################################################
13843 # S e t P i x e l #
13847 ###############################################################################
13852 Image::Magick ref=NO_INIT
13894 *reference; /* reference is the SV* of ref=SvIV(reference) */
13896 PERL_UNUSED_VAR(ref);
13897 PERL_UNUSED_VAR(ix);
13898 exception=AcquireExceptionInfo();
13899 perl_exception=newSVpv("",0);
13900 reference=SvRV(ST(0));
13901 av=(AV *) reference;
13902 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13904 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13905 if (image == (Image *) NULL)
13907 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13909 goto PerlException;
13912 normalize=MagickTrue;
13915 region.width=image->columns;
13918 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13919 channel=DefaultChannels;
13920 for (i=2; i < items; i+=2)
13922 attribute=(char *) SvPV(ST(i-1),na);
13923 switch (*attribute)
13928 if (LocaleCompare(attribute,"channel") == 0)
13933 option=ParseChannelOption(SvPV(ST(i),na));
13936 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13940 channel=(ChannelType) option;
13943 if (LocaleCompare(attribute,"color") == 0)
13945 if (SvTYPE(ST(i)) != SVt_RV)
13948 message[MagickPathExtent];
13950 (void) FormatLocaleString(message,MagickPathExtent,
13951 "invalid %.60s value",attribute);
13952 ThrowPerlException(exception,OptionError,message,
13955 av=(AV *) SvRV(ST(i));
13958 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13965 if (LocaleCompare(attribute,"geometry") == 0)
13967 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13970 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13977 if (LocaleCompare(attribute,"normalize") == 0)
13979 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13983 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13987 normalize=option != 0 ? MagickTrue : MagickFalse;
13990 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13997 if (LocaleCompare(attribute,"x") == 0)
13999 region.x=SvIV(ST(i));
14002 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14009 if (LocaleCompare(attribute,"y") == 0)
14011 region.y=SvIV(ST(i));
14014 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14020 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14026 (void) SetImageStorageClass(image,DirectClass,exception);
14027 channel_mask=SetImageChannelMask(image,channel);
14028 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14029 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14030 (SvTYPE(av) != SVt_PVAV))
14042 if (normalize != MagickFalse)
14043 scale=QuantumRange;
14044 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14047 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14048 av_fetch(av,i,0)))),q);
14051 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14054 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14055 av_fetch(av,i,0)))),q);
14058 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14061 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14062 av_fetch(av,i,0)))),q);
14065 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14066 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14068 SetPixelBlack(image,ClampToQuantum(scale*
14069 SvNV(*(av_fetch(av,i,0)))),q);
14072 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14075 SetPixelAlpha(image,ClampToQuantum(scale*
14076 SvNV(*(av_fetch(av,i,0)))),q);
14079 (void) SyncAuthenticPixels(image,exception);
14081 (void) SetImageChannelMask(image,channel_mask);
14084 InheritPerlException(exception,perl_exception);
14085 exception=DestroyExceptionInfo(exception);
14086 SvREFCNT_dec(perl_exception);
14090 ###############################################################################
14098 ###############################################################################
14103 Image::Magick ref=NO_INIT
14142 PERL_UNUSED_VAR(ref);
14143 PERL_UNUSED_VAR(ix);
14144 exception=AcquireExceptionInfo();
14145 perl_exception=newSVpv("",0);
14149 if (sv_isobject(ST(0)) == 0)
14151 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14153 goto PerlException;
14155 reference=SvRV(ST(0));
14156 hv=SvSTASH(reference);
14158 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14160 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14161 if (image == (Image *) NULL)
14163 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14165 goto PerlException;
14167 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14173 for (i=2; i < items; i+=2)
14175 attribute=(char *) SvPV(ST(i-1),na);
14176 switch (*attribute)
14181 if (LocaleCompare(attribute,"offset") == 0)
14183 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14186 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14193 if (LocaleCompare(attribute,"stack") == 0)
14195 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14199 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14205 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14211 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14217 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14219 if (image == (Image *) NULL)
14220 goto PerlException;
14221 for ( ; image; image=image->next)
14223 AddImageToRegistry(sv,image);
14225 av_push(av,sv_bless(rv,hv));
14228 exception=DestroyExceptionInfo(exception);
14229 ST(0)=av_reference;
14230 SvREFCNT_dec(perl_exception);
14234 InheritPerlException(exception,perl_exception);
14235 exception=DestroyExceptionInfo(exception);
14236 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14237 SvPOK_on(perl_exception);
14238 ST(0)=sv_2mortal(perl_exception);
14243 ###############################################################################
14247 # S t a t i s t i c s #
14251 ###############################################################################
14255 Statistics(ref,...)
14256 Image::Magick ref=NO_INIT
14258 StatisticsImage = 1
14260 statisticsimage = 3
14263 #define ChannelStatistics(channel) \
14265 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14266 (double) channel_statistics[channel].depth); \
14267 PUSHs(sv_2mortal(newSVpv(message,0))); \
14268 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14269 channel_statistics[channel].minima/scale); \
14270 PUSHs(sv_2mortal(newSVpv(message,0))); \
14271 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14272 channel_statistics[channel].maxima/scale); \
14273 PUSHs(sv_2mortal(newSVpv(message,0))); \
14274 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14275 channel_statistics[channel].mean/scale); \
14276 PUSHs(sv_2mortal(newSVpv(message,0))); \
14277 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14278 channel_statistics[channel].standard_deviation/scale); \
14279 PUSHs(sv_2mortal(newSVpv(message,0))); \
14280 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14281 channel_statistics[channel].kurtosis); \
14282 PUSHs(sv_2mortal(newSVpv(message,0))); \
14283 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14284 channel_statistics[channel].skewness); \
14285 PUSHs(sv_2mortal(newSVpv(message,0))); \
14286 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14287 channel_statistics[channel].entropy); \
14288 PUSHs(sv_2mortal(newSVpv(message,0))); \
14295 message[MagickPathExtent];
14298 *channel_statistics;
14319 PERL_UNUSED_VAR(ref);
14320 PERL_UNUSED_VAR(ix);
14321 exception=AcquireExceptionInfo();
14322 perl_exception=newSVpv("",0);
14324 if (sv_isobject(ST(0)) == 0)
14326 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14328 goto PerlException;
14330 reference=SvRV(ST(0));
14333 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14334 if (image == (Image *) NULL)
14336 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14338 goto PerlException;
14341 for ( ; image; image=image->next)
14343 channel_statistics=GetImageStatistics(image,exception);
14344 if (channel_statistics == (ChannelStatistics *) NULL)
14347 EXTEND(sp,35*count);
14348 scale=(double) QuantumRange;
14349 ChannelStatistics(RedChannel);
14350 ChannelStatistics(GreenChannel);
14351 ChannelStatistics(BlueChannel);
14352 if (image->colorspace == CMYKColorspace)
14353 ChannelStatistics(BlackChannel);
14354 if (image->alpha_trait != UndefinedPixelTrait)
14355 ChannelStatistics(AlphaChannel);
14356 channel_statistics=(ChannelStatistics *)
14357 RelinquishMagickMemory(channel_statistics);
14361 InheritPerlException(exception,perl_exception);
14362 exception=DestroyExceptionInfo(exception);
14363 SvREFCNT_dec(perl_exception);
14367 ###############################################################################
14371 # S y n c A u t h e n t i c P i x e l s #
14375 ###############################################################################
14379 SyncAuthenticPixels(ref,...)
14380 Image::Magick ref = NO_INIT
14382 Syncauthenticpixels = 1
14383 SyncImagePixels = 2
14384 syncimagepixels = 3
14403 PERL_UNUSED_VAR(ref);
14404 PERL_UNUSED_VAR(ix);
14405 exception=AcquireExceptionInfo();
14406 perl_exception=newSVpv("",0);
14407 if (sv_isobject(ST(0)) == 0)
14409 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14411 goto PerlException;
14414 reference=SvRV(ST(0));
14415 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14416 if (image == (Image *) NULL)
14418 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14420 goto PerlException;
14423 status=SyncAuthenticPixels(image,exception);
14424 if (status != MagickFalse)
14428 InheritPerlException(exception,perl_exception);
14429 exception=DestroyExceptionInfo(exception);
14430 SvREFCNT_dec(perl_exception); /* throw away all errors */
14434 ###############################################################################
14438 # T r a n s f o r m #
14442 ###############################################################################
14447 Image::Magick ref=NO_INIT
14485 PERL_UNUSED_VAR(ref);
14486 PERL_UNUSED_VAR(ix);
14487 exception=AcquireExceptionInfo();
14488 perl_exception=newSVpv("",0);
14492 if (sv_isobject(ST(0)) == 0)
14494 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14496 goto PerlException;
14498 reference=SvRV(ST(0));
14499 hv=SvSTASH(reference);
14501 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14503 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14504 if (image == (Image *) NULL)
14506 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14508 goto PerlException;
14510 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14514 crop_geometry=(char *) NULL;
14515 geometry=(char *) NULL;
14516 for (i=2; i < items; i+=2)
14518 attribute=(char *) SvPV(ST(i-1),na);
14519 switch (*attribute)
14524 if (LocaleCompare(attribute,"crop") == 0)
14526 crop_geometry=SvPV(ST(i),na);
14529 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14536 if (LocaleCompare(attribute,"geometry") == 0)
14538 geometry=SvPV(ST(i),na);
14541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14547 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14553 for ( ; image; image=image->next)
14555 clone=CloneImage(image,0,0,MagickTrue,exception);
14556 if (clone == (Image *) NULL)
14557 goto PerlException;
14558 TransformImage(&clone,crop_geometry,geometry,exception);
14559 for ( ; clone; clone=clone->next)
14561 AddImageToRegistry(sv,clone);
14563 av_push(av,sv_bless(rv,hv));
14567 exception=DestroyExceptionInfo(exception);
14568 ST(0)=av_reference;
14569 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14573 InheritPerlException(exception,perl_exception);
14574 exception=DestroyExceptionInfo(exception);
14575 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14576 SvPOK_on(perl_exception);
14577 ST(0)=sv_2mortal(perl_exception);
14582 ###############################################################################
14590 ###############################################################################
14595 Image::Magick ref=NO_INIT
14603 filename[MagickPathExtent];
14627 PERL_UNUSED_VAR(ref);
14628 PERL_UNUSED_VAR(ix);
14629 exception=AcquireExceptionInfo();
14630 perl_exception=newSVpv("",0);
14632 package_info=(struct PackageInfo *) NULL;
14633 if (sv_isobject(ST(0)) == 0)
14635 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14637 goto PerlException;
14639 reference=SvRV(ST(0));
14640 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14641 if (image == (Image *) NULL)
14643 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14645 goto PerlException;
14647 package_info=ClonePackageInfo(info,exception);
14649 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14652 for (i=2; i < items; i+=2)
14653 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14655 (void) CopyMagickString(filename,package_info->image_info->filename,
14658 for (next=image; next; next=next->next)
14660 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14661 next->scene=scene++;
14663 *package_info->image_info->magick='\0';
14664 SetImageInfo(package_info->image_info,(unsigned int)
14665 GetImageListLength(image),exception);
14666 for (next=image; next; next=next->next)
14668 (void) WriteImage(package_info->image_info,next,exception);
14670 if (package_info->image_info->adjoin)
14675 if (package_info != (struct PackageInfo *) NULL)
14676 DestroyPackageInfo(package_info);
14677 InheritPerlException(exception,perl_exception);
14678 exception=DestroyExceptionInfo(exception);
14679 sv_setiv(perl_exception,(IV) number_images);
14680 SvPOK_on(perl_exception);
14681 ST(0)=sv_2mortal(perl_exception);