blob: 2da90ae58d458c945b361c3cb7e7c4f1e770d44d [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
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 %
11% %
12% %
13% Identify an Image Format and Characteristics. %
14% %
15% Software Design %
16% John Cristy %
17% September 1994 %
18% %
19% %
20% Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization %
21% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
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. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
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.
38%
39%
40*/
41
42/*
43 Include declarations.
44*/
45#include "magick/studio.h"
46#include "magick/annotate.h"
47#include "magick/artifact.h"
cristy78e9c762009-10-14 19:36:18 +000048#include "magick/attribute.h"
cristy3ed852e2009-09-05 21:47:34 +000049#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/gem.h"
63#include "magick/geometry.h"
cristyf2e11662009-10-14 01:24:43 +000064#include "magick/histogram.h"
cristy3ed852e2009-09-05 21:47:34 +000065#include "magick/identify.h"
66#include "magick/image.h"
67#include "magick/image-private.h"
68#include "magick/list.h"
69#include "magick/locale_.h"
70#include "magick/log.h"
71#include "magick/magic.h"
72#include "magick/magick.h"
73#include "magick/memory_.h"
74#include "magick/module.h"
75#include "magick/monitor.h"
76#include "magick/montage.h"
77#include "magick/option.h"
78#include "magick/pixel-private.h"
79#include "magick/prepress.h"
80#include "magick/profile.h"
81#include "magick/property.h"
82#include "magick/quantize.h"
83#include "magick/quantum.h"
84#include "magick/random_.h"
85#include "magick/registry.h"
86#include "magick/resize.h"
87#include "magick/resource_.h"
88#include "magick/signature.h"
89#include "magick/statistic.h"
90#include "magick/string_.h"
91#include "magick/timer.h"
92#include "magick/utility.h"
93#include "magick/version.h"
94#if defined(MAGICKCORE_LCMS_DELEGATE)
95#if defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
96#include <lcms/lcms.h>
97#else
98#include "lcms.h"
99#endif
100#endif
101
102/*
103%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104% %
105% %
106% %
107% I d e n t i f y I m a g e %
108% %
109% %
110% %
111%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112%
113% IdentifyImage() identifies an image by printing its attributes to the file.
114% Attributes include the image width, height, size, and others.
115%
116% The format of the IdentifyImage method is:
117%
118% MagickBooleanType IdentifyImage(Image *image,FILE *file,
119% const MagickBooleanType verbose)
120%
121% A description of each parameter follows:
122%
123% o image: the image.
124%
125% o file: the file, typically stdout.
126%
127% o verbose: A value other than zero prints more detailed information
128% about the image.
129%
130*/
131
132MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
133 const MagickBooleanType verbose)
134{
135#define IdentifyFormat " %s:\n min: " QuantumFormat \
cristye7f51092010-01-17 00:39:37 +0000136 " (%g)\n max: " QuantumFormat " (%g)\n" \
137 " mean: %g (%g)\n standard deviation: %g (%g)\n" \
138 " kurtosis: %g\n skewness: %g\n"
cristy3ed852e2009-09-05 21:47:34 +0000139
140 char
141 color[MaxTextExtent],
142 format[MaxTextExtent],
143 key[MaxTextExtent];
144
145 ColorspaceType
146 colorspace;
147
148 const char
149 *artifact,
150 *name,
151 *property,
152 *registry,
153 *value;
154
155 const MagickInfo
156 *magick_info;
157
158 const PixelPacket
159 *pixels;
160
161 double
162 elapsed_time,
163 user_time;
164
165 ExceptionInfo
166 *exception;
167
168 ImageType
169 type;
170
171 long
172 y;
173
174 MagickBooleanType
175 ping;
176
177 register long
178 i,
179 x;
180
181 unsigned long
182 scale;
183
184 assert(image != (Image *) NULL);
185 assert(image->signature == MagickSignature);
186 if (image->debug != MagickFalse)
187 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
188 if (file == (FILE *) NULL)
189 file=stdout;
190 *format='\0';
191 elapsed_time=GetElapsedTime(&image->timer);
192 user_time=GetUserTime(&image->timer);
193 GetTimerInfo(&image->timer);
194 if (verbose == MagickFalse)
195 {
196 /*
197 Display summary info about the image.
198 */
199 if (*image->magick_filename != '\0')
200 if (LocaleCompare(image->magick_filename,image->filename) != 0)
201 (void) fprintf(file,"%s=>",image->magick_filename);
202 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
203 (GetNextImageInList(image) == (Image *) NULL) && (image->scene == 0))
204 (void) fprintf(file,"%s ",image->filename);
205 else
206 (void) fprintf(file,"%s[%lu] ",image->filename,image->scene);
207 (void) fprintf(file,"%s ",image->magick);
208 if ((image->magick_columns != 0) || (image->magick_rows != 0))
209 if ((image->magick_columns != image->columns) ||
210 (image->magick_rows != image->rows))
211 (void) fprintf(file,"%lux%lu=>",image->magick_columns,
212 image->magick_rows);
213 (void) fprintf(file,"%lux%lu ",image->columns,image->rows);
214 if ((image->page.width != 0) || (image->page.height != 0) ||
215 (image->page.x != 0) || (image->page.y != 0))
216 (void) fprintf(file,"%lux%lu%+ld%+ld ",image->page.width,
217 image->page.height,image->page.x,image->page.y);
218 (void) fprintf(file,"%lu-bit ",image->depth);
219 if (image->type != UndefinedType)
220 (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
221 (long) image->type));
222 if (image->storage_class == DirectClass)
223 {
224 (void) fprintf(file,"DirectClass ");
225 if (image->total_colors != 0)
226 {
cristyb9080c92009-12-01 20:13:26 +0000227 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +0000228 (void) fprintf(file,"%s ",format);
229 }
230 }
231 else
232 if (image->total_colors <= image->colors)
233 (void) fprintf(file,"PseudoClass %luc ",image->colors);
234 else
235 (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors,
236 image->colors);
237 if (image->error.mean_error_per_pixel != 0.0)
238 (void) fprintf(file,"%ld/%f/%fdb ",(long)
239 (image->error.mean_error_per_pixel+0.5),
240 image->error.normalized_mean_error,
241 image->error.normalized_maximum_error);
242 if (GetBlobSize(image) != 0)
243 {
cristyb9080c92009-12-01 20:13:26 +0000244 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +0000245 (void) fprintf(file,"%s ",format);
246 }
cristy3d231692009-09-29 01:05:22 +0000247 (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(long)
248 (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
249 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
cristy3ed852e2009-09-05 21:47:34 +0000250 (void) fprintf(file,"\n");
251 (void) fflush(file);
252 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
253 }
254 /*
255 Display verbose info about the image.
256 */
257 exception=AcquireExceptionInfo();
258 pixels=GetVirtualPixels(image,0,0,1,1,exception);
259 exception=DestroyExceptionInfo(exception);
260 ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
261 type=GetImageType(image,&image->exception);
262 (void) SignatureImage(image);
263 (void) fprintf(file,"Image: %s\n",image->filename);
264 if (*image->magick_filename != '\0')
265 if (LocaleCompare(image->magick_filename,image->filename) != 0)
266 {
267 char
268 filename[MaxTextExtent];
269
270 GetPathComponent(image->magick_filename,TailPath,filename);
271 (void) fprintf(file," Base filename: %s\n",filename);
272 }
273 magick_info=GetMagickInfo(image->magick,&image->exception);
274 if ((magick_info == (const MagickInfo *) NULL) ||
275 (*GetMagickDescription(magick_info) == '\0'))
276 (void) fprintf(file," Format: %s\n",image->magick);
277 else
278 (void) fprintf(file," Format: %s (%s)\n",image->magick,
279 GetMagickDescription(magick_info));
280 (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
281 (long) image->storage_class));
282 (void) fprintf(file," Geometry: %lux%lu%+ld%+ld\n",image->columns,
283 image->rows,image->tile_offset.x,image->tile_offset.y);
284 if ((image->magick_columns != 0) || (image->magick_rows != 0))
285 if ((image->magick_columns != image->columns) ||
286 (image->magick_rows != image->rows))
287 (void) fprintf(file," Base geometry: %lux%lu\n",image->magick_columns,
288 image->magick_rows);
289 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
290 {
cristye7f51092010-01-17 00:39:37 +0000291 (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution,
cristy3ed852e2009-09-05 21:47:34 +0000292 image->y_resolution);
cristye7f51092010-01-17 00:39:37 +0000293 (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/
cristy3ed852e2009-09-05 21:47:34 +0000294 image->x_resolution,(double) image->rows/image->y_resolution);
295 }
296 (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic(
297 MagickResolutionOptions,(long) image->units));
298 (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
299 (long) type));
300 if (image->type != UndefinedType)
301 (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic(
302 MagickTypeOptions,(long) image->type));
303 (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic(
304 MagickEndianOptions,(long) image->endian));
305 /*
306 Detail channel depth and extrema.
307 */
308 (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic(
309 MagickColorspaceOptions,(long) image->colorspace));
310 if (ping == MagickFalse)
311 {
312 ChannelStatistics
313 *channel_statistics;
314
315 unsigned long
316 depth;
317
318 depth=GetImageDepth(image,&image->exception);
319 if (image->depth == depth)
320 (void) fprintf(file," Depth: %lu-bit\n",image->depth);
321 else
322 (void) fprintf(file," Depth: %lu/%lu-bit\n",image->depth,depth);
323 channel_statistics=GetImageChannelStatistics(image,&image->exception);
324 (void) fprintf(file," Channel depth:\n");
325 colorspace=image->colorspace;
326 if (IsGrayImage(image,&image->exception) != MagickFalse)
327 colorspace=GRAYColorspace;
328 switch (colorspace)
329 {
330 case RGBColorspace:
331 default:
332 {
333 (void) fprintf(file," red: %lu-bit\n",
334 channel_statistics[RedChannel].depth);
335 (void) fprintf(file," green: %lu-bit\n",
336 channel_statistics[GreenChannel].depth);
337 (void) fprintf(file," blue: %lu-bit\n",
338 channel_statistics[BlueChannel].depth);
339 if (image->matte != MagickFalse)
340 (void) fprintf(file," alpha: %lu-bit\n",
341 channel_statistics[OpacityChannel].depth);
342 break;
343 }
344 case CMYKColorspace:
345 {
346 (void) fprintf(file," cyan: %lu-bit\n",
347 channel_statistics[CyanChannel].depth);
348 (void) fprintf(file," magenta: %lu-bit\n",
349 channel_statistics[MagentaChannel].depth);
350 (void) fprintf(file," yellow: %lu-bit\n",
351 channel_statistics[YellowChannel].depth);
352 (void) fprintf(file," black: %lu-bit\n",
353 channel_statistics[BlackChannel].depth);
354 if (image->matte != MagickFalse)
355 (void) fprintf(file," alpha: %lu-bit\n",
356 channel_statistics[OpacityChannel].depth);
357 break;
358 }
359 case GRAYColorspace:
360 {
361 (void) fprintf(file," gray: %lu-bit\n",
362 channel_statistics[GrayChannel].depth);
363 if (image->matte != MagickFalse)
364 (void) fprintf(file," alpha: %lu-bit\n",
365 channel_statistics[OpacityChannel].depth);
366 break;
367 }
368 }
369 scale=1;
370 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
371 scale=QuantumRange/((unsigned long) QuantumRange >> ((unsigned long)
372 MAGICKCORE_QUANTUM_DEPTH-image->depth));
373 (void) fprintf(file," Channel statistics:\n");
374 switch (colorspace)
375 {
376 case RGBColorspace:
377 default:
378 {
379 (void) fprintf(file,IdentifyFormat,"red",(Quantum)
380 (channel_statistics[RedChannel].minima/scale),(double)
381 channel_statistics[RedChannel].minima/(double) QuantumRange,
382 (Quantum) (channel_statistics[RedChannel].maxima/scale),(double)
383 channel_statistics[RedChannel].maxima/(double) QuantumRange,
384 channel_statistics[RedChannel].mean/(double) scale,
385 channel_statistics[RedChannel].mean/(double) QuantumRange,
386 channel_statistics[RedChannel].standard_deviation/(double) scale,
387 channel_statistics[RedChannel].standard_deviation/(double)
388 QuantumRange,channel_statistics[RedChannel].kurtosis,
389 channel_statistics[RedChannel].skewness);
390 (void) fprintf(file,IdentifyFormat,"green",(Quantum)
391 (channel_statistics[GreenChannel].minima/scale),(double)
392 channel_statistics[GreenChannel].minima/(double) QuantumRange,
393 (Quantum) (channel_statistics[GreenChannel].maxima/scale),(double)
394 channel_statistics[GreenChannel].maxima/(double) QuantumRange,
395 channel_statistics[GreenChannel].mean/(double) scale,
396 channel_statistics[GreenChannel].mean/(double) QuantumRange,
397 channel_statistics[GreenChannel].standard_deviation/(double) scale,
398 channel_statistics[GreenChannel].standard_deviation/(double)
399 QuantumRange,
400 channel_statistics[GreenChannel].kurtosis,
401 channel_statistics[GreenChannel].skewness);
402 (void) fprintf(file,IdentifyFormat,"blue",(Quantum)
403 (channel_statistics[BlueChannel].minima/scale),(double)
404 channel_statistics[BlueChannel].minima/(double) QuantumRange,
405 (Quantum) (channel_statistics[BlueChannel].maxima/scale),(double)
406 channel_statistics[BlueChannel].maxima/(double) QuantumRange,
407 channel_statistics[BlueChannel].mean/(double) scale,
408 channel_statistics[BlueChannel].mean/(double) QuantumRange,
409 channel_statistics[BlueChannel].standard_deviation/(double) scale,
410 channel_statistics[BlueChannel].standard_deviation/(double)
411 QuantumRange,channel_statistics[BlueChannel].kurtosis,
412 channel_statistics[BlueChannel].skewness);
413 break;
414 }
415 case CMYKColorspace:
416 {
417 (void) fprintf(file,IdentifyFormat,"cyan",(Quantum)
418 (channel_statistics[CyanChannel].minima/scale),(double)
419 channel_statistics[CyanChannel].minima/(double) QuantumRange,
420 (Quantum) (channel_statistics[CyanChannel].maxima/scale),(double)
421 channel_statistics[CyanChannel].maxima/(double) QuantumRange,
422 channel_statistics[CyanChannel].mean/(double) scale,
423 channel_statistics[CyanChannel].mean/(double) QuantumRange,
424 channel_statistics[CyanChannel].standard_deviation/(double) scale,
425 channel_statistics[CyanChannel].standard_deviation/(double)
426 QuantumRange,channel_statistics[CyanChannel].kurtosis,
427 channel_statistics[CyanChannel].skewness);
428 (void) fprintf(file,IdentifyFormat,"magenta",(Quantum)
429 (channel_statistics[MagentaChannel].minima/scale),(double)
430 channel_statistics[MagentaChannel].minima/(double) QuantumRange,
431 (Quantum) (channel_statistics[MagentaChannel].maxima/scale),(double)
432 channel_statistics[MagentaChannel].maxima/(double) QuantumRange,
433 channel_statistics[MagentaChannel].mean/(double) scale,
434 channel_statistics[MagentaChannel].mean/(double) QuantumRange,
435 channel_statistics[MagentaChannel].standard_deviation/(double)
436 scale,channel_statistics[MagentaChannel].standard_deviation/(double)
437 QuantumRange,channel_statistics[MagentaChannel].kurtosis,
438 channel_statistics[MagentaChannel].skewness);
439 (void) fprintf(file,IdentifyFormat,"yellow",(Quantum)
440 (channel_statistics[YellowChannel].minima/scale),(double)
441 channel_statistics[YellowChannel].minima/(double) QuantumRange,
442 (Quantum) (channel_statistics[YellowChannel].maxima/scale),(double)
443 channel_statistics[YellowChannel].maxima/(double) QuantumRange,
444 channel_statistics[YellowChannel].mean/(double) scale,
445 channel_statistics[YellowChannel].mean/(double) QuantumRange,
446 channel_statistics[YellowChannel].standard_deviation/(double) scale,
447 channel_statistics[YellowChannel].standard_deviation/(double)
448 QuantumRange,channel_statistics[YellowChannel].kurtosis,
449 channel_statistics[YellowChannel].skewness);
450 (void) fprintf(file,IdentifyFormat,"black",(Quantum)
451 (channel_statistics[BlackChannel].minima/scale),(double)
452 channel_statistics[BlackChannel].minima/(double) QuantumRange,
453 (Quantum) (channel_statistics[BlackChannel].maxima/scale),(double)
454 channel_statistics[BlackChannel].maxima/(double) QuantumRange,
455 channel_statistics[BlackChannel].mean/(double) scale,
456 channel_statistics[BlackChannel].mean/(double) QuantumRange,
457 channel_statistics[BlackChannel].standard_deviation/(double) scale,
458 channel_statistics[BlackChannel].standard_deviation/(double)
459 QuantumRange,channel_statistics[BlackChannel].kurtosis,
460 channel_statistics[BlackChannel].skewness);
461 break;
462 }
463 case GRAYColorspace:
464 {
465 (void) fprintf(file,IdentifyFormat,"gray",(Quantum)
466 (channel_statistics[GrayChannel].minima/scale),(double)
467 channel_statistics[GrayChannel].minima/(double) QuantumRange,
468 (Quantum) (channel_statistics[GrayChannel].maxima/scale),(double)
469 channel_statistics[GrayChannel].maxima/(double) QuantumRange,
470 channel_statistics[GrayChannel].mean/(double) scale,
471 channel_statistics[GrayChannel].mean/(double) QuantumRange,
472 channel_statistics[GrayChannel].standard_deviation/(double) scale,
473 channel_statistics[GrayChannel].standard_deviation/(double)
474 QuantumRange,channel_statistics[GrayChannel].kurtosis,
475 channel_statistics[GrayChannel].skewness);
476 break;
477 }
478 }
479 if (image->matte != MagickFalse)
480 (void) fprintf(file,IdentifyFormat,"alpha",(Quantum)
481 ((QuantumRange-channel_statistics[AlphaChannel].maxima)/scale),
482 (double) (QuantumRange-channel_statistics[AlphaChannel].maxima)/
483 (double) QuantumRange, (Quantum) ((QuantumRange-
484 channel_statistics[AlphaChannel].minima)/scale),(double)
485 (QuantumRange-channel_statistics[AlphaChannel].minima)/(double)
486 QuantumRange,(QuantumRange-channel_statistics[AlphaChannel].mean)/
487 (double) scale,(QuantumRange-channel_statistics[AlphaChannel].mean)/
488 (double) QuantumRange,
489 channel_statistics[AlphaChannel].standard_deviation/(double) scale,
490 channel_statistics[AlphaChannel].standard_deviation/(double)
491 QuantumRange,channel_statistics[AlphaChannel].kurtosis,
492 channel_statistics[AlphaChannel].skewness);
493 if (colorspace != GRAYColorspace)
494 {
495 (void) fprintf(file," Image statistics:\n");
496 (void) fprintf(file,IdentifyFormat,"Overall",(Quantum)
497 (channel_statistics[AllChannels].minima/scale),(double)
498 channel_statistics[AllChannels].minima/(double) QuantumRange,
499 (Quantum) (channel_statistics[AllChannels].maxima/scale),(double)
500 channel_statistics[AllChannels].maxima/(double) QuantumRange,
501 channel_statistics[AllChannels].mean/(double) scale,
502 channel_statistics[AllChannels].mean/(double) QuantumRange,
503 channel_statistics[AllChannels].standard_deviation/(double) scale,
504 channel_statistics[AllChannels].standard_deviation/(double)
505 QuantumRange,channel_statistics[AllChannels].kurtosis,
506 channel_statistics[AllChannels].skewness);
507 }
508 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
509 channel_statistics);
510 if (image->colorspace == CMYKColorspace)
511 (void) fprintf(file," Total ink density: %.0f%%\n",100.0*
512 GetImageTotalInkDensity(image)/(double) QuantumRange);
513 x=0;
514 if (image->matte != MagickFalse)
515 {
516 register const IndexPacket
517 *indexes;
518
519 register const PixelPacket
520 *p;
521
522 p=(PixelPacket *) NULL;
523 indexes=(IndexPacket *) NULL;
524 for (y=0; y < (long) image->rows; y++)
525 {
526 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
527 if (p == (const PixelPacket *) NULL)
528 break;
529 indexes=GetVirtualIndexQueue(image);
530 for (x=0; x < (long) image->columns; x++)
531 {
532 if (p->opacity == (Quantum) TransparentOpacity)
533 break;
534 p++;
535 }
536 if (x < (long) image->columns)
537 break;
538 }
539 if ((x < (long) image->columns) || (y < (long) image->rows))
540 {
541 char
542 tuple[MaxTextExtent];
543
544 MagickPixelPacket
545 pixel;
546
547 GetMagickPixelPacket(image,&pixel);
548 SetMagickPixelPacket(image,p,indexes+x,&pixel);
549 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
550 &image->exception);
551 (void) fprintf(file," Alpha: %s ",tuple);
552 GetColorTuple(&pixel,MagickTrue,tuple);
553 (void) fprintf(file," %s\n",tuple);
554 }
555 }
556 if (ping == MagickFalse)
557 {
558 artifact=GetImageArtifact(image,"identify:unique");
559 if ((artifact != (const char *) NULL) &&
560 (IsMagickTrue(artifact) != MagickFalse))
561 (void) fprintf(file," Colors: %lu\n",GetNumberColors(image,
562 (FILE *) NULL,&image->exception));
563 if (IsHistogramImage(image,&image->exception) != MagickFalse)
564 {
565 (void) fprintf(file," Histogram:\n");
566 (void) GetNumberColors(image,file,&image->exception);
567 }
568 }
569 }
570 if (image->storage_class == PseudoClass)
571 {
572 (void) fprintf(file," Colormap: %lu\n",image->colors);
573 if (image->colors <= 1024)
574 {
575 char
576 color[MaxTextExtent],
577 hex[MaxTextExtent],
578 tuple[MaxTextExtent];
579
580 MagickPixelPacket
581 pixel;
582
583 register PixelPacket
cristyc47d1f82009-11-26 01:44:43 +0000584 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000585
586 GetMagickPixelPacket(image,&pixel);
587 p=image->colormap;
588 for (i=0; i < (long) image->colors; i++)
589 {
590 SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
591 (void) CopyMagickString(tuple,"(",MaxTextExtent);
592 ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
593 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
594 ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
595 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
596 ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
597 if (pixel.colorspace == CMYKColorspace)
598 {
599 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
600 ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
601 tuple);
602 }
603 if (pixel.matte != MagickFalse)
604 {
605 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
606 ConcatenateColorComponent(&pixel,OpacityChannel,X11Compliance,
607 tuple);
608 }
609 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
610 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
611 &image->exception);
612 GetColorTuple(&pixel,MagickTrue,hex);
613 (void) fprintf(file," %8ld: %s %s %s\n",i,tuple,hex,color);
614 p++;
615 }
616 }
617 }
618 if (image->error.mean_error_per_pixel != 0.0)
cristye7f51092010-01-17 00:39:37 +0000619 (void) fprintf(file," Mean error per pixel: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000620 image->error.mean_error_per_pixel);
621 if (image->error.normalized_mean_error != 0.0)
cristye7f51092010-01-17 00:39:37 +0000622 (void) fprintf(file," Normalized mean error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000623 image->error.normalized_mean_error);
624 if (image->error.normalized_maximum_error != 0.0)
cristye7f51092010-01-17 00:39:37 +0000625 (void) fprintf(file," Normalized maximum error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000626 image->error.normalized_maximum_error);
627 (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic(
628 MagickIntentOptions,(long) image->rendering_intent));
629 if (image->gamma != 0.0)
cristye7f51092010-01-17 00:39:37 +0000630 (void) fprintf(file," Gamma: %g\n",image->gamma);
cristy3ed852e2009-09-05 21:47:34 +0000631 if ((image->chromaticity.red_primary.x != 0.0) ||
632 (image->chromaticity.green_primary.x != 0.0) ||
633 (image->chromaticity.blue_primary.x != 0.0) ||
634 (image->chromaticity.white_point.x != 0.0))
635 {
636 /*
637 Display image chromaticity.
638 */
639 (void) fprintf(file," Chromaticity:\n");
cristye7f51092010-01-17 00:39:37 +0000640 (void) fprintf(file," red primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000641 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
cristye7f51092010-01-17 00:39:37 +0000642 (void) fprintf(file," green primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000643 image->chromaticity.green_primary.x,
644 image->chromaticity.green_primary.y);
cristye7f51092010-01-17 00:39:37 +0000645 (void) fprintf(file," blue primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000646 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
cristye7f51092010-01-17 00:39:37 +0000647 (void) fprintf(file," white point: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000648 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
649 }
650 if ((image->extract_info.width*image->extract_info.height) != 0)
651 (void) fprintf(file," Tile geometry: %lux%lu%+ld%+ld\n",
652 image->extract_info.width,image->extract_info.height,
653 image->extract_info.x,image->extract_info.y);
654 (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic(
655 MagickInterlaceOptions,(long) image->interlace));
656 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
657 &image->exception);
658 (void) fprintf(file," Background color: %s\n",color);
659 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
660 &image->exception);
661 (void) fprintf(file," Border color: %s\n",color);
662 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
663 &image->exception);
664 (void) fprintf(file," Matte color: %s\n",color);
665 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
666 &image->exception);
667 (void) fprintf(file," Transparent color: %s\n",color);
cristy11a77682009-10-11 21:50:20 +0000668 (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic(
669 MagickComposeOptions,(long) image->compose));
cristy3ed852e2009-09-05 21:47:34 +0000670 if ((image->page.width != 0) || (image->page.height != 0) ||
671 (image->page.x != 0) || (image->page.y != 0))
672 (void) fprintf(file," Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
673 image->page.height,image->page.x,image->page.y);
674 if ((image->page.x != 0) || (image->page.y != 0))
675 (void) fprintf(file," Origin geometry: %+ld%+ld\n",image->page.x,
676 image->page.y);
677 (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic(
678 MagickDisposeOptions,(long) image->dispose));
679 if (image->delay != 0)
680 (void) fprintf(file," Delay: %lux%ld\n",image->delay,
681 image->ticks_per_second);
682 if (image->iterations != 1)
683 (void) fprintf(file," Iterations: %lu\n",image->iterations);
684 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
685 (void) fprintf(file," Scene: %lu of %lu\n",image->scene,
686 GetImageListLength(image));
687 else
688 if (image->scene != 0)
689 (void) fprintf(file," Scene: %lu\n",image->scene);
690 (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic(
691 MagickCompressOptions,(long) image->compression));
692 if (image->quality != UndefinedCompressionQuality)
693 (void) fprintf(file," Quality: %lu\n",image->quality);
694 (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic(
695 MagickOrientationOptions,(long) image->orientation));
696 if (image->montage != (char *) NULL)
697 (void) fprintf(file," Montage: %s\n",image->montage);
698 if (image->directory != (char *) NULL)
699 {
700 Image
701 *tile;
702
703 ImageInfo
704 *image_info;
705
706 register char
707 *p,
708 *q;
709
710 WarningHandler
711 handler;
712
713 /*
714 Display visual image directory.
715 */
716 image_info=AcquireImageInfo();
717 (void) CloneString(&image_info->size,"64x64");
718 (void) fprintf(file," Directory:\n");
719 for (p=image->directory; *p != '\0'; p++)
720 {
721 q=p;
722 while ((*q != '\n') && (*q != '\0'))
723 q++;
724 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
725 p=q;
726 (void) fprintf(file," %s",image_info->filename);
727 handler=SetWarningHandler((WarningHandler) NULL);
728 tile=ReadImage(image_info,&image->exception);
729 (void) SetWarningHandler(handler);
730 if (tile == (Image *) NULL)
731 {
732 (void) fprintf(file,"\n");
733 continue;
734 }
735 (void) fprintf(file," %lux%lu %s\n",tile->magick_columns,
736 tile->magick_rows,tile->magick);
737 (void) SignatureImage(tile);
738 ResetImagePropertyIterator(tile);
739 property=GetNextImageProperty(tile);
740 while (property != (const char *) NULL)
741 {
742 (void) fprintf(file," %s:\n",property);
743 value=GetImageProperty(tile,property);
744 if (value != (const char *) NULL)
745 (void) fprintf(file,"%s\n",value);
746 property=GetNextImageProperty(tile);
747 }
748 tile=DestroyImage(tile);
749 }
750 image_info=DestroyImageInfo(image_info);
751 }
752 (void) GetImageProperty(image,"exif:*");
753 ResetImagePropertyIterator(image);
754 property=GetNextImageProperty(image);
755 if (property != (const char *) NULL)
756 {
757 /*
758 Display image properties.
759 */
760 (void) fprintf(file," Properties:\n");
761 while (property != (const char *) NULL)
762 {
763 (void) fprintf(file," %c",*property);
764 if (strlen(property) > 1)
765 (void) fprintf(file,"%s: ",property+1);
766 if (strlen(property) > 80)
767 (void) fputc('\n',file);
768 value=GetImageProperty(image,property);
769 if (value != (const char *) NULL)
770 (void) fprintf(file,"%s\n",value);
771 property=GetNextImageProperty(image);
772 }
773 }
774 (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1");
775 value=GetImageProperty(image,key);
776 if (value != (const char *) NULL)
777 {
778 /*
779 Display clipping path.
780 */
781 (void) fprintf(file," Clipping path: ");
782 if (strlen(value) > 80)
783 (void) fputc('\n',file);
784 (void) fprintf(file,"%s\n",value);
785 }
786 ResetImageProfileIterator(image);
787 name=GetNextImageProfile(image);
788 if (name != (char *) NULL)
789 {
790 const StringInfo
791 *profile;
792
793 /*
794 Identify image profiles.
795 */
796 (void) fprintf(file," Profiles:\n");
797 while (name != (char *) NULL)
798 {
799 profile=GetImageProfile(image,name);
800 if (profile == (StringInfo *) NULL)
801 continue;
802 (void) fprintf(file," Profile-%s: %lu bytes\n",name,(unsigned long)
803 GetStringInfoLength(profile));
804#if defined(MAGICKCORE_LCMS_DELEGATE)
805 if ((LocaleCompare(name,"icc") == 0) ||
806 (LocaleCompare(name,"icm") == 0))
807 {
808 cmsHPROFILE
809 icc_profile;
810
811 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
812 (DWORD) GetStringInfoLength(profile));
813 if (icc_profile != (cmsHPROFILE *) NULL)
814 {
815 const char
816 *name;
817
818 name=cmsTakeProductName(icc_profile);
819 if (name != (const char *) NULL)
820 (void) fprintf(file," %s\n",name);
821 (void) cmsCloseProfile(icc_profile);
822 }
823 }
824#endif
825 if (LocaleCompare(name,"iptc") == 0)
826 {
827 char
828 *attribute,
829 **attribute_list;
830
831 const char
832 *tag;
833
834 long
835 dataset,
836 record,
837 sentinel;
838
839 register long
840 j;
841
842 size_t
843 length,
844 profile_length;
845
846 profile_length=GetStringInfoLength(profile);
847 for (i=0; i < (long) profile_length; i+=(long) length)
848 {
849 length=1;
850 sentinel=GetStringInfoDatum(profile)[i++];
851 if (sentinel != 0x1c)
852 continue;
853 dataset=GetStringInfoDatum(profile)[i++];
854 record=GetStringInfoDatum(profile)[i++];
855 switch (record)
856 {
857 case 5: tag="Image Name"; break;
858 case 7: tag="Edit Status"; break;
859 case 10: tag="Priority"; break;
860 case 15: tag="Category"; break;
861 case 20: tag="Supplemental Category"; break;
862 case 22: tag="Fixture Identifier"; break;
863 case 25: tag="Keyword"; break;
864 case 30: tag="Release Date"; break;
865 case 35: tag="Release Time"; break;
866 case 40: tag="Special Instructions"; break;
867 case 45: tag="Reference Service"; break;
868 case 47: tag="Reference Date"; break;
869 case 50: tag="Reference Number"; break;
870 case 55: tag="Created Date"; break;
871 case 60: tag="Created Time"; break;
872 case 65: tag="Originating Program"; break;
873 case 70: tag="Program Version"; break;
874 case 75: tag="Object Cycle"; break;
875 case 80: tag="Byline"; break;
876 case 85: tag="Byline Title"; break;
877 case 90: tag="City"; break;
878 case 95: tag="Province State"; break;
879 case 100: tag="Country Code"; break;
880 case 101: tag="Country"; break;
881 case 103: tag="Original Transmission Reference"; break;
882 case 105: tag="Headline"; break;
883 case 110: tag="Credit"; break;
884 case 115: tag="Src"; break;
885 case 116: tag="Copyright String"; break;
886 case 120: tag="Caption"; break;
887 case 121: tag="Local Caption"; break;
888 case 122: tag="Caption Writer"; break;
889 case 200: tag="Custom Field 1"; break;
890 case 201: tag="Custom Field 2"; break;
891 case 202: tag="Custom Field 3"; break;
892 case 203: tag="Custom Field 4"; break;
893 case 204: tag="Custom Field 5"; break;
894 case 205: tag="Custom Field 6"; break;
895 case 206: tag="Custom Field 7"; break;
896 case 207: tag="Custom Field 8"; break;
897 case 208: tag="Custom Field 9"; break;
898 case 209: tag="Custom Field 10"; break;
899 case 210: tag="Custom Field 11"; break;
900 case 211: tag="Custom Field 12"; break;
901 case 212: tag="Custom Field 13"; break;
902 case 213: tag="Custom Field 14"; break;
903 case 214: tag="Custom Field 15"; break;
904 case 215: tag="Custom Field 16"; break;
905 case 216: tag="Custom Field 17"; break;
906 case 217: tag="Custom Field 18"; break;
907 case 218: tag="Custom Field 19"; break;
908 case 219: tag="Custom Field 20"; break;
909 default: tag="unknown"; break;
910 }
911 (void) fprintf(file," %s[%ld,%ld]: ",tag,dataset,record);
912 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
913 length|=GetStringInfoDatum(profile)[i++];
914 attribute=(char *) NULL;
915 if (~length >= MaxTextExtent)
916 attribute=(char *) AcquireQuantumMemory(length+
917 MaxTextExtent,sizeof(*attribute));
918 if (attribute != (char *) NULL)
919 {
920 (void) CopyMagickString(attribute,(char *)
921 GetStringInfoDatum(profile)+i,length+1);
922 attribute_list=StringToList(attribute);
923 if (attribute_list != (char **) NULL)
924 {
925 for (j=0; attribute_list[j] != (char *) NULL; j++)
926 {
927 (void) fputs(attribute_list[j],file);
928 (void) fputs("\n",file);
929 attribute_list[j]=(char *) RelinquishMagickMemory(
930 attribute_list[j]);
931 }
932 attribute_list=(char **) RelinquishMagickMemory(
933 attribute_list);
934 }
935 attribute=DestroyString(attribute);
936 }
937 }
938 }
939 if (image->debug != MagickFalse)
940 PrintStringInfo(file,name,profile);
941 name=GetNextImageProfile(image);
942 }
943 }
944 ResetImageArtifactIterator(image);
945 artifact=GetNextImageArtifact(image);
946 if (artifact != (const char *) NULL)
947 {
948 /*
949 Display image artifacts.
950 */
951 (void) fprintf(file," Artifacts:\n");
952 while (artifact != (const char *) NULL)
953 {
954 (void) fprintf(file," %c",*artifact);
955 if (strlen(artifact) > 1)
956 (void) fprintf(file,"%s: ",artifact+1);
957 if (strlen(artifact) > 80)
958 (void) fputc('\n',file);
959 value=GetImageArtifact(image,artifact);
960 if (value != (const char *) NULL)
961 (void) fprintf(file,"%s\n",value);
962 artifact=GetNextImageArtifact(image);
963 }
964 }
965 ResetImageRegistryIterator();
966 registry=GetNextImageRegistry();
967 if (registry != (const char *) NULL)
968 {
969 /*
970 Display image registry.
971 */
972 (void) fprintf(file," Registry:\n");
973 while (registry != (const char *) NULL)
974 {
975 (void) fprintf(file," %c",*registry);
976 if (strlen(registry) > 1)
977 (void) fprintf(file,"%s: ",registry+1);
978 if (strlen(registry) > 80)
979 (void) fputc('\n',file);
980 value=(const char *) GetImageRegistry(StringRegistryType,registry,
981 &image->exception);
982 if (value != (const char *) NULL)
983 (void) fprintf(file,"%s\n",value);
984 registry=GetNextImageRegistry();
985 }
986 }
987 (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic(
988 MagickBooleanOptions,(long) image->taint));
cristyb9080c92009-12-01 20:13:26 +0000989 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +0000990 (void) fprintf(file," Filesize: %s\n",format);
cristyb9080c92009-12-01 20:13:26 +0000991 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
992 MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +0000993 (void) fprintf(file," Number pixels: %s\n",format);
cristy3d231692009-09-29 01:05:22 +0000994 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
cristyb9080c92009-12-01 20:13:26 +0000995 elapsed_time+0.5),MagickFalse,format);
cristy3d231692009-09-29 01:05:22 +0000996 (void) fprintf(file," Pixels per second: %s\n",format);
997 (void) fprintf(file," User time: %0.3fu\n",user_time);
998 (void) fprintf(file," Elapsed time: %ld:%02ld.%03ld\n",(long)
999 (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),(long)
1000 (1000.0*(elapsed_time-floor(elapsed_time))));
1001 (void) fprintf(file," Version: %s\n",GetMagickVersion((unsigned long *)
1002 NULL));
cristy3ed852e2009-09-05 21:47:34 +00001003 (void) fflush(file);
1004 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1005}