2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
56 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MagickPI 3.14159265358979323846264338327950288419716939937510
78 #define MaxArguments 33
82 #define NumberOf(array) (sizeof(array)/sizeof(*array))
83 #define PackageName "Image::Magick"
86 #define PerlIO_importFILE(f, fl) (f)
87 #define PerlIO_findFILE(f) NULL
90 #define sv_undef PL_sv_undef
93 #define AddImageToRegistry(sv,image) \
95 if (magick_registry != (SplayTreeInfo *) NULL) \
97 (void) AddValueToSplayTree(magick_registry,image,image); \
98 (sv)=newSViv(PTR2IV(image)); \
102 #define DeleteImageFromRegistry(reference,image) \
104 if (magick_registry != (SplayTreeInfo *) NULL) \
106 if (GetImageReferenceCount(image) == 1) \
107 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
108 image=DestroyImage(image); \
109 sv_setiv(reference,0); \
113 #define InheritPerlException(exception,perl_exception) \
116 message[MagickPathExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MagickPathExtent,"Exception %d: %s%s%s%s",\
121 (exception)->severity, (exception)->reason ? \
122 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
123 "Unknown", (exception)->description ? " (" : "", \
124 (exception)->description ? GetLocaleExceptionMessage( \
125 (exception)->severity,(exception)->description) : "", \
126 (exception)->description ? ")" : ""); \
127 if ((perl_exception) != (SV *) NULL) \
129 if (SvCUR(perl_exception)) \
130 sv_catpv(perl_exception,"\n"); \
131 sv_catpv(perl_exception,message); \
136 #define ThrowPerlException(exception,severity,tag,reason) \
137 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
138 tag,"`%s'",reason); \
141 Typedef and structure declarations.
145 ArrayReference = (~0),
146 RealReference = (~0)-1,
147 FileReference = (~0)-2,
148 ImageReference = (~0)-3,
149 IntegerReference = (~0)-4,
150 StringReference = (~0)-5
153 typedef struct _Arguments
193 *Image__Magick; /* data type for the Image::Magick package */
205 arguments[MaxArguments];
208 { "Comment", { {"comment", StringReference} } },
209 { "Label", { {"label", StringReference} } },
210 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
211 {"channel", MagickChannelOptions} } },
212 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
213 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
214 {"height", IntegerReference}, {"fill", StringReference},
215 {"bordercolor", StringReference}, {"color", StringReference},
216 {"compose", MagickComposeOptions} } },
217 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
218 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference}, {"gravity", MagickGravityOptions} } },
222 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
223 {"height", IntegerReference}, {"x", IntegerReference},
224 {"y", IntegerReference}, {"fuzz", StringReference},
225 {"gravity", MagickGravityOptions} } },
227 { "Edge", { {"radius", RealReference} } },
228 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
229 {"sigma", RealReference} } },
233 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
234 {"height", IntegerReference}, {"inner", IntegerReference},
235 {"outer", IntegerReference}, {"fill", StringReference},
236 {"color", StringReference}, {"compose", MagickComposeOptions} } },
237 { "Implode", { {"amount", RealReference},
238 {"interpolate", MagickInterpolateOptions} } },
240 { "MedianFilter", { {"geometry", StringReference},
241 {"width", IntegerReference}, {"height", IntegerReference},
242 {"channel", MagickChannelOptions} } },
244 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
245 { "ReduceNoise", { {"geometry", StringReference},
246 {"width", IntegerReference},{"height", IntegerReference},
247 {"channel", MagickChannelOptions} } },
248 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
249 {"y", IntegerReference} } },
250 { "Rotate", { {"degrees", RealReference},
251 {"background", StringReference} } },
252 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
253 {"height", IntegerReference} } },
254 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
255 {"height", IntegerReference} } },
256 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
257 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
258 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
259 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
260 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
261 {"y", RealReference}, { "fill", StringReference},
262 {"color", StringReference} } },
263 { "Spread", { {"radius", RealReference},
264 {"interpolate", MagickInterpolateOptions } },
265 { "Swirl", { {"degrees", RealReference},
266 {"interpolate", MagickInterpolateOptions} } },
267 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
268 {"height", IntegerReference}, {"filter", MagickFilterOptions},
269 {"support", StringReference } } },
270 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
271 {"height", IntegerReference}, {"filter", MagickFilterOptions},
272 {"support", RealReference } } },
273 { "Annotate", { {"text", StringReference}, {"font", StringReference},
274 {"pointsize", RealReference}, {"density", StringReference},
275 {"undercolor", StringReference}, {"stroke", StringReference},
276 {"fill", StringReference}, {"geometry", StringReference},
277 {"sans", StringReference}, {"x", RealReference},
278 {"y", RealReference}, {"gravity", MagickGravityOptions},
279 {"translate", StringReference}, {"scale", StringReference},
280 {"rotate", RealReference}, {"skewX", RealReference},
281 {"skewY", RealReference}, {"strokewidth", RealReference},
282 {"antialias", MagickBooleanOptions}, {"family", StringReference},
283 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
284 {"weight", IntegerReference}, {"align", MagickAlignOptions},
285 {"encoding", StringReference}, {"affine", ArrayReference},
286 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
287 {"tile", ImageReference}, {"kerning", RealReference},
288 {"interline-spacing", RealReference},
289 {"interword-spacing", RealReference},
290 {"direction", MagickDirectionOptions} } },
291 { "ColorFloodfill", { {"geometry", StringReference},
292 {"x", IntegerReference}, {"y", IntegerReference},
293 {"fill", StringReference}, {"bordercolor", StringReference},
294 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
295 { "Composite", { {"image", ImageReference},
296 {"compose", MagickComposeOptions}, {"geometry", StringReference},
297 {"x", IntegerReference}, {"y", IntegerReference},
298 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
299 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
300 {"color", StringReference}, {"mask", ImageReference},
301 {"channel", MagickChannelOptions},
302 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
303 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
304 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
305 { "CycleColormap", { {"display", IntegerReference} } },
306 { "Draw", { {"primitive", MagickPrimitiveOptions},
307 {"points", StringReference}, {"method", MagickMethodOptions},
308 {"stroke", StringReference}, {"fill", StringReference},
309 {"strokewidth", RealReference}, {"font", StringReference},
310 {"bordercolor", StringReference}, {"x", RealReference},
311 {"y", RealReference}, {"translate", StringReference},
312 {"scale", StringReference}, {"rotate", RealReference},
313 {"skewX", RealReference}, {"skewY", RealReference},
314 {"tile", ImageReference}, {"pointsize", RealReference},
315 {"antialias", MagickBooleanOptions}, {"density", StringReference},
316 {"linewidth", RealReference}, {"affine", ArrayReference},
317 {"stroke-dashoffset", RealReference},
318 {"stroke-dasharray", ArrayReference},
319 {"interpolate", MagickInterpolateOptions},
320 {"origin", StringReference}, {"text", StringReference},
321 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
322 {"vector-graphics", StringReference}, {"kerning", RealReference},
323 {"interline-spacing", RealReference},
324 {"interword-spacing", RealReference},
325 {"direction", MagickDirectionOptions} } },
326 { "Equalize", { {"channel", MagickChannelOptions} } },
327 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
328 {"red", RealReference}, {"green", RealReference},
329 {"blue", RealReference} } },
330 { "Map", { {"image", ImageReference},
331 {"dither-method", MagickDitherOptions} } },
332 { "MatteFloodfill", { {"geometry", StringReference},
333 {"x", IntegerReference}, {"y", IntegerReference},
334 {"opacity", StringReference}, {"bordercolor", StringReference},
335 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
336 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
337 {"saturation", RealReference}, {"whiteness", RealReference},
338 {"brightness", RealReference}, {"lightness", RealReference},
339 {"blackness", RealReference} } },
340 { "Negate", { {"gray", MagickBooleanOptions},
341 {"channel", MagickChannelOptions} } },
342 { "Normalize", { {"channel", MagickChannelOptions} } },
344 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
345 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
346 {"invert", MagickBooleanOptions} } },
347 { "Quantize", { {"colors", IntegerReference},
348 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
349 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
350 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
351 {"dither-method", MagickDitherOptions} } },
352 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
353 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
354 { "Segment", { {"geometry", StringReference},
355 {"cluster-threshold", RealReference},
356 {"smoothing-threshold", RealReference},
357 {"colorspace", MagickColorspaceOptions},
358 {"verbose", MagickBooleanOptions} } },
360 { "Solarize", { {"geometry", StringReference},
361 {"threshold", StringReference} } },
363 { "Texture", { {"texture", ImageReference} } },
364 { "Evaluate", { {"value", RealReference},
365 {"operator", MagickEvaluateOptions},
366 {"channel", MagickChannelOptions} } },
367 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
368 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
369 { "Threshold", { {"threshold", StringReference},
370 {"channel", MagickChannelOptions} } },
371 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
372 {"sigma", RealReference} } },
373 { "Trim", { {"fuzz", StringReference} } },
374 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
375 {"wavelength", RealReference},
376 {"interpolate", MagickInterpolateOptions} } },
377 { "Separate", { {"channel", MagickChannelOptions} } },
379 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
380 {"y", IntegerReference} } },
381 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
383 { "GaussianBlur", { {"geometry", StringReference},
384 {"radius", RealReference}, {"sigma", RealReference},
385 {"channel", MagickChannelOptions} } },
386 { "Convolve", { {"coefficients", ArrayReference},
387 {"channel", MagickChannelOptions}, {"bias", StringReference},
388 {"kernel", StringReference} } },
389 { "Profile", { {"name", StringReference}, {"profile", StringReference},
390 { "rendering-intent", MagickIntentOptions},
391 { "black-point-compensation", MagickBooleanOptions} } },
392 { "UnsharpMask", { {"geometry", StringReference},
393 {"radius", RealReference}, {"sigma", RealReference},
394 {"gain", RealReference}, {"threshold", RealReference},
395 {"channel", MagickChannelOptions} } },
396 { "MotionBlur", { {"geometry", StringReference},
397 {"radius", RealReference}, {"sigma", RealReference},
398 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
399 { "OrderedDither", { {"threshold", StringReference},
400 {"channel", MagickChannelOptions} } },
401 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
402 {"height", IntegerReference} } },
403 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
404 {"white-point", RealReference}, {"gamma", RealReference},
405 {"channel", MagickChannelOptions}, {"level", StringReference} } },
406 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
407 { "AffineTransform", { {"affine", ArrayReference},
408 {"translate", StringReference}, {"scale", StringReference},
409 {"rotate", RealReference}, {"skewX", RealReference},
410 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
411 {"background", StringReference} } },
412 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
413 { "AdaptiveThreshold", { {"geometry", StringReference},
414 {"width", IntegerReference}, {"height", IntegerReference} } },
415 { "Resample", { {"density", StringReference}, {"x", RealReference},
416 {"y", RealReference}, {"filter", MagickFilterOptions},
417 {"support", RealReference } } },
418 { "Describe", { {"file", FileReference} } },
419 { "BlackThreshold", { {"threshold", StringReference},
420 {"channel", MagickChannelOptions} } },
421 { "WhiteThreshold", { {"threshold", StringReference},
422 {"channel", MagickChannelOptions} } },
423 { "RotationalBlur", { {"geometry", StringReference},
424 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
425 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
426 {"height", IntegerReference} } },
428 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
429 { "Channel", { {"channel", MagickChannelOptions} } },
430 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
431 {"height", IntegerReference}, {"x", IntegerReference},
432 {"y", IntegerReference}, {"fuzz", StringReference},
433 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
434 { "Posterize", { {"levels", IntegerReference},
435 {"dither", MagickBooleanOptions} } },
436 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
437 {"sigma", RealReference}, {"x", IntegerReference},
438 {"y", IntegerReference} } },
439 { "Identify", { {"file", FileReference}, {"features", StringReference},
440 {"unique", MagickBooleanOptions} } },
441 { "SepiaTone", { {"threshold", RealReference} } },
442 { "SigmoidalContrast", { {"geometry", StringReference},
443 {"contrast", RealReference}, {"mid-point", RealReference},
444 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
445 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
446 {"height", IntegerReference}, {"x", IntegerReference},
447 {"y", IntegerReference}, {"fuzz", StringReference},
448 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
449 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
450 {"sigma", RealReference}, {"x", IntegerReference},
451 {"y", IntegerReference}, {"background", StringReference} } },
452 { "ContrastStretch", { {"levels", StringReference},
453 {"black-point", RealReference},{"white-point", RealReference},
454 {"channel", MagickChannelOptions} } },
457 { "AdaptiveSharpen", { {"geometry", StringReference},
458 {"radius", RealReference}, {"sigma", RealReference},
459 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
463 { "AdaptiveBlur", { {"geometry", StringReference},
464 {"radius", RealReference}, {"sigma", RealReference},
465 {"channel", MagickChannelOptions} } },
466 { "Sketch", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"angle", RealReference} } },
470 { "AdaptiveResize", { {"geometry", StringReference},
471 {"width", IntegerReference}, {"height", IntegerReference},
472 {"filter", MagickFilterOptions}, {"support", StringReference },
473 {"blur", RealReference } } },
474 { "ClipMask", { {"mask", ImageReference} } },
475 { "LinearStretch", { {"levels", StringReference},
476 {"black-point", RealReference},{"white-point", RealReference} } },
477 { "ColorMatrix", { {"matrix", ArrayReference} } },
478 { "Mask", { {"mask", ImageReference} } },
479 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
480 {"font", StringReference}, {"stroke", StringReference},
481 {"fill", StringReference}, {"strokewidth", RealReference},
482 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
483 {"background", StringReference},
484 {"interpolate", MagickInterpolateOptions} } },
485 { "FloodfillPaint", { {"geometry", StringReference},
486 {"x", IntegerReference}, {"y", IntegerReference},
487 {"fill", StringReference}, {"bordercolor", StringReference},
488 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
489 {"invert", MagickBooleanOptions} } },
490 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
491 {"virtual-pixel", MagickVirtualPixelOptions},
492 {"best-fit", MagickBooleanOptions} } },
493 { "Clut", { {"image", ImageReference},
494 {"interpolate", MagickInterpolateOptions},
495 {"channel", MagickChannelOptions} } },
496 { "LiquidRescale", { {"geometry", StringReference},
497 {"width", IntegerReference}, {"height", IntegerReference},
498 {"delta-x", RealReference}, {"rigidity", RealReference } } },
499 { "Encipher", { {"passphrase", StringReference} } },
500 { "Decipher", { {"passphrase", StringReference} } },
501 { "Deskew", { {"geometry", StringReference},
502 {"threshold", StringReference} } },
503 { "Remap", { {"image", ImageReference},
504 {"dither-method", MagickDitherOptions} } },
505 { "SparseColor", { {"points", ArrayReference},
506 {"method", MagickSparseColorOptions},
507 {"virtual-pixel", MagickVirtualPixelOptions},
508 {"channel", MagickChannelOptions} } },
509 { "Function", { {"parameters", ArrayReference},
510 {"function", MagickFunctionOptions},
511 {"virtual-pixel", MagickVirtualPixelOptions} } },
512 { "SelectiveBlur", { {"geometry", StringReference},
513 {"radius", RealReference}, {"sigma", RealReference},
514 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
515 { "HaldClut", { {"image", ImageReference},
516 {"channel", MagickChannelOptions} } },
517 { "BlueShift", { {"factor", StringReference} } },
518 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
519 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
520 { "ColorDecisionList", {
521 {"color-correction-collection", StringReference} } },
522 { "AutoGamma", { {"channel", MagickChannelOptions} } },
523 { "AutoLevel", { {"channel", MagickChannelOptions} } },
524 { "LevelColors", { {"invert", MagickBooleanOptions},
525 {"black-point", StringReference}, {"white-point", StringReference},
526 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
527 { "Clamp", { {"channel", MagickChannelOptions} } },
528 { "BrightnessContrast", { {"levels", StringReference},
529 {"brightness", RealReference},{"contrast", RealReference},
530 {"channel", MagickChannelOptions} } },
531 { "Morphology", { {"kernel", StringReference},
532 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
533 {"iterations", IntegerReference} } },
534 { "Sans", { {"matrix", ArrayReference} } },
535 { "Color", { {"color", StringReference} } },
536 { "Mode", { {"geometry", StringReference},
537 {"width", IntegerReference},{"height", IntegerReference},
538 {"channel", MagickChannelOptions} } },
539 { "Statistic", { {"geometry", StringReference},
540 {"width", IntegerReference},{"height", IntegerReference},
541 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
542 { "Perceptible", { {"epsilon", RealReference},
543 {"channel", MagickChannelOptions} } },
544 { "Poly", { {"terms", ArrayReference},
545 {"channel", MagickChannelOptions} } },
546 { "Grayscale", { {"method", MagickNoiseOptions} } },
547 { "CannyEdge", { {"geometry", StringReference},
548 {"radius", RealReference}, {"sigma", RealReference},
549 {"lower-percent", RealReference}, {"upper-percent", RealReference} } },
550 { "HoughLine", { {"geometry", StringReference},
551 {"width", IntegerReference}, {"height", IntegerReference},
552 {"threshold", IntegerReference} } },
553 { "MeanShift", { {"geometry", StringReference},
554 {"width", IntegerReference}, {"height", IntegerReference},
555 {"distance", RealReference} } },
556 { "Kuwahara", { {"geometry", StringReference}, {"radius", RealReference},
557 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
558 { "ConnectedComponents", { {"connectivity", IntegerReference} } },
559 { "CopyPixels", { {"image", ImageReference}, {"geometry", StringReference},
560 {"width", IntegerReference}, {"height", IntegerReference},
561 {"x", IntegerReference}, {"y", IntegerReference},
562 {"gravity", MagickGravityOptions}, {"offset", StringReference},
563 {"dx", IntegerReference}, {"dy", IntegerReference} } },
567 *magick_registry = (SplayTreeInfo *) NULL;
570 Forward declarations.
573 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
576 strEQcase(const char *,const char *);
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
583 % C l o n e P a c k a g e I n f o %
587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
589 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
592 % The format of the ClonePackageInfo routine is:
594 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
597 % A description of each parameter follows:
599 % o info: a structure of type info.
601 % o exception: Return any errors or warnings in this structure.
604 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
605 ExceptionInfo *exception)
610 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
611 if (clone_info == (struct PackageInfo *) NULL)
613 ThrowPerlException(exception,ResourceLimitError,
614 "UnableToClonePackageInfo",PackageName);
615 return((struct PackageInfo *) NULL);
617 if (info == (struct PackageInfo *) NULL)
619 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
623 clone_info->image_info=CloneImageInfo(info->image_info);
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
636 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
638 % constant() returns a double value for the specified name.
640 % The format of the constant routine is:
642 % double constant(char *name,ssize_t sans)
644 % A description of each parameter follows:
646 % o value: Method constant returns a double value for the specified name.
648 % o name: The name of the constant.
650 % o sans: This integer value is not used.
653 static double constant(char *name,ssize_t sans)
661 if (strEQ(name,"BlobError"))
663 if (strEQ(name,"BlobWarning"))
669 if (strEQ(name,"CacheError"))
671 if (strEQ(name,"CacheWarning"))
672 return(CacheWarning);
673 if (strEQ(name,"CoderError"))
675 if (strEQ(name,"CoderWarning"))
676 return(CoderWarning);
677 if (strEQ(name,"ConfigureError"))
678 return(ConfigureError);
679 if (strEQ(name,"ConfigureWarning"))
680 return(ConfigureWarning);
681 if (strEQ(name,"CorruptImageError"))
682 return(CorruptImageError);
683 if (strEQ(name,"CorruptImageWarning"))
684 return(CorruptImageWarning);
689 if (strEQ(name,"DelegateError"))
690 return(DelegateError);
691 if (strEQ(name,"DelegateWarning"))
692 return(DelegateWarning);
693 if (strEQ(name,"DrawError"))
695 if (strEQ(name,"DrawWarning"))
701 if (strEQ(name,"ErrorException"))
702 return(ErrorException);
703 if (strEQ(name,"ExceptionError"))
705 if (strEQ(name,"ExceptionWarning"))
706 return(CoderWarning);
711 if (strEQ(name,"FatalErrorException"))
712 return(FatalErrorException);
713 if (strEQ(name,"FileOpenError"))
714 return(FileOpenError);
715 if (strEQ(name,"FileOpenWarning"))
716 return(FileOpenWarning);
721 if (strEQ(name,"ImageError"))
723 if (strEQ(name,"ImageWarning"))
724 return(ImageWarning);
729 if (strEQ(name,"MaxRGB"))
730 return(QuantumRange);
731 if (strEQ(name,"MissingDelegateError"))
732 return(MissingDelegateError);
733 if (strEQ(name,"MissingDelegateWarning"))
734 return(MissingDelegateWarning);
735 if (strEQ(name,"ModuleError"))
737 if (strEQ(name,"ModuleWarning"))
738 return(ModuleWarning);
743 if (strEQ(name,"Opaque"))
745 if (strEQ(name,"OptionError"))
747 if (strEQ(name,"OptionWarning"))
748 return(OptionWarning);
753 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
754 return(MAGICKCORE_QUANTUM_DEPTH);
755 if (strEQ(name,"QuantumDepth"))
756 return(MAGICKCORE_QUANTUM_DEPTH);
757 if (strEQ(name,"QuantumRange"))
758 return(QuantumRange);
763 if (strEQ(name,"ResourceLimitError"))
764 return(ResourceLimitError);
765 if (strEQ(name,"ResourceLimitWarning"))
766 return(ResourceLimitWarning);
767 if (strEQ(name,"RegistryError"))
768 return(RegistryError);
769 if (strEQ(name,"RegistryWarning"))
770 return(RegistryWarning);
775 if (strEQ(name,"StreamError"))
777 if (strEQ(name,"StreamWarning"))
778 return(StreamWarning);
779 if (strEQ(name,"Success"))
785 if (strEQ(name,"Transparent"))
786 return(TransparentAlpha);
787 if (strEQ(name,"TypeError"))
789 if (strEQ(name,"TypeWarning"))
795 if (strEQ(name,"WarningException"))
796 return(WarningException);
801 if (strEQ(name,"XServerError"))
802 return(XServerError);
803 if (strEQ(name,"XServerWarning"))
804 return(XServerWarning);
813 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
817 % D e s t r o y P a c k a g e I n f o %
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
823 % Method DestroyPackageInfo frees a previously created info structure.
825 % The format of the DestroyPackageInfo routine is:
827 % DestroyPackageInfo(struct PackageInfo *info)
829 % A description of each parameter follows:
831 % o info: a structure of type info.
834 static void DestroyPackageInfo(struct PackageInfo *info)
836 info->image_info=DestroyImageInfo(info->image_info);
837 info=(struct PackageInfo *) RelinquishMagickMemory(info);
841 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
849 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
851 % Method GetList is recursively called by SetupList to traverse the
852 % Image__Magick reference. If building an reference_vector (see SetupList),
853 % *current is the current position in *reference_vector and *last is the final
854 % entry in *reference_vector.
856 % The format of the GetList routine is:
860 % A description of each parameter follows:
862 % o info: a structure of type info.
865 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
866 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
871 if (reference == (SV *) NULL)
873 switch (SvTYPE(reference))
893 previous=(Image *) NULL;
897 for (i=0; i <= n; i++)
903 if (rv && *rv && sv_isobject(*rv))
905 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
907 if (image == (Image *) NULL)
909 if (image == previous)
911 image=CloneImage(image,0,0,MagickTrue,exception);
912 if (image == (Image *) NULL)
915 image->previous=previous;
916 *(previous ? &previous->next : &head)=image;
917 for (previous=image; previous->next; previous=previous->next) ;
925 Blessed scalar, one image.
927 image=INT2PTR(Image *,SvIV(reference));
928 if (image == (Image *) NULL)
930 image->previous=(Image *) NULL;
931 image->next=(Image *) NULL;
932 if (reference_vector)
934 if (*current == *last)
937 if (*reference_vector == (SV **) NULL)
938 *reference_vector=(SV **) AcquireQuantumMemory(*last,
939 sizeof(*reference_vector));
941 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
942 *last,sizeof(*reference_vector));
944 if (*reference_vector == (SV **) NULL)
946 ThrowPerlException(exception,ResourceLimitError,
947 "MemoryAllocationFailed",PackageName);
948 return((Image *) NULL);
950 (*reference_vector)[*current]=reference;
951 (*reference_vector)[++(*current)]=NULL;
958 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
959 (double) SvTYPE(reference));
960 return((Image *) NULL);
964 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
968 % G e t P a c k a g e I n f o %
972 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
974 % Method GetPackageInfo looks up or creates an info structure for the given
975 % Image__Magick reference. If it does create a new one, the information in
976 % package_info is used to initialize it.
978 % The format of the GetPackageInfo routine is:
980 % struct PackageInfo *GetPackageInfo(void *reference,
981 % struct PackageInfo *package_info,ExceptionInfo *exception)
983 % A description of each parameter follows:
985 % o info: a structure of type info.
987 % o exception: Return any errors or warnings in this structure.
990 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
991 struct PackageInfo *package_info,ExceptionInfo *exception)
994 message[MagickPathExtent];
1002 (void) FormatLocaleString(message,MagickPathExtent,"%s::package%s%p",
1003 PackageName,XS_VERSION,reference);
1004 sv=perl_get_sv(message,(TRUE | 0x02));
1005 if (sv == (SV *) NULL)
1007 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1009 return(package_info);
1011 if (SvREFCNT(sv) == 0)
1012 (void) SvREFCNT_inc(sv);
1013 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1015 clone_info=ClonePackageInfo(package_info,exception);
1016 sv_setiv(sv,PTR2IV(clone_info));
1021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1025 % S e t A t t r i b u t e %
1029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1031 % SetAttribute() sets the attribute to the value in sval. This can change
1032 % either or both of image or info.
1034 % The format of the SetAttribute routine is:
1036 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1037 % SV *sval,ExceptionInfo *exception)
1039 % A description of each parameter follows:
1041 % o list: a list of strings.
1043 % o string: a character string.
1047 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1055 value=InterpretSiPrefixValue(string,&q);
1057 value*=interval/100.0;
1061 static inline double StringToDouble(const char *string,char **sentinal)
1063 return(InterpretLocaleValue(string,sentinal));
1066 static double StringToDoubleInterval(const char *string,const double interval)
1074 value=InterpretLocaleValue(string,&q);
1076 value*=interval/100.0;
1080 static inline ssize_t StringToLong(const char *value)
1082 return(strtol(value,(char **) NULL,10));
1085 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1086 const char *attribute,SV *sval,ExceptionInfo *exception)
1113 if (LocaleCompare(attribute,"adjoin") == 0)
1115 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1116 SvPV(sval,na)) : SvIV(sval);
1119 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1124 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1127 if (LocaleCompare(attribute,"alpha") == 0)
1129 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1130 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1133 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1137 for ( ; image; image=image->next)
1138 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1142 if (LocaleCompare(attribute,"antialias") == 0)
1144 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1145 SvPV(sval,na)) : SvIV(sval);
1148 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1153 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1156 if (LocaleCompare(attribute,"area-limit") == 0)
1161 limit=MagickResourceInfinity;
1162 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1163 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1165 (void) SetMagickResourceLimit(AreaResource,limit);
1168 if (LocaleCompare(attribute,"attenuate") == 0)
1171 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1174 if (LocaleCompare(attribute,"authenticate") == 0)
1177 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1181 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1182 for ( ; image; image=image->next)
1183 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1189 if (LocaleCompare(attribute,"background") == 0)
1191 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1194 info->image_info->background_color=target_color;
1195 for ( ; image; image=image->next)
1196 image->background_color=target_color;
1199 if (LocaleCompare(attribute,"blue-primary") == 0)
1201 for ( ; image; image=image->next)
1203 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1204 image->chromaticity.blue_primary.x=geometry_info.rho;
1205 image->chromaticity.blue_primary.y=geometry_info.sigma;
1206 if ((flags & SigmaValue) == 0)
1207 image->chromaticity.blue_primary.y=
1208 image->chromaticity.blue_primary.x;
1212 if (LocaleCompare(attribute,"bordercolor") == 0)
1214 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1217 info->image_info->border_color=target_color;
1218 for ( ; image; image=image->next)
1219 image->border_color=target_color;
1223 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1224 for ( ; image; image=image->next)
1225 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1231 if (LocaleCompare(attribute,"cache-threshold") == 0)
1233 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1234 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1235 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1236 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1239 if (LocaleCompare(attribute,"clip-mask") == 0)
1244 clip_mask=(Image *) NULL;
1246 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1247 for ( ; image; image=image->next)
1248 SetImageMask(image,ReadPixelMask,clip_mask,exception);
1251 if (LocaleNCompare(attribute,"colormap",8) == 0)
1253 for ( ; image; image=image->next)
1261 if (image->storage_class == DirectClass)
1264 items=sscanf(attribute,"%*[^[][%ld",&i);
1266 if (i > (ssize_t) image->colors)
1268 if ((strchr(SvPV(sval,na),',') == 0) ||
1269 (strchr(SvPV(sval,na),')') != 0))
1270 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1271 image->colormap+i,exception);
1274 color=image->colormap+i;
1275 pixel.red=color->red;
1276 pixel.green=color->green;
1277 pixel.blue=color->blue;
1278 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1279 pixel.red=geometry_info.rho;
1280 pixel.green=geometry_info.sigma;
1281 pixel.blue=geometry_info.xi;
1282 color->red=ClampToQuantum(pixel.red);
1283 color->green=ClampToQuantum(pixel.green);
1284 color->blue=ClampToQuantum(pixel.blue);
1289 if (LocaleCompare(attribute,"colorspace") == 0)
1291 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1292 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1295 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1299 for ( ; image; image=image->next)
1300 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1304 if (LocaleCompare(attribute,"comment") == 0)
1306 for ( ; image; image=image->next)
1307 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1308 info ? info->image_info : (ImageInfo *) NULL,image,
1309 SvPV(sval,na),exception),exception);
1312 if (LocaleCompare(attribute,"compression") == 0)
1314 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1315 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1318 ThrowPerlException(exception,OptionError,
1319 "UnrecognizedImageCompression",SvPV(sval,na));
1323 info->image_info->compression=(CompressionType) sp;
1324 for ( ; image; image=image->next)
1325 image->compression=(CompressionType) sp;
1329 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1330 for ( ; image; image=image->next)
1331 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1337 if (LocaleCompare(attribute,"debug") == 0)
1339 SetLogEventMask(SvPV(sval,na));
1342 if (LocaleCompare(attribute,"delay") == 0)
1344 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1345 for ( ; image; image=image->next)
1347 image->delay=(size_t) floor(geometry_info.rho+0.5);
1348 if ((flags & SigmaValue) != 0)
1349 image->ticks_per_second=(ssize_t)
1350 floor(geometry_info.sigma+0.5);
1354 if (LocaleCompare(attribute,"disk-limit") == 0)
1359 limit=MagickResourceInfinity;
1360 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1361 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1363 (void) SetMagickResourceLimit(DiskResource,limit);
1366 if (LocaleCompare(attribute,"density") == 0)
1368 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1370 ThrowPerlException(exception,OptionError,"MissingGeometry",
1375 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1376 for ( ; image; image=image->next)
1378 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1379 image->resolution.x=geometry_info.rho;
1380 image->resolution.y=geometry_info.sigma;
1381 if ((flags & SigmaValue) == 0)
1382 image->resolution.y=image->resolution.x;
1386 if (LocaleCompare(attribute,"depth") == 0)
1389 info->image_info->depth=SvIV(sval);
1390 for ( ; image; image=image->next)
1391 (void) SetImageDepth(image,SvIV(sval),exception);
1394 if (LocaleCompare(attribute,"dispose") == 0)
1396 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1397 SvPV(sval,na)) : SvIV(sval);
1400 ThrowPerlException(exception,OptionError,
1401 "UnrecognizedDisposeMethod",SvPV(sval,na));
1404 for ( ; image; image=image->next)
1405 image->dispose=(DisposeType) sp;
1408 if (LocaleCompare(attribute,"dither") == 0)
1412 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1413 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1416 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1420 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1424 if (LocaleCompare(attribute,"display") == 0)
1428 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1432 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1433 for ( ; image; image=image->next)
1434 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1440 if (LocaleCompare(attribute,"endian") == 0)
1442 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1443 SvPV(sval,na)) : SvIV(sval);
1446 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1451 info->image_info->endian=(EndianType) sp;
1452 for ( ; image; image=image->next)
1453 image->endian=(EndianType) sp;
1456 if (LocaleCompare(attribute,"extract") == 0)
1459 Set image extract geometry.
1461 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1465 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1466 for ( ; image; image=image->next)
1467 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1473 if (LocaleCompare(attribute,"filename") == 0)
1476 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1478 for ( ; image; image=image->next)
1479 (void) CopyMagickString(image->filename,SvPV(sval,na),
1483 if (LocaleCompare(attribute,"file") == 0)
1491 if (info == (struct PackageInfo *) NULL)
1493 io_info=IoIFP(sv_2io(sval));
1494 if (io_info == (PerlIO *) NULL)
1496 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1500 file=PerlIO_findFILE(io_info);
1501 if (file == (FILE *) NULL)
1503 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1507 SetImageInfoFile(info->image_info,file);
1510 if (LocaleCompare(attribute,"fill") == 0)
1513 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1516 if (LocaleCompare(attribute,"font") == 0)
1519 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1522 if (LocaleCompare(attribute,"foreground") == 0)
1524 if (LocaleCompare(attribute,"fuzz") == 0)
1527 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1529 for ( ; image; image=image->next)
1530 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1535 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1536 for ( ; image; image=image->next)
1537 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1543 if (LocaleCompare(attribute,"gamma") == 0)
1545 for ( ; image; image=image->next)
1546 image->gamma=SvNV(sval);
1549 if (LocaleCompare(attribute,"gravity") == 0)
1551 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1552 SvPV(sval,na)) : SvIV(sval);
1555 ThrowPerlException(exception,OptionError,
1556 "UnrecognizedGravityType",SvPV(sval,na));
1560 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1561 for ( ; image; image=image->next)
1562 image->gravity=(GravityType) sp;
1565 if (LocaleCompare(attribute,"green-primary") == 0)
1567 for ( ; image; image=image->next)
1569 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1570 image->chromaticity.green_primary.x=geometry_info.rho;
1571 image->chromaticity.green_primary.y=geometry_info.sigma;
1572 if ((flags & SigmaValue) == 0)
1573 image->chromaticity.green_primary.y=
1574 image->chromaticity.green_primary.x;
1579 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1580 for ( ; image; image=image->next)
1581 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1587 if (LocaleNCompare(attribute,"index",5) == 0)
1601 for ( ; image; image=image->next)
1603 if (image->storage_class != PseudoClass)
1607 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1609 image_view=AcquireAuthenticCacheView(image,exception);
1610 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1611 if (q != (Quantum *) NULL)
1613 items=sscanf(SvPV(sval,na),"%ld",&index);
1614 if ((index >= 0) && (index < (ssize_t) image->colors))
1615 SetPixelIndex(image,index,q);
1616 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1618 image_view=DestroyCacheView(image_view);
1622 if (LocaleCompare(attribute,"iterations") == 0)
1625 for ( ; image; image=image->next)
1626 image->iterations=SvIV(sval);
1629 if (LocaleCompare(attribute,"interlace") == 0)
1631 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1632 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1635 ThrowPerlException(exception,OptionError,
1636 "UnrecognizedInterlaceType",SvPV(sval,na));
1640 info->image_info->interlace=(InterlaceType) sp;
1641 for ( ; image; image=image->next)
1642 image->interlace=(InterlaceType) sp;
1646 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1647 for ( ; image; image=image->next)
1648 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1654 if (LocaleCompare(attribute,"label") == 0)
1656 for ( ; image; image=image->next)
1657 (void) SetImageProperty(image,"label",InterpretImageProperties(
1658 info ? info->image_info : (ImageInfo *) NULL,image,
1659 SvPV(sval,na),exception),exception);
1662 if (LocaleCompare(attribute,"loop") == 0)
1665 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1666 for ( ; image; image=image->next)
1667 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1673 if (LocaleCompare(attribute,"magick") == 0)
1676 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
1677 "%s:",SvPV(sval,na));
1678 for ( ; image; image=image->next)
1679 (void) CopyMagickString(image->magick,SvPV(sval,na),MagickPathExtent);
1682 if (LocaleCompare(attribute,"map-limit") == 0)
1687 limit=MagickResourceInfinity;
1688 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1689 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1691 (void) SetMagickResourceLimit(MapResource,limit);
1694 if (LocaleCompare(attribute,"mask") == 0)
1699 mask=(Image *) NULL;
1701 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1702 for ( ; image; image=image->next)
1703 SetImageMask(image,ReadPixelMask,mask,exception);
1706 if (LocaleCompare(attribute,"mattecolor") == 0)
1708 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1711 info->image_info->matte_color=target_color;
1712 for ( ; image; image=image->next)
1713 image->matte_color=target_color;
1716 if (LocaleCompare(attribute,"matte") == 0)
1718 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1719 SvPV(sval,na)) : SvIV(sval);
1722 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1726 for ( ; image; image=image->next)
1727 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1730 if (LocaleCompare(attribute,"memory-limit") == 0)
1735 limit=MagickResourceInfinity;
1736 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1737 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1739 (void) SetMagickResourceLimit(MemoryResource,limit);
1742 if (LocaleCompare(attribute,"monochrome") == 0)
1744 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1745 SvPV(sval,na)) : SvIV(sval);
1748 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1753 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1754 for ( ; image; image=image->next)
1755 (void) SetImageType(image,BilevelType,exception);
1759 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1760 for ( ; image; image=image->next)
1761 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1767 if (LocaleCompare(attribute,"option") == 0)
1770 DefineImageOption(info->image_info,SvPV(sval,na));
1773 if (LocaleCompare(attribute,"orientation") == 0)
1775 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1776 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1779 ThrowPerlException(exception,OptionError,
1780 "UnrecognizedOrientationType",SvPV(sval,na));
1784 info->image_info->orientation=(OrientationType) sp;
1785 for ( ; image; image=image->next)
1786 image->orientation=(OrientationType) sp;
1790 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1791 for ( ; image; image=image->next)
1792 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1798 if (LocaleCompare(attribute,"page") == 0)
1803 geometry=GetPageGeometry(SvPV(sval,na));
1805 (void) CloneString(&info->image_info->page,geometry);
1806 for ( ; image; image=image->next)
1807 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1808 geometry=(char *) RelinquishMagickMemory(geometry);
1811 if (LocaleNCompare(attribute,"pixel",5) == 0)
1825 for ( ; image; image=image->next)
1827 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1831 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1833 image_view=AcquireVirtualCacheView(image,exception);
1834 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1835 if (q != (Quantum *) NULL)
1837 if ((strchr(SvPV(sval,na),',') == 0) ||
1838 (strchr(SvPV(sval,na),')') != 0))
1839 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1843 GetPixelInfo(image,&pixel);
1844 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1845 pixel.red=geometry_info.rho;
1846 if ((flags & SigmaValue) != 0)
1847 pixel.green=geometry_info.sigma;
1848 if ((flags & XiValue) != 0)
1849 pixel.blue=geometry_info.xi;
1850 if ((flags & PsiValue) != 0)
1851 pixel.alpha=geometry_info.psi;
1852 if ((flags & ChiValue) != 0)
1853 pixel.black=geometry_info.chi;
1855 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1856 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1857 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1858 if (image->colorspace == CMYKColorspace)
1859 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1860 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1861 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1863 image_view=DestroyCacheView(image_view);
1867 if (LocaleCompare(attribute,"pointsize") == 0)
1871 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1872 info->image_info->pointsize=geometry_info.rho;
1876 if (LocaleCompare(attribute,"preview") == 0)
1878 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1879 SvPV(sval,na)) : SvIV(sval);
1882 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1887 info->image_info->preview_type=(PreviewType) sp;
1891 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1892 for ( ; image; image=image->next)
1893 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1899 if (LocaleCompare(attribute,"quality") == 0)
1902 info->image_info->quality=SvIV(sval);
1903 for ( ; image; image=image->next)
1904 image->quality=SvIV(sval);
1908 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1909 for ( ; image; image=image->next)
1910 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1916 if (LocaleCompare(attribute,"read-mask") == 0)
1921 mask=(Image *) NULL;
1923 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1924 for ( ; image; image=image->next)
1925 SetImageMask(image,ReadPixelMask,mask,exception);
1928 if (LocaleCompare(attribute,"red-primary") == 0)
1930 for ( ; image; image=image->next)
1932 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1933 image->chromaticity.red_primary.x=geometry_info.rho;
1934 image->chromaticity.red_primary.y=geometry_info.sigma;
1935 if ((flags & SigmaValue) == 0)
1936 image->chromaticity.red_primary.y=
1937 image->chromaticity.red_primary.x;
1941 if (LocaleCompare(attribute,"render") == 0)
1943 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1944 SvPV(sval,na)) : SvIV(sval);
1947 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1951 for ( ; image; image=image->next)
1952 image->rendering_intent=(RenderingIntent) sp;
1955 if (LocaleCompare(attribute,"repage") == 0)
1960 for ( ; image; image=image->next)
1962 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1963 if ((flags & WidthValue) != 0)
1965 if ((flags & HeightValue) == 0)
1966 geometry.height=geometry.width;
1967 image->page.width=geometry.width;
1968 image->page.height=geometry.height;
1970 if ((flags & AspectValue) != 0)
1972 if ((flags & XValue) != 0)
1973 image->page.x+=geometry.x;
1974 if ((flags & YValue) != 0)
1975 image->page.y+=geometry.y;
1979 if ((flags & XValue) != 0)
1981 image->page.x=geometry.x;
1982 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1983 image->page.width=image->columns+geometry.x;
1985 if ((flags & YValue) != 0)
1987 image->page.y=geometry.y;
1988 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1989 image->page.height=image->rows+geometry.y;
1996 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1997 for ( ; image; image=image->next)
1998 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2004 if (LocaleCompare(attribute,"sampling-factor") == 0)
2006 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2008 ThrowPerlException(exception,OptionError,"MissingGeometry",
2013 (void) CloneString(&info->image_info->sampling_factor,
2017 if (LocaleCompare(attribute,"scene") == 0)
2019 for ( ; image; image=image->next)
2020 image->scene=SvIV(sval);
2023 if (LocaleCompare(attribute,"server") == 0)
2025 if (LocaleCompare(attribute,"size") == 0)
2029 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2031 ThrowPerlException(exception,OptionError,"MissingGeometry",
2035 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2039 if (LocaleCompare(attribute,"stroke") == 0)
2042 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2046 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2047 for ( ; image; image=image->next)
2048 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2054 if (LocaleCompare(attribute,"texture") == 0)
2057 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2060 if (LocaleCompare(attribute,"thread-limit") == 0)
2065 limit=MagickResourceInfinity;
2066 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2067 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2069 (void) SetMagickResourceLimit(ThreadResource,limit);
2072 if (LocaleCompare(attribute,"tile-offset") == 0)
2077 geometry=GetPageGeometry(SvPV(sval,na));
2079 (void) CloneString(&info->image_info->page,geometry);
2080 for ( ; image; image=image->next)
2081 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2083 geometry=(char *) RelinquishMagickMemory(geometry);
2086 if (LocaleCompare(attribute,"time-limit") == 0)
2091 limit=MagickResourceInfinity;
2092 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2093 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2095 (void) SetMagickResourceLimit(TimeResource,limit);
2098 if (LocaleCompare(attribute,"transparent-color") == 0)
2100 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2103 info->image_info->transparent_color=target_color;
2104 for ( ; image; image=image->next)
2105 image->transparent_color=target_color;
2108 if (LocaleCompare(attribute,"type") == 0)
2110 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2111 SvPV(sval,na)) : SvIV(sval);
2114 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2119 info->image_info->type=(ImageType) sp;
2120 for ( ; image; image=image->next)
2121 SetImageType(image,(ImageType) sp,exception);
2125 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2126 for ( ; image; image=image->next)
2127 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2133 if (LocaleCompare(attribute,"units") == 0)
2135 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2136 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2139 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2144 info->image_info->units=(ResolutionType) sp;
2145 for ( ; image; image=image->next)
2150 units=(ResolutionType) sp;
2151 if (image->units != units)
2152 switch (image->units)
2154 case UndefinedResolution:
2155 case PixelsPerInchResolution:
2157 if (units == PixelsPerCentimeterResolution)
2159 image->resolution.x*=2.54;
2160 image->resolution.y*=2.54;
2164 case PixelsPerCentimeterResolution:
2166 if (units == PixelsPerInchResolution)
2168 image->resolution.x/=2.54;
2169 image->resolution.y/=2.54;
2179 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2180 for ( ; image; image=image->next)
2181 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2187 if (LocaleCompare(attribute,"verbose") == 0)
2189 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2190 SvPV(sval,na)) : SvIV(sval);
2193 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2198 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2201 if (LocaleCompare(attribute,"view") == 0)
2204 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2207 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2209 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2210 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2213 ThrowPerlException(exception,OptionError,
2214 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2217 for ( ; image; image=image->next)
2218 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2222 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2223 for ( ; image; image=image->next)
2224 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2230 if (LocaleCompare(attribute,"white-point") == 0)
2232 for ( ; image; image=image->next)
2234 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2235 image->chromaticity.white_point.x=geometry_info.rho;
2236 image->chromaticity.white_point.y=geometry_info.sigma;
2237 if ((flags & SigmaValue) == 0)
2238 image->chromaticity.white_point.y=
2239 image->chromaticity.white_point.x;
2243 if (LocaleCompare(attribute,"write-mask") == 0)
2248 mask=(Image *) NULL;
2250 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
2251 for ( ; image; image=image->next)
2252 SetImageMask(image,WritePixelMask,mask,exception);
2256 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2257 for ( ; image; image=image->next)
2258 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2264 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2265 for ( ; image; image=image->next)
2266 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2277 % S e t u p L i s t %
2281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2283 % Method SetupList returns the list of all the images linked by their
2284 % image->next and image->previous link lists for use with ImageMagick. If
2285 % info is non-NULL, an info structure is returned in *info. If
2286 % reference_vector is non-NULL,an array of SV* are returned in
2287 % *reference_vector. Reference_vector is used when the images are going to be
2288 % replaced with new Image*'s.
2290 % The format of the SetupList routine is:
2292 % Image *SetupList(SV *reference,struct PackageInfo **info,
2293 % SV ***reference_vector,ExceptionInfo *exception)
2295 % A description of each parameter follows:
2297 % o list: a list of strings.
2299 % o string: a character string.
2301 % o exception: Return any errors or warnings in this structure.
2304 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2305 SV ***reference_vector,ExceptionInfo *exception)
2314 if (reference_vector)
2315 *reference_vector=NULL;
2320 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2321 if (info && (SvTYPE(reference) == SVt_PVAV))
2322 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2328 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2332 % s t r E Q c a s e %
2336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2338 % strEQcase() compares two strings and returns 0 if they are the
2339 % same or if the second string runs out first. The comparison is case
2342 % The format of the strEQcase routine is:
2344 % ssize_t strEQcase(const char *p,const char *q)
2346 % A description of each parameter follows:
2348 % o p: a character string.
2350 % o q: a character string.
2354 static ssize_t strEQcase(const char *p,const char *q)
2362 for (i=0 ; (c=(*q)) != 0; i++)
2364 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2365 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2370 return(((*q == 0) && (*p == 0)) ? i : 0);
2374 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2378 % I m a g e : : M a g i c k %
2382 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2386 MODULE = Image::Magick PACKAGE = Image::Magick
2391 MagickCoreGenesis("PerlMagick",MagickFalse);
2392 SetWarningHandler(NULL);
2393 SetErrorHandler(NULL);
2394 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2395 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2401 if (magick_registry != (SplayTreeInfo *) NULL)
2402 magick_registry=DestroySplayTree(magick_registry);
2403 MagickCoreTerminus();
2407 constant(name,argument)
2412 ###############################################################################
2420 ###############################################################################
2425 Image::Magick ref=NO_INIT
2449 PERL_UNUSED_VAR(ref);
2450 PERL_UNUSED_VAR(ix);
2451 exception=AcquireExceptionInfo();
2452 perl_exception=newSVpv("",0);
2453 package_info=(struct PackageInfo *) NULL;
2454 if (sv_isobject(ST(0)) == 0)
2456 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2460 reference=SvRV(ST(0));
2461 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2462 if (image == (Image *) NULL)
2464 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2468 package_info=ClonePackageInfo(info,exception);
2470 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2473 for (i=2; i < items; i+=2)
2474 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2476 (void) AnimateImages(package_info->image_info,image,exception);
2477 (void) CatchImageException(image);
2480 if (package_info != (struct PackageInfo *) NULL)
2481 DestroyPackageInfo(package_info);
2482 InheritPerlException(exception,perl_exception);
2483 exception=DestroyExceptionInfo(exception);
2484 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2485 SvPOK_on(perl_exception);
2486 ST(0)=sv_2mortal(perl_exception);
2491 ###############################################################################
2499 ###############################################################################
2504 Image::Magick ref=NO_INIT
2542 PERL_UNUSED_VAR(ref);
2543 PERL_UNUSED_VAR(ix);
2544 exception=AcquireExceptionInfo();
2545 perl_exception=newSVpv("",0);
2549 if (sv_isobject(ST(0)) == 0)
2551 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2555 reference=SvRV(ST(0));
2556 hv=SvSTASH(reference);
2558 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2560 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2561 if (image == (Image *) NULL)
2563 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2567 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2572 for (i=2; i < items; i+=2)
2574 attribute=(char *) SvPV(ST(i-1),na);
2580 if (LocaleCompare(attribute,"stack") == 0)
2582 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2586 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2592 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2598 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2604 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2605 if (image == (Image *) NULL)
2607 for ( ; image; image=image->next)
2609 AddImageToRegistry(sv,image);
2611 av_push(av,sv_bless(rv,hv));
2614 exception=DestroyExceptionInfo(exception);
2616 SvREFCNT_dec(perl_exception);
2620 InheritPerlException(exception,perl_exception);
2621 exception=DestroyExceptionInfo(exception);
2622 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2623 SvPOK_on(perl_exception);
2624 ST(0)=sv_2mortal(perl_exception);
2629 ###############################################################################
2637 ###############################################################################
2642 Image::Magick ref=NO_INIT
2673 PERL_UNUSED_VAR(ref);
2674 PERL_UNUSED_VAR(ix);
2675 exception=AcquireExceptionInfo();
2676 perl_exception=newSVpv("",0);
2678 if (sv_isobject(ST(0)) == 0)
2680 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2684 reference=SvRV(ST(0));
2685 hv=SvSTASH(reference);
2686 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2687 if (image == (Image *) NULL)
2689 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2693 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2694 if (image == (Image *) NULL)
2697 Create blessed Perl array for the returned image.
2700 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2702 AddImageToRegistry(sv,image);
2704 av_push(av,sv_bless(rv,hv));
2706 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2707 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2708 "average-%.*s",(int) (MagickPathExtent-9),
2709 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2710 (void) CopyMagickString(image->filename,info->image_info->filename,
2712 SetImageInfo(info->image_info,0,exception);
2713 exception=DestroyExceptionInfo(exception);
2714 SvREFCNT_dec(perl_exception);
2718 InheritPerlException(exception,perl_exception);
2719 exception=DestroyExceptionInfo(exception);
2720 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2721 SvPOK_on(perl_exception);
2722 ST(0)=sv_2mortal(perl_exception);
2727 ###############################################################################
2731 # B l o b T o I m a g e #
2735 ###############################################################################
2739 BlobToImage(ref,...)
2740 Image::Magick ref=NO_INIT
2786 PERL_UNUSED_VAR(ref);
2787 PERL_UNUSED_VAR(ix);
2788 exception=AcquireExceptionInfo();
2789 perl_exception=newSVpv("",0);
2792 ac=(items < 2) ? 1 : items-1;
2793 length=(STRLEN *) NULL;
2794 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2795 if (list == (char **) NULL)
2797 ThrowPerlException(exception,ResourceLimitError,
2798 "MemoryAllocationFailed",PackageName);
2801 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2802 if (length == (STRLEN *) NULL)
2804 ThrowPerlException(exception,ResourceLimitError,
2805 "MemoryAllocationFailed",PackageName);
2808 if (sv_isobject(ST(0)) == 0)
2810 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2814 reference=SvRV(ST(0));
2815 hv=SvSTASH(reference);
2816 if (SvTYPE(reference) != SVt_PVAV)
2818 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2822 av=(AV *) reference;
2823 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2828 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2831 for (n=0, i=0; i < ac; i++)
2833 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2834 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2836 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2841 list[n]=(char *) NULL;
2843 for (i=number_images=0; i < n; i++)
2845 image=BlobToImage(info->image_info,list[i],length[i],exception);
2846 if (image == (Image *) NULL)
2848 for ( ; image; image=image->next)
2850 AddImageToRegistry(sv,image);
2852 av_push(av,sv_bless(rv,hv));
2860 for (i=0; i < n; i++)
2861 if (list[i] != (char *) NULL)
2862 for (p=keep; list[i] != *p++; )
2863 if (*p == (char *) NULL)
2865 list[i]=(char *) RelinquishMagickMemory(list[i]);
2871 list=(char **) RelinquishMagickMemory(list);
2873 length=(STRLEN *) RelinquishMagickMemory(length);
2874 InheritPerlException(exception,perl_exception);
2875 exception=DestroyExceptionInfo(exception);
2876 sv_setiv(perl_exception,(IV) number_images);
2877 SvPOK_on(perl_exception);
2878 ST(0)=sv_2mortal(perl_exception);
2883 ###############################################################################
2887 # C h a n n e l F x #
2891 ###############################################################################
2896 Image::Magick ref=NO_INIT
2908 expression[MagickPathExtent];
2936 PERL_UNUSED_VAR(ref);
2937 PERL_UNUSED_VAR(ix);
2938 exception=AcquireExceptionInfo();
2939 perl_exception=newSVpv("",0);
2943 if (sv_isobject(ST(0)) == 0)
2945 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2949 reference=SvRV(ST(0));
2950 hv=SvSTASH(reference);
2952 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2954 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2955 if (image == (Image *) NULL)
2957 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2961 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2965 channel=DefaultChannels;
2966 (void) CopyMagickString(expression,"u",MagickPathExtent);
2968 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
2970 for (i=2; i < items; i+=2)
2972 attribute=(char *) SvPV(ST(i-1),na);
2978 if (LocaleCompare(attribute,"channel") == 0)
2983 option=ParseChannelOption(SvPV(ST(i),na));
2986 ThrowPerlException(exception,OptionError,
2987 "UnrecognizedType",SvPV(ST(i),na));
2990 channel=(ChannelType) option;
2993 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3000 if (LocaleCompare(attribute,"expression") == 0)
3002 (void) CopyMagickString(expression,SvPV(ST(i),na),
3006 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3012 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3018 channel_mask=SetImageChannelMask(image,channel);
3019 image=ChannelFxImage(image,expression,exception);
3020 if (image != (Image *) NULL)
3021 (void) SetImageChannelMask(image,channel_mask);
3022 if (image == (Image *) NULL)
3024 for ( ; image; image=image->next)
3026 AddImageToRegistry(sv,image);
3028 av_push(av,sv_bless(rv,hv));
3031 exception=DestroyExceptionInfo(exception);
3033 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3037 InheritPerlException(exception,perl_exception);
3038 exception=DestroyExceptionInfo(exception);
3039 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3040 SvPOK_on(perl_exception);
3041 ST(0)=sv_2mortal(perl_exception);
3046 ###############################################################################
3054 ###############################################################################
3059 Image::Magick ref=NO_INIT
3092 PERL_UNUSED_VAR(ref);
3093 PERL_UNUSED_VAR(ix);
3094 exception=AcquireExceptionInfo();
3095 perl_exception=newSVpv("",0);
3097 if (sv_isobject(ST(0)) == 0)
3099 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3103 reference=SvRV(ST(0));
3104 hv=SvSTASH(reference);
3105 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3106 if (image == (Image *) NULL)
3108 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3113 Create blessed Perl array for the returned image.
3116 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3118 for ( ; image; image=image->next)
3120 clone=CloneImage(image,0,0,MagickTrue,exception);
3121 if (clone == (Image *) NULL)
3123 AddImageToRegistry(sv,clone);
3125 av_push(av,sv_bless(rv,hv));
3128 exception=DestroyExceptionInfo(exception);
3129 SvREFCNT_dec(perl_exception);
3133 InheritPerlException(exception,perl_exception);
3134 exception=DestroyExceptionInfo(exception);
3135 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3136 SvPOK_on(perl_exception);
3137 ST(0)=sv_2mortal(perl_exception);
3142 ###############################################################################
3150 ###############################################################################
3158 PERL_UNUSED_VAR(ref);
3159 if (magick_registry != (SplayTreeInfo *) NULL)
3164 ResetSplayTreeIterator(magick_registry);
3165 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3166 while (p != (Image *) NULL)
3169 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3175 ###############################################################################
3183 ###############################################################################
3188 Image::Magick ref=NO_INIT
3217 PERL_UNUSED_VAR(ref);
3218 PERL_UNUSED_VAR(ix);
3219 exception=AcquireExceptionInfo();
3220 perl_exception=newSVpv("",0);
3222 if (sv_isobject(ST(0)) == 0)
3224 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3228 reference=SvRV(ST(0));
3229 hv=SvSTASH(reference);
3231 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3233 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3234 if (image == (Image *) NULL)
3236 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3240 image=CoalesceImages(image,exception);
3241 if (image == (Image *) NULL)
3243 for ( ; image; image=image->next)
3245 AddImageToRegistry(sv,image);
3247 av_push(av,sv_bless(rv,hv));
3250 exception=DestroyExceptionInfo(exception);
3252 SvREFCNT_dec(perl_exception);
3256 InheritPerlException(exception,perl_exception);
3257 exception=DestroyExceptionInfo(exception);
3258 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3259 SvPOK_on(perl_exception);
3260 ST(0)=sv_2mortal(perl_exception);
3265 ###############################################################################
3273 ###############################################################################
3278 Image::Magick ref=NO_INIT
3324 PERL_UNUSED_VAR(ref);
3325 PERL_UNUSED_VAR(ix);
3326 exception=AcquireExceptionInfo();
3327 perl_exception=newSVpv("",0);
3331 if (sv_isobject(ST(0)) == 0)
3333 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3337 reference=SvRV(ST(0));
3338 hv=SvSTASH(reference);
3340 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3342 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3343 if (image == (Image *) NULL)
3345 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3349 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3353 reconstruct_image=image;
3354 metric=RootMeanSquaredErrorMetric;
3355 for (i=2; i < items; i+=2)
3357 attribute=(char *) SvPV(ST(i-1),na);
3363 if (LocaleCompare(attribute,"channel") == 0)
3368 option=ParseChannelOption(SvPV(ST(i),na));
3371 ThrowPerlException(exception,OptionError,
3372 "UnrecognizedType",SvPV(ST(i),na));
3375 (void) SetPixelChannelMask(image,(ChannelType) option);
3378 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3385 if (LocaleCompare(attribute,"fuzz") == 0)
3387 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3390 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3397 if (LocaleCompare(attribute,"image") == 0)
3399 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3400 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3403 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3410 if (LocaleCompare(attribute,"metric") == 0)
3412 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3416 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3420 metric=(MetricType) option;
3423 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3429 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3435 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3437 if (difference_image != (Image *) NULL)
3439 difference_image->error.mean_error_per_pixel=distortion;
3440 AddImageToRegistry(sv,difference_image);
3442 av_push(av,sv_bless(rv,hv));
3445 exception=DestroyExceptionInfo(exception);
3447 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3451 InheritPerlException(exception,perl_exception);
3452 exception=DestroyExceptionInfo(exception);
3453 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3454 SvPOK_on(perl_exception);
3455 ST(0)=sv_2mortal(perl_exception);
3460 ###############################################################################
3464 # C o m p l e x I m a g e s #
3468 ###############################################################################
3473 Image::Magick ref=NO_INIT
3510 PERL_UNUSED_VAR(ref);
3511 PERL_UNUSED_VAR(ix);
3512 exception=AcquireExceptionInfo();
3513 perl_exception=newSVpv("",0);
3515 if (sv_isobject(ST(0)) == 0)
3517 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3521 reference=SvRV(ST(0));
3522 hv=SvSTASH(reference);
3523 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3524 if (image == (Image *) NULL)
3526 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3530 op=UndefinedComplexOperator;
3536 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3540 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3544 op=(ComplexOperator) in;
3547 for (i=2; i < items; i+=2)
3549 attribute=(char *) SvPV(ST(i-1),na);
3555 if (LocaleCompare(attribute,"operator") == 0)
3560 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3561 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3564 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3568 op=(ComplexOperator) in;
3571 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3577 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3583 image=ComplexImages(image,op,exception);
3584 if (image == (Image *) NULL)
3587 Create blessed Perl array for the returned image.
3590 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3592 AddImageToRegistry(sv,image);
3594 av_push(av,sv_bless(rv,hv));
3596 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3597 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3598 "complex-%.*s",(int) (MagickPathExtent-9),
3599 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3600 (void) CopyMagickString(image->filename,info->image_info->filename,
3602 SetImageInfo(info->image_info,0,exception);
3603 exception=DestroyExceptionInfo(exception);
3604 SvREFCNT_dec(perl_exception);
3608 InheritPerlException(exception,perl_exception);
3609 exception=DestroyExceptionInfo(exception);
3610 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3611 SvPOK_on(perl_exception);
3612 ST(0)=sv_2mortal(perl_exception);
3617 ###############################################################################
3621 # C o m p a r e L a y e r s #
3625 ###############################################################################
3630 Image::Magick ref=NO_INIT
3632 CompareImagesLayers = 1
3634 compareimagelayers = 3
3671 PERL_UNUSED_VAR(ref);
3672 PERL_UNUSED_VAR(ix);
3673 exception=AcquireExceptionInfo();
3674 perl_exception=newSVpv("",0);
3676 if (sv_isobject(ST(0)) == 0)
3678 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3682 reference=SvRV(ST(0));
3683 hv=SvSTASH(reference);
3685 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3687 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3688 if (image == (Image *) NULL)
3690 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3694 method=CompareAnyLayer;
3695 for (i=2; i < items; i+=2)
3697 attribute=(char *) SvPV(ST(i-1),na);
3703 if (LocaleCompare(attribute,"method") == 0)
3705 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3709 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3713 method=(LayerMethod) option;
3716 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3722 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3728 image=CompareImagesLayers(image,method,exception);
3729 if (image == (Image *) NULL)
3731 for ( ; image; image=image->next)
3733 AddImageToRegistry(sv,image);
3735 av_push(av,sv_bless(rv,hv));
3738 exception=DestroyExceptionInfo(exception);
3740 SvREFCNT_dec(perl_exception);
3744 InheritPerlException(exception,perl_exception);
3745 exception=DestroyExceptionInfo(exception);
3746 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3747 SvPOK_on(perl_exception);
3748 ST(0)=sv_2mortal(perl_exception);
3753 ###############################################################################
3761 ###############################################################################
3766 Image::Magick ref=NO_INIT
3772 PERL_UNUSED_VAR(ref);
3773 if (sv_isobject(ST(0)) == 0)
3774 croak("ReferenceIsNotMyType");
3775 reference=SvRV(ST(0));
3776 switch (SvTYPE(reference))
3781 message[MagickPathExtent];
3799 Array (AV *) reference
3801 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3802 XS_VERSION,reference);
3803 hv=gv_stashpv(PackageName, FALSE);
3806 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3810 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3812 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3813 DestroyPackageInfo(info);
3815 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3825 Blessed scalar = (Image *) SvIV(reference)
3827 image=INT2PTR(Image *,SvIV(reference));
3828 if (image != (Image *) NULL)
3829 DeleteImageFromRegistry(reference,image);
3838 ###############################################################################
3846 ###############################################################################
3851 Image::Magick ref=NO_INIT
3875 PERL_UNUSED_VAR(ref);
3876 PERL_UNUSED_VAR(ix);
3877 exception=AcquireExceptionInfo();
3878 perl_exception=newSVpv("",0);
3879 package_info=(struct PackageInfo *) NULL;
3880 if (sv_isobject(ST(0)) == 0)
3882 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3886 reference=SvRV(ST(0));
3887 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3888 if (image == (Image *) NULL)
3890 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3894 package_info=ClonePackageInfo(info,exception);
3896 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3899 for (i=2; i < items; i+=2)
3900 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3902 (void) DisplayImages(package_info->image_info,image,exception);
3903 (void) CatchImageException(image);
3906 if (package_info != (struct PackageInfo *) NULL)
3907 DestroyPackageInfo(package_info);
3908 InheritPerlException(exception,perl_exception);
3909 exception=DestroyExceptionInfo(exception);
3910 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3911 SvPOK_on(perl_exception);
3912 ST(0)=sv_2mortal(perl_exception);
3917 ###############################################################################
3921 # E v a l u a t e I m a g e s #
3925 ###############################################################################
3930 Image::Magick ref=NO_INIT
3952 MagickEvaluateOperator
3967 PERL_UNUSED_VAR(ref);
3968 PERL_UNUSED_VAR(ix);
3969 exception=AcquireExceptionInfo();
3970 perl_exception=newSVpv("",0);
3972 if (sv_isobject(ST(0)) == 0)
3974 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3978 reference=SvRV(ST(0));
3979 hv=SvSTASH(reference);
3980 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3981 if (image == (Image *) NULL)
3983 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3987 op=MeanEvaluateOperator;
3993 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3997 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4001 op=(MagickEvaluateOperator) in;
4004 for (i=2; i < items; i+=2)
4006 attribute=(char *) SvPV(ST(i-1),na);
4012 if (LocaleCompare(attribute,"operator") == 0)
4017 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4018 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4021 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4025 op=(MagickEvaluateOperator) in;
4028 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4034 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4040 image=EvaluateImages(image,op,exception);
4041 if (image == (Image *) NULL)
4044 Create blessed Perl array for the returned image.
4047 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4049 AddImageToRegistry(sv,image);
4051 av_push(av,sv_bless(rv,hv));
4053 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4054 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4055 "evaluate-%.*s",(int) (MagickPathExtent-9),
4056 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4057 (void) CopyMagickString(image->filename,info->image_info->filename,
4059 SetImageInfo(info->image_info,0,exception);
4060 exception=DestroyExceptionInfo(exception);
4061 SvREFCNT_dec(perl_exception);
4065 InheritPerlException(exception,perl_exception);
4066 exception=DestroyExceptionInfo(exception);
4067 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4068 SvPOK_on(perl_exception);
4069 ST(0)=sv_2mortal(perl_exception);
4074 ###############################################################################
4082 ###############################################################################
4087 Image::Magick ref=NO_INIT
4094 #define ChannelFeatures(channel,direction) \
4096 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4097 channel_features[channel].angular_second_moment[direction]); \
4098 PUSHs(sv_2mortal(newSVpv(message,0))); \
4099 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4100 channel_features[channel].contrast[direction]); \
4101 PUSHs(sv_2mortal(newSVpv(message,0))); \
4102 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4103 channel_features[channel].contrast[direction]); \
4104 PUSHs(sv_2mortal(newSVpv(message,0))); \
4105 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4106 channel_features[channel].variance_sum_of_squares[direction]); \
4107 PUSHs(sv_2mortal(newSVpv(message,0))); \
4108 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4109 channel_features[channel].inverse_difference_moment[direction]); \
4110 PUSHs(sv_2mortal(newSVpv(message,0))); \
4111 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4112 channel_features[channel].sum_average[direction]); \
4113 PUSHs(sv_2mortal(newSVpv(message,0))); \
4114 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4115 channel_features[channel].sum_variance[direction]); \
4116 PUSHs(sv_2mortal(newSVpv(message,0))); \
4117 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4118 channel_features[channel].sum_entropy[direction]); \
4119 PUSHs(sv_2mortal(newSVpv(message,0))); \
4120 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4121 channel_features[channel].entropy[direction]); \
4122 PUSHs(sv_2mortal(newSVpv(message,0))); \
4123 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4124 channel_features[channel].difference_variance[direction]); \
4125 PUSHs(sv_2mortal(newSVpv(message,0))); \
4126 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4127 channel_features[channel].difference_entropy[direction]); \
4128 PUSHs(sv_2mortal(newSVpv(message,0))); \
4129 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4130 channel_features[channel].measure_of_correlation_1[direction]); \
4131 PUSHs(sv_2mortal(newSVpv(message,0))); \
4132 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4133 channel_features[channel].measure_of_correlation_2[direction]); \
4134 PUSHs(sv_2mortal(newSVpv(message,0))); \
4135 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
4136 channel_features[channel].maximum_correlation_coefficient[direction]); \
4137 PUSHs(sv_2mortal(newSVpv(message,0))); \
4145 message[MagickPathExtent];
4172 PERL_UNUSED_VAR(ref);
4173 PERL_UNUSED_VAR(ix);
4174 exception=AcquireExceptionInfo();
4175 perl_exception=newSVpv("",0);
4177 if (sv_isobject(ST(0)) == 0)
4179 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4183 reference=SvRV(ST(0));
4186 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4187 if (image == (Image *) NULL)
4189 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4194 for (i=2; i < items; i+=2)
4196 attribute=(char *) SvPV(ST(i-1),na);
4202 if (LocaleCompare(attribute,"distance") == 0)
4204 distance=StringToLong((char *) SvPV(ST(1),na));
4207 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4213 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4220 for ( ; image; image=image->next)
4222 channel_features=GetImageFeatures(image,distance,exception);
4223 if (channel_features == (ChannelFeatures *) NULL)
4226 EXTEND(sp,280*count);
4227 for (i=0; i < 4; i++)
4229 ChannelFeatures(RedChannel,i);
4230 ChannelFeatures(GreenChannel,i);
4231 ChannelFeatures(BlueChannel,i);
4232 if (image->colorspace == CMYKColorspace)
4233 ChannelFeatures(BlackChannel,i);
4234 if (image->alpha_trait != UndefinedPixelTrait)
4235 ChannelFeatures(AlphaChannel,i);
4237 channel_features=(ChannelFeatures *)
4238 RelinquishMagickMemory(channel_features);
4242 InheritPerlException(exception,perl_exception);
4243 exception=DestroyExceptionInfo(exception);
4244 SvREFCNT_dec(perl_exception);
4248 ###############################################################################
4256 ###############################################################################
4261 Image::Magick ref=NO_INIT
4299 PERL_UNUSED_VAR(ref);
4300 PERL_UNUSED_VAR(ix);
4301 exception=AcquireExceptionInfo();
4302 perl_exception=newSVpv("",0);
4304 if (sv_isobject(ST(0)) == 0)
4306 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4310 reference=SvRV(ST(0));
4311 hv=SvSTASH(reference);
4312 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4313 if (image == (Image *) NULL)
4315 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4319 background_color=image->background_color;
4321 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4322 &background_color,exception);
4324 for (i=2; i < items; i+=2)
4326 attribute=(char *) SvPV(ST(i-1),na);
4332 if (LocaleCompare(attribute,"background") == 0)
4334 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4335 AllCompliance,&background_color,exception);
4338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4344 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4350 image->background_color=background_color;
4351 image=MergeImageLayers(image,FlattenLayer,exception);
4352 if (image == (Image *) NULL)
4355 Create blessed Perl array for the returned image.
4358 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4360 AddImageToRegistry(sv,image);
4362 av_push(av,sv_bless(rv,hv));
4364 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4365 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4366 "flatten-%.*s",(int) (MagickPathExtent-9),
4367 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4368 (void) CopyMagickString(image->filename,info->image_info->filename,
4370 SetImageInfo(info->image_info,0,exception);
4371 exception=DestroyExceptionInfo(exception);
4372 SvREFCNT_dec(perl_exception);
4376 InheritPerlException(exception,perl_exception);
4377 exception=DestroyExceptionInfo(exception);
4378 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4379 SvPOK_on(perl_exception); /* return messages in string context */
4380 ST(0)=sv_2mortal(perl_exception);
4385 ###############################################################################
4393 ###############################################################################
4398 Image::Magick ref=NO_INIT
4410 expression[MagickPathExtent];
4438 PERL_UNUSED_VAR(ref);
4439 PERL_UNUSED_VAR(ix);
4440 exception=AcquireExceptionInfo();
4441 perl_exception=newSVpv("",0);
4445 if (sv_isobject(ST(0)) == 0)
4447 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4451 reference=SvRV(ST(0));
4452 hv=SvSTASH(reference);
4454 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4456 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4457 if (image == (Image *) NULL)
4459 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4463 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4467 channel=DefaultChannels;
4468 (void) CopyMagickString(expression,"u",MagickPathExtent);
4470 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
4472 for (i=2; i < items; i+=2)
4474 attribute=(char *) SvPV(ST(i-1),na);
4480 if (LocaleCompare(attribute,"channel") == 0)
4485 option=ParseChannelOption(SvPV(ST(i),na));
4488 ThrowPerlException(exception,OptionError,
4489 "UnrecognizedType",SvPV(ST(i),na));
4492 channel=(ChannelType) option;
4495 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4502 if (LocaleCompare(attribute,"expression") == 0)
4504 (void) CopyMagickString(expression,SvPV(ST(i),na),
4508 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4514 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4520 channel_mask=SetImageChannelMask(image,channel);
4521 image=FxImage(image,expression,exception);
4522 if (image != (Image *) NULL)
4523 (void) SetImageChannelMask(image,channel_mask);
4524 if (image == (Image *) NULL)
4526 for ( ; image; image=image->next)
4528 AddImageToRegistry(sv,image);
4530 av_push(av,sv_bless(rv,hv));
4533 exception=DestroyExceptionInfo(exception);
4535 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4539 InheritPerlException(exception,perl_exception);
4540 exception=DestroyExceptionInfo(exception);
4541 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4542 SvPOK_on(perl_exception);
4543 ST(0)=sv_2mortal(perl_exception);
4548 ###############################################################################
4556 ###############################################################################
4561 Image::Magick ref=NO_INIT
4572 color[MagickPathExtent];
4597 PERL_UNUSED_VAR(ref);
4598 PERL_UNUSED_VAR(ix);
4599 exception=AcquireExceptionInfo();
4600 perl_exception=newSVpv("",0);
4601 if (sv_isobject(ST(0)) == 0)
4603 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4607 reference=SvRV(ST(0));
4608 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4609 if (image == (Image *) NULL && !info)
4612 for (i=1; i < items; i++)
4614 attribute=(char *) SvPV(ST(i),na);
4621 if (LocaleCompare(attribute,"adjoin") == 0)
4624 s=newSViv((ssize_t) info->image_info->adjoin);
4625 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4628 if (LocaleCompare(attribute,"antialias") == 0)
4631 s=newSViv((ssize_t) info->image_info->antialias);
4632 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4635 if (LocaleCompare(attribute,"area") == 0)
4637 s=newSViv(GetMagickResource(AreaResource));
4638 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4641 if (LocaleCompare(attribute,"attenuate") == 0)
4646 value=GetImageProperty(image,attribute,exception);
4647 if (value != (const char *) NULL)
4649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4652 if (LocaleCompare(attribute,"authenticate") == 0)
4659 option=GetImageOption(info->image_info,attribute);
4660 if (option != (const char *) NULL)
4661 s=newSVpv(option,0);
4663 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4666 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4673 if (LocaleCompare(attribute,"background") == 0)
4675 if (image == (Image *) NULL)
4677 (void) FormatLocaleString(color,MagickPathExtent,
4678 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4679 (double) image->background_color.green,
4680 (double) image->background_color.blue,
4681 (double) image->background_color.alpha);
4683 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4686 if (LocaleCompare(attribute,"base-columns") == 0)
4688 if (image != (Image *) NULL)
4689 s=newSViv((ssize_t) image->magick_columns);
4690 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4693 if (LocaleCompare(attribute,"base-filename") == 0)
4695 if (image != (Image *) NULL)
4696 s=newSVpv(image->magick_filename,0);
4697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4700 if (LocaleCompare(attribute,"base-height") == 0)
4702 if (image != (Image *) NULL)
4703 s=newSViv((ssize_t) image->magick_rows);
4704 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4707 if (LocaleCompare(attribute,"base-rows") == 0)
4709 if (image != (Image *) NULL)
4710 s=newSViv((ssize_t) image->magick_rows);
4711 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4714 if (LocaleCompare(attribute,"base-width") == 0)
4716 if (image != (Image *) NULL)
4717 s=newSViv((ssize_t) image->magick_columns);
4718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4721 if (LocaleCompare(attribute,"blue-primary") == 0)
4723 if (image == (Image *) NULL)
4725 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
4726 image->chromaticity.blue_primary.x,
4727 image->chromaticity.blue_primary.y);
4729 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4732 if (LocaleCompare(attribute,"bordercolor") == 0)
4734 if (image == (Image *) NULL)
4736 (void) FormatLocaleString(color,MagickPathExtent,
4737 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4738 (double) image->border_color.green,
4739 (double) image->border_color.blue,
4740 (double) image->border_color.alpha);
4742 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4745 if (LocaleCompare(attribute,"bounding-box") == 0)
4748 geometry[MagickPathExtent];
4753 if (image == (Image *) NULL)
4755 page=GetImageBoundingBox(image,exception);
4756 (void) FormatLocaleString(geometry,MagickPathExtent,
4757 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4758 page.height,(double) page.x,(double) page.y);
4759 s=newSVpv(geometry,0);
4760 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4763 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4770 if (LocaleCompare(attribute,"class") == 0)
4772 if (image == (Image *) NULL)
4774 s=newSViv(image->storage_class);
4775 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4776 image->storage_class));
4778 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4781 if (LocaleCompare(attribute,"clip-mask") == 0)
4783 if (image != (Image *) NULL)
4792 if (image->read_mask == MagickFalse)
4793 ClipImage(image,exception);
4794 mask_image=GetImageMask(image,exception);
4795 if (mask_image != (Image *) NULL)
4797 AddImageToRegistry(sv,mask_image);
4798 s=sv_bless(newRV(sv),SvSTASH(reference));
4801 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4804 if (LocaleCompare(attribute,"clip-path") == 0)
4806 if (image != (Image *) NULL)
4815 if (image->read_mask != MagickFalse)
4816 ClipImage(image,exception);
4817 mask_image=GetImageMask(image,exception);
4818 if (mask_image != (Image *) NULL)
4820 AddImageToRegistry(sv,mask_image);
4821 s=sv_bless(newRV(sv),SvSTASH(reference));
4824 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4827 if (LocaleCompare(attribute,"compression") == 0)
4829 j=info ? info->image_info->compression : image ?
4830 image->compression : UndefinedCompression;
4832 if (info->image_info->compression == UndefinedCompression)
4833 j=image->compression;
4835 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4838 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4841 if (LocaleCompare(attribute,"colorspace") == 0)
4843 j=image ? image->colorspace : RGBColorspace;
4845 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4848 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4851 if (LocaleCompare(attribute,"colors") == 0)
4853 if (image != (Image *) NULL)
4854 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4856 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4859 if (LocaleNCompare(attribute,"colormap",8) == 0)
4864 if (image == (Image *) NULL || !image->colormap)
4867 items=sscanf(attribute,"%*[^[][%ld",&j);
4869 if (j > (ssize_t) image->colors)
4871 (void) FormatLocaleString(color,MagickPathExtent,
4872 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4873 (double) image->colormap[j].green,
4874 (double) image->colormap[j].blue,
4875 (double) image->colormap[j].alpha);
4877 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4880 if (LocaleCompare(attribute,"columns") == 0)
4882 if (image != (Image *) NULL)
4883 s=newSViv((ssize_t) image->columns);
4884 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4887 if (LocaleCompare(attribute,"comment") == 0)
4892 value=GetImageProperty(image,attribute,exception);
4893 if (value != (const char *) NULL)
4895 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4898 if (LocaleCompare(attribute,"copyright") == 0)
4900 s=newSVpv(GetMagickCopyright(),0);
4901 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4904 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4911 if (LocaleCompare(attribute,"density") == 0)
4914 geometry[MagickPathExtent];
4916 if (image == (Image *) NULL)
4918 (void) FormatLocaleString(geometry,MagickPathExtent,"%.15gx%.15g",
4919 image->resolution.x,image->resolution.y);
4920 s=newSVpv(geometry,0);
4921 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4924 if (LocaleCompare(attribute,"delay") == 0)
4926 if (image != (Image *) NULL)
4927 s=newSViv((ssize_t) image->delay);
4928 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4931 if (LocaleCompare(attribute,"depth") == 0)
4933 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4934 if (image != (Image *) NULL)
4935 s=newSViv((ssize_t) GetImageDepth(image,exception));
4936 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4939 if (LocaleCompare(attribute,"directory") == 0)
4941 if (image && image->directory)
4942 s=newSVpv(image->directory,0);
4943 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4946 if (LocaleCompare(attribute,"dispose") == 0)
4948 if (image == (Image *) NULL)
4951 s=newSViv(image->dispose);
4953 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4955 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4958 if (LocaleCompare(attribute,"disk") == 0)
4960 s=newSViv(GetMagickResource(DiskResource));
4961 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4964 if (LocaleCompare(attribute,"dither") == 0)
4967 s=newSViv((ssize_t) info->image_info->dither);
4968 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4971 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4973 if (info && info->image_info->server_name)
4974 s=newSVpv(info->image_info->server_name,0);
4975 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4978 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4985 if (LocaleCompare(attribute,"elapsed-time") == 0)
4987 if (image != (Image *) NULL)
4988 s=newSVnv(GetElapsedTime(&image->timer));
4989 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4992 if (LocaleCompare(attribute,"endian") == 0)
4994 j=info ? info->image_info->endian : image ? image->endian :
4997 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4999 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5002 if (LocaleCompare(attribute,"error") == 0)
5004 if (image != (Image *) NULL)
5005 s=newSVnv(image->error.mean_error_per_pixel);
5006 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5009 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5016 if (LocaleCompare(attribute,"filesize") == 0)
5018 if (image != (Image *) NULL)
5019 s=newSViv((ssize_t) GetBlobSize(image));
5020 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5023 if (LocaleCompare(attribute,"filename") == 0)
5025 if (info && info->image_info->filename &&
5026 *info->image_info->filename)
5027 s=newSVpv(info->image_info->filename,0);
5028 if (image != (Image *) NULL)
5029 s=newSVpv(image->filename,0);
5030 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5033 if (LocaleCompare(attribute,"filter") == 0)
5035 s=image ? newSViv(image->filter) : newSViv(0);
5036 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5039 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5042 if (LocaleCompare(attribute,"font") == 0)
5044 if (info && info->image_info->font)
5045 s=newSVpv(info->image_info->font,0);
5046 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5049 if (LocaleCompare(attribute,"foreground") == 0)
5051 if (LocaleCompare(attribute,"format") == 0)
5056 magick_info=(const MagickInfo *) NULL;
5057 if (info && (*info->image_info->magick != '\0'))
5058 magick_info=GetMagickInfo(info->image_info->magick,exception);
5059 if (image != (Image *) NULL)
5060 magick_info=GetMagickInfo(image->magick,exception);
5061 if ((magick_info != (const MagickInfo *) NULL) &&
5062 (*magick_info->description != '\0'))
5063 s=newSVpv((char *) magick_info->description,0);
5064 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5067 if (LocaleCompare(attribute,"fuzz") == 0)
5070 s=newSVnv(info->image_info->fuzz);
5071 if (image != (Image *) NULL)
5072 s=newSVnv(image->fuzz);
5073 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5076 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5083 if (LocaleCompare(attribute,"gamma") == 0)
5085 if (image != (Image *) NULL)
5086 s=newSVnv(image->gamma);
5087 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5090 if (LocaleCompare(attribute,"geometry") == 0)
5092 if (image && image->geometry)
5093 s=newSVpv(image->geometry,0);
5094 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5097 if (LocaleCompare(attribute,"gravity") == 0)
5099 s=image ? newSViv(image->gravity) : newSViv(0);
5100 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5103 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5106 if (LocaleCompare(attribute,"green-primary") == 0)
5108 if (image == (Image *) NULL)
5110 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5111 image->chromaticity.green_primary.x,
5112 image->chromaticity.green_primary.y);
5114 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5117 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5124 if (LocaleCompare(attribute,"height") == 0)
5126 if (image != (Image *) NULL)
5127 s=newSViv((ssize_t) image->rows);
5128 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5131 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5138 if (LocaleCompare(attribute,"icc") == 0)
5140 if (image != (Image *) NULL)
5145 profile=GetImageProfile(image,"icc");
5146 if (profile != (StringInfo *) NULL)
5147 s=newSVpv((const char *) GetStringInfoDatum(profile),
5148 GetStringInfoLength(profile));
5150 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5153 if (LocaleCompare(attribute,"icm") == 0)
5155 if (image != (Image *) NULL)
5160 profile=GetImageProfile(image,"icm");
5161 if (profile != (const StringInfo *) NULL)
5162 s=newSVpv((const char *) GetStringInfoDatum(profile),
5163 GetStringInfoLength(profile));
5165 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5168 if (LocaleCompare(attribute,"id") == 0)
5170 if (image != (Image *) NULL)
5173 key[MagickPathExtent];
5181 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5183 status=SetImageRegistry(ImageRegistryType,key,image,
5188 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5191 if (LocaleNCompare(attribute,"index",5) == 0)
5194 name[MagickPathExtent];
5203 register const Quantum
5209 if (image == (Image *) NULL)
5211 if (image->storage_class != PseudoClass)
5215 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5217 image_view=AcquireVirtualCacheView(image,exception);
5218 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5219 if (p != (const Quantum *) NULL)
5221 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5222 GetPixelIndex(image,p));
5224 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5226 image_view=DestroyCacheView(image_view);
5229 if (LocaleCompare(attribute,"iptc") == 0)
5231 if (image != (Image *) NULL)
5236 profile=GetImageProfile(image,"iptc");
5237 if (profile != (const StringInfo *) NULL)
5238 s=newSVpv((const char *) GetStringInfoDatum(profile),
5239 GetStringInfoLength(profile));
5241 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5244 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5246 if (image != (Image *) NULL)
5247 s=newSViv((ssize_t) image->iterations);
5248 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5251 if (LocaleCompare(attribute,"interlace") == 0)
5253 j=info ? info->image_info->interlace : image ? image->interlace :
5256 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5259 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5262 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5269 if (LocaleCompare(attribute,"label") == 0)
5274 if (image == (Image *) NULL)
5276 value=GetImageProperty(image,"Label",exception);
5277 if (value != (const char *) NULL)
5279 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5282 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5284 if (image != (Image *) NULL)
5285 s=newSViv((ssize_t) image->iterations);
5286 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5289 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5296 if (LocaleCompare(attribute,"magick") == 0)
5298 if (info && *info->image_info->magick)
5299 s=newSVpv(info->image_info->magick,0);
5300 if (image != (Image *) NULL)
5301 s=newSVpv(image->magick,0);
5302 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5305 if (LocaleCompare(attribute,"map") == 0)
5307 s=newSViv(GetMagickResource(MapResource));
5308 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5311 if (LocaleCompare(attribute,"maximum-error") == 0)
5313 if (image != (Image *) NULL)
5314 s=newSVnv(image->error.normalized_maximum_error);
5315 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5318 if (LocaleCompare(attribute,"memory") == 0)
5320 s=newSViv(GetMagickResource(MemoryResource));
5321 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5324 if (LocaleCompare(attribute,"mean-error") == 0)
5326 if (image != (Image *) NULL)
5327 s=newSVnv(image->error.normalized_mean_error);
5328 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5331 if (LocaleCompare(attribute,"mime") == 0)
5333 if (info && *info->image_info->magick)
5334 s=newSVpv(MagickToMime(info->image_info->magick),0);
5335 if (image != (Image *) NULL)
5336 s=newSVpv(MagickToMime(image->magick),0);
5337 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5340 if (LocaleCompare(attribute,"mattecolor") == 0)
5342 if (image == (Image *) NULL)
5344 (void) FormatLocaleString(color,MagickPathExtent,
5345 "%.20g,%.20g,%.20g,%.20g",(double) image->matte_color.red,
5346 (double) image->matte_color.green,
5347 (double) image->matte_color.blue,
5348 (double) image->matte_color.alpha);
5350 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5353 if (LocaleCompare(attribute,"matte") == 0)
5355 if (image != (Image *) NULL)
5356 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5358 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5361 if (LocaleCompare(attribute,"mime") == 0)
5367 if (info && *info->image_info->magick)
5368 magick=info->image_info->magick;
5369 if (image != (Image *) NULL)
5370 magick=image->magick;
5376 mime=MagickToMime(magick);
5378 mime=(char *) RelinquishMagickMemory(mime);
5380 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5383 if (LocaleCompare(attribute,"monochrome") == 0)
5385 if (image == (Image *) NULL)
5387 j=info ? info->image_info->monochrome :
5388 SetImageMonochrome(image,exception);
5390 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5393 if (LocaleCompare(attribute,"montage") == 0)
5395 if (image && image->montage)
5396 s=newSVpv(image->montage,0);
5397 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5407 if (LocaleCompare(attribute,"orientation") == 0)
5409 j=info ? info->image_info->orientation : image ?
5410 image->orientation : UndefinedOrientation;
5412 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5415 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5418 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5425 if (LocaleCompare(attribute,"page") == 0)
5427 if (info && info->image_info->page)
5428 s=newSVpv(info->image_info->page,0);
5429 if (image != (Image *) NULL)
5432 geometry[MagickPathExtent];
5434 (void) FormatLocaleString(geometry,MagickPathExtent,
5435 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5436 (double) image->page.height,(double) image->page.x,(double)
5438 s=newSVpv(geometry,0);
5440 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5443 if (LocaleCompare(attribute,"page.x") == 0)
5445 if (image != (Image *) NULL)
5446 s=newSViv((ssize_t) image->page.x);
5447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5450 if (LocaleCompare(attribute,"page.y") == 0)
5452 if (image != (Image *) NULL)
5453 s=newSViv((ssize_t) image->page.y);
5454 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5457 if (LocaleNCompare(attribute,"pixel",5) == 0)
5460 tuple[MagickPathExtent];
5469 register const Quantum
5472 if (image == (Image *) NULL)
5476 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5478 p=GetVirtualPixels(image,x,y,1,1,exception);
5479 if (image->colorspace != CMYKColorspace)
5480 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5481 QuantumFormat "," QuantumFormat "," QuantumFormat,
5482 GetPixelRed(image,p),GetPixelGreen(image,p),
5483 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5485 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5486 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5487 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5488 GetPixelBlue(image,p),GetPixelBlack(image,p),
5489 GetPixelAlpha(image,p));
5491 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5494 if (LocaleCompare(attribute,"pointsize") == 0)
5497 s=newSViv((ssize_t) info->image_info->pointsize);
5498 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5501 if (LocaleCompare(attribute,"preview") == 0)
5503 s=newSViv(info->image_info->preview_type);
5504 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5505 info->image_info->preview_type));
5507 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5510 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5517 if (LocaleCompare(attribute,"quality") == 0)
5520 s=newSViv((ssize_t) info->image_info->quality);
5521 if (image != (Image *) NULL)
5522 s=newSViv((ssize_t) image->quality);
5523 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5526 if (LocaleCompare(attribute,"quantum") == 0)
5529 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5530 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5533 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5540 if (LocaleCompare(attribute,"rendering-intent") == 0)
5542 s=newSViv(image->rendering_intent);
5543 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5544 image->rendering_intent));
5546 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5549 if (LocaleCompare(attribute,"red-primary") == 0)
5551 if (image == (Image *) NULL)
5553 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5554 image->chromaticity.red_primary.x,
5555 image->chromaticity.red_primary.y);
5557 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5560 if (LocaleCompare(attribute,"rows") == 0)
5562 if (image != (Image *) NULL)
5563 s=newSViv((ssize_t) image->rows);
5564 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5567 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5574 if (LocaleCompare(attribute,"sampling-factor") == 0)
5576 if (info && info->image_info->sampling_factor)
5577 s=newSVpv(info->image_info->sampling_factor,0);
5578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5581 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5583 if (info && info->image_info->server_name)
5584 s=newSVpv(info->image_info->server_name,0);
5585 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5588 if (LocaleCompare(attribute,"size") == 0)
5590 if (info && info->image_info->size)
5591 s=newSVpv(info->image_info->size,0);
5592 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5595 if (LocaleCompare(attribute,"scene") == 0)
5597 if (image != (Image *) NULL)
5598 s=newSViv((ssize_t) image->scene);
5599 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5602 if (LocaleCompare(attribute,"scenes") == 0)
5604 if (image != (Image *) NULL)
5605 s=newSViv((ssize_t) info->image_info->number_scenes);
5606 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5609 if (LocaleCompare(attribute,"signature") == 0)
5614 if (image == (Image *) NULL)
5616 (void) SignatureImage(image,exception);
5617 value=GetImageProperty(image,"Signature",exception);
5618 if (value != (const char *) NULL)
5620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5623 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5630 if (LocaleCompare(attribute,"taint") == 0)
5632 if (image != (Image *) NULL)
5633 s=newSViv((ssize_t) IsTaintImage(image));
5634 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5637 if (LocaleCompare(attribute,"texture") == 0)
5639 if (info && info->image_info->texture)
5640 s=newSVpv(info->image_info->texture,0);
5641 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5644 if (LocaleCompare(attribute,"total-ink-density") == 0)
5646 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5647 if (image != (Image *) NULL)
5648 s=newSVnv(GetImageTotalInkDensity(image,exception));
5649 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5652 if (LocaleCompare(attribute,"transparent-color") == 0)
5654 if (image == (Image *) NULL)
5656 (void) FormatLocaleString(color,MagickPathExtent,
5657 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5658 (double) image->transparent_color.green,
5659 (double) image->transparent_color.blue,
5660 (double) image->transparent_color.alpha);
5662 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5665 if (LocaleCompare(attribute,"type") == 0)
5667 if (image == (Image *) NULL)
5669 j=(ssize_t) GetImageType(image);
5671 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5673 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5676 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5683 if (LocaleCompare(attribute,"units") == 0)
5685 j=info ? info->image_info->units : image ? image->units :
5686 UndefinedResolution;
5687 if (info && (info->image_info->units == UndefinedResolution))
5690 if (j == UndefinedResolution)
5691 s=newSVpv("undefined units",0);
5693 if (j == PixelsPerInchResolution)
5694 s=newSVpv("pixels / inch",0);
5696 s=newSVpv("pixels / centimeter",0);
5697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5700 if (LocaleCompare(attribute,"user-time") == 0)
5702 if (image != (Image *) NULL)
5703 s=newSVnv(GetUserTime(&image->timer));
5704 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5707 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5714 if (LocaleCompare(attribute,"verbose") == 0)
5717 s=newSViv((ssize_t) info->image_info->verbose);
5718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5721 if (LocaleCompare(attribute,"version") == 0)
5723 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5724 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5727 if (LocaleCompare(attribute,"view") == 0)
5729 if (info && info->image_info->view)
5730 s=newSVpv(info->image_info->view,0);
5731 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5734 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5736 if (image == (Image *) NULL)
5738 j=(ssize_t) GetImageVirtualPixelMethod(image);
5740 (void) sv_setpv(s,CommandOptionToMnemonic(
5741 MagickVirtualPixelOptions,j));
5743 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5746 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5753 if (LocaleCompare(attribute,"white-point") == 0)
5755 if (image == (Image *) NULL)
5757 (void) FormatLocaleString(color,MagickPathExtent,"%.15g,%.15g",
5758 image->chromaticity.white_point.x,
5759 image->chromaticity.white_point.y);
5761 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5764 if (LocaleCompare(attribute,"width") == 0)
5766 if (image != (Image *) NULL)
5767 s=newSViv((ssize_t) image->columns);
5768 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5771 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5778 if (LocaleCompare(attribute,"x-resolution") == 0)
5780 if (image != (Image *) NULL)
5781 s=newSVnv(image->resolution.x);
5782 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5785 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5792 if (LocaleCompare(attribute,"y-resolution") == 0)
5794 if (image != (Image *) NULL)
5795 s=newSVnv(image->resolution.y);
5796 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5799 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5806 if (image == (Image *) NULL)
5807 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5811 value=GetImageProperty(image,attribute,exception);
5812 if (value != (const char *) NULL)
5815 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5818 if (*attribute != '%')
5819 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5826 meta=InterpretImageProperties(info ? info->image_info :
5827 (ImageInfo *) NULL,image,attribute,exception);
5829 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5830 meta=(char *) RelinquishMagickMemory(meta);
5834 exception=DestroyExceptionInfo(exception);
5835 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5839 ###############################################################################
5843 # G e t A u t h e n t i c P i x e l s #
5847 ###############################################################################
5851 GetAuthenticPixels(ref,...)
5852 Image::Magick ref = NO_INIT
5854 getauthenticpixels = 1
5884 PERL_UNUSED_VAR(ref);
5885 PERL_UNUSED_VAR(ix);
5886 exception=AcquireExceptionInfo();
5887 perl_exception=newSVpv("",0);
5888 if (sv_isobject(ST(0)) == 0)
5890 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5894 reference=SvRV(ST(0));
5896 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5897 if (image == (Image *) NULL)
5899 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5906 region.width=image->columns;
5909 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5910 for (i=2; i < items; i+=2)
5912 attribute=(char *) SvPV(ST(i-1),na);
5918 if (LocaleCompare(attribute,"geometry") == 0)
5920 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5923 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5930 if (LocaleCompare(attribute,"height") == 0)
5932 region.height=SvIV(ST(i));
5935 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5942 if (LocaleCompare(attribute,"x") == 0)
5944 region.x=SvIV(ST(i));
5947 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5954 if (LocaleCompare(attribute,"y") == 0)
5956 region.y=SvIV(ST(i));
5959 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5966 if (LocaleCompare(attribute,"width") == 0)
5968 region.width=SvIV(ST(i));
5971 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5977 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5978 region.height,exception);
5979 if (blob != (void *) NULL)
5983 InheritPerlException(exception,perl_exception);
5984 exception=DestroyExceptionInfo(exception);
5985 SvREFCNT_dec(perl_exception); /* throw away all errors */
5994 ###############################################################################
5998 # G e t V i r t u a l P i x e l s #
6002 ###############################################################################
6006 GetVirtualPixels(ref,...)
6007 Image::Magick ref = NO_INIT
6009 getvirtualpixels = 1
6010 AcquireImagePixels = 2
6011 acquireimagepixels = 3
6039 PERL_UNUSED_VAR(ref);
6040 PERL_UNUSED_VAR(ix);
6041 exception=AcquireExceptionInfo();
6042 perl_exception=newSVpv("",0);
6043 if (sv_isobject(ST(0)) == 0)
6045 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6049 reference=SvRV(ST(0));
6051 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6052 if (image == (Image *) NULL)
6054 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6061 region.width=image->columns;
6064 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6065 for (i=2; i < items; i+=2)
6067 attribute=(char *) SvPV(ST(i-1),na);
6073 if (LocaleCompare(attribute,"geometry") == 0)
6075 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6078 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6085 if (LocaleCompare(attribute,"height") == 0)
6087 region.height=SvIV(ST(i));
6090 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6097 if (LocaleCompare(attribute,"x") == 0)
6099 region.x=SvIV(ST(i));
6102 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6109 if (LocaleCompare(attribute,"y") == 0)
6111 region.y=SvIV(ST(i));
6114 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6121 if (LocaleCompare(attribute,"width") == 0)
6123 region.width=SvIV(ST(i));
6126 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6132 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6133 region.height,exception);
6134 if (blob != (void *) NULL)
6138 InheritPerlException(exception,perl_exception);
6139 exception=DestroyExceptionInfo(exception);
6140 SvREFCNT_dec(perl_exception); /* throw away all errors */
6143 RETVAL = (void *) blob;
6149 ###############################################################################
6153 # G e t A u t h e n t i c M e t a c o n t e n t #
6157 ###############################################################################
6161 GetAuthenticMetacontent(ref,...)
6162 Image::Magick ref = NO_INIT
6164 getauthenticmetacontent = 1
6185 PERL_UNUSED_VAR(ref);
6186 PERL_UNUSED_VAR(ix);
6187 exception=AcquireExceptionInfo();
6188 perl_exception=newSVpv("",0);
6189 if (sv_isobject(ST(0)) == 0)
6191 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6195 reference=SvRV(ST(0));
6197 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6198 if (image == (Image *) NULL)
6200 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6205 blob=(void *) GetAuthenticMetacontent(image);
6206 if (blob != (void *) NULL)
6210 InheritPerlException(exception,perl_exception);
6211 exception=DestroyExceptionInfo(exception);
6212 SvREFCNT_dec(perl_exception); /* throw away all errors */
6221 ###############################################################################
6225 # G e t V i r t u a l M e t a c o n t e n t #
6229 ###############################################################################
6233 GetVirtualMetacontent(ref,...)
6234 Image::Magick ref = NO_INIT
6236 getvirtualmetacontent = 1
6255 PERL_UNUSED_VAR(ref);
6256 PERL_UNUSED_VAR(ix);
6257 exception=AcquireExceptionInfo();
6258 perl_exception=newSVpv("",0);
6259 if (sv_isobject(ST(0)) == 0)
6261 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6265 reference=SvRV(ST(0));
6267 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6268 if (image == (Image *) NULL)
6270 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6275 blob=(void *) GetVirtualMetacontent(image);
6276 if (blob != (void *) NULL)
6280 InheritPerlException(exception,perl_exception);
6281 exception=DestroyExceptionInfo(exception);
6282 SvREFCNT_dec(perl_exception); /* throw away all errors */
6291 ###############################################################################
6295 # H i s t o g r a m #
6299 ###############################################################################
6304 Image::Magick ref=NO_INIT
6315 message[MagickPathExtent];
6342 PERL_UNUSED_VAR(ref);
6343 PERL_UNUSED_VAR(ix);
6344 exception=AcquireExceptionInfo();
6345 perl_exception=newSVpv("",0);
6347 if (sv_isobject(ST(0)) == 0)
6349 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6353 reference=SvRV(ST(0));
6356 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6357 if (image == (Image *) NULL)
6359 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6364 for ( ; image; image=image->next)
6366 histogram=GetImageHistogram(image,&number_colors,exception);
6367 if (histogram == (PixelInfo *) NULL)
6369 count+=(ssize_t) number_colors;
6371 for (i=0; i < (ssize_t) number_colors; i++)
6373 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6375 PUSHs(sv_2mortal(newSVpv(message,0)));
6376 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6377 histogram[i].green);
6378 PUSHs(sv_2mortal(newSVpv(message,0)));
6379 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6381 PUSHs(sv_2mortal(newSVpv(message,0)));
6382 if (image->colorspace == CMYKColorspace)
6384 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6385 histogram[i].black);
6386 PUSHs(sv_2mortal(newSVpv(message,0)));
6388 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6389 histogram[i].alpha);
6390 PUSHs(sv_2mortal(newSVpv(message,0)));
6391 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6392 histogram[i].count);
6393 PUSHs(sv_2mortal(newSVpv(message,0)));
6395 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6399 InheritPerlException(exception,perl_exception);
6400 exception=DestroyExceptionInfo(exception);
6401 SvREFCNT_dec(perl_exception);
6405 ###############################################################################
6413 ###############################################################################
6418 Image::Magick ref=NO_INIT
6442 register const Quantum
6456 *reference; /* reference is the SV* of ref=SvIV(reference) */
6458 PERL_UNUSED_VAR(ref);
6459 PERL_UNUSED_VAR(ix);
6460 exception=AcquireExceptionInfo();
6461 perl_exception=newSVpv("",0);
6462 reference=SvRV(ST(0));
6463 av=(AV *) reference;
6464 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6466 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6467 if (image == (Image *) NULL)
6469 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6473 normalize=MagickTrue;
6476 region.width=image->columns;
6479 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6480 for (i=2; i < items; i+=2)
6482 attribute=(char *) SvPV(ST(i-1),na);
6488 if (LocaleCompare(attribute,"channel") == 0)
6493 option=ParseChannelOption(SvPV(ST(i),na));
6496 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6500 (void) SetPixelChannelMask(image,(ChannelType) option);
6503 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6510 if (LocaleCompare(attribute,"geometry") == 0)
6512 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6515 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6522 if (LocaleCompare(attribute,"normalize") == 0)
6524 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6528 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6532 normalize=option != 0 ? MagickTrue : MagickFalse;
6535 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6542 if (LocaleCompare(attribute,"x") == 0)
6544 region.x=SvIV(ST(i));
6547 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6554 if (LocaleCompare(attribute,"y") == 0)
6556 region.y=SvIV(ST(i));
6559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6565 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6571 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6572 if (p == (const Quantum *) NULL)
6580 if (normalize != MagickFalse)
6581 scale=1.0/QuantumRange;
6582 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6583 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6584 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6585 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6586 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6587 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6588 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6589 (image->colorspace == CMYKColorspace))
6590 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6591 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6592 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6596 InheritPerlException(exception,perl_exception);
6597 exception=DestroyExceptionInfo(exception);
6598 SvREFCNT_dec(perl_exception);
6602 ###############################################################################
6606 # G e t P i x e l s #
6610 ###############################################################################
6615 Image::Magick ref=NO_INIT
6654 *reference; /* reference is the SV* of ref=SvIV(reference) */
6656 PERL_UNUSED_VAR(ref);
6657 PERL_UNUSED_VAR(ix);
6658 exception=AcquireExceptionInfo();
6659 perl_exception=newSVpv("",0);
6660 reference=SvRV(ST(0));
6661 av=(AV *) reference;
6662 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6664 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6665 if (image == (Image *) NULL)
6667 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6672 if (image->alpha_trait != UndefinedPixelTrait)
6674 if (image->colorspace == CMYKColorspace)
6677 if (image->alpha_trait != UndefinedPixelTrait)
6680 normalize=MagickFalse;
6683 region.width=image->columns;
6686 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6687 for (i=2; i < items; i+=2)
6689 attribute=(char *) SvPV(ST(i-1),na);
6695 if (LocaleCompare(attribute,"geometry") == 0)
6697 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6707 if (LocaleCompare(attribute,"height") == 0)
6709 region.height=SvIV(ST(i));
6712 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6719 if (LocaleCompare(attribute,"map") == 0)
6724 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6731 if (LocaleCompare(attribute,"normalize") == 0)
6733 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6737 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6741 normalize=option != 0 ? MagickTrue : MagickFalse;
6744 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6751 if (LocaleCompare(attribute,"width") == 0)
6753 region.width=SvIV(ST(i));
6756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6763 if (LocaleCompare(attribute,"x") == 0)
6765 region.x=SvIV(ST(i));
6768 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6775 if (LocaleCompare(attribute,"y") == 0)
6777 region.y=SvIV(ST(i));
6780 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6786 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6792 if (normalize != MagickFalse)
6797 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6798 region.height*sizeof(*pixels));
6799 if (pixels == (float *) NULL)
6801 ThrowPerlException(exception,ResourceLimitError,
6802 "MemoryAllocationFailed",PackageName);
6805 status=ExportImagePixels(image,region.x,region.y,region.width,
6806 region.height,map,FloatPixel,pixels,exception);
6807 if (status == MagickFalse)
6811 EXTEND(sp,strlen(map)*region.width*region.height);
6812 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6813 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6815 pixels=(float *) RelinquishMagickMemory(pixels);
6822 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6823 region.height*sizeof(*pixels));
6824 if (pixels == (Quantum *) NULL)
6826 ThrowPerlException(exception,ResourceLimitError,
6827 "MemoryAllocationFailed",PackageName);
6830 status=ExportImagePixels(image,region.x,region.y,region.width,
6831 region.height,map,QuantumPixel,pixels,exception);
6832 if (status == MagickFalse)
6836 EXTEND(sp,strlen(map)*region.width*region.height);
6837 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6838 PUSHs(sv_2mortal(newSViv(pixels[i])));
6840 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6844 InheritPerlException(exception,perl_exception);
6845 exception=DestroyExceptionInfo(exception);
6846 SvREFCNT_dec(perl_exception);
6850 ###############################################################################
6854 # I m a g e T o B l o b #
6858 ###############################################################################
6862 ImageToBlob(ref,...)
6863 Image::Magick ref=NO_INIT
6872 filename[MagickPathExtent];
6901 PERL_UNUSED_VAR(ref);
6902 PERL_UNUSED_VAR(ix);
6903 exception=AcquireExceptionInfo();
6904 perl_exception=newSVpv("",0);
6905 package_info=(struct PackageInfo *) NULL;
6906 if (sv_isobject(ST(0)) == 0)
6908 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6912 reference=SvRV(ST(0));
6913 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6914 if (image == (Image *) NULL)
6916 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6920 package_info=ClonePackageInfo(info,exception);
6921 for (i=2; i < items; i+=2)
6922 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6923 (void) CopyMagickString(filename,package_info->image_info->filename,
6926 for (next=image; next; next=next->next)
6928 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6929 next->scene=scene++;
6931 SetImageInfo(package_info->image_info,(unsigned int)
6932 GetImageListLength(image),exception);
6933 EXTEND(sp,(ssize_t) GetImageListLength(image));
6934 for ( ; image; image=image->next)
6937 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6938 if (blob != (char *) NULL)
6940 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6941 blob=(unsigned char *) RelinquishMagickMemory(blob);
6943 if (package_info->image_info->adjoin)
6948 if (package_info != (struct PackageInfo *) NULL)
6949 DestroyPackageInfo(package_info);
6950 InheritPerlException(exception,perl_exception);
6951 exception=DestroyExceptionInfo(exception);
6952 SvREFCNT_dec(perl_exception); /* throw away all errors */
6956 ###############################################################################
6964 ###############################################################################
6969 Image::Magick ref=NO_INIT
6973 OptimizeImageLayers = 3
6975 optimizeimagelayers = 5
7017 PERL_UNUSED_VAR(ref);
7018 PERL_UNUSED_VAR(ix);
7019 exception=AcquireExceptionInfo();
7020 perl_exception=newSVpv("",0);
7022 if (sv_isobject(ST(0)) == 0)
7024 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7028 reference=SvRV(ST(0));
7029 hv=SvSTASH(reference);
7031 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7033 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7034 if (image == (Image *) NULL)
7036 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7040 compose=image->compose;
7041 method=OptimizeLayer;
7042 for (i=2; i < items; i+=2)
7044 attribute=(char *) SvPV(ST(i-1),na);
7050 if (LocaleCompare(attribute,"compose") == 0)
7052 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7053 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7056 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7060 compose=(CompositeOperator) sp;
7063 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7070 if (LocaleCompare(attribute,"method") == 0)
7072 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7076 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7080 method=(LayerMethod) option;
7083 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7089 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7095 layers=(Image *) NULL;
7098 case CompareAnyLayer:
7099 case CompareClearLayer:
7100 case CompareOverlayLayer:
7103 layers=CompareImagesLayers(image,method,exception);
7110 layers=MergeImageLayers(image,method,exception);
7115 layers=DisposeImages(image,exception);
7118 case OptimizeImageLayer:
7120 layers=OptimizeImageLayers(image,exception);
7123 case OptimizePlusLayer:
7125 layers=OptimizePlusImageLayers(image,exception);
7128 case OptimizeTransLayer:
7130 OptimizeImageTransparency(image,exception);
7133 case RemoveDupsLayer:
7135 RemoveDuplicateLayers(&image,exception);
7138 case RemoveZeroLayer:
7140 RemoveZeroDelayLayers(&image,exception);
7149 General Purpose, GIF Animation Optimizer.
7151 layers=CoalesceImages(image,exception);
7152 if (layers == (Image *) NULL)
7155 layers=OptimizeImageLayers(image,exception);
7156 if (layers == (Image *) NULL)
7158 image=DestroyImageList(image);
7160 layers=(Image *) NULL;
7161 OptimizeImageTransparency(image,exception);
7162 quantize_info=AcquireQuantizeInfo(info->image_info);
7163 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7164 quantize_info=DestroyQuantizeInfo(quantize_info);
7167 case CompositeLayer:
7176 Split image sequence at the first 'NULL:' image.
7179 while (source != (Image *) NULL)
7181 source=GetNextImageInList(source);
7182 if ((source != (Image *) NULL) &&
7183 (LocaleCompare(source->magick,"NULL") == 0))
7186 if (source != (Image *) NULL)
7188 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7189 (GetNextImageInList(source) == (Image *) NULL))
7190 source=(Image *) NULL;
7194 Separate the two lists, junk the null: image.
7196 source=SplitImageList(source->previous);
7197 DeleteImageFromList(&source);
7200 if (source == (Image *) NULL)
7202 (void) ThrowMagickException(exception,GetMagickModule(),
7203 OptionError,"MissingNullSeparator","layers Composite");
7207 Adjust offset with gravity and virtual canvas.
7209 SetGeometry(image,&geometry);
7210 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7211 geometry.width=source->page.width != 0 ? source->page.width :
7213 geometry.height=source->page.height != 0 ? source->page.height :
7215 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7216 image->columns,image->page.height != 0 ? image->page.height :
7217 image->rows,image->gravity,&geometry);
7218 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7219 source=DestroyImageList(source);
7223 if (layers != (Image *) NULL)
7226 image=CloneImage(image,0,0,MagickTrue,exception);
7227 if (image == (Image *) NULL)
7229 for ( ; image; image=image->next)
7231 AddImageToRegistry(sv,image);
7233 av_push(av,sv_bless(rv,hv));
7236 exception=DestroyExceptionInfo(exception);
7238 SvREFCNT_dec(perl_exception);
7242 InheritPerlException(exception,perl_exception);
7243 exception=DestroyExceptionInfo(exception);
7244 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7245 SvPOK_on(perl_exception);
7246 ST(0)=sv_2mortal(perl_exception);
7251 ###############################################################################
7255 # M a g i c k T o M i m e #
7259 ###############################################################################
7263 MagickToMime(ref,name)
7264 Image::Magick ref=NO_INIT
7273 PERL_UNUSED_VAR(ref);
7274 PERL_UNUSED_VAR(ix);
7275 mime=MagickToMime(name);
7276 RETVAL=newSVpv(mime,0);
7277 mime=(char *) RelinquishMagickMemory(mime);
7283 ###############################################################################
7291 ###############################################################################
7296 Image::Magick ref=NO_INIT
7333 MedianConvolveImage = 36
7339 ReduceNoiseImage = 42
7365 ColorFloodfillImage= 68
7371 CycleColormapImage = 74
7381 MatteFloodfillImage= 84
7389 NumberColorsImage = 92
7399 SignatureImage = 102
7409 TransparentImage = 112
7411 ThresholdImage = 114
7425 DeconstructImage = 130
7427 GaussianBlurImage = 132
7433 UnsharpMaskImage = 138
7435 MotionBlurImage = 140
7437 OrderedDitherImage = 142
7444 AffineTransform = 149
7445 AffineTransformImage = 150
7447 DifferenceImage = 152
7448 AdaptiveThreshold = 153
7449 AdaptiveThresholdImage = 154
7454 BlackThreshold = 159
7455 BlackThresholdImage= 160
7456 WhiteThreshold = 161
7457 WhiteThresholdImage= 162
7458 RotationalBlur = 163
7459 RotationalBlurImage= 164
7461 ThumbnailImage = 166
7471 PosterizeImage = 176
7477 SepiaToneImage = 182
7478 SigmoidalContrast = 183
7479 SigmoidalContrastImage = 184
7484 ContrastStretch = 189
7485 ContrastStretchImage = 190
7490 AdaptiveSharpen = 195
7491 AdaptiveSharpenImage = 196
7493 TransposeImage = 198
7495 TransverseImage = 200
7497 AutoOrientImage = 202
7499 AdaptiveBlurImage = 204
7503 UniqueColorsImage = 208
7504 AdaptiveResize = 209
7505 AdaptiveResizeImage= 210
7509 LinearStretchImage = 214
7511 ColorMatrixImage = 216
7516 FloodfillPaint = 221
7517 FloodfillPaintImage= 222
7523 LiquidRescaleImage = 228
7533 SparseColorImage = 238
7537 SelectiveBlurImage = 242
7541 BlueShiftImage = 246
7542 ForwardFourierTransform = 247
7543 ForwardFourierTransformImage = 248
7544 InverseFourierTransform = 249
7545 InverseFourierTransformImage = 250
7546 ColorDecisionList = 251
7547 ColorDecisionListImage = 252
7549 AutoGammaImage = 254
7551 AutoLevelImage = 256
7553 LevelImageColors = 258
7556 BrightnessContrast = 261
7557 BrightnessContrastImage = 262
7559 MorphologyImage = 264
7565 StatisticImage = 270
7567 PerceptibleImage = 272
7571 GrayscaleImage = 276
7573 CannyEdgeImage = 279
7575 HoughLineImage = 281
7577 MeanShiftImage = 283
7580 ConnectedComponent = 286
7581 ConnectedComponentImage = 287
7583 CopyImagePixels = 289
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->matte_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 (FilterTypes) 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) OrderedPosterizeImage(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) IsImagesEqual(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,(FilterTypes)
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=(FilterTypes) 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=(DistortImageMethod) 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,exception);
11268 case 143: /* Copy */
11279 source_image=image;
11280 if (attribute_flag[0] != 0)
11281 source_image=argument_list[0].image_reference;
11282 SetGeometry(source_image,&geometry);
11283 if (attribute_flag[1] != 0)
11284 flags=ParseGravityGeometry(source_image,
11285 argument_list[1].string_reference,&geometry,exception);
11286 if (attribute_flag[2] != 0)
11287 geometry.width=argument_list[2].integer_reference;
11288 if (attribute_flag[3] != 0)
11289 geometry.height=argument_list[3].integer_reference;
11290 if (attribute_flag[4] != 0)
11291 geometry.x=argument_list[4].integer_reference;
11292 if (attribute_flag[5] != 0)
11293 geometry.y=argument_list[5].integer_reference;
11294 if (attribute_flag[6] != 0)
11295 image->gravity=(GravityType) argument_list[6].integer_reference;
11296 SetGeometry(image,&offset_geometry);
11297 if (attribute_flag[7] != 0)
11298 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11299 &offset_geometry,exception);
11300 offset.x=offset_geometry.x;
11301 offset.y=offset_geometry.y;
11302 if (attribute_flag[8] != 0)
11303 offset.x=argument_list[8].integer_reference;
11304 if (attribute_flag[9] != 0)
11305 offset.y=argument_list[9].integer_reference;
11306 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11311 if (next != (Image *) NULL)
11312 (void) CatchImageException(next);
11313 if (region_image != (Image *) NULL)
11318 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11319 region_info.x,region_info.y,exception);
11321 (void) CatchImageException(region_image);
11322 image=DestroyImage(image);
11323 image=region_image;
11325 if (image != (Image *) NULL)
11328 if (next && (next != image))
11330 image->next=next->next;
11331 if (image->next != (Image *) NULL)
11332 image->next->previous=image;
11333 DeleteImageFromRegistry(*pv,next);
11335 sv_setiv(*pv,PTR2IV(image));
11343 if (reference_vector)
11344 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11345 InheritPerlException(exception,perl_exception);
11346 exception=DestroyExceptionInfo(exception);
11347 sv_setiv(perl_exception,(IV) number_images);
11348 SvPOK_on(perl_exception);
11349 ST(0)=sv_2mortal(perl_exception);
11354 ###############################################################################
11362 ###############################################################################
11367 Image::Magick ref=NO_INIT
11412 PERL_UNUSED_VAR(ref);
11413 PERL_UNUSED_VAR(ix);
11414 exception=AcquireExceptionInfo();
11415 perl_exception=newSVpv("",0);
11418 if (sv_isobject(ST(0)) == 0)
11420 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11422 goto PerlException;
11424 reference=SvRV(ST(0));
11425 hv=SvSTASH(reference);
11427 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11429 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11430 if (image == (Image *) NULL)
11432 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11434 goto PerlException;
11439 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11440 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11441 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11443 for (i=2; i < items; i+=2)
11445 attribute=(char *) SvPV(ST(i-1),na);
11446 switch (*attribute)
11451 if (LocaleCompare(attribute,"background") == 0)
11453 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11454 &montage_info->background_color,exception);
11455 for (next=image; next; next=next->next)
11456 next->background_color=montage_info->background_color;
11459 if (LocaleCompare(attribute,"border") == 0)
11461 montage_info->border_width=SvIV(ST(i));
11464 if (LocaleCompare(attribute,"bordercolor") == 0)
11466 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11467 &montage_info->border_color,exception);
11468 for (next=image; next; next=next->next)
11469 next->border_color=montage_info->border_color;
11472 if (LocaleCompare(attribute,"borderwidth") == 0)
11474 montage_info->border_width=SvIV(ST(i));
11477 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11484 if (LocaleCompare(attribute,"compose") == 0)
11486 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11487 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11490 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11494 for (next=image; next; next=next->next)
11495 next->compose=(CompositeOperator) sp;
11498 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11505 if (LocaleCompare(attribute,"fill") == 0)
11507 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11508 &montage_info->fill,exception);
11511 if (LocaleCompare(attribute,"font") == 0)
11513 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11516 if (LocaleCompare(attribute,"frame") == 0)
11522 if (IsGeometry(p) == MagickFalse)
11524 ThrowPerlException(exception,OptionError,"MissingGeometry",
11528 (void) CloneString(&montage_info->frame,p);
11530 montage_info->frame=(char *) NULL;
11533 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11540 if (LocaleCompare(attribute,"geometry") == 0)
11546 if (IsGeometry(p) == MagickFalse)
11548 ThrowPerlException(exception,OptionError,"MissingGeometry",
11552 (void) CloneString(&montage_info->geometry,p);
11554 montage_info->geometry=(char *) NULL;
11557 if (LocaleCompare(attribute,"gravity") == 0)
11562 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11563 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11566 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11570 montage_info->gravity=(GravityType) in;
11571 for (next=image; next; next=next->next)
11572 next->gravity=(GravityType) in;
11575 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11582 if (LocaleCompare(attribute,"label") == 0)
11584 for (next=image; next; next=next->next)
11585 (void) SetImageProperty(next,"label",InterpretImageProperties(
11586 info ? info->image_info : (ImageInfo *) NULL,next,
11587 SvPV(ST(i),na),exception),exception);
11590 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11597 if (LocaleCompare(attribute,"mattecolor") == 0)
11599 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11600 &montage_info->matte_color,exception);
11601 for (next=image; next; next=next->next)
11602 next->matte_color=montage_info->matte_color;
11605 if (LocaleCompare(attribute,"mode") == 0)
11610 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11611 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11616 ThrowPerlException(exception,OptionError,
11617 "UnrecognizedModeType",SvPV(ST(i),na));
11622 (void) CloneString(&montage_info->frame,"15x15+3+3");
11623 montage_info->shadow=MagickTrue;
11628 montage_info->frame=(char *) NULL;
11629 montage_info->shadow=MagickFalse;
11630 montage_info->border_width=0;
11633 case ConcatenateMode:
11635 montage_info->frame=(char *) NULL;
11636 montage_info->shadow=MagickFalse;
11637 (void) CloneString(&montage_info->geometry,"+0+0");
11638 montage_info->border_width=0;
11643 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11650 if (LocaleCompare(attribute,"pointsize") == 0)
11652 montage_info->pointsize=SvIV(ST(i));
11655 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11662 if (LocaleCompare(attribute,"shadow") == 0)
11664 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11665 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11668 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11672 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11675 if (LocaleCompare(attribute,"stroke") == 0)
11677 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11678 &montage_info->stroke,exception);
11681 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11688 if (LocaleCompare(attribute,"texture") == 0)
11690 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11693 if (LocaleCompare(attribute,"tile") == 0)
11695 char *p=SvPV(ST(i),na);
11696 if (IsGeometry(p) == MagickFalse)
11698 ThrowPerlException(exception,OptionError,"MissingGeometry",
11702 (void) CloneString(&montage_info->tile,p);
11704 montage_info->tile=(char *) NULL;
11707 if (LocaleCompare(attribute,"title") == 0)
11709 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11712 if (LocaleCompare(attribute,"transparent") == 0)
11717 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11718 &transparent_color,exception);
11719 for (next=image; next; next=next->next)
11720 (void) TransparentPaintImage(next,&transparent_color,
11721 TransparentAlpha,MagickFalse,exception);
11724 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11730 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11736 image=MontageImageList(info->image_info,montage_info,image,exception);
11737 montage_info=DestroyMontageInfo(montage_info);
11738 if (image == (Image *) NULL)
11739 goto PerlException;
11740 if (transparent_color.alpha != TransparentAlpha)
11741 for (next=image; next; next=next->next)
11742 (void) TransparentPaintImage(next,&transparent_color,
11743 TransparentAlpha,MagickFalse,exception);
11744 for ( ; image; image=image->next)
11746 AddImageToRegistry(sv,image);
11748 av_push(av,sv_bless(rv,hv));
11751 exception=DestroyExceptionInfo(exception);
11752 ST(0)=av_reference;
11753 SvREFCNT_dec(perl_exception);
11757 InheritPerlException(exception,perl_exception);
11758 exception=DestroyExceptionInfo(exception);
11759 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11760 SvPOK_on(perl_exception);
11761 ST(0)=sv_2mortal(perl_exception);
11766 ###############################################################################
11774 ###############################################################################
11779 Image::Magick ref=NO_INIT
11817 PERL_UNUSED_VAR(ref);
11818 PERL_UNUSED_VAR(ix);
11819 exception=AcquireExceptionInfo();
11820 perl_exception=newSVpv("",0);
11824 if (sv_isobject(ST(0)) == 0)
11826 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11828 goto PerlException;
11830 reference=SvRV(ST(0));
11831 hv=SvSTASH(reference);
11833 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11835 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11836 if (image == (Image *) NULL)
11838 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11840 goto PerlException;
11842 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11847 for (i=2; i < items; i+=2)
11849 attribute=(char *) SvPV(ST(i-1),na);
11850 switch (*attribute)
11855 if (LocaleCompare(attribute,"frames") == 0)
11857 number_frames=SvIV(ST(i));
11860 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11866 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11872 image=MorphImages(image,number_frames,exception);
11873 if (image == (Image *) NULL)
11874 goto PerlException;
11875 for ( ; image; image=image->next)
11877 AddImageToRegistry(sv,image);
11879 av_push(av,sv_bless(rv,hv));
11882 exception=DestroyExceptionInfo(exception);
11883 ST(0)=av_reference;
11884 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11888 InheritPerlException(exception,perl_exception);
11889 exception=DestroyExceptionInfo(exception);
11890 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11891 SvPOK_on(perl_exception);
11892 ST(0)=sv_2mortal(perl_exception);
11897 ###############################################################################
11905 ###############################################################################
11910 Image::Magick ref=NO_INIT
11938 PERL_UNUSED_VAR(ref);
11939 PERL_UNUSED_VAR(ix);
11940 exception=AcquireExceptionInfo();
11941 perl_exception=newSVpv("",0);
11943 if (sv_isobject(ST(0)) == 0)
11945 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11947 goto PerlException;
11949 reference=SvRV(ST(0));
11950 hv=SvSTASH(reference);
11951 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11952 if (image == (Image *) NULL)
11954 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11956 goto PerlException;
11958 image=MergeImageLayers(image,MosaicLayer,exception);
11960 Create blessed Perl array for the returned image.
11963 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11965 AddImageToRegistry(sv,image);
11967 av_push(av,sv_bless(rv,hv));
11969 (void) CopyMagickString(info->image_info->filename,image->filename,
11971 SetImageInfo(info->image_info,0,exception);
11972 exception=DestroyExceptionInfo(exception);
11973 SvREFCNT_dec(perl_exception);
11977 InheritPerlException(exception,perl_exception);
11978 exception=DestroyExceptionInfo(exception);
11979 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11980 SvPOK_on(perl_exception); /* return messages in string context */
11981 ST(0)=sv_2mortal(perl_exception);
11986 ###############################################################################
11994 ###############################################################################
11999 Image::Magick ref=NO_INIT
12049 PERL_UNUSED_VAR(ref);
12050 PERL_UNUSED_VAR(ix);
12051 exception=AcquireExceptionInfo();
12052 perl_exception=newSVpv("",0);
12053 package_info=(struct PackageInfo *) NULL;
12054 ac=(items < 2) ? 1 : items-1;
12055 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12057 length=(STRLEN *) NULL;
12058 if (list == (char **) NULL)
12060 ThrowPerlException(exception,ResourceLimitError,
12061 "MemoryAllocationFailed",PackageName);
12062 goto PerlException;
12065 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12066 if (length == (STRLEN *) NULL)
12068 ThrowPerlException(exception,ResourceLimitError,
12069 "MemoryAllocationFailed",PackageName);
12070 goto PerlException;
12072 if (sv_isobject(ST(0)) == 0)
12074 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12076 goto PerlException;
12078 reference=SvRV(ST(0));
12079 if (SvTYPE(reference) != SVt_PVAV)
12081 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12083 goto PerlException;
12085 av=(AV *) reference;
12086 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12088 package_info=ClonePackageInfo(info,exception);
12091 *list=(char *) (*package_info->image_info->filename ?
12092 package_info->image_info->filename : "XC:black");
12094 for (n=0, i=0; i < ac; i++)
12096 list[n]=(char *) SvPV(ST(i+1),length[n]);
12097 if ((items >= 3) && strEQcase(list[n],"blob"))
12103 blob=(void *) (SvPV(ST(i+1),length[n]));
12104 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12106 if ((items >= 3) && strEQcase(list[n],"filename"))
12108 if ((items >= 3) && strEQcase(list[n],"file"))
12117 io_info=IoIFP(sv_2io(ST(i+1)));
12118 if (io_info == (PerlIO *) NULL)
12120 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12124 file=PerlIO_findFILE(io_info);
12125 if (file == (FILE *) NULL)
12127 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12131 SetImageInfoFile(package_info->image_info,file);
12133 if ((items >= 3) && strEQcase(list[n],"magick"))
12137 list[n]=(char *) NULL;
12139 status=ExpandFilenames(&n,&list);
12140 if (status == MagickFalse)
12142 ThrowPerlException(exception,ResourceLimitError,
12143 "MemoryAllocationFailed",PackageName);
12144 goto PerlException;
12147 for (i=0; i < n; i++)
12149 (void) CopyMagickString(package_info->image_info->filename,list[i],
12151 image=PingImage(package_info->image_info,exception);
12152 if (image == (Image *) NULL)
12154 if ((package_info->image_info->file != (FILE *) NULL) ||
12155 (package_info->image_info->blob != (void *) NULL))
12156 DisassociateImageStream(image);
12157 count+=GetImageListLength(image);
12158 EXTEND(sp,4*count);
12159 for (next=image; next; next=next->next)
12161 PUSHs(sv_2mortal(newSViv(next->columns)));
12162 PUSHs(sv_2mortal(newSViv(next->rows)));
12163 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12164 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12166 image=DestroyImageList(image);
12171 for (i=0; i < n; i++)
12172 if (list[i] != (char *) NULL)
12173 for (p=keep; list[i] != *p++; )
12176 list[i]=(char *) RelinquishMagickMemory(list[i]);
12181 if (package_info != (struct PackageInfo *) NULL)
12182 DestroyPackageInfo(package_info);
12183 if (list && (list != keep))
12184 list=(char **) RelinquishMagickMemory(list);
12186 keep=(char **) RelinquishMagickMemory(keep);
12188 length=(STRLEN *) RelinquishMagickMemory(length);
12189 InheritPerlException(exception,perl_exception);
12190 exception=DestroyExceptionInfo(exception);
12191 SvREFCNT_dec(perl_exception); /* throw away all errors */
12195 ###############################################################################
12203 ###############################################################################
12208 Image::Magick ref=NO_INIT
12241 PERL_UNUSED_VAR(ref);
12242 PERL_UNUSED_VAR(ix);
12243 exception=AcquireExceptionInfo();
12244 perl_exception=newSVpv("",0);
12247 if (sv_isobject(ST(0)) == 0)
12249 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12251 goto PerlException;
12253 reference=SvRV(ST(0));
12254 hv=SvSTASH(reference);
12256 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12258 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12259 if (image == (Image *) NULL)
12261 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12263 goto PerlException;
12265 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12266 preview_type=GammaPreview;
12268 preview_type=(PreviewType)
12269 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12270 for ( ; image; image=image->next)
12272 preview_image=PreviewImage(image,preview_type,exception);
12273 if (preview_image == (Image *) NULL)
12274 goto PerlException;
12275 AddImageToRegistry(sv,preview_image);
12277 av_push(av,sv_bless(rv,hv));
12280 exception=DestroyExceptionInfo(exception);
12281 ST(0)=av_reference;
12282 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12286 InheritPerlException(exception,perl_exception);
12287 exception=DestroyExceptionInfo(exception);
12288 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12289 SvPOK_on(perl_exception);
12290 ST(0)=sv_2mortal(perl_exception);
12295 ###############################################################################
12299 # Q u e r y C o l o r #
12303 ###############################################################################
12307 QueryColor(ref,...)
12308 Image::Magick ref=NO_INIT
12328 PERL_UNUSED_VAR(ref);
12329 PERL_UNUSED_VAR(ix);
12330 exception=AcquireExceptionInfo();
12331 perl_exception=newSVpv("",0);
12340 colorlist=GetColorInfoList("*",&colors,exception);
12342 for (i=0; i < (ssize_t) colors; i++)
12344 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12346 colorlist=(const ColorInfo **)
12347 RelinquishMagickMemory((ColorInfo **) colorlist);
12348 goto PerlException;
12350 EXTEND(sp,5*items);
12351 for (i=1; i < items; i++)
12353 name=(char *) SvPV(ST(i),na);
12354 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12359 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12360 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12361 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12362 if (color.colorspace == CMYKColorspace)
12363 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12364 if (color.alpha_trait != UndefinedPixelTrait)
12365 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12369 InheritPerlException(exception,perl_exception);
12370 exception=DestroyExceptionInfo(exception);
12371 SvREFCNT_dec(perl_exception);
12375 ###############################################################################
12379 # Q u e r y C o l o r N a m e #
12383 ###############################################################################
12387 QueryColorname(ref,...)
12388 Image::Magick ref=NO_INIT
12397 message[MagickPathExtent];
12416 *reference; /* reference is the SV* of ref=SvIV(reference) */
12418 PERL_UNUSED_VAR(ref);
12419 PERL_UNUSED_VAR(ix);
12420 exception=AcquireExceptionInfo();
12421 perl_exception=newSVpv("",0);
12422 reference=SvRV(ST(0));
12423 av=(AV *) reference;
12424 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12426 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12427 if (image == (Image *) NULL)
12429 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12431 goto PerlException;
12434 for (i=1; i < items; i++)
12436 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12438 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12440 PUSHs(sv_2mortal(newSVpv(message,0)));
12444 InheritPerlException(exception,perl_exception);
12445 exception=DestroyExceptionInfo(exception);
12446 SvREFCNT_dec(perl_exception);
12450 ###############################################################################
12454 # Q u e r y F o n t #
12458 ###############################################################################
12463 Image::Magick ref=NO_INIT
12470 message[MagickPathExtent];
12481 volatile const TypeInfo
12484 PERL_UNUSED_VAR(ref);
12485 PERL_UNUSED_VAR(ix);
12486 exception=AcquireExceptionInfo();
12487 perl_exception=newSVpv("",0);
12496 typelist=GetTypeInfoList("*",&types,exception);
12498 for (i=0; i < (ssize_t) types; i++)
12500 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12502 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12504 goto PerlException;
12506 EXTEND(sp,10*items);
12507 for (i=1; i < items; i++)
12509 name=(char *) SvPV(ST(i),na);
12510 type_info=GetTypeInfo(name,exception);
12511 if (type_info == (TypeInfo *) NULL)
12516 if (type_info->name == (char *) NULL)
12519 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12520 if (type_info->description == (char *) NULL)
12523 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12524 if (type_info->family == (char *) NULL)
12527 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12528 if (type_info->style == UndefinedStyle)
12531 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12532 type_info->style),0)));
12533 if (type_info->stretch == UndefinedStretch)
12536 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12537 type_info->stretch),0)));
12538 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12539 type_info->weight);
12540 PUSHs(sv_2mortal(newSVpv(message,0)));
12541 if (type_info->encoding == (char *) NULL)
12544 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12545 if (type_info->foundry == (char *) NULL)
12548 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12549 if (type_info->format == (char *) NULL)
12552 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12553 if (type_info->metrics == (char *) NULL)
12556 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12557 if (type_info->glyphs == (char *) NULL)
12560 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12564 InheritPerlException(exception,perl_exception);
12565 exception=DestroyExceptionInfo(exception);
12566 SvREFCNT_dec(perl_exception);
12570 ###############################################################################
12574 # Q u e r y F o n t M e t r i c s #
12578 ###############################################################################
12582 QueryFontMetrics(ref,...)
12583 Image::Magick ref=NO_INIT
12585 queryfontmetrics = 1
12632 *reference; /* reference is the SV* of ref=SvIV(reference) */
12637 PERL_UNUSED_VAR(ref);
12638 PERL_UNUSED_VAR(ix);
12639 exception=AcquireExceptionInfo();
12640 package_info=(struct PackageInfo *) NULL;
12641 perl_exception=newSVpv("",0);
12642 reference=SvRV(ST(0));
12643 av=(AV *) reference;
12644 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12646 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12647 if (image == (Image *) NULL)
12649 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12651 goto PerlException;
12653 package_info=ClonePackageInfo(info,exception);
12654 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12655 CloneString(&draw_info->text,"");
12656 current=draw_info->affine;
12657 GetAffineMatrix(&affine);
12660 EXTEND(sp,7*items);
12661 for (i=2; i < items; i+=2)
12663 attribute=(char *) SvPV(ST(i-1),na);
12664 switch (*attribute)
12669 if (LocaleCompare(attribute,"antialias") == 0)
12671 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12675 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12679 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12682 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12689 if (LocaleCompare(attribute,"density") == 0)
12691 CloneString(&draw_info->density,SvPV(ST(i),na));
12694 if (LocaleCompare(attribute,"direction") == 0)
12696 draw_info->direction=(DirectionType) ParseCommandOption(
12697 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12700 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12707 if (LocaleCompare(attribute,"encoding") == 0)
12709 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12712 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12719 if (LocaleCompare(attribute,"family") == 0)
12721 CloneString(&draw_info->family,SvPV(ST(i),na));
12724 if (LocaleCompare(attribute,"fill") == 0)
12727 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12728 &draw_info->fill,exception);
12731 if (LocaleCompare(attribute,"font") == 0)
12733 CloneString(&draw_info->font,SvPV(ST(i),na));
12736 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12743 if (LocaleCompare(attribute,"geometry") == 0)
12745 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12748 if (LocaleCompare(attribute,"gravity") == 0)
12750 draw_info->gravity=(GravityType) ParseCommandOption(
12751 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12754 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12761 if (LocaleCompare(attribute,"interline-spacing") == 0)
12763 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12764 draw_info->interline_spacing=geometry_info.rho;
12767 if (LocaleCompare(attribute,"interword-spacing") == 0)
12769 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12770 draw_info->interword_spacing=geometry_info.rho;
12773 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12780 if (LocaleCompare(attribute,"kerning") == 0)
12782 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12783 draw_info->kerning=geometry_info.rho;
12786 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12793 if (LocaleCompare(attribute,"pointsize") == 0)
12795 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12796 draw_info->pointsize=geometry_info.rho;
12799 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12806 if (LocaleCompare(attribute,"rotate") == 0)
12808 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12809 affine.rx=geometry_info.rho;
12810 affine.ry=geometry_info.sigma;
12811 if ((flags & SigmaValue) == 0)
12812 affine.ry=affine.rx;
12815 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12822 if (LocaleCompare(attribute,"scale") == 0)
12824 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12825 affine.sx=geometry_info.rho;
12826 affine.sy=geometry_info.sigma;
12827 if ((flags & SigmaValue) == 0)
12828 affine.sy=affine.sx;
12831 if (LocaleCompare(attribute,"skew") == 0)
12837 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12838 x_angle=geometry_info.rho;
12839 y_angle=geometry_info.sigma;
12840 if ((flags & SigmaValue) == 0)
12842 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12843 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12846 if (LocaleCompare(attribute,"stroke") == 0)
12849 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12850 &draw_info->stroke,exception);
12853 if (LocaleCompare(attribute,"style") == 0)
12855 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12859 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12863 draw_info->style=(StyleType) type;
12866 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12873 if (LocaleCompare(attribute,"text") == 0)
12875 CloneString(&draw_info->text,SvPV(ST(i),na));
12878 if (LocaleCompare(attribute,"translate") == 0)
12880 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12881 affine.tx=geometry_info.rho;
12882 affine.ty=geometry_info.sigma;
12883 if ((flags & SigmaValue) == 0)
12884 affine.ty=affine.tx;
12887 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12894 if (LocaleCompare(attribute,"weight") == 0)
12896 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12897 draw_info->weight=(size_t) geometry_info.rho;
12900 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12907 if (LocaleCompare(attribute,"x") == 0)
12909 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12910 x=geometry_info.rho;
12913 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12920 if (LocaleCompare(attribute,"y") == 0)
12922 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12923 y=geometry_info.rho;
12926 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12932 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12938 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12939 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12940 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12941 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12942 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12943 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12944 if (draw_info->geometry == (char *) NULL)
12946 draw_info->geometry=AcquireString((char *) NULL);
12947 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
12948 "%.15g,%.15g",x,y);
12950 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12951 (void) CatchImageException(image);
12952 if (status == MagickFalse)
12956 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12957 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12958 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12959 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12960 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12961 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12962 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12963 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12964 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12965 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12966 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12967 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12968 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12970 draw_info=DestroyDrawInfo(draw_info);
12973 if (package_info != (struct PackageInfo *) NULL)
12974 DestroyPackageInfo(package_info);
12975 InheritPerlException(exception,perl_exception);
12976 exception=DestroyExceptionInfo(exception);
12977 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12981 ###############################################################################
12985 # 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 #
12989 ###############################################################################
12993 QueryMultilineFontMetrics(ref,...)
12994 Image::Magick ref=NO_INIT
12996 querymultilinefontmetrics = 1
13043 *reference; /* reference is the SV* of ref=SvIV(reference) */
13048 PERL_UNUSED_VAR(ref);
13049 PERL_UNUSED_VAR(ix);
13050 exception=AcquireExceptionInfo();
13051 package_info=(struct PackageInfo *) NULL;
13052 perl_exception=newSVpv("",0);
13053 reference=SvRV(ST(0));
13054 av=(AV *) reference;
13055 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13057 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13058 if (image == (Image *) NULL)
13060 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13062 goto PerlException;
13064 package_info=ClonePackageInfo(info,exception);
13065 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13066 CloneString(&draw_info->text,"");
13067 current=draw_info->affine;
13068 GetAffineMatrix(&affine);
13071 EXTEND(sp,7*items);
13072 for (i=2; i < items; i+=2)
13074 attribute=(char *) SvPV(ST(i-1),na);
13075 switch (*attribute)
13080 if (LocaleCompare(attribute,"antialias") == 0)
13082 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13086 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13090 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13093 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13100 if (LocaleCompare(attribute,"density") == 0)
13102 CloneString(&draw_info->density,SvPV(ST(i),na));
13105 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13112 if (LocaleCompare(attribute,"encoding") == 0)
13114 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13117 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13124 if (LocaleCompare(attribute,"family") == 0)
13126 CloneString(&draw_info->family,SvPV(ST(i),na));
13129 if (LocaleCompare(attribute,"fill") == 0)
13132 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13133 &draw_info->fill,exception);
13136 if (LocaleCompare(attribute,"font") == 0)
13138 CloneString(&draw_info->font,SvPV(ST(i),na));
13141 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13148 if (LocaleCompare(attribute,"geometry") == 0)
13150 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13153 if (LocaleCompare(attribute,"gravity") == 0)
13155 draw_info->gravity=(GravityType) ParseCommandOption(
13156 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13159 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13166 if (LocaleCompare(attribute,"pointsize") == 0)
13168 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13169 draw_info->pointsize=geometry_info.rho;
13172 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13179 if (LocaleCompare(attribute,"rotate") == 0)
13181 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13182 affine.rx=geometry_info.rho;
13183 affine.ry=geometry_info.sigma;
13184 if ((flags & SigmaValue) == 0)
13185 affine.ry=affine.rx;
13188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13195 if (LocaleCompare(attribute,"scale") == 0)
13197 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13198 affine.sx=geometry_info.rho;
13199 affine.sy=geometry_info.sigma;
13200 if ((flags & SigmaValue) == 0)
13201 affine.sy=affine.sx;
13204 if (LocaleCompare(attribute,"skew") == 0)
13210 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13211 x_angle=geometry_info.rho;
13212 y_angle=geometry_info.sigma;
13213 if ((flags & SigmaValue) == 0)
13215 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13216 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13219 if (LocaleCompare(attribute,"stroke") == 0)
13222 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13223 &draw_info->stroke,exception);
13226 if (LocaleCompare(attribute,"style") == 0)
13228 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13232 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13236 draw_info->style=(StyleType) type;
13239 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13246 if (LocaleCompare(attribute,"text") == 0)
13248 CloneString(&draw_info->text,SvPV(ST(i),na));
13251 if (LocaleCompare(attribute,"translate") == 0)
13253 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13254 affine.tx=geometry_info.rho;
13255 affine.ty=geometry_info.sigma;
13256 if ((flags & SigmaValue) == 0)
13257 affine.ty=affine.tx;
13260 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13267 if (LocaleCompare(attribute,"weight") == 0)
13269 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13270 draw_info->weight=(size_t) geometry_info.rho;
13273 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13280 if (LocaleCompare(attribute,"x") == 0)
13282 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13283 x=geometry_info.rho;
13286 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13293 if (LocaleCompare(attribute,"y") == 0)
13295 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13296 y=geometry_info.rho;
13299 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13305 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13311 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13312 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13313 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13314 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13315 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13316 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13317 if (draw_info->geometry == (char *) NULL)
13319 draw_info->geometry=AcquireString((char *) NULL);
13320 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13321 "%.15g,%.15g",x,y);
13323 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13324 (void) CatchException(exception);
13325 if (status == MagickFalse)
13329 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13330 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13331 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13332 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13333 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13334 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13335 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13336 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13337 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13338 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13339 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13340 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13341 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13343 draw_info=DestroyDrawInfo(draw_info);
13346 if (package_info != (struct PackageInfo *) NULL)
13347 DestroyPackageInfo(package_info);
13348 InheritPerlException(exception,perl_exception);
13349 exception=DestroyExceptionInfo(exception);
13350 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13354 ###############################################################################
13358 # Q u e r y F o r m a t #
13362 ###############################################################################
13366 QueryFormat(ref,...)
13367 Image::Magick ref=NO_INIT
13384 volatile const MagickInfo
13387 PERL_UNUSED_VAR(ref);
13388 PERL_UNUSED_VAR(ix);
13389 exception=AcquireExceptionInfo();
13390 perl_exception=newSVpv("",0);
13394 format[MagickPathExtent];
13402 format_list=GetMagickInfoList("*",&types,exception);
13404 for (i=0; i < (ssize_t) types; i++)
13406 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13407 LocaleLower(format);
13408 PUSHs(sv_2mortal(newSVpv(format,0)));
13410 format_list=(const MagickInfo **)
13411 RelinquishMagickMemory((MagickInfo *) format_list);
13412 goto PerlException;
13414 EXTEND(sp,8*items);
13415 for (i=1; i < items; i++)
13417 name=(char *) SvPV(ST(i),na);
13418 magick_info=GetMagickInfo(name,exception);
13419 if (magick_info == (const MagickInfo *) NULL)
13424 if (magick_info->description == (char *) NULL)
13427 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13428 if (magick_info->module == (char *) NULL)
13431 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13435 InheritPerlException(exception,perl_exception);
13436 exception=DestroyExceptionInfo(exception);
13437 SvREFCNT_dec(perl_exception);
13441 ###############################################################################
13445 # Q u e r y O p t i o n #
13449 ###############################################################################
13453 QueryOption(ref,...)
13454 Image::Magick ref=NO_INIT
13475 PERL_UNUSED_VAR(ref);
13476 PERL_UNUSED_VAR(ix);
13477 exception=AcquireExceptionInfo();
13478 perl_exception=newSVpv("",0);
13479 EXTEND(sp,8*items);
13480 for (i=1; i < items; i++)
13482 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13484 options=GetCommandOptions((CommandOption) option);
13485 if (options == (char **) NULL)
13489 for (j=0; options[j] != (char *) NULL; j++)
13490 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13491 options=DestroyStringList(options);
13495 InheritPerlException(exception,perl_exception);
13496 exception=DestroyExceptionInfo(exception);
13497 SvREFCNT_dec(perl_exception);
13501 ###############################################################################
13509 ###############################################################################
13514 Image::Magick ref=NO_INIT
13561 *perl_exception, /* Perl variable for storing messages */
13566 PERL_UNUSED_VAR(ref);
13567 PERL_UNUSED_VAR(ix);
13568 exception=AcquireExceptionInfo();
13569 perl_exception=newSVpv("",0);
13571 package_info=(struct PackageInfo *) NULL;
13573 ac=(items < 2) ? 1 : items-1;
13574 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13576 length=(STRLEN *) NULL;
13577 if (list == (char **) NULL)
13579 ThrowPerlException(exception,ResourceLimitError,
13580 "MemoryAllocationFailed",PackageName);
13581 goto PerlException;
13583 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13584 if (length == (STRLEN *) NULL)
13586 ThrowPerlException(exception,ResourceLimitError,
13587 "MemoryAllocationFailed",PackageName);
13588 goto PerlException;
13590 if (sv_isobject(ST(0)) == 0)
13592 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13594 goto PerlException;
13596 reference=SvRV(ST(0));
13597 hv=SvSTASH(reference);
13598 if (SvTYPE(reference) != SVt_PVAV)
13600 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13602 goto PerlException;
13604 av=(AV *) reference;
13605 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13607 package_info=ClonePackageInfo(info,exception);
13610 *list=(char *) (*package_info->image_info->filename ?
13611 package_info->image_info->filename : "XC:black");
13613 for (n=0, i=0; i < ac; i++)
13615 list[n]=(char *) SvPV(ST(i+1),length[n]);
13616 if ((items >= 3) && strEQcase(list[n],"blob"))
13622 blob=(void *) (SvPV(ST(i+1),length[n]));
13623 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13625 if ((items >= 3) && strEQcase(list[n],"filename"))
13627 if ((items >= 3) && strEQcase(list[n],"file"))
13636 io_info=IoIFP(sv_2io(ST(i+1)));
13637 if (io_info == (PerlIO *) NULL)
13639 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13643 file=PerlIO_findFILE(io_info);
13644 if (file == (FILE *) NULL)
13646 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13650 SetImageInfoFile(package_info->image_info,file);
13652 if ((items >= 3) && strEQcase(list[n],"magick"))
13656 list[n]=(char *) NULL;
13658 status=ExpandFilenames(&n,&list);
13659 if (status == MagickFalse)
13661 ThrowPerlException(exception,ResourceLimitError,
13662 "MemoryAllocationFailed",PackageName);
13663 goto PerlException;
13666 for (i=0; i < n; i++)
13668 if ((package_info->image_info->file == (FILE *) NULL) &&
13669 (package_info->image_info->blob == (void *) NULL))
13670 image=ReadImages(package_info->image_info,list[i],exception);
13673 image=ReadImages(package_info->image_info,
13674 package_info->image_info->filename,exception);
13675 if (image != (Image *) NULL)
13676 DisassociateImageStream(image);
13678 if (image == (Image *) NULL)
13680 for ( ; image; image=image->next)
13682 AddImageToRegistry(sv,image);
13684 av_push(av,sv_bless(rv,hv));
13692 for (i=0; i < n; i++)
13693 if (list[i] != (char *) NULL)
13694 for (p=keep; list[i] != *p++; )
13695 if (*p == (char *) NULL)
13697 list[i]=(char *) RelinquishMagickMemory(list[i]);
13702 if (package_info != (struct PackageInfo *) NULL)
13703 DestroyPackageInfo(package_info);
13704 if (list && (list != keep))
13705 list=(char **) RelinquishMagickMemory(list);
13707 keep=(char **) RelinquishMagickMemory(keep);
13709 length=(STRLEN *) RelinquishMagickMemory(length);
13710 InheritPerlException(exception,perl_exception);
13711 exception=DestroyExceptionInfo(exception);
13712 sv_setiv(perl_exception,(IV) number_images);
13713 SvPOK_on(perl_exception);
13714 ST(0)=sv_2mortal(perl_exception);
13719 ###############################################################################
13727 ###############################################################################
13732 Image::Magick ref=NO_INIT
13755 PERL_UNUSED_VAR(ref);
13756 PERL_UNUSED_VAR(ix);
13757 exception=AcquireExceptionInfo();
13758 perl_exception=newSVpv("",0);
13759 reference=SvRV(ST(0));
13760 av=(AV *) reference;
13761 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13763 for (i=1; i < items; i++)
13764 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13765 SvPV(ST(i),na),exception);
13766 InheritPerlException(exception,perl_exception);
13767 exception=DestroyExceptionInfo(exception);
13768 SvREFCNT_dec(perl_exception); /* throw away all errors */
13772 ###############################################################################
13780 ###############################################################################
13785 Image::Magick ref=NO_INIT
13808 *reference; /* reference is the SV* of ref=SvIV(reference) */
13810 PERL_UNUSED_VAR(ref);
13811 PERL_UNUSED_VAR(ix);
13812 exception=AcquireExceptionInfo();
13813 perl_exception=newSVpv("",0);
13814 if (sv_isobject(ST(0)) == 0)
13816 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13818 goto PerlException;
13820 reference=SvRV(ST(0));
13821 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13823 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13825 for (i=2; i < items; i+=2)
13826 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13829 InheritPerlException(exception,perl_exception);
13830 exception=DestroyExceptionInfo(exception);
13831 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13832 SvPOK_on(perl_exception);
13833 ST(0)=sv_2mortal(perl_exception);
13838 ###############################################################################
13842 # S e t P i x e l #
13846 ###############################################################################
13851 Image::Magick ref=NO_INIT
13893 *reference; /* reference is the SV* of ref=SvIV(reference) */
13895 PERL_UNUSED_VAR(ref);
13896 PERL_UNUSED_VAR(ix);
13897 exception=AcquireExceptionInfo();
13898 perl_exception=newSVpv("",0);
13899 reference=SvRV(ST(0));
13900 av=(AV *) reference;
13901 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13903 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13904 if (image == (Image *) NULL)
13906 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13908 goto PerlException;
13911 normalize=MagickTrue;
13914 region.width=image->columns;
13917 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13918 channel=DefaultChannels;
13919 for (i=2; i < items; i+=2)
13921 attribute=(char *) SvPV(ST(i-1),na);
13922 switch (*attribute)
13927 if (LocaleCompare(attribute,"channel") == 0)
13932 option=ParseChannelOption(SvPV(ST(i),na));
13935 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13939 channel=(ChannelType) option;
13942 if (LocaleCompare(attribute,"color") == 0)
13944 if (SvTYPE(ST(i)) != SVt_RV)
13947 message[MagickPathExtent];
13949 (void) FormatLocaleString(message,MagickPathExtent,
13950 "invalid %.60s value",attribute);
13951 ThrowPerlException(exception,OptionError,message,
13954 av=(AV *) SvRV(ST(i));
13957 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13964 if (LocaleCompare(attribute,"geometry") == 0)
13966 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13969 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13976 if (LocaleCompare(attribute,"normalize") == 0)
13978 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13982 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13986 normalize=option != 0 ? MagickTrue : MagickFalse;
13989 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13996 if (LocaleCompare(attribute,"x") == 0)
13998 region.x=SvIV(ST(i));
14001 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14008 if (LocaleCompare(attribute,"y") == 0)
14010 region.y=SvIV(ST(i));
14013 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14019 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14025 (void) SetImageStorageClass(image,DirectClass,exception);
14026 channel_mask=SetImageChannelMask(image,channel);
14027 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14028 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14029 (SvTYPE(av) != SVt_PVAV))
14041 if (normalize != MagickFalse)
14042 scale=QuantumRange;
14043 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14046 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14047 av_fetch(av,i,0)))),q);
14050 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14053 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14054 av_fetch(av,i,0)))),q);
14057 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14060 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14061 av_fetch(av,i,0)))),q);
14064 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14065 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14067 SetPixelBlack(image,ClampToQuantum(scale*
14068 SvNV(*(av_fetch(av,i,0)))),q);
14071 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14074 SetPixelAlpha(image,ClampToQuantum(scale*
14075 SvNV(*(av_fetch(av,i,0)))),q);
14078 (void) SyncAuthenticPixels(image,exception);
14080 (void) SetImageChannelMask(image,channel_mask);
14083 InheritPerlException(exception,perl_exception);
14084 exception=DestroyExceptionInfo(exception);
14085 SvREFCNT_dec(perl_exception);
14089 ###############################################################################
14097 ###############################################################################
14102 Image::Magick ref=NO_INIT
14141 PERL_UNUSED_VAR(ref);
14142 PERL_UNUSED_VAR(ix);
14143 exception=AcquireExceptionInfo();
14144 perl_exception=newSVpv("",0);
14148 if (sv_isobject(ST(0)) == 0)
14150 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14152 goto PerlException;
14154 reference=SvRV(ST(0));
14155 hv=SvSTASH(reference);
14157 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14159 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14160 if (image == (Image *) NULL)
14162 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14164 goto PerlException;
14166 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14172 for (i=2; i < items; i+=2)
14174 attribute=(char *) SvPV(ST(i-1),na);
14175 switch (*attribute)
14180 if (LocaleCompare(attribute,"offset") == 0)
14182 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14185 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14192 if (LocaleCompare(attribute,"stack") == 0)
14194 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14198 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14204 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14210 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14216 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14218 if (image == (Image *) NULL)
14219 goto PerlException;
14220 for ( ; image; image=image->next)
14222 AddImageToRegistry(sv,image);
14224 av_push(av,sv_bless(rv,hv));
14227 exception=DestroyExceptionInfo(exception);
14228 ST(0)=av_reference;
14229 SvREFCNT_dec(perl_exception);
14233 InheritPerlException(exception,perl_exception);
14234 exception=DestroyExceptionInfo(exception);
14235 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14236 SvPOK_on(perl_exception);
14237 ST(0)=sv_2mortal(perl_exception);
14242 ###############################################################################
14246 # S t a t i s t i c s #
14250 ###############################################################################
14254 Statistics(ref,...)
14255 Image::Magick ref=NO_INIT
14257 StatisticsImage = 1
14259 statisticsimage = 3
14262 #define ChannelStatistics(channel) \
14264 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14265 (double) channel_statistics[channel].depth); \
14266 PUSHs(sv_2mortal(newSVpv(message,0))); \
14267 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14268 channel_statistics[channel].minima/scale); \
14269 PUSHs(sv_2mortal(newSVpv(message,0))); \
14270 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14271 channel_statistics[channel].maxima/scale); \
14272 PUSHs(sv_2mortal(newSVpv(message,0))); \
14273 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14274 channel_statistics[channel].mean/scale); \
14275 PUSHs(sv_2mortal(newSVpv(message,0))); \
14276 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14277 channel_statistics[channel].standard_deviation/scale); \
14278 PUSHs(sv_2mortal(newSVpv(message,0))); \
14279 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14280 channel_statistics[channel].kurtosis); \
14281 PUSHs(sv_2mortal(newSVpv(message,0))); \
14282 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14283 channel_statistics[channel].skewness); \
14284 PUSHs(sv_2mortal(newSVpv(message,0))); \
14285 (void) FormatLocaleString(message,MagickPathExtent,"%.15g", \
14286 channel_statistics[channel].entropy); \
14287 PUSHs(sv_2mortal(newSVpv(message,0))); \
14294 message[MagickPathExtent];
14297 *channel_statistics;
14318 PERL_UNUSED_VAR(ref);
14319 PERL_UNUSED_VAR(ix);
14320 exception=AcquireExceptionInfo();
14321 perl_exception=newSVpv("",0);
14323 if (sv_isobject(ST(0)) == 0)
14325 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14327 goto PerlException;
14329 reference=SvRV(ST(0));
14332 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14333 if (image == (Image *) NULL)
14335 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14337 goto PerlException;
14340 for ( ; image; image=image->next)
14342 channel_statistics=GetImageStatistics(image,exception);
14343 if (channel_statistics == (ChannelStatistics *) NULL)
14346 EXTEND(sp,35*count);
14347 scale=(double) QuantumRange;
14348 ChannelStatistics(RedChannel);
14349 ChannelStatistics(GreenChannel);
14350 ChannelStatistics(BlueChannel);
14351 if (image->colorspace == CMYKColorspace)
14352 ChannelStatistics(BlackChannel);
14353 if (image->alpha_trait != UndefinedPixelTrait)
14354 ChannelStatistics(AlphaChannel);
14355 channel_statistics=(ChannelStatistics *)
14356 RelinquishMagickMemory(channel_statistics);
14360 InheritPerlException(exception,perl_exception);
14361 exception=DestroyExceptionInfo(exception);
14362 SvREFCNT_dec(perl_exception);
14366 ###############################################################################
14370 # S y n c A u t h e n t i c P i x e l s #
14374 ###############################################################################
14378 SyncAuthenticPixels(ref,...)
14379 Image::Magick ref = NO_INIT
14381 Syncauthenticpixels = 1
14382 SyncImagePixels = 2
14383 syncimagepixels = 3
14402 PERL_UNUSED_VAR(ref);
14403 PERL_UNUSED_VAR(ix);
14404 exception=AcquireExceptionInfo();
14405 perl_exception=newSVpv("",0);
14406 if (sv_isobject(ST(0)) == 0)
14408 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14410 goto PerlException;
14413 reference=SvRV(ST(0));
14414 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14415 if (image == (Image *) NULL)
14417 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14419 goto PerlException;
14422 status=SyncAuthenticPixels(image,exception);
14423 if (status != MagickFalse)
14427 InheritPerlException(exception,perl_exception);
14428 exception=DestroyExceptionInfo(exception);
14429 SvREFCNT_dec(perl_exception); /* throw away all errors */
14433 ###############################################################################
14437 # T r a n s f o r m #
14441 ###############################################################################
14446 Image::Magick ref=NO_INIT
14484 PERL_UNUSED_VAR(ref);
14485 PERL_UNUSED_VAR(ix);
14486 exception=AcquireExceptionInfo();
14487 perl_exception=newSVpv("",0);
14491 if (sv_isobject(ST(0)) == 0)
14493 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14495 goto PerlException;
14497 reference=SvRV(ST(0));
14498 hv=SvSTASH(reference);
14500 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14502 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14503 if (image == (Image *) NULL)
14505 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14507 goto PerlException;
14509 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14513 crop_geometry=(char *) NULL;
14514 geometry=(char *) NULL;
14515 for (i=2; i < items; i+=2)
14517 attribute=(char *) SvPV(ST(i-1),na);
14518 switch (*attribute)
14523 if (LocaleCompare(attribute,"crop") == 0)
14525 crop_geometry=SvPV(ST(i),na);
14528 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14535 if (LocaleCompare(attribute,"geometry") == 0)
14537 geometry=SvPV(ST(i),na);
14540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14546 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14552 for ( ; image; image=image->next)
14554 clone=CloneImage(image,0,0,MagickTrue,exception);
14555 if (clone == (Image *) NULL)
14556 goto PerlException;
14557 TransformImage(&clone,crop_geometry,geometry,exception);
14558 for ( ; clone; clone=clone->next)
14560 AddImageToRegistry(sv,clone);
14562 av_push(av,sv_bless(rv,hv));
14566 exception=DestroyExceptionInfo(exception);
14567 ST(0)=av_reference;
14568 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14572 InheritPerlException(exception,perl_exception);
14573 exception=DestroyExceptionInfo(exception);
14574 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14575 SvPOK_on(perl_exception);
14576 ST(0)=sv_2mortal(perl_exception);
14581 ###############################################################################
14589 ###############################################################################
14594 Image::Magick ref=NO_INIT
14602 filename[MagickPathExtent];
14626 PERL_UNUSED_VAR(ref);
14627 PERL_UNUSED_VAR(ix);
14628 exception=AcquireExceptionInfo();
14629 perl_exception=newSVpv("",0);
14631 package_info=(struct PackageInfo *) NULL;
14632 if (sv_isobject(ST(0)) == 0)
14634 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14636 goto PerlException;
14638 reference=SvRV(ST(0));
14639 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14640 if (image == (Image *) NULL)
14642 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14644 goto PerlException;
14646 package_info=ClonePackageInfo(info,exception);
14648 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14651 for (i=2; i < items; i+=2)
14652 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14654 (void) CopyMagickString(filename,package_info->image_info->filename,
14657 for (next=image; next; next=next->next)
14659 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
14660 next->scene=scene++;
14662 *package_info->image_info->magick='\0';
14663 SetImageInfo(package_info->image_info,(unsigned int)
14664 GetImageListLength(image),exception);
14665 for (next=image; next; next=next->next)
14667 (void) WriteImage(package_info->image_info,next,exception);
14669 if (package_info->image_info->adjoin)
14674 if (package_info != (struct PackageInfo *) NULL)
14675 DestroyPackageInfo(package_info);
14676 InheritPerlException(exception,perl_exception);
14677 exception=DestroyExceptionInfo(exception);
14678 sv_setiv(perl_exception,(IV) number_images);
14679 SvPOK_on(perl_exception);
14680 ST(0)=sv_2mortal(perl_exception);