MagickCore  7.0.7
Convert, Edit, Or Compose Bitmap Images
property.c
Go to the documentation of this file.
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 % %
4 % %
5 % %
6 % PPPP RRRR OOO PPPP EEEEE RRRR TTTTT Y Y %
7 % P P R R O O P P E R R T Y Y %
8 % PPPP RRRR O O PPPP EEE RRRR T Y %
9 % P R R O O P E R R T Y %
10 % P R R OOO P EEEEE R R T Y %
11 % %
12 % %
13 % MagickCore Property Methods %
14 % %
15 % Software Design %
16 % Cristy %
17 % March 2000 %
18 % %
19 % %
20 % Copyright 1999-2018 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 % https://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 /*
41  Include declarations.
42 */
43 #include "MagickCore/studio.h"
44 #include "MagickCore/artifact.h"
45 #include "MagickCore/attribute.h"
46 #include "MagickCore/cache.h"
48 #include "MagickCore/color.h"
51 #include "MagickCore/compare.h"
52 #include "MagickCore/constitute.h"
53 #include "MagickCore/draw.h"
54 #include "MagickCore/effect.h"
55 #include "MagickCore/exception.h"
57 #include "MagickCore/fx.h"
58 #include "MagickCore/fx-private.h"
59 #include "MagickCore/gem.h"
60 #include "MagickCore/geometry.h"
61 #include "MagickCore/histogram.h"
62 #include "MagickCore/image.h"
63 #include "MagickCore/layer.h"
65 #include "MagickCore/list.h"
66 #include "MagickCore/magick.h"
67 #include "MagickCore/memory_.h"
68 #include "MagickCore/monitor.h"
69 #include "MagickCore/montage.h"
70 #include "MagickCore/option.h"
71 #include "MagickCore/policy.h"
72 #include "MagickCore/profile.h"
73 #include "MagickCore/property.h"
74 #include "MagickCore/quantum.h"
75 #include "MagickCore/resource_.h"
76 #include "MagickCore/splay-tree.h"
77 #include "MagickCore/signature.h"
78 #include "MagickCore/statistic.h"
79 #include "MagickCore/string_.h"
81 #include "MagickCore/token.h"
83 #include "MagickCore/utility.h"
85 #include "MagickCore/version.h"
86 #include "MagickCore/xml-tree.h"
88 #if defined(MAGICKCORE_LCMS_DELEGATE)
89 #if defined(MAGICKCORE_HAVE_LCMS2_LCMS2_H)
90 #include <lcms2/lcms2.h>
91 #elif defined(MAGICKCORE_HAVE_LCMS2_H)
92 #include "lcms2.h"
93 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
94 #include <lcms/lcms.h>
95 #else
96 #include "lcms.h"
97 #endif
98 #endif
99 
100 /*
101  Define declarations.
102 */
103 #if defined(MAGICKCORE_LCMS_DELEGATE)
104 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
105 #define cmsUInt32Number DWORD
106 #endif
107 #endif
108 
109 /*
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 % %
112 % %
113 % %
114 % C l o n e I m a g e P r o p e r t i e s %
115 % %
116 % %
117 % %
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 %
120 % CloneImageProperties() clones all the image properties to another image.
121 %
122 % The format of the CloneImageProperties method is:
123 %
124 % MagickBooleanType CloneImageProperties(Image *image,
125 % const Image *clone_image)
126 %
127 % A description of each parameter follows:
128 %
129 % o image: the image.
130 %
131 % o clone_image: the clone image.
132 %
133 */
135  const Image *clone_image)
136 {
137  assert(image != (Image *) NULL);
138  assert(image->signature == MagickCoreSignature);
139  if (image->debug != MagickFalse)
140  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
141  assert(clone_image != (const Image *) NULL);
142  assert(clone_image->signature == MagickCoreSignature);
143  if (clone_image->debug != MagickFalse)
145  clone_image->filename);
146  (void) CopyMagickString(image->filename,clone_image->filename,
148  (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
150  image->compression=clone_image->compression;
151  image->quality=clone_image->quality;
152  image->depth=clone_image->depth;
153  image->matte_color=clone_image->matte_color;
154  image->background_color=clone_image->background_color;
155  image->border_color=clone_image->border_color;
156  image->transparent_color=clone_image->transparent_color;
157  image->gamma=clone_image->gamma;
158  image->chromaticity=clone_image->chromaticity;
159  image->rendering_intent=clone_image->rendering_intent;
161  image->units=clone_image->units;
162  image->montage=(char *) NULL;
163  image->directory=(char *) NULL;
164  (void) CloneString(&image->geometry,clone_image->geometry);
165  image->offset=clone_image->offset;
166  image->resolution.x=clone_image->resolution.x;
167  image->resolution.y=clone_image->resolution.y;
168  image->page=clone_image->page;
169  image->tile_offset=clone_image->tile_offset;
170  image->extract_info=clone_image->extract_info;
171  image->filter=clone_image->filter;
172  image->fuzz=clone_image->fuzz;
173  image->intensity=clone_image->intensity;
174  image->interlace=clone_image->interlace;
175  image->interpolate=clone_image->interpolate;
176  image->endian=clone_image->endian;
177  image->gravity=clone_image->gravity;
178  image->compose=clone_image->compose;
179  image->orientation=clone_image->orientation;
180  image->scene=clone_image->scene;
181  image->dispose=clone_image->dispose;
182  image->delay=clone_image->delay;
183  image->ticks_per_second=clone_image->ticks_per_second;
184  image->iterations=clone_image->iterations;
185  image->total_colors=clone_image->total_colors;
186  image->taint=clone_image->taint;
187  image->progress_monitor=clone_image->progress_monitor;
188  image->client_data=clone_image->client_data;
189  image->start_loop=clone_image->start_loop;
190  image->error=clone_image->error;
191  image->signature=clone_image->signature;
192  if (clone_image->properties != (void *) NULL)
193  {
194  if (image->properties != (void *) NULL)
195  DestroyImageProperties(image);
197  clone_image->properties,(void *(*)(void *)) ConstantString,
198  (void *(*)(void *)) ConstantString);
199  }
200  return(MagickTrue);
201 }
202 
203 /*
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 % %
206 % %
207 % %
208 % D e f i n e I m a g e P r o p e r t y %
209 % %
210 % %
211 % %
212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
213 %
214 % DefineImageProperty() associates an assignment string of the form
215 % "key=value" with an artifact or options. It is equivelent to
216 % SetImageProperty().
217 %
218 % The format of the DefineImageProperty method is:
219 %
220 % MagickBooleanType DefineImageProperty(Image *image,const char *property,
221 % ExceptionInfo *exception)
222 %
223 % A description of each parameter follows:
224 %
225 % o image: the image.
226 %
227 % o property: the image property.
228 %
229 % o exception: return any errors or warnings in this structure.
230 %
231 */
233  const char *property,ExceptionInfo *exception)
234 {
235  char
236  key[MagickPathExtent],
237  value[MagickPathExtent];
238 
239  register char
240  *p;
241 
242  assert(image != (Image *) NULL);
243  assert(property != (const char *) NULL);
244  (void) CopyMagickString(key,property,MagickPathExtent-1);
245  for (p=key; *p != '\0'; p++)
246  if (*p == '=')
247  break;
248  *value='\0';
249  if (*p == '=')
250  (void) CopyMagickString(value,p+1,MagickPathExtent);
251  *p='\0';
252  return(SetImageProperty(image,key,value,exception));
253 }
254 
255 /*
256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
257 % %
258 % %
259 % %
260 % D e l e t e I m a g e P r o p e r t y %
261 % %
262 % %
263 % %
264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 %
266 % DeleteImageProperty() deletes an image property.
267 %
268 % The format of the DeleteImageProperty method is:
269 %
270 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
271 %
272 % A description of each parameter follows:
273 %
274 % o image: the image.
275 %
276 % o property: the image property.
277 %
278 */
280  const char *property)
281 {
282  assert(image != (Image *) NULL);
283  assert(image->signature == MagickCoreSignature);
284  if (image->debug != MagickFalse)
285  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
286  if (image->properties == (void *) NULL)
287  return(MagickFalse);
288  return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
289 }
290 
291 /*
292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
293 % %
294 % %
295 % %
296 % D e s t r o y I m a g e P r o p e r t i e s %
297 % %
298 % %
299 % %
300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301 %
302 % DestroyImageProperties() destroys all properties and associated memory
303 % attached to the given image.
304 %
305 % The format of the DestroyDefines method is:
306 %
307 % void DestroyImageProperties(Image *image)
308 %
309 % A description of each parameter follows:
310 %
311 % o image: the image.
312 %
313 */
315 {
316  assert(image != (Image *) NULL);
317  assert(image->signature == MagickCoreSignature);
318  if (image->debug != MagickFalse)
319  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
320  if (image->properties != (void *) NULL)
321  image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
322  image->properties);
323 }
324 
325 /*
326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
327 % %
328 % %
329 % %
330 % F o r m a t I m a g e P r o p e r t y %
331 % %
332 % %
333 % %
334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
335 %
336 % FormatImageProperty() permits formatted property/value pairs to be saved as
337 % an image property.
338 %
339 % The format of the FormatImageProperty method is:
340 %
341 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
342 % const char *format,...)
343 %
344 % A description of each parameter follows.
345 %
346 % o image: The image.
347 %
348 % o property: The attribute property.
349 %
350 % o format: A string describing the format to use to write the remaining
351 % arguments.
352 %
353 */
355  const char *property,const char *format,...)
356 {
357  char
358  value[MagickPathExtent];
359 
361  *exception;
362 
364  status;
365 
366  ssize_t
367  n;
368 
369  va_list
370  operands;
371 
372  va_start(operands,format);
373  n=FormatLocaleStringList(value,MagickPathExtent,format,operands);
374  (void) n;
375  va_end(operands);
376  exception=AcquireExceptionInfo();
377  status=SetImageProperty(image,property,value,exception);
378  exception=DestroyExceptionInfo(exception);
379  return(status);
380 }
381 
382 /*
383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
384 % %
385 % %
386 % %
387 % G e t I m a g e P r o p e r t y %
388 % %
389 % %
390 % %
391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
392 %
393 % GetImageProperty() gets a value associated with an image property.
394 %
395 % This includes, profile prefixes, such as "exif:", "iptc:" and "8bim:"
396 % It does not handle non-prifile prefixes, such as "fx:", "option:", or
397 % "artifact:".
398 %
399 % The returned string is stored as a properity of the same name for faster
400 % lookup later. It should NOT be freed by the caller.
401 %
402 % The format of the GetImageProperty method is:
403 %
404 % const char *GetImageProperty(const Image *image,const char *key,
405 % ExceptionInfo *exception)
406 %
407 % A description of each parameter follows:
408 %
409 % o image: the image.
410 %
411 % o key: the key.
412 %
413 % o exception: return any errors or warnings in this structure.
414 %
415 */
416 
417 static char
418  *TracePSClippath(const unsigned char *,size_t),
419  *TraceSVGClippath(const unsigned char *,size_t,const size_t,
420  const size_t);
421 
422 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key,
423  ExceptionInfo *exception)
424 {
425  char
426  *attribute,
427  *message;
428 
429  const StringInfo
430  *profile;
431 
432  long
433  count,
434  dataset,
435  record;
436 
437  register ssize_t
438  i;
439 
440  size_t
441  length;
442 
443  profile=GetImageProfile(image,"iptc");
444  if (profile == (StringInfo *) NULL)
445  profile=GetImageProfile(image,"8bim");
446  if (profile == (StringInfo *) NULL)
447  return(MagickFalse);
448  count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
449  if (count != 2)
450  return(MagickFalse);
451  attribute=(char *) NULL;
452  for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
453  {
454  length=1;
455  if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
456  continue;
457  length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
458  length|=GetStringInfoDatum(profile)[i+4];
459  if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
460  ((long) GetStringInfoDatum(profile)[i+2] == record))
461  {
462  message=(char *) NULL;
463  if (~length >= 1)
464  message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
465  if (message != (char *) NULL)
466  {
467  (void) CopyMagickString(message,(char *) GetStringInfoDatum(
468  profile)+i+5,length+1);
469  (void) ConcatenateString(&attribute,message);
470  (void) ConcatenateString(&attribute,";");
471  message=DestroyString(message);
472  }
473  }
474  i+=5;
475  }
476  if ((attribute == (char *) NULL) || (*attribute == ';'))
477  {
478  if (attribute != (char *) NULL)
479  attribute=DestroyString(attribute);
480  return(MagickFalse);
481  }
482  attribute[strlen(attribute)-1]='\0';
483  (void) SetImageProperty((Image *) image,key,(const char *) attribute,
484  exception);
485  attribute=DestroyString(attribute);
486  return(MagickTrue);
487 }
488 
489 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
490 {
491  int
492  c;
493 
494  if (*length < 1)
495  return(EOF);
496  c=(int) (*(*p)++);
497  (*length)--;
498  return(c);
499 }
500 
501 static inline signed int ReadPropertyMSBLong(const unsigned char **p,
502  size_t *length)
503 {
504  union
505  {
506  unsigned int
507  unsigned_value;
508 
509  signed int
510  signed_value;
511  } quantum;
512 
513  int
514  c;
515 
516  register ssize_t
517  i;
518 
519  unsigned char
520  buffer[4];
521 
522  unsigned int
523  value;
524 
525  if (*length < 4)
526  return(-1);
527  for (i=0; i < 4; i++)
528  {
529  c=(int) (*(*p)++);
530  (*length)--;
531  buffer[i]=(unsigned char) c;
532  }
533  value=(unsigned int) buffer[0] << 24;
534  value|=(unsigned int) buffer[1] << 16;
535  value|=(unsigned int) buffer[2] << 8;
536  value|=(unsigned int) buffer[3];
537  quantum.unsigned_value=value & 0xffffffff;
538  return(quantum.signed_value);
539 }
540 
541 static inline signed short ReadPropertyMSBShort(const unsigned char **p,
542  size_t *length)
543 {
544  union
545  {
546  unsigned short
547  unsigned_value;
548 
549  signed short
550  signed_value;
551  } quantum;
552 
553  int
554  c;
555 
556  register ssize_t
557  i;
558 
559  unsigned char
560  buffer[2];
561 
562  unsigned short
563  value;
564 
565  if (*length < 2)
566  return((unsigned short) ~0);
567  for (i=0; i < 2; i++)
568  {
569  c=(int) (*(*p)++);
570  (*length)--;
571  buffer[i]=(unsigned char) c;
572  }
573  value=(unsigned short) buffer[0] << 8;
574  value|=(unsigned short) buffer[1];
575  quantum.unsigned_value=value & 0xffff;
576  return(quantum.signed_value);
577 }
578 
579 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
580  ExceptionInfo *exception)
581 {
582  char
583  *attribute,
584  format[MagickPathExtent],
586  *resource;
587 
588  const StringInfo
589  *profile;
590 
591  const unsigned char
592  *info;
593 
594  long
595  start,
596  stop;
597 
599  status;
600 
601  register ssize_t
602  i;
603 
604  size_t
605  length;
606 
607  ssize_t
608  count,
609  id,
610  sub_number;
611 
612  /*
613  There are no newlines in path names, so it's safe as terminator.
614  */
615  profile=GetImageProfile(image,"8bim");
616  if (profile == (StringInfo *) NULL)
617  return(MagickFalse);
618  count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
619  name,format);
620  if ((count != 2) && (count != 3) && (count != 4))
621  return(MagickFalse);
622  if (count < 4)
623  (void) CopyMagickString(format,"SVG",MagickPathExtent);
624  if (count < 3)
625  *name='\0';
626  sub_number=1;
627  if (*name == '#')
628  sub_number=(ssize_t) StringToLong(&name[1]);
629  sub_number=MagickMax(sub_number,1L);
630  resource=(char *) NULL;
631  status=MagickFalse;
632  length=GetStringInfoLength(profile);
633  info=GetStringInfoDatum(profile);
634  while ((length > 0) && (status == MagickFalse))
635  {
636  if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
637  continue;
638  if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
639  continue;
640  if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
641  continue;
642  if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
643  continue;
644  id=(ssize_t) ReadPropertyMSBShort(&info,&length);
645  if (id < (ssize_t) start)
646  continue;
647  if (id > (ssize_t) stop)
648  continue;
649  if (resource != (char *) NULL)
650  resource=DestroyString(resource);
651  count=(ssize_t) ReadPropertyByte(&info,&length);
652  if ((count != 0) && ((size_t) count <= length))
653  {
654  resource=(char *) NULL;
655  if (~((size_t) count) >= (MagickPathExtent-1))
656  resource=(char *) AcquireQuantumMemory((size_t) count+
657  MagickPathExtent,sizeof(*resource));
658  if (resource != (char *) NULL)
659  {
660  for (i=0; i < (ssize_t) count; i++)
661  resource[i]=(char) ReadPropertyByte(&info,&length);
662  resource[count]='\0';
663  }
664  }
665  if ((count & 0x01) == 0)
666  (void) ReadPropertyByte(&info,&length);
667  count=(ssize_t) ReadPropertyMSBLong(&info,&length);
668  if ((count < 0) || ((size_t) count > length))
669  {
670  length=0;
671  continue;
672  }
673  if ((*name != '\0') && (*name != '#'))
674  if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
675  {
676  /*
677  No name match, scroll forward and try next.
678  */
679  info+=count;
680  length-=MagickMin(count,(ssize_t) length);
681  continue;
682  }
683  if ((*name == '#') && (sub_number != 1))
684  {
685  /*
686  No numbered match, scroll forward and try next.
687  */
688  sub_number--;
689  info+=count;
690  length-=MagickMin(count,(ssize_t) length);
691  continue;
692  }
693  /*
694  We have the resource of interest.
695  */
696  attribute=(char *) NULL;
697  if (~((size_t) count) >= (MagickPathExtent-1))
698  attribute=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent,
699  sizeof(*attribute));
700  if (attribute != (char *) NULL)
701  {
702  (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
703  attribute[count]='\0';
704  info+=count;
705  length-=MagickMin(count,(ssize_t) length);
706  if ((id <= 1999) || (id >= 2999))
707  (void) SetImageProperty((Image *) image,key,(const char *) attribute,
708  exception);
709  else
710  {
711  char
712  *path;
713 
714  if (LocaleCompare(format,"svg") == 0)
715  path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
716  image->columns,image->rows);
717  else
718  path=TracePSClippath((unsigned char *) attribute,(size_t) count);
719  (void) SetImageProperty((Image *) image,key,(const char *) path,
720  exception);
721  path=DestroyString(path);
722  }
723  attribute=DestroyString(attribute);
724  status=MagickTrue;
725  }
726  }
727  if (resource != (char *) NULL)
728  resource=DestroyString(resource);
729  return(status);
730 }
731 
732 static inline signed int ReadPropertySignedLong(const EndianType endian,
733  const unsigned char *buffer)
734 {
735  union
736  {
737  unsigned int
738  unsigned_value;
739 
740  signed int
741  signed_value;
742  } quantum;
743 
744  unsigned int
745  value;
746 
747  if (endian == LSBEndian)
748  {
749  value=(unsigned int) buffer[3] << 24;
750  value|=(unsigned int) buffer[2] << 16;
751  value|=(unsigned int) buffer[1] << 8;
752  value|=(unsigned int) buffer[0];
753  quantum.unsigned_value=value & 0xffffffff;
754  return(quantum.signed_value);
755  }
756  value=(unsigned int) buffer[0] << 24;
757  value|=(unsigned int) buffer[1] << 16;
758  value|=(unsigned int) buffer[2] << 8;
759  value|=(unsigned int) buffer[3];
760  quantum.unsigned_value=value & 0xffffffff;
761  return(quantum.signed_value);
762 }
763 
764 static inline unsigned int ReadPropertyUnsignedLong(const EndianType endian,
765  const unsigned char *buffer)
766 {
767  unsigned int
768  value;
769 
770  if (endian == LSBEndian)
771  {
772  value=(unsigned int) buffer[3] << 24;
773  value|=(unsigned int) buffer[2] << 16;
774  value|=(unsigned int) buffer[1] << 8;
775  value|=(unsigned int) buffer[0];
776  return(value & 0xffffffff);
777  }
778  value=(unsigned int) buffer[0] << 24;
779  value|=(unsigned int) buffer[1] << 16;
780  value|=(unsigned int) buffer[2] << 8;
781  value|=(unsigned int) buffer[3];
782  return(value & 0xffffffff);
783 }
784 
785 static inline signed short ReadPropertySignedShort(const EndianType endian,
786  const unsigned char *buffer)
787 {
788  union
789  {
790  unsigned short
791  unsigned_value;
792 
793  signed short
794  signed_value;
795  } quantum;
796 
797  unsigned short
798  value;
799 
800  if (endian == LSBEndian)
801  {
802  value=(unsigned short) buffer[1] << 8;
803  value|=(unsigned short) buffer[0];
804  quantum.unsigned_value=value & 0xffff;
805  return(quantum.signed_value);
806  }
807  value=(unsigned short) buffer[0] << 8;
808  value|=(unsigned short) buffer[1];
809  quantum.unsigned_value=value & 0xffff;
810  return(quantum.signed_value);
811 }
812 
813 static inline unsigned short ReadPropertyUnsignedShort(const EndianType endian,
814  const unsigned char *buffer)
815 {
816  unsigned short
817  value;
818 
819  if (endian == LSBEndian)
820  {
821  value=(unsigned short) buffer[1] << 8;
822  value|=(unsigned short) buffer[0];
823  return(value & 0xffff);
824  }
825  value=(unsigned short) buffer[0] << 8;
826  value|=(unsigned short) buffer[1];
827  return(value & 0xffff);
828 }
829 
831  const char *property,ExceptionInfo *exception)
832 {
833 #define MaxDirectoryStack 16
834 #define EXIF_DELIMITER "\n"
835 #define EXIF_NUM_FORMATS 12
836 #define EXIF_FMT_BYTE 1
837 #define EXIF_FMT_STRING 2
838 #define EXIF_FMT_USHORT 3
839 #define EXIF_FMT_ULONG 4
840 #define EXIF_FMT_URATIONAL 5
841 #define EXIF_FMT_SBYTE 6
842 #define EXIF_FMT_UNDEFINED 7
843 #define EXIF_FMT_SSHORT 8
844 #define EXIF_FMT_SLONG 9
845 #define EXIF_FMT_SRATIONAL 10
846 #define EXIF_FMT_SINGLE 11
847 #define EXIF_FMT_DOUBLE 12
848 #define TAG_EXIF_OFFSET 0x8769
849 #define TAG_GPS_OFFSET 0x8825
850 #define TAG_INTEROP_OFFSET 0xa005
851 
852 #define EXIFMultipleValues(size,format,arg) \
853 { \
854  ssize_t \
855  component; \
856  \
857  size_t \
858  length; \
859  \
860  unsigned char \
861  *p1; \
862  \
863  length=0; \
864  p1=p; \
865  for (component=0; component < components; component++) \
866  { \
867  length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
868  format", ",arg); \
869  if (length >= (MagickPathExtent-1)) \
870  length=MagickPathExtent-1; \
871  p1+=size; \
872  } \
873  if (length > 1) \
874  buffer[length-2]='\0'; \
875  value=AcquireString(buffer); \
876 }
877 
878 #define EXIFMultipleFractions(size,format,arg1,arg2) \
879 { \
880  ssize_t \
881  component; \
882  \
883  size_t \
884  length; \
885  \
886  unsigned char \
887  *p1; \
888  \
889  length=0; \
890  p1=p; \
891  for (component=0; component < components; component++) \
892  { \
893  length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
894  format", ",(arg1),(arg2)); \
895  if (length >= (MagickPathExtent-1)) \
896  length=MagickPathExtent-1; \
897  p1+=size; \
898  } \
899  if (length > 1) \
900  buffer[length-2]='\0'; \
901  value=AcquireString(buffer); \
902 }
903 
904  typedef struct _DirectoryInfo
905  {
906  const unsigned char
907  *directory;
908 
909  size_t
910  entry;
911 
912  ssize_t
913  offset;
914  } DirectoryInfo;
915 
916  typedef struct _TagInfo
917  {
918  size_t
919  tag;
920 
921  const char
922  *description;
923  } TagInfo;
924 
925  static TagInfo
926  EXIFTag[] =
927  {
928  { 0x001, "exif:InteroperabilityIndex" },
929  { 0x002, "exif:InteroperabilityVersion" },
930  { 0x100, "exif:ImageWidth" },
931  { 0x101, "exif:ImageLength" },
932  { 0x102, "exif:BitsPerSample" },
933  { 0x103, "exif:Compression" },
934  { 0x106, "exif:PhotometricInterpretation" },
935  { 0x10a, "exif:FillOrder" },
936  { 0x10d, "exif:DocumentName" },
937  { 0x10e, "exif:ImageDescription" },
938  { 0x10f, "exif:Make" },
939  { 0x110, "exif:Model" },
940  { 0x111, "exif:StripOffsets" },
941  { 0x112, "exif:Orientation" },
942  { 0x115, "exif:SamplesPerPixel" },
943  { 0x116, "exif:RowsPerStrip" },
944  { 0x117, "exif:StripByteCounts" },
945  { 0x11a, "exif:XResolution" },
946  { 0x11b, "exif:YResolution" },
947  { 0x11c, "exif:PlanarConfiguration" },
948  { 0x11d, "exif:PageName" },
949  { 0x11e, "exif:XPosition" },
950  { 0x11f, "exif:YPosition" },
951  { 0x118, "exif:MinSampleValue" },
952  { 0x119, "exif:MaxSampleValue" },
953  { 0x120, "exif:FreeOffsets" },
954  { 0x121, "exif:FreeByteCounts" },
955  { 0x122, "exif:GrayResponseUnit" },
956  { 0x123, "exif:GrayResponseCurve" },
957  { 0x124, "exif:T4Options" },
958  { 0x125, "exif:T6Options" },
959  { 0x128, "exif:ResolutionUnit" },
960  { 0x12d, "exif:TransferFunction" },
961  { 0x131, "exif:Software" },
962  { 0x132, "exif:DateTime" },
963  { 0x13b, "exif:Artist" },
964  { 0x13e, "exif:WhitePoint" },
965  { 0x13f, "exif:PrimaryChromaticities" },
966  { 0x140, "exif:ColorMap" },
967  { 0x141, "exif:HalfToneHints" },
968  { 0x142, "exif:TileWidth" },
969  { 0x143, "exif:TileLength" },
970  { 0x144, "exif:TileOffsets" },
971  { 0x145, "exif:TileByteCounts" },
972  { 0x14a, "exif:SubIFD" },
973  { 0x14c, "exif:InkSet" },
974  { 0x14d, "exif:InkNames" },
975  { 0x14e, "exif:NumberOfInks" },
976  { 0x150, "exif:DotRange" },
977  { 0x151, "exif:TargetPrinter" },
978  { 0x152, "exif:ExtraSample" },
979  { 0x153, "exif:SampleFormat" },
980  { 0x154, "exif:SMinSampleValue" },
981  { 0x155, "exif:SMaxSampleValue" },
982  { 0x156, "exif:TransferRange" },
983  { 0x157, "exif:ClipPath" },
984  { 0x158, "exif:XClipPathUnits" },
985  { 0x159, "exif:YClipPathUnits" },
986  { 0x15a, "exif:Indexed" },
987  { 0x15b, "exif:JPEGTables" },
988  { 0x15f, "exif:OPIProxy" },
989  { 0x200, "exif:JPEGProc" },
990  { 0x201, "exif:JPEGInterchangeFormat" },
991  { 0x202, "exif:JPEGInterchangeFormatLength" },
992  { 0x203, "exif:JPEGRestartInterval" },
993  { 0x205, "exif:JPEGLosslessPredictors" },
994  { 0x206, "exif:JPEGPointTransforms" },
995  { 0x207, "exif:JPEGQTables" },
996  { 0x208, "exif:JPEGDCTables" },
997  { 0x209, "exif:JPEGACTables" },
998  { 0x211, "exif:YCbCrCoefficients" },
999  { 0x212, "exif:YCbCrSubSampling" },
1000  { 0x213, "exif:YCbCrPositioning" },
1001  { 0x214, "exif:ReferenceBlackWhite" },
1002  { 0x2bc, "exif:ExtensibleMetadataPlatform" },
1003  { 0x301, "exif:Gamma" },
1004  { 0x302, "exif:ICCProfileDescriptor" },
1005  { 0x303, "exif:SRGBRenderingIntent" },
1006  { 0x320, "exif:ImageTitle" },
1007  { 0x5001, "exif:ResolutionXUnit" },
1008  { 0x5002, "exif:ResolutionYUnit" },
1009  { 0x5003, "exif:ResolutionXLengthUnit" },
1010  { 0x5004, "exif:ResolutionYLengthUnit" },
1011  { 0x5005, "exif:PrintFlags" },
1012  { 0x5006, "exif:PrintFlagsVersion" },
1013  { 0x5007, "exif:PrintFlagsCrop" },
1014  { 0x5008, "exif:PrintFlagsBleedWidth" },
1015  { 0x5009, "exif:PrintFlagsBleedWidthScale" },
1016  { 0x500A, "exif:HalftoneLPI" },
1017  { 0x500B, "exif:HalftoneLPIUnit" },
1018  { 0x500C, "exif:HalftoneDegree" },
1019  { 0x500D, "exif:HalftoneShape" },
1020  { 0x500E, "exif:HalftoneMisc" },
1021  { 0x500F, "exif:HalftoneScreen" },
1022  { 0x5010, "exif:JPEGQuality" },
1023  { 0x5011, "exif:GridSize" },
1024  { 0x5012, "exif:ThumbnailFormat" },
1025  { 0x5013, "exif:ThumbnailWidth" },
1026  { 0x5014, "exif:ThumbnailHeight" },
1027  { 0x5015, "exif:ThumbnailColorDepth" },
1028  { 0x5016, "exif:ThumbnailPlanes" },
1029  { 0x5017, "exif:ThumbnailRawBytes" },
1030  { 0x5018, "exif:ThumbnailSize" },
1031  { 0x5019, "exif:ThumbnailCompressedSize" },
1032  { 0x501a, "exif:ColorTransferFunction" },
1033  { 0x501b, "exif:ThumbnailData" },
1034  { 0x5020, "exif:ThumbnailImageWidth" },
1035  { 0x5021, "exif:ThumbnailImageHeight" },
1036  { 0x5022, "exif:ThumbnailBitsPerSample" },
1037  { 0x5023, "exif:ThumbnailCompression" },
1038  { 0x5024, "exif:ThumbnailPhotometricInterp" },
1039  { 0x5025, "exif:ThumbnailImageDescription" },
1040  { 0x5026, "exif:ThumbnailEquipMake" },
1041  { 0x5027, "exif:ThumbnailEquipModel" },
1042  { 0x5028, "exif:ThumbnailStripOffsets" },
1043  { 0x5029, "exif:ThumbnailOrientation" },
1044  { 0x502a, "exif:ThumbnailSamplesPerPixel" },
1045  { 0x502b, "exif:ThumbnailRowsPerStrip" },
1046  { 0x502c, "exif:ThumbnailStripBytesCount" },
1047  { 0x502d, "exif:ThumbnailResolutionX" },
1048  { 0x502e, "exif:ThumbnailResolutionY" },
1049  { 0x502f, "exif:ThumbnailPlanarConfig" },
1050  { 0x5030, "exif:ThumbnailResolutionUnit" },
1051  { 0x5031, "exif:ThumbnailTransferFunction" },
1052  { 0x5032, "exif:ThumbnailSoftwareUsed" },
1053  { 0x5033, "exif:ThumbnailDateTime" },
1054  { 0x5034, "exif:ThumbnailArtist" },
1055  { 0x5035, "exif:ThumbnailWhitePoint" },
1056  { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
1057  { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
1058  { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
1059  { 0x5039, "exif:ThumbnailYCbCrPositioning" },
1060  { 0x503A, "exif:ThumbnailRefBlackWhite" },
1061  { 0x503B, "exif:ThumbnailCopyRight" },
1062  { 0x5090, "exif:LuminanceTable" },
1063  { 0x5091, "exif:ChrominanceTable" },
1064  { 0x5100, "exif:FrameDelay" },
1065  { 0x5101, "exif:LoopCount" },
1066  { 0x5110, "exif:PixelUnit" },
1067  { 0x5111, "exif:PixelPerUnitX" },
1068  { 0x5112, "exif:PixelPerUnitY" },
1069  { 0x5113, "exif:PaletteHistogram" },
1070  { 0x1000, "exif:RelatedImageFileFormat" },
1071  { 0x1001, "exif:RelatedImageLength" },
1072  { 0x1002, "exif:RelatedImageWidth" },
1073  { 0x800d, "exif:ImageID" },
1074  { 0x80e3, "exif:Matteing" },
1075  { 0x80e4, "exif:DataType" },
1076  { 0x80e5, "exif:ImageDepth" },
1077  { 0x80e6, "exif:TileDepth" },
1078  { 0x828d, "exif:CFARepeatPatternDim" },
1079  { 0x828e, "exif:CFAPattern2" },
1080  { 0x828f, "exif:BatteryLevel" },
1081  { 0x8298, "exif:Copyright" },
1082  { 0x829a, "exif:ExposureTime" },
1083  { 0x829d, "exif:FNumber" },
1084  { 0x83bb, "exif:IPTC/NAA" },
1085  { 0x84e3, "exif:IT8RasterPadding" },
1086  { 0x84e5, "exif:IT8ColorTable" },
1087  { 0x8649, "exif:ImageResourceInformation" },
1088  { 0x8769, "exif:ExifOffset" },
1089  { 0x8773, "exif:InterColorProfile" },
1090  { 0x8822, "exif:ExposureProgram" },
1091  { 0x8824, "exif:SpectralSensitivity" },
1092  { 0x8825, "exif:GPSInfo" },
1093  { 0x8827, "exif:ISOSpeedRatings" },
1094  { 0x8828, "exif:OECF" },
1095  { 0x8829, "exif:Interlace" },
1096  { 0x882a, "exif:TimeZoneOffset" },
1097  { 0x882b, "exif:SelfTimerMode" },
1098  { 0x9000, "exif:ExifVersion" },
1099  { 0x9003, "exif:DateTimeOriginal" },
1100  { 0x9004, "exif:DateTimeDigitized" },
1101  { 0x9101, "exif:ComponentsConfiguration" },
1102  { 0x9102, "exif:CompressedBitsPerPixel" },
1103  { 0x9201, "exif:ShutterSpeedValue" },
1104  { 0x9202, "exif:ApertureValue" },
1105  { 0x9203, "exif:BrightnessValue" },
1106  { 0x9204, "exif:ExposureBiasValue" },
1107  { 0x9205, "exif:MaxApertureValue" },
1108  { 0x9206, "exif:SubjectDistance" },
1109  { 0x9207, "exif:MeteringMode" },
1110  { 0x9208, "exif:LightSource" },
1111  { 0x9209, "exif:Flash" },
1112  { 0x920a, "exif:FocalLength" },
1113  { 0x920b, "exif:FlashEnergy" },
1114  { 0x920c, "exif:SpatialFrequencyResponse" },
1115  { 0x920d, "exif:Noise" },
1116  { 0x9211, "exif:ImageNumber" },
1117  { 0x9212, "exif:SecurityClassification" },
1118  { 0x9213, "exif:ImageHistory" },
1119  { 0x9214, "exif:SubjectArea" },
1120  { 0x9215, "exif:ExposureIndex" },
1121  { 0x9216, "exif:TIFF-EPStandardID" },
1122  { 0x927c, "exif:MakerNote" },
1123  { 0x9C9b, "exif:WinXP-Title" },
1124  { 0x9C9c, "exif:WinXP-Comments" },
1125  { 0x9C9d, "exif:WinXP-Author" },
1126  { 0x9C9e, "exif:WinXP-Keywords" },
1127  { 0x9C9f, "exif:WinXP-Subject" },
1128  { 0x9286, "exif:UserComment" },
1129  { 0x9290, "exif:SubSecTime" },
1130  { 0x9291, "exif:SubSecTimeOriginal" },
1131  { 0x9292, "exif:SubSecTimeDigitized" },
1132  { 0xa000, "exif:FlashPixVersion" },
1133  { 0xa001, "exif:ColorSpace" },
1134  { 0xa002, "exif:ExifImageWidth" },
1135  { 0xa003, "exif:ExifImageLength" },
1136  { 0xa004, "exif:RelatedSoundFile" },
1137  { 0xa005, "exif:InteroperabilityOffset" },
1138  { 0xa20b, "exif:FlashEnergy" },
1139  { 0xa20c, "exif:SpatialFrequencyResponse" },
1140  { 0xa20d, "exif:Noise" },
1141  { 0xa20e, "exif:FocalPlaneXResolution" },
1142  { 0xa20f, "exif:FocalPlaneYResolution" },
1143  { 0xa210, "exif:FocalPlaneResolutionUnit" },
1144  { 0xa214, "exif:SubjectLocation" },
1145  { 0xa215, "exif:ExposureIndex" },
1146  { 0xa216, "exif:TIFF/EPStandardID" },
1147  { 0xa217, "exif:SensingMethod" },
1148  { 0xa300, "exif:FileSource" },
1149  { 0xa301, "exif:SceneType" },
1150  { 0xa302, "exif:CFAPattern" },
1151  { 0xa401, "exif:CustomRendered" },
1152  { 0xa402, "exif:ExposureMode" },
1153  { 0xa403, "exif:WhiteBalance" },
1154  { 0xa404, "exif:DigitalZoomRatio" },
1155  { 0xa405, "exif:FocalLengthIn35mmFilm" },
1156  { 0xa406, "exif:SceneCaptureType" },
1157  { 0xa407, "exif:GainControl" },
1158  { 0xa408, "exif:Contrast" },
1159  { 0xa409, "exif:Saturation" },
1160  { 0xa40a, "exif:Sharpness" },
1161  { 0xa40b, "exif:DeviceSettingDescription" },
1162  { 0xa40c, "exif:SubjectDistanceRange" },
1163  { 0xa420, "exif:ImageUniqueID" },
1164  { 0xc4a5, "exif:PrintImageMatching" },
1165  { 0xa500, "exif:Gamma" },
1166  { 0xc640, "exif:CR2Slice" },
1167  { 0x10000, "exif:GPSVersionID" },
1168  { 0x10001, "exif:GPSLatitudeRef" },
1169  { 0x10002, "exif:GPSLatitude" },
1170  { 0x10003, "exif:GPSLongitudeRef" },
1171  { 0x10004, "exif:GPSLongitude" },
1172  { 0x10005, "exif:GPSAltitudeRef" },
1173  { 0x10006, "exif:GPSAltitude" },
1174  { 0x10007, "exif:GPSTimeStamp" },
1175  { 0x10008, "exif:GPSSatellites" },
1176  { 0x10009, "exif:GPSStatus" },
1177  { 0x1000a, "exif:GPSMeasureMode" },
1178  { 0x1000b, "exif:GPSDop" },
1179  { 0x1000c, "exif:GPSSpeedRef" },
1180  { 0x1000d, "exif:GPSSpeed" },
1181  { 0x1000e, "exif:GPSTrackRef" },
1182  { 0x1000f, "exif:GPSTrack" },
1183  { 0x10010, "exif:GPSImgDirectionRef" },
1184  { 0x10011, "exif:GPSImgDirection" },
1185  { 0x10012, "exif:GPSMapDatum" },
1186  { 0x10013, "exif:GPSDestLatitudeRef" },
1187  { 0x10014, "exif:GPSDestLatitude" },
1188  { 0x10015, "exif:GPSDestLongitudeRef" },
1189  { 0x10016, "exif:GPSDestLongitude" },
1190  { 0x10017, "exif:GPSDestBearingRef" },
1191  { 0x10018, "exif:GPSDestBearing" },
1192  { 0x10019, "exif:GPSDestDistanceRef" },
1193  { 0x1001a, "exif:GPSDestDistance" },
1194  { 0x1001b, "exif:GPSProcessingMethod" },
1195  { 0x1001c, "exif:GPSAreaInformation" },
1196  { 0x1001d, "exif:GPSDateStamp" },
1197  { 0x1001e, "exif:GPSDifferential" },
1198  { 0x00000, (const char *) NULL }
1199  };
1200 
1201  const StringInfo
1202  *profile;
1203 
1204  const unsigned char
1205  *directory,
1206  *exif;
1207 
1208  DirectoryInfo
1209  directory_stack[MaxDirectoryStack];
1210 
1211  EndianType
1212  endian;
1213 
1215  status;
1216 
1217  register ssize_t
1218  i;
1219 
1220  size_t
1221  entry,
1222  length,
1223  number_entries,
1224  tag,
1225  tag_value;
1226 
1228  *exif_resources;
1229 
1230  ssize_t
1231  all,
1232  id,
1233  level,
1234  offset,
1235  tag_offset;
1236 
1237  static int
1238  tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1239 
1240  /*
1241  If EXIF data exists, then try to parse the request for a tag.
1242  */
1243  profile=GetImageProfile(image,"exif");
1244  if (profile == (const StringInfo *) NULL)
1245  return(MagickFalse);
1246  if ((property == (const char *) NULL) || (*property == '\0'))
1247  return(MagickFalse);
1248  while (isspace((int) ((unsigned char) *property)) != 0)
1249  property++;
1250  if (strlen(property) <= 5)
1251  return(MagickFalse);
1252  all=0;
1253  tag=(~0UL);
1254  switch (*(property+5))
1255  {
1256  case '*':
1257  {
1258  /*
1259  Caller has asked for all the tags in the EXIF data.
1260  */
1261  tag=0;
1262  all=1; /* return the data in description=value format */
1263  break;
1264  }
1265  case '!':
1266  {
1267  tag=0;
1268  all=2; /* return the data in tagid=value format */
1269  break;
1270  }
1271  case '#':
1272  case '@':
1273  {
1274  int
1275  c;
1276 
1277  size_t
1278  n;
1279 
1280  /*
1281  Check for a hex based tag specification first.
1282  */
1283  tag=(*(property+5) == '@') ? 1UL : 0UL;
1284  property+=6;
1285  n=strlen(property);
1286  if (n != 4)
1287  return(MagickFalse);
1288  /*
1289  Parse tag specification as a hex number.
1290  */
1291  n/=4;
1292  do
1293  {
1294  for (i=(ssize_t) n-1L; i >= 0; i--)
1295  {
1296  c=(*property++);
1297  tag<<=4;
1298  if ((c >= '0') && (c <= '9'))
1299  tag|=(c-'0');
1300  else
1301  if ((c >= 'A') && (c <= 'F'))
1302  tag|=(c-('A'-10));
1303  else
1304  if ((c >= 'a') && (c <= 'f'))
1305  tag|=(c-('a'-10));
1306  else
1307  return(MagickFalse);
1308  }
1309  } while (*property != '\0');
1310  break;
1311  }
1312  default:
1313  {
1314  /*
1315  Try to match the text with a tag name instead.
1316  */
1317  for (i=0; ; i++)
1318  {
1319  if (EXIFTag[i].tag == 0)
1320  break;
1321  if (LocaleCompare(EXIFTag[i].description,property) == 0)
1322  {
1323  tag=(size_t) EXIFTag[i].tag;
1324  break;
1325  }
1326  }
1327  break;
1328  }
1329  }
1330  if (tag == (~0UL))
1331  return(MagickFalse);
1332  length=GetStringInfoLength(profile);
1333  exif=GetStringInfoDatum(profile);
1334  while (length != 0)
1335  {
1336  if (ReadPropertyByte(&exif,&length) != 0x45)
1337  continue;
1338  if (ReadPropertyByte(&exif,&length) != 0x78)
1339  continue;
1340  if (ReadPropertyByte(&exif,&length) != 0x69)
1341  continue;
1342  if (ReadPropertyByte(&exif,&length) != 0x66)
1343  continue;
1344  if (ReadPropertyByte(&exif,&length) != 0x00)
1345  continue;
1346  if (ReadPropertyByte(&exif,&length) != 0x00)
1347  continue;
1348  break;
1349  }
1350  if (length < 16)
1351  return(MagickFalse);
1352  id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1353  endian=LSBEndian;
1354  if (id == 0x4949)
1355  endian=LSBEndian;
1356  else
1357  if (id == 0x4D4D)
1358  endian=MSBEndian;
1359  else
1360  return(MagickFalse);
1361  if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1362  return(MagickFalse);
1363  /*
1364  This the offset to the first IFD.
1365  */
1366  offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1367  if ((offset < 0) || (size_t) offset >= length)
1368  return(MagickFalse);
1369  /*
1370  Set the pointer to the first IFD and follow it were it leads.
1371  */
1372  status=MagickFalse;
1373  directory=exif+offset;
1374  level=0;
1375  entry=0;
1376  tag_offset=0;
1377  exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,
1378  (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
1379  do
1380  {
1381  /*
1382  If there is anything on the stack then pop it off.
1383  */
1384  if (level > 0)
1385  {
1386  level--;
1387  directory=directory_stack[level].directory;
1388  entry=directory_stack[level].entry;
1389  tag_offset=directory_stack[level].offset;
1390  }
1391  if ((directory < exif) || (directory > (exif+length-2)))
1392  break;
1393  /*
1394  Determine how many entries there are in the current IFD.
1395  */
1396  number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1397  for ( ; entry < number_entries; entry++)
1398  {
1399  register unsigned char
1400  *p,
1401  *q;
1402 
1403  size_t
1404  format;
1405 
1406  ssize_t
1407  number_bytes,
1408  components;
1409 
1410  q=(unsigned char *) (directory+(12*entry)+2);
1411  if (q > (exif+length-12))
1412  break; /* corrupt EXIF */
1413  if (GetValueFromSplayTree(exif_resources,q) == q)
1414  break;
1415  (void) AddValueToSplayTree(exif_resources,q,q);
1416  tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;
1417  format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1418  if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1419  break;
1420  components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1421  if (components < 0)
1422  break; /* corrupt EXIF */
1423  number_bytes=(size_t) components*tag_bytes[format];
1424  if (number_bytes < components)
1425  break; /* prevent overflow */
1426  if (number_bytes <= 4)
1427  p=q+8;
1428  else
1429  {
1430  ssize_t
1431  offset;
1432 
1433  /*
1434  The directory entry contains an offset.
1435  */
1436  offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1437  if ((offset < 0) || (size_t) offset >= length)
1438  continue;
1439  if ((ssize_t) (offset+number_bytes) < offset)
1440  continue; /* prevent overflow */
1441  if ((size_t) (offset+number_bytes) > length)
1442  continue;
1443  p=(unsigned char *) (exif+offset);
1444  }
1445  if ((all != 0) || (tag == (size_t) tag_value))
1446  {
1447  char
1448  buffer[MagickPathExtent],
1449  *value;
1450 
1451  value=(char *) NULL;
1452  *buffer='\0';
1453  switch (format)
1454  {
1455  case EXIF_FMT_BYTE:
1456  case EXIF_FMT_UNDEFINED:
1457  {
1458  EXIFMultipleValues(1,"%.20g",(double) (*(unsigned char *) p1));
1459  break;
1460  }
1461  case EXIF_FMT_SBYTE:
1462  {
1463  EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1464  break;
1465  }
1466  case EXIF_FMT_SSHORT:
1467  {
1468  EXIFMultipleValues(2,"%hd",ReadPropertySignedShort(endian,p1));
1469  break;
1470  }
1471  case EXIF_FMT_USHORT:
1472  {
1473  EXIFMultipleValues(2,"%hu",ReadPropertyUnsignedShort(endian,p1));
1474  break;
1475  }
1476  case EXIF_FMT_ULONG:
1477  {
1478  EXIFMultipleValues(4,"%.20g",(double)
1479  ReadPropertyUnsignedLong(endian,p1));
1480  break;
1481  }
1482  case EXIF_FMT_SLONG:
1483  {
1484  EXIFMultipleValues(4,"%.20g",(double)
1485  ReadPropertySignedLong(endian,p1));
1486  break;
1487  }
1488  case EXIF_FMT_URATIONAL:
1489  {
1490  EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1491  ReadPropertyUnsignedLong(endian,p1),(double)
1492  ReadPropertyUnsignedLong(endian,p1+4));
1493  break;
1494  }
1495  case EXIF_FMT_SRATIONAL:
1496  {
1497  EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1498  ReadPropertySignedLong(endian,p1),(double)
1499  ReadPropertySignedLong(endian,p1+4));
1500  break;
1501  }
1502  case EXIF_FMT_SINGLE:
1503  {
1504  EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1505  break;
1506  }
1507  case EXIF_FMT_DOUBLE:
1508  {
1509  EXIFMultipleValues(8,"%f",*(double *) p1);
1510  break;
1511  }
1512  default:
1513  case EXIF_FMT_STRING:
1514  {
1515  value=(char *) NULL;
1516  if (~((size_t) number_bytes) >= 1)
1517  value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1518  sizeof(*value));
1519  if (value != (char *) NULL)
1520  {
1521  register ssize_t
1522  i;
1523 
1524  for (i=0; i < (ssize_t) number_bytes; i++)
1525  {
1526  value[i]='.';
1527  if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1528  value[i]=(char) p[i];
1529  }
1530  value[i]='\0';
1531  }
1532  break;
1533  }
1534  }
1535  if (value != (char *) NULL)
1536  {
1537  char
1538  *key;
1539 
1540  register const char
1541  *p;
1542 
1543  key=AcquireString(property);
1544  switch (all)
1545  {
1546  case 1:
1547  {
1548  const char
1549  *description;
1550 
1551  register ssize_t
1552  i;
1553 
1554  description="unknown";
1555  for (i=0; ; i++)
1556  {
1557  if (EXIFTag[i].tag == 0)
1558  break;
1559  if (EXIFTag[i].tag == tag_value)
1560  {
1561  description=EXIFTag[i].description;
1562  break;
1563  }
1564  }
1565  (void) FormatLocaleString(key,MagickPathExtent,"%s",
1566  description);
1567  if (level == 2)
1568  (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1569  break;
1570  }
1571  case 2:
1572  {
1573  if (tag_value < 0x10000)
1574  (void) FormatLocaleString(key,MagickPathExtent,"#%04lx",
1575  (unsigned long) tag_value);
1576  else
1577  if (tag_value < 0x20000)
1578  (void) FormatLocaleString(key,MagickPathExtent,"@%04lx",
1579  (unsigned long) (tag_value & 0xffff));
1580  else
1581  (void) FormatLocaleString(key,MagickPathExtent,"unknown");
1582  break;
1583  }
1584  default:
1585  {
1586  if (level == 2)
1587  (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1588  }
1589  }
1590  p=(const char *) NULL;
1591  if (image->properties != (void *) NULL)
1592  p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1593  image->properties,key);
1594  if (p == (const char *) NULL)
1595  (void) SetImageProperty((Image *) image,key,value,exception);
1596  value=DestroyString(value);
1597  key=DestroyString(key);
1598  status=MagickTrue;
1599  }
1600  }
1601  if ((tag_value == TAG_EXIF_OFFSET) ||
1602  (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1603  {
1604  ssize_t
1605  offset;
1606 
1607  offset=(ssize_t) ReadPropertySignedLong(endian,p);
1608  if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1609  {
1610  ssize_t
1611  tag_offset1;
1612 
1613  tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1614  0);
1615  directory_stack[level].directory=directory;
1616  entry++;
1617  directory_stack[level].entry=entry;
1618  directory_stack[level].offset=tag_offset;
1619  level++;
1620  directory_stack[level].directory=exif+offset;
1621  directory_stack[level].offset=tag_offset1;
1622  directory_stack[level].entry=0;
1623  level++;
1624  if ((directory+2+(12*number_entries)) > (exif+length))
1625  break;
1626  offset=(ssize_t) ReadPropertySignedLong(endian,directory+2+(12*
1627  number_entries));
1628  if ((offset != 0) && ((size_t) offset < length) &&
1629  (level < (MaxDirectoryStack-2)))
1630  {
1631  directory_stack[level].directory=exif+offset;
1632  directory_stack[level].entry=0;
1633  directory_stack[level].offset=tag_offset1;
1634  level++;
1635  }
1636  }
1637  break;
1638  }
1639  }
1640  } while (level > 0);
1641  exif_resources=DestroySplayTree(exif_resources);
1642  return(status);
1643 }
1644 
1645 static MagickBooleanType GetICCProperty(const Image *image,const char *property,
1646  ExceptionInfo *exception)
1647 {
1648  const StringInfo
1649  *profile;
1650 
1651  magick_unreferenced(property);
1652 
1653  profile=GetImageProfile(image,"icc");
1654  if (profile == (StringInfo *) NULL)
1655  profile=GetImageProfile(image,"icm");
1656  if (profile == (StringInfo *) NULL)
1657  return(MagickFalse);
1658  if (GetStringInfoLength(profile) < 128)
1659  return(MagickFalse); /* minimum ICC profile length */
1660 #if defined(MAGICKCORE_LCMS_DELEGATE)
1661  {
1662  cmsHPROFILE
1663  icc_profile;
1664 
1665  icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1666  (cmsUInt32Number) GetStringInfoLength(profile));
1667  if (icc_profile != (cmsHPROFILE *) NULL)
1668  {
1669 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1670  const char
1671  *name;
1672 
1673  name=cmsTakeProductName(icc_profile);
1674  if (name != (const char *) NULL)
1675  (void) SetImageProperty((Image *) image,"icc:name",name,exception);
1676 #else
1677  char
1678  info[MagickPathExtent];
1679 
1680  (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,"en","US",
1681  info,MagickPathExtent);
1682  (void) SetImageProperty((Image *) image,"icc:description",info,
1683  exception);
1684  (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,"en","US",
1685  info,MagickPathExtent);
1686  (void) SetImageProperty((Image *) image,"icc:manufacturer",info,
1687  exception);
1688  (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en","US",info,
1690  (void) SetImageProperty((Image *) image,"icc:model",info,exception);
1691  (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,"en","US",
1692  info,MagickPathExtent);
1693  (void) SetImageProperty((Image *) image,"icc:copyright",info,exception);
1694 #endif
1695  (void) cmsCloseProfile(icc_profile);
1696  }
1697  }
1698 #endif
1699  return(MagickTrue);
1700 }
1701 
1702 static MagickBooleanType SkipXMPValue(const char *value)
1703 {
1704  if (value == (const char*) NULL)
1705  return(MagickTrue);
1706  while (*value != '\0')
1707  {
1708  if (isspace((int) ((unsigned char) *value)) == 0)
1709  return(MagickFalse);
1710  value++;
1711  }
1712  return(MagickTrue);
1713 }
1714 
1715 static MagickBooleanType GetXMPProperty(const Image *image,const char *property)
1716 {
1717  char
1718  *xmp_profile;
1719 
1720  const char
1721  *content;
1722 
1723  const StringInfo
1724  *profile;
1725 
1727  *exception;
1728 
1730  status;
1731 
1732  register const char
1733  *p;
1734 
1735  XMLTreeInfo
1736  *child,
1737  *description,
1738  *node,
1739  *rdf,
1740  *xmp;
1741 
1742  profile=GetImageProfile(image,"xmp");
1743  if (profile == (StringInfo *) NULL)
1744  return(MagickFalse);
1745  if ((property == (const char *) NULL) || (*property == '\0'))
1746  return(MagickFalse);
1747  xmp_profile=StringInfoToString(profile);
1748  if (xmp_profile == (char *) NULL)
1749  return(MagickFalse);
1750  for (p=xmp_profile; *p != '\0'; p++)
1751  if ((*p == '<') && (*(p+1) == 'x'))
1752  break;
1753  exception=AcquireExceptionInfo();
1754  xmp=NewXMLTree((char *) p,exception);
1755  xmp_profile=DestroyString(xmp_profile);
1756  exception=DestroyExceptionInfo(exception);
1757  if (xmp == (XMLTreeInfo *) NULL)
1758  return(MagickFalse);
1759  status=MagickFalse;
1760  rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1761  if (rdf != (XMLTreeInfo *) NULL)
1762  {
1763  if (image->properties == (void *) NULL)
1764  ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1766  description=GetXMLTreeChild(rdf,"rdf:Description");
1767  while (description != (XMLTreeInfo *) NULL)
1768  {
1769  char
1770  *xmp_namespace;
1771 
1772  node=GetXMLTreeChild(description,(const char *) NULL);
1773  while (node != (XMLTreeInfo *) NULL)
1774  {
1775  child=GetXMLTreeChild(node,(const char *) NULL);
1776  content=GetXMLTreeContent(node);
1777  if ((child == (XMLTreeInfo *) NULL) &&
1778  (SkipXMPValue(content) == MagickFalse))
1779  {
1780  xmp_namespace=ConstantString(GetXMLTreeTag(node));
1781  (void) SubstituteString(&xmp_namespace,"exif:","xmp:");
1782  (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1783  xmp_namespace,ConstantString(content));
1784  }
1785  while (child != (XMLTreeInfo *) NULL)
1786  {
1787  content=GetXMLTreeContent(child);
1788  if (SkipXMPValue(content) == MagickFalse)
1789  {
1790  xmp_namespace=ConstantString(GetXMLTreeTag(node));
1791  (void) SubstituteString(&xmp_namespace,"exif:","xmp:");
1792  (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1793  xmp_namespace,ConstantString(content));
1794  }
1795  child=GetXMLTreeSibling(child);
1796  }
1797  node=GetXMLTreeSibling(node);
1798  }
1799  description=GetNextXMLTreeTag(description);
1800  }
1801  }
1802  xmp=DestroyXMLTree(xmp);
1803  return(status);
1804 }
1805 
1806 static char *TracePSClippath(const unsigned char *blob,size_t length)
1807 {
1808  char
1809  *path,
1810  *message;
1811 
1813  in_subpath;
1814 
1815  PointInfo
1816  first[3],
1817  last[3],
1818  point[3];
1819 
1820  register ssize_t
1821  i,
1822  x;
1823 
1824  ssize_t
1825  knot_count,
1826  selector,
1827  y;
1828 
1829  path=AcquireString((char *) NULL);
1830  if (path == (char *) NULL)
1831  return((char *) NULL);
1832  message=AcquireString((char *) NULL);
1833  (void) FormatLocaleString(message,MagickPathExtent,"/ClipImage\n");
1834  (void) ConcatenateString(&path,message);
1835  (void) FormatLocaleString(message,MagickPathExtent,"{\n");
1836  (void) ConcatenateString(&path,message);
1837  (void) FormatLocaleString(message,MagickPathExtent,
1838  " /c {curveto} bind def\n");
1839  (void) ConcatenateString(&path,message);
1840  (void) FormatLocaleString(message,MagickPathExtent,
1841  " /l {lineto} bind def\n");
1842  (void) ConcatenateString(&path,message);
1843  (void) FormatLocaleString(message,MagickPathExtent,
1844  " /m {moveto} bind def\n");
1845  (void) ConcatenateString(&path,message);
1846  (void) FormatLocaleString(message,MagickPathExtent,
1847  " /v {currentpoint 6 2 roll curveto} bind def\n");
1848  (void) ConcatenateString(&path,message);
1849  (void) FormatLocaleString(message,MagickPathExtent,
1850  " /y {2 copy curveto} bind def\n");
1851  (void) ConcatenateString(&path,message);
1852  (void) FormatLocaleString(message,MagickPathExtent,
1853  " /z {closepath} bind def\n");
1854  (void) ConcatenateString(&path,message);
1855  (void) FormatLocaleString(message,MagickPathExtent," newpath\n");
1856  (void) ConcatenateString(&path,message);
1857  /*
1858  The clipping path format is defined in "Adobe Photoshop File Formats
1859  Specification" version 6.0 downloadable from adobe.com.
1860  */
1861  (void) ResetMagickMemory(point,0,sizeof(point));
1862  (void) ResetMagickMemory(first,0,sizeof(first));
1863  (void) ResetMagickMemory(last,0,sizeof(last));
1864  knot_count=0;
1865  in_subpath=MagickFalse;
1866  while (length > 0)
1867  {
1868  selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1869  switch (selector)
1870  {
1871  case 0:
1872  case 3:
1873  {
1874  if (knot_count != 0)
1875  {
1876  blob+=24;
1877  length-=MagickMin(24,(ssize_t) length);
1878  break;
1879  }
1880  /*
1881  Expected subpath length record.
1882  */
1883  knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1884  blob+=22;
1885  length-=MagickMin(22,(ssize_t) length);
1886  break;
1887  }
1888  case 1:
1889  case 2:
1890  case 4:
1891  case 5:
1892  {
1893  if (knot_count == 0)
1894  {
1895  /*
1896  Unexpected subpath knot
1897  */
1898  blob+=24;
1899  length-=MagickMin(24,(ssize_t) length);
1900  break;
1901  }
1902  /*
1903  Add sub-path knot
1904  */
1905  for (i=0; i < 3; i++)
1906  {
1907  size_t
1908  xx,
1909  yy;
1910 
1911  yy=(size_t) ReadPropertyMSBLong(&blob,&length);
1912  xx=(size_t) ReadPropertyMSBLong(&blob,&length);
1913  x=(ssize_t) xx;
1914  if (xx > 2147483647)
1915  x=(ssize_t) xx-4294967295U-1;
1916  y=(ssize_t) yy;
1917  if (yy > 2147483647)
1918  y=(ssize_t) yy-4294967295U-1;
1919  point[i].x=(double) x/4096/4096;
1920  point[i].y=1.0-(double) y/4096/4096;
1921  }
1922  if (in_subpath == MagickFalse)
1923  {
1924  (void) FormatLocaleString(message,MagickPathExtent," %g %g m\n",
1925  point[1].x,point[1].y);
1926  for (i=0; i < 3; i++)
1927  {
1928  first[i]=point[i];
1929  last[i]=point[i];
1930  }
1931  }
1932  else
1933  {
1934  /*
1935  Handle special cases when Bezier curves are used to describe
1936  corners and straight lines.
1937  */
1938  if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1939  (point[0].x == point[1].x) && (point[0].y == point[1].y))
1940  (void) FormatLocaleString(message,MagickPathExtent,
1941  " %g %g l\n",point[1].x,point[1].y);
1942  else
1943  if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1944  (void) FormatLocaleString(message,MagickPathExtent,
1945  " %g %g %g %g v\n",point[0].x,point[0].y,
1946  point[1].x,point[1].y);
1947  else
1948  if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1949  (void) FormatLocaleString(message,MagickPathExtent,
1950  " %g %g %g %g y\n",last[2].x,last[2].y,
1951  point[1].x,point[1].y);
1952  else
1953  (void) FormatLocaleString(message,MagickPathExtent,
1954  " %g %g %g %g %g %g c\n",last[2].x,
1955  last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1956  for (i=0; i < 3; i++)
1957  last[i]=point[i];
1958  }
1959  (void) ConcatenateString(&path,message);
1960  in_subpath=MagickTrue;
1961  knot_count--;
1962  /*
1963  Close the subpath if there are no more knots.
1964  */
1965  if (knot_count == 0)
1966  {
1967  /*
1968  Same special handling as above except we compare to the
1969  first point in the path and close the path.
1970  */
1971  if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1972  (first[0].x == first[1].x) && (first[0].y == first[1].y))
1973  (void) FormatLocaleString(message,MagickPathExtent,
1974  " %g %g l z\n",first[1].x,first[1].y);
1975  else
1976  if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1977  (void) FormatLocaleString(message,MagickPathExtent,
1978  " %g %g %g %g v z\n",first[0].x,first[0].y,
1979  first[1].x,first[1].y);
1980  else
1981  if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1982  (void) FormatLocaleString(message,MagickPathExtent,
1983  " %g %g %g %g y z\n",last[2].x,last[2].y,
1984  first[1].x,first[1].y);
1985  else
1986  (void) FormatLocaleString(message,MagickPathExtent,
1987  " %g %g %g %g %g %g c z\n",last[2].x,
1988  last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1989  (void) ConcatenateString(&path,message);
1990  in_subpath=MagickFalse;
1991  }
1992  break;
1993  }
1994  case 6:
1995  case 7:
1996  case 8:
1997  default:
1998  {
1999  blob+=24;
2000  length-=MagickMin(24,(ssize_t) length);
2001  break;
2002  }
2003  }
2004  }
2005  /*
2006  Returns an empty PS path if the path has no knots.
2007  */
2008  (void) FormatLocaleString(message,MagickPathExtent," eoclip\n");
2009  (void) ConcatenateString(&path,message);
2010  (void) FormatLocaleString(message,MagickPathExtent,"} bind def");
2011  (void) ConcatenateString(&path,message);
2012  message=DestroyString(message);
2013  return(path);
2014 }
2015 
2016 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
2017  const size_t columns,const size_t rows)
2018 {
2019  char
2020  *path,
2021  *message;
2022 
2024  in_subpath;
2025 
2026  PointInfo
2027  first[3],
2028  last[3],
2029  point[3];
2030 
2031  register ssize_t
2032  i;
2033 
2034  ssize_t
2035  knot_count,
2036  selector,
2037  x,
2038  y;
2039 
2040  path=AcquireString((char *) NULL);
2041  if (path == (char *) NULL)
2042  return((char *) NULL);
2043  message=AcquireString((char *) NULL);
2044  (void) FormatLocaleString(message,MagickPathExtent,(
2045  "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2046  "<svg xmlns=\"http://www.w3.org/2000/svg\""
2047  " width=\"%.20g\" height=\"%.20g\">\n"
2048  "<g>\n"
2049  "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2050  "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(double) columns,
2051  (double) rows);
2052  (void) ConcatenateString(&path,message);
2053  (void) ResetMagickMemory(point,0,sizeof(point));
2054  (void) ResetMagickMemory(first,0,sizeof(first));
2055  (void) ResetMagickMemory(last,0,sizeof(last));
2056  knot_count=0;
2057  in_subpath=MagickFalse;
2058  while (length != 0)
2059  {
2060  selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2061  switch (selector)
2062  {
2063  case 0:
2064  case 3:
2065  {
2066  if (knot_count != 0)
2067  {
2068  blob+=24;
2069  length-=MagickMin(24,(ssize_t) length);
2070  break;
2071  }
2072  /*
2073  Expected subpath length record.
2074  */
2075  knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2076  blob+=22;
2077  length-=MagickMin(22,(ssize_t) length);
2078  break;
2079  }
2080  case 1:
2081  case 2:
2082  case 4:
2083  case 5:
2084  {
2085  if (knot_count == 0)
2086  {
2087  /*
2088  Unexpected subpath knot.
2089  */
2090  blob+=24;
2091  length-=MagickMin(24,(ssize_t) length);
2092  break;
2093  }
2094  /*
2095  Add sub-path knot
2096  */
2097  for (i=0; i < 3; i++)
2098  {
2099  unsigned int
2100  xx,
2101  yy;
2102 
2103  yy=(unsigned int) ReadPropertyMSBLong(&blob,&length);
2104  xx=(unsigned int) ReadPropertyMSBLong(&blob,&length);
2105  x=(ssize_t) xx;
2106  if (xx > 2147483647)
2107  x=(ssize_t) xx-4294967295U-1;
2108  y=(ssize_t) yy;
2109  if (yy > 2147483647)
2110  y=(ssize_t) yy-4294967295U-1;
2111  point[i].x=(double) x*columns/4096/4096;
2112  point[i].y=(double) y*rows/4096/4096;
2113  }
2114  if (in_subpath == MagickFalse)
2115  {
2116  (void) FormatLocaleString(message,MagickPathExtent,"M %g %g\n",
2117  point[1].x,point[1].y);
2118  for (i=0; i < 3; i++)
2119  {
2120  first[i]=point[i];
2121  last[i]=point[i];
2122  }
2123  }
2124  else
2125  {
2126  /*
2127  Handle special cases when Bezier curves are used to describe
2128  corners and straight lines.
2129  */
2130  if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2131  (point[0].x == point[1].x) && (point[0].y == point[1].y))
2132  (void) FormatLocaleString(message,MagickPathExtent,
2133  "L %g %g\n",point[1].x,point[1].y);
2134  else
2135  (void) FormatLocaleString(message,MagickPathExtent,
2136  "C %g %g %g %g %g %g\n",last[2].x,
2137  last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2138  for (i=0; i < 3; i++)
2139  last[i]=point[i];
2140  }
2141  (void) ConcatenateString(&path,message);
2142  in_subpath=MagickTrue;
2143  knot_count--;
2144  /*
2145  Close the subpath if there are no more knots.
2146  */
2147  if (knot_count == 0)
2148  {
2149  /*
2150  Same special handling as above except we compare to the
2151  first point in the path and close the path.
2152  */
2153  if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2154  (first[0].x == first[1].x) && (first[0].y == first[1].y))
2155  (void) FormatLocaleString(message,MagickPathExtent,
2156  "L %g %g Z\n",first[1].x,first[1].y);
2157  else
2158  (void) FormatLocaleString(message,MagickPathExtent,
2159  "C %g %g %g %g %g %g Z\n",last[2].x,
2160  last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2161  (void) ConcatenateString(&path,message);
2162  in_subpath=MagickFalse;
2163  }
2164  break;
2165  }
2166  case 6:
2167  case 7:
2168  case 8:
2169  default:
2170  {
2171  blob+=24;
2172  length-=MagickMin(24,(ssize_t) length);
2173  break;
2174  }
2175  }
2176  }
2177  /*
2178  Return an empty SVG image if the path does not have knots.
2179  */
2180  (void) ConcatenateString(&path,"\"/>\n</g>\n</svg>\n");
2181  message=DestroyString(message);
2182  return(path);
2183 }
2184 
2185 MagickExport const char *GetImageProperty(const Image *image,
2186  const char *property,ExceptionInfo *exception)
2187 {
2188  register const char
2189  *p;
2190 
2191  assert(image != (Image *) NULL);
2192  assert(image->signature == MagickCoreSignature);
2193  if (image->debug != MagickFalse)
2194  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2195  p=(const char *) NULL;
2196  if (image->properties != (void *) NULL)
2197  {
2198  if (property == (const char *) NULL)
2199  return((const char *) GetRootValueFromSplayTree((SplayTreeInfo *)
2200  image->properties));
2201  p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2202  image->properties,property);
2203  if (p != (const char *) NULL)
2204  return(p);
2205  }
2206  if ((property == (const char *) NULL) ||
2207  (strchr(property,':') == (char *) NULL))
2208  return(p);
2209  switch (*property)
2210  {
2211  case '8':
2212  {
2213  if (LocaleNCompare("8bim:",property,5) == 0)
2214  {
2215  (void) Get8BIMProperty(image,property,exception);
2216  break;
2217  }
2218  break;
2219  }
2220  case 'E':
2221  case 'e':
2222  {
2223  if (LocaleNCompare("exif:",property,5) == 0)
2224  {
2225  (void) GetEXIFProperty(image,property,exception);
2226  break;
2227  }
2228  break;
2229  }
2230  case 'I':
2231  case 'i':
2232  {
2233  if ((LocaleNCompare("icc:",property,4) == 0) ||
2234  (LocaleNCompare("icm:",property,4) == 0))
2235  {
2236  (void) GetICCProperty(image,property,exception);
2237  break;
2238  }
2239  if (LocaleNCompare("iptc:",property,5) == 0)
2240  {
2241  (void) GetIPTCProperty(image,property,exception);
2242  break;
2243  }
2244  break;
2245  }
2246  case 'X':
2247  case 'x':
2248  {
2249  if (LocaleNCompare("xmp:",property,4) == 0)
2250  {
2251  (void) GetXMPProperty(image,property);
2252  break;
2253  }
2254  break;
2255  }
2256  default:
2257  break;
2258  }
2259  if (image->properties != (void *) NULL)
2260  {
2261  p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2262  image->properties,property);
2263  return(p);
2264  }
2265  return((const char *) NULL);
2266 }
2267 
2268 /*
2269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2270 % %
2271 % %
2272 % %
2273 + G e t M a g i c k P r o p e r t y %
2274 % %
2275 % %
2276 % %
2277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2278 %
2279 % GetMagickProperty() gets attributes or calculated values that is associated
2280 % with a fixed known property name, or single letter property. It may be
2281 % called if no image is defined (IMv7), in which case only global image_info
2282 % values are available:
2283 %
2284 % \n newline
2285 % \r carriage return
2286 % < less-than character.
2287 % > greater-than character.
2288 % & ampersand character.
2289 % %% a percent sign
2290 % %b file size of image read in
2291 % %c comment meta-data property
2292 % %d directory component of path
2293 % %e filename extension or suffix
2294 % %f filename (including suffix)
2295 % %g layer canvas page geometry (equivalent to "%Wx%H%X%Y")
2296 % %h current image height in pixels
2297 % %i image filename (note: becomes output filename for "info:")
2298 % %k CALCULATED: number of unique colors
2299 % %l label meta-data property
2300 % %m image file format (file magic)
2301 % %n number of images in current image sequence
2302 % %o output filename (used for delegates)
2303 % %p index of image in current image list
2304 % %q quantum depth (compile-time constant)
2305 % %r image class and colorspace
2306 % %s scene number (from input unless re-assigned)
2307 % %t filename without directory or extension (suffix)
2308 % %u unique temporary filename (used for delegates)
2309 % %w current width in pixels
2310 % %x x resolution (density)
2311 % %y y resolution (density)
2312 % %z image depth (as read in unless modified, image save depth)
2313 % %A image transparency channel enabled (true/false)
2314 % %C image compression type
2315 % %D image GIF dispose method
2316 % %G original image size (%wx%h; before any resizes)
2317 % %H page (canvas) height
2318 % %M Magick filename (original file exactly as given, including read mods)
2319 % %O page (canvas) offset ( = %X%Y )
2320 % %P page (canvas) size ( = %Wx%H )
2321 % %Q image compression quality ( 0 = default )
2322 % %S ?? scenes ??
2323 % %T image time delay (in centi-seconds)
2324 % %U image resolution units
2325 % %W page (canvas) width
2326 % %X page (canvas) x offset (including sign)
2327 % %Y page (canvas) y offset (including sign)
2328 % %Z unique filename (used for delegates)
2329 % %@ CALCULATED: trim bounding box (without actually trimming)
2330 % %# CALCULATED: 'signature' hash of image values
2331 %
2332 % This routine only handles specifically known properties. It does not
2333 % handle special prefixed properties, profiles, or expressions. Nor does
2334 % it return any free-form property strings.
2335 %
2336 % The returned string is stored in a structure somewhere, and should not be
2337 % directly freed. If the string was generated (common) the string will be
2338 % stored as as either as artifact or option 'get-property'. These may be
2339 % deleted (cleaned up) when no longer required, but neither artifact or
2340 % option is guranteed to exist.
2341 %
2342 % The format of the GetMagickProperty method is:
2343 %
2344 % const char *GetMagickProperty(ImageInfo *image_info,Image *image,
2345 % const char *property,ExceptionInfo *exception)
2346 %
2347 % A description of each parameter follows:
2348 %
2349 % o image_info: the image info (optional)
2350 %
2351 % o image: the image (optional)
2352 %
2353 % o key: the key.
2354 %
2355 % o exception: return any errors or warnings in this structure.
2356 %
2357 */
2358 static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2359  Image *image,const char letter,ExceptionInfo *exception)
2360 {
2361 #define WarnNoImageReturn(format,arg) \
2362  if (image == (Image *) NULL ) { \
2363  (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2364  "NoImageForProperty",format,arg); \
2365  return((const char *) NULL); \
2366  }
2367 #define WarnNoImageInfoReturn(format,arg) \
2368  if (image_info == (ImageInfo *) NULL ) { \
2369  (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2370  "NoImageInfoForProperty",format,arg); \
2371  return((const char *) NULL); \
2372  }
2373 
2374  char
2375  value[MagickPathExtent]; /* formatted string to store as an artifact */
2376 
2377  const char
2378  *string; /* return a string already stored somewher */
2379 
2380  if ((image != (Image *) NULL) && (image->debug != MagickFalse))
2381  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2382  else
2383  if ((image_info != (ImageInfo *) NULL) &&
2384  (image_info->debug != MagickFalse))
2385  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2386  *value='\0'; /* formatted string */
2387  string=(char *) NULL; /* constant string reference */
2388  /*
2389  Get properities that are directly defined by images.
2390  */
2391  switch (letter)
2392  {
2393  case 'b': /* image size read in - in bytes */
2394  {
2395  WarnNoImageReturn("\"%%%c\"",letter);
2397  value);
2398  if (image->extent == 0)
2399  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
2400  MagickPathExtent,value);
2401  break;
2402  }
2403  case 'c': /* image comment property - empty string by default */
2404  {
2405  WarnNoImageReturn("\"%%%c\"",letter);
2406  string=GetImageProperty(image,"comment",exception);
2407  if ( string == (const char *) NULL )
2408  string="";
2409  break;
2410  }
2411  case 'd': /* Directory component of filename */
2412  {
2413  WarnNoImageReturn("\"%%%c\"",letter);
2415  if (*value == '\0')
2416  string="";
2417  break;
2418  }
2419  case 'e': /* Filename extension (suffix) of image file */
2420  {
2421  WarnNoImageReturn("\"%%%c\"",letter);
2423  if (*value == '\0')
2424  string="";
2425  break;
2426  }
2427  case 'f': /* Filename without directory component */
2428  {
2429  WarnNoImageReturn("\"%%%c\"",letter);
2431  if (*value == '\0')
2432  string="";
2433  break;
2434  }
2435  case 'g': /* Image geometry, canvas and offset %Wx%H+%X+%Y */
2436  {
2437  WarnNoImageReturn("\"%%%c\"",letter);
2438  (void) FormatLocaleString(value,MagickPathExtent,
2439  "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,(double)
2440  image->page.height,(double) image->page.x,(double) image->page.y);
2441  break;
2442  }
2443  case 'h': /* Image height (current) */
2444  {
2445  WarnNoImageReturn("\"%%%c\"",letter);
2446  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2447  (image->rows != 0 ? image->rows : image->magick_rows));
2448  break;
2449  }
2450  case 'i': /* Filename last used for an image (read or write) */
2451  {
2452  WarnNoImageReturn("\"%%%c\"",letter);
2453  string=image->filename;
2454  break;
2455  }
2456  case 'k': /* Number of unique colors */
2457  {
2458  /*
2459  FUTURE: ensure this does not generate the formatted comment!
2460  */
2461  WarnNoImageReturn("\"%%%c\"",letter);
2462  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2463  GetNumberColors(image,(FILE *) NULL,exception));
2464  break;
2465  }
2466  case 'l': /* Image label property - empty string by default */
2467  {
2468  WarnNoImageReturn("\"%%%c\"",letter);
2469  string=GetImageProperty(image,"label",exception);
2470  if (string == (const char *) NULL)
2471  string="";
2472  break;
2473  }
2474  case 'm': /* Image format (file magick) */
2475  {
2476  WarnNoImageReturn("\"%%%c\"",letter);
2477  string=image->magick;
2478  break;
2479  }
2480  case 'n': /* Number of images in the list. */
2481  {
2482  if ( image != (Image *) NULL )
2483  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2484  GetImageListLength(image));
2485  else
2486  string="0"; /* no images or scenes */
2487  break;
2488  }
2489  case 'o': /* Output Filename - for delegate use only */
2490  WarnNoImageInfoReturn("\"%%%c\"",letter);
2491  string=image_info->filename;
2492  break;
2493  case 'p': /* Image index in current image list */
2494  {
2495  WarnNoImageReturn("\"%%%c\"",letter);
2496  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2497  GetImageIndexInList(image));
2498  break;
2499  }
2500  case 'q': /* Quantum depth of image in memory */
2501  {
2502  WarnNoImageReturn("\"%%%c\"",letter);
2503  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2505  break;
2506  }
2507  case 'r': /* Image storage class, colorspace, and alpha enabled. */
2508  {
2510  colorspace;
2511 
2512  WarnNoImageReturn("\"%%%c\"",letter);
2513  colorspace=image->colorspace;
2514  if (SetImageGray(image,exception) != MagickFalse)
2515  colorspace=GRAYColorspace; /* FUTURE: this is IMv6 not IMv7 */
2516  (void) FormatLocaleString(value,MagickPathExtent,"%s %s %s",
2519  (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2520  "Alpha" : "");
2521  break;
2522  }
2523  case 's': /* Image scene number */
2524  {
2525 #if 0 /* this seems non-sensical -- simplifing */
2526  if (image_info->number_scenes != 0)
2527  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2528  image_info->scene);
2529  else if (image != (Image *) NULL)
2530  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2531  image->scene);
2532  else
2533  string="0";
2534 #else
2535  WarnNoImageReturn("\"%%%c\"",letter);
2536  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2537  image->scene);
2538 #endif
2539  break;
2540  }
2541  case 't': /* Base filename without directory or extention */
2542  {
2543  WarnNoImageReturn("\"%%%c\"",letter);
2545  if (*value == '\0')
2546  string="";
2547  break;
2548  }
2549  case 'u': /* Unique filename */
2550  {
2551  WarnNoImageInfoReturn("\"%%%c\"",letter);
2552  string=image_info->unique;
2553  break;
2554  }
2555  case 'w': /* Image width (current) */
2556  {
2557  WarnNoImageReturn("\"%%%c\"",letter);
2558  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2559  (image->columns != 0 ? image->columns : image->magick_columns));
2560  break;
2561  }
2562  case 'x': /* Image horizontal resolution (with units) */
2563  {
2564  WarnNoImageReturn("\"%%%c\"",letter);
2565  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2566  fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x : 72.0);
2567  break;
2568  }
2569  case 'y': /* Image vertical resolution (with units) */
2570  {
2571  WarnNoImageReturn("\"%%%c\"",letter);
2572  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2573  fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y : 72.0);
2574  break;
2575  }
2576  case 'z': /* Image depth as read in */
2577  {
2578  WarnNoImageReturn("\"%%%c\"",letter);
2579  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2580  image->depth);
2581  break;
2582  }
2583  case 'A': /* Image alpha channel */
2584  {
2585  WarnNoImageReturn("\"%%%c\"",letter);
2587  image->alpha_trait);
2588  break;
2589  }
2590  case 'C': /* Image compression method. */
2591  {
2592  WarnNoImageReturn("\"%%%c\"",letter);
2594  image->compression);
2595  break;
2596  }
2597  case 'D': /* Image dispose method. */
2598  {
2599  WarnNoImageReturn("\"%%%c\"",letter);
2601  image->dispose);
2602  break;
2603  }
2604  case 'G': /* Image size as geometry = "%wx%h" */
2605  {
2606  WarnNoImageReturn("\"%%%c\"",letter);
2607  (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",(double)
2608  image->magick_columns,(double) image->magick_rows);
2609  break;
2610  }
2611  case 'H': /* layer canvas height */
2612  {
2613  WarnNoImageReturn("\"%%%c\"",letter);
2614  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2615  image->page.height);
2616  break;
2617  }
2618  case 'M': /* Magick filename - filename given incl. coder & read mods */
2619  {
2620  WarnNoImageReturn("\"%%%c\"",letter);
2621  string=image->magick_filename;
2622  break;
2623  }
2624  case 'O': /* layer canvas offset with sign = "+%X+%Y" */
2625  {
2626  WarnNoImageReturn("\"%%%c\"",letter);
2627  (void) FormatLocaleString(value,MagickPathExtent,"%+ld%+ld",(long)
2628  image->page.x,(long) image->page.y);
2629  break;
2630  }
2631  case 'P': /* layer canvas page size = "%Wx%H" */
2632  {
2633  WarnNoImageReturn("\"%%%c\"",letter);
2634  (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",(double)
2635  image->page.width,(double) image->page.height);
2636  break;
2637  }
2638  case 'Q': /* image compression quality */
2639  {
2640  WarnNoImageReturn("\"%%%c\"",letter);
2641  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2642  (image->quality == 0 ? 92 : image->quality));
2643  break;
2644  }
2645  case 'S': /* Number of scenes in image list. */
2646  {
2647  WarnNoImageInfoReturn("\"%%%c\"",letter);
2648 #if 0 /* What is this number? -- it makes no sense - simplifing */
2649  if (image_info->number_scenes == 0)
2650  string="2147483647";
2651  else if ( image != (Image *) NULL )
2652  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2653  image_info->scene+image_info->number_scenes);
2654  else
2655  string="0";
2656 #else
2657  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2658  (image_info->number_scenes == 0 ? 2147483647 :
2659  image_info->number_scenes));
2660 #endif
2661  break;
2662  }
2663  case 'T': /* image time delay for animations */
2664  {
2665  WarnNoImageReturn("\"%%%c\"",letter);
2666  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2667  image->delay);
2668  break;
2669  }
2670  case 'U': /* Image resolution units. */
2671  {
2672  WarnNoImageReturn("\"%%%c\"",letter);
2674  image->units);
2675  break;
2676  }
2677  case 'W': /* layer canvas width */
2678  {
2679  WarnNoImageReturn("\"%%%c\"",letter);
2680  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2681  image->page.width);
2682  break;
2683  }
2684  case 'X': /* layer canvas X offset */
2685  {
2686  WarnNoImageReturn("\"%%%c\"",letter);
2687  (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2688  image->page.x);
2689  break;
2690  }
2691  case 'Y': /* layer canvas Y offset */
2692  {
2693  WarnNoImageReturn("\"%%%c\"",letter);
2694  (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2695  image->page.y);
2696  break;
2697  }
2698  case '%': /* percent escaped */
2699  {
2700  string="%";
2701  break;
2702  }
2703  case '@': /* Trim bounding box, without actually Trimming! */
2704  {
2706  page;
2707 
2708  WarnNoImageReturn("\"%%%c\"",letter);
2709  page=GetImageBoundingBox(image,exception);
2710  (void) FormatLocaleString(value,MagickPathExtent,
2711  "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double) page.height,
2712  (double) page.x,(double)page.y);
2713  break;
2714  }
2715  case '#':
2716  {
2717  /*
2718  Image signature.
2719  */
2720  WarnNoImageReturn("\"%%%c\"",letter);
2721  (void) SignatureImage(image,exception);
2722  string=GetImageProperty(image,"signature",exception);
2723  break;
2724  }
2725  }
2726  if (string != (char *) NULL)
2727  return(string);
2728  if (*value != '\0')
2729  {
2730  /*
2731  Create a cloned copy of result.
2732  */
2733  if (image != (Image *) NULL)
2734  {
2735  (void) SetImageArtifact(image,"get-property",value);
2736  return(GetImageArtifact(image,"get-property"));
2737  }
2738  else
2739  {
2740  (void) SetImageOption(image_info,"get-property",value);
2741  return(GetImageOption(image_info,"get-property"));
2742  }
2743  }
2744  return((char *) NULL);
2745 }
2746 
2747 MagickExport const char *GetMagickProperty(ImageInfo *image_info,
2748  Image *image,const char *property,ExceptionInfo *exception)
2749 {
2750  char
2751  value[MagickPathExtent];
2752 
2753  const char
2754  *string;
2755 
2756  assert(property[0] != '\0');
2757  assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2758  if (property[1] == '\0') /* single letter property request */
2759  return(GetMagickPropertyLetter(image_info,image,*property,exception));
2760  if ((image != (Image *) NULL) && (image->debug != MagickFalse))
2761  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2762  else
2763  if ((image_info != (ImageInfo *) NULL) &&
2764  (image_info->debug != MagickFalse))
2765  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2766  *value='\0'; /* formated string */
2767  string=(char *) NULL; /* constant string reference */
2768  switch (*property)
2769  {
2770  case 'b':
2771  {
2772  if (LocaleCompare("basename",property) == 0)
2773  {
2774  WarnNoImageReturn("\"%%[%s]\"",property);
2776  if (*value == '\0')
2777  string="";
2778  break;
2779  }
2780  if (LocaleCompare("bit-depth",property) == 0)
2781  {
2782  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2783  GetImageDepth(image,exception));
2784  break;
2785  }
2786  break;
2787  }
2788  case 'c':
2789  {
2790  if (LocaleCompare("channels",property) == 0)
2791  {
2792  WarnNoImageReturn("\"%%[%s]\"",property);
2793  /* FUTURE: return actual image channels */
2794  (void) FormatLocaleString(value,MagickPathExtent,"%s",
2796  image->colorspace));
2797  LocaleLower(value);
2798  if( image->alpha_trait != UndefinedPixelTrait )
2799  (void) ConcatenateMagickString(value,"a",MagickPathExtent);
2800  break;
2801  }
2802  if (LocaleCompare("colorspace",property) == 0)
2803  {
2804  WarnNoImageReturn("\"%%[%s]\"",property);
2806  image->colorspace);
2807  break;
2808  }
2809  if (LocaleCompare("compose",property) == 0)
2810  {
2811  WarnNoImageReturn("\"%%[%s]\"",property);
2813  image->compose);
2814  break;
2815  }
2816  if (LocaleCompare("copyright",property) == 0)
2817  {
2819  break;
2820  }
2821  break;
2822  }
2823  case 'd':
2824  {
2825  if (LocaleCompare("depth",property) == 0)
2826  {
2827  WarnNoImageReturn("\"%%[%s]\"",property);
2828  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2829  image->depth);
2830  break;
2831  }
2832  if (LocaleCompare("directory",property) == 0)
2833  {
2834  WarnNoImageReturn("\"%%[%s]\"",property);
2836  if (*value == '\0')
2837  string="";
2838  break;
2839  }
2840  break;
2841  }
2842  case 'e':
2843  {
2844  if (LocaleCompare("entropy",property) == 0)
2845  {
2846  double
2847  entropy;
2848 
2849  WarnNoImageReturn("\"%%[%s]\"",property);
2850  (void) GetImageEntropy(image,&entropy,exception);
2851  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2852  GetMagickPrecision(),entropy);
2853  break;
2854  }
2855  if (LocaleCompare("extension",property) == 0)
2856  {
2857  WarnNoImageReturn("\"%%[%s]\"",property);
2859  if (*value == '\0')
2860  string="";
2861  break;
2862  }
2863  break;
2864  }
2865  case 'g':
2866  {
2867  if (LocaleCompare("gamma",property) == 0)
2868  {
2869  WarnNoImageReturn("\"%%[%s]\"",property);
2870  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2871  GetMagickPrecision(),image->gamma);
2872  break;
2873  }
2874  break;
2875  }
2876  case 'h':
2877  {
2878  if (LocaleCompare("height",property) == 0)
2879  {
2880  WarnNoImageReturn("\"%%[%s]\"",property);
2881  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2882  image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2883  break;
2884  }
2885  break;
2886  }
2887  case 'i':
2888  {
2889  if (LocaleCompare("input",property) == 0)
2890  {
2891  WarnNoImageReturn("\"%%[%s]\"",property);
2892  string=image->filename;
2893  break;
2894  }
2895  if (LocaleCompare("interlace",property) == 0)
2896  {
2898  image->interlace);
2899  break;
2900  }
2901  break;
2902  }
2903  case 'k':
2904  {
2905  if (LocaleCompare("kurtosis",property) == 0)
2906  {
2907  double
2908  kurtosis,
2909  skewness;
2910 
2911  WarnNoImageReturn("\"%%[%s]\"",property);
2912  (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
2913  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2914  GetMagickPrecision(),kurtosis);
2915  break;
2916  }
2917  break;
2918  }
2919  case 'm':
2920  {
2921  if (LocaleCompare("magick",property) == 0)
2922  {
2923  WarnNoImageReturn("\"%%[%s]\"",property);
2924  string=image->magick;
2925  break;
2926  }
2927  if ((LocaleCompare("maxima",property) == 0) ||
2928  (LocaleCompare("max",property) == 0))
2929  {
2930  double
2931  maximum,
2932  minimum;
2933 
2934  WarnNoImageReturn("\"%%[%s]\"",property);
2935  (void) GetImageRange(image,&minimum,&maximum,exception);
2936  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2937  GetMagickPrecision(),maximum);
2938  break;
2939  }
2940  if (LocaleCompare("mean",property) == 0)
2941  {
2942  double
2943  mean,
2944  standard_deviation;
2945 
2946  WarnNoImageReturn("\"%%[%s]\"",property);
2947  (void) GetImageMean(image,&mean,&standard_deviation,exception);
2948  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2949  GetMagickPrecision(),mean);
2950  break;
2951  }
2952  if ((LocaleCompare("minima",property) == 0) ||
2953  (LocaleCompare("min",property) == 0))
2954  {
2955  double
2956  maximum,
2957  minimum;
2958 
2959  WarnNoImageReturn("\"%%[%s]\"",property);
2960  (void) GetImageRange(image,&minimum,&maximum,exception);
2961  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2962  GetMagickPrecision(),minimum);
2963  break;
2964  }
2965  break;
2966  }
2967  case 'o':
2968  {
2969  if (LocaleCompare("opaque",property) == 0)
2970  {
2971  WarnNoImageReturn("\"%%[%s]\"",property);
2973  IsImageOpaque(image,exception));
2974  break;
2975  }
2976  if (LocaleCompare("orientation",property) == 0)
2977  {
2978  WarnNoImageReturn("\"%%[%s]\"",property);
2980  image->orientation);
2981  break;
2982  }
2983  if (LocaleCompare("output",property) == 0)
2984  {
2985  WarnNoImageInfoReturn("\"%%[%s]\"",property);
2986  (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
2987  break;
2988  }
2989  break;
2990  }
2991  case 'p':
2992  {
2993 #if defined(MAGICKCORE_LCMS_DELEGATE)
2994  if (LocaleCompare("profile:icc",property) == 0 ||
2995  LocaleCompare("profile:icm",property) == 0)
2996  {
2997 #if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
2998 #define cmsUInt32Number DWORD
2999 #endif
3000 
3001  const StringInfo
3002  *profile;
3003 
3004  cmsHPROFILE
3005  icc_profile;
3006 
3007  profile=GetImageProfile(image,property+8);
3008  if (profile == (StringInfo *) NULL)
3009  break;
3010  icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3011  (cmsUInt32Number) GetStringInfoLength(profile));
3012  if (icc_profile != (cmsHPROFILE *) NULL)
3013  {
3014 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3015  string=cmsTakeProductName(icc_profile);
3016 #else
3017  (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3018  "en","US",value,MagickPathExtent);
3019 #endif
3020  (void) cmsCloseProfile(icc_profile);
3021  }
3022  }
3023 #endif
3024  if (LocaleCompare("profiles",property) == 0)
3025  {
3026  const char
3027  *name;
3028 
3030  name=GetNextImageProfile(image);
3031  if (name != (char *) NULL)
3032  {
3033  (void) CopyMagickString(value,name,MagickPathExtent);
3034  name=GetNextImageProfile(image);
3035  while (name != (char *) NULL)
3036  {
3039  name=GetNextImageProfile(image);
3040  }
3041  }
3042  break;
3043  }
3044  break;
3045  }
3046  case 'r':
3047  {
3048  if (LocaleCompare("resolution.x",property) == 0)
3049  {
3050  WarnNoImageReturn("\"%%[%s]\"",property);
3051  (void) FormatLocaleString(value,MagickPathExtent,"%g",
3052  image->resolution.x);
3053  break;
3054  }
3055  if (LocaleCompare("resolution.y",property) == 0)
3056  {
3057  WarnNoImageReturn("\"%%[%s]\"",property);
3058  (void) FormatLocaleString(value,MagickPathExtent,"%g",
3059  image->resolution.y);
3060  break;
3061  }
3062  break;
3063  }
3064  case 's':
3065  {
3066  if (LocaleCompare("scene",property) == 0)
3067  {
3068  WarnNoImageInfoReturn("\"%%[%s]\"",property);
3069  if (image_info->number_scenes != 0)
3070  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3071  image_info->scene);
3072  else {
3073  WarnNoImageReturn("\"%%[%s]\"",property);
3074  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3075  image->scene);
3076  }
3077  break;
3078  }
3079  if (LocaleCompare("scenes",property) == 0)
3080  {
3081  /* FUTURE: equivelent to %n? */
3082  WarnNoImageReturn("\"%%[%s]\"",property);
3083  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3084  GetImageListLength(image));
3085  break;
3086  }
3087  if (LocaleCompare("size",property) == 0)
3088  {
3089  WarnNoImageReturn("\"%%[%s]\"",property);
3090  (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
3091  MagickPathExtent,value);
3092  break;
3093  }
3094  if (LocaleCompare("skewness",property) == 0)
3095  {
3096  double
3097  kurtosis,
3098  skewness;
3099 
3100  WarnNoImageReturn("\"%%[%s]\"",property);
3101  (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3102  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
3103  GetMagickPrecision(),skewness);
3104  break;
3105  }
3106  if (LocaleCompare("standard-deviation",property) == 0)
3107  {
3108  double
3109  mean,
3110  standard_deviation;
3111 
3112  WarnNoImageReturn("\"%%[%s]\"",property);
3113  (void) GetImageMean(image,&mean,&standard_deviation,exception);
3114  (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
3115  GetMagickPrecision(),standard_deviation);
3116  break;
3117  }
3118  break;
3119  }
3120  case 't':
3121  {
3122  if (LocaleCompare("type",property) == 0)
3123  {
3124  WarnNoImageReturn("\"%%[%s]\"",property);
3126  IdentifyImageType(image,exception));
3127  break;
3128  }
3129  break;
3130  }
3131  case 'u':
3132  {
3133  if (LocaleCompare("unique",property) == 0)
3134  {
3135  WarnNoImageInfoReturn("\"%%[%s]\"",property);
3136  string=image_info->unique;
3137  break;
3138  }
3139  if (LocaleCompare("units",property) == 0)
3140  {
3141  WarnNoImageReturn("\"%%[%s]\"",property);
3143  image->units);
3144  break;
3145  }
3146  break;
3147  }
3148  case 'v':
3149  {
3150  if (LocaleCompare("version",property) == 0)
3151  {
3152  string=GetMagickVersion((size_t *) NULL);
3153  break;
3154  }
3155  break;
3156  }
3157  case 'w':
3158  {
3159  if (LocaleCompare("width",property) == 0)
3160  {
3161  WarnNoImageReturn("\"%%[%s]\"",property);
3162  (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3163  (image->magick_columns != 0 ? image->magick_columns : 256));
3164  break;
3165  }
3166  break;
3167  }
3168  }
3169  if (string != (char *) NULL)
3170  return(string);
3171  if (*value != '\0')
3172  {
3173  /*
3174  Create a cloned copy of result, that will get cleaned up, eventually.
3175  */
3176  if (image != (Image *) NULL)
3177  {
3178  (void) SetImageArtifact(image,"get-property",value);
3179  return(GetImageArtifact(image,"get-property"));
3180  }
3181  else
3182  {
3183  (void) SetImageOption(image_info,"get-property",value);
3184  return(GetImageOption(image_info,"get-property"));
3185  }
3186  }
3187  return((char *) NULL);
3188 }
3189 #undef WarnNoImageReturn
3190 
3191 /*
3192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3193 % %
3194 % %
3195 % %
3196 % G e t N e x t I m a g e P r o p e r t y %
3197 % %
3198 % %
3199 % %
3200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3201 %
3202 % GetNextImageProperty() gets the next free-form string property name.
3203 %
3204 % The format of the GetNextImageProperty method is:
3205 %
3206 % char *GetNextImageProperty(const Image *image)
3207 %
3208 % A description of each parameter follows:
3209 %
3210 % o image: the image.
3211 %
3212 */
3213 MagickExport const char *GetNextImageProperty(const Image *image)
3214 {
3215  assert(image != (Image *) NULL);
3216  assert(image->signature == MagickCoreSignature);
3217  if (image->debug != MagickFalse)
3219  image->filename);
3220  if (image->properties == (void *) NULL)
3221  return((const char *) NULL);
3222  return((const char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3223 }
3224 
3225 /*
3226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3227 % %
3228 % %
3229 % %
3230 % I n t e r p r e t I m a g e P r o p e r t i e s %
3231 % %
3232 % %
3233 % %
3234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3235 %
3236 % InterpretImageProperties() replaces any embedded formatting characters with
3237 % the appropriate image property and returns the interpreted text.
3238 %
3239 % This searches for and replaces
3240 % \n \r \% replaced by newline, return, and percent resp.
3241 % &lt; &gt; &amp; replaced by '<', '>', '&' resp.
3242 % %% replaced by percent
3243 %
3244 % %x %[x] where 'x' is a single letter properity, case sensitive).
3245 % %[type:name] where 'type' a is special and known prefix.
3246 % %[name] where 'name' is a specifically known attribute, calculated
3247 % value, or a per-image property string name, or a per-image
3248 % 'artifact' (as generated from a global option).
3249 % It may contain ':' as long as the prefix is not special.
3250 %
3251 % Single letter % substitutions will only happen if the character before the
3252 % percent is NOT a number. But braced substitutions will always be performed.
3253 % This prevents the typical usage of percent in a interpreted geometry
3254 % argument from being substituted when the percent is a geometry flag.
3255 %
3256 % If 'glob-expresions' ('*' or '?' characters) is used for 'name' it may be
3257 % used as a search pattern to print multiple lines of "name=value\n" pairs of
3258 % the associacted set of properties.
3259 %
3260 % The returned string must be freed using DestoryString() by the caller.
3261 %
3262 % The format of the InterpretImageProperties method is:
3263 %
3264 % char *InterpretImageProperties(ImageInfo *image_info,
3265 % Image *image,const char *embed_text,ExceptionInfo *exception)
3266 %
3267 % A description of each parameter follows:
3268 %
3269 % o image_info: the image info. (required)
3270 %
3271 % o image: the image. (optional)
3272 %
3273 % o embed_text: the address of a character string containing the embedded
3274 % formatting characters.
3275 %
3276 % o exception: return any errors or warnings in this structure.
3277 %
3278 */
3280  const char *embed_text,ExceptionInfo *exception)
3281 {
3282 #define ExtendInterpretText(string_length) \
3283 DisableMSCWarning(4127) \
3284 { \
3285  size_t length=(string_length); \
3286  if ((size_t) (q-interpret_text+length+1) >= extent) \
3287  { \
3288  extent+=length; \
3289  interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3290  MaxTextExtent,sizeof(*interpret_text)); \
3291  if (interpret_text == (char *) NULL) \
3292  return((char *) NULL); \
3293  q=interpret_text+strlen(interpret_text); \
3294  } \
3295 } \
3296 RestoreMSCWarning
3297 
3298 #define AppendKeyValue2Text(key,value)\
3299 DisableMSCWarning(4127) \
3300 { \
3301  size_t length=strlen(key)+strlen(value)+2; \
3302  if ((size_t) (q-interpret_text+length+1) >= extent) \
3303  { \
3304  extent+=length; \
3305  interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3306  MaxTextExtent,sizeof(*interpret_text)); \
3307  if (interpret_text == (char *) NULL) \
3308  return((char *) NULL); \
3309  q=interpret_text+strlen(interpret_text); \
3310  } \
3311  q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3312 } \
3313 RestoreMSCWarning
3314 
3315 #define AppendString2Text(string) \
3316 DisableMSCWarning(4127) \
3317 { \
3318  size_t length=strlen((string)); \
3319  if ((size_t) (q-interpret_text+length+1) >= extent) \
3320  { \
3321  extent+=length; \
3322  interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3323  MaxTextExtent,sizeof(*interpret_text)); \
3324  if (interpret_text == (char *) NULL) \
3325  return((char *) NULL); \
3326  q=interpret_text+strlen(interpret_text); \
3327  } \
3328  (void) CopyMagickString(q,(string),extent); \
3329  q+=length; \
3330 } \
3331 RestoreMSCWarning
3332 
3333  char
3334  *interpret_text;
3335 
3337  number;
3338 
3339  register char
3340  *q; /* current position in interpret_text */
3341 
3342  register const char
3343  *p; /* position in embed_text string being expanded */
3344 
3345  size_t
3346  extent; /* allocated length of interpret_text */
3347 
3348  assert(image == NULL || image->signature == MagickCoreSignature);
3349  assert(image_info == NULL || image_info->signature == MagickCoreSignature);
3350  if ((image != (Image *) NULL) && (image->debug != MagickFalse))
3351  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3352  else
3353  if ((image_info != (ImageInfo *) NULL) && (image_info->debug != MagickFalse))
3354  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-image");
3355  if (embed_text == (const char *) NULL)
3356  return(ConstantString(""));
3357  p=embed_text;
3358  while ((isspace((int) ((unsigned char) *p)) != 0) && (*p != '\0'))
3359  p++;
3360  if (*p == '\0')
3361  return(ConstantString(""));
3362  if ((*p == '@') && (IsPathAccessible(p+1) != MagickFalse))
3363  {
3364  /*
3365  Handle a '@' replace string from file.
3366  */
3368  {
3369  errno=EPERM;
3371  "NotAuthorized","`%s'",p);
3372  return(ConstantString(""));
3373  }
3374  interpret_text=FileToString(p+1,~0UL,exception);
3375  if (interpret_text != (char *) NULL)
3376  return(interpret_text);
3377  }
3378  /*
3379  Translate any embedded format characters.
3380  */
3381  interpret_text=AcquireString(embed_text); /* new string with extra space */
3382  extent=MagickPathExtent; /* allocated space in string */
3383  number=MagickFalse; /* is last char a number? */
3384  for (q=interpret_text; *p!='\0'; number=isdigit(*p) ? MagickTrue : MagickFalse,p++)
3385  {
3386  /*
3387  Look for the various escapes, (and handle other specials)
3388  */
3389  *q='\0';
3391  switch (*p)
3392  {
3393  case '\\':
3394  {
3395  switch (*(p+1))
3396  {
3397  case '\0':
3398  continue;
3399  case 'r': /* convert to RETURN */
3400  {
3401  *q++='\r';
3402  p++;
3403  continue;
3404  }
3405  case 'n': /* convert to NEWLINE */
3406  {
3407  *q++='\n';
3408  p++;
3409  continue;
3410  }
3411  case '\n': /* EOL removal UNIX,MacOSX */
3412  {
3413  p++;
3414  continue;
3415  }
3416  case '\r': /* EOL removal DOS,Windows */
3417  {
3418  p++;
3419  if (*p == '\n') /* return-newline EOL */
3420  p++;
3421  continue;
3422  }
3423  default:
3424  {
3425  p++;
3426  *q++=(*p);
3427  }
3428  }
3429  continue;
3430  }
3431  case '&':
3432  {
3433  if (LocaleNCompare("&lt;",p,4) == 0)
3434  {
3435  *q++='<';
3436  p+=3;
3437  }
3438  else
3439  if (LocaleNCompare("&gt;",p,4) == 0)
3440  {
3441  *q++='>';
3442  p+=3;
3443  }
3444  else
3445  if (LocaleNCompare("&amp;",p,5) == 0)
3446  {
3447  *q++='&';
3448  p+=4;
3449  }
3450  else
3451  *q++=(*p);
3452  continue;
3453  }
3454  case '%':
3455  break; /* continue to next set of handlers */
3456  default:
3457  {
3458  *q++=(*p); /* any thing else is 'as normal' */
3459  continue;
3460  }
3461  }
3462  p++; /* advance beyond the percent */
3463  /*
3464  Doubled Percent - or percent at end of string.
3465  */
3466  if ((*p == '\0') || (*p == '\'') || (*p == '"'))
3467  p--;
3468  if (*p == '%')
3469  {
3470  *q++='%';
3471  continue;
3472  }
3473  /*
3474  Single letter escapes %c.
3475  */
3476  if (*p != '[')
3477  {
3478  const char
3479  *string;
3480 
3481  if (number != MagickFalse)
3482  {
3483  /*
3484  But only if not preceeded by a number!
3485  */
3486  *q++='%'; /* do NOT substitute the percent */
3487  p--; /* back up one */
3488  continue;
3489  }
3490  string=GetMagickPropertyLetter(image_info,image,*p, exception);
3491  if (string != (char *) NULL)
3492  {
3493  AppendString2Text(string);
3494  if (image != (Image *) NULL)
3495  (void) DeleteImageArtifact(image,"get-property");
3496  if (image_info != (ImageInfo *) NULL)
3497  (void) DeleteImageOption(image_info,"get-property");
3498  continue;
3499  }
3501  "UnknownImageProperty","\"%%%c\"",*p);
3502  continue;
3503  }
3504  {
3505  char
3506  pattern[2*MagickPathExtent];
3507 
3508  const char
3509  *key,
3510  *string;
3511 
3512  register ssize_t
3513  len;
3514 
3515  ssize_t
3516  depth;
3517 
3518  /*
3519  Braced Percent Escape %[...].
3520  */
3521  p++; /* advance p to just inside the opening brace */
3522  depth=1;
3523  if (*p == ']')
3524  {
3526  "UnknownImageProperty","\"%%[]\"");
3527  break;
3528  }
3529  for (len=0; len<(MagickPathExtent-1L) && (*p != '\0');)
3530  {
3531  if ((*p == '\\') && (*(p+1) != '\0'))
3532  {
3533  /*
3534  Skip escaped braces within braced pattern.
3535  */
3536  pattern[len++]=(*p++);
3537  pattern[len++]=(*p++);
3538  continue;
3539  }
3540  if (*p == '[')
3541  depth++;
3542  if (*p == ']')
3543  depth--;
3544  if (depth <= 0)
3545  break;
3546  pattern[len++]=(*p++);
3547  }
3548  pattern[len]='\0';
3549  if (depth != 0)
3550  {
3551  /*
3552  Check for unmatched final ']' for "%[...]".
3553  */
3554  if (len >= 64)
3555  {
3556  pattern[61] = '.'; /* truncate string for error message */
3557  pattern[62] = '.';
3558  pattern[63] = '.';
3559  pattern[64] = '\0';
3560  }
3562  "UnbalancedBraces","\"%%[%s\"",pattern);
3563  interpret_text=DestroyString(interpret_text);
3564  return((char *) NULL);
3565  }
3566  /*
3567  Special Lookup Prefixes %[prefix:...].
3568  */
3569  if (LocaleNCompare("fx:",pattern,3) == 0)
3570  {
3571  double
3572  value;
3573 
3574  FxInfo
3575  *fx_info;
3576 
3578  status;
3579 
3580  /*
3581  FX - value calculator.
3582  */
3583  if (image == (Image *) NULL )
3584  {
3585  (void) ThrowMagickException(exception,GetMagickModule(),
3586  OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3587  continue; /* else no image to retrieve artifact */
3588  }
3589  fx_info=AcquireFxInfo(image,pattern+3,exception);
3591  &value,exception);
3592  fx_info=DestroyFxInfo(fx_info);
3593  if (status != MagickFalse)
3594  {
3595  char
3596  result[MagickPathExtent];
3597 
3598  (void) FormatLocaleString(result,MagickPathExtent,"%.*g",
3599  GetMagickPrecision(),(double) value);
3600  AppendString2Text(result);
3601  }
3602  continue;
3603  }
3604  if (LocaleNCompare("hex:",pattern,4) == 0)
3605  {
3606  double
3607  value;
3608 
3609  FxInfo
3610  *fx_info;
3611 
3613  status;
3614 
3615  PixelInfo
3616  pixel;
3617 
3618  /*
3619  Pixel - color value calculator.
3620  */
3621  if (image == (Image *) NULL)
3622  {
3623  (void) ThrowMagickException(exception,GetMagickModule(),
3624  OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3625  continue; /* else no image to retrieve artifact */
3626  }
3627  GetPixelInfo(image,&pixel);
3628  fx_info=AcquireFxInfo(image,pattern+4,exception);
3629  status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
3630  &value,exception);
3631  pixel.red=(double) QuantumRange*value;
3632  status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
3633  &value,exception);
3634  pixel.green=(double) QuantumRange*value;
3635  status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
3636  &value,exception);
3637  pixel.blue=(double) QuantumRange*value;
3638  if (image->colorspace == CMYKColorspace)
3639  {
3640  status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
3641  &value,exception);
3642  pixel.black=(double) QuantumRange*value;
3643  }
3644  status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
3645  &value,exception);
3646  pixel.alpha=(double) QuantumRange*value;
3647  fx_info=DestroyFxInfo(fx_info);
3648  if (status != MagickFalse)
3649  {
3650  char
3651  hex[MagickPathExtent],
3653 
3654  (void) QueryColorname(image,&pixel,SVGCompliance,name,exception);
3655  GetColorTuple(&pixel,MagickTrue,hex);
3656  AppendString2Text(hex+1);
3657  }
3658  continue;
3659  }
3660  if (LocaleNCompare("pixel:",pattern,6) == 0)
3661  {
3662  double
3663  value;
3664 
3665  FxInfo
3666  *fx_info;
3667 
3669  status;
3670 
3671  PixelInfo
3672  pixel;
3673 
3674  /*
3675  Pixel - color value calculator.
3676  */
3677  if (image == (Image *) NULL)
3678  {
3679  (void) ThrowMagickException(exception,GetMagickModule(),
3680  OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3681  continue; /* else no image to retrieve artifact */
3682  }
3683  GetPixelInfo(image,&pixel);
3684  fx_info=AcquireFxInfo(image,pattern+6,exception);
3685  status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
3686  &value,exception);
3687  pixel.red=(double) QuantumRange*value;
3688  status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
3689  &value,exception);
3690  pixel.green=(double) QuantumRange*value;
3691  status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
3692  &value,exception);
3693  pixel.blue=(double) QuantumRange*value;
3694  if (image->colorspace == CMYKColorspace)
3695  {
3696  status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
3697  &value,exception);
3698  pixel.black=(double) QuantumRange*value;
3699  }
3700  status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
3701  &value,exception);
3702  pixel.alpha=(double) QuantumRange*value;
3703  fx_info=DestroyFxInfo(fx_info);
3704  if (status != MagickFalse)
3705  {
3706  char
3708 
3709  (void) QueryColorname(image,&pixel,SVGCompliance,name,exception);
3710  AppendString2Text(name);
3711  }
3712  continue;
3713  }
3714  if (LocaleNCompare("option:",pattern,7) == 0)
3715  {
3716  /*
3717  Option - direct global option lookup (with globbing).
3718  */
3719  if (image_info == (ImageInfo *) NULL )
3720  {
3721  (void) ThrowMagickException(exception,GetMagickModule(),
3722  OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3723  continue; /* else no image to retrieve artifact */
3724  }
3725  if (IsGlob(pattern+7) != MagickFalse)
3726  {
3727  ResetImageOptionIterator(image_info);
3728  while ((key=GetNextImageOption(image_info)) != (const char *) NULL)
3729  if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
3730  {
3731  string=GetImageOption(image_info,key);
3732  if (string != (const char *) NULL)
3733  AppendKeyValue2Text(key,string);
3734  /* else - assertion failure? key found but no string value! */
3735  }
3736  continue;
3737  }
3738  string=GetImageOption(image_info,pattern+7);
3739  if (string == (char *) NULL)
3740  goto PropertyLookupFailure; /* no artifact of this specifc name */
3741  AppendString2Text(string);
3742  continue;
3743  }
3744  if (LocaleNCompare("artifact:",pattern,9) == 0)
3745  {
3746  /*
3747  Artifact - direct image artifact lookup (with glob).
3748  */
3749  if (image == (Image *) NULL)
3750  {
3751  (void) ThrowMagickException(exception,GetMagickModule(),
3752  OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3753  continue; /* else no image to retrieve artifact */
3754  }
3755  if (IsGlob(pattern+9) != MagickFalse)
3756  {
3758  while ((key=GetNextImageArtifact(image)) != (const char *) NULL)
3759  if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
3760  {
3761  string=GetImageArtifact(image,key);
3762  if (string != (const char *) NULL)
3763  AppendKeyValue2Text(key,string);
3764  /* else - assertion failure? key found but no string value! */
3765  }
3766  continue;
3767  }
3768  string=GetImageArtifact(image,pattern+9);
3769  if (string == (char *) NULL)
3770  goto PropertyLookupFailure; /* no artifact of this specifc name */
3771  AppendString2Text(string);
3772  continue;
3773  }
3774  if (LocaleNCompare("property:",pattern,9) == 0)
3775  {
3776  /*
3777  Property - direct image property lookup (with glob).
3778  */
3779  if (image == (Image *) NULL)
3780  {
3781  (void) ThrowMagickException(exception,GetMagickModule(),
3782  OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3783  continue; /* else no image to retrieve artifact */
3784  }
3785  if (IsGlob(pattern+9) != MagickFalse)
3786  {
3788  while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3789  if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3790  {
3791  string=GetImageProperty(image,key,exception);
3792  if (string != (const char *) NULL)
3793  AppendKeyValue2Text(key,string);
3794  /* else - assertion failure? */
3795  }
3796  continue;
3797  }
3798  string=GetImageProperty(image,pattern+9,exception);
3799  if (string == (char *) NULL)
3800  goto PropertyLookupFailure; /* no artifact of this specifc name */
3801  AppendString2Text(string);
3802  continue;
3803  }
3804  if (image != (Image *) NULL)
3805  {
3806  /*
3807  Properties without special prefix. This handles attributes,
3808  properties, and profiles such as %[exif:...]. Note the profile
3809  properties may also include a glob expansion pattern.
3810  */
3811  string=GetImageProperty(image,pattern,exception);
3812  if (string != (const char *) NULL)
3813  {
3814  AppendString2Text(string);
3815  if (image != (Image *) NULL)
3816  (void)DeleteImageArtifact(image,"get-property");
3817  if (image_info != (ImageInfo *) NULL)
3818  (void)DeleteImageOption(image_info,"get-property");
3819  continue;
3820  }
3821  }
3822  if (IsGlob(pattern) != MagickFalse)
3823  {
3824  /*
3825  Handle property 'glob' patterns such as:
3826  %[*] %[user:array_??] %[filename:e*]>
3827  */
3828  if (image == (Image *) NULL)
3829  continue; /* else no image to retrieve proprty - no list */
3831  while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3832  if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3833  {
3834  string=GetImageProperty(image,key,exception);
3835  if (string != (const char *) NULL)
3836  AppendKeyValue2Text(key,string);
3837  /* else - assertion failure? */
3838  }
3839  continue;
3840  }
3841  /*
3842  Look for a known property or image attribute such as
3843  %[basename] %[denisty] %[delay]. Also handles a braced single
3844  letter: %[b] %[G] %[g].
3845  */
3846  string=GetMagickProperty(image_info,image,pattern,exception);
3847  if (string != (const char *) NULL)
3848  {
3849  AppendString2Text(string);
3850  continue;
3851  }
3852  /*
3853  Look for a per-image artifact. This includes option lookup
3854  (FUTURE: interpreted according to image).
3855  */
3856  if (image != (Image *) NULL)
3857  {
3858  string=GetImageArtifact(image,pattern);
3859  if (string != (char *) NULL)
3860  {
3861  AppendString2Text(string);
3862  continue;
3863  }
3864  }
3865  else
3866  if (image_info != (ImageInfo *) NULL)
3867  {
3868  /*
3869  No image, so direct 'option' lookup (no delayed percent escapes).
3870  */
3871  string=GetImageOption(image_info,pattern);
3872  if (string != (char *) NULL)
3873  {
3874  AppendString2Text(string);
3875  continue;
3876  }
3877  }
3878 PropertyLookupFailure:
3879  /*
3880  Failed to find any match anywhere!
3881  */
3882  if (len >= 64)
3883  {
3884  pattern[61] = '.'; /* truncate string for error message */
3885  pattern[62] = '.';
3886  pattern[63] = '.';
3887  pattern[64] = '\0';
3888  }
3890  "UnknownImageProperty","\"%%[%s]\"",pattern);
3891  }
3892  }
3893  *q='\0';
3894  return(interpret_text);
3895 }
3896 
3897 /*
3898 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3899 % %
3900 % %
3901 % %
3902 % R e m o v e I m a g e P r o p e r t y %
3903 % %
3904 % %
3905 % %
3906 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3907 %
3908 % RemoveImageProperty() removes a property from the image and returns its
3909 % value.
3910 %
3911 % In this case the ConstantString() value returned should be freed by the
3912 % caller when finished.
3913 %
3914 % The format of the RemoveImageProperty method is:
3915 %
3916 % char *RemoveImageProperty(Image *image,const char *property)
3917 %
3918 % A description of each parameter follows:
3919 %
3920 % o image: the image.
3921 %
3922 % o property: the image property.
3923 %
3924 */
3925 MagickExport char *RemoveImageProperty(Image *image,const char *property)
3926 {
3927  char
3928  *value;
3929 
3930  assert(image != (Image *) NULL);
3931  assert(image->signature == MagickCoreSignature);
3932  if (image->debug != MagickFalse)
3933  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3934  if (image->properties == (void *) NULL)
3935  return((char *) NULL);
3936  value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3937  property);
3938  return(value);
3939 }
3940 
3941 /*
3942 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3943 % %
3944 % %
3945 % %
3946 % R e s e t I m a g e P r o p e r t y I t e r a t o r %
3947 % %
3948 % %
3949 % %
3950 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3951 %
3952 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3953 % in conjunction with GetNextImageProperty() to iterate over all the values
3954 % associated with an image property.
3955 %
3956 % The format of the ResetImagePropertyIterator method is:
3957 %
3958 % ResetImagePropertyIterator(Image *image)
3959 %
3960 % A description of each parameter follows:
3961 %
3962 % o image: the image.
3963 %
3964 */
3966 {
3967  assert(image != (Image *) NULL);
3968  assert(image->signature == MagickCoreSignature);
3969  if (image->debug != MagickFalse)
3970  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3971  if (image->properties == (void *) NULL)
3972  return;
3974 }
3975 
3976 /*
3977 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3978 % %
3979 % %
3980 % %
3981 % S e t I m a g e P r o p e r t y %
3982 % %
3983 % %
3984 % %
3985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3986 %
3987 % SetImageProperty() saves the given string value either to specific known
3988 % attribute or to a freeform property string.
3989 %
3990 % Attempting to set a property that is normally calculated will produce
3991 % an exception.
3992 %
3993 % The format of the SetImageProperty method is:
3994 %
3995 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3996 % const char *value,ExceptionInfo *exception)
3997 %
3998 % A description of each parameter follows:
3999 %
4000 % o image: the image.
4001 %
4002 % o property: the image property.
4003 %
4004 % o values: the image property values.
4005 %
4006 % o exception: return any errors or warnings in this structure.
4007 %
4008 */
4010  const char *property,const char *value,ExceptionInfo *exception)
4011 {
4013  status;
4014 
4016  flags;
4017 
4018  assert(image != (Image *) NULL);
4019  assert(image->signature == MagickCoreSignature);
4020  if (image->debug != MagickFalse)
4021  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4022  if (image->properties == (void *) NULL)
4024  RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */
4025  if (value == (const char *) NULL)
4026  return(DeleteImageProperty(image,property)); /* delete if NULL */
4027  status=MagickTrue;
4028  if (strlen(property) <= 1)
4029  {
4030  /*
4031  Do not 'set' single letter properties - read only shorthand.
4032  */
4034  "SetReadOnlyProperty","`%s'",property);
4035  return(MagickFalse);
4036  }
4037 
4038  /* FUTURE: binary chars or quotes in key should produce a error */
4039  /* Set attributes with known names or special prefixes
4040  return result is found, or break to set a free form properity
4041  */
4042  switch (*property)
4043  {
4044 #if 0 /* Percent escape's sets values with this prefix: for later use
4045  Throwing an exception causes this setting to fail */
4046  case '8':
4047  {
4048  if (LocaleNCompare("8bim:",property,5) == 0)
4049  {
4051  "SetReadOnlyProperty","`%s'",property);
4052  return(MagickFalse);
4053  }
4054  break;
4055  }
4056 #endif
4057  case 'B':
4058  case 'b':
4059  {
4060  if (LocaleCompare("background",property) == 0)
4061  {
4062  (void) QueryColorCompliance(value,AllCompliance,
4063  &image->background_color,exception);
4064  /* check for FUTURE: value exception?? */
4065  /* also add user input to splay tree */
4066  }
4067  break; /* not an attribute, add as a property */
4068  }
4069  case 'C':
4070  case 'c':
4071  {
4072  if (LocaleCompare("channels",property) == 0)
4073  {
4075  "SetReadOnlyProperty","`%s'",property);
4076  return(MagickFalse);
4077  }
4078  if (LocaleCompare("colorspace",property) == 0)
4079  {
4080  ssize_t
4081  colorspace;
4082 
4084  value);
4085  if (colorspace < 0)
4086  return(MagickFalse); /* FUTURE: value exception?? */
4087  return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4088  }
4089  if (LocaleCompare("compose",property) == 0)
4090  {
4091  ssize_t
4092  compose;
4093 
4095  if (compose < 0)
4096  return(MagickFalse); /* FUTURE: value exception?? */
4097  image->compose=(CompositeOperator) compose;
4098  return(MagickTrue);
4099  }
4100  if (LocaleCompare("compress",property) == 0)
4101  {
4102  ssize_t
4103  compression;
4104 
4106  value);
4107  if (compression < 0)
4108  return(MagickFalse); /* FUTURE: value exception?? */
4109  image->compression=(CompressionType) compression;
4110  return(MagickTrue);
4111  }
4112  break; /* not an attribute, add as a property */
4113  }
4114  case 'D':
4115  case 'd':
4116  {
4117  if (LocaleCompare("delay",property) == 0)
4118  {
4119  GeometryInfo
4120  geometry_info;
4121 
4122  flags=ParseGeometry(value,&geometry_info);
4123  if ((flags & GreaterValue) != 0)
4124  {
4125  if (image->delay > (size_t) floor(geometry_info.rho+0.5))
4126  image->delay=(size_t) floor(geometry_info.rho+0.5);
4127  }
4128  else
4129  if ((flags & LessValue) != 0)
4130  {
4131  if (image->delay < (size_t) floor(geometry_info.rho+0.5))
4132  image->delay=(ssize_t)
4133  floor(geometry_info.sigma+0.5);
4134  }
4135  else
4136  image->delay=(size_t) floor(geometry_info.rho+0.5);
4137  if ((flags & SigmaValue) != 0)
4138  image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
4139  return(MagickTrue);
4140  }
4141  if (LocaleCompare("delay_units",property) == 0)
4142  {
4144  "SetReadOnlyProperty","`%s'",property);
4145  return(MagickFalse);
4146  }
4147  if (LocaleCompare("density",property) == 0)
4148  {
4149  GeometryInfo
4150  geometry_info;
4151 
4152  flags=ParseGeometry(value,&geometry_info);
4153  image->resolution.x=geometry_info.rho;
4154  image->resolution.y=geometry_info.sigma;
4155  if ((flags & SigmaValue) == 0)
4156  image->resolution.y=image->resolution.x;
4157  return(MagickTrue);
4158  }
4159  if (LocaleCompare("depth",property) == 0)
4160  {
4161  image->depth=StringToUnsignedLong(value);
4162  return(MagickTrue);
4163  }
4164  if (LocaleCompare("dispose",property) == 0)
4165  {
4166  ssize_t
4167  dispose;
4168 
4170  if (dispose < 0)
4171  return(MagickFalse); /* FUTURE: value exception?? */
4172  image->dispose=(DisposeType) dispose;
4173  return(MagickTrue);
4174  }
4175  break; /* not an attribute, add as a property */
4176  }
4177 #if 0 /* Percent escape's sets values with this prefix: for later use
4178  Throwing an exception causes this setting to fail */
4179  case 'E':
4180  case 'e':
4181  {
4182  if (LocaleNCompare("exif:",property,5) == 0)
4183  {
4185  "SetReadOnlyProperty","`%s'",property);
4186  return(MagickFalse);
4187  }
4188  break; /* not an attribute, add as a property */
4189  }
4190  case 'F':
4191  case 'f':
4192  {
4193  if (LocaleNCompare("fx:",property,3) == 0)
4194  {
4196  "SetReadOnlyProperty","`%s'",property);
4197  return(MagickFalse);
4198  }
4199  break; /* not an attribute, add as a property */
4200  }
4201 #endif
4202  case 'G':
4203  case 'g':
4204  {
4205  if (LocaleCompare("gamma",property) == 0)
4206  {
4207  image->gamma=StringToDouble(value,(char **) NULL);
4208  return(MagickTrue);
4209  }
4210  if (LocaleCompare("gravity",property) == 0)
4211  {
4212  ssize_t
4213  gravity;
4214 
4216  if (gravity < 0)
4217  return(MagickFalse); /* FUTURE: value exception?? */
4218  image->gravity=(GravityType) gravity;
4219  return(MagickTrue);
4220  }
4221  break; /* not an attribute, add as a property */
4222  }
4223  case 'H':
4224  case 'h':
4225  {
4226  if (LocaleCompare("height",property) == 0)
4227  {
4229  "SetReadOnlyProperty","`%s'",property);
4230  return(MagickFalse);
4231  }
4232  break; /* not an attribute, add as a property */
4233  }
4234  case 'I':
4235  case 'i':
4236  {
4237  if (LocaleCompare("intensity",property) == 0)
4238  {
4239  ssize_t
4240  intensity;
4241 
4243  if (intensity < 0)
4244  return(MagickFalse);
4245  image->intensity=(PixelIntensityMethod) intensity;
4246  return(MagickTrue);
4247  }
4248  if (LocaleCompare("intent",property) == 0)
4249  {
4250  ssize_t
4251  rendering_intent;
4252 
4254  value);
4255  if (rendering_intent < 0)
4256  return(MagickFalse); /* FUTURE: value exception?? */
4257  image->rendering_intent=(RenderingIntent) rendering_intent;
4258  return(MagickTrue);
4259  }
4260  if (LocaleCompare("interpolate",property) == 0)
4261  {
4262  ssize_t
4263  interpolate;
4264 
4266  value);
4267  if (interpolate < 0)
4268  return(MagickFalse); /* FUTURE: value exception?? */
4269  image->interpolate=(PixelInterpolateMethod) interpolate;
4270  return(MagickTrue);
4271  }
4272 #if 0 /* Percent escape's sets values with this prefix: for later use
4273  Throwing an exception causes this setting to fail */
4274  if (LocaleNCompare("iptc:",property,5) == 0)
4275  {
4277  "SetReadOnlyProperty","`%s'",property);
4278  return(MagickFalse);
4279  }
4280 #endif
4281  break; /* not an attribute, add as a property */
4282  }
4283  case 'K':
4284  case 'k':
4285  if (LocaleCompare("kurtosis",property) == 0)
4286  {
4288  "SetReadOnlyProperty","`%s'",property);
4289  return(MagickFalse);
4290  }
4291  break; /* not an attribute, add as a property */
4292  case 'L':
4293  case 'l':
4294  {
4295  if (LocaleCompare("loop",property) == 0)
4296  {
4297  image->iterations=StringToUnsignedLong(value);
4298  return(MagickTrue);
4299  }
4300  break; /* not an attribute, add as a property */
4301  }
4302  case 'M':
4303  case 'm':
4304  if ((LocaleCompare("magick",property) == 0) ||
4305  (LocaleCompare("max",property) == 0) ||
4306  (LocaleCompare("mean",property) == 0) ||
4307  (LocaleCompare("min",property) == 0) ||
4308  (LocaleCompare("min",property) == 0))
4309  {
4311  "SetReadOnlyProperty","`%s'",property);
4312  return(MagickFalse);
4313  }
4314  break; /* not an attribute, add as a property */
4315  case 'O':
4316  case 'o':
4317  if (LocaleCompare("opaque",property) == 0)
4318  {
4320  "SetReadOnlyProperty","`%s'",property);
4321  return(MagickFalse);
4322  }
4323  break; /* not an attribute, add as a property */
4324  case 'P':
4325  case 'p':
4326  {
4327  if (LocaleCompare("page",property) == 0)
4328  {
4329  char
4330  *geometry;
4331 
4332  geometry=GetPageGeometry(value);
4333  flags=ParseAbsoluteGeometry(geometry,&image->page);
4334  geometry=DestroyString(geometry);
4335  return(MagickTrue);
4336  }
4337 #if 0 /* Percent escape's sets values with this prefix: for later use
4338  Throwing an exception causes this setting to fail */
4339  if (LocaleNCompare("pixel:",property,6) == 0)
4340  {
4342  "SetReadOnlyProperty","`%s'",property);
4343  return(MagickFalse);
4344  }
4345 #endif
4346  if (LocaleCompare("profile",property) == 0)
4347  {
4348  ImageInfo
4349  *image_info;
4350 
4351  StringInfo
4352  *profile;
4353 
4354  image_info=AcquireImageInfo();
4355  (void) CopyMagickString(image_info->filename,value,MagickPathExtent);
4356  (void) SetImageInfo(image_info,1,exception);
4357  profile=FileToStringInfo(image_info->filename,~0UL,exception);
4358  if (profile != (StringInfo *) NULL)
4359  status=SetImageProfile(image,image_info->magick,profile,exception);
4360  image_info=DestroyImageInfo(image_info);
4361  return(MagickTrue);
4362  }
4363  break; /* not an attribute, add as a property */
4364  }
4365  case 'R':
4366  case 'r':
4367  {
4368  if (LocaleCompare("rendering-intent",property) == 0)
4369  {
4370  ssize_t
4371  rendering_intent;
4372 
4374  value);
4375  if (rendering_intent < 0)
4376  return(MagickFalse); /* FUTURE: value exception?? */
4377  image->rendering_intent=(RenderingIntent) rendering_intent;
4378  return(MagickTrue);
4379  }
4380  break; /* not an attribute, add as a property */
4381  }
4382  case 'S':
4383  case 's':
4384  if ((LocaleCompare("size",property) == 0) ||
4385  (LocaleCompare("skewness",property) == 0) ||
4386  (LocaleCompare("scenes",property) == 0) ||
4387  (LocaleCompare("standard-deviation",property) == 0))
4388  {
4390  "SetReadOnlyProperty","`%s'",property);
4391  return(MagickFalse);
4392  }
4393  break; /* not an attribute, add as a property */
4394  case 'T':
4395  case 't':
4396  {
4397  if (LocaleCompare("tile-offset",property) == 0)
4398  {
4399  char
4400  *geometry;
4401 
4402  geometry=GetPageGeometry(value);
4403  flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4404  geometry=DestroyString(geometry);
4405  return(MagickTrue);
4406  }
4407  break; /* not an attribute, add as a property */
4408  }
4409  case 'U':
4410  case 'u':
4411  {
4412  if (LocaleCompare("units",property) == 0)
4413  {
4414  ssize_t
4415  units;
4416 
4418  if (units < 0)
4419  return(MagickFalse); /* FUTURE: value exception?? */
4420  image->units=(ResolutionType) units;
4421  return(MagickTrue);
4422  }
4423  break; /* not an attribute, add as a property */
4424  }
4425  case 'V':
4426  case 'v':
4427  {
4428  if (LocaleCompare("version",property) == 0)
4429  {
4431  "SetReadOnlyProperty","`%s'",property);
4432  return(MagickFalse);
4433  }
4434  break; /* not an attribute, add as a property */
4435  }
4436  case 'W':
4437  case 'w':
4438  {
4439  if (LocaleCompare("width",property) == 0)
4440  {
4442  "SetReadOnlyProperty","`%s'",property);
4443  return(MagickFalse);
4444  }
4445  break; /* not an attribute, add as a property */
4446  }
4447 #if 0 /* Percent escape's sets values with this prefix: for later use
4448  Throwing an exception causes this setting to fail */
4449  case 'X':
4450  case 'x':
4451  {
4452  if (LocaleNCompare("xmp:",property,4) == 0)
4453  {
4455  "SetReadOnlyProperty","`%s'",property);
4456  return(MagickFalse);
4457  }
4458  break; /* not an attribute, add as a property */
4459  }
4460 #endif
4461  }
4462  /* Default: not an attribute, add as a property */
4463  status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4464  ConstantString(property),ConstantString(value));
4465  /* FUTURE: error if status is bad? */
4466  return(status);
4467 }
size_t rows
Definition: image.h:172
PixelInfo matte_color
Definition: image.h:357
#define AppendString2Text(string)
PixelIntensityMethod intensity
Definition: image.h:222
MagickExport ssize_t FormatMagickSize(const MagickSizeType size, const MagickBooleanType bi, const char *suffix, const size_t length, char *format)
Definition: string.c:1081
#define EXIF_FMT_SINGLE
size_t signature
Definition: image.h:479
MagickExport MagickBooleanType QueryColorname(const Image *magick_unused(image), const PixelInfo *color, const ComplianceType compliance, char *name, ExceptionInfo *exception)
Definition: color.c:2584
MagickExport ImageInfo * AcquireImageInfo(void)
Definition: image.c:341
InterlaceType interlace
Definition: image.h:225
static const char * GetMagickPropertyLetter(ImageInfo *image_info, Image *image, const char letter, ExceptionInfo *exception)
Definition: property.c:2358
MagickExport XMLTreeInfo * DestroyXMLTree(XMLTreeInfo *xml_info)
Definition: xml-tree.c:558
DisposeType dispose
Definition: image.h:237
MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, const void *key, const void *value)
Definition: splay-tree.c:154
char magick[MagickPathExtent]
Definition: image.h:471
MagickProgressMonitor progress_monitor
Definition: image.h:303
MagickExport char * RemoveImageProperty(Image *image, const char *property)
Definition: property.c:3925
MagickExport MagickBooleanType IsRightsAuthorized(const PolicyDomain domain, const PolicyRights rights, const char *pattern)
Definition: policy.c:594
size_t iterations
Definition: image.h:248
ssize_t ticks_per_second
Definition: image.h:245
static unsigned short ReadPropertyUnsignedShort(const EndianType endian, const unsigned char *buffer)
Definition: property.c:813
FilterType filter
Definition: image.h:219
static unsigned int ReadPropertyUnsignedLong(const EndianType endian, const unsigned char *buffer)
Definition: property.c:764
MagickExport MagickBooleanType DeleteImageOption(ImageInfo *image_info, const char *option)
Definition: option.c:2214
MagickExport void ResetImagePropertyIterator(const Image *image)
Definition: property.c:3965
static unsigned long StringToUnsignedLong(const char *magick_restrict value)
#define EXIF_FMT_SLONG
MagickExport ssize_t ParseCommandOption(const CommandOption option, const MagickBooleanType list, const char *options)
Definition: option.c:2954
#define EXIF_FMT_SSHORT
PixelInfo border_color
Definition: image.h:179
PixelInterpolateMethod
Definition: pixel.h:108
PixelInterpolateMethod interpolate
Definition: image.h:255
MagickPrivate ssize_t FormatLocaleStringList(char *magick_restrict, const size_t, const char *magick_restrict, va_list) magick_attribute((__format__(__printf__
MagickExport XMLTreeInfo * GetNextXMLTreeTag(XMLTreeInfo *xml_info)
Definition: xml-tree.c:745
size_t number_scenes
Definition: image.h:387
double rho
Definition: geometry.h:106
MagickExport MagickStatusType ParseAbsoluteGeometry(const char *geometry, RectangleInfo *region_info)
Definition: geometry.c:697
EndianType endian
Definition: image.h:228
MagickExport MagickBooleanType DeleteImageArtifact(Image *image, const char *artifact)
Definition: artifact.c:198
MagickBooleanType taint
Definition: image.h:169
MagickExport size_t ConcatenateMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:410
static signed int ReadPropertyMSBLong(const unsigned char **p, size_t *length)
Definition: property.c:501
PixelIntensityMethod
Definition: pixel.h:94
MagickBooleanType debug
Definition: image.h:476
static MagickBooleanType SkipXMPValue(const char *value)
Definition: property.c:1702
#define ExtendInterpretText(string_length)
MagickExport MagickBooleanType SetImageArtifact(Image *image, const char *artifact, const char *value)
Definition: artifact.c:445
MagickExport const char * GetImageArtifact(const Image *image, const char *artifact)
Definition: artifact.c:273
MagickRealType red
Definition: pixel.h:188
static MagickBooleanType GetEXIFProperty(const Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:830
static double StringToDouble(const char *magick_restrict string, char **magick_restrict sentinal)
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
Definition: exception.c:108
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
Definition: locale.c:473
ResolutionType units
Definition: image.h:198
static MagickBooleanType GetICCProperty(const Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:1645
MagickExport MagickBooleanType SignatureImage(Image *image, ExceptionInfo *exception)
Definition: signature.c:466
size_t delay
Definition: image.h:240
char magick[MagickPathExtent]
Definition: image.h:319
#define MAGICKCORE_QUANTUM_DEPTH
Definition: magick-type.h:28
size_t magick_rows
Definition: image.h:324
MagickExport void ResetImageArtifactIterator(const Image *image)
Definition: artifact.c:406
char * name
Definition: static.c:54
static long StringToLong(const char *magick_restrict value)
MagickRealType alpha
Definition: pixel.h:188
unsigned char * info
Definition: profile.c:101
static char * TraceSVGClippath(const unsigned char *, size_t, const size_t, const size_t)
Definition: property.c:2016
MagickExport const char * GetImageOption(const ImageInfo *image_info, const char *option)
Definition: option.c:2289
MagickExport char * GetPageGeometry(const char *page_geometry)
Definition: geometry.c:360
char * montage
Definition: image.h:201
#define MagickEpsilon
Definition: magick-type.h:110
CompressionType compression
Definition: image.h:160
MagickExport XMLTreeInfo * GetXMLTreeChild(XMLTreeInfo *xml_info, const char *tag)
Definition: xml-tree.c:897
double sigma
Definition: geometry.h:106
ClassType storage_class
Definition: image.h:154
size_t width
Definition: geometry.h:130
static signed int ReadPropertySignedLong(const EndianType endian, const unsigned char *buffer)
Definition: property.c:732
RectangleInfo tile_offset
Definition: image.h:261
MagickExport MagickBooleanType GetImageEntropy(const Image *image, double *entropy, ExceptionInfo *exception)
Definition: statistic.c:1140
#define EXIF_FMT_BYTE
Definition: log.h:52
MagickExport char * FileToString(const char *filename, const size_t extent, ExceptionInfo *exception)
Definition: string.c:985
#define EXIF_FMT_URATIONAL
MagickExport void GetPixelInfo(const Image *image, PixelInfo *pixel)
Definition: pixel.c:2170
MagickExport const char * GetXMLTreeTag(XMLTreeInfo *xml_info)
Definition: xml-tree.c:1159
EndianType
Definition: quantum.h:28
MagickExport MagickBooleanType SetImageOption(ImageInfo *image_info, const char *option, const char *value)
Definition: option.c:3224
Definition: image.h:151
static signed short ReadPropertySignedShort(const EndianType endian, const unsigned char *buffer)
Definition: property.c:785
static int ReadPropertyByte(const unsigned char **p, size_t *length)
Definition: property.c:489
static char * TracePSClippath(const unsigned char *, size_t)
Definition: property.c:1806
MagickExport MagickBooleanType SetImageGray(Image *image, ExceptionInfo *exception)
Definition: colorspace.c:1214
#define EXIF_FMT_USHORT
double x
Definition: geometry.h:123
#define TAG_GPS_OFFSET
#define MagickCoreSignature
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition: string.c:1283
MagickExport MagickBooleanType CloneImageProperties(Image *image, const Image *clone_image)
Definition: property.c:134
#define TAG_INTEROP_OFFSET
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
Definition: utility.c:1213
MagickBooleanType
Definition: magick-type.h:156
size_t scene
Definition: image.h:240
unsigned int MagickStatusType
Definition: magick-type.h:119
MagickExport char * AcquireString(const char *source)
Definition: string.c:124
MagickExport void LocaleLower(char *string)
Definition: locale.c:1462
MagickBooleanType black_point_compensation
Definition: image.h:258
MagickPrivate FxInfo * DestroyFxInfo(FxInfo *)
Definition: fx.c:1050
MagickExport void * ResetMagickMemory(void *memory, int byte, const size_t size)
Definition: memory.c:1153
MagickExport const char * CommandOptionToMnemonic(const CommandOption option, const ssize_t type)
Definition: option.c:2667
MagickExport StringInfo * FileToStringInfo(const char *filename, const size_t extent, ExceptionInfo *exception)
Definition: string.c:1024
static MagickBooleanType GetIPTCProperty(const Image *image, const char *key, ExceptionInfo *exception)
Definition: property.c:422
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition: memory.c:533
char filename[MagickPathExtent]
Definition: image.h:471
MagickExport void GetColorTuple(const PixelInfo *pixel, const MagickBooleanType hex, char *tuple)
Definition: color.c:1556
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
Definition: locale.c:1509
double y
Definition: geometry.h:123
MagickPrivate MagickBooleanType FxEvaluateChannelExpression(FxInfo *, const PixelChannel, const ssize_t, const ssize_t, double *, ExceptionInfo *)
Definition: fx.c:2963
GravityType gravity
Definition: image.h:231
MagickExport MagickBooleanType SetImageProperty(Image *image, const char *property, const char *value, ExceptionInfo *exception)
Definition: property.c:4009
MagickExport MagickBooleanType ConcatenateString(char **destination, const char *source)
Definition: string.c:476
MagickExport const StringInfo * GetImageProfile(const Image *image, const char *name)
Definition: profile.c:248
size_t scene
Definition: image.h:387
RectangleInfo page
Definition: image.h:212
MagickExport const char * GetXMLTreeContent(XMLTreeInfo *xml_info)
Definition: xml-tree.c:937
MagickExport void DestroyImageProperties(Image *image)
Definition: property.c:314
size_t magick_columns
Definition: image.h:324
MagickExport SplayTreeInfo * DestroySplayTree(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:682
MagickExport MagickBooleanType GlobExpression(const char *expression, const char *pattern, const MagickBooleanType case_insensitive)
Definition: token.c:349
#define MagickPathExtent
PixelTrait alpha_trait
Definition: image.h:280
MagickExport int GetMagickPrecision(void)
Definition: magick.c:868
MagickRealType blue
Definition: pixel.h:188
MagickExport SplayTreeInfo * NewSplayTree(int(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
Definition: splay-tree.c:1141
#define EXIF_FMT_DOUBLE
MagickExport MagickBooleanType SetImageInfo(ImageInfo *image_info, const unsigned int frames, ExceptionInfo *exception)
Definition: image.c:2596
GravityType
Definition: geometry.h:77
char magick_filename[MagickPathExtent]
Definition: image.h:319
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
Definition: exception.c:1058
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition: log.c:1397
Definition: fx.c:111
MagickExport MagickBooleanType IsPathAccessible(const char *path)
Definition: utility.c:1466
MagickExport const char * GetMagickVersion(size_t *version)
Definition: version.c:564
size_t signature
Definition: image.h:354
size_t columns
Definition: image.h:172
MagickExport const char * GetNextImageProperty(const Image *image)
Definition: property.c:3213
MagickPrivate MagickBooleanType IsGlob(const char *)
Definition: token.c:619
static signed short ReadPropertyMSBShort(const unsigned char **p, size_t *length)
Definition: property.c:541
MagickExport MagickBooleanType SubstituteString(char **string, const char *search, const char *replace)
Definition: string.c:2535
#define EXIFMultipleValues(size, format, arg)
ssize_t x
Definition: geometry.h:134
#define WarnNoImageInfoReturn(format, arg)
MagickExport void ResetImageOptionIterator(const ImageInfo *image_info)
Definition: option.c:3185
MagickExport const char * GetMagickCopyright(void)
Definition: version.c:75
size_t height
Definition: geometry.h:130
MagickExport ImageType IdentifyImageType(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:807
MagickExport MagickBooleanType GetImageRange(const Image *image, double *minima, double *maxima, ExceptionInfo *exception)
Definition: statistic.c:1805
MagickExport MagickBooleanType QueryColorCompliance(const char *name, const ComplianceType compliance, PixelInfo *color, ExceptionInfo *exception)
Definition: color.c:2216
MagickExport MagickBooleanType GetImageKurtosis(const Image *image, double *kurtosis, double *skewness, ExceptionInfo *exception)
Definition: statistic.c:1238
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
Definition: string.c:742
ssize_t offset
Definition: image.h:206
RectangleInfo extract_info
Definition: image.h:212
MagickExport const void * GetValueFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
Definition: splay-tree.c:921
MagickExport MagickBooleanType GetImageMean(const Image *image, double *mean, double *standard_deviation, ExceptionInfo *exception)
Definition: statistic.c:1288
#define EXIF_FMT_STRING
MagickExport char * GetNextImageProfile(const Image *image)
Definition: profile.c:287
RenderingIntent
Definition: profile.h:30
#define MagickMax(x, y)
Definition: image-private.h:26
MagickExport MagickBooleanType SetImageProfile(Image *image, const char *name, const StringInfo *profile, ExceptionInfo *exception)
Definition: profile.c:1657
#define EXIF_FMT_SRATIONAL
size_t quality
Definition: image.h:163
#define AppendKeyValue2Text(key, value)
#define MaxDirectoryStack
MagickExport int LocaleCompare(const char *p, const char *q)
Definition: locale.c:1409
DisposeType
Definition: layer.h:27
char filename[MagickPathExtent]
Definition: image.h:319
MagickExport SplayTreeInfo * CloneSplayTree(SplayTreeInfo *splay_tree, void *(*clone_key)(void *), void *(*clone_value)(void *))
Definition: splay-tree.c:346
#define GetMagickModule()
Definition: log.h:28
MagickExport int CompareSplayTreeString(const void *target, const void *source)
Definition: splay-tree.c:412
MagickExport size_t GetNumberColors(const Image *image, FILE *file, ExceptionInfo *exception)
Definition: histogram.c:1002
MagickExport char * InterpretImageProperties(ImageInfo *image_info, Image *image, const char *embed_text, ExceptionInfo *exception)
Definition: property.c:3279
MagickExport MagickSizeType GetBlobSize(const Image *image)
Definition: blob.c:1686
char unique[MagickPathExtent]
Definition: image.h:471
MagickExport XMLTreeInfo * GetXMLTreeSibling(XMLTreeInfo *xml_info)
Definition: xml-tree.c:1127
MagickExport ImageInfo * DestroyImageInfo(ImageInfo *image_info)
Definition: image.c:1253
CompressionType
Definition: compress.h:25
ssize_t start_loop
Definition: image.h:252
RenderingIntent rendering_intent
Definition: image.h:192
ErrorInfo error
Definition: image.h:297
MagickExport const void * GetNextKeyInSplayTree(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:769
MagickExport size_t GetImageDepth(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:274
#define EXIFMultipleFractions(size, format, arg1, arg2)
static MagickBooleanType GetXMPProperty(const Image *image, const char *property)
Definition: property.c:1715
MagickExport RectangleInfo GetImageBoundingBox(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:125
MagickExport MagickBooleanType SetImageColorspace(Image *image, const ColorspaceType colorspace, ExceptionInfo *exception)
Definition: colorspace.c:1134
MagickExport ssize_t GetImageIndexInList(const Image *images)
Definition: list.c:644
MagickRealType black
Definition: pixel.h:188
MagickExport char * DestroyString(char *string)
Definition: string.c:810
char * geometry
Definition: image.h:201
MagickExport MagickBooleanType DeleteImageProperty(Image *image, const char *property)
Definition: property.c:279
MagickExport const char * GetImageProperty(const Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:2185
#define EXIF_FMT_UNDEFINED
MagickExport const void * GetRootValueFromSplayTree(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:877
MagickExport MagickStatusType ParseGeometry(const char *geometry, GeometryInfo *geometry_info)
Definition: geometry.c:847
char * directory
Definition: image.h:201
ChromaticityInfo chromaticity
Definition: image.h:189
MagickExport void * RemoveNodeFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
Definition: splay-tree.c:1299
MagickExport MagickBooleanType DeleteNodeFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
Definition: splay-tree.c:603
size_t length
Definition: profile.c:98
static MagickBooleanType Get8BIMProperty(const Image *image, const char *key, ExceptionInfo *exception)
Definition: property.c:579
#define MagickMin(x, y)
Definition: image-private.h:27
MagickExport const char * GetNextImageArtifact(const Image *image)
Definition: artifact.c:323
ColorspaceType
Definition: colorspace.h:25
#define EXIF_FMT_SBYTE
MagickExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree)
Definition: splay-tree.c:1472
MagickExport void * RelinquishMagickMemory(void *memory)
Definition: memory.c:1027
size_t total_colors
Definition: image.h:248
PointInfo resolution
Definition: image.h:209
#define magick_unreferenced(x)
void * properties
Definition: image.h:315
MagickExport MagickBooleanType DefineImageProperty(Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:232
MagickRealType green
Definition: pixel.h:188
MagickExport char * CloneString(char **destination, const char *source)
Definition: string.c:270
MagickExport const char * GetMagickProperty(ImageInfo *image_info, Image *image, const char *property, ExceptionInfo *exception)
Definition: property.c:2747
CompositeOperator compose
Definition: image.h:234
CompositeOperator
Definition: composite.h:25
ResolutionType
Definition: image.h:89
MagickExport void ResetImageProfileIterator(const Image *image)
Definition: profile.c:1276
#define MagickExport
MagickSizeType extent
Definition: image.h:270
OrientationType orientation
Definition: image.h:166
#define EXIF_FMT_ULONG
double fuzz
Definition: image.h:216
ssize_t y
Definition: geometry.h:134
MagickExport MagickBooleanType FormatImageProperty(Image *image, const char *property, const char *format,...)
Definition: property.c:354
MagickExport char * StringInfoToString(const StringInfo *string_info)
Definition: string.c:1898
PixelInfo transparent_color
Definition: image.h:179
#define WarnNoImageReturn(format, arg)
MagickExport size_t GetStringInfoLength(const StringInfo *string_info)
Definition: string.c:1312
PixelInfo background_color
Definition: image.h:179
MagickExport size_t GetImageListLength(const Image *images)
Definition: list.c:680
MagickExport char * GetNextImageOption(const ImageInfo *image_info)
Definition: option.c:2591
void * client_data
Definition: image.h:306
MagickExport char * ConstantString(const char *source)
Definition: string.c:687
MagickExport void * CopyMagickMemory(void *destination, const void *source, const size_t size)
Definition: memory.c:710
double gamma
Definition: image.h:186
ColorspaceType colorspace
Definition: image.h:157
MagickExport MagickBooleanType IsImageOpaque(const Image *image, ExceptionInfo *exception)
Definition: attribute.c:931
MagickExport XMLTreeInfo * NewXMLTree(const char *xml, ExceptionInfo *exception)
Definition: xml-tree.c:1940
#define TAG_EXIF_OFFSET
#define QuantumRange
Definition: magick-type.h:83
MagickPrivate FxInfo * AcquireFxInfo(const Image *, const char *, ExceptionInfo *)
MagickBooleanType debug
Definition: image.h:334
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
Definition: exception.c:417
size_t depth
Definition: image.h:172