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