blob: b9fe6642dc91cec62a6b4272b3aa9b69f645c64a [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"
95#include "MagickCore/version.h"
cristy3ed852e2009-09-05 21:47:34 +000096#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,
cristya4037272011-08-28 15:11:39 +0000134% const MagickBooleanType verbose,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000135%
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%
cristya4037272011-08-28 15:11:39 +0000145% o exception: return any errors or warnings in this structure.
146%
cristy3ed852e2009-09-05 21:47:34 +0000147*/
148
cristy20ec7592011-05-29 01:28:05 +0000149static ssize_t PrintChannelFeatures(FILE *file,const ChannelType channel,
cristye1897792010-01-29 02:05:50 +0000150 const char *name,const ChannelFeatures *channel_features)
cristy3ed852e2009-09-05 21:47:34 +0000151{
cristye1897792010-01-29 02:05:50 +0000152#define PrintFeature(feature) \
153 GetMagickPrecision(),(feature)[0], \
154 GetMagickPrecision(),(feature)[1], \
155 GetMagickPrecision(),(feature)[2], \
cristye0acabf2010-01-30 00:52:38 +0000156 GetMagickPrecision(),(feature)[3], \
157 GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \
cristye1897792010-01-29 02:05:50 +0000158
cristybd822072010-01-27 00:30:00 +0000159#define FeaturesFormat " %s:\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000160 " Angular Second Moment:\n" \
cristye0acabf2010-01-30 00:52:38 +0000161 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000162 " Contrast:\n" \
cristye0acabf2010-01-30 00:52:38 +0000163 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycdf8e1b2010-01-28 01:52:33 +0000164 " Correlation:\n" \
cristye0acabf2010-01-30 00:52:38 +0000165 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000166 " Sum of Squares: Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000167 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristycf5e6492010-01-28 02:45:28 +0000168 " Inverse Difference Moment:\n" \
cristye0acabf2010-01-30 00:52:38 +0000169 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000170 " Sum Average:\n" \
cristye0acabf2010-01-30 00:52:38 +0000171 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000172 " Sum Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000173 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000174 " Sum Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000175 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000176 " Entropy:\n" \
cristye0acabf2010-01-30 00:52:38 +0000177 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye1897792010-01-29 02:05:50 +0000178 " Difference Variance:\n" \
cristye0acabf2010-01-30 00:52:38 +0000179 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000180 " Difference Entropy:\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 1:\n" \
cristye0acabf2010-01-30 00:52:38 +0000183 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000184 " Information Measure of Correlation 2:\n" \
cristye0acabf2010-01-30 00:52:38 +0000185 " %.*g, %.*g, %.*g, %.*g, %.*g\n" \
cristye0e19dc2010-01-29 02:13:08 +0000186 " Maximum Correlation Coefficient:\n" \
cristyc3ec0d42010-04-07 01:18:08 +0000187 " %.*g, %.*g, %.*g, %.*g, %.*g\n"
cristybd822072010-01-27 00:30:00 +0000188
cristy20ec7592011-05-29 01:28:05 +0000189 ssize_t
190 n;
cristybd822072010-01-27 00:30:00 +0000191
cristy20ec7592011-05-29 01:28:05 +0000192 n=FormatLocaleFile(file,FeaturesFormat,name,
cristye1897792010-01-29 02:05:50 +0000193 PrintFeature(channel_features[channel].angular_second_moment),
194 PrintFeature(channel_features[channel].contrast),
195 PrintFeature(channel_features[channel].correlation),
196 PrintFeature(channel_features[channel].variance_sum_of_squares),
197 PrintFeature(channel_features[channel].inverse_difference_moment),
198 PrintFeature(channel_features[channel].sum_average),
199 PrintFeature(channel_features[channel].sum_variance),
200 PrintFeature(channel_features[channel].sum_entropy),
201 PrintFeature(channel_features[channel].entropy),
cristye0e19dc2010-01-29 02:13:08 +0000202 PrintFeature(channel_features[channel].difference_variance),
203 PrintFeature(channel_features[channel].difference_entropy),
204 PrintFeature(channel_features[channel].measure_of_correlation_1),
205 PrintFeature(channel_features[channel].measure_of_correlation_2),
206 PrintFeature(channel_features[channel].maximum_correlation_coefficient));
cristy20ec7592011-05-29 01:28:05 +0000207 return(n);
cristybd822072010-01-27 00:30:00 +0000208}
209
cristy20ec7592011-05-29 01:28:05 +0000210static ssize_t PrintChannelStatistics(FILE *file,const ChannelType channel,
cristybd822072010-01-27 00:30:00 +0000211 const char *name,const double scale,
212 const ChannelStatistics *channel_statistics)
213{
214#define StatisticsFormat " %s:\n min: " QuantumFormat \
cristye7f51092010-01-17 00:39:37 +0000215 " (%g)\n max: " QuantumFormat " (%g)\n" \
216 " mean: %g (%g)\n standard deviation: %g (%g)\n" \
217 " kurtosis: %g\n skewness: %g\n"
cristy3ed852e2009-09-05 21:47:34 +0000218
cristy20ec7592011-05-29 01:28:05 +0000219 ssize_t
220 n;
cristybd822072010-01-27 00:30:00 +0000221
cristy20ec7592011-05-29 01:28:05 +0000222 n=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale*
cristya45da3b2010-03-31 02:06:45 +0000223 channel_statistics[channel].minima),channel_statistics[channel].minima/
224 (double) QuantumRange,ClampToQuantum(scale*
225 channel_statistics[channel].maxima),channel_statistics[channel].maxima/
226 (double) QuantumRange,scale*channel_statistics[channel].mean,
227 channel_statistics[channel].mean/(double) QuantumRange,scale*
228 channel_statistics[channel].standard_deviation,
cristy75b5a252010-02-26 02:40:46 +0000229 channel_statistics[channel].standard_deviation/(double) QuantumRange,
230 channel_statistics[channel].kurtosis,channel_statistics[channel].skewness);
cristy20ec7592011-05-29 01:28:05 +0000231 return(n);
cristybd822072010-01-27 00:30:00 +0000232}
233
234MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file,
cristya4037272011-08-28 15:11:39 +0000235 const MagickBooleanType verbose,ExceptionInfo *exception)
cristybd822072010-01-27 00:30:00 +0000236{
cristy3ed852e2009-09-05 21:47:34 +0000237 char
238 color[MaxTextExtent],
239 format[MaxTextExtent],
240 key[MaxTextExtent];
241
cristybd822072010-01-27 00:30:00 +0000242 ChannelFeatures
243 *channel_features;
244
245 ChannelStatistics
246 *channel_statistics;
247
cristy3ed852e2009-09-05 21:47:34 +0000248 ColorspaceType
249 colorspace;
250
251 const char
252 *artifact,
253 *name,
254 *property,
255 *registry,
256 *value;
257
258 const MagickInfo
259 *magick_info;
260
cristy3ed852e2009-09-05 21:47:34 +0000261 double
262 elapsed_time,
263 user_time;
264
cristy3ed852e2009-09-05 21:47:34 +0000265 ImageType
266 type;
267
cristy3ed852e2009-09-05 21:47:34 +0000268 MagickBooleanType
269 ping;
270
cristy4c08aed2011-07-01 19:47:50 +0000271 register const Quantum
272 *p;
273
cristybb503372010-05-27 20:51:26 +0000274 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000275 i,
276 x;
277
cristybb503372010-05-27 20:51:26 +0000278 size_t
cristybd822072010-01-27 00:30:00 +0000279 distance,
cristy3ed852e2009-09-05 21:47:34 +0000280 scale;
281
cristy9d314ff2011-03-09 01:30:28 +0000282 ssize_t
283 y;
284
cristy3ed852e2009-09-05 21:47:34 +0000285 assert(image != (Image *) NULL);
286 assert(image->signature == MagickSignature);
287 if (image->debug != MagickFalse)
288 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
289 if (file == (FILE *) NULL)
290 file=stdout;
291 *format='\0';
292 elapsed_time=GetElapsedTime(&image->timer);
293 user_time=GetUserTime(&image->timer);
294 GetTimerInfo(&image->timer);
295 if (verbose == MagickFalse)
296 {
297 /*
298 Display summary info about the image.
299 */
300 if (*image->magick_filename != '\0')
301 if (LocaleCompare(image->magick_filename,image->filename) != 0)
cristyb51dff52011-05-19 16:55:47 +0000302 (void) FormatLocaleFile(file,"%s=>",image->magick_filename);
cristy3ed852e2009-09-05 21:47:34 +0000303 if ((GetPreviousImageInList(image) == (Image *) NULL) &&
cristy81b8ce52010-02-05 01:53:17 +0000304 (GetNextImageInList(image) == (Image *) NULL) &&
305 (image->scene == 0))
cristyb51dff52011-05-19 16:55:47 +0000306 (void) FormatLocaleFile(file,"%s ",image->filename);
cristy3ed852e2009-09-05 21:47:34 +0000307 else
cristy1e604812011-05-19 18:07:50 +0000308 (void) FormatLocaleFile(file,"%s[%.20g] ",image->filename,(double)
309 image->scene);
cristyb51dff52011-05-19 16:55:47 +0000310 (void) FormatLocaleFile(file,"%s ",image->magick);
cristy3ed852e2009-09-05 21:47:34 +0000311 if ((image->magick_columns != 0) || (image->magick_rows != 0))
312 if ((image->magick_columns != image->columns) ||
313 (image->magick_rows != image->rows))
cristy1e604812011-05-19 18:07:50 +0000314 (void) FormatLocaleFile(file,"%.20gx%.20g=>",(double)
315 image->magick_columns,(double) image->magick_rows);
316 (void) FormatLocaleFile(file,"%.20gx%.20g ",(double) image->columns,
317 (double) image->rows);
cristy3ed852e2009-09-05 21:47:34 +0000318 if ((image->page.width != 0) || (image->page.height != 0) ||
319 (image->page.x != 0) || (image->page.y != 0))
cristyb51dff52011-05-19 16:55:47 +0000320 (void) FormatLocaleFile(file,"%.20gx%.20g%+.20g%+.20g ",(double)
cristye8c25f92010-06-03 00:53:06 +0000321 image->page.width,(double) image->page.height,(double) image->page.x,
322 (double) image->page.y);
cristyb51dff52011-05-19 16:55:47 +0000323 (void) FormatLocaleFile(file,"%.20g-bit ",(double) image->depth);
cristy5f1c1ff2010-12-23 21:38:06 +0000324 if (image->type != UndefinedType)
cristy1e604812011-05-19 18:07:50 +0000325 (void) FormatLocaleFile(file,"%s ",CommandOptionToMnemonic(
326 MagickTypeOptions,(ssize_t) image->type));
cristy3ed852e2009-09-05 21:47:34 +0000327 if (image->storage_class == DirectClass)
328 {
cristyb51dff52011-05-19 16:55:47 +0000329 (void) FormatLocaleFile(file,"DirectClass ");
cristy3ed852e2009-09-05 21:47:34 +0000330 if (image->total_colors != 0)
331 {
cristyb9080c92009-12-01 20:13:26 +0000332 (void) FormatMagickSize(image->total_colors,MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +0000333 (void) FormatLocaleFile(file,"%s ",format);
cristy3ed852e2009-09-05 21:47:34 +0000334 }
335 }
336 else
337 if (image->total_colors <= image->colors)
cristy1e604812011-05-19 18:07:50 +0000338 (void) FormatLocaleFile(file,"PseudoClass %.20gc ",(double)
339 image->colors);
cristyf2faecf2010-05-28 19:19:36 +0000340 else
cristyb51dff52011-05-19 16:55:47 +0000341 (void) FormatLocaleFile(file,"PseudoClass %.20g=>%.20gc ",(double)
cristye8c25f92010-06-03 00:53:06 +0000342 image->total_colors,(double) image->colors);
cristy3ed852e2009-09-05 21:47:34 +0000343 if (image->error.mean_error_per_pixel != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000344 (void) FormatLocaleFile(file,"%.20g/%f/%fdb ",(double)
cristy3ed852e2009-09-05 21:47:34 +0000345 (image->error.mean_error_per_pixel+0.5),
346 image->error.normalized_mean_error,
347 image->error.normalized_maximum_error);
348 if (GetBlobSize(image) != 0)
349 {
cristyb9080c92009-12-01 20:13:26 +0000350 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +0000351 (void) FormatLocaleFile(file,"%s ",format);
cristy3ed852e2009-09-05 21:47:34 +0000352 }
cristy1e604812011-05-19 18:07:50 +0000353 (void) FormatLocaleFile(file,"%0.3fu %lu:%02lu.%03lu",user_time,
354 (unsigned long) (elapsed_time/60.0),(unsigned long) floor(fmod(
355 elapsed_time,60.0)),(unsigned long) (1000.0*(elapsed_time-
356 floor(elapsed_time))));
cristyb51dff52011-05-19 16:55:47 +0000357 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000358 (void) fflush(file);
359 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
360 }
361 /*
362 Display verbose info about the image.
363 */
cristy4c08aed2011-07-01 19:47:50 +0000364 p=GetVirtualPixels(image,0,0,1,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000365 ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse;
cristya4037272011-08-28 15:11:39 +0000366 type=GetImageType(image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000367 (void) SignatureImage(image);
cristyb51dff52011-05-19 16:55:47 +0000368 (void) FormatLocaleFile(file,"Image: %s\n",image->filename);
cristy3ed852e2009-09-05 21:47:34 +0000369 if (*image->magick_filename != '\0')
370 if (LocaleCompare(image->magick_filename,image->filename) != 0)
371 {
372 char
373 filename[MaxTextExtent];
374
375 GetPathComponent(image->magick_filename,TailPath,filename);
cristyb51dff52011-05-19 16:55:47 +0000376 (void) FormatLocaleFile(file," Base filename: %s\n",filename);
cristy3ed852e2009-09-05 21:47:34 +0000377 }
cristya4037272011-08-28 15:11:39 +0000378 magick_info=GetMagickInfo(image->magick,exception);
cristy3ed852e2009-09-05 21:47:34 +0000379 if ((magick_info == (const MagickInfo *) NULL) ||
380 (*GetMagickDescription(magick_info) == '\0'))
cristyb51dff52011-05-19 16:55:47 +0000381 (void) FormatLocaleFile(file," Format: %s\n",image->magick);
cristy3ed852e2009-09-05 21:47:34 +0000382 else
cristyb51dff52011-05-19 16:55:47 +0000383 (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick,
cristy3ed852e2009-09-05 21:47:34 +0000384 GetMagickDescription(magick_info));
cristy1e604812011-05-19 18:07:50 +0000385 (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic(
386 MagickClassOptions,(ssize_t) image->storage_class));
cristyb51dff52011-05-19 16:55:47 +0000387 (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000388 image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
389 image->tile_offset.y);
cristy3ed852e2009-09-05 21:47:34 +0000390 if ((image->magick_columns != 0) || (image->magick_rows != 0))
391 if ((image->magick_columns != image->columns) ||
392 (image->magick_rows != image->rows))
cristyb51dff52011-05-19 16:55:47 +0000393 (void) FormatLocaleFile(file," Base geometry: %.20gx%.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000394 image->magick_columns,(double) image->magick_rows);
cristy3ed852e2009-09-05 21:47:34 +0000395 if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
396 {
cristyb51dff52011-05-19 16:55:47 +0000397 (void) FormatLocaleFile(file," Resolution: %gx%g\n",image->x_resolution,
cristy3ed852e2009-09-05 21:47:34 +0000398 image->y_resolution);
cristy1e604812011-05-19 18:07:50 +0000399 (void) FormatLocaleFile(file," Print size: %gx%g\n",(double)
400 image->columns/image->x_resolution,(double) image->rows/
401 image->y_resolution);
cristy3ed852e2009-09-05 21:47:34 +0000402 }
cristyb51dff52011-05-19 16:55:47 +0000403 (void) FormatLocaleFile(file," Units: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000404 MagickResolutionOptions,(ssize_t) image->units));
cristy1e604812011-05-19 18:07:50 +0000405 (void) FormatLocaleFile(file," Type: %s\n",CommandOptionToMnemonic(
406 MagickTypeOptions,(ssize_t) type));
cristy5f1c1ff2010-12-23 21:38:06 +0000407 if (image->type != UndefinedType)
cristyb51dff52011-05-19 16:55:47 +0000408 (void) FormatLocaleFile(file," Base type: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000409 MagickTypeOptions,(ssize_t) image->type));
cristyb51dff52011-05-19 16:55:47 +0000410 (void) FormatLocaleFile(file," Endianess: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000411 MagickEndianOptions,(ssize_t) image->endian));
cristy3ed852e2009-09-05 21:47:34 +0000412 /*
413 Detail channel depth and extrema.
414 */
cristyb51dff52011-05-19 16:55:47 +0000415 (void) FormatLocaleFile(file," Colorspace: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000416 MagickColorspaceOptions,(ssize_t) image->colorspace));
cristybd822072010-01-27 00:30:00 +0000417 channel_statistics=(ChannelStatistics *) NULL;
cristy15a88782010-01-31 23:24:49 +0000418 channel_features=(ChannelFeatures *) NULL;
419 colorspace=image->colorspace;
cristy3ed852e2009-09-05 21:47:34 +0000420 if (ping == MagickFalse)
421 {
cristybb503372010-05-27 20:51:26 +0000422 size_t
cristy3ed852e2009-09-05 21:47:34 +0000423 depth;
424
cristya4037272011-08-28 15:11:39 +0000425 channel_statistics=GetImageStatistics(image,exception);
cristy15a88782010-01-31 23:24:49 +0000426 artifact=GetImageArtifact(image,"identify:features");
427 if (artifact != (const char *) NULL)
428 {
429 distance=StringToUnsignedLong(artifact);
cristya4037272011-08-28 15:11:39 +0000430 channel_features=GetImageFeatures(image,distance,exception);
cristy15a88782010-01-31 23:24:49 +0000431 }
cristya4037272011-08-28 15:11:39 +0000432 depth=GetImageDepth(image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000433 if (image->depth == depth)
cristy1e604812011-05-19 18:07:50 +0000434 (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double)
435 image->depth);
cristy3ed852e2009-09-05 21:47:34 +0000436 else
cristyb51dff52011-05-19 16:55:47 +0000437 (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000438 image->depth,(double) depth);
cristyb51dff52011-05-19 16:55:47 +0000439 (void) FormatLocaleFile(file," Channel depth:\n");
cristya4037272011-08-28 15:11:39 +0000440 if (IsImageGray(image,exception) != MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000441 colorspace=GRAYColorspace;
442 switch (colorspace)
443 {
444 case RGBColorspace:
445 default:
446 {
cristyb51dff52011-05-19 16:55:47 +0000447 (void) FormatLocaleFile(file," red: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000448 channel_statistics[RedChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000449 (void) FormatLocaleFile(file," green: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000450 channel_statistics[GreenChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000451 (void) FormatLocaleFile(file," blue: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000452 channel_statistics[BlueChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000453 break;
454 }
455 case CMYKColorspace:
456 {
cristyb51dff52011-05-19 16:55:47 +0000457 (void) FormatLocaleFile(file," cyan: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000458 channel_statistics[CyanChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000459 (void) FormatLocaleFile(file," magenta: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000460 channel_statistics[MagentaChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000461 (void) FormatLocaleFile(file," yellow: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000462 channel_statistics[YellowChannel].depth);
cristyb51dff52011-05-19 16:55:47 +0000463 (void) FormatLocaleFile(file," black: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000464 channel_statistics[BlackChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000465 break;
466 }
467 case GRAYColorspace:
468 {
cristyb51dff52011-05-19 16:55:47 +0000469 (void) FormatLocaleFile(file," gray: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000470 channel_statistics[GrayChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000471 break;
472 }
473 }
cristye8c25f92010-06-03 00:53:06 +0000474 if (image->matte != MagickFalse)
cristyb51dff52011-05-19 16:55:47 +0000475 (void) FormatLocaleFile(file," alpha: %.20g-bit\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000476 channel_statistics[OpacityChannel].depth);
cristy3ed852e2009-09-05 21:47:34 +0000477 scale=1;
478 if (image->depth <= MAGICKCORE_QUANTUM_DEPTH)
cristybb503372010-05-27 20:51:26 +0000479 scale=QuantumRange/((size_t) QuantumRange >> ((size_t)
cristy3ed852e2009-09-05 21:47:34 +0000480 MAGICKCORE_QUANTUM_DEPTH-image->depth));
cristy15a88782010-01-31 23:24:49 +0000481 }
482 if (channel_statistics != (ChannelStatistics *) NULL)
483 {
cristyb51dff52011-05-19 16:55:47 +0000484 (void) FormatLocaleFile(file," Channel statistics:\n");
cristy3ed852e2009-09-05 21:47:34 +0000485 switch (colorspace)
486 {
487 case RGBColorspace:
488 default:
489 {
cristybd822072010-01-27 00:30:00 +0000490 (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale,
491 channel_statistics);
492 (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale,
493 channel_statistics);
494 (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale,
495 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000496 break;
497 }
498 case CMYKColorspace:
499 {
cristybd822072010-01-27 00:30:00 +0000500 (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale,
501 channel_statistics);
502 (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale,
503 channel_statistics);
504 (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale,
505 channel_statistics);
506 (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale,
507 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000508 break;
509 }
510 case GRAYColorspace:
511 {
cristybd822072010-01-27 00:30:00 +0000512 (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale,
513 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000514 break;
515 }
516 }
517 if (image->matte != MagickFalse)
cristybd822072010-01-27 00:30:00 +0000518 (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale,
519 channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000520 if (colorspace != GRAYColorspace)
521 {
cristyb51dff52011-05-19 16:55:47 +0000522 (void) FormatLocaleFile(file," Image statistics:\n");
cristy1e604812011-05-19 18:07:50 +0000523 (void) PrintChannelStatistics(file,CompositeChannels,"Overall",1.0/
524 scale,channel_statistics);
cristy3ed852e2009-09-05 21:47:34 +0000525 }
526 channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
527 channel_statistics);
cristybd822072010-01-27 00:30:00 +0000528 }
cristybd822072010-01-27 00:30:00 +0000529 if (channel_features != (ChannelFeatures *) NULL)
530 {
cristy1e604812011-05-19 18:07:50 +0000531 (void) FormatLocaleFile(file," Channel features (horizontal, vertical, "
532 "left and right diagonals, average):\n");
cristybd822072010-01-27 00:30:00 +0000533 switch (colorspace)
534 {
535 case RGBColorspace:
536 default:
cristy549a37e2010-01-26 15:24:15 +0000537 {
cristye1897792010-01-29 02:05:50 +0000538 (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features);
539 (void) PrintChannelFeatures(file,GreenChannel,"Green",
cristybd822072010-01-27 00:30:00 +0000540 channel_features);
cristye1897792010-01-29 02:05:50 +0000541 (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features);
cristybd822072010-01-27 00:30:00 +0000542 break;
543 }
544 case CMYKColorspace:
545 {
cristye1897792010-01-29 02:05:50 +0000546 (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features);
547 (void) PrintChannelFeatures(file,MagentaChannel,"Magenta",
cristybd822072010-01-27 00:30:00 +0000548 channel_features);
cristye1897792010-01-29 02:05:50 +0000549 (void) PrintChannelFeatures(file,YellowChannel,"Yellow",
cristybd822072010-01-27 00:30:00 +0000550 channel_features);
cristye1897792010-01-29 02:05:50 +0000551 (void) PrintChannelFeatures(file,BlackChannel,"Black",
cristybd822072010-01-27 00:30:00 +0000552 channel_features);
553 break;
554 }
555 case GRAYColorspace:
556 {
cristye1897792010-01-29 02:05:50 +0000557 (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features);
cristybd822072010-01-27 00:30:00 +0000558 break;
559 }
560 }
561 if (image->matte != MagickFalse)
cristye1897792010-01-29 02:05:50 +0000562 (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features);
cristybd822072010-01-27 00:30:00 +0000563 channel_features=(ChannelFeatures *) RelinquishMagickMemory(
564 channel_features);
565 }
566 if (ping == MagickFalse)
567 {
cristy3ed852e2009-09-05 21:47:34 +0000568 if (image->colorspace == CMYKColorspace)
cristyb51dff52011-05-19 16:55:47 +0000569 (void) FormatLocaleFile(file," Total ink density: %.0f%%\n",100.0*
cristy3ed852e2009-09-05 21:47:34 +0000570 GetImageTotalInkDensity(image)/(double) QuantumRange);
571 x=0;
572 if (image->matte != MagickFalse)
573 {
cristy4c08aed2011-07-01 19:47:50 +0000574 register const Quantum
cristy3ed852e2009-09-05 21:47:34 +0000575 *p;
576
cristy4c08aed2011-07-01 19:47:50 +0000577 p=(const Quantum *) NULL;
cristybb503372010-05-27 20:51:26 +0000578 for (y=0; y < (ssize_t) image->rows; y++)
cristy3ed852e2009-09-05 21:47:34 +0000579 {
580 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
cristy4c08aed2011-07-01 19:47:50 +0000581 if (p == (const Quantum *) NULL)
cristy3ed852e2009-09-05 21:47:34 +0000582 break;
cristybb503372010-05-27 20:51:26 +0000583 for (x=0; x < (ssize_t) image->columns; x++)
cristy3ed852e2009-09-05 21:47:34 +0000584 {
cristy4c08aed2011-07-01 19:47:50 +0000585 if (GetPixelAlpha(image,p) == (Quantum) TransparentAlpha)
cristy3ed852e2009-09-05 21:47:34 +0000586 break;
cristyed231572011-07-14 02:18:59 +0000587 p+=GetPixelChannels(image);
cristy3ed852e2009-09-05 21:47:34 +0000588 }
cristybb503372010-05-27 20:51:26 +0000589 if (x < (ssize_t) image->columns)
cristy3ed852e2009-09-05 21:47:34 +0000590 break;
591 }
cristybb503372010-05-27 20:51:26 +0000592 if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows))
cristy3ed852e2009-09-05 21:47:34 +0000593 {
594 char
595 tuple[MaxTextExtent];
596
cristy4c08aed2011-07-01 19:47:50 +0000597 PixelInfo
cristy3ed852e2009-09-05 21:47:34 +0000598 pixel;
599
cristy4c08aed2011-07-01 19:47:50 +0000600 GetPixelInfo(image,&pixel);
601 SetPixelInfo(image,p,&pixel);
cristy3ed852e2009-09-05 21:47:34 +0000602 (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple,
cristya4037272011-08-28 15:11:39 +0000603 exception);
cristyb51dff52011-05-19 16:55:47 +0000604 (void) FormatLocaleFile(file," Alpha: %s ",tuple);
cristy3ed852e2009-09-05 21:47:34 +0000605 GetColorTuple(&pixel,MagickTrue,tuple);
cristyb51dff52011-05-19 16:55:47 +0000606 (void) FormatLocaleFile(file," %s\n",tuple);
cristy3ed852e2009-09-05 21:47:34 +0000607 }
608 }
cristy83fae872010-04-22 15:04:16 +0000609 artifact=GetImageArtifact(image,"identify:unique-colors");
cristya4037272011-08-28 15:11:39 +0000610 if (IsHistogramImage(image,exception) != MagickFalse)
cristy3ed852e2009-09-05 21:47:34 +0000611 {
cristy4c967562011-06-16 01:46:57 +0000612 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
cristya4037272011-08-28 15:11:39 +0000613 GetNumberColors(image,(FILE *) NULL,exception));
cristyb51dff52011-05-19 16:55:47 +0000614 (void) FormatLocaleFile(file," Histogram:\n");
cristya4037272011-08-28 15:11:39 +0000615 (void) GetNumberColors(image,file,exception);
cristy3ed852e2009-09-05 21:47:34 +0000616 }
cristy4c967562011-06-16 01:46:57 +0000617 else
618 if ((artifact != (const char *) NULL) &&
619 (IsMagickTrue(artifact) != MagickFalse))
620 (void) FormatLocaleFile(file," Colors: %.20g\n",(double)
cristya4037272011-08-28 15:11:39 +0000621 GetNumberColors(image,(FILE *) NULL,exception));
cristy3ed852e2009-09-05 21:47:34 +0000622 }
623 if (image->storage_class == PseudoClass)
624 {
cristya4037272011-08-28 15:11:39 +0000625 (void) FormatLocaleFile(file," Colormap: %.20g\n",(double)
626 image->colors);
cristy3ed852e2009-09-05 21:47:34 +0000627 if (image->colors <= 1024)
628 {
629 char
630 color[MaxTextExtent],
631 hex[MaxTextExtent],
632 tuple[MaxTextExtent];
633
cristy4c08aed2011-07-01 19:47:50 +0000634 PixelInfo
cristy3ed852e2009-09-05 21:47:34 +0000635 pixel;
636
637 register PixelPacket
cristyc47d1f82009-11-26 01:44:43 +0000638 *restrict p;
cristy3ed852e2009-09-05 21:47:34 +0000639
cristy4c08aed2011-07-01 19:47:50 +0000640 GetPixelInfo(image,&pixel);
cristy3ed852e2009-09-05 21:47:34 +0000641 p=image->colormap;
cristybb503372010-05-27 20:51:26 +0000642 for (i=0; i < (ssize_t) image->colors; i++)
cristy3ed852e2009-09-05 21:47:34 +0000643 {
cristy4c08aed2011-07-01 19:47:50 +0000644 SetPixelInfoPacket(image,p,&pixel);
cristy3ed852e2009-09-05 21:47:34 +0000645 (void) CopyMagickString(tuple,"(",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000646 ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance,
cristyfa806a72011-07-04 02:06:13 +0000647 tuple);
cristy3ed852e2009-09-05 21:47:34 +0000648 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000649 ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance,
cristyfa806a72011-07-04 02:06:13 +0000650 tuple);
cristy3ed852e2009-09-05 21:47:34 +0000651 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000652 ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance,
cristyfa806a72011-07-04 02:06:13 +0000653 tuple);
cristy3ed852e2009-09-05 21:47:34 +0000654 if (pixel.colorspace == CMYKColorspace)
655 {
656 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000657 ConcatenateColorComponent(&pixel,BlackPixelChannel,
cristyfa806a72011-07-04 02:06:13 +0000658 X11Compliance,tuple);
cristy3ed852e2009-09-05 21:47:34 +0000659 }
660 if (pixel.matte != MagickFalse)
661 {
662 (void) ConcatenateMagickString(tuple,",",MaxTextExtent);
cristyed231572011-07-14 02:18:59 +0000663 ConcatenateColorComponent(&pixel,AlphaPixelChannel,
cristyfa806a72011-07-04 02:06:13 +0000664 X11Compliance,tuple);
cristy3ed852e2009-09-05 21:47:34 +0000665 }
666 (void) ConcatenateMagickString(tuple,")",MaxTextExtent);
667 (void) QueryMagickColorname(image,&pixel,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000668 exception);
cristy3ed852e2009-09-05 21:47:34 +0000669 GetColorTuple(&pixel,MagickTrue,hex);
cristy1e604812011-05-19 18:07:50 +0000670 (void) FormatLocaleFile(file," %8ld: %s %s %s\n",(long) i,tuple,
671 hex,color);
cristy3ed852e2009-09-05 21:47:34 +0000672 p++;
673 }
674 }
675 }
676 if (image->error.mean_error_per_pixel != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000677 (void) FormatLocaleFile(file," Mean error per pixel: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000678 image->error.mean_error_per_pixel);
679 if (image->error.normalized_mean_error != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000680 (void) FormatLocaleFile(file," Normalized mean error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000681 image->error.normalized_mean_error);
682 if (image->error.normalized_maximum_error != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000683 (void) FormatLocaleFile(file," Normalized maximum error: %g\n",
cristy3ed852e2009-09-05 21:47:34 +0000684 image->error.normalized_maximum_error);
cristy1e604812011-05-19 18:07:50 +0000685 (void) FormatLocaleFile(file," Rendering intent: %s\n",
686 CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
687 image->rendering_intent));
cristy3ed852e2009-09-05 21:47:34 +0000688 if (image->gamma != 0.0)
cristyb51dff52011-05-19 16:55:47 +0000689 (void) FormatLocaleFile(file," Gamma: %g\n",image->gamma);
cristy3ed852e2009-09-05 21:47:34 +0000690 if ((image->chromaticity.red_primary.x != 0.0) ||
691 (image->chromaticity.green_primary.x != 0.0) ||
692 (image->chromaticity.blue_primary.x != 0.0) ||
693 (image->chromaticity.white_point.x != 0.0))
694 {
695 /*
696 Display image chromaticity.
697 */
cristyb51dff52011-05-19 16:55:47 +0000698 (void) FormatLocaleFile(file," Chromaticity:\n");
699 (void) FormatLocaleFile(file," red primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000700 image->chromaticity.red_primary.x,image->chromaticity.red_primary.y);
cristyb51dff52011-05-19 16:55:47 +0000701 (void) FormatLocaleFile(file," green primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000702 image->chromaticity.green_primary.x,
703 image->chromaticity.green_primary.y);
cristyb51dff52011-05-19 16:55:47 +0000704 (void) FormatLocaleFile(file," blue primary: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000705 image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y);
cristyb51dff52011-05-19 16:55:47 +0000706 (void) FormatLocaleFile(file," white point: (%g,%g)\n",
cristy3ed852e2009-09-05 21:47:34 +0000707 image->chromaticity.white_point.x,image->chromaticity.white_point.y);
708 }
709 if ((image->extract_info.width*image->extract_info.height) != 0)
cristy1e604812011-05-19 18:07:50 +0000710 (void) FormatLocaleFile(file," Tile geometry: %.20gx%.20g%+.20g%+.20g\n",
711 (double) image->extract_info.width,(double) image->extract_info.height,
712 (double) image->extract_info.x,(double) image->extract_info.y);
cristyb51dff52011-05-19 16:55:47 +0000713 (void) FormatLocaleFile(file," Interlace: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000714 MagickInterlaceOptions,(ssize_t) image->interlace));
cristy3ed852e2009-09-05 21:47:34 +0000715 (void) QueryColorname(image,&image->background_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000716 exception);
cristyb51dff52011-05-19 16:55:47 +0000717 (void) FormatLocaleFile(file," Background color: %s\n",color);
cristy3ed852e2009-09-05 21:47:34 +0000718 (void) QueryColorname(image,&image->border_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000719 exception);
cristyb51dff52011-05-19 16:55:47 +0000720 (void) FormatLocaleFile(file," Border color: %s\n",color);
cristy3ed852e2009-09-05 21:47:34 +0000721 (void) QueryColorname(image,&image->matte_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000722 exception);
cristyb51dff52011-05-19 16:55:47 +0000723 (void) FormatLocaleFile(file," Matte color: %s\n",color);
cristy3ed852e2009-09-05 21:47:34 +0000724 (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color,
cristya4037272011-08-28 15:11:39 +0000725 exception);
cristyb51dff52011-05-19 16:55:47 +0000726 (void) FormatLocaleFile(file," Transparent color: %s\n",color);
727 (void) FormatLocaleFile(file," Compose: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000728 MagickComposeOptions,(ssize_t) image->compose));
cristy3ed852e2009-09-05 21:47:34 +0000729 if ((image->page.width != 0) || (image->page.height != 0) ||
730 (image->page.x != 0) || (image->page.y != 0))
cristy1e604812011-05-19 18:07:50 +0000731 (void) FormatLocaleFile(file," Page geometry: %.20gx%.20g%+.20g%+.20g\n",
732 (double) image->page.width,(double) image->page.height,(double)
cristye8c25f92010-06-03 00:53:06 +0000733 image->page.x,(double) image->page.y);
cristy3ed852e2009-09-05 21:47:34 +0000734 if ((image->page.x != 0) || (image->page.y != 0))
cristyb51dff52011-05-19 16:55:47 +0000735 (void) FormatLocaleFile(file," Origin geometry: %+.20g%+.20g\n",(double)
cristye8c25f92010-06-03 00:53:06 +0000736 image->page.x,(double) image->page.y);
cristyb51dff52011-05-19 16:55:47 +0000737 (void) FormatLocaleFile(file," Dispose: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000738 MagickDisposeOptions,(ssize_t) image->dispose));
cristy3ed852e2009-09-05 21:47:34 +0000739 if (image->delay != 0)
cristyb51dff52011-05-19 16:55:47 +0000740 (void) FormatLocaleFile(file," Delay: %.20gx%.20g\n",(double) image->delay,
cristye8c25f92010-06-03 00:53:06 +0000741 (double) image->ticks_per_second);
cristy3ed852e2009-09-05 21:47:34 +0000742 if (image->iterations != 1)
cristy1e604812011-05-19 18:07:50 +0000743 (void) FormatLocaleFile(file," Iterations: %.20g\n",(double)
744 image->iterations);
cristy3ed852e2009-09-05 21:47:34 +0000745 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL))
cristy1e604812011-05-19 18:07:50 +0000746 (void) FormatLocaleFile(file," Scene: %.20g of %.20g\n",(double)
747 image->scene,(double) GetImageListLength(image));
cristy3ed852e2009-09-05 21:47:34 +0000748 else
749 if (image->scene != 0)
cristyb51dff52011-05-19 16:55:47 +0000750 (void) FormatLocaleFile(file," Scene: %.20g\n",(double) image->scene);
751 (void) FormatLocaleFile(file," Compression: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000752 MagickCompressOptions,(ssize_t) image->compression));
cristy3ed852e2009-09-05 21:47:34 +0000753 if (image->quality != UndefinedCompressionQuality)
cristyb51dff52011-05-19 16:55:47 +0000754 (void) FormatLocaleFile(file," Quality: %.20g\n",(double) image->quality);
755 (void) FormatLocaleFile(file," Orientation: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +0000756 MagickOrientationOptions,(ssize_t) image->orientation));
cristy3ed852e2009-09-05 21:47:34 +0000757 if (image->montage != (char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000758 (void) FormatLocaleFile(file," Montage: %s\n",image->montage);
cristy3ed852e2009-09-05 21:47:34 +0000759 if (image->directory != (char *) NULL)
760 {
761 Image
762 *tile;
763
764 ImageInfo
765 *image_info;
766
767 register char
768 *p,
769 *q;
770
771 WarningHandler
772 handler;
773
774 /*
775 Display visual image directory.
776 */
777 image_info=AcquireImageInfo();
778 (void) CloneString(&image_info->size,"64x64");
cristyb51dff52011-05-19 16:55:47 +0000779 (void) FormatLocaleFile(file," Directory:\n");
cristy3ed852e2009-09-05 21:47:34 +0000780 for (p=image->directory; *p != '\0'; p++)
781 {
782 q=p;
783 while ((*q != '\n') && (*q != '\0'))
784 q++;
785 (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1));
786 p=q;
cristyb51dff52011-05-19 16:55:47 +0000787 (void) FormatLocaleFile(file," %s",image_info->filename);
cristy3ed852e2009-09-05 21:47:34 +0000788 handler=SetWarningHandler((WarningHandler) NULL);
cristya4037272011-08-28 15:11:39 +0000789 tile=ReadImage(image_info,exception);
cristy3ed852e2009-09-05 21:47:34 +0000790 (void) SetWarningHandler(handler);
791 if (tile == (Image *) NULL)
792 {
cristyb51dff52011-05-19 16:55:47 +0000793 (void) FormatLocaleFile(file,"\n");
cristy3ed852e2009-09-05 21:47:34 +0000794 continue;
795 }
cristy1e604812011-05-19 18:07:50 +0000796 (void) FormatLocaleFile(file," %.20gx%.20g %s\n",(double)
797 tile->magick_columns,(double) tile->magick_rows,tile->magick);
cristy3ed852e2009-09-05 21:47:34 +0000798 (void) SignatureImage(tile);
799 ResetImagePropertyIterator(tile);
800 property=GetNextImageProperty(tile);
801 while (property != (const char *) NULL)
802 {
cristyb51dff52011-05-19 16:55:47 +0000803 (void) FormatLocaleFile(file," %s:\n",property);
cristy3ed852e2009-09-05 21:47:34 +0000804 value=GetImageProperty(tile,property);
805 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000806 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +0000807 property=GetNextImageProperty(tile);
808 }
809 tile=DestroyImage(tile);
810 }
811 image_info=DestroyImageInfo(image_info);
812 }
813 (void) GetImageProperty(image,"exif:*");
814 ResetImagePropertyIterator(image);
815 property=GetNextImageProperty(image);
816 if (property != (const char *) NULL)
817 {
818 /*
819 Display image properties.
820 */
cristyb51dff52011-05-19 16:55:47 +0000821 (void) FormatLocaleFile(file," Properties:\n");
cristy3ed852e2009-09-05 21:47:34 +0000822 while (property != (const char *) NULL)
823 {
cristyb51dff52011-05-19 16:55:47 +0000824 (void) FormatLocaleFile(file," %s: ",property);
cristy3ed852e2009-09-05 21:47:34 +0000825 value=GetImageProperty(image,property);
826 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000827 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +0000828 property=GetNextImageProperty(image);
829 }
830 }
cristyb51dff52011-05-19 16:55:47 +0000831 (void) FormatLocaleString(key,MaxTextExtent,"8BIM:1999,2998:#1");
cristy3ed852e2009-09-05 21:47:34 +0000832 value=GetImageProperty(image,key);
833 if (value != (const char *) NULL)
834 {
835 /*
836 Display clipping path.
837 */
cristyb51dff52011-05-19 16:55:47 +0000838 (void) FormatLocaleFile(file," Clipping path: ");
cristy3ed852e2009-09-05 21:47:34 +0000839 if (strlen(value) > 80)
840 (void) fputc('\n',file);
cristyb51dff52011-05-19 16:55:47 +0000841 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +0000842 }
843 ResetImageProfileIterator(image);
844 name=GetNextImageProfile(image);
845 if (name != (char *) NULL)
846 {
847 const StringInfo
848 *profile;
849
850 /*
851 Identify image profiles.
852 */
cristyb51dff52011-05-19 16:55:47 +0000853 (void) FormatLocaleFile(file," Profiles:\n");
cristy3ed852e2009-09-05 21:47:34 +0000854 while (name != (char *) NULL)
855 {
856 profile=GetImageProfile(image,name);
857 if (profile == (StringInfo *) NULL)
858 continue;
cristy1e604812011-05-19 18:07:50 +0000859 (void) FormatLocaleFile(file," Profile-%s: %.20g bytes\n",name,
860 (double) GetStringInfoLength(profile));
cristy3ed852e2009-09-05 21:47:34 +0000861#if defined(MAGICKCORE_LCMS_DELEGATE)
862 if ((LocaleCompare(name,"icc") == 0) ||
863 (LocaleCompare(name,"icm") == 0))
864 {
865 cmsHPROFILE
866 icc_profile;
867
868 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
cristyd09bcf92010-03-25 03:04:45 +0000869 (cmsUInt32Number) GetStringInfoLength(profile));
cristy3ed852e2009-09-05 21:47:34 +0000870 if (icc_profile != (cmsHPROFILE *) NULL)
871 {
cristyd09bcf92010-03-25 03:04:45 +0000872#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
cristy3ed852e2009-09-05 21:47:34 +0000873 const char
874 *name;
875
876 name=cmsTakeProductName(icc_profile);
877 if (name != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +0000878 (void) FormatLocaleFile(file," %s\n",name);
cristyd09bcf92010-03-25 03:04:45 +0000879#else
880 char
881 info[MaxTextExtent];
882
883 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
884 "en","US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000885 (void) FormatLocaleFile(file," Description: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000886 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
887 "en","US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000888 (void) FormatLocaleFile(file," Manufacturer: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000889 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
890 "US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000891 (void) FormatLocaleFile(file," Model: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000892 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
893 "en","US",info,MaxTextExtent);
cristyb51dff52011-05-19 16:55:47 +0000894 (void) FormatLocaleFile(file," Copyright: %s\n",info);
cristyd09bcf92010-03-25 03:04:45 +0000895#endif
cristy3ed852e2009-09-05 21:47:34 +0000896 (void) cmsCloseProfile(icc_profile);
897 }
898 }
899#endif
900 if (LocaleCompare(name,"iptc") == 0)
901 {
902 char
903 *attribute,
904 **attribute_list;
905
906 const char
907 *tag;
908
cristycee97112010-05-28 00:44:52 +0000909 long
cristy3ed852e2009-09-05 21:47:34 +0000910 dataset,
911 record,
912 sentinel;
913
cristybb503372010-05-27 20:51:26 +0000914 register ssize_t
cristy3ed852e2009-09-05 21:47:34 +0000915 j;
916
917 size_t
918 length,
919 profile_length;
920
921 profile_length=GetStringInfoLength(profile);
cristybb503372010-05-27 20:51:26 +0000922 for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length)
cristy3ed852e2009-09-05 21:47:34 +0000923 {
924 length=1;
925 sentinel=GetStringInfoDatum(profile)[i++];
926 if (sentinel != 0x1c)
927 continue;
928 dataset=GetStringInfoDatum(profile)[i++];
929 record=GetStringInfoDatum(profile)[i++];
930 switch (record)
931 {
932 case 5: tag="Image Name"; break;
933 case 7: tag="Edit Status"; break;
934 case 10: tag="Priority"; break;
935 case 15: tag="Category"; break;
936 case 20: tag="Supplemental Category"; break;
937 case 22: tag="Fixture Identifier"; break;
938 case 25: tag="Keyword"; break;
939 case 30: tag="Release Date"; break;
940 case 35: tag="Release Time"; break;
941 case 40: tag="Special Instructions"; break;
942 case 45: tag="Reference Service"; break;
943 case 47: tag="Reference Date"; break;
944 case 50: tag="Reference Number"; break;
945 case 55: tag="Created Date"; break;
946 case 60: tag="Created Time"; break;
947 case 65: tag="Originating Program"; break;
948 case 70: tag="Program Version"; break;
949 case 75: tag="Object Cycle"; break;
950 case 80: tag="Byline"; break;
951 case 85: tag="Byline Title"; break;
952 case 90: tag="City"; break;
953 case 95: tag="Province State"; break;
954 case 100: tag="Country Code"; break;
955 case 101: tag="Country"; break;
956 case 103: tag="Original Transmission Reference"; break;
957 case 105: tag="Headline"; break;
958 case 110: tag="Credit"; break;
959 case 115: tag="Src"; break;
960 case 116: tag="Copyright String"; break;
961 case 120: tag="Caption"; break;
962 case 121: tag="Local Caption"; break;
963 case 122: tag="Caption Writer"; break;
964 case 200: tag="Custom Field 1"; break;
965 case 201: tag="Custom Field 2"; break;
966 case 202: tag="Custom Field 3"; break;
967 case 203: tag="Custom Field 4"; break;
968 case 204: tag="Custom Field 5"; break;
969 case 205: tag="Custom Field 6"; break;
970 case 206: tag="Custom Field 7"; break;
971 case 207: tag="Custom Field 8"; break;
972 case 208: tag="Custom Field 9"; break;
973 case 209: tag="Custom Field 10"; break;
974 case 210: tag="Custom Field 11"; break;
975 case 211: tag="Custom Field 12"; break;
976 case 212: tag="Custom Field 13"; break;
977 case 213: tag="Custom Field 14"; break;
978 case 214: tag="Custom Field 15"; break;
979 case 215: tag="Custom Field 16"; break;
980 case 216: tag="Custom Field 17"; break;
981 case 217: tag="Custom Field 18"; break;
982 case 218: tag="Custom Field 19"; break;
983 case 219: tag="Custom Field 20"; break;
984 default: tag="unknown"; break;
985 }
cristy1e604812011-05-19 18:07:50 +0000986 (void) FormatLocaleFile(file," %s[%.20g,%.20g]: ",tag,
987 (double) dataset,(double) record);
cristy3ed852e2009-09-05 21:47:34 +0000988 length=(size_t) (GetStringInfoDatum(profile)[i++] << 8);
989 length|=GetStringInfoDatum(profile)[i++];
990 attribute=(char *) NULL;
cristy37e0b382011-06-07 13:31:21 +0000991 if (~length >= (MaxTextExtent-1))
cristya4037272011-08-28 15:11:39 +0000992 attribute=(char *) AcquireQuantumMemory(length+MaxTextExtent,
993 sizeof(*attribute));
cristy3ed852e2009-09-05 21:47:34 +0000994 if (attribute != (char *) NULL)
995 {
996 (void) CopyMagickString(attribute,(char *)
997 GetStringInfoDatum(profile)+i,length+1);
998 attribute_list=StringToList(attribute);
999 if (attribute_list != (char **) NULL)
1000 {
1001 for (j=0; attribute_list[j] != (char *) NULL; j++)
1002 {
1003 (void) fputs(attribute_list[j],file);
1004 (void) fputs("\n",file);
1005 attribute_list[j]=(char *) RelinquishMagickMemory(
1006 attribute_list[j]);
1007 }
1008 attribute_list=(char **) RelinquishMagickMemory(
1009 attribute_list);
1010 }
1011 attribute=DestroyString(attribute);
1012 }
1013 }
1014 }
1015 if (image->debug != MagickFalse)
1016 PrintStringInfo(file,name,profile);
1017 name=GetNextImageProfile(image);
1018 }
1019 }
1020 ResetImageArtifactIterator(image);
1021 artifact=GetNextImageArtifact(image);
1022 if (artifact != (const char *) NULL)
1023 {
1024 /*
1025 Display image artifacts.
1026 */
cristyb51dff52011-05-19 16:55:47 +00001027 (void) FormatLocaleFile(file," Artifacts:\n");
cristy3ed852e2009-09-05 21:47:34 +00001028 while (artifact != (const char *) NULL)
1029 {
cristyb51dff52011-05-19 16:55:47 +00001030 (void) FormatLocaleFile(file," %s: ",artifact);
cristy3ed852e2009-09-05 21:47:34 +00001031 value=GetImageArtifact(image,artifact);
1032 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +00001033 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +00001034 artifact=GetNextImageArtifact(image);
1035 }
1036 }
1037 ResetImageRegistryIterator();
1038 registry=GetNextImageRegistry();
1039 if (registry != (const char *) NULL)
1040 {
1041 /*
1042 Display image registry.
1043 */
cristyb51dff52011-05-19 16:55:47 +00001044 (void) FormatLocaleFile(file," Registry:\n");
cristy3ed852e2009-09-05 21:47:34 +00001045 while (registry != (const char *) NULL)
1046 {
cristyb51dff52011-05-19 16:55:47 +00001047 (void) FormatLocaleFile(file," %s: ",registry);
cristy3ed852e2009-09-05 21:47:34 +00001048 value=(const char *) GetImageRegistry(StringRegistryType,registry,
cristya4037272011-08-28 15:11:39 +00001049 exception);
cristy3ed852e2009-09-05 21:47:34 +00001050 if (value != (const char *) NULL)
cristyb51dff52011-05-19 16:55:47 +00001051 (void) FormatLocaleFile(file,"%s\n",value);
cristy3ed852e2009-09-05 21:47:34 +00001052 registry=GetNextImageRegistry();
1053 }
1054 }
cristyb51dff52011-05-19 16:55:47 +00001055 (void) FormatLocaleFile(file," Tainted: %s\n",CommandOptionToMnemonic(
cristybb503372010-05-27 20:51:26 +00001056 MagickBooleanOptions,(ssize_t) image->taint));
cristyb9080c92009-12-01 20:13:26 +00001057 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +00001058 (void) FormatLocaleFile(file," Filesize: %sB\n",format);
cristyb9080c92009-12-01 20:13:26 +00001059 (void) FormatMagickSize((MagickSizeType) image->columns*image->rows,
1060 MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +00001061 (void) FormatLocaleFile(file," Number pixels: %s\n",format);
cristy3d231692009-09-29 01:05:22 +00001062 (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/
cristyb9080c92009-12-01 20:13:26 +00001063 elapsed_time+0.5),MagickFalse,format);
cristyb51dff52011-05-19 16:55:47 +00001064 (void) FormatLocaleFile(file," Pixels per second: %s\n",format);
1065 (void) FormatLocaleFile(file," User time: %0.3fu\n",user_time);
cristy1e604812011-05-19 18:07:50 +00001066 (void) FormatLocaleFile(file," Elapsed time: %lu:%02lu.%03lu\n",
cristya4037272011-08-28 15:11:39 +00001067 (unsigned long) (elapsed_time/60.0),(unsigned long) ceil(fmod(elapsed_time,
1068 60.0)),(unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
cristyb51dff52011-05-19 16:55:47 +00001069 (void) FormatLocaleFile(file," Version: %s\n",GetMagickVersion((size_t *)
cristy3d231692009-09-29 01:05:22 +00001070 NULL));
cristy3ed852e2009-09-05 21:47:34 +00001071 (void) fflush(file);
1072 return(ferror(file) != 0 ? MagickFalse : MagickTrue);
1073}