blob: 94a329b1ff811c4c84f53a3f3202b9194e9c0dbe [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)
cristyd09bcf92010-03-25 03:04:45 +000097#if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H)
98#include <lcms/lcms2.h>
99#elif defined(MAGICKCORE_HAVE_LCMS2_H)
100#include "lcms2.h"
101#elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
cristy3ed852e2009-09-05 21:47:34 +0000102#include <lcms/lcms.h>
103#else
104#include "lcms.h"
105#endif
106#endif
107
108/*
cristyd09bcf92010-03-25 03:04:45 +0000109 Define declarations.
110*/
111#if defined(MAGICKCORE_LCMS_DELEGATE)
112#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
113#define cmsUInt32Number DWORD
114#endif
115#endif
116
117/*
cristy3ed852e2009-09-05 21:47:34 +0000118%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119% %
120% %
121% %
122% I d e n t i f y I m a g e %
123% %
124% %
125% %
126%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127%
128% IdentifyImage() identifies an image by printing its attributes to the file.
129% Attributes include the image width, height, size, and others.
130%
131% The format of the IdentifyImage method is:
132%
133% MagickBooleanType IdentifyImage(Image *image,FILE *file,
134% const MagickBooleanType verbose)
135%
136% A description of each parameter follows:
137%
138% o image: the image.
139%
140% o file: the file, typically stdout.
141%
142% o verbose: A value other than zero prints more detailed information
143% about the image.
144%
145*/
146
cristybd822072010-01-27 00:30:00 +0000147static int PrintChannelFeatures(FILE *file,const ChannelType channel,
cristye1897792010-01-29 02:05:50 +0000148 const char *name,const ChannelFeatures *channel_features)
cristy3ed852e2009-09-05 21:47:34 +0000149{
cristye1897792010-01-29 02:05:50 +0000150#define PrintFeature(feature) \
151 GetMagickPrecision(),(feature)[0], \
152 GetMagickPrecision(),(feature)[1], \
153 GetMagickPrecision(),(feature)[2], \
cristye0acabf2010-01-30 00:52:38 +0000154 GetMagickPrecision(),(feature)[3], \
155 GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
cristye1897792010-01-29 02:05:50 +0000156
cristybd822072010-01-27 00:30:00 +0000157#define FeaturesFormat " %s:\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000158 " Angular Second Moment:\n" \
cristye0acabf2010-01-30 00:52:38 +0000159 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000160 " Contrast:\n" \
cristye0acabf2010-01-30 00:52:38 +0000161 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000162 " Correlation:\n" \
cristye0acabf2010-01-30 00:52:38 +0000163 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000164 " Sum of Squares: Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000165 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycf5e6492010-01-28 02:45:28 +0000166 " Inverse Difference Moment:\n" \
cristye0acabf2010-01-30 00:52:38 +0000167 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000168 " Sum Average:\n" \
cristye0acabf2010-01-30 00:52:38 +0000169 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000170 " Sum Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000171 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000172 " Sum Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000173 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000174 " Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000175 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000176 " Difference Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000177 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000178 " Difference Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000179 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000180 " Information Measure of Correlation 1:\n" \
cristye0acabf2010-01-30 00:52:38 +0000181 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000182 " Information Measure of Correlation 2:\n" \
cristye0acabf2010-01-30 00:52:38 +0000183 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000184 " Maximum Correlation Coefficient:\n" \
cristyc3ec0d42010-04-07 01:18:08 +0000185 " %.*g, %.*g, %.*g, %.*g, %.*g\n"
cristybd822072010-01-27 00:30:00 +0000186
187 int
188 status;
189
190 status=fprintf(file,FeaturesFormat,name,
cristye1897792010-01-29 02:05:50 +0000191 PrintFeature(channel_features[channel].angular_second_moment),
192 PrintFeature(channel_features[channel].contrast),
193 PrintFeature(channel_features[channel].correlation),
194 PrintFeature(channel_features[channel].variance_sum_of_squares),
195 PrintFeature(channel_features[channel].inverse_difference_moment),
196 PrintFeature(channel_features[channel].sum_average),
197 PrintFeature(channel_features[channel].sum_variance),
198 PrintFeature(channel_features[channel].sum_entropy),
199 PrintFeature(channel_features[channel].entropy),
cristye0e19dc2010-01-29 02:13:08 +0000200 PrintFeature(channel_features[channel].difference_variance),
201 PrintFeature(channel_features[channel].difference_entropy),
202 PrintFeature(channel_features[channel].measure_of_correlation_1),
203 PrintFeature(channel_features[channel].measure_of_correlation_2),
204 PrintFeature(channel_features[channel].maximum_correlation_coefficient));
cristybd822072010-01-27 00:30:00 +0000205 return(status);
206}
207
208static int PrintChannelStatistics(FILE *file,const ChannelType channel,
209 const char *name,const double scale,
210 const ChannelStatistics *channel_statistics)
211{
212#define StatisticsFormat " %s:\n min: " QuantumFormat \
cristye7f51092010-01-17 00:39:37 +0000213 " (%g)\n max: " QuantumFormat " (%g)\n" \
214 " mean: %g (%g)\n standard deviation: %g (%g)\n" \
215 " kurtosis: %g\n skewness: %g\n"
cristy3ed852e2009-09-05 21:47:34 +0000216
cristybd822072010-01-27 00:30:00 +0000217 int
218 status;
219
cristyc70de512010-05-07 23:32:04 +0000220 if (channel == AlphaChannel)
221 {
222 status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
cristy240205f2010-05-08 01:53:58 +0000223 (QuantumRange-channel_statistics[channel].maxima)),
cristyc70de512010-05-07 23:32:04 +0000224 (QuantumRange-channel_statistics[channel].maxima)/(double) QuantumRange,
cristy240205f2010-05-08 01:53:58 +0000225 ClampToQuantum(scale*(QuantumRange-channel_statistics[channel].minima)),
226 (QuantumRange-channel_statistics[channel].minima)/(double) QuantumRange,
cristyc70de512010-05-07 23:32:04 +0000227 scale*(QuantumRange-channel_statistics[channel].mean),(QuantumRange-
228 channel_statistics[channel].mean)/(double) QuantumRange,scale*
229 channel_statistics[channel].standard_deviation,
230 channel_statistics[channel].standard_deviation/(double) QuantumRange,
231 channel_statistics[channel].kurtosis,
232 channel_statistics[channel].skewness);
233 return(status);
234 }
cristya45da3b2010-03-31 02:06:45 +0000235 status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale*
236 channel_statistics[channel].minima),channel_statistics[channel].minima/
237 (double) QuantumRange,ClampToQuantum(scale*
238 channel_statistics[channel].maxima),channel_statistics[channel].maxima/
239 (double) QuantumRange,scale*channel_statistics[channel].mean,
240 channel_statistics[channel].mean/(double) QuantumRange,scale*
241 channel_statistics[channel].standard_deviation,
cristy75b5a252010-02-26 02:40:46 +0000242 channel_statistics[channel].standard_deviation/(double) QuantumRange,
243 channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
cristybd822072010-01-27 00:30:00 +0000244 return(status);
245}
246
247MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
248 const MagickBooleanType verbose)
249{
cristy3ed852e2009-09-05 21:47:34 +0000250 char
251 color[MaxTextExtent],
252 format[MaxTextExtent],
253 key[MaxTextExtent];
254
cristybd822072010-01-27 00:30:00 +0000255 ChannelFeatures
256 *channel_features;
257
258 ChannelStatistics
259 *channel_statistics;
260
cristy3ed852e2009-09-05 21:47:34 +0000261 ColorspaceType
262 colorspace;
263
264 const char
265 *artifact,
266 *name,
267 *property,
268 *registry,
269 *value;
270
271 const MagickInfo
272 *magick_info;
273
274 const PixelPacket
275 *pixels;
276
277 double
278 elapsed_time,
279 user_time;
280
281 ExceptionInfo
282 *exception;
283
284 ImageType
285 type;
286
cristybb503372010-05-27 20:51:26 +0000287 ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000288 y;
289
290 MagickBooleanType
291 ping;
292
cristybb503372010-05-27 20:51:26 +0000293 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000294 i,
295 x;
296
cristybb503372010-05-27 20:51:26 +0000297 size_t
cristybd822072010-01-27 00:30:00 +0000298 distance,
cristy3ed852e2009-09-05 21:47:34 +0000299 scale;
300
301 assert(image != (Image *) NULL);
302 assert(image->signature == MagickSignature);
303 if (image->debug != MagickFalse)
304 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
305 if (file == (FILE *) NULL)
306 file=stdout;
307 *format='\0';
308 elapsed_time=GetElapsedTime(&image->timer);
309 user_time=GetUserTime(&image->timer);
310 GetTimerInfo(&image->timer);
311 if (verbose == MagickFalse)
312 {
313 /*
314 Display summary info about the image.
315 */
316 if (*image->magick_filename != '\0')
317 if (LocaleCompare(image->magick_filename,image->filename) != 0)
318 (void) fprintf(file,"%s=>",image->magick_filename);
319 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
cristy81b8ce52010-02-05 01:53:17 +0000320 (GetNextImageInList(image) == (Image *) NULL) &&
321 (image->scene == 0))
cristy3ed852e2009-09-05 21:47:34 +0000322 (void) fprintf(file,"%s ",image->filename);
323 else
324 (void) fprintf(file,"%s[%lu] ",image->filename,image->scene);
325 (void) fprintf(file,"%s ",image->magick);
326 if ((image->magick_columns != 0) || (image->magick_rows != 0))
327 if ((image->magick_columns != image->columns) ||
328 (image->magick_rows != image->rows))
329 (void) fprintf(file,"%lux%lu=>",image->magick_columns,
330 image->magick_rows);
331 (void) fprintf(file,"%lux%lu ",image->columns,image->rows);
332 if ((image->page.width != 0) || (image->page.height != 0) ||
333 (image->page.x != 0) || (image->page.y != 0))
334 (void) fprintf(file,"%lux%lu%+ld%+ld ",image->page.width,
cristycee97112010-05-28 00:44:52 +0000335 image->page.height,(long) image->page.x,(long) image->page.y);
cristy3ed852e2009-09-05 21:47:34 +0000336 (void) fprintf(file,"%lu-bit ",image->depth);
337 if (image->type != UndefinedType)
338 (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
cristybb503372010-05-27 20:51:26 +0000339 (ssize_t) image->type));
cristy3ed852e2009-09-05 21:47:34 +0000340 if (image->storage_class == DirectClass)
341 {
342 (void) fprintf(file,"DirectClass ");
343 if (image->total_colors != 0)
344 {
cristyb9080c92009-12-01 20:13:26 +0000345 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +0000346 (void) fprintf(file,"%s ",format);
347 }
348 }
349 else
350 if (image->total_colors <= image->colors)
351 (void) fprintf(file,"PseudoClass %luc ",image->colors);
352 else
353 (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors,
354 image->colors);
355 if (image->error.mean_error_per_pixel != 0.0)
cristycee97112010-05-28 00:44:52 +0000356 (void) fprintf(file,"%ld/%f/%fdb ",(long)
cristy3ed852e2009-09-05 21:47:34 +0000357 (image->error.mean_error_per_pixel+0.5),
358 image->error.normalized_mean_error,
359 image->error.normalized_maximum_error);
360 if (GetBlobSize(image) != 0)
361 {
cristyb9080c92009-12-01 20:13:26 +0000362 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristy2ce15c92010-03-12 14:03:41 +0000363 (void) fprintf(file,"%sB ",format);
cristy3ed852e2009-09-05 21:47:34 +0000364 }
cristycee97112010-05-28 00:44:52 +0000365 (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(long)
366 (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)),
367 (long) (1000.0*(elapsed_time-floor(elapsed_time))));
cristy3ed852e2009-09-05 21:47:34 +0000368 (void) fprintf(file,"\n");
369 (void) fflush(file);
370 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
371 }
372 /*
373 Display verbose info about the image.
374 */
375 exception=AcquireExceptionInfo();
376 pixels=GetVirtualPixels(image,0,0,1,1,exception);
377 exception=DestroyExceptionInfo(exception);
378 ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
379 type=GetImageType(image,&image->exception);
380 (void) SignatureImage(image);
381 (void) fprintf(file,"Image: %s\n",image->filename);
382 if (*image->magick_filename != '\0')
383 if (LocaleCompare(image->magick_filename,image->filename) != 0)
384 {
385 char
386 filename[MaxTextExtent];
387
388 GetPathComponent(image->magick_filename,TailPath,filename);
389 (void) fprintf(file," Base filename: %s\n",filename);
390 }
391 magick_info=GetMagickInfo(image->magick,&image->exception);
392 if ((magick_info == (const MagickInfo *) NULL) ||
393 (*GetMagickDescription(magick_info) == '\0'))
394 (void) fprintf(file," Format: %s\n",image->magick);
395 else
396 (void) fprintf(file," Format: %s (%s)\n",image->magick,
397 GetMagickDescription(magick_info));
398 (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
cristybb503372010-05-27 20:51:26 +0000399 (ssize_t) image->storage_class));
cristy3ed852e2009-09-05 21:47:34 +0000400 (void) fprintf(file," Geometry: %lux%lu%+ld%+ld\n",image->columns,
cristycee97112010-05-28 00:44:52 +0000401 image->rows,(long) image->tile_offset.x,(long) image->tile_offset.y);
cristy3ed852e2009-09-05 21:47:34 +0000402 if ((image->magick_columns != 0) || (image->magick_rows != 0))
403 if ((image->magick_columns != image->columns) ||
404 (image->magick_rows != image->rows))
405 (void) fprintf(file," Base geometry: %lux%lu\n",image->magick_columns,
406 image->magick_rows);
407 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
408 {
cristye7f51092010-01-17 00:39:37 +0000409 (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution,
cristy3ed852e2009-09-05 21:47:34 +0000410 image->y_resolution);
cristye7f51092010-01-17 00:39:37 +0000411 (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/
cristy3ed852e2009-09-05 21:47:34 +0000412 image->x_resolution,(double) image->rows/image->y_resolution);
413 }
414 (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000415 MagickResolutionOptions,(ssize_t) image->units));
cristy3ed852e2009-09-05 21:47:34 +0000416 (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
cristybb503372010-05-27 20:51:26 +0000417 (ssize_t) type));
cristy3ed852e2009-09-05 21:47:34 +0000418 if (image->type != UndefinedType)
419 (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000420 MagickTypeOptions,(ssize_t) image->type));
cristy3ed852e2009-09-05 21:47:34 +0000421 (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000422 MagickEndianOptions,(ssize_t) image->endian));
cristy3ed852e2009-09-05 21:47:34 +0000423 /*
424 Detail channel depth and extrema.
425 */
426 (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000427 MagickColorspaceOptions,(ssize_t) image->colorspace));
cristybd822072010-01-27 00:30:00 +0000428 channel_statistics=(ChannelStatistics *) NULL;
cristy15a88782010-01-31 23:24:49 +0000429 channel_features=(ChannelFeatures *) NULL;
430 colorspace=image->colorspace;
cristy3ed852e2009-09-05 21:47:34 +0000431 if (ping == MagickFalse)
432 {
cristybb503372010-05-27 20:51:26 +0000433 size_t
cristy3ed852e2009-09-05 21:47:34 +0000434 depth;
435
cristy15a88782010-01-31 23:24:49 +0000436 channel_statistics=GetImageChannelStatistics(image,&image->exception);
437 artifact=GetImageArtifact(image,"identify:features");
438 if (artifact != (const char *) NULL)
439 {
440 distance=StringToUnsignedLong(artifact);
441 channel_features=GetImageChannelFeatures(image,distance,
442 &image->exception);
443 }
cristy3ed852e2009-09-05 21:47:34 +0000444 depth=GetImageDepth(image,&image->exception);
445 if (image->depth == depth)
446 (void) fprintf(file," Depth: %lu-bit\n",image->depth);
447 else
448 (void) fprintf(file," Depth: %lu/%lu-bit\n",image->depth,depth);
cristy3ed852e2009-09-05 21:47:34 +0000449 (void) fprintf(file," Channel depth:\n");
cristy3ed852e2009-09-05 21:47:34 +0000450 if (IsGrayImage(image,&image->exception) != MagickFalse)
451 colorspace=GRAYColorspace;
452 switch (colorspace)
453 {
454 case RGBColorspace:
455 default:
456 {
457 (void) fprintf(file," red: %lu-bit\n",
458 channel_statistics[RedChannel].depth);
459 (void) fprintf(file," green: %lu-bit\n",
460 channel_statistics[GreenChannel].depth);
461 (void) fprintf(file," blue: %lu-bit\n",
462 channel_statistics[BlueChannel].depth);
463 if (image->matte != MagickFalse)
464 (void) fprintf(file," alpha: %lu-bit\n",
465 channel_statistics[OpacityChannel].depth);
466 break;
467 }
468 case CMYKColorspace:
469 {
470 (void) fprintf(file," cyan: %lu-bit\n",
471 channel_statistics[CyanChannel].depth);
472 (void) fprintf(file," magenta: %lu-bit\n",
473 channel_statistics[MagentaChannel].depth);
474 (void) fprintf(file," yellow: %lu-bit\n",
475 channel_statistics[YellowChannel].depth);
476 (void) fprintf(file," black: %lu-bit\n",
477 channel_statistics[BlackChannel].depth);
478 if (image->matte != MagickFalse)
479 (void) fprintf(file," alpha: %lu-bit\n",
480 channel_statistics[OpacityChannel].depth);
481 break;
482 }
483 case GRAYColorspace:
484 {
485 (void) fprintf(file," gray: %lu-bit\n",
486 channel_statistics[GrayChannel].depth);
487 if (image->matte != MagickFalse)
488 (void) fprintf(file," alpha: %lu-bit\n",
489 channel_statistics[OpacityChannel].depth);
490 break;
491 }
492 }
493 scale=1;
494 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
cristybb503372010-05-27 20:51:26 +0000495 scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
cristy3ed852e2009-09-05 21:47:34 +0000496 MAGICKCORE_QUANTUM_DEPTH-image->depth));
cristy15a88782010-01-31 23:24:49 +0000497 }
498 if (channel_statistics != (ChannelStatistics *) NULL)
499 {
cristy3ed852e2009-09-05 21:47:34 +0000500 (void) fprintf(file," Channel statistics:\n");
501 switch (colorspace)
502 {
503 case RGBColorspace:
504 default:
505 {
cristybd822072010-01-27 00:30:00 +0000506 (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale,
507 channel_statistics);
508 (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale,
509 channel_statistics);
510 (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale,
511 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000512 break;
513 }
514 case CMYKColorspace:
515 {
cristybd822072010-01-27 00:30:00 +0000516 (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale,
517 channel_statistics);
518 (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale,
519 channel_statistics);
520 (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale,
521 channel_statistics);
522 (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale,
523 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000524 break;
525 }
526 case GRAYColorspace:
527 {
cristybd822072010-01-27 00:30:00 +0000528 (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale,
529 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000530 break;
531 }
532 }
533 if (image->matte != MagickFalse)
cristybd822072010-01-27 00:30:00 +0000534 (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale,
535 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000536 if (colorspace != GRAYColorspace)
537 {
538 (void) fprintf(file," Image statistics:\n");
cristybd822072010-01-27 00:30:00 +0000539 (void) PrintChannelStatistics(file,AllChannels,"Overall",1.0/scale,
540 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000541 }
542 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
543 channel_statistics);
cristybd822072010-01-27 00:30:00 +0000544 }
cristybd822072010-01-27 00:30:00 +0000545 if (channel_features != (ChannelFeatures *) NULL)
546 {
cristye0acabf2010-01-30 00:52:38 +0000547 (void) fprintf(file," Channel features (horizontal, vertical, left and right diagonals, average):\n");
cristybd822072010-01-27 00:30:00 +0000548 switch (colorspace)
549 {
550 case RGBColorspace:
551 default:
cristy549a37e2010-01-26 15:24:15 +0000552 {
cristye1897792010-01-29 02:05:50 +0000553 (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features);
554 (void) PrintChannelFeatures(file,GreenChannel,"Green",
cristybd822072010-01-27 00:30:00 +0000555 channel_features);
cristye1897792010-01-29 02:05:50 +0000556 (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features);
cristybd822072010-01-27 00:30:00 +0000557 break;
558 }
559 case CMYKColorspace:
560 {
cristye1897792010-01-29 02:05:50 +0000561 (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features);
562 (void) PrintChannelFeatures(file,MagentaChannel,"Magenta",
cristybd822072010-01-27 00:30:00 +0000563 channel_features);
cristye1897792010-01-29 02:05:50 +0000564 (void) PrintChannelFeatures(file,YellowChannel,"Yellow",
cristybd822072010-01-27 00:30:00 +0000565 channel_features);
cristye1897792010-01-29 02:05:50 +0000566 (void) PrintChannelFeatures(file,BlackChannel,"Black",
cristybd822072010-01-27 00:30:00 +0000567 channel_features);
568 break;
569 }
570 case GRAYColorspace:
571 {
cristye1897792010-01-29 02:05:50 +0000572 (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features);
cristybd822072010-01-27 00:30:00 +0000573 break;
574 }
575 }
576 if (image->matte != MagickFalse)
cristye1897792010-01-29 02:05:50 +0000577 (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features);
cristybd822072010-01-27 00:30:00 +0000578 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
579 channel_features);
580 }
581 if (ping == MagickFalse)
582 {
cristy3ed852e2009-09-05 21:47:34 +0000583 if (image->colorspace == CMYKColorspace)
584 (void) fprintf(file," Total ink density: %.0f%%\n",100.0*
585 GetImageTotalInkDensity(image)/(double) QuantumRange);
586 x=0;
587 if (image->matte != MagickFalse)
588 {
589 register const IndexPacket
590 *indexes;
591
592 register const PixelPacket
593 *p;
594
595 p=(PixelPacket *) NULL;
596 indexes=(IndexPacket *) NULL;
cristybb503372010-05-27 20:51:26 +0000597 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000598 {
599 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
600 if (p == (const PixelPacket *) NULL)
601 break;
602 indexes=GetVirtualIndexQueue(image);
cristybb503372010-05-27 20:51:26 +0000603 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000604 {
605 if (p->opacity == (Quantum) TransparentOpacity)
606 break;
607 p++;
608 }
cristybb503372010-05-27 20:51:26 +0000609 if (x < (ssize_t) image->columns)
cristy3ed852e2009-09-05 21:47:34 +0000610 break;
611 }
cristybb503372010-05-27 20:51:26 +0000612 if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
cristy3ed852e2009-09-05 21:47:34 +0000613 {
614 char
615 tuple[MaxTextExtent];
616
617 MagickPixelPacket
618 pixel;
619
620 GetMagickPixelPacket(image,&pixel);
621 SetMagickPixelPacket(image,p,indexes+x,&pixel);
622 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
623 &image->exception);
624 (void) fprintf(file," Alpha: %s ",tuple);
625 GetColorTuple(&pixel,MagickTrue,tuple);
626 (void) fprintf(file," %s\n",tuple);
627 }
628 }
cristy83fae872010-04-22 15:04:16 +0000629 artifact=GetImageArtifact(image,"identify:unique-colors");
cristy549a37e2010-01-26 15:24:15 +0000630 if ((artifact != (const char *) NULL) &&
631 (IsMagickTrue(artifact) != MagickFalse))
632 (void) fprintf(file," Colors: %lu\n",GetNumberColors(image,
633 (FILE *) NULL,&image->exception));
634 if (IsHistogramImage(image,&image->exception) != MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000635 {
cristy549a37e2010-01-26 15:24:15 +0000636 (void) fprintf(file," Histogram:\n");
637 (void) GetNumberColors(image,file,&image->exception);
cristy3ed852e2009-09-05 21:47:34 +0000638 }
639 }
640 if (image->storage_class == PseudoClass)
641 {
642 (void) fprintf(file," Colormap: %lu\n",image->colors);
643 if (image->colors <= 1024)
644 {
645 char
646 color[MaxTextExtent],
647 hex[MaxTextExtent],
648 tuple[MaxTextExtent];
649
650 MagickPixelPacket
651 pixel;
652
653 register PixelPacket
cristyc47d1f82009-11-26 01:44:43 +0000654 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000655
656 GetMagickPixelPacket(image,&pixel);
657 p=image->colormap;
cristybb503372010-05-27 20:51:26 +0000658 for (i=0; i < (ssize_t) image->colors; i++)
cristy3ed852e2009-09-05 21:47:34 +0000659 {
660 SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
661 (void) CopyMagickString(tuple,"(",MaxTextExtent);
662 ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
663 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
664 ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
665 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
666 ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
667 if (pixel.colorspace == CMYKColorspace)
668 {
669 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
670 ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
671 tuple);
672 }
673 if (pixel.matte != MagickFalse)
674 {
675 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyc3ec0d42010-04-07 01:18:08 +0000676 ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,
cristy3ed852e2009-09-05 21:47:34 +0000677 tuple);
678 }
679 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
680 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
681 &image->exception);
682 GetColorTuple(&pixel,MagickTrue,hex);
cristycee97112010-05-28 00:44:52 +0000683 (void) fprintf(file," %8ld: %s %s %s\n",(long) i,tuple,hex,color);
cristy3ed852e2009-09-05 21:47:34 +0000684 p++;
685 }
686 }
687 }
688 if (image->error.mean_error_per_pixel != 0.0)
cristye7f51092010-01-17 00:39:37 +0000689 (void) fprintf(file," Mean error per pixel: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000690 image->error.mean_error_per_pixel);
691 if (image->error.normalized_mean_error != 0.0)
cristye7f51092010-01-17 00:39:37 +0000692 (void) fprintf(file," Normalized mean error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000693 image->error.normalized_mean_error);
694 if (image->error.normalized_maximum_error != 0.0)
cristye7f51092010-01-17 00:39:37 +0000695 (void) fprintf(file," Normalized maximum error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000696 image->error.normalized_maximum_error);
697 (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000698 MagickIntentOptions,(ssize_t) image->rendering_intent));
cristy3ed852e2009-09-05 21:47:34 +0000699 if (image->gamma != 0.0)
cristye7f51092010-01-17 00:39:37 +0000700 (void) fprintf(file," Gamma: %g\n",image->gamma);
cristy3ed852e2009-09-05 21:47:34 +0000701 if ((image->chromaticity.red_primary.x != 0.0) ||
702 (image->chromaticity.green_primary.x != 0.0) ||
703 (image->chromaticity.blue_primary.x != 0.0) ||
704 (image->chromaticity.white_point.x != 0.0))
705 {
706 /*
707 Display image chromaticity.
708 */
709 (void) fprintf(file," Chromaticity:\n");
cristye7f51092010-01-17 00:39:37 +0000710 (void) fprintf(file," red primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000711 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
cristye7f51092010-01-17 00:39:37 +0000712 (void) fprintf(file," green primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000713 image->chromaticity.green_primary.x,
714 image->chromaticity.green_primary.y);
cristye7f51092010-01-17 00:39:37 +0000715 (void) fprintf(file," blue primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000716 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
cristye7f51092010-01-17 00:39:37 +0000717 (void) fprintf(file," white point: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000718 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
719 }
720 if ((image->extract_info.width*image->extract_info.height) != 0)
721 (void) fprintf(file," Tile geometry: %lux%lu%+ld%+ld\n",
722 image->extract_info.width,image->extract_info.height,
cristycee97112010-05-28 00:44:52 +0000723 (long) image->extract_info.x,(long) image->extract_info.y);
cristy3ed852e2009-09-05 21:47:34 +0000724 (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000725 MagickInterlaceOptions,(ssize_t) image->interlace));
cristy3ed852e2009-09-05 21:47:34 +0000726 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
727 &image->exception);
728 (void) fprintf(file," Background color: %s\n",color);
729 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
730 &image->exception);
731 (void) fprintf(file," Border color: %s\n",color);
732 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
733 &image->exception);
734 (void) fprintf(file," Matte color: %s\n",color);
735 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
736 &image->exception);
737 (void) fprintf(file," Transparent color: %s\n",color);
cristy11a77682009-10-11 21:50:20 +0000738 (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000739 MagickComposeOptions,(ssize_t) image->compose));
cristy3ed852e2009-09-05 21:47:34 +0000740 if ((image->page.width != 0) || (image->page.height != 0) ||
741 (image->page.x != 0) || (image->page.y != 0))
742 (void) fprintf(file," Page geometry: %lux%lu%+ld%+ld\n",image->page.width,
cristycee97112010-05-28 00:44:52 +0000743 image->page.height,(long) image->page.x,(long) image->page.y);
cristy3ed852e2009-09-05 21:47:34 +0000744 if ((image->page.x != 0) || (image->page.y != 0))
cristycee97112010-05-28 00:44:52 +0000745 (void) fprintf(file," Origin geometry: %+ld%+ld\n",(long) image->page.x,
746 (long) image->page.y);
cristy3ed852e2009-09-05 21:47:34 +0000747 (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000748 MagickDisposeOptions,(ssize_t) image->dispose));
cristy3ed852e2009-09-05 21:47:34 +0000749 if (image->delay != 0)
750 (void) fprintf(file," Delay: %lux%ld\n",image->delay,
cristycee97112010-05-28 00:44:52 +0000751 (long) image->ticks_per_second);
cristy3ed852e2009-09-05 21:47:34 +0000752 if (image->iterations != 1)
753 (void) fprintf(file," Iterations: %lu\n",image->iterations);
754 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
755 (void) fprintf(file," Scene: %lu of %lu\n",image->scene,
756 GetImageListLength(image));
757 else
758 if (image->scene != 0)
759 (void) fprintf(file," Scene: %lu\n",image->scene);
760 (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000761 MagickCompressOptions,(ssize_t) image->compression));
cristy3ed852e2009-09-05 21:47:34 +0000762 if (image->quality != UndefinedCompressionQuality)
763 (void) fprintf(file," Quality: %lu\n",image->quality);
764 (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000765 MagickOrientationOptions,(ssize_t) image->orientation));
cristy3ed852e2009-09-05 21:47:34 +0000766 if (image->montage != (char *) NULL)
767 (void) fprintf(file," Montage: %s\n",image->montage);
768 if (image->directory != (char *) NULL)
769 {
770 Image
771 *tile;
772
773 ImageInfo
774 *image_info;
775
776 register char
777 *p,
778 *q;
779
780 WarningHandler
781 handler;
782
783 /*
784 Display visual image directory.
785 */
786 image_info=AcquireImageInfo();
787 (void) CloneString(&image_info->size,"64x64");
788 (void) fprintf(file," Directory:\n");
789 for (p=image->directory; *p != '\0'; p++)
790 {
791 q=p;
792 while ((*q != '\n') && (*q != '\0'))
793 q++;
794 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
795 p=q;
796 (void) fprintf(file," %s",image_info->filename);
797 handler=SetWarningHandler((WarningHandler) NULL);
798 tile=ReadImage(image_info,&image->exception);
799 (void) SetWarningHandler(handler);
800 if (tile == (Image *) NULL)
801 {
802 (void) fprintf(file,"\n");
803 continue;
804 }
805 (void) fprintf(file," %lux%lu %s\n",tile->magick_columns,
806 tile->magick_rows,tile->magick);
807 (void) SignatureImage(tile);
808 ResetImagePropertyIterator(tile);
809 property=GetNextImageProperty(tile);
810 while (property != (const char *) NULL)
811 {
812 (void) fprintf(file," %s:\n",property);
813 value=GetImageProperty(tile,property);
814 if (value != (const char *) NULL)
815 (void) fprintf(file,"%s\n",value);
816 property=GetNextImageProperty(tile);
817 }
818 tile=DestroyImage(tile);
819 }
820 image_info=DestroyImageInfo(image_info);
821 }
822 (void) GetImageProperty(image,"exif:*");
823 ResetImagePropertyIterator(image);
824 property=GetNextImageProperty(image);
825 if (property != (const char *) NULL)
826 {
827 /*
828 Display image properties.
829 */
830 (void) fprintf(file," Properties:\n");
831 while (property != (const char *) NULL)
832 {
833 (void) fprintf(file," %c",*property);
834 if (strlen(property) > 1)
835 (void) fprintf(file,"%s: ",property+1);
836 if (strlen(property) > 80)
837 (void) fputc('\n',file);
838 value=GetImageProperty(image,property);
839 if (value != (const char *) NULL)
840 (void) fprintf(file,"%s\n",value);
841 property=GetNextImageProperty(image);
842 }
843 }
844 (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1");
845 value=GetImageProperty(image,key);
846 if (value != (const char *) NULL)
847 {
848 /*
849 Display clipping path.
850 */
851 (void) fprintf(file," Clipping path: ");
852 if (strlen(value) > 80)
853 (void) fputc('\n',file);
854 (void) fprintf(file,"%s\n",value);
855 }
856 ResetImageProfileIterator(image);
857 name=GetNextImageProfile(image);
858 if (name != (char *) NULL)
859 {
860 const StringInfo
861 *profile;
862
863 /*
864 Identify image profiles.
865 */
866 (void) fprintf(file," Profiles:\n");
867 while (name != (char *) NULL)
868 {
869 profile=GetImageProfile(image,name);
870 if (profile == (StringInfo *) NULL)
871 continue;
cristybb503372010-05-27 20:51:26 +0000872 (void) fprintf(file," Profile-%s: %lu bytes\n",name,(size_t)
cristy3ed852e2009-09-05 21:47:34 +0000873 GetStringInfoLength(profile));
874#if defined(MAGICKCORE_LCMS_DELEGATE)
875 if ((LocaleCompare(name,"icc") == 0) ||
876 (LocaleCompare(name,"icm") == 0))
877 {
878 cmsHPROFILE
879 icc_profile;
880
881 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
cristyd09bcf92010-03-25 03:04:45 +0000882 (cmsUInt32Number) GetStringInfoLength(profile));
cristy3ed852e2009-09-05 21:47:34 +0000883 if (icc_profile != (cmsHPROFILE *) NULL)
884 {
cristyd09bcf92010-03-25 03:04:45 +0000885#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
cristy3ed852e2009-09-05 21:47:34 +0000886 const char
887 *name;
888
889 name=cmsTakeProductName(icc_profile);
890 if (name != (const char *) NULL)
891 (void) fprintf(file," %s\n",name);
cristyd09bcf92010-03-25 03:04:45 +0000892#else
893 char
894 info[MaxTextExtent];
895
896 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
897 "en","US",info,MaxTextExtent);
898 (void) fprintf(file," Description: %s\n",info);
899 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
900 "en","US",info,MaxTextExtent);
901 (void) fprintf(file," Manufacturer: %s\n",info);
902 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
903 "US",info,MaxTextExtent);
904 (void) fprintf(file," Model: %s\n",info);
905 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
906 "en","US",info,MaxTextExtent);
907 (void) fprintf(file," Copyright: %s\n",info);
908#endif
cristy3ed852e2009-09-05 21:47:34 +0000909 (void) cmsCloseProfile(icc_profile);
910 }
911 }
912#endif
913 if (LocaleCompare(name,"iptc") == 0)
914 {
915 char
916 *attribute,
917 **attribute_list;
918
919 const char
920 *tag;
921
cristycee97112010-05-28 00:44:52 +0000922 long
cristy3ed852e2009-09-05 21:47:34 +0000923 dataset,
924 record,
925 sentinel;
926
cristybb503372010-05-27 20:51:26 +0000927 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000928 j;
929
930 size_t
931 length,
932 profile_length;
933
934 profile_length=GetStringInfoLength(profile);
cristybb503372010-05-27 20:51:26 +0000935 for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +0000936 {
937 length=1;
938 sentinel=GetStringInfoDatum(profile)[i++];
939 if (sentinel != 0x1c)
940 continue;
941 dataset=GetStringInfoDatum(profile)[i++];
942 record=GetStringInfoDatum(profile)[i++];
943 switch (record)
944 {
945 case 5: tag="Image Name"; break;
946 case 7: tag="Edit Status"; break;
947 case 10: tag="Priority"; break;
948 case 15: tag="Category"; break;
949 case 20: tag="Supplemental Category"; break;
950 case 22: tag="Fixture Identifier"; break;
951 case 25: tag="Keyword"; break;
952 case 30: tag="Release Date"; break;
953 case 35: tag="Release Time"; break;
954 case 40: tag="Special Instructions"; break;
955 case 45: tag="Reference Service"; break;
956 case 47: tag="Reference Date"; break;
957 case 50: tag="Reference Number"; break;
958 case 55: tag="Created Date"; break;
959 case 60: tag="Created Time"; break;
960 case 65: tag="Originating Program"; break;
961 case 70: tag="Program Version"; break;
962 case 75: tag="Object Cycle"; break;
963 case 80: tag="Byline"; break;
964 case 85: tag="Byline Title"; break;
965 case 90: tag="City"; break;
966 case 95: tag="Province State"; break;
967 case 100: tag="Country Code"; break;
968 case 101: tag="Country"; break;
969 case 103: tag="Original Transmission Reference"; break;
970 case 105: tag="Headline"; break;
971 case 110: tag="Credit"; break;
972 case 115: tag="Src"; break;
973 case 116: tag="Copyright String"; break;
974 case 120: tag="Caption"; break;
975 case 121: tag="Local Caption"; break;
976 case 122: tag="Caption Writer"; break;
977 case 200: tag="Custom Field 1"; break;
978 case 201: tag="Custom Field 2"; break;
979 case 202: tag="Custom Field 3"; break;
980 case 203: tag="Custom Field 4"; break;
981 case 204: tag="Custom Field 5"; break;
982 case 205: tag="Custom Field 6"; break;
983 case 206: tag="Custom Field 7"; break;
984 case 207: tag="Custom Field 8"; break;
985 case 208: tag="Custom Field 9"; break;
986 case 209: tag="Custom Field 10"; break;
987 case 210: tag="Custom Field 11"; break;
988 case 211: tag="Custom Field 12"; break;
989 case 212: tag="Custom Field 13"; break;
990 case 213: tag="Custom Field 14"; break;
991 case 214: tag="Custom Field 15"; break;
992 case 215: tag="Custom Field 16"; break;
993 case 216: tag="Custom Field 17"; break;
994 case 217: tag="Custom Field 18"; break;
995 case 218: tag="Custom Field 19"; break;
996 case 219: tag="Custom Field 20"; break;
997 default: tag="unknown"; break;
998 }
999 (void) fprintf(file," %s[%ld,%ld]: ",tag,dataset,record);
1000 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
1001 length|=GetStringInfoDatum(profile)[i++];
1002 attribute=(char *) NULL;
1003 if (~length >= MaxTextExtent)
1004 attribute=(char *) AcquireQuantumMemory(length+
1005 MaxTextExtent,sizeof(*attribute));
1006 if (attribute != (char *) NULL)
1007 {
1008 (void) CopyMagickString(attribute,(char *)
1009 GetStringInfoDatum(profile)+i,length+1);
1010 attribute_list=StringToList(attribute);
1011 if (attribute_list != (char **) NULL)
1012 {
1013 for (j=0; attribute_list[j] != (char *) NULL; j++)
1014 {
1015 (void) fputs(attribute_list[j],file);
1016 (void) fputs("\n",file);
1017 attribute_list[j]=(char *) RelinquishMagickMemory(
1018 attribute_list[j]);
1019 }
1020 attribute_list=(char **) RelinquishMagickMemory(
1021 attribute_list);
1022 }
1023 attribute=DestroyString(attribute);
1024 }
1025 }
1026 }
1027 if (image->debug != MagickFalse)
1028 PrintStringInfo(file,name,profile);
1029 name=GetNextImageProfile(image);
1030 }
1031 }
1032 ResetImageArtifactIterator(image);
1033 artifact=GetNextImageArtifact(image);
1034 if (artifact != (const char *) NULL)
1035 {
1036 /*
1037 Display image artifacts.
1038 */
1039 (void) fprintf(file," Artifacts:\n");
1040 while (artifact != (const char *) NULL)
1041 {
1042 (void) fprintf(file," %c",*artifact);
1043 if (strlen(artifact) > 1)
1044 (void) fprintf(file,"%s: ",artifact+1);
1045 if (strlen(artifact) > 80)
1046 (void) fputc('\n',file);
1047 value=GetImageArtifact(image,artifact);
1048 if (value != (const char *) NULL)
1049 (void) fprintf(file,"%s\n",value);
1050 artifact=GetNextImageArtifact(image);
1051 }
1052 }
1053 ResetImageRegistryIterator();
1054 registry=GetNextImageRegistry();
1055 if (registry != (const char *) NULL)
1056 {
1057 /*
1058 Display image registry.
1059 */
1060 (void) fprintf(file," Registry:\n");
1061 while (registry != (const char *) NULL)
1062 {
1063 (void) fprintf(file," %c",*registry);
1064 if (strlen(registry) > 1)
1065 (void) fprintf(file,"%s: ",registry+1);
1066 if (strlen(registry) > 80)
1067 (void) fputc('\n',file);
1068 value=(const char *) GetImageRegistry(StringRegistryType,registry,
1069 &image->exception);
1070 if (value != (const char *) NULL)
1071 (void) fprintf(file,"%s\n",value);
1072 registry=GetNextImageRegistry();
1073 }
1074 }
1075 (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +00001076 MagickBooleanOptions,(ssize_t) image->taint));
cristyb9080c92009-12-01 20:13:26 +00001077 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristy2ce15c92010-03-12 14:03:41 +00001078 (void) fprintf(file," Filesize: %sB\n",format);
cristyb9080c92009-12-01 20:13:26 +00001079 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1080 MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +00001081 (void) fprintf(file," Number pixels: %s\n",format);
cristy3d231692009-09-29 01:05:22 +00001082 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
cristyb9080c92009-12-01 20:13:26 +00001083 elapsed_time+0.5),MagickFalse,format);
cristy3d231692009-09-29 01:05:22 +00001084 (void) fprintf(file," Pixels per second: %s\n",format);
1085 (void) fprintf(file," User time: %0.3fu\n",user_time);
cristycee97112010-05-28 00:44:52 +00001086 (void) fprintf(file," Elapsed time: %ld:%02ld.%03ld\n",(long)
1087 (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),(long)
cristy3d231692009-09-29 01:05:22 +00001088 (1000.0*(elapsed_time-floor(elapsed_time))));
cristybb503372010-05-27 20:51:26 +00001089 (void) fprintf(file," Version: %s\n",GetMagickVersion((size_t *)
cristy3d231692009-09-29 01:05:22 +00001090 NULL));
cristy3ed852e2009-09-05 21:47:34 +00001091 (void) fflush(file);
1092 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1093}