blob: d309087c38a2843708a5012ac9ec979c56fb38a7 [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*/
cristy4c08aed2011-07-01 19:47:50 +000045#include "MagickCore/studio.h"
46#include "MagickCore/annotate.h"
47#include "MagickCore/artifact.h"
48#include "MagickCore/attribute.h"
49#include "MagickCore/blob.h"
50#include "MagickCore/cache.h"
51#include "MagickCore/client.h"
52#include "MagickCore/coder.h"
53#include "MagickCore/color.h"
54#include "MagickCore/configure.h"
55#include "MagickCore/constitute.h"
56#include "MagickCore/decorate.h"
57#include "MagickCore/delegate.h"
58#include "MagickCore/draw.h"
59#include "MagickCore/effect.h"
60#include "MagickCore/exception.h"
61#include "MagickCore/exception-private.h"
62#include "MagickCore/feature.h"
63#include "MagickCore/gem.h"
64#include "MagickCore/geometry.h"
65#include "MagickCore/histogram.h"
66#include "MagickCore/identify.h"
67#include "MagickCore/image.h"
68#include "MagickCore/image-private.h"
69#include "MagickCore/list.h"
70#include "MagickCore/locale_.h"
71#include "MagickCore/log.h"
72#include "MagickCore/magic.h"
73#include "MagickCore/magick.h"
74#include "MagickCore/memory_.h"
75#include "MagickCore/module.h"
76#include "MagickCore/monitor.h"
77#include "MagickCore/montage.h"
78#include "MagickCore/option.h"
79#include "MagickCore/pixel-accessor.h"
80#include "MagickCore/prepress.h"
81#include "MagickCore/profile.h"
82#include "MagickCore/property.h"
83#include "MagickCore/quantize.h"
84#include "MagickCore/quantum.h"
85#include "MagickCore/random_.h"
86#include "MagickCore/registry.h"
87#include "MagickCore/resize.h"
88#include "MagickCore/resource_.h"
89#include "MagickCore/signature.h"
90#include "MagickCore/statistic.h"
91#include "MagickCore/string_.h"
92#include "MagickCore/string-private.h"
93#include "MagickCore/timer.h"
94#include "MagickCore/utility.h"
cristyd1dd6e42011-09-04 01:46:08 +000095#include "MagickCore/utility-private.h"
cristy4c08aed2011-07-01 19:47:50 +000096#include "MagickCore/version.h"
cristy3ed852e2009-09-05 21:47:34 +000097#if defined(MAGICKCORE_LCMS_DELEGATE)
cristyd09bcf92010-03-25 03:04:45 +000098#if defined(MAGICKCORE_HAVE_LCMS_LCMS2_H)
99#include <lcms/lcms2.h>
100#elif defined(MAGICKCORE_HAVE_LCMS2_H)
101#include "lcms2.h"
102#elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
cristy3ed852e2009-09-05 21:47:34 +0000103#include <lcms/lcms.h>
104#else
105#include "lcms.h"
106#endif
107#endif
108
109/*
cristyd09bcf92010-03-25 03:04:45 +0000110 Define declarations.
111*/
112#if defined(MAGICKCORE_LCMS_DELEGATE)
113#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
114#define cmsUInt32Number DWORD
115#endif
116#endif
117
118/*
cristy3ed852e2009-09-05 21:47:34 +0000119%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120% %
121% %
122% %
123% I d e n t i f y I m a g e %
124% %
125% %
126% %
127%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128%
129% IdentifyImage() identifies an image by printing its attributes to the file.
130% Attributes include the image width, height, size, and others.
131%
132% The format of the IdentifyImage method is:
133%
134% MagickBooleanType IdentifyImage(Image *image,FILE *file,
cristya4037272011-08-28 15:11:39 +0000135% const MagickBooleanType verbose,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000136%
137% A description of each parameter follows:
138%
139% o image: the image.
140%
141% o file: the file, typically stdout.
142%
143% o verbose: A value other than zero prints more detailed information
144% about the image.
145%
cristya4037272011-08-28 15:11:39 +0000146% o exception: return any errors or warnings in this structure.
147%
cristy3ed852e2009-09-05 21:47:34 +0000148*/
149
cristy95a072b2011-10-13 18:03:11 +0000150static ssize_t PrintChannelFeatures(FILE *file,const PixelChannel channel,
cristye1897792010-01-29 02:05:50 +0000151 const char *name,const ChannelFeatures *channel_features)
cristy3ed852e2009-09-05 21:47:34 +0000152{
cristye1897792010-01-29 02:05:50 +0000153#define PrintFeature(feature) \
154 GetMagickPrecision(),(feature)[0], \
155 GetMagickPrecision(),(feature)[1], \
156 GetMagickPrecision(),(feature)[2], \
cristye0acabf2010-01-30 00:52:38 +0000157 GetMagickPrecision(),(feature)[3], \
158 GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
cristye1897792010-01-29 02:05:50 +0000159
cristybd822072010-01-27 00:30:00 +0000160#define FeaturesFormat " %s:\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000161 " Angular Second Moment:\n" \
cristye0acabf2010-01-30 00:52:38 +0000162 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000163 " Contrast:\n" \
cristye0acabf2010-01-30 00:52:38 +0000164 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000165 " Correlation:\n" \
cristye0acabf2010-01-30 00:52:38 +0000166 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000167 " Sum of Squares: Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000168 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycf5e6492010-01-28 02:45:28 +0000169 " Inverse Difference Moment:\n" \
cristye0acabf2010-01-30 00:52:38 +0000170 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000171 " Sum Average:\n" \
cristye0acabf2010-01-30 00:52:38 +0000172 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000173 " Sum Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000174 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000175 " Sum Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000176 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000177 " Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000178 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000179 " Difference Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000180 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000181 " Difference Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000182 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000183 " Information Measure of Correlation 1:\n" \
cristye0acabf2010-01-30 00:52:38 +0000184 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000185 " Information Measure of Correlation 2:\n" \
cristye0acabf2010-01-30 00:52:38 +0000186 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000187 " Maximum Correlation Coefficient:\n" \
cristyc3ec0d42010-04-07 01:18:08 +0000188 " %.*g, %.*g, %.*g, %.*g, %.*g\n"
cristybd822072010-01-27 00:30:00 +0000189
cristy20ec7592011-05-29 01:28:05 +0000190 ssize_t
191 n;
cristybd822072010-01-27 00:30:00 +0000192
cristy20ec7592011-05-29 01:28:05 +0000193 n=FormatLocaleFile(file,FeaturesFormat,name,
cristye1897792010-01-29 02:05:50 +0000194 PrintFeature(channel_features[channel].angular_second_moment),
195 PrintFeature(channel_features[channel].contrast),
196 PrintFeature(channel_features[channel].correlation),
197 PrintFeature(channel_features[channel].variance_sum_of_squares),
198 PrintFeature(channel_features[channel].inverse_difference_moment),
199 PrintFeature(channel_features[channel].sum_average),
200 PrintFeature(channel_features[channel].sum_variance),
201 PrintFeature(channel_features[channel].sum_entropy),
202 PrintFeature(channel_features[channel].entropy),
cristye0e19dc2010-01-29 02:13:08 +0000203 PrintFeature(channel_features[channel].difference_variance),
204 PrintFeature(channel_features[channel].difference_entropy),
205 PrintFeature(channel_features[channel].measure_of_correlation_1),
206 PrintFeature(channel_features[channel].measure_of_correlation_2),
207 PrintFeature(channel_features[channel].maximum_correlation_coefficient));
cristy20ec7592011-05-29 01:28:05 +0000208 return(n);
cristybd822072010-01-27 00:30:00 +0000209}
210
cristy95a072b2011-10-13 18:03:11 +0000211static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel,
cristybd822072010-01-27 00:30:00 +0000212 const char *name,const double scale,
213 const ChannelStatistics *channel_statistics)
214{
215#define StatisticsFormat " %s:\n min: " QuantumFormat \
cristye7f51092010-01-17 00:39:37 +0000216 " (%g)\n max: " QuantumFormat " (%g)\n" \
217 " mean: %g (%g)\n standard deviation: %g (%g)\n" \
218 " kurtosis: %g\n skewness: %g\n"
cristy3ed852e2009-09-05 21:47:34 +0000219
cristy20ec7592011-05-29 01:28:05 +0000220 ssize_t
221 n;
cristybd822072010-01-27 00:30:00 +0000222
cristy20ec7592011-05-29 01:28:05 +0000223 n=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale*
cristya45da3b2010-03-31 02:06:45 +0000224 channel_statistics[channel].minima),channel_statistics[channel].minima/
225 (double) QuantumRange,ClampToQuantum(scale*
226 channel_statistics[channel].maxima),channel_statistics[channel].maxima/
227 (double) QuantumRange,scale*channel_statistics[channel].mean,
228 channel_statistics[channel].mean/(double) QuantumRange,scale*
229 channel_statistics[channel].standard_deviation,
cristy75b5a252010-02-26 02:40:46 +0000230 channel_statistics[channel].standard_deviation/(double) QuantumRange,
231 channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
cristy20ec7592011-05-29 01:28:05 +0000232 return(n);
cristybd822072010-01-27 00:30:00 +0000233}
234
235MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
cristya4037272011-08-28 15:11:39 +0000236 const MagickBooleanType verbose,ExceptionInfo *exception)
cristybd822072010-01-27 00:30:00 +0000237{
cristy3ed852e2009-09-05 21:47:34 +0000238 char
239 color[MaxTextExtent],
240 format[MaxTextExtent],
241 key[MaxTextExtent];
242
cristybd822072010-01-27 00:30:00 +0000243 ChannelFeatures
244 *channel_features;
245
246 ChannelStatistics
247 *channel_statistics;
248
cristy3ed852e2009-09-05 21:47:34 +0000249 ColorspaceType
250 colorspace;
251
252 const char
253 *artifact,
254 *name,
255 *property,
256 *registry,
257 *value;
258
259 const MagickInfo
260 *magick_info;
261
cristy3ed852e2009-09-05 21:47:34 +0000262 double
263 elapsed_time,
264 user_time;
265
cristy3ed852e2009-09-05 21:47:34 +0000266 ImageType
267 type;
268
cristy3ed852e2009-09-05 21:47:34 +0000269 MagickBooleanType
270 ping;
271
cristy4c08aed2011-07-01 19:47:50 +0000272 register const Quantum
273 *p;
274
cristybb503372010-05-27 20:51:26 +0000275 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000276 i,
277 x;
278
cristybb503372010-05-27 20:51:26 +0000279 size_t
cristybd822072010-01-27 00:30:00 +0000280 distance,
cristy3ed852e2009-09-05 21:47:34 +0000281 scale;
282
cristy9d314ff2011-03-09 01:30:28 +0000283 ssize_t
284 y;
285
cristy3ed852e2009-09-05 21:47:34 +0000286 assert(image != (Image *) NULL);
287 assert(image->signature == MagickSignature);
288 if (image->debug != MagickFalse)
289 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
290 if (file == (FILE *) NULL)
291 file=stdout;
292 *format='\0';
293 elapsed_time=GetElapsedTime(&image->timer);
294 user_time=GetUserTime(&image->timer);
295 GetTimerInfo(&image->timer);
296 if (verbose == MagickFalse)
297 {
298 /*
299 Display summary info about the image.
300 */
301 if (*image->magick_filename != '\0')
302 if (LocaleCompare(image->magick_filename,image->filename) != 0)
cristyb51dff52011-05-19 16:55:47 +0000303 (void) FormatLocaleFile(file,"%s=>",image->magick_filename);
cristy3ed852e2009-09-05 21:47:34 +0000304 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
cristy81b8ce52010-02-05 01:53:17 +0000305 (GetNextImageInList(image) == (Image *) NULL) &&
306 (image->scene == 0))
cristyb51dff52011-05-19 16:55:47 +0000307 (void) FormatLocaleFile(file,"%s ",image->filename);
cristy3ed852e2009-09-05 21:47:34 +0000308 else
cristy1e604812011-05-19 18:07:50 +0000309 (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double)
310 image->scene);
cristyb51dff52011-05-19 16:55:47 +0000311 (void) FormatLocaleFile(file,"%s ",image->magick);
cristy3ed852e2009-09-05 21:47:34 +0000312 if ((image->magick_columns != 0) || (image->magick_rows != 0))
313 if ((image->magick_columns != image->columns) ||
314 (image->magick_rows != image->rows))
cristy1e604812011-05-19 18:07:50 +0000315 (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double)
316 image->magick_columns,(double) image->magick_rows);
317 (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns,
318 (double) image->rows);
cristy3ed852e2009-09-05 21:47:34 +0000319 if ((image->page.width != 0) || (image->page.height != 0) ||
320 (image->page.x != 0) || (image->page.y != 0))
cristyb51dff52011-05-19 16:55:47 +0000321 (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double)
cristye8c25f92010-06-03 00:53:06 +0000322 image->page.width,(double) image->page.height,(double) image->page.x,
323 (double) image->page.y);
cristyb51dff52011-05-19 16:55:47 +0000324 (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth);
cristy5f1c1ff2010-12-23 21:38:06 +0000325 if (image->type != UndefinedType)
cristy1e604812011-05-19 18:07:50 +0000326 (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
327 MagickTypeOptions,(ssize_t) image->type));
cristy3ed852e2009-09-05 21:47:34 +0000328 if (image->storage_class == DirectClass)
329 {
cristyb51dff52011-05-19 16:55:47 +0000330 (void) FormatLocaleFile(file,"DirectClass ");
cristy3ed852e2009-09-05 21:47:34 +0000331 if (image->total_colors != 0)
332 {
cristyb9080c92009-12-01 20:13:26 +0000333 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +0000334 (void) FormatLocaleFile(file,"%s ",format);
cristy3ed852e2009-09-05 21:47:34 +0000335 }
336 }
337 else
338 if (image->total_colors <= image->colors)
cristy1e604812011-05-19 18:07:50 +0000339 (void) FormatLocaleFile(file,"PseudoClass %.20gc ",(double)
340 image->colors);
cristyf2faecf2010-05-28 19:19:36 +0000341 else
cristyb51dff52011-05-19 16:55:47 +0000342 (void) FormatLocaleFile(file,"PseudoClass %.20g=>%.20gc ",(double)
cristye8c25f92010-06-03 00:53:06 +0000343 image->total_colors,(double) image->colors);
cristy3ed852e2009-09-05 21:47:34 +0000344 if (image->error.mean_error_per_pixel != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000345 (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double)
cristy3ed852e2009-09-05 21:47:34 +0000346 (image->error.mean_error_per_pixel+0.5),
347 image->error.normalized_mean_error,
348 image->error.normalized_maximum_error);
349 if (GetBlobSize(image) != 0)
350 {
cristyb9080c92009-12-01 20:13:26 +0000351 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +0000352 (void) FormatLocaleFile(file,"%s ",format);
cristy3ed852e2009-09-05 21:47:34 +0000353 }
cristy1e604812011-05-19 18:07:50 +0000354 (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time,
355 (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod(
356 elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time-
357 floor(elapsed_time))));
cristyb51dff52011-05-19 16:55:47 +0000358 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000359 (void) fflush(file);
360 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
361 }
362 /*
363 Display verbose info about the image.
364 */
cristy4c08aed2011-07-01 19:47:50 +0000365 p=GetVirtualPixels(image,0,0,1,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000366 ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse;
cristya4037272011-08-28 15:11:39 +0000367 type=GetImageType(image,exception);
cristy018f07f2011-09-04 21:15:19 +0000368 (void) SignatureImage(image,exception);
cristyb51dff52011-05-19 16:55:47 +0000369 (void) FormatLocaleFile(file,"Image: %s\n",image->filename);
cristy3ed852e2009-09-05 21:47:34 +0000370 if (*image->magick_filename != '\0')
371 if (LocaleCompare(image->magick_filename,image->filename) != 0)
372 {
373 char
374 filename[MaxTextExtent];
375
376 GetPathComponent(image->magick_filename,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +0000377 (void) FormatLocaleFile(file," Base filename: %s\n",filename);
cristy3ed852e2009-09-05 21:47:34 +0000378 }
cristya4037272011-08-28 15:11:39 +0000379 magick_info=GetMagickInfo(image->magick,exception);
cristy3ed852e2009-09-05 21:47:34 +0000380 if ((magick_info == (const MagickInfo *) NULL) ||
381 (*GetMagickDescription(magick_info) == '\0'))
cristyb51dff52011-05-19 16:55:47 +0000382 (void) FormatLocaleFile(file," Format: %s\n",image->magick);
cristy3ed852e2009-09-05 21:47:34 +0000383 else
cristyb51dff52011-05-19 16:55:47 +0000384 (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick,
cristy3ed852e2009-09-05 21:47:34 +0000385 GetMagickDescription(magick_info));
cristy1e604812011-05-19 18:07:50 +0000386 (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic(
387 MagickClassOptions,(ssize_t) image->storage_class));
cristyb51dff52011-05-19 16:55:47 +0000388 (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000389 image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
390 image->tile_offset.y);
cristy3ed852e2009-09-05 21:47:34 +0000391 if ((image->magick_columns != 0) || (image->magick_rows != 0))
392 if ((image->magick_columns != image->columns) ||
393 (image->magick_rows != image->rows))
cristyb51dff52011-05-19 16:55:47 +0000394 (void) FormatLocaleFile(file," Base geometry: %.20gx%.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000395 image->magick_columns,(double) image->magick_rows);
cristy3ed852e2009-09-05 21:47:34 +0000396 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
397 {
cristyb51dff52011-05-19 16:55:47 +0000398 (void) FormatLocaleFile(file," Resolution: %gx%g\n",image->x_resolution,
cristy3ed852e2009-09-05 21:47:34 +0000399 image->y_resolution);
cristy1e604812011-05-19 18:07:50 +0000400 (void) FormatLocaleFile(file," Print size: %gx%g\n",(double)
401 image->columns/image->x_resolution,(double) image->rows/
402 image->y_resolution);
cristy3ed852e2009-09-05 21:47:34 +0000403 }
cristyb51dff52011-05-19 16:55:47 +0000404 (void) FormatLocaleFile(file," Units: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000405 MagickResolutionOptions,(ssize_t) image->units));
cristy1e604812011-05-19 18:07:50 +0000406 (void) FormatLocaleFile(file," Type: %s\n",CommandOptionToMnemonic(
407 MagickTypeOptions,(ssize_t) type));
cristy5f1c1ff2010-12-23 21:38:06 +0000408 if (image->type != UndefinedType)
cristyb51dff52011-05-19 16:55:47 +0000409 (void) FormatLocaleFile(file," Base type: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000410 MagickTypeOptions,(ssize_t) image->type));
cristyb51dff52011-05-19 16:55:47 +0000411 (void) FormatLocaleFile(file," Endianess: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000412 MagickEndianOptions,(ssize_t) image->endian));
cristy3ed852e2009-09-05 21:47:34 +0000413 /*
414 Detail channel depth and extrema.
415 */
cristyb51dff52011-05-19 16:55:47 +0000416 (void) FormatLocaleFile(file," Colorspace: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000417 MagickColorspaceOptions,(ssize_t) image->colorspace));
cristybd822072010-01-27 00:30:00 +0000418 channel_statistics=(ChannelStatistics *) NULL;
cristy15a88782010-01-31 23:24:49 +0000419 channel_features=(ChannelFeatures *) NULL;
420 colorspace=image->colorspace;
cristy3ed852e2009-09-05 21:47:34 +0000421 if (ping == MagickFalse)
422 {
cristybb503372010-05-27 20:51:26 +0000423 size_t
cristy3ed852e2009-09-05 21:47:34 +0000424 depth;
425
cristya4037272011-08-28 15:11:39 +0000426 channel_statistics=GetImageStatistics(image,exception);
cristy15a88782010-01-31 23:24:49 +0000427 artifact=GetImageArtifact(image,"identify:features");
428 if (artifact != (const char *) NULL)
429 {
430 distance=StringToUnsignedLong(artifact);
cristya4037272011-08-28 15:11:39 +0000431 channel_features=GetImageFeatures(image,distance,exception);
cristy15a88782010-01-31 23:24:49 +0000432 }
cristya4037272011-08-28 15:11:39 +0000433 depth=GetImageDepth(image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000434 if (image->depth == depth)
cristy1e604812011-05-19 18:07:50 +0000435 (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double)
436 image->depth);
cristy3ed852e2009-09-05 21:47:34 +0000437 else
cristyb51dff52011-05-19 16:55:47 +0000438 (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000439 image->depth,(double) depth);
cristyb51dff52011-05-19 16:55:47 +0000440 (void) FormatLocaleFile(file," Channel depth:\n");
cristya4037272011-08-28 15:11:39 +0000441 if (IsImageGray(image,exception) != MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000442 colorspace=GRAYColorspace;
443 switch (colorspace)
444 {
445 case RGBColorspace:
446 default:
447 {
cristyb51dff52011-05-19 16:55:47 +0000448 (void) FormatLocaleFile(file," red: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000449 channel_statistics[RedPixelChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000450 (void) FormatLocaleFile(file," green: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000451 channel_statistics[GreenPixelChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000452 (void) FormatLocaleFile(file," blue: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000453 channel_statistics[BluePixelChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000454 break;
455 }
456 case CMYKColorspace:
457 {
cristyb51dff52011-05-19 16:55:47 +0000458 (void) FormatLocaleFile(file," cyan: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000459 channel_statistics[CyanPixelChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000460 (void) FormatLocaleFile(file," magenta: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000461 channel_statistics[MagentaPixelChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000462 (void) FormatLocaleFile(file," yellow: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000463 channel_statistics[YellowPixelChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000464 (void) FormatLocaleFile(file," black: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000465 channel_statistics[BlackPixelChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000466 break;
467 }
468 case GRAYColorspace:
469 {
cristyb51dff52011-05-19 16:55:47 +0000470 (void) FormatLocaleFile(file," gray: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000471 channel_statistics[GrayPixelChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000472 break;
473 }
474 }
cristye8c25f92010-06-03 00:53:06 +0000475 if (image->matte != MagickFalse)
cristyb51dff52011-05-19 16:55:47 +0000476 (void) FormatLocaleFile(file," alpha: %.20g-bit\n",(double)
cristy95a072b2011-10-13 18:03:11 +0000477 channel_statistics[AlphaPixelChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000478 scale=1;
479 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
cristybb503372010-05-27 20:51:26 +0000480 scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
cristy3ed852e2009-09-05 21:47:34 +0000481 MAGICKCORE_QUANTUM_DEPTH-image->depth));
cristy15a88782010-01-31 23:24:49 +0000482 }
483 if (channel_statistics != (ChannelStatistics *) NULL)
484 {
cristyb51dff52011-05-19 16:55:47 +0000485 (void) FormatLocaleFile(file," Channel statistics:\n");
cristy3ed852e2009-09-05 21:47:34 +0000486 switch (colorspace)
487 {
488 case RGBColorspace:
489 default:
490 {
cristy95a072b2011-10-13 18:03:11 +0000491 (void) PrintChannelStatistics(file,RedPixelChannel,"Red",1.0/
492 scale,channel_statistics);
493 (void) PrintChannelStatistics(file,GreenPixelChannel,"Green",1.0/
494 scale,channel_statistics);
495 (void) PrintChannelStatistics(file,BluePixelChannel,"Blue",1.0/
496 scale,channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000497 break;
498 }
499 case CMYKColorspace:
500 {
cristy95a072b2011-10-13 18:03:11 +0000501 (void) PrintChannelStatistics(file,CyanPixelChannel,"Cyan",1.0/
502 scale,channel_statistics);
503 (void) PrintChannelStatistics(file,MagentaPixelChannel,"Magenta",1.0/
504 scale,channel_statistics);
505 (void) PrintChannelStatistics(file,YellowPixelChannel,"Yellow",1.0/
506 scale,channel_statistics);
507 (void) PrintChannelStatistics(file,BlackPixelChannel,"Black",1.0/
508 scale,channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000509 break;
510 }
511 case GRAYColorspace:
512 {
cristy95a072b2011-10-13 18:03:11 +0000513 (void) PrintChannelStatistics(file,GrayPixelChannel,"Gray",1.0/
514 scale,channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000515 break;
516 }
517 }
518 if (image->matte != MagickFalse)
cristy95a072b2011-10-13 18:03:11 +0000519 (void) PrintChannelStatistics(file,AlphaPixelChannel,"Alpha",1.0/
520 scale,channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000521 if (colorspace != GRAYColorspace)
522 {
cristyb51dff52011-05-19 16:55:47 +0000523 (void) FormatLocaleFile(file," Image statistics:\n");
cristy95a072b2011-10-13 18:03:11 +0000524 (void) PrintChannelStatistics(file,MaxPixelChannels,"Overall",
525 1.0/scale,channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000526 }
527 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
528 channel_statistics);
cristybd822072010-01-27 00:30:00 +0000529 }
cristybd822072010-01-27 00:30:00 +0000530 if (channel_features != (ChannelFeatures *) NULL)
531 {
cristy1e604812011-05-19 18:07:50 +0000532 (void) FormatLocaleFile(file," Channel features (horizontal, vertical, "
533 "left and right diagonals, average):\n");
cristybd822072010-01-27 00:30:00 +0000534 switch (colorspace)
535 {
536 case RGBColorspace:
537 default:
cristy549a37e2010-01-26 15:24:15 +0000538 {
cristy95a072b2011-10-13 18:03:11 +0000539 (void) PrintChannelFeatures(file,RedPixelChannel,"Red",
cristybd822072010-01-27 00:30:00 +0000540 channel_features);
cristy95a072b2011-10-13 18:03:11 +0000541 (void) PrintChannelFeatures(file,GreenPixelChannel,"Green",
542 channel_features);
543 (void) PrintChannelFeatures(file,BluePixelChannel,"Blue",
544 channel_features);
cristybd822072010-01-27 00:30:00 +0000545 break;
546 }
547 case CMYKColorspace:
548 {
cristy95a072b2011-10-13 18:03:11 +0000549 (void) PrintChannelFeatures(file,CyanPixelChannel,"Cyan",
cristybd822072010-01-27 00:30:00 +0000550 channel_features);
cristy95a072b2011-10-13 18:03:11 +0000551 (void) PrintChannelFeatures(file,MagentaPixelChannel,"Magenta",
cristybd822072010-01-27 00:30:00 +0000552 channel_features);
cristy95a072b2011-10-13 18:03:11 +0000553 (void) PrintChannelFeatures(file,YellowPixelChannel,"Yellow",
554 channel_features);
555 (void) PrintChannelFeatures(file,BlackPixelChannel,"Black",
cristybd822072010-01-27 00:30:00 +0000556 channel_features);
557 break;
558 }
559 case GRAYColorspace:
560 {
cristy95a072b2011-10-13 18:03:11 +0000561 (void) PrintChannelFeatures(file,GrayPixelChannel,"Gray",
562 channel_features);
cristybd822072010-01-27 00:30:00 +0000563 break;
564 }
565 }
566 if (image->matte != MagickFalse)
cristy95a072b2011-10-13 18:03:11 +0000567 (void) PrintChannelFeatures(file,AlphaPixelChannel,"Alpha",
568 channel_features);
cristybd822072010-01-27 00:30:00 +0000569 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
570 channel_features);
571 }
572 if (ping == MagickFalse)
573 {
cristy3ed852e2009-09-05 21:47:34 +0000574 if (image->colorspace == CMYKColorspace)
cristyb51dff52011-05-19 16:55:47 +0000575 (void) FormatLocaleFile(file," Total ink density: %.0f%%\n",100.0*
cristy3ed852e2009-09-05 21:47:34 +0000576 GetImageTotalInkDensity(image)/(double) QuantumRange);
577 x=0;
578 if (image->matte != MagickFalse)
579 {
cristy4c08aed2011-07-01 19:47:50 +0000580 register const Quantum
cristy3ed852e2009-09-05 21:47:34 +0000581 *p;
582
cristy4c08aed2011-07-01 19:47:50 +0000583 p=(const Quantum *) NULL;
cristybb503372010-05-27 20:51:26 +0000584 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000585 {
586 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000587 if (p == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000588 break;
cristybb503372010-05-27 20:51:26 +0000589 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000590 {
cristy4c08aed2011-07-01 19:47:50 +0000591 if (GetPixelAlpha(image,p) == (Quantum) TransparentAlpha)
cristy3ed852e2009-09-05 21:47:34 +0000592 break;
cristyed231572011-07-14 02:18:59 +0000593 p+=GetPixelChannels(image);
cristy3ed852e2009-09-05 21:47:34 +0000594 }
cristybb503372010-05-27 20:51:26 +0000595 if (x < (ssize_t) image->columns)
cristy3ed852e2009-09-05 21:47:34 +0000596 break;
597 }
cristybb503372010-05-27 20:51:26 +0000598 if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
cristy3ed852e2009-09-05 21:47:34 +0000599 {
600 char
601 tuple[MaxTextExtent];
602
cristy4c08aed2011-07-01 19:47:50 +0000603 PixelInfo
cristy3ed852e2009-09-05 21:47:34 +0000604 pixel;
605
cristy4c08aed2011-07-01 19:47:50 +0000606 GetPixelInfo(image,&pixel);
607 SetPixelInfo(image,p,&pixel);
cristy269c9412011-10-13 23:41:15 +0000608 (void) QueryColorname(image,&pixel,SVGCompliance,tuple,
cristya4037272011-08-28 15:11:39 +0000609 exception);
cristyb51dff52011-05-19 16:55:47 +0000610 (void) FormatLocaleFile(file," Alpha: %s ",tuple);
cristy3ed852e2009-09-05 21:47:34 +0000611 GetColorTuple(&pixel,MagickTrue,tuple);
cristyb51dff52011-05-19 16:55:47 +0000612 (void) FormatLocaleFile(file," %s\n",tuple);
cristy3ed852e2009-09-05 21:47:34 +0000613 }
614 }
cristy83fae872010-04-22 15:04:16 +0000615 artifact=GetImageArtifact(image,"identify:unique-colors");
cristya4037272011-08-28 15:11:39 +0000616 if (IsHistogramImage(image,exception) != MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000617 {
cristy4c967562011-06-16 01:46:57 +0000618 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
cristya4037272011-08-28 15:11:39 +0000619 GetNumberColors(image,(FILE *) NULL,exception));
cristyb51dff52011-05-19 16:55:47 +0000620 (void) FormatLocaleFile(file," Histogram:\n");
cristya4037272011-08-28 15:11:39 +0000621 (void) GetNumberColors(image,file,exception);
cristy3ed852e2009-09-05 21:47:34 +0000622 }
cristy4c967562011-06-16 01:46:57 +0000623 else
624 if ((artifact != (const char *) NULL) &&
625 (IsMagickTrue(artifact) != MagickFalse))
626 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
cristya4037272011-08-28 15:11:39 +0000627 GetNumberColors(image,(FILE *) NULL,exception));
cristy3ed852e2009-09-05 21:47:34 +0000628 }
629 if (image->storage_class == PseudoClass)
630 {
cristya4037272011-08-28 15:11:39 +0000631 (void) FormatLocaleFile(file," Colormap: %.20g\n",(double)
632 image->colors);
cristy3ed852e2009-09-05 21:47:34 +0000633 if (image->colors <= 1024)
634 {
635 char
636 color[MaxTextExtent],
637 hex[MaxTextExtent],
638 tuple[MaxTextExtent];
639
cristy4c08aed2011-07-01 19:47:50 +0000640 PixelInfo
cristy3ed852e2009-09-05 21:47:34 +0000641 pixel;
642
cristy101ab702011-10-13 13:06:32 +0000643 register PixelInfo
cristyc47d1f82009-11-26 01:44:43 +0000644 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000645
cristy4c08aed2011-07-01 19:47:50 +0000646 GetPixelInfo(image,&pixel);
cristy3ed852e2009-09-05 21:47:34 +0000647 p=image->colormap;
cristybb503372010-05-27 20:51:26 +0000648 for (i=0; i < (ssize_t) image->colors; i++)
cristy3ed852e2009-09-05 21:47:34 +0000649 {
cristy4c08aed2011-07-01 19:47:50 +0000650 SetPixelInfoPacket(image,p,&pixel);
cristy3ed852e2009-09-05 21:47:34 +0000651 (void) CopyMagickString(tuple,"(",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000652 ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
cristyfa806a72011-07-04 02:06:13 +0000653 tuple);
cristy3ed852e2009-09-05 21:47:34 +0000654 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000655 ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
cristyfa806a72011-07-04 02:06:13 +0000656 tuple);
cristy3ed852e2009-09-05 21:47:34 +0000657 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000658 ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
cristyfa806a72011-07-04 02:06:13 +0000659 tuple);
cristy3ed852e2009-09-05 21:47:34 +0000660 if (pixel.colorspace == CMYKColorspace)
661 {
662 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000663 ConcatenateColorComponent(&pixel,BlackPixelChannel,
cristyfa806a72011-07-04 02:06:13 +0000664 X11Compliance,tuple);
cristy3ed852e2009-09-05 21:47:34 +0000665 }
666 if (pixel.matte != MagickFalse)
667 {
668 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000669 ConcatenateColorComponent(&pixel,AlphaPixelChannel,
cristyfa806a72011-07-04 02:06:13 +0000670 X11Compliance,tuple);
cristy3ed852e2009-09-05 21:47:34 +0000671 }
672 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
cristy269c9412011-10-13 23:41:15 +0000673 (void) QueryColorname(image,&pixel,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000674 exception);
cristy3ed852e2009-09-05 21:47:34 +0000675 GetColorTuple(&pixel,MagickTrue,hex);
cristy1e604812011-05-19 18:07:50 +0000676 (void) FormatLocaleFile(file," %8ld: %s %s %s\n",(long) i,tuple,
677 hex,color);
cristy3ed852e2009-09-05 21:47:34 +0000678 p++;
679 }
680 }
681 }
682 if (image->error.mean_error_per_pixel != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000683 (void) FormatLocaleFile(file," Mean error per pixel: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000684 image->error.mean_error_per_pixel);
685 if (image->error.normalized_mean_error != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000686 (void) FormatLocaleFile(file," Normalized mean error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000687 image->error.normalized_mean_error);
688 if (image->error.normalized_maximum_error != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000689 (void) FormatLocaleFile(file," Normalized maximum error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000690 image->error.normalized_maximum_error);
cristy1e604812011-05-19 18:07:50 +0000691 (void) FormatLocaleFile(file," Rendering intent: %s\n",
692 CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
693 image->rendering_intent));
cristy3ed852e2009-09-05 21:47:34 +0000694 if (image->gamma != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000695 (void) FormatLocaleFile(file," Gamma: %g\n",image->gamma);
cristy3ed852e2009-09-05 21:47:34 +0000696 if ((image->chromaticity.red_primary.x != 0.0) ||
697 (image->chromaticity.green_primary.x != 0.0) ||
698 (image->chromaticity.blue_primary.x != 0.0) ||
699 (image->chromaticity.white_point.x != 0.0))
700 {
701 /*
702 Display image chromaticity.
703 */
cristyb51dff52011-05-19 16:55:47 +0000704 (void) FormatLocaleFile(file," Chromaticity:\n");
705 (void) FormatLocaleFile(file," red primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000706 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
cristyb51dff52011-05-19 16:55:47 +0000707 (void) FormatLocaleFile(file," green primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000708 image->chromaticity.green_primary.x,
709 image->chromaticity.green_primary.y);
cristyb51dff52011-05-19 16:55:47 +0000710 (void) FormatLocaleFile(file," blue primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000711 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
cristyb51dff52011-05-19 16:55:47 +0000712 (void) FormatLocaleFile(file," white point: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000713 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
714 }
715 if ((image->extract_info.width*image->extract_info.height) != 0)
cristy1e604812011-05-19 18:07:50 +0000716 (void) FormatLocaleFile(file," Tile geometry: %.20gx%.20g%+.20g%+.20g\n",
717 (double) image->extract_info.width,(double) image->extract_info.height,
718 (double) image->extract_info.x,(double) image->extract_info.y);
cristyb51dff52011-05-19 16:55:47 +0000719 (void) FormatLocaleFile(file," Interlace: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000720 MagickInterlaceOptions,(ssize_t) image->interlace));
cristy3ed852e2009-09-05 21:47:34 +0000721 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000722 exception);
cristyb51dff52011-05-19 16:55:47 +0000723 (void) FormatLocaleFile(file," Background color: %s\n",color);
cristy3ed852e2009-09-05 21:47:34 +0000724 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000725 exception);
cristyb51dff52011-05-19 16:55:47 +0000726 (void) FormatLocaleFile(file," Border color: %s\n",color);
cristy3ed852e2009-09-05 21:47:34 +0000727 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000728 exception);
cristyb51dff52011-05-19 16:55:47 +0000729 (void) FormatLocaleFile(file," Matte color: %s\n",color);
cristy3ed852e2009-09-05 21:47:34 +0000730 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000731 exception);
cristyb51dff52011-05-19 16:55:47 +0000732 (void) FormatLocaleFile(file," Transparent color: %s\n",color);
733 (void) FormatLocaleFile(file," Compose: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000734 MagickComposeOptions,(ssize_t) image->compose));
cristy3ed852e2009-09-05 21:47:34 +0000735 if ((image->page.width != 0) || (image->page.height != 0) ||
736 (image->page.x != 0) || (image->page.y != 0))
cristy1e604812011-05-19 18:07:50 +0000737 (void) FormatLocaleFile(file," Page geometry: %.20gx%.20g%+.20g%+.20g\n",
738 (double) image->page.width,(double) image->page.height,(double)
cristye8c25f92010-06-03 00:53:06 +0000739 image->page.x,(double) image->page.y);
cristy3ed852e2009-09-05 21:47:34 +0000740 if ((image->page.x != 0) || (image->page.y != 0))
cristyb51dff52011-05-19 16:55:47 +0000741 (void) FormatLocaleFile(file," Origin geometry: %+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000742 image->page.x,(double) image->page.y);
cristyb51dff52011-05-19 16:55:47 +0000743 (void) FormatLocaleFile(file," Dispose: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000744 MagickDisposeOptions,(ssize_t) image->dispose));
cristy3ed852e2009-09-05 21:47:34 +0000745 if (image->delay != 0)
cristyb51dff52011-05-19 16:55:47 +0000746 (void) FormatLocaleFile(file," Delay: %.20gx%.20g\n",(double) image->delay,
cristye8c25f92010-06-03 00:53:06 +0000747 (double) image->ticks_per_second);
cristy3ed852e2009-09-05 21:47:34 +0000748 if (image->iterations != 1)
cristy1e604812011-05-19 18:07:50 +0000749 (void) FormatLocaleFile(file," Iterations: %.20g\n",(double)
750 image->iterations);
cristy3ed852e2009-09-05 21:47:34 +0000751 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
cristy1e604812011-05-19 18:07:50 +0000752 (void) FormatLocaleFile(file," Scene: %.20g of %.20g\n",(double)
753 image->scene,(double) GetImageListLength(image));
cristy3ed852e2009-09-05 21:47:34 +0000754 else
755 if (image->scene != 0)
cristyb51dff52011-05-19 16:55:47 +0000756 (void) FormatLocaleFile(file," Scene: %.20g\n",(double) image->scene);
757 (void) FormatLocaleFile(file," Compression: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000758 MagickCompressOptions,(ssize_t) image->compression));
cristy3ed852e2009-09-05 21:47:34 +0000759 if (image->quality != UndefinedCompressionQuality)
cristyb51dff52011-05-19 16:55:47 +0000760 (void) FormatLocaleFile(file," Quality: %.20g\n",(double) image->quality);
761 (void) FormatLocaleFile(file," Orientation: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000762 MagickOrientationOptions,(ssize_t) image->orientation));
cristy3ed852e2009-09-05 21:47:34 +0000763 if (image->montage != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000764 (void) FormatLocaleFile(file," Montage: %s\n",image->montage);
cristy3ed852e2009-09-05 21:47:34 +0000765 if (image->directory != (char *) NULL)
766 {
767 Image
768 *tile;
769
770 ImageInfo
771 *image_info;
772
773 register char
774 *p,
775 *q;
776
777 WarningHandler
778 handler;
779
780 /*
781 Display visual image directory.
782 */
783 image_info=AcquireImageInfo();
784 (void) CloneString(&image_info->size,"64x64");
cristyb51dff52011-05-19 16:55:47 +0000785 (void) FormatLocaleFile(file," Directory:\n");
cristy3ed852e2009-09-05 21:47:34 +0000786 for (p=image->directory; *p != '\0'; p++)
787 {
788 q=p;
789 while ((*q != '\n') && (*q != '\0'))
790 q++;
791 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
792 p=q;
cristyb51dff52011-05-19 16:55:47 +0000793 (void) FormatLocaleFile(file," %s",image_info->filename);
cristy3ed852e2009-09-05 21:47:34 +0000794 handler=SetWarningHandler((WarningHandler) NULL);
cristya4037272011-08-28 15:11:39 +0000795 tile=ReadImage(image_info,exception);
cristy3ed852e2009-09-05 21:47:34 +0000796 (void) SetWarningHandler(handler);
797 if (tile == (Image *) NULL)
798 {
cristyb51dff52011-05-19 16:55:47 +0000799 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000800 continue;
801 }
cristy1e604812011-05-19 18:07:50 +0000802 (void) FormatLocaleFile(file," %.20gx%.20g %s\n",(double)
803 tile->magick_columns,(double) tile->magick_rows,tile->magick);
cristy018f07f2011-09-04 21:15:19 +0000804 (void) SignatureImage(tile,exception);
cristy3ed852e2009-09-05 21:47:34 +0000805 ResetImagePropertyIterator(tile);
806 property=GetNextImageProperty(tile);
807 while (property != (const char *) NULL)
808 {
cristyb51dff52011-05-19 16:55:47 +0000809 (void) FormatLocaleFile(file," %s:\n",property);
cristyd15e6592011-10-15 00:13:06 +0000810 value=GetImageProperty(tile,property,exception);
cristy3ed852e2009-09-05 21:47:34 +0000811 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000812 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +0000813 property=GetNextImageProperty(tile);
814 }
815 tile=DestroyImage(tile);
816 }
817 image_info=DestroyImageInfo(image_info);
818 }
cristyd15e6592011-10-15 00:13:06 +0000819 (void) GetImageProperty(image,"exif:*",exception);
cristy3ed852e2009-09-05 21:47:34 +0000820 ResetImagePropertyIterator(image);
821 property=GetNextImageProperty(image);
822 if (property != (const char *) NULL)
823 {
824 /*
825 Display image properties.
826 */
cristyb51dff52011-05-19 16:55:47 +0000827 (void) FormatLocaleFile(file," Properties:\n");
cristy3ed852e2009-09-05 21:47:34 +0000828 while (property != (const char *) NULL)
829 {
cristyb51dff52011-05-19 16:55:47 +0000830 (void) FormatLocaleFile(file," %s: ",property);
cristyd15e6592011-10-15 00:13:06 +0000831 value=GetImageProperty(image,property,exception);
cristy3ed852e2009-09-05 21:47:34 +0000832 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000833 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +0000834 property=GetNextImageProperty(image);
835 }
836 }
cristyb51dff52011-05-19 16:55:47 +0000837 (void) FormatLocaleString(key,MaxTextExtent,"8BIM:1999,2998:#1");
cristyd15e6592011-10-15 00:13:06 +0000838 value=GetImageProperty(image,key,exception);
cristy3ed852e2009-09-05 21:47:34 +0000839 if (value != (const char *) NULL)
840 {
841 /*
842 Display clipping path.
843 */
cristyb51dff52011-05-19 16:55:47 +0000844 (void) FormatLocaleFile(file," Clipping path: ");
cristy3ed852e2009-09-05 21:47:34 +0000845 if (strlen(value) > 80)
846 (void) fputc('\n',file);
cristyb51dff52011-05-19 16:55:47 +0000847 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +0000848 }
849 ResetImageProfileIterator(image);
850 name=GetNextImageProfile(image);
851 if (name != (char *) NULL)
852 {
853 const StringInfo
854 *profile;
855
856 /*
857 Identify image profiles.
858 */
cristyb51dff52011-05-19 16:55:47 +0000859 (void) FormatLocaleFile(file," Profiles:\n");
cristy3ed852e2009-09-05 21:47:34 +0000860 while (name != (char *) NULL)
861 {
862 profile=GetImageProfile(image,name);
863 if (profile == (StringInfo *) NULL)
864 continue;
cristy1e604812011-05-19 18:07:50 +0000865 (void) FormatLocaleFile(file," Profile-%s: %.20g bytes\n",name,
866 (double) GetStringInfoLength(profile));
cristy3ed852e2009-09-05 21:47:34 +0000867#if defined(MAGICKCORE_LCMS_DELEGATE)
868 if ((LocaleCompare(name,"icc") == 0) ||
869 (LocaleCompare(name,"icm") == 0))
870 {
871 cmsHPROFILE
872 icc_profile;
873
874 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
cristyd09bcf92010-03-25 03:04:45 +0000875 (cmsUInt32Number) GetStringInfoLength(profile));
cristy3ed852e2009-09-05 21:47:34 +0000876 if (icc_profile != (cmsHPROFILE *) NULL)
877 {
cristyd09bcf92010-03-25 03:04:45 +0000878#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
cristy3ed852e2009-09-05 21:47:34 +0000879 const char
880 *name;
881
882 name=cmsTakeProductName(icc_profile);
883 if (name != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000884 (void) FormatLocaleFile(file," %s\n",name);
cristyd09bcf92010-03-25 03:04:45 +0000885#else
886 char
887 info[MaxTextExtent];
888
889 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
890 "en","US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000891 (void) FormatLocaleFile(file," Description: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000892 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
893 "en","US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000894 (void) FormatLocaleFile(file," Manufacturer: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000895 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
896 "US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000897 (void) FormatLocaleFile(file," Model: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000898 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
899 "en","US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000900 (void) FormatLocaleFile(file," Copyright: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000901#endif
cristy3ed852e2009-09-05 21:47:34 +0000902 (void) cmsCloseProfile(icc_profile);
903 }
904 }
905#endif
906 if (LocaleCompare(name,"iptc") == 0)
907 {
908 char
909 *attribute,
910 **attribute_list;
911
912 const char
913 *tag;
914
cristycee97112010-05-28 00:44:52 +0000915 long
cristy3ed852e2009-09-05 21:47:34 +0000916 dataset,
917 record,
918 sentinel;
919
cristybb503372010-05-27 20:51:26 +0000920 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000921 j;
922
923 size_t
924 length,
925 profile_length;
926
927 profile_length=GetStringInfoLength(profile);
cristybb503372010-05-27 20:51:26 +0000928 for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +0000929 {
930 length=1;
931 sentinel=GetStringInfoDatum(profile)[i++];
932 if (sentinel != 0x1c)
933 continue;
934 dataset=GetStringInfoDatum(profile)[i++];
935 record=GetStringInfoDatum(profile)[i++];
936 switch (record)
937 {
938 case 5: tag="Image Name"; break;
939 case 7: tag="Edit Status"; break;
940 case 10: tag="Priority"; break;
941 case 15: tag="Category"; break;
942 case 20: tag="Supplemental Category"; break;
943 case 22: tag="Fixture Identifier"; break;
944 case 25: tag="Keyword"; break;
945 case 30: tag="Release Date"; break;
946 case 35: tag="Release Time"; break;
947 case 40: tag="Special Instructions"; break;
948 case 45: tag="Reference Service"; break;
949 case 47: tag="Reference Date"; break;
950 case 50: tag="Reference Number"; break;
951 case 55: tag="Created Date"; break;
952 case 60: tag="Created Time"; break;
953 case 65: tag="Originating Program"; break;
954 case 70: tag="Program Version"; break;
955 case 75: tag="Object Cycle"; break;
956 case 80: tag="Byline"; break;
957 case 85: tag="Byline Title"; break;
958 case 90: tag="City"; break;
959 case 95: tag="Province State"; break;
960 case 100: tag="Country Code"; break;
961 case 101: tag="Country"; break;
962 case 103: tag="Original Transmission Reference"; break;
963 case 105: tag="Headline"; break;
964 case 110: tag="Credit"; break;
965 case 115: tag="Src"; break;
966 case 116: tag="Copyright String"; break;
967 case 120: tag="Caption"; break;
968 case 121: tag="Local Caption"; break;
969 case 122: tag="Caption Writer"; break;
970 case 200: tag="Custom Field 1"; break;
971 case 201: tag="Custom Field 2"; break;
972 case 202: tag="Custom Field 3"; break;
973 case 203: tag="Custom Field 4"; break;
974 case 204: tag="Custom Field 5"; break;
975 case 205: tag="Custom Field 6"; break;
976 case 206: tag="Custom Field 7"; break;
977 case 207: tag="Custom Field 8"; break;
978 case 208: tag="Custom Field 9"; break;
979 case 209: tag="Custom Field 10"; break;
980 case 210: tag="Custom Field 11"; break;
981 case 211: tag="Custom Field 12"; break;
982 case 212: tag="Custom Field 13"; break;
983 case 213: tag="Custom Field 14"; break;
984 case 214: tag="Custom Field 15"; break;
985 case 215: tag="Custom Field 16"; break;
986 case 216: tag="Custom Field 17"; break;
987 case 217: tag="Custom Field 18"; break;
988 case 218: tag="Custom Field 19"; break;
989 case 219: tag="Custom Field 20"; break;
990 default: tag="unknown"; break;
991 }
cristy1e604812011-05-19 18:07:50 +0000992 (void) FormatLocaleFile(file," %s[%.20g,%.20g]: ",tag,
993 (double) dataset,(double) record);
cristy3ed852e2009-09-05 21:47:34 +0000994 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
995 length|=GetStringInfoDatum(profile)[i++];
996 attribute=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +0000997 if (~length >= (MaxTextExtent-1))
cristya4037272011-08-28 15:11:39 +0000998 attribute=(char *) AcquireQuantumMemory(length+MaxTextExtent,
999 sizeof(*attribute));
cristy3ed852e2009-09-05 21:47:34 +00001000 if (attribute != (char *) NULL)
1001 {
1002 (void) CopyMagickString(attribute,(char *)
1003 GetStringInfoDatum(profile)+i,length+1);
1004 attribute_list=StringToList(attribute);
1005 if (attribute_list != (char **) NULL)
1006 {
1007 for (j=0; attribute_list[j] != (char *) NULL; j++)
1008 {
1009 (void) fputs(attribute_list[j],file);
1010 (void) fputs("\n",file);
1011 attribute_list[j]=(char *) RelinquishMagickMemory(
1012 attribute_list[j]);
1013 }
1014 attribute_list=(char **) RelinquishMagickMemory(
1015 attribute_list);
1016 }
1017 attribute=DestroyString(attribute);
1018 }
1019 }
1020 }
1021 if (image->debug != MagickFalse)
1022 PrintStringInfo(file,name,profile);
1023 name=GetNextImageProfile(image);
1024 }
1025 }
1026 ResetImageArtifactIterator(image);
1027 artifact=GetNextImageArtifact(image);
1028 if (artifact != (const char *) NULL)
1029 {
1030 /*
1031 Display image artifacts.
1032 */
cristyb51dff52011-05-19 16:55:47 +00001033 (void) FormatLocaleFile(file," Artifacts:\n");
cristy3ed852e2009-09-05 21:47:34 +00001034 while (artifact != (const char *) NULL)
1035 {
cristyb51dff52011-05-19 16:55:47 +00001036 (void) FormatLocaleFile(file," %s: ",artifact);
cristy3ed852e2009-09-05 21:47:34 +00001037 value=GetImageArtifact(image,artifact);
1038 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +00001039 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +00001040 artifact=GetNextImageArtifact(image);
1041 }
1042 }
1043 ResetImageRegistryIterator();
1044 registry=GetNextImageRegistry();
1045 if (registry != (const char *) NULL)
1046 {
1047 /*
1048 Display image registry.
1049 */
cristyb51dff52011-05-19 16:55:47 +00001050 (void) FormatLocaleFile(file," Registry:\n");
cristy3ed852e2009-09-05 21:47:34 +00001051 while (registry != (const char *) NULL)
1052 {
cristyb51dff52011-05-19 16:55:47 +00001053 (void) FormatLocaleFile(file," %s: ",registry);
cristy3ed852e2009-09-05 21:47:34 +00001054 value=(const char *) GetImageRegistry(StringRegistryType,registry,
cristya4037272011-08-28 15:11:39 +00001055 exception);
cristy3ed852e2009-09-05 21:47:34 +00001056 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +00001057 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +00001058 registry=GetNextImageRegistry();
1059 }
1060 }
cristyb51dff52011-05-19 16:55:47 +00001061 (void) FormatLocaleFile(file," Tainted: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +00001062 MagickBooleanOptions,(ssize_t) image->taint));
cristyb9080c92009-12-01 20:13:26 +00001063 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +00001064 (void) FormatLocaleFile(file," Filesize: %sB\n",format);
cristyb9080c92009-12-01 20:13:26 +00001065 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1066 MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +00001067 (void) FormatLocaleFile(file," Number pixels: %s\n",format);
cristy3d231692009-09-29 01:05:22 +00001068 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
cristyb9080c92009-12-01 20:13:26 +00001069 elapsed_time+0.5),MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +00001070 (void) FormatLocaleFile(file," Pixels per second: %s\n",format);
1071 (void) FormatLocaleFile(file," User time: %0.3fu\n",user_time);
cristy1e604812011-05-19 18:07:50 +00001072 (void) FormatLocaleFile(file," Elapsed time: %lu:%02lu.%03lu\n",
cristya4037272011-08-28 15:11:39 +00001073 (unsigned long) (elapsed_time/60.0),(unsigned long) ceil(fmod(elapsed_time,
1074 60.0)),(unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
cristyb51dff52011-05-19 16:55:47 +00001075 (void) FormatLocaleFile(file," Version: %s\n",GetMagickVersion((size_t *)
cristy3d231692009-09-29 01:05:22 +00001076 NULL));
cristy3ed852e2009-09-05 21:47:34 +00001077 (void) fflush(file);
1078 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1079}