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-2019 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 % https://imagemagick.org/script/license.php %
34 % Unless required by applicable law or agreed to in writing, software %
35 % distributed under the License is distributed on an "AS IS" BASIS, %
36 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
37 % See the License for the specific language governing permissions and %
38 % limitations under the License. %
40 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 % PerlMagick is an objected-oriented Perl interface to ImageMagick. Use
43 % the module to read, manipulate, or write an image or image sequence from
44 % within a Perl script. This makes PerlMagick suitable for Web CGI scripts.
51 #if defined(__cplusplus) || defined(c_plusplus)
55 #define PERL_NO_GET_CONTEXT
60 #include <MagickCore/MagickCore.h>
63 #if defined(__cplusplus) || defined(c_plusplus)
75 #define DegreesToRadians(x) (MagickPI*(x)/180.0)
76 #define EndOf(array) (&array[NumberOf(array)])
77 #define MagickPI 3.14159265358979323846264338327950288419716939937510
78 #define MaxArguments 34
82 #define NumberOf(array) (sizeof(array)/sizeof(*array))
83 #define PackageName "Image::Magick::@MAGICK_ABI_SUFFIX@"
86 #define PerlIO_importFILE(f, fl) (f)
87 #define PerlIO_findFILE(f) NULL
90 #define sv_undef PL_sv_undef
93 #define AddImageToRegistry(sv,image) \
95 if (magick_registry != (SplayTreeInfo *) NULL) \
97 (void) AddValueToSplayTree(magick_registry,image,image); \
98 (sv)=newSViv(PTR2IV(image)); \
102 #define DeleteImageFromRegistry(reference,image) \
104 if (magick_registry != (SplayTreeInfo *) NULL) \
106 if (GetImageReferenceCount(image) == 1) \
107 (void) DeleteNodeByValueFromSplayTree(magick_registry,image); \
108 image=DestroyImage(image); \
109 sv_setiv(reference,0); \
113 #define InheritPerlException(exception,perl_exception) \
116 message[MagickPathExtent]; \
118 if ((exception)->severity != UndefinedException) \
120 (void) FormatLocaleString(message,MagickPathExtent,"Exception %d: %s%s%s%s",\
121 (exception)->severity, (exception)->reason ? \
122 GetLocaleExceptionMessage((exception)->severity,(exception)->reason) : \
123 "Unknown", (exception)->description ? " (" : "", \
124 (exception)->description ? GetLocaleExceptionMessage( \
125 (exception)->severity,(exception)->description) : "", \
126 (exception)->description ? ")" : ""); \
127 if ((perl_exception) != (SV *) NULL) \
129 if (SvCUR(perl_exception)) \
130 sv_catpv(perl_exception,"\n"); \
131 sv_catpv(perl_exception,message); \
136 #define ThrowPerlException(exception,severity,tag,reason) \
137 (void) ThrowMagickException(exception,GetMagickModule(),severity, \
138 tag,"`%s'",reason); \
141 Typedef and structure declarations.
146 ArrayReference = (~0),
147 RealReference = (~0)-1,
148 FileReference = (~0)-2,
149 ImageReference = (~0)-3,
150 IntegerReference = (~0)-4,
151 StringReference = (~0)-5
154 typedef struct _Arguments
194 *Image__Magick__@MAGICK_ABI_SUFFIX@; /* data type for the Image::Magick::@MAGICK_ABI_NAME@ package */
206 arguments[MaxArguments];
209 { "Comment", { {"comment", StringReference} } },
210 { "Label", { {"label", StringReference} } },
211 { "AddNoise", { {"noise", MagickNoiseOptions}, {"attenuate", RealReference},
212 {"channel", MagickChannelOptions} } },
213 { "Colorize", { {"fill", StringReference}, {"blend", StringReference} } },
214 { "Border", { {"geometry", StringReference}, {"width", IntegerReference},
215 {"height", IntegerReference}, {"fill", StringReference},
216 {"bordercolor", StringReference}, {"color", StringReference},
217 {"compose", MagickComposeOptions} } },
218 { "Blur", { {"geometry", StringReference}, {"radius", RealReference},
219 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
220 { "Chop", { {"geometry", StringReference}, {"width", IntegerReference},
221 {"height", IntegerReference}, {"x", IntegerReference},
222 {"y", IntegerReference}, {"gravity", MagickGravityOptions} } },
223 { "Crop", { {"geometry", StringReference}, {"width", IntegerReference},
224 {"height", IntegerReference}, {"x", IntegerReference},
225 {"y", IntegerReference}, {"fuzz", StringReference},
226 {"gravity", MagickGravityOptions} } },
227 { "Despeckle", { { (const char *) NULL, NullReference } } },
228 { "Edge", { {"radius", RealReference} } },
229 { "Emboss", { {"geometry", StringReference}, {"radius", RealReference},
230 {"sigma", RealReference} } },
231 { "Enhance", { { (const char *) NULL, NullReference } } },
232 { "Flip", { { (const char *) NULL, NullReference } } },
233 { "Flop", { { (const char *) NULL, NullReference } } },
234 { "Frame", { {"geometry", StringReference}, {"width", IntegerReference},
235 {"height", IntegerReference}, {"inner", IntegerReference},
236 {"outer", IntegerReference}, {"fill", StringReference},
237 {"color", StringReference}, {"compose", MagickComposeOptions} } },
238 { "Implode", { {"amount", RealReference},
239 {"interpolate", MagickInterpolateOptions} } },
240 { "Magnify", { { (const char *) NULL, NullReference } } },
241 { "MedianFilter", { {"geometry", StringReference},
242 {"width", IntegerReference}, {"height", IntegerReference},
243 {"channel", MagickChannelOptions} } },
244 { "Minify", { { (const char *) NULL, NullReference } } },
245 { "OilPaint", { {"radius", RealReference}, {"sigma", RealReference} } },
246 { "ReduceNoise", { {"geometry", StringReference},
247 {"width", IntegerReference},{"height", IntegerReference},
248 {"channel", MagickChannelOptions} } },
249 { "Roll", { {"geometry", StringReference}, {"x", IntegerReference},
250 {"y", IntegerReference} } },
251 { "Rotate", { {"degrees", RealReference},
252 {"background", StringReference} } },
253 { "Sample", { {"geometry", StringReference}, {"width", IntegerReference},
254 {"height", IntegerReference} } },
255 { "Scale", { {"geometry", StringReference}, {"width", IntegerReference},
256 {"height", IntegerReference} } },
257 { "Shade", { {"geometry", StringReference}, {"azimuth", RealReference},
258 {"elevation", RealReference}, {"gray", MagickBooleanOptions} } },
259 { "Sharpen", { {"geometry", StringReference}, {"radius", RealReference},
260 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
261 { "Shear", { {"geometry", StringReference}, {"x", RealReference},
262 {"y", RealReference}, { "fill", StringReference},
263 {"color", StringReference} } },
264 { "Spread", { {"radius", RealReference},
265 {"interpolate", MagickInterpolateOptions} } },
266 { "Swirl", { {"degrees", RealReference},
267 {"interpolate", MagickInterpolateOptions} } },
268 { "Resize", { {"geometry", StringReference}, {"width", IntegerReference},
269 {"height", IntegerReference}, {"filter", MagickFilterOptions},
270 {"support", StringReference } } },
271 { "Zoom", { {"geometry", StringReference}, {"width", IntegerReference},
272 {"height", IntegerReference}, {"filter", MagickFilterOptions},
273 {"support", RealReference } } },
274 { "Annotate", { {"text", StringReference}, {"font", StringReference},
275 {"pointsize", RealReference}, {"density", StringReference},
276 {"undercolor", StringReference}, {"stroke", StringReference},
277 {"fill", StringReference}, {"geometry", StringReference},
278 {"sans", StringReference}, {"x", RealReference},
279 {"y", RealReference}, {"gravity", MagickGravityOptions},
280 {"translate", StringReference}, {"scale", StringReference},
281 {"rotate", RealReference}, {"skewX", RealReference},
282 {"skewY", RealReference}, {"strokewidth", RealReference},
283 {"antialias", MagickBooleanOptions}, {"family", StringReference},
284 {"style", MagickStyleOptions}, {"stretch", MagickStretchOptions},
285 {"weight", IntegerReference}, {"align", MagickAlignOptions},
286 {"encoding", StringReference}, {"affine", ArrayReference},
287 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
288 {"tile", ImageReference}, {"kerning", RealReference},
289 {"interline-spacing", RealReference},
290 {"interword-spacing", RealReference},
291 {"direction", MagickDirectionOptions},
292 {"decorate", MagickDecorateOptions} } },
293 { "ColorFloodfill", { {"geometry", StringReference},
294 {"x", IntegerReference}, {"y", IntegerReference},
295 {"fill", StringReference}, {"bordercolor", StringReference},
296 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
297 { "Composite", { {"image", ImageReference},
298 {"compose", MagickComposeOptions}, {"geometry", StringReference},
299 {"x", IntegerReference}, {"y", IntegerReference},
300 {"gravity", MagickGravityOptions}, {"opacity", StringReference},
301 {"tile", MagickBooleanOptions}, {"rotate", RealReference},
302 {"color", StringReference}, {"mask", ImageReference},
303 {"channel", MagickChannelOptions},
304 {"interpolate", MagickInterpolateOptions}, {"args", StringReference},
305 {"blend", StringReference}, {"clip-to-self", MagickBooleanOptions} } },
306 { "Contrast", { {"sharpen", MagickBooleanOptions} } },
307 { "CycleColormap", { {"display", IntegerReference} } },
308 { "Draw", { {"primitive", MagickPrimitiveOptions},
309 {"points", StringReference}, {"method", MagickMethodOptions},
310 {"stroke", StringReference}, {"fill", StringReference},
311 {"strokewidth", RealReference}, {"font", StringReference},
312 {"bordercolor", StringReference}, {"x", RealReference},
313 {"y", RealReference}, {"translate", StringReference},
314 {"scale", StringReference}, {"rotate", RealReference},
315 {"skewX", RealReference}, {"skewY", RealReference},
316 {"tile", ImageReference}, {"pointsize", RealReference},
317 {"antialias", MagickBooleanOptions}, {"density", StringReference},
318 {"linewidth", RealReference}, {"affine", ArrayReference},
319 {"stroke-dashoffset", RealReference},
320 {"stroke-dasharray", ArrayReference},
321 {"interpolate", MagickInterpolateOptions},
322 {"origin", StringReference}, {"text", StringReference},
323 {"fill-pattern", ImageReference}, {"stroke-pattern", ImageReference},
324 {"vector-graphics", StringReference}, {"kerning", RealReference},
325 {"interline-spacing", RealReference},
326 {"interword-spacing", RealReference},
327 {"direction", MagickDirectionOptions} } },
328 { "Equalize", { {"channel", MagickChannelOptions} } },
329 { "Gamma", { {"gamma", StringReference}, {"channel", MagickChannelOptions},
330 {"red", RealReference}, {"green", RealReference},
331 {"blue", RealReference} } },
332 { "Map", { {"image", ImageReference},
333 {"dither-method", MagickDitherOptions} } },
334 { "MatteFloodfill", { {"geometry", StringReference},
335 {"x", IntegerReference}, {"y", IntegerReference},
336 {"opacity", StringReference}, {"bordercolor", StringReference},
337 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
338 { "Modulate", { {"factor", StringReference}, {"hue", RealReference},
339 {"saturation", RealReference}, {"whiteness", RealReference},
340 {"brightness", RealReference}, {"lightness", RealReference},
341 {"blackness", RealReference} } },
342 { "Negate", { {"gray", MagickBooleanOptions},
343 {"channel", MagickChannelOptions} } },
344 { "Normalize", { {"channel", MagickChannelOptions} } },
345 { "NumberColors", { { (const char *) NULL, NullReference } } },
346 { "Opaque", { {"color", StringReference}, {"fill", StringReference},
347 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
348 {"invert", MagickBooleanOptions} } },
349 { "Quantize", { {"colors", IntegerReference},
350 {"treedepth", IntegerReference}, {"colorspace", MagickColorspaceOptions},
351 {"dither", MagickDitherOptions}, {"measure", MagickBooleanOptions},
352 {"global", MagickBooleanOptions}, {"transparent-color", StringReference},
353 {"dither-method", MagickDitherOptions} } },
354 { "Raise", { {"geometry", StringReference}, {"width", IntegerReference},
355 {"height", IntegerReference}, {"raise", MagickBooleanOptions} } },
356 { "Segment", { {"geometry", StringReference},
357 {"cluster-threshold", RealReference},
358 {"smoothing-threshold", RealReference},
359 {"colorspace", MagickColorspaceOptions},
360 {"verbose", MagickBooleanOptions} } },
361 { "Signature", { { (const char *) NULL, NullReference } } },
362 { "Solarize", { {"geometry", StringReference},
363 {"threshold", StringReference} } },
364 { "Sync", { { (const char *) NULL, NullReference } } },
365 { "Texture", { {"texture", ImageReference} } },
366 { "Evaluate", { {"value", RealReference},
367 {"operator", MagickEvaluateOptions},
368 {"channel", MagickChannelOptions} } },
369 { "Transparent", { {"color", StringReference}, {"opacity", StringReference},
370 {"fuzz", StringReference}, {"invert", MagickBooleanOptions} } },
371 { "Threshold", { {"threshold", StringReference},
372 {"channel", MagickChannelOptions} } },
373 { "Charcoal", { {"geometry", StringReference}, {"radius", RealReference},
374 {"sigma", RealReference} } },
375 { "Trim", { {"fuzz", StringReference} } },
376 { "Wave", { {"geometry", StringReference}, {"amplitude", RealReference},
377 {"wavelength", RealReference},
378 {"interpolate", MagickInterpolateOptions} } },
379 { "Separate", { {"channel", MagickChannelOptions} } },
380 { "Condense", { { (const char *) NULL, NullReference } } },
381 { "Stereo", { {"image", ImageReference}, {"x", IntegerReference},
382 {"y", IntegerReference} } },
383 { "Stegano", { {"image", ImageReference}, {"offset", IntegerReference} } },
384 { "Deconstruct", { { (const char *) NULL, NullReference } } },
385 { "GaussianBlur", { {"geometry", StringReference},
386 {"radius", RealReference}, {"sigma", RealReference},
387 {"channel", MagickChannelOptions} } },
388 { "Convolve", { {"coefficients", ArrayReference},
389 {"channel", MagickChannelOptions}, {"bias", StringReference},
390 {"kernel", StringReference} } },
391 { "Profile", { {"name", StringReference}, {"profile", StringReference},
392 { "rendering-intent", MagickIntentOptions},
393 { "black-point-compensation", MagickBooleanOptions} } },
394 { "UnsharpMask", { {"geometry", StringReference},
395 {"radius", RealReference}, {"sigma", RealReference},
396 {"gain", RealReference}, {"threshold", RealReference},
397 {"channel", MagickChannelOptions} } },
398 { "MotionBlur", { {"geometry", StringReference},
399 {"radius", RealReference}, {"sigma", RealReference},
400 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
401 { "OrderedDither", { {"threshold", StringReference},
402 {"channel", MagickChannelOptions} } },
403 { "Shave", { {"geometry", StringReference}, {"width", IntegerReference},
404 {"height", IntegerReference} } },
405 { "Level", { {"levels", StringReference}, {"black-point", RealReference},
406 {"white-point", RealReference}, {"gamma", RealReference},
407 {"channel", MagickChannelOptions}, {"level", StringReference} } },
408 { "Clip", { {"id", StringReference}, {"inside", MagickBooleanOptions} } },
409 { "AffineTransform", { {"affine", ArrayReference},
410 {"translate", StringReference}, {"scale", StringReference},
411 {"rotate", RealReference}, {"skewX", RealReference},
412 {"skewY", RealReference}, {"interpolate", MagickInterpolateOptions},
413 {"background", StringReference} } },
414 { "Difference", { {"image", ImageReference}, {"fuzz", StringReference} } },
415 { "AdaptiveThreshold", { {"geometry", StringReference},
416 {"width", IntegerReference}, {"height", IntegerReference},
417 {"bias", RealReference} } },
418 { "Resample", { {"density", StringReference}, {"x", RealReference},
419 {"y", RealReference}, {"filter", MagickFilterOptions},
420 {"support", RealReference } } },
421 { "Describe", { {"file", FileReference} } },
422 { "BlackThreshold", { {"threshold", StringReference},
423 {"channel", MagickChannelOptions} } },
424 { "WhiteThreshold", { {"threshold", StringReference},
425 {"channel", MagickChannelOptions} } },
426 { "RotationalBlur", { {"geometry", StringReference},
427 {"angle", RealReference}, {"channel", MagickChannelOptions} } },
428 { "Thumbnail", { {"geometry", StringReference}, {"width", IntegerReference},
429 {"height", IntegerReference} } },
430 { "Strip", { { (const char *) NULL, NullReference } } },
431 { "Tint", { {"fill", StringReference}, {"blend", StringReference} } },
432 { "Channel", { {"channel", MagickChannelOptions} } },
433 { "Splice", { {"geometry", StringReference}, {"width", IntegerReference},
434 {"height", IntegerReference}, {"x", IntegerReference},
435 {"y", IntegerReference}, {"fuzz", StringReference},
436 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
437 { "Posterize", { {"levels", IntegerReference},
438 {"dither", MagickBooleanOptions} } },
439 { "Shadow", { {"geometry", StringReference}, {"alpha", RealReference},
440 {"sigma", RealReference}, {"x", IntegerReference},
441 {"y", IntegerReference} } },
442 { "Identify", { {"file", FileReference}, {"features", StringReference},
443 {"unique", MagickBooleanOptions} } },
444 { "SepiaTone", { {"threshold", RealReference} } },
445 { "SigmoidalContrast", { {"geometry", StringReference},
446 {"contrast", RealReference}, {"mid-point", RealReference},
447 {"channel", MagickChannelOptions}, {"sharpen", MagickBooleanOptions} } },
448 { "Extent", { {"geometry", StringReference}, {"width", IntegerReference},
449 {"height", IntegerReference}, {"x", IntegerReference},
450 {"y", IntegerReference}, {"fuzz", StringReference},
451 {"background", StringReference}, {"gravity", MagickGravityOptions} } },
452 { "Vignette", { {"geometry", StringReference}, {"radius", RealReference},
453 {"sigma", RealReference}, {"x", IntegerReference},
454 {"y", IntegerReference}, {"background", StringReference} } },
455 { "ContrastStretch", { {"levels", StringReference},
456 {"black-point", RealReference},{"white-point", RealReference},
457 {"channel", MagickChannelOptions} } },
458 { "Sans0", { { (const char *) NULL, NullReference } } },
459 { "Sans1", { { (const char *) NULL, NullReference } } },
460 { "AdaptiveSharpen", { {"geometry", StringReference},
461 {"radius", RealReference}, {"sigma", RealReference},
462 {"bias", RealReference}, {"channel", MagickChannelOptions} } },
463 { "Transpose", { { (const char *) NULL, NullReference } } },
464 { "Transverse", { { (const char *) NULL, NullReference } } },
465 { "AutoOrient", { { (const char *) NULL, NullReference } } },
466 { "AdaptiveBlur", { {"geometry", StringReference},
467 {"radius", RealReference}, {"sigma", RealReference},
468 {"channel", MagickChannelOptions} } },
469 { "Sketch", { {"geometry", StringReference},
470 {"radius", RealReference}, {"sigma", RealReference},
471 {"angle", RealReference} } },
472 { "UniqueColors", { { (const char *) NULL, NullReference } } },
473 { "AdaptiveResize", { {"geometry", StringReference},
474 {"width", IntegerReference}, {"height", IntegerReference},
475 {"filter", MagickFilterOptions}, {"support", StringReference },
476 {"blur", RealReference } } },
477 { "ClipMask", { {"mask", ImageReference} } },
478 { "LinearStretch", { {"levels", StringReference},
479 {"black-point", RealReference},{"white-point", RealReference} } },
480 { "ColorMatrix", { {"matrix", ArrayReference} } },
481 { "Mask", { {"mask", ImageReference} } },
482 { "Polaroid", { {"caption", StringReference}, {"angle", RealReference},
483 {"font", StringReference}, {"stroke", StringReference},
484 {"fill", StringReference}, {"strokewidth", RealReference},
485 {"pointsize", RealReference}, {"gravity", MagickGravityOptions},
486 {"background", StringReference},
487 {"interpolate", MagickInterpolateOptions} } },
488 { "FloodfillPaint", { {"geometry", StringReference},
489 {"x", IntegerReference}, {"y", IntegerReference},
490 {"fill", StringReference}, {"bordercolor", StringReference},
491 {"fuzz", StringReference}, {"channel", MagickChannelOptions},
492 {"invert", MagickBooleanOptions} } },
493 { "Distort", { {"points", ArrayReference}, {"method", MagickDistortOptions},
494 {"virtual-pixel", MagickVirtualPixelOptions},
495 {"best-fit", MagickBooleanOptions} } },
496 { "Clut", { {"image", ImageReference},
497 {"interpolate", MagickInterpolateOptions},
498 {"channel", MagickChannelOptions} } },
499 { "LiquidRescale", { {"geometry", StringReference},
500 {"width", IntegerReference}, {"height", IntegerReference},
501 {"delta-x", RealReference}, {"rigidity", RealReference } } },
502 { "Encipher", { {"passphrase", StringReference} } },
503 { "Decipher", { {"passphrase", StringReference} } },
504 { "Deskew", { {"geometry", StringReference},
505 {"threshold", StringReference} } },
506 { "Remap", { {"image", ImageReference},
507 {"dither-method", MagickDitherOptions} } },
508 { "SparseColor", { {"points", ArrayReference},
509 {"method", MagickSparseColorOptions},
510 {"virtual-pixel", MagickVirtualPixelOptions},
511 {"channel", MagickChannelOptions} } },
512 { "Function", { {"parameters", ArrayReference},
513 {"function", MagickFunctionOptions},
514 {"virtual-pixel", MagickVirtualPixelOptions} } },
515 { "SelectiveBlur", { {"geometry", StringReference},
516 {"radius", RealReference}, {"sigma", RealReference},
517 {"threshold", RealReference}, {"channel", MagickChannelOptions} } },
518 { "HaldClut", { {"image", ImageReference},
519 {"channel", MagickChannelOptions} } },
520 { "BlueShift", { {"factor", StringReference} } },
521 { "ForwardFourierTransform", { {"magnitude", MagickBooleanOptions} } },
522 { "InverseFourierTransform", { {"magnitude", MagickBooleanOptions} } },
523 { "ColorDecisionList", {
524 {"color-correction-collection", StringReference} } },
525 { "AutoGamma", { {"channel", MagickChannelOptions} } },
526 { "AutoLevel", { {"channel", MagickChannelOptions} } },
527 { "LevelColors", { {"invert", MagickBooleanOptions},
528 {"black-point", StringReference}, {"white-point", StringReference},
529 {"channel", MagickChannelOptions}, {"invert", MagickBooleanOptions} } },
530 { "Clamp", { {"channel", MagickChannelOptions} } },
531 { "BrightnessContrast", { {"levels", StringReference},
532 {"brightness", RealReference},{"contrast", RealReference},
533 {"channel", MagickChannelOptions} } },
534 { "Morphology", { {"kernel", StringReference},
535 {"channel", MagickChannelOptions}, {"method", MagickMorphologyOptions},
536 {"iterations", IntegerReference} } },
537 { "Mode", { {"geometry", StringReference},
538 {"width", IntegerReference},{"height", IntegerReference},
539 {"channel", MagickChannelOptions} } },
540 { "Statistic", { {"geometry", StringReference},
541 {"width", IntegerReference},{"height", IntegerReference},
542 {"channel", MagickChannelOptions}, {"type", MagickStatisticOptions} } },
543 { "Perceptible", { {"epsilon", RealReference},
544 {"channel", MagickChannelOptions} } },
545 { "Poly", { {"terms", ArrayReference},
546 {"channel", MagickChannelOptions} } },
547 { "Grayscale", { {"method", MagickNoiseOptions} } },
548 { "CannyEdge", { {"geometry", StringReference},
549 {"radius", RealReference}, {"sigma", RealReference},
550 {"lower-percent", RealReference}, {"upper-percent", RealReference} } },
551 { "HoughLine", { {"geometry", StringReference},
552 {"width", IntegerReference}, {"height", IntegerReference},
553 {"threshold", IntegerReference} } },
554 { "MeanShift", { {"geometry", StringReference},
555 {"width", IntegerReference}, {"height", IntegerReference},
556 {"distance", RealReference} } },
557 { "Kuwahara", { {"geometry", StringReference}, {"radius", RealReference},
558 {"sigma", RealReference}, {"channel", MagickChannelOptions} } },
559 { "ConnectedComponents", { {"connectivity", IntegerReference} } },
560 { "CopyPixels", { {"image", ImageReference}, {"geometry", StringReference},
561 {"width", IntegerReference}, {"height", IntegerReference},
562 {"x", IntegerReference}, {"y", IntegerReference},
563 {"gravity", MagickGravityOptions}, {"offset", StringReference},
564 {"dx", IntegerReference}, {"dy", IntegerReference} } },
565 { "Color", { {"color", StringReference} } },
566 { "WaveletDenoise", { {"geometry", StringReference},
567 {"threshold", RealReference}, {"softness", RealReference},
568 {"channel", MagickChannelOptions} } },
569 { "Colorspace", { {"colorspace", MagickColorspaceOptions} } },
570 { "AutoThreshold", { {"method", MagickAutoThresholdOptions} } },
571 { "RangeThreshold", { {"geometry", StringReference},
572 {"low-black", RealReference}, {"low-white", RealReference},
573 {"high-white", RealReference}, {"high-black", RealReference},
574 {"channel", MagickChannelOptions} } },
575 { "CLAHE", { {"geometry", StringReference}, {"width", IntegerReference},
576 {"height", IntegerReference}, {"number-bins", IntegerReference},
577 {"clip-limit", RealReference} } },
578 { "OTSUThreshold", { {"channel", MagickChannelOptions} } },
582 *magick_registry = (SplayTreeInfo *) NULL;
585 Forward declarations.
588 *SetupList(pTHX_ SV *,struct PackageInfo **,SV ***,ExceptionInfo *);
591 strEQcase(const char *,const char *);
594 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
598 % C l o n e P a c k a g e I n f o %
602 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
604 % ClonePackageInfo makes a duplicate of the given info, or if info is NULL,
607 % The format of the ClonePackageInfo routine is:
609 % struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
612 % A description of each parameter follows:
614 % o info: a structure of type info.
616 % o exception: Return any errors or warnings in this structure.
619 static struct PackageInfo *ClonePackageInfo(struct PackageInfo *info,
620 ExceptionInfo *exception)
625 clone_info=(struct PackageInfo *) AcquireQuantumMemory(1,sizeof(*clone_info));
626 if (clone_info == (struct PackageInfo *) NULL)
628 ThrowPerlException(exception,ResourceLimitError,
629 "UnableToClonePackageInfo",PackageName);
630 return((struct PackageInfo *) NULL);
632 if (info == (struct PackageInfo *) NULL)
634 clone_info->image_info=CloneImageInfo((ImageInfo *) NULL);
638 clone_info->image_info=CloneImageInfo(info->image_info);
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
651 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
653 % constant() returns a double value for the specified name.
655 % The format of the constant routine is:
657 % double constant(char *name,ssize_t sans)
659 % A description of each parameter follows:
661 % o value: Method constant returns a double value for the specified name.
663 % o name: The name of the constant.
665 % o sans: This integer value is not used.
668 static double constant(char *name,ssize_t sans)
676 if (strEQ(name,"BlobError"))
678 if (strEQ(name,"BlobWarning"))
684 if (strEQ(name,"CacheError"))
686 if (strEQ(name,"CacheWarning"))
687 return(CacheWarning);
688 if (strEQ(name,"CoderError"))
690 if (strEQ(name,"CoderWarning"))
691 return(CoderWarning);
692 if (strEQ(name,"ConfigureError"))
693 return(ConfigureError);
694 if (strEQ(name,"ConfigureWarning"))
695 return(ConfigureWarning);
696 if (strEQ(name,"CorruptImageError"))
697 return(CorruptImageError);
698 if (strEQ(name,"CorruptImageWarning"))
699 return(CorruptImageWarning);
704 if (strEQ(name,"DelegateError"))
705 return(DelegateError);
706 if (strEQ(name,"DelegateWarning"))
707 return(DelegateWarning);
708 if (strEQ(name,"DrawError"))
710 if (strEQ(name,"DrawWarning"))
716 if (strEQ(name,"ErrorException"))
717 return(ErrorException);
718 if (strEQ(name,"ExceptionError"))
720 if (strEQ(name,"ExceptionWarning"))
721 return(CoderWarning);
726 if (strEQ(name,"FatalErrorException"))
727 return(FatalErrorException);
728 if (strEQ(name,"FileOpenError"))
729 return(FileOpenError);
730 if (strEQ(name,"FileOpenWarning"))
731 return(FileOpenWarning);
736 if (strEQ(name,"ImageError"))
738 if (strEQ(name,"ImageWarning"))
739 return(ImageWarning);
744 if (strEQ(name,"MaxRGB"))
745 return(QuantumRange);
746 if (strEQ(name,"MissingDelegateError"))
747 return(MissingDelegateError);
748 if (strEQ(name,"MissingDelegateWarning"))
749 return(MissingDelegateWarning);
750 if (strEQ(name,"ModuleError"))
752 if (strEQ(name,"ModuleWarning"))
753 return(ModuleWarning);
758 if (strEQ(name,"Opaque"))
760 if (strEQ(name,"OptionError"))
762 if (strEQ(name,"OptionWarning"))
763 return(OptionWarning);
768 if (strEQ(name,"MAGICKCORE_QUANTUM_DEPTH"))
769 return(MAGICKCORE_QUANTUM_DEPTH);
770 if (strEQ(name,"QuantumDepth"))
771 return(MAGICKCORE_QUANTUM_DEPTH);
772 if (strEQ(name,"QuantumRange"))
773 return(QuantumRange);
778 if (strEQ(name,"ResourceLimitError"))
779 return(ResourceLimitError);
780 if (strEQ(name,"ResourceLimitWarning"))
781 return(ResourceLimitWarning);
782 if (strEQ(name,"RegistryError"))
783 return(RegistryError);
784 if (strEQ(name,"RegistryWarning"))
785 return(RegistryWarning);
790 if (strEQ(name,"StreamError"))
792 if (strEQ(name,"StreamWarning"))
793 return(StreamWarning);
794 if (strEQ(name,"Success"))
800 if (strEQ(name,"Transparent"))
801 return(TransparentAlpha);
802 if (strEQ(name,"TypeError"))
804 if (strEQ(name,"TypeWarning"))
810 if (strEQ(name,"WarningException"))
811 return(WarningException);
816 if (strEQ(name,"XServerError"))
817 return(XServerError);
818 if (strEQ(name,"XServerWarning"))
819 return(XServerWarning);
828 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
832 % D e s t r o y P a c k a g e I n f o %
836 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
838 % Method DestroyPackageInfo frees a previously created info structure.
840 % The format of the DestroyPackageInfo routine is:
842 % DestroyPackageInfo(struct PackageInfo *info)
844 % A description of each parameter follows:
846 % o info: a structure of type info.
849 static void DestroyPackageInfo(struct PackageInfo *info)
851 info->image_info=DestroyImageInfo(info->image_info);
852 info=(struct PackageInfo *) RelinquishMagickMemory(info);
856 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
864 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
866 % Method GetList is recursively called by SetupList to traverse the
867 % Image__Magick reference. If building an reference_vector (see SetupList),
868 % *current is the current position in *reference_vector and *last is the final
869 % entry in *reference_vector.
871 % The format of the GetList routine is:
875 % A description of each parameter follows:
877 % o info: a structure of type info.
880 static Image *GetList(pTHX_ SV *reference,SV ***reference_vector,
881 ssize_t *current,ssize_t *last,ExceptionInfo *exception)
886 if (reference == (SV *) NULL)
888 switch (SvTYPE(reference))
908 previous=(Image *) NULL;
912 for (i=0; i <= n; i++)
918 if (rv && *rv && sv_isobject(*rv))
920 image=GetList(aTHX_ SvRV(*rv),reference_vector,current,last,
922 if (image == (Image *) NULL)
924 if (image == previous)
926 image=CloneImage(image,0,0,MagickTrue,exception);
927 if (image == (Image *) NULL)
930 image->previous=previous;
931 *(previous ? &previous->next : &head)=image;
932 for (previous=image; previous->next; previous=previous->next) ;
940 Blessed scalar, one image.
942 image=INT2PTR(Image *,SvIV(reference));
943 if (image == (Image *) NULL)
945 image->previous=(Image *) NULL;
946 image->next=(Image *) NULL;
947 if (reference_vector)
949 if (*current == *last)
952 if (*reference_vector == (SV **) NULL)
953 *reference_vector=(SV **) AcquireQuantumMemory(*last,
954 sizeof(*reference_vector));
956 *reference_vector=(SV **) ResizeQuantumMemory(*reference_vector,
957 *last,sizeof(*reference_vector));
959 if (*reference_vector == (SV **) NULL)
961 ThrowPerlException(exception,ResourceLimitError,
962 "MemoryAllocationFailed",PackageName);
963 return((Image *) NULL);
965 (*reference_vector)[*current]=reference;
966 (*reference_vector)[++(*current)]=NULL;
973 (void) fprintf(stderr,"GetList: UnrecognizedType %.20g\n",
974 (double) SvTYPE(reference));
975 return((Image *) NULL);
979 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
983 % G e t P a c k a g e I n f o %
987 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
989 % Method GetPackageInfo looks up or creates an info structure for the given
990 % Image__Magick reference. If it does create a new one, the information in
991 % package_info is used to initialize it.
993 % The format of the GetPackageInfo routine is:
995 % struct PackageInfo *GetPackageInfo(void *reference,
996 % struct PackageInfo *package_info,ExceptionInfo *exception)
998 % A description of each parameter follows:
1000 % o info: a structure of type info.
1002 % o exception: Return any errors or warnings in this structure.
1005 static struct PackageInfo *GetPackageInfo(pTHX_ void *reference,
1006 struct PackageInfo *package_info,ExceptionInfo *exception)
1009 message[MagickPathExtent];
1017 (void) FormatLocaleString(message,MagickPathExtent,"%s::package%s%p",
1018 PackageName,XS_VERSION,reference);
1019 sv=perl_get_sv(message,(TRUE | 0x02));
1020 if (sv == (SV *) NULL)
1022 ThrowPerlException(exception,ResourceLimitError,"UnableToGetPackageInfo",
1024 return(package_info);
1026 if (SvREFCNT(sv) == 0)
1027 (void) SvREFCNT_inc(sv);
1028 if (SvIOKp(sv) && (clone_info=INT2PTR(struct PackageInfo *,SvIV(sv))))
1030 clone_info=ClonePackageInfo(package_info,exception);
1031 sv_setiv(sv,PTR2IV(clone_info));
1036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1040 % S e t A t t r i b u t e %
1044 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1046 % SetAttribute() sets the attribute to the value in sval. This can change
1047 % either or both of image or info.
1049 % The format of the SetAttribute routine is:
1051 % SetAttribute(struct PackageInfo *info,Image *image,char *attribute,
1052 % SV *sval,ExceptionInfo *exception)
1054 % A description of each parameter follows:
1056 % o list: a list of strings.
1058 % o string: a character string.
1062 static double SiPrefixToDoubleInterval(const char *string,const double interval)
1070 value=InterpretSiPrefixValue(string,&q);
1072 value*=interval/100.0;
1076 static inline double StringToDouble(const char *string,char **sentinal)
1078 return(InterpretLocaleValue(string,sentinal));
1081 static double StringToDoubleInterval(const char *string,const double interval)
1089 value=InterpretLocaleValue(string,&q);
1091 value*=interval/100.0;
1095 static inline ssize_t StringToLong(const char *value)
1097 return(strtol(value,(char **) NULL,10));
1100 static void SetAttribute(pTHX_ struct PackageInfo *info,Image *image,
1101 const char *attribute,SV *sval,ExceptionInfo *exception)
1128 if (LocaleCompare(attribute,"adjoin") == 0)
1130 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1131 SvPV(sval,na)) : SvIV(sval);
1134 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1139 info->image_info->adjoin=sp != 0 ? MagickTrue : MagickFalse;
1142 if (LocaleCompare(attribute,"alpha") == 0)
1144 sp=SvPOK(sval) ? ParseCommandOption(MagickAlphaChannelOptions,
1145 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1148 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1152 for ( ; image; image=image->next)
1153 (void) SetImageAlphaChannel(image,(AlphaChannelOption) sp,
1157 if (LocaleCompare(attribute,"antialias") == 0)
1159 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1160 SvPV(sval,na)) : SvIV(sval);
1163 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1168 info->image_info->antialias=sp != 0 ? MagickTrue : MagickFalse;
1171 if (LocaleCompare(attribute,"area-limit") == 0)
1176 limit=MagickResourceInfinity;
1177 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1178 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1180 (void) SetMagickResourceLimit(AreaResource,limit);
1183 if (LocaleCompare(attribute,"attenuate") == 0)
1186 (void) SetImageOption(info->image_info,attribute,SvPV(sval,na));
1189 if (LocaleCompare(attribute,"authenticate") == 0)
1192 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1196 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1197 for ( ; image; image=image->next)
1199 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1200 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1207 if (LocaleCompare(attribute,"background") == 0)
1209 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1212 info->image_info->background_color=target_color;
1213 for ( ; image; image=image->next)
1214 image->background_color=target_color;
1217 if (LocaleCompare(attribute,"blue-primary") == 0)
1219 for ( ; image; image=image->next)
1221 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1222 image->chromaticity.blue_primary.x=geometry_info.rho;
1223 image->chromaticity.blue_primary.y=geometry_info.sigma;
1224 if ((flags & SigmaValue) == 0)
1225 image->chromaticity.blue_primary.y=
1226 image->chromaticity.blue_primary.x;
1230 if (LocaleCompare(attribute,"bordercolor") == 0)
1232 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1235 info->image_info->border_color=target_color;
1236 for ( ; image; image=image->next)
1237 image->border_color=target_color;
1241 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1242 for ( ; image; image=image->next)
1244 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1245 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1252 if (LocaleCompare(attribute,"cache-threshold") == 0)
1254 (void) SetMagickResourceLimit(MemoryResource,(MagickSizeType)
1255 SiPrefixToDoubleInterval(SvPV(sval,na),100.0));
1256 (void) SetMagickResourceLimit(MapResource,(MagickSizeType)
1257 (2.0*SiPrefixToDoubleInterval(SvPV(sval,na),100.0)));
1260 if (LocaleCompare(attribute,"clip-mask") == 0)
1265 clip_mask=(Image *) NULL;
1267 clip_mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1268 for ( ; image; image=image->next)
1269 SetImageMask(image,ReadPixelMask,clip_mask,exception);
1272 if (LocaleNCompare(attribute,"colormap",8) == 0)
1274 for ( ; image; image=image->next)
1282 if (image->storage_class == DirectClass)
1285 items=sscanf(attribute,"%*[^[][%ld",&i);
1287 if (i > (ssize_t) image->colors)
1289 if ((strchr(SvPV(sval,na),',') == 0) ||
1290 (strchr(SvPV(sval,na),')') != 0))
1291 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1292 image->colormap+i,exception);
1295 color=image->colormap+i;
1296 pixel.red=color->red;
1297 pixel.green=color->green;
1298 pixel.blue=color->blue;
1299 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1300 pixel.red=geometry_info.rho;
1301 pixel.green=geometry_info.sigma;
1302 pixel.blue=geometry_info.xi;
1303 color->red=ClampToQuantum(pixel.red);
1304 color->green=ClampToQuantum(pixel.green);
1305 color->blue=ClampToQuantum(pixel.blue);
1310 if (LocaleCompare(attribute,"colorspace") == 0)
1312 sp=SvPOK(sval) ? ParseCommandOption(MagickColorspaceOptions,
1313 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1316 ThrowPerlException(exception,OptionError,"UnrecognizedColorspace",
1320 for ( ; image; image=image->next)
1321 (void) SetImageColorspace(image,(ColorspaceType) sp,exception);
1324 if (LocaleCompare(attribute,"comment") == 0)
1326 for ( ; image; image=image->next)
1327 (void) SetImageProperty(image,"Comment",InterpretImageProperties(
1328 info ? info->image_info : (ImageInfo *) NULL,image,
1329 SvPV(sval,na),exception),exception);
1332 if (LocaleCompare(attribute,"compression") == 0)
1334 sp=SvPOK(sval) ? ParseCommandOption(MagickCompressOptions,
1335 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1338 ThrowPerlException(exception,OptionError,
1339 "UnrecognizedImageCompression",SvPV(sval,na));
1343 info->image_info->compression=(CompressionType) sp;
1344 for ( ; image; image=image->next)
1345 image->compression=(CompressionType) sp;
1349 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1350 for ( ; image; image=image->next)
1352 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1353 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1360 if (LocaleCompare(attribute,"debug") == 0)
1362 SetLogEventMask(SvPV(sval,na));
1365 if (LocaleCompare(attribute,"delay") == 0)
1367 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1368 for ( ; image; image=image->next)
1370 image->delay=(size_t) floor(geometry_info.rho+0.5);
1371 if ((flags & SigmaValue) != 0)
1372 image->ticks_per_second=(ssize_t)
1373 floor(geometry_info.sigma+0.5);
1377 if (LocaleCompare(attribute,"disk-limit") == 0)
1382 limit=MagickResourceInfinity;
1383 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1384 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1386 (void) SetMagickResourceLimit(DiskResource,limit);
1389 if (LocaleCompare(attribute,"density") == 0)
1391 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
1393 ThrowPerlException(exception,OptionError,"MissingGeometry",
1398 (void) CloneString(&info->image_info->density,SvPV(sval,na));
1399 for ( ; image; image=image->next)
1401 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1402 image->resolution.x=geometry_info.rho;
1403 image->resolution.y=geometry_info.sigma;
1404 if ((flags & SigmaValue) == 0)
1405 image->resolution.y=image->resolution.x;
1409 if (LocaleCompare(attribute,"depth") == 0)
1412 info->image_info->depth=SvIV(sval);
1413 for ( ; image; image=image->next)
1414 (void) SetImageDepth(image,SvIV(sval),exception);
1417 if (LocaleCompare(attribute,"dispose") == 0)
1419 sp=SvPOK(sval) ? ParseCommandOption(MagickDisposeOptions,MagickFalse,
1420 SvPV(sval,na)) : SvIV(sval);
1423 ThrowPerlException(exception,OptionError,
1424 "UnrecognizedDisposeMethod",SvPV(sval,na));
1427 for ( ; image; image=image->next)
1428 image->dispose=(DisposeType) sp;
1431 if (LocaleCompare(attribute,"dither") == 0)
1435 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,
1436 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1439 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1443 info->image_info->dither=sp != 0 ? MagickTrue : MagickFalse;
1447 if (LocaleCompare(attribute,"display") == 0)
1451 (void) CloneString(&info->image_info->server_name,SvPV(sval,na));
1455 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1456 for ( ; image; image=image->next)
1458 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1459 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1466 if (LocaleCompare(attribute,"endian") == 0)
1468 sp=SvPOK(sval) ? ParseCommandOption(MagickEndianOptions,MagickFalse,
1469 SvPV(sval,na)) : SvIV(sval);
1472 ThrowPerlException(exception,OptionError,"UnrecognizedEndianType",
1477 info->image_info->endian=(EndianType) sp;
1478 for ( ; image; image=image->next)
1479 image->endian=(EndianType) sp;
1482 if (LocaleCompare(attribute,"extract") == 0)
1485 Set image extract geometry.
1487 (void) CloneString(&info->image_info->extract,SvPV(sval,na));
1491 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1492 for ( ; image; image=image->next)
1494 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1495 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1502 if (LocaleCompare(attribute,"filename") == 0)
1505 (void) CopyMagickString(info->image_info->filename,SvPV(sval,na),
1507 for ( ; image; image=image->next)
1508 (void) CopyMagickString(image->filename,SvPV(sval,na),
1512 if (LocaleCompare(attribute,"file") == 0)
1520 if (info == (struct PackageInfo *) NULL)
1522 io_info=IoIFP(sv_2io(sval));
1523 if (io_info == (PerlIO *) NULL)
1525 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1529 file=PerlIO_findFILE(io_info);
1530 if (file == (FILE *) NULL)
1532 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
1536 SetImageInfoFile(info->image_info,file);
1539 if (LocaleCompare(attribute,"fill") == 0)
1542 (void) SetImageOption(info->image_info,"fill",SvPV(sval,na));
1545 if (LocaleCompare(attribute,"font") == 0)
1548 (void) CloneString(&info->image_info->font,SvPV(sval,na));
1551 if (LocaleCompare(attribute,"foreground") == 0)
1553 if (LocaleCompare(attribute,"fuzz") == 0)
1556 info->image_info->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1558 for ( ; image; image=image->next)
1559 image->fuzz=StringToDoubleInterval(SvPV(sval,na),(double)
1564 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1565 for ( ; image; image=image->next)
1567 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1568 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1575 if (LocaleCompare(attribute,"gamma") == 0)
1577 for ( ; image; image=image->next)
1578 image->gamma=SvNV(sval);
1581 if (LocaleCompare(attribute,"gravity") == 0)
1583 sp=SvPOK(sval) ? ParseCommandOption(MagickGravityOptions,MagickFalse,
1584 SvPV(sval,na)) : SvIV(sval);
1587 ThrowPerlException(exception,OptionError,
1588 "UnrecognizedGravityType",SvPV(sval,na));
1592 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1593 for ( ; image; image=image->next)
1594 image->gravity=(GravityType) sp;
1597 if (LocaleCompare(attribute,"green-primary") == 0)
1599 for ( ; image; image=image->next)
1601 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1602 image->chromaticity.green_primary.x=geometry_info.rho;
1603 image->chromaticity.green_primary.y=geometry_info.sigma;
1604 if ((flags & SigmaValue) == 0)
1605 image->chromaticity.green_primary.y=
1606 image->chromaticity.green_primary.x;
1611 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1612 for ( ; image; image=image->next)
1614 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1615 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1622 if (LocaleNCompare(attribute,"index",5) == 0)
1636 for ( ; image; image=image->next)
1638 if (image->storage_class != PseudoClass)
1642 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1644 image_view=AcquireAuthenticCacheView(image,exception);
1645 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1646 if (q != (Quantum *) NULL)
1648 items=sscanf(SvPV(sval,na),"%ld",&index);
1649 if ((index >= 0) && (index < (ssize_t) image->colors))
1650 SetPixelIndex(image,index,q);
1651 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1653 image_view=DestroyCacheView(image_view);
1657 if (LocaleCompare(attribute,"iterations") == 0)
1660 for ( ; image; image=image->next)
1661 image->iterations=SvIV(sval);
1664 if (LocaleCompare(attribute,"interlace") == 0)
1666 sp=SvPOK(sval) ? ParseCommandOption(MagickInterlaceOptions,
1667 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1670 ThrowPerlException(exception,OptionError,
1671 "UnrecognizedInterlaceType",SvPV(sval,na));
1675 info->image_info->interlace=(InterlaceType) sp;
1676 for ( ; image; image=image->next)
1677 image->interlace=(InterlaceType) sp;
1681 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1682 for ( ; image; image=image->next)
1683 SetImageProperty(image,attribute,SvPV(sval,na),exception);
1689 if (LocaleCompare(attribute,"label") == 0)
1691 for ( ; image; image=image->next)
1692 (void) SetImageProperty(image,"label",InterpretImageProperties(
1693 info ? info->image_info : (ImageInfo *) NULL,image,
1694 SvPV(sval,na),exception),exception);
1697 if (LocaleCompare(attribute,"loop") == 0)
1700 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1701 for ( ; image; image=image->next)
1703 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1704 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1711 if (LocaleCompare(attribute,"magick") == 0)
1714 (void) FormatLocaleString(info->image_info->filename,
1715 MagickPathExtent,"%s:",SvPV(sval,na));
1716 for ( ; image; image=image->next)
1717 (void) CopyMagickString(image->magick,SvPV(sval,na),
1721 if (LocaleCompare(attribute,"map-limit") == 0)
1726 limit=MagickResourceInfinity;
1727 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1728 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1730 (void) SetMagickResourceLimit(MapResource,limit);
1733 if (LocaleCompare(attribute,"mask") == 0)
1738 mask=(Image *) NULL;
1740 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1741 for ( ; image; image=image->next)
1742 SetImageMask(image,ReadPixelMask,mask,exception);
1745 if (LocaleCompare(attribute,"mattecolor") == 0)
1747 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
1750 info->image_info->alpha_color=target_color;
1751 for ( ; image; image=image->next)
1752 image->alpha_color=target_color;
1755 if (LocaleCompare(attribute,"matte") == 0)
1757 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1758 SvPV(sval,na)) : SvIV(sval);
1761 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1765 for ( ; image; image=image->next)
1766 image->alpha_trait=sp != 0 ? BlendPixelTrait : UndefinedPixelTrait;
1769 if (LocaleCompare(attribute,"memory-limit") == 0)
1774 limit=MagickResourceInfinity;
1775 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
1776 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
1778 (void) SetMagickResourceLimit(MemoryResource,limit);
1781 if (LocaleCompare(attribute,"monochrome") == 0)
1783 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
1784 SvPV(sval,na)) : SvIV(sval);
1787 ThrowPerlException(exception,OptionError,"UnrecognizedType",
1792 info->image_info->monochrome=sp != 0 ? MagickTrue : MagickFalse;
1793 for ( ; image; image=image->next)
1794 (void) SetImageType(image,BilevelType,exception);
1798 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1799 for ( ; image; image=image->next)
1801 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1802 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1809 if (LocaleCompare(attribute,"option") == 0)
1812 DefineImageOption(info->image_info,SvPV(sval,na));
1815 if (LocaleCompare(attribute,"orientation") == 0)
1817 sp=SvPOK(sval) ? ParseCommandOption(MagickOrientationOptions,
1818 MagickFalse,SvPV(sval,na)) : SvIV(sval);
1821 ThrowPerlException(exception,OptionError,
1822 "UnrecognizedOrientationType",SvPV(sval,na));
1826 info->image_info->orientation=(OrientationType) sp;
1827 for ( ; image; image=image->next)
1828 image->orientation=(OrientationType) sp;
1832 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1833 for ( ; image; image=image->next)
1835 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1836 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1843 if (LocaleCompare(attribute,"page") == 0)
1848 geometry=GetPageGeometry(SvPV(sval,na));
1850 (void) CloneString(&info->image_info->page,geometry);
1851 for ( ; image; image=image->next)
1852 (void) ParsePageGeometry(image,geometry,&image->page,exception);
1853 geometry=(char *) RelinquishMagickMemory(geometry);
1856 if (LocaleNCompare(attribute,"pixel",5) == 0)
1870 for ( ; image; image=image->next)
1872 if (SetImageStorageClass(image,DirectClass,exception) == MagickFalse)
1876 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
1878 image_view=AcquireVirtualCacheView(image,exception);
1879 q=GetCacheViewAuthenticPixels(image_view,x,y,1,1,exception);
1880 if (q != (Quantum *) NULL)
1882 if ((strchr(SvPV(sval,na),',') == 0) ||
1883 (strchr(SvPV(sval,na),')') != 0))
1884 QueryColorCompliance(SvPV(sval,na),AllCompliance,
1888 GetPixelInfo(image,&pixel);
1889 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1890 pixel.red=geometry_info.rho;
1891 if ((flags & SigmaValue) != 0)
1892 pixel.green=geometry_info.sigma;
1893 if ((flags & XiValue) != 0)
1894 pixel.blue=geometry_info.xi;
1895 if ((flags & PsiValue) != 0)
1896 pixel.alpha=geometry_info.psi;
1897 if ((flags & ChiValue) != 0)
1898 pixel.black=geometry_info.chi;
1900 SetPixelRed(image,ClampToQuantum(pixel.red),q);
1901 SetPixelGreen(image,ClampToQuantum(pixel.green),q);
1902 SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
1903 if (image->colorspace == CMYKColorspace)
1904 SetPixelBlack(image,ClampToQuantum(pixel.black),q);
1905 SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q);
1906 (void) SyncCacheViewAuthenticPixels(image_view,exception);
1908 image_view=DestroyCacheView(image_view);
1912 if (LocaleCompare(attribute,"pointsize") == 0)
1916 (void) ParseGeometry(SvPV(sval,na),&geometry_info);
1917 info->image_info->pointsize=geometry_info.rho;
1922 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1923 for ( ; image; image=image->next)
1925 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1926 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1933 if (LocaleCompare(attribute,"quality") == 0)
1936 info->image_info->quality=SvIV(sval);
1937 for ( ; image; image=image->next)
1938 image->quality=SvIV(sval);
1942 SetImageOption(info->image_info,attribute,SvPV(sval,na));
1943 for ( ; image; image=image->next)
1945 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
1946 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
1953 if (LocaleCompare(attribute,"read-mask") == 0)
1958 mask=(Image *) NULL;
1960 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
1961 for ( ; image; image=image->next)
1962 SetImageMask(image,ReadPixelMask,mask,exception);
1965 if (LocaleCompare(attribute,"red-primary") == 0)
1967 for ( ; image; image=image->next)
1969 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
1970 image->chromaticity.red_primary.x=geometry_info.rho;
1971 image->chromaticity.red_primary.y=geometry_info.sigma;
1972 if ((flags & SigmaValue) == 0)
1973 image->chromaticity.red_primary.y=
1974 image->chromaticity.red_primary.x;
1978 if (LocaleCompare(attribute,"render") == 0)
1980 sp=SvPOK(sval) ? ParseCommandOption(MagickIntentOptions,MagickFalse,
1981 SvPV(sval,na)) : SvIV(sval);
1984 ThrowPerlException(exception,OptionError,"UnrecognizedIntentType",
1988 for ( ; image; image=image->next)
1989 image->rendering_intent=(RenderingIntent) sp;
1992 if (LocaleCompare(attribute,"repage") == 0)
1997 for ( ; image; image=image->next)
1999 flags=ParseAbsoluteGeometry(SvPV(sval,na),&geometry);
2000 if ((flags & WidthValue) != 0)
2002 if ((flags & HeightValue) == 0)
2003 geometry.height=geometry.width;
2004 image->page.width=geometry.width;
2005 image->page.height=geometry.height;
2007 if ((flags & AspectValue) != 0)
2009 if ((flags & XValue) != 0)
2010 image->page.x+=geometry.x;
2011 if ((flags & YValue) != 0)
2012 image->page.y+=geometry.y;
2016 if ((flags & XValue) != 0)
2018 image->page.x=geometry.x;
2019 if (((flags & WidthValue) != 0) && (geometry.x > 0))
2020 image->page.width=image->columns+geometry.x;
2022 if ((flags & YValue) != 0)
2024 image->page.y=geometry.y;
2025 if (((flags & HeightValue) != 0) && (geometry.y > 0))
2026 image->page.height=image->rows+geometry.y;
2033 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2034 for ( ; image; image=image->next)
2036 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
2037 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
2044 if (LocaleCompare(attribute,"sampling-factor") == 0)
2046 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2048 ThrowPerlException(exception,OptionError,"MissingGeometry",
2053 (void) CloneString(&info->image_info->sampling_factor,
2057 if (LocaleCompare(attribute,"scene") == 0)
2059 for ( ; image; image=image->next)
2060 image->scene=SvIV(sval);
2063 if (LocaleCompare(attribute,"server") == 0)
2065 if (LocaleCompare(attribute,"size") == 0)
2069 if (IsGeometry(SvPV(sval,na)) == MagickFalse)
2071 ThrowPerlException(exception,OptionError,"MissingGeometry",
2075 (void) CloneString(&info->image_info->size,SvPV(sval,na));
2079 if (LocaleCompare(attribute,"stroke") == 0)
2082 (void) SetImageOption(info->image_info,"stroke",SvPV(sval,na));
2086 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2087 for ( ; image; image=image->next)
2089 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
2090 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
2097 if (LocaleCompare(attribute,"texture") == 0)
2100 (void) CloneString(&info->image_info->texture,SvPV(sval,na));
2103 if (LocaleCompare(attribute,"thread-limit") == 0)
2108 limit=MagickResourceInfinity;
2109 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2110 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2112 (void) SetMagickResourceLimit(ThreadResource,limit);
2115 if (LocaleCompare(attribute,"tile-offset") == 0)
2120 geometry=GetPageGeometry(SvPV(sval,na));
2122 (void) CloneString(&info->image_info->page,geometry);
2123 for ( ; image; image=image->next)
2124 (void) ParsePageGeometry(image,geometry,&image->tile_offset,
2126 geometry=(char *) RelinquishMagickMemory(geometry);
2129 if (LocaleCompare(attribute,"time-limit") == 0)
2134 limit=MagickResourceInfinity;
2135 if (LocaleCompare(SvPV(sval,na),"unlimited") != 0)
2136 limit=(MagickSizeType) SiPrefixToDoubleInterval(SvPV(sval,na),
2138 (void) SetMagickResourceLimit(TimeResource,limit);
2141 if (LocaleCompare(attribute,"transparent-color") == 0)
2143 (void) QueryColorCompliance(SvPV(sval,na),AllCompliance,&target_color,
2146 info->image_info->transparent_color=target_color;
2147 for ( ; image; image=image->next)
2148 image->transparent_color=target_color;
2151 if (LocaleCompare(attribute,"type") == 0)
2153 sp=SvPOK(sval) ? ParseCommandOption(MagickTypeOptions,MagickFalse,
2154 SvPV(sval,na)) : SvIV(sval);
2157 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2162 info->image_info->type=(ImageType) sp;
2163 for ( ; image; image=image->next)
2164 SetImageType(image,(ImageType) sp,exception);
2168 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2169 for ( ; image; image=image->next)
2171 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
2172 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
2179 if (LocaleCompare(attribute,"units") == 0)
2181 sp=SvPOK(sval) ? ParseCommandOption(MagickResolutionOptions,
2182 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2185 ThrowPerlException(exception,OptionError,"UnrecognizedUnitsType",
2190 info->image_info->units=(ResolutionType) sp;
2191 for ( ; image; image=image->next)
2196 units=(ResolutionType) sp;
2197 if (image->units != units)
2198 switch (image->units)
2200 case UndefinedResolution:
2201 case PixelsPerInchResolution:
2203 if (units == PixelsPerCentimeterResolution)
2205 image->resolution.x*=2.54;
2206 image->resolution.y*=2.54;
2210 case PixelsPerCentimeterResolution:
2212 if (units == PixelsPerInchResolution)
2214 image->resolution.x/=2.54;
2215 image->resolution.y/=2.54;
2225 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2226 for ( ; image; image=image->next)
2228 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
2229 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
2236 if (LocaleCompare(attribute,"verbose") == 0)
2238 sp=SvPOK(sval) ? ParseCommandOption(MagickBooleanOptions,MagickFalse,
2239 SvPV(sval,na)) : SvIV(sval);
2242 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2247 info->image_info->verbose=sp != 0 ? MagickTrue : MagickFalse;
2250 if (LocaleCompare(attribute,"virtual-pixel") == 0)
2252 sp=SvPOK(sval) ? ParseCommandOption(MagickVirtualPixelOptions,
2253 MagickFalse,SvPV(sval,na)) : SvIV(sval);
2256 ThrowPerlException(exception,OptionError,
2257 "UnrecognizedVirtualPixelMethod",SvPV(sval,na));
2260 for ( ; image; image=image->next)
2261 SetImageVirtualPixelMethod(image,(VirtualPixelMethod) sp,exception);
2265 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2266 for ( ; image; image=image->next)
2268 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
2269 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
2276 if (LocaleCompare(attribute,"white-point") == 0)
2278 for ( ; image; image=image->next)
2280 flags=ParseGeometry(SvPV(sval,na),&geometry_info);
2281 image->chromaticity.white_point.x=geometry_info.rho;
2282 image->chromaticity.white_point.y=geometry_info.sigma;
2283 if ((flags & SigmaValue) == 0)
2284 image->chromaticity.white_point.y=
2285 image->chromaticity.white_point.x;
2289 if (LocaleCompare(attribute,"write-mask") == 0)
2294 mask=(Image *) NULL;
2296 mask=SetupList(aTHX_ SvRV(sval),&info,(SV ***) NULL,exception);
2297 for ( ; image; image=image->next)
2298 SetImageMask(image,WritePixelMask,mask,exception);
2302 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2303 for ( ; image; image=image->next)
2305 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
2306 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
2313 SetImageOption(info->image_info,attribute,SvPV(sval,na));
2314 for ( ; image; image=image->next)
2316 (void) SetImageProperty(image,attribute,SvPV(sval,na),exception);
2317 (void) SetImageArtifact(image,attribute,SvPV(sval,na));
2325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2329 % S e t u p L i s t %
2333 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2335 % Method SetupList returns the list of all the images linked by their
2336 % image->next and image->previous link lists for use with ImageMagick. If
2337 % info is non-NULL, an info structure is returned in *info. If
2338 % reference_vector is non-NULL,an array of SV* are returned in
2339 % *reference_vector. Reference_vector is used when the images are going to be
2340 % replaced with new Image*'s.
2342 % The format of the SetupList routine is:
2344 % Image *SetupList(SV *reference,struct PackageInfo **info,
2345 % SV ***reference_vector,ExceptionInfo *exception)
2347 % A description of each parameter follows:
2349 % o list: a list of strings.
2351 % o string: a character string.
2353 % o exception: Return any errors or warnings in this structure.
2356 static Image *SetupList(pTHX_ SV *reference,struct PackageInfo **info,
2357 SV ***reference_vector,ExceptionInfo *exception)
2366 if (reference_vector)
2367 *reference_vector=NULL;
2372 image=GetList(aTHX_ reference,reference_vector,¤t,&last,exception);
2373 if (info && (SvTYPE(reference) == SVt_PVAV))
2374 *info=GetPackageInfo(aTHX_ (void *) reference,(struct PackageInfo *) NULL,
2380 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2384 % s t r E Q c a s e %
2388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2390 % strEQcase() compares two strings and returns 0 if they are the
2391 % same or if the second string runs out first. The comparison is case
2394 % The format of the strEQcase routine is:
2396 % ssize_t strEQcase(const char *p,const char *q)
2398 % A description of each parameter follows:
2400 % o p: a character string.
2402 % o q: a character string.
2406 static ssize_t strEQcase(const char *p,const char *q)
2414 for (i=0 ; (c=(*q)) != 0; i++)
2416 if ((isUPPER((unsigned char) c) ? toLOWER(c) : c) !=
2417 (isUPPER((unsigned char) *p) ? toLOWER(*p) : *p))
2422 return(((*q == 0) && (*p == 0)) ? i : 0);
2426 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2430 % I m a g e : : M a g i c k %
2434 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2438 MODULE = Image::Magick::@MAGICK_ABI_SUFFIX@ PACKAGE = Image::Magick::@MAGICK_ABI_SUFFIX@
2443 MagickCoreGenesis("PerlMagick",MagickFalse);
2444 SetWarningHandler(NULL);
2445 SetErrorHandler(NULL);
2446 magick_registry=NewSplayTree((int (*)(const void *,const void *))
2447 NULL,(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
2453 if (magick_registry != (SplayTreeInfo *) NULL)
2454 magick_registry=DestroySplayTree(magick_registry);
2455 MagickCoreTerminus();
2459 constant(name,argument)
2464 ###############################################################################
2472 ###############################################################################
2477 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
2501 PERL_UNUSED_VAR(ref);
2502 PERL_UNUSED_VAR(ix);
2503 exception=AcquireExceptionInfo();
2504 perl_exception=newSVpv("",0);
2505 package_info=(struct PackageInfo *) NULL;
2506 if (sv_isobject(ST(0)) == 0)
2508 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2512 reference=SvRV(ST(0));
2513 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2514 if (image == (Image *) NULL)
2516 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2520 package_info=ClonePackageInfo(info,exception);
2522 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
2525 for (i=2; i < items; i+=2)
2526 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
2528 (void) AnimateImages(package_info->image_info,image,exception);
2529 (void) CatchImageException(image);
2532 if (package_info != (struct PackageInfo *) NULL)
2533 DestroyPackageInfo(package_info);
2534 InheritPerlException(exception,perl_exception);
2535 exception=DestroyExceptionInfo(exception);
2536 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2537 SvPOK_on(perl_exception);
2538 ST(0)=sv_2mortal(perl_exception);
2543 ###############################################################################
2551 ###############################################################################
2556 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
2594 PERL_UNUSED_VAR(ref);
2595 PERL_UNUSED_VAR(ix);
2596 exception=AcquireExceptionInfo();
2597 perl_exception=newSVpv("",0);
2601 if (sv_isobject(ST(0)) == 0)
2603 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2607 reference=SvRV(ST(0));
2608 hv=SvSTASH(reference);
2610 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2612 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2613 if (image == (Image *) NULL)
2615 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2619 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2624 for (i=2; i < items; i+=2)
2626 attribute=(char *) SvPV(ST(i-1),na);
2632 if (LocaleCompare(attribute,"stack") == 0)
2634 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
2638 ThrowPerlException(exception,OptionError,"UnrecognizedType",
2644 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2650 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
2656 image=AppendImages(image,stack != 0 ? MagickTrue : MagickFalse,exception);
2657 if (image == (Image *) NULL)
2659 for ( ; image; image=image->next)
2661 AddImageToRegistry(sv,image);
2663 av_push(av,sv_bless(rv,hv));
2666 exception=DestroyExceptionInfo(exception);
2668 SvREFCNT_dec(perl_exception);
2672 InheritPerlException(exception,perl_exception);
2673 exception=DestroyExceptionInfo(exception);
2674 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2675 SvPOK_on(perl_exception);
2676 ST(0)=sv_2mortal(perl_exception);
2681 ###############################################################################
2689 ###############################################################################
2694 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
2725 PERL_UNUSED_VAR(ref);
2726 PERL_UNUSED_VAR(ix);
2727 exception=AcquireExceptionInfo();
2728 perl_exception=newSVpv("",0);
2730 if (sv_isobject(ST(0)) == 0)
2732 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2736 reference=SvRV(ST(0));
2737 hv=SvSTASH(reference);
2738 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
2739 if (image == (Image *) NULL)
2741 ThrowPerlException(exception,OptionError,"NoImagesDefined",
2745 image=EvaluateImages(image,MeanEvaluateOperator,exception);
2746 if (image == (Image *) NULL)
2749 Create blessed Perl array for the returned image.
2752 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
2754 AddImageToRegistry(sv,image);
2756 av_push(av,sv_bless(rv,hv));
2758 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
2759 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
2760 "average-%.*s",(int) (MagickPathExtent-9),
2761 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
2762 (void) CopyMagickString(image->filename,info->image_info->filename,
2764 SetImageInfo(info->image_info,0,exception);
2765 exception=DestroyExceptionInfo(exception);
2766 SvREFCNT_dec(perl_exception);
2770 InheritPerlException(exception,perl_exception);
2771 exception=DestroyExceptionInfo(exception);
2772 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
2773 SvPOK_on(perl_exception);
2774 ST(0)=sv_2mortal(perl_exception);
2779 ###############################################################################
2783 # B l o b T o I m a g e #
2787 ###############################################################################
2791 BlobToImage(ref,...)
2792 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
2838 PERL_UNUSED_VAR(ref);
2839 PERL_UNUSED_VAR(ix);
2840 exception=AcquireExceptionInfo();
2841 perl_exception=newSVpv("",0);
2844 ac=(items < 2) ? 1 : items-1;
2845 length=(STRLEN *) NULL;
2846 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
2847 if (list == (char **) NULL)
2849 ThrowPerlException(exception,ResourceLimitError,
2850 "MemoryAllocationFailed",PackageName);
2853 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
2854 if (length == (STRLEN *) NULL)
2856 ThrowPerlException(exception,ResourceLimitError,
2857 "MemoryAllocationFailed",PackageName);
2860 if (sv_isobject(ST(0)) == 0)
2862 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2866 reference=SvRV(ST(0));
2867 hv=SvSTASH(reference);
2868 if (SvTYPE(reference) != SVt_PVAV)
2870 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
2874 av=(AV *) reference;
2875 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
2880 ThrowPerlException(exception,OptionError,"NoBlobDefined",PackageName);
2883 for (n=0, i=0; i < ac; i++)
2885 list[n]=(char *) (SvPV(ST(i+1),length[n]));
2886 if ((items >= 3) && strEQcase((char *) SvPV(ST(i+1),na),"blob"))
2888 list[n]=(char *) (SvPV(ST(i+2),length[n]));
2893 list[n]=(char *) NULL;
2895 for (i=number_images=0; i < n; i++)
2897 image=BlobToImage(info->image_info,list[i],length[i],exception);
2898 if (image == (Image *) NULL)
2900 for ( ; image; image=image->next)
2902 AddImageToRegistry(sv,image);
2904 av_push(av,sv_bless(rv,hv));
2912 for (i=0; i < n; i++)
2913 if (list[i] != (char *) NULL)
2914 for (p=keep; list[i] != *p++; )
2915 if (*p == (char *) NULL)
2917 list[i]=(char *) RelinquishMagickMemory(list[i]);
2923 list=(char **) RelinquishMagickMemory(list);
2925 length=(STRLEN *) RelinquishMagickMemory(length);
2926 InheritPerlException(exception,perl_exception);
2927 exception=DestroyExceptionInfo(exception);
2928 sv_setiv(perl_exception,(IV) number_images);
2929 SvPOK_on(perl_exception);
2930 ST(0)=sv_2mortal(perl_exception);
2935 ###############################################################################
2939 # C h a n n e l F x #
2943 ###############################################################################
2948 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
2960 expression[MagickPathExtent];
2988 PERL_UNUSED_VAR(ref);
2989 PERL_UNUSED_VAR(ix);
2990 exception=AcquireExceptionInfo();
2991 perl_exception=newSVpv("",0);
2995 if (sv_isobject(ST(0)) == 0)
2997 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3001 reference=SvRV(ST(0));
3002 hv=SvSTASH(reference);
3004 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3006 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3007 if (image == (Image *) NULL)
3009 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3013 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3017 channel=DefaultChannels;
3018 (void) CopyMagickString(expression,"u",MagickPathExtent);
3020 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),MagickPathExtent);
3022 for (i=2; i < items; i+=2)
3024 attribute=(char *) SvPV(ST(i-1),na);
3030 if (LocaleCompare(attribute,"channel") == 0)
3035 option=ParseChannelOption(SvPV(ST(i),na));
3038 ThrowPerlException(exception,OptionError,
3039 "UnrecognizedType",SvPV(ST(i),na));
3042 channel=(ChannelType) option;
3045 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3052 if (LocaleCompare(attribute,"expression") == 0)
3054 (void) CopyMagickString(expression,SvPV(ST(i),na),
3058 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3064 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3070 channel_mask=SetImageChannelMask(image,channel);
3071 image=ChannelFxImage(image,expression,exception);
3072 if (image != (Image *) NULL)
3073 (void) SetImageChannelMask(image,channel_mask);
3074 if (image == (Image *) NULL)
3076 for ( ; image; image=image->next)
3078 AddImageToRegistry(sv,image);
3080 av_push(av,sv_bless(rv,hv));
3083 exception=DestroyExceptionInfo(exception);
3085 SvREFCNT_dec(perl_exception); /* can't return warning messages */
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 ###############################################################################
3111 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
3144 PERL_UNUSED_VAR(ref);
3145 PERL_UNUSED_VAR(ix);
3146 exception=AcquireExceptionInfo();
3147 perl_exception=newSVpv("",0);
3149 if (sv_isobject(ST(0)) == 0)
3151 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3155 reference=SvRV(ST(0));
3156 hv=SvSTASH(reference);
3157 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3158 if (image == (Image *) NULL)
3160 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3165 Create blessed Perl array for the returned image.
3168 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3170 for ( ; image; image=image->next)
3172 clone=CloneImage(image,0,0,MagickTrue,exception);
3173 if (clone == (Image *) NULL)
3175 AddImageToRegistry(sv,clone);
3177 av_push(av,sv_bless(rv,hv));
3180 exception=DestroyExceptionInfo(exception);
3181 SvREFCNT_dec(perl_exception);
3185 InheritPerlException(exception,perl_exception);
3186 exception=DestroyExceptionInfo(exception);
3187 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3188 SvPOK_on(perl_exception);
3189 ST(0)=sv_2mortal(perl_exception);
3194 ###############################################################################
3202 ###############################################################################
3210 PERL_UNUSED_VAR(ref);
3211 if (magick_registry != (SplayTreeInfo *) NULL)
3216 ResetSplayTreeIterator(magick_registry);
3217 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3218 while (p != (Image *) NULL)
3221 p=(Image *) GetNextKeyInSplayTree(magick_registry);
3227 ###############################################################################
3235 ###############################################################################
3240 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
3269 PERL_UNUSED_VAR(ref);
3270 PERL_UNUSED_VAR(ix);
3271 exception=AcquireExceptionInfo();
3272 perl_exception=newSVpv("",0);
3274 if (sv_isobject(ST(0)) == 0)
3276 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3280 reference=SvRV(ST(0));
3281 hv=SvSTASH(reference);
3283 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3285 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3286 if (image == (Image *) NULL)
3288 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3292 image=CoalesceImages(image,exception);
3293 if (image == (Image *) NULL)
3295 for ( ; image; image=image->next)
3297 AddImageToRegistry(sv,image);
3299 av_push(av,sv_bless(rv,hv));
3302 exception=DestroyExceptionInfo(exception);
3304 SvREFCNT_dec(perl_exception);
3308 InheritPerlException(exception,perl_exception);
3309 exception=DestroyExceptionInfo(exception);
3310 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3311 SvPOK_on(perl_exception);
3312 ST(0)=sv_2mortal(perl_exception);
3317 ###############################################################################
3325 ###############################################################################
3330 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
3376 PERL_UNUSED_VAR(ref);
3377 PERL_UNUSED_VAR(ix);
3378 exception=AcquireExceptionInfo();
3379 perl_exception=newSVpv("",0);
3383 if (sv_isobject(ST(0)) == 0)
3385 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3389 reference=SvRV(ST(0));
3390 hv=SvSTASH(reference);
3392 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3394 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3395 if (image == (Image *) NULL)
3397 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3401 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3405 reconstruct_image=image;
3406 metric=RootMeanSquaredErrorMetric;
3407 for (i=2; i < items; i+=2)
3409 attribute=(char *) SvPV(ST(i-1),na);
3415 if (LocaleCompare(attribute,"channel") == 0)
3420 option=ParseChannelOption(SvPV(ST(i),na));
3423 ThrowPerlException(exception,OptionError,
3424 "UnrecognizedType",SvPV(ST(i),na));
3427 (void) SetPixelChannelMask(image,(ChannelType) option);
3430 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3437 if (LocaleCompare(attribute,"fuzz") == 0)
3439 image->fuzz=StringToDoubleInterval(SvPV(ST(i),na),100.0);
3442 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3449 if (LocaleCompare(attribute,"image") == 0)
3451 reconstruct_image=SetupList(aTHX_ SvRV(ST(i)),
3452 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
3455 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3462 if (LocaleCompare(attribute,"metric") == 0)
3464 option=ParseCommandOption(MagickMetricOptions,MagickFalse,
3468 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3472 metric=(MetricType) option;
3475 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3481 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3487 difference_image=CompareImages(image,reconstruct_image,metric,&distortion,
3489 if (difference_image != (Image *) NULL)
3491 difference_image->error.mean_error_per_pixel=distortion;
3492 AddImageToRegistry(sv,difference_image);
3494 av_push(av,sv_bless(rv,hv));
3497 exception=DestroyExceptionInfo(exception);
3499 SvREFCNT_dec(perl_exception); /* can't return warning messages */
3503 InheritPerlException(exception,perl_exception);
3504 exception=DestroyExceptionInfo(exception);
3505 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3506 SvPOK_on(perl_exception);
3507 ST(0)=sv_2mortal(perl_exception);
3512 ###############################################################################
3516 # C o m p l e x I m a g e s #
3520 ###############################################################################
3524 ComplexImages(ref,...)
3525 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
3562 PERL_UNUSED_VAR(ref);
3563 PERL_UNUSED_VAR(ix);
3564 exception=AcquireExceptionInfo();
3565 perl_exception=newSVpv("",0);
3567 if (sv_isobject(ST(0)) == 0)
3569 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3573 reference=SvRV(ST(0));
3574 hv=SvSTASH(reference);
3575 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3576 if (image == (Image *) NULL)
3578 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3582 op=UndefinedComplexOperator;
3588 in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
3592 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3596 op=(ComplexOperator) in;
3599 for (i=2; i < items; i+=2)
3601 attribute=(char *) SvPV(ST(i-1),na);
3607 if (LocaleCompare(attribute,"operator") == 0)
3612 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
3613 MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
3616 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3620 op=(ComplexOperator) in;
3623 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3629 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3635 image=ComplexImages(image,op,exception);
3636 if (image == (Image *) NULL)
3639 Create blessed Perl array for the returned image.
3642 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3644 AddImageToRegistry(sv,image);
3646 av_push(av,sv_bless(rv,hv));
3648 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
3649 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
3650 "complex-%.*s",(int) (MagickPathExtent-9),
3651 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
3652 (void) CopyMagickString(image->filename,info->image_info->filename,
3654 SetImageInfo(info->image_info,0,exception);
3655 exception=DestroyExceptionInfo(exception);
3656 SvREFCNT_dec(perl_exception);
3660 InheritPerlException(exception,perl_exception);
3661 exception=DestroyExceptionInfo(exception);
3662 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3663 SvPOK_on(perl_exception);
3664 ST(0)=sv_2mortal(perl_exception);
3669 ###############################################################################
3673 # C o m p a r e L a y e r s #
3677 ###############################################################################
3681 CompareLayers(ref,...)
3682 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
3684 CompareImagesLayers = 1
3686 compareimagelayers = 3
3723 PERL_UNUSED_VAR(ref);
3724 PERL_UNUSED_VAR(ix);
3725 exception=AcquireExceptionInfo();
3726 perl_exception=newSVpv("",0);
3728 if (sv_isobject(ST(0)) == 0)
3730 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3734 reference=SvRV(ST(0));
3735 hv=SvSTASH(reference);
3737 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
3739 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3740 if (image == (Image *) NULL)
3742 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3746 method=CompareAnyLayer;
3747 for (i=2; i < items; i+=2)
3749 attribute=(char *) SvPV(ST(i-1),na);
3755 if (LocaleCompare(attribute,"method") == 0)
3757 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
3761 ThrowPerlException(exception,OptionError,"UnrecognizedType",
3765 method=(LayerMethod) option;
3768 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3774 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
3780 image=CompareImagesLayers(image,method,exception);
3781 if (image == (Image *) NULL)
3783 for ( ; image; image=image->next)
3785 AddImageToRegistry(sv,image);
3787 av_push(av,sv_bless(rv,hv));
3790 exception=DestroyExceptionInfo(exception);
3792 SvREFCNT_dec(perl_exception);
3796 InheritPerlException(exception,perl_exception);
3797 exception=DestroyExceptionInfo(exception);
3798 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3799 SvPOK_on(perl_exception);
3800 ST(0)=sv_2mortal(perl_exception);
3805 ###############################################################################
3813 ###############################################################################
3818 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
3824 PERL_UNUSED_VAR(ref);
3825 if (sv_isobject(ST(0)) == 0)
3826 croak("ReferenceIsNotMyType");
3827 reference=SvRV(ST(0));
3828 switch (SvTYPE(reference))
3833 message[MagickPathExtent];
3851 Array (AV *) reference
3853 (void) FormatLocaleString(message,MagickPathExtent,"package%s%p",
3854 XS_VERSION,reference);
3855 hv=gv_stashpv(PackageName, FALSE);
3858 gvp=(GV **) hv_fetch(hv,message,(long) strlen(message),FALSE);
3862 if (sv && (SvREFCNT(sv) == 1) && SvIOK(sv))
3864 info=INT2PTR(struct PackageInfo *,SvIV(sv));
3865 DestroyPackageInfo(info);
3867 key=hv_delete(hv,message,(long) strlen(message),G_DISCARD);
3877 Blessed scalar = (Image *) SvIV(reference)
3879 image=INT2PTR(Image *,SvIV(reference));
3880 if (image != (Image *) NULL)
3881 DeleteImageFromRegistry(reference,image);
3890 ###############################################################################
3898 ###############################################################################
3903 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
3927 PERL_UNUSED_VAR(ref);
3928 PERL_UNUSED_VAR(ix);
3929 exception=AcquireExceptionInfo();
3930 perl_exception=newSVpv("",0);
3931 package_info=(struct PackageInfo *) NULL;
3932 if (sv_isobject(ST(0)) == 0)
3934 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
3938 reference=SvRV(ST(0));
3939 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
3940 if (image == (Image *) NULL)
3942 ThrowPerlException(exception,OptionError,"NoImagesDefined",
3946 package_info=ClonePackageInfo(info,exception);
3948 SetAttribute(aTHX_ package_info,NULL,"server",ST(1),exception);
3951 for (i=2; i < items; i+=2)
3952 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
3954 (void) DisplayImages(package_info->image_info,image,exception);
3955 (void) CatchImageException(image);
3958 if (package_info != (struct PackageInfo *) NULL)
3959 DestroyPackageInfo(package_info);
3960 InheritPerlException(exception,perl_exception);
3961 exception=DestroyExceptionInfo(exception);
3962 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
3963 SvPOK_on(perl_exception);
3964 ST(0)=sv_2mortal(perl_exception);
3969 ###############################################################################
3973 # E v a l u a t e I m a g e s #
3977 ###############################################################################
3981 EvaluateImages(ref,...)
3982 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
4004 MagickEvaluateOperator
4019 PERL_UNUSED_VAR(ref);
4020 PERL_UNUSED_VAR(ix);
4021 exception=AcquireExceptionInfo();
4022 perl_exception=newSVpv("",0);
4024 if (sv_isobject(ST(0)) == 0)
4026 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4030 reference=SvRV(ST(0));
4031 hv=SvSTASH(reference);
4032 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4033 if (image == (Image *) NULL)
4035 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4039 op=MeanEvaluateOperator;
4045 in=ParseCommandOption(MagickEvaluateOptions,MagickFalse,(char *)
4049 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4053 op=(MagickEvaluateOperator) in;
4056 for (i=2; i < items; i+=2)
4058 attribute=(char *) SvPV(ST(i-1),na);
4064 if (LocaleCompare(attribute,"operator") == 0)
4069 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
4070 MagickEvaluateOptions,MagickFalse,SvPV(ST(i),na));
4073 ThrowPerlException(exception,OptionError,"UnrecognizedType",
4077 op=(MagickEvaluateOperator) in;
4080 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4086 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4092 image=EvaluateImages(image,op,exception);
4093 if (image == (Image *) NULL)
4096 Create blessed Perl array for the returned image.
4099 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4101 AddImageToRegistry(sv,image);
4103 av_push(av,sv_bless(rv,hv));
4105 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4106 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4107 "evaluate-%.*s",(int) (MagickPathExtent-9),
4108 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4109 (void) CopyMagickString(image->filename,info->image_info->filename,
4111 SetImageInfo(info->image_info,0,exception);
4112 exception=DestroyExceptionInfo(exception);
4113 SvREFCNT_dec(perl_exception);
4117 InheritPerlException(exception,perl_exception);
4118 exception=DestroyExceptionInfo(exception);
4119 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4120 SvPOK_on(perl_exception);
4121 ST(0)=sv_2mortal(perl_exception);
4126 ###############################################################################
4134 ###############################################################################
4139 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
4146 #define ChannelFeatures(channel,direction) \
4148 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4149 channel_features[channel].angular_second_moment[direction]); \
4150 PUSHs(sv_2mortal(newSVpv(message,0))); \
4151 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4152 channel_features[channel].contrast[direction]); \
4153 PUSHs(sv_2mortal(newSVpv(message,0))); \
4154 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4155 channel_features[channel].contrast[direction]); \
4156 PUSHs(sv_2mortal(newSVpv(message,0))); \
4157 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4158 channel_features[channel].variance_sum_of_squares[direction]); \
4159 PUSHs(sv_2mortal(newSVpv(message,0))); \
4160 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4161 channel_features[channel].inverse_difference_moment[direction]); \
4162 PUSHs(sv_2mortal(newSVpv(message,0))); \
4163 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4164 channel_features[channel].sum_average[direction]); \
4165 PUSHs(sv_2mortal(newSVpv(message,0))); \
4166 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4167 channel_features[channel].sum_variance[direction]); \
4168 PUSHs(sv_2mortal(newSVpv(message,0))); \
4169 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4170 channel_features[channel].sum_entropy[direction]); \
4171 PUSHs(sv_2mortal(newSVpv(message,0))); \
4172 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4173 channel_features[channel].entropy[direction]); \
4174 PUSHs(sv_2mortal(newSVpv(message,0))); \
4175 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4176 channel_features[channel].difference_variance[direction]); \
4177 PUSHs(sv_2mortal(newSVpv(message,0))); \
4178 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4179 channel_features[channel].difference_entropy[direction]); \
4180 PUSHs(sv_2mortal(newSVpv(message,0))); \
4181 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4182 channel_features[channel].measure_of_correlation_1[direction]); \
4183 PUSHs(sv_2mortal(newSVpv(message,0))); \
4184 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4185 channel_features[channel].measure_of_correlation_2[direction]); \
4186 PUSHs(sv_2mortal(newSVpv(message,0))); \
4187 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
4188 channel_features[channel].maximum_correlation_coefficient[direction]); \
4189 PUSHs(sv_2mortal(newSVpv(message,0))); \
4197 message[MagickPathExtent];
4224 PERL_UNUSED_VAR(ref);
4225 PERL_UNUSED_VAR(ix);
4226 exception=AcquireExceptionInfo();
4227 perl_exception=newSVpv("",0);
4229 if (sv_isobject(ST(0)) == 0)
4231 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4235 reference=SvRV(ST(0));
4238 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4239 if (image == (Image *) NULL)
4241 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4246 for (i=2; i < items; i+=2)
4248 attribute=(char *) SvPV(ST(i-1),na);
4254 if (LocaleCompare(attribute,"distance") == 0)
4256 distance=StringToLong((char *) SvPV(ST(1),na));
4259 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4265 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4272 for ( ; image; image=image->next)
4277 channel_features=GetImageFeatures(image,distance,exception);
4278 if (channel_features == (ChannelFeatures *) NULL)
4281 for (j=0; j < 4; j++)
4283 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
4285 PixelChannel channel=GetPixelChannelChannel(image,i);
4286 PixelTrait traits=GetPixelChannelTraits(image,channel);
4287 if (traits == UndefinedPixelTrait)
4289 EXTEND(sp,14*(i+1)*count);
4290 ChannelFeatures(channel,j);
4293 channel_features=(ChannelFeatures *)
4294 RelinquishMagickMemory(channel_features);
4298 InheritPerlException(exception,perl_exception);
4299 exception=DestroyExceptionInfo(exception);
4300 SvREFCNT_dec(perl_exception);
4304 ###############################################################################
4312 ###############################################################################
4317 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
4355 PERL_UNUSED_VAR(ref);
4356 PERL_UNUSED_VAR(ix);
4357 exception=AcquireExceptionInfo();
4358 perl_exception=newSVpv("",0);
4360 if (sv_isobject(ST(0)) == 0)
4362 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4366 reference=SvRV(ST(0));
4367 hv=SvSTASH(reference);
4368 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4369 if (image == (Image *) NULL)
4371 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4375 background_color=image->background_color;
4377 (void) QueryColorCompliance((char *) SvPV(ST(1),na),AllCompliance,
4378 &background_color,exception);
4380 for (i=2; i < items; i+=2)
4382 attribute=(char *) SvPV(ST(i-1),na);
4388 if (LocaleCompare(attribute,"background") == 0)
4390 (void) QueryColorCompliance((char *) SvPV(ST(1),na),
4391 AllCompliance,&background_color,exception);
4394 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4400 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4406 image->background_color=background_color;
4407 image=MergeImageLayers(image,FlattenLayer,exception);
4408 if (image == (Image *) NULL)
4411 Create blessed Perl array for the returned image.
4414 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4416 AddImageToRegistry(sv,image);
4418 av_push(av,sv_bless(rv,hv));
4420 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4421 (void) FormatLocaleString(info->image_info->filename,MagickPathExtent,
4422 "flatten-%.*s",(int) (MagickPathExtent-9),
4423 ((p=strrchr(image->filename,'/')) ? p+1 : image->filename));
4424 (void) CopyMagickString(image->filename,info->image_info->filename,
4426 SetImageInfo(info->image_info,0,exception);
4427 exception=DestroyExceptionInfo(exception);
4428 SvREFCNT_dec(perl_exception);
4432 InheritPerlException(exception,perl_exception);
4433 exception=DestroyExceptionInfo(exception);
4434 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4435 SvPOK_on(perl_exception); /* return messages in string context */
4436 ST(0)=sv_2mortal(perl_exception);
4441 ###############################################################################
4449 ###############################################################################
4454 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
4466 expression[MagickPathExtent];
4494 PERL_UNUSED_VAR(ref);
4495 PERL_UNUSED_VAR(ix);
4496 exception=AcquireExceptionInfo();
4497 perl_exception=newSVpv("",0);
4501 if (sv_isobject(ST(0)) == 0)
4503 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4507 reference=SvRV(ST(0));
4508 hv=SvSTASH(reference);
4510 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
4512 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4513 if (image == (Image *) NULL)
4515 ThrowPerlException(exception,OptionError,"NoImagesDefined",
4519 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
4523 channel=DefaultChannels;
4524 (void) CopyMagickString(expression,"u",MagickPathExtent);
4526 (void) CopyMagickString(expression,(char *) SvPV(ST(1),na),
4529 for (i=2; i < items; i+=2)
4531 attribute=(char *) SvPV(ST(i-1),na);
4537 if (LocaleCompare(attribute,"channel") == 0)
4542 option=ParseChannelOption(SvPV(ST(i),na));
4545 ThrowPerlException(exception,OptionError,
4546 "UnrecognizedType",SvPV(ST(i),na));
4549 channel=(ChannelType) option;
4552 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4559 if (LocaleCompare(attribute,"expression") == 0)
4561 (void) CopyMagickString(expression,SvPV(ST(i),na),
4565 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4571 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4577 channel_mask=SetImageChannelMask(image,channel);
4578 image=FxImage(image,expression,exception);
4579 if (image != (Image *) NULL)
4580 (void) SetImageChannelMask(image,channel_mask);
4581 if (image == (Image *) NULL)
4583 for ( ; image; image=image->next)
4585 AddImageToRegistry(sv,image);
4587 av_push(av,sv_bless(rv,hv));
4590 exception=DestroyExceptionInfo(exception);
4592 SvREFCNT_dec(perl_exception); /* can't return warning messages */
4596 InheritPerlException(exception,perl_exception);
4597 exception=DestroyExceptionInfo(exception);
4598 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
4599 SvPOK_on(perl_exception);
4600 ST(0)=sv_2mortal(perl_exception);
4605 ###############################################################################
4613 ###############################################################################
4618 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
4629 color[MagickPathExtent];
4654 PERL_UNUSED_VAR(ref);
4655 PERL_UNUSED_VAR(ix);
4656 exception=AcquireExceptionInfo();
4657 perl_exception=newSVpv("",0);
4658 if (sv_isobject(ST(0)) == 0)
4660 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
4664 reference=SvRV(ST(0));
4665 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
4666 if (image == (Image *) NULL && !info)
4669 for (i=1; i < items; i++)
4671 attribute=(char *) SvPV(ST(i),na);
4678 if (LocaleCompare(attribute,"adjoin") == 0)
4681 s=newSViv((ssize_t) info->image_info->adjoin);
4682 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4685 if (LocaleCompare(attribute,"antialias") == 0)
4688 s=newSViv((ssize_t) info->image_info->antialias);
4689 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4692 if (LocaleCompare(attribute,"area") == 0)
4694 s=newSViv(GetMagickResource(AreaResource));
4695 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4698 if (LocaleCompare(attribute,"attenuate") == 0)
4703 value=GetImageProperty(image,attribute,exception);
4704 if (value != (const char *) NULL)
4706 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4709 if (LocaleCompare(attribute,"authenticate") == 0)
4716 option=GetImageOption(info->image_info,attribute);
4717 if (option != (const char *) NULL)
4718 s=newSVpv(option,0);
4720 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4723 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4730 if (LocaleCompare(attribute,"background") == 0)
4732 if (image == (Image *) NULL)
4734 (void) FormatLocaleString(color,MagickPathExtent,
4735 "%.20g,%.20g,%.20g,%.20g",(double) image->background_color.red,
4736 (double) image->background_color.green,
4737 (double) image->background_color.blue,
4738 (double) image->background_color.alpha);
4740 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4743 if (LocaleCompare(attribute,"base-columns") == 0)
4745 if (image != (Image *) NULL)
4746 s=newSViv((ssize_t) image->magick_columns);
4747 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4750 if (LocaleCompare(attribute,"base-filename") == 0)
4752 if (image != (Image *) NULL)
4753 s=newSVpv(image->magick_filename,0);
4754 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4757 if (LocaleCompare(attribute,"base-height") == 0)
4759 if (image != (Image *) NULL)
4760 s=newSViv((ssize_t) image->magick_rows);
4761 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4764 if (LocaleCompare(attribute,"base-rows") == 0)
4766 if (image != (Image *) NULL)
4767 s=newSViv((ssize_t) image->magick_rows);
4768 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4771 if (LocaleCompare(attribute,"base-width") == 0)
4773 if (image != (Image *) NULL)
4774 s=newSViv((ssize_t) image->magick_columns);
4775 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4778 if (LocaleCompare(attribute,"blue-primary") == 0)
4780 if (image == (Image *) NULL)
4782 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
4783 image->chromaticity.blue_primary.x,
4784 image->chromaticity.blue_primary.y);
4786 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4789 if (LocaleCompare(attribute,"bordercolor") == 0)
4791 if (image == (Image *) NULL)
4793 (void) FormatLocaleString(color,MagickPathExtent,
4794 "%.20g,%.20g,%.20g,%.20g",(double) image->border_color.red,
4795 (double) image->border_color.green,
4796 (double) image->border_color.blue,
4797 (double) image->border_color.alpha);
4799 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4802 if (LocaleCompare(attribute,"bounding-box") == 0)
4805 geometry[MagickPathExtent];
4810 if (image == (Image *) NULL)
4812 page=GetImageBoundingBox(image,exception);
4813 (void) FormatLocaleString(geometry,MagickPathExtent,
4814 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double)
4815 page.height,(double) page.x,(double) page.y);
4816 s=newSVpv(geometry,0);
4817 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4820 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4827 if (LocaleCompare(attribute,"class") == 0)
4829 if (image == (Image *) NULL)
4831 s=newSViv(image->storage_class);
4832 (void) sv_setpv(s,CommandOptionToMnemonic(MagickClassOptions,
4833 image->storage_class));
4835 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4838 if (LocaleCompare(attribute,"clip-mask") == 0)
4840 if (image != (Image *) NULL)
4849 if ((image->channels & WriteMaskChannel) == 0)
4850 (void) ClipImage(image,exception);
4851 mask_image=GetImageMask(image,ReadPixelMask,exception);
4852 if (mask_image != (Image *) NULL)
4854 AddImageToRegistry(sv,mask_image);
4855 s=sv_bless(newRV(sv),SvSTASH(reference));
4858 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4861 if (LocaleCompare(attribute,"clip-path") == 0)
4863 if (image != (Image *) NULL)
4872 if ((image->channels & WriteMaskChannel) == 0)
4873 (void) ClipImage(image,exception);
4874 mask_image=GetImageMask(image,ReadPixelMask,exception);
4875 if (mask_image != (Image *) NULL)
4877 AddImageToRegistry(sv,mask_image);
4878 s=sv_bless(newRV(sv),SvSTASH(reference));
4881 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4884 if (LocaleCompare(attribute,"compression") == 0)
4886 j=info ? info->image_info->compression : image ?
4887 image->compression : UndefinedCompression;
4889 if (info->image_info->compression == UndefinedCompression)
4890 j=image->compression;
4892 (void) sv_setpv(s,CommandOptionToMnemonic(MagickCompressOptions,
4895 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4898 if (LocaleCompare(attribute,"colorspace") == 0)
4900 j=image ? image->colorspace : RGBColorspace;
4902 (void) sv_setpv(s,CommandOptionToMnemonic(MagickColorspaceOptions,
4905 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4908 if (LocaleCompare(attribute,"colors") == 0)
4910 if (image != (Image *) NULL)
4911 s=newSViv((ssize_t) GetNumberColors(image,(FILE *) NULL,
4913 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4916 if (LocaleNCompare(attribute,"colormap",8) == 0)
4921 if (image == (Image *) NULL || !image->colormap)
4924 items=sscanf(attribute,"%*[^[][%ld",&j);
4926 if (j > (ssize_t) image->colors)
4928 (void) FormatLocaleString(color,MagickPathExtent,
4929 "%.20g,%.20g,%.20g,%.20g",(double) image->colormap[j].red,
4930 (double) image->colormap[j].green,
4931 (double) image->colormap[j].blue,
4932 (double) image->colormap[j].alpha);
4934 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4937 if (LocaleCompare(attribute,"columns") == 0)
4939 if (image != (Image *) NULL)
4940 s=newSViv((ssize_t) image->columns);
4941 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4944 if (LocaleCompare(attribute,"comment") == 0)
4949 value=GetImageProperty(image,attribute,exception);
4950 if (value != (const char *) NULL)
4952 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4955 if (LocaleCompare(attribute,"copyright") == 0)
4957 s=newSVpv(GetMagickCopyright(),0);
4958 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4961 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
4968 if (LocaleCompare(attribute,"density") == 0)
4971 geometry[MagickPathExtent];
4973 if (image == (Image *) NULL)
4975 (void) FormatLocaleString(geometry,MagickPathExtent,"%.20gx%.20g",
4976 image->resolution.x,image->resolution.y);
4977 s=newSVpv(geometry,0);
4978 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4981 if (LocaleCompare(attribute,"delay") == 0)
4983 if (image != (Image *) NULL)
4984 s=newSViv((ssize_t) image->delay);
4985 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4988 if (LocaleCompare(attribute,"depth") == 0)
4990 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
4991 if (image != (Image *) NULL)
4992 s=newSViv((ssize_t) GetImageDepth(image,exception));
4993 PUSHs(s ? sv_2mortal(s) : &sv_undef);
4996 if (LocaleCompare(attribute,"directory") == 0)
4998 if (image && image->directory)
4999 s=newSVpv(image->directory,0);
5000 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5003 if (LocaleCompare(attribute,"dispose") == 0)
5005 if (image == (Image *) NULL)
5008 s=newSViv(image->dispose);
5010 CommandOptionToMnemonic(MagickDisposeOptions,image->dispose));
5012 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5015 if (LocaleCompare(attribute,"disk") == 0)
5017 s=newSViv(GetMagickResource(DiskResource));
5018 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5021 if (LocaleCompare(attribute,"dither") == 0)
5024 s=newSViv((ssize_t) info->image_info->dither);
5025 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5028 if (LocaleCompare(attribute,"display") == 0) /* same as server */
5030 if (info && info->image_info->server_name)
5031 s=newSVpv(info->image_info->server_name,0);
5032 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5035 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5042 if (LocaleCompare(attribute,"elapsed-time") == 0)
5044 if (image != (Image *) NULL)
5045 s=newSVnv(GetElapsedTime(&image->timer));
5046 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5049 if (LocaleCompare(attribute,"endian") == 0)
5051 j=info ? info->image_info->endian : image ? image->endian :
5054 (void) sv_setpv(s,CommandOptionToMnemonic(MagickEndianOptions,j));
5056 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5059 if (LocaleCompare(attribute,"error") == 0)
5061 if (image != (Image *) NULL)
5062 s=newSVnv(image->error.mean_error_per_pixel);
5063 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5066 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5073 if (LocaleCompare(attribute,"filesize") == 0)
5075 if (image != (Image *) NULL)
5076 s=newSViv((ssize_t) GetBlobSize(image));
5077 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5080 if (LocaleCompare(attribute,"filename") == 0)
5082 if (image != (Image *) NULL)
5083 s=newSVpv(image->filename,0);
5085 if (info && *info->image_info->filename)
5086 s=newSVpv(info->image_info->filename,0);
5087 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5090 if (LocaleCompare(attribute,"filter") == 0)
5092 s=image ? newSViv(image->filter) : newSViv(0);
5093 (void) sv_setpv(s,CommandOptionToMnemonic(MagickFilterOptions,
5096 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5099 if (LocaleCompare(attribute,"font") == 0)
5101 if (info && info->image_info->font)
5102 s=newSVpv(info->image_info->font,0);
5103 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5106 if (LocaleCompare(attribute,"foreground") == 0)
5108 if (LocaleCompare(attribute,"format") == 0)
5113 magick_info=(const MagickInfo *) NULL;
5114 if (info && (*info->image_info->magick != '\0'))
5115 magick_info=GetMagickInfo(info->image_info->magick,exception);
5116 if (image != (Image *) NULL)
5117 magick_info=GetMagickInfo(image->magick,exception);
5118 if ((magick_info != (const MagickInfo *) NULL) &&
5119 (*magick_info->description != '\0'))
5120 s=newSVpv((char *) magick_info->description,0);
5121 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5124 if (LocaleCompare(attribute,"fuzz") == 0)
5127 s=newSVnv(info->image_info->fuzz);
5128 if (image != (Image *) NULL)
5129 s=newSVnv(image->fuzz);
5130 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5133 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5140 if (LocaleCompare(attribute,"gamma") == 0)
5142 if (image != (Image *) NULL)
5143 s=newSVnv(image->gamma);
5144 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5147 if (LocaleCompare(attribute,"geometry") == 0)
5149 if (image && image->geometry)
5150 s=newSVpv(image->geometry,0);
5151 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5154 if (LocaleCompare(attribute,"gravity") == 0)
5156 s=image ? newSViv(image->gravity) : newSViv(0);
5157 (void) sv_setpv(s,CommandOptionToMnemonic(MagickGravityOptions,
5160 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5163 if (LocaleCompare(attribute,"green-primary") == 0)
5165 if (image == (Image *) NULL)
5167 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
5168 image->chromaticity.green_primary.x,
5169 image->chromaticity.green_primary.y);
5171 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5174 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5181 if (LocaleCompare(attribute,"height") == 0)
5183 if (image != (Image *) NULL)
5184 s=newSViv((ssize_t) image->rows);
5185 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5188 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5195 if (LocaleCompare(attribute,"icc") == 0)
5197 if (image != (Image *) NULL)
5202 profile=GetImageProfile(image,"icc");
5203 if (profile != (StringInfo *) NULL)
5204 s=newSVpv((const char *) GetStringInfoDatum(profile),
5205 GetStringInfoLength(profile));
5207 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5210 if (LocaleCompare(attribute,"icm") == 0)
5212 if (image != (Image *) NULL)
5217 profile=GetImageProfile(image,"icm");
5218 if (profile != (const StringInfo *) NULL)
5219 s=newSVpv((const char *) GetStringInfoDatum(profile),
5220 GetStringInfoLength(profile));
5222 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5225 if (LocaleCompare(attribute,"id") == 0)
5227 if (image != (Image *) NULL)
5230 key[MagickPathExtent];
5238 (void) FormatLocaleString(key,MagickPathExtent,"%.20g\n",(double)
5240 status=SetImageRegistry(ImageRegistryType,key,image,
5245 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5248 if (LocaleNCompare(attribute,"index",5) == 0)
5251 name[MagickPathExtent];
5260 register const Quantum
5266 if (image == (Image *) NULL)
5268 if (image->storage_class != PseudoClass)
5272 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5274 image_view=AcquireVirtualCacheView(image,exception);
5275 p=GetCacheViewVirtualPixels(image_view,x,y,1,1,exception);
5276 if (p != (const Quantum *) NULL)
5278 (void) FormatLocaleString(name,MagickPathExtent,QuantumFormat,
5279 GetPixelIndex(image,p));
5281 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5283 image_view=DestroyCacheView(image_view);
5286 if (LocaleCompare(attribute,"iptc") == 0)
5288 if (image != (Image *) NULL)
5293 profile=GetImageProfile(image,"iptc");
5294 if (profile != (const StringInfo *) NULL)
5295 s=newSVpv((const char *) GetStringInfoDatum(profile),
5296 GetStringInfoLength(profile));
5298 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5301 if (LocaleCompare(attribute,"iterations") == 0) /* same as loop */
5303 if (image != (Image *) NULL)
5304 s=newSViv((ssize_t) image->iterations);
5305 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5308 if (LocaleCompare(attribute,"interlace") == 0)
5310 j=info ? info->image_info->interlace : image ? image->interlace :
5313 (void) sv_setpv(s,CommandOptionToMnemonic(MagickInterlaceOptions,
5316 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5319 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5326 if (LocaleCompare(attribute,"label") == 0)
5331 if (image == (Image *) NULL)
5333 value=GetImageProperty(image,"Label",exception);
5334 if (value != (const char *) NULL)
5336 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5339 if (LocaleCompare(attribute,"loop") == 0) /* same as iterations */
5341 if (image != (Image *) NULL)
5342 s=newSViv((ssize_t) image->iterations);
5343 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5346 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5353 if (LocaleCompare(attribute,"magick") == 0)
5355 if (info && *info->image_info->magick)
5356 s=newSVpv(info->image_info->magick,0);
5357 if (image != (Image *) NULL)
5358 s=newSVpv(image->magick,0);
5359 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5362 if (LocaleCompare(attribute,"map") == 0)
5364 s=newSViv(GetMagickResource(MapResource));
5365 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5368 if (LocaleCompare(attribute,"maximum-error") == 0)
5370 if (image != (Image *) NULL)
5371 s=newSVnv(image->error.normalized_maximum_error);
5372 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5375 if (LocaleCompare(attribute,"memory") == 0)
5377 s=newSViv(GetMagickResource(MemoryResource));
5378 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5381 if (LocaleCompare(attribute,"mean-error") == 0)
5383 if (image != (Image *) NULL)
5384 s=newSVnv(image->error.normalized_mean_error);
5385 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5388 if (LocaleCompare(attribute,"mime") == 0)
5390 if (info && *info->image_info->magick)
5391 s=newSVpv(MagickToMime(info->image_info->magick),0);
5392 if (image != (Image *) NULL)
5393 s=newSVpv(MagickToMime(image->magick),0);
5394 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5397 if (LocaleCompare(attribute,"mattecolor") == 0)
5399 if (image == (Image *) NULL)
5401 (void) FormatLocaleString(color,MagickPathExtent,
5402 "%.20g,%.20g,%.20g,%.20g",(double) image->alpha_color.red,
5403 (double) image->alpha_color.green,
5404 (double) image->alpha_color.blue,
5405 (double) image->alpha_color.alpha);
5407 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5410 if (LocaleCompare(attribute,"matte") == 0)
5412 if (image != (Image *) NULL)
5413 s=newSViv((ssize_t) image->alpha_trait != UndefinedPixelTrait ?
5415 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5418 if (LocaleCompare(attribute,"mime") == 0)
5424 if (info && *info->image_info->magick)
5425 magick=info->image_info->magick;
5426 if (image != (Image *) NULL)
5427 magick=image->magick;
5433 mime=MagickToMime(magick);
5435 mime=(char *) RelinquishMagickMemory(mime);
5437 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5440 if (LocaleCompare(attribute,"monochrome") == 0)
5442 if (image == (Image *) NULL)
5444 j=info ? info->image_info->monochrome :
5445 SetImageMonochrome(image,exception);
5447 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5450 if (LocaleCompare(attribute,"montage") == 0)
5452 if (image && image->montage)
5453 s=newSVpv(image->montage,0);
5454 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5457 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5464 if (LocaleCompare(attribute,"orientation") == 0)
5466 j=info ? info->image_info->orientation : image ?
5467 image->orientation : UndefinedOrientation;
5469 (void) sv_setpv(s,CommandOptionToMnemonic(MagickOrientationOptions,
5472 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5475 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5482 if (LocaleCompare(attribute,"page") == 0)
5484 if (info && info->image_info->page)
5485 s=newSVpv(info->image_info->page,0);
5486 if (image != (Image *) NULL)
5489 geometry[MagickPathExtent];
5491 (void) FormatLocaleString(geometry,MagickPathExtent,
5492 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,
5493 (double) image->page.height,(double) image->page.x,(double)
5495 s=newSVpv(geometry,0);
5497 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5500 if (LocaleCompare(attribute,"page.x") == 0)
5502 if (image != (Image *) NULL)
5503 s=newSViv((ssize_t) image->page.x);
5504 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5507 if (LocaleCompare(attribute,"page.y") == 0)
5509 if (image != (Image *) NULL)
5510 s=newSViv((ssize_t) image->page.y);
5511 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5514 if (LocaleNCompare(attribute,"pixel",5) == 0)
5517 tuple[MagickPathExtent];
5526 register const Quantum
5529 if (image == (Image *) NULL)
5533 items=sscanf(attribute,"%*[^[][%ld%*[,/]%ld",&x,&y);
5535 p=GetVirtualPixels(image,x,y,1,1,exception);
5536 if (image->colorspace != CMYKColorspace)
5537 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5538 QuantumFormat "," QuantumFormat "," QuantumFormat,
5539 GetPixelRed(image,p),GetPixelGreen(image,p),
5540 GetPixelBlue(image,p),GetPixelAlpha(image,p));
5542 (void) FormatLocaleString(tuple,MagickPathExtent,QuantumFormat ","
5543 QuantumFormat "," QuantumFormat "," QuantumFormat ","
5544 QuantumFormat,GetPixelRed(image,p),GetPixelGreen(image,p),
5545 GetPixelBlue(image,p),GetPixelBlack(image,p),
5546 GetPixelAlpha(image,p));
5548 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5551 if (LocaleCompare(attribute,"pointsize") == 0)
5554 s=newSViv((ssize_t) info->image_info->pointsize);
5555 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5558 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5565 if (LocaleCompare(attribute,"quality") == 0)
5568 s=newSViv((ssize_t) info->image_info->quality);
5569 if (image != (Image *) NULL)
5570 s=newSViv((ssize_t) image->quality);
5571 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5574 if (LocaleCompare(attribute,"quantum") == 0)
5577 s=newSViv((ssize_t) MAGICKCORE_QUANTUM_DEPTH);
5578 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5581 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5588 if (LocaleCompare(attribute,"rendering-intent") == 0)
5590 s=newSViv(image->rendering_intent);
5591 (void) sv_setpv(s,CommandOptionToMnemonic(MagickIntentOptions,
5592 image->rendering_intent));
5594 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5597 if (LocaleCompare(attribute,"red-primary") == 0)
5599 if (image == (Image *) NULL)
5601 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
5602 image->chromaticity.red_primary.x,
5603 image->chromaticity.red_primary.y);
5605 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5608 if (LocaleCompare(attribute,"rows") == 0)
5610 if (image != (Image *) NULL)
5611 s=newSViv((ssize_t) image->rows);
5612 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5615 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5622 if (LocaleCompare(attribute,"sampling-factor") == 0)
5624 if (info && info->image_info->sampling_factor)
5625 s=newSVpv(info->image_info->sampling_factor,0);
5626 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5629 if (LocaleCompare(attribute,"server") == 0) /* same as display */
5631 if (info && info->image_info->server_name)
5632 s=newSVpv(info->image_info->server_name,0);
5633 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5636 if (LocaleCompare(attribute,"size") == 0)
5638 if (info && info->image_info->size)
5639 s=newSVpv(info->image_info->size,0);
5640 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5643 if (LocaleCompare(attribute,"scene") == 0)
5645 if (image != (Image *) NULL)
5646 s=newSViv((ssize_t) image->scene);
5647 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5650 if (LocaleCompare(attribute,"scenes") == 0)
5652 if (image != (Image *) NULL)
5653 s=newSViv((ssize_t) info->image_info->number_scenes);
5654 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5657 if (LocaleCompare(attribute,"signature") == 0)
5662 if (image == (Image *) NULL)
5664 (void) SignatureImage(image,exception);
5665 value=GetImageProperty(image,"Signature",exception);
5666 if (value != (const char *) NULL)
5668 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5671 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5678 if (LocaleCompare(attribute,"taint") == 0)
5680 if (image != (Image *) NULL)
5681 s=newSViv((ssize_t) IsTaintImage(image));
5682 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5685 if (LocaleCompare(attribute,"texture") == 0)
5687 if (info && info->image_info->texture)
5688 s=newSVpv(info->image_info->texture,0);
5689 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5692 if (LocaleCompare(attribute,"total-ink-density") == 0)
5694 s=newSViv(MAGICKCORE_QUANTUM_DEPTH);
5695 if (image != (Image *) NULL)
5696 s=newSVnv(GetImageTotalInkDensity(image,exception));
5697 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5700 if (LocaleCompare(attribute,"transparent-color") == 0)
5702 if (image == (Image *) NULL)
5704 (void) FormatLocaleString(color,MagickPathExtent,
5705 "%.20g,%.20g,%.20g,%.20g",(double) image->transparent_color.red,
5706 (double) image->transparent_color.green,
5707 (double) image->transparent_color.blue,
5708 (double) image->transparent_color.alpha);
5710 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5713 if (LocaleCompare(attribute,"type") == 0)
5715 if (image == (Image *) NULL)
5717 j=(ssize_t) GetImageType(image);
5719 (void) sv_setpv(s,CommandOptionToMnemonic(MagickTypeOptions,j));
5721 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5724 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5731 if (LocaleCompare(attribute,"units") == 0)
5733 j=info ? info->image_info->units : image ? image->units :
5734 UndefinedResolution;
5735 if (info && (info->image_info->units == UndefinedResolution))
5738 if (j == UndefinedResolution)
5739 s=newSVpv("undefined units",0);
5741 if (j == PixelsPerInchResolution)
5742 s=newSVpv("pixels / inch",0);
5744 s=newSVpv("pixels / centimeter",0);
5745 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5748 if (LocaleCompare(attribute,"user-time") == 0)
5750 if (image != (Image *) NULL)
5751 s=newSVnv(GetUserTime(&image->timer));
5752 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5755 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5762 if (LocaleCompare(attribute,"verbose") == 0)
5765 s=newSViv((ssize_t) info->image_info->verbose);
5766 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5769 if (LocaleCompare(attribute,"version") == 0)
5771 s=newSVpv(GetMagickVersion((size_t *) NULL),0);
5772 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5775 if (LocaleCompare(attribute,"virtual-pixel") == 0)
5777 if (image == (Image *) NULL)
5779 j=(ssize_t) GetImageVirtualPixelMethod(image);
5781 (void) sv_setpv(s,CommandOptionToMnemonic(
5782 MagickVirtualPixelOptions,j));
5784 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5787 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5794 if (LocaleCompare(attribute,"white-point") == 0)
5796 if (image == (Image *) NULL)
5798 (void) FormatLocaleString(color,MagickPathExtent,"%.20g,%.20g",
5799 image->chromaticity.white_point.x,
5800 image->chromaticity.white_point.y);
5802 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5805 if (LocaleCompare(attribute,"width") == 0)
5807 if (image != (Image *) NULL)
5808 s=newSViv((ssize_t) image->columns);
5809 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5812 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5819 if (LocaleCompare(attribute,"xmp") == 0)
5821 if (image != (Image *) NULL)
5826 profile=GetImageProfile(image,"xmp");
5827 if (profile != (StringInfo *) NULL)
5828 s=newSVpv((const char *) GetStringInfoDatum(profile),
5829 GetStringInfoLength(profile));
5831 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5834 if (LocaleCompare(attribute,"x-resolution") == 0)
5836 if (image != (Image *) NULL)
5837 s=newSVnv(image->resolution.x);
5838 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5841 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5848 if (LocaleCompare(attribute,"y-resolution") == 0)
5850 if (image != (Image *) NULL)
5851 s=newSVnv(image->resolution.y);
5852 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5855 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5862 if (image == (Image *) NULL)
5863 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5867 value=GetImageProperty(image,attribute,exception);
5868 if (value != (const char *) NULL)
5871 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5874 if (*attribute != '%')
5875 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5882 meta=InterpretImageProperties(info ? info->image_info :
5883 (ImageInfo *) NULL,image,attribute,exception);
5885 PUSHs(s ? sv_2mortal(s) : &sv_undef);
5886 meta=(char *) RelinquishMagickMemory(meta);
5890 exception=DestroyExceptionInfo(exception);
5891 SvREFCNT_dec(perl_exception); /* can't return warning messages */
5895 ###############################################################################
5899 # G e t A u t h e n t i c P i x e l s #
5903 ###############################################################################
5907 GetAuthenticPixels(ref,...)
5908 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
5910 getauthenticpixels = 1
5940 PERL_UNUSED_VAR(ref);
5941 PERL_UNUSED_VAR(ix);
5942 exception=AcquireExceptionInfo();
5943 perl_exception=newSVpv("",0);
5944 if (sv_isobject(ST(0)) == 0)
5946 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
5950 reference=SvRV(ST(0));
5952 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
5953 if (image == (Image *) NULL)
5955 ThrowPerlException(exception,OptionError,"NoImagesDefined",
5962 region.width=image->columns;
5965 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
5966 for (i=2; i < items; i+=2)
5968 attribute=(char *) SvPV(ST(i-1),na);
5974 if (LocaleCompare(attribute,"geometry") == 0)
5976 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
5979 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
5986 if (LocaleCompare(attribute,"height") == 0)
5988 region.height=SvIV(ST(i));
5991 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
5998 if (LocaleCompare(attribute,"x") == 0)
6000 region.x=SvIV(ST(i));
6003 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6010 if (LocaleCompare(attribute,"y") == 0)
6012 region.y=SvIV(ST(i));
6015 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6022 if (LocaleCompare(attribute,"width") == 0)
6024 region.width=SvIV(ST(i));
6027 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6033 blob=(void *) GetAuthenticPixels(image,region.x,region.y,region.width,
6034 region.height,exception);
6035 if (blob != (void *) NULL)
6039 InheritPerlException(exception,perl_exception);
6040 exception=DestroyExceptionInfo(exception);
6041 SvREFCNT_dec(perl_exception); /* throw away all errors */
6050 ###############################################################################
6054 # G e t V i r t u a l P i x e l s #
6058 ###############################################################################
6062 GetVirtualPixels(ref,...)
6063 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
6065 getvirtualpixels = 1
6066 AcquireImagePixels = 2
6067 acquireimagepixels = 3
6095 PERL_UNUSED_VAR(ref);
6096 PERL_UNUSED_VAR(ix);
6097 exception=AcquireExceptionInfo();
6098 perl_exception=newSVpv("",0);
6099 if (sv_isobject(ST(0)) == 0)
6101 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6105 reference=SvRV(ST(0));
6107 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6108 if (image == (Image *) NULL)
6110 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6117 region.width=image->columns;
6120 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6121 for (i=2; i < items; i+=2)
6123 attribute=(char *) SvPV(ST(i-1),na);
6129 if (LocaleCompare(attribute,"geometry") == 0)
6131 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6134 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6141 if (LocaleCompare(attribute,"height") == 0)
6143 region.height=SvIV(ST(i));
6146 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6153 if (LocaleCompare(attribute,"x") == 0)
6155 region.x=SvIV(ST(i));
6158 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6165 if (LocaleCompare(attribute,"y") == 0)
6167 region.y=SvIV(ST(i));
6170 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6177 if (LocaleCompare(attribute,"width") == 0)
6179 region.width=SvIV(ST(i));
6182 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
6188 blob=(const void *) GetVirtualPixels(image,region.x,region.y,region.width,
6189 region.height,exception);
6190 if (blob != (void *) NULL)
6194 InheritPerlException(exception,perl_exception);
6195 exception=DestroyExceptionInfo(exception);
6196 SvREFCNT_dec(perl_exception); /* throw away all errors */
6199 RETVAL = (void *) blob;
6205 ###############################################################################
6209 # G e t A u t h e n t i c M e t a c o n t e n t #
6213 ###############################################################################
6217 GetAuthenticMetacontent(ref,...)
6218 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
6220 getauthenticmetacontent = 1
6241 PERL_UNUSED_VAR(ref);
6242 PERL_UNUSED_VAR(ix);
6243 exception=AcquireExceptionInfo();
6244 perl_exception=newSVpv("",0);
6245 if (sv_isobject(ST(0)) == 0)
6247 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6251 reference=SvRV(ST(0));
6253 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6254 if (image == (Image *) NULL)
6256 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6261 blob=(void *) GetAuthenticMetacontent(image);
6262 if (blob != (void *) NULL)
6266 InheritPerlException(exception,perl_exception);
6267 exception=DestroyExceptionInfo(exception);
6268 SvREFCNT_dec(perl_exception); /* throw away all errors */
6277 ###############################################################################
6281 # G e t V i r t u a l M e t a c o n t e n t #
6285 ###############################################################################
6289 GetVirtualMetacontent(ref,...)
6290 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
6292 getvirtualmetacontent = 1
6311 PERL_UNUSED_VAR(ref);
6312 PERL_UNUSED_VAR(ix);
6313 exception=AcquireExceptionInfo();
6314 perl_exception=newSVpv("",0);
6315 if (sv_isobject(ST(0)) == 0)
6317 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6321 reference=SvRV(ST(0));
6323 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6324 if (image == (Image *) NULL)
6326 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6331 blob=(void *) GetVirtualMetacontent(image);
6332 if (blob != (void *) NULL)
6336 InheritPerlException(exception,perl_exception);
6337 exception=DestroyExceptionInfo(exception);
6338 SvREFCNT_dec(perl_exception); /* throw away all errors */
6347 ###############################################################################
6351 # H i s t o g r a m #
6355 ###############################################################################
6360 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
6371 message[MagickPathExtent];
6398 PERL_UNUSED_VAR(ref);
6399 PERL_UNUSED_VAR(ix);
6400 exception=AcquireExceptionInfo();
6401 perl_exception=newSVpv("",0);
6403 if (sv_isobject(ST(0)) == 0)
6405 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6409 reference=SvRV(ST(0));
6412 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6413 if (image == (Image *) NULL)
6415 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6420 for ( ; image; image=image->next)
6422 histogram=GetImageHistogram(image,&number_colors,exception);
6423 if (histogram == (PixelInfo *) NULL)
6425 count+=(ssize_t) number_colors;
6427 for (i=0; i < (ssize_t) number_colors; i++)
6429 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6431 PUSHs(sv_2mortal(newSVpv(message,0)));
6432 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6433 histogram[i].green);
6434 PUSHs(sv_2mortal(newSVpv(message,0)));
6435 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6437 PUSHs(sv_2mortal(newSVpv(message,0)));
6438 if (image->colorspace == CMYKColorspace)
6440 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6441 histogram[i].black);
6442 PUSHs(sv_2mortal(newSVpv(message,0)));
6444 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
6445 histogram[i].alpha);
6446 PUSHs(sv_2mortal(newSVpv(message,0)));
6447 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
6448 histogram[i].count);
6449 PUSHs(sv_2mortal(newSVpv(message,0)));
6451 histogram=(PixelInfo *) RelinquishMagickMemory(histogram);
6455 InheritPerlException(exception,perl_exception);
6456 exception=DestroyExceptionInfo(exception);
6457 SvREFCNT_dec(perl_exception);
6461 ###############################################################################
6469 ###############################################################################
6474 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
6498 register const Quantum
6512 *reference; /* reference is the SV* of ref=SvIV(reference) */
6514 PERL_UNUSED_VAR(ref);
6515 PERL_UNUSED_VAR(ix);
6516 exception=AcquireExceptionInfo();
6517 perl_exception=newSVpv("",0);
6518 reference=SvRV(ST(0));
6519 av=(AV *) reference;
6520 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6522 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6523 if (image == (Image *) NULL)
6525 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6529 normalize=MagickTrue;
6532 region.width=image->columns;
6535 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6536 for (i=2; i < items; i+=2)
6538 attribute=(char *) SvPV(ST(i-1),na);
6544 if (LocaleCompare(attribute,"channel") == 0)
6549 option=ParseChannelOption(SvPV(ST(i),na));
6552 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6556 (void) SetPixelChannelMask(image,(ChannelType) option);
6559 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6566 if (LocaleCompare(attribute,"geometry") == 0)
6568 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6571 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6578 if (LocaleCompare(attribute,"normalize") == 0)
6580 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6584 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6588 normalize=option != 0 ? MagickTrue : MagickFalse;
6591 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6598 if (LocaleCompare(attribute,"x") == 0)
6600 region.x=SvIV(ST(i));
6603 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6610 if (LocaleCompare(attribute,"y") == 0)
6612 region.y=SvIV(ST(i));
6615 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6621 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6627 p=GetVirtualPixels(image,region.x,region.y,1,1,exception);
6628 if (p == (const Quantum *) NULL)
6636 if (normalize != MagickFalse)
6637 scale=1.0/QuantumRange;
6638 if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
6639 PUSHs(sv_2mortal(newSVnv(scale*GetPixelRed(image,p))));
6640 if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
6641 PUSHs(sv_2mortal(newSVnv(scale*GetPixelGreen(image,p))));
6642 if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
6643 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlue(image,p))));
6644 if (((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
6645 (image->colorspace == CMYKColorspace))
6646 PUSHs(sv_2mortal(newSVnv(scale*GetPixelBlack(image,p))));
6647 if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
6648 PUSHs(sv_2mortal(newSVnv(scale*GetPixelAlpha(image,p))));
6652 InheritPerlException(exception,perl_exception);
6653 exception=DestroyExceptionInfo(exception);
6654 SvREFCNT_dec(perl_exception);
6658 ###############################################################################
6662 # G e t P i x e l s #
6666 ###############################################################################
6671 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
6710 *reference; /* reference is the SV* of ref=SvIV(reference) */
6712 PERL_UNUSED_VAR(ref);
6713 PERL_UNUSED_VAR(ix);
6714 exception=AcquireExceptionInfo();
6715 perl_exception=newSVpv("",0);
6716 reference=SvRV(ST(0));
6717 av=(AV *) reference;
6718 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
6720 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6721 if (image == (Image *) NULL)
6723 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6728 if (image->alpha_trait != UndefinedPixelTrait)
6730 if (image->colorspace == CMYKColorspace)
6733 if (image->alpha_trait != UndefinedPixelTrait)
6736 normalize=MagickFalse;
6739 region.width=image->columns;
6742 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
6743 for (i=2; i < items; i+=2)
6745 attribute=(char *) SvPV(ST(i-1),na);
6751 if (LocaleCompare(attribute,"geometry") == 0)
6753 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
6756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6763 if (LocaleCompare(attribute,"height") == 0)
6765 region.height=SvIV(ST(i));
6768 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6775 if (LocaleCompare(attribute,"map") == 0)
6780 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6787 if (LocaleCompare(attribute,"normalize") == 0)
6789 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
6793 ThrowPerlException(exception,OptionError,"UnrecognizedType",
6797 normalize=option != 0 ? MagickTrue : MagickFalse;
6800 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6807 if (LocaleCompare(attribute,"width") == 0)
6809 region.width=SvIV(ST(i));
6812 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6819 if (LocaleCompare(attribute,"x") == 0)
6821 region.x=SvIV(ST(i));
6824 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6831 if (LocaleCompare(attribute,"y") == 0)
6833 region.y=SvIV(ST(i));
6836 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6842 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
6848 if (normalize != MagickFalse)
6853 pixels=(float *) AcquireQuantumMemory(strlen(map)*region.width,
6854 region.height*sizeof(*pixels));
6855 if (pixels == (float *) NULL)
6857 ThrowPerlException(exception,ResourceLimitError,
6858 "MemoryAllocationFailed",PackageName);
6861 status=ExportImagePixels(image,region.x,region.y,region.width,
6862 region.height,map,FloatPixel,pixels,exception);
6863 if (status == MagickFalse)
6867 EXTEND(sp,strlen(map)*region.width*region.height);
6868 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6869 PUSHs(sv_2mortal(newSVnv(pixels[i])));
6871 pixels=(float *) RelinquishMagickMemory(pixels);
6878 pixels=(Quantum *) AcquireQuantumMemory(strlen(map)*region.width,
6879 region.height*sizeof(*pixels));
6880 if (pixels == (Quantum *) NULL)
6882 ThrowPerlException(exception,ResourceLimitError,
6883 "MemoryAllocationFailed",PackageName);
6886 status=ExportImagePixels(image,region.x,region.y,region.width,
6887 region.height,map,QuantumPixel,pixels,exception);
6888 if (status == MagickFalse)
6892 EXTEND(sp,strlen(map)*region.width*region.height);
6893 for (i=0; i < (ssize_t) (strlen(map)*region.width*region.height); i++)
6894 PUSHs(sv_2mortal(newSViv(pixels[i])));
6896 pixels=(Quantum *) RelinquishMagickMemory(pixels);
6900 InheritPerlException(exception,perl_exception);
6901 exception=DestroyExceptionInfo(exception);
6902 SvREFCNT_dec(perl_exception);
6906 ###############################################################################
6910 # I m a g e T o B l o b #
6914 ###############################################################################
6918 ImageToBlob(ref,...)
6919 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
6928 filename[MagickPathExtent];
6957 PERL_UNUSED_VAR(ref);
6958 PERL_UNUSED_VAR(ix);
6959 exception=AcquireExceptionInfo();
6960 perl_exception=newSVpv("",0);
6961 package_info=(struct PackageInfo *) NULL;
6962 if (sv_isobject(ST(0)) == 0)
6964 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
6968 reference=SvRV(ST(0));
6969 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
6970 if (image == (Image *) NULL)
6972 ThrowPerlException(exception,OptionError,"NoImagesDefined",
6976 package_info=ClonePackageInfo(info,exception);
6977 for (i=2; i < items; i+=2)
6978 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),exception);
6979 (void) CopyMagickString(filename,package_info->image_info->filename,
6982 for (next=image; next; next=next->next)
6984 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
6985 next->scene=scene++;
6987 SetImageInfo(package_info->image_info,(unsigned int)
6988 GetImageListLength(image),exception);
6989 EXTEND(sp,(ssize_t) GetImageListLength(image));
6990 for ( ; image; image=image->next)
6993 blob=ImagesToBlob(package_info->image_info,image,&length,exception);
6994 if (blob != (char *) NULL)
6996 PUSHs(sv_2mortal(newSVpv((const char *) blob,length)));
6997 blob=(unsigned char *) RelinquishMagickMemory(blob);
6999 if (package_info->image_info->adjoin)
7004 if (package_info != (struct PackageInfo *) NULL)
7005 DestroyPackageInfo(package_info);
7006 InheritPerlException(exception,perl_exception);
7007 exception=DestroyExceptionInfo(exception);
7008 SvREFCNT_dec(perl_exception); /* throw away all errors */
7012 ###############################################################################
7020 ###############################################################################
7025 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
7029 OptimizeImageLayers = 3
7031 optimizeimagelayers = 5
7073 PERL_UNUSED_VAR(ref);
7074 PERL_UNUSED_VAR(ix);
7075 exception=AcquireExceptionInfo();
7076 perl_exception=newSVpv("",0);
7078 if (sv_isobject(ST(0)) == 0)
7080 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7084 reference=SvRV(ST(0));
7085 hv=SvSTASH(reference);
7087 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
7089 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
7090 if (image == (Image *) NULL)
7092 ThrowPerlException(exception,OptionError,"NoImagesDefined",
7096 compose=image->compose;
7097 method=OptimizeLayer;
7098 for (i=2; i < items; i+=2)
7100 attribute=(char *) SvPV(ST(i-1),na);
7106 if (LocaleCompare(attribute,"compose") == 0)
7108 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
7109 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
7112 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7116 compose=(CompositeOperator) sp;
7119 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7126 if (LocaleCompare(attribute,"method") == 0)
7128 option=ParseCommandOption(MagickLayerOptions,MagickFalse,
7132 ThrowPerlException(exception,OptionError,"UnrecognizedType",
7136 method=(LayerMethod) option;
7139 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7145 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
7151 layers=(Image *) NULL;
7154 case CompareAnyLayer:
7155 case CompareClearLayer:
7156 case CompareOverlayLayer:
7159 layers=CompareImagesLayers(image,method,exception);
7166 layers=MergeImageLayers(image,method,exception);
7171 layers=DisposeImages(image,exception);
7174 case OptimizeImageLayer:
7176 layers=OptimizeImageLayers(image,exception);
7179 case OptimizePlusLayer:
7181 layers=OptimizePlusImageLayers(image,exception);
7184 case OptimizeTransLayer:
7186 OptimizeImageTransparency(image,exception);
7189 case RemoveDupsLayer:
7191 RemoveDuplicateLayers(&image,exception);
7194 case RemoveZeroLayer:
7196 RemoveZeroDelayLayers(&image,exception);
7205 General Purpose, GIF Animation Optimizer.
7207 layers=CoalesceImages(image,exception);
7208 if (layers == (Image *) NULL)
7211 layers=OptimizeImageLayers(image,exception);
7212 if (layers == (Image *) NULL)
7214 image=DestroyImageList(image);
7216 layers=(Image *) NULL;
7217 OptimizeImageTransparency(image,exception);
7218 quantize_info=AcquireQuantizeInfo(info->image_info);
7219 (void) RemapImages(quantize_info,image,(Image *) NULL,exception);
7220 quantize_info=DestroyQuantizeInfo(quantize_info);
7223 case CompositeLayer:
7232 Split image sequence at the first 'NULL:' image.
7235 while (source != (Image *) NULL)
7237 source=GetNextImageInList(source);
7238 if ((source != (Image *) NULL) &&
7239 (LocaleCompare(source->magick,"NULL") == 0))
7242 if (source != (Image *) NULL)
7244 if ((GetPreviousImageInList(source) == (Image *) NULL) ||
7245 (GetNextImageInList(source) == (Image *) NULL))
7246 source=(Image *) NULL;
7250 Separate the two lists, junk the null: image.
7252 source=SplitImageList(source->previous);
7253 DeleteImageFromList(&source);
7256 if (source == (Image *) NULL)
7258 (void) ThrowMagickException(exception,GetMagickModule(),
7259 OptionError,"MissingNullSeparator","layers Composite");
7263 Adjust offset with gravity and virtual canvas.
7265 SetGeometry(image,&geometry);
7266 (void) ParseAbsoluteGeometry(image->geometry,&geometry);
7267 geometry.width=source->page.width != 0 ? source->page.width :
7269 geometry.height=source->page.height != 0 ? source->page.height :
7271 GravityAdjustGeometry(image->page.width != 0 ? image->page.width :
7272 image->columns,image->page.height != 0 ? image->page.height :
7273 image->rows,image->gravity,&geometry);
7274 CompositeLayers(image,compose,source,geometry.x,geometry.y,exception);
7275 source=DestroyImageList(source);
7279 if (layers != (Image *) NULL)
7282 image=CloneImage(image,0,0,MagickTrue,exception);
7283 if (image == (Image *) NULL)
7285 for ( ; image; image=image->next)
7287 AddImageToRegistry(sv,image);
7289 av_push(av,sv_bless(rv,hv));
7292 exception=DestroyExceptionInfo(exception);
7294 SvREFCNT_dec(perl_exception);
7298 InheritPerlException(exception,perl_exception);
7299 exception=DestroyExceptionInfo(exception);
7300 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
7301 SvPOK_on(perl_exception);
7302 ST(0)=sv_2mortal(perl_exception);
7307 ###############################################################################
7311 # M a g i c k T o M i m e #
7315 ###############################################################################
7319 MagickToMime(ref,name)
7320 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
7329 PERL_UNUSED_VAR(ref);
7330 PERL_UNUSED_VAR(ix);
7331 mime=MagickToMime(name);
7332 RETVAL=newSVpv(mime,0);
7333 mime=(char *) RelinquishMagickMemory(mime);
7339 ###############################################################################
7347 ###############################################################################
7352 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
7389 MedianConvolveImage = 36
7395 ReduceNoiseImage = 42
7421 ColorFloodfillImage= 68
7427 CycleColormapImage = 74
7437 MatteFloodfillImage= 84
7445 NumberColorsImage = 92
7455 SignatureImage = 102
7465 TransparentImage = 112
7467 ThresholdImage = 114
7481 DeconstructImage = 130
7483 GaussianBlurImage = 132
7489 UnsharpMaskImage = 138
7491 MotionBlurImage = 140
7493 OrderedDitherImage = 142
7500 AffineTransform = 149
7501 AffineTransformImage = 150
7503 DifferenceImage = 152
7504 AdaptiveThreshold = 153
7505 AdaptiveThresholdImage = 154
7510 BlackThreshold = 159
7511 BlackThresholdImage= 160
7512 WhiteThreshold = 161
7513 WhiteThresholdImage= 162
7514 RotationalBlur = 163
7515 RotationalBlurImage= 164
7517 ThumbnailImage = 166
7527 PosterizeImage = 176
7533 SepiaToneImage = 182
7534 SigmoidalContrast = 183
7535 SigmoidalContrastImage = 184
7540 ContrastStretch = 189
7541 ContrastStretchImage = 190
7546 AdaptiveSharpen = 195
7547 AdaptiveSharpenImage = 196
7549 TransposeImage = 198
7551 TransverseImage = 200
7553 AutoOrientImage = 202
7555 AdaptiveBlurImage = 204
7559 UniqueColorsImage = 208
7560 AdaptiveResize = 209
7561 AdaptiveResizeImage= 210
7565 LinearStretchImage = 214
7567 ColorMatrixImage = 216
7572 FloodfillPaint = 221
7573 FloodfillPaintImage= 222
7579 LiquidRescaleImage = 228
7589 SparseColorImage = 238
7593 SelectiveBlurImage = 242
7597 BlueShiftImage = 246
7598 ForwardFourierTransform = 247
7599 ForwardFourierTransformImage = 248
7600 InverseFourierTransform = 249
7601 InverseFourierTransformImage = 250
7602 ColorDecisionList = 251
7603 ColorDecisionListImage = 252
7605 AutoGammaImage = 254
7607 AutoLevelImage = 256
7609 LevelImageColors = 258
7612 BrightnessContrast = 261
7613 BrightnessContrastImage = 262
7615 MorphologyImage = 264
7619 StatisticImage = 268
7621 PerceptibleImage = 270
7625 GrayscaleImage = 274
7627 CannyEdgeImage = 276
7629 HoughLineImage = 278
7631 MeanShiftImage = 280
7634 ConnectedComponents = 283
7635 ConnectedComponentsImage = 284
7637 CopyImagePixels = 286
7640 WaveletDenoise = 289
7641 WaveletDenoiseImage= 290
7643 ColorspaceImage = 292
7645 AutoThresholdImage = 294
7646 RangeThreshold = 295
7647 RangeThresholdImage= 296
7651 OTSUThresholdImage = 300
7660 attribute_flag[MaxArguments],
7661 message[MagickPathExtent];
7718 argument_list[MaxArguments];
7720 PERL_UNUSED_VAR(ref);
7721 PERL_UNUSED_VAR(ix);
7722 exception=AcquireExceptionInfo();
7723 perl_exception=newSVpv("",0);
7724 reference_vector=NULL;
7727 if (sv_isobject(ST(0)) == 0)
7729 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7733 reference=SvRV(ST(0));
7734 region_info.width=0;
7735 region_info.height=0;
7738 image=SetupList(aTHX_ reference,&info,&reference_vector,exception);
7739 if (ix && (ix != 666))
7742 Called as Method(...)
7745 rp=(&Methods[ix-1]);
7751 Called as Mogrify("Method",...)
7753 attribute=(char *) SvPV(ST(1),na);
7756 flags=ParseGravityGeometry(image,attribute,®ion_info,exception);
7757 attribute=(char *) SvPV(ST(2),na);
7760 for (rp=Methods; ; rp++)
7762 if (rp >= EndOf(Methods))
7764 ThrowPerlException(exception,OptionError,
7765 "UnrecognizedPerlMagickMethod",attribute);
7768 if (strEQcase(attribute,rp->name))
7774 if (image == (Image *) NULL)
7776 ThrowPerlException(exception,OptionError,"NoImagesDefined",attribute);
7779 Zero(&argument_list,NumberOf(argument_list),struct ArgumentList);
7780 Zero(&attribute_flag,NumberOf(attribute_flag),char);
7781 for (i=base; (i < items) || ((i == items) && (base == items)); i+=2)
7798 pp=(Arguments *) NULL;
7806 for (sv=ST(i), attribute=(char *) SvPV(ST(i-1),na); ; qq++)
7808 if ((qq >= EndOf(rp->arguments)) || (qq->method == NULL))
7810 if (strEQcase(attribute,qq->method) > ssize_test)
7813 ssize_test=strEQcase(attribute,qq->method);
7816 if (pp == (Arguments *) NULL)
7818 ThrowPerlException(exception,OptionError,"UnrecognizedOption",
7820 goto continue_outer_loop;
7822 al=(&argument_list[pp-rp->arguments]);
7825 case ArrayReference:
7827 if (SvTYPE(sv) != SVt_RV)
7829 (void) FormatLocaleString(message,MagickPathExtent,
7830 "invalid %.60s value",pp->method);
7831 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7832 goto continue_outer_loop;
7834 al->array_reference=SvRV(sv);
7839 al->real_reference=SvNV(sv);
7844 al->file_reference=(FILE *) PerlIO_findFILE(IoIFP(sv_2io(sv)));
7847 case ImageReference:
7849 if (!sv_isobject(sv) ||
7850 !(al->image_reference=SetupList(aTHX_ SvRV(sv),
7851 (struct PackageInfo **) NULL,(SV ***) NULL,exception)))
7853 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
7859 case IntegerReference:
7861 al->integer_reference=SvIV(sv);
7864 case StringReference:
7866 al->string_reference=(char *) SvPV(sv,al->length);
7867 if (sv_isobject(sv))
7868 al->image_reference=SetupList(aTHX_ SvRV(sv),
7869 (struct PackageInfo **) NULL,(SV ***) NULL,exception);
7875 Is a string; look up name.
7877 if ((al->length > 1) && (*(char *) SvPV(sv,al->length) == '@'))
7879 al->string_reference=(char *) SvPV(sv,al->length);
7880 al->integer_reference=(-1);
7883 al->integer_reference=ParseCommandOption((CommandOption) pp->type,
7884 MagickFalse,SvPV(sv,na));
7885 if (pp->type == MagickChannelOptions)
7886 al->integer_reference=ParseChannelOption(SvPV(sv,na));
7887 if ((al->integer_reference < 0) &&
7888 ((al->integer_reference=SvIV(sv)) <= 0))
7890 (void) FormatLocaleString(message,MagickPathExtent,
7891 "invalid %.60s value",pp->method);
7892 ThrowPerlException(exception,OptionError,message,SvPV(sv,na));
7893 goto continue_outer_loop;
7898 attribute_flag[pp-rp->arguments]++;
7899 continue_outer_loop: ;
7901 (void) ResetMagickMemory((char *) &fill_color,0,sizeof(fill_color));
7902 pv=reference_vector;
7903 SetGeometryInfo(&geometry_info);
7904 channel=DefaultChannels;
7905 for (next=image; next; next=next->next)
7908 SetGeometry(image,&geometry);
7909 if ((region_info.width*region_info.height) != 0)
7910 (void) SetImageRegionMask(image,WritePixelMask,®ion_info,exception);
7915 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
7917 ThrowPerlException(exception,OptionError,
7918 "UnrecognizedPerlMagickMethod",message);
7921 case 1: /* Comment */
7923 if (attribute_flag[0] == 0)
7924 argument_list[0].string_reference=(char *) NULL;
7925 (void) SetImageProperty(image,"comment",InterpretImageProperties(
7926 info ? info->image_info : (ImageInfo *) NULL,image,
7927 argument_list[0].string_reference,exception),exception);
7932 if (attribute_flag[0] == 0)
7933 argument_list[0].string_reference=(char *) NULL;
7934 (void) SetImageProperty(image,"label",InterpretImageProperties(
7935 info ? info->image_info : (ImageInfo *) NULL,image,
7936 argument_list[0].string_reference,exception),exception);
7939 case 3: /* AddNoise */
7944 if (attribute_flag[0] == 0)
7945 argument_list[0].integer_reference=UniformNoise;
7947 if (attribute_flag[1] != 0)
7948 attenuate=argument_list[1].real_reference;
7949 if (attribute_flag[2] != 0)
7950 channel=(ChannelType) argument_list[2].integer_reference;
7951 channel_mask=SetImageChannelMask(image,channel);
7952 image=AddNoiseImage(image,(NoiseType)
7953 argument_list[0].integer_reference,attenuate,exception);
7954 if (image != (Image *) NULL)
7955 (void) SetImageChannelMask(image,channel_mask);
7958 case 4: /* Colorize */
7963 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,0,0,
7965 if (attribute_flag[0] != 0)
7966 (void) QueryColorCompliance(argument_list[0].string_reference,
7967 AllCompliance,&target,exception);
7968 if (attribute_flag[1] == 0)
7969 argument_list[1].string_reference="100%";
7970 image=ColorizeImage(image,argument_list[1].string_reference,&target,
7974 case 5: /* Border */
7981 if (attribute_flag[0] != 0)
7982 flags=ParsePageGeometry(image,argument_list[0].string_reference,
7983 &geometry,exception);
7984 if (attribute_flag[1] != 0)
7985 geometry.width=argument_list[1].integer_reference;
7986 if (attribute_flag[2] != 0)
7987 geometry.height=argument_list[2].integer_reference;
7988 if (attribute_flag[3] != 0)
7989 QueryColorCompliance(argument_list[3].string_reference,
7990 AllCompliance,&image->border_color,exception);
7991 if (attribute_flag[4] != 0)
7992 QueryColorCompliance(argument_list[4].string_reference,
7993 AllCompliance,&image->border_color,exception);
7994 if (attribute_flag[5] != 0)
7995 QueryColorCompliance(argument_list[5].string_reference,
7996 AllCompliance,&image->border_color,exception);
7997 compose=image->compose;
7998 if (attribute_flag[6] != 0)
7999 compose=(CompositeOperator) argument_list[6].integer_reference;
8000 image=BorderImage(image,&geometry,compose,exception);
8005 if (attribute_flag[0] != 0)
8007 flags=ParseGeometry(argument_list[0].string_reference,
8009 if ((flags & SigmaValue) == 0)
8010 geometry_info.sigma=1.0;
8012 if (attribute_flag[1] != 0)
8013 geometry_info.rho=argument_list[1].real_reference;
8014 if (attribute_flag[2] != 0)
8015 geometry_info.sigma=argument_list[2].real_reference;
8016 if (attribute_flag[3] != 0)
8017 channel=(ChannelType) argument_list[3].integer_reference;
8018 channel_mask=SetImageChannelMask(image,channel);
8019 image=BlurImage(image,geometry_info.rho,geometry_info.sigma,
8021 if (image != (Image *) NULL)
8022 (void) SetImageChannelMask(image,channel_mask);
8027 if (attribute_flag[5] != 0)
8028 image->gravity=(GravityType) argument_list[5].integer_reference;
8029 if (attribute_flag[0] != 0)
8030 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
8031 &geometry,exception);
8032 if (attribute_flag[1] != 0)
8033 geometry.width=argument_list[1].integer_reference;
8034 if (attribute_flag[2] != 0)
8035 geometry.height=argument_list[2].integer_reference;
8036 if (attribute_flag[3] != 0)
8037 geometry.x=argument_list[3].integer_reference;
8038 if (attribute_flag[4] != 0)
8039 geometry.y=argument_list[4].integer_reference;
8040 image=ChopImage(image,&geometry,exception);
8045 if (attribute_flag[6] != 0)
8046 image->gravity=(GravityType) argument_list[6].integer_reference;
8047 if (attribute_flag[0] != 0)
8048 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
8049 &geometry,exception);
8050 if (attribute_flag[1] != 0)
8051 geometry.width=argument_list[1].integer_reference;
8052 if (attribute_flag[2] != 0)
8053 geometry.height=argument_list[2].integer_reference;
8054 if (attribute_flag[3] != 0)
8055 geometry.x=argument_list[3].integer_reference;
8056 if (attribute_flag[4] != 0)
8057 geometry.y=argument_list[4].integer_reference;
8058 if (attribute_flag[5] != 0)
8059 image->fuzz=StringToDoubleInterval(
8060 argument_list[5].string_reference,(double) QuantumRange+1.0);
8061 image=CropImage(image,&geometry,exception);
8064 case 9: /* Despeckle */
8066 image=DespeckleImage(image,exception);
8071 if (attribute_flag[0] != 0)
8072 geometry_info.rho=argument_list[0].real_reference;
8073 image=EdgeImage(image,geometry_info.rho,exception);
8076 case 11: /* Emboss */
8078 if (attribute_flag[0] != 0)
8080 flags=ParseGeometry(argument_list[0].string_reference,
8082 if ((flags & SigmaValue) == 0)
8083 geometry_info.sigma=1.0;
8085 if (attribute_flag[1] != 0)
8086 geometry_info.rho=argument_list[1].real_reference;
8087 if (attribute_flag[2] != 0)
8088 geometry_info.sigma=argument_list[2].real_reference;
8089 image=EmbossImage(image,geometry_info.rho,geometry_info.sigma,
8093 case 12: /* Enhance */
8095 image=EnhanceImage(image,exception);
8100 image=FlipImage(image,exception);
8105 image=FlopImage(image,exception);
8108 case 15: /* Frame */
8116 if (attribute_flag[0] != 0)
8118 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8119 &geometry,exception);
8120 frame_info.width=geometry.width;
8121 frame_info.height=geometry.height;
8122 frame_info.outer_bevel=geometry.x;
8123 frame_info.inner_bevel=geometry.y;
8125 if (attribute_flag[1] != 0)
8126 frame_info.width=argument_list[1].integer_reference;
8127 if (attribute_flag[2] != 0)
8128 frame_info.height=argument_list[2].integer_reference;
8129 if (attribute_flag[3] != 0)
8130 frame_info.inner_bevel=argument_list[3].integer_reference;
8131 if (attribute_flag[4] != 0)
8132 frame_info.outer_bevel=argument_list[4].integer_reference;
8133 if (attribute_flag[5] != 0)
8134 QueryColorCompliance(argument_list[5].string_reference,
8135 AllCompliance,&fill_color,exception);
8136 if (attribute_flag[6] != 0)
8137 QueryColorCompliance(argument_list[6].string_reference,
8138 AllCompliance,&fill_color,exception);
8139 frame_info.x=(ssize_t) frame_info.width;
8140 frame_info.y=(ssize_t) frame_info.height;
8141 frame_info.width=image->columns+2*frame_info.x;
8142 frame_info.height=image->rows+2*frame_info.y;
8143 if ((attribute_flag[5] != 0) || (attribute_flag[6] != 0))
8144 image->alpha_color=fill_color;
8145 compose=image->compose;
8146 if (attribute_flag[7] != 0)
8147 compose=(CompositeOperator) argument_list[7].integer_reference;
8148 image=FrameImage(image,&frame_info,compose,exception);
8151 case 16: /* Implode */
8153 PixelInterpolateMethod
8156 if (attribute_flag[0] == 0)
8157 argument_list[0].real_reference=0.5;
8158 method=UndefinedInterpolatePixel;
8159 if (attribute_flag[1] != 0)
8160 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8161 image=ImplodeImage(image,argument_list[0].real_reference,
8165 case 17: /* Magnify */
8167 image=MagnifyImage(image,exception);
8170 case 18: /* MedianFilter */
8172 if (attribute_flag[0] != 0)
8174 flags=ParseGeometry(argument_list[0].string_reference,
8176 if ((flags & SigmaValue) == 0)
8177 geometry_info.sigma=geometry_info.rho;
8179 if (attribute_flag[1] != 0)
8180 geometry_info.rho=argument_list[1].real_reference;
8181 if (attribute_flag[2] != 0)
8182 geometry_info.sigma=argument_list[2].real_reference;
8183 if (attribute_flag[3] != 0)
8184 channel=(ChannelType) argument_list[3].integer_reference;
8185 channel_mask=SetImageChannelMask(image,channel);
8186 image=StatisticImage(image,MedianStatistic,(size_t) geometry_info.rho,
8187 (size_t) geometry_info.sigma,exception);
8188 if (image != (Image *) NULL)
8189 (void) SetImageChannelMask(image,channel_mask);
8192 case 19: /* Minify */
8194 image=MinifyImage(image,exception);
8197 case 20: /* OilPaint */
8199 if (attribute_flag[0] == 0)
8200 argument_list[0].real_reference=0.0;
8201 if (attribute_flag[1] == 0)
8202 argument_list[1].real_reference=1.0;
8203 image=OilPaintImage(image,argument_list[0].real_reference,
8204 argument_list[1].real_reference,exception);
8207 case 21: /* ReduceNoise */
8209 if (attribute_flag[0] != 0)
8211 flags=ParseGeometry(argument_list[0].string_reference,
8213 if ((flags & SigmaValue) == 0)
8214 geometry_info.sigma=1.0;
8216 if (attribute_flag[1] != 0)
8217 geometry_info.rho=argument_list[1].real_reference;
8218 if (attribute_flag[2] != 0)
8219 geometry_info.sigma=argument_list[2].real_reference;
8220 if (attribute_flag[3] != 0)
8221 channel=(ChannelType) argument_list[3].integer_reference;
8222 channel_mask=SetImageChannelMask(image,channel);
8223 image=StatisticImage(image,NonpeakStatistic,(size_t)
8224 geometry_info.rho,(size_t) geometry_info.sigma,exception);
8225 if (image != (Image *) NULL)
8226 (void) SetImageChannelMask(image,channel_mask);
8231 if (attribute_flag[0] != 0)
8233 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8234 &geometry,exception);
8235 if ((flags & PercentValue) != 0)
8237 geometry.x*=(double) image->columns/100.0;
8238 geometry.y*=(double) image->rows/100.0;
8241 if (attribute_flag[1] != 0)
8242 geometry.x=argument_list[1].integer_reference;
8243 if (attribute_flag[2] != 0)
8244 geometry.y=argument_list[2].integer_reference;
8245 image=RollImage(image,geometry.x,geometry.y,exception);
8248 case 23: /* Rotate */
8250 if (attribute_flag[0] == 0)
8251 argument_list[0].real_reference=90.0;
8252 if (attribute_flag[1] != 0)
8254 QueryColorCompliance(argument_list[1].string_reference,
8255 AllCompliance,&image->background_color,exception);
8256 if ((image->background_color.alpha_trait != UndefinedPixelTrait) &&
8257 (image->alpha_trait == UndefinedPixelTrait))
8258 (void) SetImageAlpha(image,OpaqueAlpha,exception);
8260 image=RotateImage(image,argument_list[0].real_reference,exception);
8263 case 24: /* Sample */
8265 if (attribute_flag[0] != 0)
8266 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8267 &geometry,exception);
8268 if (attribute_flag[1] != 0)
8269 geometry.width=argument_list[1].integer_reference;
8270 if (attribute_flag[2] != 0)
8271 geometry.height=argument_list[2].integer_reference;
8272 image=SampleImage(image,geometry.width,geometry.height,exception);
8275 case 25: /* Scale */
8277 if (attribute_flag[0] != 0)
8278 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8279 &geometry,exception);
8280 if (attribute_flag[1] != 0)
8281 geometry.width=argument_list[1].integer_reference;
8282 if (attribute_flag[2] != 0)
8283 geometry.height=argument_list[2].integer_reference;
8284 image=ScaleImage(image,geometry.width,geometry.height,exception);
8287 case 26: /* Shade */
8289 if (attribute_flag[0] != 0)
8291 flags=ParseGeometry(argument_list[0].string_reference,
8293 if ((flags & SigmaValue) == 0)
8294 geometry_info.sigma=0.0;
8296 if (attribute_flag[1] != 0)
8297 geometry_info.rho=argument_list[1].real_reference;
8298 if (attribute_flag[2] != 0)
8299 geometry_info.sigma=argument_list[2].real_reference;
8300 image=ShadeImage(image,
8301 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
8302 geometry_info.rho,geometry_info.sigma,exception);
8305 case 27: /* Sharpen */
8307 if (attribute_flag[0] != 0)
8309 flags=ParseGeometry(argument_list[0].string_reference,
8311 if ((flags & SigmaValue) == 0)
8312 geometry_info.sigma=1.0;
8314 if (attribute_flag[1] != 0)
8315 geometry_info.rho=argument_list[1].real_reference;
8316 if (attribute_flag[2] != 0)
8317 geometry_info.sigma=argument_list[2].real_reference;
8318 if (attribute_flag[3] != 0)
8319 channel=(ChannelType) argument_list[3].integer_reference;
8320 channel_mask=SetImageChannelMask(image,channel);
8321 image=SharpenImage(image,geometry_info.rho,geometry_info.sigma,
8323 if (image != (Image *) NULL)
8324 (void) SetImageChannelMask(image,channel_mask);
8327 case 28: /* Shear */
8329 if (attribute_flag[0] != 0)
8331 flags=ParseGeometry(argument_list[0].string_reference,
8333 if ((flags & SigmaValue) == 0)
8334 geometry_info.sigma=geometry_info.rho;
8336 if (attribute_flag[1] != 0)
8337 geometry_info.rho=argument_list[1].real_reference;
8338 if (attribute_flag[2] != 0)
8339 geometry_info.sigma=argument_list[2].real_reference;
8340 if (attribute_flag[3] != 0)
8341 QueryColorCompliance(argument_list[3].string_reference,
8342 AllCompliance,&image->background_color,exception);
8343 if (attribute_flag[4] != 0)
8344 QueryColorCompliance(argument_list[4].string_reference,
8345 AllCompliance,&image->background_color,exception);
8346 image=ShearImage(image,geometry_info.rho,geometry_info.sigma,
8350 case 29: /* Spread */
8352 PixelInterpolateMethod
8355 if (attribute_flag[0] == 0)
8356 argument_list[0].real_reference=1.0;
8357 method=UndefinedInterpolatePixel;
8358 if (attribute_flag[1] != 0)
8359 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8360 image=SpreadImage(image,method,argument_list[0].real_reference,
8364 case 30: /* Swirl */
8366 PixelInterpolateMethod
8369 if (attribute_flag[0] == 0)
8370 argument_list[0].real_reference=50.0;
8371 method=UndefinedInterpolatePixel;
8372 if (attribute_flag[1] != 0)
8373 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
8374 image=SwirlImage(image,argument_list[0].real_reference,
8378 case 31: /* Resize */
8381 if (attribute_flag[0] != 0)
8382 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
8383 &geometry,exception);
8384 if (attribute_flag[1] != 0)
8385 geometry.width=argument_list[1].integer_reference;
8386 if (attribute_flag[2] != 0)
8387 geometry.height=argument_list[2].integer_reference;
8388 if (attribute_flag[3] == 0)
8389 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
8390 if (attribute_flag[4] != 0)
8391 SetImageArtifact(image,"filter:support",
8392 argument_list[4].string_reference);
8393 image=ResizeImage(image,geometry.width,geometry.height,
8394 (FilterType) argument_list[3].integer_reference,
8398 case 33: /* Annotate */
8403 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8405 if (attribute_flag[0] != 0)
8410 text=InterpretImageProperties(info ? info->image_info :
8411 (ImageInfo *) NULL,image,argument_list[0].string_reference,
8413 (void) CloneString(&draw_info->text,text);
8414 text=DestroyString(text);
8416 if (attribute_flag[1] != 0)
8417 (void) CloneString(&draw_info->font,
8418 argument_list[1].string_reference);
8419 if (attribute_flag[2] != 0)
8420 draw_info->pointsize=argument_list[2].real_reference;
8421 if (attribute_flag[3] != 0)
8422 (void) CloneString(&draw_info->density,
8423 argument_list[3].string_reference);
8424 if (attribute_flag[4] != 0)
8425 (void) QueryColorCompliance(argument_list[4].string_reference,
8426 AllCompliance,&draw_info->undercolor,exception);
8427 if (attribute_flag[5] != 0)
8429 (void) QueryColorCompliance(argument_list[5].string_reference,
8430 AllCompliance,&draw_info->stroke,exception);
8431 if (argument_list[5].image_reference != (Image *) NULL)
8432 draw_info->stroke_pattern=CloneImage(
8433 argument_list[5].image_reference,0,0,MagickTrue,exception);
8435 if (attribute_flag[6] != 0)
8437 (void) QueryColorCompliance(argument_list[6].string_reference,
8438 AllCompliance,&draw_info->fill,exception);
8439 if (argument_list[6].image_reference != (Image *) NULL)
8440 draw_info->fill_pattern=CloneImage(
8441 argument_list[6].image_reference,0,0,MagickTrue,exception);
8443 if (attribute_flag[7] != 0)
8445 (void) CloneString(&draw_info->geometry,
8446 argument_list[7].string_reference);
8447 flags=ParsePageGeometry(image,argument_list[7].string_reference,
8448 &geometry,exception);
8449 if (((flags & SigmaValue) == 0) && ((flags & XiValue) != 0))
8450 geometry_info.sigma=geometry_info.xi;
8452 if (attribute_flag[8] != 0)
8453 (void) QueryColorCompliance(argument_list[8].string_reference,
8454 AllCompliance,&draw_info->fill,exception);
8455 if (attribute_flag[11] != 0)
8456 draw_info->gravity=(GravityType)
8457 argument_list[11].integer_reference;
8458 if (attribute_flag[25] != 0)
8463 av=(AV *) argument_list[25].array_reference;
8464 if ((av_len(av) != 3) && (av_len(av) != 5))
8466 ThrowPerlException(exception,OptionError,
8467 "affine matrix must have 4 or 6 elements",PackageName);
8470 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
8471 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
8472 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
8473 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
8474 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
8475 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
8477 ThrowPerlException(exception,OptionError,
8478 "affine matrix is singular",PackageName);
8481 if (av_len(av) == 5)
8483 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
8484 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
8487 for (j=12; j < 17; j++)
8489 if (attribute_flag[j] == 0)
8491 value=argument_list[j].string_reference;
8492 angle=argument_list[j].real_reference;
8493 current=draw_info->affine;
8494 GetAffineMatrix(&affine);
8502 flags=ParseGeometry(value,&geometry_info);
8503 affine.tx=geometry_info.xi;
8504 affine.ty=geometry_info.psi;
8505 if ((flags & PsiValue) == 0)
8506 affine.ty=affine.tx;
8514 flags=ParseGeometry(value,&geometry_info);
8515 affine.sx=geometry_info.rho;
8516 affine.sy=geometry_info.sigma;
8517 if ((flags & SigmaValue) == 0)
8518 affine.sy=affine.sx;
8528 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
8529 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
8530 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
8531 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
8539 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
8547 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
8551 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
8552 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
8553 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
8554 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
8555 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
8557 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
8560 if (attribute_flag[9] == 0)
8561 argument_list[9].real_reference=0.0;
8562 if (attribute_flag[10] == 0)
8563 argument_list[10].real_reference=0.0;
8564 if ((attribute_flag[9] != 0) || (attribute_flag[10] != 0))
8567 geometry[MagickPathExtent];
8569 (void) FormatLocaleString(geometry,MagickPathExtent,"%+f%+f",
8570 (double) argument_list[9].real_reference+draw_info->affine.tx,
8571 (double) argument_list[10].real_reference+draw_info->affine.ty);
8572 (void) CloneString(&draw_info->geometry,geometry);
8574 if (attribute_flag[17] != 0)
8575 draw_info->stroke_width=argument_list[17].real_reference;
8576 if (attribute_flag[18] != 0)
8578 draw_info->text_antialias=
8579 argument_list[18].integer_reference != 0 ? MagickTrue :
8581 draw_info->stroke_antialias=draw_info->text_antialias;
8583 if (attribute_flag[19] != 0)
8584 (void) CloneString(&draw_info->family,
8585 argument_list[19].string_reference);
8586 if (attribute_flag[20] != 0)
8587 draw_info->style=(StyleType) argument_list[20].integer_reference;
8588 if (attribute_flag[21] != 0)
8589 draw_info->stretch=(StretchType)
8590 argument_list[21].integer_reference;
8591 if (attribute_flag[22] != 0)
8592 draw_info->weight=argument_list[22].integer_reference;
8593 if (attribute_flag[23] != 0)
8594 draw_info->align=(AlignType) argument_list[23].integer_reference;
8595 if (attribute_flag[24] != 0)
8596 (void) CloneString(&draw_info->encoding,
8597 argument_list[24].string_reference);
8598 if (attribute_flag[25] != 0)
8599 draw_info->fill_pattern=CloneImage(
8600 argument_list[25].image_reference,0,0,MagickTrue,exception);
8601 if (attribute_flag[26] != 0)
8602 draw_info->fill_pattern=CloneImage(
8603 argument_list[26].image_reference,0,0,MagickTrue,exception);
8604 if (attribute_flag[27] != 0)
8605 draw_info->stroke_pattern=CloneImage(
8606 argument_list[27].image_reference,0,0,MagickTrue,exception);
8607 if (attribute_flag[29] != 0)
8608 draw_info->kerning=argument_list[29].real_reference;
8609 if (attribute_flag[30] != 0)
8610 draw_info->interline_spacing=argument_list[30].real_reference;
8611 if (attribute_flag[31] != 0)
8612 draw_info->interword_spacing=argument_list[31].real_reference;
8613 if (attribute_flag[32] != 0)
8614 draw_info->direction=(DirectionType)
8615 argument_list[32].integer_reference;
8616 if (attribute_flag[33] != 0)
8617 draw_info->decorate=(DecorationType)
8618 argument_list[33].integer_reference;
8619 (void) AnnotateImage(image,draw_info,exception);
8620 draw_info=DestroyDrawInfo(draw_info);
8623 case 34: /* ColorFloodfill */
8634 draw_info=CloneDrawInfo(info ? info->image_info :
8635 (ImageInfo *) NULL,(DrawInfo *) NULL);
8636 if (attribute_flag[0] != 0)
8637 flags=ParsePageGeometry(image,argument_list[0].string_reference,
8638 &geometry,exception);
8639 if (attribute_flag[1] != 0)
8640 geometry.x=argument_list[1].integer_reference;
8641 if (attribute_flag[2] != 0)
8642 geometry.y=argument_list[2].integer_reference;
8643 if (attribute_flag[3] != 0)
8644 (void) QueryColorCompliance(argument_list[3].string_reference,
8645 AllCompliance,&draw_info->fill,exception);
8646 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
8647 geometry.x,geometry.y,&target,exception);
8649 if (attribute_flag[4] != 0)
8651 QueryColorCompliance(argument_list[4].string_reference,
8652 AllCompliance,&target,exception);
8655 if (attribute_flag[5] != 0)
8656 image->fuzz=StringToDoubleInterval(
8657 argument_list[5].string_reference,(double) QuantumRange+1.0);
8658 if (attribute_flag[6] != 0)
8659 invert=(MagickBooleanType) argument_list[6].integer_reference;
8660 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
8661 geometry.y,invert,exception);
8662 draw_info=DestroyDrawInfo(draw_info);
8665 case 35: /* Composite */
8668 composite_geometry[MagickPathExtent];
8677 compose=OverCompositeOp;
8678 if (attribute_flag[0] != 0)
8679 composite_image=argument_list[0].image_reference;
8682 ThrowPerlException(exception,OptionError,
8683 "CompositeImageRequired",PackageName);
8687 Parameter Handling used for BOTH normal and tiled composition.
8689 if (attribute_flag[1] != 0) /* compose */
8690 compose=(CompositeOperator) argument_list[1].integer_reference;
8691 if (attribute_flag[6] != 0) /* opacity */
8693 if (compose != DissolveCompositeOp)
8694 (void) SetImageAlpha(composite_image,(Quantum)
8695 StringToDoubleInterval(argument_list[6].string_reference,
8696 (double) QuantumRange+1.0),exception);
8718 Handle dissolve composite operator (patch by
8721 (void) CloneString(&image->geometry,
8722 argument_list[6].string_reference);
8723 opacity=(Quantum) StringToDoubleInterval(
8724 argument_list[6].string_reference,(double) QuantumRange+
8726 if (composite_image->alpha_trait != UndefinedPixelTrait)
8727 (void) SetImageAlpha(composite_image,OpaqueAlpha,exception);
8728 composite_view=AcquireAuthenticCacheView(composite_image,
8730 for (y=0; y < (ssize_t) composite_image->rows ; y++)
8732 q=GetCacheViewAuthenticPixels(composite_view,0,y,(ssize_t)
8733 composite_image->columns,1,exception);
8734 for (x=0; x < (ssize_t) composite_image->columns; x++)
8736 if (GetPixelAlpha(image,q) == OpaqueAlpha)
8737 SetPixelAlpha(composite_image,ClampToQuantum(opacity),
8739 q+=GetPixelChannels(composite_image);
8741 sync=SyncCacheViewAuthenticPixels(composite_view,exception);
8742 if (sync == MagickFalse)
8745 composite_view=DestroyCacheView(composite_view);
8748 if (attribute_flag[9] != 0) /* "color=>" */
8749 QueryColorCompliance(argument_list[9].string_reference,
8750 AllCompliance,&composite_image->background_color,exception);
8751 if (attribute_flag[12] != 0) /* "interpolate=>" */
8752 image->interpolate=(PixelInterpolateMethod)
8753 argument_list[12].integer_reference;
8754 if (attribute_flag[13] != 0) /* "args=>" */
8755 (void) SetImageArtifact(composite_image,"compose:args",
8756 argument_list[13].string_reference);
8757 if (attribute_flag[14] != 0) /* "blend=>" depreciated */
8758 (void) SetImageArtifact(composite_image,"compose:args",
8759 argument_list[14].string_reference);
8760 clip_to_self=MagickTrue;
8763 case ClearCompositeOp:
8764 case SrcCompositeOp:
8766 case SrcInCompositeOp:
8767 case OutCompositeOp:
8768 case SrcOutCompositeOp:
8769 case DstInCompositeOp:
8770 case DstAtopCompositeOp:
8771 case CopyAlphaCompositeOp:
8772 case ChangeMaskCompositeOp:
8773 case DissolveCompositeOp:
8774 case BlendCompositeOp:
8776 clip_to_self=MagickFalse;
8782 if (attribute_flag[15] != 0)
8783 clip_to_self=(MagickBooleanType)
8784 argument_list[15].integer_reference;
8786 Tiling Composition (with orthogonal rotate).
8788 rotate_image=(Image *) NULL;
8789 if (attribute_flag[8] != 0) /* "rotate=>" */
8794 rotate_image=RotateImage(composite_image,
8795 argument_list[8].real_reference,exception);
8796 if (rotate_image == (Image *) NULL)
8799 if ((attribute_flag[7] != 0) &&
8800 (argument_list[7].integer_reference != 0)) /* tile */
8807 Tile the composite image.
8809 for (y=0; y < (ssize_t) image->rows; y+=(ssize_t) composite_image->rows)
8810 for (x=0; x < (ssize_t) image->columns; x+=(ssize_t) composite_image->columns)
8812 if (attribute_flag[8] != 0) /* rotate */
8813 (void) CompositeImage(image,rotate_image,compose,
8814 MagickTrue,x,y,exception);
8816 (void) CompositeImage(image,composite_image,compose,
8817 MagickTrue,x,y,exception);
8819 if (attribute_flag[8] != 0) /* rotate */
8820 rotate_image=DestroyImage(rotate_image);
8824 Parameter Handling used used ONLY for normal composition.
8826 if (attribute_flag[5] != 0) /* gravity */
8827 image->gravity=(GravityType) argument_list[5].integer_reference;
8828 if (attribute_flag[2] != 0) /* geometry offset */
8830 SetGeometry(image,&geometry);
8831 (void) ParseAbsoluteGeometry(argument_list[2].string_reference,
8833 GravityAdjustGeometry(image->columns,image->rows,image->gravity,
8836 if (attribute_flag[3] != 0) /* x offset */
8837 geometry.x=argument_list[3].integer_reference;
8838 if (attribute_flag[4] != 0) /* y offset */
8839 geometry.y=argument_list[4].integer_reference;
8840 if (attribute_flag[10] != 0) /* mask */
8842 if ((image->compose == DisplaceCompositeOp) ||
8843 (image->compose == DistortCompositeOp))
8846 Merge Y displacement into X displacement image.
8848 composite_image=CloneImage(composite_image,0,0,MagickTrue,
8850 (void) CompositeImage(composite_image,
8851 argument_list[10].image_reference,CopyGreenCompositeOp,
8852 clip_to_self,0,0,exception);
8860 Set a blending mask for the composition.
8862 mask_image=CloneImage(argument_list[10].image_reference,0,0,
8863 MagickTrue,exception);
8864 (void) SetImageMask(composite_image,ReadPixelMask,mask_image,
8866 mask_image=DestroyImage(mask_image);
8869 if (attribute_flag[11] != 0) /* channel */
8870 channel=(ChannelType) argument_list[11].integer_reference;
8872 Composite two images (normal composition).
8874 (void) FormatLocaleString(composite_geometry,MagickPathExtent,
8875 "%.20gx%.20g%+.20g%+.20g",(double) composite_image->columns,
8876 (double) composite_image->rows,(double) geometry.x,(double)
8878 flags=ParseGravityGeometry(image,composite_geometry,&geometry,
8880 channel_mask=SetImageChannelMask(image,channel);
8881 if (attribute_flag[8] == 0) /* no rotate */
8882 CompositeImage(image,composite_image,compose,clip_to_self,
8883 geometry.x,geometry.y,exception);
8887 Position adjust rotated image then composite.
8889 geometry.x-=(ssize_t) (rotate_image->columns-
8890 composite_image->columns)/2;
8891 geometry.y-=(ssize_t) (rotate_image->rows-
8892 composite_image->rows)/2;
8893 CompositeImage(image,rotate_image,compose,clip_to_self,geometry.x,
8894 geometry.y,exception);
8895 rotate_image=DestroyImage(rotate_image);
8897 if (attribute_flag[10] != 0) /* mask */
8899 if ((image->compose == DisplaceCompositeOp) ||
8900 (image->compose == DistortCompositeOp))
8901 composite_image=DestroyImage(composite_image);
8903 (void) SetImageMask(image,ReadPixelMask,(Image *) NULL,
8906 (void) SetImageChannelMask(image,channel_mask);
8909 case 36: /* Contrast */
8911 if (attribute_flag[0] == 0)
8912 argument_list[0].integer_reference=0;
8913 (void) ContrastImage(image,argument_list[0].integer_reference != 0 ?
8914 MagickTrue : MagickFalse,exception);
8917 case 37: /* CycleColormap */
8919 if (attribute_flag[0] == 0)
8920 argument_list[0].integer_reference=6;
8921 (void) CycleColormapImage(image,argument_list[0].integer_reference,
8930 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
8932 (void) CloneString(&draw_info->primitive,"point");
8933 if (attribute_flag[0] != 0)
8935 if (argument_list[0].integer_reference < 0)
8936 (void) CloneString(&draw_info->primitive,
8937 argument_list[0].string_reference);
8939 (void) CloneString(&draw_info->primitive,
8940 CommandOptionToMnemonic(MagickPrimitiveOptions,
8941 argument_list[0].integer_reference));
8943 if (attribute_flag[1] != 0)
8945 if (LocaleCompare(draw_info->primitive,"path") == 0)
8947 (void) ConcatenateString(&draw_info->primitive," '");
8948 ConcatenateString(&draw_info->primitive,
8949 argument_list[1].string_reference);
8950 (void) ConcatenateString(&draw_info->primitive,"'");
8954 (void) ConcatenateString(&draw_info->primitive," ");
8955 ConcatenateString(&draw_info->primitive,
8956 argument_list[1].string_reference);
8959 if (attribute_flag[2] != 0)
8961 (void) ConcatenateString(&draw_info->primitive," ");
8962 (void) ConcatenateString(&draw_info->primitive,
8963 CommandOptionToMnemonic(MagickMethodOptions,
8964 argument_list[2].integer_reference));
8966 if (attribute_flag[3] != 0)
8968 (void) QueryColorCompliance(argument_list[3].string_reference,
8969 AllCompliance,&draw_info->stroke,exception);
8970 if (argument_list[3].image_reference != (Image *) NULL)
8971 draw_info->stroke_pattern=CloneImage(
8972 argument_list[3].image_reference,0,0,MagickTrue,exception);
8974 if (attribute_flag[4] != 0)
8976 (void) QueryColorCompliance(argument_list[4].string_reference,
8977 AllCompliance,&draw_info->fill,exception);
8978 if (argument_list[4].image_reference != (Image *) NULL)
8979 draw_info->fill_pattern=CloneImage(
8980 argument_list[4].image_reference,0,0,MagickTrue,exception);
8982 if (attribute_flag[5] != 0)
8983 draw_info->stroke_width=argument_list[5].real_reference;
8984 if (attribute_flag[6] != 0)
8985 (void) CloneString(&draw_info->font,
8986 argument_list[6].string_reference);
8987 if (attribute_flag[7] != 0)
8988 (void) QueryColorCompliance(argument_list[7].string_reference,
8989 AllCompliance,&draw_info->border_color,exception);
8990 if (attribute_flag[8] != 0)
8991 draw_info->affine.tx=argument_list[8].real_reference;
8992 if (attribute_flag[9] != 0)
8993 draw_info->affine.ty=argument_list[9].real_reference;
8994 if (attribute_flag[20] != 0)
8999 av=(AV *) argument_list[20].array_reference;
9000 if ((av_len(av) != 3) && (av_len(av) != 5))
9002 ThrowPerlException(exception,OptionError,
9003 "affine matrix must have 4 or 6 elements",PackageName);
9006 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9007 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9008 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9009 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9010 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9011 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9013 ThrowPerlException(exception,OptionError,
9014 "affine matrix is singular",PackageName);
9017 if (av_len(av) == 5)
9019 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9020 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9023 for (j=10; j < 15; j++)
9025 if (attribute_flag[j] == 0)
9027 value=argument_list[j].string_reference;
9028 angle=argument_list[j].real_reference;
9029 current=draw_info->affine;
9030 GetAffineMatrix(&affine);
9038 flags=ParseGeometry(value,&geometry_info);
9039 affine.tx=geometry_info.xi;
9040 affine.ty=geometry_info.psi;
9041 if ((flags & PsiValue) == 0)
9042 affine.ty=affine.tx;
9050 flags=ParseGeometry(value,&geometry_info);
9051 affine.sx=geometry_info.rho;
9052 affine.sy=geometry_info.sigma;
9053 if ((flags & SigmaValue) == 0)
9054 affine.sy=affine.sx;
9064 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
9065 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
9066 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
9067 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
9075 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
9083 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
9087 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
9088 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
9089 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
9090 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
9091 draw_info->affine.tx=
9092 current.sx*affine.tx+current.ry*affine.ty+current.tx;
9093 draw_info->affine.ty=
9094 current.rx*affine.tx+current.sy*affine.ty+current.ty;
9096 if (attribute_flag[15] != 0)
9097 draw_info->fill_pattern=CloneImage(
9098 argument_list[15].image_reference,0,0,MagickTrue,exception);
9099 if (attribute_flag[16] != 0)
9100 draw_info->pointsize=argument_list[16].real_reference;
9101 if (attribute_flag[17] != 0)
9103 draw_info->stroke_antialias=
9104 argument_list[17].integer_reference != 0 ? MagickTrue :
9106 draw_info->text_antialias=draw_info->stroke_antialias;
9108 if (attribute_flag[18] != 0)
9109 (void) CloneString(&draw_info->density,
9110 argument_list[18].string_reference);
9111 if (attribute_flag[19] != 0)
9112 draw_info->stroke_width=argument_list[19].real_reference;
9113 if (attribute_flag[21] != 0)
9114 draw_info->dash_offset=argument_list[21].real_reference;
9115 if (attribute_flag[22] != 0)
9120 av=(AV *) argument_list[22].array_reference;
9121 draw_info->dash_pattern=(double *) AcquireQuantumMemory(
9122 av_len(av)+2UL,sizeof(*draw_info->dash_pattern));
9123 if (draw_info->dash_pattern != (double *) NULL)
9125 for (i=0; i <= av_len(av); i++)
9126 draw_info->dash_pattern[i]=(double)
9127 SvNV(*(av_fetch(av,i,0)));
9128 draw_info->dash_pattern[i]=0.0;
9131 if (attribute_flag[23] != 0)
9132 image->interpolate=(PixelInterpolateMethod)
9133 argument_list[23].integer_reference;
9134 if ((attribute_flag[24] != 0) &&
9135 (draw_info->fill_pattern != (Image *) NULL))
9136 flags=ParsePageGeometry(draw_info->fill_pattern,
9137 argument_list[24].string_reference,
9138 &draw_info->fill_pattern->tile_offset,exception);
9139 if (attribute_flag[25] != 0)
9141 (void) ConcatenateString(&draw_info->primitive," '");
9142 (void) ConcatenateString(&draw_info->primitive,
9143 argument_list[25].string_reference);
9144 (void) ConcatenateString(&draw_info->primitive,"'");
9146 if (attribute_flag[26] != 0)
9147 draw_info->fill_pattern=CloneImage(
9148 argument_list[26].image_reference,0,0,MagickTrue,exception);
9149 if (attribute_flag[27] != 0)
9150 draw_info->stroke_pattern=CloneImage(
9151 argument_list[27].image_reference,0,0,MagickTrue,exception);
9152 if (attribute_flag[28] != 0)
9153 (void) CloneString(&draw_info->primitive,
9154 argument_list[28].string_reference);
9155 if (attribute_flag[29] != 0)
9156 draw_info->kerning=argument_list[29].real_reference;
9157 if (attribute_flag[30] != 0)
9158 draw_info->interline_spacing=argument_list[30].real_reference;
9159 if (attribute_flag[31] != 0)
9160 draw_info->interword_spacing=argument_list[31].real_reference;
9161 if (attribute_flag[32] != 0)
9162 draw_info->direction=(DirectionType)
9163 argument_list[32].integer_reference;
9164 DrawImage(image,draw_info,exception);
9165 draw_info=DestroyDrawInfo(draw_info);
9168 case 39: /* Equalize */
9170 if (attribute_flag[0] != 0)
9171 channel=(ChannelType) argument_list[0].integer_reference;
9172 channel_mask=SetImageChannelMask(image,channel);
9173 (void) EqualizeImage(image,exception);
9174 (void) SetImageChannelMask(image,channel_mask);
9177 case 40: /* Gamma */
9179 if (attribute_flag[1] != 0)
9180 channel=(ChannelType) argument_list[1].integer_reference;
9181 if (attribute_flag[2] == 0)
9182 argument_list[2].real_reference=1.0;
9183 if (attribute_flag[3] == 0)
9184 argument_list[3].real_reference=1.0;
9185 if (attribute_flag[4] == 0)
9186 argument_list[4].real_reference=1.0;
9187 if (attribute_flag[0] == 0)
9189 (void) FormatLocaleString(message,MagickPathExtent,
9190 "%.20g,%.20g,%.20g",(double) argument_list[2].real_reference,
9191 (double) argument_list[3].real_reference,
9192 (double) argument_list[4].real_reference);
9193 argument_list[0].string_reference=message;
9195 (void) GammaImage(image,StringToDouble(
9196 argument_list[0].string_reference,(char **) NULL),exception);
9204 if (attribute_flag[0] == 0)
9206 ThrowPerlException(exception,OptionError,"MapImageRequired",
9210 quantize_info=AcquireQuantizeInfo(info->image_info);
9211 if (attribute_flag[1] != 0)
9212 quantize_info->dither_method=(DitherMethod)
9213 argument_list[1].integer_reference;
9214 (void) RemapImages(quantize_info,image,
9215 argument_list[0].image_reference,exception);
9216 quantize_info=DestroyQuantizeInfo(quantize_info);
9219 case 42: /* MatteFloodfill */
9230 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9232 if (attribute_flag[0] != 0)
9233 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9234 &geometry,exception);
9235 if (attribute_flag[1] != 0)
9236 geometry.x=argument_list[1].integer_reference;
9237 if (attribute_flag[2] != 0)
9238 geometry.y=argument_list[2].integer_reference;
9239 if (image->alpha_trait == UndefinedPixelTrait)
9240 (void) SetImageAlpha(image,OpaqueAlpha,exception);
9241 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
9242 geometry.x,geometry.y,&target,exception);
9243 if (attribute_flag[4] != 0)
9244 QueryColorCompliance(argument_list[4].string_reference,
9245 AllCompliance,&target,exception);
9246 if (attribute_flag[3] != 0)
9247 target.alpha=StringToDoubleInterval(
9248 argument_list[3].string_reference,(double) (double) QuantumRange+
9250 if (attribute_flag[5] != 0)
9251 image->fuzz=StringToDoubleInterval(
9252 argument_list[5].string_reference,(double) QuantumRange+1.0);
9254 if (attribute_flag[6] != 0)
9255 invert=(MagickBooleanType) argument_list[6].integer_reference;
9256 channel_mask=SetImageChannelMask(image,AlphaChannel);
9257 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
9258 geometry.y,invert,exception);
9259 (void) SetImageChannelMask(image,channel_mask);
9260 draw_info=DestroyDrawInfo(draw_info);
9263 case 43: /* Modulate */
9266 modulate[MagickPathExtent];
9268 geometry_info.rho=100.0;
9269 geometry_info.sigma=100.0;
9270 geometry_info.xi=100.0;
9271 if (attribute_flag[0] != 0)
9272 (void)ParseGeometry(argument_list[0].string_reference,
9274 if (attribute_flag[1] != 0)
9275 geometry_info.xi=argument_list[1].real_reference;
9276 if (attribute_flag[2] != 0)
9277 geometry_info.sigma=argument_list[2].real_reference;
9278 if (attribute_flag[3] != 0)
9280 geometry_info.sigma=argument_list[3].real_reference;
9281 SetImageArtifact(image,"modulate:colorspace","HWB");
9283 if (attribute_flag[4] != 0)
9285 geometry_info.rho=argument_list[4].real_reference;
9286 SetImageArtifact(image,"modulate:colorspace","HSB");
9288 if (attribute_flag[5] != 0)
9290 geometry_info.sigma=argument_list[5].real_reference;
9291 SetImageArtifact(image,"modulate:colorspace","HSL");
9293 if (attribute_flag[6] != 0)
9295 geometry_info.rho=argument_list[6].real_reference;
9296 SetImageArtifact(image,"modulate:colorspace","HWB");
9298 (void) FormatLocaleString(modulate,MagickPathExtent,
9299 "%.20g,%.20g,%.20g",geometry_info.rho,geometry_info.sigma,
9301 (void) ModulateImage(image,modulate,exception);
9304 case 44: /* Negate */
9306 if (attribute_flag[0] == 0)
9307 argument_list[0].integer_reference=0;
9308 if (attribute_flag[1] != 0)
9309 channel=(ChannelType) argument_list[1].integer_reference;
9310 channel_mask=SetImageChannelMask(image,channel);
9311 (void) NegateImage(image,argument_list[0].integer_reference != 0 ?
9312 MagickTrue : MagickFalse,exception);
9313 (void) SetImageChannelMask(image,channel_mask);
9316 case 45: /* Normalize */
9318 if (attribute_flag[0] != 0)
9319 channel=(ChannelType) argument_list[0].integer_reference;
9320 channel_mask=SetImageChannelMask(image,channel);
9321 NormalizeImage(image,exception);
9322 (void) SetImageChannelMask(image,channel_mask);
9325 case 46: /* NumberColors */
9327 case 47: /* Opaque */
9336 (void) QueryColorCompliance("none",AllCompliance,&target,
9338 (void) QueryColorCompliance("none",AllCompliance,&fill_color,
9340 if (attribute_flag[0] != 0)
9341 (void) QueryColorCompliance(argument_list[0].string_reference,
9342 AllCompliance,&target,exception);
9343 if (attribute_flag[1] != 0)
9344 (void) QueryColorCompliance(argument_list[1].string_reference,
9345 AllCompliance,&fill_color,exception);
9346 if (attribute_flag[2] != 0)
9347 image->fuzz=StringToDoubleInterval(
9348 argument_list[2].string_reference,(double) QuantumRange+1.0);
9349 if (attribute_flag[3] != 0)
9350 channel=(ChannelType) argument_list[3].integer_reference;
9352 if (attribute_flag[4] != 0)
9353 invert=(MagickBooleanType) argument_list[4].integer_reference;
9354 channel_mask=SetImageChannelMask(image,channel);
9355 (void) OpaquePaintImage(image,&target,&fill_color,invert,exception);
9356 (void) SetImageChannelMask(image,channel_mask);
9359 case 48: /* Quantize */
9364 quantize_info=AcquireQuantizeInfo(info->image_info);
9365 if (attribute_flag[0] != 0)
9366 quantize_info->number_colors=(size_t)
9367 argument_list[0].integer_reference;
9368 if (attribute_flag[1] != 0)
9369 quantize_info->tree_depth=(size_t)
9370 argument_list[1].integer_reference;
9371 if (attribute_flag[2] != 0)
9372 quantize_info->colorspace=(ColorspaceType)
9373 argument_list[2].integer_reference;
9374 if (attribute_flag[3] != 0)
9375 quantize_info->dither_method=(DitherMethod)
9376 argument_list[3].integer_reference;
9377 if (attribute_flag[4] != 0)
9378 quantize_info->measure_error=
9379 argument_list[4].integer_reference != 0 ? MagickTrue :
9381 if (attribute_flag[6] != 0)
9382 (void) QueryColorCompliance(argument_list[6].string_reference,
9383 AllCompliance,&image->transparent_color,exception);
9384 if (attribute_flag[7] != 0)
9385 quantize_info->dither_method=(DitherMethod)
9386 argument_list[7].integer_reference;
9387 if (attribute_flag[5] && argument_list[5].integer_reference)
9388 (void) QuantizeImages(quantize_info,image,exception);
9390 if ((image->storage_class == DirectClass) ||
9391 (image->colors > quantize_info->number_colors) ||
9392 (quantize_info->colorspace == GRAYColorspace))
9393 (void) QuantizeImage(quantize_info,image,exception);
9395 CompressImageColormap(image,exception);
9396 quantize_info=DestroyQuantizeInfo(quantize_info);
9399 case 49: /* Raise */
9401 if (attribute_flag[0] != 0)
9402 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9403 &geometry,exception);
9404 if (attribute_flag[1] != 0)
9405 geometry.width=argument_list[1].integer_reference;
9406 if (attribute_flag[2] != 0)
9407 geometry.height=argument_list[2].integer_reference;
9408 if (attribute_flag[3] == 0)
9409 argument_list[3].integer_reference=1;
9410 (void) RaiseImage(image,&geometry,
9411 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
9415 case 50: /* Segment */
9422 smoothing_threshold;
9427 cluster_threshold=1.0;
9428 smoothing_threshold=1.5;
9429 colorspace=sRGBColorspace;
9430 verbose=MagickFalse;
9431 if (attribute_flag[0] != 0)
9433 flags=ParseGeometry(argument_list[0].string_reference,
9435 cluster_threshold=geometry_info.rho;
9436 if (flags & SigmaValue)
9437 smoothing_threshold=geometry_info.sigma;
9439 if (attribute_flag[1] != 0)
9440 cluster_threshold=argument_list[1].real_reference;
9441 if (attribute_flag[2] != 0)
9442 smoothing_threshold=argument_list[2].real_reference;
9443 if (attribute_flag[3] != 0)
9444 colorspace=(ColorspaceType) argument_list[3].integer_reference;
9445 if (attribute_flag[4] != 0)
9446 verbose=argument_list[4].integer_reference != 0 ? MagickTrue :
9448 (void) SegmentImage(image,colorspace,verbose,cluster_threshold,
9449 smoothing_threshold,exception);
9452 case 51: /* Signature */
9454 (void) SignatureImage(image,exception);
9457 case 52: /* Solarize */
9459 geometry_info.rho=QuantumRange/2.0;
9460 if (attribute_flag[0] != 0)
9461 flags=ParseGeometry(argument_list[0].string_reference,
9463 if (attribute_flag[1] != 0)
9464 geometry_info.rho=StringToDoubleInterval(
9465 argument_list[1].string_reference,(double) QuantumRange+1.0);
9466 (void) SolarizeImage(image,geometry_info.rho,exception);
9471 (void) SyncImage(image,exception);
9474 case 54: /* Texture */
9476 if (attribute_flag[0] == 0)
9478 TextureImage(image,argument_list[0].image_reference,exception);
9481 case 55: /* Evalute */
9483 MagickEvaluateOperator
9486 op=SetEvaluateOperator;
9487 if (attribute_flag[0] == MagickFalse)
9488 argument_list[0].real_reference=0.0;
9489 if (attribute_flag[1] != MagickFalse)
9490 op=(MagickEvaluateOperator) argument_list[1].integer_reference;
9491 if (attribute_flag[2] != MagickFalse)
9492 channel=(ChannelType) argument_list[2].integer_reference;
9493 channel_mask=SetImageChannelMask(image,channel);
9494 (void) EvaluateImage(image,op,argument_list[0].real_reference,
9496 (void) SetImageChannelMask(image,channel_mask);
9499 case 56: /* Transparent */
9510 (void) QueryColorCompliance("none",AllCompliance,&target,
9512 if (attribute_flag[0] != 0)
9513 (void) QueryColorCompliance(argument_list[0].string_reference,
9514 AllCompliance,&target,exception);
9515 opacity=TransparentAlpha;
9516 if (attribute_flag[1] != 0)
9517 opacity=StringToDoubleInterval(argument_list[1].string_reference,
9518 (double) QuantumRange+1.0);
9519 if (attribute_flag[2] != 0)
9520 image->fuzz=StringToDoubleInterval(
9521 argument_list[2].string_reference,(double) QuantumRange+1.0);
9522 if (attribute_flag[3] == 0)
9523 argument_list[3].integer_reference=0;
9525 if (attribute_flag[3] != 0)
9526 invert=(MagickBooleanType) argument_list[3].integer_reference;
9527 (void) TransparentPaintImage(image,&target,ClampToQuantum(opacity),
9531 case 57: /* Threshold */
9536 if (attribute_flag[0] == 0)
9537 argument_list[0].string_reference="50%";
9538 if (attribute_flag[1] != 0)
9539 channel=(ChannelType) argument_list[1].integer_reference;
9540 threshold=StringToDoubleInterval(argument_list[0].string_reference,
9541 (double) QuantumRange+1.0);
9542 channel_mask=SetImageChannelMask(image,channel);
9543 (void) BilevelImage(image,threshold,exception);
9544 (void) SetImageChannelMask(image,channel_mask);
9547 case 58: /* Charcoal */
9549 if (attribute_flag[0] != 0)
9551 flags=ParseGeometry(argument_list[0].string_reference,
9553 if ((flags & SigmaValue) == 0)
9554 geometry_info.sigma=1.0;
9556 if (attribute_flag[1] != 0)
9557 geometry_info.rho=argument_list[1].real_reference;
9558 if (attribute_flag[2] != 0)
9559 geometry_info.sigma=argument_list[2].real_reference;
9560 image=CharcoalImage(image,geometry_info.rho,geometry_info.sigma,
9566 if (attribute_flag[0] != 0)
9567 image->fuzz=StringToDoubleInterval(
9568 argument_list[0].string_reference,(double) QuantumRange+1.0);
9569 image=TrimImage(image,exception);
9574 PixelInterpolateMethod
9577 if (attribute_flag[0] != 0)
9579 flags=ParseGeometry(argument_list[0].string_reference,
9581 if ((flags & SigmaValue) == 0)
9582 geometry_info.sigma=1.0;
9584 if (attribute_flag[1] != 0)
9585 geometry_info.rho=argument_list[1].real_reference;
9586 if (attribute_flag[2] != 0)
9587 geometry_info.sigma=argument_list[2].real_reference;
9588 method=UndefinedInterpolatePixel;
9589 if (attribute_flag[3] != 0)
9590 method=(PixelInterpolateMethod) argument_list[3].integer_reference;
9591 image=WaveImage(image,geometry_info.rho,geometry_info.sigma,
9595 case 61: /* Separate */
9597 if (attribute_flag[0] != 0)
9598 channel=(ChannelType) argument_list[0].integer_reference;
9599 image=SeparateImage(image,channel,exception);
9602 case 63: /* Stereo */
9604 if (attribute_flag[0] == 0)
9606 ThrowPerlException(exception,OptionError,"StereoImageRequired",
9610 if (attribute_flag[1] != 0)
9611 geometry.x=argument_list[1].integer_reference;
9612 if (attribute_flag[2] != 0)
9613 geometry.y=argument_list[2].integer_reference;
9614 image=StereoAnaglyphImage(image,argument_list[0].image_reference,
9615 geometry.x,geometry.y,exception);
9618 case 64: /* Stegano */
9620 if (attribute_flag[0] == 0)
9622 ThrowPerlException(exception,OptionError,"SteganoImageRequired",
9626 if (attribute_flag[1] == 0)
9627 argument_list[1].integer_reference=0;
9628 image->offset=argument_list[1].integer_reference;
9629 image=SteganoImage(image,argument_list[0].image_reference,exception);
9632 case 65: /* Deconstruct */
9634 image=CompareImagesLayers(image,CompareAnyLayer,exception);
9637 case 66: /* GaussianBlur */
9639 if (attribute_flag[0] != 0)
9641 flags=ParseGeometry(argument_list[0].string_reference,
9643 if ((flags & SigmaValue) == 0)
9644 geometry_info.sigma=1.0;
9646 if (attribute_flag[1] != 0)
9647 geometry_info.rho=argument_list[1].real_reference;
9648 if (attribute_flag[2] != 0)
9649 geometry_info.sigma=argument_list[2].real_reference;
9650 if (attribute_flag[3] != 0)
9651 channel=(ChannelType) argument_list[3].integer_reference;
9652 channel_mask=SetImageChannelMask(image,channel);
9653 image=GaussianBlurImage(image,geometry_info.rho,geometry_info.sigma,
9655 if (image != (Image *) NULL)
9656 (void) SetImageChannelMask(image,channel_mask);
9659 case 67: /* Convolve */
9664 kernel=(KernelInfo *) NULL;
9665 if ((attribute_flag[0] == 0) && (attribute_flag[3] == 0))
9667 if (attribute_flag[0] != 0)
9675 kernel=AcquireKernelInfo((const char *) NULL,exception);
9676 if (kernel == (KernelInfo *) NULL)
9678 av=(AV *) argument_list[0].array_reference;
9679 order=(size_t) sqrt(av_len(av)+1);
9680 kernel->width=order;
9681 kernel->height=order;
9682 kernel->values=(MagickRealType *) AcquireAlignedMemory(order,
9683 order*sizeof(*kernel->values));
9684 if (kernel->values == (MagickRealType *) NULL)
9686 kernel=DestroyKernelInfo(kernel);
9687 ThrowPerlException(exception,ResourceLimitFatalError,
9688 "MemoryAllocationFailed",PackageName);
9691 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
9692 kernel->values[j]=(MagickRealType) SvNV(*(av_fetch(av,j,0)));
9693 for ( ; j < (ssize_t) (order*order); j++)
9694 kernel->values[j]=0.0;
9696 if (attribute_flag[1] != 0)
9697 channel=(ChannelType) argument_list[1].integer_reference;
9698 if (attribute_flag[2] != 0)
9699 SetImageArtifact(image,"convolve:bias",
9700 argument_list[2].string_reference);
9701 if (attribute_flag[3] != 0)
9703 kernel=AcquireKernelInfo(argument_list[3].string_reference,
9705 if (kernel == (KernelInfo *) NULL)
9708 channel_mask=SetImageChannelMask(image,channel);
9709 image=ConvolveImage(image,kernel,exception);
9710 if (image != (Image *) NULL)
9711 (void) SetImageChannelMask(image,channel_mask);
9712 kernel=DestroyKernelInfo(kernel);
9715 case 68: /* Profile */
9730 if (attribute_flag[0] != 0)
9731 name=argument_list[0].string_reference;
9732 if (attribute_flag[2] != 0)
9733 image->rendering_intent=(RenderingIntent)
9734 argument_list[2].integer_reference;
9735 if (attribute_flag[3] != 0)
9736 image->black_point_compensation=
9737 argument_list[3].integer_reference != 0 ? MagickTrue :
9739 if (attribute_flag[1] != 0)
9741 if (argument_list[1].length == 0)
9744 Remove a profile from the image.
9746 (void) ProfileImage(image,name,(const unsigned char *) NULL,0,
9751 Associate user supplied profile with the image.
9753 profile=AcquireStringInfo(argument_list[1].length);
9754 SetStringInfoDatum(profile,(const unsigned char *)
9755 argument_list[1].string_reference);
9756 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9757 (size_t) GetStringInfoLength(profile),exception);
9758 profile=DestroyStringInfo(profile);
9762 Associate a profile with the image.
9764 profile_info=CloneImageInfo(info ? info->image_info : (ImageInfo *)
9766 profile_image=ReadImages(profile_info,name,exception);
9767 if (profile_image == (Image *) NULL)
9769 ResetImageProfileIterator(profile_image);
9770 name=GetNextImageProfile(profile_image);
9771 while (name != (const char *) NULL)
9776 profile=GetImageProfile(profile_image,name);
9777 if (profile != (const StringInfo *) NULL)
9778 (void) ProfileImage(image,name,GetStringInfoDatum(profile),
9779 (size_t) GetStringInfoLength(profile),exception);
9780 name=GetNextImageProfile(profile_image);
9782 profile_image=DestroyImage(profile_image);
9783 profile_info=DestroyImageInfo(profile_info);
9786 case 69: /* UnsharpMask */
9788 if (attribute_flag[0] != 0)
9790 flags=ParseGeometry(argument_list[0].string_reference,
9792 if ((flags & SigmaValue) == 0)
9793 geometry_info.sigma=1.0;
9794 if ((flags & XiValue) == 0)
9795 geometry_info.xi=1.0;
9796 if ((flags & PsiValue) == 0)
9797 geometry_info.psi=0.5;
9799 if (attribute_flag[1] != 0)
9800 geometry_info.rho=argument_list[1].real_reference;
9801 if (attribute_flag[2] != 0)
9802 geometry_info.sigma=argument_list[2].real_reference;
9803 if (attribute_flag[3] != 0)
9804 geometry_info.xi=argument_list[3].real_reference;
9805 if (attribute_flag[4] != 0)
9806 geometry_info.psi=argument_list[4].real_reference;
9807 if (attribute_flag[5] != 0)
9808 channel=(ChannelType) argument_list[5].integer_reference;
9809 channel_mask=SetImageChannelMask(image,channel);
9810 image=UnsharpMaskImage(image,geometry_info.rho,geometry_info.sigma,
9811 geometry_info.xi,geometry_info.psi,exception);
9812 if (image != (Image *) NULL)
9813 (void) SetImageChannelMask(image,channel_mask);
9816 case 70: /* MotionBlur */
9818 if (attribute_flag[0] != 0)
9820 flags=ParseGeometry(argument_list[0].string_reference,
9822 if ((flags & SigmaValue) == 0)
9823 geometry_info.sigma=1.0;
9824 if ((flags & XiValue) == 0)
9825 geometry_info.xi=1.0;
9827 if (attribute_flag[1] != 0)
9828 geometry_info.rho=argument_list[1].real_reference;
9829 if (attribute_flag[2] != 0)
9830 geometry_info.sigma=argument_list[2].real_reference;
9831 if (attribute_flag[3] != 0)
9832 geometry_info.xi=argument_list[3].real_reference;
9833 if (attribute_flag[4] != 0)
9834 channel=(ChannelType) argument_list[4].integer_reference;
9835 channel_mask=SetImageChannelMask(image,channel);
9836 image=MotionBlurImage(image,geometry_info.rho,geometry_info.sigma,
9837 geometry_info.xi,exception);
9838 if (image != (Image *) NULL)
9839 (void) SetImageChannelMask(image,channel_mask);
9842 case 71: /* OrderedDither */
9844 if (attribute_flag[0] == 0)
9845 argument_list[0].string_reference="o8x8";
9846 if (attribute_flag[1] != 0)
9847 channel=(ChannelType) argument_list[1].integer_reference;
9848 channel_mask=SetImageChannelMask(image,channel);
9849 (void) OrderedDitherImage(image,argument_list[0].string_reference,
9851 (void) SetImageChannelMask(image,channel_mask);
9854 case 72: /* Shave */
9856 if (attribute_flag[0] != 0)
9857 flags=ParsePageGeometry(image,argument_list[0].string_reference,
9858 &geometry,exception);
9859 if (attribute_flag[1] != 0)
9860 geometry.width=argument_list[1].integer_reference;
9861 if (attribute_flag[2] != 0)
9862 geometry.height=argument_list[2].integer_reference;
9863 image=ShaveImage(image,&geometry,exception);
9866 case 73: /* Level */
9874 white_point=(double) image->columns*image->rows;
9876 if (attribute_flag[0] != 0)
9878 flags=ParseGeometry(argument_list[0].string_reference,
9880 black_point=geometry_info.rho;
9881 if ((flags & SigmaValue) != 0)
9882 white_point=geometry_info.sigma;
9883 if ((flags & XiValue) != 0)
9884 gamma=geometry_info.xi;
9885 if ((flags & PercentValue) != 0)
9887 black_point*=(double) (QuantumRange/100.0);
9888 white_point*=(double) (QuantumRange/100.0);
9890 if ((flags & SigmaValue) == 0)
9891 white_point=(double) QuantumRange-black_point;
9893 if (attribute_flag[1] != 0)
9894 black_point=argument_list[1].real_reference;
9895 if (attribute_flag[2] != 0)
9896 white_point=argument_list[2].real_reference;
9897 if (attribute_flag[3] != 0)
9898 gamma=argument_list[3].real_reference;
9899 if (attribute_flag[4] != 0)
9900 channel=(ChannelType) argument_list[4].integer_reference;
9901 if (attribute_flag[5] != 0)
9903 argument_list[0].real_reference=argument_list[5].real_reference;
9904 attribute_flag[0]=attribute_flag[5];
9906 channel_mask=SetImageChannelMask(image,channel);
9907 (void) LevelImage(image,black_point,white_point,gamma,exception);
9908 (void) SetImageChannelMask(image,channel_mask);
9913 if (attribute_flag[0] == 0)
9914 argument_list[0].string_reference="#1";
9915 if (attribute_flag[1] == 0)
9916 argument_list[1].integer_reference=MagickTrue;
9917 (void) ClipImagePath(image,argument_list[0].string_reference,
9918 argument_list[1].integer_reference != 0 ? MagickTrue : MagickFalse,
9922 case 75: /* AffineTransform */
9927 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
9929 if (attribute_flag[0] != 0)
9934 av=(AV *) argument_list[0].array_reference;
9935 if ((av_len(av) != 3) && (av_len(av) != 5))
9937 ThrowPerlException(exception,OptionError,
9938 "affine matrix must have 4 or 6 elements",PackageName);
9941 draw_info->affine.sx=(double) SvNV(*(av_fetch(av,0,0)));
9942 draw_info->affine.rx=(double) SvNV(*(av_fetch(av,1,0)));
9943 draw_info->affine.ry=(double) SvNV(*(av_fetch(av,2,0)));
9944 draw_info->affine.sy=(double) SvNV(*(av_fetch(av,3,0)));
9945 if (fabs(draw_info->affine.sx*draw_info->affine.sy-
9946 draw_info->affine.rx*draw_info->affine.ry) < MagickEpsilon)
9948 ThrowPerlException(exception,OptionError,
9949 "affine matrix is singular",PackageName);
9952 if (av_len(av) == 5)
9954 draw_info->affine.tx=(double) SvNV(*(av_fetch(av,4,0)));
9955 draw_info->affine.ty=(double) SvNV(*(av_fetch(av,5,0)));
9958 for (j=1; j < 6; j++)
9960 if (attribute_flag[j] == 0)
9962 value=argument_list[j].string_reference;
9963 angle=argument_list[j].real_reference;
9964 current=draw_info->affine;
9965 GetAffineMatrix(&affine);
9973 flags=ParseGeometry(value,&geometry_info);
9974 affine.tx=geometry_info.xi;
9975 affine.ty=geometry_info.psi;
9976 if ((flags & PsiValue) == 0)
9977 affine.ty=affine.tx;
9985 flags=ParseGeometry(value,&geometry_info);
9986 affine.sx=geometry_info.rho;
9987 affine.sy=geometry_info.sigma;
9988 if ((flags & SigmaValue) == 0)
9989 affine.sy=affine.sx;
9999 affine.sx=cos(DegreesToRadians(fmod(angle,360.0)));
10000 affine.rx=sin(DegreesToRadians(fmod(angle,360.0)));
10001 affine.ry=(-sin(DegreesToRadians(fmod(angle,360.0))));
10002 affine.sy=cos(DegreesToRadians(fmod(angle,360.0)));
10010 affine.ry=tan(DegreesToRadians(fmod(angle,360.0)));
10018 affine.rx=tan(DegreesToRadians(fmod(angle,360.0)));
10022 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
10023 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
10024 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
10025 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
10026 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+
10028 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+
10031 if (attribute_flag[6] != 0)
10032 image->interpolate=(PixelInterpolateMethod)
10033 argument_list[6].integer_reference;
10034 if (attribute_flag[7] != 0)
10035 QueryColorCompliance(argument_list[7].string_reference,
10036 AllCompliance,&image->background_color,exception);
10037 image=AffineTransformImage(image,&draw_info->affine,exception);
10038 draw_info=DestroyDrawInfo(draw_info);
10041 case 76: /* Difference */
10043 if (attribute_flag[0] == 0)
10045 ThrowPerlException(exception,OptionError,
10046 "ReferenceImageRequired",PackageName);
10047 goto PerlException;
10049 if (attribute_flag[1] != 0)
10050 image->fuzz=StringToDoubleInterval(
10051 argument_list[1].string_reference,(double) QuantumRange+1.0);
10052 (void) SetImageColorMetric(image,argument_list[0].image_reference,
10056 case 77: /* AdaptiveThreshold */
10058 if (attribute_flag[0] != 0)
10060 flags=ParseGeometry(argument_list[0].string_reference,
10062 if ((flags & PercentValue) != 0)
10063 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10065 if (attribute_flag[1] != 0)
10066 geometry_info.rho=argument_list[1].integer_reference;
10067 if (attribute_flag[2] != 0)
10068 geometry_info.sigma=argument_list[2].integer_reference;
10069 if (attribute_flag[3] != 0)
10070 geometry_info.xi=argument_list[3].integer_reference;;
10071 image=AdaptiveThresholdImage(image,(size_t) geometry_info.rho,
10072 (size_t) geometry_info.sigma,(double) geometry_info.xi,exception);
10075 case 78: /* Resample */
10081 if (attribute_flag[0] != 0)
10083 flags=ParseGeometry(argument_list[0].string_reference,
10085 if ((flags & SigmaValue) == 0)
10086 geometry_info.sigma=geometry_info.rho;
10088 if (attribute_flag[1] != 0)
10089 geometry_info.rho=argument_list[1].real_reference;
10090 if (attribute_flag[2] != 0)
10091 geometry_info.sigma=argument_list[2].real_reference;
10092 if (attribute_flag[3] == 0)
10093 argument_list[3].integer_reference=(ssize_t) UndefinedFilter;
10094 if (attribute_flag[4] == 0)
10095 SetImageArtifact(image,"filter:support",
10096 argument_list[4].string_reference);
10097 width=(size_t) (geometry_info.rho*image->columns/
10098 (image->resolution.x == 0.0 ? 72.0 : image->resolution.x)+0.5);
10099 height=(size_t) (geometry_info.sigma*image->rows/
10100 (image->resolution.y == 0.0 ? 72.0 : image->resolution.y)+0.5);
10101 image=ResizeImage(image,width,height,(FilterType)
10102 argument_list[3].integer_reference,exception);
10103 if (image != (Image *) NULL)
10105 image->resolution.x=geometry_info.rho;
10106 image->resolution.y=geometry_info.sigma;
10110 case 79: /* Describe */
10112 if (attribute_flag[0] == 0)
10113 argument_list[0].file_reference=(FILE *) NULL;
10114 if (attribute_flag[1] != 0)
10115 (void) SetImageArtifact(image,"identify:features",
10116 argument_list[1].string_reference);
10117 (void) IdentifyImage(image,argument_list[0].file_reference,
10118 MagickTrue,exception);
10121 case 80: /* BlackThreshold */
10123 if (attribute_flag[0] == 0)
10124 argument_list[0].string_reference="50%";
10125 if (attribute_flag[2] != 0)
10126 channel=(ChannelType) argument_list[2].integer_reference;
10127 channel_mask=SetImageChannelMask(image,channel);
10128 BlackThresholdImage(image,argument_list[0].string_reference,
10130 (void) SetImageChannelMask(image,channel_mask);
10133 case 81: /* WhiteThreshold */
10135 if (attribute_flag[0] == 0)
10136 argument_list[0].string_reference="50%";
10137 if (attribute_flag[2] != 0)
10138 channel=(ChannelType) argument_list[2].integer_reference;
10139 channel_mask=SetImageChannelMask(image,channel);
10140 WhiteThresholdImage(image,argument_list[0].string_reference,
10142 (void) SetImageChannelMask(image,channel_mask);
10145 case 82: /* RotationalBlur */
10147 if (attribute_flag[0] != 0)
10148 flags=ParseGeometry(argument_list[0].string_reference,
10150 if (attribute_flag[1] != 0)
10151 geometry_info.rho=argument_list[1].real_reference;
10152 if (attribute_flag[2] != 0)
10153 channel=(ChannelType) argument_list[2].integer_reference;
10154 channel_mask=SetImageChannelMask(image,channel);
10155 image=RotationalBlurImage(image,geometry_info.rho,exception);
10156 if (image != (Image *) NULL)
10157 (void) SetImageChannelMask(image,channel_mask);
10160 case 83: /* Thumbnail */
10162 if (attribute_flag[0] != 0)
10163 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10164 &geometry,exception);
10165 if (attribute_flag[1] != 0)
10166 geometry.width=argument_list[1].integer_reference;
10167 if (attribute_flag[2] != 0)
10168 geometry.height=argument_list[2].integer_reference;
10169 image=ThumbnailImage(image,geometry.width,geometry.height,exception);
10172 case 84: /* Strip */
10174 (void) StripImage(image,exception);
10177 case 85: /* Tint */
10182 GetPixelInfo(image,&tint);
10183 if (attribute_flag[0] != 0)
10184 (void) QueryColorCompliance(argument_list[0].string_reference,
10185 AllCompliance,&tint,exception);
10186 if (attribute_flag[1] == 0)
10187 argument_list[1].string_reference="100";
10188 image=TintImage(image,argument_list[1].string_reference,&tint,
10192 case 86: /* Channel */
10194 if (attribute_flag[0] != 0)
10195 channel=(ChannelType) argument_list[0].integer_reference;
10196 image=SeparateImage(image,channel,exception);
10199 case 87: /* Splice */
10201 if (attribute_flag[7] != 0)
10202 image->gravity=(GravityType) argument_list[7].integer_reference;
10203 if (attribute_flag[0] != 0)
10204 flags=ParseGravityGeometry(image,argument_list[0].string_reference,
10205 &geometry,exception);
10206 if (attribute_flag[1] != 0)
10207 geometry.width=argument_list[1].integer_reference;
10208 if (attribute_flag[2] != 0)
10209 geometry.height=argument_list[2].integer_reference;
10210 if (attribute_flag[3] != 0)
10211 geometry.x=argument_list[3].integer_reference;
10212 if (attribute_flag[4] != 0)
10213 geometry.y=argument_list[4].integer_reference;
10214 if (attribute_flag[5] != 0)
10215 image->fuzz=StringToDoubleInterval(
10216 argument_list[5].string_reference,(double) QuantumRange+1.0);
10217 if (attribute_flag[6] != 0)
10218 (void) QueryColorCompliance(argument_list[6].string_reference,
10219 AllCompliance,&image->background_color,exception);
10220 image=SpliceImage(image,&geometry,exception);
10223 case 88: /* Posterize */
10225 if (attribute_flag[0] == 0)
10226 argument_list[0].integer_reference=3;
10227 if (attribute_flag[1] == 0)
10228 argument_list[1].integer_reference=0;
10229 (void) PosterizeImage(image,argument_list[0].integer_reference,
10230 argument_list[1].integer_reference ? RiemersmaDitherMethod :
10231 NoDitherMethod,exception);
10234 case 89: /* Shadow */
10236 if (attribute_flag[0] != 0)
10238 flags=ParseGeometry(argument_list[0].string_reference,
10240 if ((flags & SigmaValue) == 0)
10241 geometry_info.sigma=1.0;
10242 if ((flags & XiValue) == 0)
10243 geometry_info.xi=4.0;
10244 if ((flags & PsiValue) == 0)
10245 geometry_info.psi=4.0;
10247 if (attribute_flag[1] != 0)
10248 geometry_info.rho=argument_list[1].real_reference;
10249 if (attribute_flag[2] != 0)
10250 geometry_info.sigma=argument_list[2].real_reference;
10251 if (attribute_flag[3] != 0)
10252 geometry_info.xi=argument_list[3].integer_reference;
10253 if (attribute_flag[4] != 0)
10254 geometry_info.psi=argument_list[4].integer_reference;
10255 image=ShadowImage(image,geometry_info.rho,geometry_info.sigma,
10256 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10257 ceil(geometry_info.psi-0.5),exception);
10260 case 90: /* Identify */
10262 if (attribute_flag[0] == 0)
10263 argument_list[0].file_reference=(FILE *) NULL;
10264 if (attribute_flag[1] != 0)
10265 (void) SetImageArtifact(image,"identify:features",
10266 argument_list[1].string_reference);
10267 if ((attribute_flag[2] != 0) &&
10268 (argument_list[2].integer_reference != 0))
10269 (void) SetImageArtifact(image,"identify:unique","true");
10270 (void) IdentifyImage(image,argument_list[0].file_reference,
10271 MagickTrue,exception);
10274 case 91: /* SepiaTone */
10276 if (attribute_flag[0] == 0)
10277 argument_list[0].real_reference=80.0*QuantumRange/100.0;
10278 image=SepiaToneImage(image,argument_list[0].real_reference,exception);
10281 case 92: /* SigmoidalContrast */
10286 if (attribute_flag[0] != 0)
10288 flags=ParseGeometry(argument_list[0].string_reference,
10290 if ((flags & SigmaValue) == 0)
10291 geometry_info.sigma=QuantumRange/2.0;
10292 if ((flags & PercentValue) != 0)
10293 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
10295 if (attribute_flag[1] != 0)
10296 geometry_info.rho=argument_list[1].real_reference;
10297 if (attribute_flag[2] != 0)
10298 geometry_info.sigma=argument_list[2].real_reference;
10299 if (attribute_flag[3] != 0)
10300 channel=(ChannelType) argument_list[3].integer_reference;
10301 sharpen=MagickTrue;
10302 if (attribute_flag[4] != 0)
10303 sharpen=argument_list[4].integer_reference != 0 ? MagickTrue :
10305 channel_mask=SetImageChannelMask(image,channel);
10306 (void) SigmoidalContrastImage(image,sharpen,geometry_info.rho,
10307 geometry_info.sigma,exception);
10308 (void) SetImageChannelMask(image,channel_mask);
10311 case 93: /* Extent */
10313 if (attribute_flag[7] != 0)
10314 image->gravity=(GravityType) argument_list[7].integer_reference;
10315 if (attribute_flag[0] != 0)
10320 flags=ParseGravityGeometry(image,
10321 argument_list[0].string_reference,&geometry,exception);
10323 if (geometry.width == 0)
10324 geometry.width=image->columns;
10325 if (geometry.height == 0)
10326 geometry.height=image->rows;
10328 if (attribute_flag[1] != 0)
10329 geometry.width=argument_list[1].integer_reference;
10330 if (attribute_flag[2] != 0)
10331 geometry.height=argument_list[2].integer_reference;
10332 if (attribute_flag[3] != 0)
10333 geometry.x=argument_list[3].integer_reference;
10334 if (attribute_flag[4] != 0)
10335 geometry.y=argument_list[4].integer_reference;
10336 if (attribute_flag[5] != 0)
10337 image->fuzz=StringToDoubleInterval(
10338 argument_list[5].string_reference,(double) QuantumRange+1.0);
10339 if (attribute_flag[6] != 0)
10340 (void) QueryColorCompliance(argument_list[6].string_reference,
10341 AllCompliance,&image->background_color,exception);
10342 image=ExtentImage(image,&geometry,exception);
10345 case 94: /* Vignette */
10347 if (attribute_flag[0] != 0)
10349 flags=ParseGeometry(argument_list[0].string_reference,
10351 if ((flags & SigmaValue) == 0)
10352 geometry_info.sigma=1.0;
10353 if ((flags & XiValue) == 0)
10354 geometry_info.xi=0.1*image->columns;
10355 if ((flags & PsiValue) == 0)
10356 geometry_info.psi=0.1*image->rows;
10358 if (attribute_flag[1] != 0)
10359 geometry_info.rho=argument_list[1].real_reference;
10360 if (attribute_flag[2] != 0)
10361 geometry_info.sigma=argument_list[2].real_reference;
10362 if (attribute_flag[3] != 0)
10363 geometry_info.xi=argument_list[3].integer_reference;
10364 if (attribute_flag[4] != 0)
10365 geometry_info.psi=argument_list[4].integer_reference;
10366 if (attribute_flag[5] != 0)
10367 (void) QueryColorCompliance(argument_list[5].string_reference,
10368 AllCompliance,&image->background_color,exception);
10369 image=VignetteImage(image,geometry_info.rho,geometry_info.sigma,
10370 (ssize_t) ceil(geometry_info.xi-0.5),(ssize_t)
10371 ceil(geometry_info.psi-0.5),exception);
10374 case 95: /* ContrastStretch */
10381 white_point=(double) image->columns*image->rows;
10382 if (attribute_flag[0] != 0)
10384 flags=ParseGeometry(argument_list[0].string_reference,
10386 black_point=geometry_info.rho;
10387 white_point=(flags & SigmaValue) != 0 ? geometry_info.sigma :
10389 if ((flags & PercentValue) != 0)
10391 black_point*=(double) image->columns*image->rows/100.0;
10392 white_point*=(double) image->columns*image->rows/100.0;
10394 white_point=(double) image->columns*image->rows-white_point;
10396 if (attribute_flag[1] != 0)
10397 black_point=argument_list[1].real_reference;
10398 if (attribute_flag[2] != 0)
10399 white_point=argument_list[2].real_reference;
10400 if (attribute_flag[4] != 0)
10401 channel=(ChannelType) argument_list[4].integer_reference;
10402 channel_mask=SetImageChannelMask(image,channel);
10403 (void) ContrastStretchImage(image,black_point,white_point,exception);
10404 (void) SetImageChannelMask(image,channel_mask);
10407 case 96: /* Sans0 */
10411 case 97: /* Sans1 */
10415 case 98: /* AdaptiveSharpen */
10417 if (attribute_flag[0] != 0)
10419 flags=ParseGeometry(argument_list[0].string_reference,
10421 if ((flags & SigmaValue) == 0)
10422 geometry_info.sigma=1.0;
10423 if ((flags & XiValue) == 0)
10424 geometry_info.xi=0.0;
10426 if (attribute_flag[1] != 0)
10427 geometry_info.rho=argument_list[1].real_reference;
10428 if (attribute_flag[2] != 0)
10429 geometry_info.sigma=argument_list[2].real_reference;
10430 if (attribute_flag[3] != 0)
10431 geometry_info.xi=argument_list[3].real_reference;
10432 if (attribute_flag[4] != 0)
10433 channel=(ChannelType) argument_list[4].integer_reference;
10434 channel_mask=SetImageChannelMask(image,channel);
10435 image=AdaptiveSharpenImage(image,geometry_info.rho,
10436 geometry_info.sigma,exception);
10437 if (image != (Image *) NULL)
10438 (void) SetImageChannelMask(image,channel_mask);
10441 case 99: /* Transpose */
10443 image=TransposeImage(image,exception);
10446 case 100: /* Tranverse */
10448 image=TransverseImage(image,exception);
10451 case 101: /* AutoOrient */
10453 image=AutoOrientImage(image,image->orientation,exception);
10456 case 102: /* AdaptiveBlur */
10458 if (attribute_flag[0] != 0)
10460 flags=ParseGeometry(argument_list[0].string_reference,
10462 if ((flags & SigmaValue) == 0)
10463 geometry_info.sigma=1.0;
10464 if ((flags & XiValue) == 0)
10465 geometry_info.xi=0.0;
10467 if (attribute_flag[1] != 0)
10468 geometry_info.rho=argument_list[1].real_reference;
10469 if (attribute_flag[2] != 0)
10470 geometry_info.sigma=argument_list[2].real_reference;
10471 if (attribute_flag[3] != 0)
10472 channel=(ChannelType) argument_list[3].integer_reference;
10473 channel_mask=SetImageChannelMask(image,channel);
10474 image=AdaptiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10476 if (image != (Image *) NULL)
10477 (void) SetImageChannelMask(image,channel_mask);
10480 case 103: /* Sketch */
10482 if (attribute_flag[0] != 0)
10484 flags=ParseGeometry(argument_list[0].string_reference,
10486 if ((flags & SigmaValue) == 0)
10487 geometry_info.sigma=1.0;
10488 if ((flags & XiValue) == 0)
10489 geometry_info.xi=1.0;
10491 if (attribute_flag[1] != 0)
10492 geometry_info.rho=argument_list[1].real_reference;
10493 if (attribute_flag[2] != 0)
10494 geometry_info.sigma=argument_list[2].real_reference;
10495 if (attribute_flag[3] != 0)
10496 geometry_info.xi=argument_list[3].real_reference;
10497 image=SketchImage(image,geometry_info.rho,geometry_info.sigma,
10498 geometry_info.xi,exception);
10501 case 104: /* UniqueColors */
10503 image=UniqueImageColors(image,exception);
10506 case 105: /* AdaptiveResize */
10508 if (attribute_flag[0] != 0)
10509 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10510 &geometry,exception);
10511 if (attribute_flag[1] != 0)
10512 geometry.width=argument_list[1].integer_reference;
10513 if (attribute_flag[2] != 0)
10514 geometry.height=argument_list[2].integer_reference;
10515 if (attribute_flag[3] != 0)
10516 image->filter=(FilterType) argument_list[4].integer_reference;
10517 if (attribute_flag[4] != 0)
10518 SetImageArtifact(image,"filter:support",
10519 argument_list[4].string_reference);
10520 image=AdaptiveResizeImage(image,geometry.width,geometry.height,
10524 case 106: /* ClipMask */
10529 if (attribute_flag[0] == 0)
10531 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10533 goto PerlException;
10535 mask_image=CloneImage(argument_list[0].image_reference,0,0,MagickTrue,
10537 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10538 mask_image=DestroyImage(mask_image);
10541 case 107: /* LinearStretch */
10548 white_point=(double) image->columns*image->rows;
10549 if (attribute_flag[0] != 0)
10551 flags=ParseGeometry(argument_list[0].string_reference,
10553 if ((flags & SigmaValue) != 0)
10554 white_point=geometry_info.sigma;
10555 if ((flags & PercentValue) != 0)
10557 black_point*=(double) image->columns*image->rows/100.0;
10558 white_point*=(double) image->columns*image->rows/100.0;
10560 if ((flags & SigmaValue) == 0)
10561 white_point=(double) image->columns*image->rows-black_point;
10563 if (attribute_flag[1] != 0)
10564 black_point=argument_list[1].real_reference;
10565 if (attribute_flag[2] != 0)
10566 white_point=argument_list[2].real_reference;
10567 (void) LinearStretchImage(image,black_point,white_point,exception);
10570 case 108: /* ColorMatrix */
10584 if (attribute_flag[0] == 0)
10586 av=(AV *) argument_list[0].array_reference;
10587 order=(size_t) sqrt(av_len(av)+1);
10588 color_matrix=(double *) AcquireQuantumMemory(order,order*
10589 sizeof(*color_matrix));
10590 if (color_matrix == (double *) NULL)
10592 ThrowPerlException(exception,ResourceLimitFatalError,
10593 "MemoryAllocationFailed",PackageName);
10594 goto PerlException;
10596 for (j=0; (j < (ssize_t) (order*order)) && (j < (av_len(av)+1)); j++)
10597 color_matrix[j]=(double) SvNV(*(av_fetch(av,j,0)));
10598 for ( ; j < (ssize_t) (order*order); j++)
10599 color_matrix[j]=0.0;
10600 kernel_info=AcquireKernelInfo((const char *) NULL,exception);
10601 if (kernel_info == (KernelInfo *) NULL)
10603 kernel_info->width=order;
10604 kernel_info->height=order;
10605 kernel_info->values=(MagickRealType *) AcquireAlignedMemory(order,
10606 order*sizeof(*kernel_info->values));
10607 if (kernel_info->values != (MagickRealType *) NULL)
10609 for (i=0; i < (ssize_t) (order*order); i++)
10610 kernel_info->values[i]=(MagickRealType) color_matrix[i];
10611 image=ColorMatrixImage(image,kernel_info,exception);
10613 kernel_info=DestroyKernelInfo(kernel_info);
10614 color_matrix=(double *) RelinquishMagickMemory(color_matrix);
10617 case 109: /* Mask */
10622 if (attribute_flag[0] == 0)
10624 ThrowPerlException(exception,OptionError,"MaskImageRequired",
10626 goto PerlException;
10628 mask_image=CloneImage(argument_list[0].image_reference,0,0,
10629 MagickTrue,exception);
10630 (void) SetImageMask(image,ReadPixelMask,mask_image,exception);
10631 mask_image=DestroyImage(mask_image);
10634 case 110: /* Polaroid */
10645 PixelInterpolateMethod
10648 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10649 (DrawInfo *) NULL);
10650 caption=(char *) NULL;
10651 if (attribute_flag[0] != 0)
10652 caption=InterpretImageProperties(info ? info->image_info :
10653 (ImageInfo *) NULL,image,argument_list[0].string_reference,
10656 if (attribute_flag[1] != 0)
10657 angle=argument_list[1].real_reference;
10658 if (attribute_flag[2] != 0)
10659 (void) CloneString(&draw_info->font,
10660 argument_list[2].string_reference);
10661 if (attribute_flag[3] != 0)
10662 (void) QueryColorCompliance(argument_list[3].string_reference,
10663 AllCompliance,&draw_info->stroke,exception);
10664 if (attribute_flag[4] != 0)
10665 (void) QueryColorCompliance(argument_list[4].string_reference,
10666 AllCompliance,&draw_info->fill,exception);
10667 if (attribute_flag[5] != 0)
10668 draw_info->stroke_width=argument_list[5].real_reference;
10669 if (attribute_flag[6] != 0)
10670 draw_info->pointsize=argument_list[6].real_reference;
10671 if (attribute_flag[7] != 0)
10672 draw_info->gravity=(GravityType) argument_list[7].integer_reference;
10673 if (attribute_flag[8] != 0)
10674 (void) QueryColorCompliance(argument_list[8].string_reference,
10675 AllCompliance,&image->background_color,exception);
10676 method=UndefinedInterpolatePixel;
10677 if (attribute_flag[9] != 0)
10678 method=(PixelInterpolateMethod) argument_list[9].integer_reference;
10679 image=PolaroidImage(image,draw_info,caption,angle,method,exception);
10680 draw_info=DestroyDrawInfo(draw_info);
10681 if (caption != (char *) NULL)
10682 caption=DestroyString(caption);
10685 case 111: /* FloodfillPaint */
10696 draw_info=CloneDrawInfo(info ? info->image_info : (ImageInfo *) NULL,
10697 (DrawInfo *) NULL);
10698 if (attribute_flag[0] != 0)
10699 flags=ParsePageGeometry(image,argument_list[0].string_reference,
10700 &geometry,exception);
10701 if (attribute_flag[1] != 0)
10702 geometry.x=argument_list[1].integer_reference;
10703 if (attribute_flag[2] != 0)
10704 geometry.y=argument_list[2].integer_reference;
10705 if (attribute_flag[3] != 0)
10706 (void) QueryColorCompliance(argument_list[3].string_reference,
10707 AllCompliance,&draw_info->fill,exception);
10708 (void) GetOneVirtualPixelInfo(image,UndefinedVirtualPixelMethod,
10709 geometry.x,geometry.y,&target,exception);
10710 if (attribute_flag[4] != 0)
10711 QueryColorCompliance(argument_list[4].string_reference,
10712 AllCompliance,&target,exception);
10713 if (attribute_flag[5] != 0)
10714 image->fuzz=StringToDoubleInterval(
10715 argument_list[5].string_reference,(double) QuantumRange+1.0);
10716 if (attribute_flag[6] != 0)
10717 channel=(ChannelType) argument_list[6].integer_reference;
10718 invert=MagickFalse;
10719 if (attribute_flag[7] != 0)
10720 invert=(MagickBooleanType) argument_list[7].integer_reference;
10721 channel_mask=SetImageChannelMask(image,channel);
10722 (void) FloodfillPaintImage(image,draw_info,&target,geometry.x,
10723 geometry.y,invert,exception);
10724 (void) SetImageChannelMask(image,channel_mask);
10725 draw_info=DestroyDrawInfo(draw_info);
10728 case 112: /* Distort */
10740 number_coordinates;
10745 if (attribute_flag[0] == 0)
10747 method=UndefinedDistortion;
10748 if (attribute_flag[1] != 0)
10749 method=(DistortMethod) argument_list[1].integer_reference;
10750 av=(AV *) argument_list[0].array_reference;
10751 number_coordinates=(size_t) av_len(av)+1;
10752 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10753 sizeof(*coordinates));
10754 if (coordinates == (double *) NULL)
10756 ThrowPerlException(exception,ResourceLimitFatalError,
10757 "MemoryAllocationFailed",PackageName);
10758 goto PerlException;
10760 for (j=0; j < (ssize_t) number_coordinates; j++)
10761 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10762 virtual_pixel=UndefinedVirtualPixelMethod;
10763 if (attribute_flag[2] != 0)
10764 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10765 argument_list[2].integer_reference,exception);
10766 image=DistortImage(image,method,number_coordinates,coordinates,
10767 argument_list[3].integer_reference != 0 ? MagickTrue : MagickFalse,
10769 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10770 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10772 coordinates=(double *) RelinquishMagickMemory(coordinates);
10775 case 113: /* Clut */
10777 PixelInterpolateMethod
10780 if (attribute_flag[0] == 0)
10782 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10784 goto PerlException;
10786 method=UndefinedInterpolatePixel;
10787 if (attribute_flag[1] != 0)
10788 method=(PixelInterpolateMethod) argument_list[1].integer_reference;
10789 if (attribute_flag[2] != 0)
10790 channel=(ChannelType) argument_list[2].integer_reference;
10791 channel_mask=SetImageChannelMask(image,channel);
10792 (void) ClutImage(image,argument_list[0].image_reference,method,
10794 (void) SetImageChannelMask(image,channel_mask);
10797 case 114: /* LiquidRescale */
10799 if (attribute_flag[0] != 0)
10800 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
10801 &geometry,exception);
10802 if (attribute_flag[1] != 0)
10803 geometry.width=argument_list[1].integer_reference;
10804 if (attribute_flag[2] != 0)
10805 geometry.height=argument_list[2].integer_reference;
10806 if (attribute_flag[3] == 0)
10807 argument_list[3].real_reference=1.0;
10808 if (attribute_flag[4] == 0)
10809 argument_list[4].real_reference=0.0;
10810 image=LiquidRescaleImage(image,geometry.width,geometry.height,
10811 argument_list[3].real_reference,argument_list[4].real_reference,
10815 case 115: /* EncipherImage */
10817 (void) EncipherImage(image,argument_list[0].string_reference,
10821 case 116: /* DecipherImage */
10823 (void) DecipherImage(image,argument_list[0].string_reference,
10827 case 117: /* Deskew */
10829 geometry_info.rho=QuantumRange/2.0;
10830 if (attribute_flag[0] != 0)
10831 flags=ParseGeometry(argument_list[0].string_reference,
10833 if (attribute_flag[1] != 0)
10834 geometry_info.rho=StringToDoubleInterval(
10835 argument_list[1].string_reference,(double) QuantumRange+1.0);
10836 image=DeskewImage(image,geometry_info.rho,exception);
10839 case 118: /* Remap */
10844 if (attribute_flag[0] == 0)
10846 ThrowPerlException(exception,OptionError,"RemapImageRequired",
10848 goto PerlException;
10850 quantize_info=AcquireQuantizeInfo(info->image_info);
10851 if (attribute_flag[1] != 0)
10852 quantize_info->dither_method=(DitherMethod)
10853 argument_list[1].integer_reference;
10854 (void) RemapImages(quantize_info,image,
10855 argument_list[0].image_reference,exception);
10856 quantize_info=DestroyQuantizeInfo(quantize_info);
10859 case 119: /* SparseColor */
10868 number_coordinates;
10876 if (attribute_flag[0] == 0)
10878 method=UndefinedColorInterpolate;
10879 if (attribute_flag[1] != 0)
10880 method=(SparseColorMethod) argument_list[1].integer_reference;
10881 av=(AV *) argument_list[0].array_reference;
10882 number_coordinates=(size_t) av_len(av)+1;
10883 coordinates=(double *) AcquireQuantumMemory(number_coordinates,
10884 sizeof(*coordinates));
10885 if (coordinates == (double *) NULL)
10887 ThrowPerlException(exception,ResourceLimitFatalError,
10888 "MemoryAllocationFailed",PackageName);
10889 goto PerlException;
10891 for (j=0; j < (ssize_t) number_coordinates; j++)
10892 coordinates[j]=(double) SvNV(*(av_fetch(av,j,0)));
10893 virtual_pixel=UndefinedVirtualPixelMethod;
10894 if (attribute_flag[2] != 0)
10895 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10896 argument_list[2].integer_reference,exception);
10897 if (attribute_flag[3] != 0)
10898 channel=(ChannelType) argument_list[3].integer_reference;
10899 channel_mask=SetImageChannelMask(image,channel);
10900 image=SparseColorImage(image,method,number_coordinates,coordinates,
10902 if (image != (Image *) NULL)
10903 (void) SetImageChannelMask(image,channel_mask);
10904 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10905 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10907 coordinates=(double *) RelinquishMagickMemory(coordinates);
10910 case 120: /* Function */
10927 if (attribute_flag[0] == 0)
10929 function=UndefinedFunction;
10930 if (attribute_flag[1] != 0)
10931 function=(MagickFunction) argument_list[1].integer_reference;
10932 av=(AV *) argument_list[0].array_reference;
10933 number_parameters=(size_t) av_len(av)+1;
10934 parameters=(double *) AcquireQuantumMemory(number_parameters,
10935 sizeof(*parameters));
10936 if (parameters == (double *) NULL)
10938 ThrowPerlException(exception,ResourceLimitFatalError,
10939 "MemoryAllocationFailed",PackageName);
10940 goto PerlException;
10942 for (j=0; j < (ssize_t) number_parameters; j++)
10943 parameters[j]=(double) SvNV(*(av_fetch(av,j,0)));
10944 virtual_pixel=UndefinedVirtualPixelMethod;
10945 if (attribute_flag[2] != 0)
10946 virtual_pixel=SetImageVirtualPixelMethod(image,(VirtualPixelMethod)
10947 argument_list[2].integer_reference,exception);
10948 (void) FunctionImage(image,function,number_parameters,parameters,
10950 if ((attribute_flag[2] != 0) && (image != (Image *) NULL))
10951 virtual_pixel=SetImageVirtualPixelMethod(image,virtual_pixel,
10953 parameters=(double *) RelinquishMagickMemory(parameters);
10956 case 121: /* SelectiveBlur */
10958 if (attribute_flag[0] != 0)
10960 flags=ParseGeometry(argument_list[0].string_reference,
10962 if ((flags & SigmaValue) == 0)
10963 geometry_info.sigma=1.0;
10964 if ((flags & PercentValue) != 0)
10965 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
10967 if (attribute_flag[1] != 0)
10968 geometry_info.rho=argument_list[1].real_reference;
10969 if (attribute_flag[2] != 0)
10970 geometry_info.sigma=argument_list[2].real_reference;
10971 if (attribute_flag[3] != 0)
10972 geometry_info.xi=argument_list[3].integer_reference;;
10973 if (attribute_flag[5] != 0)
10974 channel=(ChannelType) argument_list[5].integer_reference;
10975 channel_mask=SetImageChannelMask(image,channel);
10976 image=SelectiveBlurImage(image,geometry_info.rho,geometry_info.sigma,
10977 geometry_info.xi,exception);
10978 if (image != (Image *) NULL)
10979 (void) SetImageChannelMask(image,channel_mask);
10982 case 122: /* HaldClut */
10984 if (attribute_flag[0] == 0)
10986 ThrowPerlException(exception,OptionError,"ClutImageRequired",
10988 goto PerlException;
10990 if (attribute_flag[1] != 0)
10991 channel=(ChannelType) argument_list[1].integer_reference;
10992 channel_mask=SetImageChannelMask(image,channel);
10993 (void) HaldClutImage(image,argument_list[0].image_reference,
10995 (void) SetImageChannelMask(image,channel_mask);
10998 case 123: /* BlueShift */
11000 if (attribute_flag[0] != 0)
11001 (void) ParseGeometry(argument_list[0].string_reference,
11003 image=BlueShiftImage(image,geometry_info.rho,exception);
11006 case 124: /* ForwardFourierTransformImage */
11008 image=ForwardFourierTransformImage(image,
11009 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
11013 case 125: /* InverseFourierTransformImage */
11015 image=InverseFourierTransformImage(image,image->next,
11016 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
11020 case 126: /* ColorDecisionList */
11022 if (attribute_flag[0] == 0)
11023 argument_list[0].string_reference=(char *) NULL;
11024 (void) ColorDecisionListImage(image,
11025 argument_list[0].string_reference,exception);
11028 case 127: /* AutoGamma */
11030 if (attribute_flag[0] != 0)
11031 channel=(ChannelType) argument_list[0].integer_reference;
11032 channel_mask=SetImageChannelMask(image,channel);
11033 (void) AutoGammaImage(image,exception);
11034 (void) SetImageChannelMask(image,channel_mask);
11037 case 128: /* AutoLevel */
11039 if (attribute_flag[0] != 0)
11040 channel=(ChannelType) argument_list[0].integer_reference;
11041 channel_mask=SetImageChannelMask(image,channel);
11042 (void) AutoLevelImage(image,exception);
11043 (void) SetImageChannelMask(image,channel_mask);
11046 case 129: /* LevelColors */
11052 (void) QueryColorCompliance("#000000",AllCompliance,&black_point,
11054 (void) QueryColorCompliance("#ffffff",AllCompliance,&white_point,
11056 if (attribute_flag[1] != 0)
11057 (void) QueryColorCompliance(
11058 argument_list[1].string_reference,AllCompliance,&black_point,
11060 if (attribute_flag[2] != 0)
11061 (void) QueryColorCompliance(
11062 argument_list[2].string_reference,AllCompliance,&white_point,
11064 if (attribute_flag[3] != 0)
11065 channel=(ChannelType) argument_list[3].integer_reference;
11066 channel_mask=SetImageChannelMask(image,channel);
11067 (void) LevelImageColors(image,&black_point,&white_point,
11068 argument_list[0].integer_reference != 0 ? MagickTrue : MagickFalse,
11070 (void) SetImageChannelMask(image,channel_mask);
11073 case 130: /* Clamp */
11075 if (attribute_flag[0] != 0)
11076 channel=(ChannelType) argument_list[0].integer_reference;
11077 channel_mask=SetImageChannelMask(image,channel);
11078 (void) ClampImage(image,exception);
11079 (void) SetImageChannelMask(image,channel_mask);
11082 case 131: /* BrightnessContrast */
11090 if (attribute_flag[0] != 0)
11092 flags=ParseGeometry(argument_list[0].string_reference,
11094 brightness=geometry_info.rho;
11095 if ((flags & SigmaValue) == 0)
11096 contrast=geometry_info.sigma;
11098 if (attribute_flag[1] != 0)
11099 brightness=argument_list[1].real_reference;
11100 if (attribute_flag[2] != 0)
11101 contrast=argument_list[2].real_reference;
11102 if (attribute_flag[4] != 0)
11103 channel=(ChannelType) argument_list[4].integer_reference;
11104 channel_mask=SetImageChannelMask(image,channel);
11105 (void) BrightnessContrastImage(image,brightness,contrast,exception);
11106 (void) SetImageChannelMask(image,channel_mask);
11109 case 132: /* Morphology */
11120 if (attribute_flag[0] == 0)
11122 kernel=AcquireKernelInfo(argument_list[0].string_reference,exception);
11123 if (kernel == (KernelInfo *) NULL)
11125 if (attribute_flag[1] != 0)
11126 channel=(ChannelType) argument_list[1].integer_reference;
11127 method=UndefinedMorphology;
11128 if (attribute_flag[2] != 0)
11129 method=argument_list[2].integer_reference;
11131 if (attribute_flag[3] != 0)
11132 iterations=argument_list[3].integer_reference;
11133 channel_mask=SetImageChannelMask(image,channel);
11134 image=MorphologyImage(image,method,iterations,kernel,exception);
11135 if (image != (Image *) NULL)
11136 (void) SetImageChannelMask(image,channel_mask);
11137 kernel=DestroyKernelInfo(kernel);
11140 case 133: /* Mode */
11142 if (attribute_flag[0] != 0)
11144 flags=ParseGeometry(argument_list[0].string_reference,
11146 if ((flags & SigmaValue) == 0)
11147 geometry_info.sigma=1.0;
11149 if (attribute_flag[1] != 0)
11150 geometry_info.rho=argument_list[1].real_reference;
11151 if (attribute_flag[2] != 0)
11152 geometry_info.sigma=argument_list[2].real_reference;
11153 if (attribute_flag[3] != 0)
11154 channel=(ChannelType) argument_list[3].integer_reference;
11155 channel_mask=SetImageChannelMask(image,channel);
11156 image=StatisticImage(image,ModeStatistic,(size_t) geometry_info.rho,
11157 (size_t) geometry_info.sigma,exception);
11158 if (image != (Image *) NULL)
11159 (void) SetImageChannelMask(image,channel_mask);
11162 case 134: /* Statistic */
11167 statistic=UndefinedStatistic;
11168 if (attribute_flag[0] != 0)
11170 flags=ParseGeometry(argument_list[0].string_reference,
11172 if ((flags & SigmaValue) == 0)
11173 geometry_info.sigma=1.0;
11175 if (attribute_flag[1] != 0)
11176 geometry_info.rho=argument_list[1].real_reference;
11177 if (attribute_flag[2] != 0)
11178 geometry_info.sigma=argument_list[2].real_reference;
11179 if (attribute_flag[3] != 0)
11180 channel=(ChannelType) argument_list[3].integer_reference;
11181 if (attribute_flag[4] != 0)
11182 statistic=(StatisticType) argument_list[4].integer_reference;
11183 channel_mask=SetImageChannelMask(image,channel);
11184 image=StatisticImage(image,statistic,(size_t) geometry_info.rho,
11185 (size_t) geometry_info.sigma,exception);
11186 if (image != (Image *) NULL)
11187 (void) SetImageChannelMask(image,channel_mask);
11190 case 135: /* Perceptible */
11195 epsilon=MagickEpsilon;
11196 if (attribute_flag[0] != 0)
11197 epsilon=argument_list[0].real_reference;
11198 if (attribute_flag[1] != 0)
11199 channel=(ChannelType) argument_list[1].integer_reference;
11200 channel_mask=SetImageChannelMask(image,channel);
11201 (void) PerceptibleImage(image,epsilon,exception);
11202 (void) SetImageChannelMask(image,channel_mask);
11205 case 136: /* Poly */
11216 if (attribute_flag[0] == 0)
11218 if (attribute_flag[1] != 0)
11219 channel=(ChannelType) argument_list[1].integer_reference;
11220 av=(AV *) argument_list[0].array_reference;
11221 number_terms=(size_t) av_len(av);
11222 terms=(double *) AcquireQuantumMemory(number_terms,sizeof(*terms));
11223 if (terms == (double *) NULL)
11225 ThrowPerlException(exception,ResourceLimitFatalError,
11226 "MemoryAllocationFailed",PackageName);
11227 goto PerlException;
11229 for (j=0; j < av_len(av); j++)
11230 terms[j]=(double) SvNV(*(av_fetch(av,j,0)));
11231 image=PolynomialImage(image,number_terms >> 1,terms,exception);
11232 terms=(double *) RelinquishMagickMemory(terms);
11235 case 137: /* Grayscale */
11237 PixelIntensityMethod
11240 method=UndefinedPixelIntensityMethod;
11241 if (attribute_flag[0] != 0)
11242 method=(PixelIntensityMethod) argument_list[0].integer_reference;
11243 (void) GrayscaleImage(image,method,exception);
11246 case 138: /* Canny */
11248 if (attribute_flag[0] != 0)
11250 flags=ParseGeometry(argument_list[0].string_reference,
11252 if ((flags & SigmaValue) == 0)
11253 geometry_info.sigma=1.0;
11254 if ((flags & XiValue) == 0)
11255 geometry_info.xi=0.10;
11256 if ((flags & PsiValue) == 0)
11257 geometry_info.psi=0.30;
11258 if ((flags & PercentValue) != 0)
11260 geometry_info.xi/=100.0;
11261 geometry_info.psi/=100.0;
11264 if (attribute_flag[1] != 0)
11265 geometry_info.rho=argument_list[1].real_reference;
11266 if (attribute_flag[2] != 0)
11267 geometry_info.sigma=argument_list[2].real_reference;
11268 if (attribute_flag[3] != 0)
11269 geometry_info.xi=argument_list[3].real_reference;
11270 if (attribute_flag[4] != 0)
11271 geometry_info.psi=argument_list[4].real_reference;
11272 if (attribute_flag[5] != 0)
11273 channel=(ChannelType) argument_list[5].integer_reference;
11274 channel_mask=SetImageChannelMask(image,channel);
11275 image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
11276 geometry_info.xi,geometry_info.psi,exception);
11277 if (image != (Image *) NULL)
11278 (void) SetImageChannelMask(image,channel_mask);
11281 case 139: /* HoughLine */
11283 if (attribute_flag[0] != 0)
11285 flags=ParseGeometry(argument_list[0].string_reference,
11287 if ((flags & SigmaValue) == 0)
11288 geometry_info.sigma=geometry_info.rho;
11289 if ((flags & XiValue) == 0)
11290 geometry_info.xi=40;
11292 if (attribute_flag[1] != 0)
11293 geometry_info.rho=(double) argument_list[1].integer_reference;
11294 if (attribute_flag[2] != 0)
11295 geometry_info.sigma=(double) argument_list[2].integer_reference;
11296 if (attribute_flag[3] != 0)
11297 geometry_info.xi=(double) argument_list[3].integer_reference;
11298 image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
11299 geometry_info.sigma,(size_t) geometry_info.xi,exception);
11302 case 140: /* MeanShift */
11304 if (attribute_flag[0] != 0)
11306 flags=ParseGeometry(argument_list[0].string_reference,
11308 if ((flags & SigmaValue) == 0)
11309 geometry_info.sigma=geometry_info.rho;
11310 if ((flags & XiValue) == 0)
11311 geometry_info.xi=0.10*QuantumRange;
11312 if ((flags & PercentValue) != 0)
11313 geometry_info.xi=QuantumRange*geometry_info.xi/100.0;
11315 if (attribute_flag[1] != 0)
11316 geometry_info.rho=(double) argument_list[1].integer_reference;
11317 if (attribute_flag[2] != 0)
11318 geometry_info.sigma=(double) argument_list[2].integer_reference;
11319 if (attribute_flag[3] != 0)
11320 geometry_info.xi=(double) argument_list[3].integer_reference;
11321 image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
11322 geometry_info.sigma,geometry_info.xi,exception);
11325 case 141: /* Kuwahara */
11327 if (attribute_flag[0] != 0)
11329 flags=ParseGeometry(argument_list[0].string_reference,
11331 if ((flags & SigmaValue) == 0)
11332 geometry_info.sigma=geometry_info.rho-0.5;
11334 if (attribute_flag[1] != 0)
11335 geometry_info.rho=argument_list[1].real_reference;
11336 if (attribute_flag[2] != 0)
11337 geometry_info.sigma=argument_list[2].real_reference;
11338 if (attribute_flag[3] != 0)
11339 channel=(ChannelType) argument_list[3].integer_reference;
11340 channel_mask=SetImageChannelMask(image,channel);
11341 image=KuwaharaImage(image,geometry_info.rho,geometry_info.sigma,
11343 if (image != (Image *) NULL)
11344 (void) SetImageChannelMask(image,channel_mask);
11347 case 142: /* ConnectedComponents */
11353 if (attribute_flag[0] != 0)
11354 connectivity=argument_list[0].integer_reference;
11355 image=ConnectedComponentsImage(image,connectivity,
11356 (CCObjectInfo **) NULL,exception);
11359 case 143: /* Copy */
11370 source_image=image;
11371 if (attribute_flag[0] != 0)
11372 source_image=argument_list[0].image_reference;
11373 SetGeometry(source_image,&geometry);
11374 if (attribute_flag[1] != 0)
11375 flags=ParseGravityGeometry(source_image,
11376 argument_list[1].string_reference,&geometry,exception);
11377 if (attribute_flag[2] != 0)
11378 geometry.width=argument_list[2].integer_reference;
11379 if (attribute_flag[3] != 0)
11380 geometry.height=argument_list[3].integer_reference;
11381 if (attribute_flag[4] != 0)
11382 geometry.x=argument_list[4].integer_reference;
11383 if (attribute_flag[5] != 0)
11384 geometry.y=argument_list[5].integer_reference;
11385 if (attribute_flag[6] != 0)
11386 image->gravity=(GravityType) argument_list[6].integer_reference;
11387 SetGeometry(image,&offset_geometry);
11388 if (attribute_flag[7] != 0)
11389 flags=ParseGravityGeometry(image,argument_list[7].string_reference,
11390 &offset_geometry,exception);
11391 offset.x=offset_geometry.x;
11392 offset.y=offset_geometry.y;
11393 if (attribute_flag[8] != 0)
11394 offset.x=argument_list[8].integer_reference;
11395 if (attribute_flag[9] != 0)
11396 offset.y=argument_list[9].integer_reference;
11397 (void) CopyImagePixels(image,source_image,&geometry,&offset,
11401 case 144: /* Color */
11406 (void) QueryColorCompliance("none",AllCompliance,&color,exception);
11407 if (attribute_flag[0] != 0)
11408 (void) QueryColorCompliance(argument_list[0].string_reference,
11409 AllCompliance,&color,exception);
11410 (void) SetImageColor(image,&color,exception);
11413 case 145: /* WaveletDenoise */
11415 if (attribute_flag[0] != 0)
11417 flags=ParseGeometry(argument_list[0].string_reference,
11419 if ((flags & PercentValue) != 0)
11421 geometry_info.rho=QuantumRange*geometry_info.rho/100.0;
11422 geometry_info.sigma=QuantumRange*geometry_info.sigma/100.0;
11424 if ((flags & SigmaValue) == 0)
11425 geometry_info.sigma=0.0;
11427 if (attribute_flag[1] != 0)
11428 geometry_info.rho=argument_list[1].real_reference;
11429 if (attribute_flag[2] != 0)
11430 geometry_info.sigma=argument_list[2].real_reference;
11431 if (attribute_flag[3] != 0)
11432 channel=(ChannelType) argument_list[3].integer_reference;
11433 channel_mask=SetImageChannelMask(image,channel);
11434 image=WaveletDenoiseImage(image,geometry_info.rho,geometry_info.sigma,
11436 if (image != (Image *) NULL)
11437 (void) SetImageChannelMask(image,channel_mask);
11440 case 146: /* Colorspace */
11445 colorspace=sRGBColorspace;
11446 if (attribute_flag[0] != 0)
11447 colorspace=(ColorspaceType) argument_list[0].integer_reference;
11448 (void) TransformImageColorspace(image,colorspace,exception);
11451 case 147: /* AutoThreshold */
11453 AutoThresholdMethod
11456 method=UndefinedThresholdMethod;
11457 if (attribute_flag[0] != 0)
11458 method=(AutoThresholdMethod) argument_list[0].integer_reference;
11459 (void) AutoThresholdImage(image,method,exception);
11462 case 148: /* RangeThreshold */
11464 if (attribute_flag[0] != 0)
11466 flags=ParseGeometry(argument_list[0].string_reference,
11468 if ((flags & SigmaValue) == 0)
11469 geometry_info.sigma=geometry_info.rho;
11470 if ((flags & XiValue) == 0)
11471 geometry_info.xi=geometry_info.sigma;
11472 if ((flags & PsiValue) == 0)
11473 geometry_info.psi=geometry_info.xi;
11475 if (attribute_flag[1] != 0)
11476 geometry_info.rho=argument_list[1].real_reference;
11477 if (attribute_flag[2] != 0)
11478 geometry_info.sigma=argument_list[2].real_reference;
11479 if (attribute_flag[3] != 0)
11480 geometry_info.xi=argument_list[3].real_reference;
11481 if (attribute_flag[4] != 0)
11482 geometry_info.psi=argument_list[4].real_reference;
11483 if (attribute_flag[5] != 0)
11484 channel=(ChannelType) argument_list[5].integer_reference;
11485 channel_mask=SetImageChannelMask(image,channel);
11486 (void) RangeThresholdImage(image,geometry_info.rho,
11487 geometry_info.sigma,geometry_info.xi,geometry_info.psi,exception);
11488 if (image != (Image *) NULL)
11489 (void) SetImageChannelMask(image,channel_mask);
11492 case 149: /* CLAHE */
11494 if (attribute_flag[0] != 0)
11496 flags=ParseGeometry(argument_list[0].string_reference,
11498 flags=ParseRegionGeometry(image,argument_list[0].string_reference,
11499 &geometry,exception);
11501 if (attribute_flag[1] != 0)
11502 geometry.width=argument_list[1].integer_reference;
11503 if (attribute_flag[2] != 0)
11504 geometry.height=argument_list[2].integer_reference;
11505 if (attribute_flag[3] != 0)
11506 geometry.x=argument_list[3].integer_reference;
11507 if (attribute_flag[4] != 0)
11508 geometry_info.psi=argument_list[4].real_reference;
11509 (void) CLAHEImage(image,geometry.width,geometry.height,geometry.x,
11510 geometry_info.psi,exception);
11513 case 150: /* OTSUThreshold */
11515 if (attribute_flag[0] != 0)
11516 channel=(ChannelType) argument_list[0].integer_reference;
11517 channel_mask=SetImageChannelMask(image,channel);
11518 (void) OTSUThresholdImage(image,exception);
11519 if (image != (Image *) NULL)
11520 (void) SetImageChannelMask(image,channel_mask);
11524 if (next != (Image *) NULL)
11525 (void) CatchImageException(next);
11526 if ((region_info.width*region_info.height) != 0)
11527 (void) SetImageRegionMask(image,WritePixelMask,(const RectangleInfo *)
11529 if (image != (Image *) NULL)
11532 if (next && (next != image))
11534 image->next=next->next;
11535 if (image->next != (Image *) NULL)
11536 image->next->previous=image;
11537 DeleteImageFromRegistry(*pv,next);
11539 sv_setiv(*pv,PTR2IV(image));
11547 if (reference_vector)
11548 reference_vector=(SV **) RelinquishMagickMemory(reference_vector);
11549 InheritPerlException(exception,perl_exception);
11550 exception=DestroyExceptionInfo(exception);
11551 sv_setiv(perl_exception,(IV) number_images);
11552 SvPOK_on(perl_exception);
11553 ST(0)=sv_2mortal(perl_exception);
11558 ###############################################################################
11566 ###############################################################################
11571 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
11616 PERL_UNUSED_VAR(ref);
11617 PERL_UNUSED_VAR(ix);
11618 exception=AcquireExceptionInfo();
11619 perl_exception=newSVpv("",0);
11622 if (sv_isobject(ST(0)) == 0)
11624 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
11626 goto PerlException;
11628 reference=SvRV(ST(0));
11629 hv=SvSTASH(reference);
11631 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
11633 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
11634 if (image == (Image *) NULL)
11636 ThrowPerlException(exception,OptionError,"NoImagesDefined",
11638 goto PerlException;
11643 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
11644 montage_info=CloneMontageInfo(info->image_info,(MontageInfo *) NULL);
11645 (void) QueryColorCompliance("none",AllCompliance,&transparent_color,
11647 for (i=2; i < items; i+=2)
11649 attribute=(char *) SvPV(ST(i-1),na);
11650 switch (*attribute)
11655 if (LocaleCompare(attribute,"background") == 0)
11657 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11658 &montage_info->background_color,exception);
11659 for (next=image; next; next=next->next)
11660 next->background_color=montage_info->background_color;
11663 if (LocaleCompare(attribute,"border") == 0)
11665 montage_info->border_width=SvIV(ST(i));
11668 if (LocaleCompare(attribute,"bordercolor") == 0)
11670 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11671 &montage_info->border_color,exception);
11672 for (next=image; next; next=next->next)
11673 next->border_color=montage_info->border_color;
11676 if (LocaleCompare(attribute,"borderwidth") == 0)
11678 montage_info->border_width=SvIV(ST(i));
11681 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11688 if (LocaleCompare(attribute,"compose") == 0)
11690 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11691 MagickComposeOptions,MagickFalse,SvPV(ST(i),na));
11694 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11698 for (next=image; next; next=next->next)
11699 next->compose=(CompositeOperator) sp;
11702 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11709 if (LocaleCompare(attribute,"fill") == 0)
11711 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11712 &montage_info->fill,exception);
11715 if (LocaleCompare(attribute,"font") == 0)
11717 (void) CloneString(&montage_info->font,SvPV(ST(i),na));
11720 if (LocaleCompare(attribute,"frame") == 0)
11726 if (IsGeometry(p) == MagickFalse)
11728 ThrowPerlException(exception,OptionError,"MissingGeometry",
11732 (void) CloneString(&montage_info->frame,p);
11734 montage_info->frame=(char *) NULL;
11737 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11744 if (LocaleCompare(attribute,"geometry") == 0)
11750 if (IsGeometry(p) == MagickFalse)
11752 ThrowPerlException(exception,OptionError,"MissingGeometry",
11756 (void) CloneString(&montage_info->geometry,p);
11758 montage_info->geometry=(char *) NULL;
11761 if (LocaleCompare(attribute,"gravity") == 0)
11766 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11767 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
11770 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11774 montage_info->gravity=(GravityType) in;
11775 for (next=image; next; next=next->next)
11776 next->gravity=(GravityType) in;
11779 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11786 if (LocaleCompare(attribute,"label") == 0)
11788 for (next=image; next; next=next->next)
11789 (void) SetImageProperty(next,"label",InterpretImageProperties(
11790 info ? info->image_info : (ImageInfo *) NULL,next,
11791 SvPV(ST(i),na),exception),exception);
11794 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11801 if (LocaleCompare(attribute,"mattecolor") == 0)
11803 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11804 &montage_info->alpha_color,exception);
11805 for (next=image; next; next=next->next)
11806 next->alpha_color=montage_info->alpha_color;
11809 if (LocaleCompare(attribute,"mode") == 0)
11814 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11815 MagickModeOptions,MagickFalse,SvPV(ST(i),na));
11820 ThrowPerlException(exception,OptionError,
11821 "UnrecognizedModeType",SvPV(ST(i),na));
11826 (void) CloneString(&montage_info->frame,"15x15+3+3");
11827 montage_info->shadow=MagickTrue;
11832 montage_info->frame=(char *) NULL;
11833 montage_info->shadow=MagickFalse;
11834 montage_info->border_width=0;
11837 case ConcatenateMode:
11839 montage_info->frame=(char *) NULL;
11840 montage_info->shadow=MagickFalse;
11841 (void) CloneString(&montage_info->geometry,"+0+0");
11842 montage_info->border_width=0;
11847 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11854 if (LocaleCompare(attribute,"pointsize") == 0)
11856 montage_info->pointsize=SvIV(ST(i));
11859 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11866 if (LocaleCompare(attribute,"shadow") == 0)
11868 sp=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
11869 MagickBooleanOptions,MagickFalse,SvPV(ST(i),na));
11872 ThrowPerlException(exception,OptionError,"UnrecognizedType",
11876 montage_info->shadow=sp != 0 ? MagickTrue : MagickFalse;
11879 if (LocaleCompare(attribute,"stroke") == 0)
11881 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11882 &montage_info->stroke,exception);
11885 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11892 if (LocaleCompare(attribute,"texture") == 0)
11894 (void) CloneString(&montage_info->texture,SvPV(ST(i),na));
11897 if (LocaleCompare(attribute,"tile") == 0)
11899 char *p=SvPV(ST(i),na);
11900 if (IsGeometry(p) == MagickFalse)
11902 ThrowPerlException(exception,OptionError,"MissingGeometry",
11906 (void) CloneString(&montage_info->tile,p);
11908 montage_info->tile=(char *) NULL;
11911 if (LocaleCompare(attribute,"title") == 0)
11913 (void) CloneString(&montage_info->title,SvPV(ST(i),na));
11916 if (LocaleCompare(attribute,"transparent") == 0)
11921 QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
11922 &transparent_color,exception);
11923 for (next=image; next; next=next->next)
11924 (void) TransparentPaintImage(next,&transparent_color,
11925 TransparentAlpha,MagickFalse,exception);
11928 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11934 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
11940 image=MontageImageList(info->image_info,montage_info,image,exception);
11941 montage_info=DestroyMontageInfo(montage_info);
11942 if (image == (Image *) NULL)
11943 goto PerlException;
11944 if (transparent_color.alpha != TransparentAlpha)
11945 for (next=image; next; next=next->next)
11946 (void) TransparentPaintImage(next,&transparent_color,
11947 TransparentAlpha,MagickFalse,exception);
11948 for ( ; image; image=image->next)
11950 AddImageToRegistry(sv,image);
11952 av_push(av,sv_bless(rv,hv));
11955 exception=DestroyExceptionInfo(exception);
11956 ST(0)=av_reference;
11957 SvREFCNT_dec(perl_exception);
11961 InheritPerlException(exception,perl_exception);
11962 exception=DestroyExceptionInfo(exception);
11963 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
11964 SvPOK_on(perl_exception);
11965 ST(0)=sv_2mortal(perl_exception);
11970 ###############################################################################
11978 ###############################################################################
11983 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12021 PERL_UNUSED_VAR(ref);
12022 PERL_UNUSED_VAR(ix);
12023 exception=AcquireExceptionInfo();
12024 perl_exception=newSVpv("",0);
12028 if (sv_isobject(ST(0)) == 0)
12030 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12032 goto PerlException;
12034 reference=SvRV(ST(0));
12035 hv=SvSTASH(reference);
12037 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12039 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12040 if (image == (Image *) NULL)
12042 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12044 goto PerlException;
12046 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12051 for (i=2; i < items; i+=2)
12053 attribute=(char *) SvPV(ST(i-1),na);
12054 switch (*attribute)
12059 if (LocaleCompare(attribute,"frames") == 0)
12061 number_frames=SvIV(ST(i));
12064 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12070 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
12076 image=MorphImages(image,number_frames,exception);
12077 if (image == (Image *) NULL)
12078 goto PerlException;
12079 for ( ; image; image=image->next)
12081 AddImageToRegistry(sv,image);
12083 av_push(av,sv_bless(rv,hv));
12086 exception=DestroyExceptionInfo(exception);
12087 ST(0)=av_reference;
12088 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12092 InheritPerlException(exception,perl_exception);
12093 exception=DestroyExceptionInfo(exception);
12094 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12095 SvPOK_on(perl_exception);
12096 ST(0)=sv_2mortal(perl_exception);
12101 ###############################################################################
12109 ###############################################################################
12114 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12142 PERL_UNUSED_VAR(ref);
12143 PERL_UNUSED_VAR(ix);
12144 exception=AcquireExceptionInfo();
12145 perl_exception=newSVpv("",0);
12147 if (sv_isobject(ST(0)) == 0)
12149 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12151 goto PerlException;
12153 reference=SvRV(ST(0));
12154 hv=SvSTASH(reference);
12155 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12156 if (image == (Image *) NULL)
12158 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12160 goto PerlException;
12162 image=MergeImageLayers(image,MosaicLayer,exception);
12164 Create blessed Perl array for the returned image.
12167 ST(0)=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12169 AddImageToRegistry(sv,image);
12171 av_push(av,sv_bless(rv,hv));
12173 (void) CopyMagickString(info->image_info->filename,image->filename,
12175 SetImageInfo(info->image_info,0,exception);
12176 exception=DestroyExceptionInfo(exception);
12177 SvREFCNT_dec(perl_exception);
12181 InheritPerlException(exception,perl_exception);
12182 exception=DestroyExceptionInfo(exception);
12183 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12184 SvPOK_on(perl_exception); /* return messages in string context */
12185 ST(0)=sv_2mortal(perl_exception);
12190 ###############################################################################
12194 # P e r c e p t u a l H a s h #
12198 ###############################################################################
12202 PerceptualHash(ref)
12203 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12205 PerceptualHashImage = 1
12207 perceptualhashimage = 3
12213 ChannelPerceptualHash
12217 message[MagickPathExtent];
12235 PERL_UNUSED_VAR(ref);
12236 PERL_UNUSED_VAR(ix);
12237 exception=AcquireExceptionInfo();
12238 perl_exception=newSVpv("",0);
12240 if (sv_isobject(ST(0)) == 0)
12242 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12244 goto PerlException;
12246 reference=SvRV(ST(0));
12249 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12250 if (image == (Image *) NULL)
12252 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12254 goto PerlException;
12257 for ( ; image; image=image->next)
12262 channel_phash=GetImagePerceptualHash(image,exception);
12263 if (channel_phash == (ChannelPerceptualHash *) NULL)
12266 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
12271 PixelChannel channel=GetPixelChannelChannel(image,i);
12272 PixelTrait traits=GetPixelChannelTraits(image,channel);
12273 if (traits == UndefinedPixelTrait)
12275 EXTEND(sp,GetPixelChannels(image)*MaximumNumberOfPerceptualHashes*
12276 channel_phash[0].number_colorspaces*(i+1)*count);
12277 for (j=0; j < MaximumNumberOfPerceptualHashes; j++)
12282 for (k=0; k < (ssize_t) channel_phash[0].number_colorspaces; k++)
12284 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",
12285 channel_phash[channel].phash[k][j]);
12286 PUSHs(sv_2mortal(newSVpv(message,0)));
12290 channel_phash=(ChannelPerceptualHash *)
12291 RelinquishMagickMemory(channel_phash);
12295 InheritPerlException(exception,perl_exception);
12296 exception=DestroyExceptionInfo(exception);
12297 SvREFCNT_dec(perl_exception);
12301 ###############################################################################
12309 ###############################################################################
12314 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12364 PERL_UNUSED_VAR(ref);
12365 PERL_UNUSED_VAR(ix);
12366 exception=AcquireExceptionInfo();
12367 perl_exception=newSVpv("",0);
12368 package_info=(struct PackageInfo *) NULL;
12369 ac=(items < 2) ? 1 : items-1;
12370 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
12372 length=(STRLEN *) NULL;
12373 if (list == (char **) NULL)
12375 ThrowPerlException(exception,ResourceLimitError,
12376 "MemoryAllocationFailed",PackageName);
12377 goto PerlException;
12380 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
12381 if (length == (STRLEN *) NULL)
12383 ThrowPerlException(exception,ResourceLimitError,
12384 "MemoryAllocationFailed",PackageName);
12385 goto PerlException;
12387 if (sv_isobject(ST(0)) == 0)
12389 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12391 goto PerlException;
12393 reference=SvRV(ST(0));
12394 if (SvTYPE(reference) != SVt_PVAV)
12396 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12398 goto PerlException;
12400 av=(AV *) reference;
12401 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12403 package_info=ClonePackageInfo(info,exception);
12406 *list=(char *) (*package_info->image_info->filename ?
12407 package_info->image_info->filename : "XC:black");
12409 for (n=0, i=0; i < ac; i++)
12411 list[n]=(char *) SvPV(ST(i+1),length[n]);
12412 if ((items >= 3) && strEQcase(list[n],"blob"))
12418 blob=(void *) (SvPV(ST(i+1),length[n]));
12419 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
12421 if ((items >= 3) && strEQcase(list[n],"filename"))
12423 if ((items >= 3) && strEQcase(list[n],"file"))
12432 io_info=IoIFP(sv_2io(ST(i+1)));
12433 if (io_info == (PerlIO *) NULL)
12435 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12439 file=PerlIO_findFILE(io_info);
12440 if (file == (FILE *) NULL)
12442 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
12446 SetImageInfoFile(package_info->image_info,file);
12448 if ((items >= 3) && strEQcase(list[n],"magick"))
12452 list[n]=(char *) NULL;
12454 status=ExpandFilenames(&n,&list);
12455 if (status == MagickFalse)
12457 ThrowPerlException(exception,ResourceLimitError,
12458 "MemoryAllocationFailed",PackageName);
12459 goto PerlException;
12462 for (i=0; i < n; i++)
12464 (void) CopyMagickString(package_info->image_info->filename,list[i],
12466 image=PingImage(package_info->image_info,exception);
12467 if (image == (Image *) NULL)
12469 if ((package_info->image_info->file != (FILE *) NULL) ||
12470 (package_info->image_info->blob != (void *) NULL))
12471 DisassociateImageStream(image);
12472 count+=GetImageListLength(image);
12473 EXTEND(sp,4*count);
12474 for (next=image; next; next=next->next)
12476 PUSHs(sv_2mortal(newSViv(next->columns)));
12477 PUSHs(sv_2mortal(newSViv(next->rows)));
12478 PUSHs(sv_2mortal(newSViv((size_t) GetBlobSize(next))));
12479 PUSHs(sv_2mortal(newSVpv(next->magick,0)));
12481 image=DestroyImageList(image);
12486 for (i=0; i < n; i++)
12487 if (list[i] != (char *) NULL)
12488 for (p=keep; list[i] != *p++; )
12491 list[i]=(char *) RelinquishMagickMemory(list[i]);
12496 if (package_info != (struct PackageInfo *) NULL)
12497 DestroyPackageInfo(package_info);
12498 if (list && (list != keep))
12499 list=(char **) RelinquishMagickMemory(list);
12501 keep=(char **) RelinquishMagickMemory(keep);
12503 length=(STRLEN *) RelinquishMagickMemory(length);
12504 InheritPerlException(exception,perl_exception);
12505 exception=DestroyExceptionInfo(exception);
12506 SvREFCNT_dec(perl_exception); /* throw away all errors */
12510 ###############################################################################
12518 ###############################################################################
12523 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12556 PERL_UNUSED_VAR(ref);
12557 PERL_UNUSED_VAR(ix);
12558 exception=AcquireExceptionInfo();
12559 perl_exception=newSVpv("",0);
12562 if (sv_isobject(ST(0)) == 0)
12564 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
12566 goto PerlException;
12568 reference=SvRV(ST(0));
12569 hv=SvSTASH(reference);
12571 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
12573 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12574 if (image == (Image *) NULL)
12576 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12578 goto PerlException;
12580 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
12581 preview_type=GammaPreview;
12583 preview_type=(PreviewType) ParseCommandOption(MagickPreviewOptions,
12584 MagickFalse,SvPV(ST(1),na));
12585 for ( ; image; image=image->next)
12587 preview_image=PreviewImage(image,preview_type,exception);
12588 if (preview_image == (Image *) NULL)
12589 goto PerlException;
12590 AddImageToRegistry(sv,preview_image);
12592 av_push(av,sv_bless(rv,hv));
12595 exception=DestroyExceptionInfo(exception);
12596 ST(0)=av_reference;
12597 SvREFCNT_dec(perl_exception); /* can't return warning messages */
12601 InheritPerlException(exception,perl_exception);
12602 exception=DestroyExceptionInfo(exception);
12603 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
12604 SvPOK_on(perl_exception);
12605 ST(0)=sv_2mortal(perl_exception);
12610 ###############################################################################
12614 # Q u e r y C o l o r #
12618 ###############################################################################
12622 QueryColor(ref,...)
12623 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12643 PERL_UNUSED_VAR(ref);
12644 PERL_UNUSED_VAR(ix);
12645 exception=AcquireExceptionInfo();
12646 perl_exception=newSVpv("",0);
12655 colorlist=GetColorInfoList("*",&colors,exception);
12657 for (i=0; i < (ssize_t) colors; i++)
12659 PUSHs(sv_2mortal(newSVpv(colorlist[i]->name,0)));
12661 colorlist=(const ColorInfo **)
12662 RelinquishMagickMemory((ColorInfo **) colorlist);
12663 goto PerlException;
12665 EXTEND(sp,5*items);
12666 for (i=1; i < items; i++)
12668 name=(char *) SvPV(ST(i),na);
12669 if (QueryColorCompliance(name,AllCompliance,&color,exception) == MagickFalse)
12674 PUSHs(sv_2mortal(newSViv((size_t) floor(color.red+0.5))));
12675 PUSHs(sv_2mortal(newSViv((size_t) floor(color.green+0.5))));
12676 PUSHs(sv_2mortal(newSViv((size_t) floor(color.blue+0.5))));
12677 if (color.colorspace == CMYKColorspace)
12678 PUSHs(sv_2mortal(newSViv((size_t) floor(color.black+0.5))));
12679 if (color.alpha_trait != UndefinedPixelTrait)
12680 PUSHs(sv_2mortal(newSViv((size_t) floor(color.alpha+0.5))));
12684 InheritPerlException(exception,perl_exception);
12685 exception=DestroyExceptionInfo(exception);
12686 SvREFCNT_dec(perl_exception);
12690 ###############################################################################
12694 # Q u e r y C o l o r N a m e #
12698 ###############################################################################
12702 QueryColorname(ref,...)
12703 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12712 message[MagickPathExtent];
12731 *reference; /* reference is the SV* of ref=SvIV(reference) */
12733 PERL_UNUSED_VAR(ref);
12734 PERL_UNUSED_VAR(ix);
12735 exception=AcquireExceptionInfo();
12736 perl_exception=newSVpv("",0);
12737 reference=SvRV(ST(0));
12738 av=(AV *) reference;
12739 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12741 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12742 if (image == (Image *) NULL)
12744 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12746 goto PerlException;
12749 for (i=1; i < items; i++)
12751 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,&target_color,
12753 (void) QueryColorname(image,&target_color,SVGCompliance,message,
12755 PUSHs(sv_2mortal(newSVpv(message,0)));
12759 InheritPerlException(exception,perl_exception);
12760 exception=DestroyExceptionInfo(exception);
12761 SvREFCNT_dec(perl_exception);
12765 ###############################################################################
12769 # Q u e r y F o n t #
12773 ###############################################################################
12778 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12785 message[MagickPathExtent];
12796 volatile const TypeInfo
12799 PERL_UNUSED_VAR(ref);
12800 PERL_UNUSED_VAR(ix);
12801 exception=AcquireExceptionInfo();
12802 perl_exception=newSVpv("",0);
12811 typelist=GetTypeInfoList("*",&types,exception);
12813 for (i=0; i < (ssize_t) types; i++)
12815 PUSHs(sv_2mortal(newSVpv(typelist[i]->name,0)));
12817 typelist=(const TypeInfo **) RelinquishMagickMemory((TypeInfo **)
12819 goto PerlException;
12821 EXTEND(sp,10*items);
12822 for (i=1; i < items; i++)
12824 name=(char *) SvPV(ST(i),na);
12825 type_info=GetTypeInfo(name,exception);
12826 if (type_info == (TypeInfo *) NULL)
12831 if (type_info->name == (char *) NULL)
12834 PUSHs(sv_2mortal(newSVpv(type_info->name,0)));
12835 if (type_info->description == (char *) NULL)
12838 PUSHs(sv_2mortal(newSVpv(type_info->description,0)));
12839 if (type_info->family == (char *) NULL)
12842 PUSHs(sv_2mortal(newSVpv(type_info->family,0)));
12843 if (type_info->style == UndefinedStyle)
12846 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStyleOptions,
12847 type_info->style),0)));
12848 if (type_info->stretch == UndefinedStretch)
12851 PUSHs(sv_2mortal(newSVpv(CommandOptionToMnemonic(MagickStretchOptions,
12852 type_info->stretch),0)));
12853 (void) FormatLocaleString(message,MagickPathExtent,"%.20g",(double)
12854 type_info->weight);
12855 PUSHs(sv_2mortal(newSVpv(message,0)));
12856 if (type_info->encoding == (char *) NULL)
12859 PUSHs(sv_2mortal(newSVpv(type_info->encoding,0)));
12860 if (type_info->foundry == (char *) NULL)
12863 PUSHs(sv_2mortal(newSVpv(type_info->foundry,0)));
12864 if (type_info->format == (char *) NULL)
12867 PUSHs(sv_2mortal(newSVpv(type_info->format,0)));
12868 if (type_info->metrics == (char *) NULL)
12871 PUSHs(sv_2mortal(newSVpv(type_info->metrics,0)));
12872 if (type_info->glyphs == (char *) NULL)
12875 PUSHs(sv_2mortal(newSVpv(type_info->glyphs,0)));
12879 InheritPerlException(exception,perl_exception);
12880 exception=DestroyExceptionInfo(exception);
12881 SvREFCNT_dec(perl_exception);
12885 ###############################################################################
12889 # Q u e r y F o n t M e t r i c s #
12893 ###############################################################################
12897 QueryFontMetrics(ref,...)
12898 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
12900 queryfontmetrics = 1
12947 *reference; /* reference is the SV* of ref=SvIV(reference) */
12952 PERL_UNUSED_VAR(ref);
12953 PERL_UNUSED_VAR(ix);
12954 exception=AcquireExceptionInfo();
12955 package_info=(struct PackageInfo *) NULL;
12956 perl_exception=newSVpv("",0);
12957 reference=SvRV(ST(0));
12958 av=(AV *) reference;
12959 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
12961 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
12962 if (image == (Image *) NULL)
12964 ThrowPerlException(exception,OptionError,"NoImagesDefined",
12966 goto PerlException;
12968 package_info=ClonePackageInfo(info,exception);
12969 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
12970 CloneString(&draw_info->text,"");
12971 current=draw_info->affine;
12972 GetAffineMatrix(&affine);
12975 EXTEND(sp,7*items);
12976 for (i=2; i < items; i+=2)
12978 attribute=(char *) SvPV(ST(i-1),na);
12979 switch (*attribute)
12984 if (LocaleCompare(attribute,"antialias") == 0)
12986 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
12990 ThrowPerlException(exception,OptionError,"UnrecognizedType",
12994 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
12997 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13004 if (LocaleCompare(attribute,"density") == 0)
13006 CloneString(&draw_info->density,SvPV(ST(i),na));
13009 if (LocaleCompare(attribute,"direction") == 0)
13011 draw_info->direction=(DirectionType) ParseCommandOption(
13012 MagickDirectionOptions,MagickFalse,SvPV(ST(i),na));
13015 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13022 if (LocaleCompare(attribute,"encoding") == 0)
13024 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13027 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13034 if (LocaleCompare(attribute,"family") == 0)
13036 CloneString(&draw_info->family,SvPV(ST(i),na));
13039 if (LocaleCompare(attribute,"fill") == 0)
13042 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13043 &draw_info->fill,exception);
13046 if (LocaleCompare(attribute,"font") == 0)
13048 CloneString(&draw_info->font,SvPV(ST(i),na));
13051 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13058 if (LocaleCompare(attribute,"geometry") == 0)
13060 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13063 if (LocaleCompare(attribute,"gravity") == 0)
13065 draw_info->gravity=(GravityType) ParseCommandOption(
13066 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13069 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13076 if (LocaleCompare(attribute,"interline-spacing") == 0)
13078 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13079 draw_info->interline_spacing=geometry_info.rho;
13082 if (LocaleCompare(attribute,"interword-spacing") == 0)
13084 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13085 draw_info->interword_spacing=geometry_info.rho;
13088 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13095 if (LocaleCompare(attribute,"kerning") == 0)
13097 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13098 draw_info->kerning=geometry_info.rho;
13101 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13108 if (LocaleCompare(attribute,"pointsize") == 0)
13110 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13111 draw_info->pointsize=geometry_info.rho;
13114 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13121 if (LocaleCompare(attribute,"rotate") == 0)
13123 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13124 affine.rx=geometry_info.rho;
13125 affine.ry=geometry_info.sigma;
13126 if ((flags & SigmaValue) == 0)
13127 affine.ry=affine.rx;
13130 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13137 if (LocaleCompare(attribute,"scale") == 0)
13139 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13140 affine.sx=geometry_info.rho;
13141 affine.sy=geometry_info.sigma;
13142 if ((flags & SigmaValue) == 0)
13143 affine.sy=affine.sx;
13146 if (LocaleCompare(attribute,"skew") == 0)
13152 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13153 x_angle=geometry_info.rho;
13154 y_angle=geometry_info.sigma;
13155 if ((flags & SigmaValue) == 0)
13157 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13158 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13161 if (LocaleCompare(attribute,"stroke") == 0)
13164 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13165 &draw_info->stroke,exception);
13168 if (LocaleCompare(attribute,"style") == 0)
13170 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13174 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13178 draw_info->style=(StyleType) type;
13181 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13188 if (LocaleCompare(attribute,"text") == 0)
13190 CloneString(&draw_info->text,SvPV(ST(i),na));
13193 if (LocaleCompare(attribute,"translate") == 0)
13195 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13196 affine.tx=geometry_info.rho;
13197 affine.ty=geometry_info.sigma;
13198 if ((flags & SigmaValue) == 0)
13199 affine.ty=affine.tx;
13202 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13209 if (LocaleCompare(attribute,"weight") == 0)
13211 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13212 draw_info->weight=(size_t) geometry_info.rho;
13215 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13222 if (LocaleCompare(attribute,"x") == 0)
13224 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13225 x=geometry_info.rho;
13228 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13235 if (LocaleCompare(attribute,"y") == 0)
13237 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13238 y=geometry_info.rho;
13241 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13247 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13253 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13254 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13255 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13256 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13257 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13258 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13259 if (draw_info->geometry == (char *) NULL)
13261 draw_info->geometry=AcquireString((char *) NULL);
13262 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13263 "%.20g,%.20g",x,y);
13265 status=GetTypeMetrics(image,draw_info,&metrics,exception);
13266 (void) CatchImageException(image);
13267 if (status == MagickFalse)
13271 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13272 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13273 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13274 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13275 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13276 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13277 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13278 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13279 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13280 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13281 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13282 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13283 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13285 draw_info=DestroyDrawInfo(draw_info);
13288 if (package_info != (struct PackageInfo *) NULL)
13289 DestroyPackageInfo(package_info);
13290 InheritPerlException(exception,perl_exception);
13291 exception=DestroyExceptionInfo(exception);
13292 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13296 ###############################################################################
13300 # 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 #
13304 ###############################################################################
13308 QueryMultilineFontMetrics(ref,...)
13309 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
13311 querymultilinefontmetrics = 1
13358 *reference; /* reference is the SV* of ref=SvIV(reference) */
13363 PERL_UNUSED_VAR(ref);
13364 PERL_UNUSED_VAR(ix);
13365 exception=AcquireExceptionInfo();
13366 package_info=(struct PackageInfo *) NULL;
13367 perl_exception=newSVpv("",0);
13368 reference=SvRV(ST(0));
13369 av=(AV *) reference;
13370 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13372 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
13373 if (image == (Image *) NULL)
13375 ThrowPerlException(exception,OptionError,"NoImagesDefined",
13377 goto PerlException;
13379 package_info=ClonePackageInfo(info,exception);
13380 draw_info=CloneDrawInfo(package_info->image_info,(DrawInfo *) NULL);
13381 CloneString(&draw_info->text,"");
13382 current=draw_info->affine;
13383 GetAffineMatrix(&affine);
13386 EXTEND(sp,7*items);
13387 for (i=2; i < items; i+=2)
13389 attribute=(char *) SvPV(ST(i-1),na);
13390 switch (*attribute)
13395 if (LocaleCompare(attribute,"antialias") == 0)
13397 type=ParseCommandOption(MagickBooleanOptions,MagickFalse,
13401 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13405 draw_info->text_antialias=type != 0 ? MagickTrue : MagickFalse;
13408 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13415 if (LocaleCompare(attribute,"density") == 0)
13417 CloneString(&draw_info->density,SvPV(ST(i),na));
13420 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13427 if (LocaleCompare(attribute,"encoding") == 0)
13429 CloneString(&draw_info->encoding,SvPV(ST(i),na));
13432 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13439 if (LocaleCompare(attribute,"family") == 0)
13441 CloneString(&draw_info->family,SvPV(ST(i),na));
13444 if (LocaleCompare(attribute,"fill") == 0)
13447 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13448 &draw_info->fill,exception);
13451 if (LocaleCompare(attribute,"font") == 0)
13453 CloneString(&draw_info->font,SvPV(ST(i),na));
13456 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13463 if (LocaleCompare(attribute,"geometry") == 0)
13465 CloneString(&draw_info->geometry,SvPV(ST(i),na));
13468 if (LocaleCompare(attribute,"gravity") == 0)
13470 draw_info->gravity=(GravityType) ParseCommandOption(
13471 MagickGravityOptions,MagickFalse,SvPV(ST(i),na));
13474 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13481 if (LocaleCompare(attribute,"pointsize") == 0)
13483 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13484 draw_info->pointsize=geometry_info.rho;
13487 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13494 if (LocaleCompare(attribute,"rotate") == 0)
13496 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13497 affine.rx=geometry_info.rho;
13498 affine.ry=geometry_info.sigma;
13499 if ((flags & SigmaValue) == 0)
13500 affine.ry=affine.rx;
13503 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13510 if (LocaleCompare(attribute,"scale") == 0)
13512 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13513 affine.sx=geometry_info.rho;
13514 affine.sy=geometry_info.sigma;
13515 if ((flags & SigmaValue) == 0)
13516 affine.sy=affine.sx;
13519 if (LocaleCompare(attribute,"skew") == 0)
13525 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13526 x_angle=geometry_info.rho;
13527 y_angle=geometry_info.sigma;
13528 if ((flags & SigmaValue) == 0)
13530 affine.ry=tan(DegreesToRadians(fmod(x_angle,360.0)));
13531 affine.rx=tan(DegreesToRadians(fmod(y_angle,360.0)));
13534 if (LocaleCompare(attribute,"stroke") == 0)
13537 (void) QueryColorCompliance(SvPV(ST(i),na),AllCompliance,
13538 &draw_info->stroke,exception);
13541 if (LocaleCompare(attribute,"style") == 0)
13543 type=ParseCommandOption(MagickStyleOptions,MagickFalse,
13547 ThrowPerlException(exception,OptionError,"UnrecognizedType",
13551 draw_info->style=(StyleType) type;
13554 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13561 if (LocaleCompare(attribute,"text") == 0)
13563 CloneString(&draw_info->text,SvPV(ST(i),na));
13566 if (LocaleCompare(attribute,"translate") == 0)
13568 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13569 affine.tx=geometry_info.rho;
13570 affine.ty=geometry_info.sigma;
13571 if ((flags & SigmaValue) == 0)
13572 affine.ty=affine.tx;
13575 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13582 if (LocaleCompare(attribute,"weight") == 0)
13584 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13585 draw_info->weight=(size_t) geometry_info.rho;
13588 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13595 if (LocaleCompare(attribute,"x") == 0)
13597 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13598 x=geometry_info.rho;
13601 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13608 if (LocaleCompare(attribute,"y") == 0)
13610 flags=ParseGeometry(SvPV(ST(i),na),&geometry_info);
13611 y=geometry_info.rho;
13614 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13620 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
13626 draw_info->affine.sx=current.sx*affine.sx+current.ry*affine.rx;
13627 draw_info->affine.rx=current.rx*affine.sx+current.sy*affine.rx;
13628 draw_info->affine.ry=current.sx*affine.ry+current.ry*affine.sy;
13629 draw_info->affine.sy=current.rx*affine.ry+current.sy*affine.sy;
13630 draw_info->affine.tx=current.sx*affine.tx+current.ry*affine.ty+current.tx;
13631 draw_info->affine.ty=current.rx*affine.tx+current.sy*affine.ty+current.ty;
13632 if (draw_info->geometry == (char *) NULL)
13634 draw_info->geometry=AcquireString((char *) NULL);
13635 (void) FormatLocaleString(draw_info->geometry,MagickPathExtent,
13636 "%.20g,%.20g",x,y);
13638 status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
13639 (void) CatchException(exception);
13640 if (status == MagickFalse)
13644 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.x)));
13645 PUSHs(sv_2mortal(newSVnv(metrics.pixels_per_em.y)));
13646 PUSHs(sv_2mortal(newSVnv(metrics.ascent)));
13647 PUSHs(sv_2mortal(newSVnv(metrics.descent)));
13648 PUSHs(sv_2mortal(newSVnv(metrics.width)));
13649 PUSHs(sv_2mortal(newSVnv(metrics.height)));
13650 PUSHs(sv_2mortal(newSVnv(metrics.max_advance)));
13651 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x1)));
13652 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y1)));
13653 PUSHs(sv_2mortal(newSVnv(metrics.bounds.x2)));
13654 PUSHs(sv_2mortal(newSVnv(metrics.bounds.y2)));
13655 PUSHs(sv_2mortal(newSVnv(metrics.origin.x)));
13656 PUSHs(sv_2mortal(newSVnv(metrics.origin.y)));
13658 draw_info=DestroyDrawInfo(draw_info);
13661 if (package_info != (struct PackageInfo *) NULL)
13662 DestroyPackageInfo(package_info);
13663 InheritPerlException(exception,perl_exception);
13664 exception=DestroyExceptionInfo(exception);
13665 SvREFCNT_dec(perl_exception); /* can't return warning messages */
13669 ###############################################################################
13673 # Q u e r y F o r m a t #
13677 ###############################################################################
13681 QueryFormat(ref,...)
13682 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
13699 volatile const MagickInfo
13702 PERL_UNUSED_VAR(ref);
13703 PERL_UNUSED_VAR(ix);
13704 exception=AcquireExceptionInfo();
13705 perl_exception=newSVpv("",0);
13709 format[MagickPathExtent];
13717 format_list=GetMagickInfoList("*",&types,exception);
13719 for (i=0; i < (ssize_t) types; i++)
13721 (void) CopyMagickString(format,format_list[i]->name,MagickPathExtent);
13722 LocaleLower(format);
13723 PUSHs(sv_2mortal(newSVpv(format,0)));
13725 format_list=(const MagickInfo **)
13726 RelinquishMagickMemory((MagickInfo *) format_list);
13727 goto PerlException;
13729 EXTEND(sp,8*items);
13730 for (i=1; i < items; i++)
13732 name=(char *) SvPV(ST(i),na);
13733 magick_info=GetMagickInfo(name,exception);
13734 if (magick_info == (const MagickInfo *) NULL)
13739 if (magick_info->description == (char *) NULL)
13742 PUSHs(sv_2mortal(newSVpv(magick_info->description,0)));
13743 if (magick_info->module == (char *) NULL)
13746 PUSHs(sv_2mortal(newSVpv(magick_info->module,0)));
13750 InheritPerlException(exception,perl_exception);
13751 exception=DestroyExceptionInfo(exception);
13752 SvREFCNT_dec(perl_exception);
13756 ###############################################################################
13760 # Q u e r y O p t i o n #
13764 ###############################################################################
13768 QueryOption(ref,...)
13769 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
13790 PERL_UNUSED_VAR(ref);
13791 PERL_UNUSED_VAR(ix);
13792 exception=AcquireExceptionInfo();
13793 perl_exception=newSVpv("",0);
13794 EXTEND(sp,8*items);
13795 for (i=1; i < items; i++)
13797 option=ParseCommandOption(MagickListOptions,MagickFalse,(char *)
13799 options=GetCommandOptions((CommandOption) option);
13800 if (options == (char **) NULL)
13804 for (j=0; options[j] != (char *) NULL; j++)
13805 PUSHs(sv_2mortal(newSVpv(options[j],0)));
13806 options=DestroyStringList(options);
13810 InheritPerlException(exception,perl_exception);
13811 exception=DestroyExceptionInfo(exception);
13812 SvREFCNT_dec(perl_exception);
13816 ###############################################################################
13824 ###############################################################################
13829 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
13876 *perl_exception, /* Perl variable for storing messages */
13881 PERL_UNUSED_VAR(ref);
13882 PERL_UNUSED_VAR(ix);
13883 exception=AcquireExceptionInfo();
13884 perl_exception=newSVpv("",0);
13886 package_info=(struct PackageInfo *) NULL;
13888 ac=(items < 2) ? 1 : items-1;
13889 list=(char **) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*list));
13891 length=(STRLEN *) NULL;
13892 if (list == (char **) NULL)
13894 ThrowPerlException(exception,ResourceLimitError,
13895 "MemoryAllocationFailed",PackageName);
13896 goto PerlException;
13898 length=(STRLEN *) AcquireQuantumMemory((size_t) ac+1UL,sizeof(*length));
13899 if (length == (STRLEN *) NULL)
13901 ThrowPerlException(exception,ResourceLimitError,
13902 "MemoryAllocationFailed",PackageName);
13903 goto PerlException;
13905 if (sv_isobject(ST(0)) == 0)
13907 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13909 goto PerlException;
13911 reference=SvRV(ST(0));
13912 hv=SvSTASH(reference);
13913 if (SvTYPE(reference) != SVt_PVAV)
13915 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
13917 goto PerlException;
13919 av=(AV *) reference;
13920 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
13922 package_info=ClonePackageInfo(info,exception);
13925 *list=(char *) (*package_info->image_info->filename ?
13926 package_info->image_info->filename : "XC:black");
13928 for (n=0, i=0; i < ac; i++)
13930 list[n]=(char *) SvPV(ST(i+1),length[n]);
13931 if ((items >= 3) && strEQcase(list[n],"blob"))
13937 blob=(void *) (SvPV(ST(i+1),length[n]));
13938 SetImageInfoBlob(package_info->image_info,blob,(size_t) length[n]);
13940 if ((items >= 3) && strEQcase(list[n],"filename"))
13942 if ((items >= 3) && strEQcase(list[n],"file"))
13951 io_info=IoIFP(sv_2io(ST(i+1)));
13952 if (io_info == (PerlIO *) NULL)
13954 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13958 file=PerlIO_findFILE(io_info);
13959 if (file == (FILE *) NULL)
13961 ThrowPerlException(exception,BlobError,"UnableToOpenFile",
13965 SetImageInfoFile(package_info->image_info,file);
13967 if ((items >= 3) && strEQcase(list[n],"magick"))
13971 list[n]=(char *) NULL;
13973 status=ExpandFilenames(&n,&list);
13974 if (status == MagickFalse)
13976 ThrowPerlException(exception,ResourceLimitError,
13977 "MemoryAllocationFailed",PackageName);
13978 goto PerlException;
13981 for (i=0; i < n; i++)
13983 if ((package_info->image_info->file == (FILE *) NULL) &&
13984 (package_info->image_info->blob == (void *) NULL))
13985 image=ReadImages(package_info->image_info,list[i],exception);
13988 image=ReadImages(package_info->image_info,
13989 package_info->image_info->filename,exception);
13990 if (image != (Image *) NULL)
13991 DisassociateImageStream(image);
13993 if (image == (Image *) NULL)
13995 for ( ; image; image=image->next)
13997 AddImageToRegistry(sv,image);
13999 av_push(av,sv_bless(rv,hv));
14007 for (i=0; i < n; i++)
14008 if (list[i] != (char *) NULL)
14009 for (p=keep; list[i] != *p++; )
14010 if (*p == (char *) NULL)
14012 list[i]=(char *) RelinquishMagickMemory(list[i]);
14017 if (package_info != (struct PackageInfo *) NULL)
14018 DestroyPackageInfo(package_info);
14019 if (list && (list != keep))
14020 list=(char **) RelinquishMagickMemory(list);
14022 keep=(char **) RelinquishMagickMemory(keep);
14024 length=(STRLEN *) RelinquishMagickMemory(length);
14025 InheritPerlException(exception,perl_exception);
14026 exception=DestroyExceptionInfo(exception);
14027 sv_setiv(perl_exception,(IV) number_images);
14028 SvPOK_on(perl_exception);
14029 ST(0)=sv_2mortal(perl_exception);
14034 ###############################################################################
14042 ###############################################################################
14047 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14070 PERL_UNUSED_VAR(ref);
14071 PERL_UNUSED_VAR(ix);
14072 exception=AcquireExceptionInfo();
14073 perl_exception=newSVpv("",0);
14074 reference=SvRV(ST(0));
14075 av=(AV *) reference;
14076 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
14078 for (i=1; i < items; i++)
14079 (void) RemoteDisplayCommand(info->image_info,(char *) NULL,(char *)
14080 SvPV(ST(i),na),exception);
14081 InheritPerlException(exception,perl_exception);
14082 exception=DestroyExceptionInfo(exception);
14083 SvREFCNT_dec(perl_exception); /* throw away all errors */
14087 ###############################################################################
14095 ###############################################################################
14100 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14123 *reference; /* reference is the SV* of ref=SvIV(reference) */
14125 PERL_UNUSED_VAR(ref);
14126 PERL_UNUSED_VAR(ix);
14127 exception=AcquireExceptionInfo();
14128 perl_exception=newSVpv("",0);
14129 if (sv_isobject(ST(0)) == 0)
14131 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14133 goto PerlException;
14135 reference=SvRV(ST(0));
14136 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14138 SetAttribute(aTHX_ info,image,"size",ST(1),exception);
14140 for (i=2; i < items; i+=2)
14141 SetAttribute(aTHX_ info,image,SvPV(ST(i-1),na),ST(i),exception);
14144 InheritPerlException(exception,perl_exception);
14145 exception=DestroyExceptionInfo(exception);
14146 sv_setiv(perl_exception,(IV) (SvCUR(perl_exception) != 0));
14147 SvPOK_on(perl_exception);
14148 ST(0)=sv_2mortal(perl_exception);
14153 ###############################################################################
14157 # S e t P i x e l #
14161 ###############################################################################
14166 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14208 *reference; /* reference is the SV* of ref=SvIV(reference) */
14210 PERL_UNUSED_VAR(ref);
14211 PERL_UNUSED_VAR(ix);
14212 exception=AcquireExceptionInfo();
14213 perl_exception=newSVpv("",0);
14214 reference=SvRV(ST(0));
14215 av=(AV *) reference;
14216 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
14218 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14219 if (image == (Image *) NULL)
14221 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14223 goto PerlException;
14226 normalize=MagickTrue;
14229 region.width=image->columns;
14232 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
14233 channel=DefaultChannels;
14234 for (i=2; i < items; i+=2)
14236 attribute=(char *) SvPV(ST(i-1),na);
14237 switch (*attribute)
14242 if (LocaleCompare(attribute,"channel") == 0)
14247 option=ParseChannelOption(SvPV(ST(i),na));
14250 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14254 channel=(ChannelType) option;
14257 if (LocaleCompare(attribute,"color") == 0)
14259 if (SvTYPE(ST(i)) != SVt_RV)
14262 message[MagickPathExtent];
14264 (void) FormatLocaleString(message,MagickPathExtent,
14265 "invalid %.60s value",attribute);
14266 ThrowPerlException(exception,OptionError,message,
14269 av=(AV *) SvRV(ST(i));
14272 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14279 if (LocaleCompare(attribute,"geometry") == 0)
14281 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
14284 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14291 if (LocaleCompare(attribute,"normalize") == 0)
14293 option=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14297 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14301 normalize=option != 0 ? MagickTrue : MagickFalse;
14304 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14311 if (LocaleCompare(attribute,"x") == 0)
14313 region.x=SvIV(ST(i));
14316 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14323 if (LocaleCompare(attribute,"y") == 0)
14325 region.y=SvIV(ST(i));
14328 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14334 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14340 (void) SetImageStorageClass(image,DirectClass,exception);
14341 channel_mask=SetImageChannelMask(image,channel);
14342 q=GetAuthenticPixels(image,region.x,region.y,1,1,exception);
14343 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14344 (SvTYPE(av) != SVt_PVAV))
14356 if (normalize != MagickFalse)
14357 scale=QuantumRange;
14358 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14361 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14362 av_fetch(av,i,0)))),q);
14365 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14368 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14369 av_fetch(av,i,0)))),q);
14372 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14375 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14376 av_fetch(av,i,0)))),q);
14379 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14380 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14382 SetPixelBlack(image,ClampToQuantum(scale*
14383 SvNV(*(av_fetch(av,i,0)))),q);
14386 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14389 SetPixelAlpha(image,ClampToQuantum(scale*
14390 SvNV(*(av_fetch(av,i,0)))),q);
14393 (void) SyncAuthenticPixels(image,exception);
14395 (void) SetImageChannelMask(image,channel_mask);
14398 InheritPerlException(exception,perl_exception);
14399 exception=DestroyExceptionInfo(exception);
14400 SvREFCNT_dec(perl_exception);
14404 ###############################################################################
14408 # S e t P i x e l s #
14412 ###############################################################################
14417 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14453 *reference; /* reference is the SV* of ref=SvIV(reference) */
14455 PERL_UNUSED_VAR(ref);
14456 PERL_UNUSED_VAR(ix);
14457 exception=AcquireExceptionInfo();
14458 perl_exception=newSVpv("",0);
14459 reference=SvRV(ST(0));
14460 av=(AV *) reference;
14461 info=GetPackageInfo(aTHX_ (void *) av,(struct PackageInfo *) NULL,
14463 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14464 if (image == (Image *) NULL)
14466 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14468 goto PerlException;
14473 region.width=image->columns;
14476 (void) ParseAbsoluteGeometry(SvPV(ST(1),na),®ion);
14477 channel=DefaultChannels;
14478 for (i=2; i < items; i+=2)
14480 attribute=(char *) SvPV(ST(i-1),na);
14481 switch (*attribute)
14486 if (LocaleCompare(attribute,"channel") == 0)
14491 option=ParseChannelOption(SvPV(ST(i),na));
14494 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14498 channel=(ChannelType) option;
14501 if (LocaleCompare(attribute,"color") == 0)
14503 if (SvTYPE(ST(i)) != SVt_RV)
14506 message[MagickPathExtent];
14508 (void) FormatLocaleString(message,MagickPathExtent,
14509 "invalid %.60s value",attribute);
14510 ThrowPerlException(exception,OptionError,message,
14513 av=(AV *) SvRV(ST(i));
14516 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14523 if (LocaleCompare(attribute,"geometry") == 0)
14525 (void) ParseAbsoluteGeometry(SvPV(ST(i),na),®ion);
14528 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14535 if (LocaleCompare(attribute,"height") == 0)
14537 region.height=SvIV(ST(i));
14540 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14547 if (LocaleCompare(attribute,"width") == 0)
14549 region.width=SvIV(ST(i));
14552 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14559 if (LocaleCompare(attribute,"x") == 0)
14561 region.x=SvIV(ST(i));
14564 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14571 if (LocaleCompare(attribute,"y") == 0)
14573 region.y=SvIV(ST(i));
14576 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14582 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14588 (void) SetImageStorageClass(image,DirectClass,exception);
14589 channel_mask=SetImageChannelMask(image,channel);
14590 q=GetAuthenticPixels(image,region.x,region.y,region.width,region.height,
14592 if ((q == (Quantum *) NULL) || (av == (AV *) NULL) ||
14593 (SvTYPE(av) != SVt_PVAV))
14607 scale=(double) QuantumRange;
14608 number_pixels=region.width*region.height;
14609 while ((n < number_pixels) && (i < av_len(av)))
14611 if (((GetPixelRedTraits(image) & UpdatePixelTrait) != 0) &&
14614 SetPixelRed(image,ClampToQuantum(scale*SvNV(*(
14615 av_fetch(av,i,0)))),q);
14618 if (((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0) &&
14621 SetPixelGreen(image,ClampToQuantum(scale*SvNV(*(
14622 av_fetch(av,i,0)))),q);
14625 if (((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0) &&
14628 SetPixelBlue(image,ClampToQuantum(scale*SvNV(*(
14629 av_fetch(av,i,0)))),q);
14632 if ((((GetPixelBlackTraits(image) & UpdatePixelTrait) != 0) &&
14633 (image->colorspace == CMYKColorspace)) && (i <= av_len(av)))
14635 SetPixelBlack(image,ClampToQuantum(scale*
14636 SvNV(*(av_fetch(av,i,0)))),q);
14639 if (((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0) &&
14642 SetPixelAlpha(image,ClampToQuantum(scale*
14643 SvNV(*(av_fetch(av,i,0)))),q);
14647 q+=image->number_channels;
14649 (void) SyncAuthenticPixels(image,exception);
14651 (void) SetImageChannelMask(image,channel_mask);
14654 InheritPerlException(exception,perl_exception);
14655 exception=DestroyExceptionInfo(exception);
14656 SvREFCNT_dec(perl_exception);
14660 ###############################################################################
14668 ###############################################################################
14673 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14712 PERL_UNUSED_VAR(ref);
14713 PERL_UNUSED_VAR(ix);
14714 exception=AcquireExceptionInfo();
14715 perl_exception=newSVpv("",0);
14719 if (sv_isobject(ST(0)) == 0)
14721 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14723 goto PerlException;
14725 reference=SvRV(ST(0));
14726 hv=SvSTASH(reference);
14728 av_reference=sv_2mortal(sv_bless(newRV((SV *) av),hv));
14730 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14731 if (image == (Image *) NULL)
14733 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14735 goto PerlException;
14737 info=GetPackageInfo(aTHX_ (void *) av,info,exception);
14743 for (i=2; i < items; i+=2)
14745 attribute=(char *) SvPV(ST(i-1),na);
14746 switch (*attribute)
14751 if (LocaleCompare(attribute,"offset") == 0)
14753 offset=(ssize_t) StringToLong((char *) SvPV(ST(1),na));
14756 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14763 if (LocaleCompare(attribute,"stack") == 0)
14765 stack=ParseCommandOption(MagickBooleanOptions,MagickFalse,
14769 ThrowPerlException(exception,OptionError,"UnrecognizedType",
14775 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14781 ThrowPerlException(exception,OptionError,"UnrecognizedAttribute",
14787 image=SmushImages(image,stack != 0 ? MagickTrue : MagickFalse,offset,
14789 if (image == (Image *) NULL)
14790 goto PerlException;
14791 for ( ; image; image=image->next)
14793 AddImageToRegistry(sv,image);
14795 av_push(av,sv_bless(rv,hv));
14798 exception=DestroyExceptionInfo(exception);
14799 ST(0)=av_reference;
14800 SvREFCNT_dec(perl_exception);
14804 InheritPerlException(exception,perl_exception);
14805 exception=DestroyExceptionInfo(exception);
14806 sv_setiv(perl_exception,(IV) SvCUR(perl_exception) != 0);
14807 SvPOK_on(perl_exception);
14808 ST(0)=sv_2mortal(perl_exception);
14813 ###############################################################################
14817 # S t a t i s t i c s #
14821 ###############################################################################
14826 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14828 StatisticsImage = 1
14830 statisticsimage = 3
14833 #define ChannelStatistics(channel) \
14835 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14836 (double) channel_statistics[channel].depth); \
14837 PUSHs(sv_2mortal(newSVpv(message,0))); \
14838 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14839 channel_statistics[channel].minima/QuantumRange); \
14840 PUSHs(sv_2mortal(newSVpv(message,0))); \
14841 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14842 channel_statistics[channel].maxima/QuantumRange); \
14843 PUSHs(sv_2mortal(newSVpv(message,0))); \
14844 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14845 channel_statistics[channel].mean/QuantumRange); \
14846 PUSHs(sv_2mortal(newSVpv(message,0))); \
14847 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14848 channel_statistics[channel].standard_deviation/QuantumRange); \
14849 PUSHs(sv_2mortal(newSVpv(message,0))); \
14850 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14851 channel_statistics[channel].kurtosis); \
14852 PUSHs(sv_2mortal(newSVpv(message,0))); \
14853 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14854 channel_statistics[channel].skewness); \
14855 PUSHs(sv_2mortal(newSVpv(message,0))); \
14856 (void) FormatLocaleString(message,MagickPathExtent,"%.20g", \
14857 channel_statistics[channel].entropy); \
14858 PUSHs(sv_2mortal(newSVpv(message,0))); \
14865 message[MagickPathExtent];
14868 *channel_statistics;
14886 PERL_UNUSED_VAR(ref);
14887 PERL_UNUSED_VAR(ix);
14888 exception=AcquireExceptionInfo();
14889 perl_exception=newSVpv("",0);
14891 if (sv_isobject(ST(0)) == 0)
14893 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14895 goto PerlException;
14897 reference=SvRV(ST(0));
14900 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14901 if (image == (Image *) NULL)
14903 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14905 goto PerlException;
14908 for ( ; image; image=image->next)
14913 channel_statistics=GetImageStatistics(image,exception);
14914 if (channel_statistics == (ChannelStatistics *) NULL)
14917 for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
14919 PixelChannel channel=GetPixelChannelChannel(image,i);
14920 PixelTrait traits=GetPixelChannelTraits(image,channel);
14921 if (traits == UndefinedPixelTrait)
14923 EXTEND(sp,8*(i+1)*count);
14924 ChannelStatistics(channel);
14926 EXTEND(sp,8*(i+1)*count);
14927 ChannelStatistics(CompositePixelChannel);
14928 channel_statistics=(ChannelStatistics *)
14929 RelinquishMagickMemory(channel_statistics);
14933 InheritPerlException(exception,perl_exception);
14934 exception=DestroyExceptionInfo(exception);
14935 SvREFCNT_dec(perl_exception);
14939 ###############################################################################
14943 # S y n c A u t h e n t i c P i x e l s #
14947 ###############################################################################
14951 SyncAuthenticPixels(ref,...)
14952 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
14954 Syncauthenticpixels = 1
14955 SyncImagePixels = 2
14956 syncimagepixels = 3
14975 PERL_UNUSED_VAR(ref);
14976 PERL_UNUSED_VAR(ix);
14977 exception=AcquireExceptionInfo();
14978 perl_exception=newSVpv("",0);
14979 if (sv_isobject(ST(0)) == 0)
14981 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
14983 goto PerlException;
14986 reference=SvRV(ST(0));
14987 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
14988 if (image == (Image *) NULL)
14990 ThrowPerlException(exception,OptionError,"NoImagesDefined",
14992 goto PerlException;
14995 status=SyncAuthenticPixels(image,exception);
14996 if (status != MagickFalse)
15000 InheritPerlException(exception,perl_exception);
15001 exception=DestroyExceptionInfo(exception);
15002 SvREFCNT_dec(perl_exception); /* throw away all errors */
15007 ###############################################################################
15015 ###############################################################################
15020 Image::Magick::@MAGICK_ABI_SUFFIX@ ref = NO_INIT
15028 filename[MagickPathExtent];
15052 PERL_UNUSED_VAR(ref);
15053 PERL_UNUSED_VAR(ix);
15054 exception=AcquireExceptionInfo();
15055 perl_exception=newSVpv("",0);
15057 package_info=(struct PackageInfo *) NULL;
15058 if (sv_isobject(ST(0)) == 0)
15060 ThrowPerlException(exception,OptionError,"ReferenceIsNotMyType",
15062 goto PerlException;
15064 reference=SvRV(ST(0));
15065 image=SetupList(aTHX_ reference,&info,(SV ***) NULL,exception);
15066 if (image == (Image *) NULL)
15068 ThrowPerlException(exception,OptionError,"NoImagesDefined",
15070 goto PerlException;
15073 for (next=image; next; next=next->next)
15074 next->scene=scene++;
15075 package_info=ClonePackageInfo(info,exception);
15077 SetAttribute(aTHX_ package_info,NULL,"filename",ST(1),exception);
15080 for (i=2; i < items; i+=2)
15081 SetAttribute(aTHX_ package_info,image,SvPV(ST(i-1),na),ST(i),
15083 (void) CopyMagickString(filename,package_info->image_info->filename,
15085 for (next=image; next; next=next->next)
15086 (void) CopyMagickString(next->filename,filename,MagickPathExtent);
15087 *package_info->image_info->magick='\0';
15088 SetImageInfo(package_info->image_info,(unsigned int)
15089 GetImageListLength(image),exception);
15090 for (next=image; next; next=next->next)
15092 (void) WriteImage(package_info->image_info,next,exception);
15094 if (package_info->image_info->adjoin)
15099 if (package_info != (struct PackageInfo *) NULL)
15100 DestroyPackageInfo(package_info);
15101 InheritPerlException(exception,perl_exception);
15102 exception=DestroyExceptionInfo(exception);
15103 sv_setiv(perl_exception,(IV) number_images);
15104 SvPOK_on(perl_exception);
15105 ST(0)=sv_2mortal(perl_exception);