blob: f2561d091288bd038debf7b127b64241fa906a5a [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
cristye8c25f92010-06-03 00:53:06 +0000324 (void) fprintf(file,"%s[%.20g] ",image->filename,(double) image->scene);
cristy3ed852e2009-09-05 21:47:34 +0000325 (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))
cristye8c25f92010-06-03 00:53:06 +0000329 (void) fprintf(file,"%.20gx%.20g=>",(double) image->magick_columns,
330 (double) image->magick_rows);
331 (void) fprintf(file,"%.20gx%.20g ",(double) image->columns,(double)
332 image->rows);
cristy3ed852e2009-09-05 21:47:34 +0000333 if ((image->page.width != 0) || (image->page.height != 0) ||
334 (image->page.x != 0) || (image->page.y != 0))
cristy6d8abba2010-06-03 01:10:47 +0000335 (void) fprintf(file,"%.20gx%.20g%+.20g%+.20g ",(double)
cristye8c25f92010-06-03 00:53:06 +0000336 image->page.width,(double) image->page.height,(double) image->page.x,
337 (double) image->page.y);
338 (void) fprintf(file,"%.20g-bit ",(double) image->depth);
cristy5f1c1ff2010-12-23 21:38:06 +0000339 if (image->type != UndefinedType)
cristy3ed852e2009-09-05 21:47:34 +0000340 (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions,
cristybb503372010-05-27 20:51:26 +0000341 (ssize_t) image->type));
cristy3ed852e2009-09-05 21:47:34 +0000342 if (image->storage_class == DirectClass)
343 {
344 (void) fprintf(file,"DirectClass ");
345 if (image->total_colors != 0)
346 {
cristyb9080c92009-12-01 20:13:26 +0000347 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +0000348 (void) fprintf(file,"%s ",format);
349 }
350 }
351 else
352 if (image->total_colors <= image->colors)
cristye8c25f92010-06-03 00:53:06 +0000353 (void) fprintf(file,"PseudoClass %.20gc ",(double) image->colors);
cristyf2faecf2010-05-28 19:19:36 +0000354 else
cristye8c25f92010-06-03 00:53:06 +0000355 (void) fprintf(file,"PseudoClass %.20g=>%.20gc ",(double)
356 image->total_colors,(double) image->colors);
cristy3ed852e2009-09-05 21:47:34 +0000357 if (image->error.mean_error_per_pixel != 0.0)
cristye8c25f92010-06-03 00:53:06 +0000358 (void) fprintf(file,"%.20g/%f/%fdb ",(double)
cristy3ed852e2009-09-05 21:47:34 +0000359 (image->error.mean_error_per_pixel+0.5),
360 image->error.normalized_mean_error,
361 image->error.normalized_maximum_error);
362 if (GetBlobSize(image) != 0)
363 {
cristyb9080c92009-12-01 20:13:26 +0000364 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristy55923c72010-11-18 14:46:15 +0000365 (void) fprintf(file,"%s ",format);
cristy3ed852e2009-09-05 21:47:34 +0000366 }
cristy91f905a2010-06-03 01:01:32 +0000367 (void) fprintf(file,"%0.3fu %lu:%02lu.%03lu",user_time,(unsigned long)
368 (elapsed_time/60.0),(unsigned long) floor(fmod(elapsed_time,60.0)),
369 (unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
cristy3ed852e2009-09-05 21:47:34 +0000370 (void) fprintf(file,"\n");
371 (void) fflush(file);
372 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
373 }
374 /*
375 Display verbose info about the image.
376 */
377 exception=AcquireExceptionInfo();
378 pixels=GetVirtualPixels(image,0,0,1,1,exception);
379 exception=DestroyExceptionInfo(exception);
380 ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
381 type=GetImageType(image,&image->exception);
382 (void) SignatureImage(image);
383 (void) fprintf(file,"Image: %s\n",image->filename);
384 if (*image->magick_filename != '\0')
385 if (LocaleCompare(image->magick_filename,image->filename) != 0)
386 {
387 char
388 filename[MaxTextExtent];
389
390 GetPathComponent(image->magick_filename,TailPath,filename);
391 (void) fprintf(file," Base filename: %s\n",filename);
392 }
393 magick_info=GetMagickInfo(image->magick,&image->exception);
394 if ((magick_info == (const MagickInfo *) NULL) ||
395 (*GetMagickDescription(magick_info) == '\0'))
396 (void) fprintf(file," Format: %s\n",image->magick);
397 else
398 (void) fprintf(file," Format: %s (%s)\n",image->magick,
399 GetMagickDescription(magick_info));
400 (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
cristybb503372010-05-27 20:51:26 +0000401 (ssize_t) image->storage_class));
cristy6d8abba2010-06-03 01:10:47 +0000402 (void) fprintf(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000403 image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
404 image->tile_offset.y);
cristy3ed852e2009-09-05 21:47:34 +0000405 if ((image->magick_columns != 0) || (image->magick_rows != 0))
406 if ((image->magick_columns != image->columns) ||
407 (image->magick_rows != image->rows))
cristye8c25f92010-06-03 00:53:06 +0000408 (void) fprintf(file," Base geometry: %.20gx%.20g\n",(double)
409 image->magick_columns,(double) image->magick_rows);
cristy3ed852e2009-09-05 21:47:34 +0000410 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
411 {
cristye7f51092010-01-17 00:39:37 +0000412 (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution,
cristy3ed852e2009-09-05 21:47:34 +0000413 image->y_resolution);
cristye7f51092010-01-17 00:39:37 +0000414 (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/
cristy3ed852e2009-09-05 21:47:34 +0000415 image->x_resolution,(double) image->rows/image->y_resolution);
416 }
417 (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000418 MagickResolutionOptions,(ssize_t) image->units));
cristy3ed852e2009-09-05 21:47:34 +0000419 (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions,
cristybb503372010-05-27 20:51:26 +0000420 (ssize_t) type));
cristy5f1c1ff2010-12-23 21:38:06 +0000421 if (image->type != UndefinedType)
cristy3ed852e2009-09-05 21:47:34 +0000422 (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000423 MagickTypeOptions,(ssize_t) image->type));
cristy3ed852e2009-09-05 21:47:34 +0000424 (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000425 MagickEndianOptions,(ssize_t) image->endian));
cristy3ed852e2009-09-05 21:47:34 +0000426 /*
427 Detail channel depth and extrema.
428 */
429 (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000430 MagickColorspaceOptions,(ssize_t) image->colorspace));
cristybd822072010-01-27 00:30:00 +0000431 channel_statistics=(ChannelStatistics *) NULL;
cristy15a88782010-01-31 23:24:49 +0000432 channel_features=(ChannelFeatures *) NULL;
433 colorspace=image->colorspace;
cristy3ed852e2009-09-05 21:47:34 +0000434 if (ping == MagickFalse)
435 {
cristybb503372010-05-27 20:51:26 +0000436 size_t
cristy3ed852e2009-09-05 21:47:34 +0000437 depth;
438
cristy15a88782010-01-31 23:24:49 +0000439 channel_statistics=GetImageChannelStatistics(image,&image->exception);
440 artifact=GetImageArtifact(image,"identify:features");
441 if (artifact != (const char *) NULL)
442 {
443 distance=StringToUnsignedLong(artifact);
444 channel_features=GetImageChannelFeatures(image,distance,
445 &image->exception);
446 }
cristy3ed852e2009-09-05 21:47:34 +0000447 depth=GetImageDepth(image,&image->exception);
448 if (image->depth == depth)
cristye8c25f92010-06-03 00:53:06 +0000449 (void) fprintf(file," Depth: %.20g-bit\n",(double) image->depth);
cristy3ed852e2009-09-05 21:47:34 +0000450 else
cristye8c25f92010-06-03 00:53:06 +0000451 (void) fprintf(file," Depth: %.20g/%.20g-bit\n",(double)
452 image->depth,(double) depth);
cristy3ed852e2009-09-05 21:47:34 +0000453 (void) fprintf(file," Channel depth:\n");
cristy3ed852e2009-09-05 21:47:34 +0000454 if (IsGrayImage(image,&image->exception) != MagickFalse)
455 colorspace=GRAYColorspace;
456 switch (colorspace)
457 {
458 case RGBColorspace:
459 default:
460 {
cristye8c25f92010-06-03 00:53:06 +0000461 (void) fprintf(file," red: %.20g-bit\n",(double)
462 channel_statistics[RedChannel].depth);
463 (void) fprintf(file," green: %.20g-bit\n",(double)
464 channel_statistics[GreenChannel].depth);
465 (void) fprintf(file," blue: %.20g-bit\n",(double)
466 channel_statistics[BlueChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000467 break;
468 }
469 case CMYKColorspace:
470 {
cristye8c25f92010-06-03 00:53:06 +0000471 (void) fprintf(file," cyan: %.20g-bit\n",(double)
472 channel_statistics[CyanChannel].depth);
473 (void) fprintf(file," magenta: %.20g-bit\n",(double)
474 channel_statistics[MagentaChannel].depth);
475 (void) fprintf(file," yellow: %.20g-bit\n",(double)
476 channel_statistics[YellowChannel].depth);
477 (void) fprintf(file," black: %.20g-bit\n",(double)
478 channel_statistics[BlackChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000479 break;
480 }
481 case GRAYColorspace:
482 {
cristye8c25f92010-06-03 00:53:06 +0000483 (void) fprintf(file," gray: %.20g-bit\n",(double)
484 channel_statistics[GrayChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000485 break;
486 }
487 }
cristye8c25f92010-06-03 00:53:06 +0000488 if (image->matte != MagickFalse)
489 (void) fprintf(file," alpha: %.20g-bit\n",(double)
490 channel_statistics[OpacityChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000491 scale=1;
492 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
cristybb503372010-05-27 20:51:26 +0000493 scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
cristy3ed852e2009-09-05 21:47:34 +0000494 MAGICKCORE_QUANTUM_DEPTH-image->depth));
cristy15a88782010-01-31 23:24:49 +0000495 }
496 if (channel_statistics != (ChannelStatistics *) NULL)
497 {
cristy3ed852e2009-09-05 21:47:34 +0000498 (void) fprintf(file," Channel statistics:\n");
499 switch (colorspace)
500 {
501 case RGBColorspace:
502 default:
503 {
cristybd822072010-01-27 00:30:00 +0000504 (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale,
505 channel_statistics);
506 (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale,
507 channel_statistics);
508 (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale,
509 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000510 break;
511 }
512 case CMYKColorspace:
513 {
cristybd822072010-01-27 00:30:00 +0000514 (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale,
515 channel_statistics);
516 (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale,
517 channel_statistics);
518 (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale,
519 channel_statistics);
520 (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale,
521 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000522 break;
523 }
524 case GRAYColorspace:
525 {
cristybd822072010-01-27 00:30:00 +0000526 (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale,
527 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000528 break;
529 }
530 }
531 if (image->matte != MagickFalse)
cristybd822072010-01-27 00:30:00 +0000532 (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale,
533 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000534 if (colorspace != GRAYColorspace)
535 {
536 (void) fprintf(file," Image statistics:\n");
cristybd822072010-01-27 00:30:00 +0000537 (void) PrintChannelStatistics(file,AllChannels,"Overall",1.0/scale,
538 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000539 }
540 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
541 channel_statistics);
cristybd822072010-01-27 00:30:00 +0000542 }
cristybd822072010-01-27 00:30:00 +0000543 if (channel_features != (ChannelFeatures *) NULL)
544 {
cristye0acabf2010-01-30 00:52:38 +0000545 (void) fprintf(file," Channel features (horizontal, vertical, left and right diagonals, average):\n");
cristybd822072010-01-27 00:30:00 +0000546 switch (colorspace)
547 {
548 case RGBColorspace:
549 default:
cristy549a37e2010-01-26 15:24:15 +0000550 {
cristye1897792010-01-29 02:05:50 +0000551 (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features);
552 (void) PrintChannelFeatures(file,GreenChannel,"Green",
cristybd822072010-01-27 00:30:00 +0000553 channel_features);
cristye1897792010-01-29 02:05:50 +0000554 (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features);
cristybd822072010-01-27 00:30:00 +0000555 break;
556 }
557 case CMYKColorspace:
558 {
cristye1897792010-01-29 02:05:50 +0000559 (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features);
560 (void) PrintChannelFeatures(file,MagentaChannel,"Magenta",
cristybd822072010-01-27 00:30:00 +0000561 channel_features);
cristye1897792010-01-29 02:05:50 +0000562 (void) PrintChannelFeatures(file,YellowChannel,"Yellow",
cristybd822072010-01-27 00:30:00 +0000563 channel_features);
cristye1897792010-01-29 02:05:50 +0000564 (void) PrintChannelFeatures(file,BlackChannel,"Black",
cristybd822072010-01-27 00:30:00 +0000565 channel_features);
566 break;
567 }
568 case GRAYColorspace:
569 {
cristye1897792010-01-29 02:05:50 +0000570 (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features);
cristybd822072010-01-27 00:30:00 +0000571 break;
572 }
573 }
574 if (image->matte != MagickFalse)
cristye1897792010-01-29 02:05:50 +0000575 (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features);
cristybd822072010-01-27 00:30:00 +0000576 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
577 channel_features);
578 }
579 if (ping == MagickFalse)
580 {
cristy3ed852e2009-09-05 21:47:34 +0000581 if (image->colorspace == CMYKColorspace)
582 (void) fprintf(file," Total ink density: %.0f%%\n",100.0*
583 GetImageTotalInkDensity(image)/(double) QuantumRange);
584 x=0;
585 if (image->matte != MagickFalse)
586 {
587 register const IndexPacket
588 *indexes;
589
590 register const PixelPacket
591 *p;
592
593 p=(PixelPacket *) NULL;
594 indexes=(IndexPacket *) NULL;
cristybb503372010-05-27 20:51:26 +0000595 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000596 {
597 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
598 if (p == (const PixelPacket *) NULL)
599 break;
600 indexes=GetVirtualIndexQueue(image);
cristybb503372010-05-27 20:51:26 +0000601 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000602 {
603 if (p->opacity == (Quantum) TransparentOpacity)
604 break;
605 p++;
606 }
cristybb503372010-05-27 20:51:26 +0000607 if (x < (ssize_t) image->columns)
cristy3ed852e2009-09-05 21:47:34 +0000608 break;
609 }
cristybb503372010-05-27 20:51:26 +0000610 if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
cristy3ed852e2009-09-05 21:47:34 +0000611 {
612 char
613 tuple[MaxTextExtent];
614
615 MagickPixelPacket
616 pixel;
617
618 GetMagickPixelPacket(image,&pixel);
619 SetMagickPixelPacket(image,p,indexes+x,&pixel);
620 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
621 &image->exception);
622 (void) fprintf(file," Alpha: %s ",tuple);
623 GetColorTuple(&pixel,MagickTrue,tuple);
624 (void) fprintf(file," %s\n",tuple);
625 }
626 }
cristy83fae872010-04-22 15:04:16 +0000627 artifact=GetImageArtifact(image,"identify:unique-colors");
cristy549a37e2010-01-26 15:24:15 +0000628 if ((artifact != (const char *) NULL) &&
629 (IsMagickTrue(artifact) != MagickFalse))
cristye8c25f92010-06-03 00:53:06 +0000630 (void) fprintf(file," Colors: %.20g\n",(double)
cristyf2faecf2010-05-28 19:19:36 +0000631 GetNumberColors(image,(FILE *) NULL,&image->exception));
cristy549a37e2010-01-26 15:24:15 +0000632 if (IsHistogramImage(image,&image->exception) != MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000633 {
cristy549a37e2010-01-26 15:24:15 +0000634 (void) fprintf(file," Histogram:\n");
635 (void) GetNumberColors(image,file,&image->exception);
cristy3ed852e2009-09-05 21:47:34 +0000636 }
637 }
638 if (image->storage_class == PseudoClass)
639 {
cristye8c25f92010-06-03 00:53:06 +0000640 (void) fprintf(file," Colormap: %.20g\n",(double) image->colors);
cristy3ed852e2009-09-05 21:47:34 +0000641 if (image->colors <= 1024)
642 {
643 char
644 color[MaxTextExtent],
645 hex[MaxTextExtent],
646 tuple[MaxTextExtent];
647
648 MagickPixelPacket
649 pixel;
650
651 register PixelPacket
cristyc47d1f82009-11-26 01:44:43 +0000652 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000653
654 GetMagickPixelPacket(image,&pixel);
655 p=image->colormap;
cristybb503372010-05-27 20:51:26 +0000656 for (i=0; i < (ssize_t) image->colors; i++)
cristy3ed852e2009-09-05 21:47:34 +0000657 {
658 SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel);
659 (void) CopyMagickString(tuple,"(",MaxTextExtent);
660 ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple);
661 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
662 ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple);
663 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
664 ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple);
665 if (pixel.colorspace == CMYKColorspace)
666 {
667 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
668 ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance,
669 tuple);
670 }
671 if (pixel.matte != MagickFalse)
672 {
673 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyc3ec0d42010-04-07 01:18:08 +0000674 ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance,
cristy3ed852e2009-09-05 21:47:34 +0000675 tuple);
676 }
677 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
678 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
679 &image->exception);
680 GetColorTuple(&pixel,MagickTrue,hex);
cristycee97112010-05-28 00:44:52 +0000681 (void) fprintf(file," %8ld: %s %s %s\n",(long) i,tuple,hex,color);
cristy3ed852e2009-09-05 21:47:34 +0000682 p++;
683 }
684 }
685 }
686 if (image->error.mean_error_per_pixel != 0.0)
cristye7f51092010-01-17 00:39:37 +0000687 (void) fprintf(file," Mean error per pixel: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000688 image->error.mean_error_per_pixel);
689 if (image->error.normalized_mean_error != 0.0)
cristye7f51092010-01-17 00:39:37 +0000690 (void) fprintf(file," Normalized mean error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000691 image->error.normalized_mean_error);
692 if (image->error.normalized_maximum_error != 0.0)
cristye7f51092010-01-17 00:39:37 +0000693 (void) fprintf(file," Normalized maximum error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000694 image->error.normalized_maximum_error);
695 (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000696 MagickIntentOptions,(ssize_t) image->rendering_intent));
cristy3ed852e2009-09-05 21:47:34 +0000697 if (image->gamma != 0.0)
cristye7f51092010-01-17 00:39:37 +0000698 (void) fprintf(file," Gamma: %g\n",image->gamma);
cristy3ed852e2009-09-05 21:47:34 +0000699 if ((image->chromaticity.red_primary.x != 0.0) ||
700 (image->chromaticity.green_primary.x != 0.0) ||
701 (image->chromaticity.blue_primary.x != 0.0) ||
702 (image->chromaticity.white_point.x != 0.0))
703 {
704 /*
705 Display image chromaticity.
706 */
707 (void) fprintf(file," Chromaticity:\n");
cristye7f51092010-01-17 00:39:37 +0000708 (void) fprintf(file," red primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000709 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
cristye7f51092010-01-17 00:39:37 +0000710 (void) fprintf(file," green primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000711 image->chromaticity.green_primary.x,
712 image->chromaticity.green_primary.y);
cristye7f51092010-01-17 00:39:37 +0000713 (void) fprintf(file," blue primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000714 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
cristye7f51092010-01-17 00:39:37 +0000715 (void) fprintf(file," white point: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000716 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
717 }
718 if ((image->extract_info.width*image->extract_info.height) != 0)
cristy6d8abba2010-06-03 01:10:47 +0000719 (void) fprintf(file," Tile geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000720 image->extract_info.width,(double) image->extract_info.height,(double)
721 image->extract_info.x,(double) image->extract_info.y);
cristy3ed852e2009-09-05 21:47:34 +0000722 (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000723 MagickInterlaceOptions,(ssize_t) image->interlace));
cristy3ed852e2009-09-05 21:47:34 +0000724 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
725 &image->exception);
726 (void) fprintf(file," Background color: %s\n",color);
727 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
728 &image->exception);
729 (void) fprintf(file," Border color: %s\n",color);
730 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
731 &image->exception);
732 (void) fprintf(file," Matte color: %s\n",color);
733 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
734 &image->exception);
735 (void) fprintf(file," Transparent color: %s\n",color);
cristy11a77682009-10-11 21:50:20 +0000736 (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000737 MagickComposeOptions,(ssize_t) image->compose));
cristy3ed852e2009-09-05 21:47:34 +0000738 if ((image->page.width != 0) || (image->page.height != 0) ||
739 (image->page.x != 0) || (image->page.y != 0))
cristy6d8abba2010-06-03 01:10:47 +0000740 (void) fprintf(file," Page geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000741 image->page.width,(double) image->page.height,(double)
742 image->page.x,(double) image->page.y);
cristy3ed852e2009-09-05 21:47:34 +0000743 if ((image->page.x != 0) || (image->page.y != 0))
cristy1565ccb2010-07-17 23:37:30 +0000744 (void) fprintf(file," Origin geometry: %+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000745 image->page.x,(double) image->page.y);
cristy3ed852e2009-09-05 21:47:34 +0000746 (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000747 MagickDisposeOptions,(ssize_t) image->dispose));
cristy3ed852e2009-09-05 21:47:34 +0000748 if (image->delay != 0)
cristye8c25f92010-06-03 00:53:06 +0000749 (void) fprintf(file," Delay: %.20gx%.20g\n",(double) image->delay,
750 (double) image->ticks_per_second);
cristy3ed852e2009-09-05 21:47:34 +0000751 if (image->iterations != 1)
cristye8c25f92010-06-03 00:53:06 +0000752 (void) fprintf(file," Iterations: %.20g\n",(double) image->iterations);
cristy3ed852e2009-09-05 21:47:34 +0000753 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
cristye8c25f92010-06-03 00:53:06 +0000754 (void) fprintf(file," Scene: %.20g of %.20g\n",(double) image->scene,
755 (double) GetImageListLength(image));
cristy3ed852e2009-09-05 21:47:34 +0000756 else
757 if (image->scene != 0)
cristye8c25f92010-06-03 00:53:06 +0000758 (void) fprintf(file," Scene: %.20g\n",(double) image->scene);
cristy3ed852e2009-09-05 21:47:34 +0000759 (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000760 MagickCompressOptions,(ssize_t) image->compression));
cristy3ed852e2009-09-05 21:47:34 +0000761 if (image->quality != UndefinedCompressionQuality)
cristye8c25f92010-06-03 00:53:06 +0000762 (void) fprintf(file," Quality: %.20g\n",(double) image->quality);
cristy3ed852e2009-09-05 21:47:34 +0000763 (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000764 MagickOrientationOptions,(ssize_t) image->orientation));
cristy3ed852e2009-09-05 21:47:34 +0000765 if (image->montage != (char *) NULL)
766 (void) fprintf(file," Montage: %s\n",image->montage);
767 if (image->directory != (char *) NULL)
768 {
769 Image
770 *tile;
771
772 ImageInfo
773 *image_info;
774
775 register char
776 *p,
777 *q;
778
779 WarningHandler
780 handler;
781
782 /*
783 Display visual image directory.
784 */
785 image_info=AcquireImageInfo();
786 (void) CloneString(&image_info->size,"64x64");
787 (void) fprintf(file," Directory:\n");
788 for (p=image->directory; *p != '\0'; p++)
789 {
790 q=p;
791 while ((*q != '\n') && (*q != '\0'))
792 q++;
793 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
794 p=q;
795 (void) fprintf(file," %s",image_info->filename);
796 handler=SetWarningHandler((WarningHandler) NULL);
797 tile=ReadImage(image_info,&image->exception);
798 (void) SetWarningHandler(handler);
799 if (tile == (Image *) NULL)
800 {
801 (void) fprintf(file,"\n");
802 continue;
803 }
cristye8c25f92010-06-03 00:53:06 +0000804 (void) fprintf(file," %.20gx%.20g %s\n",(double) tile->magick_columns,
805 (double) tile->magick_rows,tile->magick);
cristy3ed852e2009-09-05 21:47:34 +0000806 (void) SignatureImage(tile);
807 ResetImagePropertyIterator(tile);
808 property=GetNextImageProperty(tile);
809 while (property != (const char *) NULL)
810 {
811 (void) fprintf(file," %s:\n",property);
812 value=GetImageProperty(tile,property);
813 if (value != (const char *) NULL)
814 (void) fprintf(file,"%s\n",value);
815 property=GetNextImageProperty(tile);
816 }
817 tile=DestroyImage(tile);
818 }
819 image_info=DestroyImageInfo(image_info);
820 }
821 (void) GetImageProperty(image,"exif:*");
822 ResetImagePropertyIterator(image);
823 property=GetNextImageProperty(image);
824 if (property != (const char *) NULL)
825 {
826 /*
827 Display image properties.
828 */
829 (void) fprintf(file," Properties:\n");
830 while (property != (const char *) NULL)
831 {
cristy877146d2010-06-10 12:29:48 +0000832 (void) fprintf(file," %s: ",property);
cristy3ed852e2009-09-05 21:47:34 +0000833 value=GetImageProperty(image,property);
834 if (value != (const char *) NULL)
835 (void) fprintf(file,"%s\n",value);
836 property=GetNextImageProperty(image);
837 }
838 }
839 (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1");
840 value=GetImageProperty(image,key);
841 if (value != (const char *) NULL)
842 {
843 /*
844 Display clipping path.
845 */
846 (void) fprintf(file," Clipping path: ");
847 if (strlen(value) > 80)
848 (void) fputc('\n',file);
849 (void) fprintf(file,"%s\n",value);
850 }
851 ResetImageProfileIterator(image);
852 name=GetNextImageProfile(image);
853 if (name != (char *) NULL)
854 {
855 const StringInfo
856 *profile;
857
858 /*
859 Identify image profiles.
860 */
861 (void) fprintf(file," Profiles:\n");
862 while (name != (char *) NULL)
863 {
864 profile=GetImageProfile(image,name);
865 if (profile == (StringInfo *) NULL)
866 continue;
cristye8c25f92010-06-03 00:53:06 +0000867 (void) fprintf(file," Profile-%s: %.20g bytes\n",name,(double)
cristy3ed852e2009-09-05 21:47:34 +0000868 GetStringInfoLength(profile));
869#if defined(MAGICKCORE_LCMS_DELEGATE)
870 if ((LocaleCompare(name,"icc") == 0) ||
871 (LocaleCompare(name,"icm") == 0))
872 {
873 cmsHPROFILE
874 icc_profile;
875
876 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
cristyd09bcf92010-03-25 03:04:45 +0000877 (cmsUInt32Number) GetStringInfoLength(profile));
cristy3ed852e2009-09-05 21:47:34 +0000878 if (icc_profile != (cmsHPROFILE *) NULL)
879 {
cristyd09bcf92010-03-25 03:04:45 +0000880#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
cristy3ed852e2009-09-05 21:47:34 +0000881 const char
882 *name;
883
884 name=cmsTakeProductName(icc_profile);
885 if (name != (const char *) NULL)
886 (void) fprintf(file," %s\n",name);
cristyd09bcf92010-03-25 03:04:45 +0000887#else
888 char
889 info[MaxTextExtent];
890
891 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
892 "en","US",info,MaxTextExtent);
893 (void) fprintf(file," Description: %s\n",info);
894 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
895 "en","US",info,MaxTextExtent);
896 (void) fprintf(file," Manufacturer: %s\n",info);
897 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
898 "US",info,MaxTextExtent);
899 (void) fprintf(file," Model: %s\n",info);
900 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
901 "en","US",info,MaxTextExtent);
902 (void) fprintf(file," Copyright: %s\n",info);
903#endif
cristy3ed852e2009-09-05 21:47:34 +0000904 (void) cmsCloseProfile(icc_profile);
905 }
906 }
907#endif
908 if (LocaleCompare(name,"iptc") == 0)
909 {
910 char
911 *attribute,
912 **attribute_list;
913
914 const char
915 *tag;
916
cristycee97112010-05-28 00:44:52 +0000917 long
cristy3ed852e2009-09-05 21:47:34 +0000918 dataset,
919 record,
920 sentinel;
921
cristybb503372010-05-27 20:51:26 +0000922 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000923 j;
924
925 size_t
926 length,
927 profile_length;
928
929 profile_length=GetStringInfoLength(profile);
cristybb503372010-05-27 20:51:26 +0000930 for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +0000931 {
932 length=1;
933 sentinel=GetStringInfoDatum(profile)[i++];
934 if (sentinel != 0x1c)
935 continue;
936 dataset=GetStringInfoDatum(profile)[i++];
937 record=GetStringInfoDatum(profile)[i++];
938 switch (record)
939 {
940 case 5: tag="Image Name"; break;
941 case 7: tag="Edit Status"; break;
942 case 10: tag="Priority"; break;
943 case 15: tag="Category"; break;
944 case 20: tag="Supplemental Category"; break;
945 case 22: tag="Fixture Identifier"; break;
946 case 25: tag="Keyword"; break;
947 case 30: tag="Release Date"; break;
948 case 35: tag="Release Time"; break;
949 case 40: tag="Special Instructions"; break;
950 case 45: tag="Reference Service"; break;
951 case 47: tag="Reference Date"; break;
952 case 50: tag="Reference Number"; break;
953 case 55: tag="Created Date"; break;
954 case 60: tag="Created Time"; break;
955 case 65: tag="Originating Program"; break;
956 case 70: tag="Program Version"; break;
957 case 75: tag="Object Cycle"; break;
958 case 80: tag="Byline"; break;
959 case 85: tag="Byline Title"; break;
960 case 90: tag="City"; break;
961 case 95: tag="Province State"; break;
962 case 100: tag="Country Code"; break;
963 case 101: tag="Country"; break;
964 case 103: tag="Original Transmission Reference"; break;
965 case 105: tag="Headline"; break;
966 case 110: tag="Credit"; break;
967 case 115: tag="Src"; break;
968 case 116: tag="Copyright String"; break;
969 case 120: tag="Caption"; break;
970 case 121: tag="Local Caption"; break;
971 case 122: tag="Caption Writer"; break;
972 case 200: tag="Custom Field 1"; break;
973 case 201: tag="Custom Field 2"; break;
974 case 202: tag="Custom Field 3"; break;
975 case 203: tag="Custom Field 4"; break;
976 case 204: tag="Custom Field 5"; break;
977 case 205: tag="Custom Field 6"; break;
978 case 206: tag="Custom Field 7"; break;
979 case 207: tag="Custom Field 8"; break;
980 case 208: tag="Custom Field 9"; break;
981 case 209: tag="Custom Field 10"; break;
982 case 210: tag="Custom Field 11"; break;
983 case 211: tag="Custom Field 12"; break;
984 case 212: tag="Custom Field 13"; break;
985 case 213: tag="Custom Field 14"; break;
986 case 214: tag="Custom Field 15"; break;
987 case 215: tag="Custom Field 16"; break;
988 case 216: tag="Custom Field 17"; break;
989 case 217: tag="Custom Field 18"; break;
990 case 218: tag="Custom Field 19"; break;
991 case 219: tag="Custom Field 20"; break;
992 default: tag="unknown"; break;
993 }
cristye8c25f92010-06-03 00:53:06 +0000994 (void) fprintf(file," %s[%.20g,%.20g]: ",tag,(double)
995 dataset,(double) record);
cristy3ed852e2009-09-05 21:47:34 +0000996 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
997 length|=GetStringInfoDatum(profile)[i++];
998 attribute=(char *) NULL;
999 if (~length >= MaxTextExtent)
1000 attribute=(char *) AcquireQuantumMemory(length+
1001 MaxTextExtent,sizeof(*attribute));
1002 if (attribute != (char *) NULL)
1003 {
1004 (void) CopyMagickString(attribute,(char *)
1005 GetStringInfoDatum(profile)+i,length+1);
1006 attribute_list=StringToList(attribute);
1007 if (attribute_list != (char **) NULL)
1008 {
1009 for (j=0; attribute_list[j] != (char *) NULL; j++)
1010 {
1011 (void) fputs(attribute_list[j],file);
1012 (void) fputs("\n",file);
1013 attribute_list[j]=(char *) RelinquishMagickMemory(
1014 attribute_list[j]);
1015 }
1016 attribute_list=(char **) RelinquishMagickMemory(
1017 attribute_list);
1018 }
1019 attribute=DestroyString(attribute);
1020 }
1021 }
1022 }
1023 if (image->debug != MagickFalse)
1024 PrintStringInfo(file,name,profile);
1025 name=GetNextImageProfile(image);
1026 }
1027 }
1028 ResetImageArtifactIterator(image);
1029 artifact=GetNextImageArtifact(image);
1030 if (artifact != (const char *) NULL)
1031 {
1032 /*
1033 Display image artifacts.
1034 */
1035 (void) fprintf(file," Artifacts:\n");
1036 while (artifact != (const char *) NULL)
1037 {
cristy877146d2010-06-10 12:29:48 +00001038 (void) fprintf(file," %s: ",artifact);
cristy3ed852e2009-09-05 21:47:34 +00001039 value=GetImageArtifact(image,artifact);
1040 if (value != (const char *) NULL)
1041 (void) fprintf(file,"%s\n",value);
1042 artifact=GetNextImageArtifact(image);
1043 }
1044 }
1045 ResetImageRegistryIterator();
1046 registry=GetNextImageRegistry();
1047 if (registry != (const char *) NULL)
1048 {
1049 /*
1050 Display image registry.
1051 */
1052 (void) fprintf(file," Registry:\n");
1053 while (registry != (const char *) NULL)
1054 {
cristy877146d2010-06-10 12:29:48 +00001055 (void) fprintf(file," %s: ",registry);
cristy3ed852e2009-09-05 21:47:34 +00001056 value=(const char *) GetImageRegistry(StringRegistryType,registry,
1057 &image->exception);
1058 if (value != (const char *) NULL)
1059 (void) fprintf(file,"%s\n",value);
1060 registry=GetNextImageRegistry();
1061 }
1062 }
1063 (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +00001064 MagickBooleanOptions,(ssize_t) image->taint));
cristyb9080c92009-12-01 20:13:26 +00001065 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristy2ce15c92010-03-12 14:03:41 +00001066 (void) fprintf(file," Filesize: %sB\n",format);
cristyb9080c92009-12-01 20:13:26 +00001067 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1068 MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +00001069 (void) fprintf(file," Number pixels: %s\n",format);
cristy3d231692009-09-29 01:05:22 +00001070 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
cristyb9080c92009-12-01 20:13:26 +00001071 elapsed_time+0.5),MagickFalse,format);
cristy3d231692009-09-29 01:05:22 +00001072 (void) fprintf(file," Pixels per second: %s\n",format);
1073 (void) fprintf(file," User time: %0.3fu\n",user_time);
cristy91f905a2010-06-03 01:01:32 +00001074 (void) fprintf(file," Elapsed time: %lu:%02lu.%03lu\n",(unsigned long)
cristydaa71c52010-06-03 19:09:25 +00001075 (elapsed_time/60.0),(unsigned long) ceil(fmod(elapsed_time,60.0)),
cristy91f905a2010-06-03 01:01:32 +00001076 (unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
cristybb503372010-05-27 20:51:26 +00001077 (void) fprintf(file," Version: %s\n",GetMagickVersion((size_t *)
cristy3d231692009-09-29 01:05:22 +00001078 NULL));
cristy3ed852e2009-09-05 21:47:34 +00001079 (void) fflush(file);
1080 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1081}