cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % JJJJJ SSSSS OOO N N % |
| 7 | % J SS O O NN N % |
| 8 | % J SSS O O N N N % |
| 9 | % J J SS O O N NN % |
| 10 | % JJJ SSSSS OOO N N % |
| 11 | % % |
| 12 | % % |
| 13 | % Write Info About the Image in JSON Format. % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % Cristy % |
| 17 | % January 2014 % |
| 18 | % % |
| 19 | % % |
| 20 | % Copyright 1999-2014 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 | % |
| 37 | */ |
| 38 | |
| 39 | /* |
| 40 | Include declarations. |
| 41 | */ |
| 42 | #include "MagickCore/studio.h" |
| 43 | #include "MagickCore/artifact.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 44 | #include "MagickCore/attribute.h" |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 45 | #include "MagickCore/blob.h" |
| 46 | #include "MagickCore/blob-private.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 47 | #include "MagickCore/cache.h" |
cristy | 4360277 | 2014-01-29 14:07:29 +0000 | [diff] [blame] | 48 | #include "MagickCore/colorspace.h" |
| 49 | #include "MagickCore/colorspace-private.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 50 | #include "MagickCore/constitute.h" |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 51 | #include "MagickCore/exception.h" |
| 52 | #include "MagickCore/exception-private.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 53 | #include "MagickCore/feature.h" |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 54 | #include "MagickCore/image.h" |
| 55 | #include "MagickCore/image-private.h" |
| 56 | #include "MagickCore/list.h" |
| 57 | #include "MagickCore/magick.h" |
| 58 | #include "MagickCore/memory_.h" |
| 59 | #include "MagickCore/monitor.h" |
| 60 | #include "MagickCore/monitor-private.h" |
| 61 | #include "MagickCore/option.h" |
cristy | 4360277 | 2014-01-29 14:07:29 +0000 | [diff] [blame] | 62 | #include "MagickCore/pixel.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 63 | #include "MagickCore/pixel-accessor.h" |
cristy | 4360277 | 2014-01-29 14:07:29 +0000 | [diff] [blame] | 64 | #include "MagickCore/pixel-private.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 65 | #include "MagickCore/prepress.h" |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 66 | #include "MagickCore/property.h" |
cristy | 4360277 | 2014-01-29 14:07:29 +0000 | [diff] [blame] | 67 | #include "MagickCore/quantum-private.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 68 | #include "MagickCore/registry.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 69 | #include "MagickCore/signature.h" |
cristy | 4360277 | 2014-01-29 14:07:29 +0000 | [diff] [blame] | 70 | #include "MagickCore/static.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 71 | #include "MagickCore/statistic.h" |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 72 | #include "MagickCore/string_.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 73 | #include "MagickCore/string-private.h" |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 74 | #include "MagickCore/utility.h" |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 75 | #include "MagickCore/version.h" |
cristy | 4360277 | 2014-01-29 14:07:29 +0000 | [diff] [blame] | 76 | #include "MagickCore/module.h" |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 77 | |
| 78 | /* |
| 79 | Forward declarations. |
| 80 | */ |
| 81 | static MagickBooleanType |
| 82 | WriteJSONImage(const ImageInfo *,Image *,ExceptionInfo *); |
| 83 | |
| 84 | /* |
| 85 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 86 | % % |
| 87 | % % |
| 88 | % % |
| 89 | % R e g i s t e r J S O N I m a g e % |
| 90 | % % |
| 91 | % % |
| 92 | % % |
| 93 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 94 | % |
| 95 | % RegisterJSONImage() adds attributes for the JSON image format to |
| 96 | % the list of supported formats. The attributes include the image format |
| 97 | % tag, a method to read and/or write the format, whether the format |
| 98 | % supports the saving of more than one frame to the same file or blob, |
| 99 | % whether the format supports native in-memory I/O, and a brief |
| 100 | % description of the format. |
| 101 | % |
| 102 | % The format of the RegisterJSONImage method is: |
| 103 | % |
| 104 | % size_t RegisterJSONImage(void) |
| 105 | % |
| 106 | */ |
| 107 | ModuleExport size_t RegisterJSONImage(void) |
| 108 | { |
| 109 | MagickInfo |
| 110 | *entry; |
| 111 | |
| 112 | entry=SetMagickInfo("JSON"); |
| 113 | entry->encoder=(EncodeImageHandler *) WriteJSONImage; |
| 114 | entry->blob_support=MagickFalse; |
| 115 | entry->description=ConstantString("The image format and characteristics"); |
| 116 | entry->module=ConstantString("JSON"); |
| 117 | (void) RegisterMagickInfo(entry); |
| 118 | return(MagickImageCoderSignature); |
| 119 | } |
| 120 | |
| 121 | /* |
| 122 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 123 | % % |
| 124 | % % |
| 125 | % % |
| 126 | % U n r e g i s t e r J S O N I m a g e % |
| 127 | % % |
| 128 | % % |
| 129 | % % |
| 130 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 131 | % |
| 132 | % UnregisterJSONImage() removes format registrations made by the |
| 133 | % JSON module from the list of supported formats. |
| 134 | % |
| 135 | % The format of the UnregisterJSONImage method is: |
| 136 | % |
| 137 | % UnregisterJSONImage(void) |
| 138 | % |
| 139 | */ |
| 140 | ModuleExport void UnregisterJSONImage(void) |
| 141 | { |
| 142 | (void) UnregisterMagickInfo("JSON"); |
| 143 | } |
| 144 | |
| 145 | /* |
| 146 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 147 | % % |
| 148 | % % |
| 149 | % % |
| 150 | % W r i t e J S O N I m a g e % |
| 151 | % % |
| 152 | % % |
| 153 | % % |
| 154 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 155 | % |
| 156 | % WriteJSONImage writes the image attributes in the JSON format. |
| 157 | % |
| 158 | % The format of the WriteJSONImage method is: |
| 159 | % |
| 160 | % MagickBooleanType WriteJSONImage(const ImageInfo *image_info, |
| 161 | % Image *image,ExceptionInfo *exception) |
| 162 | % |
| 163 | % A description of each parameter follows. |
| 164 | % |
| 165 | % o image_info: the image info. |
| 166 | % |
| 167 | % o image: The image. |
| 168 | % |
| 169 | % o exception: return any errors or warnings in this structure. |
| 170 | % |
| 171 | */ |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 172 | |
| 173 | static ChannelStatistics *GetLocationStatistics(const Image *image, |
| 174 | const StatisticType type,ExceptionInfo *exception) |
| 175 | { |
| 176 | ChannelStatistics |
| 177 | *channel_statistics; |
| 178 | |
| 179 | register ssize_t |
| 180 | i; |
| 181 | |
| 182 | ssize_t |
| 183 | y; |
| 184 | |
| 185 | assert(image != (Image *) NULL); |
| 186 | assert(image->signature == MagickSignature); |
| 187 | if (image->debug != MagickFalse) |
| 188 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 189 | channel_statistics=(ChannelStatistics *) AcquireQuantumMemory( |
| 190 | MaxPixelChannels+1,sizeof(*channel_statistics)); |
| 191 | if (channel_statistics == (ChannelStatistics *) NULL) |
| 192 | ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); |
| 193 | (void) ResetMagickMemory(channel_statistics,0,(MaxPixelChannels+1)* |
| 194 | sizeof(*channel_statistics)); |
| 195 | for (i=0; i <= (ssize_t) MaxPixelChannels; i++) |
| 196 | { |
| 197 | switch (type) |
| 198 | { |
| 199 | case MaximumStatistic: |
| 200 | default: |
| 201 | { |
cristy | fe181a7 | 2014-02-02 21:17:43 +0000 | [diff] [blame] | 202 | channel_statistics[i].maxima=(-MagickMaximumValue); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 203 | break; |
| 204 | } |
| 205 | case MinimumStatistic: |
| 206 | { |
cristy | fe181a7 | 2014-02-02 21:17:43 +0000 | [diff] [blame] | 207 | channel_statistics[i].minima=MagickMaximumValue; |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 208 | break; |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | for (y=0; y < (ssize_t) image->rows; y++) |
| 213 | { |
| 214 | register const Quantum |
| 215 | *restrict p; |
| 216 | |
| 217 | register ssize_t |
| 218 | x; |
| 219 | |
| 220 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
| 221 | if (p == (const Quantum *) NULL) |
| 222 | break; |
| 223 | for (x=0; x < (ssize_t) image->columns; x++) |
| 224 | { |
| 225 | register ssize_t |
| 226 | i; |
| 227 | |
| 228 | if (GetPixelReadMask(image,p) == 0) |
| 229 | { |
| 230 | p+=GetPixelChannels(image); |
| 231 | continue; |
| 232 | } |
| 233 | for (i=0; i < (ssize_t) GetPixelChannels(image); i++) |
| 234 | { |
| 235 | PixelChannel channel=GetPixelChannelChannel(image,i); |
| 236 | PixelTrait traits=GetPixelChannelTraits(image,channel); |
| 237 | if (traits == UndefinedPixelTrait) |
| 238 | continue; |
| 239 | switch (type) |
| 240 | { |
| 241 | case MaximumStatistic: |
| 242 | default: |
| 243 | { |
| 244 | if ((double) p[i] > channel_statistics[channel].maxima) |
| 245 | channel_statistics[channel].maxima=(double) p[i]; |
| 246 | break; |
| 247 | } |
| 248 | case MinimumStatistic: |
| 249 | { |
| 250 | if ((double) p[i] < channel_statistics[channel].minima) |
| 251 | channel_statistics[channel].minima=(double) p[i]; |
| 252 | break; |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | p+=GetPixelChannels(image); |
| 257 | } |
| 258 | } |
| 259 | return(channel_statistics); |
| 260 | } |
| 261 | |
| 262 | static ssize_t PrintChannelFeatures(FILE *file,const PixelChannel channel, |
| 263 | const char *name,const ChannelFeatures *channel_features) |
| 264 | { |
| 265 | #define PrintFeature(feature) \ |
| 266 | GetMagickPrecision(),(feature)[0], \ |
| 267 | GetMagickPrecision(),(feature)[1], \ |
| 268 | GetMagickPrecision(),(feature)[2], \ |
| 269 | GetMagickPrecision(),(feature)[3], \ |
| 270 | GetMagickPrecision(),((feature)[0]+(feature)[1]+(feature)[2]+(feature)[3])/4.0 \ |
| 271 | |
| 272 | #define FeaturesFormat " %s:\n" \ |
| 273 | " Angular Second Moment:\n" \ |
| 274 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 275 | " Contrast:\n" \ |
| 276 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 277 | " Correlation:\n" \ |
| 278 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 279 | " Sum of Squares: Variance:\n" \ |
| 280 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 281 | " Inverse Difference Moment:\n" \ |
| 282 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 283 | " Sum Average:\n" \ |
| 284 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 285 | " Sum Variance:\n" \ |
| 286 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 287 | " Sum Entropy:\n" \ |
| 288 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 289 | " Entropy:\n" \ |
| 290 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 291 | " Difference Variance:\n" \ |
| 292 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 293 | " Difference Entropy:\n" \ |
| 294 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 295 | " Information Measure of Correlation 1:\n" \ |
| 296 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 297 | " Information Measure of Correlation 2:\n" \ |
| 298 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" \ |
| 299 | " Maximum Correlation Coefficient:\n" \ |
| 300 | " %.*g, %.*g, %.*g, %.*g, %.*g\n" |
| 301 | |
| 302 | ssize_t |
| 303 | n; |
| 304 | |
| 305 | n=FormatLocaleFile(file,FeaturesFormat,name, |
| 306 | PrintFeature(channel_features[channel].angular_second_moment), |
| 307 | PrintFeature(channel_features[channel].contrast), |
| 308 | PrintFeature(channel_features[channel].correlation), |
| 309 | PrintFeature(channel_features[channel].variance_sum_of_squares), |
| 310 | PrintFeature(channel_features[channel].inverse_difference_moment), |
| 311 | PrintFeature(channel_features[channel].sum_average), |
| 312 | PrintFeature(channel_features[channel].sum_variance), |
| 313 | PrintFeature(channel_features[channel].sum_entropy), |
| 314 | PrintFeature(channel_features[channel].entropy), |
| 315 | PrintFeature(channel_features[channel].difference_variance), |
| 316 | PrintFeature(channel_features[channel].difference_entropy), |
| 317 | PrintFeature(channel_features[channel].measure_of_correlation_1), |
| 318 | PrintFeature(channel_features[channel].measure_of_correlation_2), |
| 319 | PrintFeature(channel_features[channel].maximum_correlation_coefficient)); |
| 320 | return(n); |
| 321 | } |
| 322 | |
| 323 | static ssize_t PrintChannelLocations(FILE *file,const Image *image, |
| 324 | const PixelChannel channel,const char *name,const StatisticType type, |
| 325 | const size_t max_locations,const ChannelStatistics *channel_statistics) |
| 326 | { |
| 327 | double |
| 328 | target; |
| 329 | |
| 330 | ExceptionInfo |
| 331 | *exception; |
| 332 | |
| 333 | ssize_t |
| 334 | n, |
| 335 | y; |
| 336 | |
| 337 | switch (type) |
| 338 | { |
| 339 | case MaximumStatistic: |
| 340 | default: |
| 341 | { |
| 342 | target=channel_statistics[channel].maxima; |
| 343 | break; |
| 344 | } |
| 345 | case MinimumStatistic: |
| 346 | { |
| 347 | target=channel_statistics[channel].minima; |
| 348 | break; |
| 349 | } |
| 350 | } |
| 351 | (void) FormatLocaleFile(file," %s: %.*g (%.*g)",name,GetMagickPrecision(), |
| 352 | target,GetMagickPrecision(),QuantumScale*target); |
| 353 | exception=AcquireExceptionInfo(); |
| 354 | n=0; |
| 355 | for (y=0; y < (ssize_t) image->rows; y++) |
| 356 | { |
| 357 | register const Quantum |
| 358 | *p; |
| 359 | |
| 360 | ssize_t |
| 361 | offset, |
| 362 | x; |
| 363 | |
| 364 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
| 365 | if (p == (const Quantum *) NULL) |
| 366 | break; |
| 367 | for (x=0; x < (ssize_t) image->columns; x++) |
| 368 | { |
| 369 | MagickBooleanType |
| 370 | match; |
| 371 | |
| 372 | PixelTrait traits=GetPixelChannelTraits(image,channel); |
| 373 | if (traits == UndefinedPixelTrait) |
| 374 | continue; |
| 375 | offset=GetPixelChannelOffset(image,channel); |
| 376 | match=fabs((double) p[offset]-target) < 0.5 ? MagickTrue : MagickFalse; |
| 377 | if (match != MagickFalse) |
| 378 | { |
| 379 | if ((max_locations != 0) && (n >= (ssize_t) max_locations)) |
| 380 | break; |
| 381 | (void) FormatLocaleFile(file," %.20g,%.20g",(double) x,(double) y); |
| 382 | n++; |
| 383 | } |
| 384 | p+=GetPixelChannels(image); |
| 385 | } |
| 386 | if (x < (ssize_t) image->columns) |
| 387 | break; |
| 388 | } |
| 389 | (void) FormatLocaleFile(file,"\n"); |
| 390 | return(n); |
| 391 | } |
| 392 | |
| 393 | static ssize_t PrintChannelMoments(FILE *file,const PixelChannel channel, |
| 394 | const char *name,const ChannelMoments *channel_moments) |
| 395 | { |
| 396 | register ssize_t |
| 397 | i; |
| 398 | |
| 399 | ssize_t |
| 400 | n; |
| 401 | |
| 402 | n=FormatLocaleFile(file," %s:\n",name); |
| 403 | n+=FormatLocaleFile(file," Centroid: %.*g,%.*g\n", |
| 404 | GetMagickPrecision(),channel_moments[channel].centroid.x, |
| 405 | GetMagickPrecision(),channel_moments[channel].centroid.y); |
| 406 | n+=FormatLocaleFile(file," Ellipse Semi-Major/Minor axis: %.*g,%.*g\n", |
| 407 | GetMagickPrecision(),channel_moments[channel].ellipse_axis.x, |
| 408 | GetMagickPrecision(),channel_moments[channel].ellipse_axis.y); |
| 409 | n+=FormatLocaleFile(file," Ellipse angle: %.*g\n", |
| 410 | GetMagickPrecision(),channel_moments[channel].ellipse_angle); |
| 411 | n+=FormatLocaleFile(file," Ellipse eccentricity: %.*g\n", |
| 412 | GetMagickPrecision(),channel_moments[channel].ellipse_eccentricity); |
| 413 | n+=FormatLocaleFile(file," Ellipse intensity: %.*g\n", |
| 414 | GetMagickPrecision(),channel_moments[channel].ellipse_intensity); |
| 415 | for (i=0; i < 8; i++) |
| 416 | n+=FormatLocaleFile(file," I%.20g: %.*g\n",i+1.0,GetMagickPrecision(), |
cristy | 57f7128 | 2014-10-04 12:32:50 +0000 | [diff] [blame^] | 417 | channel_moments[channel].invariant[i]); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 418 | return(n); |
| 419 | } |
| 420 | |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 421 | static ssize_t PrintChannelPerceptualHash(FILE *file,const ChannelType channel, |
| 422 | const char *name,const MagickBooleanType separator, |
| 423 | const ChannelPerceptualHash *channel_phash) |
| 424 | { |
| 425 | register ssize_t |
| 426 | i; |
| 427 | |
| 428 | ssize_t |
| 429 | n; |
| 430 | |
| 431 | n=FormatLocaleFile(file," \"%s\": {\n",name); |
cristy | 79a41dc | 2014-02-23 21:42:49 +0000 | [diff] [blame] | 432 | for (i=0; i < 6; i++) |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 433 | n+=FormatLocaleFile(file, |
cristy | ff4072b | 2014-02-23 21:47:32 +0000 | [diff] [blame] | 434 | " \"PH%.20g\": [ \"%.*g\", \"%.*g\" ],\n",i+1.0, |
cristy | c018762 | 2014-09-06 00:45:58 +0000 | [diff] [blame] | 435 | GetMagickPrecision(),channel_phash[channel].srgb_hu_phash[i], |
| 436 | GetMagickPrecision(),channel_phash[channel].hclp_hu_phash[i]); |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 437 | n+=FormatLocaleFile(file, |
cristy | ff4072b | 2014-02-23 21:47:32 +0000 | [diff] [blame] | 438 | " \"PH%.20g\": [ \"%.*g\", \"%.*g\" ]\n",i+1.0, |
cristy | c018762 | 2014-09-06 00:45:58 +0000 | [diff] [blame] | 439 | GetMagickPrecision(),channel_phash[channel].srgb_hu_phash[i], |
| 440 | GetMagickPrecision(),channel_phash[channel].hclp_hu_phash[i]); |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 441 | (void) FormatLocaleFile(file," }"); |
| 442 | if (separator != MagickFalse) |
| 443 | (void) FormatLocaleFile(file,","); |
| 444 | (void) FormatLocaleFile(file,"\n"); |
| 445 | return(n); |
| 446 | } |
| 447 | |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 448 | static ssize_t PrintChannelStatistics(FILE *file,const PixelChannel channel, |
| 449 | const char *name,const double scale, |
| 450 | const ChannelStatistics *channel_statistics) |
| 451 | { |
| 452 | #define StatisticsFormat " %s:\n min: " QuantumFormat \ |
| 453 | " (%g)\n max: " QuantumFormat " (%g)\n" \ |
| 454 | " mean: %g (%g)\n standard deviation: %g (%g)\n" \ |
| 455 | " kurtosis: %g\n skewness: %g\n" |
| 456 | |
| 457 | ssize_t |
| 458 | n; |
| 459 | |
| 460 | n=FormatLocaleFile(file,StatisticsFormat,name,ClampToQuantum(scale* |
| 461 | channel_statistics[channel].minima),channel_statistics[channel].minima/ |
| 462 | (double) QuantumRange,ClampToQuantum(scale* |
| 463 | channel_statistics[channel].maxima),channel_statistics[channel].maxima/ |
| 464 | (double) QuantumRange,scale*channel_statistics[channel].mean, |
| 465 | channel_statistics[channel].mean/(double) QuantumRange,scale* |
| 466 | channel_statistics[channel].standard_deviation, |
| 467 | channel_statistics[channel].standard_deviation/(double) QuantumRange, |
| 468 | channel_statistics[channel].kurtosis,channel_statistics[channel].skewness); |
| 469 | return(n); |
| 470 | } |
| 471 | |
| 472 | static MagickBooleanType EncodeImageAttributes(Image *image,FILE *file, |
| 473 | ExceptionInfo *exception) |
| 474 | { |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 475 | char |
| 476 | color[MaxTextExtent], |
| 477 | format[MaxTextExtent], |
| 478 | key[MaxTextExtent]; |
| 479 | |
| 480 | ChannelFeatures |
| 481 | *channel_features; |
| 482 | |
| 483 | ChannelMoments |
| 484 | *channel_moments; |
| 485 | |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 486 | ChannelPerceptualHash |
| 487 | *channel_phash; |
| 488 | |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 489 | ChannelStatistics |
| 490 | *channel_statistics; |
| 491 | |
| 492 | ColorspaceType |
| 493 | colorspace; |
| 494 | |
| 495 | const char |
| 496 | *artifact, |
| 497 | *locate, |
| 498 | *name, |
| 499 | *property, |
| 500 | *registry, |
| 501 | *value; |
| 502 | |
| 503 | const MagickInfo |
| 504 | *magick_info; |
| 505 | |
| 506 | double |
| 507 | elapsed_time, |
| 508 | user_time; |
| 509 | |
| 510 | ImageType |
| 511 | type; |
| 512 | |
| 513 | MagickBooleanType |
| 514 | ping; |
| 515 | |
| 516 | register const Quantum |
| 517 | *p; |
| 518 | |
| 519 | register ssize_t |
| 520 | i, |
| 521 | x; |
| 522 | |
| 523 | size_t |
| 524 | distance, |
| 525 | scale; |
| 526 | |
| 527 | ssize_t |
| 528 | y; |
| 529 | |
| 530 | assert(image != (Image *) NULL); |
| 531 | assert(image->signature == MagickSignature); |
| 532 | if (image->debug != MagickFalse) |
| 533 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 534 | if (file == (FILE *) NULL) |
| 535 | file=stdout; |
cristy | a10f744 | 2014-01-19 18:32:15 +0000 | [diff] [blame] | 536 | *format='\0'; |
| 537 | elapsed_time=GetElapsedTime(&image->timer); |
| 538 | user_time=GetUserTime(&image->timer); |
| 539 | GetTimerInfo(&image->timer); |
| 540 | p=GetVirtualPixels(image,0,0,1,1,exception); |
| 541 | ping=p == (const Quantum *) NULL ? MagickTrue : MagickFalse; |
| 542 | type=GetImageType(image,exception); |
| 543 | (void) SignatureImage(image,exception); |
| 544 | (void) FormatLocaleFile(file,"Image: %s\n",image->filename); |
| 545 | if (*image->magick_filename != '\0') |
| 546 | if (LocaleCompare(image->magick_filename,image->filename) != 0) |
| 547 | { |
| 548 | char |
| 549 | filename[MaxTextExtent]; |
| 550 | |
| 551 | GetPathComponent(image->magick_filename,TailPath,filename); |
| 552 | (void) FormatLocaleFile(file," Base filename: %s\n",filename); |
| 553 | } |
| 554 | magick_info=GetMagickInfo(image->magick,exception); |
| 555 | if ((magick_info == (const MagickInfo *) NULL) || |
| 556 | (GetMagickDescription(magick_info) == (const char *) NULL)) |
| 557 | (void) FormatLocaleFile(file," Format: %s\n",image->magick); |
| 558 | else |
| 559 | (void) FormatLocaleFile(file," Format: %s (%s)\n",image->magick, |
| 560 | GetMagickDescription(magick_info)); |
| 561 | if ((magick_info == (const MagickInfo *) NULL) || |
| 562 | (GetMagickMimeType(magick_info) != (const char *) NULL)) |
| 563 | (void) FormatLocaleFile(file," Mime type: %s\n",GetMagickMimeType( |
| 564 | magick_info)); |
| 565 | (void) FormatLocaleFile(file," Class: %s\n",CommandOptionToMnemonic( |
| 566 | MagickClassOptions,(ssize_t) image->storage_class)); |
| 567 | (void) FormatLocaleFile(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double) |
| 568 | image->columns,(double) image->rows,(double) image->tile_offset.x,(double) |
| 569 | image->tile_offset.y); |
| 570 | if ((image->magick_columns != 0) || (image->magick_rows != 0)) |
| 571 | if ((image->magick_columns != image->columns) || |
| 572 | (image->magick_rows != image->rows)) |
| 573 | (void) FormatLocaleFile(file," Base geometry: %.20gx%.20g\n",(double) |
| 574 | image->magick_columns,(double) image->magick_rows); |
| 575 | if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0)) |
| 576 | { |
| 577 | (void) FormatLocaleFile(file," Resolution: %gx%g\n",image->resolution.x, |
| 578 | image->resolution.y); |
| 579 | (void) FormatLocaleFile(file," Print size: %gx%g\n",(double) |
| 580 | image->columns/image->resolution.x,(double) image->rows/ |
| 581 | image->resolution.y); |
| 582 | } |
| 583 | (void) FormatLocaleFile(file," Units: %s\n",CommandOptionToMnemonic( |
| 584 | MagickResolutionOptions,(ssize_t) image->units)); |
| 585 | (void) FormatLocaleFile(file," Type: %s\n",CommandOptionToMnemonic( |
| 586 | MagickTypeOptions,(ssize_t) type)); |
| 587 | if (image->type != UndefinedType) |
| 588 | (void) FormatLocaleFile(file," Base type: %s\n",CommandOptionToMnemonic( |
| 589 | MagickTypeOptions,(ssize_t) image->type)); |
| 590 | (void) FormatLocaleFile(file," Endianess: %s\n",CommandOptionToMnemonic( |
| 591 | MagickEndianOptions,(ssize_t) image->endian)); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 592 | locate=GetImageArtifact(image,"identify:locate"); |
cristy | 3e583dd | 2014-01-19 14:11:51 +0000 | [diff] [blame] | 593 | if (locate == (const char *) NULL) |
| 594 | locate=GetImageArtifact(image,"json:locate"); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 595 | if (locate != (const char *) NULL) |
| 596 | { |
| 597 | const char |
| 598 | *limit; |
| 599 | |
| 600 | size_t |
| 601 | max_locations; |
| 602 | |
| 603 | StatisticType |
| 604 | type; |
| 605 | |
| 606 | /* |
| 607 | Display minimum, maximum, or mean pixel locations. |
| 608 | */ |
| 609 | type=(StatisticType) ParseCommandOption(MagickStatisticOptions, |
| 610 | MagickFalse,locate); |
| 611 | limit=GetImageArtifact(image,"identify:limit"); |
cristy | 3e583dd | 2014-01-19 14:11:51 +0000 | [diff] [blame] | 612 | if (limit == (const char *) NULL) |
| 613 | limit=GetImageArtifact(image,"json:limit"); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 614 | max_locations=0; |
| 615 | if (limit != (const char *) NULL) |
| 616 | max_locations=StringToUnsignedLong(limit); |
| 617 | channel_statistics=GetLocationStatistics(image,type,exception); |
| 618 | if (channel_statistics == (ChannelStatistics *) NULL) |
| 619 | return(MagickFalse); |
| 620 | colorspace=image->colorspace; |
| 621 | if (IsImageGray(image,exception) != MagickFalse) |
| 622 | colorspace=GRAYColorspace; |
| 623 | (void) FormatLocaleFile(file,"Channel %s locations:\n",locate); |
| 624 | switch (colorspace) |
| 625 | { |
| 626 | case RGBColorspace: |
| 627 | default: |
| 628 | { |
| 629 | (void) PrintChannelLocations(file,image,RedPixelChannel,"Red", |
| 630 | type,max_locations,channel_statistics); |
| 631 | (void) PrintChannelLocations(file,image,GreenPixelChannel,"Green", |
| 632 | type,max_locations,channel_statistics); |
| 633 | (void) PrintChannelLocations(file,image,BluePixelChannel,"Blue", |
| 634 | type,max_locations,channel_statistics); |
| 635 | break; |
| 636 | } |
| 637 | case CMYKColorspace: |
| 638 | { |
| 639 | (void) PrintChannelLocations(file,image,CyanPixelChannel,"Cyan", |
| 640 | type,max_locations,channel_statistics); |
| 641 | (void) PrintChannelLocations(file,image,MagentaPixelChannel,"Magenta", |
| 642 | type,max_locations,channel_statistics); |
| 643 | (void) PrintChannelLocations(file,image,YellowPixelChannel,"Yellow", |
| 644 | type,max_locations,channel_statistics); |
| 645 | (void) PrintChannelLocations(file,image,BlackPixelChannel,"Black", |
| 646 | type,max_locations,channel_statistics); |
| 647 | break; |
| 648 | } |
| 649 | case GRAYColorspace: |
| 650 | { |
| 651 | (void) PrintChannelLocations(file,image,GrayPixelChannel,"Gray", |
| 652 | type,max_locations,channel_statistics); |
| 653 | break; |
| 654 | } |
| 655 | } |
| 656 | if (image->alpha_trait == BlendPixelTrait) |
| 657 | (void) PrintChannelLocations(file,image,AlphaPixelChannel,"Alpha", |
| 658 | type,max_locations,channel_statistics); |
| 659 | channel_statistics=(ChannelStatistics *) RelinquishMagickMemory( |
| 660 | channel_statistics); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 661 | } |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 662 | /* |
| 663 | Detail channel depth and extrema. |
| 664 | */ |
| 665 | (void) FormatLocaleFile(file," Colorspace: %s\n",CommandOptionToMnemonic( |
| 666 | MagickColorspaceOptions,(ssize_t) image->colorspace)); |
| 667 | channel_statistics=(ChannelStatistics *) NULL; |
| 668 | channel_moments=(ChannelMoments *) NULL; |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 669 | channel_phash=(ChannelPerceptualHash *) NULL; |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 670 | channel_features=(ChannelFeatures *) NULL; |
| 671 | colorspace=image->colorspace; |
| 672 | scale=1; |
| 673 | if (ping == MagickFalse) |
| 674 | { |
| 675 | size_t |
| 676 | depth; |
| 677 | |
| 678 | channel_statistics=GetImageStatistics(image,exception); |
| 679 | if (channel_statistics == (ChannelStatistics *) NULL) |
| 680 | return(MagickFalse); |
| 681 | artifact=GetImageArtifact(image,"identify:moments"); |
cristy | 3e583dd | 2014-01-19 14:11:51 +0000 | [diff] [blame] | 682 | if (artifact == (const char *) NULL) |
| 683 | artifact=GetImageArtifact(image,"json:moments"); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 684 | if (artifact != (const char *) NULL) |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 685 | { |
| 686 | channel_moments=GetImageMoments(image,exception); |
| 687 | channel_phash=GetImagePerceptualHash(image,exception); |
| 688 | } |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 689 | artifact=GetImageArtifact(image,"identify:features"); |
cristy | 3e583dd | 2014-01-19 14:11:51 +0000 | [diff] [blame] | 690 | if (artifact == (const char *) NULL) |
| 691 | artifact=GetImageArtifact(image,"json:features"); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 692 | if (artifact != (const char *) NULL) |
| 693 | { |
| 694 | distance=StringToUnsignedLong(artifact); |
| 695 | channel_features=GetImageFeatures(image,distance,exception); |
| 696 | } |
| 697 | depth=GetImageDepth(image,exception); |
| 698 | if (image->depth == depth) |
| 699 | (void) FormatLocaleFile(file," Depth: %.20g-bit\n",(double) |
| 700 | image->depth); |
| 701 | else |
| 702 | (void) FormatLocaleFile(file," Depth: %.20g/%.20g-bit\n",(double) |
| 703 | image->depth,(double) depth); |
| 704 | (void) FormatLocaleFile(file," Channel depth:\n"); |
| 705 | if (IsImageGray(image,exception) != MagickFalse) |
| 706 | colorspace=GRAYColorspace; |
| 707 | switch (colorspace) |
| 708 | { |
| 709 | case RGBColorspace: |
| 710 | default: |
| 711 | { |
| 712 | (void) FormatLocaleFile(file," Red: %.20g-bit\n",(double) |
| 713 | channel_statistics[RedPixelChannel].depth); |
| 714 | (void) FormatLocaleFile(file," Green: %.20g-bit\n",(double) |
| 715 | channel_statistics[GreenPixelChannel].depth); |
| 716 | (void) FormatLocaleFile(file," Blue: %.20g-bit\n",(double) |
| 717 | channel_statistics[BluePixelChannel].depth); |
| 718 | break; |
| 719 | } |
| 720 | case CMYKColorspace: |
| 721 | { |
| 722 | (void) FormatLocaleFile(file," Cyan: %.20g-bit\n",(double) |
| 723 | channel_statistics[CyanPixelChannel].depth); |
| 724 | (void) FormatLocaleFile(file," Magenta: %.20g-bit\n",(double) |
| 725 | channel_statistics[MagentaPixelChannel].depth); |
| 726 | (void) FormatLocaleFile(file," Yellow: %.20g-bit\n",(double) |
| 727 | channel_statistics[YellowPixelChannel].depth); |
| 728 | (void) FormatLocaleFile(file," Black: %.20g-bit\n",(double) |
| 729 | channel_statistics[BlackPixelChannel].depth); |
| 730 | break; |
| 731 | } |
| 732 | case GRAYColorspace: |
| 733 | { |
| 734 | (void) FormatLocaleFile(file," Gray: %.20g-bit\n",(double) |
| 735 | channel_statistics[GrayPixelChannel].depth); |
| 736 | break; |
| 737 | } |
| 738 | } |
| 739 | if (image->alpha_trait == BlendPixelTrait) |
| 740 | (void) FormatLocaleFile(file," alpha: %.20g-bit\n",(double) |
| 741 | channel_statistics[AlphaPixelChannel].depth); |
| 742 | scale=1; |
| 743 | if (image->depth <= MAGICKCORE_QUANTUM_DEPTH) |
| 744 | scale=QuantumRange/((size_t) QuantumRange >> ((size_t) |
| 745 | MAGICKCORE_QUANTUM_DEPTH-image->depth)); |
| 746 | } |
| 747 | if (channel_statistics != (ChannelStatistics *) NULL) |
| 748 | { |
| 749 | (void) FormatLocaleFile(file," Channel statistics:\n"); |
| 750 | (void) FormatLocaleFile(file," Pixels: %.20g\n", |
| 751 | channel_statistics[CompositePixelChannel].area); |
| 752 | switch (colorspace) |
| 753 | { |
| 754 | case RGBColorspace: |
| 755 | default: |
| 756 | { |
| 757 | (void) PrintChannelStatistics(file,RedPixelChannel,"Red",1.0/ |
| 758 | scale,channel_statistics); |
| 759 | (void) PrintChannelStatistics(file,GreenPixelChannel,"Green",1.0/ |
| 760 | scale,channel_statistics); |
| 761 | (void) PrintChannelStatistics(file,BluePixelChannel,"Blue",1.0/ |
| 762 | scale,channel_statistics); |
| 763 | break; |
| 764 | } |
| 765 | case CMYKColorspace: |
| 766 | { |
| 767 | (void) PrintChannelStatistics(file,CyanPixelChannel,"Cyan",1.0/ |
| 768 | scale,channel_statistics); |
| 769 | (void) PrintChannelStatistics(file,MagentaPixelChannel,"Magenta",1.0/ |
| 770 | scale,channel_statistics); |
| 771 | (void) PrintChannelStatistics(file,YellowPixelChannel,"Yellow",1.0/ |
| 772 | scale,channel_statistics); |
| 773 | (void) PrintChannelStatistics(file,BlackPixelChannel,"Black",1.0/ |
| 774 | scale,channel_statistics); |
| 775 | break; |
| 776 | } |
| 777 | case GRAYColorspace: |
| 778 | { |
| 779 | (void) PrintChannelStatistics(file,GrayPixelChannel,"Gray",1.0/ |
| 780 | scale,channel_statistics); |
| 781 | break; |
| 782 | } |
| 783 | } |
| 784 | if (image->alpha_trait == BlendPixelTrait) |
| 785 | (void) PrintChannelStatistics(file,AlphaPixelChannel,"Alpha",1.0/ |
| 786 | scale,channel_statistics); |
| 787 | if (colorspace != GRAYColorspace) |
| 788 | { |
| 789 | (void) FormatLocaleFile(file," Image statistics:\n"); |
| 790 | (void) PrintChannelStatistics(file,(PixelChannel) MaxPixelChannels, |
| 791 | "Overall",1.0/scale,channel_statistics); |
| 792 | } |
| 793 | channel_statistics=(ChannelStatistics *) RelinquishMagickMemory( |
| 794 | channel_statistics); |
| 795 | } |
| 796 | if (channel_moments != (ChannelMoments *) NULL) |
| 797 | { |
| 798 | (void) FormatLocaleFile(file," Channel moments:\n"); |
| 799 | switch (colorspace) |
| 800 | { |
| 801 | case RGBColorspace: |
| 802 | default: |
| 803 | { |
| 804 | (void) PrintChannelMoments(file,RedPixelChannel,"Red", |
| 805 | channel_moments); |
| 806 | (void) PrintChannelMoments(file,GreenPixelChannel,"Green", |
| 807 | channel_moments); |
| 808 | (void) PrintChannelMoments(file,BluePixelChannel,"Blue", |
| 809 | channel_moments); |
| 810 | break; |
| 811 | } |
| 812 | case CMYKColorspace: |
| 813 | { |
| 814 | (void) PrintChannelMoments(file,CyanPixelChannel,"Cyan", |
| 815 | channel_moments); |
| 816 | (void) PrintChannelMoments(file,MagentaPixelChannel,"Magenta", |
| 817 | channel_moments); |
| 818 | (void) PrintChannelMoments(file,YellowPixelChannel,"Yellow", |
| 819 | channel_moments); |
| 820 | (void) PrintChannelMoments(file,BlackPixelChannel,"Black", |
| 821 | channel_moments); |
| 822 | break; |
| 823 | } |
| 824 | case GRAYColorspace: |
| 825 | { |
| 826 | (void) PrintChannelMoments(file,GrayPixelChannel,"Gray", |
| 827 | channel_moments); |
| 828 | break; |
| 829 | } |
| 830 | } |
| 831 | if (image->alpha_trait == BlendPixelTrait) |
| 832 | (void) PrintChannelMoments(file,AlphaPixelChannel,"Alpha", |
| 833 | channel_moments); |
| 834 | channel_moments=(ChannelMoments *) RelinquishMagickMemory( |
| 835 | channel_moments); |
| 836 | } |
cristy | dc39517 | 2014-02-23 01:33:36 +0000 | [diff] [blame] | 837 | if (channel_phash != (ChannelPerceptualHash *) NULL) |
| 838 | { |
| 839 | (void) FormatLocaleFile(file," \"channelPerceptualHash\": {\n"); |
| 840 | if (image->alpha_trait == BlendPixelTrait) |
| 841 | (void) PrintChannelPerceptualHash(file,AlphaChannel,"alphaAlpha", |
| 842 | MagickTrue,channel_phash); |
| 843 | (void) PrintChannelPerceptualHash(file,RedChannel,"redHue",MagickTrue, |
| 844 | channel_phash); |
| 845 | (void) PrintChannelPerceptualHash(file,GreenChannel,"greenChroma", |
| 846 | MagickTrue,channel_phash); |
| 847 | (void) PrintChannelPerceptualHash(file,BlueChannel,"blueLuma",MagickFalse, |
| 848 | channel_phash); |
| 849 | (void) FormatLocaleFile(file," },\n"); |
| 850 | channel_phash=(ChannelPerceptualHash *) RelinquishMagickMemory( |
| 851 | channel_phash); |
| 852 | } |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 853 | if (channel_features != (ChannelFeatures *) NULL) |
| 854 | { |
| 855 | (void) FormatLocaleFile(file," Channel features (horizontal, vertical, " |
| 856 | "left and right diagonals, average):\n"); |
| 857 | switch (colorspace) |
| 858 | { |
| 859 | case RGBColorspace: |
| 860 | default: |
| 861 | { |
| 862 | (void) PrintChannelFeatures(file,RedPixelChannel,"Red", |
| 863 | channel_features); |
| 864 | (void) PrintChannelFeatures(file,GreenPixelChannel,"Green", |
| 865 | channel_features); |
| 866 | (void) PrintChannelFeatures(file,BluePixelChannel,"Blue", |
| 867 | channel_features); |
| 868 | break; |
| 869 | } |
| 870 | case CMYKColorspace: |
| 871 | { |
| 872 | (void) PrintChannelFeatures(file,CyanPixelChannel,"Cyan", |
| 873 | channel_features); |
| 874 | (void) PrintChannelFeatures(file,MagentaPixelChannel,"Magenta", |
| 875 | channel_features); |
| 876 | (void) PrintChannelFeatures(file,YellowPixelChannel,"Yellow", |
| 877 | channel_features); |
| 878 | (void) PrintChannelFeatures(file,BlackPixelChannel,"Black", |
| 879 | channel_features); |
| 880 | break; |
| 881 | } |
| 882 | case GRAYColorspace: |
| 883 | { |
| 884 | (void) PrintChannelFeatures(file,GrayPixelChannel,"Gray", |
| 885 | channel_features); |
| 886 | break; |
| 887 | } |
| 888 | } |
| 889 | if (image->alpha_trait == BlendPixelTrait) |
| 890 | (void) PrintChannelFeatures(file,AlphaPixelChannel,"Alpha", |
| 891 | channel_features); |
| 892 | channel_features=(ChannelFeatures *) RelinquishMagickMemory( |
| 893 | channel_features); |
| 894 | } |
| 895 | if (ping == MagickFalse) |
| 896 | { |
| 897 | if (image->colorspace == CMYKColorspace) |
| 898 | (void) FormatLocaleFile(file," Total ink density: %.0f%%\n",100.0* |
| 899 | GetImageTotalInkDensity(image,exception)/(double) QuantumRange); |
| 900 | x=0; |
| 901 | if (image->alpha_trait == BlendPixelTrait) |
| 902 | { |
| 903 | register const Quantum |
| 904 | *p; |
| 905 | |
| 906 | p=(const Quantum *) NULL; |
| 907 | for (y=0; y < (ssize_t) image->rows; y++) |
| 908 | { |
| 909 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
| 910 | if (p == (const Quantum *) NULL) |
| 911 | break; |
| 912 | for (x=0; x < (ssize_t) image->columns; x++) |
| 913 | { |
| 914 | if (GetPixelAlpha(image,p) == (Quantum) TransparentAlpha) |
| 915 | break; |
| 916 | p+=GetPixelChannels(image); |
| 917 | } |
| 918 | if (x < (ssize_t) image->columns) |
| 919 | break; |
| 920 | } |
| 921 | if ((x < (ssize_t) image->columns) || (y < (ssize_t) image->rows)) |
| 922 | { |
| 923 | char |
| 924 | tuple[MaxTextExtent]; |
| 925 | |
| 926 | PixelInfo |
| 927 | pixel; |
| 928 | |
| 929 | GetPixelInfo(image,&pixel); |
| 930 | GetPixelInfoPixel(image,p,&pixel); |
| 931 | (void) QueryColorname(image,&pixel,SVGCompliance,tuple, |
| 932 | exception); |
| 933 | (void) FormatLocaleFile(file," Alpha: %s ",tuple); |
| 934 | GetColorTuple(&pixel,MagickTrue,tuple); |
| 935 | (void) FormatLocaleFile(file," %s\n",tuple); |
| 936 | } |
| 937 | } |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 938 | } |
| 939 | if (image->storage_class == PseudoClass) |
| 940 | { |
| 941 | (void) FormatLocaleFile(file," Colormap entries: %.20g\n",(double) |
| 942 | image->colors); |
| 943 | (void) FormatLocaleFile(file," Colormap:\n"); |
| 944 | if (image->colors <= 1024) |
| 945 | { |
| 946 | char |
| 947 | color[MaxTextExtent], |
| 948 | hex[MaxTextExtent], |
| 949 | tuple[MaxTextExtent]; |
| 950 | |
| 951 | PixelInfo |
| 952 | pixel; |
| 953 | |
| 954 | register PixelInfo |
| 955 | *restrict p; |
| 956 | |
| 957 | GetPixelInfo(image,&pixel); |
| 958 | p=image->colormap; |
| 959 | for (i=0; i < (ssize_t) image->colors; i++) |
| 960 | { |
| 961 | pixel=(*p); |
| 962 | (void) CopyMagickString(tuple,"(",MaxTextExtent); |
| 963 | ConcatenateColorComponent(&pixel,RedPixelChannel,X11Compliance, |
| 964 | tuple); |
| 965 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 966 | ConcatenateColorComponent(&pixel,GreenPixelChannel,X11Compliance, |
| 967 | tuple); |
| 968 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 969 | ConcatenateColorComponent(&pixel,BluePixelChannel,X11Compliance, |
| 970 | tuple); |
| 971 | if (pixel.colorspace == CMYKColorspace) |
| 972 | { |
| 973 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 974 | ConcatenateColorComponent(&pixel,BlackPixelChannel, |
| 975 | X11Compliance,tuple); |
| 976 | } |
| 977 | if (pixel.alpha_trait == BlendPixelTrait) |
| 978 | { |
| 979 | (void) ConcatenateMagickString(tuple,",",MaxTextExtent); |
| 980 | ConcatenateColorComponent(&pixel,AlphaPixelChannel, |
| 981 | X11Compliance,tuple); |
| 982 | } |
| 983 | (void) ConcatenateMagickString(tuple,")",MaxTextExtent); |
| 984 | (void) QueryColorname(image,&pixel,SVGCompliance,color, |
| 985 | exception); |
| 986 | GetColorTuple(&pixel,MagickTrue,hex); |
| 987 | (void) FormatLocaleFile(file," %8ld: %s %s %s\n",(long) i,tuple, |
| 988 | hex,color); |
| 989 | p++; |
| 990 | } |
| 991 | } |
| 992 | } |
| 993 | if (image->error.mean_error_per_pixel != 0.0) |
| 994 | (void) FormatLocaleFile(file," Mean error per pixel: %g\n", |
| 995 | image->error.mean_error_per_pixel); |
| 996 | if (image->error.normalized_mean_error != 0.0) |
| 997 | (void) FormatLocaleFile(file," Normalized mean error: %g\n", |
| 998 | image->error.normalized_mean_error); |
| 999 | if (image->error.normalized_maximum_error != 0.0) |
| 1000 | (void) FormatLocaleFile(file," Normalized maximum error: %g\n", |
| 1001 | image->error.normalized_maximum_error); |
| 1002 | (void) FormatLocaleFile(file," Rendering intent: %s\n", |
| 1003 | CommandOptionToMnemonic(MagickIntentOptions,(ssize_t) |
| 1004 | image->rendering_intent)); |
| 1005 | if (image->gamma != 0.0) |
| 1006 | (void) FormatLocaleFile(file," Gamma: %g\n",image->gamma); |
| 1007 | if ((image->chromaticity.red_primary.x != 0.0) || |
| 1008 | (image->chromaticity.green_primary.x != 0.0) || |
| 1009 | (image->chromaticity.blue_primary.x != 0.0) || |
| 1010 | (image->chromaticity.white_point.x != 0.0)) |
| 1011 | { |
| 1012 | /* |
| 1013 | Display image chromaticity. |
| 1014 | */ |
| 1015 | (void) FormatLocaleFile(file," Chromaticity:\n"); |
| 1016 | (void) FormatLocaleFile(file," red primary: (%g,%g)\n", |
| 1017 | image->chromaticity.red_primary.x,image->chromaticity.red_primary.y); |
| 1018 | (void) FormatLocaleFile(file," green primary: (%g,%g)\n", |
| 1019 | image->chromaticity.green_primary.x, |
| 1020 | image->chromaticity.green_primary.y); |
| 1021 | (void) FormatLocaleFile(file," blue primary: (%g,%g)\n", |
| 1022 | image->chromaticity.blue_primary.x,image->chromaticity.blue_primary.y); |
| 1023 | (void) FormatLocaleFile(file," white point: (%g,%g)\n", |
| 1024 | image->chromaticity.white_point.x,image->chromaticity.white_point.y); |
| 1025 | } |
| 1026 | if ((image->extract_info.width*image->extract_info.height) != 0) |
| 1027 | (void) FormatLocaleFile(file," Tile geometry: %.20gx%.20g%+.20g%+.20g\n", |
| 1028 | (double) image->extract_info.width,(double) image->extract_info.height, |
| 1029 | (double) image->extract_info.x,(double) image->extract_info.y); |
| 1030 | (void) QueryColorname(image,&image->background_color,SVGCompliance,color, |
| 1031 | exception); |
| 1032 | (void) FormatLocaleFile(file," Background color: %s\n",color); |
| 1033 | (void) QueryColorname(image,&image->border_color,SVGCompliance,color, |
| 1034 | exception); |
| 1035 | (void) FormatLocaleFile(file," Border color: %s\n",color); |
| 1036 | (void) QueryColorname(image,&image->matte_color,SVGCompliance,color, |
| 1037 | exception); |
| 1038 | (void) FormatLocaleFile(file," Matte color: %s\n",color); |
| 1039 | (void) QueryColorname(image,&image->transparent_color,SVGCompliance,color, |
| 1040 | exception); |
| 1041 | (void) FormatLocaleFile(file," Transparent color: %s\n",color); |
| 1042 | (void) FormatLocaleFile(file," Interlace: %s\n",CommandOptionToMnemonic( |
| 1043 | MagickInterlaceOptions,(ssize_t) image->interlace)); |
| 1044 | (void) FormatLocaleFile(file," Intensity: %s\n",CommandOptionToMnemonic( |
| 1045 | MagickPixelIntensityOptions,(ssize_t) image->intensity)); |
| 1046 | (void) FormatLocaleFile(file," Compose: %s\n",CommandOptionToMnemonic( |
| 1047 | MagickComposeOptions,(ssize_t) image->compose)); |
| 1048 | if ((image->page.width != 0) || (image->page.height != 0) || |
| 1049 | (image->page.x != 0) || (image->page.y != 0)) |
| 1050 | (void) FormatLocaleFile(file," Page geometry: %.20gx%.20g%+.20g%+.20g\n", |
| 1051 | (double) image->page.width,(double) image->page.height,(double) |
| 1052 | image->page.x,(double) image->page.y); |
| 1053 | if ((image->page.x != 0) || (image->page.y != 0)) |
| 1054 | (void) FormatLocaleFile(file," Origin geometry: %+.20g%+.20g\n",(double) |
| 1055 | image->page.x,(double) image->page.y); |
| 1056 | (void) FormatLocaleFile(file," Dispose: %s\n",CommandOptionToMnemonic( |
| 1057 | MagickDisposeOptions,(ssize_t) image->dispose)); |
| 1058 | if (image->delay != 0) |
| 1059 | (void) FormatLocaleFile(file," Delay: %.20gx%.20g\n",(double) image->delay, |
| 1060 | (double) image->ticks_per_second); |
| 1061 | if (image->iterations != 1) |
| 1062 | (void) FormatLocaleFile(file," Iterations: %.20g\n",(double) |
| 1063 | image->iterations); |
| 1064 | if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL)) |
| 1065 | (void) FormatLocaleFile(file," Scene: %.20g of %.20g\n",(double) |
| 1066 | image->scene,(double) GetImageListLength(image)); |
| 1067 | else |
| 1068 | if (image->scene != 0) |
| 1069 | (void) FormatLocaleFile(file," Scene: %.20g\n",(double) image->scene); |
| 1070 | (void) FormatLocaleFile(file," Compression: %s\n",CommandOptionToMnemonic( |
| 1071 | MagickCompressOptions,(ssize_t) image->compression)); |
| 1072 | if (image->quality != UndefinedCompressionQuality) |
| 1073 | (void) FormatLocaleFile(file," Quality: %.20g\n",(double) image->quality); |
| 1074 | (void) FormatLocaleFile(file," Orientation: %s\n",CommandOptionToMnemonic( |
| 1075 | MagickOrientationOptions,(ssize_t) image->orientation)); |
| 1076 | if (image->montage != (char *) NULL) |
| 1077 | (void) FormatLocaleFile(file," Montage: %s\n",image->montage); |
| 1078 | if (image->directory != (char *) NULL) |
| 1079 | { |
| 1080 | Image |
| 1081 | *tile; |
| 1082 | |
| 1083 | ImageInfo |
| 1084 | *image_info; |
| 1085 | |
| 1086 | register char |
| 1087 | *p, |
| 1088 | *q; |
| 1089 | |
| 1090 | WarningHandler |
| 1091 | handler; |
| 1092 | |
| 1093 | /* |
| 1094 | Display visual image directory. |
| 1095 | */ |
| 1096 | image_info=AcquireImageInfo(); |
| 1097 | (void) CloneString(&image_info->size,"64x64"); |
| 1098 | (void) FormatLocaleFile(file," Directory:\n"); |
| 1099 | for (p=image->directory; *p != '\0'; p++) |
| 1100 | { |
| 1101 | q=p; |
| 1102 | while ((*q != '\n') && (*q != '\0')) |
| 1103 | q++; |
| 1104 | (void) CopyMagickString(image_info->filename,p,(size_t) (q-p+1)); |
| 1105 | p=q; |
| 1106 | (void) FormatLocaleFile(file," %s",image_info->filename); |
| 1107 | handler=SetWarningHandler((WarningHandler) NULL); |
| 1108 | tile=ReadImage(image_info,exception); |
| 1109 | (void) SetWarningHandler(handler); |
| 1110 | if (tile == (Image *) NULL) |
| 1111 | { |
| 1112 | (void) FormatLocaleFile(file,"\n"); |
| 1113 | continue; |
| 1114 | } |
| 1115 | (void) FormatLocaleFile(file," %.20gx%.20g %s\n",(double) |
| 1116 | tile->magick_columns,(double) tile->magick_rows,tile->magick); |
| 1117 | (void) SignatureImage(tile,exception); |
| 1118 | ResetImagePropertyIterator(tile); |
| 1119 | property=GetNextImageProperty(tile); |
| 1120 | while (property != (const char *) NULL) |
| 1121 | { |
| 1122 | (void) FormatLocaleFile(file," %s:\n",property); |
| 1123 | value=GetImageProperty(tile,property,exception); |
| 1124 | if (value != (const char *) NULL) |
| 1125 | (void) FormatLocaleFile(file,"%s\n",value); |
| 1126 | property=GetNextImageProperty(tile); |
| 1127 | } |
| 1128 | tile=DestroyImage(tile); |
| 1129 | } |
| 1130 | image_info=DestroyImageInfo(image_info); |
| 1131 | } |
| 1132 | (void) GetImageProperty(image,"exif:*",exception); |
cristy | 5516632 | 2014-01-23 01:53:24 +0000 | [diff] [blame] | 1133 | (void) GetImageProperty(image,"icc:*",exception); |
| 1134 | (void) GetImageProperty(image,"iptc:*",exception); |
| 1135 | (void) GetImageProperty(image,"xmp:*",exception); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 1136 | ResetImagePropertyIterator(image); |
| 1137 | property=GetNextImageProperty(image); |
| 1138 | if (property != (const char *) NULL) |
| 1139 | { |
| 1140 | /* |
| 1141 | Display image properties. |
| 1142 | */ |
| 1143 | (void) FormatLocaleFile(file," Properties:\n"); |
| 1144 | while (property != (const char *) NULL) |
| 1145 | { |
| 1146 | (void) FormatLocaleFile(file," %s: ",property); |
| 1147 | value=GetImageProperty(image,property,exception); |
| 1148 | if (value != (const char *) NULL) |
| 1149 | (void) FormatLocaleFile(file,"%s\n",value); |
| 1150 | property=GetNextImageProperty(image); |
| 1151 | } |
| 1152 | } |
| 1153 | (void) FormatLocaleString(key,MaxTextExtent,"8BIM:1999,2998:#1"); |
| 1154 | value=GetImageProperty(image,key,exception); |
| 1155 | if (value != (const char *) NULL) |
| 1156 | { |
| 1157 | /* |
| 1158 | Display clipping path. |
| 1159 | */ |
| 1160 | (void) FormatLocaleFile(file," Clipping path: "); |
| 1161 | if (strlen(value) > 80) |
| 1162 | (void) fputc('\n',file); |
| 1163 | (void) FormatLocaleFile(file,"%s\n",value); |
| 1164 | } |
| 1165 | ResetImageProfileIterator(image); |
| 1166 | name=GetNextImageProfile(image); |
| 1167 | if (name != (char *) NULL) |
| 1168 | { |
| 1169 | const StringInfo |
| 1170 | *profile; |
| 1171 | |
| 1172 | /* |
| 1173 | Identify image profiles. |
| 1174 | */ |
| 1175 | (void) FormatLocaleFile(file," Profiles:\n"); |
| 1176 | while (name != (char *) NULL) |
| 1177 | { |
| 1178 | profile=GetImageProfile(image,name); |
| 1179 | if (profile == (StringInfo *) NULL) |
| 1180 | continue; |
| 1181 | (void) FormatLocaleFile(file," Profile-%s: %.20g bytes\n",name, |
| 1182 | (double) GetStringInfoLength(profile)); |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 1183 | if (LocaleCompare(name,"iptc") == 0) |
| 1184 | { |
| 1185 | char |
| 1186 | *attribute, |
| 1187 | **attribute_list; |
| 1188 | |
| 1189 | const char |
| 1190 | *tag; |
| 1191 | |
| 1192 | long |
| 1193 | dataset, |
| 1194 | record, |
| 1195 | sentinel; |
| 1196 | |
| 1197 | register ssize_t |
| 1198 | j; |
| 1199 | |
| 1200 | size_t |
| 1201 | length, |
| 1202 | profile_length; |
| 1203 | |
| 1204 | profile_length=GetStringInfoLength(profile); |
| 1205 | for (i=0; i < (ssize_t) profile_length; i+=(ssize_t) length) |
| 1206 | { |
| 1207 | length=1; |
| 1208 | sentinel=GetStringInfoDatum(profile)[i++]; |
| 1209 | if (sentinel != 0x1c) |
| 1210 | continue; |
| 1211 | dataset=GetStringInfoDatum(profile)[i++]; |
| 1212 | record=GetStringInfoDatum(profile)[i++]; |
| 1213 | switch (record) |
| 1214 | { |
| 1215 | case 5: tag="Image Name"; break; |
| 1216 | case 7: tag="Edit Status"; break; |
| 1217 | case 10: tag="Priority"; break; |
| 1218 | case 15: tag="Category"; break; |
| 1219 | case 20: tag="Supplemental Category"; break; |
| 1220 | case 22: tag="Fixture Identifier"; break; |
| 1221 | case 25: tag="Keyword"; break; |
| 1222 | case 30: tag="Release Date"; break; |
| 1223 | case 35: tag="Release Time"; break; |
| 1224 | case 40: tag="Special Instructions"; break; |
| 1225 | case 45: tag="Reference Service"; break; |
| 1226 | case 47: tag="Reference Date"; break; |
| 1227 | case 50: tag="Reference Number"; break; |
| 1228 | case 55: tag="Created Date"; break; |
| 1229 | case 60: tag="Created Time"; break; |
| 1230 | case 65: tag="Originating Program"; break; |
| 1231 | case 70: tag="Program Version"; break; |
| 1232 | case 75: tag="Object Cycle"; break; |
| 1233 | case 80: tag="Byline"; break; |
| 1234 | case 85: tag="Byline Title"; break; |
| 1235 | case 90: tag="City"; break; |
| 1236 | case 95: tag="Province State"; break; |
| 1237 | case 100: tag="Country Code"; break; |
| 1238 | case 101: tag="Country"; break; |
| 1239 | case 103: tag="Original Transmission Reference"; break; |
| 1240 | case 105: tag="Headline"; break; |
| 1241 | case 110: tag="Credit"; break; |
| 1242 | case 115: tag="Src"; break; |
| 1243 | case 116: tag="Copyright String"; break; |
| 1244 | case 120: tag="Caption"; break; |
| 1245 | case 121: tag="Local Caption"; break; |
| 1246 | case 122: tag="Caption Writer"; break; |
| 1247 | case 200: tag="Custom Field 1"; break; |
| 1248 | case 201: tag="Custom Field 2"; break; |
| 1249 | case 202: tag="Custom Field 3"; break; |
| 1250 | case 203: tag="Custom Field 4"; break; |
| 1251 | case 204: tag="Custom Field 5"; break; |
| 1252 | case 205: tag="Custom Field 6"; break; |
| 1253 | case 206: tag="Custom Field 7"; break; |
| 1254 | case 207: tag="Custom Field 8"; break; |
| 1255 | case 208: tag="Custom Field 9"; break; |
| 1256 | case 209: tag="Custom Field 10"; break; |
| 1257 | case 210: tag="Custom Field 11"; break; |
| 1258 | case 211: tag="Custom Field 12"; break; |
| 1259 | case 212: tag="Custom Field 13"; break; |
| 1260 | case 213: tag="Custom Field 14"; break; |
| 1261 | case 214: tag="Custom Field 15"; break; |
| 1262 | case 215: tag="Custom Field 16"; break; |
| 1263 | case 216: tag="Custom Field 17"; break; |
| 1264 | case 217: tag="Custom Field 18"; break; |
| 1265 | case 218: tag="Custom Field 19"; break; |
| 1266 | case 219: tag="Custom Field 20"; break; |
| 1267 | default: tag="unknown"; break; |
| 1268 | } |
| 1269 | (void) FormatLocaleFile(file," %s[%.20g,%.20g]: ",tag, |
| 1270 | (double) dataset,(double) record); |
| 1271 | length=(size_t) (GetStringInfoDatum(profile)[i++] << 8); |
| 1272 | length|=GetStringInfoDatum(profile)[i++]; |
| 1273 | attribute=(char *) NULL; |
| 1274 | if (~length >= (MaxTextExtent-1)) |
| 1275 | attribute=(char *) AcquireQuantumMemory(length+MaxTextExtent, |
| 1276 | sizeof(*attribute)); |
| 1277 | if (attribute != (char *) NULL) |
| 1278 | { |
| 1279 | (void) CopyMagickString(attribute,(char *) |
| 1280 | GetStringInfoDatum(profile)+i,length+1); |
| 1281 | attribute_list=StringToList(attribute); |
| 1282 | if (attribute_list != (char **) NULL) |
| 1283 | { |
| 1284 | for (j=0; attribute_list[j] != (char *) NULL; j++) |
| 1285 | { |
| 1286 | (void) fputs(attribute_list[j],file); |
| 1287 | (void) fputs("\n",file); |
| 1288 | attribute_list[j]=(char *) RelinquishMagickMemory( |
| 1289 | attribute_list[j]); |
| 1290 | } |
| 1291 | attribute_list=(char **) RelinquishMagickMemory( |
| 1292 | attribute_list); |
| 1293 | } |
| 1294 | attribute=DestroyString(attribute); |
| 1295 | } |
| 1296 | } |
| 1297 | } |
| 1298 | if (image->debug != MagickFalse) |
| 1299 | PrintStringInfo(file,name,profile); |
| 1300 | name=GetNextImageProfile(image); |
| 1301 | } |
| 1302 | } |
| 1303 | ResetImageArtifactIterator(image); |
| 1304 | artifact=GetNextImageArtifact(image); |
| 1305 | if (artifact != (const char *) NULL) |
| 1306 | { |
| 1307 | /* |
| 1308 | Display image artifacts. |
| 1309 | */ |
| 1310 | (void) FormatLocaleFile(file," Artifacts:\n"); |
| 1311 | while (artifact != (const char *) NULL) |
| 1312 | { |
| 1313 | (void) FormatLocaleFile(file," %s: ",artifact); |
| 1314 | value=GetImageArtifact(image,artifact); |
| 1315 | if (value != (const char *) NULL) |
| 1316 | (void) FormatLocaleFile(file,"%s\n",value); |
| 1317 | artifact=GetNextImageArtifact(image); |
| 1318 | } |
| 1319 | } |
| 1320 | ResetImageRegistryIterator(); |
| 1321 | registry=GetNextImageRegistry(); |
| 1322 | if (registry != (const char *) NULL) |
| 1323 | { |
| 1324 | /* |
| 1325 | Display image registry. |
| 1326 | */ |
| 1327 | (void) FormatLocaleFile(file," Registry:\n"); |
| 1328 | while (registry != (const char *) NULL) |
| 1329 | { |
| 1330 | (void) FormatLocaleFile(file," %s: ",registry); |
| 1331 | value=(const char *) GetImageRegistry(StringRegistryType,registry, |
| 1332 | exception); |
| 1333 | if (value != (const char *) NULL) |
| 1334 | (void) FormatLocaleFile(file,"%s\n",value); |
| 1335 | registry=GetNextImageRegistry(); |
| 1336 | } |
| 1337 | } |
| 1338 | (void) FormatLocaleFile(file," Tainted: %s\n",CommandOptionToMnemonic( |
| 1339 | MagickBooleanOptions,(ssize_t) image->taint)); |
| 1340 | (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format); |
| 1341 | (void) FormatLocaleFile(file," Filesize: %s\n",format); |
| 1342 | (void) FormatMagickSize((MagickSizeType) image->columns*image->rows, |
| 1343 | MagickFalse,format); |
| 1344 | if (strlen(format) > 1) |
| 1345 | format[strlen(format)-1]='\0'; |
| 1346 | (void) FormatLocaleFile(file," Number pixels: %s\n",format); |
| 1347 | (void) FormatMagickSize((MagickSizeType) ((double) image->columns*image->rows/ |
| 1348 | elapsed_time+0.5),MagickFalse,format); |
| 1349 | (void) FormatLocaleFile(file," Pixels per second: %s\n",format); |
| 1350 | (void) FormatLocaleFile(file," User time: %0.3fu\n",user_time); |
| 1351 | (void) FormatLocaleFile(file," Elapsed time: %lu:%02lu.%03lu\n", |
| 1352 | (unsigned long) (elapsed_time/60.0),(unsigned long) ceil(fmod(elapsed_time, |
| 1353 | 60.0)),(unsigned long) (1000.0*(elapsed_time-floor(elapsed_time)))); |
| 1354 | (void) FormatLocaleFile(file," Version: %s\n",GetMagickVersion((size_t *) |
| 1355 | NULL)); |
| 1356 | (void) fflush(file); |
| 1357 | return(ferror(file) != 0 ? MagickFalse : MagickTrue); |
| 1358 | } |
| 1359 | |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 1360 | static MagickBooleanType WriteJSONImage(const ImageInfo *image_info, |
| 1361 | Image *image,ExceptionInfo *exception) |
| 1362 | { |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 1363 | MagickBooleanType |
| 1364 | status; |
| 1365 | |
| 1366 | MagickOffsetType |
| 1367 | scene; |
| 1368 | |
| 1369 | /* |
| 1370 | Open output image file. |
| 1371 | */ |
| 1372 | assert(image_info != (const ImageInfo *) NULL); |
| 1373 | assert(image_info->signature == MagickSignature); |
| 1374 | assert(image != (Image *) NULL); |
| 1375 | assert(image->signature == MagickSignature); |
| 1376 | if (image->debug != MagickFalse) |
| 1377 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 1378 | status=OpenBlob(image_info,image,WriteBlobMode,exception); |
| 1379 | if (status == MagickFalse) |
| 1380 | return(status); |
| 1381 | scene=0; |
| 1382 | do |
| 1383 | { |
cristy | 9e81898 | 2014-01-18 14:54:37 +0000 | [diff] [blame] | 1384 | (void) CopyMagickString(image->filename,image->magick_filename, |
| 1385 | MaxTextExtent); |
| 1386 | image->magick_columns=image->columns; |
| 1387 | image->magick_rows=image->rows; |
| 1388 | (void) EncodeImageAttributes(image,GetBlobFileHandle(image),exception); |
cristy | 3f07aa3 | 2014-01-18 01:16:33 +0000 | [diff] [blame] | 1389 | if (GetNextImageInList(image) == (Image *) NULL) |
| 1390 | break; |
| 1391 | image=SyncNextImageInList(image); |
| 1392 | status=SetImageProgress(image,SaveImagesTag,scene++, |
| 1393 | GetImageListLength(image)); |
| 1394 | if (status == MagickFalse) |
| 1395 | break; |
| 1396 | } while (image_info->adjoin != MagickFalse); |
| 1397 | (void) CloseBlob(image); |
| 1398 | return(MagickTrue); |
| 1399 | } |