cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % IIIII DDDD EEEEE N N TTTTT IIIII FFFFF Y Y % |
| 7 | % I D D E NN N T I F Y Y % |
| 8 | % I D D EEE N N N T I FFF Y % |
| 9 | % I D D E N NN T I F Y % |
| 10 | % IIIII DDDD EEEEE N N T IIIII F Y % |
| 11 | % % |
| 12 | % % |
| 13 | % Identify an Image Format and Characteristics. % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % September 1994 % |
| 18 | % % |
| 19 | % % |
| 20 | % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization % |
| 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 28 | % Unless required by applicable law or agreed to in writing, software % |
| 29 | % distributed under the License is distributed on an "AS IS" BASIS, % |
| 30 | % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % |
| 31 | % See the License for the specific language governing permissions and % |
| 32 | % limitations under the License. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % Identify describes the format and characteristics of one or more image |
| 37 | % files. It will also report if an image is incomplete or corrupt. |
| 38 | % |
| 39 | % |
| 40 | */ |
| 41 | |
| 42 | /* |
| 43 | Include declarations. |
| 44 | */ |
| 45 | #include "magick/studio.h" |
| 46 | #include "magick/annotate.h" |
| 47 | #include "magick/artifact.h" |
cristy | 78e9c76 | 2009-10-14 19:36:18 +0000 | [diff] [blame] | 48 | #include "magick/attribute.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 49 | #include "magick/blob.h" |
| 50 | #include "magick/cache.h" |
| 51 | #include "magick/client.h" |
| 52 | #include "magick/coder.h" |
| 53 | #include "magick/color.h" |
| 54 | #include "magick/configure.h" |
| 55 | #include "magick/constitute.h" |
| 56 | #include "magick/decorate.h" |
| 57 | #include "magick/delegate.h" |
| 58 | #include "magick/draw.h" |
| 59 | #include "magick/effect.h" |
| 60 | #include "magick/exception.h" |
| 61 | #include "magick/exception-private.h" |
cristy | 549a37e | 2010-01-26 15:24:15 +0000 | [diff] [blame] | 62 | #include "magick/feature.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 63 | #include "magick/gem.h" |
| 64 | #include "magick/geometry.h" |
cristy | f2e1166 | 2009-10-14 01:24:43 +0000 | [diff] [blame] | 65 | #include "magick/histogram.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | #include "magick/identify.h" |
| 67 | #include "magick/image.h" |
| 68 | #include "magick/image-private.h" |
| 69 | #include "magick/list.h" |
| 70 | #include "magick/locale_.h" |
| 71 | #include "magick/log.h" |
| 72 | #include "magick/magic.h" |
| 73 | #include "magick/magick.h" |
| 74 | #include "magick/memory_.h" |
| 75 | #include "magick/module.h" |
| 76 | #include "magick/monitor.h" |
| 77 | #include "magick/montage.h" |
| 78 | #include "magick/option.h" |
| 79 | #include "magick/pixel-private.h" |
| 80 | #include "magick/prepress.h" |
| 81 | #include "magick/profile.h" |
| 82 | #include "magick/property.h" |
| 83 | #include "magick/quantize.h" |
| 84 | #include "magick/quantum.h" |
| 85 | #include "magick/random_.h" |
| 86 | #include "magick/registry.h" |
| 87 | #include "magick/resize.h" |
| 88 | #include "magick/resource_.h" |
| 89 | #include "magick/signature.h" |
| 90 | #include "magick/statistic.h" |
| 91 | #include "magick/string_.h" |
cristy | cd483f1 | 2010-01-26 15:30:08 +0000 | [diff] [blame] | 92 | #include "magick/string-private.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 93 | #include "magick/timer.h" |
| 94 | #include "magick/utility.h" |
| 95 | #include "magick/version.h" |
| 96 | #if defined(MAGICKCORE_LCMS_DELEGATE) |
cristy | d09bcf9 | 2010-03-25 03:04:45 +0000 | [diff] [blame] | 97 | #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) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 102 | #include <lcms/lcms.h> |
| 103 | #else |
| 104 | #include "lcms.h" |
| 105 | #endif |
| 106 | #endif |
| 107 | |
| 108 | /* |
cristy | d09bcf9 | 2010-03-25 03:04:45 +0000 | [diff] [blame] | 109 | 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 | /* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 118 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 119 | % % |
| 120 | % % |
| 121 | % % |
| 122 | % I d e n t i f y I m a g e % |
| 123 | % % |
| 124 | % % |
| 125 | % % |
| 126 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 127 | % |
| 128 | % IdentifyImage() identifies an image by printing its attributes to the file. |
| 129 | % Attributes include the image width, height, size, and others. |
| 130 | % |
| 131 | % The format of the IdentifyImage method is: |
| 132 | % |
| 133 | % MagickBooleanType IdentifyImage(Image *image,FILE *file, |
| 134 | % const MagickBooleanType verbose) |
| 135 | % |
| 136 | % A description of each parameter follows: |
| 137 | % |
| 138 | % o image: the image. |
| 139 | % |
| 140 | % o file: the file, typically stdout. |
| 141 | % |
| 142 | % o verbose: A value other than zero prints more detailed information |
| 143 | % about the image. |
| 144 | % |
| 145 | */ |
| 146 | |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 147 | static int PrintChannelFeatures(FILE *file,const ChannelType channel, |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 148 | const char *name,const ChannelFeatures *channel_features) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 149 | { |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 150 | #define PrintFeature(feature) \ |
| 151 | GetMagickPrecision(),(feature)[0], \ |
| 152 | GetMagickPrecision(),(feature)[1], \ |
| 153 | GetMagickPrecision(),(feature)[2], \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 154 | GetMagickPrecision(),(feature)[3], \ |
| 155 | GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \ |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 156 | |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 157 | #define FeaturesFormat " %s:\n" \ |
cristy | cdf8e1b | 2010-01-28 01:52:33 +0000 | [diff] [blame] | 158 | " Angular Second Moment:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 159 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | cdf8e1b | 2010-01-28 01:52:33 +0000 | [diff] [blame] | 160 | " Contrast:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 161 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | cdf8e1b | 2010-01-28 01:52:33 +0000 | [diff] [blame] | 162 | " Correlation:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 163 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 164 | " Sum of Squares: Variance:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 165 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | cf5e649 | 2010-01-28 02:45:28 +0000 | [diff] [blame] | 166 | " Inverse Difference Moment:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 167 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 168 | " Sum Average:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 169 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 170 | " Sum Variance:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 171 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 172 | " Sum Entropy:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 173 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 174 | " Entropy:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 175 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 176 | " Difference Variance:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 177 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e0e19dc | 2010-01-29 02:13:08 +0000 | [diff] [blame] | 178 | " Difference Entropy:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 179 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e0e19dc | 2010-01-29 02:13:08 +0000 | [diff] [blame] | 180 | " Information Measure of Correlation 1:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 181 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e0e19dc | 2010-01-29 02:13:08 +0000 | [diff] [blame] | 182 | " Information Measure of Correlation 2:\n" \ |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 183 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
cristy | e0e19dc | 2010-01-29 02:13:08 +0000 | [diff] [blame] | 184 | " Maximum Correlation Coefficient:\n" \ |
cristy | c3ec0d4 | 2010-04-07 01:18:08 +0000 | [diff] [blame] | 185 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 186 | |
| 187 | int |
| 188 | status; |
| 189 | |
| 190 | status=fprintf(file,FeaturesFormat,name, |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 191 | PrintFeature(channel_features[channel].angular_second_moment), |
| 192 | PrintFeature(channel_features[channel].contrast), |
| 193 | PrintFeature(channel_features[channel].correlation), |
| 194 | PrintFeature(channel_features[channel].variance_sum_of_squares), |
| 195 | PrintFeature(channel_features[channel].inverse_difference_moment), |
| 196 | PrintFeature(channel_features[channel].sum_average), |
| 197 | PrintFeature(channel_features[channel].sum_variance), |
| 198 | PrintFeature(channel_features[channel].sum_entropy), |
| 199 | PrintFeature(channel_features[channel].entropy), |
cristy | e0e19dc | 2010-01-29 02:13:08 +0000 | [diff] [blame] | 200 | PrintFeature(channel_features[channel].difference_variance), |
| 201 | PrintFeature(channel_features[channel].difference_entropy), |
| 202 | PrintFeature(channel_features[channel].measure_of_correlation_1), |
| 203 | PrintFeature(channel_features[channel].measure_of_correlation_2), |
| 204 | PrintFeature(channel_features[channel].maximum_correlation_coefficient)); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 205 | return(status); |
| 206 | } |
| 207 | |
| 208 | static int PrintChannelStatistics(FILE *file,const ChannelType channel, |
| 209 | const char *name,const double scale, |
| 210 | const ChannelStatistics *channel_statistics) |
| 211 | { |
| 212 | #define StatisticsFormat " %s:\n min: " QuantumFormat \ |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 213 | " (%g)\n max: " QuantumFormat " (%g)\n" \ |
| 214 | " mean: %g (%g)\n standard deviation: %g (%g)\n" \ |
| 215 | " kurtosis: %g\n skewness: %g\n" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 216 | |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 217 | int |
| 218 | status; |
| 219 | |
cristy | a45da3b | 2010-03-31 02:06:45 +0000 | [diff] [blame] | 220 | status=fprintf(file,StatisticsFormat,name,ClampToQuantum(scale* |
| 221 | channel_statistics[channel].minima),channel_statistics[channel].minima/ |
| 222 | (double) QuantumRange,ClampToQuantum(scale* |
| 223 | channel_statistics[channel].maxima),channel_statistics[channel].maxima/ |
| 224 | (double) QuantumRange,scale*channel_statistics[channel].mean, |
| 225 | channel_statistics[channel].mean/(double) QuantumRange,scale* |
| 226 | channel_statistics[channel].standard_deviation, |
cristy | 75b5a25 | 2010-02-26 02:40:46 +0000 | [diff] [blame] | 227 | channel_statistics[channel].standard_deviation/(double) QuantumRange, |
| 228 | channel_statistics[channel].kurtosis,channel_statistics[channel].skewness); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 229 | return(status); |
| 230 | } |
| 231 | |
| 232 | MagickExport MagickBooleanType IdentifyImage(Image *image,FILE *file, |
| 233 | const MagickBooleanType verbose) |
| 234 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 235 | char |
| 236 | color[MaxTextExtent], |
| 237 | format[MaxTextExtent], |
| 238 | key[MaxTextExtent]; |
| 239 | |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 240 | ChannelFeatures |
| 241 | *channel_features; |
| 242 | |
| 243 | ChannelStatistics |
| 244 | *channel_statistics; |
| 245 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 246 | ColorspaceType |
| 247 | colorspace; |
| 248 | |
| 249 | const char |
| 250 | *artifact, |
| 251 | *name, |
| 252 | *property, |
| 253 | *registry, |
| 254 | *value; |
| 255 | |
| 256 | const MagickInfo |
| 257 | *magick_info; |
| 258 | |
| 259 | const PixelPacket |
| 260 | *pixels; |
| 261 | |
| 262 | double |
| 263 | elapsed_time, |
| 264 | user_time; |
| 265 | |
| 266 | ExceptionInfo |
| 267 | *exception; |
| 268 | |
| 269 | ImageType |
| 270 | type; |
| 271 | |
| 272 | long |
| 273 | y; |
| 274 | |
| 275 | MagickBooleanType |
| 276 | ping; |
| 277 | |
| 278 | register long |
| 279 | i, |
| 280 | x; |
| 281 | |
| 282 | unsigned long |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 283 | distance, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 284 | scale; |
| 285 | |
| 286 | 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) |
| 303 | (void) fprintf(file,"%s=>",image->magick_filename); |
| 304 | if ((GetPreviousImageInList(image) == (Image *) NULL) && |
cristy | 81b8ce5 | 2010-02-05 01:53:17 +0000 | [diff] [blame] | 305 | (GetNextImageInList(image) == (Image *) NULL) && |
| 306 | (image->scene == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 307 | (void) fprintf(file,"%s ",image->filename); |
| 308 | else |
| 309 | (void) fprintf(file,"%s[%lu] ",image->filename,image->scene); |
| 310 | (void) fprintf(file,"%s ",image->magick); |
| 311 | if ((image->magick_columns != 0) || (image->magick_rows != 0)) |
| 312 | if ((image->magick_columns != image->columns) || |
| 313 | (image->magick_rows != image->rows)) |
| 314 | (void) fprintf(file,"%lux%lu=>",image->magick_columns, |
| 315 | image->magick_rows); |
| 316 | (void) fprintf(file,"%lux%lu ",image->columns,image->rows); |
| 317 | if ((image->page.width != 0) || (image->page.height != 0) || |
| 318 | (image->page.x != 0) || (image->page.y != 0)) |
| 319 | (void) fprintf(file,"%lux%lu%+ld%+ld ",image->page.width, |
| 320 | image->page.height,image->page.x,image->page.y); |
| 321 | (void) fprintf(file,"%lu-bit ",image->depth); |
| 322 | if (image->type != UndefinedType) |
| 323 | (void) fprintf(file,"%s ",MagickOptionToMnemonic(MagickTypeOptions, |
| 324 | (long) image->type)); |
| 325 | if (image->storage_class == DirectClass) |
| 326 | { |
| 327 | (void) fprintf(file,"DirectClass "); |
| 328 | if (image->total_colors != 0) |
| 329 | { |
cristy | b9080c9 | 2009-12-01 20:13:26 +0000 | [diff] [blame] | 330 | (void) FormatMagickSize(image->total_colors,MagickFalse,format); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 331 | (void) fprintf(file,"%s ",format); |
| 332 | } |
| 333 | } |
| 334 | else |
| 335 | if (image->total_colors <= image->colors) |
| 336 | (void) fprintf(file,"PseudoClass %luc ",image->colors); |
| 337 | else |
| 338 | (void) fprintf(file,"PseudoClass %lu=>%luc ",image->total_colors, |
| 339 | image->colors); |
| 340 | if (image->error.mean_error_per_pixel != 0.0) |
| 341 | (void) fprintf(file,"%ld/%f/%fdb ",(long) |
| 342 | (image->error.mean_error_per_pixel+0.5), |
| 343 | image->error.normalized_mean_error, |
| 344 | image->error.normalized_maximum_error); |
| 345 | if (GetBlobSize(image) != 0) |
| 346 | { |
cristy | b9080c9 | 2009-12-01 20:13:26 +0000 | [diff] [blame] | 347 | (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format); |
cristy | 2ce15c9 | 2010-03-12 14:03:41 +0000 | [diff] [blame] | 348 | (void) fprintf(file,"%sB ",format); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 349 | } |
cristy | 3d23169 | 2009-09-29 01:05:22 +0000 | [diff] [blame] | 350 | (void) fprintf(file,"%0.3fu %ld:%02ld.%03ld",user_time,(long) |
| 351 | (elapsed_time/60.0),(long) floor(fmod(elapsed_time,60.0)), |
| 352 | (long) (1000.0*(elapsed_time-floor(elapsed_time)))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 353 | (void) fprintf(file,"\n"); |
| 354 | (void) fflush(file); |
| 355 | return(ferror(file) != 0 ? MagickFalse : MagickTrue); |
| 356 | } |
| 357 | /* |
| 358 | Display verbose info about the image. |
| 359 | */ |
| 360 | exception=AcquireExceptionInfo(); |
| 361 | pixels=GetVirtualPixels(image,0,0,1,1,exception); |
| 362 | exception=DestroyExceptionInfo(exception); |
| 363 | ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse; |
| 364 | type=GetImageType(image,&image->exception); |
| 365 | (void) SignatureImage(image); |
| 366 | (void) fprintf(file,"Image: %s\n",image->filename); |
| 367 | if (*image->magick_filename != '\0') |
| 368 | if (LocaleCompare(image->magick_filename,image->filename) != 0) |
| 369 | { |
| 370 | char |
| 371 | filename[MaxTextExtent]; |
| 372 | |
| 373 | GetPathComponent(image->magick_filename,TailPath,filename); |
| 374 | (void) fprintf(file," Base filename: %s\n",filename); |
| 375 | } |
| 376 | magick_info=GetMagickInfo(image->magick,&image->exception); |
| 377 | if ((magick_info == (const MagickInfo *) NULL) || |
| 378 | (*GetMagickDescription(magick_info) == '\0')) |
| 379 | (void) fprintf(file," Format: %s\n",image->magick); |
| 380 | else |
| 381 | (void) fprintf(file," Format: %s (%s)\n",image->magick, |
| 382 | GetMagickDescription(magick_info)); |
| 383 | (void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions, |
| 384 | (long) image->storage_class)); |
| 385 | (void) fprintf(file," Geometry: %lux%lu%+ld%+ld\n",image->columns, |
| 386 | image->rows,image->tile_offset.x,image->tile_offset.y); |
| 387 | if ((image->magick_columns != 0) || (image->magick_rows != 0)) |
| 388 | if ((image->magick_columns != image->columns) || |
| 389 | (image->magick_rows != image->rows)) |
| 390 | (void) fprintf(file," Base geometry: %lux%lu\n",image->magick_columns, |
| 391 | image->magick_rows); |
| 392 | if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0)) |
| 393 | { |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 394 | (void) fprintf(file," Resolution: %gx%g\n",image->x_resolution, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 395 | image->y_resolution); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 396 | (void) fprintf(file," Print size: %gx%g\n",(double) image->columns/ |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 397 | image->x_resolution,(double) image->rows/image->y_resolution); |
| 398 | } |
| 399 | (void) fprintf(file," Units: %s\n",MagickOptionToMnemonic( |
| 400 | MagickResolutionOptions,(long) image->units)); |
| 401 | (void) fprintf(file," Type: %s\n",MagickOptionToMnemonic(MagickTypeOptions, |
| 402 | (long) type)); |
| 403 | if (image->type != UndefinedType) |
| 404 | (void) fprintf(file," Base type: %s\n",MagickOptionToMnemonic( |
| 405 | MagickTypeOptions,(long) image->type)); |
| 406 | (void) fprintf(file," Endianess: %s\n",MagickOptionToMnemonic( |
| 407 | MagickEndianOptions,(long) image->endian)); |
| 408 | /* |
| 409 | Detail channel depth and extrema. |
| 410 | */ |
| 411 | (void) fprintf(file," Colorspace: %s\n",MagickOptionToMnemonic( |
| 412 | MagickColorspaceOptions,(long) image->colorspace)); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 413 | channel_statistics=(ChannelStatistics *) NULL; |
cristy | 15a8878 | 2010-01-31 23:24:49 +0000 | [diff] [blame] | 414 | channel_features=(ChannelFeatures *) NULL; |
| 415 | colorspace=image->colorspace; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 416 | if (ping == MagickFalse) |
| 417 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 418 | unsigned long |
| 419 | depth; |
| 420 | |
cristy | 15a8878 | 2010-01-31 23:24:49 +0000 | [diff] [blame] | 421 | channel_statistics=GetImageChannelStatistics(image,&image->exception); |
| 422 | artifact=GetImageArtifact(image,"identify:features"); |
| 423 | if (artifact != (const char *) NULL) |
| 424 | { |
| 425 | distance=StringToUnsignedLong(artifact); |
| 426 | channel_features=GetImageChannelFeatures(image,distance, |
| 427 | &image->exception); |
| 428 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 429 | depth=GetImageDepth(image,&image->exception); |
| 430 | if (image->depth == depth) |
| 431 | (void) fprintf(file," Depth: %lu-bit\n",image->depth); |
| 432 | else |
| 433 | (void) fprintf(file," Depth: %lu/%lu-bit\n",image->depth,depth); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 434 | (void) fprintf(file," Channel depth:\n"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 435 | if (IsGrayImage(image,&image->exception) != MagickFalse) |
| 436 | colorspace=GRAYColorspace; |
| 437 | switch (colorspace) |
| 438 | { |
| 439 | case RGBColorspace: |
| 440 | default: |
| 441 | { |
| 442 | (void) fprintf(file," red: %lu-bit\n", |
| 443 | channel_statistics[RedChannel].depth); |
| 444 | (void) fprintf(file," green: %lu-bit\n", |
| 445 | channel_statistics[GreenChannel].depth); |
| 446 | (void) fprintf(file," blue: %lu-bit\n", |
| 447 | channel_statistics[BlueChannel].depth); |
| 448 | if (image->matte != MagickFalse) |
| 449 | (void) fprintf(file," alpha: %lu-bit\n", |
| 450 | channel_statistics[OpacityChannel].depth); |
| 451 | break; |
| 452 | } |
| 453 | case CMYKColorspace: |
| 454 | { |
| 455 | (void) fprintf(file," cyan: %lu-bit\n", |
| 456 | channel_statistics[CyanChannel].depth); |
| 457 | (void) fprintf(file," magenta: %lu-bit\n", |
| 458 | channel_statistics[MagentaChannel].depth); |
| 459 | (void) fprintf(file," yellow: %lu-bit\n", |
| 460 | channel_statistics[YellowChannel].depth); |
| 461 | (void) fprintf(file," black: %lu-bit\n", |
| 462 | channel_statistics[BlackChannel].depth); |
| 463 | if (image->matte != MagickFalse) |
| 464 | (void) fprintf(file," alpha: %lu-bit\n", |
| 465 | channel_statistics[OpacityChannel].depth); |
| 466 | break; |
| 467 | } |
| 468 | case GRAYColorspace: |
| 469 | { |
| 470 | (void) fprintf(file," gray: %lu-bit\n", |
| 471 | channel_statistics[GrayChannel].depth); |
| 472 | if (image->matte != MagickFalse) |
| 473 | (void) fprintf(file," alpha: %lu-bit\n", |
| 474 | channel_statistics[OpacityChannel].depth); |
| 475 | break; |
| 476 | } |
| 477 | } |
| 478 | scale=1; |
| 479 | if (image->depth <= MAGICKCORE_QUANTUM_DEPTH) |
| 480 | scale=QuantumRange/((unsigned long) QuantumRange >> ((unsigned long) |
| 481 | MAGICKCORE_QUANTUM_DEPTH-image->depth)); |
cristy | 15a8878 | 2010-01-31 23:24:49 +0000 | [diff] [blame] | 482 | } |
| 483 | if (channel_statistics != (ChannelStatistics *) NULL) |
| 484 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 485 | (void) fprintf(file," Channel statistics:\n"); |
| 486 | switch (colorspace) |
| 487 | { |
| 488 | case RGBColorspace: |
| 489 | default: |
| 490 | { |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 491 | (void) PrintChannelStatistics(file,RedChannel,"Red",1.0/scale, |
| 492 | channel_statistics); |
| 493 | (void) PrintChannelStatistics(file,GreenChannel,"Green",1.0/scale, |
| 494 | channel_statistics); |
| 495 | (void) PrintChannelStatistics(file,BlueChannel,"Blue",1.0/scale, |
| 496 | channel_statistics); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 497 | break; |
| 498 | } |
| 499 | case CMYKColorspace: |
| 500 | { |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 501 | (void) PrintChannelStatistics(file,CyanChannel,"Cyan",1.0/scale, |
| 502 | channel_statistics); |
| 503 | (void) PrintChannelStatistics(file,MagentaChannel,"Magenta",1.0/scale, |
| 504 | channel_statistics); |
| 505 | (void) PrintChannelStatistics(file,YellowChannel,"Yellow",1.0/scale, |
| 506 | channel_statistics); |
| 507 | (void) PrintChannelStatistics(file,BlackChannel,"Black",1.0/scale, |
| 508 | channel_statistics); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 509 | break; |
| 510 | } |
| 511 | case GRAYColorspace: |
| 512 | { |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 513 | (void) PrintChannelStatistics(file,GrayChannel,"Gray",1.0/scale, |
| 514 | channel_statistics); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 515 | break; |
| 516 | } |
| 517 | } |
| 518 | if (image->matte != MagickFalse) |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 519 | (void) PrintChannelStatistics(file,AlphaChannel,"Alpha",1.0/scale, |
| 520 | channel_statistics); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 521 | if (colorspace != GRAYColorspace) |
| 522 | { |
| 523 | (void) fprintf(file," Image statistics:\n"); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 524 | (void) PrintChannelStatistics(file,AllChannels,"Overall",1.0/scale, |
| 525 | channel_statistics); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 526 | } |
| 527 | channel_statistics=(ChannelStatistics *) RelinquishMagickMemory( |
| 528 | channel_statistics); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 529 | } |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 530 | if (channel_features != (ChannelFeatures *) NULL) |
| 531 | { |
cristy | e0acabf | 2010-01-30 00:52:38 +0000 | [diff] [blame] | 532 | (void) fprintf(file," Channel features (horizontal, vertical, left and right diagonals, average):\n"); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 533 | switch (colorspace) |
| 534 | { |
| 535 | case RGBColorspace: |
| 536 | default: |
cristy | 549a37e | 2010-01-26 15:24:15 +0000 | [diff] [blame] | 537 | { |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 538 | (void) PrintChannelFeatures(file,RedChannel,"Red",channel_features); |
| 539 | (void) PrintChannelFeatures(file,GreenChannel,"Green", |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 540 | channel_features); |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 541 | (void) PrintChannelFeatures(file,BlueChannel,"Blue",channel_features); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 542 | break; |
| 543 | } |
| 544 | case CMYKColorspace: |
| 545 | { |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 546 | (void) PrintChannelFeatures(file,CyanChannel,"Cyan",channel_features); |
| 547 | (void) PrintChannelFeatures(file,MagentaChannel,"Magenta", |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 548 | channel_features); |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 549 | (void) PrintChannelFeatures(file,YellowChannel,"Yellow", |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 550 | channel_features); |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 551 | (void) PrintChannelFeatures(file,BlackChannel,"Black", |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 552 | channel_features); |
| 553 | break; |
| 554 | } |
| 555 | case GRAYColorspace: |
| 556 | { |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 557 | (void) PrintChannelFeatures(file,GrayChannel,"Gray",channel_features); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 558 | break; |
| 559 | } |
| 560 | } |
| 561 | if (image->matte != MagickFalse) |
cristy | e189779 | 2010-01-29 02:05:50 +0000 | [diff] [blame] | 562 | (void) PrintChannelFeatures(file,AlphaChannel,"Alpha",channel_features); |
cristy | bd82207 | 2010-01-27 00:30:00 +0000 | [diff] [blame] | 563 | channel_features=(ChannelFeatures *) RelinquishMagickMemory( |
| 564 | channel_features); |
| 565 | } |
| 566 | if (ping == MagickFalse) |
| 567 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 568 | if (image->colorspace == CMYKColorspace) |
| 569 | (void) fprintf(file," Total ink density: %.0f%%\n",100.0* |
| 570 | GetImageTotalInkDensity(image)/(double) QuantumRange); |
| 571 | x=0; |
| 572 | if (image->matte != MagickFalse) |
| 573 | { |
| 574 | register const IndexPacket |
| 575 | *indexes; |
| 576 | |
| 577 | register const PixelPacket |
| 578 | *p; |
| 579 | |
| 580 | p=(PixelPacket *) NULL; |
| 581 | indexes=(IndexPacket *) NULL; |
| 582 | for (y=0; y < (long) image->rows; y++) |
| 583 | { |
| 584 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
| 585 | if (p == (const PixelPacket *) NULL) |
| 586 | break; |
| 587 | indexes=GetVirtualIndexQueue(image); |
| 588 | for (x=0; x < (long) image->columns; x++) |
| 589 | { |
| 590 | if (p->opacity == (Quantum) TransparentOpacity) |
| 591 | break; |
| 592 | p++; |
| 593 | } |
| 594 | if (x < (long) image->columns) |
| 595 | break; |
| 596 | } |
| 597 | if ((x < (long) image->columns) || (y < (long) image->rows)) |
| 598 | { |
| 599 | char |
| 600 | tuple[MaxTextExtent]; |
| 601 | |
| 602 | MagickPixelPacket |
| 603 | pixel; |
| 604 | |
| 605 | GetMagickPixelPacket(image,&pixel); |
| 606 | SetMagickPixelPacket(image,p,indexes+x,&pixel); |
| 607 | (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple, |
| 608 | &image->exception); |
| 609 | (void) fprintf(file," Alpha: %s ",tuple); |
| 610 | GetColorTuple(&pixel,MagickTrue,tuple); |
| 611 | (void) fprintf(file," %s\n",tuple); |
| 612 | } |
| 613 | } |
cristy | 83fae87 | 2010-04-22 15:04:16 +0000 | [diff] [blame^] | 614 | artifact=GetImageArtifact(image,"identify:unique-colors"); |
cristy | 549a37e | 2010-01-26 15:24:15 +0000 | [diff] [blame] | 615 | if ((artifact != (const char *) NULL) && |
| 616 | (IsMagickTrue(artifact) != MagickFalse)) |
| 617 | (void) fprintf(file," Colors: %lu\n",GetNumberColors(image, |
| 618 | (FILE *) NULL,&image->exception)); |
| 619 | if (IsHistogramImage(image,&image->exception) != MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 620 | { |
cristy | 549a37e | 2010-01-26 15:24:15 +0000 | [diff] [blame] | 621 | (void) fprintf(file," Histogram:\n"); |
| 622 | (void) GetNumberColors(image,file,&image->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 623 | } |
| 624 | } |
| 625 | if (image->storage_class == PseudoClass) |
| 626 | { |
| 627 | (void) fprintf(file," Colormap: %lu\n",image->colors); |
| 628 | if (image->colors <= 1024) |
| 629 | { |
| 630 | char |
| 631 | color[MaxTextExtent], |
| 632 | hex[MaxTextExtent], |
| 633 | tuple[MaxTextExtent]; |
| 634 | |
| 635 | MagickPixelPacket |
| 636 | pixel; |
| 637 | |
| 638 | register PixelPacket |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 639 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 640 | |
| 641 | GetMagickPixelPacket(image,&pixel); |
| 642 | p=image->colormap; |
| 643 | for (i=0; i < (long) image->colors; i++) |
| 644 | { |
| 645 | SetMagickPixelPacket(image,p,(IndexPacket *) NULL,&pixel); |
| 646 | (void) CopyMagickString(tuple,"(",MaxTextExtent); |
| 647 | ConcatenateColorComponent(&pixel,RedChannel,X11Compliance,tuple); |
| 648 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 649 | ConcatenateColorComponent(&pixel,GreenChannel,X11Compliance,tuple); |
| 650 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 651 | ConcatenateColorComponent(&pixel,BlueChannel,X11Compliance,tuple); |
| 652 | if (pixel.colorspace == CMYKColorspace) |
| 653 | { |
| 654 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 655 | ConcatenateColorComponent(&pixel,IndexChannel,X11Compliance, |
| 656 | tuple); |
| 657 | } |
| 658 | if (pixel.matte != MagickFalse) |
| 659 | { |
| 660 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
cristy | c3ec0d4 | 2010-04-07 01:18:08 +0000 | [diff] [blame] | 661 | ConcatenateColorComponent(&pixel,AlphaChannel,X11Compliance, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 662 | tuple); |
| 663 | } |
| 664 | (void) ConcatenateMagickString(tuple,")",MaxTextExtent); |
| 665 | (void) QueryMagickColorname(image,&pixel,SVGCompliance,color, |
| 666 | &image->exception); |
| 667 | GetColorTuple(&pixel,MagickTrue,hex); |
| 668 | (void) fprintf(file," %8ld: %s %s %s\n",i,tuple,hex,color); |
| 669 | p++; |
| 670 | } |
| 671 | } |
| 672 | } |
| 673 | if (image->error.mean_error_per_pixel != 0.0) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 674 | (void) fprintf(file," Mean error per pixel: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 675 | image->error.mean_error_per_pixel); |
| 676 | if (image->error.normalized_mean_error != 0.0) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 677 | (void) fprintf(file," Normalized mean error: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 678 | image->error.normalized_mean_error); |
| 679 | if (image->error.normalized_maximum_error != 0.0) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 680 | (void) fprintf(file," Normalized maximum error: %g\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 681 | image->error.normalized_maximum_error); |
| 682 | (void) fprintf(file," Rendering intent: %s\n",MagickOptionToMnemonic( |
| 683 | MagickIntentOptions,(long) image->rendering_intent)); |
| 684 | if (image->gamma != 0.0) |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 685 | (void) fprintf(file," Gamma: %g\n",image->gamma); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 686 | if ((image->chromaticity.red_primary.x != 0.0) || |
| 687 | (image->chromaticity.green_primary.x != 0.0) || |
| 688 | (image->chromaticity.blue_primary.x != 0.0) || |
| 689 | (image->chromaticity.white_point.x != 0.0)) |
| 690 | { |
| 691 | /* |
| 692 | Display image chromaticity. |
| 693 | */ |
| 694 | (void) fprintf(file," Chromaticity:\n"); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 695 | (void) fprintf(file," red primary: (%g,%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 696 | image->chromaticity.red_primary.x,image->chromaticity.red_primary.y); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 697 | (void) fprintf(file," green primary: (%g,%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 698 | image->chromaticity.green_primary.x, |
| 699 | image->chromaticity.green_primary.y); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 700 | (void) fprintf(file," blue primary: (%g,%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 701 | image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y); |
cristy | e7f5109 | 2010-01-17 00:39:37 +0000 | [diff] [blame] | 702 | (void) fprintf(file," white point: (%g,%g)\n", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 703 | image->chromaticity.white_point.x,image->chromaticity.white_point.y); |
| 704 | } |
| 705 | if ((image->extract_info.width*image->extract_info.height) != 0) |
| 706 | (void) fprintf(file," Tile geometry: %lux%lu%+ld%+ld\n", |
| 707 | image->extract_info.width,image->extract_info.height, |
| 708 | image->extract_info.x,image->extract_info.y); |
| 709 | (void) fprintf(file," Interlace: %s\n",MagickOptionToMnemonic( |
| 710 | MagickInterlaceOptions,(long) image->interlace)); |
| 711 | (void) QueryColorname(image,&image->background_color,SVGCompliance,color, |
| 712 | &image->exception); |
| 713 | (void) fprintf(file," Background color: %s\n",color); |
| 714 | (void) QueryColorname(image,&image->border_color,SVGCompliance,color, |
| 715 | &image->exception); |
| 716 | (void) fprintf(file," Border color: %s\n",color); |
| 717 | (void) QueryColorname(image,&image->matte_color,SVGCompliance,color, |
| 718 | &image->exception); |
| 719 | (void) fprintf(file," Matte color: %s\n",color); |
| 720 | (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color, |
| 721 | &image->exception); |
| 722 | (void) fprintf(file," Transparent color: %s\n",color); |
cristy | 11a7768 | 2009-10-11 21:50:20 +0000 | [diff] [blame] | 723 | (void) fprintf(file," Compose: %s\n",MagickOptionToMnemonic( |
| 724 | MagickComposeOptions,(long) image->compose)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 725 | if ((image->page.width != 0) || (image->page.height != 0) || |
| 726 | (image->page.x != 0) || (image->page.y != 0)) |
| 727 | (void) fprintf(file," Page geometry: %lux%lu%+ld%+ld\n",image->page.width, |
| 728 | image->page.height,image->page.x,image->page.y); |
| 729 | if ((image->page.x != 0) || (image->page.y != 0)) |
| 730 | (void) fprintf(file," Origin geometry: %+ld%+ld\n",image->page.x, |
| 731 | image->page.y); |
| 732 | (void) fprintf(file," Dispose: %s\n",MagickOptionToMnemonic( |
| 733 | MagickDisposeOptions,(long) image->dispose)); |
| 734 | if (image->delay != 0) |
| 735 | (void) fprintf(file," Delay: %lux%ld\n",image->delay, |
| 736 | image->ticks_per_second); |
| 737 | if (image->iterations != 1) |
| 738 | (void) fprintf(file," Iterations: %lu\n",image->iterations); |
| 739 | if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL)) |
| 740 | (void) fprintf(file," Scene: %lu of %lu\n",image->scene, |
| 741 | GetImageListLength(image)); |
| 742 | else |
| 743 | if (image->scene != 0) |
| 744 | (void) fprintf(file," Scene: %lu\n",image->scene); |
| 745 | (void) fprintf(file," Compression: %s\n",MagickOptionToMnemonic( |
| 746 | MagickCompressOptions,(long) image->compression)); |
| 747 | if (image->quality != UndefinedCompressionQuality) |
| 748 | (void) fprintf(file," Quality: %lu\n",image->quality); |
| 749 | (void) fprintf(file," Orientation: %s\n",MagickOptionToMnemonic( |
| 750 | MagickOrientationOptions,(long) image->orientation)); |
| 751 | if (image->montage != (char *) NULL) |
| 752 | (void) fprintf(file," Montage: %s\n",image->montage); |
| 753 | if (image->directory != (char *) NULL) |
| 754 | { |
| 755 | Image |
| 756 | *tile; |
| 757 | |
| 758 | ImageInfo |
| 759 | *image_info; |
| 760 | |
| 761 | register char |
| 762 | *p, |
| 763 | *q; |
| 764 | |
| 765 | WarningHandler |
| 766 | handler; |
| 767 | |
| 768 | /* |
| 769 | Display visual image directory. |
| 770 | */ |
| 771 | image_info=AcquireImageInfo(); |
| 772 | (void) CloneString(&image_info->size,"64x64"); |
| 773 | (void) fprintf(file," Directory:\n"); |
| 774 | for (p=image->directory; *p != '\0'; p++) |
| 775 | { |
| 776 | q=p; |
| 777 | while ((*q != '\n') && (*q != '\0')) |
| 778 | q++; |
| 779 | (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1)); |
| 780 | p=q; |
| 781 | (void) fprintf(file," %s",image_info->filename); |
| 782 | handler=SetWarningHandler((WarningHandler) NULL); |
| 783 | tile=ReadImage(image_info,&image->exception); |
| 784 | (void) SetWarningHandler(handler); |
| 785 | if (tile == (Image *) NULL) |
| 786 | { |
| 787 | (void) fprintf(file,"\n"); |
| 788 | continue; |
| 789 | } |
| 790 | (void) fprintf(file," %lux%lu %s\n",tile->magick_columns, |
| 791 | tile->magick_rows,tile->magick); |
| 792 | (void) SignatureImage(tile); |
| 793 | ResetImagePropertyIterator(tile); |
| 794 | property=GetNextImageProperty(tile); |
| 795 | while (property != (const char *) NULL) |
| 796 | { |
| 797 | (void) fprintf(file," %s:\n",property); |
| 798 | value=GetImageProperty(tile,property); |
| 799 | if (value != (const char *) NULL) |
| 800 | (void) fprintf(file,"%s\n",value); |
| 801 | property=GetNextImageProperty(tile); |
| 802 | } |
| 803 | tile=DestroyImage(tile); |
| 804 | } |
| 805 | image_info=DestroyImageInfo(image_info); |
| 806 | } |
| 807 | (void) GetImageProperty(image,"exif:*"); |
| 808 | ResetImagePropertyIterator(image); |
| 809 | property=GetNextImageProperty(image); |
| 810 | if (property != (const char *) NULL) |
| 811 | { |
| 812 | /* |
| 813 | Display image properties. |
| 814 | */ |
| 815 | (void) fprintf(file," Properties:\n"); |
| 816 | while (property != (const char *) NULL) |
| 817 | { |
| 818 | (void) fprintf(file," %c",*property); |
| 819 | if (strlen(property) > 1) |
| 820 | (void) fprintf(file,"%s: ",property+1); |
| 821 | if (strlen(property) > 80) |
| 822 | (void) fputc('\n',file); |
| 823 | value=GetImageProperty(image,property); |
| 824 | if (value != (const char *) NULL) |
| 825 | (void) fprintf(file,"%s\n",value); |
| 826 | property=GetNextImageProperty(image); |
| 827 | } |
| 828 | } |
| 829 | (void) FormatMagickString(key,MaxTextExtent,"8BIM:1999,2998:#1"); |
| 830 | value=GetImageProperty(image,key); |
| 831 | if (value != (const char *) NULL) |
| 832 | { |
| 833 | /* |
| 834 | Display clipping path. |
| 835 | */ |
| 836 | (void) fprintf(file," Clipping path: "); |
| 837 | if (strlen(value) > 80) |
| 838 | (void) fputc('\n',file); |
| 839 | (void) fprintf(file,"%s\n",value); |
| 840 | } |
| 841 | ResetImageProfileIterator(image); |
| 842 | name=GetNextImageProfile(image); |
| 843 | if (name != (char *) NULL) |
| 844 | { |
| 845 | const StringInfo |
| 846 | *profile; |
| 847 | |
| 848 | /* |
| 849 | Identify image profiles. |
| 850 | */ |
| 851 | (void) fprintf(file," Profiles:\n"); |
| 852 | while (name != (char *) NULL) |
| 853 | { |
| 854 | profile=GetImageProfile(image,name); |
| 855 | if (profile == (StringInfo *) NULL) |
| 856 | continue; |
| 857 | (void) fprintf(file," Profile-%s: %lu bytes\n",name,(unsigned long) |
| 858 | GetStringInfoLength(profile)); |
| 859 | #if defined(MAGICKCORE_LCMS_DELEGATE) |
| 860 | if ((LocaleCompare(name,"icc") == 0) || |
| 861 | (LocaleCompare(name,"icm") == 0)) |
| 862 | { |
| 863 | cmsHPROFILE |
| 864 | icc_profile; |
| 865 | |
| 866 | icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile), |
cristy | d09bcf9 | 2010-03-25 03:04:45 +0000 | [diff] [blame] | 867 | (cmsUInt32Number) GetStringInfoLength(profile)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 868 | if (icc_profile != (cmsHPROFILE *) NULL) |
| 869 | { |
cristy | d09bcf9 | 2010-03-25 03:04:45 +0000 | [diff] [blame] | 870 | #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 871 | const char |
| 872 | *name; |
| 873 | |
| 874 | name=cmsTakeProductName(icc_profile); |
| 875 | if (name != (const char *) NULL) |
| 876 | (void) fprintf(file," %s\n",name); |
cristy | d09bcf9 | 2010-03-25 03:04:45 +0000 | [diff] [blame] | 877 | #else |
| 878 | char |
| 879 | info[MaxTextExtent]; |
| 880 | |
| 881 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription, |
| 882 | "en","US",info,MaxTextExtent); |
| 883 | (void) fprintf(file," Description: %s\n",info); |
| 884 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer, |
| 885 | "en","US",info,MaxTextExtent); |
| 886 | (void) fprintf(file," Manufacturer: %s\n",info); |
| 887 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en", |
| 888 | "US",info,MaxTextExtent); |
| 889 | (void) fprintf(file," Model: %s\n",info); |
| 890 | (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright, |
| 891 | "en","US",info,MaxTextExtent); |
| 892 | (void) fprintf(file," Copyright: %s\n",info); |
| 893 | #endif |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 894 | (void) cmsCloseProfile(icc_profile); |
| 895 | } |
| 896 | } |
| 897 | #endif |
| 898 | if (LocaleCompare(name,"iptc") == 0) |
| 899 | { |
| 900 | char |
| 901 | *attribute, |
| 902 | **attribute_list; |
| 903 | |
| 904 | const char |
| 905 | *tag; |
| 906 | |
| 907 | long |
| 908 | dataset, |
| 909 | record, |
| 910 | sentinel; |
| 911 | |
| 912 | register long |
| 913 | j; |
| 914 | |
| 915 | size_t |
| 916 | length, |
| 917 | profile_length; |
| 918 | |
| 919 | profile_length=GetStringInfoLength(profile); |
| 920 | for (i=0; i < (long) profile_length; i+=(long) length) |
| 921 | { |
| 922 | length=1; |
| 923 | sentinel=GetStringInfoDatum(profile)[i++]; |
| 924 | if (sentinel != 0x1c) |
| 925 | continue; |
| 926 | dataset=GetStringInfoDatum(profile)[i++]; |
| 927 | record=GetStringInfoDatum(profile)[i++]; |
| 928 | switch (record) |
| 929 | { |
| 930 | case 5: tag="Image Name"; break; |
| 931 | case 7: tag="Edit Status"; break; |
| 932 | case 10: tag="Priority"; break; |
| 933 | case 15: tag="Category"; break; |
| 934 | case 20: tag="Supplemental Category"; break; |
| 935 | case 22: tag="Fixture Identifier"; break; |
| 936 | case 25: tag="Keyword"; break; |
| 937 | case 30: tag="Release Date"; break; |
| 938 | case 35: tag="Release Time"; break; |
| 939 | case 40: tag="Special Instructions"; break; |
| 940 | case 45: tag="Reference Service"; break; |
| 941 | case 47: tag="Reference Date"; break; |
| 942 | case 50: tag="Reference Number"; break; |
| 943 | case 55: tag="Created Date"; break; |
| 944 | case 60: tag="Created Time"; break; |
| 945 | case 65: tag="Originating Program"; break; |
| 946 | case 70: tag="Program Version"; break; |
| 947 | case 75: tag="Object Cycle"; break; |
| 948 | case 80: tag="Byline"; break; |
| 949 | case 85: tag="Byline Title"; break; |
| 950 | case 90: tag="City"; break; |
| 951 | case 95: tag="Province State"; break; |
| 952 | case 100: tag="Country Code"; break; |
| 953 | case 101: tag="Country"; break; |
| 954 | case 103: tag="Original Transmission Reference"; break; |
| 955 | case 105: tag="Headline"; break; |
| 956 | case 110: tag="Credit"; break; |
| 957 | case 115: tag="Src"; break; |
| 958 | case 116: tag="Copyright String"; break; |
| 959 | case 120: tag="Caption"; break; |
| 960 | case 121: tag="Local Caption"; break; |
| 961 | case 122: tag="Caption Writer"; break; |
| 962 | case 200: tag="Custom Field 1"; break; |
| 963 | case 201: tag="Custom Field 2"; break; |
| 964 | case 202: tag="Custom Field 3"; break; |
| 965 | case 203: tag="Custom Field 4"; break; |
| 966 | case 204: tag="Custom Field 5"; break; |
| 967 | case 205: tag="Custom Field 6"; break; |
| 968 | case 206: tag="Custom Field 7"; break; |
| 969 | case 207: tag="Custom Field 8"; break; |
| 970 | case 208: tag="Custom Field 9"; break; |
| 971 | case 209: tag="Custom Field 10"; break; |
| 972 | case 210: tag="Custom Field 11"; break; |
| 973 | case 211: tag="Custom Field 12"; break; |
| 974 | case 212: tag="Custom Field 13"; break; |
| 975 | case 213: tag="Custom Field 14"; break; |
| 976 | case 214: tag="Custom Field 15"; break; |
| 977 | case 215: tag="Custom Field 16"; break; |
| 978 | case 216: tag="Custom Field 17"; break; |
| 979 | case 217: tag="Custom Field 18"; break; |
| 980 | case 218: tag="Custom Field 19"; break; |
| 981 | case 219: tag="Custom Field 20"; break; |
| 982 | default: tag="unknown"; break; |
| 983 | } |
| 984 | (void) fprintf(file," %s[%ld,%ld]: ",tag,dataset,record); |
| 985 | length=(size_t) (GetStringInfoDatum(profile)[i++] << 8); |
| 986 | length|=GetStringInfoDatum(profile)[i++]; |
| 987 | attribute=(char *) NULL; |
| 988 | if (~length >= MaxTextExtent) |
| 989 | attribute=(char *) AcquireQuantumMemory(length+ |
| 990 | MaxTextExtent,sizeof(*attribute)); |
| 991 | if (attribute != (char *) NULL) |
| 992 | { |
| 993 | (void) CopyMagickString(attribute,(char *) |
| 994 | GetStringInfoDatum(profile)+i,length+1); |
| 995 | attribute_list=StringToList(attribute); |
| 996 | if (attribute_list != (char **) NULL) |
| 997 | { |
| 998 | for (j=0; attribute_list[j] != (char *) NULL; j++) |
| 999 | { |
| 1000 | (void) fputs(attribute_list[j],file); |
| 1001 | (void) fputs("\n",file); |
| 1002 | attribute_list[j]=(char *) RelinquishMagickMemory( |
| 1003 | attribute_list[j]); |
| 1004 | } |
| 1005 | attribute_list=(char **) RelinquishMagickMemory( |
| 1006 | attribute_list); |
| 1007 | } |
| 1008 | attribute=DestroyString(attribute); |
| 1009 | } |
| 1010 | } |
| 1011 | } |
| 1012 | if (image->debug != MagickFalse) |
| 1013 | PrintStringInfo(file,name,profile); |
| 1014 | name=GetNextImageProfile(image); |
| 1015 | } |
| 1016 | } |
| 1017 | ResetImageArtifactIterator(image); |
| 1018 | artifact=GetNextImageArtifact(image); |
| 1019 | if (artifact != (const char *) NULL) |
| 1020 | { |
| 1021 | /* |
| 1022 | Display image artifacts. |
| 1023 | */ |
| 1024 | (void) fprintf(file," Artifacts:\n"); |
| 1025 | while (artifact != (const char *) NULL) |
| 1026 | { |
| 1027 | (void) fprintf(file," %c",*artifact); |
| 1028 | if (strlen(artifact) > 1) |
| 1029 | (void) fprintf(file,"%s: ",artifact+1); |
| 1030 | if (strlen(artifact) > 80) |
| 1031 | (void) fputc('\n',file); |
| 1032 | value=GetImageArtifact(image,artifact); |
| 1033 | if (value != (const char *) NULL) |
| 1034 | (void) fprintf(file,"%s\n",value); |
| 1035 | artifact=GetNextImageArtifact(image); |
| 1036 | } |
| 1037 | } |
| 1038 | ResetImageRegistryIterator(); |
| 1039 | registry=GetNextImageRegistry(); |
| 1040 | if (registry != (const char *) NULL) |
| 1041 | { |
| 1042 | /* |
| 1043 | Display image registry. |
| 1044 | */ |
| 1045 | (void) fprintf(file," Registry:\n"); |
| 1046 | while (registry != (const char *) NULL) |
| 1047 | { |
| 1048 | (void) fprintf(file," %c",*registry); |
| 1049 | if (strlen(registry) > 1) |
| 1050 | (void) fprintf(file,"%s: ",registry+1); |
| 1051 | if (strlen(registry) > 80) |
| 1052 | (void) fputc('\n',file); |
| 1053 | value=(const char *) GetImageRegistry(StringRegistryType,registry, |
| 1054 | &image->exception); |
| 1055 | if (value != (const char *) NULL) |
| 1056 | (void) fprintf(file,"%s\n",value); |
| 1057 | registry=GetNextImageRegistry(); |
| 1058 | } |
| 1059 | } |
| 1060 | (void) fprintf(file," Tainted: %s\n",MagickOptionToMnemonic( |
| 1061 | MagickBooleanOptions,(long) image->taint)); |
cristy | b9080c9 | 2009-12-01 20:13:26 +0000 | [diff] [blame] | 1062 | (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format); |
cristy | 2ce15c9 | 2010-03-12 14:03:41 +0000 | [diff] [blame] | 1063 | (void) fprintf(file," Filesize: %sB\n",format); |
cristy | b9080c9 | 2009-12-01 20:13:26 +0000 | [diff] [blame] | 1064 | (void) FormatMagickSize((MagickSizeType) image->columns*image->rows, |
| 1065 | MagickFalse,format); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1066 | (void) fprintf(file," Number pixels: %s\n",format); |
cristy | 3d23169 | 2009-09-29 01:05:22 +0000 | [diff] [blame] | 1067 | (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/ |
cristy | b9080c9 | 2009-12-01 20:13:26 +0000 | [diff] [blame] | 1068 | elapsed_time+0.5),MagickFalse,format); |
cristy | 3d23169 | 2009-09-29 01:05:22 +0000 | [diff] [blame] | 1069 | (void) fprintf(file," Pixels per second: %s\n",format); |
| 1070 | (void) fprintf(file," User time: %0.3fu\n",user_time); |
| 1071 | (void) fprintf(file," Elapsed time: %ld:%02ld.%03ld\n",(long) |
| 1072 | (elapsed_time/60.0),(long) ceil(fmod(elapsed_time,60.0)),(long) |
| 1073 | (1000.0*(elapsed_time-floor(elapsed_time)))); |
| 1074 | (void) fprintf(file," Version: %s\n",GetMagickVersion((unsigned long *) |
| 1075 | NULL)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1076 | (void) fflush(file); |
| 1077 | return(ferror(file) != 0 ? MagickFalse : MagickTrue); |
| 1078 | } |