2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % IIIII DDDD EEEEE N N TTTTT IIIII FFFFF Y Y %
7 % I D D E NN N T I F Y Y %
8 % I D D EEE N N N T I FFF Y %
9 % I D D E N NN T I F Y %
10 % IIIII DDDD EEEEE N N T IIIII F Y %
13 % Identify an Image Format and Characteristics. %
20 % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % Identify describes the format and characteristics of one or more image
37 % files. It will also report if an image is incomplete or corrupt.
45 #include "magick/studio.h"
46 #include "magick/annotate.h"
47 #include "magick/artifact.h"
48 #include "magick/attribute.h"
49 #include "magick/blob.h"
50 #include "magick/cache.h"
51 #include "magick/client.h"
52 #include "magick/coder.h"
53 #include "magick/color.h"
54 #include "magick/configure.h"
55 #include "magick/constitute.h"
56 #include "magick/decorate.h"
57 #include "magick/delegate.h"
58 #include "magick/draw.h"
59 #include "magick/effect.h"
60 #include "magick/exception.h"
61 #include "magick/exception-private.h"
62 #include "magick/feature.h"
63 #include "magick/gem.h"
64 #include "magick/geometry.h"
65 #include "magick/histogram.h"
66 #include "magick/identify.h"
67 #include "magick/image.h"
68 #include "magick/image-private.h"
69 #include "magick/list.h"
70 #include "magick/locale_.h"
71 #include "magick/log.h"
72 #include "magick/magic.h"
73 #include "magick/magick.h"
74 #include "magick/memory_.h"
75 #include "magick/module.h"
76 #include "magick/monitor.h"
77 #include "magick/montage.h"
78 #include "magick/option.h"
79 #include "magick/pixel-private.h"
80 #include "magick/prepress.h"
81 #include "magick/profile.h"
82 #include "magick/property.h"
83 #include "magick/quantize.h"
84 #include "magick/quantum.h"
85 #include "magick/random_.h"
86 #include "magick/registry.h"
87 #include "magick/resize.h"
88 #include "magick/resource_.h"
89 #include "magick/signature.h"
90 #include "magick/statistic.h"
91 #include "magick/string_.h"
92 #include "magick/timer.h"
93 #include "magick/utility.h"
94 #include "magick/version.h"
95 #if defined(MAGICKCORE_LCMS_DELEGATE)
96 #if defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
97 #include <lcms/lcms.h>
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 % I d e n t i f y I m a g e %
112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 % IdentifyImage() identifies an image by printing its attributes to the file.
115 % Attributes include the image width, height, size, and others.
117 % The format of the IdentifyImage method is:
119 % MagickBooleanType IdentifyImage(Image *image,FILE *file,
120 % const MagickBooleanType verbose)
122 % A description of each parameter follows:
124 % o image: the image.
126 % o file: the file, typically stdout.
128 % o verbose: A value other than zero prints more detailed information
133 MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
134 const MagickBooleanType verbose)
136 #define IdentifyFormat " %s:\n min: " QuantumFormat \
137 " (%g)\n max: " QuantumFormat " (%g)\n" \
138 " mean: %g (%g)\n standard deviation: %g (%g)\n" \
139 " kurtosis: %g\n skewness: %g\n"
142 color[MaxTextExtent],
143 format[MaxTextExtent],
185 assert(image != (Image *) NULL);
186 assert(image->signature == MagickSignature);
187 if (image->debug != MagickFalse)
188 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
189 if (file == (FILE *) NULL)
192 elapsed_time=GetElapsedTime(&image->timer);
193 user_time=GetUserTime(&image->timer);
194 GetTimerInfo(&image->timer);
195 if (verbose == MagickFalse)
198 Display summary info about the image.
200 if (*image->magick_filename != '\0')
201 if (LocaleCompare(image->magick_filename,image->filename) != 0)
202 (void) fprintf(file,"%s=>",image->magick_filename);
203 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
204 (GetNextImageInList(image) == (Image *) NULL) && (image->scene == 0))
205 (void) fprintf(file,"%s ",image->filename);
207 (void) fprintf(file,"%s[%lu] ",image->filename,image->scene);
208 (void) fprintf(file,"%s ",image->magick);
209 if ((image->magick_columns != 0) || (image->magick_rows != 0))
210 if ((image->magick_columns != image->columns) ||
211 (image->magick_rows != image->rows))
212 (void) fprintf(file,"%lux%lu=>",image->magick_columns,
214 (void) fprintf(file,"%lux%lu ",image->columns,image->rows);
215 if ((image->page.width != 0) || (image->page.height != 0) ||
216 (image->page.x != 0) || (image->page.y != 0))
217 (void) fprintf(file,"%lux%lu%+ld%+ld ",image->page.width,
218 image->page.height,image->page.x,image->page.y);
219 (void) fprintf(file,"%lu-bit ",image->depth);
220 if (image->type != UndefinedType)
221 (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
222 (long) image->type));
223 if (image->storage_class == DirectClass)
225 (void) fprintf(file,"DirectClass ");
226 if (image->total_colors != 0)
228 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
229 (void) fprintf(file,"%s ",format);
233 if (image->total_colors <= image->colors)
234 (void) fprintf(file,"PseudoClass %luc ",image->colors);
236 (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors,
238 if (image->error.mean_error_per_pixel != 0.0)
239 (void) fprintf(file,"%ld/%f/%fdb ",(long)
240 (image->error.mean_error_per_pixel+0.5),
241 image->error.normalized_mean_error,
242 image->error.normalized_maximum_error);
243 if (GetBlobSize(image) != 0)
245 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
246 (void) fprintf(file,"%s ",format);
248 (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(long)
249 (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
250 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
251 (void) fprintf(file,"\n");
253 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
256 Display verbose info about the image.
258 exception=AcquireExceptionInfo();
259 pixels=GetVirtualPixels(image,0,0,1,1,exception);
260 exception=DestroyExceptionInfo(exception);
261 ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
262 type=GetImageType(image,&image->exception);
263 (void) SignatureImage(image);
264 (void) fprintf(file,"Image: %s\n",image->filename);
265 if (*image->magick_filename != '\0')
266 if (LocaleCompare(image->magick_filename,image->filename) != 0)
269 filename[MaxTextExtent];
271 GetPathComponent(image->magick_filename,TailPath,filename);
272 (void) fprintf(file," Base filename: %s\n",filename);
274 magick_info=GetMagickInfo(image->magick,&image->exception);
275 if ((magick_info == (const MagickInfo *) NULL) ||
276 (*GetMagickDescription(magick_info) == '\0'))
277 (void) fprintf(file," Format: %s\n",image->magick);
279 (void) fprintf(file," Format: %s (%s)\n",image->magick,
280 GetMagickDescription(magick_info));
281 (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
282 (long) image->storage_class));
283 (void) fprintf(file," Geometry: %lux%lu%+ld%+ld\n",image->columns,
284 image->rows,image->tile_offset.x,image->tile_offset.y);
285 if ((image->magick_columns != 0) || (image->magick_rows != 0))
286 if ((image->magick_columns != image->columns) ||
287 (image->magick_rows != image->rows))
288 (void) fprintf(file," Base geometry: %lux%lu\n",image->magick_columns,
290 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
292 (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution,
293 image->y_resolution);
294 (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/
295 image->x_resolution,(double) image->rows/image->y_resolution);
297 (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic(
298 MagickResolutionOptions,(long) image->units));
299 (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
301 if (image->type != UndefinedType)
302 (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic(
303 MagickTypeOptions,(long) image->type));
304 (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic(
305 MagickEndianOptions,(long) image->endian));
307 Detail channel depth and extrema.
309 (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic(
310 MagickColorspaceOptions,(long) image->colorspace));
311 if (ping == MagickFalse)
319 depth=GetImageDepth(image,&image->exception);
320 if (image->depth == depth)
321 (void) fprintf(file," Depth: %lu-bit\n",image->depth);
323 (void) fprintf(file," Depth: %lu/%lu-bit\n",image->depth,depth);
324 channel_statistics=GetImageChannelStatistics(image,&image->exception);
325 (void) fprintf(file," Channel depth:\n");
326 colorspace=image->colorspace;
327 if (IsGrayImage(image,&image->exception) != MagickFalse)
328 colorspace=GRAYColorspace;
334 (void) fprintf(file," red: %lu-bit\n",
335 channel_statistics[RedChannel].depth);
336 (void) fprintf(file," green: %lu-bit\n",
337 channel_statistics[GreenChannel].depth);
338 (void) fprintf(file," blue: %lu-bit\n",
339 channel_statistics[BlueChannel].depth);
340 if (image->matte != MagickFalse)
341 (void) fprintf(file," alpha: %lu-bit\n",
342 channel_statistics[OpacityChannel].depth);
347 (void) fprintf(file," cyan: %lu-bit\n",
348 channel_statistics[CyanChannel].depth);
349 (void) fprintf(file," magenta: %lu-bit\n",
350 channel_statistics[MagentaChannel].depth);
351 (void) fprintf(file," yellow: %lu-bit\n",
352 channel_statistics[YellowChannel].depth);
353 (void) fprintf(file," black: %lu-bit\n",
354 channel_statistics[BlackChannel].depth);
355 if (image->matte != MagickFalse)
356 (void) fprintf(file," alpha: %lu-bit\n",
357 channel_statistics[OpacityChannel].depth);
362 (void) fprintf(file," gray: %lu-bit\n",
363 channel_statistics[GrayChannel].depth);
364 if (image->matte != MagickFalse)
365 (void) fprintf(file," alpha: %lu-bit\n",
366 channel_statistics[OpacityChannel].depth);
371 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
372 scale=QuantumRange/((unsigned long) QuantumRange >> ((unsigned long)
373 MAGICKCORE_QUANTUM_DEPTH-image->depth));
374 (void) fprintf(file," Channel statistics:\n");
380 (void) fprintf(file,IdentifyFormat,"red",(Quantum)
381 (channel_statistics[RedChannel].minima/scale),(double)
382 channel_statistics[RedChannel].minima/(double) QuantumRange,
383 (Quantum) (channel_statistics[RedChannel].maxima/scale),(double)
384 channel_statistics[RedChannel].maxima/(double) QuantumRange,
385 channel_statistics[RedChannel].mean/(double) scale,
386 channel_statistics[RedChannel].mean/(double) QuantumRange,
387 channel_statistics[RedChannel].standard_deviation/(double) scale,
388 channel_statistics[RedChannel].standard_deviation/(double)
389 QuantumRange,channel_statistics[RedChannel].kurtosis,
390 channel_statistics[RedChannel].skewness);
391 (void) fprintf(file,IdentifyFormat,"green",(Quantum)
392 (channel_statistics[GreenChannel].minima/scale),(double)
393 channel_statistics[GreenChannel].minima/(double) QuantumRange,
394 (Quantum) (channel_statistics[GreenChannel].maxima/scale),(double)
395 channel_statistics[GreenChannel].maxima/(double) QuantumRange,
396 channel_statistics[GreenChannel].mean/(double) scale,
397 channel_statistics[GreenChannel].mean/(double) QuantumRange,
398 channel_statistics[GreenChannel].standard_deviation/(double) scale,
399 channel_statistics[GreenChannel].standard_deviation/(double)
401 channel_statistics[GreenChannel].kurtosis,
402 channel_statistics[GreenChannel].skewness);
403 (void) fprintf(file,IdentifyFormat,"blue",(Quantum)
404 (channel_statistics[BlueChannel].minima/scale),(double)
405 channel_statistics[BlueChannel].minima/(double) QuantumRange,
406 (Quantum) (channel_statistics[BlueChannel].maxima/scale),(double)
407 channel_statistics[BlueChannel].maxima/(double) QuantumRange,
408 channel_statistics[BlueChannel].mean/(double) scale,
409 channel_statistics[BlueChannel].mean/(double) QuantumRange,
410 channel_statistics[BlueChannel].standard_deviation/(double) scale,
411 channel_statistics[BlueChannel].standard_deviation/(double)
412 QuantumRange,channel_statistics[BlueChannel].kurtosis,
413 channel_statistics[BlueChannel].skewness);
418 (void) fprintf(file,IdentifyFormat,"cyan",(Quantum)
419 (channel_statistics[CyanChannel].minima/scale),(double)
420 channel_statistics[CyanChannel].minima/(double) QuantumRange,
421 (Quantum) (channel_statistics[CyanChannel].maxima/scale),(double)
422 channel_statistics[CyanChannel].maxima/(double) QuantumRange,
423 channel_statistics[CyanChannel].mean/(double) scale,
424 channel_statistics[CyanChannel].mean/(double) QuantumRange,
425 channel_statistics[CyanChannel].standard_deviation/(double) scale,
426 channel_statistics[CyanChannel].standard_deviation/(double)
427 QuantumRange,channel_statistics[CyanChannel].kurtosis,
428 channel_statistics[CyanChannel].skewness);
429 (void) fprintf(file,IdentifyFormat,"magenta",(Quantum)
430 (channel_statistics[MagentaChannel].minima/scale),(double)
431 channel_statistics[MagentaChannel].minima/(double) QuantumRange,
432 (Quantum) (channel_statistics[MagentaChannel].maxima/scale),(double)
433 channel_statistics[MagentaChannel].maxima/(double) QuantumRange,
434 channel_statistics[MagentaChannel].mean/(double) scale,
435 channel_statistics[MagentaChannel].mean/(double) QuantumRange,
436 channel_statistics[MagentaChannel].standard_deviation/(double)
437 scale,channel_statistics[MagentaChannel].standard_deviation/(double)
438 QuantumRange,channel_statistics[MagentaChannel].kurtosis,
439 channel_statistics[MagentaChannel].skewness);
440 (void) fprintf(file,IdentifyFormat,"yellow",(Quantum)
441 (channel_statistics[YellowChannel].minima/scale),(double)
442 channel_statistics[YellowChannel].minima/(double) QuantumRange,
443 (Quantum) (channel_statistics[YellowChannel].maxima/scale),(double)
444 channel_statistics[YellowChannel].maxima/(double) QuantumRange,
445 channel_statistics[YellowChannel].mean/(double) scale,
446 channel_statistics[YellowChannel].mean/(double) QuantumRange,
447 channel_statistics[YellowChannel].standard_deviation/(double) scale,
448 channel_statistics[YellowChannel].standard_deviation/(double)
449 QuantumRange,channel_statistics[YellowChannel].kurtosis,
450 channel_statistics[YellowChannel].skewness);
451 (void) fprintf(file,IdentifyFormat,"black",(Quantum)
452 (channel_statistics[BlackChannel].minima/scale),(double)
453 channel_statistics[BlackChannel].minima/(double) QuantumRange,
454 (Quantum) (channel_statistics[BlackChannel].maxima/scale),(double)
455 channel_statistics[BlackChannel].maxima/(double) QuantumRange,
456 channel_statistics[BlackChannel].mean/(double) scale,
457 channel_statistics[BlackChannel].mean/(double) QuantumRange,
458 channel_statistics[BlackChannel].standard_deviation/(double) scale,
459 channel_statistics[BlackChannel].standard_deviation/(double)
460 QuantumRange,channel_statistics[BlackChannel].kurtosis,
461 channel_statistics[BlackChannel].skewness);
466 (void) fprintf(file,IdentifyFormat,"gray",(Quantum)
467 (channel_statistics[GrayChannel].minima/scale),(double)
468 channel_statistics[GrayChannel].minima/(double) QuantumRange,
469 (Quantum) (channel_statistics[GrayChannel].maxima/scale),(double)
470 channel_statistics[GrayChannel].maxima/(double) QuantumRange,
471 channel_statistics[GrayChannel].mean/(double) scale,
472 channel_statistics[GrayChannel].mean/(double) QuantumRange,
473 channel_statistics[GrayChannel].standard_deviation/(double) scale,
474 channel_statistics[GrayChannel].standard_deviation/(double)
475 QuantumRange,channel_statistics[GrayChannel].kurtosis,
476 channel_statistics[GrayChannel].skewness);
480 if (image->matte != MagickFalse)
481 (void) fprintf(file,IdentifyFormat,"alpha",(Quantum)
482 ((QuantumRange-channel_statistics[AlphaChannel].maxima)/scale),
483 (double) (QuantumRange-channel_statistics[AlphaChannel].maxima)/
484 (double) QuantumRange, (Quantum) ((QuantumRange-
485 channel_statistics[AlphaChannel].minima)/scale),(double)
486 (QuantumRange-channel_statistics[AlphaChannel].minima)/(double)
487 QuantumRange,(QuantumRange-channel_statistics[AlphaChannel].mean)/
488 (double) scale,(QuantumRange-channel_statistics[AlphaChannel].mean)/
489 (double) QuantumRange,
490 channel_statistics[AlphaChannel].standard_deviation/(double) scale,
491 channel_statistics[AlphaChannel].standard_deviation/(double)
492 QuantumRange,channel_statistics[AlphaChannel].kurtosis,
493 channel_statistics[AlphaChannel].skewness);
494 if (colorspace != GRAYColorspace)
496 (void) fprintf(file," Image statistics:\n");
497 (void) fprintf(file,IdentifyFormat,"Overall",(Quantum)
498 (channel_statistics[AllChannels].minima/scale),(double)
499 channel_statistics[AllChannels].minima/(double) QuantumRange,
500 (Quantum) (channel_statistics[AllChannels].maxima/scale),(double)
501 channel_statistics[AllChannels].maxima/(double) QuantumRange,
502 channel_statistics[AllChannels].mean/(double) scale,
503 channel_statistics[AllChannels].mean/(double) QuantumRange,
504 channel_statistics[AllChannels].standard_deviation/(double) scale,
505 channel_statistics[AllChannels].standard_deviation/(double)
506 QuantumRange,channel_statistics[AllChannels].kurtosis,
507 channel_statistics[AllChannels].skewness);
509 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
511 artifact=GetImageArtifact(image,"identify:features");
512 if ((artifact != (const char *) NULL) &&
513 (IsMagickTrue(artifact) != MagickFalse) && (ping == MagickFalse))
518 channel_features=GetImageChannelFeatures(image,1,&image->exception);
519 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
522 if (image->colorspace == CMYKColorspace)
523 (void) fprintf(file," Total ink density: %.0f%%\n",100.0*
524 GetImageTotalInkDensity(image)/(double) QuantumRange);
526 if (image->matte != MagickFalse)
528 register const IndexPacket
531 register const PixelPacket
534 p=(PixelPacket *) NULL;
535 indexes=(IndexPacket *) NULL;
536 for (y=0; y < (long) image->rows; y++)
538 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
539 if (p == (const PixelPacket *) NULL)
541 indexes=GetVirtualIndexQueue(image);
542 for (x=0; x < (long) image->columns; x++)
544 if (p->opacity == (Quantum) TransparentOpacity)
548 if (x < (long) image->columns)
551 if ((x < (long) image->columns) || (y < (long) image->rows))
554 tuple[MaxTextExtent];
559 GetMagickPixelPacket(image,&pixel);
560 SetMagickPixelPacket(image,p,indexes+x,&pixel);
561 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
563 (void) fprintf(file," Alpha: %s ",tuple);
564 GetColorTuple(&pixel,MagickTrue,tuple);
565 (void) fprintf(file," %s\n",tuple);
568 artifact=GetImageArtifact(image,"identify:unique");
569 if ((artifact != (const char *) NULL) &&
570 (IsMagickTrue(artifact) != MagickFalse))
571 (void) fprintf(file," Colors: %lu\n",GetNumberColors(image,
572 (FILE *) NULL,&image->exception));
573 if (IsHistogramImage(image,&image->exception) != MagickFalse)
575 (void) fprintf(file," Histogram:\n");
576 (void) GetNumberColors(image,file,&image->exception);
579 if (image->storage_class == PseudoClass)
581 (void) fprintf(file," Colormap: %lu\n",image->colors);
582 if (image->colors <= 1024)
585 color[MaxTextExtent],
587 tuple[MaxTextExtent];
595 GetMagickPixelPacket(image,&pixel);
597 for (i=0; i < (long) image->colors; i++)
599 SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
600 (void) CopyMagickString(tuple,"(",MaxTextExtent);
601 ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
602 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
603 ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
604 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
605 ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
606 if (pixel.colorspace == CMYKColorspace)
608 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
609 ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
612 if (pixel.matte != MagickFalse)
614 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
615 ConcatenateColorComponent(&pixel,OpacityChannel,X11Compliance,
618 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
619 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
621 GetColorTuple(&pixel,MagickTrue,hex);
622 (void) fprintf(file," %8ld: %s %s %s\n",i,tuple,hex,color);
627 if (image->error.mean_error_per_pixel != 0.0)
628 (void) fprintf(file," Mean error per pixel: %g\n",
629 image->error.mean_error_per_pixel);
630 if (image->error.normalized_mean_error != 0.0)
631 (void) fprintf(file," Normalized mean error: %g\n",
632 image->error.normalized_mean_error);
633 if (image->error.normalized_maximum_error != 0.0)
634 (void) fprintf(file," Normalized maximum error: %g\n",
635 image->error.normalized_maximum_error);
636 (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic(
637 MagickIntentOptions,(long) image->rendering_intent));
638 if (image->gamma != 0.0)
639 (void) fprintf(file," Gamma: %g\n",image->gamma);
640 if ((image->chromaticity.red_primary.x != 0.0) ||
641 (image->chromaticity.green_primary.x != 0.0) ||
642 (image->chromaticity.blue_primary.x != 0.0) ||
643 (image->chromaticity.white_point.x != 0.0))
646 Display image chromaticity.
648 (void) fprintf(file," Chromaticity:\n");
649 (void) fprintf(file," red primary: (%g,%g)\n",
650 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
651 (void) fprintf(file," green primary: (%g,%g)\n",
652 image->chromaticity.green_primary.x,
653 image->chromaticity.green_primary.y);
654 (void) fprintf(file," blue primary: (%g,%g)\n",
655 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
656 (void) fprintf(file," white point: (%g,%g)\n",
657 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
659 if ((image->extract_info.width*image->extract_info.height) != 0)
660 (void) fprintf(file," Tile geometry: %lux%lu%+ld%+ld\n",
661 image->extract_info.width,image->extract_info.height,
662 image->extract_info.x,image->extract_info.y);
663 (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic(
664 MagickInterlaceOptions,(long) image->interlace));
665 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
667 (void) fprintf(file," Background color: %s\n",color);
668 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
670 (void) fprintf(file," Border color: %s\n",color);
671 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
673 (void) fprintf(file," Matte color: %s\n",color);
674 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
676 (void) fprintf(file," Transparent color: %s\n",color);
677 (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic(
678 MagickComposeOptions,(long) image->compose));
679 if ((image->page.width != 0) || (image->page.height != 0) ||
680 (image->page.x != 0) || (image->page.y != 0))
681 (void) fprintf(file," Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
682 image->page.height,image->page.x,image->page.y);
683 if ((image->page.x != 0) || (image->page.y != 0))
684 (void) fprintf(file," Origin geometry: %+ld%+ld\n",image->page.x,
686 (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic(
687 MagickDisposeOptions,(long) image->dispose));
688 if (image->delay != 0)
689 (void) fprintf(file," Delay: %lux%ld\n",image->delay,
690 image->ticks_per_second);
691 if (image->iterations != 1)
692 (void) fprintf(file," Iterations: %lu\n",image->iterations);
693 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
694 (void) fprintf(file," Scene: %lu of %lu\n",image->scene,
695 GetImageListLength(image));
697 if (image->scene != 0)
698 (void) fprintf(file," Scene: %lu\n",image->scene);
699 (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic(
700 MagickCompressOptions,(long) image->compression));
701 if (image->quality != UndefinedCompressionQuality)
702 (void) fprintf(file," Quality: %lu\n",image->quality);
703 (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic(
704 MagickOrientationOptions,(long) image->orientation));
705 if (image->montage != (char *) NULL)
706 (void) fprintf(file," Montage: %s\n",image->montage);
707 if (image->directory != (char *) NULL)
723 Display visual image directory.
725 image_info=AcquireImageInfo();
726 (void) CloneString(&image_info->size,"64x64");
727 (void) fprintf(file," Directory:\n");
728 for (p=image->directory; *p != '\0'; p++)
731 while ((*q != '\n') && (*q != '\0'))
733 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
735 (void) fprintf(file," %s",image_info->filename);
736 handler=SetWarningHandler((WarningHandler) NULL);
737 tile=ReadImage(image_info,&image->exception);
738 (void) SetWarningHandler(handler);
739 if (tile == (Image *) NULL)
741 (void) fprintf(file,"\n");
744 (void) fprintf(file," %lux%lu %s\n",tile->magick_columns,
745 tile->magick_rows,tile->magick);
746 (void) SignatureImage(tile);
747 ResetImagePropertyIterator(tile);
748 property=GetNextImageProperty(tile);
749 while (property != (const char *) NULL)
751 (void) fprintf(file," %s:\n",property);
752 value=GetImageProperty(tile,property);
753 if (value != (const char *) NULL)
754 (void) fprintf(file,"%s\n",value);
755 property=GetNextImageProperty(tile);
757 tile=DestroyImage(tile);
759 image_info=DestroyImageInfo(image_info);
761 (void) GetImageProperty(image,"exif:*");
762 ResetImagePropertyIterator(image);
763 property=GetNextImageProperty(image);
764 if (property != (const char *) NULL)
767 Display image properties.
769 (void) fprintf(file," Properties:\n");
770 while (property != (const char *) NULL)
772 (void) fprintf(file," %c",*property);
773 if (strlen(property) > 1)
774 (void) fprintf(file,"%s: ",property+1);
775 if (strlen(property) > 80)
776 (void) fputc('\n',file);
777 value=GetImageProperty(image,property);
778 if (value != (const char *) NULL)
779 (void) fprintf(file,"%s\n",value);
780 property=GetNextImageProperty(image);
783 (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1");
784 value=GetImageProperty(image,key);
785 if (value != (const char *) NULL)
788 Display clipping path.
790 (void) fprintf(file," Clipping path: ");
791 if (strlen(value) > 80)
792 (void) fputc('\n',file);
793 (void) fprintf(file,"%s\n",value);
795 ResetImageProfileIterator(image);
796 name=GetNextImageProfile(image);
797 if (name != (char *) NULL)
803 Identify image profiles.
805 (void) fprintf(file," Profiles:\n");
806 while (name != (char *) NULL)
808 profile=GetImageProfile(image,name);
809 if (profile == (StringInfo *) NULL)
811 (void) fprintf(file," Profile-%s: %lu bytes\n",name,(unsigned long)
812 GetStringInfoLength(profile));
813 #if defined(MAGICKCORE_LCMS_DELEGATE)
814 if ((LocaleCompare(name,"icc") == 0) ||
815 (LocaleCompare(name,"icm") == 0))
820 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
821 (DWORD) GetStringInfoLength(profile));
822 if (icc_profile != (cmsHPROFILE *) NULL)
827 name=cmsTakeProductName(icc_profile);
828 if (name != (const char *) NULL)
829 (void) fprintf(file," %s\n",name);
830 (void) cmsCloseProfile(icc_profile);
834 if (LocaleCompare(name,"iptc") == 0)
855 profile_length=GetStringInfoLength(profile);
856 for (i=0; i < (long) profile_length; i+=(long) length)
859 sentinel=GetStringInfoDatum(profile)[i++];
860 if (sentinel != 0x1c)
862 dataset=GetStringInfoDatum(profile)[i++];
863 record=GetStringInfoDatum(profile)[i++];
866 case 5: tag="Image Name"; break;
867 case 7: tag="Edit Status"; break;
868 case 10: tag="Priority"; break;
869 case 15: tag="Category"; break;
870 case 20: tag="Supplemental Category"; break;
871 case 22: tag="Fixture Identifier"; break;
872 case 25: tag="Keyword"; break;
873 case 30: tag="Release Date"; break;
874 case 35: tag="Release Time"; break;
875 case 40: tag="Special Instructions"; break;
876 case 45: tag="Reference Service"; break;
877 case 47: tag="Reference Date"; break;
878 case 50: tag="Reference Number"; break;
879 case 55: tag="Created Date"; break;
880 case 60: tag="Created Time"; break;
881 case 65: tag="Originating Program"; break;
882 case 70: tag="Program Version"; break;
883 case 75: tag="Object Cycle"; break;
884 case 80: tag="Byline"; break;
885 case 85: tag="Byline Title"; break;
886 case 90: tag="City"; break;
887 case 95: tag="Province State"; break;
888 case 100: tag="Country Code"; break;
889 case 101: tag="Country"; break;
890 case 103: tag="Original Transmission Reference"; break;
891 case 105: tag="Headline"; break;
892 case 110: tag="Credit"; break;
893 case 115: tag="Src"; break;
894 case 116: tag="Copyright String"; break;
895 case 120: tag="Caption"; break;
896 case 121: tag="Local Caption"; break;
897 case 122: tag="Caption Writer"; break;
898 case 200: tag="Custom Field 1"; break;
899 case 201: tag="Custom Field 2"; break;
900 case 202: tag="Custom Field 3"; break;
901 case 203: tag="Custom Field 4"; break;
902 case 204: tag="Custom Field 5"; break;
903 case 205: tag="Custom Field 6"; break;
904 case 206: tag="Custom Field 7"; break;
905 case 207: tag="Custom Field 8"; break;
906 case 208: tag="Custom Field 9"; break;
907 case 209: tag="Custom Field 10"; break;
908 case 210: tag="Custom Field 11"; break;
909 case 211: tag="Custom Field 12"; break;
910 case 212: tag="Custom Field 13"; break;
911 case 213: tag="Custom Field 14"; break;
912 case 214: tag="Custom Field 15"; break;
913 case 215: tag="Custom Field 16"; break;
914 case 216: tag="Custom Field 17"; break;
915 case 217: tag="Custom Field 18"; break;
916 case 218: tag="Custom Field 19"; break;
917 case 219: tag="Custom Field 20"; break;
918 default: tag="unknown"; break;
920 (void) fprintf(file," %s[%ld,%ld]: ",tag,dataset,record);
921 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
922 length|=GetStringInfoDatum(profile)[i++];
923 attribute=(char *) NULL;
924 if (~length >= MaxTextExtent)
925 attribute=(char *) AcquireQuantumMemory(length+
926 MaxTextExtent,sizeof(*attribute));
927 if (attribute != (char *) NULL)
929 (void) CopyMagickString(attribute,(char *)
930 GetStringInfoDatum(profile)+i,length+1);
931 attribute_list=StringToList(attribute);
932 if (attribute_list != (char **) NULL)
934 for (j=0; attribute_list[j] != (char *) NULL; j++)
936 (void) fputs(attribute_list[j],file);
937 (void) fputs("\n",file);
938 attribute_list[j]=(char *) RelinquishMagickMemory(
941 attribute_list=(char **) RelinquishMagickMemory(
944 attribute=DestroyString(attribute);
948 if (image->debug != MagickFalse)
949 PrintStringInfo(file,name,profile);
950 name=GetNextImageProfile(image);
953 ResetImageArtifactIterator(image);
954 artifact=GetNextImageArtifact(image);
955 if (artifact != (const char *) NULL)
958 Display image artifacts.
960 (void) fprintf(file," Artifacts:\n");
961 while (artifact != (const char *) NULL)
963 (void) fprintf(file," %c",*artifact);
964 if (strlen(artifact) > 1)
965 (void) fprintf(file,"%s: ",artifact+1);
966 if (strlen(artifact) > 80)
967 (void) fputc('\n',file);
968 value=GetImageArtifact(image,artifact);
969 if (value != (const char *) NULL)
970 (void) fprintf(file,"%s\n",value);
971 artifact=GetNextImageArtifact(image);
974 ResetImageRegistryIterator();
975 registry=GetNextImageRegistry();
976 if (registry != (const char *) NULL)
979 Display image registry.
981 (void) fprintf(file," Registry:\n");
982 while (registry != (const char *) NULL)
984 (void) fprintf(file," %c",*registry);
985 if (strlen(registry) > 1)
986 (void) fprintf(file,"%s: ",registry+1);
987 if (strlen(registry) > 80)
988 (void) fputc('\n',file);
989 value=(const char *) GetImageRegistry(StringRegistryType,registry,
991 if (value != (const char *) NULL)
992 (void) fprintf(file,"%s\n",value);
993 registry=GetNextImageRegistry();
996 (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic(
997 MagickBooleanOptions,(long) image->taint));
998 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
999 (void) fprintf(file," Filesize: %s\n",format);
1000 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1001 MagickFalse,format);
1002 (void) fprintf(file," Number pixels: %s\n",format);
1003 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
1004 elapsed_time+0.5),MagickFalse,format);
1005 (void) fprintf(file," Pixels per second: %s\n",format);
1006 (void) fprintf(file," User time: %0.3fu\n",user_time);
1007 (void) fprintf(file," Elapsed time: %ld:%02ld.%03ld\n",(long)
1008 (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),(long)
1009 (1000.0*(elapsed_time-floor(elapsed_time))));
1010 (void) fprintf(file," Version: %s\n",GetMagickVersion((unsigned long *)
1012 (void) fflush(file);
1013 return(ferror(file) != 0 ? MagickFalse : MagickTrue);