2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11 % M M AAA GGGG IIIII CCCC K K %
12 % MM MM A A G I C K K %
13 % M M M AAAAA G GGG I C KKK %
14 % M M A A G G I C K K %
15 % M M A A GGGG IIIII CCCC K K %
18 % Object-oriented Perl interface to ImageMagick %
26 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
27 % dedicated to making software imaging solutions freely available. %
29 % You may not use this file except in compliance with the License. You may %
30 % obtain a copy of the License at %
32 % http://www.imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MagickPI 3.14159265358979323846264338327950288419716939937510
78 #define MaxArguments 33
82 #define NumberOf(array) (sizeof(array)/sizeof(*array))
83 #define PackageName "Image::Magick"
86 #define PerlIO_importFILE(f, fl) (f)
87 #define PerlIO_findFILE(f) NULL
90 #define sv_undef PL_sv_undef
93 #define AddImageToRegistry(sv,image) \
95 if (magick_registry != (SplayTreeInfo *) NULL) \
97 (void) AddValueToSplayTree(magick_registry,image,image); \
98 (sv)=newSViv(PTR2IV(image)); \
102 #define DeleteImageFromRegistry(reference,image) \
104 if (magick_registry != (SplayTreeInfo *) NULL) \
106 if (GetImageReferenceCount(image) == 1) \
107 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
108 image=DestroyImage(image); \
109 sv_setiv(reference,0); \
113 #define InheritPerlException(exception,perl_exception) \
116 message[MaxTextExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
121 (exception)->severity, (exception)->reason ? \
122 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
123 "Unknown", (exception)->description ? " (" : "", \
124 (exception)->description ? GetLocaleExceptionMessage( \
125 (exception)->severity,(exception)->description) : "", \
126 (exception)->description ? ")" : ""); \
127 if ((perl_exception) != (SV *) NULL) \
129 if (SvCUR(perl_exception)) \
130 sv_catpv(perl_exception,"\n"); \
131 sv_catpv(perl_exception,message); \
136 #define ThrowPerlException(exception,severity,tag,reason) \
137 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
138 tag,"`%s'",reason); \
141 Typedef and structure declarations.
145 ArrayReference = (~0),
146 RealReference = (~0)-1,
147 FileReference = (~0)-2,
148 ImageReference = (~0)-3,
149 IntegerReference = (~0)-4,
150 StringReference = (~0)-5
153 typedef struct _Arguments
193 *Image__Magick; /* data type for the Image::Magick package */
205 arguments[MaxArguments];
208 { "Comment", { {"comment", StringReference} } },
209 { "Label", { {"label", StringReference} } },
210 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
211 {"channel", MagickChannelOptions} } },
212 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
213 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
214 {"height", IntegerReference}, {"fill", StringReference},
215 {"bordercolor", StringReference}, {"color", StringReference},
216 {"compose", MagickComposeOptions} } },
217 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
218 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
219 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
220 {"height", IntegerReference}, {"x", IntegerReference},
221 {"y", IntegerReference} } },
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} } },
553 *magick_registry = (SplayTreeInfo *) NULL;
556 Forward declarations.
559 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
562 strEQcase(const char *,const char *);
565 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569 % C l o n e P a c k a g e I n f o %
573 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
575 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
578 % The format of the ClonePackageInfo routine is:
580 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
583 % A description of each parameter follows:
585 % o info: a structure of type info.
587 % o exception: Return any errors or warnings in this structure.
590 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
591 ExceptionInfo *exception)
596 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
597 if (clone_info == (struct PackageInfo *) NULL)
599 ThrowPerlException(exception,ResourceLimitError,
600 "UnableToClonePackageInfo",PackageName);
601 return((struct PackageInfo *) NULL);
603 if (info == (struct PackageInfo *) NULL)
605 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
609 clone_info->image_info=CloneImageInfo(info->image_info);
614 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
622 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
624 % constant() returns a double value for the specified name.
626 % The format of the constant routine is:
628 % double constant(char *name,ssize_t sans)
630 % A description of each parameter follows:
632 % o value: Method constant returns a double value for the specified name.
634 % o name: The name of the constant.
636 % o sans: This integer value is not used.
639 static double constant(char *name,ssize_t sans)
647 if (strEQ(name,"BlobError"))
649 if (strEQ(name,"BlobWarning"))
655 if (strEQ(name,"CacheError"))
657 if (strEQ(name,"CacheWarning"))
658 return(CacheWarning);
659 if (strEQ(name,"CoderError"))
661 if (strEQ(name,"CoderWarning"))
662 return(CoderWarning);
663 if (strEQ(name,"ConfigureError"))
664 return(ConfigureError);
665 if (strEQ(name,"ConfigureWarning"))
666 return(ConfigureWarning);
667 if (strEQ(name,"CorruptImageError"))
668 return(CorruptImageError);
669 if (strEQ(name,"CorruptImageWarning"))
670 return(CorruptImageWarning);
675 if (strEQ(name,"DelegateError"))
676 return(DelegateError);
677 if (strEQ(name,"DelegateWarning"))
678 return(DelegateWarning);
679 if (strEQ(name,"DrawError"))
681 if (strEQ(name,"DrawWarning"))
687 if (strEQ(name,"ErrorException"))
688 return(ErrorException);
689 if (strEQ(name,"ExceptionError"))
691 if (strEQ(name,"ExceptionWarning"))
692 return(CoderWarning);
697 if (strEQ(name,"FatalErrorException"))
698 return(FatalErrorException);
699 if (strEQ(name,"FileOpenError"))
700 return(FileOpenError);
701 if (strEQ(name,"FileOpenWarning"))
702 return(FileOpenWarning);
707 if (strEQ(name,"ImageError"))
709 if (strEQ(name,"ImageWarning"))
710 return(ImageWarning);
715 if (strEQ(name,"MaxRGB"))
716 return(QuantumRange);
717 if (strEQ(name,"MissingDelegateError"))
718 return(MissingDelegateError);
719 if (strEQ(name,"MissingDelegateWarning"))
720 return(MissingDelegateWarning);
721 if (strEQ(name,"ModuleError"))
723 if (strEQ(name,"ModuleWarning"))
724 return(ModuleWarning);
729 if (strEQ(name,"Opaque"))
731 if (strEQ(name,"OptionError"))
733 if (strEQ(name,"OptionWarning"))
734 return(OptionWarning);
739 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
740 return(MAGICKCORE_QUANTUM_DEPTH);
741 if (strEQ(name,"QuantumDepth"))
742 return(MAGICKCORE_QUANTUM_DEPTH);
743 if (strEQ(name,"QuantumRange"))
744 return(QuantumRange);
749 if (strEQ(name,"ResourceLimitError"))
750 return(ResourceLimitError);
751 if (strEQ(name,"ResourceLimitWarning"))
752 return(ResourceLimitWarning);
753 if (strEQ(name,"RegistryError"))
754 return(RegistryError);
755 if (strEQ(name,"RegistryWarning"))
756 return(RegistryWarning);
761 if (strEQ(name,"StreamError"))
763 if (strEQ(name,"StreamWarning"))
764 return(StreamWarning);
765 if (strEQ(name,"Success"))
771 if (strEQ(name,"Transparent"))
772 return(TransparentAlpha);
773 if (strEQ(name,"TypeError"))
775 if (strEQ(name,"TypeWarning"))
781 if (strEQ(name,"WarningException"))
782 return(WarningException);
787 if (strEQ(name,"XServerError"))
788 return(XServerError);
789 if (strEQ(name,"XServerWarning"))
790 return(XServerWarning);
799 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % D e s t r o y P a c k a g e I n f o %
807 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
809 % Method DestroyPackageInfo frees a previously created info structure.
811 % The format of the DestroyPackageInfo routine is:
813 % DestroyPackageInfo(struct PackageInfo *info)
815 % A description of each parameter follows:
817 % o info: a structure of type info.
820 static void DestroyPackageInfo(struct PackageInfo *info)
822 info->image_info=DestroyImageInfo(info->image_info);
823 info=(struct PackageInfo *) RelinquishMagickMemory(info);
827 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
835 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
837 % Method GetList is recursively called by SetupList to traverse the
838 % Image__Magick reference. If building an reference_vector (see SetupList),
839 % *current is the current position in *reference_vector and *last is the final
840 % entry in *reference_vector.
842 % The format of the GetList routine is:
846 % A description of each parameter follows:
848 % o info: a structure of type info.
851 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
852 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
857 if (reference == (SV *) NULL)
859 switch (SvTYPE(reference))
879 previous=(Image *) NULL;
883 for (i=0; i <= n; i++)
889 if (rv && *rv && sv_isobject(*rv))
891 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
893 if (image == (Image *) NULL)
895 if (image == previous)
897 image=CloneImage(image,0,0,MagickTrue,exception);
898 if (image == (Image *) NULL)
901 image->previous=previous;
902 *(previous ? &previous->next : &head)=image;
903 for (previous=image; previous->next; previous=previous->next) ;
911 Blessed scalar, one image.
913 image=INT2PTR(Image *,SvIV(reference));
914 if (image == (Image *) NULL)
916 image->previous=(Image *) NULL;
917 image->next=(Image *) NULL;
918 if (reference_vector)
920 if (*current == *last)
923 if (*reference_vector == (SV **) NULL)
924 *reference_vector=(SV **) AcquireQuantumMemory(*last,
925 sizeof(*reference_vector));
927 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
928 *last,sizeof(*reference_vector));
930 if (*reference_vector == (SV **) NULL)
932 ThrowPerlException(exception,ResourceLimitError,
933 "MemoryAllocationFailed",PackageName);
934 return((Image *) NULL);
936 (*reference_vector)[*current]=reference;
937 (*reference_vector)[++(*current)]=NULL;
944 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
945 (double) SvTYPE(reference));
946 return((Image *) NULL);
950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954 % G e t P a c k a g e I n f o %
958 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
960 % Method GetPackageInfo looks up or creates an info structure for the given
961 % Image__Magick reference. If it does create a new one, the information in
962 % package_info is used to initialize it.
964 % The format of the GetPackageInfo routine is:
966 % struct PackageInfo *GetPackageInfo(void *reference,
967 % struct PackageInfo *package_info,ExceptionInfo *exception)
969 % A description of each parameter follows:
971 % o info: a structure of type info.
973 % o exception: Return any errors or warnings in this structure.
976 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
977 struct PackageInfo *package_info,ExceptionInfo *exception)
980 message[MaxTextExtent];
988 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
989 PackageName,XS_VERSION,reference);
990 sv=perl_get_sv(message,(TRUE | 0x02));
991 if (sv == (SV *) NULL)
993 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
995 return(package_info);
997 if (SvREFCNT(sv) == 0)
998 (void) SvREFCNT_inc(sv);
999 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1001 clone_info=ClonePackageInfo(package_info,exception);
1002 sv_setiv(sv,PTR2IV(clone_info));
1007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1011 % S e t A t t r i b u t e %
1015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1017 % SetAttribute() sets the attribute to the value in sval. This can change
1018 % either or both of image or info.
1020 % The format of the SetAttribute routine is:
1022 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1023 % SV *sval,ExceptionInfo *exception)
1025 % A description of each parameter follows:
1027 % o list: a list of strings.
1029 % o string: a character string.
1033 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1041 value=InterpretSiPrefixValue(string,&q);
1043 value*=interval/100.0;
1047 static inline double StringToDouble(const char *string,char **sentinal)
1049 return(InterpretLocaleValue(string,sentinal));
1052 static double StringToDoubleInterval(const char *string,const double interval)
1060 value=InterpretLocaleValue(string,&q);
1062 value*=interval/100.0;
1066 static inline ssize_t StringToLong(const char *value)
1068 return(strtol(value,(char **) NULL,10));
1071 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1072 const char *attribute,SV *sval,ExceptionInfo *exception)
1099 if (LocaleCompare(attribute,"adjoin") == 0)
1101 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1102 SvPV(sval,na)) : SvIV(sval);
1105 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1110 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1113 if (LocaleCompare(attribute,"alpha") == 0)
1115 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1116 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1119 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1123 for ( ; image; image=image->next)
1124 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1128 if (LocaleCompare(attribute,"antialias") == 0)
1130 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1131 SvPV(sval,na)) : SvIV(sval);
1134 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1139 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1142 if (LocaleCompare(attribute,"area-limit") == 0)
1147 limit=MagickResourceInfinity;
1148 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1149 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1151 (void) SetMagickResourceLimit(AreaResource,limit);
1154 if (LocaleCompare(attribute,"attenuate") == 0)
1157 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1160 if (LocaleCompare(attribute,"authenticate") == 0)
1163 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1167 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1168 for ( ; image; image=image->next)
1169 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1175 if (LocaleCompare(attribute,"background") == 0)
1177 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1180 info->image_info->background_color=target_color;
1181 for ( ; image; image=image->next)
1182 image->background_color=target_color;
1185 if (LocaleCompare(attribute,"blue-primary") == 0)
1187 for ( ; image; image=image->next)
1189 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1190 image->chromaticity.blue_primary.x=geometry_info.rho;
1191 image->chromaticity.blue_primary.y=geometry_info.sigma;
1192 if ((flags & SigmaValue) == 0)
1193 image->chromaticity.blue_primary.y=
1194 image->chromaticity.blue_primary.x;
1198 if (LocaleCompare(attribute,"bordercolor") == 0)
1200 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1203 info->image_info->border_color=target_color;
1204 for ( ; image; image=image->next)
1205 image->border_color=target_color;
1209 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1210 for ( ; image; image=image->next)
1211 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1217 if (LocaleCompare(attribute,"cache-threshold") == 0)
1219 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1220 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1221 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1222 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1225 if (LocaleCompare(attribute,"clip-mask") == 0)
1230 clip_mask=(Image *) NULL;
1232 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1233 for ( ; image; image=image->next)
1234 SetImageMask(image,clip_mask,exception);
1237 if (LocaleNCompare(attribute,"colormap",8) == 0)
1239 for ( ; image; image=image->next)
1247 if (image->storage_class == DirectClass)
1250 items=sscanf(attribute,"%*[^[][%ld",&i);
1252 if (i > (ssize_t) image->colors)
1254 if ((strchr(SvPV(sval,na),',') == 0) ||
1255 (strchr(SvPV(sval,na),')') != 0))
1256 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1257 image->colormap+i,exception);
1260 color=image->colormap+i;
1261 pixel.red=color->red;
1262 pixel.green=color->green;
1263 pixel.blue=color->blue;
1264 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1265 pixel.red=geometry_info.rho;
1266 pixel.green=geometry_info.sigma;
1267 pixel.blue=geometry_info.xi;
1268 color->red=ClampToQuantum(pixel.red);
1269 color->green=ClampToQuantum(pixel.green);
1270 color->blue=ClampToQuantum(pixel.blue);
1275 if (LocaleCompare(attribute,"colorspace") == 0)
1277 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1278 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1281 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1285 for ( ; image; image=image->next)
1286 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1290 if (LocaleCompare(attribute,"comment") == 0)
1292 for ( ; image; image=image->next)
1293 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1294 info ? info->image_info : (ImageInfo *) NULL,image,
1295 SvPV(sval,na),exception),exception);
1298 if (LocaleCompare(attribute,"compression") == 0)
1300 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1301 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1304 ThrowPerlException(exception,OptionError,
1305 "UnrecognizedImageCompression",SvPV(sval,na));
1309 info->image_info->compression=(CompressionType) sp;
1310 for ( ; image; image=image->next)
1311 image->compression=(CompressionType) sp;
1315 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1316 for ( ; image; image=image->next)
1317 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1323 if (LocaleCompare(attribute,"debug") == 0)
1325 SetLogEventMask(SvPV(sval,na));
1328 if (LocaleCompare(attribute,"delay") == 0)
1330 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1331 for ( ; image; image=image->next)
1333 image->delay=(size_t) floor(geometry_info.rho+0.5);
1334 if ((flags & SigmaValue) != 0)
1335 image->ticks_per_second=(ssize_t)
1336 floor(geometry_info.sigma+0.5);
1340 if (LocaleCompare(attribute,"disk-limit") == 0)
1345 limit=MagickResourceInfinity;
1346 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1347 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1349 (void) SetMagickResourceLimit(DiskResource,limit);
1352 if (LocaleCompare(attribute,"density") == 0)
1354 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1356 ThrowPerlException(exception,OptionError,"MissingGeometry",
1361 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1362 for ( ; image; image=image->next)
1364 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1365 image->resolution.x=geometry_info.rho;
1366 image->resolution.y=geometry_info.sigma;
1367 if ((flags & SigmaValue) == 0)
1368 image->resolution.y=image->resolution.x;
1372 if (LocaleCompare(attribute,"depth") == 0)
1375 info->image_info->depth=SvIV(sval);
1376 for ( ; image; image=image->next)
1377 (void) SetImageDepth(image,SvIV(sval),exception);
1380 if (LocaleCompare(attribute,"dispose") == 0)
1382 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1383 SvPV(sval,na)) : SvIV(sval);
1386 ThrowPerlException(exception,OptionError,
1387 "UnrecognizedDisposeMethod",SvPV(sval,na));
1390 for ( ; image; image=image->next)
1391 image->dispose=(DisposeType) sp;
1394 if (LocaleCompare(attribute,"dither") == 0)
1398 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1399 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1402 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1406 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1410 if (LocaleCompare(attribute,"display") == 0)
1414 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1418 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1419 for ( ; image; image=image->next)
1420 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1426 if (LocaleCompare(attribute,"endian") == 0)
1428 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1429 SvPV(sval,na)) : SvIV(sval);
1432 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1437 info->image_info->endian=(EndianType) sp;
1438 for ( ; image; image=image->next)
1439 image->endian=(EndianType) sp;
1442 if (LocaleCompare(attribute,"extract") == 0)
1445 Set image extract geometry.
1447 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1451 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1452 for ( ; image; image=image->next)
1453 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1459 if (LocaleCompare(attribute,"filename") == 0)
1462 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1464 for ( ; image; image=image->next)
1465 (void) CopyMagickString(image->filename,SvPV(sval,na),
1469 if (LocaleCompare(attribute,"file") == 0)
1477 if (info == (struct PackageInfo *) NULL)
1479 io_info=IoIFP(sv_2io(sval));
1480 if (io_info == (PerlIO *) NULL)
1482 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1486 file=PerlIO_findFILE(io_info);
1487 if (file == (FILE *) NULL)
1489 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1493 SetImageInfoFile(info->image_info,file);
1496 if (LocaleCompare(attribute,"fill") == 0)
1499 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1502 if (LocaleCompare(attribute,"font") == 0)
1505 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1508 if (LocaleCompare(attribute,"foreground") == 0)
1510 if (LocaleCompare(attribute,"fuzz") == 0)
1513 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1515 for ( ; image; image=image->next)
1516 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1521 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1522 for ( ; image; image=image->next)
1523 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1529 if (LocaleCompare(attribute,"gamma") == 0)
1531 for ( ; image; image=image->next)
1532 image->gamma=SvNV(sval);
1535 if (LocaleCompare(attribute,"gravity") == 0)
1537 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1538 SvPV(sval,na)) : SvIV(sval);
1541 ThrowPerlException(exception,OptionError,
1542 "UnrecognizedGravityType",SvPV(sval,na));
1546 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1547 for ( ; image; image=image->next)
1548 image->gravity=(GravityType) sp;
1551 if (LocaleCompare(attribute,"green-primary") == 0)
1553 for ( ; image; image=image->next)
1555 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1556 image->chromaticity.green_primary.x=geometry_info.rho;
1557 image->chromaticity.green_primary.y=geometry_info.sigma;
1558 if ((flags & SigmaValue) == 0)
1559 image->chromaticity.green_primary.y=
1560 image->chromaticity.green_primary.x;
1565 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1566 for ( ; image; image=image->next)
1567 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1573 if (LocaleNCompare(attribute,"index",5) == 0)
1587 for ( ; image; image=image->next)
1589 if (image->storage_class != PseudoClass)
1593 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1595 image_view=AcquireAuthenticCacheView(image,exception);
1596 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1597 if (q != (Quantum *) NULL)
1599 items=sscanf(SvPV(sval,na),"%ld",&index);
1600 if ((index >= 0) && (index < (ssize_t) image->colors))
1601 SetPixelIndex(image,index,q);
1602 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1604 image_view=DestroyCacheView(image_view);
1608 if (LocaleCompare(attribute,"iterations") == 0)
1611 for ( ; image; image=image->next)
1612 image->iterations=SvIV(sval);
1615 if (LocaleCompare(attribute,"interlace") == 0)
1617 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1618 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1621 ThrowPerlException(exception,OptionError,
1622 "UnrecognizedInterlaceType",SvPV(sval,na));
1626 info->image_info->interlace=(InterlaceType) sp;
1627 for ( ; image; image=image->next)
1628 image->interlace=(InterlaceType) sp;
1632 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1633 for ( ; image; image=image->next)
1634 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1640 if (LocaleCompare(attribute,"label") == 0)
1642 for ( ; image; image=image->next)
1643 (void) SetImageProperty(image,"label",InterpretImageProperties(
1644 info ? info->image_info : (ImageInfo *) NULL,image,
1645 SvPV(sval,na),exception),exception);
1648 if (LocaleCompare(attribute,"loop") == 0)
1651 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1652 for ( ; image; image=image->next)
1653 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1659 if (LocaleCompare(attribute,"magick") == 0)
1662 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1663 "%s:",SvPV(sval,na));
1664 for ( ; image; image=image->next)
1665 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1668 if (LocaleCompare(attribute,"map-limit") == 0)
1673 limit=MagickResourceInfinity;
1674 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1675 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1677 (void) SetMagickResourceLimit(MapResource,limit);
1680 if (LocaleCompare(attribute,"mask") == 0)
1685 mask=(Image *) NULL;
1687 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1688 for ( ; image; image=image->next)
1689 SetImageMask(image,mask,exception);
1692 if (LocaleCompare(attribute,"mattecolor") == 0)
1694 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1697 info->image_info->matte_color=target_color;
1698 for ( ; image; image=image->next)
1699 image->matte_color=target_color;
1702 if (LocaleCompare(attribute,"matte") == 0)
1704 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1705 SvPV(sval,na)) : SvIV(sval);
1708 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1712 for ( ; image; image=image->next)
1713 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1716 if (LocaleCompare(attribute,"memory-limit") == 0)
1721 limit=MagickResourceInfinity;
1722 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1723 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1725 (void) SetMagickResourceLimit(MemoryResource,limit);
1728 if (LocaleCompare(attribute,"monochrome") == 0)
1730 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1731 SvPV(sval,na)) : SvIV(sval);
1734 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1739 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1740 for ( ; image; image=image->next)
1741 (void) SetImageType(image,BilevelType,exception);
1745 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1746 for ( ; image; image=image->next)
1747 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1753 if (LocaleCompare(attribute,"option") == 0)
1756 DefineImageOption(info->image_info,SvPV(sval,na));
1759 if (LocaleCompare(attribute,"orientation") == 0)
1761 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1762 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1765 ThrowPerlException(exception,OptionError,
1766 "UnrecognizedOrientationType",SvPV(sval,na));
1770 info->image_info->orientation=(OrientationType) sp;
1771 for ( ; image; image=image->next)
1772 image->orientation=(OrientationType) sp;
1776 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1777 for ( ; image; image=image->next)
1778 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1784 if (LocaleCompare(attribute,"page") == 0)
1789 geometry=GetPageGeometry(SvPV(sval,na));
1791 (void) CloneString(&info->image_info->page,geometry);
1792 for ( ; image; image=image->next)
1793 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1794 geometry=(char *) RelinquishMagickMemory(geometry);
1797 if (LocaleNCompare(attribute,"pixel",5) == 0)
1811 for ( ; image; image=image->next)
1813 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1817 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1819 image_view=AcquireVirtualCacheView(image,exception);
1820 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1821 if (q != (Quantum *) NULL)
1823 if ((strchr(SvPV(sval,na),',') == 0) ||
1824 (strchr(SvPV(sval,na),')') != 0))
1825 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1829 GetPixelInfo(image,&pixel);
1830 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1831 pixel.red=geometry_info.rho;
1832 if ((flags & SigmaValue) != 0)
1833 pixel.green=geometry_info.sigma;
1834 if ((flags & XiValue) != 0)
1835 pixel.blue=geometry_info.xi;
1836 if ((flags & PsiValue) != 0)
1837 pixel.alpha=geometry_info.psi;
1838 if ((flags & ChiValue) != 0)
1839 pixel.black=geometry_info.chi;
1841 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1842 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1843 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1844 if (image->colorspace == CMYKColorspace)
1845 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1846 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1847 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1849 image_view=DestroyCacheView(image_view);
1853 if (LocaleCompare(attribute,"pointsize") == 0)
1857 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1858 info->image_info->pointsize=geometry_info.rho;
1862 if (LocaleCompare(attribute,"preview") == 0)
1864 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1865 SvPV(sval,na)) : SvIV(sval);
1868 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1873 info->image_info->preview_type=(PreviewType) sp;
1877 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1878 for ( ; image; image=image->next)
1879 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1885 if (LocaleCompare(attribute,"quality") == 0)
1888 info->image_info->quality=SvIV(sval);
1889 for ( ; image; image=image->next)
1890 image->quality=SvIV(sval);
1894 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1895 for ( ; image; image=image->next)
1896 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1902 if (LocaleCompare(attribute,"red-primary") == 0)
1904 for ( ; image; image=image->next)
1906 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1907 image->chromaticity.red_primary.x=geometry_info.rho;
1908 image->chromaticity.red_primary.y=geometry_info.sigma;
1909 if ((flags & SigmaValue) == 0)
1910 image->chromaticity.red_primary.y=
1911 image->chromaticity.red_primary.x;
1915 if (LocaleCompare(attribute,"render") == 0)
1917 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1918 SvPV(sval,na)) : SvIV(sval);
1921 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1925 for ( ; image; image=image->next)
1926 image->rendering_intent=(RenderingIntent) sp;
1929 if (LocaleCompare(attribute,"repage") == 0)
1934 for ( ; image; image=image->next)
1936 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1937 if ((flags & WidthValue) != 0)
1939 if ((flags & HeightValue) == 0)
1940 geometry.height=geometry.width;
1941 image->page.width=geometry.width;
1942 image->page.height=geometry.height;
1944 if ((flags & AspectValue) != 0)
1946 if ((flags & XValue) != 0)
1947 image->page.x+=geometry.x;
1948 if ((flags & YValue) != 0)
1949 image->page.y+=geometry.y;
1953 if ((flags & XValue) != 0)
1955 image->page.x=geometry.x;
1956 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1957 image->page.width=image->columns+geometry.x;
1959 if ((flags & YValue) != 0)
1961 image->page.y=geometry.y;
1962 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1963 image->page.height=image->rows+geometry.y;
1970 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1971 for ( ; image; image=image->next)
1972 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1978 if (LocaleCompare(attribute,"sampling-factor") == 0)
1980 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1982 ThrowPerlException(exception,OptionError,"MissingGeometry",
1987 (void) CloneString(&info->image_info->sampling_factor,
1991 if (LocaleCompare(attribute,"scene") == 0)
1993 for ( ; image; image=image->next)
1994 image->scene=SvIV(sval);
1997 if (LocaleCompare(attribute,"server") == 0)
1999 if (LocaleCompare(attribute,"size") == 0)
2003 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2005 ThrowPerlException(exception,OptionError,"MissingGeometry",
2009 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2013 if (LocaleCompare(attribute,"stroke") == 0)
2016 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2020 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2021 for ( ; image; image=image->next)
2022 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2028 if (LocaleCompare(attribute,"texture") == 0)
2031 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2034 if (LocaleCompare(attribute,"thread-limit") == 0)
2039 limit=MagickResourceInfinity;
2040 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2041 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2043 (void) SetMagickResourceLimit(ThreadResource,limit);
2046 if (LocaleCompare(attribute,"tile-offset") == 0)
2051 geometry=GetPageGeometry(SvPV(sval,na));
2053 (void) CloneString(&info->image_info->page,geometry);
2054 for ( ; image; image=image->next)
2055 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2057 geometry=(char *) RelinquishMagickMemory(geometry);
2060 if (LocaleCompare(attribute,"time-limit") == 0)
2065 limit=MagickResourceInfinity;
2066 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2067 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2069 (void) SetMagickResourceLimit(TimeResource,limit);
2072 if (LocaleCompare(attribute,"transparent-color") == 0)
2074 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2077 info->image_info->transparent_color=target_color;
2078 for ( ; image; image=image->next)
2079 image->transparent_color=target_color;
2082 if (LocaleCompare(attribute,"type") == 0)
2084 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2085 SvPV(sval,na)) : SvIV(sval);
2088 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2093 info->image_info->type=(ImageType) sp;
2094 for ( ; image; image=image->next)
2095 SetImageType(image,(ImageType) sp,exception);
2099 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2100 for ( ; image; image=image->next)
2101 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2107 if (LocaleCompare(attribute,"units") == 0)
2109 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2110 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2113 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2118 info->image_info->units=(ResolutionType) sp;
2119 for ( ; image; image=image->next)
2124 units=(ResolutionType) sp;
2125 if (image->units != units)
2126 switch (image->units)
2128 case UndefinedResolution:
2129 case PixelsPerInchResolution:
2131 if (units == PixelsPerCentimeterResolution)
2133 image->resolution.x*=2.54;
2134 image->resolution.y*=2.54;
2138 case PixelsPerCentimeterResolution:
2140 if (units == PixelsPerInchResolution)
2142 image->resolution.x/=2.54;
2143 image->resolution.y/=2.54;
2153 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2154 for ( ; image; image=image->next)
2155 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2161 if (LocaleCompare(attribute,"verbose") == 0)
2163 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2164 SvPV(sval,na)) : SvIV(sval);
2167 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2172 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2175 if (LocaleCompare(attribute,"view") == 0)
2178 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2181 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2183 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2184 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2187 ThrowPerlException(exception,OptionError,
2188 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2191 for ( ; image; image=image->next)
2192 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2196 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2197 for ( ; image; image=image->next)
2198 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2204 if (LocaleCompare(attribute,"white-point") == 0)
2206 for ( ; image; image=image->next)
2208 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2209 image->chromaticity.white_point.x=geometry_info.rho;
2210 image->chromaticity.white_point.y=geometry_info.sigma;
2211 if ((flags & SigmaValue) == 0)
2212 image->chromaticity.white_point.y=
2213 image->chromaticity.white_point.x;
2218 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2219 for ( ; image; image=image->next)
2220 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2226 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2227 for ( ; image; image=image->next)
2228 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2239 % S e t u p L i s t %
2243 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2245 % Method SetupList returns the list of all the images linked by their
2246 % image->next and image->previous link lists for use with ImageMagick. If
2247 % info is non-NULL, an info structure is returned in *info. If
2248 % reference_vector is non-NULL,an array of SV* are returned in
2249 % *reference_vector. Reference_vector is used when the images are going to be
2250 % replaced with new Image*'s.
2252 % The format of the SetupList routine is:
2254 % Image *SetupList(SV *reference,struct PackageInfo **info,
2255 % SV ***reference_vector,ExceptionInfo *exception)
2257 % A description of each parameter follows:
2259 % o list: a list of strings.
2261 % o string: a character string.
2263 % o exception: Return any errors or warnings in this structure.
2266 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2267 SV ***reference_vector,ExceptionInfo *exception)
2276 if (reference_vector)
2277 *reference_vector=NULL;
2282 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2283 if (info && (SvTYPE(reference) == SVt_PVAV))
2284 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2290 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2294 % s t r E Q c a s e %
2298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2300 % strEQcase() compares two strings and returns 0 if they are the
2301 % same or if the second string runs out first. The comparison is case
2304 % The format of the strEQcase routine is:
2306 % ssize_t strEQcase(const char *p,const char *q)
2308 % A description of each parameter follows:
2310 % o p: a character string.
2312 % o q: a character string.
2316 static ssize_t strEQcase(const char *p,const char *q)
2324 for (i=0 ; (c=(*q)) != 0; i++)
2326 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2327 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2332 return(((*q == 0) && (*p == 0)) ? i : 0);
2336 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2340 % I m a g e : : M a g i c k %
2344 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2348 MODULE = Image::Magick PACKAGE = Image::Magick
2353 MagickCoreGenesis("PerlMagick",MagickFalse);
2354 SetWarningHandler(NULL);
2355 SetErrorHandler(NULL);
2356 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2357 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2363 if (magick_registry != (SplayTreeInfo *) NULL)
2364 magick_registry=DestroySplayTree(magick_registry);
2365 MagickCoreTerminus();
2369 constant(name,argument)
2374 ###############################################################################
2382 ###############################################################################
2387 Image::Magick ref=NO_INIT
2411 PERL_UNUSED_VAR(ref);
2412 PERL_UNUSED_VAR(ix);
2413 exception=AcquireExceptionInfo();
2414 perl_exception=newSVpv("",0);
2415 package_info=(struct PackageInfo *) NULL;
2416 if (sv_isobject(ST(0)) == 0)
2418 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2422 reference=SvRV(ST(0));
2423 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2424 if (image == (Image *) NULL)
2426 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2430 package_info=ClonePackageInfo(info,exception);
2432 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2435 for (i=2; i < items; i+=2)
2436 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2438 (void) AnimateImages(package_info->image_info,image,exception);
2439 (void) CatchImageException(image);
2442 if (package_info != (struct PackageInfo *) NULL)
2443 DestroyPackageInfo(package_info);
2444 InheritPerlException(exception,perl_exception);
2445 exception=DestroyExceptionInfo(exception);
2446 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2447 SvPOK_on(perl_exception);
2448 ST(0)=sv_2mortal(perl_exception);
2453 ###############################################################################
2461 ###############################################################################
2466 Image::Magick ref=NO_INIT
2504 PERL_UNUSED_VAR(ref);
2505 PERL_UNUSED_VAR(ix);
2506 exception=AcquireExceptionInfo();
2507 perl_exception=newSVpv("",0);
2511 if (sv_isobject(ST(0)) == 0)
2513 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2517 reference=SvRV(ST(0));
2518 hv=SvSTASH(reference);
2520 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2522 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2523 if (image == (Image *) NULL)
2525 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2529 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2534 for (i=2; i < items; i+=2)
2536 attribute=(char *) SvPV(ST(i-1),na);
2542 if (LocaleCompare(attribute,"stack") == 0)
2544 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2548 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2554 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2560 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2566 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2567 if (image == (Image *) NULL)
2569 for ( ; image; image=image->next)
2571 AddImageToRegistry(sv,image);
2573 av_push(av,sv_bless(rv,hv));
2576 exception=DestroyExceptionInfo(exception);
2578 SvREFCNT_dec(perl_exception);
2582 InheritPerlException(exception,perl_exception);
2583 exception=DestroyExceptionInfo(exception);
2584 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2585 SvPOK_on(perl_exception);
2586 ST(0)=sv_2mortal(perl_exception);
2591 ###############################################################################
2599 ###############################################################################
2604 Image::Magick ref=NO_INIT
2635 PERL_UNUSED_VAR(ref);
2636 PERL_UNUSED_VAR(ix);
2637 exception=AcquireExceptionInfo();
2638 perl_exception=newSVpv("",0);
2640 if (sv_isobject(ST(0)) == 0)
2642 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2646 reference=SvRV(ST(0));
2647 hv=SvSTASH(reference);
2648 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2649 if (image == (Image *) NULL)
2651 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2655 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2656 if (image == (Image *) NULL)
2659 Create blessed Perl array for the returned image.
2662 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2664 AddImageToRegistry(sv,image);
2666 av_push(av,sv_bless(rv,hv));
2668 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2669 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2670 "average-%.*s",(int) (MaxTextExtent-9),
2671 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2672 (void) CopyMagickString(image->filename,info->image_info->filename,
2674 SetImageInfo(info->image_info,0,exception);
2675 exception=DestroyExceptionInfo(exception);
2676 SvREFCNT_dec(perl_exception);
2680 InheritPerlException(exception,perl_exception);
2681 exception=DestroyExceptionInfo(exception);
2682 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2683 SvPOK_on(perl_exception);
2684 ST(0)=sv_2mortal(perl_exception);
2689 ###############################################################################
2693 # B l o b T o I m a g e #
2697 ###############################################################################
2701 BlobToImage(ref,...)
2702 Image::Magick ref=NO_INIT
2748 PERL_UNUSED_VAR(ref);
2749 PERL_UNUSED_VAR(ix);
2750 exception=AcquireExceptionInfo();
2751 perl_exception=newSVpv("",0);
2754 ac=(items < 2) ? 1 : items-1;
2755 length=(STRLEN *) NULL;
2756 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2757 if (list == (char **) NULL)
2759 ThrowPerlException(exception,ResourceLimitError,
2760 "MemoryAllocationFailed",PackageName);
2763 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2764 if (length == (STRLEN *) NULL)
2766 ThrowPerlException(exception,ResourceLimitError,
2767 "MemoryAllocationFailed",PackageName);
2770 if (sv_isobject(ST(0)) == 0)
2772 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2776 reference=SvRV(ST(0));
2777 hv=SvSTASH(reference);
2778 if (SvTYPE(reference) != SVt_PVAV)
2780 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2784 av=(AV *) reference;
2785 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2790 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2793 for (n=0, i=0; i < ac; i++)
2795 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2796 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2798 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2803 list[n]=(char *) NULL;
2805 for (i=number_images=0; i < n; i++)
2807 image=BlobToImage(info->image_info,list[i],length[i],exception);
2808 if (image == (Image *) NULL)
2810 for ( ; image; image=image->next)
2812 AddImageToRegistry(sv,image);
2814 av_push(av,sv_bless(rv,hv));
2822 for (i=0; i < n; i++)
2823 if (list[i] != (char *) NULL)
2824 for (p=keep; list[i] != *p++; )
2825 if (*p == (char *) NULL)
2827 list[i]=(char *) RelinquishMagickMemory(list[i]);
2833 list=(char **) RelinquishMagickMemory(list);
2835 length=(STRLEN *) RelinquishMagickMemory(length);
2836 InheritPerlException(exception,perl_exception);
2837 exception=DestroyExceptionInfo(exception);
2838 sv_setiv(perl_exception,(IV) number_images);
2839 SvPOK_on(perl_exception);
2840 ST(0)=sv_2mortal(perl_exception);
2845 ###############################################################################
2849 # C h a n n e l F x #
2853 ###############################################################################
2858 Image::Magick ref=NO_INIT
2870 expression[MaxTextExtent];
2898 PERL_UNUSED_VAR(ref);
2899 PERL_UNUSED_VAR(ix);
2900 exception=AcquireExceptionInfo();
2901 perl_exception=newSVpv("",0);
2905 if (sv_isobject(ST(0)) == 0)
2907 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2911 reference=SvRV(ST(0));
2912 hv=SvSTASH(reference);
2914 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2916 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2917 if (image == (Image *) NULL)
2919 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2923 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2927 channel=DefaultChannels;
2928 (void) CopyMagickString(expression,"u",MaxTextExtent);
2930 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
2932 for (i=2; i < items; i+=2)
2934 attribute=(char *) SvPV(ST(i-1),na);
2940 if (LocaleCompare(attribute,"channel") == 0)
2945 option=ParseChannelOption(SvPV(ST(i),na));
2948 ThrowPerlException(exception,OptionError,
2949 "UnrecognizedType",SvPV(ST(i),na));
2952 channel=(ChannelType) option;
2955 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2962 if (LocaleCompare(attribute,"expression") == 0)
2964 (void) CopyMagickString(expression,SvPV(ST(i),na),
2968 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2974 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2980 channel_mask=SetImageChannelMask(image,channel);
2981 image=ChannelFxImage(image,expression,exception);
2982 if (image != (Image *) NULL)
2983 (void) SetImageChannelMask(image,channel_mask);
2984 if (image == (Image *) NULL)
2986 for ( ; image; image=image->next)
2988 AddImageToRegistry(sv,image);
2990 av_push(av,sv_bless(rv,hv));
2993 exception=DestroyExceptionInfo(exception);
2995 SvREFCNT_dec(perl_exception); /* can't return warning messages */
2999 InheritPerlException(exception,perl_exception);
3000 exception=DestroyExceptionInfo(exception);
3001 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3002 SvPOK_on(perl_exception);
3003 ST(0)=sv_2mortal(perl_exception);
3008 ###############################################################################
3016 ###############################################################################
3021 Image::Magick ref=NO_INIT
3054 PERL_UNUSED_VAR(ref);
3055 PERL_UNUSED_VAR(ix);
3056 exception=AcquireExceptionInfo();
3057 perl_exception=newSVpv("",0);
3059 if (sv_isobject(ST(0)) == 0)
3061 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3065 reference=SvRV(ST(0));
3066 hv=SvSTASH(reference);
3067 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3068 if (image == (Image *) NULL)
3070 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3075 Create blessed Perl array for the returned image.
3078 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3080 for ( ; image; image=image->next)
3082 clone=CloneImage(image,0,0,MagickTrue,exception);
3083 if (clone == (Image *) NULL)
3085 AddImageToRegistry(sv,clone);
3087 av_push(av,sv_bless(rv,hv));
3090 exception=DestroyExceptionInfo(exception);
3091 SvREFCNT_dec(perl_exception);
3095 InheritPerlException(exception,perl_exception);
3096 exception=DestroyExceptionInfo(exception);
3097 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3098 SvPOK_on(perl_exception);
3099 ST(0)=sv_2mortal(perl_exception);
3104 ###############################################################################
3112 ###############################################################################
3120 PERL_UNUSED_VAR(ref);
3121 if (magick_registry != (SplayTreeInfo *) NULL)
3126 ResetSplayTreeIterator(magick_registry);
3127 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3128 while (p != (Image *) NULL)
3131 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3137 ###############################################################################
3145 ###############################################################################
3150 Image::Magick ref=NO_INIT
3179 PERL_UNUSED_VAR(ref);
3180 PERL_UNUSED_VAR(ix);
3181 exception=AcquireExceptionInfo();
3182 perl_exception=newSVpv("",0);
3184 if (sv_isobject(ST(0)) == 0)
3186 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3190 reference=SvRV(ST(0));
3191 hv=SvSTASH(reference);
3193 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3195 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3196 if (image == (Image *) NULL)
3198 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3202 image=CoalesceImages(image,exception);
3203 if (image == (Image *) NULL)
3205 for ( ; image; image=image->next)
3207 AddImageToRegistry(sv,image);
3209 av_push(av,sv_bless(rv,hv));
3212 exception=DestroyExceptionInfo(exception);
3214 SvREFCNT_dec(perl_exception);
3218 InheritPerlException(exception,perl_exception);
3219 exception=DestroyExceptionInfo(exception);
3220 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3221 SvPOK_on(perl_exception);
3222 ST(0)=sv_2mortal(perl_exception);
3227 ###############################################################################
3235 ###############################################################################
3240 Image::Magick ref=NO_INIT
3286 PERL_UNUSED_VAR(ref);
3287 PERL_UNUSED_VAR(ix);
3288 exception=AcquireExceptionInfo();
3289 perl_exception=newSVpv("",0);
3293 if (sv_isobject(ST(0)) == 0)
3295 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3299 reference=SvRV(ST(0));
3300 hv=SvSTASH(reference);
3302 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3304 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3305 if (image == (Image *) NULL)
3307 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3311 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3315 reconstruct_image=image;
3316 metric=RootMeanSquaredErrorMetric;
3317 for (i=2; i < items; i+=2)
3319 attribute=(char *) SvPV(ST(i-1),na);
3325 if (LocaleCompare(attribute,"channel") == 0)
3330 option=ParseChannelOption(SvPV(ST(i),na));
3333 ThrowPerlException(exception,OptionError,
3334 "UnrecognizedType",SvPV(ST(i),na));
3337 SetPixelChannelMask(image,(ChannelType) option);
3340 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3347 if (LocaleCompare(attribute,"fuzz") == 0)
3349 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3352 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3359 if (LocaleCompare(attribute,"image") == 0)
3361 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3362 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3365 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3372 if (LocaleCompare(attribute,"metric") == 0)
3374 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3378 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3382 metric=(MetricType) option;
3385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3391 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3397 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3399 if (difference_image != (Image *) NULL)
3401 difference_image->error.mean_error_per_pixel=distortion;
3402 AddImageToRegistry(sv,difference_image);
3404 av_push(av,sv_bless(rv,hv));
3407 exception=DestroyExceptionInfo(exception);
3409 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3413 InheritPerlException(exception,perl_exception);
3414 exception=DestroyExceptionInfo(exception);
3415 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3416 SvPOK_on(perl_exception);
3417 ST(0)=sv_2mortal(perl_exception);
3422 ###############################################################################
3426 # C o m p l e x I m a g e s #
3430 ###############################################################################
3435 Image::Magick ref=NO_INIT
3472 PERL_UNUSED_VAR(ref);
3473 PERL_UNUSED_VAR(ix);
3474 exception=AcquireExceptionInfo();
3475 perl_exception=newSVpv("",0);
3477 if (sv_isobject(ST(0)) == 0)
3479 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3483 reference=SvRV(ST(0));
3484 hv=SvSTASH(reference);
3485 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3486 if (image == (Image *) NULL)
3488 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3492 op=UndefinedComplexOperator;
3498 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3502 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3506 op=(ComplexOperator) in;
3509 for (i=2; i < items; i+=2)
3511 attribute=(char *) SvPV(ST(i-1),na);
3517 if (LocaleCompare(attribute,"operator") == 0)
3522 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3523 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3526 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3530 op=(ComplexOperator) in;
3533 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3539 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3545 image=ComplexImages(image,op,exception);
3546 if (image == (Image *) NULL)
3549 Create blessed Perl array for the returned image.
3552 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3554 AddImageToRegistry(sv,image);
3556 av_push(av,sv_bless(rv,hv));
3558 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3559 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3560 "complex-%.*s",(int) (MaxTextExtent-9),
3561 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3562 (void) CopyMagickString(image->filename,info->image_info->filename,
3564 SetImageInfo(info->image_info,0,exception);
3565 exception=DestroyExceptionInfo(exception);
3566 SvREFCNT_dec(perl_exception);
3570 InheritPerlException(exception,perl_exception);
3571 exception=DestroyExceptionInfo(exception);
3572 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3573 SvPOK_on(perl_exception);
3574 ST(0)=sv_2mortal(perl_exception);
3579 ###############################################################################
3583 # C o m p a r e L a y e r s #
3587 ###############################################################################
3592 Image::Magick ref=NO_INIT
3594 CompareImagesLayers = 1
3596 compareimagelayers = 3
3633 PERL_UNUSED_VAR(ref);
3634 PERL_UNUSED_VAR(ix);
3635 exception=AcquireExceptionInfo();
3636 perl_exception=newSVpv("",0);
3638 if (sv_isobject(ST(0)) == 0)
3640 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3644 reference=SvRV(ST(0));
3645 hv=SvSTASH(reference);
3647 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3649 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3650 if (image == (Image *) NULL)
3652 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3656 method=CompareAnyLayer;
3657 for (i=2; i < items; i+=2)
3659 attribute=(char *) SvPV(ST(i-1),na);
3665 if (LocaleCompare(attribute,"method") == 0)
3667 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3671 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3675 method=(LayerMethod) option;
3678 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3684 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3690 image=CompareImagesLayers(image,method,exception);
3691 if (image == (Image *) NULL)
3693 for ( ; image; image=image->next)
3695 AddImageToRegistry(sv,image);
3697 av_push(av,sv_bless(rv,hv));
3700 exception=DestroyExceptionInfo(exception);
3702 SvREFCNT_dec(perl_exception);
3706 InheritPerlException(exception,perl_exception);
3707 exception=DestroyExceptionInfo(exception);
3708 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3709 SvPOK_on(perl_exception);
3710 ST(0)=sv_2mortal(perl_exception);
3715 ###############################################################################
3723 ###############################################################################
3728 Image::Magick ref=NO_INIT
3734 PERL_UNUSED_VAR(ref);
3735 if (sv_isobject(ST(0)) == 0)
3736 croak("ReferenceIsNotMyType");
3737 reference=SvRV(ST(0));
3738 switch (SvTYPE(reference))
3743 message[MaxTextExtent];
3761 Array (AV *) reference
3763 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3764 XS_VERSION,reference);
3765 hv=gv_stashpv(PackageName, FALSE);
3768 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3772 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3774 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3775 DestroyPackageInfo(info);
3777 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3787 Blessed scalar = (Image *) SvIV(reference)
3789 image=INT2PTR(Image *,SvIV(reference));
3790 if (image != (Image *) NULL)
3791 DeleteImageFromRegistry(reference,image);
3800 ###############################################################################
3808 ###############################################################################
3813 Image::Magick ref=NO_INIT
3837 PERL_UNUSED_VAR(ref);
3838 PERL_UNUSED_VAR(ix);
3839 exception=AcquireExceptionInfo();
3840 perl_exception=newSVpv("",0);
3841 package_info=(struct PackageInfo *) NULL;
3842 if (sv_isobject(ST(0)) == 0)
3844 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3848 reference=SvRV(ST(0));
3849 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3850 if (image == (Image *) NULL)
3852 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3856 package_info=ClonePackageInfo(info,exception);
3858 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3861 for (i=2; i < items; i+=2)
3862 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3864 (void) DisplayImages(package_info->image_info,image,exception);
3865 (void) CatchImageException(image);
3868 if (package_info != (struct PackageInfo *) NULL)
3869 DestroyPackageInfo(package_info);
3870 InheritPerlException(exception,perl_exception);
3871 exception=DestroyExceptionInfo(exception);
3872 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3873 SvPOK_on(perl_exception);
3874 ST(0)=sv_2mortal(perl_exception);
3879 ###############################################################################
3883 # E v a l u a t e I m a g e s #
3887 ###############################################################################
3892 Image::Magick ref=NO_INIT
3914 MagickEvaluateOperator
3929 PERL_UNUSED_VAR(ref);
3930 PERL_UNUSED_VAR(ix);
3931 exception=AcquireExceptionInfo();
3932 perl_exception=newSVpv("",0);
3934 if (sv_isobject(ST(0)) == 0)
3936 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3940 reference=SvRV(ST(0));
3941 hv=SvSTASH(reference);
3942 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3943 if (image == (Image *) NULL)
3945 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3949 op=MeanEvaluateOperator;
3955 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3959 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3963 op=(MagickEvaluateOperator) in;
3966 for (i=2; i < items; i+=2)
3968 attribute=(char *) SvPV(ST(i-1),na);
3974 if (LocaleCompare(attribute,"operator") == 0)
3979 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3980 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3983 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3987 op=(MagickEvaluateOperator) in;
3990 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3996 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4002 image=EvaluateImages(image,op,exception);
4003 if (image == (Image *) NULL)
4006 Create blessed Perl array for the returned image.
4009 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4011 AddImageToRegistry(sv,image);
4013 av_push(av,sv_bless(rv,hv));
4015 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4016 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4017 "evaluate-%.*s",(int) (MaxTextExtent-9),
4018 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4019 (void) CopyMagickString(image->filename,info->image_info->filename,
4021 SetImageInfo(info->image_info,0,exception);
4022 exception=DestroyExceptionInfo(exception);
4023 SvREFCNT_dec(perl_exception);
4027 InheritPerlException(exception,perl_exception);
4028 exception=DestroyExceptionInfo(exception);
4029 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4030 SvPOK_on(perl_exception);
4031 ST(0)=sv_2mortal(perl_exception);
4036 ###############################################################################
4044 ###############################################################################
4049 Image::Magick ref=NO_INIT
4056 #define ChannelFeatures(channel,direction) \
4058 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4059 channel_features[channel].angular_second_moment[direction]); \
4060 PUSHs(sv_2mortal(newSVpv(message,0))); \
4061 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4062 channel_features[channel].contrast[direction]); \
4063 PUSHs(sv_2mortal(newSVpv(message,0))); \
4064 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4065 channel_features[channel].contrast[direction]); \
4066 PUSHs(sv_2mortal(newSVpv(message,0))); \
4067 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4068 channel_features[channel].variance_sum_of_squares[direction]); \
4069 PUSHs(sv_2mortal(newSVpv(message,0))); \
4070 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4071 channel_features[channel].inverse_difference_moment[direction]); \
4072 PUSHs(sv_2mortal(newSVpv(message,0))); \
4073 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4074 channel_features[channel].sum_average[direction]); \
4075 PUSHs(sv_2mortal(newSVpv(message,0))); \
4076 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4077 channel_features[channel].sum_variance[direction]); \
4078 PUSHs(sv_2mortal(newSVpv(message,0))); \
4079 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4080 channel_features[channel].sum_entropy[direction]); \
4081 PUSHs(sv_2mortal(newSVpv(message,0))); \
4082 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4083 channel_features[channel].entropy[direction]); \
4084 PUSHs(sv_2mortal(newSVpv(message,0))); \
4085 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4086 channel_features[channel].difference_variance[direction]); \
4087 PUSHs(sv_2mortal(newSVpv(message,0))); \
4088 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4089 channel_features[channel].difference_entropy[direction]); \
4090 PUSHs(sv_2mortal(newSVpv(message,0))); \
4091 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4092 channel_features[channel].measure_of_correlation_1[direction]); \
4093 PUSHs(sv_2mortal(newSVpv(message,0))); \
4094 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4095 channel_features[channel].measure_of_correlation_2[direction]); \
4096 PUSHs(sv_2mortal(newSVpv(message,0))); \
4097 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
4098 channel_features[channel].maximum_correlation_coefficient[direction]); \
4099 PUSHs(sv_2mortal(newSVpv(message,0))); \
4107 message[MaxTextExtent];
4134 PERL_UNUSED_VAR(ref);
4135 PERL_UNUSED_VAR(ix);
4136 exception=AcquireExceptionInfo();
4137 perl_exception=newSVpv("",0);
4139 if (sv_isobject(ST(0)) == 0)
4141 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4145 reference=SvRV(ST(0));
4148 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4149 if (image == (Image *) NULL)
4151 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4155 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4157 for (i=2; i < items; i+=2)
4159 attribute=(char *) SvPV(ST(i-1),na);
4165 if (LocaleCompare(attribute,"distance") == 0)
4167 distance=StringToLong((char *) SvPV(ST(1),na));
4170 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4176 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4183 for ( ; image; image=image->next)
4185 channel_features=GetImageFeatures(image,distance,exception);
4186 if (channel_features == (ChannelFeatures *) NULL)
4189 EXTEND(sp,75*count);
4190 for (i=0; i < 4; i++)
4192 ChannelFeatures(RedChannel,i);
4193 ChannelFeatures(GreenChannel,i);
4194 ChannelFeatures(BlueChannel,i);
4195 if (image->colorspace == CMYKColorspace)
4196 ChannelFeatures(BlackChannel,i);
4197 if (image->alpha_trait == BlendPixelTrait)
4198 ChannelFeatures(AlphaChannel,i);
4200 channel_features=(ChannelFeatures *)
4201 RelinquishMagickMemory(channel_features);
4205 InheritPerlException(exception,perl_exception);
4206 exception=DestroyExceptionInfo(exception);
4207 SvREFCNT_dec(perl_exception);
4211 ###############################################################################
4219 ###############################################################################
4224 Image::Magick ref=NO_INIT
4262 PERL_UNUSED_VAR(ref);
4263 PERL_UNUSED_VAR(ix);
4264 exception=AcquireExceptionInfo();
4265 perl_exception=newSVpv("",0);
4267 if (sv_isobject(ST(0)) == 0)
4269 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4273 reference=SvRV(ST(0));
4274 hv=SvSTASH(reference);
4275 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4276 if (image == (Image *) NULL)
4278 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4282 background_color=image->background_color;
4284 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4285 &background_color,exception);
4287 for (i=2; i < items; i+=2)
4289 attribute=(char *) SvPV(ST(i-1),na);
4295 if (LocaleCompare(attribute,"background") == 0)
4297 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4298 AllCompliance,&background_color,exception);
4301 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4307 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4313 image->background_color=background_color;
4314 image=MergeImageLayers(image,FlattenLayer,exception);
4315 if (image == (Image *) NULL)
4318 Create blessed Perl array for the returned image.
4321 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4323 AddImageToRegistry(sv,image);
4325 av_push(av,sv_bless(rv,hv));
4327 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4328 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4329 "flatten-%.*s",(int) (MaxTextExtent-9),
4330 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4331 (void) CopyMagickString(image->filename,info->image_info->filename,
4333 SetImageInfo(info->image_info,0,exception);
4334 exception=DestroyExceptionInfo(exception);
4335 SvREFCNT_dec(perl_exception);
4339 InheritPerlException(exception,perl_exception);
4340 exception=DestroyExceptionInfo(exception);
4341 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4342 SvPOK_on(perl_exception); /* return messages in string context */
4343 ST(0)=sv_2mortal(perl_exception);
4348 ###############################################################################
4356 ###############################################################################
4361 Image::Magick ref=NO_INIT
4373 expression[MaxTextExtent];
4401 PERL_UNUSED_VAR(ref);
4402 PERL_UNUSED_VAR(ix);
4403 exception=AcquireExceptionInfo();
4404 perl_exception=newSVpv("",0);
4408 if (sv_isobject(ST(0)) == 0)
4410 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4414 reference=SvRV(ST(0));
4415 hv=SvSTASH(reference);
4417 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4419 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4420 if (image == (Image *) NULL)
4422 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4426 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4430 channel=DefaultChannels;
4431 (void) CopyMagickString(expression,"u",MaxTextExtent);
4433 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4435 for (i=2; i < items; i+=2)
4437 attribute=(char *) SvPV(ST(i-1),na);
4443 if (LocaleCompare(attribute,"channel") == 0)
4448 option=ParseChannelOption(SvPV(ST(i),na));
4451 ThrowPerlException(exception,OptionError,
4452 "UnrecognizedType",SvPV(ST(i),na));
4455 channel=(ChannelType) option;
4458 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4465 if (LocaleCompare(attribute,"expression") == 0)
4467 (void) CopyMagickString(expression,SvPV(ST(i),na),
4471 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4477 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4483 channel_mask=SetImageChannelMask(image,channel);
4484 image=FxImage(image,expression,exception);
4485 if (image != (Image *) NULL)
4486 (void) SetImageChannelMask(image,channel_mask);
4487 if (image == (Image *) NULL)
4489 for ( ; image; image=image->next)
4491 AddImageToRegistry(sv,image);
4493 av_push(av,sv_bless(rv,hv));
4496 exception=DestroyExceptionInfo(exception);
4498 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4502 InheritPerlException(exception,perl_exception);
4503 exception=DestroyExceptionInfo(exception);
4504 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4505 SvPOK_on(perl_exception);
4506 ST(0)=sv_2mortal(perl_exception);
4511 ###############################################################################
4519 ###############################################################################
4524 Image::Magick ref=NO_INIT
4535 color[MaxTextExtent];
4560 PERL_UNUSED_VAR(ref);
4561 PERL_UNUSED_VAR(ix);
4562 exception=AcquireExceptionInfo();
4563 perl_exception=newSVpv("",0);
4564 if (sv_isobject(ST(0)) == 0)
4566 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4570 reference=SvRV(ST(0));
4571 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4572 if (image == (Image *) NULL && !info)
4575 for (i=1; i < items; i++)
4577 attribute=(char *) SvPV(ST(i),na);
4584 if (LocaleCompare(attribute,"adjoin") == 0)
4587 s=newSViv((ssize_t) info->image_info->adjoin);
4588 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4591 if (LocaleCompare(attribute,"antialias") == 0)
4594 s=newSViv((ssize_t) info->image_info->antialias);
4595 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4598 if (LocaleCompare(attribute,"area") == 0)
4600 s=newSViv(GetMagickResource(AreaResource));
4601 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4604 if (LocaleCompare(attribute,"attenuate") == 0)
4609 value=GetImageProperty(image,attribute,exception);
4610 if (value != (const char *) NULL)
4612 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4615 if (LocaleCompare(attribute,"authenticate") == 0)
4622 option=GetImageOption(info->image_info,attribute);
4623 if (option != (const char *) NULL)
4624 s=newSVpv(option,0);
4626 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4629 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4636 if (LocaleCompare(attribute,"background") == 0)
4638 if (image == (Image *) NULL)
4640 (void) FormatLocaleString(color,MaxTextExtent,
4641 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4642 image->background_color.green,image->background_color.blue,
4643 image->background_color.alpha);
4645 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4648 if (LocaleCompare(attribute,"base-columns") == 0)
4650 if (image != (Image *) NULL)
4651 s=newSViv((ssize_t) image->magick_columns);
4652 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4655 if (LocaleCompare(attribute,"base-filename") == 0)
4657 if (image != (Image *) NULL)
4658 s=newSVpv(image->magick_filename,0);
4659 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4662 if (LocaleCompare(attribute,"base-height") == 0)
4664 if (image != (Image *) NULL)
4665 s=newSViv((ssize_t) image->magick_rows);
4666 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4669 if (LocaleCompare(attribute,"base-rows") == 0)
4671 if (image != (Image *) NULL)
4672 s=newSViv((ssize_t) image->magick_rows);
4673 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4676 if (LocaleCompare(attribute,"base-width") == 0)
4678 if (image != (Image *) NULL)
4679 s=newSViv((ssize_t) image->magick_columns);
4680 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4683 if (LocaleCompare(attribute,"blue-primary") == 0)
4685 if (image == (Image *) NULL)
4687 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4688 image->chromaticity.blue_primary.x,
4689 image->chromaticity.blue_primary.y);
4691 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4694 if (LocaleCompare(attribute,"bordercolor") == 0)
4696 if (image == (Image *) NULL)
4698 (void) FormatLocaleString(color,MaxTextExtent,
4699 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4700 image->border_color.green,image->border_color.blue,
4701 image->border_color.alpha);
4703 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4706 if (LocaleCompare(attribute,"bounding-box") == 0)
4709 geometry[MaxTextExtent];
4714 if (image == (Image *) NULL)
4716 page=GetImageBoundingBox(image,exception);
4717 (void) FormatLocaleString(geometry,MaxTextExtent,
4718 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4719 page.height,(double) page.x,(double) page.y);
4720 s=newSVpv(geometry,0);
4721 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4724 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4731 if (LocaleCompare(attribute,"class") == 0)
4733 if (image == (Image *) NULL)
4735 s=newSViv(image->storage_class);
4736 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4737 image->storage_class));
4739 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4742 if (LocaleCompare(attribute,"clip-mask") == 0)
4744 if (image != (Image *) NULL)
4753 if (image->read_mask == MagickFalse)
4754 ClipImage(image,exception);
4755 mask_image=GetImageMask(image,exception);
4756 if (mask_image != (Image *) NULL)
4758 AddImageToRegistry(sv,mask_image);
4759 s=sv_bless(newRV(sv),SvSTASH(reference));
4762 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4765 if (LocaleCompare(attribute,"clip-path") == 0)
4767 if (image != (Image *) NULL)
4776 if (image->read_mask != MagickFalse)
4777 ClipImage(image,exception);
4778 mask_image=GetImageMask(image,exception);
4779 if (mask_image != (Image *) NULL)
4781 AddImageToRegistry(sv,mask_image);
4782 s=sv_bless(newRV(sv),SvSTASH(reference));
4785 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4788 if (LocaleCompare(attribute,"compression") == 0)
4790 j=info ? info->image_info->compression : image ?
4791 image->compression : UndefinedCompression;
4793 if (info->image_info->compression == UndefinedCompression)
4794 j=image->compression;
4796 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4799 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4802 if (LocaleCompare(attribute,"colorspace") == 0)
4804 j=image ? image->colorspace : RGBColorspace;
4806 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4809 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4812 if (LocaleCompare(attribute,"colors") == 0)
4814 if (image != (Image *) NULL)
4815 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4817 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4820 if (LocaleNCompare(attribute,"colormap",8) == 0)
4825 if (image == (Image *) NULL || !image->colormap)
4828 items=sscanf(attribute,"%*[^[][%ld",&j);
4830 if (j > (ssize_t) image->colors)
4832 (void) FormatLocaleString(color,MaxTextExtent,
4833 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4834 image->colormap[j].green,image->colormap[j].blue,
4835 image->colormap[j].alpha);
4837 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4840 if (LocaleCompare(attribute,"columns") == 0)
4842 if (image != (Image *) NULL)
4843 s=newSViv((ssize_t) image->columns);
4844 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4847 if (LocaleCompare(attribute,"comment") == 0)
4852 value=GetImageProperty(image,attribute,exception);
4853 if (value != (const char *) NULL)
4855 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4858 if (LocaleCompare(attribute,"copyright") == 0)
4860 s=newSVpv(GetMagickCopyright(),0);
4861 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4864 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4871 if (LocaleCompare(attribute,"density") == 0)
4874 geometry[MaxTextExtent];
4876 if (image == (Image *) NULL)
4878 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4879 image->resolution.x,image->resolution.y);
4880 s=newSVpv(geometry,0);
4881 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4884 if (LocaleCompare(attribute,"delay") == 0)
4886 if (image != (Image *) NULL)
4887 s=newSViv((ssize_t) image->delay);
4888 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4891 if (LocaleCompare(attribute,"depth") == 0)
4893 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4894 if (image != (Image *) NULL)
4895 s=newSViv((ssize_t) GetImageDepth(image,exception));
4896 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4899 if (LocaleCompare(attribute,"directory") == 0)
4901 if (image && image->directory)
4902 s=newSVpv(image->directory,0);
4903 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4906 if (LocaleCompare(attribute,"dispose") == 0)
4908 if (image == (Image *) NULL)
4911 s=newSViv(image->dispose);
4913 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4915 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4918 if (LocaleCompare(attribute,"disk") == 0)
4920 s=newSViv(GetMagickResource(DiskResource));
4921 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4924 if (LocaleCompare(attribute,"dither") == 0)
4927 s=newSViv((ssize_t) info->image_info->dither);
4928 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4931 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4933 if (info && info->image_info->server_name)
4934 s=newSVpv(info->image_info->server_name,0);
4935 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4938 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4945 if (LocaleCompare(attribute,"elapsed-time") == 0)
4947 if (image != (Image *) NULL)
4948 s=newSVnv(GetElapsedTime(&image->timer));
4949 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4952 if (LocaleCompare(attribute,"endian") == 0)
4954 j=info ? info->image_info->endian : image ? image->endian :
4957 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4959 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4962 if (LocaleCompare(attribute,"error") == 0)
4964 if (image != (Image *) NULL)
4965 s=newSVnv(image->error.mean_error_per_pixel);
4966 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4969 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4976 if (LocaleCompare(attribute,"filesize") == 0)
4978 if (image != (Image *) NULL)
4979 s=newSViv((ssize_t) GetBlobSize(image));
4980 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4983 if (LocaleCompare(attribute,"filename") == 0)
4985 if (info && info->image_info->filename &&
4986 *info->image_info->filename)
4987 s=newSVpv(info->image_info->filename,0);
4988 if (image != (Image *) NULL)
4989 s=newSVpv(image->filename,0);
4990 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4993 if (LocaleCompare(attribute,"filter") == 0)
4995 s=image ? newSViv(image->filter) : newSViv(0);
4996 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4999 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5002 if (LocaleCompare(attribute,"font") == 0)
5004 if (info && info->image_info->font)
5005 s=newSVpv(info->image_info->font,0);
5006 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5009 if (LocaleCompare(attribute,"foreground") == 0)
5011 if (LocaleCompare(attribute,"format") == 0)
5016 magick_info=(const MagickInfo *) NULL;
5017 if (info && (*info->image_info->magick != '\0'))
5018 magick_info=GetMagickInfo(info->image_info->magick,exception);
5019 if (image != (Image *) NULL)
5020 magick_info=GetMagickInfo(image->magick,exception);
5021 if ((magick_info != (const MagickInfo *) NULL) &&
5022 (*magick_info->description != '\0'))
5023 s=newSVpv((char *) magick_info->description,0);
5024 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5027 if (LocaleCompare(attribute,"fuzz") == 0)
5030 s=newSVnv(info->image_info->fuzz);
5031 if (image != (Image *) NULL)
5032 s=newSVnv(image->fuzz);
5033 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5036 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5043 if (LocaleCompare(attribute,"gamma") == 0)
5045 if (image != (Image *) NULL)
5046 s=newSVnv(image->gamma);
5047 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5050 if (LocaleCompare(attribute,"geometry") == 0)
5052 if (image && image->geometry)
5053 s=newSVpv(image->geometry,0);
5054 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5057 if (LocaleCompare(attribute,"gravity") == 0)
5059 s=image ? newSViv(image->gravity) : newSViv(0);
5060 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5063 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5066 if (LocaleCompare(attribute,"green-primary") == 0)
5068 if (image == (Image *) NULL)
5070 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5071 image->chromaticity.green_primary.x,
5072 image->chromaticity.green_primary.y);
5074 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5077 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5084 if (LocaleCompare(attribute,"height") == 0)
5086 if (image != (Image *) NULL)
5087 s=newSViv((ssize_t) image->rows);
5088 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5091 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5098 if (LocaleCompare(attribute,"icc") == 0)
5100 if (image != (Image *) NULL)
5105 profile=GetImageProfile(image,"icc");
5106 if (profile != (StringInfo *) NULL)
5107 s=newSVpv((const char *) GetStringInfoDatum(profile),
5108 GetStringInfoLength(profile));
5110 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5113 if (LocaleCompare(attribute,"icm") == 0)
5115 if (image != (Image *) NULL)
5120 profile=GetImageProfile(image,"icm");
5121 if (profile != (const StringInfo *) NULL)
5122 s=newSVpv((const char *) GetStringInfoDatum(profile),
5123 GetStringInfoLength(profile));
5125 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5128 if (LocaleCompare(attribute,"id") == 0)
5130 if (image != (Image *) NULL)
5141 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
5143 status=SetImageRegistry(ImageRegistryType,key,image,
5148 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5151 if (LocaleNCompare(attribute,"index",5) == 0)
5154 name[MaxTextExtent];
5163 register const Quantum
5169 if (image == (Image *) NULL)
5171 if (image->storage_class != PseudoClass)
5175 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5177 image_view=AcquireVirtualCacheView(image,exception);
5178 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5179 if (p != (const Quantum *) NULL)
5181 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5182 GetPixelIndex(image,p));
5184 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5186 image_view=DestroyCacheView(image_view);
5189 if (LocaleCompare(attribute,"iptc") == 0)
5191 if (image != (Image *) NULL)
5196 profile=GetImageProfile(image,"iptc");
5197 if (profile != (const StringInfo *) NULL)
5198 s=newSVpv((const char *) GetStringInfoDatum(profile),
5199 GetStringInfoLength(profile));
5201 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5204 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5206 if (image != (Image *) NULL)
5207 s=newSViv((ssize_t) image->iterations);
5208 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5211 if (LocaleCompare(attribute,"interlace") == 0)
5213 j=info ? info->image_info->interlace : image ? image->interlace :
5216 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5219 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5222 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5229 if (LocaleCompare(attribute,"label") == 0)
5234 if (image == (Image *) NULL)
5236 value=GetImageProperty(image,"Label",exception);
5237 if (value != (const char *) NULL)
5239 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5242 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5244 if (image != (Image *) NULL)
5245 s=newSViv((ssize_t) image->iterations);
5246 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5249 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5256 if (LocaleCompare(attribute,"magick") == 0)
5258 if (info && *info->image_info->magick)
5259 s=newSVpv(info->image_info->magick,0);
5260 if (image != (Image *) NULL)
5261 s=newSVpv(image->magick,0);
5262 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5265 if (LocaleCompare(attribute,"map") == 0)
5267 s=newSViv(GetMagickResource(MapResource));
5268 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5271 if (LocaleCompare(attribute,"maximum-error") == 0)
5273 if (image != (Image *) NULL)
5274 s=newSVnv(image->error.normalized_maximum_error);
5275 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5278 if (LocaleCompare(attribute,"memory") == 0)
5280 s=newSViv(GetMagickResource(MemoryResource));
5281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5284 if (LocaleCompare(attribute,"mean-error") == 0)
5286 if (image != (Image *) NULL)
5287 s=newSVnv(image->error.normalized_mean_error);
5288 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5291 if (LocaleCompare(attribute,"mime") == 0)
5293 if (info && *info->image_info->magick)
5294 s=newSVpv(MagickToMime(info->image_info->magick),0);
5295 if (image != (Image *) NULL)
5296 s=newSVpv(MagickToMime(image->magick),0);
5297 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5300 if (LocaleCompare(attribute,"mattecolor") == 0)
5302 if (image == (Image *) NULL)
5304 (void) FormatLocaleString(color,MaxTextExtent,
5305 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
5306 image->matte_color.green,image->matte_color.blue,
5307 image->matte_color.alpha);
5309 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5312 if (LocaleCompare(attribute,"matte") == 0)
5314 if (image != (Image *) NULL)
5315 s=newSViv((ssize_t) image->alpha_trait == BlendPixelTrait ?
5317 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5320 if (LocaleCompare(attribute,"mime") == 0)
5326 if (info && *info->image_info->magick)
5327 magick=info->image_info->magick;
5328 if (image != (Image *) NULL)
5329 magick=image->magick;
5335 mime=MagickToMime(magick);
5337 mime=(char *) RelinquishMagickMemory(mime);
5339 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5342 if (LocaleCompare(attribute,"monochrome") == 0)
5344 if (image == (Image *) NULL)
5346 j=info ? info->image_info->monochrome :
5347 IsImageMonochrome(image,exception);
5349 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5352 if (LocaleCompare(attribute,"montage") == 0)
5354 if (image && image->montage)
5355 s=newSVpv(image->montage,0);
5356 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5359 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5366 if (LocaleCompare(attribute,"orientation") == 0)
5368 j=info ? info->image_info->orientation : image ?
5369 image->orientation : UndefinedOrientation;
5371 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5374 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5377 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5384 if (LocaleCompare(attribute,"page") == 0)
5386 if (info && info->image_info->page)
5387 s=newSVpv(info->image_info->page,0);
5388 if (image != (Image *) NULL)
5391 geometry[MaxTextExtent];
5393 (void) FormatLocaleString(geometry,MaxTextExtent,
5394 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5395 (double) image->page.height,(double) image->page.x,(double)
5397 s=newSVpv(geometry,0);
5399 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5402 if (LocaleCompare(attribute,"page.x") == 0)
5404 if (image != (Image *) NULL)
5405 s=newSViv((ssize_t) image->page.x);
5406 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5409 if (LocaleCompare(attribute,"page.y") == 0)
5411 if (image != (Image *) NULL)
5412 s=newSViv((ssize_t) image->page.y);
5413 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5416 if (LocaleNCompare(attribute,"pixel",5) == 0)
5419 tuple[MaxTextExtent];
5428 register const Quantum
5431 if (image == (Image *) NULL)
5435 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5437 p=GetVirtualPixels(image,x,y,1,1,exception);
5438 if (image->colorspace != CMYKColorspace)
5439 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5440 QuantumFormat "," QuantumFormat "," QuantumFormat,
5441 GetPixelRed(image,p),GetPixelGreen(image,p),
5442 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5444 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5445 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5446 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5447 GetPixelBlue(image,p),GetPixelBlack(image,p),
5448 GetPixelAlpha(image,p));
5450 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5453 if (LocaleCompare(attribute,"pointsize") == 0)
5456 s=newSViv((ssize_t) info->image_info->pointsize);
5457 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5460 if (LocaleCompare(attribute,"preview") == 0)
5462 s=newSViv(info->image_info->preview_type);
5463 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5464 info->image_info->preview_type));
5466 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5469 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5476 if (LocaleCompare(attribute,"quality") == 0)
5479 s=newSViv((ssize_t) info->image_info->quality);
5480 if (image != (Image *) NULL)
5481 s=newSViv((ssize_t) image->quality);
5482 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5485 if (LocaleCompare(attribute,"quantum") == 0)
5488 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5489 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5492 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5499 if (LocaleCompare(attribute,"rendering-intent") == 0)
5501 s=newSViv(image->rendering_intent);
5502 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5503 image->rendering_intent));
5505 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5508 if (LocaleCompare(attribute,"red-primary") == 0)
5510 if (image == (Image *) NULL)
5512 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5513 image->chromaticity.red_primary.x,
5514 image->chromaticity.red_primary.y);
5516 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5519 if (LocaleCompare(attribute,"rows") == 0)
5521 if (image != (Image *) NULL)
5522 s=newSViv((ssize_t) image->rows);
5523 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5526 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5533 if (LocaleCompare(attribute,"sampling-factor") == 0)
5535 if (info && info->image_info->sampling_factor)
5536 s=newSVpv(info->image_info->sampling_factor,0);
5537 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5540 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5542 if (info && info->image_info->server_name)
5543 s=newSVpv(info->image_info->server_name,0);
5544 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5547 if (LocaleCompare(attribute,"size") == 0)
5549 if (info && info->image_info->size)
5550 s=newSVpv(info->image_info->size,0);
5551 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5554 if (LocaleCompare(attribute,"scene") == 0)
5556 if (image != (Image *) NULL)
5557 s=newSViv((ssize_t) image->scene);
5558 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5561 if (LocaleCompare(attribute,"scenes") == 0)
5563 if (image != (Image *) NULL)
5564 s=newSViv((ssize_t) info->image_info->number_scenes);
5565 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5568 if (LocaleCompare(attribute,"signature") == 0)
5573 if (image == (Image *) NULL)
5575 (void) SignatureImage(image,exception);
5576 value=GetImageProperty(image,"Signature",exception);
5577 if (value != (const char *) NULL)
5579 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5582 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5589 if (LocaleCompare(attribute,"taint") == 0)
5591 if (image != (Image *) NULL)
5592 s=newSViv((ssize_t) IsTaintImage(image));
5593 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5596 if (LocaleCompare(attribute,"texture") == 0)
5598 if (info && info->image_info->texture)
5599 s=newSVpv(info->image_info->texture,0);
5600 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5603 if (LocaleCompare(attribute,"total-ink-density") == 0)
5605 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5606 if (image != (Image *) NULL)
5607 s=newSVnv(GetImageTotalInkDensity(image,exception));
5608 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5611 if (LocaleCompare(attribute,"transparent-color") == 0)
5613 if (image == (Image *) NULL)
5615 (void) FormatLocaleString(color,MaxTextExtent,
5616 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5617 image->transparent_color.green,image->transparent_color.blue,
5618 image->transparent_color.alpha);
5620 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5623 if (LocaleCompare(attribute,"type") == 0)
5625 if (image == (Image *) NULL)
5627 j=(ssize_t) GetImageType(image,exception);
5629 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5631 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5634 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5641 if (LocaleCompare(attribute,"units") == 0)
5643 j=info ? info->image_info->units : image ? image->units :
5644 UndefinedResolution;
5645 if (info && (info->image_info->units == UndefinedResolution))
5648 if (j == UndefinedResolution)
5649 s=newSVpv("undefined units",0);
5651 if (j == PixelsPerInchResolution)
5652 s=newSVpv("pixels / inch",0);
5654 s=newSVpv("pixels / centimeter",0);
5655 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5658 if (LocaleCompare(attribute,"user-time") == 0)
5660 if (image != (Image *) NULL)
5661 s=newSVnv(GetUserTime(&image->timer));
5662 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5665 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5672 if (LocaleCompare(attribute,"verbose") == 0)
5675 s=newSViv((ssize_t) info->image_info->verbose);
5676 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5679 if (LocaleCompare(attribute,"version") == 0)
5681 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5682 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5685 if (LocaleCompare(attribute,"view") == 0)
5687 if (info && info->image_info->view)
5688 s=newSVpv(info->image_info->view,0);
5689 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5692 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5694 if (image == (Image *) NULL)
5696 j=(ssize_t) GetImageVirtualPixelMethod(image);
5698 (void) sv_setpv(s,CommandOptionToMnemonic(
5699 MagickVirtualPixelOptions,j));
5701 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5704 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5711 if (LocaleCompare(attribute,"white-point") == 0)
5713 if (image == (Image *) NULL)
5715 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5716 image->chromaticity.white_point.x,
5717 image->chromaticity.white_point.y);
5719 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5722 if (LocaleCompare(attribute,"width") == 0)
5724 if (image != (Image *) NULL)
5725 s=newSViv((ssize_t) image->columns);
5726 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5729 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5736 if (LocaleCompare(attribute,"x-resolution") == 0)
5738 if (image != (Image *) NULL)
5739 s=newSVnv(image->resolution.x);
5740 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5743 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5750 if (LocaleCompare(attribute,"y-resolution") == 0)
5752 if (image != (Image *) NULL)
5753 s=newSVnv(image->resolution.y);
5754 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5757 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5764 if (image == (Image *) NULL)
5765 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5769 value=GetImageProperty(image,attribute,exception);
5770 if (value != (const char *) NULL)
5773 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5776 if (*attribute != '%')
5777 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5784 meta=InterpretImageProperties(info ? info->image_info :
5785 (ImageInfo *) NULL,image,attribute,exception);
5787 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5788 meta=(char *) RelinquishMagickMemory(meta);
5792 exception=DestroyExceptionInfo(exception);
5793 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5797 ###############################################################################
5801 # G e t A u t h e n t i c P i x e l s #
5805 ###############################################################################
5809 GetAuthenticPixels(ref,...)
5810 Image::Magick ref = NO_INIT
5812 getauthenticpixels = 1
5842 PERL_UNUSED_VAR(ref);
5843 PERL_UNUSED_VAR(ix);
5844 exception=AcquireExceptionInfo();
5845 perl_exception=newSVpv("",0);
5846 if (sv_isobject(ST(0)) == 0)
5848 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5852 reference=SvRV(ST(0));
5854 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5855 if (image == (Image *) NULL)
5857 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5864 region.width=image->columns;
5867 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5868 for (i=2; i < items; i+=2)
5870 attribute=(char *) SvPV(ST(i-1),na);
5876 if (LocaleCompare(attribute,"geometry") == 0)
5878 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5881 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5888 if (LocaleCompare(attribute,"height") == 0)
5890 region.height=SvIV(ST(i));
5893 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5900 if (LocaleCompare(attribute,"x") == 0)
5902 region.x=SvIV(ST(i));
5905 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5912 if (LocaleCompare(attribute,"y") == 0)
5914 region.y=SvIV(ST(i));
5917 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5924 if (LocaleCompare(attribute,"width") == 0)
5926 region.width=SvIV(ST(i));
5929 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5935 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5936 region.height,exception);
5937 if (blob != (void *) NULL)
5941 InheritPerlException(exception,perl_exception);
5942 exception=DestroyExceptionInfo(exception);
5943 SvREFCNT_dec(perl_exception); /* throw away all errors */
5952 ###############################################################################
5956 # G e t V i r t u a l P i x e l s #
5960 ###############################################################################
5964 GetVirtualPixels(ref,...)
5965 Image::Magick ref = NO_INIT
5967 getvirtualpixels = 1
5968 AcquireImagePixels = 2
5969 acquireimagepixels = 3
5997 PERL_UNUSED_VAR(ref);
5998 PERL_UNUSED_VAR(ix);
5999 exception=AcquireExceptionInfo();
6000 perl_exception=newSVpv("",0);
6001 if (sv_isobject(ST(0)) == 0)
6003 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6007 reference=SvRV(ST(0));
6009 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6010 if (image == (Image *) NULL)
6012 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6019 region.width=image->columns;
6022 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6023 for (i=2; i < items; i+=2)
6025 attribute=(char *) SvPV(ST(i-1),na);
6031 if (LocaleCompare(attribute,"geometry") == 0)
6033 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6036 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6043 if (LocaleCompare(attribute,"height") == 0)
6045 region.height=SvIV(ST(i));
6048 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6055 if (LocaleCompare(attribute,"x") == 0)
6057 region.x=SvIV(ST(i));
6060 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6067 if (LocaleCompare(attribute,"y") == 0)
6069 region.y=SvIV(ST(i));
6072 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6079 if (LocaleCompare(attribute,"width") == 0)
6081 region.width=SvIV(ST(i));
6084 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6090 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6091 region.height,exception);
6092 if (blob != (void *) NULL)
6096 InheritPerlException(exception,perl_exception);
6097 exception=DestroyExceptionInfo(exception);
6098 SvREFCNT_dec(perl_exception); /* throw away all errors */
6101 RETVAL = (void *) blob;
6107 ###############################################################################
6111 # G e t A u t h e n t i c M e t a c o n t e n t #
6115 ###############################################################################
6119 GetAuthenticMetacontent(ref,...)
6120 Image::Magick ref = NO_INIT
6122 getauthenticmetacontent = 1
6143 PERL_UNUSED_VAR(ref);
6144 PERL_UNUSED_VAR(ix);
6145 exception=AcquireExceptionInfo();
6146 perl_exception=newSVpv("",0);
6147 if (sv_isobject(ST(0)) == 0)
6149 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6153 reference=SvRV(ST(0));
6155 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6156 if (image == (Image *) NULL)
6158 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6163 blob=(void *) GetAuthenticMetacontent(image);
6164 if (blob != (void *) NULL)
6168 InheritPerlException(exception,perl_exception);
6169 exception=DestroyExceptionInfo(exception);
6170 SvREFCNT_dec(perl_exception); /* throw away all errors */
6179 ###############################################################################
6183 # G e t V i r t u a l M e t a c o n t e n t #
6187 ###############################################################################
6191 GetVirtualMetacontent(ref,...)
6192 Image::Magick ref = NO_INIT
6194 getvirtualmetacontent = 1
6213 PERL_UNUSED_VAR(ref);
6214 PERL_UNUSED_VAR(ix);
6215 exception=AcquireExceptionInfo();
6216 perl_exception=newSVpv("",0);
6217 if (sv_isobject(ST(0)) == 0)
6219 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6223 reference=SvRV(ST(0));
6225 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6226 if (image == (Image *) NULL)
6228 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6233 blob=(void *) GetVirtualMetacontent(image);
6234 if (blob != (void *) NULL)
6238 InheritPerlException(exception,perl_exception);
6239 exception=DestroyExceptionInfo(exception);
6240 SvREFCNT_dec(perl_exception); /* throw away all errors */
6249 ###############################################################################
6253 # H i s t o g r a m #
6257 ###############################################################################
6262 Image::Magick ref=NO_INIT
6273 message[MaxTextExtent];
6300 PERL_UNUSED_VAR(ref);
6301 PERL_UNUSED_VAR(ix);
6302 exception=AcquireExceptionInfo();
6303 perl_exception=newSVpv("",0);
6305 if (sv_isobject(ST(0)) == 0)
6307 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6311 reference=SvRV(ST(0));
6314 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6315 if (image == (Image *) NULL)
6317 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6321 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6323 for ( ; image; image=image->next)
6325 histogram=GetImageHistogram(image,&number_colors,exception);
6326 if (histogram == (PixelInfo *) NULL)
6328 count+=(ssize_t) number_colors;
6330 for (i=0; i < (ssize_t) number_colors; i++)
6332 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6334 PUSHs(sv_2mortal(newSVpv(message,0)));
6335 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6336 histogram[i].green);
6337 PUSHs(sv_2mortal(newSVpv(message,0)));
6338 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6340 PUSHs(sv_2mortal(newSVpv(message,0)));
6341 if (image->colorspace == CMYKColorspace)
6343 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6344 histogram[i].black);
6345 PUSHs(sv_2mortal(newSVpv(message,0)));
6347 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6348 histogram[i].alpha);
6349 PUSHs(sv_2mortal(newSVpv(message,0)));
6350 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6351 histogram[i].count);
6352 PUSHs(sv_2mortal(newSVpv(message,0)));
6354 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6358 InheritPerlException(exception,perl_exception);
6359 exception=DestroyExceptionInfo(exception);
6360 SvREFCNT_dec(perl_exception);
6364 ###############################################################################
6372 ###############################################################################
6377 Image::Magick ref=NO_INIT
6401 register const Quantum
6415 *reference; /* reference is the SV* of ref=SvIV(reference) */
6417 PERL_UNUSED_VAR(ref);
6418 PERL_UNUSED_VAR(ix);
6419 exception=AcquireExceptionInfo();
6420 perl_exception=newSVpv("",0);
6421 reference=SvRV(ST(0));
6422 av=(AV *) reference;
6423 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6425 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6426 if (image == (Image *) NULL)
6428 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6432 normalize=MagickTrue;
6435 region.width=image->columns;
6438 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6439 for (i=2; i < items; i+=2)
6441 attribute=(char *) SvPV(ST(i-1),na);
6447 if (LocaleCompare(attribute,"channel") == 0)
6452 option=ParseChannelOption(SvPV(ST(i),na));
6455 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6459 SetPixelChannelMask(image,(ChannelType) option);
6462 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6469 if (LocaleCompare(attribute,"geometry") == 0)
6471 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6474 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6481 if (LocaleCompare(attribute,"normalize") == 0)
6483 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6487 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6491 normalize=option != 0 ? MagickTrue : MagickFalse;
6494 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6501 if (LocaleCompare(attribute,"x") == 0)
6503 region.x=SvIV(ST(i));
6506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6513 if (LocaleCompare(attribute,"y") == 0)
6515 region.y=SvIV(ST(i));
6518 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6524 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6530 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6531 if (p == (const Quantum *) NULL)
6539 if (normalize != MagickFalse)
6540 scale=1.0/QuantumRange;
6541 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6542 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6543 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6544 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6545 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6546 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6547 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6548 (image->colorspace == CMYKColorspace))
6549 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6550 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6551 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6555 InheritPerlException(exception,perl_exception);
6556 exception=DestroyExceptionInfo(exception);
6557 SvREFCNT_dec(perl_exception);
6561 ###############################################################################
6565 # G e t P i x e l s #
6569 ###############################################################################
6574 Image::Magick ref=NO_INIT
6613 *reference; /* reference is the SV* of ref=SvIV(reference) */
6615 PERL_UNUSED_VAR(ref);
6616 PERL_UNUSED_VAR(ix);
6617 exception=AcquireExceptionInfo();
6618 perl_exception=newSVpv("",0);
6619 reference=SvRV(ST(0));
6620 av=(AV *) reference;
6621 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6623 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6624 if (image == (Image *) NULL)
6626 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6631 if (image->alpha_trait == BlendPixelTrait)
6633 if (image->colorspace == CMYKColorspace)
6636 if (image->alpha_trait == BlendPixelTrait)
6639 normalize=MagickFalse;
6642 region.width=image->columns;
6645 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6646 for (i=2; i < items; i+=2)
6648 attribute=(char *) SvPV(ST(i-1),na);
6654 if (LocaleCompare(attribute,"geometry") == 0)
6656 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6659 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6666 if (LocaleCompare(attribute,"height") == 0)
6668 region.height=SvIV(ST(i));
6671 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6678 if (LocaleCompare(attribute,"map") == 0)
6683 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6690 if (LocaleCompare(attribute,"normalize") == 0)
6692 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6696 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6700 normalize=option != 0 ? MagickTrue : MagickFalse;
6703 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6710 if (LocaleCompare(attribute,"width") == 0)
6712 region.width=SvIV(ST(i));
6715 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6722 if (LocaleCompare(attribute,"x") == 0)
6724 region.x=SvIV(ST(i));
6727 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6734 if (LocaleCompare(attribute,"y") == 0)
6736 region.y=SvIV(ST(i));
6739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6745 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6751 if (normalize != MagickFalse)
6756 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6757 region.height*sizeof(*pixels));
6758 if (pixels == (float *) NULL)
6760 ThrowPerlException(exception,ResourceLimitError,
6761 "MemoryAllocationFailed",PackageName);
6764 status=ExportImagePixels(image,region.x,region.y,region.width,
6765 region.height,map,FloatPixel,pixels,exception);
6766 if (status == MagickFalse)
6770 EXTEND(sp,strlen(map)*region.width*region.height);
6771 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6772 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6774 pixels=(float *) RelinquishMagickMemory(pixels);
6781 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6782 region.height*sizeof(*pixels));
6783 if (pixels == (Quantum *) NULL)
6785 ThrowPerlException(exception,ResourceLimitError,
6786 "MemoryAllocationFailed",PackageName);
6789 status=ExportImagePixels(image,region.x,region.y,region.width,
6790 region.height,map,QuantumPixel,pixels,exception);
6791 if (status == MagickFalse)
6795 EXTEND(sp,strlen(map)*region.width*region.height);
6796 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6797 PUSHs(sv_2mortal(newSViv(pixels[i])));
6799 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6803 InheritPerlException(exception,perl_exception);
6804 exception=DestroyExceptionInfo(exception);
6805 SvREFCNT_dec(perl_exception);
6809 ###############################################################################
6813 # I m a g e T o B l o b #
6817 ###############################################################################
6821 ImageToBlob(ref,...)
6822 Image::Magick ref=NO_INIT
6831 filename[MaxTextExtent];
6860 PERL_UNUSED_VAR(ref);
6861 PERL_UNUSED_VAR(ix);
6862 exception=AcquireExceptionInfo();
6863 perl_exception=newSVpv("",0);
6864 package_info=(struct PackageInfo *) NULL;
6865 if (sv_isobject(ST(0)) == 0)
6867 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6871 reference=SvRV(ST(0));
6872 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6873 if (image == (Image *) NULL)
6875 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6879 package_info=ClonePackageInfo(info,exception);
6880 for (i=2; i < items; i+=2)
6881 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6882 (void) CopyMagickString(filename,package_info->image_info->filename,
6885 for (next=image; next; next=next->next)
6887 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6888 next->scene=scene++;
6890 SetImageInfo(package_info->image_info,(unsigned int)
6891 GetImageListLength(image),exception);
6892 EXTEND(sp,(ssize_t) GetImageListLength(image));
6893 for ( ; image; image=image->next)
6896 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6897 if (blob != (char *) NULL)
6899 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6900 blob=(unsigned char *) RelinquishMagickMemory(blob);
6902 if (package_info->image_info->adjoin)
6907 if (package_info != (struct PackageInfo *) NULL)
6908 DestroyPackageInfo(package_info);
6909 InheritPerlException(exception,perl_exception);
6910 exception=DestroyExceptionInfo(exception);
6911 SvREFCNT_dec(perl_exception); /* throw away all errors */
6915 ###############################################################################
6923 ###############################################################################
6928 Image::Magick ref=NO_INIT
6932 OptimizeImageLayers = 3
6934 optimizeimagelayers = 5
6976 PERL_UNUSED_VAR(ref);
6977 PERL_UNUSED_VAR(ix);
6978 exception=AcquireExceptionInfo();
6979 perl_exception=newSVpv("",0);
6981 if (sv_isobject(ST(0)) == 0)
6983 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6987 reference=SvRV(ST(0));
6988 hv=SvSTASH(reference);
6990 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6992 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6993 if (image == (Image *) NULL)
6995 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6999 compose=image->compose;
7000 method=OptimizeLayer;
7001 for (i=2; i < items; i+=2)
7003 attribute=(char *) SvPV(ST(i-1),na);
7009 if (LocaleCompare(attribute,"compose") == 0)
7011 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7012 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7015 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7019 compose=(CompositeOperator) sp;
7022 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7029 if (LocaleCompare(attribute,"method") == 0)
7031 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7035 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7039 method=(LayerMethod) option;
7042 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7048 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7054 layers=(Image *) NULL;
7057 case CompareAnyLayer:
7058 case CompareClearLayer:
7059 case CompareOverlayLayer:
7062 layers=CompareImagesLayers(image,method,exception);
7069 layers=MergeImageLayers(image,method,exception);
7074 layers=DisposeImages(image,exception);
7077 case OptimizeImageLayer:
7079 layers=OptimizeImageLayers(image,exception);
7082 case OptimizePlusLayer:
7084 layers=OptimizePlusImageLayers(image,exception);
7087 case OptimizeTransLayer:
7089 OptimizeImageTransparency(image,exception);
7092 case RemoveDupsLayer:
7094 RemoveDuplicateLayers(&image,exception);
7097 case RemoveZeroLayer:
7099 RemoveZeroDelayLayers(&image,exception);
7108 General Purpose, GIF Animation Optimizer.
7110 layers=CoalesceImages(image,exception);
7111 if (layers == (Image *) NULL)
7114 layers=OptimizeImageLayers(image,exception);
7115 if (layers == (Image *) NULL)
7117 image=DestroyImageList(image);
7119 layers=(Image *) NULL;
7120 OptimizeImageTransparency(image,exception);
7121 quantize_info=AcquireQuantizeInfo(info->image_info);
7122 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7123 quantize_info=DestroyQuantizeInfo(quantize_info);
7126 case CompositeLayer:
7135 Split image sequence at the first 'NULL:' image.
7138 while (source != (Image *) NULL)
7140 source=GetNextImageInList(source);
7141 if ((source != (Image *) NULL) &&
7142 (LocaleCompare(source->magick,"NULL") == 0))
7145 if (source != (Image *) NULL)
7147 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7148 (GetNextImageInList(source) == (Image *) NULL))
7149 source=(Image *) NULL;
7153 Separate the two lists, junk the null: image.
7155 source=SplitImageList(source->previous);
7156 DeleteImageFromList(&source);
7159 if (source == (Image *) NULL)
7161 (void) ThrowMagickException(exception,GetMagickModule(),
7162 OptionError,"MissingNullSeparator","layers Composite");
7166 Adjust offset with gravity and virtual canvas.
7168 SetGeometry(image,&geometry);
7169 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7170 geometry.width=source->page.width != 0 ? source->page.width :
7172 geometry.height=source->page.height != 0 ? source->page.height :
7174 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7175 image->columns,image->page.height != 0 ? image->page.height :
7176 image->rows,image->gravity,&geometry);
7177 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7178 source=DestroyImageList(source);
7182 if (layers != (Image *) NULL)
7185 image=CloneImage(image,0,0,MagickTrue,exception);
7186 if (image == (Image *) NULL)
7188 for ( ; image; image=image->next)
7190 AddImageToRegistry(sv,image);
7192 av_push(av,sv_bless(rv,hv));
7195 exception=DestroyExceptionInfo(exception);
7197 SvREFCNT_dec(perl_exception);
7201 InheritPerlException(exception,perl_exception);
7202 exception=DestroyExceptionInfo(exception);
7203 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7204 SvPOK_on(perl_exception);
7205 ST(0)=sv_2mortal(perl_exception);
7210 ###############################################################################
7214 # M a g i c k T o M i m e #
7218 ###############################################################################
7222 MagickToMime(ref,name)
7223 Image::Magick ref=NO_INIT
7232 PERL_UNUSED_VAR(ref);
7233 PERL_UNUSED_VAR(ix);
7234 mime=MagickToMime(name);
7235 RETVAL=newSVpv(mime,0);
7236 mime=(char *) RelinquishMagickMemory(mime);
7242 ###############################################################################
7250 ###############################################################################
7255 Image::Magick ref=NO_INIT
7292 MedianConvolveImage = 36
7298 ReduceNoiseImage = 42
7324 ColorFloodfillImage= 68
7330 CycleColormapImage = 74
7340 MatteFloodfillImage= 84
7348 NumberColorsImage = 92
7358 SignatureImage = 102
7368 TransparentImage = 112
7370 ThresholdImage = 114
7384 DeconstructImage = 130
7386 GaussianBlurImage = 132
7392 UnsharpMaskImage = 138
7394 MotionBlurImage = 140
7396 OrderedDitherImage = 142
7403 AffineTransform = 149
7404 AffineTransformImage = 150
7406 DifferenceImage = 152
7407 AdaptiveThreshold = 153
7408 AdaptiveThresholdImage = 154
7413 BlackThreshold = 159
7414 BlackThresholdImage= 160
7415 WhiteThreshold = 161
7416 WhiteThresholdImage= 162
7417 RotationalBlur = 163
7418 RotationalBlurImage= 164
7420 ThumbnailImage = 166
7430 PosterizeImage = 176
7436 SepiaToneImage = 182
7437 SigmoidalContrast = 183
7438 SigmoidalContrastImage = 184
7443 ContrastStretch = 189
7444 ContrastStretchImage = 190
7449 AdaptiveSharpen = 195
7450 AdaptiveSharpenImage = 196
7452 TransposeImage = 198
7454 TransverseImage = 200
7456 AutoOrientImage = 202
7458 AdaptiveBlurImage = 204
7462 UniqueColorsImage = 208
7463 AdaptiveResize = 209
7464 AdaptiveResizeImage= 210
7468 LinearStretchImage = 214
7470 ColorMatrixImage = 216
7475 FloodfillPaint = 221
7476 FloodfillPaintImage= 222
7482 LiquidRescaleImage = 228
7492 SparseColorImage = 238
7496 SelectiveBlurImage = 242
7500 BlueShiftImage = 246
7501 ForwardFourierTransform = 247
7502 ForwardFourierTransformImage = 248
7503 InverseFourierTransform = 249
7504 InverseFourierTransformImage = 250
7505 ColorDecisionList = 251
7506 ColorDecisionListImage = 252
7508 AutoGammaImage = 254
7510 AutoLevelImage = 256
7512 LevelImageColors = 258
7515 BrightnessContrast = 261
7516 BrightnessContrastImage = 262
7518 MorphologyImage = 264
7524 StatisticImage = 270
7526 PerceptibleImage = 272
7530 GrayscaleImage = 276
7532 CannyEdgeImage = 279
7541 attribute_flag[MaxArguments],
7542 message[MaxTextExtent];
7603 argument_list[MaxArguments];
7605 PERL_UNUSED_VAR(ref);
7606 PERL_UNUSED_VAR(ix);
7607 exception=AcquireExceptionInfo();
7608 perl_exception=newSVpv("",0);
7609 reference_vector=NULL;
7613 if (sv_isobject(ST(0)) == 0)
7615 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7619 reference=SvRV(ST(0));
7620 region_info.width=0;
7621 region_info.height=0;
7624 region_image=(Image *) NULL;
7625 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7626 if (ix && (ix != 666))
7629 Called as Method(...)
7632 rp=(&Methods[ix-1]);
7638 Called as Mogrify("Method",...)
7640 attribute=(char *) SvPV(ST(1),na);
7643 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7644 attribute=(char *) SvPV(ST(2),na);
7647 for (rp=Methods; ; rp++)
7649 if (rp >= EndOf(Methods))
7651 ThrowPerlException(exception,OptionError,
7652 "UnrecognizedPerlMagickMethod",attribute);
7655 if (strEQcase(attribute,rp->name))
7661 if (image == (Image *) NULL)
7663 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7666 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7667 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7668 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7685 pp=(Arguments *) NULL;
7693 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7695 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7697 if (strEQcase(attribute,qq->method) > ssize_test)
7700 ssize_test=strEQcase(attribute,qq->method);
7703 if (pp == (Arguments *) NULL)
7705 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7707 goto continue_outer_loop;
7709 al=(&argument_list[pp-rp->arguments]);
7712 case ArrayReference:
7714 if (SvTYPE(sv) != SVt_RV)
7716 (void) FormatLocaleString(message,MaxTextExtent,
7717 "invalid %.60s value",pp->method);
7718 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7719 goto continue_outer_loop;
7721 al->array_reference=SvRV(sv);
7726 al->real_reference=SvNV(sv);
7731 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7734 case ImageReference:
7736 if (!sv_isobject(sv) ||
7737 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7738 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7740 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7746 case IntegerReference:
7748 al->integer_reference=SvIV(sv);
7751 case StringReference:
7753 al->string_reference=(char *) SvPV(sv,al->length);
7754 if (sv_isobject(sv))
7755 al->image_reference=SetupList(aTHX_ SvRV(sv),
7756 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7762 Is a string; look up name.
7764 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7766 al->string_reference=(char *) SvPV(sv,al->length);
7767 al->integer_reference=(-1);
7770 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7771 MagickFalse,SvPV(sv,na));
7772 if (pp->type == MagickChannelOptions)
7773 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7774 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7776 (void) FormatLocaleString(message,MaxTextExtent,
7777 "invalid %.60s value",pp->method);
7778 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7779 goto continue_outer_loop;
7784 attribute_flag[pp-rp->arguments]++;
7785 continue_outer_loop: ;
7787 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7788 pv=reference_vector;
7789 SetGeometryInfo(&geometry_info);
7790 channel=DefaultChannels;
7791 for (next=image; next; next=next->next)
7794 SetGeometry(image,&geometry);
7795 if ((region_info.width*region_info.height) != 0)
7798 image=CropImage(image,®ion_info,exception);
7804 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7805 ThrowPerlException(exception,OptionError,
7806 "UnrecognizedPerlMagickMethod",message);
7809 case 1: /* Comment */
7811 if (attribute_flag[0] == 0)
7812 argument_list[0].string_reference=(char *) NULL;
7813 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7814 info ? info->image_info : (ImageInfo *) NULL,image,
7815 argument_list[0].string_reference,exception),exception);
7820 if (attribute_flag[0] == 0)
7821 argument_list[0].string_reference=(char *) NULL;
7822 (void) SetImageProperty(image,"label",InterpretImageProperties(
7823 info ? info->image_info : (ImageInfo *) NULL,image,
7824 argument_list[0].string_reference,exception),exception);
7827 case 3: /* AddNoise */
7832 if (attribute_flag[0] == 0)
7833 argument_list[0].integer_reference=UniformNoise;
7835 if (attribute_flag[1] != 0)
7836 attenuate=argument_list[1].real_reference;
7837 if (attribute_flag[2] != 0)
7838 channel=(ChannelType) argument_list[2].integer_reference;
7839 channel_mask=SetImageChannelMask(image,channel);
7840 image=AddNoiseImage(image,(NoiseType)
7841 argument_list[0].integer_reference,attenuate,exception);
7842 if (image != (Image *) NULL)
7843 (void) SetImageChannelMask(image,channel_mask);
7846 case 4: /* Colorize */
7851 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7852 0,0,&target,exception);
7853 if (attribute_flag[0] != 0)
7854 (void) QueryColorCompliance(argument_list[0].string_reference,
7855 AllCompliance,&target,exception);
7856 if (attribute_flag[1] == 0)
7857 argument_list[1].string_reference="100%";
7858 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7862 case 5: /* Border */
7869 if (attribute_flag[0] != 0)
7870 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7871 &geometry,exception);
7872 if (attribute_flag[1] != 0)
7873 geometry.width=argument_list[1].integer_reference;
7874 if (attribute_flag[2] != 0)
7875 geometry.height=argument_list[2].integer_reference;
7876 if (attribute_flag[3] != 0)
7877 QueryColorCompliance(argument_list[3].string_reference,
7878 AllCompliance,&image->border_color,exception);
7879 if (attribute_flag[4] != 0)
7880 QueryColorCompliance(argument_list[4].string_reference,
7881 AllCompliance,&image->border_color,exception);
7882 if (attribute_flag[5] != 0)
7883 QueryColorCompliance(argument_list[5].string_reference,
7884 AllCompliance,&image->border_color,exception);
7885 compose=image->compose;
7886 if (attribute_flag[6] != 0)
7887 compose=(CompositeOperator) argument_list[6].integer_reference;
7888 image=BorderImage(image,&geometry,compose,exception);
7893 if (attribute_flag[0] != 0)
7895 flags=ParseGeometry(argument_list[0].string_reference,
7897 if ((flags & SigmaValue) == 0)
7898 geometry_info.sigma=1.0;
7900 if (attribute_flag[1] != 0)
7901 geometry_info.rho=argument_list[1].real_reference;
7902 if (attribute_flag[2] != 0)
7903 geometry_info.sigma=argument_list[2].real_reference;
7904 if (attribute_flag[3] != 0)
7905 channel=(ChannelType) argument_list[3].integer_reference;
7906 channel_mask=SetImageChannelMask(image,channel);
7907 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7909 if (image != (Image *) NULL)
7910 (void) SetImageChannelMask(image,channel_mask);
7915 if (attribute_flag[0] != 0)
7916 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7917 &geometry,exception);
7918 if (attribute_flag[1] != 0)
7919 geometry.width=argument_list[1].integer_reference;
7920 if (attribute_flag[2] != 0)
7921 geometry.height=argument_list[2].integer_reference;
7922 if (attribute_flag[3] != 0)
7923 geometry.x=argument_list[3].integer_reference;
7924 if (attribute_flag[4] != 0)
7925 geometry.y=argument_list[4].integer_reference;
7926 image=ChopImage(image,&geometry,exception);
7931 if (attribute_flag[6] != 0)
7932 image->gravity=(GravityType) argument_list[6].integer_reference;
7933 if (attribute_flag[0] != 0)
7934 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7935 &geometry,exception);
7936 if (attribute_flag[1] != 0)
7937 geometry.width=argument_list[1].integer_reference;
7938 if (attribute_flag[2] != 0)
7939 geometry.height=argument_list[2].integer_reference;
7940 if (attribute_flag[3] != 0)
7941 geometry.x=argument_list[3].integer_reference;
7942 if (attribute_flag[4] != 0)
7943 geometry.y=argument_list[4].integer_reference;
7944 if (attribute_flag[5] != 0)
7945 image->fuzz=StringToDoubleInterval(
7946 argument_list[5].string_reference,(double) QuantumRange+1.0);
7947 image=CropImage(image,&geometry,exception);
7950 case 9: /* Despeckle */
7952 image=DespeckleImage(image,exception);
7957 if (attribute_flag[0] != 0)
7958 geometry_info.rho=argument_list[0].real_reference;
7959 image=EdgeImage(image,geometry_info.rho,exception);
7962 case 11: /* Emboss */
7964 if (attribute_flag[0] != 0)
7966 flags=ParseGeometry(argument_list[0].string_reference,
7968 if ((flags & SigmaValue) == 0)
7969 geometry_info.sigma=1.0;
7971 if (attribute_flag[1] != 0)
7972 geometry_info.rho=argument_list[1].real_reference;
7973 if (attribute_flag[2] != 0)
7974 geometry_info.sigma=argument_list[2].real_reference;
7975 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7979 case 12: /* Enhance */
7981 image=EnhanceImage(image,exception);
7986 image=FlipImage(image,exception);
7991 image=FlopImage(image,exception);
7994 case 15: /* Frame */
8002 if (attribute_flag[0] != 0)
8004 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8005 &geometry,exception);
8006 frame_info.width=geometry.width;
8007 frame_info.height=geometry.height;
8008 frame_info.outer_bevel=geometry.x;
8009 frame_info.inner_bevel=geometry.y;
8011 if (attribute_flag[1] != 0)
8012 frame_info.width=argument_list[1].integer_reference;
8013 if (attribute_flag[2] != 0)
8014 frame_info.height=argument_list[2].integer_reference;
8015 if (attribute_flag[3] != 0)
8016 frame_info.inner_bevel=argument_list[3].integer_reference;
8017 if (attribute_flag[4] != 0)
8018 frame_info.outer_bevel=argument_list[4].integer_reference;
8019 if (attribute_flag[5] != 0)
8020 QueryColorCompliance(argument_list[5].string_reference,
8021 AllCompliance,&fill_color,exception);
8022 if (attribute_flag[6] != 0)
8023 QueryColorCompliance(argument_list[6].string_reference,
8024 AllCompliance,&fill_color,exception);
8025 frame_info.x=(ssize_t) frame_info.width;
8026 frame_info.y=(ssize_t) frame_info.height;
8027 frame_info.width=image->columns+2*frame_info.x;
8028 frame_info.height=image->rows+2*frame_info.y;
8029 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8030 image->matte_color=fill_color;
8031 compose=image->compose;
8032 if (attribute_flag[7] != 0)
8033 compose=(CompositeOperator) argument_list[7].integer_reference;
8034 image=FrameImage(image,&frame_info,compose,exception);
8037 case 16: /* Implode */
8039 PixelInterpolateMethod
8042 if (attribute_flag[0] == 0)
8043 argument_list[0].real_reference=0.5;
8044 method=UndefinedInterpolatePixel;
8045 if (attribute_flag[1] != 0)
8046 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8047 image=ImplodeImage(image,argument_list[0].real_reference,
8051 case 17: /* Magnify */
8053 image=MagnifyImage(image,exception);
8056 case 18: /* MedianFilter */
8058 if (attribute_flag[0] != 0)
8060 flags=ParseGeometry(argument_list[0].string_reference,
8062 if ((flags & SigmaValue) == 0)
8063 geometry_info.sigma=geometry_info.rho;
8065 if (attribute_flag[1] != 0)
8066 geometry_info.rho=argument_list[1].real_reference;
8067 if (attribute_flag[2] != 0)
8068 geometry_info.sigma=argument_list[2].real_reference;
8069 if (attribute_flag[3] != 0)
8070 channel=(ChannelType) argument_list[3].integer_reference;
8071 channel_mask=SetImageChannelMask(image,channel);
8072 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8073 (size_t) geometry_info.sigma,exception);
8074 if (image != (Image *) NULL)
8075 (void) SetImageChannelMask(image,channel_mask);
8078 case 19: /* Minify */
8080 image=MinifyImage(image,exception);
8083 case 20: /* OilPaint */
8085 if (attribute_flag[0] == 0)
8086 argument_list[0].real_reference=0.0;
8087 if (attribute_flag[1] == 0)
8088 argument_list[1].real_reference=1.0;
8089 image=OilPaintImage(image,argument_list[0].real_reference,
8090 argument_list[1].real_reference,exception);
8093 case 21: /* ReduceNoise */
8095 if (attribute_flag[0] != 0)
8097 flags=ParseGeometry(argument_list[0].string_reference,
8099 if ((flags & SigmaValue) == 0)
8100 geometry_info.sigma=1.0;
8102 if (attribute_flag[1] != 0)
8103 geometry_info.rho=argument_list[1].real_reference;
8104 if (attribute_flag[2] != 0)
8105 geometry_info.sigma=argument_list[2].real_reference;
8106 if (attribute_flag[3] != 0)
8107 channel=(ChannelType) argument_list[3].integer_reference;
8108 channel_mask=SetImageChannelMask(image,channel);
8109 image=StatisticImage(image,NonpeakStatistic,(size_t)
8110 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8111 if (image != (Image *) NULL)
8112 (void) SetImageChannelMask(image,channel_mask);
8117 if (attribute_flag[0] != 0)
8118 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8119 &geometry,exception);
8120 if (attribute_flag[1] != 0)
8121 geometry.x=argument_list[1].integer_reference;
8122 if (attribute_flag[2] != 0)
8123 geometry.y=argument_list[2].integer_reference;
8124 image=RollImage(image,geometry.x,geometry.y,exception);
8127 case 23: /* Rotate */
8129 if (attribute_flag[0] == 0)
8130 argument_list[0].real_reference=90.0;
8131 if (attribute_flag[1] != 0)
8133 QueryColorCompliance(argument_list[1].string_reference,
8134 AllCompliance,&image->background_color,exception);
8135 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
8136 (image->alpha_trait != BlendPixelTrait))
8137 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8139 image=RotateImage(image,argument_list[0].real_reference,exception);
8142 case 24: /* Sample */
8144 if (attribute_flag[0] != 0)
8145 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8146 &geometry,exception);
8147 if (attribute_flag[1] != 0)
8148 geometry.width=argument_list[1].integer_reference;
8149 if (attribute_flag[2] != 0)
8150 geometry.height=argument_list[2].integer_reference;
8151 image=SampleImage(image,geometry.width,geometry.height,exception);
8154 case 25: /* Scale */
8156 if (attribute_flag[0] != 0)
8157 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8158 &geometry,exception);
8159 if (attribute_flag[1] != 0)
8160 geometry.width=argument_list[1].integer_reference;
8161 if (attribute_flag[2] != 0)
8162 geometry.height=argument_list[2].integer_reference;
8163 image=ScaleImage(image,geometry.width,geometry.height,exception);
8166 case 26: /* Shade */
8168 if (attribute_flag[0] != 0)
8170 flags=ParseGeometry(argument_list[0].string_reference,
8172 if ((flags & SigmaValue) == 0)
8173 geometry_info.sigma=0.0;
8175 if (attribute_flag[1] != 0)
8176 geometry_info.rho=argument_list[1].real_reference;
8177 if (attribute_flag[2] != 0)
8178 geometry_info.sigma=argument_list[2].real_reference;
8179 image=ShadeImage(image,
8180 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8181 geometry_info.rho,geometry_info.sigma,exception);
8184 case 27: /* Sharpen */
8186 if (attribute_flag[0] != 0)
8188 flags=ParseGeometry(argument_list[0].string_reference,
8190 if ((flags & SigmaValue) == 0)
8191 geometry_info.sigma=1.0;
8193 if (attribute_flag[1] != 0)
8194 geometry_info.rho=argument_list[1].real_reference;
8195 if (attribute_flag[2] != 0)
8196 geometry_info.sigma=argument_list[2].real_reference;
8197 if (attribute_flag[3] != 0)
8198 channel=(ChannelType) argument_list[3].integer_reference;
8199 channel_mask=SetImageChannelMask(image,channel);
8200 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8202 if (image != (Image *) NULL)
8203 (void) SetImageChannelMask(image,channel_mask);
8206 case 28: /* Shear */
8208 if (attribute_flag[0] != 0)
8210 flags=ParseGeometry(argument_list[0].string_reference,
8212 if ((flags & SigmaValue) == 0)
8213 geometry_info.sigma=geometry_info.rho;
8215 if (attribute_flag[1] != 0)
8216 geometry_info.rho=argument_list[1].real_reference;
8217 if (attribute_flag[2] != 0)
8218 geometry_info.sigma=argument_list[2].real_reference;
8219 if (attribute_flag[3] != 0)
8220 QueryColorCompliance(argument_list[3].string_reference,
8221 AllCompliance,&image->background_color,exception);
8222 if (attribute_flag[4] != 0)
8223 QueryColorCompliance(argument_list[4].string_reference,
8224 AllCompliance,&image->background_color,exception);
8225 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8229 case 29: /* Spread */
8231 PixelInterpolateMethod
8234 if (attribute_flag[0] == 0)
8235 argument_list[0].real_reference=1.0;
8236 method=UndefinedInterpolatePixel;
8237 if (attribute_flag[1] != 0)
8238 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8239 image=SpreadImage(image,argument_list[0].real_reference,method,
8243 case 30: /* Swirl */
8245 PixelInterpolateMethod
8248 if (attribute_flag[0] == 0)
8249 argument_list[0].real_reference=50.0;
8250 method=UndefinedInterpolatePixel;
8251 if (attribute_flag[1] != 0)
8252 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8253 image=SwirlImage(image,argument_list[0].real_reference,
8257 case 31: /* Resize */
8260 if (attribute_flag[0] != 0)
8261 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8262 &geometry,exception);
8263 if (attribute_flag[1] != 0)
8264 geometry.width=argument_list[1].integer_reference;
8265 if (attribute_flag[2] != 0)
8266 geometry.height=argument_list[2].integer_reference;
8267 if (attribute_flag[3] == 0)
8268 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8269 if (attribute_flag[4] != 0)
8270 SetImageArtifact(image,"filter:support",
8271 argument_list[4].string_reference);
8272 image=ResizeImage(image,geometry.width,geometry.height,
8273 (FilterTypes) argument_list[3].integer_reference,
8277 case 33: /* Annotate */
8282 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8284 if (attribute_flag[0] != 0)
8289 text=InterpretImageProperties(info ? info->image_info :
8290 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8292 (void) CloneString(&draw_info->text,text);
8293 text=DestroyString(text);
8295 if (attribute_flag[1] != 0)
8296 (void) CloneString(&draw_info->font,
8297 argument_list[1].string_reference);
8298 if (attribute_flag[2] != 0)
8299 draw_info->pointsize=argument_list[2].real_reference;
8300 if (attribute_flag[3] != 0)
8301 (void) CloneString(&draw_info->density,
8302 argument_list[3].string_reference);
8303 if (attribute_flag[4] != 0)
8304 (void) QueryColorCompliance(argument_list[4].string_reference,
8305 AllCompliance,&draw_info->undercolor,exception);
8306 if (attribute_flag[5] != 0)
8308 (void) QueryColorCompliance(argument_list[5].string_reference,
8309 AllCompliance,&draw_info->stroke,exception);
8310 if (argument_list[5].image_reference != (Image *) NULL)
8311 draw_info->stroke_pattern=CloneImage(
8312 argument_list[5].image_reference,0,0,MagickTrue,exception);
8314 if (attribute_flag[6] != 0)
8316 (void) QueryColorCompliance(argument_list[6].string_reference,
8317 AllCompliance,&draw_info->fill,exception);
8318 if (argument_list[6].image_reference != (Image *) NULL)
8319 draw_info->fill_pattern=CloneImage(
8320 argument_list[6].image_reference,0,0,MagickTrue,exception);
8322 if (attribute_flag[7] != 0)
8324 (void) CloneString(&draw_info->geometry,
8325 argument_list[7].string_reference);
8326 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8327 &geometry,exception);
8328 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8329 geometry_info.sigma=geometry_info.xi;
8331 if (attribute_flag[8] != 0)
8332 (void) QueryColorCompliance(argument_list[8].string_reference,
8333 AllCompliance,&draw_info->fill,exception);
8334 if (attribute_flag[11] != 0)
8335 draw_info->gravity=(GravityType)
8336 argument_list[11].integer_reference;
8337 if (attribute_flag[25] != 0)
8342 av=(AV *) argument_list[25].array_reference;
8343 if ((av_len(av) != 3) && (av_len(av) != 5))
8345 ThrowPerlException(exception,OptionError,
8346 "affine matrix must have 4 or 6 elements",PackageName);
8349 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8350 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8351 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8352 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8353 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8354 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8356 ThrowPerlException(exception,OptionError,
8357 "affine matrix is singular",PackageName);
8360 if (av_len(av) == 5)
8362 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8363 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8366 for (j=12; j < 17; j++)
8368 if (attribute_flag[j] == 0)
8370 value=argument_list[j].string_reference;
8371 angle=argument_list[j].real_reference;
8372 current=draw_info->affine;
8373 GetAffineMatrix(&affine);
8381 flags=ParseGeometry(value,&geometry_info);
8382 affine.tx=geometry_info.xi;
8383 affine.ty=geometry_info.psi;
8384 if ((flags & PsiValue) == 0)
8385 affine.ty=affine.tx;
8393 flags=ParseGeometry(value,&geometry_info);
8394 affine.sx=geometry_info.rho;
8395 affine.sy=geometry_info.sigma;
8396 if ((flags & SigmaValue) == 0)
8397 affine.sy=affine.sx;
8407 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8408 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8409 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8410 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8418 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8426 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8430 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8431 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8432 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8433 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8434 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8436 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8439 if (attribute_flag[9] == 0)
8440 argument_list[9].real_reference=0.0;
8441 if (attribute_flag[10] == 0)
8442 argument_list[10].real_reference=0.0;
8443 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8446 geometry[MaxTextExtent];
8448 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8449 (double) argument_list[9].real_reference+draw_info->affine.tx,
8450 (double) argument_list[10].real_reference+draw_info->affine.ty);
8451 (void) CloneString(&draw_info->geometry,geometry);
8453 if (attribute_flag[17] != 0)
8454 draw_info->stroke_width=argument_list[17].real_reference;
8455 if (attribute_flag[18] != 0)
8457 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8458 MagickTrue : MagickFalse;
8459 draw_info->stroke_antialias=draw_info->text_antialias;
8461 if (attribute_flag[19] != 0)
8462 (void) CloneString(&draw_info->family,
8463 argument_list[19].string_reference);
8464 if (attribute_flag[20] != 0)
8465 draw_info->style=(StyleType) argument_list[20].integer_reference;
8466 if (attribute_flag[21] != 0)
8467 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8468 if (attribute_flag[22] != 0)
8469 draw_info->weight=argument_list[22].integer_reference;
8470 if (attribute_flag[23] != 0)
8471 draw_info->align=(AlignType) argument_list[23].integer_reference;
8472 if (attribute_flag[24] != 0)
8473 (void) CloneString(&draw_info->encoding,
8474 argument_list[24].string_reference);
8475 if (attribute_flag[25] != 0)
8476 draw_info->fill_pattern=CloneImage(
8477 argument_list[25].image_reference,0,0,MagickTrue,exception);
8478 if (attribute_flag[26] != 0)
8479 draw_info->fill_pattern=CloneImage(
8480 argument_list[26].image_reference,0,0,MagickTrue,exception);
8481 if (attribute_flag[27] != 0)
8482 draw_info->stroke_pattern=CloneImage(
8483 argument_list[27].image_reference,0,0,MagickTrue,exception);
8484 if (attribute_flag[29] != 0)
8485 draw_info->kerning=argument_list[29].real_reference;
8486 if (attribute_flag[30] != 0)
8487 draw_info->interline_spacing=argument_list[30].real_reference;
8488 if (attribute_flag[31] != 0)
8489 draw_info->interword_spacing=argument_list[31].real_reference;
8490 if (attribute_flag[32] != 0)
8491 draw_info->direction=(DirectionType)
8492 argument_list[32].integer_reference;
8493 (void) AnnotateImage(image,draw_info,exception);
8494 draw_info=DestroyDrawInfo(draw_info);
8497 case 34: /* ColorFloodfill */
8508 draw_info=CloneDrawInfo(info ? info->image_info :
8509 (ImageInfo *) NULL,(DrawInfo *) NULL);
8510 if (attribute_flag[0] != 0)
8511 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8512 &geometry,exception);
8513 if (attribute_flag[1] != 0)
8514 geometry.x=argument_list[1].integer_reference;
8515 if (attribute_flag[2] != 0)
8516 geometry.y=argument_list[2].integer_reference;
8517 if (attribute_flag[3] != 0)
8518 (void) QueryColorCompliance(argument_list[3].string_reference,
8519 AllCompliance,&draw_info->fill,exception);
8520 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8521 geometry.x,geometry.y,&target,exception);
8523 if (attribute_flag[4] != 0)
8525 QueryColorCompliance(argument_list[4].string_reference,
8526 AllCompliance,&target,exception);
8529 if (attribute_flag[5] != 0)
8530 image->fuzz=StringToDoubleInterval(
8531 argument_list[5].string_reference,(double) QuantumRange+1.0);
8532 if (attribute_flag[6] != 0)
8533 invert=(MagickBooleanType) argument_list[6].integer_reference;
8534 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8535 geometry.y,invert,exception);
8536 draw_info=DestroyDrawInfo(draw_info);
8539 case 35: /* Composite */
8542 composite_geometry[MaxTextExtent];
8551 compose=OverCompositeOp;
8552 if (attribute_flag[0] != 0)
8553 composite_image=argument_list[0].image_reference;
8556 ThrowPerlException(exception,OptionError,
8557 "CompositeImageRequired",PackageName);
8561 Parameter Handling used for BOTH normal and tiled composition.
8563 if (attribute_flag[1] != 0) /* compose */
8564 compose=(CompositeOperator) argument_list[1].integer_reference;
8565 if (attribute_flag[6] != 0) /* opacity */
8567 if (compose != DissolveCompositeOp)
8568 (void) SetImageAlpha(composite_image,(Quantum)
8569 StringToDoubleInterval(argument_list[6].string_reference,
8570 (double) QuantumRange+1.0),exception);
8592 Handle dissolve composite operator (patch by
8595 (void) CloneString(&image->geometry,
8596 argument_list[6].string_reference);
8597 opacity=(Quantum) StringToDoubleInterval(
8598 argument_list[6].string_reference,(double) QuantumRange+
8600 if (composite_image->alpha_trait == BlendPixelTrait)
8601 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8602 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8603 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8605 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8606 composite_image->columns,1,exception);
8607 for (x=0; x < (ssize_t) composite_image->columns; x++)
8609 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8610 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8612 q+=GetPixelChannels(composite_image);
8614 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8615 if (sync == MagickFalse)
8618 composite_view=DestroyCacheView(composite_view);
8621 if (attribute_flag[9] != 0) /* "color=>" */
8622 QueryColorCompliance(argument_list[9].string_reference,
8623 AllCompliance,&composite_image->background_color,exception);
8624 if (attribute_flag[12] != 0) /* "interpolate=>" */
8625 image->interpolate=(PixelInterpolateMethod)
8626 argument_list[12].integer_reference;
8627 if (attribute_flag[13] != 0) /* "args=>" */
8628 (void) SetImageArtifact(composite_image,"compose:args",
8629 argument_list[13].string_reference);
8630 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8631 (void) SetImageArtifact(composite_image,"compose:args",
8632 argument_list[14].string_reference);
8633 clip_to_self=MagickTrue;
8634 if (attribute_flag[15] != 0)
8635 clip_to_self=(MagickBooleanType)
8636 argument_list[15].integer_reference;
8638 Tiling Composition (with orthogonal rotate).
8640 rotate_image=(Image *) NULL;
8641 if (attribute_flag[8] != 0) /* "rotate=>" */
8646 rotate_image=RotateImage(composite_image,
8647 argument_list[8].real_reference,exception);
8648 if (rotate_image == (Image *) NULL)
8651 if ((attribute_flag[7] != 0) &&
8652 (argument_list[7].integer_reference != 0)) /* tile */
8659 Tile the composite image.
8661 if (attribute_flag[8] != 0) /* "tile=>" */
8662 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8665 (void) SetImageArtifact(composite_image,
8666 "compose:outside-overlay","false");
8667 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8668 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8670 if (attribute_flag[8] != 0) /* rotate */
8671 (void) CompositeImage(image,rotate_image,compose,
8672 MagickTrue,x,y,exception);
8674 (void) CompositeImage(image,composite_image,compose,
8675 MagickTrue,x,y,exception);
8677 if (attribute_flag[8] != 0) /* rotate */
8678 rotate_image=DestroyImage(rotate_image);
8682 Parameter Handling used used ONLY for normal composition.
8684 if (attribute_flag[5] != 0) /* gravity */
8685 image->gravity=(GravityType) argument_list[5].integer_reference;
8686 if (attribute_flag[2] != 0) /* geometry offset */
8688 SetGeometry(image,&geometry);
8689 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8691 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8694 if (attribute_flag[3] != 0) /* x offset */
8695 geometry.x=argument_list[3].integer_reference;
8696 if (attribute_flag[4] != 0) /* y offset */
8697 geometry.y=argument_list[4].integer_reference;
8698 if (attribute_flag[10] != 0) /* mask */
8700 if ((image->compose == DisplaceCompositeOp) ||
8701 (image->compose == DistortCompositeOp))
8704 Merge Y displacement into X displacement image.
8706 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8708 (void) CompositeImage(composite_image,
8709 argument_list[10].image_reference,CopyGreenCompositeOp,
8710 MagickTrue,0,0,exception);
8718 Set a blending mask for the composition.
8720 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8721 MagickTrue,exception);
8722 (void) SetImageMask(composite_image,mask_image,exception);
8723 mask_image=DestroyImage(mask_image);
8726 if (attribute_flag[11] != 0) /* channel */
8727 channel=(ChannelType) argument_list[11].integer_reference;
8729 Composite two images (normal composition).
8731 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8732 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8733 (double) composite_image->rows,(double) geometry.x,(double)
8735 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8737 channel_mask=SetImageChannelMask(image,channel);
8738 if (attribute_flag[8] == 0) /* no rotate */
8739 CompositeImage(image,composite_image,compose,clip_to_self,
8740 geometry.x,geometry.y,exception);
8744 Position adjust rotated image then composite.
8746 geometry.x-=(ssize_t) (rotate_image->columns-
8747 composite_image->columns)/2;
8748 geometry.y-=(ssize_t) (rotate_image->rows-
8749 composite_image->rows)/2;
8750 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8751 geometry.y,exception);
8752 rotate_image=DestroyImage(rotate_image);
8754 if (attribute_flag[10] != 0) /* mask */
8756 if ((image->compose == DisplaceCompositeOp) ||
8757 (image->compose == DistortCompositeOp))
8758 composite_image=DestroyImage(composite_image);
8760 (void) SetImageMask(image,(Image *) NULL,exception);
8762 (void) SetImageChannelMask(image,channel_mask);
8765 case 36: /* Contrast */
8767 if (attribute_flag[0] == 0)
8768 argument_list[0].integer_reference=0;
8769 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8770 MagickTrue : MagickFalse,exception);
8773 case 37: /* CycleColormap */
8775 if (attribute_flag[0] == 0)
8776 argument_list[0].integer_reference=6;
8777 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8786 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8788 (void) CloneString(&draw_info->primitive,"point");
8789 if (attribute_flag[0] != 0)
8791 if (argument_list[0].integer_reference < 0)
8792 (void) CloneString(&draw_info->primitive,
8793 argument_list[0].string_reference);
8795 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8796 MagickPrimitiveOptions,argument_list[0].integer_reference));
8798 if (attribute_flag[1] != 0)
8800 if (LocaleCompare(draw_info->primitive,"path") == 0)
8802 (void) ConcatenateString(&draw_info->primitive," '");
8803 ConcatenateString(&draw_info->primitive,
8804 argument_list[1].string_reference);
8805 (void) ConcatenateString(&draw_info->primitive,"'");
8809 (void) ConcatenateString(&draw_info->primitive," ");
8810 ConcatenateString(&draw_info->primitive,
8811 argument_list[1].string_reference);
8814 if (attribute_flag[2] != 0)
8816 (void) ConcatenateString(&draw_info->primitive," ");
8817 (void) ConcatenateString(&draw_info->primitive,
8818 CommandOptionToMnemonic(MagickMethodOptions,
8819 argument_list[2].integer_reference));
8821 if (attribute_flag[3] != 0)
8823 (void) QueryColorCompliance(argument_list[3].string_reference,
8824 AllCompliance,&draw_info->stroke,exception);
8825 if (argument_list[3].image_reference != (Image *) NULL)
8826 draw_info->stroke_pattern=CloneImage(
8827 argument_list[3].image_reference,0,0,MagickTrue,exception);
8829 if (attribute_flag[4] != 0)
8831 (void) QueryColorCompliance(argument_list[4].string_reference,
8832 AllCompliance,&draw_info->fill,exception);
8833 if (argument_list[4].image_reference != (Image *) NULL)
8834 draw_info->fill_pattern=CloneImage(
8835 argument_list[4].image_reference,0,0,MagickTrue,exception);
8837 if (attribute_flag[5] != 0)
8838 draw_info->stroke_width=argument_list[5].real_reference;
8839 if (attribute_flag[6] != 0)
8840 (void) CloneString(&draw_info->font,
8841 argument_list[6].string_reference);
8842 if (attribute_flag[7] != 0)
8843 (void) QueryColorCompliance(argument_list[7].string_reference,
8844 AllCompliance,&draw_info->border_color,exception);
8845 if (attribute_flag[8] != 0)
8846 draw_info->affine.tx=argument_list[8].real_reference;
8847 if (attribute_flag[9] != 0)
8848 draw_info->affine.ty=argument_list[9].real_reference;
8849 if (attribute_flag[20] != 0)
8854 av=(AV *) argument_list[20].array_reference;
8855 if ((av_len(av) != 3) && (av_len(av) != 5))
8857 ThrowPerlException(exception,OptionError,
8858 "affine matrix must have 4 or 6 elements",PackageName);
8861 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8862 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8863 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8864 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8865 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8866 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8868 ThrowPerlException(exception,OptionError,
8869 "affine matrix is singular",PackageName);
8872 if (av_len(av) == 5)
8874 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8875 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8878 for (j=10; j < 15; j++)
8880 if (attribute_flag[j] == 0)
8882 value=argument_list[j].string_reference;
8883 angle=argument_list[j].real_reference;
8884 current=draw_info->affine;
8885 GetAffineMatrix(&affine);
8893 flags=ParseGeometry(value,&geometry_info);
8894 affine.tx=geometry_info.xi;
8895 affine.ty=geometry_info.psi;
8896 if ((flags & PsiValue) == 0)
8897 affine.ty=affine.tx;
8905 flags=ParseGeometry(value,&geometry_info);
8906 affine.sx=geometry_info.rho;
8907 affine.sy=geometry_info.sigma;
8908 if ((flags & SigmaValue) == 0)
8909 affine.sy=affine.sx;
8919 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8920 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8921 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8922 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8930 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8938 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8942 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8943 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8944 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8945 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8946 draw_info->affine.tx=
8947 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8948 draw_info->affine.ty=
8949 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8951 if (attribute_flag[15] != 0)
8952 draw_info->fill_pattern=CloneImage(
8953 argument_list[15].image_reference,0,0,MagickTrue,exception);
8954 if (attribute_flag[16] != 0)
8955 draw_info->pointsize=argument_list[16].real_reference;
8956 if (attribute_flag[17] != 0)
8958 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8959 ? MagickTrue : MagickFalse;
8960 draw_info->text_antialias=draw_info->stroke_antialias;
8962 if (attribute_flag[18] != 0)
8963 (void) CloneString(&draw_info->density,
8964 argument_list[18].string_reference);
8965 if (attribute_flag[19] != 0)
8966 draw_info->stroke_width=argument_list[19].real_reference;
8967 if (attribute_flag[21] != 0)
8968 draw_info->dash_offset=argument_list[21].real_reference;
8969 if (attribute_flag[22] != 0)
8974 av=(AV *) argument_list[22].array_reference;
8975 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8976 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8977 if (draw_info->dash_pattern != (double *) NULL)
8979 for (i=0; i <= av_len(av); i++)
8980 draw_info->dash_pattern[i]=(double)
8981 SvNV(*(av_fetch(av,i,0)));
8982 draw_info->dash_pattern[i]=0.0;
8985 if (attribute_flag[23] != 0)
8986 image->interpolate=(PixelInterpolateMethod)
8987 argument_list[23].integer_reference;
8988 if ((attribute_flag[24] != 0) &&
8989 (draw_info->fill_pattern != (Image *) NULL))
8990 flags=ParsePageGeometry(draw_info->fill_pattern,
8991 argument_list[24].string_reference,
8992 &draw_info->fill_pattern->tile_offset,exception);
8993 if (attribute_flag[25] != 0)
8995 (void) ConcatenateString(&draw_info->primitive," '");
8996 (void) ConcatenateString(&draw_info->primitive,
8997 argument_list[25].string_reference);
8998 (void) ConcatenateString(&draw_info->primitive,"'");
9000 if (attribute_flag[26] != 0)
9001 draw_info->fill_pattern=CloneImage(
9002 argument_list[26].image_reference,0,0,MagickTrue,exception);
9003 if (attribute_flag[27] != 0)
9004 draw_info->stroke_pattern=CloneImage(
9005 argument_list[27].image_reference,0,0,MagickTrue,exception);
9006 if (attribute_flag[28] != 0)
9007 (void) CloneString(&draw_info->primitive,
9008 argument_list[28].string_reference);
9009 if (attribute_flag[29] != 0)
9010 draw_info->kerning=argument_list[29].real_reference;
9011 if (attribute_flag[30] != 0)
9012 draw_info->interline_spacing=argument_list[30].real_reference;
9013 if (attribute_flag[31] != 0)
9014 draw_info->interword_spacing=argument_list[31].real_reference;
9015 if (attribute_flag[32] != 0)
9016 draw_info->direction=(DirectionType)
9017 argument_list[32].integer_reference;
9018 DrawImage(image,draw_info,exception);
9019 draw_info=DestroyDrawInfo(draw_info);
9022 case 39: /* Equalize */
9024 if (attribute_flag[0] != 0)
9025 channel=(ChannelType) argument_list[0].integer_reference;
9026 channel_mask=SetImageChannelMask(image,channel);
9027 EqualizeImage(image,exception);
9028 (void) SetImageChannelMask(image,channel_mask);
9031 case 40: /* Gamma */
9033 if (attribute_flag[1] != 0)
9034 channel=(ChannelType) argument_list[1].integer_reference;
9035 if (attribute_flag[2] == 0)
9036 argument_list[2].real_reference=1.0;
9037 if (attribute_flag[3] == 0)
9038 argument_list[3].real_reference=1.0;
9039 if (attribute_flag[4] == 0)
9040 argument_list[4].real_reference=1.0;
9041 if (attribute_flag[0] == 0)
9043 (void) FormatLocaleString(message,MaxTextExtent,
9044 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
9045 (double) argument_list[3].real_reference,
9046 (double) argument_list[4].real_reference);
9047 argument_list[0].string_reference=message;
9049 (void) GammaImage(image,StringToDouble(
9050 argument_list[0].string_reference,(char **) NULL),exception);
9058 if (attribute_flag[0] == 0)
9060 ThrowPerlException(exception,OptionError,"MapImageRequired",
9064 quantize_info=AcquireQuantizeInfo(info->image_info);
9065 if (attribute_flag[1] != 0)
9066 quantize_info->dither_method=(DitherMethod)
9067 argument_list[1].integer_reference;
9068 (void) RemapImages(quantize_info,image,
9069 argument_list[0].image_reference,exception);
9070 quantize_info=DestroyQuantizeInfo(quantize_info);
9073 case 42: /* MatteFloodfill */
9084 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9086 if (attribute_flag[0] != 0)
9087 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9088 &geometry,exception);
9089 if (attribute_flag[1] != 0)
9090 geometry.x=argument_list[1].integer_reference;
9091 if (attribute_flag[2] != 0)
9092 geometry.y=argument_list[2].integer_reference;
9093 if (image->alpha_trait != BlendPixelTrait)
9094 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9095 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9096 geometry.x,geometry.y,&target,exception);
9097 if (attribute_flag[4] != 0)
9098 QueryColorCompliance(argument_list[4].string_reference,
9099 AllCompliance,&target,exception);
9100 if (attribute_flag[3] != 0)
9101 target.alpha=StringToDoubleInterval(
9102 argument_list[3].string_reference,(double) (double) QuantumRange+
9104 if (attribute_flag[5] != 0)
9105 image->fuzz=StringToDoubleInterval(
9106 argument_list[5].string_reference,(double) QuantumRange+1.0);
9108 if (attribute_flag[6] != 0)
9109 invert=(MagickBooleanType) argument_list[6].integer_reference;
9110 channel_mask=SetImageChannelMask(image,AlphaChannel);
9111 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9112 geometry.y,invert,exception);
9113 (void) SetImageChannelMask(image,channel_mask);
9114 draw_info=DestroyDrawInfo(draw_info);
9117 case 43: /* Modulate */
9120 modulate[MaxTextExtent];
9122 geometry_info.rho=100.0;
9123 geometry_info.sigma=100.0;
9124 geometry_info.xi=100.0;
9125 if (attribute_flag[0] != 0)
9126 (void)ParseGeometry(argument_list[0].string_reference,
9128 if (attribute_flag[1] != 0)
9129 geometry_info.xi=argument_list[1].real_reference;
9130 if (attribute_flag[2] != 0)
9131 geometry_info.sigma=argument_list[2].real_reference;
9132 if (attribute_flag[3] != 0)
9134 geometry_info.sigma=argument_list[3].real_reference;
9135 SetImageArtifact(image,"modulate:colorspace","HWB");
9137 if (attribute_flag[4] != 0)
9139 geometry_info.rho=argument_list[4].real_reference;
9140 SetImageArtifact(image,"modulate:colorspace","HSB");
9142 if (attribute_flag[5] != 0)
9144 geometry_info.sigma=argument_list[5].real_reference;
9145 SetImageArtifact(image,"modulate:colorspace","HSL");
9147 if (attribute_flag[6] != 0)
9149 geometry_info.rho=argument_list[6].real_reference;
9150 SetImageArtifact(image,"modulate:colorspace","HWB");
9152 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
9153 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
9154 (void) ModulateImage(image,modulate,exception);
9157 case 44: /* Negate */
9159 if (attribute_flag[0] == 0)
9160 argument_list[0].integer_reference=0;
9161 if (attribute_flag[1] != 0)
9162 channel=(ChannelType) argument_list[1].integer_reference;
9163 channel_mask=SetImageChannelMask(image,channel);
9164 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9165 MagickTrue : MagickFalse,exception);
9166 (void) SetImageChannelMask(image,channel_mask);
9169 case 45: /* Normalize */
9171 if (attribute_flag[0] != 0)
9172 channel=(ChannelType) argument_list[0].integer_reference;
9173 channel_mask=SetImageChannelMask(image,channel);
9174 NormalizeImage(image,exception);
9175 (void) SetImageChannelMask(image,channel_mask);
9178 case 46: /* NumberColors */
9180 case 47: /* Opaque */
9189 (void) QueryColorCompliance("none",AllCompliance,&target,
9191 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9193 if (attribute_flag[0] != 0)
9194 (void) QueryColorCompliance(argument_list[0].string_reference,
9195 AllCompliance,&target,exception);
9196 if (attribute_flag[1] != 0)
9197 (void) QueryColorCompliance(argument_list[1].string_reference,
9198 AllCompliance,&fill_color,exception);
9199 if (attribute_flag[2] != 0)
9200 image->fuzz=StringToDoubleInterval(
9201 argument_list[2].string_reference,(double) QuantumRange+1.0);
9202 if (attribute_flag[3] != 0)
9203 channel=(ChannelType) argument_list[3].integer_reference;
9205 if (attribute_flag[4] != 0)
9206 invert=(MagickBooleanType) argument_list[4].integer_reference;
9207 channel_mask=SetImageChannelMask(image,channel);
9208 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9209 (void) SetImageChannelMask(image,channel_mask);
9212 case 48: /* Quantize */
9217 quantize_info=AcquireQuantizeInfo(info->image_info);
9218 if (attribute_flag[0] != 0)
9219 quantize_info->number_colors=(size_t)
9220 argument_list[0].integer_reference;
9221 if (attribute_flag[1] != 0)
9222 quantize_info->tree_depth=(size_t)
9223 argument_list[1].integer_reference;
9224 if (attribute_flag[2] != 0)
9225 quantize_info->colorspace=(ColorspaceType)
9226 argument_list[2].integer_reference;
9227 if (attribute_flag[3] != 0)
9228 quantize_info->dither_method=(DitherMethod)
9229 argument_list[3].integer_reference;
9230 if (attribute_flag[4] != 0)
9231 quantize_info->measure_error=
9232 argument_list[4].integer_reference != 0 ? MagickTrue : MagickFalse;
9233 if (attribute_flag[6] != 0)
9234 (void) QueryColorCompliance(argument_list[6].string_reference,
9235 AllCompliance,&image->transparent_color,exception);
9236 if (attribute_flag[7] != 0)
9237 quantize_info->dither_method=(DitherMethod)
9238 argument_list[7].integer_reference;
9239 if (attribute_flag[5] && argument_list[5].integer_reference)
9240 (void) QuantizeImages(quantize_info,image,exception);
9242 if ((image->storage_class == DirectClass) ||
9243 (image->colors > quantize_info->number_colors) ||
9244 (quantize_info->colorspace == GRAYColorspace))
9245 (void) QuantizeImage(quantize_info,image,exception);
9247 CompressImageColormap(image,exception);
9248 quantize_info=DestroyQuantizeInfo(quantize_info);
9251 case 49: /* Raise */
9253 if (attribute_flag[0] != 0)
9254 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9255 &geometry,exception);
9256 if (attribute_flag[1] != 0)
9257 geometry.width=argument_list[1].integer_reference;
9258 if (attribute_flag[2] != 0)
9259 geometry.height=argument_list[2].integer_reference;
9260 if (attribute_flag[3] == 0)
9261 argument_list[3].integer_reference=1;
9262 (void) RaiseImage(image,&geometry,
9263 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9267 case 50: /* Segment */
9274 smoothing_threshold;
9279 cluster_threshold=1.0;
9280 smoothing_threshold=1.5;
9281 colorspace=sRGBColorspace;
9282 verbose=MagickFalse;
9283 if (attribute_flag[0] != 0)
9285 flags=ParseGeometry(argument_list[0].string_reference,
9287 cluster_threshold=geometry_info.rho;
9288 if (flags & SigmaValue)
9289 smoothing_threshold=geometry_info.sigma;
9291 if (attribute_flag[1] != 0)
9292 cluster_threshold=argument_list[1].real_reference;
9293 if (attribute_flag[2] != 0)
9294 smoothing_threshold=argument_list[2].real_reference;
9295 if (attribute_flag[3] != 0)
9296 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9297 if (attribute_flag[4] != 0)
9298 verbose=argument_list[4].integer_reference != 0 ?
9299 MagickTrue : MagickFalse;
9300 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9301 smoothing_threshold,exception);
9304 case 51: /* Signature */
9306 (void) SignatureImage(image,exception);
9309 case 52: /* Solarize */
9311 geometry_info.rho=QuantumRange/2.0;
9312 if (attribute_flag[0] != 0)
9313 flags=ParseGeometry(argument_list[0].string_reference,
9315 if (attribute_flag[1] != 0)
9316 geometry_info.rho=StringToDoubleInterval(
9317 argument_list[1].string_reference,(double) QuantumRange+1.0);
9318 (void) SolarizeImage(image,geometry_info.rho,exception);
9323 (void) SyncImage(image,exception);
9326 case 54: /* Texture */
9328 if (attribute_flag[0] == 0)
9330 TextureImage(image,argument_list[0].image_reference,exception);
9333 case 55: /* Evalute */
9335 MagickEvaluateOperator
9338 op=SetEvaluateOperator;
9339 if (attribute_flag[0] == MagickFalse)
9340 argument_list[0].real_reference=0.0;
9341 if (attribute_flag[1] != MagickFalse)
9342 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9343 if (attribute_flag[2] != MagickFalse)
9344 channel=(ChannelType) argument_list[2].integer_reference;
9345 channel_mask=SetImageChannelMask(image,channel);
9346 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9348 (void) SetImageChannelMask(image,channel_mask);
9351 case 56: /* Transparent */
9362 (void) QueryColorCompliance("none",AllCompliance,&target,
9364 if (attribute_flag[0] != 0)
9365 (void) QueryColorCompliance(argument_list[0].string_reference,
9366 AllCompliance,&target,exception);
9367 opacity=TransparentAlpha;
9368 if (attribute_flag[1] != 0)
9369 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9370 (double) QuantumRange+1.0);
9371 if (attribute_flag[2] != 0)
9372 image->fuzz=StringToDoubleInterval(
9373 argument_list[2].string_reference,(double) QuantumRange+1.0);
9374 if (attribute_flag[3] == 0)
9375 argument_list[3].integer_reference=0;
9377 if (attribute_flag[3] != 0)
9378 invert=(MagickBooleanType) argument_list[3].integer_reference;
9379 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9383 case 57: /* Threshold */
9388 if (attribute_flag[0] == 0)
9389 argument_list[0].string_reference="50%";
9390 if (attribute_flag[1] != 0)
9391 channel=(ChannelType) argument_list[1].integer_reference;
9392 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9393 (double) QuantumRange+1.0);
9394 channel_mask=SetImageChannelMask(image,channel);
9395 (void) BilevelImage(image,threshold,exception);
9396 (void) SetImageChannelMask(image,channel_mask);
9399 case 58: /* Charcoal */
9401 if (attribute_flag[0] != 0)
9403 flags=ParseGeometry(argument_list[0].string_reference,
9405 if ((flags & SigmaValue) == 0)
9406 geometry_info.sigma=1.0;
9408 if (attribute_flag[1] != 0)
9409 geometry_info.rho=argument_list[1].real_reference;
9410 if (attribute_flag[2] != 0)
9411 geometry_info.sigma=argument_list[2].real_reference;
9412 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9418 if (attribute_flag[0] != 0)
9419 image->fuzz=StringToDoubleInterval(
9420 argument_list[0].string_reference,(double) QuantumRange+1.0);
9421 image=TrimImage(image,exception);
9426 PixelInterpolateMethod
9429 if (attribute_flag[0] != 0)
9431 flags=ParseGeometry(argument_list[0].string_reference,
9433 if ((flags & SigmaValue) == 0)
9434 geometry_info.sigma=1.0;
9436 if (attribute_flag[1] != 0)
9437 geometry_info.rho=argument_list[1].real_reference;
9438 if (attribute_flag[2] != 0)
9439 geometry_info.sigma=argument_list[2].real_reference;
9440 method=UndefinedInterpolatePixel;
9441 if (attribute_flag[3] != 0)
9442 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9443 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9447 case 61: /* Separate */
9449 if (attribute_flag[0] != 0)
9450 channel=(ChannelType) argument_list[0].integer_reference;
9451 image=SeparateImage(image,channel,exception);
9454 case 63: /* Stereo */
9456 if (attribute_flag[0] == 0)
9458 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9462 if (attribute_flag[1] != 0)
9463 geometry.x=argument_list[1].integer_reference;
9464 if (attribute_flag[2] != 0)
9465 geometry.y=argument_list[2].integer_reference;
9466 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9467 geometry.x,geometry.y,exception);
9470 case 64: /* Stegano */
9472 if (attribute_flag[0] == 0)
9474 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9478 if (attribute_flag[1] == 0)
9479 argument_list[1].integer_reference=0;
9480 image->offset=argument_list[1].integer_reference;
9481 image=SteganoImage(image,argument_list[0].image_reference,exception);
9484 case 65: /* Deconstruct */
9486 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9489 case 66: /* GaussianBlur */
9491 if (attribute_flag[0] != 0)
9493 flags=ParseGeometry(argument_list[0].string_reference,
9495 if ((flags & SigmaValue) == 0)
9496 geometry_info.sigma=1.0;
9498 if (attribute_flag[1] != 0)
9499 geometry_info.rho=argument_list[1].real_reference;
9500 if (attribute_flag[2] != 0)
9501 geometry_info.sigma=argument_list[2].real_reference;
9502 if (attribute_flag[3] != 0)
9503 channel=(ChannelType) argument_list[3].integer_reference;
9504 channel_mask=SetImageChannelMask(image,channel);
9505 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9507 if (image != (Image *) NULL)
9508 (void) SetImageChannelMask(image,channel_mask);
9511 case 67: /* Convolve */
9516 kernel=(KernelInfo *) NULL;
9517 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9519 if (attribute_flag[0] != 0)
9527 kernel=AcquireKernelInfo((const char *) NULL);
9528 if (kernel == (KernelInfo *) NULL)
9530 av=(AV *) argument_list[0].array_reference;
9531 order=(size_t) sqrt(av_len(av)+1);
9532 kernel->width=order;
9533 kernel->height=order;
9534 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9535 order*sizeof(*kernel->values));
9536 if (kernel->values == (MagickRealType *) NULL)
9538 kernel=DestroyKernelInfo(kernel);
9539 ThrowPerlException(exception,ResourceLimitFatalError,
9540 "MemoryAllocationFailed",PackageName);
9543 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9544 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9545 for ( ; j < (ssize_t) (order*order); j++)
9546 kernel->values[j]=0.0;
9548 if (attribute_flag[1] != 0)
9549 channel=(ChannelType) argument_list[1].integer_reference;
9550 if (attribute_flag[2] != 0)
9551 SetImageArtifact(image,"filter:blur",
9552 argument_list[2].string_reference);
9553 if (attribute_flag[3] != 0)
9555 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9556 if (kernel == (KernelInfo *) NULL)
9559 channel_mask=SetImageChannelMask(image,channel);
9560 image=ConvolveImage(image,kernel,exception);
9561 if (image != (Image *) NULL)
9562 (void) SetImageChannelMask(image,channel_mask);
9563 kernel=DestroyKernelInfo(kernel);
9566 case 68: /* Profile */
9581 if (attribute_flag[0] != 0)
9582 name=argument_list[0].string_reference;
9583 if (attribute_flag[2] != 0)
9584 image->rendering_intent=(RenderingIntent)
9585 argument_list[2].integer_reference;
9586 if (attribute_flag[3] != 0)
9587 image->black_point_compensation=
9588 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9589 if (attribute_flag[1] != 0)
9591 if (argument_list[1].length == 0)
9594 Remove a profile from the image.
9596 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9601 Associate user supplied profile with the image.
9603 profile=AcquireStringInfo(argument_list[1].length);
9604 SetStringInfoDatum(profile,(const unsigned char *)
9605 argument_list[1].string_reference);
9606 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9607 (size_t) GetStringInfoLength(profile),exception);
9608 profile=DestroyStringInfo(profile);
9612 Associate a profile with the image.
9614 profile_info=CloneImageInfo(info ? info->image_info :
9615 (ImageInfo *) NULL);
9616 profile_image=ReadImages(profile_info,name,exception);
9617 if (profile_image == (Image *) NULL)
9619 ResetImageProfileIterator(profile_image);
9620 name=GetNextImageProfile(profile_image);
9621 while (name != (const char *) NULL)
9626 profile=GetImageProfile(profile_image,name);
9627 if (profile != (const StringInfo *) NULL)
9628 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9629 (size_t) GetStringInfoLength(profile),exception);
9630 name=GetNextImageProfile(profile_image);
9632 profile_image=DestroyImage(profile_image);
9633 profile_info=DestroyImageInfo(profile_info);
9636 case 69: /* UnsharpMask */
9638 if (attribute_flag[0] != 0)
9640 flags=ParseGeometry(argument_list[0].string_reference,
9642 if ((flags & SigmaValue) == 0)
9643 geometry_info.sigma=1.0;
9644 if ((flags & XiValue) == 0)
9645 geometry_info.xi=1.0;
9646 if ((flags & PsiValue) == 0)
9647 geometry_info.psi=0.5;
9649 if (attribute_flag[1] != 0)
9650 geometry_info.rho=argument_list[1].real_reference;
9651 if (attribute_flag[2] != 0)
9652 geometry_info.sigma=argument_list[2].real_reference;
9653 if (attribute_flag[3] != 0)
9654 geometry_info.xi=argument_list[3].real_reference;
9655 if (attribute_flag[4] != 0)
9656 geometry_info.psi=argument_list[4].real_reference;
9657 if (attribute_flag[5] != 0)
9658 channel=(ChannelType) argument_list[5].integer_reference;
9659 channel_mask=SetImageChannelMask(image,channel);
9660 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9661 geometry_info.xi,geometry_info.psi,exception);
9662 if (image != (Image *) NULL)
9663 (void) SetImageChannelMask(image,channel_mask);
9666 case 70: /* MotionBlur */
9668 if (attribute_flag[0] != 0)
9670 flags=ParseGeometry(argument_list[0].string_reference,
9672 if ((flags & SigmaValue) == 0)
9673 geometry_info.sigma=1.0;
9674 if ((flags & XiValue) == 0)
9675 geometry_info.xi=1.0;
9677 if (attribute_flag[1] != 0)
9678 geometry_info.rho=argument_list[1].real_reference;
9679 if (attribute_flag[2] != 0)
9680 geometry_info.sigma=argument_list[2].real_reference;
9681 if (attribute_flag[3] != 0)
9682 geometry_info.xi=argument_list[3].real_reference;
9683 if (attribute_flag[4] != 0)
9684 channel=(ChannelType) argument_list[4].integer_reference;
9685 channel_mask=SetImageChannelMask(image,channel);
9686 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9687 geometry_info.xi,exception);
9688 if (image != (Image *) NULL)
9689 (void) SetImageChannelMask(image,channel_mask);
9692 case 71: /* OrderedDither */
9694 if (attribute_flag[0] == 0)
9695 argument_list[0].string_reference="o8x8";
9696 if (attribute_flag[1] != 0)
9697 channel=(ChannelType) argument_list[1].integer_reference;
9698 channel_mask=SetImageChannelMask(image,channel);
9699 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9701 (void) SetImageChannelMask(image,channel_mask);
9704 case 72: /* Shave */
9706 if (attribute_flag[0] != 0)
9707 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9708 &geometry,exception);
9709 if (attribute_flag[1] != 0)
9710 geometry.width=argument_list[1].integer_reference;
9711 if (attribute_flag[2] != 0)
9712 geometry.height=argument_list[2].integer_reference;
9713 image=ShaveImage(image,&geometry,exception);
9716 case 73: /* Level */
9724 white_point=(double) image->columns*image->rows;
9726 if (attribute_flag[0] != 0)
9728 flags=ParseGeometry(argument_list[0].string_reference,
9730 black_point=geometry_info.rho;
9731 if ((flags & SigmaValue) != 0)
9732 white_point=geometry_info.sigma;
9733 if ((flags & XiValue) != 0)
9734 gamma=geometry_info.xi;
9735 if ((flags & PercentValue) != 0)
9737 black_point*=(double) (QuantumRange/100.0);
9738 white_point*=(double) (QuantumRange/100.0);
9740 if ((flags & SigmaValue) == 0)
9741 white_point=(double) QuantumRange-black_point;
9743 if (attribute_flag[1] != 0)
9744 black_point=argument_list[1].real_reference;
9745 if (attribute_flag[2] != 0)
9746 white_point=argument_list[2].real_reference;
9747 if (attribute_flag[3] != 0)
9748 gamma=argument_list[3].real_reference;
9749 if (attribute_flag[4] != 0)
9750 channel=(ChannelType) argument_list[4].integer_reference;
9751 if (attribute_flag[5] != 0)
9753 argument_list[0].real_reference=argument_list[5].real_reference;
9754 attribute_flag[0]=attribute_flag[5];
9756 channel_mask=SetImageChannelMask(image,channel);
9757 (void) LevelImage(image,black_point,white_point,gamma,exception);
9758 (void) SetImageChannelMask(image,channel_mask);
9763 if (attribute_flag[0] == 0)
9764 argument_list[0].string_reference="#1";
9765 if (attribute_flag[1] == 0)
9766 argument_list[1].integer_reference=MagickTrue;
9767 (void) ClipImagePath(image,argument_list[0].string_reference,
9768 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9772 case 75: /* AffineTransform */
9777 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9779 if (attribute_flag[0] != 0)
9784 av=(AV *) argument_list[0].array_reference;
9785 if ((av_len(av) != 3) && (av_len(av) != 5))
9787 ThrowPerlException(exception,OptionError,
9788 "affine matrix must have 4 or 6 elements",PackageName);
9791 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9792 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9793 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9794 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9795 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9796 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9798 ThrowPerlException(exception,OptionError,
9799 "affine matrix is singular",PackageName);
9802 if (av_len(av) == 5)
9804 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9805 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9808 for (j=1; j < 6; j++)
9810 if (attribute_flag[j] == 0)
9812 value=argument_list[j].string_reference;
9813 angle=argument_list[j].real_reference;
9814 current=draw_info->affine;
9815 GetAffineMatrix(&affine);
9823 flags=ParseGeometry(value,&geometry_info);
9824 affine.tx=geometry_info.xi;
9825 affine.ty=geometry_info.psi;
9826 if ((flags & PsiValue) == 0)
9827 affine.ty=affine.tx;
9835 flags=ParseGeometry(value,&geometry_info);
9836 affine.sx=geometry_info.rho;
9837 affine.sy=geometry_info.sigma;
9838 if ((flags & SigmaValue) == 0)
9839 affine.sy=affine.sx;
9849 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9850 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9851 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9852 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9860 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9868 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9872 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9873 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9874 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9875 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9876 draw_info->affine.tx=
9877 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9878 draw_info->affine.ty=
9879 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9881 if (attribute_flag[6] != 0)
9882 image->interpolate=(PixelInterpolateMethod)
9883 argument_list[6].integer_reference;
9884 if (attribute_flag[7] != 0)
9885 QueryColorCompliance(argument_list[7].string_reference,
9886 AllCompliance,&image->background_color,exception);
9887 image=AffineTransformImage(image,&draw_info->affine,exception);
9888 draw_info=DestroyDrawInfo(draw_info);
9891 case 76: /* Difference */
9893 if (attribute_flag[0] == 0)
9895 ThrowPerlException(exception,OptionError,
9896 "ReferenceImageRequired",PackageName);
9899 if (attribute_flag[1] != 0)
9900 image->fuzz=StringToDoubleInterval(
9901 argument_list[1].string_reference,(double) QuantumRange+1.0);
9902 (void) IsImagesEqual(image,argument_list[0].image_reference,
9906 case 77: /* AdaptiveThreshold */
9908 if (attribute_flag[0] != 0)
9910 flags=ParseGeometry(argument_list[0].string_reference,
9912 if ((flags & PercentValue) != 0)
9913 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9915 if (attribute_flag[1] != 0)
9916 geometry_info.rho=argument_list[1].integer_reference;
9917 if (attribute_flag[2] != 0)
9918 geometry_info.sigma=argument_list[2].integer_reference;
9919 if (attribute_flag[3] != 0)
9920 geometry_info.xi=argument_list[3].integer_reference;;
9921 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9922 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9925 case 78: /* Resample */
9931 if (attribute_flag[0] != 0)
9933 flags=ParseGeometry(argument_list[0].string_reference,
9935 if ((flags & SigmaValue) == 0)
9936 geometry_info.sigma=geometry_info.rho;
9938 if (attribute_flag[1] != 0)
9939 geometry_info.rho=argument_list[1].real_reference;
9940 if (attribute_flag[2] != 0)
9941 geometry_info.sigma=argument_list[2].real_reference;
9942 if (attribute_flag[3] == 0)
9943 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9944 if (attribute_flag[4] == 0)
9945 SetImageArtifact(image,"filter:support",
9946 argument_list[4].string_reference);
9947 width=(size_t) (geometry_info.rho*image->columns/
9948 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9949 height=(size_t) (geometry_info.sigma*image->rows/
9950 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9951 image=ResizeImage(image,width,height,(FilterTypes)
9952 argument_list[3].integer_reference,exception);
9953 if (image != (Image *) NULL)
9955 image->resolution.x=geometry_info.rho;
9956 image->resolution.y=geometry_info.sigma;
9960 case 79: /* Describe */
9962 if (attribute_flag[0] == 0)
9963 argument_list[0].file_reference=(FILE *) NULL;
9964 if (attribute_flag[1] != 0)
9965 (void) SetImageArtifact(image,"identify:features",
9966 argument_list[1].string_reference);
9967 (void) IdentifyImage(image,argument_list[0].file_reference,
9968 MagickTrue,exception);
9971 case 80: /* BlackThreshold */
9973 if (attribute_flag[0] == 0)
9974 argument_list[0].string_reference="50%";
9975 if (attribute_flag[2] != 0)
9976 channel=(ChannelType) argument_list[2].integer_reference;
9977 channel_mask=SetImageChannelMask(image,channel);
9978 BlackThresholdImage(image,argument_list[0].string_reference,
9980 (void) SetImageChannelMask(image,channel_mask);
9983 case 81: /* WhiteThreshold */
9985 if (attribute_flag[0] == 0)
9986 argument_list[0].string_reference="50%";
9987 if (attribute_flag[2] != 0)
9988 channel=(ChannelType) argument_list[2].integer_reference;
9989 channel_mask=SetImageChannelMask(image,channel);
9990 WhiteThresholdImage(image,argument_list[0].string_reference,
9992 (void) SetImageChannelMask(image,channel_mask);
9995 case 82: /* RotationalBlur */
9997 if (attribute_flag[0] != 0)
9999 flags=ParseGeometry(argument_list[0].string_reference,
10002 if (attribute_flag[1] != 0)
10003 geometry_info.rho=argument_list[1].real_reference;
10004 if (attribute_flag[2] != 0)
10005 channel=(ChannelType) argument_list[2].integer_reference;
10006 channel_mask=SetImageChannelMask(image,channel);
10007 image=RotationalBlurImage(image,geometry_info.rho,exception);
10008 if (image != (Image *) NULL)
10009 (void) SetImageChannelMask(image,channel_mask);
10012 case 83: /* Thumbnail */
10014 if (attribute_flag[0] != 0)
10015 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10016 &geometry,exception);
10017 if (attribute_flag[1] != 0)
10018 geometry.width=argument_list[1].integer_reference;
10019 if (attribute_flag[2] != 0)
10020 geometry.height=argument_list[2].integer_reference;
10021 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10024 case 84: /* Strip */
10026 (void) StripImage(image,exception);
10029 case 85: /* Tint */
10034 GetPixelInfo(image,&tint);
10035 if (attribute_flag[0] != 0)
10036 (void) QueryColorCompliance(argument_list[0].string_reference,
10037 AllCompliance,&tint,exception);
10038 if (attribute_flag[1] == 0)
10039 argument_list[1].string_reference="100";
10040 image=TintImage(image,argument_list[1].string_reference,&tint,
10044 case 86: /* Channel */
10046 if (attribute_flag[0] != 0)
10047 channel=(ChannelType) argument_list[0].integer_reference;
10048 image=SeparateImage(image,channel,exception);
10051 case 87: /* Splice */
10053 if (attribute_flag[0] != 0)
10054 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10055 &geometry,exception);
10056 if (attribute_flag[1] != 0)
10057 geometry.width=argument_list[1].integer_reference;
10058 if (attribute_flag[2] != 0)
10059 geometry.height=argument_list[2].integer_reference;
10060 if (attribute_flag[3] != 0)
10061 geometry.x=argument_list[3].integer_reference;
10062 if (attribute_flag[4] != 0)
10063 geometry.y=argument_list[4].integer_reference;
10064 if (attribute_flag[5] != 0)
10065 image->fuzz=StringToDoubleInterval(
10066 argument_list[5].string_reference,(double) QuantumRange+1.0);
10067 if (attribute_flag[6] != 0)
10068 (void) QueryColorCompliance(argument_list[6].string_reference,
10069 AllCompliance,&image->background_color,exception);
10070 if (attribute_flag[7] != 0)
10071 image->gravity=(GravityType) argument_list[7].integer_reference;
10072 image=SpliceImage(image,&geometry,exception);
10075 case 88: /* Posterize */
10077 if (attribute_flag[0] == 0)
10078 argument_list[0].integer_reference=3;
10079 if (attribute_flag[1] == 0)
10080 argument_list[1].integer_reference=0;
10081 (void) PosterizeImage(image,argument_list[0].integer_reference,
10082 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10083 NoDitherMethod,exception);
10086 case 89: /* Shadow */
10088 if (attribute_flag[0] != 0)
10090 flags=ParseGeometry(argument_list[0].string_reference,
10092 if ((flags & SigmaValue) == 0)
10093 geometry_info.sigma=1.0;
10094 if ((flags & XiValue) == 0)
10095 geometry_info.xi=4.0;
10096 if ((flags & PsiValue) == 0)
10097 geometry_info.psi=4.0;
10099 if (attribute_flag[1] != 0)
10100 geometry_info.rho=argument_list[1].real_reference;
10101 if (attribute_flag[2] != 0)
10102 geometry_info.sigma=argument_list[2].real_reference;
10103 if (attribute_flag[3] != 0)
10104 geometry_info.xi=argument_list[3].integer_reference;
10105 if (attribute_flag[4] != 0)
10106 geometry_info.psi=argument_list[4].integer_reference;
10107 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10108 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10109 ceil(geometry_info.psi-0.5),exception);
10112 case 90: /* Identify */
10114 if (attribute_flag[0] == 0)
10115 argument_list[0].file_reference=(FILE *) NULL;
10116 if (attribute_flag[1] != 0)
10117 (void) SetImageArtifact(image,"identify:features",
10118 argument_list[1].string_reference);
10119 if ((attribute_flag[2] != 0) &&
10120 (argument_list[2].integer_reference != 0))
10121 (void) SetImageArtifact(image,"identify:unique","true");
10122 (void) IdentifyImage(image,argument_list[0].file_reference,
10123 MagickTrue,exception);
10126 case 91: /* SepiaTone */
10128 if (attribute_flag[0] == 0)
10129 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10130 image=SepiaToneImage(image,argument_list[0].real_reference,
10134 case 92: /* SigmoidalContrast */
10139 if (attribute_flag[0] != 0)
10141 flags=ParseGeometry(argument_list[0].string_reference,
10143 if ((flags & SigmaValue) == 0)
10144 geometry_info.sigma=QuantumRange/2.0;
10145 if ((flags & PercentValue) != 0)
10146 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10148 if (attribute_flag[1] != 0)
10149 geometry_info.rho=argument_list[1].real_reference;
10150 if (attribute_flag[2] != 0)
10151 geometry_info.sigma=argument_list[2].real_reference;
10152 if (attribute_flag[3] != 0)
10153 channel=(ChannelType) argument_list[3].integer_reference;
10154 sharpen=MagickTrue;
10155 if (attribute_flag[4] != 0)
10156 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10158 channel_mask=SetImageChannelMask(image,channel);
10159 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10160 geometry_info.sigma,exception);
10161 (void) SetImageChannelMask(image,channel_mask);
10164 case 93: /* Extent */
10166 if (attribute_flag[7] != 0)
10167 image->gravity=(GravityType) argument_list[7].integer_reference;
10168 if (attribute_flag[0] != 0)
10173 flags=ParseGravityGeometry(image,
10174 argument_list[0].string_reference,&geometry,exception);
10176 if (geometry.width == 0)
10177 geometry.width=image->columns;
10178 if (geometry.height == 0)
10179 geometry.height=image->rows;
10181 if (attribute_flag[1] != 0)
10182 geometry.width=argument_list[1].integer_reference;
10183 if (attribute_flag[2] != 0)
10184 geometry.height=argument_list[2].integer_reference;
10185 if (attribute_flag[3] != 0)
10186 geometry.x=argument_list[3].integer_reference;
10187 if (attribute_flag[4] != 0)
10188 geometry.y=argument_list[4].integer_reference;
10189 if (attribute_flag[5] != 0)
10190 image->fuzz=StringToDoubleInterval(
10191 argument_list[5].string_reference,(double) QuantumRange+1.0);
10192 if (attribute_flag[6] != 0)
10193 (void) QueryColorCompliance(argument_list[6].string_reference,
10194 AllCompliance,&image->background_color,exception);
10195 image=ExtentImage(image,&geometry,exception);
10198 case 94: /* Vignette */
10200 if (attribute_flag[0] != 0)
10202 flags=ParseGeometry(argument_list[0].string_reference,
10204 if ((flags & SigmaValue) == 0)
10205 geometry_info.sigma=1.0;
10206 if ((flags & XiValue) == 0)
10207 geometry_info.xi=0.1*image->columns;
10208 if ((flags & PsiValue) == 0)
10209 geometry_info.psi=0.1*image->rows;
10211 if (attribute_flag[1] != 0)
10212 geometry_info.rho=argument_list[1].real_reference;
10213 if (attribute_flag[2] != 0)
10214 geometry_info.sigma=argument_list[2].real_reference;
10215 if (attribute_flag[3] != 0)
10216 geometry_info.xi=argument_list[3].integer_reference;
10217 if (attribute_flag[4] != 0)
10218 geometry_info.psi=argument_list[4].integer_reference;
10219 if (attribute_flag[5] != 0)
10220 (void) QueryColorCompliance(argument_list[5].string_reference,
10221 AllCompliance,&image->background_color,exception);
10222 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10223 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10224 ceil(geometry_info.psi-0.5),exception);
10227 case 95: /* ContrastStretch */
10234 white_point=(double) image->columns*image->rows;
10235 if (attribute_flag[0] != 0)
10237 flags=ParseGeometry(argument_list[0].string_reference,
10239 black_point=geometry_info.rho;
10240 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10242 if ((flags & PercentValue) != 0)
10244 black_point*=(double) image->columns*image->rows/100.0;
10245 white_point*=(double) image->columns*image->rows/100.0;
10247 white_point=(double) image->columns*image->rows-
10250 if (attribute_flag[1] != 0)
10251 black_point=argument_list[1].real_reference;
10252 if (attribute_flag[2] != 0)
10253 white_point=argument_list[2].real_reference;
10254 if (attribute_flag[4] != 0)
10255 channel=(ChannelType) argument_list[4].integer_reference;
10256 channel_mask=SetImageChannelMask(image,channel);
10257 (void) ContrastStretchImage(image,black_point,white_point,exception);
10258 (void) SetImageChannelMask(image,channel_mask);
10261 case 96: /* Sans0 */
10265 case 97: /* Sans1 */
10269 case 98: /* AdaptiveSharpen */
10271 if (attribute_flag[0] != 0)
10273 flags=ParseGeometry(argument_list[0].string_reference,
10275 if ((flags & SigmaValue) == 0)
10276 geometry_info.sigma=1.0;
10277 if ((flags & XiValue) == 0)
10278 geometry_info.xi=0.0;
10280 if (attribute_flag[1] != 0)
10281 geometry_info.rho=argument_list[1].real_reference;
10282 if (attribute_flag[2] != 0)
10283 geometry_info.sigma=argument_list[2].real_reference;
10284 if (attribute_flag[3] != 0)
10285 geometry_info.xi=argument_list[3].real_reference;
10286 if (attribute_flag[4] != 0)
10287 channel=(ChannelType) argument_list[4].integer_reference;
10288 channel_mask=SetImageChannelMask(image,channel);
10289 image=AdaptiveSharpenImage(image,geometry_info.rho,
10290 geometry_info.sigma,exception);
10291 if (image != (Image *) NULL)
10292 (void) SetImageChannelMask(image,channel_mask);
10295 case 99: /* Transpose */
10297 image=TransposeImage(image,exception);
10300 case 100: /* Tranverse */
10302 image=TransverseImage(image,exception);
10305 case 101: /* AutoOrient */
10307 image=AutoOrientImage(image,image->orientation,exception);
10310 case 102: /* AdaptiveBlur */
10312 if (attribute_flag[0] != 0)
10314 flags=ParseGeometry(argument_list[0].string_reference,
10316 if ((flags & SigmaValue) == 0)
10317 geometry_info.sigma=1.0;
10318 if ((flags & XiValue) == 0)
10319 geometry_info.xi=0.0;
10321 if (attribute_flag[1] != 0)
10322 geometry_info.rho=argument_list[1].real_reference;
10323 if (attribute_flag[2] != 0)
10324 geometry_info.sigma=argument_list[2].real_reference;
10325 if (attribute_flag[3] != 0)
10326 channel=(ChannelType) argument_list[3].integer_reference;
10327 channel_mask=SetImageChannelMask(image,channel);
10328 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10330 if (image != (Image *) NULL)
10331 (void) SetImageChannelMask(image,channel_mask);
10334 case 103: /* Sketch */
10336 if (attribute_flag[0] != 0)
10338 flags=ParseGeometry(argument_list[0].string_reference,
10340 if ((flags & SigmaValue) == 0)
10341 geometry_info.sigma=1.0;
10342 if ((flags & XiValue) == 0)
10343 geometry_info.xi=1.0;
10345 if (attribute_flag[1] != 0)
10346 geometry_info.rho=argument_list[1].real_reference;
10347 if (attribute_flag[2] != 0)
10348 geometry_info.sigma=argument_list[2].real_reference;
10349 if (attribute_flag[3] != 0)
10350 geometry_info.xi=argument_list[3].real_reference;
10351 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10352 geometry_info.xi,exception);
10355 case 104: /* UniqueColors */
10357 image=UniqueImageColors(image,exception);
10360 case 105: /* AdaptiveResize */
10362 if (attribute_flag[0] != 0)
10363 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10364 &geometry,exception);
10365 if (attribute_flag[1] != 0)
10366 geometry.width=argument_list[1].integer_reference;
10367 if (attribute_flag[2] != 0)
10368 geometry.height=argument_list[2].integer_reference;
10369 if (attribute_flag[3] != 0)
10370 image->filter=(FilterTypes) argument_list[4].integer_reference;
10371 if (attribute_flag[4] != 0)
10372 SetImageArtifact(image,"filter:support",
10373 argument_list[4].string_reference);
10374 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10378 case 106: /* ClipMask */
10383 if (attribute_flag[0] == 0)
10385 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10387 goto PerlException;
10389 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10391 (void) SetImageMask(image,mask_image,exception);
10392 mask_image=DestroyImage(mask_image);
10395 case 107: /* LinearStretch */
10402 white_point=(double) image->columns*image->rows;
10403 if (attribute_flag[0] != 0)
10405 flags=ParseGeometry(argument_list[0].string_reference,
10407 if ((flags & SigmaValue) != 0)
10408 white_point=geometry_info.sigma;
10409 if ((flags & PercentValue) != 0)
10411 black_point*=(double) image->columns*image->rows/100.0;
10412 white_point*=(double) image->columns*image->rows/100.0;
10414 if ((flags & SigmaValue) == 0)
10415 white_point=(double) image->columns*image->rows-black_point;
10417 if (attribute_flag[1] != 0)
10418 black_point=argument_list[1].real_reference;
10419 if (attribute_flag[2] != 0)
10420 white_point=argument_list[2].real_reference;
10421 (void) LinearStretchImage(image,black_point,white_point,exception);
10424 case 108: /* ColorMatrix */
10438 if (attribute_flag[0] == 0)
10440 av=(AV *) argument_list[0].array_reference;
10441 order=(size_t) sqrt(av_len(av)+1);
10442 color_matrix=(double *) AcquireQuantumMemory(order,order*
10443 sizeof(*color_matrix));
10444 if (color_matrix == (double *) NULL)
10446 ThrowPerlException(exception,ResourceLimitFatalError,
10447 "MemoryAllocationFailed",PackageName);
10448 goto PerlException;
10450 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10451 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10452 for ( ; j < (ssize_t) (order*order); j++)
10453 color_matrix[j]=0.0;
10454 kernel_info=AcquireKernelInfo((const char *) NULL);
10455 if (kernel_info == (KernelInfo *) NULL)
10457 kernel_info->width=order;
10458 kernel_info->height=order;
10459 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10460 order*sizeof(*kernel_info->values));
10461 if (kernel_info->values != (MagickRealType *) NULL)
10463 for (i=0; i < (ssize_t) (order*order); i++)
10464 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10465 image=ColorMatrixImage(image,kernel_info,exception);
10467 kernel_info=DestroyKernelInfo(kernel_info);
10468 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10471 case 109: /* Mask */
10476 if (attribute_flag[0] == 0)
10478 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10480 goto PerlException;
10482 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10483 MagickTrue,exception);
10484 (void) SetImageMask(image,mask_image,exception);
10485 mask_image=DestroyImage(mask_image);
10488 case 110: /* Polaroid */
10499 PixelInterpolateMethod
10502 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10503 (DrawInfo *) NULL);
10504 caption=(char *) NULL;
10505 if (attribute_flag[0] != 0)
10506 caption=InterpretImageProperties(info ? info->image_info :
10507 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10510 if (attribute_flag[1] != 0)
10511 angle=argument_list[1].real_reference;
10512 if (attribute_flag[2] != 0)
10513 (void) CloneString(&draw_info->font,
10514 argument_list[2].string_reference);
10515 if (attribute_flag[3] != 0)
10516 (void) QueryColorCompliance(argument_list[3].string_reference,
10517 AllCompliance,&draw_info->stroke,exception);
10518 if (attribute_flag[4] != 0)
10519 (void) QueryColorCompliance(argument_list[4].string_reference,
10520 AllCompliance,&draw_info->fill,exception);
10521 if (attribute_flag[5] != 0)
10522 draw_info->stroke_width=argument_list[5].real_reference;
10523 if (attribute_flag[6] != 0)
10524 draw_info->pointsize=argument_list[6].real_reference;
10525 if (attribute_flag[7] != 0)
10526 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10527 if (attribute_flag[8] != 0)
10528 (void) QueryColorCompliance(argument_list[8].string_reference,
10529 AllCompliance,&image->background_color,exception);
10530 method=UndefinedInterpolatePixel;
10531 if (attribute_flag[9] != 0)
10532 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10533 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10534 draw_info=DestroyDrawInfo(draw_info);
10535 if (caption != (char *) NULL)
10536 caption=DestroyString(caption);
10539 case 111: /* FloodfillPaint */
10550 draw_info=CloneDrawInfo(info ? info->image_info :
10551 (ImageInfo *) NULL,(DrawInfo *) NULL);
10552 if (attribute_flag[0] != 0)
10553 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10554 &geometry,exception);
10555 if (attribute_flag[1] != 0)
10556 geometry.x=argument_list[1].integer_reference;
10557 if (attribute_flag[2] != 0)
10558 geometry.y=argument_list[2].integer_reference;
10559 if (attribute_flag[3] != 0)
10560 (void) QueryColorCompliance(argument_list[3].string_reference,
10561 AllCompliance,&draw_info->fill,exception);
10562 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10563 geometry.x,geometry.y,&target,exception);
10564 if (attribute_flag[4] != 0)
10565 QueryColorCompliance(argument_list[4].string_reference,
10566 AllCompliance,&target,exception);
10567 if (attribute_flag[5] != 0)
10568 image->fuzz=StringToDoubleInterval(
10569 argument_list[5].string_reference,(double) QuantumRange+1.0);
10570 if (attribute_flag[6] != 0)
10571 channel=(ChannelType) argument_list[6].integer_reference;
10572 invert=MagickFalse;
10573 if (attribute_flag[7] != 0)
10574 invert=(MagickBooleanType) argument_list[7].integer_reference;
10575 channel_mask=SetImageChannelMask(image,channel);
10576 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10577 geometry.y,invert,exception);
10578 (void) SetImageChannelMask(image,channel_mask);
10579 draw_info=DestroyDrawInfo(draw_info);
10582 case 112: /* Distort */
10594 number_coordinates;
10599 if (attribute_flag[0] == 0)
10601 method=UndefinedDistortion;
10602 if (attribute_flag[1] != 0)
10603 method=(DistortImageMethod) argument_list[1].integer_reference;
10604 av=(AV *) argument_list[0].array_reference;
10605 number_coordinates=(size_t) av_len(av)+1;
10606 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10607 sizeof(*coordinates));
10608 if (coordinates == (double *) NULL)
10610 ThrowPerlException(exception,ResourceLimitFatalError,
10611 "MemoryAllocationFailed",PackageName);
10612 goto PerlException;
10614 for (j=0; j < (ssize_t) number_coordinates; j++)
10615 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10616 virtual_pixel=UndefinedVirtualPixelMethod;
10617 if (attribute_flag[2] != 0)
10618 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10619 argument_list[2].integer_reference,exception);
10620 image=DistortImage(image,method,number_coordinates,coordinates,
10621 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10623 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10624 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10626 coordinates=(double *) RelinquishMagickMemory(coordinates);
10629 case 113: /* Clut */
10631 PixelInterpolateMethod
10634 if (attribute_flag[0] == 0)
10636 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10638 goto PerlException;
10640 method=UndefinedInterpolatePixel;
10641 if (attribute_flag[1] != 0)
10642 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10643 if (attribute_flag[2] != 0)
10644 channel=(ChannelType) argument_list[2].integer_reference;
10645 channel_mask=SetImageChannelMask(image,channel);
10646 (void) ClutImage(image,argument_list[0].image_reference,method,
10648 (void) SetImageChannelMask(image,channel_mask);
10651 case 114: /* LiquidRescale */
10653 if (attribute_flag[0] != 0)
10654 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10655 &geometry,exception);
10656 if (attribute_flag[1] != 0)
10657 geometry.width=argument_list[1].integer_reference;
10658 if (attribute_flag[2] != 0)
10659 geometry.height=argument_list[2].integer_reference;
10660 if (attribute_flag[3] == 0)
10661 argument_list[3].real_reference=1.0;
10662 if (attribute_flag[4] == 0)
10663 argument_list[4].real_reference=0.0;
10664 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10665 argument_list[3].real_reference,argument_list[4].real_reference,
10669 case 115: /* EncipherImage */
10671 (void) EncipherImage(image,argument_list[0].string_reference,
10675 case 116: /* DecipherImage */
10677 (void) DecipherImage(image,argument_list[0].string_reference,
10681 case 117: /* Deskew */
10683 geometry_info.rho=QuantumRange/2.0;
10684 if (attribute_flag[0] != 0)
10685 flags=ParseGeometry(argument_list[0].string_reference,
10687 if (attribute_flag[1] != 0)
10688 geometry_info.rho=StringToDoubleInterval(
10689 argument_list[1].string_reference,(double) QuantumRange+1.0);
10690 image=DeskewImage(image,geometry_info.rho,exception);
10693 case 118: /* Remap */
10698 if (attribute_flag[0] == 0)
10700 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10702 goto PerlException;
10704 quantize_info=AcquireQuantizeInfo(info->image_info);
10705 if (attribute_flag[1] != 0)
10706 quantize_info->dither_method=(DitherMethod)
10707 argument_list[1].integer_reference;
10708 (void) RemapImages(quantize_info,image,
10709 argument_list[0].image_reference,exception);
10710 quantize_info=DestroyQuantizeInfo(quantize_info);
10713 case 119: /* SparseColor */
10725 number_coordinates;
10730 if (attribute_flag[0] == 0)
10732 method=UndefinedColorInterpolate;
10733 if (attribute_flag[1] != 0)
10734 method=(SparseColorMethod) argument_list[1].integer_reference;
10735 av=(AV *) argument_list[0].array_reference;
10736 number_coordinates=(size_t) av_len(av)+1;
10737 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10738 sizeof(*coordinates));
10739 if (coordinates == (double *) NULL)
10741 ThrowPerlException(exception,ResourceLimitFatalError,
10742 "MemoryAllocationFailed",PackageName);
10743 goto PerlException;
10745 for (j=0; j < (ssize_t) number_coordinates; j++)
10746 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10747 virtual_pixel=UndefinedVirtualPixelMethod;
10748 if (attribute_flag[2] != 0)
10749 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10750 argument_list[2].integer_reference,exception);
10751 if (attribute_flag[3] != 0)
10752 channel=(ChannelType) argument_list[3].integer_reference;
10753 channel_mask=SetImageChannelMask(image,channel);
10754 image=SparseColorImage(image,method,number_coordinates,coordinates,
10756 if (image != (Image *) NULL)
10757 (void) SetImageChannelMask(image,channel_mask);
10758 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10759 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10761 coordinates=(double *) RelinquishMagickMemory(coordinates);
10764 case 120: /* Function */
10781 if (attribute_flag[0] == 0)
10783 function=UndefinedFunction;
10784 if (attribute_flag[1] != 0)
10785 function=(MagickFunction) argument_list[1].integer_reference;
10786 av=(AV *) argument_list[0].array_reference;
10787 number_parameters=(size_t) av_len(av)+1;
10788 parameters=(double *) AcquireQuantumMemory(number_parameters,
10789 sizeof(*parameters));
10790 if (parameters == (double *) NULL)
10792 ThrowPerlException(exception,ResourceLimitFatalError,
10793 "MemoryAllocationFailed",PackageName);
10794 goto PerlException;
10796 for (j=0; j < (ssize_t) number_parameters; j++)
10797 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10798 virtual_pixel=UndefinedVirtualPixelMethod;
10799 if (attribute_flag[2] != 0)
10800 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10801 argument_list[2].integer_reference,exception);
10802 (void) FunctionImage(image,function,number_parameters,parameters,
10804 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10805 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10807 parameters=(double *) RelinquishMagickMemory(parameters);
10810 case 121: /* SelectiveBlur */
10812 if (attribute_flag[0] != 0)
10814 flags=ParseGeometry(argument_list[0].string_reference,
10816 if ((flags & SigmaValue) == 0)
10817 geometry_info.sigma=1.0;
10818 if ((flags & PercentValue) != 0)
10819 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10821 if (attribute_flag[1] != 0)
10822 geometry_info.rho=argument_list[1].real_reference;
10823 if (attribute_flag[2] != 0)
10824 geometry_info.sigma=argument_list[2].real_reference;
10825 if (attribute_flag[3] != 0)
10826 geometry_info.xi=argument_list[3].integer_reference;;
10827 if (attribute_flag[5] != 0)
10828 channel=(ChannelType) argument_list[5].integer_reference;
10829 channel_mask=SetImageChannelMask(image,channel);
10830 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10831 geometry_info.xi,exception);
10832 if (image != (Image *) NULL)
10833 (void) SetImageChannelMask(image,channel_mask);
10836 case 122: /* HaldClut */
10838 if (attribute_flag[0] == 0)
10840 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10842 goto PerlException;
10844 if (attribute_flag[1] != 0)
10845 channel=(ChannelType) argument_list[1].integer_reference;
10846 channel_mask=SetImageChannelMask(image,channel);
10847 (void) HaldClutImage(image,argument_list[0].image_reference,
10849 (void) SetImageChannelMask(image,channel_mask);
10852 case 123: /* BlueShift */
10854 if (attribute_flag[0] != 0)
10855 (void) ParseGeometry(argument_list[0].string_reference,
10857 image=BlueShiftImage(image,geometry_info.rho,exception);
10860 case 124: /* ForwardFourierTransformImage */
10862 image=ForwardFourierTransformImage(image,
10863 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10867 case 125: /* InverseFourierTransformImage */
10869 image=InverseFourierTransformImage(image,image->next,
10870 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10874 case 126: /* ColorDecisionList */
10876 if (attribute_flag[0] == 0)
10877 argument_list[0].string_reference=(char *) NULL;
10878 (void) ColorDecisionListImage(image,
10879 argument_list[0].string_reference,exception);
10882 case 127: /* AutoGamma */
10884 if (attribute_flag[0] != 0)
10885 channel=(ChannelType) argument_list[0].integer_reference;
10886 channel_mask=SetImageChannelMask(image,channel);
10887 (void) AutoGammaImage(image,exception);
10888 (void) SetImageChannelMask(image,channel_mask);
10891 case 128: /* AutoLevel */
10893 if (attribute_flag[0] != 0)
10894 channel=(ChannelType) argument_list[0].integer_reference;
10895 channel_mask=SetImageChannelMask(image,channel);
10896 (void) AutoLevelImage(image,exception);
10897 (void) SetImageChannelMask(image,channel_mask);
10900 case 129: /* LevelColors */
10906 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10908 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10910 if (attribute_flag[1] != 0)
10911 (void) QueryColorCompliance(
10912 argument_list[1].string_reference,AllCompliance,&black_point,
10914 if (attribute_flag[2] != 0)
10915 (void) QueryColorCompliance(
10916 argument_list[2].string_reference,AllCompliance,&white_point,
10918 if (attribute_flag[3] != 0)
10919 channel=(ChannelType) argument_list[3].integer_reference;
10920 channel_mask=SetImageChannelMask(image,channel);
10921 (void) LevelImageColors(image,&black_point,&white_point,
10922 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10924 (void) SetImageChannelMask(image,channel_mask);
10927 case 130: /* Clamp */
10929 if (attribute_flag[0] != 0)
10930 channel=(ChannelType) argument_list[0].integer_reference;
10931 channel_mask=SetImageChannelMask(image,channel);
10932 (void) ClampImage(image,exception);
10933 (void) SetImageChannelMask(image,channel_mask);
10936 case 131: /* BrightnessContrast */
10944 if (attribute_flag[0] != 0)
10946 flags=ParseGeometry(argument_list[0].string_reference,
10948 brightness=geometry_info.rho;
10949 if ((flags & SigmaValue) == 0)
10950 contrast=geometry_info.sigma;
10952 if (attribute_flag[1] != 0)
10953 brightness=argument_list[1].real_reference;
10954 if (attribute_flag[2] != 0)
10955 contrast=argument_list[2].real_reference;
10956 if (attribute_flag[4] != 0)
10957 channel=(ChannelType) argument_list[4].integer_reference;
10958 channel_mask=SetImageChannelMask(image,channel);
10959 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10960 (void) SetImageChannelMask(image,channel_mask);
10963 case 132: /* Morphology */
10974 if (attribute_flag[0] == 0)
10976 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10977 if (kernel == (KernelInfo *) NULL)
10979 if (attribute_flag[1] != 0)
10980 channel=(ChannelType) argument_list[1].integer_reference;
10981 method=UndefinedMorphology;
10982 if (attribute_flag[2] != 0)
10983 method=argument_list[2].integer_reference;
10985 if (attribute_flag[3] != 0)
10986 iterations=argument_list[3].integer_reference;
10987 channel_mask=SetImageChannelMask(image,channel);
10988 image=MorphologyImage(image,method,iterations,kernel,exception);
10989 if (image != (Image *) NULL)
10990 (void) SetImageChannelMask(image,channel_mask);
10991 kernel=DestroyKernelInfo(kernel);
10994 case 133: /* Mode */
10996 if (attribute_flag[0] != 0)
10998 flags=ParseGeometry(argument_list[0].string_reference,
11000 if ((flags & SigmaValue) == 0)
11001 geometry_info.sigma=1.0;
11003 if (attribute_flag[1] != 0)
11004 geometry_info.rho=argument_list[1].real_reference;
11005 if (attribute_flag[2] != 0)
11006 geometry_info.sigma=argument_list[2].real_reference;
11007 if (attribute_flag[3] != 0)
11008 channel=(ChannelType) argument_list[3].integer_reference;
11009 channel_mask=SetImageChannelMask(image,channel);
11010 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11011 (size_t) geometry_info.sigma,exception);
11012 if (image != (Image *) NULL)
11013 (void) SetImageChannelMask(image,channel_mask);
11016 case 134: /* Statistic */
11021 statistic=UndefinedStatistic;
11022 if (attribute_flag[0] != 0)
11024 flags=ParseGeometry(argument_list[0].string_reference,
11026 if ((flags & SigmaValue) == 0)
11027 geometry_info.sigma=1.0;
11029 if (attribute_flag[1] != 0)
11030 geometry_info.rho=argument_list[1].real_reference;
11031 if (attribute_flag[2] != 0)
11032 geometry_info.sigma=argument_list[2].real_reference;
11033 if (attribute_flag[3] != 0)
11034 channel=(ChannelType) argument_list[3].integer_reference;
11035 if (attribute_flag[4] != 0)
11036 statistic=(StatisticType) argument_list[4].integer_reference;
11037 channel_mask=SetImageChannelMask(image,channel);
11038 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11039 (size_t) geometry_info.sigma,exception);
11040 if (image != (Image *) NULL)
11041 (void) SetImageChannelMask(image,channel_mask);
11044 case 135: /* Perceptible */
11049 epsilon=MagickEpsilon;
11050 if (attribute_flag[0] != 0)
11051 epsilon=argument_list[0].real_reference;
11052 if (attribute_flag[1] != 0)
11053 channel=(ChannelType) argument_list[1].integer_reference;
11054 channel_mask=SetImageChannelMask(image,channel);
11055 (void) PerceptibleImage(image,epsilon,exception);
11056 (void) SetImageChannelMask(image,channel_mask);
11059 case 136: /* Poly */
11070 if (attribute_flag[0] == 0)
11072 if (attribute_flag[1] != 0)
11073 channel=(ChannelType) argument_list[1].integer_reference;
11074 av=(AV *) argument_list[0].array_reference;
11075 number_terms=(size_t) av_len(av);
11076 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11077 if (terms == (double *) NULL)
11079 ThrowPerlException(exception,ResourceLimitFatalError,
11080 "MemoryAllocationFailed",PackageName);
11081 goto PerlException;
11083 for (j=0; j < av_len(av); j++)
11084 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11085 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11086 terms=(double *) RelinquishMagickMemory(terms);
11089 case 137: /* Grayscale */
11091 PixelIntensityMethod
11094 method=UndefinedPixelIntensityMethod;
11095 if (attribute_flag[0] != 0)
11096 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11097 (void) GrayscaleImage(image,method,exception);
11100 case 138: /* Canny */
11102 if (attribute_flag[0] != 0)
11104 flags=ParseGeometry(argument_list[0].string_reference,
11106 if ((flags & SigmaValue) == 0)
11107 geometry_info.sigma=1.0;
11108 if ((flags & XiValue) == 0)
11109 geometry_info.xi=0.10;
11110 if ((flags & PsiValue) == 0)
11111 geometry_info.psi=0.30;
11112 if ((flags & PercentValue) != 0)
11114 geometry_info.xi/=100.0;
11115 geometry_info.psi/=100.0;
11118 if (attribute_flag[1] != 0)
11119 geometry_info.rho=argument_list[1].real_reference;
11120 if (attribute_flag[2] != 0)
11121 geometry_info.sigma=argument_list[2].real_reference;
11122 if (attribute_flag[3] != 0)
11123 geometry_info.xi=argument_list[3].real_reference;
11124 if (attribute_flag[4] != 0)
11125 geometry_info.psi=argument_list[4].real_reference;
11126 if (attribute_flag[5] != 0)
11127 channel=(ChannelType) argument_list[5].integer_reference;
11128 channel_mask=SetImageChannelMask(image,channel);
11129 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11130 geometry_info.xi,geometry_info.psi,exception);
11131 if (image != (Image *) NULL)
11132 (void) SetImageChannelMask(image,channel_mask);
11136 if (next != (Image *) NULL)
11137 (void) CatchImageException(next);
11138 if (region_image != (Image *) NULL)
11143 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
11144 region_info.x,region_info.y,exception);
11146 (void) CatchImageException(region_image);
11147 image=DestroyImage(image);
11148 image=region_image;
11150 if (image != (Image *) NULL)
11153 if (next && (next != image))
11155 image->next=next->next;
11156 if (image->next != (Image *) NULL)
11157 image->next->previous=image;
11158 DeleteImageFromRegistry(*pv,next);
11160 sv_setiv(*pv,PTR2IV(image));
11168 if (reference_vector)
11169 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11170 InheritPerlException(exception,perl_exception);
11171 exception=DestroyExceptionInfo(exception);
11172 sv_setiv(perl_exception,(IV) number_images);
11173 SvPOK_on(perl_exception);
11174 ST(0)=sv_2mortal(perl_exception);
11179 ###############################################################################
11187 ###############################################################################
11192 Image::Magick ref=NO_INIT
11237 PERL_UNUSED_VAR(ref);
11238 PERL_UNUSED_VAR(ix);
11239 exception=AcquireExceptionInfo();
11240 perl_exception=newSVpv("",0);
11243 if (sv_isobject(ST(0)) == 0)
11245 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11247 goto PerlException;
11249 reference=SvRV(ST(0));
11250 hv=SvSTASH(reference);
11252 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11254 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11255 if (image == (Image *) NULL)
11257 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11259 goto PerlException;
11264 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11265 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11266 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11268 for (i=2; i < items; i+=2)
11270 attribute=(char *) SvPV(ST(i-1),na);
11271 switch (*attribute)
11276 if (LocaleCompare(attribute,"background") == 0)
11278 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11279 &montage_info->background_color,exception);
11280 for (next=image; next; next=next->next)
11281 next->background_color=montage_info->background_color;
11284 if (LocaleCompare(attribute,"border") == 0)
11286 montage_info->border_width=SvIV(ST(i));
11289 if (LocaleCompare(attribute,"bordercolor") == 0)
11291 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11292 &montage_info->border_color,exception);
11293 for (next=image; next; next=next->next)
11294 next->border_color=montage_info->border_color;
11297 if (LocaleCompare(attribute,"borderwidth") == 0)
11299 montage_info->border_width=SvIV(ST(i));
11302 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11309 if (LocaleCompare(attribute,"compose") == 0)
11311 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11312 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11315 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11319 for (next=image; next; next=next->next)
11320 next->compose=(CompositeOperator) sp;
11323 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11330 if (LocaleCompare(attribute,"fill") == 0)
11332 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11333 &montage_info->fill,exception);
11336 if (LocaleCompare(attribute,"font") == 0)
11338 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11341 if (LocaleCompare(attribute,"frame") == 0)
11347 if (IsGeometry(p) == MagickFalse)
11349 ThrowPerlException(exception,OptionError,"MissingGeometry",
11353 (void) CloneString(&montage_info->frame,p);
11355 montage_info->frame=(char *) NULL;
11358 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11365 if (LocaleCompare(attribute,"geometry") == 0)
11371 if (IsGeometry(p) == MagickFalse)
11373 ThrowPerlException(exception,OptionError,"MissingGeometry",
11377 (void) CloneString(&montage_info->geometry,p);
11379 montage_info->geometry=(char *) NULL;
11382 if (LocaleCompare(attribute,"gravity") == 0)
11387 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11388 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11391 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11395 montage_info->gravity=(GravityType) in;
11396 for (next=image; next; next=next->next)
11397 next->gravity=(GravityType) in;
11400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11407 if (LocaleCompare(attribute,"label") == 0)
11409 for (next=image; next; next=next->next)
11410 (void) SetImageProperty(next,"label",InterpretImageProperties(
11411 info ? info->image_info : (ImageInfo *) NULL,next,
11412 SvPV(ST(i),na),exception),exception);
11415 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11422 if (LocaleCompare(attribute,"mattecolor") == 0)
11424 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11425 &montage_info->matte_color,exception);
11426 for (next=image; next; next=next->next)
11427 next->matte_color=montage_info->matte_color;
11430 if (LocaleCompare(attribute,"mode") == 0)
11435 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11436 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11441 ThrowPerlException(exception,OptionError,
11442 "UnrecognizedModeType",SvPV(ST(i),na));
11447 (void) CloneString(&montage_info->frame,"15x15+3+3");
11448 montage_info->shadow=MagickTrue;
11453 montage_info->frame=(char *) NULL;
11454 montage_info->shadow=MagickFalse;
11455 montage_info->border_width=0;
11458 case ConcatenateMode:
11460 montage_info->frame=(char *) NULL;
11461 montage_info->shadow=MagickFalse;
11462 (void) CloneString(&montage_info->geometry,"+0+0");
11463 montage_info->border_width=0;
11468 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11475 if (LocaleCompare(attribute,"pointsize") == 0)
11477 montage_info->pointsize=SvIV(ST(i));
11480 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11487 if (LocaleCompare(attribute,"shadow") == 0)
11489 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11490 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11493 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11497 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11500 if (LocaleCompare(attribute,"stroke") == 0)
11502 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11503 &montage_info->stroke,exception);
11506 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11513 if (LocaleCompare(attribute,"texture") == 0)
11515 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11518 if (LocaleCompare(attribute,"tile") == 0)
11520 char *p=SvPV(ST(i),na);
11521 if (IsGeometry(p) == MagickFalse)
11523 ThrowPerlException(exception,OptionError,"MissingGeometry",
11527 (void) CloneString(&montage_info->tile,p);
11529 montage_info->tile=(char *) NULL;
11532 if (LocaleCompare(attribute,"title") == 0)
11534 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11537 if (LocaleCompare(attribute,"transparent") == 0)
11542 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11543 &transparent_color,exception);
11544 for (next=image; next; next=next->next)
11545 (void) TransparentPaintImage(next,&transparent_color,
11546 TransparentAlpha,MagickFalse,exception);
11549 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11555 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11561 image=MontageImageList(info->image_info,montage_info,image,exception);
11562 montage_info=DestroyMontageInfo(montage_info);
11563 if (image == (Image *) NULL)
11564 goto PerlException;
11565 if (transparent_color.alpha != TransparentAlpha)
11566 for (next=image; next; next=next->next)
11567 (void) TransparentPaintImage(next,&transparent_color,
11568 TransparentAlpha,MagickFalse,exception);
11569 for ( ; image; image=image->next)
11571 AddImageToRegistry(sv,image);
11573 av_push(av,sv_bless(rv,hv));
11576 exception=DestroyExceptionInfo(exception);
11577 ST(0)=av_reference;
11578 SvREFCNT_dec(perl_exception);
11582 InheritPerlException(exception,perl_exception);
11583 exception=DestroyExceptionInfo(exception);
11584 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11585 SvPOK_on(perl_exception);
11586 ST(0)=sv_2mortal(perl_exception);
11591 ###############################################################################
11599 ###############################################################################
11604 Image::Magick ref=NO_INIT
11642 PERL_UNUSED_VAR(ref);
11643 PERL_UNUSED_VAR(ix);
11644 exception=AcquireExceptionInfo();
11645 perl_exception=newSVpv("",0);
11649 if (sv_isobject(ST(0)) == 0)
11651 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11653 goto PerlException;
11655 reference=SvRV(ST(0));
11656 hv=SvSTASH(reference);
11658 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11660 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11661 if (image == (Image *) NULL)
11663 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11665 goto PerlException;
11667 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11672 for (i=2; i < items; i+=2)
11674 attribute=(char *) SvPV(ST(i-1),na);
11675 switch (*attribute)
11680 if (LocaleCompare(attribute,"frames") == 0)
11682 number_frames=SvIV(ST(i));
11685 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11691 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11697 image=MorphImages(image,number_frames,exception);
11698 if (image == (Image *) NULL)
11699 goto PerlException;
11700 for ( ; image; image=image->next)
11702 AddImageToRegistry(sv,image);
11704 av_push(av,sv_bless(rv,hv));
11707 exception=DestroyExceptionInfo(exception);
11708 ST(0)=av_reference;
11709 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11713 InheritPerlException(exception,perl_exception);
11714 exception=DestroyExceptionInfo(exception);
11715 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11716 SvPOK_on(perl_exception);
11717 ST(0)=sv_2mortal(perl_exception);
11722 ###############################################################################
11730 ###############################################################################
11735 Image::Magick ref=NO_INIT
11763 PERL_UNUSED_VAR(ref);
11764 PERL_UNUSED_VAR(ix);
11765 exception=AcquireExceptionInfo();
11766 perl_exception=newSVpv("",0);
11768 if (sv_isobject(ST(0)) == 0)
11770 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11772 goto PerlException;
11774 reference=SvRV(ST(0));
11775 hv=SvSTASH(reference);
11776 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11777 if (image == (Image *) NULL)
11779 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11781 goto PerlException;
11783 image=MergeImageLayers(image,MosaicLayer,exception);
11785 Create blessed Perl array for the returned image.
11788 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11790 AddImageToRegistry(sv,image);
11792 av_push(av,sv_bless(rv,hv));
11794 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11795 (void) CopyMagickString(info->image_info->filename,image->filename,
11797 SetImageInfo(info->image_info,0,exception);
11798 exception=DestroyExceptionInfo(exception);
11799 SvREFCNT_dec(perl_exception);
11803 InheritPerlException(exception,perl_exception);
11804 exception=DestroyExceptionInfo(exception);
11805 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11806 SvPOK_on(perl_exception); /* return messages in string context */
11807 ST(0)=sv_2mortal(perl_exception);
11812 ###############################################################################
11820 ###############################################################################
11825 Image::Magick ref=NO_INIT
11875 PERL_UNUSED_VAR(ref);
11876 PERL_UNUSED_VAR(ix);
11877 exception=AcquireExceptionInfo();
11878 perl_exception=newSVpv("",0);
11879 package_info=(struct PackageInfo *) NULL;
11880 ac=(items < 2) ? 1 : items-1;
11881 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11883 length=(STRLEN *) NULL;
11884 if (list == (char **) NULL)
11886 ThrowPerlException(exception,ResourceLimitError,
11887 "MemoryAllocationFailed",PackageName);
11888 goto PerlException;
11891 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11892 if (length == (STRLEN *) NULL)
11894 ThrowPerlException(exception,ResourceLimitError,
11895 "MemoryAllocationFailed",PackageName);
11896 goto PerlException;
11898 if (sv_isobject(ST(0)) == 0)
11900 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11902 goto PerlException;
11904 reference=SvRV(ST(0));
11905 if (SvTYPE(reference) != SVt_PVAV)
11907 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11909 goto PerlException;
11911 av=(AV *) reference;
11912 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11914 package_info=ClonePackageInfo(info,exception);
11917 *list=(char *) (*package_info->image_info->filename ?
11918 package_info->image_info->filename : "XC:black");
11920 for (n=0, i=0; i < ac; i++)
11922 list[n]=(char *) SvPV(ST(i+1),length[n]);
11923 if ((items >= 3) && strEQcase(list[n],"blob"))
11929 blob=(void *) (SvPV(ST(i+1),length[n]));
11930 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11932 if ((items >= 3) && strEQcase(list[n],"filename"))
11934 if ((items >= 3) && strEQcase(list[n],"file"))
11943 io_info=IoIFP(sv_2io(ST(i+1)));
11944 if (io_info == (PerlIO *) NULL)
11946 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11950 file=PerlIO_findFILE(io_info);
11951 if (file == (FILE *) NULL)
11953 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11957 SetImageInfoFile(package_info->image_info,file);
11959 if ((items >= 3) && strEQcase(list[n],"magick"))
11963 list[n]=(char *) NULL;
11965 status=ExpandFilenames(&n,&list);
11966 if (status == MagickFalse)
11968 ThrowPerlException(exception,ResourceLimitError,
11969 "MemoryAllocationFailed",PackageName);
11970 goto PerlException;
11973 for (i=0; i < n; i++)
11975 (void) CopyMagickString(package_info->image_info->filename,list[i],
11977 image=PingImage(package_info->image_info,exception);
11978 if (image == (Image *) NULL)
11980 if ((package_info->image_info->file != (FILE *) NULL) ||
11981 (package_info->image_info->blob != (void *) NULL))
11982 DisassociateImageStream(image);
11983 count+=GetImageListLength(image);
11984 EXTEND(sp,4*count);
11985 for (next=image; next; next=next->next)
11987 PUSHs(sv_2mortal(newSViv(next->columns)));
11988 PUSHs(sv_2mortal(newSViv(next->rows)));
11989 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11990 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11992 image=DestroyImageList(image);
11997 for (i=0; i < n; i++)
11998 if (list[i] != (char *) NULL)
11999 for (p=keep; list[i] != *p++; )
12002 list[i]=(char *) RelinquishMagickMemory(list[i]);
12007 if (package_info != (struct PackageInfo *) NULL)
12008 DestroyPackageInfo(package_info);
12009 if (list && (list != keep))
12010 list=(char **) RelinquishMagickMemory(list);
12012 keep=(char **) RelinquishMagickMemory(keep);
12014 length=(STRLEN *) RelinquishMagickMemory(length);
12015 InheritPerlException(exception,perl_exception);
12016 exception=DestroyExceptionInfo(exception);
12017 SvREFCNT_dec(perl_exception); /* throw away all errors */
12021 ###############################################################################
12029 ###############################################################################
12034 Image::Magick ref=NO_INIT
12067 PERL_UNUSED_VAR(ref);
12068 PERL_UNUSED_VAR(ix);
12069 exception=AcquireExceptionInfo();
12070 perl_exception=newSVpv("",0);
12073 if (sv_isobject(ST(0)) == 0)
12075 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12077 goto PerlException;
12079 reference=SvRV(ST(0));
12080 hv=SvSTASH(reference);
12082 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12084 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12085 if (image == (Image *) NULL)
12087 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12089 goto PerlException;
12091 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12092 preview_type=GammaPreview;
12094 preview_type=(PreviewType)
12095 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
12096 for ( ; image; image=image->next)
12098 preview_image=PreviewImage(image,preview_type,exception);
12099 if (preview_image == (Image *) NULL)
12100 goto PerlException;
12101 AddImageToRegistry(sv,preview_image);
12103 av_push(av,sv_bless(rv,hv));
12106 exception=DestroyExceptionInfo(exception);
12107 ST(0)=av_reference;
12108 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12112 InheritPerlException(exception,perl_exception);
12113 exception=DestroyExceptionInfo(exception);
12114 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12115 SvPOK_on(perl_exception);
12116 ST(0)=sv_2mortal(perl_exception);
12121 ###############################################################################
12125 # Q u e r y C o l o r #
12129 ###############################################################################
12133 QueryColor(ref,...)
12134 Image::Magick ref=NO_INIT
12154 PERL_UNUSED_VAR(ref);
12155 PERL_UNUSED_VAR(ix);
12156 exception=AcquireExceptionInfo();
12157 perl_exception=newSVpv("",0);
12166 colorlist=GetColorInfoList("*",&colors,exception);
12168 for (i=0; i < (ssize_t) colors; i++)
12170 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12172 colorlist=(const ColorInfo **)
12173 RelinquishMagickMemory((ColorInfo **) colorlist);
12174 goto PerlException;
12176 EXTEND(sp,5*items);
12177 for (i=1; i < items; i++)
12179 name=(char *) SvPV(ST(i),na);
12180 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12185 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12186 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12187 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12188 if (color.colorspace == CMYKColorspace)
12189 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12190 if (color.alpha_trait == BlendPixelTrait)
12191 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12195 InheritPerlException(exception,perl_exception);
12196 exception=DestroyExceptionInfo(exception);
12197 SvREFCNT_dec(perl_exception);
12201 ###############################################################################
12205 # Q u e r y C o l o r N a m e #
12209 ###############################################################################
12213 QueryColorname(ref,...)
12214 Image::Magick ref=NO_INIT
12223 message[MaxTextExtent];
12242 *reference; /* reference is the SV* of ref=SvIV(reference) */
12244 PERL_UNUSED_VAR(ref);
12245 PERL_UNUSED_VAR(ix);
12246 exception=AcquireExceptionInfo();
12247 perl_exception=newSVpv("",0);
12248 reference=SvRV(ST(0));
12249 av=(AV *) reference;
12250 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12252 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12253 if (image == (Image *) NULL)
12255 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12257 goto PerlException;
12260 for (i=1; i < items; i++)
12262 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12264 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12266 PUSHs(sv_2mortal(newSVpv(message,0)));
12270 InheritPerlException(exception,perl_exception);
12271 exception=DestroyExceptionInfo(exception);
12272 SvREFCNT_dec(perl_exception);
12276 ###############################################################################
12280 # Q u e r y F o n t #
12284 ###############################################################################
12289 Image::Magick ref=NO_INIT
12296 message[MaxTextExtent];
12307 volatile const TypeInfo
12310 PERL_UNUSED_VAR(ref);
12311 PERL_UNUSED_VAR(ix);
12312 exception=AcquireExceptionInfo();
12313 perl_exception=newSVpv("",0);
12322 typelist=GetTypeInfoList("*",&types,exception);
12324 for (i=0; i < (ssize_t) types; i++)
12326 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12328 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12330 goto PerlException;
12332 EXTEND(sp,10*items);
12333 for (i=1; i < items; i++)
12335 name=(char *) SvPV(ST(i),na);
12336 type_info=GetTypeInfo(name,exception);
12337 if (type_info == (TypeInfo *) NULL)
12342 if (type_info->name == (char *) NULL)
12345 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12346 if (type_info->description == (char *) NULL)
12349 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12350 if (type_info->family == (char *) NULL)
12353 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12354 if (type_info->style == UndefinedStyle)
12357 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12358 type_info->style),0)));
12359 if (type_info->stretch == UndefinedStretch)
12362 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12363 type_info->stretch),0)));
12364 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12365 type_info->weight);
12366 PUSHs(sv_2mortal(newSVpv(message,0)));
12367 if (type_info->encoding == (char *) NULL)
12370 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12371 if (type_info->foundry == (char *) NULL)
12374 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12375 if (type_info->format == (char *) NULL)
12378 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12379 if (type_info->metrics == (char *) NULL)
12382 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12383 if (type_info->glyphs == (char *) NULL)
12386 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12390 InheritPerlException(exception,perl_exception);
12391 exception=DestroyExceptionInfo(exception);
12392 SvREFCNT_dec(perl_exception);
12396 ###############################################################################
12400 # Q u e r y F o n t M e t r i c s #
12404 ###############################################################################
12408 QueryFontMetrics(ref,...)
12409 Image::Magick ref=NO_INIT
12411 queryfontmetrics = 1
12458 *reference; /* reference is the SV* of ref=SvIV(reference) */
12463 PERL_UNUSED_VAR(ref);
12464 PERL_UNUSED_VAR(ix);
12465 exception=AcquireExceptionInfo();
12466 package_info=(struct PackageInfo *) NULL;
12467 perl_exception=newSVpv("",0);
12468 reference=SvRV(ST(0));
12469 av=(AV *) reference;
12470 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12472 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12473 if (image == (Image *) NULL)
12475 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12477 goto PerlException;
12479 package_info=ClonePackageInfo(info,exception);
12480 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12481 CloneString(&draw_info->text,"");
12482 current=draw_info->affine;
12483 GetAffineMatrix(&affine);
12486 EXTEND(sp,7*items);
12487 for (i=2; i < items; i+=2)
12489 attribute=(char *) SvPV(ST(i-1),na);
12490 switch (*attribute)
12495 if (LocaleCompare(attribute,"antialias") == 0)
12497 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12501 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12505 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12508 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12515 if (LocaleCompare(attribute,"density") == 0)
12517 CloneString(&draw_info->density,SvPV(ST(i),na));
12520 if (LocaleCompare(attribute,"direction") == 0)
12522 draw_info->direction=(DirectionType) ParseCommandOption(
12523 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12526 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12533 if (LocaleCompare(attribute,"encoding") == 0)
12535 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12538 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12545 if (LocaleCompare(attribute,"family") == 0)
12547 CloneString(&draw_info->family,SvPV(ST(i),na));
12550 if (LocaleCompare(attribute,"fill") == 0)
12553 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12554 &draw_info->fill,exception);
12557 if (LocaleCompare(attribute,"font") == 0)
12559 CloneString(&draw_info->font,SvPV(ST(i),na));
12562 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12569 if (LocaleCompare(attribute,"geometry") == 0)
12571 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12574 if (LocaleCompare(attribute,"gravity") == 0)
12576 draw_info->gravity=(GravityType) ParseCommandOption(
12577 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12580 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12587 if (LocaleCompare(attribute,"interline-spacing") == 0)
12589 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12590 draw_info->interline_spacing=geometry_info.rho;
12593 if (LocaleCompare(attribute,"interword-spacing") == 0)
12595 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12596 draw_info->interword_spacing=geometry_info.rho;
12599 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12606 if (LocaleCompare(attribute,"kerning") == 0)
12608 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12609 draw_info->kerning=geometry_info.rho;
12612 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12619 if (LocaleCompare(attribute,"pointsize") == 0)
12621 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12622 draw_info->pointsize=geometry_info.rho;
12625 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12632 if (LocaleCompare(attribute,"rotate") == 0)
12634 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12635 affine.rx=geometry_info.rho;
12636 affine.ry=geometry_info.sigma;
12637 if ((flags & SigmaValue) == 0)
12638 affine.ry=affine.rx;
12641 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12648 if (LocaleCompare(attribute,"scale") == 0)
12650 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12651 affine.sx=geometry_info.rho;
12652 affine.sy=geometry_info.sigma;
12653 if ((flags & SigmaValue) == 0)
12654 affine.sy=affine.sx;
12657 if (LocaleCompare(attribute,"skew") == 0)
12663 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12664 x_angle=geometry_info.rho;
12665 y_angle=geometry_info.sigma;
12666 if ((flags & SigmaValue) == 0)
12668 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12669 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12672 if (LocaleCompare(attribute,"stroke") == 0)
12675 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12676 &draw_info->stroke,exception);
12679 if (LocaleCompare(attribute,"style") == 0)
12681 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12685 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12689 draw_info->style=(StyleType) type;
12692 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12699 if (LocaleCompare(attribute,"text") == 0)
12701 CloneString(&draw_info->text,SvPV(ST(i),na));
12704 if (LocaleCompare(attribute,"translate") == 0)
12706 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12707 affine.tx=geometry_info.rho;
12708 affine.ty=geometry_info.sigma;
12709 if ((flags & SigmaValue) == 0)
12710 affine.ty=affine.tx;
12713 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12720 if (LocaleCompare(attribute,"weight") == 0)
12722 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12723 draw_info->weight=(size_t) geometry_info.rho;
12726 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12733 if (LocaleCompare(attribute,"x") == 0)
12735 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12736 x=geometry_info.rho;
12739 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12746 if (LocaleCompare(attribute,"y") == 0)
12748 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12749 y=geometry_info.rho;
12752 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12758 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12764 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12765 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12766 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12767 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12768 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12769 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12770 if (draw_info->geometry == (char *) NULL)
12772 draw_info->geometry=AcquireString((char *) NULL);
12773 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12774 "%.15g,%.15g",x,y);
12776 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12777 (void) CatchImageException(image);
12778 if (status == MagickFalse)
12782 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12783 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12784 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12785 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12786 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12787 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12788 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12789 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12790 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12791 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12792 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12793 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12794 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12796 draw_info=DestroyDrawInfo(draw_info);
12799 if (package_info != (struct PackageInfo *) NULL)
12800 DestroyPackageInfo(package_info);
12801 InheritPerlException(exception,perl_exception);
12802 exception=DestroyExceptionInfo(exception);
12803 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12807 ###############################################################################
12811 # 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 #
12815 ###############################################################################
12819 QueryMultilineFontMetrics(ref,...)
12820 Image::Magick ref=NO_INIT
12822 querymultilinefontmetrics = 1
12869 *reference; /* reference is the SV* of ref=SvIV(reference) */
12874 PERL_UNUSED_VAR(ref);
12875 PERL_UNUSED_VAR(ix);
12876 exception=AcquireExceptionInfo();
12877 package_info=(struct PackageInfo *) NULL;
12878 perl_exception=newSVpv("",0);
12879 reference=SvRV(ST(0));
12880 av=(AV *) reference;
12881 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12883 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12884 if (image == (Image *) NULL)
12886 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12888 goto PerlException;
12890 package_info=ClonePackageInfo(info,exception);
12891 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12892 CloneString(&draw_info->text,"");
12893 current=draw_info->affine;
12894 GetAffineMatrix(&affine);
12897 EXTEND(sp,7*items);
12898 for (i=2; i < items; i+=2)
12900 attribute=(char *) SvPV(ST(i-1),na);
12901 switch (*attribute)
12906 if (LocaleCompare(attribute,"antialias") == 0)
12908 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12912 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12916 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12919 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12926 if (LocaleCompare(attribute,"density") == 0)
12928 CloneString(&draw_info->density,SvPV(ST(i),na));
12931 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12938 if (LocaleCompare(attribute,"encoding") == 0)
12940 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12943 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12950 if (LocaleCompare(attribute,"family") == 0)
12952 CloneString(&draw_info->family,SvPV(ST(i),na));
12955 if (LocaleCompare(attribute,"fill") == 0)
12958 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12959 &draw_info->fill,exception);
12962 if (LocaleCompare(attribute,"font") == 0)
12964 CloneString(&draw_info->font,SvPV(ST(i),na));
12967 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12974 if (LocaleCompare(attribute,"geometry") == 0)
12976 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12979 if (LocaleCompare(attribute,"gravity") == 0)
12981 draw_info->gravity=(GravityType) ParseCommandOption(
12982 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12985 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12992 if (LocaleCompare(attribute,"pointsize") == 0)
12994 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12995 draw_info->pointsize=geometry_info.rho;
12998 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13005 if (LocaleCompare(attribute,"rotate") == 0)
13007 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13008 affine.rx=geometry_info.rho;
13009 affine.ry=geometry_info.sigma;
13010 if ((flags & SigmaValue) == 0)
13011 affine.ry=affine.rx;
13014 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13021 if (LocaleCompare(attribute,"scale") == 0)
13023 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13024 affine.sx=geometry_info.rho;
13025 affine.sy=geometry_info.sigma;
13026 if ((flags & SigmaValue) == 0)
13027 affine.sy=affine.sx;
13030 if (LocaleCompare(attribute,"skew") == 0)
13036 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13037 x_angle=geometry_info.rho;
13038 y_angle=geometry_info.sigma;
13039 if ((flags & SigmaValue) == 0)
13041 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13042 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13045 if (LocaleCompare(attribute,"stroke") == 0)
13048 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13049 &draw_info->stroke,exception);
13052 if (LocaleCompare(attribute,"style") == 0)
13054 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13058 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13062 draw_info->style=(StyleType) type;
13065 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13072 if (LocaleCompare(attribute,"text") == 0)
13074 CloneString(&draw_info->text,SvPV(ST(i),na));
13077 if (LocaleCompare(attribute,"translate") == 0)
13079 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13080 affine.tx=geometry_info.rho;
13081 affine.ty=geometry_info.sigma;
13082 if ((flags & SigmaValue) == 0)
13083 affine.ty=affine.tx;
13086 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13093 if (LocaleCompare(attribute,"weight") == 0)
13095 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13096 draw_info->weight=(size_t) geometry_info.rho;
13099 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13106 if (LocaleCompare(attribute,"x") == 0)
13108 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13109 x=geometry_info.rho;
13112 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13119 if (LocaleCompare(attribute,"y") == 0)
13121 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13122 y=geometry_info.rho;
13125 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13131 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13137 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13138 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13139 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13140 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13141 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13142 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13143 if (draw_info->geometry == (char *) NULL)
13145 draw_info->geometry=AcquireString((char *) NULL);
13146 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
13147 "%.15g,%.15g",x,y);
13149 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13150 (void) CatchException(exception);
13151 if (status == MagickFalse)
13155 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13156 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13157 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13158 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13159 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13160 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13161 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13162 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13163 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13164 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13165 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13166 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13167 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13169 draw_info=DestroyDrawInfo(draw_info);
13172 if (package_info != (struct PackageInfo *) NULL)
13173 DestroyPackageInfo(package_info);
13174 InheritPerlException(exception,perl_exception);
13175 exception=DestroyExceptionInfo(exception);
13176 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13180 ###############################################################################
13184 # Q u e r y F o r m a t #
13188 ###############################################################################
13192 QueryFormat(ref,...)
13193 Image::Magick ref=NO_INIT
13210 volatile const MagickInfo
13213 PERL_UNUSED_VAR(ref);
13214 PERL_UNUSED_VAR(ix);
13215 exception=AcquireExceptionInfo();
13216 perl_exception=newSVpv("",0);
13220 format[MaxTextExtent];
13228 format_list=GetMagickInfoList("*",&types,exception);
13230 for (i=0; i < (ssize_t) types; i++)
13232 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13233 LocaleLower(format);
13234 PUSHs(sv_2mortal(newSVpv(format,0)));
13236 format_list=(const MagickInfo **)
13237 RelinquishMagickMemory((MagickInfo *) format_list);
13238 goto PerlException;
13240 EXTEND(sp,8*items);
13241 for (i=1; i < items; i++)
13243 name=(char *) SvPV(ST(i),na);
13244 magick_info=GetMagickInfo(name,exception);
13245 if (magick_info == (const MagickInfo *) NULL)
13250 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13251 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13252 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13253 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13254 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13255 if (magick_info->description == (char *) NULL)
13258 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13259 if (magick_info->module == (char *) NULL)
13262 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13266 InheritPerlException(exception,perl_exception);
13267 exception=DestroyExceptionInfo(exception);
13268 SvREFCNT_dec(perl_exception);
13272 ###############################################################################
13276 # Q u e r y O p t i o n #
13280 ###############################################################################
13284 QueryOption(ref,...)
13285 Image::Magick ref=NO_INIT
13306 PERL_UNUSED_VAR(ref);
13307 PERL_UNUSED_VAR(ix);
13308 exception=AcquireExceptionInfo();
13309 perl_exception=newSVpv("",0);
13310 EXTEND(sp,8*items);
13311 for (i=1; i < items; i++)
13313 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13315 options=GetCommandOptions((CommandOption) option);
13316 if (options == (char **) NULL)
13320 for (j=0; options[j] != (char *) NULL; j++)
13321 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13322 options=DestroyStringList(options);
13326 InheritPerlException(exception,perl_exception);
13327 exception=DestroyExceptionInfo(exception);
13328 SvREFCNT_dec(perl_exception);
13332 ###############################################################################
13340 ###############################################################################
13345 Image::Magick ref=NO_INIT
13392 *perl_exception, /* Perl variable for storing messages */
13397 PERL_UNUSED_VAR(ref);
13398 PERL_UNUSED_VAR(ix);
13399 exception=AcquireExceptionInfo();
13400 perl_exception=newSVpv("",0);
13402 package_info=(struct PackageInfo *) NULL;
13404 ac=(items < 2) ? 1 : items-1;
13405 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13407 length=(STRLEN *) NULL;
13408 if (list == (char **) NULL)
13410 ThrowPerlException(exception,ResourceLimitError,
13411 "MemoryAllocationFailed",PackageName);
13412 goto PerlException;
13414 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13415 if (length == (STRLEN *) NULL)
13417 ThrowPerlException(exception,ResourceLimitError,
13418 "MemoryAllocationFailed",PackageName);
13419 goto PerlException;
13421 if (sv_isobject(ST(0)) == 0)
13423 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13425 goto PerlException;
13427 reference=SvRV(ST(0));
13428 hv=SvSTASH(reference);
13429 if (SvTYPE(reference) != SVt_PVAV)
13431 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13433 goto PerlException;
13435 av=(AV *) reference;
13436 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13438 package_info=ClonePackageInfo(info,exception);
13441 *list=(char *) (*package_info->image_info->filename ?
13442 package_info->image_info->filename : "XC:black");
13444 for (n=0, i=0; i < ac; i++)
13446 list[n]=(char *) SvPV(ST(i+1),length[n]);
13447 if ((items >= 3) && strEQcase(list[n],"blob"))
13453 blob=(void *) (SvPV(ST(i+1),length[n]));
13454 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13456 if ((items >= 3) && strEQcase(list[n],"filename"))
13458 if ((items >= 3) && strEQcase(list[n],"file"))
13467 io_info=IoIFP(sv_2io(ST(i+1)));
13468 if (io_info == (PerlIO *) NULL)
13470 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13474 file=PerlIO_findFILE(io_info);
13475 if (file == (FILE *) NULL)
13477 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13481 SetImageInfoFile(package_info->image_info,file);
13483 if ((items >= 3) && strEQcase(list[n],"magick"))
13487 list[n]=(char *) NULL;
13489 status=ExpandFilenames(&n,&list);
13490 if (status == MagickFalse)
13492 ThrowPerlException(exception,ResourceLimitError,
13493 "MemoryAllocationFailed",PackageName);
13494 goto PerlException;
13497 for (i=0; i < n; i++)
13499 if ((package_info->image_info->file == (FILE *) NULL) &&
13500 (package_info->image_info->blob == (void *) NULL))
13501 image=ReadImages(package_info->image_info,list[i],exception);
13504 image=ReadImages(package_info->image_info,
13505 package_info->image_info->filename,exception);
13506 if (image != (Image *) NULL)
13507 DisassociateImageStream(image);
13509 if (image == (Image *) NULL)
13511 for ( ; image; image=image->next)
13513 AddImageToRegistry(sv,image);
13515 av_push(av,sv_bless(rv,hv));
13523 for (i=0; i < n; i++)
13524 if (list[i] != (char *) NULL)
13525 for (p=keep; list[i] != *p++; )
13526 if (*p == (char *) NULL)
13528 list[i]=(char *) RelinquishMagickMemory(list[i]);
13533 if (package_info != (struct PackageInfo *) NULL)
13534 DestroyPackageInfo(package_info);
13535 if (list && (list != keep))
13536 list=(char **) RelinquishMagickMemory(list);
13538 keep=(char **) RelinquishMagickMemory(keep);
13540 length=(STRLEN *) RelinquishMagickMemory(length);
13541 InheritPerlException(exception,perl_exception);
13542 exception=DestroyExceptionInfo(exception);
13543 sv_setiv(perl_exception,(IV) number_images);
13544 SvPOK_on(perl_exception);
13545 ST(0)=sv_2mortal(perl_exception);
13550 ###############################################################################
13558 ###############################################################################
13563 Image::Magick ref=NO_INIT
13586 PERL_UNUSED_VAR(ref);
13587 PERL_UNUSED_VAR(ix);
13588 exception=AcquireExceptionInfo();
13589 perl_exception=newSVpv("",0);
13590 reference=SvRV(ST(0));
13591 av=(AV *) reference;
13592 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13594 for (i=1; i < items; i++)
13595 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13596 SvPV(ST(i),na),exception);
13597 InheritPerlException(exception,perl_exception);
13598 exception=DestroyExceptionInfo(exception);
13599 SvREFCNT_dec(perl_exception); /* throw away all errors */
13603 ###############################################################################
13611 ###############################################################################
13616 Image::Magick ref=NO_INIT
13639 *reference; /* reference is the SV* of ref=SvIV(reference) */
13641 PERL_UNUSED_VAR(ref);
13642 PERL_UNUSED_VAR(ix);
13643 exception=AcquireExceptionInfo();
13644 perl_exception=newSVpv("",0);
13645 if (sv_isobject(ST(0)) == 0)
13647 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13649 goto PerlException;
13651 reference=SvRV(ST(0));
13652 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13654 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13656 for (i=2; i < items; i+=2)
13657 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13660 InheritPerlException(exception,perl_exception);
13661 exception=DestroyExceptionInfo(exception);
13662 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13663 SvPOK_on(perl_exception);
13664 ST(0)=sv_2mortal(perl_exception);
13669 ###############################################################################
13673 # S e t P i x e l #
13677 ###############################################################################
13682 Image::Magick ref=NO_INIT
13724 *reference; /* reference is the SV* of ref=SvIV(reference) */
13726 PERL_UNUSED_VAR(ref);
13727 PERL_UNUSED_VAR(ix);
13728 exception=AcquireExceptionInfo();
13729 perl_exception=newSVpv("",0);
13730 reference=SvRV(ST(0));
13731 av=(AV *) reference;
13732 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13734 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13735 if (image == (Image *) NULL)
13737 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13739 goto PerlException;
13742 normalize=MagickTrue;
13745 region.width=image->columns;
13748 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13749 channel=DefaultChannels;
13750 for (i=2; i < items; i+=2)
13752 attribute=(char *) SvPV(ST(i-1),na);
13753 switch (*attribute)
13758 if (LocaleCompare(attribute,"channel") == 0)
13763 option=ParseChannelOption(SvPV(ST(i),na));
13766 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13770 channel=(ChannelType) option;
13773 if (LocaleCompare(attribute,"color") == 0)
13775 if (SvTYPE(ST(i)) != SVt_RV)
13778 message[MaxTextExtent];
13780 (void) FormatLocaleString(message,MaxTextExtent,
13781 "invalid %.60s value",attribute);
13782 ThrowPerlException(exception,OptionError,message,
13785 av=(AV *) SvRV(ST(i));
13788 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13795 if (LocaleCompare(attribute,"geometry") == 0)
13797 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13800 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13807 if (LocaleCompare(attribute,"normalize") == 0)
13809 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13813 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13817 normalize=option != 0 ? MagickTrue : MagickFalse;
13820 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13827 if (LocaleCompare(attribute,"x") == 0)
13829 region.x=SvIV(ST(i));
13832 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13839 if (LocaleCompare(attribute,"y") == 0)
13841 region.y=SvIV(ST(i));
13844 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13850 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13856 (void) SetImageStorageClass(image,DirectClass,exception);
13857 channel_mask=SetImageChannelMask(image,channel);
13858 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13859 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13860 (SvTYPE(av) != SVt_PVAV))
13872 if (normalize != MagickFalse)
13873 scale=QuantumRange;
13874 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13877 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13878 av_fetch(av,i,0)))),q);
13881 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13884 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13885 av_fetch(av,i,0)))),q);
13888 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13891 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13892 av_fetch(av,i,0)))),q);
13895 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13896 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13898 SetPixelBlack(image,ClampToQuantum(scale*
13899 SvNV(*(av_fetch(av,i,0)))),q);
13902 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13905 SetPixelAlpha(image,ClampToQuantum(scale*
13906 SvNV(*(av_fetch(av,i,0)))),q);
13909 (void) SyncAuthenticPixels(image,exception);
13911 (void) SetImageChannelMask(image,channel_mask);
13914 InheritPerlException(exception,perl_exception);
13915 exception=DestroyExceptionInfo(exception);
13916 SvREFCNT_dec(perl_exception);
13920 ###############################################################################
13928 ###############################################################################
13933 Image::Magick ref=NO_INIT
13972 PERL_UNUSED_VAR(ref);
13973 PERL_UNUSED_VAR(ix);
13974 exception=AcquireExceptionInfo();
13975 perl_exception=newSVpv("",0);
13979 if (sv_isobject(ST(0)) == 0)
13981 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13983 goto PerlException;
13985 reference=SvRV(ST(0));
13986 hv=SvSTASH(reference);
13988 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13990 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13991 if (image == (Image *) NULL)
13993 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13995 goto PerlException;
13997 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14003 for (i=2; i < items; i+=2)
14005 attribute=(char *) SvPV(ST(i-1),na);
14006 switch (*attribute)
14011 if (LocaleCompare(attribute,"offset") == 0)
14013 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14016 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14023 if (LocaleCompare(attribute,"stack") == 0)
14025 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14029 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14035 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14041 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14047 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14049 if (image == (Image *) NULL)
14050 goto PerlException;
14051 for ( ; image; image=image->next)
14053 AddImageToRegistry(sv,image);
14055 av_push(av,sv_bless(rv,hv));
14058 exception=DestroyExceptionInfo(exception);
14059 ST(0)=av_reference;
14060 SvREFCNT_dec(perl_exception);
14064 InheritPerlException(exception,perl_exception);
14065 exception=DestroyExceptionInfo(exception);
14066 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14067 SvPOK_on(perl_exception);
14068 ST(0)=sv_2mortal(perl_exception);
14073 ###############################################################################
14077 # S t a t i s t i c s #
14081 ###############################################################################
14085 Statistics(ref,...)
14086 Image::Magick ref=NO_INIT
14088 StatisticsImage = 1
14090 statisticsimage = 3
14093 #define ChannelStatistics(channel) \
14095 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
14096 (double) channel_statistics[channel].depth); \
14097 PUSHs(sv_2mortal(newSVpv(message,0))); \
14098 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14099 channel_statistics[channel].minima/scale); \
14100 PUSHs(sv_2mortal(newSVpv(message,0))); \
14101 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14102 channel_statistics[channel].maxima/scale); \
14103 PUSHs(sv_2mortal(newSVpv(message,0))); \
14104 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14105 channel_statistics[channel].mean/scale); \
14106 PUSHs(sv_2mortal(newSVpv(message,0))); \
14107 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14108 channel_statistics[channel].standard_deviation/scale); \
14109 PUSHs(sv_2mortal(newSVpv(message,0))); \
14110 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14111 channel_statistics[channel].kurtosis); \
14112 PUSHs(sv_2mortal(newSVpv(message,0))); \
14113 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
14114 channel_statistics[channel].skewness); \
14115 PUSHs(sv_2mortal(newSVpv(message,0))); \
14122 message[MaxTextExtent];
14125 *channel_statistics;
14146 PERL_UNUSED_VAR(ref);
14147 PERL_UNUSED_VAR(ix);
14148 exception=AcquireExceptionInfo();
14149 perl_exception=newSVpv("",0);
14151 if (sv_isobject(ST(0)) == 0)
14153 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14155 goto PerlException;
14157 reference=SvRV(ST(0));
14160 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14161 if (image == (Image *) NULL)
14163 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14165 goto PerlException;
14167 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14169 for ( ; image; image=image->next)
14171 channel_statistics=GetImageStatistics(image,exception);
14172 if (channel_statistics == (ChannelStatistics *) NULL)
14175 EXTEND(sp,35*count);
14176 scale=(double) QuantumRange;
14177 ChannelStatistics(RedChannel);
14178 ChannelStatistics(GreenChannel);
14179 ChannelStatistics(BlueChannel);
14180 if (image->colorspace == CMYKColorspace)
14181 ChannelStatistics(BlackChannel);
14182 if (image->alpha_trait == BlendPixelTrait)
14183 ChannelStatistics(AlphaChannel);
14184 channel_statistics=(ChannelStatistics *)
14185 RelinquishMagickMemory(channel_statistics);
14189 InheritPerlException(exception,perl_exception);
14190 exception=DestroyExceptionInfo(exception);
14191 SvREFCNT_dec(perl_exception);
14195 ###############################################################################
14199 # S y n c A u t h e n t i c P i x e l s #
14203 ###############################################################################
14207 SyncAuthenticPixels(ref,...)
14208 Image::Magick ref = NO_INIT
14210 Syncauthenticpixels = 1
14211 SyncImagePixels = 2
14212 syncimagepixels = 3
14231 PERL_UNUSED_VAR(ref);
14232 PERL_UNUSED_VAR(ix);
14233 exception=AcquireExceptionInfo();
14234 perl_exception=newSVpv("",0);
14235 if (sv_isobject(ST(0)) == 0)
14237 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14239 goto PerlException;
14242 reference=SvRV(ST(0));
14243 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14244 if (image == (Image *) NULL)
14246 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14248 goto PerlException;
14251 status=SyncAuthenticPixels(image,exception);
14252 if (status != MagickFalse)
14256 InheritPerlException(exception,perl_exception);
14257 exception=DestroyExceptionInfo(exception);
14258 SvREFCNT_dec(perl_exception); /* throw away all errors */
14262 ###############################################################################
14266 # T r a n s f o r m #
14270 ###############################################################################
14275 Image::Magick ref=NO_INIT
14313 PERL_UNUSED_VAR(ref);
14314 PERL_UNUSED_VAR(ix);
14315 exception=AcquireExceptionInfo();
14316 perl_exception=newSVpv("",0);
14320 if (sv_isobject(ST(0)) == 0)
14322 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14324 goto PerlException;
14326 reference=SvRV(ST(0));
14327 hv=SvSTASH(reference);
14329 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14331 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14332 if (image == (Image *) NULL)
14334 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14336 goto PerlException;
14338 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14342 crop_geometry=(char *) NULL;
14343 geometry=(char *) NULL;
14344 for (i=2; i < items; i+=2)
14346 attribute=(char *) SvPV(ST(i-1),na);
14347 switch (*attribute)
14352 if (LocaleCompare(attribute,"crop") == 0)
14354 crop_geometry=SvPV(ST(i),na);
14357 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14364 if (LocaleCompare(attribute,"geometry") == 0)
14366 geometry=SvPV(ST(i),na);
14369 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14375 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14381 for ( ; image; image=image->next)
14383 clone=CloneImage(image,0,0,MagickTrue,exception);
14384 if (clone == (Image *) NULL)
14385 goto PerlException;
14386 TransformImage(&clone,crop_geometry,geometry,exception);
14387 for ( ; clone; clone=clone->next)
14389 AddImageToRegistry(sv,clone);
14391 av_push(av,sv_bless(rv,hv));
14395 exception=DestroyExceptionInfo(exception);
14396 ST(0)=av_reference;
14397 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14401 InheritPerlException(exception,perl_exception);
14402 exception=DestroyExceptionInfo(exception);
14403 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14404 SvPOK_on(perl_exception);
14405 ST(0)=sv_2mortal(perl_exception);
14410 ###############################################################################
14418 ###############################################################################
14423 Image::Magick ref=NO_INIT
14431 filename[MaxTextExtent];
14455 PERL_UNUSED_VAR(ref);
14456 PERL_UNUSED_VAR(ix);
14457 exception=AcquireExceptionInfo();
14458 perl_exception=newSVpv("",0);
14460 package_info=(struct PackageInfo *) NULL;
14461 if (sv_isobject(ST(0)) == 0)
14463 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14465 goto PerlException;
14467 reference=SvRV(ST(0));
14468 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14469 if (image == (Image *) NULL)
14471 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14473 goto PerlException;
14475 package_info=ClonePackageInfo(info,exception);
14477 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14480 for (i=2; i < items; i+=2)
14481 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14483 (void) CopyMagickString(filename,package_info->image_info->filename,
14486 for (next=image; next; next=next->next)
14488 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14489 next->scene=scene++;
14491 SetImageInfo(package_info->image_info,(unsigned int)
14492 GetImageListLength(image),exception);
14493 for (next=image; next; next=next->next)
14495 (void) WriteImage(package_info->image_info,next,exception);
14497 if (package_info->image_info->adjoin)
14502 if (package_info != (struct PackageInfo *) NULL)
14503 DestroyPackageInfo(package_info);
14504 InheritPerlException(exception,perl_exception);
14505 exception=DestroyExceptionInfo(exception);
14506 sv_setiv(perl_exception,(IV) number_images);
14507 SvPOK_on(perl_exception);
14508 ST(0)=sv_2mortal(perl_exception);