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-2013 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 MaxArguments 33
81 #define NumberOf(array) (sizeof(array)/sizeof(*array))
82 #define PackageName "Image::Magick::@MAGICK_ABI_NAME@"
85 #define PerlIO_importFILE(f, fl) (f)
86 #define PerlIO_findFILE(f) NULL
89 #define sv_undef PL_sv_undef
92 #define AddImageToRegistry(sv,image) \
94 if (magick_registry != (SplayTreeInfo *) NULL) \
96 (void) AddValueToSplayTree(magick_registry,image,image); \
97 (sv)=newSViv(PTR2IV(image)); \
101 #define DeleteImageFromRegistry(reference,image) \
103 if (magick_registry != (SplayTreeInfo *) NULL) \
105 if (GetImageReferenceCount(image) == 1) \
106 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
107 image=DestroyImage(image); \
108 sv_setiv(reference,0); \
112 #define InheritPerlException(exception,perl_exception) \
115 message[MaxTextExtent]; \
117 if ((exception)->severity != UndefinedException) \
119 (void) FormatLocaleString(message,MaxTextExtent,"Exception %d: %s%s%s%s",\
120 (exception)->severity, (exception)->reason ? \
121 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
122 "Unknown", (exception)->description ? " (" : "", \
123 (exception)->description ? GetLocaleExceptionMessage( \
124 (exception)->severity,(exception)->description) : "", \
125 (exception)->description ? ")" : ""); \
126 if ((perl_exception) != (SV *) NULL) \
128 if (SvCUR(perl_exception)) \
129 sv_catpv(perl_exception,"\n"); \
130 sv_catpv(perl_exception,message); \
135 #define ThrowPerlException(exception,severity,tag,reason) \
136 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
137 tag,"`%s'",reason); \
140 Typedef and structure declarations.
144 ArrayReference = (~0),
145 RealReference = (~0)-1,
146 FileReference = (~0)-2,
147 ImageReference = (~0)-3,
148 IntegerReference = (~0)-4,
149 StringReference = (~0)-5
152 typedef struct _Arguments
192 *Image__Magick__Q16HDRI; /* data type for the Image::Magick::@MAGICK_ABI_NAME@ package */
204 arguments[MaxArguments];
207 { "Comment", { {"comment", StringReference} } },
208 { "Label", { {"label", StringReference} } },
209 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
210 {"channel", MagickChannelOptions} } },
211 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
212 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
213 {"height", IntegerReference}, {"fill", StringReference},
214 {"bordercolor", StringReference}, {"color", StringReference},
215 {"compose", MagickComposeOptions} } },
216 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
217 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
218 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
219 {"height", IntegerReference}, {"x", IntegerReference},
220 {"y", IntegerReference} } },
221 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
222 {"height", IntegerReference}, {"x", IntegerReference},
223 {"y", IntegerReference}, {"fuzz", StringReference},
224 {"gravity", MagickGravityOptions} } },
226 { "Edge", { {"radius", RealReference} } },
227 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
228 {"sigma", RealReference} } },
232 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
233 {"height", IntegerReference}, {"inner", IntegerReference},
234 {"outer", IntegerReference}, {"fill", StringReference},
235 {"color", StringReference}, {"compose", MagickComposeOptions} } },
236 { "Implode", { {"amount", RealReference},
237 {"interpolate", MagickInterpolateOptions} } },
239 { "MedianFilter", { {"geometry", StringReference},
240 {"width", IntegerReference}, {"height", IntegerReference},
241 {"channel", MagickChannelOptions} } },
243 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
244 { "ReduceNoise", { {"geometry", StringReference},
245 {"width", IntegerReference},{"height", IntegerReference},
246 {"channel", MagickChannelOptions} } },
247 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
248 {"y", IntegerReference} } },
249 { "Rotate", { {"degrees", RealReference},
250 {"background", StringReference} } },
251 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
252 {"height", IntegerReference} } },
253 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
254 {"height", IntegerReference} } },
255 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
256 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
257 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
258 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
259 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
260 {"y", RealReference}, { "fill", StringReference},
261 {"color", StringReference} } },
262 { "Spread", { {"radius", RealReference},
263 {"interpolate", MagickInterpolateOptions} } },
264 { "Swirl", { {"degrees", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
267 {"height", IntegerReference}, {"filter", MagickFilterOptions},
268 {"support", StringReference } } },
269 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
270 {"height", IntegerReference}, {"filter", MagickFilterOptions},
271 {"support", RealReference } } },
272 { "Annotate", { {"text", StringReference}, {"font", StringReference},
273 {"pointsize", RealReference}, {"density", StringReference},
274 {"undercolor", StringReference}, {"stroke", StringReference},
275 {"fill", StringReference}, {"geometry", StringReference},
276 {"sans", StringReference}, {"x", RealReference},
277 {"y", RealReference}, {"gravity", MagickGravityOptions},
278 {"translate", StringReference}, {"scale", StringReference},
279 {"rotate", RealReference}, {"skewX", RealReference},
280 {"skewY", RealReference}, {"strokewidth", RealReference},
281 {"antialias", MagickBooleanOptions}, {"family", StringReference},
282 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
283 {"weight", IntegerReference}, {"align", MagickAlignOptions},
284 {"encoding", StringReference}, {"affine", ArrayReference},
285 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
286 {"tile", ImageReference}, {"kerning", RealReference},
287 {"interline-spacing", RealReference},
288 {"interword-spacing", RealReference},
289 {"direction", MagickDirectionOptions} } },
290 { "ColorFloodfill", { {"geometry", StringReference},
291 {"x", IntegerReference}, {"y", IntegerReference},
292 {"fill", StringReference}, {"bordercolor", StringReference},
293 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
294 { "Composite", { {"image", ImageReference},
295 {"compose", MagickComposeOptions}, {"geometry", StringReference},
296 {"x", IntegerReference}, {"y", IntegerReference},
297 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
298 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
299 {"color", StringReference}, {"mask", ImageReference},
300 {"channel", MagickChannelOptions},
301 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
302 {"blend", StringReference}, {"crop-to-self", MagickBooleanOptions} } },
303 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
304 { "CycleColormap", { {"display", IntegerReference} } },
305 { "Draw", { {"primitive", MagickPrimitiveOptions},
306 {"points", StringReference}, {"method", MagickMethodOptions},
307 {"stroke", StringReference}, {"fill", StringReference},
308 {"strokewidth", RealReference}, {"font", StringReference},
309 {"bordercolor", StringReference}, {"x", RealReference},
310 {"y", RealReference}, {"translate", StringReference},
311 {"scale", StringReference}, {"rotate", RealReference},
312 {"skewX", RealReference}, {"skewY", RealReference},
313 {"tile", ImageReference}, {"pointsize", RealReference},
314 {"antialias", MagickBooleanOptions}, {"density", StringReference},
315 {"linewidth", RealReference}, {"affine", ArrayReference},
316 {"stroke-dashoffset", RealReference},
317 {"stroke-dasharray", ArrayReference},
318 {"interpolate", MagickInterpolateOptions},
319 {"origin", StringReference}, {"text", StringReference},
320 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
321 {"vector-graphics", StringReference}, {"kerning", RealReference},
322 {"interline-spacing", RealReference},
323 {"interword-spacing", RealReference},
324 {"direction", MagickDirectionOptions} } },
325 { "Equalize", { {"channel", MagickChannelOptions} } },
326 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
327 {"red", RealReference}, {"green", RealReference},
328 {"blue", RealReference} } },
329 { "Map", { {"image", ImageReference},
330 {"dither-method", MagickDitherOptions} } },
331 { "MatteFloodfill", { {"geometry", StringReference},
332 {"x", IntegerReference}, {"y", IntegerReference},
333 {"opacity", StringReference}, {"bordercolor", StringReference},
334 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
335 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
336 {"saturation", RealReference}, {"whiteness", RealReference},
337 {"brightness", RealReference}, {"lightness", RealReference},
338 {"blackness", RealReference} } },
339 { "Negate", { {"gray", MagickBooleanOptions},
340 {"channel", MagickChannelOptions} } },
341 { "Normalize", { {"channel", MagickChannelOptions} } },
343 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
344 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
345 {"invert", MagickBooleanOptions} } },
346 { "Quantize", { {"colors", IntegerReference},
347 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
348 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
349 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
350 {"dither-method", MagickDitherOptions} } },
351 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
352 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
353 { "Segment", { {"geometry", StringReference},
354 {"cluster-threshold", RealReference},
355 {"smoothing-threshold", RealReference},
356 {"colorspace", MagickColorspaceOptions},
357 {"verbose", MagickBooleanOptions} } },
359 { "Solarize", { {"geometry", StringReference},
360 {"threshold", StringReference} } },
362 { "Texture", { {"texture", ImageReference} } },
363 { "Evaluate", { {"value", RealReference},
364 {"operator", MagickEvaluateOptions},
365 {"channel", MagickChannelOptions} } },
366 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
367 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
368 { "Threshold", { {"threshold", StringReference},
369 {"channel", MagickChannelOptions} } },
370 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
371 {"sigma", RealReference} } },
372 { "Trim", { {"fuzz", StringReference} } },
373 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
374 {"wavelength", RealReference},
375 {"interpolate", MagickInterpolateOptions} } },
376 { "Separate", { {"channel", MagickChannelOptions} } },
378 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
379 {"y", IntegerReference} } },
380 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
382 { "GaussianBlur", { {"geometry", StringReference},
383 {"radius", RealReference}, {"sigma", RealReference},
384 {"channel", MagickChannelOptions} } },
385 { "Convolve", { {"coefficients", ArrayReference},
386 {"channel", MagickChannelOptions}, {"bias", StringReference},
387 {"kernel", StringReference} } },
388 { "Profile", { {"name", StringReference}, {"profile", StringReference},
389 { "rendering-intent", MagickIntentOptions},
390 { "black-point-compensation", MagickBooleanOptions} } },
391 { "UnsharpMask", { {"geometry", StringReference},
392 {"radius", RealReference}, {"sigma", RealReference},
393 {"gain", RealReference}, {"channel", MagickChannelOptions} } },
394 { "MotionBlur", { {"geometry", StringReference},
395 {"radius", RealReference}, {"sigma", RealReference},
396 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
397 { "OrderedDither", { {"threshold", StringReference},
398 {"channel", MagickChannelOptions} } },
399 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
400 {"height", IntegerReference} } },
401 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
402 {"white-point", RealReference}, {"gamma", RealReference},
403 {"channel", MagickChannelOptions}, {"level", StringReference} } },
404 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
405 { "AffineTransform", { {"affine", ArrayReference},
406 {"translate", StringReference}, {"scale", StringReference},
407 {"rotate", RealReference}, {"skewX", RealReference},
408 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
409 {"background", StringReference} } },
410 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
411 { "AdaptiveThreshold", { {"geometry", StringReference},
412 {"width", IntegerReference}, {"height", IntegerReference} } },
413 { "Resample", { {"density", StringReference}, {"x", RealReference},
414 {"y", RealReference}, {"filter", MagickFilterOptions},
415 {"support", RealReference } } },
416 { "Describe", { {"file", FileReference} } },
417 { "BlackThreshold", { {"threshold", StringReference},
418 {"channel", MagickChannelOptions} } },
419 { "WhiteThreshold", { {"threshold", StringReference},
420 {"channel", MagickChannelOptions} } },
421 { "RadialBlur", { {"geometry", StringReference}, {"angle", RealReference},
422 {"channel", MagickChannelOptions} } },
423 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
424 {"height", IntegerReference} } },
426 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
427 { "Channel", { {"channel", MagickChannelOptions} } },
428 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference}, {"x", IntegerReference},
430 {"y", IntegerReference}, {"fuzz", StringReference},
431 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
432 { "Posterize", { {"levels", IntegerReference},
433 {"dither", MagickBooleanOptions} } },
434 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
435 {"sigma", RealReference}, {"x", IntegerReference},
436 {"y", IntegerReference} } },
437 { "Identify", { {"file", FileReference}, {"features", StringReference},
438 {"unique", MagickBooleanOptions} } },
439 { "SepiaTone", { {"threshold", RealReference} } },
440 { "SigmoidalContrast", { {"geometry", StringReference},
441 {"contrast", RealReference}, {"mid-point", RealReference},
442 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
443 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
444 {"height", IntegerReference}, {"x", IntegerReference},
445 {"y", IntegerReference}, {"fuzz", StringReference},
446 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
447 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
448 {"sigma", RealReference}, {"x", IntegerReference},
449 {"y", IntegerReference}, {"background", StringReference} } },
450 { "ContrastStretch", { {"levels", StringReference},
451 {"black-point", RealReference},{"white-point", RealReference},
452 {"channel", MagickChannelOptions} } },
455 { "AdaptiveSharpen", { {"geometry", StringReference},
456 {"radius", RealReference}, {"sigma", RealReference},
457 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
461 { "AdaptiveBlur", { {"geometry", StringReference},
462 {"radius", RealReference}, {"sigma", RealReference},
463 {"channel", MagickChannelOptions} } },
464 { "Sketch", { {"geometry", StringReference},
465 {"radius", RealReference}, {"sigma", RealReference},
466 {"angle", RealReference} } },
468 { "AdaptiveResize", { {"geometry", StringReference},
469 {"width", IntegerReference}, {"height", IntegerReference},
470 {"filter", MagickFilterOptions}, {"support", StringReference },
471 {"blur", RealReference } } },
472 { "ClipMask", { {"mask", ImageReference} } },
473 { "LinearStretch", { {"levels", StringReference},
474 {"black-point", RealReference},{"white-point", RealReference} } },
475 { "ColorMatrix", { {"matrix", ArrayReference} } },
476 { "Mask", { {"mask", ImageReference} } },
477 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
478 {"font", StringReference}, {"stroke", StringReference},
479 {"fill", StringReference}, {"strokewidth", RealReference},
480 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
481 {"background", StringReference},
482 {"interpolate", MagickInterpolateOptions} } },
483 { "FloodfillPaint", { {"geometry", StringReference},
484 {"x", IntegerReference}, {"y", IntegerReference},
485 {"fill", StringReference}, {"bordercolor", StringReference},
486 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
487 {"invert", MagickBooleanOptions} } },
488 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
489 {"virtual-pixel", MagickVirtualPixelOptions},
490 {"best-fit", MagickBooleanOptions} } },
491 { "Clut", { {"image", ImageReference},
492 {"interpolate", MagickInterpolateOptions},
493 {"channel", MagickChannelOptions} } },
494 { "LiquidRescale", { {"geometry", StringReference},
495 {"width", IntegerReference}, {"height", IntegerReference},
496 {"delta-x", RealReference}, {"rigidity", RealReference } } },
497 { "Encipher", { {"passphrase", StringReference} } },
498 { "Decipher", { {"passphrase", StringReference} } },
499 { "Deskew", { {"geometry", StringReference},
500 {"threshold", StringReference} } },
501 { "Remap", { {"image", ImageReference},
502 {"dither-method", MagickDitherOptions} } },
503 { "SparseColor", { {"points", ArrayReference},
504 {"method", MagickSparseColorOptions},
505 {"virtual-pixel", MagickVirtualPixelOptions},
506 {"channel", MagickChannelOptions} } },
507 { "Function", { {"parameters", ArrayReference},
508 {"function", MagickFunctionOptions},
509 {"virtual-pixel", MagickVirtualPixelOptions} } },
510 { "SelectiveBlur", { {"geometry", StringReference},
511 {"radius", RealReference}, {"sigma", RealReference},
512 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
513 { "HaldClut", { {"image", ImageReference},
514 {"channel", MagickChannelOptions} } },
515 { "BlueShift", { {"factor", StringReference} } },
516 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
517 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
518 { "ColorDecisionList", {
519 {"color-correction-collection", StringReference} } },
520 { "AutoGamma", { {"channel", MagickChannelOptions} } },
521 { "AutoLevel", { {"channel", MagickChannelOptions} } },
522 { "LevelColors", { {"invert", MagickBooleanOptions},
523 {"black-point", StringReference}, {"white-point", StringReference},
524 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
525 { "Clamp", { {"channel", MagickChannelOptions} } },
526 { "BrightnessContrast", { {"levels", StringReference},
527 {"brightness", RealReference},{"contrast", RealReference},
528 {"channel", MagickChannelOptions} } },
529 { "Morphology", { {"kernel", StringReference},
530 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
531 {"iterations", IntegerReference} } },
532 { "Sans", { {"matrix", ArrayReference} } },
533 { "Color", { {"color", StringReference} } },
534 { "Mode", { {"geometry", StringReference},
535 {"width", IntegerReference},{"height", IntegerReference},
536 {"channel", MagickChannelOptions} } },
537 { "Statistic", { {"geometry", StringReference},
538 {"width", IntegerReference},{"height", IntegerReference},
539 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
540 { "Perceptible", { {"epsilon", RealReference},
541 {"channel", MagickChannelOptions} } },
542 { "Poly", { {"terms", ArrayReference},
543 {"channel", MagickChannelOptions} } }
547 *magick_registry = (SplayTreeInfo *) NULL;
550 Forward declarations.
553 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
556 strEQcase(const char *,const char *);
559 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
563 % C l o n e P a c k a g e I n f o %
567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
569 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
572 % The format of the ClonePackageInfo routine is:
574 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
577 % A description of each parameter follows:
579 % o info: a structure of type info.
581 % o exception: Return any errors or warnings in this structure.
584 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
585 ExceptionInfo *exception)
590 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
591 if (clone_info == (struct PackageInfo *) NULL)
593 ThrowPerlException(exception,ResourceLimitError,
594 "UnableToClonePackageInfo",PackageName);
595 return((struct PackageInfo *) NULL);
597 if (info == (struct PackageInfo *) NULL)
599 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
603 clone_info->image_info=CloneImageInfo(info->image_info);
608 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
618 % constant() returns a double value for the specified name.
620 % The format of the constant routine is:
622 % double constant(char *name,ssize_t sans)
624 % A description of each parameter follows:
626 % o value: Method constant returns a double value for the specified name.
628 % o name: The name of the constant.
630 % o sans: This integer value is not used.
633 static double constant(char *name,ssize_t sans)
641 if (strEQ(name,"BlobError"))
643 if (strEQ(name,"BlobWarning"))
649 if (strEQ(name,"CacheError"))
651 if (strEQ(name,"CacheWarning"))
652 return(CacheWarning);
653 if (strEQ(name,"CoderError"))
655 if (strEQ(name,"CoderWarning"))
656 return(CoderWarning);
657 if (strEQ(name,"ConfigureError"))
658 return(ConfigureError);
659 if (strEQ(name,"ConfigureWarning"))
660 return(ConfigureWarning);
661 if (strEQ(name,"CorruptImageError"))
662 return(CorruptImageError);
663 if (strEQ(name,"CorruptImageWarning"))
664 return(CorruptImageWarning);
669 if (strEQ(name,"DelegateError"))
670 return(DelegateError);
671 if (strEQ(name,"DelegateWarning"))
672 return(DelegateWarning);
673 if (strEQ(name,"DrawError"))
675 if (strEQ(name,"DrawWarning"))
681 if (strEQ(name,"ErrorException"))
682 return(ErrorException);
683 if (strEQ(name,"ExceptionError"))
685 if (strEQ(name,"ExceptionWarning"))
686 return(CoderWarning);
691 if (strEQ(name,"FatalErrorException"))
692 return(FatalErrorException);
693 if (strEQ(name,"FileOpenError"))
694 return(FileOpenError);
695 if (strEQ(name,"FileOpenWarning"))
696 return(FileOpenWarning);
701 if (strEQ(name,"ImageError"))
703 if (strEQ(name,"ImageWarning"))
704 return(ImageWarning);
709 if (strEQ(name,"MaxRGB"))
710 return(QuantumRange);
711 if (strEQ(name,"MissingDelegateError"))
712 return(MissingDelegateError);
713 if (strEQ(name,"MissingDelegateWarning"))
714 return(MissingDelegateWarning);
715 if (strEQ(name,"ModuleError"))
717 if (strEQ(name,"ModuleWarning"))
718 return(ModuleWarning);
723 if (strEQ(name,"Opaque"))
725 if (strEQ(name,"OptionError"))
727 if (strEQ(name,"OptionWarning"))
728 return(OptionWarning);
733 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
734 return(MAGICKCORE_QUANTUM_DEPTH);
735 if (strEQ(name,"QuantumDepth"))
736 return(MAGICKCORE_QUANTUM_DEPTH);
737 if (strEQ(name,"QuantumRange"))
738 return(QuantumRange);
743 if (strEQ(name,"ResourceLimitError"))
744 return(ResourceLimitError);
745 if (strEQ(name,"ResourceLimitWarning"))
746 return(ResourceLimitWarning);
747 if (strEQ(name,"RegistryError"))
748 return(RegistryError);
749 if (strEQ(name,"RegistryWarning"))
750 return(RegistryWarning);
755 if (strEQ(name,"StreamError"))
757 if (strEQ(name,"StreamWarning"))
758 return(StreamWarning);
759 if (strEQ(name,"Success"))
765 if (strEQ(name,"Transparent"))
766 return(TransparentAlpha);
767 if (strEQ(name,"TypeError"))
769 if (strEQ(name,"TypeWarning"))
775 if (strEQ(name,"WarningException"))
776 return(WarningException);
781 if (strEQ(name,"XServerError"))
782 return(XServerError);
783 if (strEQ(name,"XServerWarning"))
784 return(XServerWarning);
793 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
797 % D e s t r o y P a c k a g e I n f o %
801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
803 % Method DestroyPackageInfo frees a previously created info structure.
805 % The format of the DestroyPackageInfo routine is:
807 % DestroyPackageInfo(struct PackageInfo *info)
809 % A description of each parameter follows:
811 % o info: a structure of type info.
814 static void DestroyPackageInfo(struct PackageInfo *info)
816 info->image_info=DestroyImageInfo(info->image_info);
817 info=(struct PackageInfo *) RelinquishMagickMemory(info);
821 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
829 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
831 % Method GetList is recursively called by SetupList to traverse the
832 % Image__Magick reference. If building an reference_vector (see SetupList),
833 % *current is the current position in *reference_vector and *last is the final
834 % entry in *reference_vector.
836 % The format of the GetList routine is:
840 % A description of each parameter follows:
842 % o info: a structure of type info.
845 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
846 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
851 if (reference == (SV *) NULL)
853 switch (SvTYPE(reference))
873 previous=(Image *) NULL;
877 for (i=0; i <= n; i++)
883 if (rv && *rv && sv_isobject(*rv))
885 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
887 if (image == (Image *) NULL)
889 if (image == previous)
891 image=CloneImage(image,0,0,MagickTrue,exception);
892 if (image == (Image *) NULL)
895 image->previous=previous;
896 *(previous ? &previous->next : &head)=image;
897 for (previous=image; previous->next; previous=previous->next) ;
905 Blessed scalar, one image.
907 image=INT2PTR(Image *,SvIV(reference));
908 if (image == (Image *) NULL)
910 image->previous=(Image *) NULL;
911 image->next=(Image *) NULL;
912 if (reference_vector)
914 if (*current == *last)
917 if (*reference_vector == (SV **) NULL)
918 *reference_vector=(SV **) AcquireQuantumMemory(*last,
919 sizeof(*reference_vector));
921 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
922 *last,sizeof(*reference_vector));
924 if (*reference_vector == (SV **) NULL)
926 ThrowPerlException(exception,ResourceLimitError,
927 "MemoryAllocationFailed",PackageName);
928 return((Image *) NULL);
930 (*reference_vector)[*current]=reference;
931 (*reference_vector)[++(*current)]=NULL;
938 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
939 (double) SvTYPE(reference));
940 return((Image *) NULL);
944 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
948 % G e t P a c k a g e I n f o %
952 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
954 % Method GetPackageInfo looks up or creates an info structure for the given
955 % Image__Magick reference. If it does create a new one, the information in
956 % package_info is used to initialize it.
958 % The format of the GetPackageInfo routine is:
960 % struct PackageInfo *GetPackageInfo(void *reference,
961 % struct PackageInfo *package_info,ExceptionInfo *exception)
963 % A description of each parameter follows:
965 % o info: a structure of type info.
967 % o exception: Return any errors or warnings in this structure.
970 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
971 struct PackageInfo *package_info,ExceptionInfo *exception)
974 message[MaxTextExtent];
982 (void) FormatLocaleString(message,MaxTextExtent,"%s::package%s%p",
983 PackageName,XS_VERSION,reference);
984 sv=perl_get_sv(message,(TRUE | 0x02));
985 if (sv == (SV *) NULL)
987 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
989 return(package_info);
991 if (SvREFCNT(sv) == 0)
992 (void) SvREFCNT_inc(sv);
993 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
995 clone_info=ClonePackageInfo(package_info,exception);
996 sv_setiv(sv,PTR2IV(clone_info));
1001 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1005 % S e t A t t r i b u t e %
1009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1011 % SetAttribute() sets the attribute to the value in sval. This can change
1012 % either or both of image or info.
1014 % The format of the SetAttribute routine is:
1016 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1017 % SV *sval,ExceptionInfo *exception)
1019 % A description of each parameter follows:
1021 % o list: a list of strings.
1023 % o string: a character string.
1027 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1035 value=InterpretSiPrefixValue(string,&q);
1037 value*=interval/100.0;
1041 static inline double StringToDouble(const char *string,char **sentinal)
1043 return(InterpretLocaleValue(string,sentinal));
1046 static double StringToDoubleInterval(const char *string,const double interval)
1054 value=InterpretLocaleValue(string,&q);
1056 value*=interval/100.0;
1060 static inline ssize_t StringToLong(const char *value)
1062 return(strtol(value,(char **) NULL,10));
1065 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1066 const char *attribute,SV *sval,ExceptionInfo *exception)
1093 if (LocaleCompare(attribute,"adjoin") == 0)
1095 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1096 SvPV(sval,na)) : SvIV(sval);
1099 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1104 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1107 if (LocaleCompare(attribute,"alpha") == 0)
1109 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1110 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1113 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1117 for ( ; image; image=image->next)
1118 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1122 if (LocaleCompare(attribute,"antialias") == 0)
1124 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1125 SvPV(sval,na)) : SvIV(sval);
1128 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1133 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1136 if (LocaleCompare(attribute,"area-limit") == 0)
1141 limit=MagickResourceInfinity;
1142 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1143 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1145 (void) SetMagickResourceLimit(AreaResource,limit);
1148 if (LocaleCompare(attribute,"attenuate") == 0)
1151 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1154 if (LocaleCompare(attribute,"authenticate") == 0)
1157 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1161 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1162 for ( ; image; image=image->next)
1163 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1169 if (LocaleCompare(attribute,"background") == 0)
1171 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1174 info->image_info->background_color=target_color;
1175 for ( ; image; image=image->next)
1176 image->background_color=target_color;
1179 if (LocaleCompare(attribute,"blue-primary") == 0)
1181 for ( ; image; image=image->next)
1183 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1184 image->chromaticity.blue_primary.x=geometry_info.rho;
1185 image->chromaticity.blue_primary.y=geometry_info.sigma;
1186 if ((flags & SigmaValue) == 0)
1187 image->chromaticity.blue_primary.y=
1188 image->chromaticity.blue_primary.x;
1192 if (LocaleCompare(attribute,"bordercolor") == 0)
1194 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1197 info->image_info->border_color=target_color;
1198 for ( ; image; image=image->next)
1199 image->border_color=target_color;
1203 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1204 for ( ; image; image=image->next)
1205 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1211 if (LocaleCompare(attribute,"cache-threshold") == 0)
1213 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1214 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1215 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1216 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1219 if (LocaleCompare(attribute,"clip-mask") == 0)
1224 clip_mask=(Image *) NULL;
1226 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1227 for ( ; image; image=image->next)
1228 SetImageMask(image,clip_mask,exception);
1231 if (LocaleNCompare(attribute,"colormap",8) == 0)
1233 for ( ; image; image=image->next)
1241 if (image->storage_class == DirectClass)
1244 items=sscanf(attribute,"%*[^[][%ld",&i);
1246 if (i > (ssize_t) image->colors)
1248 if ((strchr(SvPV(sval,na),',') == 0) ||
1249 (strchr(SvPV(sval,na),')') != 0))
1250 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1251 image->colormap+i,exception);
1254 color=image->colormap+i;
1255 pixel.red=color->red;
1256 pixel.green=color->green;
1257 pixel.blue=color->blue;
1258 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1259 pixel.red=geometry_info.rho;
1260 pixel.green=geometry_info.sigma;
1261 pixel.blue=geometry_info.xi;
1262 color->red=ClampToQuantum(pixel.red);
1263 color->green=ClampToQuantum(pixel.green);
1264 color->blue=ClampToQuantum(pixel.blue);
1269 if (LocaleCompare(attribute,"colorspace") == 0)
1271 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1272 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1275 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1279 for ( ; image; image=image->next)
1280 (void) TransformImageColorspace(image,(ColorspaceType) sp,
1284 if (LocaleCompare(attribute,"comment") == 0)
1286 for ( ; image; image=image->next)
1287 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1288 info ? info->image_info : (ImageInfo *) NULL,image,
1289 SvPV(sval,na),exception),exception);
1292 if (LocaleCompare(attribute,"compression") == 0)
1294 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1295 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1298 ThrowPerlException(exception,OptionError,
1299 "UnrecognizedImageCompression",SvPV(sval,na));
1303 info->image_info->compression=(CompressionType) sp;
1304 for ( ; image; image=image->next)
1305 image->compression=(CompressionType) sp;
1309 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1310 for ( ; image; image=image->next)
1311 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1317 if (LocaleCompare(attribute,"debug") == 0)
1319 SetLogEventMask(SvPV(sval,na));
1322 if (LocaleCompare(attribute,"delay") == 0)
1324 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1325 for ( ; image; image=image->next)
1327 image->delay=(size_t) floor(geometry_info.rho+0.5);
1328 if ((flags & SigmaValue) != 0)
1329 image->ticks_per_second=(ssize_t)
1330 floor(geometry_info.sigma+0.5);
1334 if (LocaleCompare(attribute,"disk-limit") == 0)
1339 limit=MagickResourceInfinity;
1340 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1341 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1343 (void) SetMagickResourceLimit(DiskResource,limit);
1346 if (LocaleCompare(attribute,"density") == 0)
1348 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1350 ThrowPerlException(exception,OptionError,"MissingGeometry",
1355 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1356 for ( ; image; image=image->next)
1358 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1359 image->resolution.x=geometry_info.rho;
1360 image->resolution.y=geometry_info.sigma;
1361 if ((flags & SigmaValue) == 0)
1362 image->resolution.y=image->resolution.x;
1366 if (LocaleCompare(attribute,"depth") == 0)
1369 info->image_info->depth=SvIV(sval);
1370 for ( ; image; image=image->next)
1371 (void) SetImageDepth(image,SvIV(sval),exception);
1374 if (LocaleCompare(attribute,"dispose") == 0)
1376 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1377 SvPV(sval,na)) : SvIV(sval);
1380 ThrowPerlException(exception,OptionError,
1381 "UnrecognizedDisposeMethod",SvPV(sval,na));
1384 for ( ; image; image=image->next)
1385 image->dispose=(DisposeType) sp;
1388 if (LocaleCompare(attribute,"dither") == 0)
1392 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1393 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1396 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1400 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1404 if (LocaleCompare(attribute,"display") == 0)
1408 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1412 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1413 for ( ; image; image=image->next)
1414 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1420 if (LocaleCompare(attribute,"endian") == 0)
1422 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1423 SvPV(sval,na)) : SvIV(sval);
1426 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1431 info->image_info->endian=(EndianType) sp;
1432 for ( ; image; image=image->next)
1433 image->endian=(EndianType) sp;
1436 if (LocaleCompare(attribute,"extract") == 0)
1439 Set image extract geometry.
1441 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1445 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1446 for ( ; image; image=image->next)
1447 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1453 if (LocaleCompare(attribute,"filename") == 0)
1456 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1458 for ( ; image; image=image->next)
1459 (void) CopyMagickString(image->filename,SvPV(sval,na),
1463 if (LocaleCompare(attribute,"file") == 0)
1471 if (info == (struct PackageInfo *) NULL)
1473 io_info=IoIFP(sv_2io(sval));
1474 if (io_info == (PerlIO *) NULL)
1476 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1480 file=PerlIO_findFILE(io_info);
1481 if (file == (FILE *) NULL)
1483 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1487 SetImageInfoFile(info->image_info,file);
1490 if (LocaleCompare(attribute,"fill") == 0)
1493 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1496 if (LocaleCompare(attribute,"font") == 0)
1499 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1502 if (LocaleCompare(attribute,"foreground") == 0)
1504 if (LocaleCompare(attribute,"fuzz") == 0)
1507 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1509 for ( ; image; image=image->next)
1510 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1515 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1516 for ( ; image; image=image->next)
1517 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1523 if (LocaleCompare(attribute,"gamma") == 0)
1525 for ( ; image; image=image->next)
1526 image->gamma=SvNV(sval);
1529 if (LocaleCompare(attribute,"gravity") == 0)
1531 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1532 SvPV(sval,na)) : SvIV(sval);
1535 ThrowPerlException(exception,OptionError,
1536 "UnrecognizedGravityType",SvPV(sval,na));
1540 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1541 for ( ; image; image=image->next)
1542 image->gravity=(GravityType) sp;
1545 if (LocaleCompare(attribute,"green-primary") == 0)
1547 for ( ; image; image=image->next)
1549 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1550 image->chromaticity.green_primary.x=geometry_info.rho;
1551 image->chromaticity.green_primary.y=geometry_info.sigma;
1552 if ((flags & SigmaValue) == 0)
1553 image->chromaticity.green_primary.y=
1554 image->chromaticity.green_primary.x;
1559 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1560 for ( ; image; image=image->next)
1561 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1567 if (LocaleNCompare(attribute,"index",5) == 0)
1581 for ( ; image; image=image->next)
1583 if (image->storage_class != PseudoClass)
1587 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1589 image_view=AcquireAuthenticCacheView(image,exception);
1590 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1591 if (q != (Quantum *) NULL)
1593 items=sscanf(SvPV(sval,na),"%ld",&index);
1594 if ((index >= 0) && (index < (ssize_t) image->colors))
1595 SetPixelIndex(image,index,q);
1596 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1598 image_view=DestroyCacheView(image_view);
1602 if (LocaleCompare(attribute,"iterations") == 0)
1605 for ( ; image; image=image->next)
1606 image->iterations=SvIV(sval);
1609 if (LocaleCompare(attribute,"interlace") == 0)
1611 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1612 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1615 ThrowPerlException(exception,OptionError,
1616 "UnrecognizedInterlaceType",SvPV(sval,na));
1620 info->image_info->interlace=(InterlaceType) sp;
1621 for ( ; image; image=image->next)
1622 image->interlace=(InterlaceType) sp;
1626 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1627 for ( ; image; image=image->next)
1628 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1634 if (LocaleCompare(attribute,"label") == 0)
1636 for ( ; image; image=image->next)
1637 (void) SetImageProperty(image,"label",InterpretImageProperties(
1638 info ? info->image_info : (ImageInfo *) NULL,image,
1639 SvPV(sval,na),exception),exception);
1642 if (LocaleCompare(attribute,"loop") == 0)
1645 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1646 for ( ; image; image=image->next)
1647 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1653 if (LocaleCompare(attribute,"magick") == 0)
1656 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
1657 "%s:",SvPV(sval,na));
1658 for ( ; image; image=image->next)
1659 (void) CopyMagickString(image->magick,SvPV(sval,na),MaxTextExtent);
1662 if (LocaleCompare(attribute,"map-limit") == 0)
1667 limit=MagickResourceInfinity;
1668 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1669 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1671 (void) SetMagickResourceLimit(MapResource,limit);
1674 if (LocaleCompare(attribute,"mask") == 0)
1679 mask=(Image *) NULL;
1681 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1682 for ( ; image; image=image->next)
1683 SetImageMask(image,mask,exception);
1686 if (LocaleCompare(attribute,"mattecolor") == 0)
1688 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1691 info->image_info->matte_color=target_color;
1692 for ( ; image; image=image->next)
1693 image->matte_color=target_color;
1696 if (LocaleCompare(attribute,"matte") == 0)
1698 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1699 SvPV(sval,na)) : SvIV(sval);
1702 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1706 for ( ; image; image=image->next)
1707 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1710 if (LocaleCompare(attribute,"memory-limit") == 0)
1715 limit=MagickResourceInfinity;
1716 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1717 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1719 (void) SetMagickResourceLimit(MemoryResource,limit);
1722 if (LocaleCompare(attribute,"monochrome") == 0)
1724 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1725 SvPV(sval,na)) : SvIV(sval);
1728 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1733 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1734 for ( ; image; image=image->next)
1735 (void) SetImageType(image,BilevelType,exception);
1739 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1740 for ( ; image; image=image->next)
1741 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1747 if (LocaleCompare(attribute,"option") == 0)
1750 DefineImageOption(info->image_info,SvPV(sval,na));
1753 if (LocaleCompare(attribute,"orientation") == 0)
1755 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1756 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1759 ThrowPerlException(exception,OptionError,
1760 "UnrecognizedOrientationType",SvPV(sval,na));
1764 info->image_info->orientation=(OrientationType) sp;
1765 for ( ; image; image=image->next)
1766 image->orientation=(OrientationType) sp;
1770 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1771 for ( ; image; image=image->next)
1772 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1778 if (LocaleCompare(attribute,"page") == 0)
1783 geometry=GetPageGeometry(SvPV(sval,na));
1785 (void) CloneString(&info->image_info->page,geometry);
1786 for ( ; image; image=image->next)
1787 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1788 geometry=(char *) RelinquishMagickMemory(geometry);
1791 if (LocaleNCompare(attribute,"pixel",5) == 0)
1805 for ( ; image; image=image->next)
1807 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1811 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1813 image_view=AcquireVirtualCacheView(image,exception);
1814 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1815 if (q != (Quantum *) NULL)
1817 if ((strchr(SvPV(sval,na),',') == 0) ||
1818 (strchr(SvPV(sval,na),')') != 0))
1819 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1823 GetPixelInfo(image,&pixel);
1824 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1825 pixel.red=geometry_info.rho;
1826 if ((flags & SigmaValue) != 0)
1827 pixel.green=geometry_info.sigma;
1828 if ((flags & XiValue) != 0)
1829 pixel.blue=geometry_info.xi;
1830 if ((flags & PsiValue) != 0)
1831 pixel.alpha=geometry_info.psi;
1832 if ((flags & ChiValue) != 0)
1833 pixel.black=geometry_info.chi;
1835 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1836 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1837 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1838 if (image->colorspace == CMYKColorspace)
1839 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1840 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1841 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1843 image_view=DestroyCacheView(image_view);
1847 if (LocaleCompare(attribute,"pointsize") == 0)
1851 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1852 info->image_info->pointsize=geometry_info.rho;
1856 if (LocaleCompare(attribute,"preview") == 0)
1858 sp=SvPOK(sval) ? ParseCommandOption(MagickPreviewOptions,MagickFalse,
1859 SvPV(sval,na)) : SvIV(sval);
1862 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1867 info->image_info->preview_type=(PreviewType) sp;
1871 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1872 for ( ; image; image=image->next)
1873 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1879 if (LocaleCompare(attribute,"quality") == 0)
1882 info->image_info->quality=SvIV(sval);
1883 for ( ; image; image=image->next)
1884 image->quality=SvIV(sval);
1888 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1889 for ( ; image; image=image->next)
1890 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1896 if (LocaleCompare(attribute,"red-primary") == 0)
1898 for ( ; image; image=image->next)
1900 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1901 image->chromaticity.red_primary.x=geometry_info.rho;
1902 image->chromaticity.red_primary.y=geometry_info.sigma;
1903 if ((flags & SigmaValue) == 0)
1904 image->chromaticity.red_primary.y=
1905 image->chromaticity.red_primary.x;
1909 if (LocaleCompare(attribute,"render") == 0)
1911 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1912 SvPV(sval,na)) : SvIV(sval);
1915 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1919 for ( ; image; image=image->next)
1920 image->rendering_intent=(RenderingIntent) sp;
1923 if (LocaleCompare(attribute,"repage") == 0)
1928 for ( ; image; image=image->next)
1930 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
1931 if ((flags & WidthValue) != 0)
1933 if ((flags & HeightValue) == 0)
1934 geometry.height=geometry.width;
1935 image->page.width=geometry.width;
1936 image->page.height=geometry.height;
1938 if ((flags & AspectValue) != 0)
1940 if ((flags & XValue) != 0)
1941 image->page.x+=geometry.x;
1942 if ((flags & YValue) != 0)
1943 image->page.y+=geometry.y;
1947 if ((flags & XValue) != 0)
1949 image->page.x=geometry.x;
1950 if (((flags & WidthValue) != 0) && (geometry.x > 0))
1951 image->page.width=image->columns+geometry.x;
1953 if ((flags & YValue) != 0)
1955 image->page.y=geometry.y;
1956 if (((flags & HeightValue) != 0) && (geometry.y > 0))
1957 image->page.height=image->rows+geometry.y;
1964 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1965 for ( ; image; image=image->next)
1966 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1972 if (LocaleCompare(attribute,"sampling-factor") == 0)
1974 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1976 ThrowPerlException(exception,OptionError,"MissingGeometry",
1981 (void) CloneString(&info->image_info->sampling_factor,
1985 if (LocaleCompare(attribute,"scene") == 0)
1987 for ( ; image; image=image->next)
1988 image->scene=SvIV(sval);
1991 if (LocaleCompare(attribute,"server") == 0)
1993 if (LocaleCompare(attribute,"size") == 0)
1997 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1999 ThrowPerlException(exception,OptionError,"MissingGeometry",
2003 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2007 if (LocaleCompare(attribute,"stroke") == 0)
2010 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2014 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2015 for ( ; image; image=image->next)
2016 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2022 if (LocaleCompare(attribute,"texture") == 0)
2025 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2028 if (LocaleCompare(attribute,"thread-limit") == 0)
2033 limit=MagickResourceInfinity;
2034 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2035 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2037 (void) SetMagickResourceLimit(ThreadResource,limit);
2040 if (LocaleCompare(attribute,"tile-offset") == 0)
2045 geometry=GetPageGeometry(SvPV(sval,na));
2047 (void) CloneString(&info->image_info->page,geometry);
2048 for ( ; image; image=image->next)
2049 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2051 geometry=(char *) RelinquishMagickMemory(geometry);
2054 if (LocaleCompare(attribute,"time-limit") == 0)
2059 limit=MagickResourceInfinity;
2060 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2061 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2063 (void) SetMagickResourceLimit(TimeResource,limit);
2066 if (LocaleCompare(attribute,"transparent-color") == 0)
2068 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2071 info->image_info->transparent_color=target_color;
2072 for ( ; image; image=image->next)
2073 image->transparent_color=target_color;
2076 if (LocaleCompare(attribute,"type") == 0)
2078 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2079 SvPV(sval,na)) : SvIV(sval);
2082 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2087 info->image_info->type=(ImageType) sp;
2088 for ( ; image; image=image->next)
2089 SetImageType(image,(ImageType) sp,exception);
2093 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2094 for ( ; image; image=image->next)
2095 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2101 if (LocaleCompare(attribute,"units") == 0)
2103 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2104 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2107 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2112 info->image_info->units=(ResolutionType) sp;
2113 for ( ; image; image=image->next)
2118 units=(ResolutionType) sp;
2119 if (image->units != units)
2120 switch (image->units)
2122 case UndefinedResolution:
2123 case PixelsPerInchResolution:
2125 if (units == PixelsPerCentimeterResolution)
2127 image->resolution.x*=2.54;
2128 image->resolution.y*=2.54;
2132 case PixelsPerCentimeterResolution:
2134 if (units == PixelsPerInchResolution)
2136 image->resolution.x/=2.54;
2137 image->resolution.y/=2.54;
2147 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2148 for ( ; image; image=image->next)
2149 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2155 if (LocaleCompare(attribute,"verbose") == 0)
2157 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2158 SvPV(sval,na)) : SvIV(sval);
2161 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2166 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2169 if (LocaleCompare(attribute,"view") == 0)
2172 (void) CloneString(&info->image_info->view,SvPV(sval,na));
2175 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2177 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2178 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2181 ThrowPerlException(exception,OptionError,
2182 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2185 for ( ; image; image=image->next)
2186 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2190 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2191 for ( ; image; image=image->next)
2192 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2198 if (LocaleCompare(attribute,"white-point") == 0)
2200 for ( ; image; image=image->next)
2202 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2203 image->chromaticity.white_point.x=geometry_info.rho;
2204 image->chromaticity.white_point.y=geometry_info.sigma;
2205 if ((flags & SigmaValue) == 0)
2206 image->chromaticity.white_point.y=
2207 image->chromaticity.white_point.x;
2212 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2213 for ( ; image; image=image->next)
2214 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2220 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2221 for ( ; image; image=image->next)
2222 SetImageProperty(image,attribute,SvPV(sval,na),exception);
2229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2233 % S e t u p L i s t %
2237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2239 % Method SetupList returns the list of all the images linked by their
2240 % image->next and image->previous link lists for use with ImageMagick. If
2241 % info is non-NULL, an info structure is returned in *info. If
2242 % reference_vector is non-NULL,an array of SV* are returned in
2243 % *reference_vector. Reference_vector is used when the images are going to be
2244 % replaced with new Image*'s.
2246 % The format of the SetupList routine is:
2248 % Image *SetupList(SV *reference,struct PackageInfo **info,
2249 % SV ***reference_vector,ExceptionInfo *exception)
2251 % A description of each parameter follows:
2253 % o list: a list of strings.
2255 % o string: a character string.
2257 % o exception: Return any errors or warnings in this structure.
2260 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2261 SV ***reference_vector,ExceptionInfo *exception)
2270 if (reference_vector)
2271 *reference_vector=NULL;
2276 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2277 if (info && (SvTYPE(reference) == SVt_PVAV))
2278 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2288 % s t r E Q c a s e %
2292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2294 % strEQcase() compares two strings and returns 0 if they are the
2295 % same or if the second string runs out first. The comparison is case
2298 % The format of the strEQcase routine is:
2300 % ssize_t strEQcase(const char *p,const char *q)
2302 % A description of each parameter follows:
2304 % o p: a character string.
2306 % o q: a character string.
2310 static ssize_t strEQcase(const char *p,const char *q)
2318 for (i=0 ; (c=(*q)) != 0; i++)
2320 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2321 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2326 return(((*q == 0) && (*p == 0)) ? i : 0);
2330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2334 % I m a g e : : M a g i c k %
2338 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2342 MODULE = Image::Magick::Q16HDRI PACKAGE = Image::Magick::Q16HDRI
2347 MagickCoreGenesis("PerlMagick",MagickFalse);
2348 SetWarningHandler(NULL);
2349 SetErrorHandler(NULL);
2350 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2351 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2357 if (magick_registry != (SplayTreeInfo *) NULL)
2358 magick_registry=DestroySplayTree(magick_registry);
2359 MagickCoreTerminus();
2363 constant(name,argument)
2368 ###############################################################################
2376 ###############################################################################
2381 Image::Magick::Q16HDRI ref=NO_INIT
2405 PERL_UNUSED_VAR(ref);
2406 PERL_UNUSED_VAR(ix);
2407 exception=AcquireExceptionInfo();
2408 perl_exception=newSVpv("",0);
2409 package_info=(struct PackageInfo *) NULL;
2410 if (sv_isobject(ST(0)) == 0)
2412 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2416 reference=SvRV(ST(0));
2417 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2418 if (image == (Image *) NULL)
2420 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2424 package_info=ClonePackageInfo(info,exception);
2426 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2429 for (i=2; i < items; i+=2)
2430 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2432 (void) AnimateImages(package_info->image_info,image,exception);
2433 (void) CatchImageException(image);
2436 if (package_info != (struct PackageInfo *) NULL)
2437 DestroyPackageInfo(package_info);
2438 InheritPerlException(exception,perl_exception);
2439 exception=DestroyExceptionInfo(exception);
2440 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2441 SvPOK_on(perl_exception);
2442 ST(0)=sv_2mortal(perl_exception);
2447 ###############################################################################
2455 ###############################################################################
2460 Image::Magick::Q16HDRI ref=NO_INIT
2498 PERL_UNUSED_VAR(ref);
2499 PERL_UNUSED_VAR(ix);
2500 exception=AcquireExceptionInfo();
2501 perl_exception=newSVpv("",0);
2505 if (sv_isobject(ST(0)) == 0)
2507 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2511 reference=SvRV(ST(0));
2512 hv=SvSTASH(reference);
2514 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2516 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2517 if (image == (Image *) NULL)
2519 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2523 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2528 for (i=2; i < items; i+=2)
2530 attribute=(char *) SvPV(ST(i-1),na);
2536 if (LocaleCompare(attribute,"stack") == 0)
2538 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2542 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2548 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2554 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2560 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2561 if (image == (Image *) NULL)
2563 for ( ; image; image=image->next)
2565 AddImageToRegistry(sv,image);
2567 av_push(av,sv_bless(rv,hv));
2570 exception=DestroyExceptionInfo(exception);
2572 SvREFCNT_dec(perl_exception);
2576 InheritPerlException(exception,perl_exception);
2577 exception=DestroyExceptionInfo(exception);
2578 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2579 SvPOK_on(perl_exception);
2580 ST(0)=sv_2mortal(perl_exception);
2585 ###############################################################################
2593 ###############################################################################
2598 Image::Magick::Q16HDRI ref=NO_INIT
2629 PERL_UNUSED_VAR(ref);
2630 PERL_UNUSED_VAR(ix);
2631 exception=AcquireExceptionInfo();
2632 perl_exception=newSVpv("",0);
2634 if (sv_isobject(ST(0)) == 0)
2636 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2640 reference=SvRV(ST(0));
2641 hv=SvSTASH(reference);
2642 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2643 if (image == (Image *) NULL)
2645 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2649 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2650 if (image == (Image *) NULL)
2653 Create blessed Perl array for the returned image.
2656 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2658 AddImageToRegistry(sv,image);
2660 av_push(av,sv_bless(rv,hv));
2662 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2663 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
2664 "average-%.*s",(int) (MaxTextExtent-9),
2665 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2666 (void) CopyMagickString(image->filename,info->image_info->filename,
2668 SetImageInfo(info->image_info,0,exception);
2669 exception=DestroyExceptionInfo(exception);
2670 SvREFCNT_dec(perl_exception);
2674 InheritPerlException(exception,perl_exception);
2675 exception=DestroyExceptionInfo(exception);
2676 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2677 SvPOK_on(perl_exception);
2678 ST(0)=sv_2mortal(perl_exception);
2683 ###############################################################################
2687 # B l o b T o I m a g e #
2691 ###############################################################################
2695 BlobToImage(ref,...)
2696 Image::Magick::Q16HDRI ref=NO_INIT
2742 PERL_UNUSED_VAR(ref);
2743 PERL_UNUSED_VAR(ix);
2744 exception=AcquireExceptionInfo();
2745 perl_exception=newSVpv("",0);
2748 ac=(items < 2) ? 1 : items-1;
2749 length=(STRLEN *) NULL;
2750 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2751 if (list == (char **) NULL)
2753 ThrowPerlException(exception,ResourceLimitError,
2754 "MemoryAllocationFailed",PackageName);
2757 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2758 if (length == (STRLEN *) NULL)
2760 ThrowPerlException(exception,ResourceLimitError,
2761 "MemoryAllocationFailed",PackageName);
2764 if (sv_isobject(ST(0)) == 0)
2766 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2770 reference=SvRV(ST(0));
2771 hv=SvSTASH(reference);
2772 if (SvTYPE(reference) != SVt_PVAV)
2774 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2778 av=(AV *) reference;
2779 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2784 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2787 for (n=0, i=0; i < ac; i++)
2789 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2790 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2792 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2797 list[n]=(char *) NULL;
2799 for (i=number_images=0; i < n; i++)
2801 image=BlobToImage(info->image_info,list[i],length[i],exception);
2802 if (image == (Image *) NULL)
2804 for ( ; image; image=image->next)
2806 AddImageToRegistry(sv,image);
2808 av_push(av,sv_bless(rv,hv));
2816 for (i=0; i < n; i++)
2817 if (list[i] != (char *) NULL)
2818 for (p=keep; list[i] != *p++; )
2819 if (*p == (char *) NULL)
2821 list[i]=(char *) RelinquishMagickMemory(list[i]);
2827 list=(char **) RelinquishMagickMemory(list);
2829 length=(STRLEN *) RelinquishMagickMemory(length);
2830 InheritPerlException(exception,perl_exception);
2831 exception=DestroyExceptionInfo(exception);
2832 sv_setiv(perl_exception,(IV) number_images);
2833 SvPOK_on(perl_exception);
2834 ST(0)=sv_2mortal(perl_exception);
2839 ###############################################################################
2843 # C h a n n e l F x #
2847 ###############################################################################
2852 Image::Magick::Q16HDRI ref=NO_INIT
2864 expression[MaxTextExtent];
2892 PERL_UNUSED_VAR(ref);
2893 PERL_UNUSED_VAR(ix);
2894 exception=AcquireExceptionInfo();
2895 perl_exception=newSVpv("",0);
2899 if (sv_isobject(ST(0)) == 0)
2901 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2905 reference=SvRV(ST(0));
2906 hv=SvSTASH(reference);
2908 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2910 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2911 if (image == (Image *) NULL)
2913 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2917 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2921 channel=DefaultChannels;
2922 (void) CopyMagickString(expression,"u",MaxTextExtent);
2924 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
2926 for (i=2; i < items; i+=2)
2928 attribute=(char *) SvPV(ST(i-1),na);
2934 if (LocaleCompare(attribute,"channel") == 0)
2939 option=ParseChannelOption(SvPV(ST(i),na));
2942 ThrowPerlException(exception,OptionError,
2943 "UnrecognizedType",SvPV(ST(i),na));
2946 channel=(ChannelType) option;
2949 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2956 if (LocaleCompare(attribute,"expression") == 0)
2958 (void) CopyMagickString(expression,SvPV(ST(i),na),
2962 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2968 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2974 channel_mask=SetImageChannelMask(image,channel);
2975 image=ChannelFxImage(image,expression,exception);
2976 if (image != (Image *) NULL)
2977 (void) SetImageChannelMask(image,channel_mask);
2978 if (image == (Image *) NULL)
2980 for ( ; image; image=image->next)
2982 AddImageToRegistry(sv,image);
2984 av_push(av,sv_bless(rv,hv));
2987 exception=DestroyExceptionInfo(exception);
2989 SvREFCNT_dec(perl_exception); /* can't return warning messages */
2993 InheritPerlException(exception,perl_exception);
2994 exception=DestroyExceptionInfo(exception);
2995 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2996 SvPOK_on(perl_exception);
2997 ST(0)=sv_2mortal(perl_exception);
3002 ###############################################################################
3010 ###############################################################################
3015 Image::Magick::Q16HDRI ref=NO_INIT
3048 PERL_UNUSED_VAR(ref);
3049 PERL_UNUSED_VAR(ix);
3050 exception=AcquireExceptionInfo();
3051 perl_exception=newSVpv("",0);
3053 if (sv_isobject(ST(0)) == 0)
3055 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3059 reference=SvRV(ST(0));
3060 hv=SvSTASH(reference);
3061 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3062 if (image == (Image *) NULL)
3064 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3069 Create blessed Perl array for the returned image.
3072 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3074 for ( ; image; image=image->next)
3076 clone=CloneImage(image,0,0,MagickTrue,exception);
3077 if (clone == (Image *) NULL)
3079 AddImageToRegistry(sv,clone);
3081 av_push(av,sv_bless(rv,hv));
3084 exception=DestroyExceptionInfo(exception);
3085 SvREFCNT_dec(perl_exception);
3089 InheritPerlException(exception,perl_exception);
3090 exception=DestroyExceptionInfo(exception);
3091 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3092 SvPOK_on(perl_exception);
3093 ST(0)=sv_2mortal(perl_exception);
3098 ###############################################################################
3106 ###############################################################################
3114 PERL_UNUSED_VAR(ref);
3115 if (magick_registry != (SplayTreeInfo *) NULL)
3120 ResetSplayTreeIterator(magick_registry);
3121 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3122 while (p != (Image *) NULL)
3125 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3131 ###############################################################################
3139 ###############################################################################
3144 Image::Magick::Q16HDRI ref=NO_INIT
3173 PERL_UNUSED_VAR(ref);
3174 PERL_UNUSED_VAR(ix);
3175 exception=AcquireExceptionInfo();
3176 perl_exception=newSVpv("",0);
3178 if (sv_isobject(ST(0)) == 0)
3180 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3184 reference=SvRV(ST(0));
3185 hv=SvSTASH(reference);
3187 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3189 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3190 if (image == (Image *) NULL)
3192 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3196 image=CoalesceImages(image,exception);
3197 if (image == (Image *) NULL)
3199 for ( ; image; image=image->next)
3201 AddImageToRegistry(sv,image);
3203 av_push(av,sv_bless(rv,hv));
3206 exception=DestroyExceptionInfo(exception);
3208 SvREFCNT_dec(perl_exception);
3212 InheritPerlException(exception,perl_exception);
3213 exception=DestroyExceptionInfo(exception);
3214 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3215 SvPOK_on(perl_exception);
3216 ST(0)=sv_2mortal(perl_exception);
3221 ###############################################################################
3229 ###############################################################################
3234 Image::Magick::Q16HDRI ref=NO_INIT
3280 PERL_UNUSED_VAR(ref);
3281 PERL_UNUSED_VAR(ix);
3282 exception=AcquireExceptionInfo();
3283 perl_exception=newSVpv("",0);
3287 if (sv_isobject(ST(0)) == 0)
3289 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3293 reference=SvRV(ST(0));
3294 hv=SvSTASH(reference);
3296 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3298 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3299 if (image == (Image *) NULL)
3301 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3305 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3309 reconstruct_image=image;
3310 metric=RootMeanSquaredErrorMetric;
3311 for (i=2; i < items; i+=2)
3313 attribute=(char *) SvPV(ST(i-1),na);
3319 if (LocaleCompare(attribute,"channel") == 0)
3324 option=ParseChannelOption(SvPV(ST(i),na));
3327 ThrowPerlException(exception,OptionError,
3328 "UnrecognizedType",SvPV(ST(i),na));
3331 SetPixelChannelMask(image,(ChannelType) option);
3334 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3341 if (LocaleCompare(attribute,"fuzz") == 0)
3343 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3346 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3353 if (LocaleCompare(attribute,"image") == 0)
3355 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3356 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3359 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3366 if (LocaleCompare(attribute,"metric") == 0)
3368 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3372 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3376 metric=(MetricType) option;
3379 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3385 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3391 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3393 if (difference_image != (Image *) NULL)
3395 difference_image->error.mean_error_per_pixel=distortion;
3396 AddImageToRegistry(sv,difference_image);
3398 av_push(av,sv_bless(rv,hv));
3401 exception=DestroyExceptionInfo(exception);
3403 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3407 InheritPerlException(exception,perl_exception);
3408 exception=DestroyExceptionInfo(exception);
3409 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3410 SvPOK_on(perl_exception);
3411 ST(0)=sv_2mortal(perl_exception);
3416 ###############################################################################
3420 # C o m p a r e L a y e r s #
3424 ###############################################################################
3429 Image::Magick::Q16HDRI ref=NO_INIT
3431 CompareImagesLayers = 1
3433 compareimagelayers = 3
3470 PERL_UNUSED_VAR(ref);
3471 PERL_UNUSED_VAR(ix);
3472 exception=AcquireExceptionInfo();
3473 perl_exception=newSVpv("",0);
3475 if (sv_isobject(ST(0)) == 0)
3477 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3481 reference=SvRV(ST(0));
3482 hv=SvSTASH(reference);
3484 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3486 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3487 if (image == (Image *) NULL)
3489 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3493 method=CompareAnyLayer;
3494 for (i=2; i < items; i+=2)
3496 attribute=(char *) SvPV(ST(i-1),na);
3502 if (LocaleCompare(attribute,"method") == 0)
3504 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3508 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3512 method=(LayerMethod) option;
3515 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3521 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3527 image=CompareImagesLayers(image,method,exception);
3528 if (image == (Image *) NULL)
3530 for ( ; image; image=image->next)
3532 AddImageToRegistry(sv,image);
3534 av_push(av,sv_bless(rv,hv));
3537 exception=DestroyExceptionInfo(exception);
3539 SvREFCNT_dec(perl_exception);
3543 InheritPerlException(exception,perl_exception);
3544 exception=DestroyExceptionInfo(exception);
3545 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3546 SvPOK_on(perl_exception);
3547 ST(0)=sv_2mortal(perl_exception);
3552 ###############################################################################
3560 ###############################################################################
3565 Image::Magick::Q16HDRI ref=NO_INIT
3571 PERL_UNUSED_VAR(ref);
3572 if (sv_isobject(ST(0)) == 0)
3573 croak("ReferenceIsNotMyType");
3574 reference=SvRV(ST(0));
3575 switch (SvTYPE(reference))
3580 message[MaxTextExtent];
3598 Array (AV *) reference
3600 (void) FormatLocaleString(message,MaxTextExtent,"package%s%p",
3601 XS_VERSION,reference);
3602 hv=gv_stashpv(PackageName, FALSE);
3605 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3609 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3611 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3612 DestroyPackageInfo(info);
3614 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3624 Blessed scalar = (Image *) SvIV(reference)
3626 image=INT2PTR(Image *,SvIV(reference));
3627 if (image != (Image *) NULL)
3628 DeleteImageFromRegistry(reference,image);
3637 ###############################################################################
3645 ###############################################################################
3650 Image::Magick::Q16HDRI ref=NO_INIT
3674 PERL_UNUSED_VAR(ref);
3675 PERL_UNUSED_VAR(ix);
3676 exception=AcquireExceptionInfo();
3677 perl_exception=newSVpv("",0);
3678 package_info=(struct PackageInfo *) NULL;
3679 if (sv_isobject(ST(0)) == 0)
3681 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3685 reference=SvRV(ST(0));
3686 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3687 if (image == (Image *) NULL)
3689 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3693 package_info=ClonePackageInfo(info,exception);
3695 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3698 for (i=2; i < items; i+=2)
3699 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3701 (void) DisplayImages(package_info->image_info,image,exception);
3702 (void) CatchImageException(image);
3705 if (package_info != (struct PackageInfo *) NULL)
3706 DestroyPackageInfo(package_info);
3707 InheritPerlException(exception,perl_exception);
3708 exception=DestroyExceptionInfo(exception);
3709 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3710 SvPOK_on(perl_exception);
3711 ST(0)=sv_2mortal(perl_exception);
3716 ###############################################################################
3720 # E v a l u a t e I m a g e s #
3724 ###############################################################################
3729 Image::Magick::Q16HDRI ref=NO_INIT
3751 MagickEvaluateOperator
3766 PERL_UNUSED_VAR(ref);
3767 PERL_UNUSED_VAR(ix);
3768 exception=AcquireExceptionInfo();
3769 perl_exception=newSVpv("",0);
3771 if (sv_isobject(ST(0)) == 0)
3773 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3777 reference=SvRV(ST(0));
3778 hv=SvSTASH(reference);
3779 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3780 if (image == (Image *) NULL)
3782 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3786 op=MeanEvaluateOperator;
3792 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
3796 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3800 op=(MagickEvaluateOperator) in;
3803 for (i=2; i < items; i+=2)
3805 attribute=(char *) SvPV(ST(i-1),na);
3811 if (LocaleCompare(attribute,"operator") == 0)
3816 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3817 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
3820 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3824 op=(MagickEvaluateOperator) in;
3827 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3833 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3839 image=EvaluateImages(image,op,exception);
3840 if (image == (Image *) NULL)
3843 Create blessed Perl array for the returned image.
3846 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3848 AddImageToRegistry(sv,image);
3850 av_push(av,sv_bless(rv,hv));
3852 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3853 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
3854 "evaluate-%.*s",(int) (MaxTextExtent-9),
3855 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3856 (void) CopyMagickString(image->filename,info->image_info->filename,
3858 SetImageInfo(info->image_info,0,exception);
3859 exception=DestroyExceptionInfo(exception);
3860 SvREFCNT_dec(perl_exception);
3864 InheritPerlException(exception,perl_exception);
3865 exception=DestroyExceptionInfo(exception);
3866 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3867 SvPOK_on(perl_exception);
3868 ST(0)=sv_2mortal(perl_exception);
3873 ###############################################################################
3881 ###############################################################################
3886 Image::Magick::Q16HDRI ref=NO_INIT
3893 #define ChannelFeatures(channel,direction) \
3895 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3896 channel_features[channel].angular_second_moment[direction]); \
3897 PUSHs(sv_2mortal(newSVpv(message,0))); \
3898 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3899 channel_features[channel].contrast[direction]); \
3900 PUSHs(sv_2mortal(newSVpv(message,0))); \
3901 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3902 channel_features[channel].contrast[direction]); \
3903 PUSHs(sv_2mortal(newSVpv(message,0))); \
3904 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3905 channel_features[channel].variance_sum_of_squares[direction]); \
3906 PUSHs(sv_2mortal(newSVpv(message,0))); \
3907 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3908 channel_features[channel].inverse_difference_moment[direction]); \
3909 PUSHs(sv_2mortal(newSVpv(message,0))); \
3910 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3911 channel_features[channel].sum_average[direction]); \
3912 PUSHs(sv_2mortal(newSVpv(message,0))); \
3913 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3914 channel_features[channel].sum_variance[direction]); \
3915 PUSHs(sv_2mortal(newSVpv(message,0))); \
3916 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3917 channel_features[channel].sum_entropy[direction]); \
3918 PUSHs(sv_2mortal(newSVpv(message,0))); \
3919 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3920 channel_features[channel].entropy[direction]); \
3921 PUSHs(sv_2mortal(newSVpv(message,0))); \
3922 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3923 channel_features[channel].difference_variance[direction]); \
3924 PUSHs(sv_2mortal(newSVpv(message,0))); \
3925 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3926 channel_features[channel].difference_entropy[direction]); \
3927 PUSHs(sv_2mortal(newSVpv(message,0))); \
3928 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3929 channel_features[channel].measure_of_correlation_1[direction]); \
3930 PUSHs(sv_2mortal(newSVpv(message,0))); \
3931 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3932 channel_features[channel].measure_of_correlation_2[direction]); \
3933 PUSHs(sv_2mortal(newSVpv(message,0))); \
3934 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
3935 channel_features[channel].maximum_correlation_coefficient[direction]); \
3936 PUSHs(sv_2mortal(newSVpv(message,0))); \
3944 message[MaxTextExtent];
3971 PERL_UNUSED_VAR(ref);
3972 PERL_UNUSED_VAR(ix);
3973 exception=AcquireExceptionInfo();
3974 perl_exception=newSVpv("",0);
3976 if (sv_isobject(ST(0)) == 0)
3978 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3982 reference=SvRV(ST(0));
3985 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3986 if (image == (Image *) NULL)
3988 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3992 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3994 for (i=2; i < items; i+=2)
3996 attribute=(char *) SvPV(ST(i-1),na);
4002 if (LocaleCompare(attribute,"distance") == 0)
4004 distance=StringToLong((char *) SvPV(ST(1),na));
4007 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4013 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4020 for ( ; image; image=image->next)
4022 channel_features=GetImageFeatures(image,distance,exception);
4023 if (channel_features == (ChannelFeatures *) NULL)
4026 EXTEND(sp,75*count);
4027 for (i=0; i < 4; i++)
4029 ChannelFeatures(RedChannel,i);
4030 ChannelFeatures(GreenChannel,i);
4031 ChannelFeatures(BlueChannel,i);
4032 if (image->colorspace == CMYKColorspace)
4033 ChannelFeatures(BlackChannel,i);
4034 if (image->alpha_trait == BlendPixelTrait)
4035 ChannelFeatures(AlphaChannel,i);
4037 channel_features=(ChannelFeatures *)
4038 RelinquishMagickMemory(channel_features);
4042 InheritPerlException(exception,perl_exception);
4043 exception=DestroyExceptionInfo(exception);
4044 SvREFCNT_dec(perl_exception);
4048 ###############################################################################
4056 ###############################################################################
4061 Image::Magick::Q16HDRI ref=NO_INIT
4099 PERL_UNUSED_VAR(ref);
4100 PERL_UNUSED_VAR(ix);
4101 exception=AcquireExceptionInfo();
4102 perl_exception=newSVpv("",0);
4104 if (sv_isobject(ST(0)) == 0)
4106 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4110 reference=SvRV(ST(0));
4111 hv=SvSTASH(reference);
4112 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4113 if (image == (Image *) NULL)
4115 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4119 background_color=image->background_color;
4121 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4122 &background_color,exception);
4124 for (i=2; i < items; i+=2)
4126 attribute=(char *) SvPV(ST(i-1),na);
4132 if (LocaleCompare(attribute,"background") == 0)
4134 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4135 AllCompliance,&background_color,exception);
4138 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4144 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4150 image->background_color=background_color;
4151 image=MergeImageLayers(image,FlattenLayer,exception);
4152 if (image == (Image *) NULL)
4155 Create blessed Perl array for the returned image.
4158 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4160 AddImageToRegistry(sv,image);
4162 av_push(av,sv_bless(rv,hv));
4164 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4165 (void) FormatLocaleString(info->image_info->filename,MaxTextExtent,
4166 "flatten-%.*s",(int) (MaxTextExtent-9),
4167 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4168 (void) CopyMagickString(image->filename,info->image_info->filename,
4170 SetImageInfo(info->image_info,0,exception);
4171 exception=DestroyExceptionInfo(exception);
4172 SvREFCNT_dec(perl_exception);
4176 InheritPerlException(exception,perl_exception);
4177 exception=DestroyExceptionInfo(exception);
4178 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4179 SvPOK_on(perl_exception); /* return messages in string context */
4180 ST(0)=sv_2mortal(perl_exception);
4185 ###############################################################################
4193 ###############################################################################
4198 Image::Magick::Q16HDRI ref=NO_INIT
4210 expression[MaxTextExtent];
4238 PERL_UNUSED_VAR(ref);
4239 PERL_UNUSED_VAR(ix);
4240 exception=AcquireExceptionInfo();
4241 perl_exception=newSVpv("",0);
4245 if (sv_isobject(ST(0)) == 0)
4247 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4251 reference=SvRV(ST(0));
4252 hv=SvSTASH(reference);
4254 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4256 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4257 if (image == (Image *) NULL)
4259 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4263 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4267 channel=DefaultChannels;
4268 (void) CopyMagickString(expression,"u",MaxTextExtent);
4270 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MaxTextExtent);
4272 for (i=2; i < items; i+=2)
4274 attribute=(char *) SvPV(ST(i-1),na);
4280 if (LocaleCompare(attribute,"channel") == 0)
4285 option=ParseChannelOption(SvPV(ST(i),na));
4288 ThrowPerlException(exception,OptionError,
4289 "UnrecognizedType",SvPV(ST(i),na));
4292 channel=(ChannelType) option;
4295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4302 if (LocaleCompare(attribute,"expression") == 0)
4304 (void) CopyMagickString(expression,SvPV(ST(i),na),
4308 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4314 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4320 channel_mask=SetImageChannelMask(image,channel);
4321 image=FxImage(image,expression,exception);
4322 if (image != (Image *) NULL)
4323 (void) SetImageChannelMask(image,channel_mask);
4324 if (image == (Image *) NULL)
4326 for ( ; image; image=image->next)
4328 AddImageToRegistry(sv,image);
4330 av_push(av,sv_bless(rv,hv));
4333 exception=DestroyExceptionInfo(exception);
4335 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4339 InheritPerlException(exception,perl_exception);
4340 exception=DestroyExceptionInfo(exception);
4341 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4342 SvPOK_on(perl_exception);
4343 ST(0)=sv_2mortal(perl_exception);
4348 ###############################################################################
4356 ###############################################################################
4361 Image::Magick::Q16HDRI ref=NO_INIT
4372 color[MaxTextExtent];
4397 PERL_UNUSED_VAR(ref);
4398 PERL_UNUSED_VAR(ix);
4399 exception=AcquireExceptionInfo();
4400 perl_exception=newSVpv("",0);
4401 if (sv_isobject(ST(0)) == 0)
4403 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4407 reference=SvRV(ST(0));
4408 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4409 if (image == (Image *) NULL && !info)
4412 for (i=1; i < items; i++)
4414 attribute=(char *) SvPV(ST(i),na);
4421 if (LocaleCompare(attribute,"adjoin") == 0)
4424 s=newSViv((ssize_t) info->image_info->adjoin);
4425 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4428 if (LocaleCompare(attribute,"antialias") == 0)
4431 s=newSViv((ssize_t) info->image_info->antialias);
4432 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4435 if (LocaleCompare(attribute,"area") == 0)
4437 s=newSViv(GetMagickResource(AreaResource));
4438 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4441 if (LocaleCompare(attribute,"attenuate") == 0)
4446 value=GetImageProperty(image,attribute,exception);
4447 if (value != (const char *) NULL)
4449 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4452 if (LocaleCompare(attribute,"authenticate") == 0)
4459 option=GetImageOption(info->image_info,attribute);
4460 if (option != (const char *) NULL)
4461 s=newSVpv(option,0);
4463 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4466 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4473 if (LocaleCompare(attribute,"background") == 0)
4475 if (image == (Image *) NULL)
4477 (void) FormatLocaleString(color,MaxTextExtent,
4478 "%.20g,%.20g,%.20g,%.20g",image->background_color.red,
4479 image->background_color.green,image->background_color.blue,
4480 image->background_color.alpha);
4482 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4485 if (LocaleCompare(attribute,"base-columns") == 0)
4487 if (image != (Image *) NULL)
4488 s=newSViv((ssize_t) image->magick_columns);
4489 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4492 if (LocaleCompare(attribute,"base-filename") == 0)
4494 if (image != (Image *) NULL)
4495 s=newSVpv(image->magick_filename,0);
4496 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4499 if (LocaleCompare(attribute,"base-height") == 0)
4501 if (image != (Image *) NULL)
4502 s=newSViv((ssize_t) image->magick_rows);
4503 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4506 if (LocaleCompare(attribute,"base-rows") == 0)
4508 if (image != (Image *) NULL)
4509 s=newSViv((ssize_t) image->magick_rows);
4510 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4513 if (LocaleCompare(attribute,"base-width") == 0)
4515 if (image != (Image *) NULL)
4516 s=newSViv((ssize_t) image->magick_columns);
4517 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4520 if (LocaleCompare(attribute,"blue-primary") == 0)
4522 if (image == (Image *) NULL)
4524 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4525 image->chromaticity.blue_primary.x,
4526 image->chromaticity.blue_primary.y);
4528 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4531 if (LocaleCompare(attribute,"bordercolor") == 0)
4533 if (image == (Image *) NULL)
4535 (void) FormatLocaleString(color,MaxTextExtent,
4536 "%.20g,%.20g,%.20g,%.20g",image->border_color.red,
4537 image->border_color.green,image->border_color.blue,
4538 image->border_color.alpha);
4540 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4543 if (LocaleCompare(attribute,"bounding-box") == 0)
4546 geometry[MaxTextExtent];
4551 if (image == (Image *) NULL)
4553 page=GetImageBoundingBox(image,exception);
4554 (void) FormatLocaleString(geometry,MaxTextExtent,
4555 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4556 page.height,(double) page.x,(double) page.y);
4557 s=newSVpv(geometry,0);
4558 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4561 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4568 if (LocaleCompare(attribute,"class") == 0)
4570 if (image == (Image *) NULL)
4572 s=newSViv(image->storage_class);
4573 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4574 image->storage_class));
4576 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4579 if (LocaleCompare(attribute,"clip-mask") == 0)
4581 if (image != (Image *) NULL)
4590 if (image->mask == MagickFalse)
4591 ClipImage(image,exception);
4592 mask_image=GetImageMask(image,exception);
4593 if (mask_image != (Image *) NULL)
4595 AddImageToRegistry(sv,mask_image);
4596 s=sv_bless(newRV(sv),SvSTASH(reference));
4599 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4602 if (LocaleCompare(attribute,"clip-path") == 0)
4604 if (image != (Image *) NULL)
4613 if (image->mask != MagickFalse)
4614 ClipImage(image,exception);
4615 mask_image=GetImageMask(image,exception);
4616 if (mask_image != (Image *) NULL)
4618 AddImageToRegistry(sv,mask_image);
4619 s=sv_bless(newRV(sv),SvSTASH(reference));
4622 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4625 if (LocaleCompare(attribute,"compression") == 0)
4627 j=info ? info->image_info->compression : image ?
4628 image->compression : UndefinedCompression;
4630 if (info->image_info->compression == UndefinedCompression)
4631 j=image->compression;
4633 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4636 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4639 if (LocaleCompare(attribute,"colorspace") == 0)
4641 j=image ? image->colorspace : RGBColorspace;
4643 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4646 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4649 if (LocaleCompare(attribute,"colors") == 0)
4651 if (image != (Image *) NULL)
4652 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4654 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4657 if (LocaleNCompare(attribute,"colormap",8) == 0)
4662 if (image == (Image *) NULL || !image->colormap)
4665 items=sscanf(attribute,"%*[^[][%ld",&j);
4667 if (j > (ssize_t) image->colors)
4669 (void) FormatLocaleString(color,MaxTextExtent,
4670 "%.20g,%.20g,%.20g,%.20g",image->colormap[j].red,
4671 image->colormap[j].green,image->colormap[j].blue,
4672 image->colormap[j].alpha);
4674 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4677 if (LocaleCompare(attribute,"columns") == 0)
4679 if (image != (Image *) NULL)
4680 s=newSViv((ssize_t) image->columns);
4681 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4684 if (LocaleCompare(attribute,"comment") == 0)
4689 value=GetImageProperty(image,attribute,exception);
4690 if (value != (const char *) NULL)
4692 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4695 if (LocaleCompare(attribute,"copyright") == 0)
4697 s=newSVpv(GetMagickCopyright(),0);
4698 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4701 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4708 if (LocaleCompare(attribute,"density") == 0)
4711 geometry[MaxTextExtent];
4713 if (image == (Image *) NULL)
4715 (void) FormatLocaleString(geometry,MaxTextExtent,"%.15gx%.15g",
4716 image->resolution.x,image->resolution.y);
4717 s=newSVpv(geometry,0);
4718 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4721 if (LocaleCompare(attribute,"delay") == 0)
4723 if (image != (Image *) NULL)
4724 s=newSViv((ssize_t) image->delay);
4725 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4728 if (LocaleCompare(attribute,"depth") == 0)
4730 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4731 if (image != (Image *) NULL)
4732 s=newSViv((ssize_t) GetImageDepth(image,exception));
4733 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4736 if (LocaleCompare(attribute,"directory") == 0)
4738 if (image && image->directory)
4739 s=newSVpv(image->directory,0);
4740 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4743 if (LocaleCompare(attribute,"dispose") == 0)
4745 if (image == (Image *) NULL)
4748 s=newSViv(image->dispose);
4750 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
4752 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4755 if (LocaleCompare(attribute,"disk") == 0)
4757 s=newSViv(GetMagickResource(DiskResource));
4758 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4761 if (LocaleCompare(attribute,"dither") == 0)
4764 s=newSViv((ssize_t) info->image_info->dither);
4765 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4768 if (LocaleCompare(attribute,"display") == 0) /* same as server */
4770 if (info && info->image_info->server_name)
4771 s=newSVpv(info->image_info->server_name,0);
4772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4775 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4782 if (LocaleCompare(attribute,"elapsed-time") == 0)
4784 if (image != (Image *) NULL)
4785 s=newSVnv(GetElapsedTime(&image->timer));
4786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4789 if (LocaleCompare(attribute,"endian") == 0)
4791 j=info ? info->image_info->endian : image ? image->endian :
4794 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
4796 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4799 if (LocaleCompare(attribute,"error") == 0)
4801 if (image != (Image *) NULL)
4802 s=newSVnv(image->error.mean_error_per_pixel);
4803 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4806 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4813 if (LocaleCompare(attribute,"filesize") == 0)
4815 if (image != (Image *) NULL)
4816 s=newSViv((ssize_t) GetBlobSize(image));
4817 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4820 if (LocaleCompare(attribute,"filename") == 0)
4822 if (info && info->image_info->filename &&
4823 *info->image_info->filename)
4824 s=newSVpv(info->image_info->filename,0);
4825 if (image != (Image *) NULL)
4826 s=newSVpv(image->filename,0);
4827 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4830 if (LocaleCompare(attribute,"filter") == 0)
4832 s=image ? newSViv(image->filter) : newSViv(0);
4833 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
4836 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4839 if (LocaleCompare(attribute,"font") == 0)
4841 if (info && info->image_info->font)
4842 s=newSVpv(info->image_info->font,0);
4843 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4846 if (LocaleCompare(attribute,"foreground") == 0)
4848 if (LocaleCompare(attribute,"format") == 0)
4853 magick_info=(const MagickInfo *) NULL;
4854 if (info && (*info->image_info->magick != '\0'))
4855 magick_info=GetMagickInfo(info->image_info->magick,exception);
4856 if (image != (Image *) NULL)
4857 magick_info=GetMagickInfo(image->magick,exception);
4858 if ((magick_info != (const MagickInfo *) NULL) &&
4859 (*magick_info->description != '\0'))
4860 s=newSVpv((char *) magick_info->description,0);
4861 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4864 if (LocaleCompare(attribute,"fuzz") == 0)
4867 s=newSVnv(info->image_info->fuzz);
4868 if (image != (Image *) NULL)
4869 s=newSVnv(image->fuzz);
4870 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4873 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4880 if (LocaleCompare(attribute,"gamma") == 0)
4882 if (image != (Image *) NULL)
4883 s=newSVnv(image->gamma);
4884 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4887 if (LocaleCompare(attribute,"geometry") == 0)
4889 if (image && image->geometry)
4890 s=newSVpv(image->geometry,0);
4891 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4894 if (LocaleCompare(attribute,"gravity") == 0)
4896 s=image ? newSViv(image->gravity) : newSViv(0);
4897 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
4900 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4903 if (LocaleCompare(attribute,"green-primary") == 0)
4905 if (image == (Image *) NULL)
4907 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
4908 image->chromaticity.green_primary.x,
4909 image->chromaticity.green_primary.y);
4911 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4914 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4921 if (LocaleCompare(attribute,"height") == 0)
4923 if (image != (Image *) NULL)
4924 s=newSViv((ssize_t) image->rows);
4925 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4928 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4935 if (LocaleCompare(attribute,"icc") == 0)
4937 if (image != (Image *) NULL)
4942 profile=GetImageProfile(image,"icc");
4943 if (profile != (StringInfo *) NULL)
4944 s=newSVpv((const char *) GetStringInfoDatum(profile),
4945 GetStringInfoLength(profile));
4947 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4950 if (LocaleCompare(attribute,"icm") == 0)
4952 if (image != (Image *) NULL)
4957 profile=GetImageProfile(image,"icm");
4958 if (profile != (const StringInfo *) NULL)
4959 s=newSVpv((const char *) GetStringInfoDatum(profile),
4960 GetStringInfoLength(profile));
4962 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4965 if (LocaleCompare(attribute,"id") == 0)
4967 if (image != (Image *) NULL)
4978 (void) FormatLocaleString(key,MaxTextExtent,"%.20g\n",(double)
4980 status=SetImageRegistry(ImageRegistryType,key,image,
4985 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4988 if (LocaleNCompare(attribute,"index",5) == 0)
4991 name[MaxTextExtent];
5000 register const Quantum
5006 if (image == (Image *) NULL)
5008 if (image->storage_class != PseudoClass)
5012 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5014 image_view=AcquireVirtualCacheView(image,exception);
5015 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5016 if (p != (const Quantum *) NULL)
5018 (void) FormatLocaleString(name,MaxTextExtent,QuantumFormat,
5019 GetPixelIndex(image,p));
5021 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5023 image_view=DestroyCacheView(image_view);
5026 if (LocaleCompare(attribute,"iptc") == 0)
5028 if (image != (Image *) NULL)
5033 profile=GetImageProfile(image,"iptc");
5034 if (profile != (const StringInfo *) NULL)
5035 s=newSVpv((const char *) GetStringInfoDatum(profile),
5036 GetStringInfoLength(profile));
5038 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5041 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5043 if (image != (Image *) NULL)
5044 s=newSViv((ssize_t) image->iterations);
5045 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5048 if (LocaleCompare(attribute,"interlace") == 0)
5050 j=info ? info->image_info->interlace : image ? image->interlace :
5053 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5056 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5059 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5066 if (LocaleCompare(attribute,"label") == 0)
5071 if (image == (Image *) NULL)
5073 value=GetImageProperty(image,"Label",exception);
5074 if (value != (const char *) NULL)
5076 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5079 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5081 if (image != (Image *) NULL)
5082 s=newSViv((ssize_t) image->iterations);
5083 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5086 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5093 if (LocaleCompare(attribute,"magick") == 0)
5095 if (info && *info->image_info->magick)
5096 s=newSVpv(info->image_info->magick,0);
5097 if (image != (Image *) NULL)
5098 s=newSVpv(image->magick,0);
5099 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5102 if (LocaleCompare(attribute,"map") == 0)
5104 s=newSViv(GetMagickResource(MapResource));
5105 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5108 if (LocaleCompare(attribute,"maximum-error") == 0)
5110 if (image != (Image *) NULL)
5111 s=newSVnv(image->error.normalized_maximum_error);
5112 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5115 if (LocaleCompare(attribute,"memory") == 0)
5117 s=newSViv(GetMagickResource(MemoryResource));
5118 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5121 if (LocaleCompare(attribute,"mean-error") == 0)
5123 if (image != (Image *) NULL)
5124 s=newSVnv(image->error.normalized_mean_error);
5125 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5128 if (LocaleCompare(attribute,"mime") == 0)
5130 if (info && *info->image_info->magick)
5131 s=newSVpv(MagickToMime(info->image_info->magick),0);
5132 if (image != (Image *) NULL)
5133 s=newSVpv(MagickToMime(image->magick),0);
5134 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5137 if (LocaleCompare(attribute,"mattecolor") == 0)
5139 if (image == (Image *) NULL)
5141 (void) FormatLocaleString(color,MaxTextExtent,
5142 "%.20g,%.20g,%.20g,%.20g",image->matte_color.red,
5143 image->matte_color.green,image->matte_color.blue,
5144 image->matte_color.alpha);
5146 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5149 if (LocaleCompare(attribute,"matte") == 0)
5151 if (image != (Image *) NULL)
5152 s=newSViv((ssize_t) image->alpha_trait == BlendPixelTrait ?
5154 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5157 if (LocaleCompare(attribute,"mime") == 0)
5163 if (info && *info->image_info->magick)
5164 magick=info->image_info->magick;
5165 if (image != (Image *) NULL)
5166 magick=image->magick;
5172 mime=MagickToMime(magick);
5174 mime=(char *) RelinquishMagickMemory(mime);
5176 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5179 if (LocaleCompare(attribute,"monochrome") == 0)
5181 if (image == (Image *) NULL)
5183 j=info ? info->image_info->monochrome :
5184 IsImageMonochrome(image,exception);
5186 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5189 if (LocaleCompare(attribute,"montage") == 0)
5191 if (image && image->montage)
5192 s=newSVpv(image->montage,0);
5193 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5196 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5203 if (LocaleCompare(attribute,"orientation") == 0)
5205 j=info ? info->image_info->orientation : image ?
5206 image->orientation : UndefinedOrientation;
5208 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5211 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5214 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5221 if (LocaleCompare(attribute,"page") == 0)
5223 if (info && info->image_info->page)
5224 s=newSVpv(info->image_info->page,0);
5225 if (image != (Image *) NULL)
5228 geometry[MaxTextExtent];
5230 (void) FormatLocaleString(geometry,MaxTextExtent,
5231 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5232 (double) image->page.height,(double) image->page.x,(double)
5234 s=newSVpv(geometry,0);
5236 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5239 if (LocaleCompare(attribute,"page.x") == 0)
5241 if (image != (Image *) NULL)
5242 s=newSViv((ssize_t) image->page.x);
5243 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5246 if (LocaleCompare(attribute,"page.y") == 0)
5248 if (image != (Image *) NULL)
5249 s=newSViv((ssize_t) image->page.y);
5250 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5253 if (LocaleNCompare(attribute,"pixel",5) == 0)
5256 tuple[MaxTextExtent];
5265 register const Quantum
5268 if (image == (Image *) NULL)
5272 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5274 p=GetVirtualPixels(image,x,y,1,1,exception);
5275 if (image->colorspace != CMYKColorspace)
5276 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5277 QuantumFormat "," QuantumFormat "," QuantumFormat,
5278 GetPixelRed(image,p),GetPixelGreen(image,p),
5279 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5281 (void) FormatLocaleString(tuple,MaxTextExtent,QuantumFormat ","
5282 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5283 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5284 GetPixelBlue(image,p),GetPixelBlack(image,p),
5285 GetPixelAlpha(image,p));
5287 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5290 if (LocaleCompare(attribute,"pointsize") == 0)
5293 s=newSViv((ssize_t) info->image_info->pointsize);
5294 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5297 if (LocaleCompare(attribute,"preview") == 0)
5299 s=newSViv(info->image_info->preview_type);
5300 (void) sv_setpv(s,CommandOptionToMnemonic(MagickPreviewOptions,
5301 info->image_info->preview_type));
5303 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5306 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5313 if (LocaleCompare(attribute,"quality") == 0)
5316 s=newSViv((ssize_t) info->image_info->quality);
5317 if (image != (Image *) NULL)
5318 s=newSViv((ssize_t) image->quality);
5319 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5322 if (LocaleCompare(attribute,"quantum") == 0)
5325 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5326 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5329 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5336 if (LocaleCompare(attribute,"rendering-intent") == 0)
5338 s=newSViv(image->rendering_intent);
5339 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5340 image->rendering_intent));
5342 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5345 if (LocaleCompare(attribute,"red-primary") == 0)
5347 if (image == (Image *) NULL)
5349 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5350 image->chromaticity.red_primary.x,
5351 image->chromaticity.red_primary.y);
5353 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5356 if (LocaleCompare(attribute,"rows") == 0)
5358 if (image != (Image *) NULL)
5359 s=newSViv((ssize_t) image->rows);
5360 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5363 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5370 if (LocaleCompare(attribute,"sampling-factor") == 0)
5372 if (info && info->image_info->sampling_factor)
5373 s=newSVpv(info->image_info->sampling_factor,0);
5374 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5377 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5379 if (info && info->image_info->server_name)
5380 s=newSVpv(info->image_info->server_name,0);
5381 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5384 if (LocaleCompare(attribute,"size") == 0)
5386 if (info && info->image_info->size)
5387 s=newSVpv(info->image_info->size,0);
5388 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5391 if (LocaleCompare(attribute,"scene") == 0)
5393 if (image != (Image *) NULL)
5394 s=newSViv((ssize_t) image->scene);
5395 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5398 if (LocaleCompare(attribute,"scenes") == 0)
5400 if (image != (Image *) NULL)
5401 s=newSViv((ssize_t) info->image_info->number_scenes);
5402 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5405 if (LocaleCompare(attribute,"signature") == 0)
5410 if (image == (Image *) NULL)
5412 (void) SignatureImage(image,exception);
5413 value=GetImageProperty(image,"Signature",exception);
5414 if (value != (const char *) NULL)
5416 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5419 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5426 if (LocaleCompare(attribute,"taint") == 0)
5428 if (image != (Image *) NULL)
5429 s=newSViv((ssize_t) IsTaintImage(image));
5430 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5433 if (LocaleCompare(attribute,"texture") == 0)
5435 if (info && info->image_info->texture)
5436 s=newSVpv(info->image_info->texture,0);
5437 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5440 if (LocaleCompare(attribute,"total-ink-density") == 0)
5442 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5443 if (image != (Image *) NULL)
5444 s=newSVnv(GetImageTotalInkDensity(image,exception));
5445 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5448 if (LocaleCompare(attribute,"transparent-color") == 0)
5450 if (image == (Image *) NULL)
5452 (void) FormatLocaleString(color,MaxTextExtent,
5453 "%.20g,%.20g,%.20g,%.20g",image->transparent_color.red,
5454 image->transparent_color.green,image->transparent_color.blue,
5455 image->transparent_color.alpha);
5457 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5460 if (LocaleCompare(attribute,"type") == 0)
5462 if (image == (Image *) NULL)
5464 j=(ssize_t) GetImageType(image,exception);
5466 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5468 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5471 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5478 if (LocaleCompare(attribute,"units") == 0)
5480 j=info ? info->image_info->units : image ? image->units :
5481 UndefinedResolution;
5482 if (info && (info->image_info->units == UndefinedResolution))
5485 if (j == UndefinedResolution)
5486 s=newSVpv("undefined units",0);
5488 if (j == PixelsPerInchResolution)
5489 s=newSVpv("pixels / inch",0);
5491 s=newSVpv("pixels / centimeter",0);
5492 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5495 if (LocaleCompare(attribute,"user-time") == 0)
5497 if (image != (Image *) NULL)
5498 s=newSVnv(GetUserTime(&image->timer));
5499 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5502 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5509 if (LocaleCompare(attribute,"verbose") == 0)
5512 s=newSViv((ssize_t) info->image_info->verbose);
5513 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5516 if (LocaleCompare(attribute,"version") == 0)
5518 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5519 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5522 if (LocaleCompare(attribute,"view") == 0)
5524 if (info && info->image_info->view)
5525 s=newSVpv(info->image_info->view,0);
5526 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5529 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5531 if (image == (Image *) NULL)
5533 j=(ssize_t) GetImageVirtualPixelMethod(image);
5535 (void) sv_setpv(s,CommandOptionToMnemonic(
5536 MagickVirtualPixelOptions,j));
5538 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5548 if (LocaleCompare(attribute,"white-point") == 0)
5550 if (image == (Image *) NULL)
5552 (void) FormatLocaleString(color,MaxTextExtent,"%.15g,%.15g",
5553 image->chromaticity.white_point.x,
5554 image->chromaticity.white_point.y);
5556 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5559 if (LocaleCompare(attribute,"width") == 0)
5561 if (image != (Image *) NULL)
5562 s=newSViv((ssize_t) image->columns);
5563 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5566 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5573 if (LocaleCompare(attribute,"x-resolution") == 0)
5575 if (image != (Image *) NULL)
5576 s=newSVnv(image->resolution.x);
5577 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5580 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5587 if (LocaleCompare(attribute,"y-resolution") == 0)
5589 if (image != (Image *) NULL)
5590 s=newSVnv(image->resolution.y);
5591 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5594 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5601 if (image == (Image *) NULL)
5602 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5606 value=GetImageProperty(image,attribute,exception);
5607 if (value != (const char *) NULL)
5610 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5613 if (*attribute != '%')
5614 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5621 meta=InterpretImageProperties(info ? info->image_info :
5622 (ImageInfo *) NULL,image,attribute,exception);
5624 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5625 meta=(char *) RelinquishMagickMemory(meta);
5629 exception=DestroyExceptionInfo(exception);
5630 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5634 ###############################################################################
5638 # G e t A u t h e n t i c P i x e l s #
5642 ###############################################################################
5646 GetAuthenticPixels(ref,...)
5647 Image::Magick::Q16HDRI ref = NO_INIT
5649 getauthenticpixels = 1
5679 PERL_UNUSED_VAR(ref);
5680 PERL_UNUSED_VAR(ix);
5681 exception=AcquireExceptionInfo();
5682 perl_exception=newSVpv("",0);
5683 if (sv_isobject(ST(0)) == 0)
5685 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5689 reference=SvRV(ST(0));
5691 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5692 if (image == (Image *) NULL)
5694 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5701 region.width=image->columns;
5704 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5705 for (i=2; i < items; i+=2)
5707 attribute=(char *) SvPV(ST(i-1),na);
5713 if (LocaleCompare(attribute,"geometry") == 0)
5715 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5718 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5725 if (LocaleCompare(attribute,"height") == 0)
5727 region.height=SvIV(ST(i));
5730 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5737 if (LocaleCompare(attribute,"x") == 0)
5739 region.x=SvIV(ST(i));
5742 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5749 if (LocaleCompare(attribute,"y") == 0)
5751 region.y=SvIV(ST(i));
5754 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5761 if (LocaleCompare(attribute,"width") == 0)
5763 region.width=SvIV(ST(i));
5766 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5772 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
5773 region.height,exception);
5774 if (blob != (void *) NULL)
5778 InheritPerlException(exception,perl_exception);
5779 exception=DestroyExceptionInfo(exception);
5780 SvREFCNT_dec(perl_exception); /* throw away all errors */
5789 ###############################################################################
5793 # G e t V i r t u a l P i x e l s #
5797 ###############################################################################
5801 GetVirtualPixels(ref,...)
5802 Image::Magick::Q16HDRI ref = NO_INIT
5804 getvirtualpixels = 1
5805 AcquireImagePixels = 2
5806 acquireimagepixels = 3
5834 PERL_UNUSED_VAR(ref);
5835 PERL_UNUSED_VAR(ix);
5836 exception=AcquireExceptionInfo();
5837 perl_exception=newSVpv("",0);
5838 if (sv_isobject(ST(0)) == 0)
5840 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5844 reference=SvRV(ST(0));
5846 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5847 if (image == (Image *) NULL)
5849 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5856 region.width=image->columns;
5859 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5860 for (i=2; i < items; i+=2)
5862 attribute=(char *) SvPV(ST(i-1),na);
5868 if (LocaleCompare(attribute,"geometry") == 0)
5870 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5873 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5880 if (LocaleCompare(attribute,"height") == 0)
5882 region.height=SvIV(ST(i));
5885 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5892 if (LocaleCompare(attribute,"x") == 0)
5894 region.x=SvIV(ST(i));
5897 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5904 if (LocaleCompare(attribute,"y") == 0)
5906 region.y=SvIV(ST(i));
5909 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5916 if (LocaleCompare(attribute,"width") == 0)
5918 region.width=SvIV(ST(i));
5921 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5927 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
5928 region.height,exception);
5929 if (blob != (void *) NULL)
5933 InheritPerlException(exception,perl_exception);
5934 exception=DestroyExceptionInfo(exception);
5935 SvREFCNT_dec(perl_exception); /* throw away all errors */
5938 RETVAL = (void *) blob;
5944 ###############################################################################
5948 # G e t A u t h e n t i c M e t a c o n t e n t #
5952 ###############################################################################
5956 GetAuthenticMetacontent(ref,...)
5957 Image::Magick::Q16HDRI ref = NO_INIT
5959 getauthenticmetacontent = 1
5980 PERL_UNUSED_VAR(ref);
5981 PERL_UNUSED_VAR(ix);
5982 exception=AcquireExceptionInfo();
5983 perl_exception=newSVpv("",0);
5984 if (sv_isobject(ST(0)) == 0)
5986 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5990 reference=SvRV(ST(0));
5992 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5993 if (image == (Image *) NULL)
5995 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6000 blob=(void *) GetAuthenticMetacontent(image);
6001 if (blob != (void *) NULL)
6005 InheritPerlException(exception,perl_exception);
6006 exception=DestroyExceptionInfo(exception);
6007 SvREFCNT_dec(perl_exception); /* throw away all errors */
6016 ###############################################################################
6020 # G e t V i r t u a l M e t a c o n t e n t #
6024 ###############################################################################
6028 GetVirtualMetacontent(ref,...)
6029 Image::Magick::Q16HDRI ref = NO_INIT
6031 getvirtualmetacontent = 1
6050 PERL_UNUSED_VAR(ref);
6051 PERL_UNUSED_VAR(ix);
6052 exception=AcquireExceptionInfo();
6053 perl_exception=newSVpv("",0);
6054 if (sv_isobject(ST(0)) == 0)
6056 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6060 reference=SvRV(ST(0));
6062 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6063 if (image == (Image *) NULL)
6065 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6070 blob=(void *) GetVirtualMetacontent(image);
6071 if (blob != (void *) NULL)
6075 InheritPerlException(exception,perl_exception);
6076 exception=DestroyExceptionInfo(exception);
6077 SvREFCNT_dec(perl_exception); /* throw away all errors */
6086 ###############################################################################
6090 # H i s t o g r a m #
6094 ###############################################################################
6099 Image::Magick::Q16HDRI ref=NO_INIT
6110 message[MaxTextExtent];
6137 PERL_UNUSED_VAR(ref);
6138 PERL_UNUSED_VAR(ix);
6139 exception=AcquireExceptionInfo();
6140 perl_exception=newSVpv("",0);
6142 if (sv_isobject(ST(0)) == 0)
6144 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6148 reference=SvRV(ST(0));
6151 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6152 if (image == (Image *) NULL)
6154 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6158 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
6160 for ( ; image; image=image->next)
6162 histogram=GetImageHistogram(image,&number_colors,exception);
6163 if (histogram == (PixelInfo *) NULL)
6165 count+=(ssize_t) number_colors;
6167 for (i=0; i < (ssize_t) number_colors; i++)
6169 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6171 PUSHs(sv_2mortal(newSVpv(message,0)));
6172 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6173 histogram[i].green);
6174 PUSHs(sv_2mortal(newSVpv(message,0)));
6175 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6177 PUSHs(sv_2mortal(newSVpv(message,0)));
6178 if (image->colorspace == CMYKColorspace)
6180 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6181 histogram[i].black);
6182 PUSHs(sv_2mortal(newSVpv(message,0)));
6184 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",
6185 histogram[i].alpha);
6186 PUSHs(sv_2mortal(newSVpv(message,0)));
6187 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
6188 histogram[i].count);
6189 PUSHs(sv_2mortal(newSVpv(message,0)));
6191 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6195 InheritPerlException(exception,perl_exception);
6196 exception=DestroyExceptionInfo(exception);
6197 SvREFCNT_dec(perl_exception);
6201 ###############################################################################
6209 ###############################################################################
6214 Image::Magick::Q16HDRI ref=NO_INIT
6238 register const Quantum
6252 *reference; /* reference is the SV* of ref=SvIV(reference) */
6254 PERL_UNUSED_VAR(ref);
6255 PERL_UNUSED_VAR(ix);
6256 exception=AcquireExceptionInfo();
6257 perl_exception=newSVpv("",0);
6258 reference=SvRV(ST(0));
6259 av=(AV *) reference;
6260 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6262 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6263 if (image == (Image *) NULL)
6265 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6269 normalize=MagickTrue;
6272 region.width=image->columns;
6275 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6276 for (i=2; i < items; i+=2)
6278 attribute=(char *) SvPV(ST(i-1),na);
6284 if (LocaleCompare(attribute,"channel") == 0)
6289 option=ParseChannelOption(SvPV(ST(i),na));
6292 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6296 SetPixelChannelMask(image,(ChannelType) option);
6299 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6306 if (LocaleCompare(attribute,"geometry") == 0)
6308 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6311 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6318 if (LocaleCompare(attribute,"normalize") == 0)
6320 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6324 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6328 normalize=option != 0 ? MagickTrue : MagickFalse;
6331 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6338 if (LocaleCompare(attribute,"x") == 0)
6340 region.x=SvIV(ST(i));
6343 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6350 if (LocaleCompare(attribute,"y") == 0)
6352 region.y=SvIV(ST(i));
6355 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6361 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6367 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6368 if (p == (const Quantum *) NULL)
6376 if (normalize != MagickFalse)
6377 scale=1.0/QuantumRange;
6378 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6379 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6380 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6381 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6382 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6383 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6384 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6385 (image->colorspace == CMYKColorspace))
6386 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6387 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6388 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6392 InheritPerlException(exception,perl_exception);
6393 exception=DestroyExceptionInfo(exception);
6394 SvREFCNT_dec(perl_exception);
6398 ###############################################################################
6402 # G e t P i x e l s #
6406 ###############################################################################
6411 Image::Magick::Q16HDRI ref=NO_INIT
6450 *reference; /* reference is the SV* of ref=SvIV(reference) */
6452 PERL_UNUSED_VAR(ref);
6453 PERL_UNUSED_VAR(ix);
6454 exception=AcquireExceptionInfo();
6455 perl_exception=newSVpv("",0);
6456 reference=SvRV(ST(0));
6457 av=(AV *) reference;
6458 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6460 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6461 if (image == (Image *) NULL)
6463 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6468 if (image->alpha_trait == BlendPixelTrait)
6470 if (image->colorspace == CMYKColorspace)
6473 if (image->alpha_trait == BlendPixelTrait)
6476 normalize=MagickFalse;
6479 region.width=image->columns;
6482 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6483 for (i=2; i < items; i+=2)
6485 attribute=(char *) SvPV(ST(i-1),na);
6491 if (LocaleCompare(attribute,"geometry") == 0)
6493 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6496 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6503 if (LocaleCompare(attribute,"height") == 0)
6505 region.height=SvIV(ST(i));
6508 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6515 if (LocaleCompare(attribute,"map") == 0)
6520 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6527 if (LocaleCompare(attribute,"normalize") == 0)
6529 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6533 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6537 normalize=option != 0 ? MagickTrue : MagickFalse;
6540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6547 if (LocaleCompare(attribute,"width") == 0)
6549 region.width=SvIV(ST(i));
6552 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6559 if (LocaleCompare(attribute,"x") == 0)
6561 region.x=SvIV(ST(i));
6564 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6571 if (LocaleCompare(attribute,"y") == 0)
6573 region.y=SvIV(ST(i));
6576 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6582 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6588 if (normalize != MagickFalse)
6593 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6594 region.height*sizeof(*pixels));
6595 if (pixels == (float *) NULL)
6597 ThrowPerlException(exception,ResourceLimitError,
6598 "MemoryAllocationFailed",PackageName);
6601 status=ExportImagePixels(image,region.x,region.y,region.width,
6602 region.height,map,FloatPixel,pixels,exception);
6603 if (status == MagickFalse)
6607 EXTEND(sp,strlen(map)*region.width*region.height);
6608 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6609 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6611 pixels=(float *) RelinquishMagickMemory(pixels);
6618 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6619 region.height*sizeof(*pixels));
6620 if (pixels == (Quantum *) NULL)
6622 ThrowPerlException(exception,ResourceLimitError,
6623 "MemoryAllocationFailed",PackageName);
6626 status=ExportImagePixels(image,region.x,region.y,region.width,
6627 region.height,map,QuantumPixel,pixels,exception);
6628 if (status == MagickFalse)
6632 EXTEND(sp,strlen(map)*region.width*region.height);
6633 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6634 PUSHs(sv_2mortal(newSViv(pixels[i])));
6636 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6640 InheritPerlException(exception,perl_exception);
6641 exception=DestroyExceptionInfo(exception);
6642 SvREFCNT_dec(perl_exception);
6646 ###############################################################################
6650 # I m a g e T o B l o b #
6654 ###############################################################################
6658 ImageToBlob(ref,...)
6659 Image::Magick::Q16HDRI ref=NO_INIT
6668 filename[MaxTextExtent];
6697 PERL_UNUSED_VAR(ref);
6698 PERL_UNUSED_VAR(ix);
6699 exception=AcquireExceptionInfo();
6700 perl_exception=newSVpv("",0);
6701 package_info=(struct PackageInfo *) NULL;
6702 if (sv_isobject(ST(0)) == 0)
6704 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6708 reference=SvRV(ST(0));
6709 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6710 if (image == (Image *) NULL)
6712 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6716 package_info=ClonePackageInfo(info,exception);
6717 for (i=2; i < items; i+=2)
6718 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6719 (void) CopyMagickString(filename,package_info->image_info->filename,
6722 for (next=image; next; next=next->next)
6724 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
6725 next->scene=scene++;
6727 SetImageInfo(package_info->image_info,(unsigned int)
6728 GetImageListLength(image),exception);
6729 EXTEND(sp,(ssize_t) GetImageListLength(image));
6730 for ( ; image; image=image->next)
6733 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6734 if (blob != (char *) NULL)
6736 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6737 blob=(unsigned char *) RelinquishMagickMemory(blob);
6739 if (package_info->image_info->adjoin)
6744 if (package_info != (struct PackageInfo *) NULL)
6745 DestroyPackageInfo(package_info);
6746 InheritPerlException(exception,perl_exception);
6747 exception=DestroyExceptionInfo(exception);
6748 SvREFCNT_dec(perl_exception); /* throw away all errors */
6752 ###############################################################################
6760 ###############################################################################
6765 Image::Magick::Q16HDRI ref=NO_INIT
6769 OptimizeImageLayers = 3
6771 optimizeimagelayers = 5
6813 PERL_UNUSED_VAR(ref);
6814 PERL_UNUSED_VAR(ix);
6815 exception=AcquireExceptionInfo();
6816 perl_exception=newSVpv("",0);
6818 if (sv_isobject(ST(0)) == 0)
6820 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6824 reference=SvRV(ST(0));
6825 hv=SvSTASH(reference);
6827 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
6829 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6830 if (image == (Image *) NULL)
6832 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6836 compose=image->compose;
6837 method=OptimizeLayer;
6838 for (i=2; i < items; i+=2)
6840 attribute=(char *) SvPV(ST(i-1),na);
6846 if (LocaleCompare(attribute,"compose") == 0)
6848 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
6849 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
6852 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6856 compose=(CompositeOperator) sp;
6859 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6866 if (LocaleCompare(attribute,"method") == 0)
6868 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
6872 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6876 method=(LayerMethod) option;
6879 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6885 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6891 layers=(Image *) NULL;
6894 case CompareAnyLayer:
6895 case CompareClearLayer:
6896 case CompareOverlayLayer:
6899 layers=CompareImagesLayers(image,method,exception);
6906 layers=MergeImageLayers(image,method,exception);
6911 layers=DisposeImages(image,exception);
6914 case OptimizeImageLayer:
6916 layers=OptimizeImageLayers(image,exception);
6919 case OptimizePlusLayer:
6921 layers=OptimizePlusImageLayers(image,exception);
6924 case OptimizeTransLayer:
6926 OptimizeImageTransparency(image,exception);
6929 case RemoveDupsLayer:
6931 RemoveDuplicateLayers(&image,exception);
6934 case RemoveZeroLayer:
6936 RemoveZeroDelayLayers(&image,exception);
6945 General Purpose, GIF Animation Optimizer.
6947 layers=CoalesceImages(image,exception);
6948 if (layers == (Image *) NULL)
6951 layers=OptimizeImageLayers(image,exception);
6952 if (layers == (Image *) NULL)
6954 image=DestroyImageList(image);
6956 layers=(Image *) NULL;
6957 OptimizeImageTransparency(image,exception);
6958 quantize_info=AcquireQuantizeInfo(info->image_info);
6959 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
6960 quantize_info=DestroyQuantizeInfo(quantize_info);
6963 case CompositeLayer:
6972 Split image sequence at the first 'NULL:' image.
6975 while (source != (Image *) NULL)
6977 source=GetNextImageInList(source);
6978 if ((source != (Image *) NULL) &&
6979 (LocaleCompare(source->magick,"NULL") == 0))
6982 if (source != (Image *) NULL)
6984 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
6985 (GetNextImageInList(source) == (Image *) NULL))
6986 source=(Image *) NULL;
6990 Separate the two lists, junk the null: image.
6992 source=SplitImageList(source->previous);
6993 DeleteImageFromList(&source);
6996 if (source == (Image *) NULL)
6998 (void) ThrowMagickException(exception,GetMagickModule(),
6999 OptionError,"MissingNullSeparator","layers Composite");
7003 Adjust offset with gravity and virtual canvas.
7005 SetGeometry(image,&geometry);
7006 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7007 geometry.width=source->page.width != 0 ? source->page.width :
7009 geometry.height=source->page.height != 0 ? source->page.height :
7011 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7012 image->columns,image->page.height != 0 ? image->page.height :
7013 image->rows,image->gravity,&geometry);
7014 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7015 source=DestroyImageList(source);
7019 if (layers != (Image *) NULL)
7021 if (image == (Image *) NULL)
7023 for ( ; image; image=image->next)
7025 AddImageToRegistry(sv,image);
7027 av_push(av,sv_bless(rv,hv));
7030 exception=DestroyExceptionInfo(exception);
7032 SvREFCNT_dec(perl_exception);
7036 InheritPerlException(exception,perl_exception);
7037 exception=DestroyExceptionInfo(exception);
7038 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7039 SvPOK_on(perl_exception);
7040 ST(0)=sv_2mortal(perl_exception);
7045 ###############################################################################
7049 # M a g i c k T o M i m e #
7053 ###############################################################################
7057 MagickToMime(ref,name)
7058 Image::Magick::Q16HDRI ref=NO_INIT
7067 PERL_UNUSED_VAR(ref);
7068 PERL_UNUSED_VAR(ix);
7069 mime=MagickToMime(name);
7070 RETVAL=newSVpv(mime,0);
7071 mime=(char *) RelinquishMagickMemory(mime);
7077 ###############################################################################
7085 ###############################################################################
7090 Image::Magick::Q16HDRI ref=NO_INIT
7127 MedianConvolveImage = 36
7133 ReduceNoiseImage = 42
7159 ColorFloodfillImage= 68
7165 CycleColormapImage = 74
7175 MatteFloodfillImage= 84
7183 NumberColorsImage = 92
7193 SignatureImage = 102
7203 TransparentImage = 112
7205 ThresholdImage = 114
7219 DeconstructImage = 130
7221 GaussianBlurImage = 132
7227 UnsharpMaskImage = 138
7229 MotionBlurImage = 140
7231 OrderedDitherImage = 142
7238 AffineTransform = 149
7239 AffineTransformImage = 150
7241 DifferenceImage = 152
7242 AdaptiveThreshold = 153
7243 AdaptiveThresholdImage = 154
7248 BlackThreshold = 159
7249 BlackThresholdImage= 160
7250 WhiteThreshold = 161
7251 WhiteThresholdImage= 162
7253 RadialBlurImage = 164
7255 ThumbnailImage = 166
7265 PosterizeImage = 176
7271 SepiaToneImage = 182
7272 SigmoidalContrast = 183
7273 SigmoidalContrastImage = 184
7278 ContrastStretch = 189
7279 ContrastStretchImage = 190
7284 AdaptiveSharpen = 195
7285 AdaptiveSharpenImage = 196
7287 TransposeImage = 198
7289 TransverseImage = 200
7291 AutoOrientImage = 202
7293 AdaptiveBlurImage = 204
7297 UniqueColorsImage = 208
7298 AdaptiveResize = 209
7299 AdaptiveResizeImage= 210
7303 LinearStretchImage = 214
7305 ColorMatrixImage = 216
7310 FloodfillPaint = 221
7311 FloodfillPaintImage= 222
7317 LiquidRescaleImage = 228
7327 SparseColorImage = 238
7331 SelectiveBlurImage = 242
7335 BlueShiftImage = 246
7336 ForwardFourierTransform = 247
7337 ForwardFourierTransformImage = 248
7338 InverseFourierTransform = 249
7339 InverseFourierTransformImage = 250
7340 ColorDecisionList = 251
7341 ColorDecisionListImage = 252
7343 AutoGammaImage = 254
7345 AutoLevelImage = 256
7347 LevelImageColors = 258
7350 BrightnessContrast = 261
7351 BrightnessContrastImage = 262
7353 MorphologyImage = 264
7359 StatisticImage = 270
7361 PerceptibleImage = 272
7372 attribute_flag[MaxArguments],
7373 message[MaxTextExtent];
7434 argument_list[MaxArguments];
7436 PERL_UNUSED_VAR(ref);
7437 PERL_UNUSED_VAR(ix);
7438 exception=AcquireExceptionInfo();
7439 perl_exception=newSVpv("",0);
7440 reference_vector=NULL;
7444 if (sv_isobject(ST(0)) == 0)
7446 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7450 reference=SvRV(ST(0));
7451 region_info.width=0;
7452 region_info.height=0;
7455 region_image=(Image *) NULL;
7456 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7457 if (ix && (ix != 666))
7460 Called as Method(...)
7463 rp=(&Methods[ix-1]);
7469 Called as Mogrify("Method",...)
7471 attribute=(char *) SvPV(ST(1),na);
7474 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7475 attribute=(char *) SvPV(ST(2),na);
7478 for (rp=Methods; ; rp++)
7480 if (rp >= EndOf(Methods))
7482 ThrowPerlException(exception,OptionError,
7483 "UnrecognizedPerlMagickMethod",attribute);
7486 if (strEQcase(attribute,rp->name))
7492 if (image == (Image *) NULL)
7494 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7497 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7498 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7499 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7516 pp=(Arguments *) NULL;
7524 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7526 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7528 if (strEQcase(attribute,qq->method) > ssize_test)
7531 ssize_test=strEQcase(attribute,qq->method);
7534 if (pp == (Arguments *) NULL)
7536 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7538 goto continue_outer_loop;
7540 al=(&argument_list[pp-rp->arguments]);
7543 case ArrayReference:
7545 if (SvTYPE(sv) != SVt_RV)
7547 (void) FormatLocaleString(message,MaxTextExtent,
7548 "invalid %.60s value",pp->method);
7549 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7550 goto continue_outer_loop;
7552 al->array_reference=SvRV(sv);
7557 al->real_reference=SvNV(sv);
7562 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7565 case ImageReference:
7567 if (!sv_isobject(sv) ||
7568 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7569 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7571 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7577 case IntegerReference:
7579 al->integer_reference=SvIV(sv);
7582 case StringReference:
7584 al->string_reference=(char *) SvPV(sv,al->length);
7585 if (sv_isobject(sv))
7586 al->image_reference=SetupList(aTHX_ SvRV(sv),
7587 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7593 Is a string; look up name.
7595 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7597 al->string_reference=(char *) SvPV(sv,al->length);
7598 al->integer_reference=(-1);
7601 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7602 MagickFalse,SvPV(sv,na));
7603 if (pp->type == MagickChannelOptions)
7604 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7605 if ((al->integer_reference < 0) && ((al->integer_reference=SvIV(sv)) <= 0))
7607 (void) FormatLocaleString(message,MaxTextExtent,
7608 "invalid %.60s value",pp->method);
7609 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7610 goto continue_outer_loop;
7615 attribute_flag[pp-rp->arguments]++;
7616 continue_outer_loop: ;
7618 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7619 pv=reference_vector;
7620 SetGeometryInfo(&geometry_info);
7621 channel=DefaultChannels;
7622 for (next=image; next; next=next->next)
7625 SetGeometry(image,&geometry);
7626 if ((region_info.width*region_info.height) != 0)
7629 image=CropImage(image,®ion_info,exception);
7635 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double) ix);
7636 ThrowPerlException(exception,OptionError,
7637 "UnrecognizedPerlMagickMethod",message);
7640 case 1: /* Comment */
7642 if (attribute_flag[0] == 0)
7643 argument_list[0].string_reference=(char *) NULL;
7644 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7645 info ? info->image_info : (ImageInfo *) NULL,image,
7646 argument_list[0].string_reference,exception),exception);
7651 if (attribute_flag[0] == 0)
7652 argument_list[0].string_reference=(char *) NULL;
7653 (void) SetImageProperty(image,"label",InterpretImageProperties(
7654 info ? info->image_info : (ImageInfo *) NULL,image,
7655 argument_list[0].string_reference,exception),exception);
7658 case 3: /* AddNoise */
7663 if (attribute_flag[0] == 0)
7664 argument_list[0].integer_reference=UniformNoise;
7666 if (attribute_flag[1] != 0)
7667 attenuate=argument_list[1].real_reference;
7668 if (attribute_flag[2] != 0)
7669 channel=(ChannelType) argument_list[2].integer_reference;
7670 channel_mask=SetImageChannelMask(image,channel);
7671 image=AddNoiseImage(image,(NoiseType)
7672 argument_list[0].integer_reference,attenuate,exception);
7673 if (image != (Image *) NULL)
7674 (void) SetImageChannelMask(image,channel_mask);
7677 case 4: /* Colorize */
7682 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
7683 0,0,&target,exception);
7684 if (attribute_flag[0] != 0)
7685 (void) QueryColorCompliance(argument_list[0].string_reference,
7686 AllCompliance,&target,exception);
7687 if (attribute_flag[1] == 0)
7688 argument_list[1].string_reference="100%";
7689 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7693 case 5: /* Border */
7700 if (attribute_flag[0] != 0)
7701 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7702 &geometry,exception);
7703 if (attribute_flag[1] != 0)
7704 geometry.width=argument_list[1].integer_reference;
7705 if (attribute_flag[2] != 0)
7706 geometry.height=argument_list[2].integer_reference;
7707 if (attribute_flag[3] != 0)
7708 QueryColorCompliance(argument_list[3].string_reference,
7709 AllCompliance,&image->border_color,exception);
7710 if (attribute_flag[4] != 0)
7711 QueryColorCompliance(argument_list[4].string_reference,
7712 AllCompliance,&image->border_color,exception);
7713 if (attribute_flag[5] != 0)
7714 QueryColorCompliance(argument_list[5].string_reference,
7715 AllCompliance,&image->border_color,exception);
7716 compose=image->compose;
7717 if (attribute_flag[6] != 0)
7718 compose=(CompositeOperator) argument_list[6].integer_reference;
7719 image=BorderImage(image,&geometry,compose,exception);
7724 if (attribute_flag[0] != 0)
7726 flags=ParseGeometry(argument_list[0].string_reference,
7728 if ((flags & SigmaValue) == 0)
7729 geometry_info.sigma=1.0;
7731 if (attribute_flag[1] != 0)
7732 geometry_info.rho=argument_list[1].real_reference;
7733 if (attribute_flag[2] != 0)
7734 geometry_info.sigma=argument_list[2].real_reference;
7735 if (attribute_flag[3] != 0)
7736 channel=(ChannelType) argument_list[3].integer_reference;
7737 channel_mask=SetImageChannelMask(image,channel);
7738 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
7740 if (image != (Image *) NULL)
7741 (void) SetImageChannelMask(image,channel_mask);
7746 if (attribute_flag[0] != 0)
7747 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7748 &geometry,exception);
7749 if (attribute_flag[1] != 0)
7750 geometry.width=argument_list[1].integer_reference;
7751 if (attribute_flag[2] != 0)
7752 geometry.height=argument_list[2].integer_reference;
7753 if (attribute_flag[3] != 0)
7754 geometry.x=argument_list[3].integer_reference;
7755 if (attribute_flag[4] != 0)
7756 geometry.y=argument_list[4].integer_reference;
7757 image=ChopImage(image,&geometry,exception);
7762 if (attribute_flag[6] != 0)
7763 image->gravity=(GravityType) argument_list[6].integer_reference;
7764 if (attribute_flag[0] != 0)
7765 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
7766 &geometry,exception);
7767 if (attribute_flag[1] != 0)
7768 geometry.width=argument_list[1].integer_reference;
7769 if (attribute_flag[2] != 0)
7770 geometry.height=argument_list[2].integer_reference;
7771 if (attribute_flag[3] != 0)
7772 geometry.x=argument_list[3].integer_reference;
7773 if (attribute_flag[4] != 0)
7774 geometry.y=argument_list[4].integer_reference;
7775 if (attribute_flag[5] != 0)
7776 image->fuzz=StringToDoubleInterval(
7777 argument_list[5].string_reference,(double) QuantumRange+1.0);
7778 image=CropImage(image,&geometry,exception);
7781 case 9: /* Despeckle */
7783 image=DespeckleImage(image,exception);
7788 if (attribute_flag[0] != 0)
7789 geometry_info.rho=argument_list[0].real_reference;
7790 image=EdgeImage(image,geometry_info.rho,geometry_info.sigma,
7794 case 11: /* Emboss */
7796 if (attribute_flag[0] != 0)
7798 flags=ParseGeometry(argument_list[0].string_reference,
7800 if ((flags & SigmaValue) == 0)
7801 geometry_info.sigma=1.0;
7803 if (attribute_flag[1] != 0)
7804 geometry_info.rho=argument_list[1].real_reference;
7805 if (attribute_flag[2] != 0)
7806 geometry_info.sigma=argument_list[2].real_reference;
7807 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
7811 case 12: /* Enhance */
7813 image=EnhanceImage(image,exception);
7818 image=FlipImage(image,exception);
7823 image=FlopImage(image,exception);
7826 case 15: /* Frame */
7834 if (attribute_flag[0] != 0)
7836 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7837 &geometry,exception);
7838 frame_info.width=geometry.width;
7839 frame_info.height=geometry.height;
7840 frame_info.outer_bevel=geometry.x;
7841 frame_info.inner_bevel=geometry.y;
7843 if (attribute_flag[1] != 0)
7844 frame_info.width=argument_list[1].integer_reference;
7845 if (attribute_flag[2] != 0)
7846 frame_info.height=argument_list[2].integer_reference;
7847 if (attribute_flag[3] != 0)
7848 frame_info.inner_bevel=argument_list[3].integer_reference;
7849 if (attribute_flag[4] != 0)
7850 frame_info.outer_bevel=argument_list[4].integer_reference;
7851 if (attribute_flag[5] != 0)
7852 QueryColorCompliance(argument_list[5].string_reference,
7853 AllCompliance,&fill_color,exception);
7854 if (attribute_flag[6] != 0)
7855 QueryColorCompliance(argument_list[6].string_reference,
7856 AllCompliance,&fill_color,exception);
7857 frame_info.x=(ssize_t) frame_info.width;
7858 frame_info.y=(ssize_t) frame_info.height;
7859 frame_info.width=image->columns+2*frame_info.x;
7860 frame_info.height=image->rows+2*frame_info.y;
7861 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
7862 image->matte_color=fill_color;
7863 compose=image->compose;
7864 if (attribute_flag[7] != 0)
7865 compose=(CompositeOperator) argument_list[7].integer_reference;
7866 image=FrameImage(image,&frame_info,compose,exception);
7869 case 16: /* Implode */
7871 PixelInterpolateMethod
7874 if (attribute_flag[0] == 0)
7875 argument_list[0].real_reference=0.5;
7876 method=UndefinedInterpolatePixel;
7877 if (attribute_flag[1] != 0)
7878 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
7879 image=ImplodeImage(image,argument_list[0].real_reference,
7883 case 17: /* Magnify */
7885 image=MagnifyImage(image,exception);
7888 case 18: /* MedianFilter */
7890 if (attribute_flag[0] != 0)
7892 flags=ParseGeometry(argument_list[0].string_reference,
7894 if ((flags & SigmaValue) == 0)
7895 geometry_info.sigma=geometry_info.rho;
7897 if (attribute_flag[1] != 0)
7898 geometry_info.rho=argument_list[1].real_reference;
7899 if (attribute_flag[2] != 0)
7900 geometry_info.sigma=argument_list[2].real_reference;
7901 if (attribute_flag[3] != 0)
7902 channel=(ChannelType) argument_list[3].integer_reference;
7903 channel_mask=SetImageChannelMask(image,channel);
7904 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
7905 (size_t) geometry_info.sigma,exception);
7906 if (image != (Image *) NULL)
7907 (void) SetImageChannelMask(image,channel_mask);
7910 case 19: /* Minify */
7912 image=MinifyImage(image,exception);
7915 case 20: /* OilPaint */
7917 if (attribute_flag[0] == 0)
7918 argument_list[0].real_reference=0.0;
7919 if (attribute_flag[1] == 0)
7920 argument_list[1].real_reference=1.0;
7921 image=OilPaintImage(image,argument_list[0].real_reference,
7922 argument_list[1].real_reference,exception);
7925 case 21: /* ReduceNoise */
7927 if (attribute_flag[0] != 0)
7929 flags=ParseGeometry(argument_list[0].string_reference,
7931 if ((flags & SigmaValue) == 0)
7932 geometry_info.sigma=1.0;
7934 if (attribute_flag[1] != 0)
7935 geometry_info.rho=argument_list[1].real_reference;
7936 if (attribute_flag[2] != 0)
7937 geometry_info.sigma=argument_list[2].real_reference;
7938 if (attribute_flag[3] != 0)
7939 channel=(ChannelType) argument_list[3].integer_reference;
7940 channel_mask=SetImageChannelMask(image,channel);
7941 image=StatisticImage(image,NonpeakStatistic,(size_t)
7942 geometry_info.rho,(size_t) geometry_info.sigma,exception);
7943 if (image != (Image *) NULL)
7944 (void) SetImageChannelMask(image,channel_mask);
7949 if (attribute_flag[0] != 0)
7950 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7951 &geometry,exception);
7952 if (attribute_flag[1] != 0)
7953 geometry.x=argument_list[1].integer_reference;
7954 if (attribute_flag[2] != 0)
7955 geometry.y=argument_list[2].integer_reference;
7956 image=RollImage(image,geometry.x,geometry.y,exception);
7959 case 23: /* Rotate */
7961 if (attribute_flag[0] == 0)
7962 argument_list[0].real_reference=90.0;
7963 if (attribute_flag[1] != 0)
7965 QueryColorCompliance(argument_list[1].string_reference,
7966 AllCompliance,&image->background_color,exception);
7967 if ((image->background_color.alpha_trait == BlendPixelTrait) &&
7968 (image->alpha_trait != BlendPixelTrait))
7969 (void) SetImageAlpha(image,OpaqueAlpha,exception);
7971 image=RotateImage(image,argument_list[0].real_reference,exception);
7974 case 24: /* Sample */
7976 if (attribute_flag[0] != 0)
7977 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7978 &geometry,exception);
7979 if (attribute_flag[1] != 0)
7980 geometry.width=argument_list[1].integer_reference;
7981 if (attribute_flag[2] != 0)
7982 geometry.height=argument_list[2].integer_reference;
7983 image=SampleImage(image,geometry.width,geometry.height,exception);
7986 case 25: /* Scale */
7988 if (attribute_flag[0] != 0)
7989 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
7990 &geometry,exception);
7991 if (attribute_flag[1] != 0)
7992 geometry.width=argument_list[1].integer_reference;
7993 if (attribute_flag[2] != 0)
7994 geometry.height=argument_list[2].integer_reference;
7995 image=ScaleImage(image,geometry.width,geometry.height,exception);
7998 case 26: /* Shade */
8000 if (attribute_flag[0] != 0)
8002 flags=ParseGeometry(argument_list[0].string_reference,
8004 if ((flags & SigmaValue) == 0)
8005 geometry_info.sigma=0.0;
8007 if (attribute_flag[1] != 0)
8008 geometry_info.rho=argument_list[1].real_reference;
8009 if (attribute_flag[2] != 0)
8010 geometry_info.sigma=argument_list[2].real_reference;
8011 image=ShadeImage(image,
8012 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8013 geometry_info.rho,geometry_info.sigma,exception);
8016 case 27: /* Sharpen */
8018 if (attribute_flag[0] != 0)
8020 flags=ParseGeometry(argument_list[0].string_reference,
8022 if ((flags & SigmaValue) == 0)
8023 geometry_info.sigma=1.0;
8025 if (attribute_flag[1] != 0)
8026 geometry_info.rho=argument_list[1].real_reference;
8027 if (attribute_flag[2] != 0)
8028 geometry_info.sigma=argument_list[2].real_reference;
8029 if (attribute_flag[3] != 0)
8030 channel=(ChannelType) argument_list[3].integer_reference;
8031 channel_mask=SetImageChannelMask(image,channel);
8032 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8034 if (image != (Image *) NULL)
8035 (void) SetImageChannelMask(image,channel_mask);
8038 case 28: /* Shear */
8040 if (attribute_flag[0] != 0)
8042 flags=ParseGeometry(argument_list[0].string_reference,
8044 if ((flags & SigmaValue) == 0)
8045 geometry_info.sigma=geometry_info.rho;
8047 if (attribute_flag[1] != 0)
8048 geometry_info.rho=argument_list[1].real_reference;
8049 if (attribute_flag[2] != 0)
8050 geometry_info.sigma=argument_list[2].real_reference;
8051 if (attribute_flag[3] != 0)
8052 QueryColorCompliance(argument_list[3].string_reference,
8053 AllCompliance,&image->background_color,exception);
8054 if (attribute_flag[4] != 0)
8055 QueryColorCompliance(argument_list[4].string_reference,
8056 AllCompliance,&image->background_color,exception);
8057 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8061 case 29: /* Spread */
8063 PixelInterpolateMethod
8066 if (attribute_flag[0] == 0)
8067 argument_list[0].real_reference=1.0;
8068 method=UndefinedInterpolatePixel;
8069 if (attribute_flag[1] != 0)
8070 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8071 image=SpreadImage(image,argument_list[0].real_reference,method,
8075 case 30: /* Swirl */
8077 PixelInterpolateMethod
8080 if (attribute_flag[0] == 0)
8081 argument_list[0].real_reference=50.0;
8082 method=UndefinedInterpolatePixel;
8083 if (attribute_flag[1] != 0)
8084 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8085 image=SwirlImage(image,argument_list[0].real_reference,
8089 case 31: /* Resize */
8092 if (attribute_flag[0] != 0)
8093 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8094 &geometry,exception);
8095 if (attribute_flag[1] != 0)
8096 geometry.width=argument_list[1].integer_reference;
8097 if (attribute_flag[2] != 0)
8098 geometry.height=argument_list[2].integer_reference;
8099 if (attribute_flag[3] == 0)
8100 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8101 if (attribute_flag[4] != 0)
8102 SetImageArtifact(image,"filter:support",
8103 argument_list[4].string_reference);
8104 image=ResizeImage(image,geometry.width,geometry.height,
8105 (FilterTypes) argument_list[3].integer_reference,
8109 case 33: /* Annotate */
8114 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8116 if (attribute_flag[0] != 0)
8121 text=InterpretImageProperties(info ? info->image_info :
8122 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8124 (void) CloneString(&draw_info->text,text);
8125 text=DestroyString(text);
8127 if (attribute_flag[1] != 0)
8128 (void) CloneString(&draw_info->font,
8129 argument_list[1].string_reference);
8130 if (attribute_flag[2] != 0)
8131 draw_info->pointsize=argument_list[2].real_reference;
8132 if (attribute_flag[3] != 0)
8133 (void) CloneString(&draw_info->density,
8134 argument_list[3].string_reference);
8135 if (attribute_flag[4] != 0)
8136 (void) QueryColorCompliance(argument_list[4].string_reference,
8137 AllCompliance,&draw_info->undercolor,exception);
8138 if (attribute_flag[5] != 0)
8140 (void) QueryColorCompliance(argument_list[5].string_reference,
8141 AllCompliance,&draw_info->stroke,exception);
8142 if (argument_list[5].image_reference != (Image *) NULL)
8143 draw_info->stroke_pattern=CloneImage(
8144 argument_list[5].image_reference,0,0,MagickTrue,exception);
8146 if (attribute_flag[6] != 0)
8148 (void) QueryColorCompliance(argument_list[6].string_reference,
8149 AllCompliance,&draw_info->fill,exception);
8150 if (argument_list[6].image_reference != (Image *) NULL)
8151 draw_info->fill_pattern=CloneImage(
8152 argument_list[6].image_reference,0,0,MagickTrue,exception);
8154 if (attribute_flag[7] != 0)
8156 (void) CloneString(&draw_info->geometry,
8157 argument_list[7].string_reference);
8158 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8159 &geometry,exception);
8160 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8161 geometry_info.sigma=geometry_info.xi;
8163 if (attribute_flag[8] != 0)
8164 (void) QueryColorCompliance(argument_list[8].string_reference,
8165 AllCompliance,&draw_info->fill,exception);
8166 if (attribute_flag[11] != 0)
8167 draw_info->gravity=(GravityType)
8168 argument_list[11].integer_reference;
8169 if (attribute_flag[25] != 0)
8174 av=(AV *) argument_list[25].array_reference;
8175 if ((av_len(av) != 3) && (av_len(av) != 5))
8177 ThrowPerlException(exception,OptionError,
8178 "affine matrix must have 4 or 6 elements",PackageName);
8181 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8182 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8183 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8184 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8185 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8186 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8188 ThrowPerlException(exception,OptionError,
8189 "affine matrix is singular",PackageName);
8192 if (av_len(av) == 5)
8194 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8195 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8198 for (j=12; j < 17; j++)
8200 if (attribute_flag[j] == 0)
8202 value=argument_list[j].string_reference;
8203 angle=argument_list[j].real_reference;
8204 current=draw_info->affine;
8205 GetAffineMatrix(&affine);
8213 flags=ParseGeometry(value,&geometry_info);
8214 affine.tx=geometry_info.xi;
8215 affine.ty=geometry_info.psi;
8216 if ((flags & PsiValue) == 0)
8217 affine.ty=affine.tx;
8225 flags=ParseGeometry(value,&geometry_info);
8226 affine.sx=geometry_info.rho;
8227 affine.sy=geometry_info.sigma;
8228 if ((flags & SigmaValue) == 0)
8229 affine.sy=affine.sx;
8239 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8240 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8241 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8242 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8250 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8258 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8262 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8263 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8264 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8265 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8266 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8268 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8271 if (attribute_flag[9] == 0)
8272 argument_list[9].real_reference=0.0;
8273 if (attribute_flag[10] == 0)
8274 argument_list[10].real_reference=0.0;
8275 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8278 geometry[MaxTextExtent];
8280 (void) FormatLocaleString(geometry,MaxTextExtent,"%+f%+f",
8281 (double) argument_list[9].real_reference+draw_info->affine.tx,
8282 (double) argument_list[10].real_reference+draw_info->affine.ty);
8283 (void) CloneString(&draw_info->geometry,geometry);
8285 if (attribute_flag[17] != 0)
8286 draw_info->stroke_width=argument_list[17].real_reference;
8287 if (attribute_flag[18] != 0)
8289 draw_info->text_antialias=argument_list[18].integer_reference != 0 ?
8290 MagickTrue : MagickFalse;
8291 draw_info->stroke_antialias=draw_info->text_antialias;
8293 if (attribute_flag[19] != 0)
8294 (void) CloneString(&draw_info->family,
8295 argument_list[19].string_reference);
8296 if (attribute_flag[20] != 0)
8297 draw_info->style=(StyleType) argument_list[20].integer_reference;
8298 if (attribute_flag[21] != 0)
8299 draw_info->stretch=(StretchType) argument_list[21].integer_reference;
8300 if (attribute_flag[22] != 0)
8301 draw_info->weight=argument_list[22].integer_reference;
8302 if (attribute_flag[23] != 0)
8303 draw_info->align=(AlignType) argument_list[23].integer_reference;
8304 if (attribute_flag[24] != 0)
8305 (void) CloneString(&draw_info->encoding,
8306 argument_list[24].string_reference);
8307 if (attribute_flag[25] != 0)
8308 draw_info->fill_pattern=CloneImage(
8309 argument_list[25].image_reference,0,0,MagickTrue,exception);
8310 if (attribute_flag[26] != 0)
8311 draw_info->fill_pattern=CloneImage(
8312 argument_list[26].image_reference,0,0,MagickTrue,exception);
8313 if (attribute_flag[27] != 0)
8314 draw_info->stroke_pattern=CloneImage(
8315 argument_list[27].image_reference,0,0,MagickTrue,exception);
8316 if (attribute_flag[29] != 0)
8317 draw_info->kerning=argument_list[29].real_reference;
8318 if (attribute_flag[30] != 0)
8319 draw_info->interline_spacing=argument_list[30].real_reference;
8320 if (attribute_flag[31] != 0)
8321 draw_info->interword_spacing=argument_list[31].real_reference;
8322 if (attribute_flag[32] != 0)
8323 draw_info->direction=(DirectionType)
8324 argument_list[32].integer_reference;
8325 (void) AnnotateImage(image,draw_info,exception);
8326 draw_info=DestroyDrawInfo(draw_info);
8329 case 34: /* ColorFloodfill */
8340 draw_info=CloneDrawInfo(info ? info->image_info :
8341 (ImageInfo *) NULL,(DrawInfo *) NULL);
8342 if (attribute_flag[0] != 0)
8343 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8344 &geometry,exception);
8345 if (attribute_flag[1] != 0)
8346 geometry.x=argument_list[1].integer_reference;
8347 if (attribute_flag[2] != 0)
8348 geometry.y=argument_list[2].integer_reference;
8349 if (attribute_flag[3] != 0)
8350 (void) QueryColorCompliance(argument_list[3].string_reference,
8351 AllCompliance,&draw_info->fill,exception);
8352 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8353 geometry.x,geometry.y,&target,exception);
8355 if (attribute_flag[4] != 0)
8357 QueryColorCompliance(argument_list[4].string_reference,
8358 AllCompliance,&target,exception);
8361 if (attribute_flag[5] != 0)
8362 image->fuzz=StringToDoubleInterval(
8363 argument_list[5].string_reference,(double) QuantumRange+1.0);
8364 if (attribute_flag[6] != 0)
8365 invert=(MagickBooleanType) argument_list[6].integer_reference;
8366 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8367 geometry.y,invert,exception);
8368 draw_info=DestroyDrawInfo(draw_info);
8371 case 35: /* Composite */
8374 composite_geometry[MaxTextExtent];
8383 compose=OverCompositeOp;
8384 if (attribute_flag[0] != 0)
8385 composite_image=argument_list[0].image_reference;
8388 ThrowPerlException(exception,OptionError,
8389 "CompositeImageRequired",PackageName);
8393 Parameter Handling used for BOTH normal and tiled composition.
8395 if (attribute_flag[1] != 0) /* compose */
8396 compose=(CompositeOperator) argument_list[1].integer_reference;
8397 if (attribute_flag[6] != 0) /* opacity */
8399 if (compose != DissolveCompositeOp)
8400 (void) SetImageAlpha(composite_image,(Quantum)
8401 StringToDoubleInterval(argument_list[6].string_reference,
8402 (double) QuantumRange+1.0),exception);
8424 Handle dissolve composite operator (patch by
8427 (void) CloneString(&image->geometry,
8428 argument_list[6].string_reference);
8429 opacity=(Quantum) StringToDoubleInterval(
8430 argument_list[6].string_reference,(double) QuantumRange+
8432 if (composite_image->alpha_trait == BlendPixelTrait)
8433 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8434 composite_view=AcquireAuthenticCacheView(composite_image,exception);
8435 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8437 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8438 composite_image->columns,1,exception);
8439 for (x=0; x < (ssize_t) composite_image->columns; x++)
8441 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8442 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8444 q+=GetPixelChannels(composite_image);
8446 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8447 if (sync == MagickFalse)
8450 composite_view=DestroyCacheView(composite_view);
8453 if (attribute_flag[9] != 0) /* "color=>" */
8454 QueryColorCompliance(argument_list[9].string_reference,
8455 AllCompliance,&composite_image->background_color,exception);
8456 if (attribute_flag[12] != 0) /* "interpolate=>" */
8457 image->interpolate=(PixelInterpolateMethod)
8458 argument_list[12].integer_reference;
8459 if (attribute_flag[13] != 0) /* "args=>" */
8460 (void) SetImageArtifact(composite_image,"compose:args",
8461 argument_list[13].string_reference);
8462 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8463 (void) SetImageArtifact(composite_image,"compose:args",
8464 argument_list[14].string_reference);
8465 clip_to_self=MagickTrue;
8466 if (attribute_flag[15] != 0)
8467 clip_to_self=(MagickBooleanType)
8468 argument_list[15].integer_reference;
8470 Tiling Composition (with orthogonal rotate).
8472 rotate_image=(Image *) NULL;
8473 if (attribute_flag[8] != 0) /* "rotate=>" */
8478 rotate_image=RotateImage(composite_image,
8479 argument_list[8].real_reference,exception);
8480 if (rotate_image == (Image *) NULL)
8483 if ((attribute_flag[7] != 0) &&
8484 (argument_list[7].integer_reference != 0)) /* tile */
8491 Tile the composite image.
8493 if (attribute_flag[8] != 0) /* "tile=>" */
8494 (void) SetImageArtifact(rotate_image,"compose:outside-overlay",
8497 (void) SetImageArtifact(composite_image,
8498 "compose:outside-overlay","false");
8499 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8500 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8502 if (attribute_flag[8] != 0) /* rotate */
8503 (void) CompositeImage(image,rotate_image,compose,
8504 MagickTrue,x,y,exception);
8506 (void) CompositeImage(image,composite_image,compose,
8507 MagickTrue,x,y,exception);
8509 if (attribute_flag[8] != 0) /* rotate */
8510 rotate_image=DestroyImage(rotate_image);
8514 Parameter Handling used used ONLY for normal composition.
8516 if (attribute_flag[5] != 0) /* gravity */
8517 image->gravity=(GravityType) argument_list[5].integer_reference;
8518 if (attribute_flag[2] != 0) /* geometry offset */
8520 SetGeometry(image,&geometry);
8521 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8523 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8526 if (attribute_flag[3] != 0) /* x offset */
8527 geometry.x=argument_list[3].integer_reference;
8528 if (attribute_flag[4] != 0) /* y offset */
8529 geometry.y=argument_list[4].integer_reference;
8530 if (attribute_flag[10] != 0) /* mask */
8532 if ((image->compose == DisplaceCompositeOp) ||
8533 (image->compose == DistortCompositeOp))
8536 Merge Y displacement into X displacement image.
8538 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8540 (void) CompositeImage(composite_image,
8541 argument_list[10].image_reference,CopyGreenCompositeOp,
8542 MagickTrue,0,0,exception);
8550 Set a blending mask for the composition.
8552 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8553 MagickTrue,exception);
8554 (void) NegateImage(mask_image,MagickFalse,exception);
8555 (void) SetImageMask(composite_image,mask_image,exception);
8556 mask_image=DestroyImage(mask_image);
8559 if (attribute_flag[11] != 0) /* channel */
8560 channel=(ChannelType) argument_list[11].integer_reference;
8562 Composite two images (normal composition).
8564 (void) FormatLocaleString(composite_geometry,MaxTextExtent,
8565 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8566 (double) composite_image->rows,(double) geometry.x,(double)
8568 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8570 channel_mask=SetImageChannelMask(image,channel);
8571 if (attribute_flag[8] == 0) /* no rotate */
8572 CompositeImage(image,composite_image,compose,clip_to_self,
8573 geometry.x,geometry.y,exception);
8577 Position adjust rotated image then composite.
8579 geometry.x-=(ssize_t) (rotate_image->columns-
8580 composite_image->columns)/2;
8581 geometry.y-=(ssize_t) (rotate_image->rows-
8582 composite_image->rows)/2;
8583 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8584 geometry.y,exception);
8585 rotate_image=DestroyImage(rotate_image);
8587 if (attribute_flag[10] != 0) /* mask */
8589 if ((image->compose == DisplaceCompositeOp) ||
8590 (image->compose == DistortCompositeOp))
8591 composite_image=DestroyImage(composite_image);
8593 (void) SetImageMask(image,(Image *) NULL,exception);
8595 (void) SetImageChannelMask(image,channel_mask);
8598 case 36: /* Contrast */
8600 if (attribute_flag[0] == 0)
8601 argument_list[0].integer_reference=0;
8602 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8603 MagickTrue : MagickFalse,exception);
8606 case 37: /* CycleColormap */
8608 if (attribute_flag[0] == 0)
8609 argument_list[0].integer_reference=6;
8610 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8619 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8621 (void) CloneString(&draw_info->primitive,"point");
8622 if (attribute_flag[0] != 0)
8624 if (argument_list[0].integer_reference < 0)
8625 (void) CloneString(&draw_info->primitive,
8626 argument_list[0].string_reference);
8628 (void) CloneString(&draw_info->primitive,CommandOptionToMnemonic(
8629 MagickPrimitiveOptions,argument_list[0].integer_reference));
8631 if (attribute_flag[1] != 0)
8633 if (LocaleCompare(draw_info->primitive,"path") == 0)
8635 (void) ConcatenateString(&draw_info->primitive," '");
8636 ConcatenateString(&draw_info->primitive,
8637 argument_list[1].string_reference);
8638 (void) ConcatenateString(&draw_info->primitive,"'");
8642 (void) ConcatenateString(&draw_info->primitive," ");
8643 ConcatenateString(&draw_info->primitive,
8644 argument_list[1].string_reference);
8647 if (attribute_flag[2] != 0)
8649 (void) ConcatenateString(&draw_info->primitive," ");
8650 (void) ConcatenateString(&draw_info->primitive,
8651 CommandOptionToMnemonic(MagickMethodOptions,
8652 argument_list[2].integer_reference));
8654 if (attribute_flag[3] != 0)
8656 (void) QueryColorCompliance(argument_list[3].string_reference,
8657 AllCompliance,&draw_info->stroke,exception);
8658 if (argument_list[3].image_reference != (Image *) NULL)
8659 draw_info->stroke_pattern=CloneImage(
8660 argument_list[3].image_reference,0,0,MagickTrue,exception);
8662 if (attribute_flag[4] != 0)
8664 (void) QueryColorCompliance(argument_list[4].string_reference,
8665 AllCompliance,&draw_info->fill,exception);
8666 if (argument_list[4].image_reference != (Image *) NULL)
8667 draw_info->fill_pattern=CloneImage(
8668 argument_list[4].image_reference,0,0,MagickTrue,exception);
8670 if (attribute_flag[5] != 0)
8671 draw_info->stroke_width=argument_list[5].real_reference;
8672 if (attribute_flag[6] != 0)
8673 (void) CloneString(&draw_info->font,
8674 argument_list[6].string_reference);
8675 if (attribute_flag[7] != 0)
8676 (void) QueryColorCompliance(argument_list[7].string_reference,
8677 AllCompliance,&draw_info->border_color,exception);
8678 if (attribute_flag[8] != 0)
8679 draw_info->affine.tx=argument_list[8].real_reference;
8680 if (attribute_flag[9] != 0)
8681 draw_info->affine.ty=argument_list[9].real_reference;
8682 if (attribute_flag[20] != 0)
8687 av=(AV *) argument_list[20].array_reference;
8688 if ((av_len(av) != 3) && (av_len(av) != 5))
8690 ThrowPerlException(exception,OptionError,
8691 "affine matrix must have 4 or 6 elements",PackageName);
8694 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8695 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8696 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8697 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8698 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8699 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8701 ThrowPerlException(exception,OptionError,
8702 "affine matrix is singular",PackageName);
8705 if (av_len(av) == 5)
8707 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8708 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8711 for (j=10; j < 15; j++)
8713 if (attribute_flag[j] == 0)
8715 value=argument_list[j].string_reference;
8716 angle=argument_list[j].real_reference;
8717 current=draw_info->affine;
8718 GetAffineMatrix(&affine);
8726 flags=ParseGeometry(value,&geometry_info);
8727 affine.tx=geometry_info.xi;
8728 affine.ty=geometry_info.psi;
8729 if ((flags & PsiValue) == 0)
8730 affine.ty=affine.tx;
8738 flags=ParseGeometry(value,&geometry_info);
8739 affine.sx=geometry_info.rho;
8740 affine.sy=geometry_info.sigma;
8741 if ((flags & SigmaValue) == 0)
8742 affine.sy=affine.sx;
8752 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8753 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8754 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8755 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8763 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8771 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8775 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8776 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8777 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8778 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8779 draw_info->affine.tx=
8780 current.sx*affine.tx+current.ry*affine.ty+current.tx;
8781 draw_info->affine.ty=
8782 current.rx*affine.tx+current.sy*affine.ty+current.ty;
8784 if (attribute_flag[15] != 0)
8785 draw_info->fill_pattern=CloneImage(
8786 argument_list[15].image_reference,0,0,MagickTrue,exception);
8787 if (attribute_flag[16] != 0)
8788 draw_info->pointsize=argument_list[16].real_reference;
8789 if (attribute_flag[17] != 0)
8791 draw_info->stroke_antialias=argument_list[17].integer_reference != 0
8792 ? MagickTrue : MagickFalse;
8793 draw_info->text_antialias=draw_info->stroke_antialias;
8795 if (attribute_flag[18] != 0)
8796 (void) CloneString(&draw_info->density,
8797 argument_list[18].string_reference);
8798 if (attribute_flag[19] != 0)
8799 draw_info->stroke_width=argument_list[19].real_reference;
8800 if (attribute_flag[21] != 0)
8801 draw_info->dash_offset=argument_list[21].real_reference;
8802 if (attribute_flag[22] != 0)
8807 av=(AV *) argument_list[22].array_reference;
8808 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
8809 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
8810 if (draw_info->dash_pattern != (double *) NULL)
8812 for (i=0; i <= av_len(av); i++)
8813 draw_info->dash_pattern[i]=(double)
8814 SvNV(*(av_fetch(av,i,0)));
8815 draw_info->dash_pattern[i]=0.0;
8818 if (attribute_flag[23] != 0)
8819 image->interpolate=(PixelInterpolateMethod)
8820 argument_list[23].integer_reference;
8821 if ((attribute_flag[24] != 0) &&
8822 (draw_info->fill_pattern != (Image *) NULL))
8823 flags=ParsePageGeometry(draw_info->fill_pattern,
8824 argument_list[24].string_reference,
8825 &draw_info->fill_pattern->tile_offset,exception);
8826 if (attribute_flag[25] != 0)
8828 (void) ConcatenateString(&draw_info->primitive," '");
8829 (void) ConcatenateString(&draw_info->primitive,
8830 argument_list[25].string_reference);
8831 (void) ConcatenateString(&draw_info->primitive,"'");
8833 if (attribute_flag[26] != 0)
8834 draw_info->fill_pattern=CloneImage(
8835 argument_list[26].image_reference,0,0,MagickTrue,exception);
8836 if (attribute_flag[27] != 0)
8837 draw_info->stroke_pattern=CloneImage(
8838 argument_list[27].image_reference,0,0,MagickTrue,exception);
8839 if (attribute_flag[28] != 0)
8840 (void) CloneString(&draw_info->primitive,
8841 argument_list[28].string_reference);
8842 if (attribute_flag[29] != 0)
8843 draw_info->kerning=argument_list[29].real_reference;
8844 if (attribute_flag[30] != 0)
8845 draw_info->interline_spacing=argument_list[30].real_reference;
8846 if (attribute_flag[31] != 0)
8847 draw_info->interword_spacing=argument_list[31].real_reference;
8848 if (attribute_flag[32] != 0)
8849 draw_info->direction=(DirectionType)
8850 argument_list[32].integer_reference;
8851 DrawImage(image,draw_info,exception);
8852 draw_info=DestroyDrawInfo(draw_info);
8855 case 39: /* Equalize */
8857 if (attribute_flag[0] != 0)
8858 channel=(ChannelType) argument_list[0].integer_reference;
8859 channel_mask=SetImageChannelMask(image,channel);
8860 EqualizeImage(image,exception);
8861 (void) SetImageChannelMask(image,channel_mask);
8864 case 40: /* Gamma */
8866 if (attribute_flag[1] != 0)
8867 channel=(ChannelType) argument_list[1].integer_reference;
8868 if (attribute_flag[2] == 0)
8869 argument_list[2].real_reference=1.0;
8870 if (attribute_flag[3] == 0)
8871 argument_list[3].real_reference=1.0;
8872 if (attribute_flag[4] == 0)
8873 argument_list[4].real_reference=1.0;
8874 if (attribute_flag[0] == 0)
8876 (void) FormatLocaleString(message,MaxTextExtent,
8877 "%.15g,%.15g,%.15g",(double) argument_list[2].real_reference,
8878 (double) argument_list[3].real_reference,
8879 (double) argument_list[4].real_reference);
8880 argument_list[0].string_reference=message;
8882 (void) GammaImage(image,StringToDouble(
8883 argument_list[0].string_reference,(char **) NULL),exception);
8891 if (attribute_flag[0] == 0)
8893 ThrowPerlException(exception,OptionError,"MapImageRequired",
8897 quantize_info=AcquireQuantizeInfo(info->image_info);
8898 if (attribute_flag[1] != 0)
8899 quantize_info->dither_method=(DitherMethod)
8900 argument_list[1].integer_reference;
8901 (void) RemapImages(quantize_info,image,
8902 argument_list[0].image_reference,exception);
8903 quantize_info=DestroyQuantizeInfo(quantize_info);
8906 case 42: /* MatteFloodfill */
8917 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8919 if (attribute_flag[0] != 0)
8920 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8921 &geometry,exception);
8922 if (attribute_flag[1] != 0)
8923 geometry.x=argument_list[1].integer_reference;
8924 if (attribute_flag[2] != 0)
8925 geometry.y=argument_list[2].integer_reference;
8926 if (image->alpha_trait != BlendPixelTrait)
8927 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8928 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8929 geometry.x,geometry.y,&target,exception);
8930 if (attribute_flag[4] != 0)
8931 QueryColorCompliance(argument_list[4].string_reference,
8932 AllCompliance,&target,exception);
8933 if (attribute_flag[3] != 0)
8934 target.alpha=StringToDoubleInterval(
8935 argument_list[3].string_reference,(double) (double) QuantumRange+
8937 if (attribute_flag[5] != 0)
8938 image->fuzz=StringToDoubleInterval(
8939 argument_list[5].string_reference,(double) QuantumRange+1.0);
8941 if (attribute_flag[6] != 0)
8942 invert=(MagickBooleanType) argument_list[6].integer_reference;
8943 channel_mask=SetImageChannelMask(image,AlphaChannel);
8944 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8945 geometry.y,invert,exception);
8946 (void) SetImageChannelMask(image,channel_mask);
8947 draw_info=DestroyDrawInfo(draw_info);
8950 case 43: /* Modulate */
8953 modulate[MaxTextExtent];
8955 geometry_info.rho=100.0;
8956 geometry_info.sigma=100.0;
8957 geometry_info.xi=100.0;
8958 if (attribute_flag[0] != 0)
8959 (void)ParseGeometry(argument_list[0].string_reference,
8961 if (attribute_flag[1] != 0)
8962 geometry_info.xi=argument_list[1].real_reference;
8963 if (attribute_flag[2] != 0)
8964 geometry_info.sigma=argument_list[2].real_reference;
8965 if (attribute_flag[3] != 0)
8967 geometry_info.sigma=argument_list[3].real_reference;
8968 SetImageArtifact(image,"modulate:colorspace","HWB");
8970 if (attribute_flag[4] != 0)
8972 geometry_info.rho=argument_list[4].real_reference;
8973 SetImageArtifact(image,"modulate:colorspace","HSB");
8975 if (attribute_flag[5] != 0)
8977 geometry_info.sigma=argument_list[5].real_reference;
8978 SetImageArtifact(image,"modulate:colorspace","HSL");
8980 if (attribute_flag[6] != 0)
8982 geometry_info.rho=argument_list[6].real_reference;
8983 SetImageArtifact(image,"modulate:colorspace","HWB");
8985 (void) FormatLocaleString(modulate,MaxTextExtent,"%.15g,%.15g,%.15g",
8986 geometry_info.rho,geometry_info.sigma,geometry_info.xi);
8987 (void) ModulateImage(image,modulate,exception);
8990 case 44: /* Negate */
8992 if (attribute_flag[0] == 0)
8993 argument_list[0].integer_reference=0;
8994 if (attribute_flag[1] != 0)
8995 channel=(ChannelType) argument_list[1].integer_reference;
8996 channel_mask=SetImageChannelMask(image,channel);
8997 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
8998 MagickTrue : MagickFalse,exception);
8999 (void) SetImageChannelMask(image,channel_mask);
9002 case 45: /* Normalize */
9004 if (attribute_flag[0] != 0)
9005 channel=(ChannelType) argument_list[0].integer_reference;
9006 channel_mask=SetImageChannelMask(image,channel);
9007 NormalizeImage(image,exception);
9008 (void) SetImageChannelMask(image,channel_mask);
9011 case 46: /* NumberColors */
9013 case 47: /* Opaque */
9022 (void) QueryColorCompliance("none",AllCompliance,&target,
9024 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9026 if (attribute_flag[0] != 0)
9027 (void) QueryColorCompliance(argument_list[0].string_reference,
9028 AllCompliance,&target,exception);
9029 if (attribute_flag[1] != 0)
9030 (void) QueryColorCompliance(argument_list[1].string_reference,
9031 AllCompliance,&fill_color,exception);
9032 if (attribute_flag[2] != 0)
9033 image->fuzz=StringToDoubleInterval(
9034 argument_list[2].string_reference,(double) QuantumRange+1.0);
9035 if (attribute_flag[3] != 0)
9036 channel=(ChannelType) argument_list[3].integer_reference;
9038 if (attribute_flag[4] != 0)
9039 invert=(MagickBooleanType) argument_list[4].integer_reference;
9040 channel_mask=SetImageChannelMask(image,channel);
9041 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9042 (void) SetImageChannelMask(image,channel_mask);
9045 case 48: /* Quantize */
9050 quantize_info=AcquireQuantizeInfo(info->image_info);
9051 if (attribute_flag[0] != 0)
9052 quantize_info->number_colors=(size_t)
9053 argument_list[0].integer_reference;
9054 if (attribute_flag[1] != 0)
9055 quantize_info->tree_depth=(size_t)
9056 argument_list[1].integer_reference;
9057 if (attribute_flag[2] != 0)
9058 quantize_info->colorspace=(ColorspaceType)
9059 argument_list[2].integer_reference;
9060 if (attribute_flag[3] != 0)
9061 quantize_info->dither_method=(DitherMethod)
9062 argument_list[3].integer_reference;
9063 if (attribute_flag[4] != 0)
9064 quantize_info->measure_error=argument_list[4].integer_reference !=
9065 0 ? MagickTrue : MagickFalse;
9066 if (attribute_flag[5] != 0)
9067 (void) QueryColorCompliance(argument_list[5].string_reference,
9068 AllCompliance,&image->transparent_color,exception);
9069 if (attribute_flag[5] && argument_list[5].integer_reference)
9071 (void) QuantizeImages(quantize_info,image,exception);
9074 if (attribute_flag[6] != 0)
9075 quantize_info->dither_method=(DitherMethod)
9076 argument_list[6].integer_reference;
9077 if ((image->storage_class == DirectClass) ||
9078 (image->colors > quantize_info->number_colors) ||
9079 (quantize_info->colorspace == GRAYColorspace))
9080 (void) QuantizeImage(quantize_info,image,exception);
9082 CompressImageColormap(image,exception);
9083 quantize_info=DestroyQuantizeInfo(quantize_info);
9086 case 49: /* Raise */
9088 if (attribute_flag[0] != 0)
9089 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9090 &geometry,exception);
9091 if (attribute_flag[1] != 0)
9092 geometry.width=argument_list[1].integer_reference;
9093 if (attribute_flag[2] != 0)
9094 geometry.height=argument_list[2].integer_reference;
9095 if (attribute_flag[3] == 0)
9096 argument_list[3].integer_reference=1;
9097 (void) RaiseImage(image,&geometry,
9098 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9102 case 50: /* Segment */
9109 smoothing_threshold;
9114 cluster_threshold=1.0;
9115 smoothing_threshold=1.5;
9116 colorspace=sRGBColorspace;
9117 verbose=MagickFalse;
9118 if (attribute_flag[0] != 0)
9120 flags=ParseGeometry(argument_list[0].string_reference,
9122 cluster_threshold=geometry_info.rho;
9123 if (flags & SigmaValue)
9124 smoothing_threshold=geometry_info.sigma;
9126 if (attribute_flag[1] != 0)
9127 cluster_threshold=argument_list[1].real_reference;
9128 if (attribute_flag[2] != 0)
9129 smoothing_threshold=argument_list[2].real_reference;
9130 if (attribute_flag[3] != 0)
9131 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9132 if (attribute_flag[4] != 0)
9133 verbose=argument_list[4].integer_reference != 0 ?
9134 MagickTrue : MagickFalse;
9135 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9136 smoothing_threshold,exception);
9139 case 51: /* Signature */
9141 (void) SignatureImage(image,exception);
9144 case 52: /* Solarize */
9146 geometry_info.rho=QuantumRange/2.0;
9147 if (attribute_flag[0] != 0)
9148 flags=ParseGeometry(argument_list[0].string_reference,
9150 if (attribute_flag[1] != 0)
9151 geometry_info.rho=StringToDoubleInterval(
9152 argument_list[1].string_reference,(double) QuantumRange+1.0);
9153 (void) SolarizeImage(image,geometry_info.rho,exception);
9158 (void) SyncImage(image,exception);
9161 case 54: /* Texture */
9163 if (attribute_flag[0] == 0)
9165 TextureImage(image,argument_list[0].image_reference,exception);
9168 case 55: /* Evalute */
9170 MagickEvaluateOperator
9173 op=SetEvaluateOperator;
9174 if (attribute_flag[0] == MagickFalse)
9175 argument_list[0].real_reference=0.0;
9176 if (attribute_flag[1] != MagickFalse)
9177 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9178 if (attribute_flag[2] != MagickFalse)
9179 channel=(ChannelType) argument_list[2].integer_reference;
9180 channel_mask=SetImageChannelMask(image,channel);
9181 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9183 (void) SetImageChannelMask(image,channel_mask);
9186 case 56: /* Transparent */
9197 (void) QueryColorCompliance("none",AllCompliance,&target,
9199 if (attribute_flag[0] != 0)
9200 (void) QueryColorCompliance(argument_list[0].string_reference,
9201 AllCompliance,&target,exception);
9202 opacity=TransparentAlpha;
9203 if (attribute_flag[1] != 0)
9204 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9205 (double) QuantumRange+1.0);
9206 if (attribute_flag[2] != 0)
9207 image->fuzz=StringToDoubleInterval(
9208 argument_list[2].string_reference,(double) QuantumRange+1.0);
9209 if (attribute_flag[3] == 0)
9210 argument_list[3].integer_reference=0;
9212 if (attribute_flag[3] != 0)
9213 invert=(MagickBooleanType) argument_list[3].integer_reference;
9214 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9218 case 57: /* Threshold */
9223 if (attribute_flag[0] == 0)
9224 argument_list[0].string_reference="50%";
9225 if (attribute_flag[1] != 0)
9226 channel=(ChannelType) argument_list[1].integer_reference;
9227 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9228 (double) QuantumRange+1.0);
9229 channel_mask=SetImageChannelMask(image,channel);
9230 (void) BilevelImage(image,threshold,exception);
9231 (void) SetImageChannelMask(image,channel_mask);
9234 case 58: /* Charcoal */
9236 if (attribute_flag[0] != 0)
9238 flags=ParseGeometry(argument_list[0].string_reference,
9240 if ((flags & SigmaValue) == 0)
9241 geometry_info.sigma=1.0;
9243 if (attribute_flag[1] != 0)
9244 geometry_info.rho=argument_list[1].real_reference;
9245 if (attribute_flag[2] != 0)
9246 geometry_info.sigma=argument_list[2].real_reference;
9247 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9253 if (attribute_flag[0] != 0)
9254 image->fuzz=StringToDoubleInterval(
9255 argument_list[0].string_reference,(double) QuantumRange+1.0);
9256 image=TrimImage(image,exception);
9261 PixelInterpolateMethod
9264 if (attribute_flag[0] != 0)
9266 flags=ParseGeometry(argument_list[0].string_reference,
9268 if ((flags & SigmaValue) == 0)
9269 geometry_info.sigma=1.0;
9271 if (attribute_flag[1] != 0)
9272 geometry_info.rho=argument_list[1].real_reference;
9273 if (attribute_flag[2] != 0)
9274 geometry_info.sigma=argument_list[2].real_reference;
9275 method=UndefinedInterpolatePixel;
9276 if (attribute_flag[3] != 0)
9277 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9278 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9282 case 61: /* Separate */
9284 if (attribute_flag[0] != 0)
9285 channel=(ChannelType) argument_list[0].integer_reference;
9286 image=SeparateImage(image,channel,exception);
9289 case 63: /* Stereo */
9291 if (attribute_flag[0] == 0)
9293 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9297 if (attribute_flag[1] != 0)
9298 geometry.x=argument_list[1].integer_reference;
9299 if (attribute_flag[2] != 0)
9300 geometry.y=argument_list[2].integer_reference;
9301 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9302 geometry.x,geometry.y,exception);
9305 case 64: /* Stegano */
9307 if (attribute_flag[0] == 0)
9309 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9313 if (attribute_flag[1] == 0)
9314 argument_list[1].integer_reference=0;
9315 image->offset=argument_list[1].integer_reference;
9316 image=SteganoImage(image,argument_list[0].image_reference,exception);
9319 case 65: /* Deconstruct */
9321 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9324 case 66: /* GaussianBlur */
9326 if (attribute_flag[0] != 0)
9328 flags=ParseGeometry(argument_list[0].string_reference,
9330 if ((flags & SigmaValue) == 0)
9331 geometry_info.sigma=1.0;
9333 if (attribute_flag[1] != 0)
9334 geometry_info.rho=argument_list[1].real_reference;
9335 if (attribute_flag[2] != 0)
9336 geometry_info.sigma=argument_list[2].real_reference;
9337 if (attribute_flag[3] != 0)
9338 channel=(ChannelType) argument_list[3].integer_reference;
9339 channel_mask=SetImageChannelMask(image,channel);
9340 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9342 if (image != (Image *) NULL)
9343 (void) SetImageChannelMask(image,channel_mask);
9346 case 67: /* Convolve */
9351 kernel=(KernelInfo *) NULL;
9352 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9354 if (attribute_flag[0] != 0)
9362 kernel=AcquireKernelInfo((const char *) NULL);
9363 if (kernel == (KernelInfo *) NULL)
9365 av=(AV *) argument_list[0].array_reference;
9366 order=(size_t) sqrt(av_len(av)+1);
9367 kernel->width=order;
9368 kernel->height=order;
9369 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9370 order*sizeof(*kernel->values));
9371 if (kernel->values == (MagickRealType *) NULL)
9373 kernel=DestroyKernelInfo(kernel);
9374 ThrowPerlException(exception,ResourceLimitFatalError,
9375 "MemoryAllocationFailed",PackageName);
9378 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9379 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9380 for ( ; j < (ssize_t) (order*order); j++)
9381 kernel->values[j]=0.0;
9383 if (attribute_flag[1] != 0)
9384 channel=(ChannelType) argument_list[1].integer_reference;
9385 if (attribute_flag[2] != 0)
9386 SetImageArtifact(image,"filter:blur",
9387 argument_list[2].string_reference);
9388 if (attribute_flag[3] != 0)
9390 kernel=AcquireKernelInfo(argument_list[3].string_reference);
9391 if (kernel == (KernelInfo *) NULL)
9394 channel_mask=SetImageChannelMask(image,channel);
9395 image=ConvolveImage(image,kernel,exception);
9396 if (image != (Image *) NULL)
9397 (void) SetImageChannelMask(image,channel_mask);
9398 kernel=DestroyKernelInfo(kernel);
9401 case 68: /* Profile */
9416 if (attribute_flag[0] != 0)
9417 name=argument_list[0].string_reference;
9418 if (attribute_flag[2] != 0)
9419 image->rendering_intent=(RenderingIntent)
9420 argument_list[2].integer_reference;
9421 if (attribute_flag[3] != 0)
9422 image->black_point_compensation=
9423 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse;
9424 if (attribute_flag[1] != 0)
9426 if (argument_list[1].length == 0)
9429 Remove a profile from the image.
9431 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9436 Associate user supplied profile with the image.
9438 profile=AcquireStringInfo(argument_list[1].length);
9439 SetStringInfoDatum(profile,(const unsigned char *)
9440 argument_list[1].string_reference);
9441 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9442 (size_t) GetStringInfoLength(profile),exception);
9443 profile=DestroyStringInfo(profile);
9447 Associate a profile with the image.
9449 profile_info=CloneImageInfo(info ? info->image_info :
9450 (ImageInfo *) NULL);
9451 profile_image=ReadImages(profile_info,name,exception);
9452 if (profile_image == (Image *) NULL)
9454 ResetImageProfileIterator(profile_image);
9455 name=GetNextImageProfile(profile_image);
9456 while (name != (const char *) NULL)
9461 profile=GetImageProfile(profile_image,name);
9462 if (profile != (const StringInfo *) NULL)
9463 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9464 (size_t) GetStringInfoLength(profile),exception);
9465 name=GetNextImageProfile(profile_image);
9467 profile_image=DestroyImage(profile_image);
9468 profile_info=DestroyImageInfo(profile_info);
9471 case 69: /* UnsharpMask */
9473 if (attribute_flag[0] != 0)
9475 flags=ParseGeometry(argument_list[0].string_reference,
9477 if ((flags & SigmaValue) == 0)
9478 geometry_info.sigma=1.0;
9479 if ((flags & XiValue) == 0)
9480 geometry_info.xi=1.0;
9481 if ((flags & PsiValue) == 0)
9482 geometry_info.psi=0.5;
9484 if (attribute_flag[1] != 0)
9485 geometry_info.rho=argument_list[1].real_reference;
9486 if (attribute_flag[2] != 0)
9487 geometry_info.sigma=argument_list[2].real_reference;
9488 if (attribute_flag[3] != 0)
9489 geometry_info.xi=argument_list[3].real_reference;
9490 if (attribute_flag[4] != 0)
9491 channel=(ChannelType) argument_list[4].integer_reference;
9492 channel_mask=SetImageChannelMask(image,channel);
9493 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9494 geometry_info.xi,exception);
9495 if (image != (Image *) NULL)
9496 (void) SetImageChannelMask(image,channel_mask);
9499 case 70: /* MotionBlur */
9501 if (attribute_flag[0] != 0)
9503 flags=ParseGeometry(argument_list[0].string_reference,
9505 if ((flags & SigmaValue) == 0)
9506 geometry_info.sigma=1.0;
9507 if ((flags & XiValue) == 0)
9508 geometry_info.xi=1.0;
9510 if (attribute_flag[1] != 0)
9511 geometry_info.rho=argument_list[1].real_reference;
9512 if (attribute_flag[2] != 0)
9513 geometry_info.sigma=argument_list[2].real_reference;
9514 if (attribute_flag[3] != 0)
9515 geometry_info.xi=argument_list[3].real_reference;
9516 if (attribute_flag[4] != 0)
9517 channel=(ChannelType) argument_list[4].integer_reference;
9518 channel_mask=SetImageChannelMask(image,channel);
9519 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9520 geometry_info.xi,exception);
9521 if (image != (Image *) NULL)
9522 (void) SetImageChannelMask(image,channel_mask);
9525 case 71: /* OrderedDither */
9527 if (attribute_flag[0] == 0)
9528 argument_list[0].string_reference="o8x8";
9529 if (attribute_flag[1] != 0)
9530 channel=(ChannelType) argument_list[1].integer_reference;
9531 channel_mask=SetImageChannelMask(image,channel);
9532 (void) OrderedPosterizeImage(image,argument_list[0].string_reference,
9534 (void) SetImageChannelMask(image,channel_mask);
9537 case 72: /* Shave */
9539 if (attribute_flag[0] != 0)
9540 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9541 &geometry,exception);
9542 if (attribute_flag[1] != 0)
9543 geometry.width=argument_list[1].integer_reference;
9544 if (attribute_flag[2] != 0)
9545 geometry.height=argument_list[2].integer_reference;
9546 image=ShaveImage(image,&geometry,exception);
9549 case 73: /* Level */
9557 white_point=(double) image->columns*image->rows;
9559 if (attribute_flag[0] != 0)
9561 flags=ParseGeometry(argument_list[0].string_reference,
9563 black_point=geometry_info.rho;
9564 if ((flags & SigmaValue) != 0)
9565 white_point=geometry_info.sigma;
9566 if ((flags & XiValue) != 0)
9567 gamma=geometry_info.xi;
9568 if ((flags & PercentValue) != 0)
9570 black_point*=(double) (QuantumRange/100.0);
9571 white_point*=(double) (QuantumRange/100.0);
9573 if ((flags & SigmaValue) == 0)
9574 white_point=(double) QuantumRange-black_point;
9576 if (attribute_flag[1] != 0)
9577 black_point=argument_list[1].real_reference;
9578 if (attribute_flag[2] != 0)
9579 white_point=argument_list[2].real_reference;
9580 if (attribute_flag[3] != 0)
9581 gamma=argument_list[3].real_reference;
9582 if (attribute_flag[4] != 0)
9583 channel=(ChannelType) argument_list[4].integer_reference;
9584 if (attribute_flag[5] != 0)
9586 argument_list[0].real_reference=argument_list[5].real_reference;
9587 attribute_flag[0]=attribute_flag[5];
9589 channel_mask=SetImageChannelMask(image,channel);
9590 (void) LevelImage(image,black_point,white_point,gamma,exception);
9591 (void) SetImageChannelMask(image,channel_mask);
9596 if (attribute_flag[0] == 0)
9597 argument_list[0].string_reference="#1";
9598 if (attribute_flag[1] == 0)
9599 argument_list[1].integer_reference=MagickTrue;
9600 (void) ClipImagePath(image,argument_list[0].string_reference,
9601 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9605 case 75: /* AffineTransform */
9610 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9612 if (attribute_flag[0] != 0)
9617 av=(AV *) argument_list[0].array_reference;
9618 if ((av_len(av) != 3) && (av_len(av) != 5))
9620 ThrowPerlException(exception,OptionError,
9621 "affine matrix must have 4 or 6 elements",PackageName);
9624 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9625 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9626 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9627 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9628 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9629 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9631 ThrowPerlException(exception,OptionError,
9632 "affine matrix is singular",PackageName);
9635 if (av_len(av) == 5)
9637 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9638 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9641 for (j=1; j < 6; j++)
9643 if (attribute_flag[j] == 0)
9645 value=argument_list[j].string_reference;
9646 angle=argument_list[j].real_reference;
9647 current=draw_info->affine;
9648 GetAffineMatrix(&affine);
9656 flags=ParseGeometry(value,&geometry_info);
9657 affine.tx=geometry_info.xi;
9658 affine.ty=geometry_info.psi;
9659 if ((flags & PsiValue) == 0)
9660 affine.ty=affine.tx;
9668 flags=ParseGeometry(value,&geometry_info);
9669 affine.sx=geometry_info.rho;
9670 affine.sy=geometry_info.sigma;
9671 if ((flags & SigmaValue) == 0)
9672 affine.sy=affine.sx;
9682 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9683 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9684 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9685 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9693 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9701 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9705 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9706 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9707 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9708 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9709 draw_info->affine.tx=
9710 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9711 draw_info->affine.ty=
9712 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9714 if (attribute_flag[6] != 0)
9715 image->interpolate=(PixelInterpolateMethod)
9716 argument_list[6].integer_reference;
9717 if (attribute_flag[7] != 0)
9718 QueryColorCompliance(argument_list[7].string_reference,
9719 AllCompliance,&image->background_color,exception);
9720 image=AffineTransformImage(image,&draw_info->affine,exception);
9721 draw_info=DestroyDrawInfo(draw_info);
9724 case 76: /* Difference */
9726 if (attribute_flag[0] == 0)
9728 ThrowPerlException(exception,OptionError,
9729 "ReferenceImageRequired",PackageName);
9732 if (attribute_flag[1] != 0)
9733 image->fuzz=StringToDoubleInterval(
9734 argument_list[1].string_reference,(double) QuantumRange+1.0);
9735 (void) IsImagesEqual(image,argument_list[0].image_reference,
9739 case 77: /* AdaptiveThreshold */
9741 if (attribute_flag[0] != 0)
9743 flags=ParseGeometry(argument_list[0].string_reference,
9745 if ((flags & PercentValue) != 0)
9746 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
9748 if (attribute_flag[1] != 0)
9749 geometry_info.rho=argument_list[1].integer_reference;
9750 if (attribute_flag[2] != 0)
9751 geometry_info.sigma=argument_list[2].integer_reference;
9752 if (attribute_flag[3] != 0)
9753 geometry_info.xi=argument_list[3].integer_reference;;
9754 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
9755 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
9758 case 78: /* Resample */
9764 if (attribute_flag[0] != 0)
9766 flags=ParseGeometry(argument_list[0].string_reference,
9768 if ((flags & SigmaValue) == 0)
9769 geometry_info.sigma=geometry_info.rho;
9771 if (attribute_flag[1] != 0)
9772 geometry_info.rho=argument_list[1].real_reference;
9773 if (attribute_flag[2] != 0)
9774 geometry_info.sigma=argument_list[2].real_reference;
9775 if (attribute_flag[3] == 0)
9776 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
9777 if (attribute_flag[4] == 0)
9778 SetImageArtifact(image,"filter:support",
9779 argument_list[4].string_reference);
9780 width=(size_t) (geometry_info.rho*image->columns/
9781 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
9782 height=(size_t) (geometry_info.sigma*image->rows/
9783 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
9784 image=ResizeImage(image,width,height,(FilterTypes)
9785 argument_list[3].integer_reference,exception);
9786 if (image != (Image *) NULL)
9788 image->resolution.x=geometry_info.rho;
9789 image->resolution.y=geometry_info.sigma;
9793 case 79: /* Describe */
9795 if (attribute_flag[0] == 0)
9796 argument_list[0].file_reference=(FILE *) NULL;
9797 if (attribute_flag[1] != 0)
9798 (void) SetImageArtifact(image,"identify:features",
9799 argument_list[1].string_reference);
9800 (void) IdentifyImage(image,argument_list[0].file_reference,
9801 MagickTrue,exception);
9804 case 80: /* BlackThreshold */
9806 if (attribute_flag[0] == 0)
9807 argument_list[0].string_reference="50%";
9808 if (attribute_flag[2] != 0)
9809 channel=(ChannelType) argument_list[2].integer_reference;
9810 channel_mask=SetImageChannelMask(image,channel);
9811 BlackThresholdImage(image,argument_list[0].string_reference,
9813 (void) SetImageChannelMask(image,channel_mask);
9816 case 81: /* WhiteThreshold */
9818 if (attribute_flag[0] == 0)
9819 argument_list[0].string_reference="50%";
9820 if (attribute_flag[2] != 0)
9821 channel=(ChannelType) argument_list[2].integer_reference;
9822 channel_mask=SetImageChannelMask(image,channel);
9823 WhiteThresholdImage(image,argument_list[0].string_reference,
9825 (void) SetImageChannelMask(image,channel_mask);
9828 case 82: /* RadialBlur */
9830 if (attribute_flag[0] != 0)
9832 flags=ParseGeometry(argument_list[0].string_reference,
9835 if (attribute_flag[1] != 0)
9836 geometry_info.rho=argument_list[1].real_reference;
9837 if (attribute_flag[2] != 0)
9838 channel=(ChannelType) argument_list[2].integer_reference;
9839 channel_mask=SetImageChannelMask(image,channel);
9840 image=RadialBlurImage(image,geometry_info.rho,exception);
9841 if (image != (Image *) NULL)
9842 (void) SetImageChannelMask(image,channel_mask);
9845 case 83: /* Thumbnail */
9847 if (attribute_flag[0] != 0)
9848 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
9849 &geometry,exception);
9850 if (attribute_flag[1] != 0)
9851 geometry.width=argument_list[1].integer_reference;
9852 if (attribute_flag[2] != 0)
9853 geometry.height=argument_list[2].integer_reference;
9854 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
9857 case 84: /* Strip */
9859 (void) StripImage(image,exception);
9867 GetPixelInfo(image,&tint);
9868 if (attribute_flag[0] != 0)
9869 (void) QueryColorCompliance(argument_list[0].string_reference,
9870 AllCompliance,&tint,exception);
9871 if (attribute_flag[1] == 0)
9872 argument_list[1].string_reference="100";
9873 image=TintImage(image,argument_list[1].string_reference,&tint,
9877 case 86: /* Channel */
9879 if (attribute_flag[0] != 0)
9880 channel=(ChannelType) argument_list[0].integer_reference;
9881 image=SeparateImage(image,channel,exception);
9884 case 87: /* Splice */
9886 if (attribute_flag[0] != 0)
9887 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
9888 &geometry,exception);
9889 if (attribute_flag[1] != 0)
9890 geometry.width=argument_list[1].integer_reference;
9891 if (attribute_flag[2] != 0)
9892 geometry.height=argument_list[2].integer_reference;
9893 if (attribute_flag[3] != 0)
9894 geometry.x=argument_list[3].integer_reference;
9895 if (attribute_flag[4] != 0)
9896 geometry.y=argument_list[4].integer_reference;
9897 if (attribute_flag[5] != 0)
9898 image->fuzz=StringToDoubleInterval(
9899 argument_list[5].string_reference,(double) QuantumRange+1.0);
9900 if (attribute_flag[6] != 0)
9901 (void) QueryColorCompliance(argument_list[6].string_reference,
9902 AllCompliance,&image->background_color,exception);
9903 if (attribute_flag[7] != 0)
9904 image->gravity=(GravityType) argument_list[7].integer_reference;
9905 image=SpliceImage(image,&geometry,exception);
9908 case 88: /* Posterize */
9910 if (attribute_flag[0] == 0)
9911 argument_list[0].integer_reference=3;
9912 if (attribute_flag[1] == 0)
9913 argument_list[1].integer_reference=0;
9914 (void) PosterizeImage(image,argument_list[0].integer_reference,
9915 argument_list[1].integer_reference ? RiemersmaDitherMethod :
9916 NoDitherMethod,exception);
9919 case 89: /* Shadow */
9921 if (attribute_flag[0] != 0)
9923 flags=ParseGeometry(argument_list[0].string_reference,
9925 if ((flags & SigmaValue) == 0)
9926 geometry_info.sigma=1.0;
9927 if ((flags & XiValue) == 0)
9928 geometry_info.xi=4.0;
9929 if ((flags & PsiValue) == 0)
9930 geometry_info.psi=4.0;
9932 if (attribute_flag[1] != 0)
9933 geometry_info.rho=argument_list[1].real_reference;
9934 if (attribute_flag[2] != 0)
9935 geometry_info.sigma=argument_list[2].real_reference;
9936 if (attribute_flag[3] != 0)
9937 geometry_info.xi=argument_list[3].integer_reference;
9938 if (attribute_flag[4] != 0)
9939 geometry_info.psi=argument_list[4].integer_reference;
9940 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
9941 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
9942 ceil(geometry_info.psi-0.5),exception);
9945 case 90: /* Identify */
9947 if (attribute_flag[0] == 0)
9948 argument_list[0].file_reference=(FILE *) NULL;
9949 if (attribute_flag[1] != 0)
9950 (void) SetImageArtifact(image,"identify:features",
9951 argument_list[1].string_reference);
9952 if ((attribute_flag[2] != 0) &&
9953 (argument_list[2].integer_reference != 0))
9954 (void) SetImageArtifact(image,"identify:unique","true");
9955 (void) IdentifyImage(image,argument_list[0].file_reference,
9956 MagickTrue,exception);
9959 case 91: /* SepiaTone */
9961 if (attribute_flag[0] == 0)
9962 argument_list[0].real_reference=80.0*QuantumRange/100.0;
9963 image=SepiaToneImage(image,argument_list[0].real_reference,
9967 case 92: /* SigmoidalContrast */
9972 if (attribute_flag[0] != 0)
9974 flags=ParseGeometry(argument_list[0].string_reference,
9976 if ((flags & SigmaValue) == 0)
9977 geometry_info.sigma=QuantumRange/2.0;
9978 if ((flags & PercentValue) != 0)
9979 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
9981 if (attribute_flag[1] != 0)
9982 geometry_info.rho=argument_list[1].real_reference;
9983 if (attribute_flag[2] != 0)
9984 geometry_info.sigma=argument_list[2].real_reference;
9985 if (attribute_flag[3] != 0)
9986 channel=(ChannelType) argument_list[3].integer_reference;
9988 if (attribute_flag[4] != 0)
9989 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
9991 channel_mask=SetImageChannelMask(image,channel);
9992 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
9993 geometry_info.sigma,exception);
9994 (void) SetImageChannelMask(image,channel_mask);
9997 case 93: /* Extent */
9999 if (attribute_flag[7] != 0)
10000 image->gravity=(GravityType) argument_list[7].integer_reference;
10001 if (attribute_flag[0] != 0)
10006 flags=ParseGravityGeometry(image,
10007 argument_list[0].string_reference,&geometry,exception);
10009 if (geometry.width == 0)
10010 geometry.width=image->columns;
10011 if (geometry.height == 0)
10012 geometry.height=image->rows;
10014 if (attribute_flag[1] != 0)
10015 geometry.width=argument_list[1].integer_reference;
10016 if (attribute_flag[2] != 0)
10017 geometry.height=argument_list[2].integer_reference;
10018 if (attribute_flag[3] != 0)
10019 geometry.x=argument_list[3].integer_reference;
10020 if (attribute_flag[4] != 0)
10021 geometry.y=argument_list[4].integer_reference;
10022 if (attribute_flag[5] != 0)
10023 image->fuzz=StringToDoubleInterval(
10024 argument_list[5].string_reference,(double) QuantumRange+1.0);
10025 if (attribute_flag[6] != 0)
10026 (void) QueryColorCompliance(argument_list[6].string_reference,
10027 AllCompliance,&image->background_color,exception);
10028 image=ExtentImage(image,&geometry,exception);
10031 case 94: /* Vignette */
10033 if (attribute_flag[0] != 0)
10035 flags=ParseGeometry(argument_list[0].string_reference,
10037 if ((flags & SigmaValue) == 0)
10038 geometry_info.sigma=1.0;
10039 if ((flags & XiValue) == 0)
10040 geometry_info.xi=0.1*image->columns;
10041 if ((flags & PsiValue) == 0)
10042 geometry_info.psi=0.1*image->rows;
10044 if (attribute_flag[1] != 0)
10045 geometry_info.rho=argument_list[1].real_reference;
10046 if (attribute_flag[2] != 0)
10047 geometry_info.sigma=argument_list[2].real_reference;
10048 if (attribute_flag[3] != 0)
10049 geometry_info.xi=argument_list[3].integer_reference;
10050 if (attribute_flag[4] != 0)
10051 geometry_info.psi=argument_list[4].integer_reference;
10052 if (attribute_flag[5] != 0)
10053 (void) QueryColorCompliance(argument_list[5].string_reference,
10054 AllCompliance,&image->background_color,exception);
10055 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10056 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10057 ceil(geometry_info.psi-0.5),exception);
10060 case 95: /* ContrastStretch */
10067 white_point=(double) image->columns*image->rows;
10068 if (attribute_flag[0] != 0)
10070 flags=ParseGeometry(argument_list[0].string_reference,
10072 black_point=geometry_info.rho;
10073 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10075 if ((flags & PercentValue) != 0)
10077 black_point*=(double) image->columns*image->rows/100.0;
10078 white_point*=(double) image->columns*image->rows/100.0;
10080 white_point=(double) image->columns*image->rows-
10083 if (attribute_flag[1] != 0)
10084 black_point=argument_list[1].real_reference;
10085 if (attribute_flag[2] != 0)
10086 white_point=argument_list[2].real_reference;
10087 if (attribute_flag[4] != 0)
10088 channel=(ChannelType) argument_list[4].integer_reference;
10089 channel_mask=SetImageChannelMask(image,channel);
10090 (void) ContrastStretchImage(image,black_point,white_point,exception);
10091 (void) SetImageChannelMask(image,channel_mask);
10094 case 96: /* Sans0 */
10098 case 97: /* Sans1 */
10102 case 98: /* AdaptiveSharpen */
10104 if (attribute_flag[0] != 0)
10106 flags=ParseGeometry(argument_list[0].string_reference,
10108 if ((flags & SigmaValue) == 0)
10109 geometry_info.sigma=1.0;
10110 if ((flags & XiValue) == 0)
10111 geometry_info.xi=0.0;
10113 if (attribute_flag[1] != 0)
10114 geometry_info.rho=argument_list[1].real_reference;
10115 if (attribute_flag[2] != 0)
10116 geometry_info.sigma=argument_list[2].real_reference;
10117 if (attribute_flag[3] != 0)
10118 geometry_info.xi=argument_list[3].real_reference;
10119 if (attribute_flag[4] != 0)
10120 channel=(ChannelType) argument_list[4].integer_reference;
10121 channel_mask=SetImageChannelMask(image,channel);
10122 image=AdaptiveSharpenImage(image,geometry_info.rho,
10123 geometry_info.sigma,exception);
10124 if (image != (Image *) NULL)
10125 (void) SetImageChannelMask(image,channel_mask);
10128 case 99: /* Transpose */
10130 image=TransposeImage(image,exception);
10133 case 100: /* Tranverse */
10135 image=TransverseImage(image,exception);
10138 case 101: /* AutoOrient */
10140 image=AutoOrientImage(image,image->orientation,exception);
10143 case 102: /* AdaptiveBlur */
10145 if (attribute_flag[0] != 0)
10147 flags=ParseGeometry(argument_list[0].string_reference,
10149 if ((flags & SigmaValue) == 0)
10150 geometry_info.sigma=1.0;
10151 if ((flags & XiValue) == 0)
10152 geometry_info.xi=0.0;
10154 if (attribute_flag[1] != 0)
10155 geometry_info.rho=argument_list[1].real_reference;
10156 if (attribute_flag[2] != 0)
10157 geometry_info.sigma=argument_list[2].real_reference;
10158 if (attribute_flag[3] != 0)
10159 channel=(ChannelType) argument_list[3].integer_reference;
10160 channel_mask=SetImageChannelMask(image,channel);
10161 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10163 if (image != (Image *) NULL)
10164 (void) SetImageChannelMask(image,channel_mask);
10167 case 103: /* Sketch */
10169 if (attribute_flag[0] != 0)
10171 flags=ParseGeometry(argument_list[0].string_reference,
10173 if ((flags & SigmaValue) == 0)
10174 geometry_info.sigma=1.0;
10175 if ((flags & XiValue) == 0)
10176 geometry_info.xi=1.0;
10178 if (attribute_flag[1] != 0)
10179 geometry_info.rho=argument_list[1].real_reference;
10180 if (attribute_flag[2] != 0)
10181 geometry_info.sigma=argument_list[2].real_reference;
10182 if (attribute_flag[3] != 0)
10183 geometry_info.xi=argument_list[3].real_reference;
10184 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10185 geometry_info.xi,exception);
10188 case 104: /* UniqueColors */
10190 image=UniqueImageColors(image,exception);
10193 case 105: /* AdaptiveResize */
10195 if (attribute_flag[0] != 0)
10196 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10197 &geometry,exception);
10198 if (attribute_flag[1] != 0)
10199 geometry.width=argument_list[1].integer_reference;
10200 if (attribute_flag[2] != 0)
10201 geometry.height=argument_list[2].integer_reference;
10202 if (attribute_flag[3] != 0)
10203 image->filter=(FilterTypes) argument_list[4].integer_reference;
10204 if (attribute_flag[4] != 0)
10205 SetImageArtifact(image,"filter:support",
10206 argument_list[4].string_reference);
10207 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10211 case 106: /* ClipMask */
10216 if (attribute_flag[0] == 0)
10218 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10220 goto PerlException;
10222 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10224 (void) NegateImage(mask_image,MagickFalse,exception);
10225 (void) SetImageMask(image,mask_image,exception);
10226 mask_image=DestroyImage(mask_image);
10229 case 107: /* LinearStretch */
10236 white_point=(double) image->columns*image->rows;
10237 if (attribute_flag[0] != 0)
10239 flags=ParseGeometry(argument_list[0].string_reference,
10241 if ((flags & SigmaValue) != 0)
10242 white_point=geometry_info.sigma;
10243 if ((flags & PercentValue) != 0)
10245 black_point*=(double) image->columns*image->rows/100.0;
10246 white_point*=(double) image->columns*image->rows/100.0;
10248 if ((flags & SigmaValue) == 0)
10249 white_point=(double) image->columns*image->rows-black_point;
10251 if (attribute_flag[1] != 0)
10252 black_point=argument_list[1].real_reference;
10253 if (attribute_flag[2] != 0)
10254 white_point=argument_list[2].real_reference;
10255 (void) LinearStretchImage(image,black_point,white_point,exception);
10258 case 108: /* ColorMatrix */
10272 if (attribute_flag[0] == 0)
10274 av=(AV *) argument_list[0].array_reference;
10275 order=(size_t) sqrt(av_len(av)+1);
10276 color_matrix=(double *) AcquireQuantumMemory(order,order*
10277 sizeof(*color_matrix));
10278 if (color_matrix == (double *) NULL)
10280 ThrowPerlException(exception,ResourceLimitFatalError,
10281 "MemoryAllocationFailed",PackageName);
10282 goto PerlException;
10284 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10285 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10286 for ( ; j < (ssize_t) (order*order); j++)
10287 color_matrix[j]=0.0;
10288 kernel_info=AcquireKernelInfo((const char *) NULL);
10289 if (kernel_info == (KernelInfo *) NULL)
10291 kernel_info->width=order;
10292 kernel_info->height=order;
10293 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10294 order*sizeof(*kernel_info->values));
10295 if (kernel_info->values != (MagickRealType *) NULL)
10297 for (i=0; i < (ssize_t) (order*order); i++)
10298 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10299 image=ColorMatrixImage(image,kernel_info,exception);
10301 kernel_info=DestroyKernelInfo(kernel_info);
10302 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10305 case 109: /* Mask */
10310 if (attribute_flag[0] == 0)
10312 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10314 goto PerlException;
10316 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10317 MagickTrue,exception);
10318 (void) NegateImage(mask_image,MagickFalse,exception);
10319 (void) SetImageMask(image,mask_image,exception);
10320 mask_image=DestroyImage(mask_image);
10323 case 110: /* Polaroid */
10334 PixelInterpolateMethod
10337 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10338 (DrawInfo *) NULL);
10339 caption=(char *) NULL;
10340 if (attribute_flag[0] != 0)
10341 caption=InterpretImageProperties(info ? info->image_info :
10342 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10345 if (attribute_flag[1] != 0)
10346 angle=argument_list[1].real_reference;
10347 if (attribute_flag[2] != 0)
10348 (void) CloneString(&draw_info->font,
10349 argument_list[2].string_reference);
10350 if (attribute_flag[3] != 0)
10351 (void) QueryColorCompliance(argument_list[3].string_reference,
10352 AllCompliance,&draw_info->stroke,exception);
10353 if (attribute_flag[4] != 0)
10354 (void) QueryColorCompliance(argument_list[4].string_reference,
10355 AllCompliance,&draw_info->fill,exception);
10356 if (attribute_flag[5] != 0)
10357 draw_info->stroke_width=argument_list[5].real_reference;
10358 if (attribute_flag[6] != 0)
10359 draw_info->pointsize=argument_list[6].real_reference;
10360 if (attribute_flag[7] != 0)
10361 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10362 if (attribute_flag[8] != 0)
10363 (void) QueryColorCompliance(argument_list[8].string_reference,
10364 AllCompliance,&image->background_color,exception);
10365 method=UndefinedInterpolatePixel;
10366 if (attribute_flag[9] != 0)
10367 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10368 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10369 draw_info=DestroyDrawInfo(draw_info);
10370 if (caption != (char *) NULL)
10371 caption=DestroyString(caption);
10374 case 111: /* FloodfillPaint */
10385 draw_info=CloneDrawInfo(info ? info->image_info :
10386 (ImageInfo *) NULL,(DrawInfo *) NULL);
10387 if (attribute_flag[0] != 0)
10388 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10389 &geometry,exception);
10390 if (attribute_flag[1] != 0)
10391 geometry.x=argument_list[1].integer_reference;
10392 if (attribute_flag[2] != 0)
10393 geometry.y=argument_list[2].integer_reference;
10394 if (attribute_flag[3] != 0)
10395 (void) QueryColorCompliance(argument_list[3].string_reference,
10396 AllCompliance,&draw_info->fill,exception);
10397 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10398 geometry.x,geometry.y,&target,exception);
10399 if (attribute_flag[4] != 0)
10400 QueryColorCompliance(argument_list[4].string_reference,
10401 AllCompliance,&target,exception);
10402 if (attribute_flag[5] != 0)
10403 image->fuzz=StringToDoubleInterval(
10404 argument_list[5].string_reference,(double) QuantumRange+1.0);
10405 if (attribute_flag[6] != 0)
10406 channel=(ChannelType) argument_list[6].integer_reference;
10407 invert=MagickFalse;
10408 if (attribute_flag[7] != 0)
10409 invert=(MagickBooleanType) argument_list[7].integer_reference;
10410 channel_mask=SetImageChannelMask(image,channel);
10411 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10412 geometry.y,invert,exception);
10413 (void) SetImageChannelMask(image,channel_mask);
10414 draw_info=DestroyDrawInfo(draw_info);
10417 case 112: /* Distort */
10429 number_coordinates;
10434 if (attribute_flag[0] == 0)
10436 method=UndefinedDistortion;
10437 if (attribute_flag[1] != 0)
10438 method=(DistortImageMethod) argument_list[1].integer_reference;
10439 av=(AV *) argument_list[0].array_reference;
10440 number_coordinates=(size_t) av_len(av)+1;
10441 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10442 sizeof(*coordinates));
10443 if (coordinates == (double *) NULL)
10445 ThrowPerlException(exception,ResourceLimitFatalError,
10446 "MemoryAllocationFailed",PackageName);
10447 goto PerlException;
10449 for (j=0; j < (ssize_t) number_coordinates; j++)
10450 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10451 virtual_pixel=UndefinedVirtualPixelMethod;
10452 if (attribute_flag[2] != 0)
10453 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10454 argument_list[2].integer_reference,exception);
10455 image=DistortImage(image,method,number_coordinates,coordinates,
10456 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10458 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10459 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10461 coordinates=(double *) RelinquishMagickMemory(coordinates);
10464 case 113: /* Clut */
10466 PixelInterpolateMethod
10469 if (attribute_flag[0] == 0)
10471 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10473 goto PerlException;
10475 method=UndefinedInterpolatePixel;
10476 if (attribute_flag[1] != 0)
10477 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10478 if (attribute_flag[2] != 0)
10479 channel=(ChannelType) argument_list[2].integer_reference;
10480 channel_mask=SetImageChannelMask(image,channel);
10481 (void) ClutImage(image,argument_list[0].image_reference,method,
10483 (void) SetImageChannelMask(image,channel_mask);
10486 case 114: /* LiquidRescale */
10488 if (attribute_flag[0] != 0)
10489 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10490 &geometry,exception);
10491 if (attribute_flag[1] != 0)
10492 geometry.width=argument_list[1].integer_reference;
10493 if (attribute_flag[2] != 0)
10494 geometry.height=argument_list[2].integer_reference;
10495 if (attribute_flag[3] == 0)
10496 argument_list[3].real_reference=1.0;
10497 if (attribute_flag[4] == 0)
10498 argument_list[4].real_reference=0.0;
10499 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10500 argument_list[3].real_reference,argument_list[4].real_reference,
10504 case 115: /* EncipherImage */
10506 (void) EncipherImage(image,argument_list[0].string_reference,
10510 case 116: /* DecipherImage */
10512 (void) DecipherImage(image,argument_list[0].string_reference,
10516 case 117: /* Deskew */
10518 geometry_info.rho=QuantumRange/2.0;
10519 if (attribute_flag[0] != 0)
10520 flags=ParseGeometry(argument_list[0].string_reference,
10522 if (attribute_flag[1] != 0)
10523 geometry_info.rho=StringToDoubleInterval(
10524 argument_list[1].string_reference,(double) QuantumRange+1.0);
10525 image=DeskewImage(image,geometry_info.rho,exception);
10528 case 118: /* Remap */
10533 if (attribute_flag[0] == 0)
10535 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10537 goto PerlException;
10539 quantize_info=AcquireQuantizeInfo(info->image_info);
10540 if (attribute_flag[1] != 0)
10541 quantize_info->dither_method=(DitherMethod)
10542 argument_list[1].integer_reference;
10543 (void) RemapImages(quantize_info,image,
10544 argument_list[0].image_reference,exception);
10545 quantize_info=DestroyQuantizeInfo(quantize_info);
10548 case 119: /* SparseColor */
10560 number_coordinates;
10565 if (attribute_flag[0] == 0)
10567 method=UndefinedColorInterpolate;
10568 if (attribute_flag[1] != 0)
10569 method=(SparseColorMethod) argument_list[1].integer_reference;
10570 av=(AV *) argument_list[0].array_reference;
10571 number_coordinates=(size_t) av_len(av)+1;
10572 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10573 sizeof(*coordinates));
10574 if (coordinates == (double *) NULL)
10576 ThrowPerlException(exception,ResourceLimitFatalError,
10577 "MemoryAllocationFailed",PackageName);
10578 goto PerlException;
10580 for (j=0; j < (ssize_t) number_coordinates; j++)
10581 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10582 virtual_pixel=UndefinedVirtualPixelMethod;
10583 if (attribute_flag[2] != 0)
10584 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10585 argument_list[2].integer_reference,exception);
10586 if (attribute_flag[3] != 0)
10587 channel=(ChannelType) argument_list[3].integer_reference;
10588 channel_mask=SetImageChannelMask(image,channel);
10589 image=SparseColorImage(image,method,number_coordinates,coordinates,
10591 if (image != (Image *) NULL)
10592 (void) SetImageChannelMask(image,channel_mask);
10593 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10594 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10596 coordinates=(double *) RelinquishMagickMemory(coordinates);
10599 case 120: /* Function */
10616 if (attribute_flag[0] == 0)
10618 function=UndefinedFunction;
10619 if (attribute_flag[1] != 0)
10620 function=(MagickFunction) argument_list[1].integer_reference;
10621 av=(AV *) argument_list[0].array_reference;
10622 number_parameters=(size_t) av_len(av)+1;
10623 parameters=(double *) AcquireQuantumMemory(number_parameters,
10624 sizeof(*parameters));
10625 if (parameters == (double *) NULL)
10627 ThrowPerlException(exception,ResourceLimitFatalError,
10628 "MemoryAllocationFailed",PackageName);
10629 goto PerlException;
10631 for (j=0; j < (ssize_t) number_parameters; j++)
10632 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10633 virtual_pixel=UndefinedVirtualPixelMethod;
10634 if (attribute_flag[2] != 0)
10635 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10636 argument_list[2].integer_reference,exception);
10637 (void) FunctionImage(image,function,number_parameters,parameters,
10639 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10640 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10642 parameters=(double *) RelinquishMagickMemory(parameters);
10645 case 121: /* SelectiveBlur */
10647 if (attribute_flag[0] != 0)
10649 flags=ParseGeometry(argument_list[0].string_reference,
10651 if ((flags & SigmaValue) == 0)
10652 geometry_info.sigma=1.0;
10653 if ((flags & PercentValue) != 0)
10654 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10656 if (attribute_flag[1] != 0)
10657 geometry_info.rho=argument_list[1].real_reference;
10658 if (attribute_flag[2] != 0)
10659 geometry_info.sigma=argument_list[2].real_reference;
10660 if (attribute_flag[3] != 0)
10661 geometry_info.xi=argument_list[3].integer_reference;;
10662 if (attribute_flag[5] != 0)
10663 channel=(ChannelType) argument_list[5].integer_reference;
10664 channel_mask=SetImageChannelMask(image,channel);
10665 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10666 geometry_info.xi,exception);
10667 if (image != (Image *) NULL)
10668 (void) SetImageChannelMask(image,channel_mask);
10671 case 122: /* HaldClut */
10673 if (attribute_flag[0] == 0)
10675 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10677 goto PerlException;
10679 if (attribute_flag[1] != 0)
10680 channel=(ChannelType) argument_list[1].integer_reference;
10681 channel_mask=SetImageChannelMask(image,channel);
10682 (void) HaldClutImage(image,argument_list[0].image_reference,
10684 (void) SetImageChannelMask(image,channel_mask);
10687 case 123: /* BlueShift */
10689 if (attribute_flag[0] != 0)
10690 (void) ParseGeometry(argument_list[0].string_reference,
10692 image=BlueShiftImage(image,geometry_info.rho,exception);
10695 case 124: /* ForwardFourierTransformImage */
10697 image=ForwardFourierTransformImage(image,
10698 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10702 case 125: /* InverseFourierTransformImage */
10704 image=InverseFourierTransformImage(image,image->next,
10705 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10709 case 126: /* ColorDecisionList */
10711 if (attribute_flag[0] == 0)
10712 argument_list[0].string_reference=(char *) NULL;
10713 (void) ColorDecisionListImage(image,
10714 argument_list[0].string_reference,exception);
10717 case 127: /* AutoGamma */
10719 if (attribute_flag[0] != 0)
10720 channel=(ChannelType) argument_list[0].integer_reference;
10721 channel_mask=SetImageChannelMask(image,channel);
10722 (void) AutoGammaImage(image,exception);
10723 (void) SetImageChannelMask(image,channel_mask);
10726 case 128: /* AutoLevel */
10728 if (attribute_flag[0] != 0)
10729 channel=(ChannelType) argument_list[0].integer_reference;
10730 channel_mask=SetImageChannelMask(image,channel);
10731 (void) AutoLevelImage(image,exception);
10732 (void) SetImageChannelMask(image,channel_mask);
10735 case 129: /* LevelColors */
10741 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
10743 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
10745 if (attribute_flag[1] != 0)
10746 (void) QueryColorCompliance(
10747 argument_list[1].string_reference,AllCompliance,&black_point,
10749 if (attribute_flag[2] != 0)
10750 (void) QueryColorCompliance(
10751 argument_list[2].string_reference,AllCompliance,&white_point,
10753 if (attribute_flag[3] != 0)
10754 channel=(ChannelType) argument_list[3].integer_reference;
10755 channel_mask=SetImageChannelMask(image,channel);
10756 (void) LevelImageColors(image,&black_point,&white_point,
10757 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
10759 (void) SetImageChannelMask(image,channel_mask);
10762 case 130: /* Clamp */
10764 if (attribute_flag[0] != 0)
10765 channel=(ChannelType) argument_list[0].integer_reference;
10766 channel_mask=SetImageChannelMask(image,channel);
10767 (void) ClampImage(image,exception);
10768 (void) SetImageChannelMask(image,channel_mask);
10771 case 131: /* BrightnessContrast */
10779 if (attribute_flag[0] != 0)
10781 flags=ParseGeometry(argument_list[0].string_reference,
10783 brightness=geometry_info.rho;
10784 if ((flags & SigmaValue) == 0)
10785 contrast=geometry_info.sigma;
10787 if (attribute_flag[1] != 0)
10788 brightness=argument_list[1].real_reference;
10789 if (attribute_flag[2] != 0)
10790 contrast=argument_list[2].real_reference;
10791 if (attribute_flag[4] != 0)
10792 channel=(ChannelType) argument_list[4].integer_reference;
10793 channel_mask=SetImageChannelMask(image,channel);
10794 (void) BrightnessContrastImage(image,brightness,contrast,exception);
10795 (void) SetImageChannelMask(image,channel_mask);
10798 case 132: /* Morphology */
10809 if (attribute_flag[0] == 0)
10811 kernel=AcquireKernelInfo(argument_list[0].string_reference);
10812 if (kernel == (KernelInfo *) NULL)
10814 if (attribute_flag[1] != 0)
10815 channel=(ChannelType) argument_list[1].integer_reference;
10816 method=UndefinedMorphology;
10817 if (attribute_flag[2] != 0)
10818 method=argument_list[2].integer_reference;
10820 if (attribute_flag[3] != 0)
10821 iterations=argument_list[3].integer_reference;
10822 channel_mask=SetImageChannelMask(image,channel);
10823 image=MorphologyImage(image,method,iterations,kernel,exception);
10824 if (image != (Image *) NULL)
10825 (void) SetImageChannelMask(image,channel_mask);
10826 kernel=DestroyKernelInfo(kernel);
10829 case 133: /* Mode */
10831 if (attribute_flag[0] != 0)
10833 flags=ParseGeometry(argument_list[0].string_reference,
10835 if ((flags & SigmaValue) == 0)
10836 geometry_info.sigma=1.0;
10838 if (attribute_flag[1] != 0)
10839 geometry_info.rho=argument_list[1].real_reference;
10840 if (attribute_flag[2] != 0)
10841 geometry_info.sigma=argument_list[2].real_reference;
10842 if (attribute_flag[3] != 0)
10843 channel=(ChannelType) argument_list[3].integer_reference;
10844 channel_mask=SetImageChannelMask(image,channel);
10845 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
10846 (size_t) geometry_info.sigma,exception);
10847 if (image != (Image *) NULL)
10848 (void) SetImageChannelMask(image,channel_mask);
10851 case 134: /* Statistic */
10856 statistic=UndefinedStatistic;
10857 if (attribute_flag[0] != 0)
10859 flags=ParseGeometry(argument_list[0].string_reference,
10861 if ((flags & SigmaValue) == 0)
10862 geometry_info.sigma=1.0;
10864 if (attribute_flag[1] != 0)
10865 geometry_info.rho=argument_list[1].real_reference;
10866 if (attribute_flag[2] != 0)
10867 geometry_info.sigma=argument_list[2].real_reference;
10868 if (attribute_flag[3] != 0)
10869 channel=(ChannelType) argument_list[3].integer_reference;
10870 if (attribute_flag[4] != 0)
10871 statistic=(StatisticType) argument_list[4].integer_reference;
10872 channel_mask=SetImageChannelMask(image,channel);
10873 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
10874 (size_t) geometry_info.sigma,exception);
10875 if (image != (Image *) NULL)
10876 (void) SetImageChannelMask(image,channel_mask);
10879 case 135: /* Perceptible */
10884 epsilon=MagickEpsilon;
10885 if (attribute_flag[0] != 0)
10886 epsilon=argument_list[0].real_reference;
10887 if (attribute_flag[1] != 0)
10888 channel=(ChannelType) argument_list[1].integer_reference;
10889 channel_mask=SetImageChannelMask(image,channel);
10890 (void) PerceptibleImage(image,epsilon,exception);
10891 (void) SetImageChannelMask(image,channel_mask);
10894 case 136: /* Poly */
10905 if (attribute_flag[0] == 0)
10907 if (attribute_flag[1] != 0)
10908 channel=(ChannelType) argument_list[1].integer_reference;
10909 av=(AV *) argument_list[0].array_reference;
10910 number_terms=(size_t) av_len(av);
10911 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
10912 if (terms == (double *) NULL)
10914 ThrowPerlException(exception,ResourceLimitFatalError,
10915 "MemoryAllocationFailed",PackageName);
10916 goto PerlException;
10918 for (j=0; j < av_len(av); j++)
10919 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
10920 image=PolynomialImage(image,number_terms >> 1,terms,exception);
10921 terms=(double *) RelinquishMagickMemory(terms);
10925 if (next != (Image *) NULL)
10926 (void) CatchImageException(next);
10927 if (region_image != (Image *) NULL)
10932 status=CompositeImage(region_image,image,CopyCompositeOp,MagickTrue,
10933 region_info.x,region_info.y,exception);
10935 (void) CatchImageException(region_image);
10936 image=DestroyImage(image);
10937 image=region_image;
10939 if (image != (Image *) NULL)
10942 if (next && (next != image))
10944 image->next=next->next;
10945 if (image->next != (Image *) NULL)
10946 image->next->previous=image;
10947 DeleteImageFromRegistry(*pv,next);
10949 sv_setiv(*pv,PTR2IV(image));
10957 if (reference_vector)
10958 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
10959 InheritPerlException(exception,perl_exception);
10960 exception=DestroyExceptionInfo(exception);
10961 sv_setiv(perl_exception,(IV) number_images);
10962 SvPOK_on(perl_exception);
10963 ST(0)=sv_2mortal(perl_exception);
10968 ###############################################################################
10976 ###############################################################################
10981 Image::Magick::Q16HDRI ref=NO_INIT
11026 PERL_UNUSED_VAR(ref);
11027 PERL_UNUSED_VAR(ix);
11028 exception=AcquireExceptionInfo();
11029 perl_exception=newSVpv("",0);
11032 if (sv_isobject(ST(0)) == 0)
11034 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11036 goto PerlException;
11038 reference=SvRV(ST(0));
11039 hv=SvSTASH(reference);
11041 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11043 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11044 if (image == (Image *) NULL)
11046 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11048 goto PerlException;
11053 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11054 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11055 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11057 for (i=2; i < items; i+=2)
11059 attribute=(char *) SvPV(ST(i-1),na);
11060 switch (*attribute)
11065 if (LocaleCompare(attribute,"background") == 0)
11067 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11068 &montage_info->background_color,exception);
11069 for (next=image; next; next=next->next)
11070 next->background_color=montage_info->background_color;
11073 if (LocaleCompare(attribute,"border") == 0)
11075 montage_info->border_width=SvIV(ST(i));
11078 if (LocaleCompare(attribute,"bordercolor") == 0)
11080 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11081 &montage_info->border_color,exception);
11082 for (next=image; next; next=next->next)
11083 next->border_color=montage_info->border_color;
11086 if (LocaleCompare(attribute,"borderwidth") == 0)
11088 montage_info->border_width=SvIV(ST(i));
11091 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11098 if (LocaleCompare(attribute,"compose") == 0)
11100 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11101 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11104 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11108 for (next=image; next; next=next->next)
11109 next->compose=(CompositeOperator) sp;
11112 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11119 if (LocaleCompare(attribute,"fill") == 0)
11121 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11122 &montage_info->fill,exception);
11125 if (LocaleCompare(attribute,"font") == 0)
11127 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11130 if (LocaleCompare(attribute,"frame") == 0)
11136 if (IsGeometry(p) == MagickFalse)
11138 ThrowPerlException(exception,OptionError,"MissingGeometry",
11142 (void) CloneString(&montage_info->frame,p);
11144 montage_info->frame=(char *) NULL;
11147 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11154 if (LocaleCompare(attribute,"geometry") == 0)
11160 if (IsGeometry(p) == MagickFalse)
11162 ThrowPerlException(exception,OptionError,"MissingGeometry",
11166 (void) CloneString(&montage_info->geometry,p);
11168 montage_info->geometry=(char *) NULL;
11171 if (LocaleCompare(attribute,"gravity") == 0)
11176 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11177 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11180 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11184 montage_info->gravity=(GravityType) in;
11185 for (next=image; next; next=next->next)
11186 next->gravity=(GravityType) in;
11189 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11196 if (LocaleCompare(attribute,"label") == 0)
11198 for (next=image; next; next=next->next)
11199 (void) SetImageProperty(next,"label",InterpretImageProperties(
11200 info ? info->image_info : (ImageInfo *) NULL,next,
11201 SvPV(ST(i),na),exception),exception);
11204 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11211 if (LocaleCompare(attribute,"mattecolor") == 0)
11213 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11214 &montage_info->matte_color,exception);
11215 for (next=image; next; next=next->next)
11216 next->matte_color=montage_info->matte_color;
11219 if (LocaleCompare(attribute,"mode") == 0)
11224 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11225 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11230 ThrowPerlException(exception,OptionError,
11231 "UnrecognizedModeType",SvPV(ST(i),na));
11236 (void) CloneString(&montage_info->frame,"15x15+3+3");
11237 montage_info->shadow=MagickTrue;
11242 montage_info->frame=(char *) NULL;
11243 montage_info->shadow=MagickFalse;
11244 montage_info->border_width=0;
11247 case ConcatenateMode:
11249 montage_info->frame=(char *) NULL;
11250 montage_info->shadow=MagickFalse;
11251 (void) CloneString(&montage_info->geometry,"+0+0");
11252 montage_info->border_width=0;
11257 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11264 if (LocaleCompare(attribute,"pointsize") == 0)
11266 montage_info->pointsize=SvIV(ST(i));
11269 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11276 if (LocaleCompare(attribute,"shadow") == 0)
11278 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11279 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11282 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11286 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11289 if (LocaleCompare(attribute,"stroke") == 0)
11291 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11292 &montage_info->stroke,exception);
11295 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11302 if (LocaleCompare(attribute,"texture") == 0)
11304 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11307 if (LocaleCompare(attribute,"tile") == 0)
11309 char *p=SvPV(ST(i),na);
11310 if (IsGeometry(p) == MagickFalse)
11312 ThrowPerlException(exception,OptionError,"MissingGeometry",
11316 (void) CloneString(&montage_info->tile,p);
11318 montage_info->tile=(char *) NULL;
11321 if (LocaleCompare(attribute,"title") == 0)
11323 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11326 if (LocaleCompare(attribute,"transparent") == 0)
11331 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11332 &transparent_color,exception);
11333 for (next=image; next; next=next->next)
11334 (void) TransparentPaintImage(next,&transparent_color,
11335 TransparentAlpha,MagickFalse,exception);
11338 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11344 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11350 image=MontageImageList(info->image_info,montage_info,image,exception);
11351 montage_info=DestroyMontageInfo(montage_info);
11352 if (image == (Image *) NULL)
11353 goto PerlException;
11354 if (transparent_color.alpha != TransparentAlpha)
11355 for (next=image; next; next=next->next)
11356 (void) TransparentPaintImage(next,&transparent_color,
11357 TransparentAlpha,MagickFalse,exception);
11358 for ( ; image; image=image->next)
11360 AddImageToRegistry(sv,image);
11362 av_push(av,sv_bless(rv,hv));
11365 exception=DestroyExceptionInfo(exception);
11366 ST(0)=av_reference;
11367 SvREFCNT_dec(perl_exception);
11371 InheritPerlException(exception,perl_exception);
11372 exception=DestroyExceptionInfo(exception);
11373 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11374 SvPOK_on(perl_exception);
11375 ST(0)=sv_2mortal(perl_exception);
11380 ###############################################################################
11388 ###############################################################################
11393 Image::Magick::Q16HDRI ref=NO_INIT
11431 PERL_UNUSED_VAR(ref);
11432 PERL_UNUSED_VAR(ix);
11433 exception=AcquireExceptionInfo();
11434 perl_exception=newSVpv("",0);
11438 if (sv_isobject(ST(0)) == 0)
11440 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11442 goto PerlException;
11444 reference=SvRV(ST(0));
11445 hv=SvSTASH(reference);
11447 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11449 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11450 if (image == (Image *) NULL)
11452 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11454 goto PerlException;
11456 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11461 for (i=2; i < items; i+=2)
11463 attribute=(char *) SvPV(ST(i-1),na);
11464 switch (*attribute)
11469 if (LocaleCompare(attribute,"frames") == 0)
11471 number_frames=SvIV(ST(i));
11474 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11480 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11486 image=MorphImages(image,number_frames,exception);
11487 if (image == (Image *) NULL)
11488 goto PerlException;
11489 for ( ; image; image=image->next)
11491 AddImageToRegistry(sv,image);
11493 av_push(av,sv_bless(rv,hv));
11496 exception=DestroyExceptionInfo(exception);
11497 ST(0)=av_reference;
11498 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11502 InheritPerlException(exception,perl_exception);
11503 exception=DestroyExceptionInfo(exception);
11504 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11505 SvPOK_on(perl_exception);
11506 ST(0)=sv_2mortal(perl_exception);
11511 ###############################################################################
11519 ###############################################################################
11524 Image::Magick::Q16HDRI ref=NO_INIT
11552 PERL_UNUSED_VAR(ref);
11553 PERL_UNUSED_VAR(ix);
11554 exception=AcquireExceptionInfo();
11555 perl_exception=newSVpv("",0);
11557 if (sv_isobject(ST(0)) == 0)
11559 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11561 goto PerlException;
11563 reference=SvRV(ST(0));
11564 hv=SvSTASH(reference);
11565 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11566 if (image == (Image *) NULL)
11568 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11570 goto PerlException;
11572 image=MergeImageLayers(image,MosaicLayer,exception);
11574 Create blessed Perl array for the returned image.
11577 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11579 AddImageToRegistry(sv,image);
11581 av_push(av,sv_bless(rv,hv));
11583 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11584 (void) CopyMagickString(info->image_info->filename,image->filename,
11586 SetImageInfo(info->image_info,0,exception);
11587 exception=DestroyExceptionInfo(exception);
11588 SvREFCNT_dec(perl_exception);
11592 InheritPerlException(exception,perl_exception);
11593 exception=DestroyExceptionInfo(exception);
11594 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11595 SvPOK_on(perl_exception); /* return messages in string context */
11596 ST(0)=sv_2mortal(perl_exception);
11601 ###############################################################################
11609 ###############################################################################
11614 Image::Magick::Q16HDRI ref=NO_INIT
11664 PERL_UNUSED_VAR(ref);
11665 PERL_UNUSED_VAR(ix);
11666 exception=AcquireExceptionInfo();
11667 perl_exception=newSVpv("",0);
11668 package_info=(struct PackageInfo *) NULL;
11669 ac=(items < 2) ? 1 : items-1;
11670 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
11672 length=(STRLEN *) NULL;
11673 if (list == (char **) NULL)
11675 ThrowPerlException(exception,ResourceLimitError,
11676 "MemoryAllocationFailed",PackageName);
11677 goto PerlException;
11680 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
11681 if (length == (STRLEN *) NULL)
11683 ThrowPerlException(exception,ResourceLimitError,
11684 "MemoryAllocationFailed",PackageName);
11685 goto PerlException;
11687 if (sv_isobject(ST(0)) == 0)
11689 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11691 goto PerlException;
11693 reference=SvRV(ST(0));
11694 if (SvTYPE(reference) != SVt_PVAV)
11696 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11698 goto PerlException;
11700 av=(AV *) reference;
11701 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
11703 package_info=ClonePackageInfo(info,exception);
11706 *list=(char *) (*package_info->image_info->filename ?
11707 package_info->image_info->filename : "XC:black");
11709 for (n=0, i=0; i < ac; i++)
11711 list[n]=(char *) SvPV(ST(i+1),length[n]);
11712 if ((items >= 3) && strEQcase(list[n],"blob"))
11718 blob=(void *) (SvPV(ST(i+1),length[n]));
11719 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
11721 if ((items >= 3) && strEQcase(list[n],"filename"))
11723 if ((items >= 3) && strEQcase(list[n],"file"))
11732 io_info=IoIFP(sv_2io(ST(i+1)));
11733 if (io_info == (PerlIO *) NULL)
11735 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11739 file=PerlIO_findFILE(io_info);
11740 if (file == (FILE *) NULL)
11742 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
11746 SetImageInfoFile(package_info->image_info,file);
11748 if ((items >= 3) && strEQcase(list[n],"magick"))
11752 list[n]=(char *) NULL;
11754 status=ExpandFilenames(&n,&list);
11755 if (status == MagickFalse)
11757 ThrowPerlException(exception,ResourceLimitError,
11758 "MemoryAllocationFailed",PackageName);
11759 goto PerlException;
11762 for (i=0; i < n; i++)
11764 (void) CopyMagickString(package_info->image_info->filename,list[i],
11766 image=PingImage(package_info->image_info,exception);
11767 if (image == (Image *) NULL)
11769 if ((package_info->image_info->file != (FILE *) NULL) ||
11770 (package_info->image_info->blob != (void *) NULL))
11771 DisassociateImageStream(image);
11772 count+=GetImageListLength(image);
11773 EXTEND(sp,4*count);
11774 for (next=image; next; next=next->next)
11776 PUSHs(sv_2mortal(newSViv(next->columns)));
11777 PUSHs(sv_2mortal(newSViv(next->rows)));
11778 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
11779 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
11781 image=DestroyImageList(image);
11786 for (i=0; i < n; i++)
11787 if (list[i] != (char *) NULL)
11788 for (p=keep; list[i] != *p++; )
11791 list[i]=(char *) RelinquishMagickMemory(list[i]);
11796 if (package_info != (struct PackageInfo *) NULL)
11797 DestroyPackageInfo(package_info);
11798 if (list && (list != keep))
11799 list=(char **) RelinquishMagickMemory(list);
11801 keep=(char **) RelinquishMagickMemory(keep);
11803 length=(STRLEN *) RelinquishMagickMemory(length);
11804 InheritPerlException(exception,perl_exception);
11805 exception=DestroyExceptionInfo(exception);
11806 SvREFCNT_dec(perl_exception); /* throw away all errors */
11810 ###############################################################################
11818 ###############################################################################
11823 Image::Magick::Q16HDRI ref=NO_INIT
11856 PERL_UNUSED_VAR(ref);
11857 PERL_UNUSED_VAR(ix);
11858 exception=AcquireExceptionInfo();
11859 perl_exception=newSVpv("",0);
11862 if (sv_isobject(ST(0)) == 0)
11864 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11866 goto PerlException;
11868 reference=SvRV(ST(0));
11869 hv=SvSTASH(reference);
11871 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11873 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11874 if (image == (Image *) NULL)
11876 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11878 goto PerlException;
11880 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11881 preview_type=GammaPreview;
11883 preview_type=(PreviewType)
11884 ParseCommandOption(MagickPreviewOptions,MagickFalse,SvPV(ST(1),na));
11885 for ( ; image; image=image->next)
11887 preview_image=PreviewImage(image,preview_type,exception);
11888 if (preview_image == (Image *) NULL)
11889 goto PerlException;
11890 AddImageToRegistry(sv,preview_image);
11892 av_push(av,sv_bless(rv,hv));
11895 exception=DestroyExceptionInfo(exception);
11896 ST(0)=av_reference;
11897 SvREFCNT_dec(perl_exception); /* can't return warning messages */
11901 InheritPerlException(exception,perl_exception);
11902 exception=DestroyExceptionInfo(exception);
11903 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11904 SvPOK_on(perl_exception);
11905 ST(0)=sv_2mortal(perl_exception);
11910 ###############################################################################
11914 # Q u e r y C o l o r #
11918 ###############################################################################
11922 QueryColor(ref,...)
11923 Image::Magick::Q16HDRI ref=NO_INIT
11943 PERL_UNUSED_VAR(ref);
11944 PERL_UNUSED_VAR(ix);
11945 exception=AcquireExceptionInfo();
11946 perl_exception=newSVpv("",0);
11955 colorlist=GetColorInfoList("*",&colors,exception);
11957 for (i=0; i < (ssize_t) colors; i++)
11959 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
11961 colorlist=(const ColorInfo **)
11962 RelinquishMagickMemory((ColorInfo **) colorlist);
11963 goto PerlException;
11965 EXTEND(sp,5*items);
11966 for (i=1; i < items; i++)
11968 name=(char *) SvPV(ST(i),na);
11969 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
11974 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
11975 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
11976 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
11977 if (color.colorspace == CMYKColorspace)
11978 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
11979 if (color.alpha_trait == BlendPixelTrait)
11980 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
11984 InheritPerlException(exception,perl_exception);
11985 exception=DestroyExceptionInfo(exception);
11986 SvREFCNT_dec(perl_exception);
11990 ###############################################################################
11994 # Q u e r y C o l o r N a m e #
11998 ###############################################################################
12002 QueryColorname(ref,...)
12003 Image::Magick::Q16HDRI ref=NO_INIT
12012 message[MaxTextExtent];
12031 *reference; /* reference is the SV* of ref=SvIV(reference) */
12033 PERL_UNUSED_VAR(ref);
12034 PERL_UNUSED_VAR(ix);
12035 exception=AcquireExceptionInfo();
12036 perl_exception=newSVpv("",0);
12037 reference=SvRV(ST(0));
12038 av=(AV *) reference;
12039 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12041 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12042 if (image == (Image *) NULL)
12044 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12046 goto PerlException;
12049 for (i=1; i < items; i++)
12051 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12053 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12055 PUSHs(sv_2mortal(newSVpv(message,0)));
12059 InheritPerlException(exception,perl_exception);
12060 exception=DestroyExceptionInfo(exception);
12061 SvREFCNT_dec(perl_exception);
12065 ###############################################################################
12069 # Q u e r y F o n t #
12073 ###############################################################################
12078 Image::Magick::Q16HDRI ref=NO_INIT
12085 message[MaxTextExtent];
12096 volatile const TypeInfo
12099 PERL_UNUSED_VAR(ref);
12100 PERL_UNUSED_VAR(ix);
12101 exception=AcquireExceptionInfo();
12102 perl_exception=newSVpv("",0);
12111 typelist=GetTypeInfoList("*",&types,exception);
12113 for (i=0; i < (ssize_t) types; i++)
12115 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12117 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12119 goto PerlException;
12121 EXTEND(sp,10*items);
12122 for (i=1; i < items; i++)
12124 name=(char *) SvPV(ST(i),na);
12125 type_info=GetTypeInfo(name,exception);
12126 if (type_info == (TypeInfo *) NULL)
12131 if (type_info->name == (char *) NULL)
12134 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12135 if (type_info->description == (char *) NULL)
12138 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12139 if (type_info->family == (char *) NULL)
12142 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12143 if (type_info->style == UndefinedStyle)
12146 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12147 type_info->style),0)));
12148 if (type_info->stretch == UndefinedStretch)
12151 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12152 type_info->stretch),0)));
12153 (void) FormatLocaleString(message,MaxTextExtent,"%.20g",(double)
12154 type_info->weight);
12155 PUSHs(sv_2mortal(newSVpv(message,0)));
12156 if (type_info->encoding == (char *) NULL)
12159 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12160 if (type_info->foundry == (char *) NULL)
12163 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12164 if (type_info->format == (char *) NULL)
12167 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12168 if (type_info->metrics == (char *) NULL)
12171 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12172 if (type_info->glyphs == (char *) NULL)
12175 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12179 InheritPerlException(exception,perl_exception);
12180 exception=DestroyExceptionInfo(exception);
12181 SvREFCNT_dec(perl_exception);
12185 ###############################################################################
12189 # Q u e r y F o n t M e t r i c s #
12193 ###############################################################################
12197 QueryFontMetrics(ref,...)
12198 Image::Magick::Q16HDRI ref=NO_INIT
12200 queryfontmetrics = 1
12247 *reference; /* reference is the SV* of ref=SvIV(reference) */
12252 PERL_UNUSED_VAR(ref);
12253 PERL_UNUSED_VAR(ix);
12254 exception=AcquireExceptionInfo();
12255 package_info=(struct PackageInfo *) NULL;
12256 perl_exception=newSVpv("",0);
12257 reference=SvRV(ST(0));
12258 av=(AV *) reference;
12259 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12261 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12262 if (image == (Image *) NULL)
12264 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12266 goto PerlException;
12268 package_info=ClonePackageInfo(info,exception);
12269 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12270 CloneString(&draw_info->text,"");
12271 current=draw_info->affine;
12272 GetAffineMatrix(&affine);
12275 EXTEND(sp,7*items);
12276 for (i=2; i < items; i+=2)
12278 attribute=(char *) SvPV(ST(i-1),na);
12279 switch (*attribute)
12284 if (LocaleCompare(attribute,"antialias") == 0)
12286 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12290 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12294 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12297 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12304 if (LocaleCompare(attribute,"density") == 0)
12306 CloneString(&draw_info->density,SvPV(ST(i),na));
12309 if (LocaleCompare(attribute,"direction") == 0)
12311 draw_info->direction=(DirectionType) ParseCommandOption(
12312 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
12315 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12322 if (LocaleCompare(attribute,"encoding") == 0)
12324 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12327 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12334 if (LocaleCompare(attribute,"family") == 0)
12336 CloneString(&draw_info->family,SvPV(ST(i),na));
12339 if (LocaleCompare(attribute,"fill") == 0)
12342 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12343 &draw_info->fill,exception);
12346 if (LocaleCompare(attribute,"font") == 0)
12348 CloneString(&draw_info->font,SvPV(ST(i),na));
12351 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12358 if (LocaleCompare(attribute,"geometry") == 0)
12360 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12363 if (LocaleCompare(attribute,"gravity") == 0)
12365 draw_info->gravity=(GravityType) ParseCommandOption(
12366 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12369 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12376 if (LocaleCompare(attribute,"interline-spacing") == 0)
12378 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12379 draw_info->interline_spacing=geometry_info.rho;
12382 if (LocaleCompare(attribute,"interword-spacing") == 0)
12384 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12385 draw_info->interword_spacing=geometry_info.rho;
12388 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12395 if (LocaleCompare(attribute,"kerning") == 0)
12397 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12398 draw_info->kerning=geometry_info.rho;
12401 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12408 if (LocaleCompare(attribute,"pointsize") == 0)
12410 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12411 draw_info->pointsize=geometry_info.rho;
12414 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12421 if (LocaleCompare(attribute,"rotate") == 0)
12423 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12424 affine.rx=geometry_info.rho;
12425 affine.ry=geometry_info.sigma;
12426 if ((flags & SigmaValue) == 0)
12427 affine.ry=affine.rx;
12430 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12437 if (LocaleCompare(attribute,"scale") == 0)
12439 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12440 affine.sx=geometry_info.rho;
12441 affine.sy=geometry_info.sigma;
12442 if ((flags & SigmaValue) == 0)
12443 affine.sy=affine.sx;
12446 if (LocaleCompare(attribute,"skew") == 0)
12452 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12453 x_angle=geometry_info.rho;
12454 y_angle=geometry_info.sigma;
12455 if ((flags & SigmaValue) == 0)
12457 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12458 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12461 if (LocaleCompare(attribute,"stroke") == 0)
12464 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12465 &draw_info->stroke,exception);
12468 if (LocaleCompare(attribute,"style") == 0)
12470 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12474 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12478 draw_info->style=(StyleType) type;
12481 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12488 if (LocaleCompare(attribute,"text") == 0)
12490 CloneString(&draw_info->text,SvPV(ST(i),na));
12493 if (LocaleCompare(attribute,"translate") == 0)
12495 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12496 affine.tx=geometry_info.rho;
12497 affine.ty=geometry_info.sigma;
12498 if ((flags & SigmaValue) == 0)
12499 affine.ty=affine.tx;
12502 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12509 if (LocaleCompare(attribute,"weight") == 0)
12511 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12512 draw_info->weight=(size_t) geometry_info.rho;
12515 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12522 if (LocaleCompare(attribute,"x") == 0)
12524 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12525 x=geometry_info.rho;
12528 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12535 if (LocaleCompare(attribute,"y") == 0)
12537 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12538 y=geometry_info.rho;
12541 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12547 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12553 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12554 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12555 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12556 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12557 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12558 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12559 if (draw_info->geometry == (char *) NULL)
12561 draw_info->geometry=AcquireString((char *) NULL);
12562 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12563 "%.15g,%.15g",x,y);
12565 status=GetTypeMetrics(image,draw_info,&metrics,exception);
12566 (void) CatchImageException(image);
12567 if (status == MagickFalse)
12571 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12572 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12573 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12574 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12575 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12576 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12577 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12578 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12579 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12580 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12581 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12582 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12583 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12585 draw_info=DestroyDrawInfo(draw_info);
12588 if (package_info != (struct PackageInfo *) NULL)
12589 DestroyPackageInfo(package_info);
12590 InheritPerlException(exception,perl_exception);
12591 exception=DestroyExceptionInfo(exception);
12592 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12596 ###############################################################################
12600 # 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 #
12604 ###############################################################################
12608 QueryMultilineFontMetrics(ref,...)
12609 Image::Magick::Q16HDRI ref=NO_INIT
12611 querymultilinefontmetrics = 1
12658 *reference; /* reference is the SV* of ref=SvIV(reference) */
12663 PERL_UNUSED_VAR(ref);
12664 PERL_UNUSED_VAR(ix);
12665 exception=AcquireExceptionInfo();
12666 package_info=(struct PackageInfo *) NULL;
12667 perl_exception=newSVpv("",0);
12668 reference=SvRV(ST(0));
12669 av=(AV *) reference;
12670 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12672 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12673 if (image == (Image *) NULL)
12675 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12677 goto PerlException;
12679 package_info=ClonePackageInfo(info,exception);
12680 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12681 CloneString(&draw_info->text,"");
12682 current=draw_info->affine;
12683 GetAffineMatrix(&affine);
12686 EXTEND(sp,7*items);
12687 for (i=2; i < items; i+=2)
12689 attribute=(char *) SvPV(ST(i-1),na);
12690 switch (*attribute)
12695 if (LocaleCompare(attribute,"antialias") == 0)
12697 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12701 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12705 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12708 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12715 if (LocaleCompare(attribute,"density") == 0)
12717 CloneString(&draw_info->density,SvPV(ST(i),na));
12720 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12727 if (LocaleCompare(attribute,"encoding") == 0)
12729 CloneString(&draw_info->encoding,SvPV(ST(i),na));
12732 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12739 if (LocaleCompare(attribute,"family") == 0)
12741 CloneString(&draw_info->family,SvPV(ST(i),na));
12744 if (LocaleCompare(attribute,"fill") == 0)
12747 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12748 &draw_info->fill,exception);
12751 if (LocaleCompare(attribute,"font") == 0)
12753 CloneString(&draw_info->font,SvPV(ST(i),na));
12756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12763 if (LocaleCompare(attribute,"geometry") == 0)
12765 CloneString(&draw_info->geometry,SvPV(ST(i),na));
12768 if (LocaleCompare(attribute,"gravity") == 0)
12770 draw_info->gravity=(GravityType) ParseCommandOption(
12771 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
12774 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12781 if (LocaleCompare(attribute,"pointsize") == 0)
12783 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12784 draw_info->pointsize=geometry_info.rho;
12787 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12794 if (LocaleCompare(attribute,"rotate") == 0)
12796 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12797 affine.rx=geometry_info.rho;
12798 affine.ry=geometry_info.sigma;
12799 if ((flags & SigmaValue) == 0)
12800 affine.ry=affine.rx;
12803 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12810 if (LocaleCompare(attribute,"scale") == 0)
12812 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12813 affine.sx=geometry_info.rho;
12814 affine.sy=geometry_info.sigma;
12815 if ((flags & SigmaValue) == 0)
12816 affine.sy=affine.sx;
12819 if (LocaleCompare(attribute,"skew") == 0)
12825 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12826 x_angle=geometry_info.rho;
12827 y_angle=geometry_info.sigma;
12828 if ((flags & SigmaValue) == 0)
12830 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
12831 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
12834 if (LocaleCompare(attribute,"stroke") == 0)
12837 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
12838 &draw_info->stroke,exception);
12841 if (LocaleCompare(attribute,"style") == 0)
12843 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
12847 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12851 draw_info->style=(StyleType) type;
12854 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12861 if (LocaleCompare(attribute,"text") == 0)
12863 CloneString(&draw_info->text,SvPV(ST(i),na));
12866 if (LocaleCompare(attribute,"translate") == 0)
12868 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12869 affine.tx=geometry_info.rho;
12870 affine.ty=geometry_info.sigma;
12871 if ((flags & SigmaValue) == 0)
12872 affine.ty=affine.tx;
12875 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12882 if (LocaleCompare(attribute,"weight") == 0)
12884 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12885 draw_info->weight=(size_t) geometry_info.rho;
12888 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12895 if (LocaleCompare(attribute,"x") == 0)
12897 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12898 x=geometry_info.rho;
12901 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12908 if (LocaleCompare(attribute,"y") == 0)
12910 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
12911 y=geometry_info.rho;
12914 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12920 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12926 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
12927 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
12928 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
12929 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
12930 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
12931 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
12932 if (draw_info->geometry == (char *) NULL)
12934 draw_info->geometry=AcquireString((char *) NULL);
12935 (void) FormatLocaleString(draw_info->geometry,MaxTextExtent,
12936 "%.15g,%.15g",x,y);
12938 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
12939 (void) CatchException(exception);
12940 if (status == MagickFalse)
12944 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
12945 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
12946 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
12947 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
12948 PUSHs(sv_2mortal(newSVnv(metrics.width)));
12949 PUSHs(sv_2mortal(newSVnv(metrics.height)));
12950 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
12951 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
12952 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
12953 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
12954 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
12955 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
12956 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
12958 draw_info=DestroyDrawInfo(draw_info);
12961 if (package_info != (struct PackageInfo *) NULL)
12962 DestroyPackageInfo(package_info);
12963 InheritPerlException(exception,perl_exception);
12964 exception=DestroyExceptionInfo(exception);
12965 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12969 ###############################################################################
12973 # Q u e r y F o r m a t #
12977 ###############################################################################
12981 QueryFormat(ref,...)
12982 Image::Magick::Q16HDRI ref=NO_INIT
12999 volatile const MagickInfo
13002 PERL_UNUSED_VAR(ref);
13003 PERL_UNUSED_VAR(ix);
13004 exception=AcquireExceptionInfo();
13005 perl_exception=newSVpv("",0);
13009 format[MaxTextExtent];
13017 format_list=GetMagickInfoList("*",&types,exception);
13019 for (i=0; i < (ssize_t) types; i++)
13021 (void) CopyMagickString(format,format_list[i]->name,MaxTextExtent);
13022 LocaleLower(format);
13023 PUSHs(sv_2mortal(newSVpv(format,0)));
13025 format_list=(const MagickInfo **)
13026 RelinquishMagickMemory((MagickInfo *) format_list);
13027 goto PerlException;
13029 EXTEND(sp,8*items);
13030 for (i=1; i < items; i++)
13032 name=(char *) SvPV(ST(i),na);
13033 magick_info=GetMagickInfo(name,exception);
13034 if (magick_info == (const MagickInfo *) NULL)
13039 PUSHs(sv_2mortal(newSViv(magick_info->adjoin)));
13040 PUSHs(sv_2mortal(newSViv(magick_info->blob_support)));
13041 PUSHs(sv_2mortal(newSViv(magick_info->raw)));
13042 PUSHs(sv_2mortal(newSViv((long) magick_info->decoder)));
13043 PUSHs(sv_2mortal(newSViv((long) magick_info->encoder)));
13044 if (magick_info->description == (char *) NULL)
13047 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13048 if (magick_info->module == (char *) NULL)
13051 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13055 InheritPerlException(exception,perl_exception);
13056 exception=DestroyExceptionInfo(exception);
13057 SvREFCNT_dec(perl_exception);
13061 ###############################################################################
13065 # Q u e r y O p t i o n #
13069 ###############################################################################
13073 QueryOption(ref,...)
13074 Image::Magick::Q16HDRI ref=NO_INIT
13095 PERL_UNUSED_VAR(ref);
13096 PERL_UNUSED_VAR(ix);
13097 exception=AcquireExceptionInfo();
13098 perl_exception=newSVpv("",0);
13099 EXTEND(sp,8*items);
13100 for (i=1; i < items; i++)
13102 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13104 options=GetCommandOptions((CommandOption) option);
13105 if (options == (char **) NULL)
13109 for (j=0; options[j] != (char *) NULL; j++)
13110 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13111 options=DestroyStringList(options);
13115 InheritPerlException(exception,perl_exception);
13116 exception=DestroyExceptionInfo(exception);
13117 SvREFCNT_dec(perl_exception);
13121 ###############################################################################
13129 ###############################################################################
13134 Image::Magick::Q16HDRI ref=NO_INIT
13181 *perl_exception, /* Perl variable for storing messages */
13186 PERL_UNUSED_VAR(ref);
13187 PERL_UNUSED_VAR(ix);
13188 exception=AcquireExceptionInfo();
13189 perl_exception=newSVpv("",0);
13191 package_info=(struct PackageInfo *) NULL;
13193 ac=(items < 2) ? 1 : items-1;
13194 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13196 length=(STRLEN *) NULL;
13197 if (list == (char **) NULL)
13199 ThrowPerlException(exception,ResourceLimitError,
13200 "MemoryAllocationFailed",PackageName);
13201 goto PerlException;
13203 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13204 if (length == (STRLEN *) NULL)
13206 ThrowPerlException(exception,ResourceLimitError,
13207 "MemoryAllocationFailed",PackageName);
13208 goto PerlException;
13210 if (sv_isobject(ST(0)) == 0)
13212 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13214 goto PerlException;
13216 reference=SvRV(ST(0));
13217 hv=SvSTASH(reference);
13218 if (SvTYPE(reference) != SVt_PVAV)
13220 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13222 goto PerlException;
13224 av=(AV *) reference;
13225 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13227 package_info=ClonePackageInfo(info,exception);
13230 *list=(char *) (*package_info->image_info->filename ?
13231 package_info->image_info->filename : "XC:black");
13233 for (n=0, i=0; i < ac; i++)
13235 list[n]=(char *) SvPV(ST(i+1),length[n]);
13236 if ((items >= 3) && strEQcase(list[n],"blob"))
13242 blob=(void *) (SvPV(ST(i+1),length[n]));
13243 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13245 if ((items >= 3) && strEQcase(list[n],"filename"))
13247 if ((items >= 3) && strEQcase(list[n],"file"))
13256 io_info=IoIFP(sv_2io(ST(i+1)));
13257 if (io_info == (PerlIO *) NULL)
13259 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13263 file=PerlIO_findFILE(io_info);
13264 if (file == (FILE *) NULL)
13266 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13270 SetImageInfoFile(package_info->image_info,file);
13272 if ((items >= 3) && strEQcase(list[n],"magick"))
13276 list[n]=(char *) NULL;
13278 status=ExpandFilenames(&n,&list);
13279 if (status == MagickFalse)
13281 ThrowPerlException(exception,ResourceLimitError,
13282 "MemoryAllocationFailed",PackageName);
13283 goto PerlException;
13286 for (i=0; i < n; i++)
13288 if ((package_info->image_info->file == (FILE *) NULL) &&
13289 (package_info->image_info->blob == (void *) NULL))
13290 image=ReadImages(package_info->image_info,list[i],exception);
13293 image=ReadImages(package_info->image_info,
13294 package_info->image_info->filename,exception);
13295 if (image != (Image *) NULL)
13296 DisassociateImageStream(image);
13298 if (image == (Image *) NULL)
13300 for ( ; image; image=image->next)
13302 AddImageToRegistry(sv,image);
13304 av_push(av,sv_bless(rv,hv));
13312 for (i=0; i < n; i++)
13313 if (list[i] != (char *) NULL)
13314 for (p=keep; list[i] != *p++; )
13315 if (*p == (char *) NULL)
13317 list[i]=(char *) RelinquishMagickMemory(list[i]);
13322 if (package_info != (struct PackageInfo *) NULL)
13323 DestroyPackageInfo(package_info);
13324 if (list && (list != keep))
13325 list=(char **) RelinquishMagickMemory(list);
13327 keep=(char **) RelinquishMagickMemory(keep);
13329 length=(STRLEN *) RelinquishMagickMemory(length);
13330 InheritPerlException(exception,perl_exception);
13331 exception=DestroyExceptionInfo(exception);
13332 sv_setiv(perl_exception,(IV) number_images);
13333 SvPOK_on(perl_exception);
13334 ST(0)=sv_2mortal(perl_exception);
13339 ###############################################################################
13347 ###############################################################################
13352 Image::Magick::Q16HDRI ref=NO_INIT
13375 PERL_UNUSED_VAR(ref);
13376 PERL_UNUSED_VAR(ix);
13377 exception=AcquireExceptionInfo();
13378 perl_exception=newSVpv("",0);
13379 reference=SvRV(ST(0));
13380 av=(AV *) reference;
13381 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13383 for (i=1; i < items; i++)
13384 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
13385 SvPV(ST(i),na),exception);
13386 InheritPerlException(exception,perl_exception);
13387 exception=DestroyExceptionInfo(exception);
13388 SvREFCNT_dec(perl_exception); /* throw away all errors */
13392 ###############################################################################
13400 ###############################################################################
13405 Image::Magick::Q16HDRI ref=NO_INIT
13428 *reference; /* reference is the SV* of ref=SvIV(reference) */
13430 PERL_UNUSED_VAR(ref);
13431 PERL_UNUSED_VAR(ix);
13432 exception=AcquireExceptionInfo();
13433 perl_exception=newSVpv("",0);
13434 if (sv_isobject(ST(0)) == 0)
13436 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13438 goto PerlException;
13440 reference=SvRV(ST(0));
13441 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13443 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
13445 for (i=2; i < items; i+=2)
13446 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
13449 InheritPerlException(exception,perl_exception);
13450 exception=DestroyExceptionInfo(exception);
13451 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
13452 SvPOK_on(perl_exception);
13453 ST(0)=sv_2mortal(perl_exception);
13458 ###############################################################################
13462 # S e t P i x e l #
13466 ###############################################################################
13471 Image::Magick::Q16HDRI ref=NO_INIT
13513 *reference; /* reference is the SV* of ref=SvIV(reference) */
13515 PERL_UNUSED_VAR(ref);
13516 PERL_UNUSED_VAR(ix);
13517 exception=AcquireExceptionInfo();
13518 perl_exception=newSVpv("",0);
13519 reference=SvRV(ST(0));
13520 av=(AV *) reference;
13521 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13523 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13524 if (image == (Image *) NULL)
13526 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13528 goto PerlException;
13531 normalize=MagickTrue;
13534 region.width=image->columns;
13537 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
13538 channel=DefaultChannels;
13539 for (i=2; i < items; i+=2)
13541 attribute=(char *) SvPV(ST(i-1),na);
13542 switch (*attribute)
13547 if (LocaleCompare(attribute,"channel") == 0)
13552 option=ParseChannelOption(SvPV(ST(i),na));
13555 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13559 channel=(ChannelType) option;
13562 if (LocaleCompare(attribute,"color") == 0)
13564 if (SvTYPE(ST(i)) != SVt_RV)
13567 message[MaxTextExtent];
13569 (void) FormatLocaleString(message,MaxTextExtent,
13570 "invalid %.60s value",attribute);
13571 ThrowPerlException(exception,OptionError,message,
13574 av=(AV *) SvRV(ST(i));
13577 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13584 if (LocaleCompare(attribute,"geometry") == 0)
13586 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
13589 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13596 if (LocaleCompare(attribute,"normalize") == 0)
13598 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13602 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13606 normalize=option != 0 ? MagickTrue : MagickFalse;
13609 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13616 if (LocaleCompare(attribute,"x") == 0)
13618 region.x=SvIV(ST(i));
13621 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13628 if (LocaleCompare(attribute,"y") == 0)
13630 region.y=SvIV(ST(i));
13633 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13639 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13645 (void) SetImageStorageClass(image,DirectClass,exception);
13646 channel_mask=SetImageChannelMask(image,channel);
13647 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
13648 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
13649 (SvTYPE(av) != SVt_PVAV))
13661 if (normalize != MagickFalse)
13662 scale=QuantumRange;
13663 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
13666 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
13667 av_fetch(av,i,0)))),q);
13670 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
13673 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
13674 av_fetch(av,i,0)))),q);
13677 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
13680 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
13681 av_fetch(av,i,0)))),q);
13684 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
13685 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
13687 SetPixelBlack(image,ClampToQuantum(scale*
13688 SvNV(*(av_fetch(av,i,0)))),q);
13691 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
13694 SetPixelAlpha(image,ClampToQuantum(scale*
13695 SvNV(*(av_fetch(av,i,0)))),q);
13698 (void) SyncAuthenticPixels(image,exception);
13700 (void) SetImageChannelMask(image,channel_mask);
13703 InheritPerlException(exception,perl_exception);
13704 exception=DestroyExceptionInfo(exception);
13705 SvREFCNT_dec(perl_exception);
13709 ###############################################################################
13717 ###############################################################################
13722 Image::Magick::Q16HDRI ref=NO_INIT
13761 PERL_UNUSED_VAR(ref);
13762 PERL_UNUSED_VAR(ix);
13763 exception=AcquireExceptionInfo();
13764 perl_exception=newSVpv("",0);
13768 if (sv_isobject(ST(0)) == 0)
13770 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13772 goto PerlException;
13774 reference=SvRV(ST(0));
13775 hv=SvSTASH(reference);
13777 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
13779 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13780 if (image == (Image *) NULL)
13782 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13784 goto PerlException;
13786 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13792 for (i=2; i < items; i+=2)
13794 attribute=(char *) SvPV(ST(i-1),na);
13795 switch (*attribute)
13800 if (LocaleCompare(attribute,"offset") == 0)
13802 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
13805 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13812 if (LocaleCompare(attribute,"stack") == 0)
13814 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13818 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13824 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13830 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13836 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
13838 if (image == (Image *) NULL)
13839 goto PerlException;
13840 for ( ; image; image=image->next)
13842 AddImageToRegistry(sv,image);
13844 av_push(av,sv_bless(rv,hv));
13847 exception=DestroyExceptionInfo(exception);
13848 ST(0)=av_reference;
13849 SvREFCNT_dec(perl_exception);
13853 InheritPerlException(exception,perl_exception);
13854 exception=DestroyExceptionInfo(exception);
13855 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
13856 SvPOK_on(perl_exception);
13857 ST(0)=sv_2mortal(perl_exception);
13862 ###############################################################################
13866 # S t a t i s t i c s #
13870 ###############################################################################
13874 Statistics(ref,...)
13875 Image::Magick::Q16HDRI ref=NO_INIT
13877 StatisticsImage = 1
13879 statisticsimage = 3
13882 #define ChannelStatistics(channel) \
13884 (void) FormatLocaleString(message,MaxTextExtent,"%.20g", \
13885 (double) channel_statistics[channel].depth); \
13886 PUSHs(sv_2mortal(newSVpv(message,0))); \
13887 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13888 channel_statistics[channel].minima/scale); \
13889 PUSHs(sv_2mortal(newSVpv(message,0))); \
13890 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13891 channel_statistics[channel].maxima/scale); \
13892 PUSHs(sv_2mortal(newSVpv(message,0))); \
13893 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13894 channel_statistics[channel].mean/scale); \
13895 PUSHs(sv_2mortal(newSVpv(message,0))); \
13896 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13897 channel_statistics[channel].standard_deviation/scale); \
13898 PUSHs(sv_2mortal(newSVpv(message,0))); \
13899 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13900 channel_statistics[channel].kurtosis); \
13901 PUSHs(sv_2mortal(newSVpv(message,0))); \
13902 (void) FormatLocaleString(message,MaxTextExtent,"%.15g", \
13903 channel_statistics[channel].skewness); \
13904 PUSHs(sv_2mortal(newSVpv(message,0))); \
13911 message[MaxTextExtent];
13914 *channel_statistics;
13935 PERL_UNUSED_VAR(ref);
13936 PERL_UNUSED_VAR(ix);
13937 exception=AcquireExceptionInfo();
13938 perl_exception=newSVpv("",0);
13940 if (sv_isobject(ST(0)) == 0)
13942 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13944 goto PerlException;
13946 reference=SvRV(ST(0));
13949 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13950 if (image == (Image *) NULL)
13952 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13954 goto PerlException;
13956 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
13958 for ( ; image; image=image->next)
13960 channel_statistics=GetImageStatistics(image,exception);
13961 if (channel_statistics == (ChannelStatistics *) NULL)
13964 EXTEND(sp,35*count);
13965 scale=(double) QuantumRange;
13966 ChannelStatistics(RedChannel);
13967 ChannelStatistics(GreenChannel);
13968 ChannelStatistics(BlueChannel);
13969 if (image->colorspace == CMYKColorspace)
13970 ChannelStatistics(BlackChannel);
13971 if (image->alpha_trait == BlendPixelTrait)
13972 ChannelStatistics(AlphaChannel);
13973 channel_statistics=(ChannelStatistics *)
13974 RelinquishMagickMemory(channel_statistics);
13978 InheritPerlException(exception,perl_exception);
13979 exception=DestroyExceptionInfo(exception);
13980 SvREFCNT_dec(perl_exception);
13984 ###############################################################################
13988 # S y n c A u t h e n t i c P i x e l s #
13992 ###############################################################################
13996 SyncAuthenticPixels(ref,...)
13997 Image::Magick::Q16HDRI ref = NO_INIT
13999 Syncauthenticpixels = 1
14000 SyncImagePixels = 2
14001 syncimagepixels = 3
14020 PERL_UNUSED_VAR(ref);
14021 PERL_UNUSED_VAR(ix);
14022 exception=AcquireExceptionInfo();
14023 perl_exception=newSVpv("",0);
14024 if (sv_isobject(ST(0)) == 0)
14026 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14028 goto PerlException;
14031 reference=SvRV(ST(0));
14032 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14033 if (image == (Image *) NULL)
14035 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14037 goto PerlException;
14040 status=SyncAuthenticPixels(image,exception);
14041 if (status != MagickFalse)
14045 InheritPerlException(exception,perl_exception);
14046 exception=DestroyExceptionInfo(exception);
14047 SvREFCNT_dec(perl_exception); /* throw away all errors */
14051 ###############################################################################
14055 # T r a n s f o r m #
14059 ###############################################################################
14064 Image::Magick::Q16HDRI ref=NO_INIT
14102 PERL_UNUSED_VAR(ref);
14103 PERL_UNUSED_VAR(ix);
14104 exception=AcquireExceptionInfo();
14105 perl_exception=newSVpv("",0);
14109 if (sv_isobject(ST(0)) == 0)
14111 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14113 goto PerlException;
14115 reference=SvRV(ST(0));
14116 hv=SvSTASH(reference);
14118 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14120 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14121 if (image == (Image *) NULL)
14123 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14125 goto PerlException;
14127 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14131 crop_geometry=(char *) NULL;
14132 geometry=(char *) NULL;
14133 for (i=2; i < items; i+=2)
14135 attribute=(char *) SvPV(ST(i-1),na);
14136 switch (*attribute)
14141 if (LocaleCompare(attribute,"crop") == 0)
14143 crop_geometry=SvPV(ST(i),na);
14146 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14153 if (LocaleCompare(attribute,"geometry") == 0)
14155 geometry=SvPV(ST(i),na);
14158 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14164 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14170 for ( ; image; image=image->next)
14172 clone=CloneImage(image,0,0,MagickTrue,exception);
14173 if (clone == (Image *) NULL)
14174 goto PerlException;
14175 TransformImage(&clone,crop_geometry,geometry,exception);
14176 for ( ; clone; clone=clone->next)
14178 AddImageToRegistry(sv,clone);
14180 av_push(av,sv_bless(rv,hv));
14184 exception=DestroyExceptionInfo(exception);
14185 ST(0)=av_reference;
14186 SvREFCNT_dec(perl_exception); /* can't return warning messages */
14190 InheritPerlException(exception,perl_exception);
14191 exception=DestroyExceptionInfo(exception);
14192 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14193 SvPOK_on(perl_exception);
14194 ST(0)=sv_2mortal(perl_exception);
14199 ###############################################################################
14207 ###############################################################################
14212 Image::Magick::Q16HDRI ref=NO_INIT
14220 filename[MaxTextExtent];
14244 PERL_UNUSED_VAR(ref);
14245 PERL_UNUSED_VAR(ix);
14246 exception=AcquireExceptionInfo();
14247 perl_exception=newSVpv("",0);
14249 package_info=(struct PackageInfo *) NULL;
14250 if (sv_isobject(ST(0)) == 0)
14252 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14254 goto PerlException;
14256 reference=SvRV(ST(0));
14257 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14258 if (image == (Image *) NULL)
14260 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14262 goto PerlException;
14264 package_info=ClonePackageInfo(info,exception);
14266 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
14269 for (i=2; i < items; i+=2)
14270 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
14272 (void) CopyMagickString(filename,package_info->image_info->filename,
14275 for (next=image; next; next=next->next)
14277 (void) CopyMagickString(next->filename,filename,MaxTextExtent);
14278 next->scene=scene++;
14280 SetImageInfo(package_info->image_info,(unsigned int)
14281 GetImageListLength(image),exception);
14282 for (next=image; next; next=next->next)
14284 (void) WriteImage(package_info->image_info,next,exception);
14286 if (package_info->image_info->adjoin)
14291 if (package_info != (struct PackageInfo *) NULL)
14292 DestroyPackageInfo(package_info);
14293 InheritPerlException(exception,perl_exception);
14294 exception=DestroyExceptionInfo(exception);
14295 sv_setiv(perl_exception,(IV) number_images);
14296 SvPOK_on(perl_exception);
14297 ST(0)=sv_2mortal(perl_exception);