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