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