2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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 %
13 % MagickCore Property Methods %
20 % Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "MagickCore/studio.h"
44 #include "MagickCore/artifact.h"
45 #include "MagickCore/attribute.h"
46 #include "MagickCore/cache.h"
47 #include "MagickCore/cache-private.h"
48 #include "MagickCore/color.h"
49 #include "MagickCore/color-private.h"
50 #include "MagickCore/colorspace-private.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"
56 #include "MagickCore/exception-private.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"
64 #include "MagickCore/locale-private.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"
80 #include "MagickCore/string-private.h"
81 #include "MagickCore/token.h"
82 #include "MagickCore/token-private.h"
83 #include "MagickCore/utility.h"
84 #include "MagickCore/utility-private.h"
85 #include "MagickCore/version.h"
86 #include "MagickCore/xml-tree.h"
87 #include "MagickCore/xml-tree-private.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)
93 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
94 #include <lcms/lcms.h>
103 #if defined(MAGICKCORE_LCMS_DELEGATE)
104 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
105 #define cmsUInt32Number DWORD
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114 % C l o n e I m a g e P r o p e r t i e s %
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
120 % CloneImageProperties() clones all the image properties to another image.
122 % The format of the CloneImageProperties method is:
124 % MagickBooleanType CloneImageProperties(Image *image,
125 % const Image *clone_image)
127 % A description of each parameter follows:
129 % o image: the image.
131 % o clone_image: the clone image.
134 MagickExport MagickBooleanType CloneImageProperties(Image *image,
135 const Image *clone_image)
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)
144 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
145 clone_image->filename);
146 (void) CopyMagickString(image->filename,clone_image->filename,MagickPathExtent);
147 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
149 image->compression=clone_image->compression;
150 image->quality=clone_image->quality;
151 image->depth=clone_image->depth;
152 image->alpha_color=clone_image->alpha_color;
153 image->background_color=clone_image->background_color;
154 image->border_color=clone_image->border_color;
155 image->transparent_color=clone_image->transparent_color;
156 image->gamma=clone_image->gamma;
157 image->chromaticity=clone_image->chromaticity;
158 image->rendering_intent=clone_image->rendering_intent;
159 image->black_point_compensation=clone_image->black_point_compensation;
160 image->units=clone_image->units;
161 image->montage=(char *) NULL;
162 image->directory=(char *) NULL;
163 (void) CloneString(&image->geometry,clone_image->geometry);
164 image->offset=clone_image->offset;
165 image->resolution.x=clone_image->resolution.x;
166 image->resolution.y=clone_image->resolution.y;
167 image->page=clone_image->page;
168 image->tile_offset=clone_image->tile_offset;
169 image->extract_info=clone_image->extract_info;
170 image->filter=clone_image->filter;
171 image->fuzz=clone_image->fuzz;
172 image->intensity=clone_image->intensity;
173 image->interlace=clone_image->interlace;
174 image->interpolate=clone_image->interpolate;
175 image->endian=clone_image->endian;
176 image->gravity=clone_image->gravity;
177 image->compose=clone_image->compose;
178 image->orientation=clone_image->orientation;
179 image->scene=clone_image->scene;
180 image->dispose=clone_image->dispose;
181 image->delay=clone_image->delay;
182 image->ticks_per_second=clone_image->ticks_per_second;
183 image->iterations=clone_image->iterations;
184 image->total_colors=clone_image->total_colors;
185 image->taint=clone_image->taint;
186 image->progress_monitor=clone_image->progress_monitor;
187 image->client_data=clone_image->client_data;
188 image->start_loop=clone_image->start_loop;
189 image->error=clone_image->error;
190 image->signature=clone_image->signature;
191 if (clone_image->properties != (void *) NULL)
193 if (image->properties != (void *) NULL)
194 DestroyImageProperties(image);
195 image->properties=CloneSplayTree((SplayTreeInfo *)
196 clone_image->properties,(void *(*)(void *)) ConstantString,
197 (void *(*)(void *)) ConstantString);
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207 % D e f i n e I m a g e P r o p e r t y %
211 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
213 % DefineImageProperty() associates an assignment string of the form
214 % "key=value" with an artifact or options. It is equivelent to
217 % The format of the DefineImageProperty method is:
219 % MagickBooleanType DefineImageProperty(Image *image,const char *property,
220 % ExceptionInfo *exception)
222 % A description of each parameter follows:
224 % o image: the image.
226 % o property: the image property.
228 % o exception: return any errors or warnings in this structure.
231 MagickExport MagickBooleanType DefineImageProperty(Image *image,
232 const char *property,ExceptionInfo *exception)
235 key[MagickPathExtent],
236 value[MagickPathExtent];
241 assert(image != (Image *) NULL);
242 assert(property != (const char *) NULL);
243 (void) CopyMagickString(key,property,MagickPathExtent-1);
244 for (p=key; *p != '\0'; p++)
249 (void) CopyMagickString(value,p+1,MagickPathExtent);
251 return(SetImageProperty(image,key,value,exception));
255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
259 % D e l e t e I m a g e P r o p e r t y %
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 % DeleteImageProperty() deletes an image property.
267 % The format of the DeleteImageProperty method is:
269 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
271 % A description of each parameter follows:
273 % o image: the image.
275 % o property: the image property.
278 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
279 const char *property)
281 assert(image != (Image *) NULL);
282 assert(image->signature == MagickCoreSignature);
283 if (image->debug != MagickFalse)
284 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
286 if (image->properties == (void *) NULL)
288 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
296 % D e s t r o y I m a g e P r o p e r t i e s %
300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302 % DestroyImageProperties() destroys all properties and associated memory
303 % attached to the given image.
305 % The format of the DestroyDefines method is:
307 % void DestroyImageProperties(Image *image)
309 % A description of each parameter follows:
311 % o image: the image.
314 MagickExport void DestroyImageProperties(Image *image)
316 assert(image != (Image *) NULL);
317 assert(image->signature == MagickCoreSignature);
318 if (image->debug != MagickFalse)
319 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
321 if (image->properties != (void *) NULL)
322 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331 % F o r m a t I m a g e P r o p e r t y %
335 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
337 % FormatImageProperty() permits formatted property/value pairs to be saved as
340 % The format of the FormatImageProperty method is:
342 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
343 % const char *format,...)
345 % A description of each parameter follows.
347 % o image: The image.
349 % o property: The attribute property.
351 % o format: A string describing the format to use to write the remaining
355 MagickExport MagickBooleanType FormatImageProperty(Image *image,
356 const char *property,const char *format,...)
359 value[MagickPathExtent];
373 va_start(operands,format);
374 n=FormatLocaleStringList(value,MagickPathExtent,format,operands);
377 exception=AcquireExceptionInfo();
378 status=SetImageProperty(image,property,value,exception);
379 exception=DestroyExceptionInfo(exception);
384 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
388 % G e t I m a g e P r o p e r t y %
392 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
394 % GetImageProperty() gets a value associated with an image property.
396 % This includes, profile prefixes, such as "exif:", "iptc:" and "8bim:"
397 % It does not handle non-prifile prefixes, such as "fx:", "option:", or
400 % The returned string is stored as a properity of the same name for faster
401 % lookup later. It should NOT be freed by the caller.
403 % The format of the GetImageProperty method is:
405 % const char *GetImageProperty(const Image *image,const char *key,
406 % ExceptionInfo *exception)
408 % A description of each parameter follows:
410 % o image: the image.
414 % o exception: return any errors or warnings in this structure.
419 *TracePSClippath(const unsigned char *,size_t),
420 *TraceSVGClippath(const unsigned char *,size_t,const size_t,
423 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key,
424 ExceptionInfo *exception)
444 profile=GetImageProfile(image,"iptc");
445 if (profile == (StringInfo *) NULL)
446 profile=GetImageProfile(image,"8bim");
447 if (profile == (StringInfo *) NULL)
449 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
452 attribute=(char *) NULL;
453 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
456 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
458 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
459 length|=GetStringInfoDatum(profile)[i+4];
460 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
461 ((long) GetStringInfoDatum(profile)[i+2] == record))
463 message=(char *) NULL;
465 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
466 if (message != (char *) NULL)
468 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
469 profile)+i+5,length+1);
470 (void) ConcatenateString(&attribute,message);
471 (void) ConcatenateString(&attribute,";");
472 message=DestroyString(message);
477 if ((attribute == (char *) NULL) || (*attribute == ';'))
479 if (attribute != (char *) NULL)
480 attribute=DestroyString(attribute);
483 attribute[strlen(attribute)-1]='\0';
484 (void) SetImageProperty((Image *) image,key,(const char *) attribute,
486 attribute=DestroyString(attribute);
490 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
502 static inline signed int ReadPropertyMSBLong(const unsigned char **p,
528 for (i=0; i < 4; i++)
532 buffer[i]=(unsigned char) c;
534 value=(unsigned int) buffer[0] << 24;
535 value|=(unsigned int) buffer[1] << 16;
536 value|=(unsigned int) buffer[2] << 8;
537 value|=(unsigned int) buffer[3];
538 quantum.unsigned_value=value & 0xffffffff;
539 return(quantum.signed_value);
542 static inline signed short ReadPropertyMSBShort(const unsigned char **p,
567 return((unsigned short) ~0);
568 for (i=0; i < 2; i++)
572 buffer[i]=(unsigned char) c;
574 value=(unsigned short) buffer[0] << 8;
575 value|=(unsigned short) buffer[1];
576 quantum.unsigned_value=value & 0xffff;
577 return(quantum.signed_value);
580 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
581 ExceptionInfo *exception)
585 format[MagickPathExtent],
586 name[MagickPathExtent],
614 There are no newlines in path names, so it's safe as terminator.
616 profile=GetImageProfile(image,"8bim");
617 if (profile == (StringInfo *) NULL)
619 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
621 if ((count != 2) && (count != 3) && (count != 4))
624 (void) CopyMagickString(format,"SVG",MagickPathExtent);
629 sub_number=(ssize_t) StringToLong(&name[1]);
630 sub_number=MagickMax(sub_number,1L);
631 resource=(char *) NULL;
633 length=GetStringInfoLength(profile);
634 info=GetStringInfoDatum(profile);
635 while ((length > 0) && (status == MagickFalse))
637 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
639 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
641 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
643 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
645 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
646 if (id < (ssize_t) start)
648 if (id > (ssize_t) stop)
650 if (resource != (char *) NULL)
651 resource=DestroyString(resource);
652 count=(ssize_t) ReadPropertyByte(&info,&length);
653 if ((count != 0) && ((size_t) count <= length))
655 resource=(char *) NULL;
656 if (~((size_t) count) >= (MagickPathExtent-1))
657 resource=(char *) AcquireQuantumMemory((size_t) count+
658 MagickPathExtent,sizeof(*resource));
659 if (resource != (char *) NULL)
661 for (i=0; i < (ssize_t) count; i++)
662 resource[i]=(char) ReadPropertyByte(&info,&length);
663 resource[count]='\0';
666 if ((count & 0x01) == 0)
667 (void) ReadPropertyByte(&info,&length);
668 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
669 if ((*name != '\0') && (*name != '#'))
670 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
673 No name match, scroll forward and try next.
676 length-=MagickMin(count,(ssize_t) length);
679 if ((*name == '#') && (sub_number != 1))
682 No numbered match, scroll forward and try next.
686 length-=MagickMin(count,(ssize_t) length);
690 We have the resource of interest.
692 attribute=(char *) NULL;
693 if (~((size_t) count) >= (MagickPathExtent-1))
694 attribute=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent,
696 if (attribute != (char *) NULL)
698 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
699 attribute[count]='\0';
701 length-=MagickMin(count,(ssize_t) length);
702 if ((id <= 1999) || (id >= 2999))
703 (void) SetImageProperty((Image *) image,key,(const char *)
704 attribute,exception);
710 if (LocaleCompare(format,"svg") == 0)
711 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
712 image->columns,image->rows);
714 path=TracePSClippath((unsigned char *) attribute,(size_t) count);
715 (void) SetImageProperty((Image *) image,key,(const char *) path,
717 path=DestroyString(path);
719 attribute=DestroyString(attribute);
723 if (resource != (char *) NULL)
724 resource=DestroyString(resource);
728 static inline signed int ReadPropertySignedLong(const EndianType endian,
729 const unsigned char *buffer)
743 if (endian == LSBEndian)
745 value=(unsigned int) buffer[3] << 24;
746 value|=(unsigned int) buffer[2] << 16;
747 value|=(unsigned int) buffer[1] << 8;
748 value|=(unsigned int) buffer[0];
749 quantum.unsigned_value=value & 0xffffffff;
750 return(quantum.signed_value);
752 value=(unsigned int) buffer[0] << 24;
753 value|=(unsigned int) buffer[1] << 16;
754 value|=(unsigned int) buffer[2] << 8;
755 value|=(unsigned int) buffer[3];
756 quantum.unsigned_value=value & 0xffffffff;
757 return(quantum.signed_value);
760 static inline unsigned int ReadPropertyUnsignedLong(const EndianType endian,
761 const unsigned char *buffer)
766 if (endian == LSBEndian)
768 value=(unsigned int) buffer[3] << 24;
769 value|=(unsigned int) buffer[2] << 16;
770 value|=(unsigned int) buffer[1] << 8;
771 value|=(unsigned int) buffer[0];
772 return(value & 0xffffffff);
774 value=(unsigned int) buffer[0] << 24;
775 value|=(unsigned int) buffer[1] << 16;
776 value|=(unsigned int) buffer[2] << 8;
777 value|=(unsigned int) buffer[3];
778 return(value & 0xffffffff);
781 static inline signed short ReadPropertySignedShort(const EndianType endian,
782 const unsigned char *buffer)
796 if (endian == LSBEndian)
798 value=(unsigned short) buffer[1] << 8;
799 value|=(unsigned short) buffer[0];
800 quantum.unsigned_value=value & 0xffff;
801 return(quantum.signed_value);
803 value=(unsigned short) buffer[0] << 8;
804 value|=(unsigned short) buffer[1];
805 quantum.unsigned_value=value & 0xffff;
806 return(quantum.signed_value);
809 static inline unsigned short ReadPropertyUnsignedShort(const EndianType endian,
810 const unsigned char *buffer)
815 if (endian == LSBEndian)
817 value=(unsigned short) buffer[1] << 8;
818 value|=(unsigned short) buffer[0];
819 return(value & 0xffff);
821 value=(unsigned short) buffer[0] << 8;
822 value|=(unsigned short) buffer[1];
823 return(value & 0xffff);
826 static MagickBooleanType GetEXIFProperty(const Image *image,
827 const char *property,ExceptionInfo *exception)
829 #define MaxDirectoryStack 16
830 #define EXIF_DELIMITER "\n"
831 #define EXIF_NUM_FORMATS 12
832 #define EXIF_FMT_BYTE 1
833 #define EXIF_FMT_STRING 2
834 #define EXIF_FMT_USHORT 3
835 #define EXIF_FMT_ULONG 4
836 #define EXIF_FMT_URATIONAL 5
837 #define EXIF_FMT_SBYTE 6
838 #define EXIF_FMT_UNDEFINED 7
839 #define EXIF_FMT_SSHORT 8
840 #define EXIF_FMT_SLONG 9
841 #define EXIF_FMT_SRATIONAL 10
842 #define EXIF_FMT_SINGLE 11
843 #define EXIF_FMT_DOUBLE 12
844 #define TAG_EXIF_OFFSET 0x8769
845 #define TAG_GPS_OFFSET 0x8825
846 #define TAG_INTEROP_OFFSET 0xa005
848 #define EXIFMultipleValues(size,format,arg) \
861 for (component=0; component < components; component++) \
863 length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
865 if (length >= (MagickPathExtent-1)) \
866 length=MagickPathExtent-1; \
870 buffer[length-2]='\0'; \
871 value=AcquireString(buffer); \
874 #define EXIFMultipleFractions(size,format,arg1,arg2) \
887 for (component=0; component < components; component++) \
889 length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
890 format", ",(arg1),(arg2)); \
891 if (length >= (MagickPathExtent-1)) \
892 length=MagickPathExtent-1; \
896 buffer[length-2]='\0'; \
897 value=AcquireString(buffer); \
900 typedef struct _DirectoryInfo
912 typedef struct _TagInfo
924 { 0x001, "exif:InteroperabilityIndex" },
925 { 0x002, "exif:InteroperabilityVersion" },
926 { 0x100, "exif:ImageWidth" },
927 { 0x101, "exif:ImageLength" },
928 { 0x102, "exif:BitsPerSample" },
929 { 0x103, "exif:Compression" },
930 { 0x106, "exif:PhotometricInterpretation" },
931 { 0x10a, "exif:FillOrder" },
932 { 0x10d, "exif:DocumentName" },
933 { 0x10e, "exif:ImageDescription" },
934 { 0x10f, "exif:Make" },
935 { 0x110, "exif:Model" },
936 { 0x111, "exif:StripOffsets" },
937 { 0x112, "exif:Orientation" },
938 { 0x115, "exif:SamplesPerPixel" },
939 { 0x116, "exif:RowsPerStrip" },
940 { 0x117, "exif:StripByteCounts" },
941 { 0x11a, "exif:XResolution" },
942 { 0x11b, "exif:YResolution" },
943 { 0x11c, "exif:PlanarConfiguration" },
944 { 0x11d, "exif:PageName" },
945 { 0x11e, "exif:XPosition" },
946 { 0x11f, "exif:YPosition" },
947 { 0x118, "exif:MinSampleValue" },
948 { 0x119, "exif:MaxSampleValue" },
949 { 0x120, "exif:FreeOffsets" },
950 { 0x121, "exif:FreeByteCounts" },
951 { 0x122, "exif:GrayResponseUnit" },
952 { 0x123, "exif:GrayResponseCurve" },
953 { 0x124, "exif:T4Options" },
954 { 0x125, "exif:T6Options" },
955 { 0x128, "exif:ResolutionUnit" },
956 { 0x12d, "exif:TransferFunction" },
957 { 0x131, "exif:Software" },
958 { 0x132, "exif:DateTime" },
959 { 0x13b, "exif:Artist" },
960 { 0x13e, "exif:WhitePoint" },
961 { 0x13f, "exif:PrimaryChromaticities" },
962 { 0x140, "exif:ColorMap" },
963 { 0x141, "exif:HalfToneHints" },
964 { 0x142, "exif:TileWidth" },
965 { 0x143, "exif:TileLength" },
966 { 0x144, "exif:TileOffsets" },
967 { 0x145, "exif:TileByteCounts" },
968 { 0x14a, "exif:SubIFD" },
969 { 0x14c, "exif:InkSet" },
970 { 0x14d, "exif:InkNames" },
971 { 0x14e, "exif:NumberOfInks" },
972 { 0x150, "exif:DotRange" },
973 { 0x151, "exif:TargetPrinter" },
974 { 0x152, "exif:ExtraSample" },
975 { 0x153, "exif:SampleFormat" },
976 { 0x154, "exif:SMinSampleValue" },
977 { 0x155, "exif:SMaxSampleValue" },
978 { 0x156, "exif:TransferRange" },
979 { 0x157, "exif:ClipPath" },
980 { 0x158, "exif:XClipPathUnits" },
981 { 0x159, "exif:YClipPathUnits" },
982 { 0x15a, "exif:Indexed" },
983 { 0x15b, "exif:JPEGTables" },
984 { 0x15f, "exif:OPIProxy" },
985 { 0x200, "exif:JPEGProc" },
986 { 0x201, "exif:JPEGInterchangeFormat" },
987 { 0x202, "exif:JPEGInterchangeFormatLength" },
988 { 0x203, "exif:JPEGRestartInterval" },
989 { 0x205, "exif:JPEGLosslessPredictors" },
990 { 0x206, "exif:JPEGPointTransforms" },
991 { 0x207, "exif:JPEGQTables" },
992 { 0x208, "exif:JPEGDCTables" },
993 { 0x209, "exif:JPEGACTables" },
994 { 0x211, "exif:YCbCrCoefficients" },
995 { 0x212, "exif:YCbCrSubSampling" },
996 { 0x213, "exif:YCbCrPositioning" },
997 { 0x214, "exif:ReferenceBlackWhite" },
998 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
999 { 0x301, "exif:Gamma" },
1000 { 0x302, "exif:ICCProfileDescriptor" },
1001 { 0x303, "exif:SRGBRenderingIntent" },
1002 { 0x320, "exif:ImageTitle" },
1003 { 0x5001, "exif:ResolutionXUnit" },
1004 { 0x5002, "exif:ResolutionYUnit" },
1005 { 0x5003, "exif:ResolutionXLengthUnit" },
1006 { 0x5004, "exif:ResolutionYLengthUnit" },
1007 { 0x5005, "exif:PrintFlags" },
1008 { 0x5006, "exif:PrintFlagsVersion" },
1009 { 0x5007, "exif:PrintFlagsCrop" },
1010 { 0x5008, "exif:PrintFlagsBleedWidth" },
1011 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
1012 { 0x500A, "exif:HalftoneLPI" },
1013 { 0x500B, "exif:HalftoneLPIUnit" },
1014 { 0x500C, "exif:HalftoneDegree" },
1015 { 0x500D, "exif:HalftoneShape" },
1016 { 0x500E, "exif:HalftoneMisc" },
1017 { 0x500F, "exif:HalftoneScreen" },
1018 { 0x5010, "exif:JPEGQuality" },
1019 { 0x5011, "exif:GridSize" },
1020 { 0x5012, "exif:ThumbnailFormat" },
1021 { 0x5013, "exif:ThumbnailWidth" },
1022 { 0x5014, "exif:ThumbnailHeight" },
1023 { 0x5015, "exif:ThumbnailColorDepth" },
1024 { 0x5016, "exif:ThumbnailPlanes" },
1025 { 0x5017, "exif:ThumbnailRawBytes" },
1026 { 0x5018, "exif:ThumbnailSize" },
1027 { 0x5019, "exif:ThumbnailCompressedSize" },
1028 { 0x501a, "exif:ColorTransferFunction" },
1029 { 0x501b, "exif:ThumbnailData" },
1030 { 0x5020, "exif:ThumbnailImageWidth" },
1031 { 0x5021, "exif:ThumbnailImageHeight" },
1032 { 0x5022, "exif:ThumbnailBitsPerSample" },
1033 { 0x5023, "exif:ThumbnailCompression" },
1034 { 0x5024, "exif:ThumbnailPhotometricInterp" },
1035 { 0x5025, "exif:ThumbnailImageDescription" },
1036 { 0x5026, "exif:ThumbnailEquipMake" },
1037 { 0x5027, "exif:ThumbnailEquipModel" },
1038 { 0x5028, "exif:ThumbnailStripOffsets" },
1039 { 0x5029, "exif:ThumbnailOrientation" },
1040 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
1041 { 0x502b, "exif:ThumbnailRowsPerStrip" },
1042 { 0x502c, "exif:ThumbnailStripBytesCount" },
1043 { 0x502d, "exif:ThumbnailResolutionX" },
1044 { 0x502e, "exif:ThumbnailResolutionY" },
1045 { 0x502f, "exif:ThumbnailPlanarConfig" },
1046 { 0x5030, "exif:ThumbnailResolutionUnit" },
1047 { 0x5031, "exif:ThumbnailTransferFunction" },
1048 { 0x5032, "exif:ThumbnailSoftwareUsed" },
1049 { 0x5033, "exif:ThumbnailDateTime" },
1050 { 0x5034, "exif:ThumbnailArtist" },
1051 { 0x5035, "exif:ThumbnailWhitePoint" },
1052 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
1053 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
1054 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
1055 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
1056 { 0x503A, "exif:ThumbnailRefBlackWhite" },
1057 { 0x503B, "exif:ThumbnailCopyRight" },
1058 { 0x5090, "exif:LuminanceTable" },
1059 { 0x5091, "exif:ChrominanceTable" },
1060 { 0x5100, "exif:FrameDelay" },
1061 { 0x5101, "exif:LoopCount" },
1062 { 0x5110, "exif:PixelUnit" },
1063 { 0x5111, "exif:PixelPerUnitX" },
1064 { 0x5112, "exif:PixelPerUnitY" },
1065 { 0x5113, "exif:PaletteHistogram" },
1066 { 0x1000, "exif:RelatedImageFileFormat" },
1067 { 0x1001, "exif:RelatedImageLength" },
1068 { 0x1002, "exif:RelatedImageWidth" },
1069 { 0x800d, "exif:ImageID" },
1070 { 0x80e3, "exif:Matteing" },
1071 { 0x80e4, "exif:DataType" },
1072 { 0x80e5, "exif:ImageDepth" },
1073 { 0x80e6, "exif:TileDepth" },
1074 { 0x828d, "exif:CFARepeatPatternDim" },
1075 { 0x828e, "exif:CFAPattern2" },
1076 { 0x828f, "exif:BatteryLevel" },
1077 { 0x8298, "exif:Copyright" },
1078 { 0x829a, "exif:ExposureTime" },
1079 { 0x829d, "exif:FNumber" },
1080 { 0x83bb, "exif:IPTC/NAA" },
1081 { 0x84e3, "exif:IT8RasterPadding" },
1082 { 0x84e5, "exif:IT8ColorTable" },
1083 { 0x8649, "exif:ImageResourceInformation" },
1084 { 0x8769, "exif:ExifOffset" },
1085 { 0x8773, "exif:InterColorProfile" },
1086 { 0x8822, "exif:ExposureProgram" },
1087 { 0x8824, "exif:SpectralSensitivity" },
1088 { 0x8825, "exif:GPSInfo" },
1089 { 0x8827, "exif:ISOSpeedRatings" },
1090 { 0x8828, "exif:OECF" },
1091 { 0x8829, "exif:Interlace" },
1092 { 0x882a, "exif:TimeZoneOffset" },
1093 { 0x882b, "exif:SelfTimerMode" },
1094 { 0x9000, "exif:ExifVersion" },
1095 { 0x9003, "exif:DateTimeOriginal" },
1096 { 0x9004, "exif:DateTimeDigitized" },
1097 { 0x9101, "exif:ComponentsConfiguration" },
1098 { 0x9102, "exif:CompressedBitsPerPixel" },
1099 { 0x9201, "exif:ShutterSpeedValue" },
1100 { 0x9202, "exif:ApertureValue" },
1101 { 0x9203, "exif:BrightnessValue" },
1102 { 0x9204, "exif:ExposureBiasValue" },
1103 { 0x9205, "exif:MaxApertureValue" },
1104 { 0x9206, "exif:SubjectDistance" },
1105 { 0x9207, "exif:MeteringMode" },
1106 { 0x9208, "exif:LightSource" },
1107 { 0x9209, "exif:Flash" },
1108 { 0x920a, "exif:FocalLength" },
1109 { 0x920b, "exif:FlashEnergy" },
1110 { 0x920c, "exif:SpatialFrequencyResponse" },
1111 { 0x920d, "exif:Noise" },
1112 { 0x9211, "exif:ImageNumber" },
1113 { 0x9212, "exif:SecurityClassification" },
1114 { 0x9213, "exif:ImageHistory" },
1115 { 0x9214, "exif:SubjectArea" },
1116 { 0x9215, "exif:ExposureIndex" },
1117 { 0x9216, "exif:TIFF-EPStandardID" },
1118 { 0x927c, "exif:MakerNote" },
1119 { 0x9C9b, "exif:WinXP-Title" },
1120 { 0x9C9c, "exif:WinXP-Comments" },
1121 { 0x9C9d, "exif:WinXP-Author" },
1122 { 0x9C9e, "exif:WinXP-Keywords" },
1123 { 0x9C9f, "exif:WinXP-Subject" },
1124 { 0x9286, "exif:UserComment" },
1125 { 0x9290, "exif:SubSecTime" },
1126 { 0x9291, "exif:SubSecTimeOriginal" },
1127 { 0x9292, "exif:SubSecTimeDigitized" },
1128 { 0xa000, "exif:FlashPixVersion" },
1129 { 0xa001, "exif:ColorSpace" },
1130 { 0xa002, "exif:ExifImageWidth" },
1131 { 0xa003, "exif:ExifImageLength" },
1132 { 0xa004, "exif:RelatedSoundFile" },
1133 { 0xa005, "exif:InteroperabilityOffset" },
1134 { 0xa20b, "exif:FlashEnergy" },
1135 { 0xa20c, "exif:SpatialFrequencyResponse" },
1136 { 0xa20d, "exif:Noise" },
1137 { 0xa20e, "exif:FocalPlaneXResolution" },
1138 { 0xa20f, "exif:FocalPlaneYResolution" },
1139 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1140 { 0xa214, "exif:SubjectLocation" },
1141 { 0xa215, "exif:ExposureIndex" },
1142 { 0xa216, "exif:TIFF/EPStandardID" },
1143 { 0xa217, "exif:SensingMethod" },
1144 { 0xa300, "exif:FileSource" },
1145 { 0xa301, "exif:SceneType" },
1146 { 0xa302, "exif:CFAPattern" },
1147 { 0xa401, "exif:CustomRendered" },
1148 { 0xa402, "exif:ExposureMode" },
1149 { 0xa403, "exif:WhiteBalance" },
1150 { 0xa404, "exif:DigitalZoomRatio" },
1151 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1152 { 0xa406, "exif:SceneCaptureType" },
1153 { 0xa407, "exif:GainControl" },
1154 { 0xa408, "exif:Contrast" },
1155 { 0xa409, "exif:Saturation" },
1156 { 0xa40a, "exif:Sharpness" },
1157 { 0xa40b, "exif:DeviceSettingDescription" },
1158 { 0xa40c, "exif:SubjectDistanceRange" },
1159 { 0xa420, "exif:ImageUniqueID" },
1160 { 0xc4a5, "exif:PrintImageMatching" },
1161 { 0xa500, "exif:Gamma" },
1162 { 0xc640, "exif:CR2Slice" },
1163 { 0x10000, "exif:GPSVersionID" },
1164 { 0x10001, "exif:GPSLatitudeRef" },
1165 { 0x10002, "exif:GPSLatitude" },
1166 { 0x10003, "exif:GPSLongitudeRef" },
1167 { 0x10004, "exif:GPSLongitude" },
1168 { 0x10005, "exif:GPSAltitudeRef" },
1169 { 0x10006, "exif:GPSAltitude" },
1170 { 0x10007, "exif:GPSTimeStamp" },
1171 { 0x10008, "exif:GPSSatellites" },
1172 { 0x10009, "exif:GPSStatus" },
1173 { 0x1000a, "exif:GPSMeasureMode" },
1174 { 0x1000b, "exif:GPSDop" },
1175 { 0x1000c, "exif:GPSSpeedRef" },
1176 { 0x1000d, "exif:GPSSpeed" },
1177 { 0x1000e, "exif:GPSTrackRef" },
1178 { 0x1000f, "exif:GPSTrack" },
1179 { 0x10010, "exif:GPSImgDirectionRef" },
1180 { 0x10011, "exif:GPSImgDirection" },
1181 { 0x10012, "exif:GPSMapDatum" },
1182 { 0x10013, "exif:GPSDestLatitudeRef" },
1183 { 0x10014, "exif:GPSDestLatitude" },
1184 { 0x10015, "exif:GPSDestLongitudeRef" },
1185 { 0x10016, "exif:GPSDestLongitude" },
1186 { 0x10017, "exif:GPSDestBearingRef" },
1187 { 0x10018, "exif:GPSDestBearing" },
1188 { 0x10019, "exif:GPSDestDistanceRef" },
1189 { 0x1001a, "exif:GPSDestDistance" },
1190 { 0x1001b, "exif:GPSProcessingMethod" },
1191 { 0x1001c, "exif:GPSAreaInformation" },
1192 { 0x1001d, "exif:GPSDateStamp" },
1193 { 0x1001e, "exif:GPSDifferential" },
1194 { 0x00000, (const char *) NULL }
1205 directory_stack[MaxDirectoryStack];
1234 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1237 If EXIF data exists, then try to parse the request for a tag.
1239 profile=GetImageProfile(image,"exif");
1240 if (profile == (const StringInfo *) NULL)
1241 return(MagickFalse);
1242 if ((property == (const char *) NULL) || (*property == '\0'))
1243 return(MagickFalse);
1244 while (isspace((int) ((unsigned char) *property)) != 0)
1246 if (strlen(property) <= 5)
1247 return(MagickFalse);
1250 switch (*(property+5))
1255 Caller has asked for all the tags in the EXIF data.
1258 all=1; /* return the data in description=value format */
1264 all=2; /* return the data in tagid=value format */
1277 Check for a hex based tag specification first.
1279 tag=(*(property+5) == '@') ? 1UL : 0UL;
1283 return(MagickFalse);
1285 Parse tag specification as a hex number.
1290 for (i=(ssize_t) n-1L; i >= 0; i--)
1294 if ((c >= '0') && (c <= '9'))
1297 if ((c >= 'A') && (c <= 'F'))
1300 if ((c >= 'a') && (c <= 'f'))
1303 return(MagickFalse);
1305 } while (*property != '\0');
1311 Try to match the text with a tag name instead.
1315 if (EXIFTag[i].tag == 0)
1317 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1319 tag=(size_t) EXIFTag[i].tag;
1327 return(MagickFalse);
1328 length=GetStringInfoLength(profile);
1329 exif=GetStringInfoDatum(profile);
1332 if (ReadPropertyByte(&exif,&length) != 0x45)
1334 if (ReadPropertyByte(&exif,&length) != 0x78)
1336 if (ReadPropertyByte(&exif,&length) != 0x69)
1338 if (ReadPropertyByte(&exif,&length) != 0x66)
1340 if (ReadPropertyByte(&exif,&length) != 0x00)
1342 if (ReadPropertyByte(&exif,&length) != 0x00)
1347 return(MagickFalse);
1348 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1356 return(MagickFalse);
1357 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1358 return(MagickFalse);
1360 This the offset to the first IFD.
1362 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1363 if ((offset < 0) || (size_t) offset >= length)
1364 return(MagickFalse);
1366 Set the pointer to the first IFD and follow it were it leads.
1369 directory=exif+offset;
1373 exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,
1374 (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
1378 If there is anything on the stack then pop it off.
1383 directory=directory_stack[level].directory;
1384 entry=directory_stack[level].entry;
1385 tag_offset=directory_stack[level].offset;
1387 if ((directory < exif) || (directory > (exif+length-2)))
1390 Determine how many entries there are in the current IFD.
1392 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1393 for ( ; entry < number_entries; entry++)
1395 register unsigned char
1406 q=(unsigned char *) (directory+(12*entry)+2);
1407 if (q > (exif+length-12))
1408 break; /* corrupt EXIF */
1409 if (GetValueFromSplayTree(exif_resources,q) == q)
1411 (void) AddValueToSplayTree(exif_resources,q,q);
1412 tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;
1413 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1414 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1416 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1418 break; /* corrupt EXIF */
1419 number_bytes=(size_t) components*tag_bytes[format];
1420 if (number_bytes < components)
1421 break; /* prevent overflow */
1422 if (number_bytes <= 4)
1430 The directory entry contains an offset.
1432 offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1433 if ((offset < 0) || (size_t) offset >= length)
1435 if ((ssize_t) (offset+number_bytes) < offset)
1436 continue; /* prevent overflow */
1437 if ((size_t) (offset+number_bytes) > length)
1439 p=(unsigned char *) (exif+offset);
1441 if ((all != 0) || (tag == (size_t) tag_value))
1444 buffer[MagickPathExtent],
1447 value=(char *) NULL;
1452 case EXIF_FMT_UNDEFINED:
1454 EXIFMultipleValues(1,"%.20g",(double) (*(unsigned char *) p1));
1457 case EXIF_FMT_SBYTE:
1459 EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1462 case EXIF_FMT_SSHORT:
1464 EXIFMultipleValues(2,"%hd",ReadPropertySignedShort(endian,p1));
1467 case EXIF_FMT_USHORT:
1469 EXIFMultipleValues(2,"%hu",ReadPropertyUnsignedShort(endian,p1));
1472 case EXIF_FMT_ULONG:
1474 EXIFMultipleValues(4,"%.20g",(double)
1475 ReadPropertyUnsignedLong(endian,p1));
1478 case EXIF_FMT_SLONG:
1480 EXIFMultipleValues(4,"%.20g",(double)
1481 ReadPropertySignedLong(endian,p1));
1484 case EXIF_FMT_URATIONAL:
1486 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1487 ReadPropertyUnsignedLong(endian,p1),(double)
1488 ReadPropertyUnsignedLong(endian,p1+4));
1491 case EXIF_FMT_SRATIONAL:
1493 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1494 ReadPropertySignedLong(endian,p1),(double)
1495 ReadPropertySignedLong(endian,p1+4));
1498 case EXIF_FMT_SINGLE:
1500 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1503 case EXIF_FMT_DOUBLE:
1505 EXIFMultipleValues(8,"%f",*(double *) p1);
1509 case EXIF_FMT_STRING:
1511 value=(char *) NULL;
1512 if (~((size_t) number_bytes) >= 1)
1513 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1515 if (value != (char *) NULL)
1520 for (i=0; i < (ssize_t) number_bytes; i++)
1523 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1524 value[i]=(char) p[i];
1531 if (value != (char *) NULL)
1539 key=AcquireString(property);
1550 description="unknown";
1553 if (EXIFTag[i].tag == 0)
1555 if (EXIFTag[i].tag == tag_value)
1557 description=EXIFTag[i].description;
1561 (void) FormatLocaleString(key,MagickPathExtent,"%s",
1564 (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1569 if (tag_value < 0x10000)
1570 (void) FormatLocaleString(key,MagickPathExtent,"#%04lx",
1571 (unsigned long) tag_value);
1573 if (tag_value < 0x20000)
1574 (void) FormatLocaleString(key,MagickPathExtent,"@%04lx",
1575 (unsigned long) (tag_value & 0xffff));
1577 (void) FormatLocaleString(key,MagickPathExtent,"unknown");
1583 (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1586 p=(const char *) NULL;
1587 if (image->properties != (void *) NULL)
1588 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1589 image->properties,key);
1590 if (p == (const char *) NULL)
1591 (void) SetImageProperty((Image *) image,key,value,exception);
1592 value=DestroyString(value);
1593 key=DestroyString(key);
1597 if ((tag_value == TAG_EXIF_OFFSET) ||
1598 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1603 offset=(ssize_t) ReadPropertySignedLong(endian,p);
1604 if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1609 tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1611 directory_stack[level].directory=directory;
1613 directory_stack[level].entry=entry;
1614 directory_stack[level].offset=tag_offset;
1616 directory_stack[level].directory=exif+offset;
1617 directory_stack[level].offset=tag_offset1;
1618 directory_stack[level].entry=0;
1620 if ((directory+2+(12*number_entries)) > (exif+length))
1622 offset=(ssize_t) ReadPropertySignedLong(endian,directory+2+(12*
1624 if ((offset != 0) && ((size_t) offset < length) &&
1625 (level < (MaxDirectoryStack-2)))
1627 directory_stack[level].directory=exif+offset;
1628 directory_stack[level].entry=0;
1629 directory_stack[level].offset=tag_offset1;
1636 } while (level > 0);
1637 exif_resources=DestroySplayTree(exif_resources);
1641 static MagickBooleanType GetICCProperty(const Image *image,const char *property,
1642 ExceptionInfo *exception)
1647 magick_unreferenced(property);
1649 profile=GetImageProfile(image,"icc");
1650 if (profile == (StringInfo *) NULL)
1651 profile=GetImageProfile(image,"icm");
1652 if (profile == (StringInfo *) NULL)
1653 return(MagickFalse);
1654 if (GetStringInfoLength(profile) < 128)
1655 return(MagickFalse); /* minimum ICC profile length */
1656 #if defined(MAGICKCORE_LCMS_DELEGATE)
1661 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1662 (cmsUInt32Number) GetStringInfoLength(profile));
1663 if (icc_profile != (cmsHPROFILE *) NULL)
1665 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1669 name=cmsTakeProductName(icc_profile);
1670 if (name != (const char *) NULL)
1671 (void) SetImageProperty((Image *) image,"icc:name",name,exception);
1674 info[MagickPathExtent];
1676 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
1677 "en","US",info,MagickPathExtent);
1678 (void) SetImageProperty((Image *) image,"icc:description",info,
1680 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
1681 "en","US",info,MagickPathExtent);
1682 (void) SetImageProperty((Image *) image,"icc:manufacturer",info,
1684 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
1685 "US",info,MagickPathExtent);
1686 (void) SetImageProperty((Image *) image,"icc:model",info,exception);
1687 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
1688 "en","US",info,MagickPathExtent);
1689 (void) SetImageProperty((Image *) image,"icc:copyright",info,exception);
1691 (void) cmsCloseProfile(icc_profile);
1698 static MagickBooleanType SkipXMPValue(const char *value)
1700 if (value == (const char*) NULL)
1702 while (*value != '\0')
1704 if (isspace((int) ((unsigned char) *value)) == 0)
1705 return(MagickFalse);
1711 static MagickBooleanType GetXMPProperty(const Image *image,const char *property)
1738 profile=GetImageProfile(image,"xmp");
1739 if (profile == (StringInfo *) NULL)
1740 return(MagickFalse);
1741 if ((property == (const char *) NULL) || (*property == '\0'))
1742 return(MagickFalse);
1743 xmp_profile=StringInfoToString(profile);
1744 if (xmp_profile == (char *) NULL)
1745 return(MagickFalse);
1746 for (p=xmp_profile; *p != '\0'; p++)
1747 if ((*p == '<') && (*(p+1) == 'x'))
1749 exception=AcquireExceptionInfo();
1750 xmp=NewXMLTree((char *) p,exception);
1751 xmp_profile=DestroyString(xmp_profile);
1752 exception=DestroyExceptionInfo(exception);
1753 if (xmp == (XMLTreeInfo *) NULL)
1754 return(MagickFalse);
1756 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1757 if (rdf != (XMLTreeInfo *) NULL)
1759 if (image->properties == (void *) NULL)
1760 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1761 RelinquishMagickMemory,RelinquishMagickMemory);
1762 description=GetXMLTreeChild(rdf,"rdf:Description");
1763 while (description != (XMLTreeInfo *) NULL)
1765 node=GetXMLTreeChild(description,(const char *) NULL);
1766 while (node != (XMLTreeInfo *) NULL)
1768 child=GetXMLTreeChild(node,(const char *) NULL);
1769 content=GetXMLTreeContent(node);
1770 if ((child == (XMLTreeInfo *) NULL) &&
1771 (SkipXMPValue(content) == MagickFalse))
1772 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1773 ConstantString(GetXMLTreeTag(node)),ConstantString(content));
1774 while (child != (XMLTreeInfo *) NULL)
1776 content=GetXMLTreeContent(child);
1777 if (SkipXMPValue(content) == MagickFalse)
1778 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1779 ConstantString(GetXMLTreeTag(child)),ConstantString(content));
1780 child=GetXMLTreeSibling(child);
1782 node=GetXMLTreeSibling(node);
1784 description=GetNextXMLTreeTag(description);
1787 xmp=DestroyXMLTree(xmp);
1791 static char *TracePSClippath(const unsigned char *blob,size_t length)
1814 path=AcquireString((char *) NULL);
1815 if (path == (char *) NULL)
1816 return((char *) NULL);
1817 message=AcquireString((char *) NULL);
1818 (void) FormatLocaleString(message,MagickPathExtent,"/ClipImage\n");
1819 (void) ConcatenateString(&path,message);
1820 (void) FormatLocaleString(message,MagickPathExtent,"{\n");
1821 (void) ConcatenateString(&path,message);
1822 (void) FormatLocaleString(message,MagickPathExtent,
1823 " /c {curveto} bind def\n");
1824 (void) ConcatenateString(&path,message);
1825 (void) FormatLocaleString(message,MagickPathExtent,
1826 " /l {lineto} bind def\n");
1827 (void) ConcatenateString(&path,message);
1828 (void) FormatLocaleString(message,MagickPathExtent,
1829 " /m {moveto} bind def\n");
1830 (void) ConcatenateString(&path,message);
1831 (void) FormatLocaleString(message,MagickPathExtent,
1832 " /v {currentpoint 6 2 roll curveto} bind def\n");
1833 (void) ConcatenateString(&path,message);
1834 (void) FormatLocaleString(message,MagickPathExtent,
1835 " /y {2 copy curveto} bind def\n");
1836 (void) ConcatenateString(&path,message);
1837 (void) FormatLocaleString(message,MagickPathExtent,
1838 " /z {closepath} bind def\n");
1839 (void) ConcatenateString(&path,message);
1840 (void) FormatLocaleString(message,MagickPathExtent," newpath\n");
1841 (void) ConcatenateString(&path,message);
1843 The clipping path format is defined in "Adobe Photoshop File Formats
1844 Specification" version 6.0 downloadable from adobe.com.
1846 (void) ResetMagickMemory(point,0,sizeof(point));
1847 (void) ResetMagickMemory(first,0,sizeof(first));
1848 (void) ResetMagickMemory(last,0,sizeof(last));
1850 in_subpath=MagickFalse;
1853 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1859 if (knot_count != 0)
1862 length-=MagickMin(24,(ssize_t) length);
1866 Expected subpath length record.
1868 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1870 length-=MagickMin(22,(ssize_t) length);
1878 if (knot_count == 0)
1881 Unexpected subpath knot
1884 length-=MagickMin(24,(ssize_t) length);
1890 for (i=0; i < 3; i++)
1896 yy=(size_t) ReadPropertyMSBLong(&blob,&length);
1897 xx=(size_t) ReadPropertyMSBLong(&blob,&length);
1899 if (xx > 2147483647)
1900 x=(ssize_t) xx-4294967295U-1;
1902 if (yy > 2147483647)
1903 y=(ssize_t) yy-4294967295U-1;
1904 point[i].x=(double) x/4096/4096;
1905 point[i].y=1.0-(double) y/4096/4096;
1907 if (in_subpath == MagickFalse)
1909 (void) FormatLocaleString(message,MagickPathExtent," %g %g m\n",
1910 point[1].x,point[1].y);
1911 for (i=0; i < 3; i++)
1920 Handle special cases when Bezier curves are used to describe
1921 corners and straight lines.
1923 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1924 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1925 (void) FormatLocaleString(message,MagickPathExtent,
1926 " %g %g l\n",point[1].x,point[1].y);
1928 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1929 (void) FormatLocaleString(message,MagickPathExtent,
1930 " %g %g %g %g v\n",point[0].x,point[0].y,
1931 point[1].x,point[1].y);
1933 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1934 (void) FormatLocaleString(message,MagickPathExtent,
1935 " %g %g %g %g y\n",last[2].x,last[2].y,
1936 point[1].x,point[1].y);
1938 (void) FormatLocaleString(message,MagickPathExtent,
1939 " %g %g %g %g %g %g c\n",last[2].x,
1940 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1941 for (i=0; i < 3; i++)
1944 (void) ConcatenateString(&path,message);
1945 in_subpath=MagickTrue;
1948 Close the subpath if there are no more knots.
1950 if (knot_count == 0)
1953 Same special handling as above except we compare to the
1954 first point in the path and close the path.
1956 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1957 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1958 (void) FormatLocaleString(message,MagickPathExtent,
1959 " %g %g l z\n",first[1].x,first[1].y);
1961 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1962 (void) FormatLocaleString(message,MagickPathExtent,
1963 " %g %g %g %g v z\n",first[0].x,first[0].y,
1964 first[1].x,first[1].y);
1966 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1967 (void) FormatLocaleString(message,MagickPathExtent,
1968 " %g %g %g %g y z\n",last[2].x,last[2].y,
1969 first[1].x,first[1].y);
1971 (void) FormatLocaleString(message,MagickPathExtent,
1972 " %g %g %g %g %g %g c z\n",last[2].x,
1973 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1974 (void) ConcatenateString(&path,message);
1975 in_subpath=MagickFalse;
1985 length-=MagickMin(24,(ssize_t) length);
1991 Returns an empty PS path if the path has no knots.
1993 (void) FormatLocaleString(message,MagickPathExtent," eoclip\n");
1994 (void) ConcatenateString(&path,message);
1995 (void) FormatLocaleString(message,MagickPathExtent,"} bind def");
1996 (void) ConcatenateString(&path,message);
1997 message=DestroyString(message);
2001 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
2002 const size_t columns,const size_t rows)
2025 path=AcquireString((char *) NULL);
2026 if (path == (char *) NULL)
2027 return((char *) NULL);
2028 message=AcquireString((char *) NULL);
2029 (void) FormatLocaleString(message,MagickPathExtent,(
2030 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2031 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2032 " width=\"%.20g\" height=\"%.20g\">\n"
2034 "<path fill-rule=\"evenodd\" style=\"fill:#00000000;stroke:#00000000;"
2035 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(double) columns,
2037 (void) ConcatenateString(&path,message);
2038 (void) ResetMagickMemory(point,0,sizeof(point));
2039 (void) ResetMagickMemory(first,0,sizeof(first));
2040 (void) ResetMagickMemory(last,0,sizeof(last));
2042 in_subpath=MagickFalse;
2045 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2051 if (knot_count != 0)
2054 length-=MagickMin(24,(ssize_t) length);
2058 Expected subpath length record.
2060 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2062 length-=MagickMin(22,(ssize_t) length);
2070 if (knot_count == 0)
2073 Unexpected subpath knot.
2076 length-=MagickMin(24,(ssize_t) length);
2082 for (i=0; i < 3; i++)
2088 yy=(unsigned int) ReadPropertyMSBLong(&blob,&length);
2089 xx=(unsigned int) ReadPropertyMSBLong(&blob,&length);
2091 if (xx > 2147483647)
2092 x=(ssize_t) xx-4294967295U-1;
2094 if (yy > 2147483647)
2095 y=(ssize_t) yy-4294967295U-1;
2096 point[i].x=(double) x*columns/4096/4096;
2097 point[i].y=(double) y*rows/4096/4096;
2099 if (in_subpath == MagickFalse)
2101 (void) FormatLocaleString(message,MagickPathExtent,"M %g %g\n",
2102 point[1].x,point[1].y);
2103 for (i=0; i < 3; i++)
2112 Handle special cases when Bezier curves are used to describe
2113 corners and straight lines.
2115 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2116 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2117 (void) FormatLocaleString(message,MagickPathExtent,
2118 "L %g %g\n",point[1].x,point[1].y);
2120 (void) FormatLocaleString(message,MagickPathExtent,
2121 "C %g %g %g %g %g %g\n",last[2].x,
2122 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2123 for (i=0; i < 3; i++)
2126 (void) ConcatenateString(&path,message);
2127 in_subpath=MagickTrue;
2130 Close the subpath if there are no more knots.
2132 if (knot_count == 0)
2135 Same special handling as above except we compare to the
2136 first point in the path and close the path.
2138 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2139 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2140 (void) FormatLocaleString(message,MagickPathExtent,
2141 "L %g %g Z\n",first[1].x,first[1].y);
2143 (void) FormatLocaleString(message,MagickPathExtent,
2144 "C %g %g %g %g %g %g Z\n",last[2].x,
2145 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2146 (void) ConcatenateString(&path,message);
2147 in_subpath=MagickFalse;
2157 length-=MagickMin(24,(ssize_t) length);
2163 Return an empty SVG image if the path does not have knots.
2165 (void) ConcatenateString(&path,"\"/>\n</g>\n</svg>\n");
2166 message=DestroyString(message);
2170 MagickExport const char *GetImageProperty(const Image *image,
2171 const char *property,ExceptionInfo *exception)
2176 assert(image != (Image *) NULL);
2177 assert(image->signature == MagickCoreSignature);
2178 if (image->debug != MagickFalse)
2179 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2180 p=(const char *) NULL;
2181 if (image->properties != (void *) NULL)
2183 if (property == (const char *) NULL)
2185 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
2186 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
2190 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2191 image->properties,property);
2192 if (p != (const char *) NULL)
2195 if ((property == (const char *) NULL) ||
2196 (strchr(property,':') == (char *) NULL))
2202 if (LocaleNCompare("8bim:",property,5) == 0)
2204 (void) Get8BIMProperty(image,property,exception);
2212 if (LocaleNCompare("exif:",property,5) == 0)
2214 (void) GetEXIFProperty(image,property,exception);
2222 if ((LocaleNCompare("icc:",property,4) == 0) ||
2223 (LocaleNCompare("icm:",property,4) == 0))
2225 (void) GetICCProperty(image,property,exception);
2228 if (LocaleNCompare("iptc:",property,5) == 0)
2230 (void) GetIPTCProperty(image,property,exception);
2238 if (LocaleNCompare("xmp:",property,4) == 0)
2240 (void) GetXMPProperty(image,property);
2248 if (image->properties != (void *) NULL)
2250 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2251 image->properties,property);
2254 return((const char *) NULL);
2258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2262 + G e t M a g i c k P r o p e r t y %
2266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2268 % GetMagickProperty() gets attributes or calculated values that is associated
2269 % with a fixed known property name, or single letter property. It may be
2270 % called if no image is defined (IMv7), in which case only global image_info
2271 % values are available:
2274 % \r carriage return
2275 % < less-than character.
2276 % > greater-than character.
2277 % & ampersand character.
2279 % %b file size of image read in
2280 % %c comment meta-data property
2281 % %d directory component of path
2282 % %e filename extension or suffix
2283 % %f filename (including suffix)
2284 % %g layer canvas page geometry (equivalent to "%Wx%H%X%Y")
2285 % %h current image height in pixels
2286 % %i image filename (note: becomes output filename for "info:")
2287 % %k CALCULATED: number of unique colors
2288 % %l label meta-data property
2289 % %m image file format (file magic)
2290 % %n number of images in current image sequence
2291 % %o output filename (used for delegates)
2292 % %p index of image in current image list
2293 % %q quantum depth (compile-time constant)
2294 % %r image class and colorspace
2295 % %s scene number (from input unless re-assigned)
2296 % %t filename without directory or extension (suffix)
2297 % %u unique temporary filename (used for delegates)
2298 % %w current width in pixels
2299 % %x x resolution (density)
2300 % %y y resolution (density)
2301 % %z image depth (as read in unless modified, image save depth)
2302 % %A image transparency channel enabled (true/false)
2303 % %C image compression type
2304 % %D image GIF dispose method
2305 % %G original image size (%wx%h; before any resizes)
2306 % %H page (canvas) height
2307 % %M Magick filename (original file exactly as given, including read mods)
2308 % %O page (canvas) offset ( = %X%Y )
2309 % %P page (canvas) size ( = %Wx%H )
2310 % %Q image compression quality ( 0 = default )
2312 % %T image time delay (in centi-seconds)
2313 % %U image resolution units
2314 % %W page (canvas) width
2315 % %X page (canvas) x offset (including sign)
2316 % %Y page (canvas) y offset (including sign)
2317 % %Z unique filename (used for delegates)
2318 % %@ CALCULATED: trim bounding box (without actually trimming)
2319 % %# CALCULATED: 'signature' hash of image values
2321 % This routine only handles specifically known properties. It does not
2322 % handle special prefixed properties, profiles, or expressions. Nor does
2323 % it return any free-form property strings.
2325 % The returned string is stored in a structure somewhere, and should not be
2326 % directly freed. If the string was generated (common) the string will be
2327 % stored as as either as artifact or option 'get-property'. These may be
2328 % deleted (cleaned up) when no longer required, but neither artifact or
2329 % option is guranteed to exist.
2331 % The format of the GetMagickProperty method is:
2333 % const char *GetMagickProperty(ImageInfo *image_info,Image *image,
2334 % const char *property,ExceptionInfo *exception)
2336 % A description of each parameter follows:
2338 % o image_info: the image info (optional)
2340 % o image: the image (optional)
2344 % o exception: return any errors or warnings in this structure.
2347 static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2348 Image *image,const char letter,ExceptionInfo *exception)
2350 #define WarnNoImageReturn(format,arg) \
2351 if (image == (Image *) NULL ) { \
2352 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2353 "NoImageForProperty",format,arg); \
2354 return((const char *) NULL); \
2356 #define WarnNoImageInfoReturn(format,arg) \
2357 if (image_info == (ImageInfo *) NULL ) { \
2358 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2359 "NoImageInfoForProperty",format,arg); \
2360 return((const char *) NULL); \
2364 value[MagickPathExtent]; /* formated string to store as a returned artifact */
2367 *string; /* return a string already stored somewher */
2369 if ((image != (Image *) NULL) && (image->debug != MagickFalse))
2370 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2372 if ((image_info != (ImageInfo *) NULL) &&
2373 (image_info->debug != MagickFalse))
2374 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2375 *value='\0'; /* formatted string */
2376 string=(char *) NULL; /* constant string reference */
2378 Get properities that are directly defined by images.
2382 case 'b': /* image size read in - in bytes */
2384 WarnNoImageReturn("\"%%%c\"",letter);
2385 (void) FormatMagickSize(image->extent,MagickFalse,"B",MagickPathExtent,
2387 if (image->extent == 0)
2388 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
2389 MagickPathExtent,value);
2392 case 'c': /* image comment property - empty string by default */
2394 WarnNoImageReturn("\"%%%c\"",letter);
2395 string=GetImageProperty(image,"comment",exception);
2396 if ( string == (const char *) NULL )
2400 case 'd': /* Directory component of filename */
2402 WarnNoImageReturn("\"%%%c\"",letter);
2403 GetPathComponent(image->magick_filename,HeadPath,value);
2404 if (*value == '\0') string="";
2407 case 'e': /* Filename extension (suffix) of image file */
2409 WarnNoImageReturn("\"%%%c\"",letter);
2410 GetPathComponent(image->magick_filename,ExtensionPath,value);
2411 if (*value == '\0') string="";
2414 case 'f': /* Filename without directory component */
2416 WarnNoImageReturn("\"%%%c\"",letter);
2417 GetPathComponent(image->magick_filename,TailPath,value);
2418 if (*value == '\0') string="";
2421 case 'g': /* Image geometry, canvas and offset %Wx%H+%X+%Y */
2423 WarnNoImageReturn("\"%%%c\"",letter);
2424 (void) FormatLocaleString(value,MagickPathExtent,
2425 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,(double)
2426 image->page.height,(double) image->page.x,(double) image->page.y);
2429 case 'h': /* Image height (current) */
2431 WarnNoImageReturn("\"%%%c\"",letter);
2432 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2433 (image->rows != 0 ? image->rows : image->magick_rows));
2436 case 'i': /* Filename last used for an image (read or write) */
2438 WarnNoImageReturn("\"%%%c\"",letter);
2439 string=image->filename;
2442 case 'k': /* Number of unique colors */
2445 FUTURE: ensure this does not generate the formatted comment!
2447 WarnNoImageReturn("\"%%%c\"",letter);
2448 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2449 GetNumberColors(image,(FILE *) NULL,exception));
2452 case 'l': /* Image label property - empty string by default */
2454 WarnNoImageReturn("\"%%%c\"",letter);
2455 string=GetImageProperty(image,"label",exception);
2456 if ( string == (const char *) NULL)
2460 case 'm': /* Image format (file magick) */
2462 WarnNoImageReturn("\"%%%c\"",letter);
2463 string=image->magick;
2466 case 'n': /* Number of images in the list. */
2468 if ( image != (Image *) NULL )
2469 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2470 GetImageListLength(image));
2472 string="0"; /* no images or scenes */
2475 case 'o': /* Output Filename - for delegate use only */
2476 WarnNoImageInfoReturn("\"%%%c\"",letter);
2477 string=image_info->filename;
2479 case 'p': /* Image index in current image list */
2481 WarnNoImageReturn("\"%%%c\"",letter);
2482 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2483 GetImageIndexInList(image));
2486 case 'q': /* Quantum depth of image in memory */
2488 WarnNoImageReturn("\"%%%c\"",letter);
2489 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2490 MAGICKCORE_QUANTUM_DEPTH);
2493 case 'r': /* Image storage class, colorspace, and alpha enabled. */
2498 WarnNoImageReturn("\"%%%c\"",letter);
2499 colorspace=image->colorspace;
2500 if (SetImageGray(image,exception) != MagickFalse)
2501 colorspace=GRAYColorspace; /* FUTURE: this is IMv6 not IMv7 */
2502 (void) FormatLocaleString(value,MagickPathExtent,"%s %s %s",
2503 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2504 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2505 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2509 case 's': /* Image scene number */
2511 #if 0 /* this seems non-sensical -- simplifing */
2512 if (image_info->number_scenes != 0)
2513 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2515 else if (image != (Image *) NULL)
2516 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2521 WarnNoImageReturn("\"%%%c\"",letter);
2522 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2527 case 't': /* Base filename without directory or extention */
2529 WarnNoImageReturn("\"%%%c\"",letter);
2530 GetPathComponent(image->magick_filename,BasePath,value);
2531 if (*value == '\0') string="";
2534 case 'u': /* Unique filename */
2536 WarnNoImageInfoReturn("\"%%%c\"",letter);
2537 string=image_info->unique;
2540 case 'w': /* Image width (current) */
2542 WarnNoImageReturn("\"%%%c\"",letter);
2543 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2544 (image->columns != 0 ? image->columns : image->magick_columns));
2547 case 'x': /* Image horizontal resolution (with units) */
2549 WarnNoImageReturn("\"%%%c\"",letter);
2550 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2551 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x : 72.0);
2554 case 'y': /* Image vertical resolution (with units) */
2556 WarnNoImageReturn("\"%%%c\"",letter);
2557 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2558 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y : 72.0);
2561 case 'z': /* Image depth as read in */
2563 WarnNoImageReturn("\"%%%c\"",letter);
2564 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2565 (double) image->depth);
2568 case 'A': /* Image alpha channel */
2570 WarnNoImageReturn("\"%%%c\"",letter);
2571 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2572 image->alpha_trait);
2575 case 'C': /* Image compression method. */
2577 WarnNoImageReturn("\"%%%c\"",letter);
2578 string=CommandOptionToMnemonic(MagickCompressOptions,
2579 (ssize_t) image->compression);
2582 case 'D': /* Image dispose method. */
2584 WarnNoImageReturn("\"%%%c\"",letter);
2585 string=CommandOptionToMnemonic(MagickDisposeOptions,
2586 (ssize_t) image->dispose);
2589 case 'G': /* Image size as geometry = "%wx%h" */
2591 WarnNoImageReturn("\"%%%c\"",letter);
2592 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",
2593 (double)image->magick_columns,(double) image->magick_rows);
2596 case 'H': /* layer canvas height */
2598 WarnNoImageReturn("\"%%%c\"",letter);
2599 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2600 (double) image->page.height);
2603 case 'M': /* Magick filename - filename given incl. coder & read mods */
2605 WarnNoImageReturn("\"%%%c\"",letter);
2606 string=image->magick_filename;
2609 case 'O': /* layer canvas offset with sign = "+%X+%Y" */
2611 WarnNoImageReturn("\"%%%c\"",letter);
2612 (void) FormatLocaleString(value,MagickPathExtent,"%+ld%+ld",(long)
2613 image->page.x,(long) image->page.y);
2616 case 'P': /* layer canvas page size = "%Wx%H" */
2618 WarnNoImageReturn("\"%%%c\"",letter);
2619 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",
2620 (double) image->page.width,(double) image->page.height);
2623 case 'Q': /* image compression quality */
2625 WarnNoImageReturn("\"%%%c\"",letter);
2626 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2627 (image->quality == 0 ? 92 : image->quality));
2630 case 'S': /* Number of scenes in image list. */
2632 WarnNoImageInfoReturn("\"%%%c\"",letter);
2633 #if 0 /* What is this number? -- it makes no sense - simplifing */
2634 if (image_info->number_scenes == 0)
2635 string="2147483647";
2636 else if ( image != (Image *) NULL )
2637 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2638 image_info->scene+image_info->number_scenes);
2642 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2643 (image_info->number_scenes == 0 ? 2147483647 :
2644 image_info->number_scenes));
2648 case 'T': /* image time delay for animations */
2650 WarnNoImageReturn("\"%%%c\"",letter);
2651 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2655 case 'U': /* Image resolution units. */
2657 WarnNoImageReturn("\"%%%c\"",letter);
2658 string=CommandOptionToMnemonic(MagickResolutionOptions,
2659 (ssize_t) image->units);
2662 case 'W': /* layer canvas width */
2664 WarnNoImageReturn("\"%%%c\"",letter);
2665 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2669 case 'X': /* layer canvas X offset */
2671 WarnNoImageReturn("\"%%%c\"",letter);
2672 (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2676 case 'Y': /* layer canvas Y offset */
2678 WarnNoImageReturn("\"%%%c\"",letter);
2679 (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2683 case '%': /* percent escaped */
2688 case '@': /* Trim bounding box, without actually Trimming! */
2693 WarnNoImageReturn("\"%%%c\"",letter);
2694 page=GetImageBoundingBox(image,exception);
2695 (void) FormatLocaleString(value,MagickPathExtent,
2696 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double) page.height,
2697 (double) page.x,(double)page.y);
2705 WarnNoImageReturn("\"%%%c\"",letter);
2706 (void) SignatureImage(image,exception);
2707 string=GetImageProperty(image,"signature",exception);
2711 if (string != (char *) NULL)
2716 Create a cloned copy of result.
2718 if (image != (Image *) NULL)
2720 (void) SetImageArtifact(image,"get-property",value);
2721 return(GetImageArtifact(image,"get-property"));
2725 (void) SetImageOption(image_info,"get-property",value);
2726 return(GetImageOption(image_info,"get-property"));
2729 return((char *) NULL);
2732 MagickExport const char *GetMagickProperty(ImageInfo *image_info,
2733 Image *image,const char *property,ExceptionInfo *exception)
2736 value[MagickPathExtent];
2741 assert(property[0] != '\0');
2742 assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2744 if (property[1] == '\0') /* single letter property request */
2745 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2747 if (image != (Image *) NULL && image->debug != MagickFalse)
2748 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2749 else if( image_info != (ImageInfo *) NULL && image_info->debug != MagickFalse)
2750 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2752 *value='\0'; /* formated string */
2753 string=(char *) NULL; /* constant string reference */
2758 if (LocaleCompare("basename",property) == 0)
2760 WarnNoImageReturn("\"%%[%s]\"",property);
2761 GetPathComponent(image->magick_filename,BasePath,value);
2762 if (*value == '\0') string="";
2765 if (LocaleCompare("bit-depth",property) == 0)
2767 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2768 GetImageDepth(image, exception));
2775 if (LocaleCompare("channels",property) == 0)
2777 WarnNoImageReturn("\"%%[%s]\"",property);
2778 /* FUTURE: return actual image channels */
2779 (void) FormatLocaleString(value,MagickPathExtent,"%s",
2780 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2781 image->colorspace));
2783 if( image->alpha_trait != UndefinedPixelTrait )
2784 (void) ConcatenateMagickString(value,"a",MagickPathExtent);
2787 if (LocaleCompare("colorspace",property) == 0)
2789 WarnNoImageReturn("\"%%[%s]\"",property);
2790 /* FUTURE: return actual colorspace - no 'gray' stuff */
2791 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2795 if (LocaleCompare("copyright",property) == 0)
2797 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
2804 if (LocaleCompare("depth",property) == 0)
2806 WarnNoImageReturn("\"%%[%s]\"",property);
2807 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2811 if (LocaleCompare("directory",property) == 0)
2813 WarnNoImageReturn("\"%%[%s]\"",property);
2814 GetPathComponent(image->magick_filename,HeadPath,value);
2815 if (*value == '\0') string="";
2822 if (LocaleCompare("entropy",property) == 0)
2827 WarnNoImageReturn("\"%%[%s]\"",property);
2828 (void) GetImageEntropy(image,&entropy,exception);
2829 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2830 GetMagickPrecision(),entropy);
2833 if (LocaleCompare("extension",property) == 0)
2835 WarnNoImageReturn("\"%%[%s]\"",property);
2836 GetPathComponent(image->magick_filename,ExtensionPath,value);
2837 if (*value == '\0') string="";
2844 if (LocaleCompare("gamma",property) == 0)
2846 WarnNoImageReturn("\"%%[%s]\"",property);
2847 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2848 GetMagickPrecision(),image->gamma);
2855 if (LocaleCompare("height",property) == 0)
2857 WarnNoImageReturn("\"%%[%s]\"",property);
2858 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2859 image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2866 if (LocaleCompare("input",property) == 0)
2868 WarnNoImageReturn("\"%%[%s]\"",property);
2869 string=image->filename;
2876 if (LocaleCompare("kurtosis",property) == 0)
2882 WarnNoImageReturn("\"%%[%s]\"",property);
2883 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
2884 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2885 GetMagickPrecision(),kurtosis);
2892 if (LocaleCompare("magick",property) == 0)
2894 WarnNoImageReturn("\"%%[%s]\"",property);
2895 string=image->magick;
2898 if ((LocaleCompare("maxima",property) == 0) ||
2899 (LocaleCompare("max",property) == 0))
2905 WarnNoImageReturn("\"%%[%s]\"",property);
2906 (void) GetImageRange(image,&minimum,&maximum,exception);
2907 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2908 GetMagickPrecision(),maximum);
2911 if (LocaleCompare("mean",property) == 0)
2917 WarnNoImageReturn("\"%%[%s]\"",property);
2918 (void) GetImageMean(image,&mean,&standard_deviation,exception);
2919 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2920 GetMagickPrecision(),mean);
2923 if ((LocaleCompare("minima",property) == 0) ||
2924 (LocaleCompare("min",property) == 0))
2930 WarnNoImageReturn("\"%%[%s]\"",property);
2931 (void) GetImageRange(image,&minimum,&maximum,exception);
2932 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2933 GetMagickPrecision(),minimum);
2940 if (LocaleCompare("opaque",property) == 0)
2942 WarnNoImageReturn("\"%%[%s]\"",property);
2943 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
2944 IsImageOpaque(image,exception));
2947 if (LocaleCompare("orientation",property) == 0)
2949 WarnNoImageReturn("\"%%[%s]\"",property);
2950 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
2951 image->orientation);
2954 if (LocaleCompare("output",property) == 0)
2956 WarnNoImageInfoReturn("\"%%[%s]\"",property);
2957 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
2964 #if defined(MAGICKCORE_LCMS_DELEGATE)
2965 if (LocaleCompare("profile:icc",property) == 0 ||
2966 LocaleCompare("profile:icm",property) == 0)
2968 #if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
2969 #define cmsUInt32Number DWORD
2978 profile=GetImageProfile(image,property+8);
2979 if (profile == (StringInfo *) NULL)
2981 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
2982 (cmsUInt32Number) GetStringInfoLength(profile));
2983 if (icc_profile != (cmsHPROFILE *) NULL)
2985 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
2986 string=cmsTakeProductName(icc_profile);
2988 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
2989 "en","US",value,MagickPathExtent);
2991 (void) cmsCloseProfile(icc_profile);
2995 if (LocaleCompare("profiles",property) == 0)
3000 ResetImageProfileIterator(image);
3001 name=GetNextImageProfile(image);
3002 if (name != (char *) NULL)
3004 (void) CopyMagickString(value,name,MagickPathExtent);
3005 name=GetNextImageProfile(image);
3006 while (name != (char *) NULL)
3008 ConcatenateMagickString(value,",",MagickPathExtent);
3009 ConcatenateMagickString(value,name,MagickPathExtent);
3010 name=GetNextImageProfile(image);
3019 if (LocaleCompare("resolution.x",property) == 0)
3021 WarnNoImageReturn("\"%%[%s]\"",property);
3022 (void) FormatLocaleString(value,MagickPathExtent,"%g",
3023 image->resolution.x);
3026 if (LocaleCompare("resolution.y",property) == 0)
3028 WarnNoImageReturn("\"%%[%s]\"",property);
3029 (void) FormatLocaleString(value,MagickPathExtent,"%g",
3030 image->resolution.y);
3037 if (LocaleCompare("scene",property) == 0)
3039 WarnNoImageInfoReturn("\"%%[%s]\"",property);
3040 if (image_info->number_scenes != 0)
3041 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3044 WarnNoImageReturn("\"%%[%s]\"",property);
3045 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3050 if (LocaleCompare("scenes",property) == 0)
3052 /* FUTURE: equivelent to %n? */
3053 WarnNoImageReturn("\"%%[%s]\"",property);
3054 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3055 GetImageListLength(image));
3058 if (LocaleCompare("size",property) == 0)
3060 WarnNoImageReturn("\"%%[%s]\"",property);
3061 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
3062 MagickPathExtent,value);
3065 if (LocaleCompare("skewness",property) == 0)
3071 WarnNoImageReturn("\"%%[%s]\"",property);
3072 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3073 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
3074 GetMagickPrecision(),skewness);
3077 if (LocaleCompare("standard-deviation",property) == 0)
3083 WarnNoImageReturn("\"%%[%s]\"",property);
3084 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3085 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
3086 GetMagickPrecision(),standard_deviation);
3093 if (LocaleCompare("type",property) == 0)
3095 WarnNoImageReturn("\"%%[%s]\"",property);
3096 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3097 IdentifyImageType(image,exception));
3104 if (LocaleCompare("unique",property) == 0)
3106 WarnNoImageInfoReturn("\"%%[%s]\"",property);
3107 string=image_info->unique;
3110 if (LocaleCompare("units",property) == 0)
3112 WarnNoImageReturn("\"%%[%s]\"",property);
3113 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3117 if (LocaleCompare("copyright",property) == 0)
3122 if (LocaleCompare("version",property) == 0)
3124 string=GetMagickVersion((size_t *) NULL);
3131 if (LocaleCompare("width",property) == 0)
3133 WarnNoImageReturn("\"%%[%s]\"",property);
3134 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3135 (image->magick_columns != 0 ? image->magick_columns : 256));
3141 if (string != (char *) NULL)
3145 /* create a cloned copy of result, that will get cleaned up, eventually */
3146 if (image != (Image *) NULL)
3148 (void) SetImageArtifact(image,"get-property",value);
3149 return(GetImageArtifact(image,"get-property"));
3153 (void) SetImageOption(image_info,"get-property",value);
3154 return(GetImageOption(image_info,"get-property"));
3157 return((char *) NULL);
3159 #undef WarnNoImageReturn
3162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3166 % G e t N e x t I m a g e P r o p e r t y %
3170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3172 % GetNextImageProperty() gets the next free-form string property name.
3174 % The format of the GetNextImageProperty method is:
3176 % char *GetNextImageProperty(const Image *image)
3178 % A description of each parameter follows:
3180 % o image: the image.
3183 MagickExport const char *GetNextImageProperty(const Image *image)
3185 assert(image != (Image *) NULL);
3186 assert(image->signature == MagickCoreSignature);
3187 if (image->debug != MagickFalse)
3188 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3190 if (image->properties == (void *) NULL)
3191 return((const char *) NULL);
3192 return((const char *) GetNextKeyInSplayTree(
3193 (SplayTreeInfo *) image->properties));
3197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3201 % I n t e r p r e t I m a g e P r o p e r t i e s %
3205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3207 % InterpretImageProperties() replaces any embedded formatting characters with
3208 % the appropriate image property and returns the interpreted text.
3210 % This searches for and replaces
3211 % \n \r \% replaced by newline, return, and percent resp.
3212 % < > & replaced by '<', '>', '&' resp.
3213 % %% replaced by percent
3215 % %x %[x] where 'x' is a single letter properity, case sensitive).
3216 % %[type:name] where 'type' a is special and known prefix.
3217 % %[name] where 'name' is a specifically known attribute, calculated
3218 % value, or a per-image property string name, or a per-image
3219 % 'artifact' (as generated from a global option).
3220 % It may contain ':' as long as the prefix is not special.
3222 % Single letter % substitutions will only happen if the character before the
3223 % percent is NOT a number. But braced substitutions will always be performed.
3224 % This prevents the typical usage of percent in a interpreted geometry
3225 % argument from being substituted when the percent is a geometry flag.
3227 % If 'glob-expresions' ('*' or '?' characters) is used for 'name' it may be
3228 % used as a search pattern to print multiple lines of "name=value\n" pairs of
3229 % the associacted set of properties.
3231 % The returned string must be freed using DestoryString() by the caller.
3233 % The format of the InterpretImageProperties method is:
3235 % char *InterpretImageProperties(ImageInfo *image_info,
3236 % Image *image,const char *embed_text,ExceptionInfo *exception)
3238 % A description of each parameter follows:
3240 % o image_info: the image info. (required)
3242 % o image: the image. (optional)
3244 % o embed_text: the address of a character string containing the embedded
3245 % formatting characters.
3247 % o exception: return any errors or warnings in this structure.
3250 MagickExport char *InterpretImageProperties(ImageInfo *image_info,
3251 Image *image,const char *embed_text,ExceptionInfo *exception)
3253 #define ExtendInterpretText(string_length) \
3254 DisableMSCWarning(4127) \
3256 size_t length=(string_length); \
3257 if ((size_t) (q-interpret_text+length+1) >= extent) \
3260 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3261 MaxTextExtent,sizeof(*interpret_text)); \
3262 if (interpret_text == (char *) NULL) \
3263 return((char *) NULL); \
3264 q=interpret_text+strlen(interpret_text); \
3269 #define AppendKeyValue2Text(key,value)\
3270 DisableMSCWarning(4127) \
3272 size_t length=strlen(key)+strlen(value)+2; \
3273 if ((size_t) (q-interpret_text+length+1) >= extent) \
3276 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3277 MaxTextExtent,sizeof(*interpret_text)); \
3278 if (interpret_text == (char *) NULL) \
3279 return((char *) NULL); \
3280 q=interpret_text+strlen(interpret_text); \
3282 q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3286 #define AppendString2Text(string) \
3287 DisableMSCWarning(4127) \
3289 size_t length=strlen((string)); \
3290 if ((size_t) (q-interpret_text+length+1) >= extent) \
3293 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3294 MaxTextExtent,sizeof(*interpret_text)); \
3295 if (interpret_text == (char *) NULL) \
3296 return((char *) NULL); \
3297 q=interpret_text+strlen(interpret_text); \
3299 (void) CopyMagickString(q,(string),extent); \
3308 *q; /* current position in interpret_text */
3311 *p; /* position in embed_text string being expanded */
3314 extent; /* allocated length of interpret_text */
3319 assert(image == NULL || image->signature == MagickCoreSignature);
3320 assert(image_info == NULL || image_info->signature == MagickCoreSignature);
3321 if ((image != (Image *) NULL) && (image->debug != MagickFalse))
3322 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3324 if ((image_info != (ImageInfo *) NULL) && (image_info->debug != MagickFalse))
3325 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-image");
3326 if (embed_text == (const char *) NULL)
3327 return(ConstantString(""));
3329 while ((isspace((int) ((unsigned char) *p)) != 0) && (*p != '\0'))
3332 return(ConstantString(""));
3333 if ((*p == '@') && (IsPathAccessible(p+1) != MagickFalse))
3336 Handle a '@' replace string from file.
3338 if (IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,p) == MagickFalse)
3341 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
3342 "NotAuthorized","`%s'",p);
3343 return(ConstantString(""));
3345 interpret_text=FileToString(p+1,~0UL,exception);
3346 if (interpret_text != (char *) NULL)
3347 return(interpret_text);
3350 Translate any embedded format characters.
3352 interpret_text=AcquireString(embed_text); /* new string with extra space */
3353 extent=MagickPathExtent; /* allocated space in string */
3354 number=MagickFalse; /* is last char a number? */
3355 for (q=interpret_text; *p!='\0';
3356 number=isdigit(*p) ? MagickTrue : MagickFalse,p++)
3359 Look for the various escapes, (and handle other specials)
3362 ExtendInterpretText(MagickPathExtent);
3371 case 'r': /* convert to RETURN */
3377 case 'n': /* convert to NEWLINE */
3383 case '\n': /* EOL removal UNIX,MacOSX */
3388 case '\r': /* EOL removal DOS,Windows */
3391 if (*p == '\n') /* return-newline EOL */
3405 if (LocaleNCompare("<",p,4) == 0)
3411 if (LocaleNCompare(">",p,4) == 0)
3417 if (LocaleNCompare("&",p,5) == 0)
3427 break; /* continue to next set of handlers */
3430 *q++=(*p); /* any thing else is 'as normal' */
3434 p++; /* advance beyond the percent */
3436 Doubled Percent - or percent at end of string.
3438 if ((*p == '\0') || (*p == '\'') || (*p == '"'))
3446 Single letter escapes %c.
3453 if (number != MagickFalse)
3456 But only if not preceeded by a number!
3458 *q++='%'; /* do NOT substitute the percent */
3459 p--; /* back up one */
3462 string=GetMagickPropertyLetter(image_info,image,*p, exception);
3463 if (string != (char *) NULL)
3465 AppendString2Text(string);
3466 if (image != (Image *) NULL)
3467 (void) DeleteImageArtifact(image,"get-property");
3468 if (image_info != (ImageInfo *) NULL)
3469 (void) DeleteImageOption(image_info,"get-property");
3472 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3473 "UnknownImageProperty","\"%%%c\"",*p);
3478 pattern[2*MagickPathExtent];
3491 Braced Percent Escape %[...].
3493 p++; /* advance p to just inside the opening brace */
3497 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3498 "UnknownImageProperty","\"%%[]\"");
3501 for (len=0; len<(MagickPathExtent-1L) && (*p != '\0');)
3503 if ((*p == '\\') && (*(p+1) != '\0'))
3506 Skip escaped braces within braced pattern.
3508 pattern[len++]=(*p++);
3509 pattern[len++]=(*p++);
3518 pattern[len++]=(*p++);
3524 Check for unmatched final ']' for "%[...]".
3528 pattern[61] = '.'; /* truncate string for error message */
3533 (void) ThrowMagickException(exception,GetMagickModule(),
3534 OptionError,"UnbalancedBraces","\"%%[%s\"",pattern);
3535 interpret_text=DestroyString(interpret_text);
3536 return((char *) NULL);
3539 Special Lookup Prefixes %[prefix:...].
3541 if (LocaleNCompare("fx:",pattern,3) == 0)
3553 FX - value calculator.
3555 if (image == (Image *) NULL )
3557 (void) ThrowMagickException(exception,GetMagickModule(),
3558 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3559 continue; /* else no image to retrieve artifact */
3561 fx_info=AcquireFxInfo(image,pattern+3,exception);
3562 status=FxEvaluateChannelExpression(fx_info,IntensityPixelChannel,0,0,
3564 fx_info=DestroyFxInfo(fx_info);
3565 if (status != MagickFalse)
3568 result[MagickPathExtent];
3570 (void) FormatLocaleString(result,MagickPathExtent,"%.*g",
3571 GetMagickPrecision(),(double) value);
3572 AppendString2Text(result);
3576 if (LocaleNCompare("pixel:",pattern,6) == 0)
3591 Pixel - color value calculator.
3593 if (image == (Image *) NULL)
3595 (void) ThrowMagickException(exception,GetMagickModule(),
3596 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3597 continue; /* else no image to retrieve artifact */
3599 GetPixelInfo(image,&pixel);
3600 fx_info=AcquireFxInfo(image,pattern+6,exception);
3601 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
3603 pixel.red=(double) QuantumRange*value;
3604 status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
3606 pixel.green=(double) QuantumRange*value;
3607 status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
3609 pixel.blue=(double) QuantumRange*value;
3610 if (image->colorspace == CMYKColorspace)
3612 status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
3614 pixel.black=(double) QuantumRange*value;
3616 status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
3618 pixel.alpha=(double) QuantumRange*value;
3619 fx_info=DestroyFxInfo(fx_info);
3620 if (status != MagickFalse)
3623 name[MagickPathExtent];
3625 (void) QueryColorname(image,&pixel,SVGCompliance,name,
3627 AppendString2Text(name);
3631 if (LocaleNCompare("option:",pattern,7) == 0)
3634 Option - direct global option lookup (with globbing).
3636 if (image_info == (ImageInfo *) NULL )
3638 (void) ThrowMagickException(exception,GetMagickModule(),
3639 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3640 continue; /* else no image to retrieve artifact */
3642 if (IsGlob(pattern+7) != MagickFalse)
3644 ResetImageOptionIterator(image_info);
3645 while ((key=GetNextImageOption(image_info)) != (const char *) NULL)
3646 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
3648 string=GetImageOption(image_info,key);
3649 if (string != (const char *) NULL)
3650 AppendKeyValue2Text(key,string);
3651 /* else - assertion failure? key found but no string value! */
3655 string=GetImageOption(image_info,pattern+7);
3656 if (string == (char *) NULL)
3657 goto PropertyLookupFailure; /* no artifact of this specifc name */
3658 AppendString2Text(string);
3661 if (LocaleNCompare("artifact:",pattern,9) == 0)
3664 Artifact - direct image artifact lookup (with glob).
3666 if (image == (Image *) NULL)
3668 (void) ThrowMagickException(exception,GetMagickModule(),
3669 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3670 continue; /* else no image to retrieve artifact */
3672 if (IsGlob(pattern+9) != MagickFalse)
3674 ResetImageArtifactIterator(image);
3675 while ((key=GetNextImageArtifact(image)) != (const char *) NULL)
3676 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
3678 string=GetImageArtifact(image,key);
3679 if (string != (const char *) NULL)
3680 AppendKeyValue2Text(key,string);
3681 /* else - assertion failure? key found but no string value! */
3685 string=GetImageArtifact(image,pattern+9);
3686 if (string == (char *) NULL)
3687 goto PropertyLookupFailure; /* no artifact of this specifc name */
3688 AppendString2Text(string);
3691 if (LocaleNCompare("property:",pattern,9) == 0)
3694 Property - direct image property lookup (with glob).
3696 if (image == (Image *) NULL)
3698 (void) ThrowMagickException(exception,GetMagickModule(),
3699 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3700 continue; /* else no image to retrieve artifact */
3702 if (IsGlob(pattern+9) != MagickFalse)
3704 ResetImagePropertyIterator(image);
3705 while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3706 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3708 string=GetImageProperty(image,key,exception);
3709 if (string != (const char *) NULL)
3710 AppendKeyValue2Text(key,string);
3711 /* else - assertion failure? */
3715 string=GetImageProperty(image,pattern+9,exception);
3716 if (string == (char *) NULL)
3717 goto PropertyLookupFailure; /* no artifact of this specifc name */
3718 AppendString2Text(string);
3721 if (image != (Image *) NULL)
3724 Properties without special prefix. This handles attributes,
3725 properties, and profiles such as %[exif:...]. Note the profile
3726 properties may also include a glob expansion pattern.
3728 string=GetImageProperty(image,pattern,exception);
3729 if (string != (const char *) NULL)
3731 AppendString2Text(string);
3732 if (image != (Image *) NULL)
3733 (void)DeleteImageArtifact(image,"get-property");
3734 if (image_info != (ImageInfo *) NULL)
3735 (void)DeleteImageOption(image_info,"get-property");
3739 if (IsGlob(pattern) != MagickFalse)
3742 Handle property 'glob' patterns such as:
3743 %[*] %[user:array_??] %[filename:e*]>
3745 if (image == (Image *) NULL)
3746 continue; /* else no image to retrieve proprty - no list */
3747 ResetImagePropertyIterator(image);
3748 while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3749 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3751 string=GetImageProperty(image,key,exception);
3752 if (string != (const char *) NULL)
3753 AppendKeyValue2Text(key,string);
3754 /* else - assertion failure? */
3759 Look for a known property or image attribute such as
3760 %[basename] %[denisty] %[delay]. Also handles a braced single
3761 letter: %[b] %[G] %[g].
3763 string=GetMagickProperty(image_info,image,pattern,exception);
3764 if (string != (const char *) NULL)
3766 AppendString2Text(string);
3770 Look for a per-image artifact. This includes option lookup
3771 (FUTURE: interpreted according to image).
3773 if (image != (Image *) NULL)
3775 string=GetImageArtifact(image,pattern);
3776 if (string != (char *) NULL)
3778 AppendString2Text(string);
3783 if (image_info != (ImageInfo *) NULL)
3786 No image, so direct 'option' lookup (no delayed percent escapes).
3788 string=GetImageOption(image_info,pattern);
3789 if (string != (char *) NULL)
3791 AppendString2Text(string);
3795 PropertyLookupFailure:
3797 Failed to find any match anywhere!
3801 pattern[61] = '.'; /* truncate string for error message */
3806 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3807 "UnknownImageProperty","\"%%[%s]\"",pattern);
3811 return(interpret_text);
3815 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3819 % R e m o v e I m a g e P r o p e r t y %
3823 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3825 % RemoveImageProperty() removes a property from the image and returns its
3828 % In this case the ConstantString() value returned should be freed by the
3829 % caller when finished.
3831 % The format of the RemoveImageProperty method is:
3833 % char *RemoveImageProperty(Image *image,const char *property)
3835 % A description of each parameter follows:
3837 % o image: the image.
3839 % o property: the image property.
3842 MagickExport char *RemoveImageProperty(Image *image,
3843 const char *property)
3848 assert(image != (Image *) NULL);
3849 assert(image->signature == MagickCoreSignature);
3850 if (image->debug != MagickFalse)
3851 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3853 if (image->properties == (void *) NULL)
3854 return((char *) NULL);
3855 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3865 % 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 %
3869 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3871 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3872 % in conjunction with GetNextImageProperty() to iterate over all the values
3873 % associated with an image property.
3875 % The format of the ResetImagePropertyIterator method is:
3877 % ResetImagePropertyIterator(Image *image)
3879 % A description of each parameter follows:
3881 % o image: the image.
3884 MagickExport void ResetImagePropertyIterator(const Image *image)
3886 assert(image != (Image *) NULL);
3887 assert(image->signature == MagickCoreSignature);
3888 if (image->debug != MagickFalse)
3889 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3891 if (image->properties == (void *) NULL)
3893 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3897 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3901 % S e t I m a g e P r o p e r t y %
3905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3907 % SetImageProperty() saves the given string value either to specific known
3908 % attribute or to a freeform property string.
3910 % Attempting to set a property that is normally calculated will produce
3913 % The format of the SetImageProperty method is:
3915 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3916 % const char *value,ExceptionInfo *exception)
3918 % A description of each parameter follows:
3920 % o image: the image.
3922 % o property: the image property.
3924 % o values: the image property values.
3926 % o exception: return any errors or warnings in this structure.
3929 MagickExport MagickBooleanType SetImageProperty(Image *image,
3930 const char *property,const char *value,ExceptionInfo *exception)
3938 assert(image != (Image *) NULL);
3939 assert(image->signature == MagickCoreSignature);
3940 if (image->debug != MagickFalse)
3941 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3942 if (image->properties == (void *) NULL)
3943 image->properties=NewSplayTree(CompareSplayTreeString,
3944 RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */
3945 if (value == (const char *) NULL)
3946 return(DeleteImageProperty(image,property)); /* delete if NULL */
3948 if (strlen(property) <= 1)
3951 Do not 'set' single letter properties - read only shorthand.
3953 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3954 "SetReadOnlyProperty","`%s'",property);
3955 return(MagickFalse);
3958 /* FUTURE: binary chars or quotes in key should produce a error */
3959 /* Set attributes with known names or special prefixes
3960 return result is found, or break to set a free form properity
3964 #if 0 /* Percent escape's sets values with this prefix: for later use
3965 Throwing an exception causes this setting to fail */
3968 if (LocaleNCompare("8bim:",property,5) == 0)
3970 (void) ThrowMagickException(exception,GetMagickModule(),
3971 OptionError,"SetReadOnlyProperty","`%s'",property);
3972 return(MagickFalse);
3980 if (LocaleCompare("background",property) == 0)
3982 (void) QueryColorCompliance(value,AllCompliance,
3983 &image->background_color,exception);
3984 /* check for FUTURE: value exception?? */
3985 /* also add user input to splay tree */
3987 break; /* not an attribute, add as a property */
3992 if (LocaleCompare("channels",property) == 0)
3994 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3995 "SetReadOnlyProperty","`%s'",property);
3996 return(MagickFalse);
3998 if (LocaleCompare("colorspace",property) == 0)
4003 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4006 return(MagickFalse); /* FUTURE: value exception?? */
4007 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4009 if (LocaleCompare("compose",property) == 0)
4014 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4016 return(MagickFalse); /* FUTURE: value exception?? */
4017 image->compose=(CompositeOperator) compose;
4020 if (LocaleCompare("compress",property) == 0)
4025 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4027 if (compression < 0)
4028 return(MagickFalse); /* FUTURE: value exception?? */
4029 image->compression=(CompressionType) compression;
4032 break; /* not an attribute, add as a property */
4037 if (LocaleCompare("delay",property) == 0)
4042 flags=ParseGeometry(value,&geometry_info);
4043 if ((flags & GreaterValue) != 0)
4045 if (image->delay > (size_t) floor(geometry_info.rho+0.5))
4046 image->delay=(size_t) floor(geometry_info.rho+0.5);
4049 if ((flags & LessValue) != 0)
4051 if (image->delay < (size_t) floor(geometry_info.rho+0.5))
4052 image->delay=(ssize_t)
4053 floor(geometry_info.sigma+0.5);
4056 image->delay=(size_t) floor(geometry_info.rho+0.5);
4057 if ((flags & SigmaValue) != 0)
4058 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
4061 if (LocaleCompare("delay_units",property) == 0)
4063 (void) ThrowMagickException(exception,GetMagickModule(),
4064 OptionError,"SetReadOnlyProperty","`%s'",property);
4065 return(MagickFalse);
4067 if (LocaleCompare("density",property) == 0)
4072 flags=ParseGeometry(value,&geometry_info);
4073 image->resolution.x=geometry_info.rho;
4074 image->resolution.y=geometry_info.sigma;
4075 if ((flags & SigmaValue) == 0)
4076 image->resolution.y=image->resolution.x;
4079 if (LocaleCompare("depth",property) == 0)
4081 image->depth=StringToUnsignedLong(value);
4084 if (LocaleCompare("dispose",property) == 0)
4089 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4091 return(MagickFalse); /* FUTURE: value exception?? */
4092 image->dispose=(DisposeType) dispose;
4095 break; /* not an attribute, add as a property */
4097 #if 0 /* Percent escape's sets values with this prefix: for later use
4098 Throwing an exception causes this setting to fail */
4102 if (LocaleNCompare("exif:",property,5) == 0)
4104 (void) ThrowMagickException(exception,GetMagickModule(),
4105 OptionError,"SetReadOnlyProperty","`%s'",property);
4106 return(MagickFalse);
4108 break; /* not an attribute, add as a property */
4113 if (LocaleNCompare("fx:",property,3) == 0)
4115 (void) ThrowMagickException(exception,GetMagickModule(),
4116 OptionError,"SetReadOnlyProperty","`%s'",property);
4117 return(MagickFalse);
4119 break; /* not an attribute, add as a property */
4125 if (LocaleCompare("gamma",property) == 0)
4127 image->gamma=StringToDouble(value,(char **) NULL);
4130 if (LocaleCompare("gravity",property) == 0)
4135 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4137 return(MagickFalse); /* FUTURE: value exception?? */
4138 image->gravity=(GravityType) gravity;
4141 break; /* not an attribute, add as a property */
4146 if (LocaleCompare("height",property) == 0)
4148 (void) ThrowMagickException(exception,GetMagickModule(),
4149 OptionError,"SetReadOnlyProperty","`%s'",property);
4150 return(MagickFalse);
4152 break; /* not an attribute, add as a property */
4157 if (LocaleCompare("intensity",property) == 0)
4162 intensity=ParseCommandOption(MagickIntentOptions,MagickFalse,
4165 return(MagickFalse);
4166 image->intensity=(PixelIntensityMethod) intensity;
4169 if (LocaleCompare("intent",property) == 0)
4174 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4176 if (rendering_intent < 0)
4177 return(MagickFalse); /* FUTURE: value exception?? */
4178 image->rendering_intent=(RenderingIntent) rendering_intent;
4181 if (LocaleCompare("interpolate",property) == 0)
4186 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4188 if (interpolate < 0)
4189 return(MagickFalse); /* FUTURE: value exception?? */
4190 image->interpolate=(PixelInterpolateMethod) interpolate;
4193 #if 0 /* Percent escape's sets values with this prefix: for later use
4194 Throwing an exception causes this setting to fail */
4195 if (LocaleNCompare("iptc:",property,5) == 0)
4197 (void) ThrowMagickException(exception,GetMagickModule(),
4198 OptionError,"SetReadOnlyProperty","`%s'",property);
4199 return(MagickFalse);
4202 break; /* not an attribute, add as a property */
4206 if (LocaleCompare("kurtosis",property) == 0)
4208 (void) ThrowMagickException(exception,GetMagickModule(),
4209 OptionError,"SetReadOnlyProperty","`%s'",property);
4210 return(MagickFalse);
4212 break; /* not an attribute, add as a property */
4216 if (LocaleCompare("loop",property) == 0)
4218 image->iterations=StringToUnsignedLong(value);
4221 break; /* not an attribute, add as a property */
4225 if ( (LocaleCompare("magick",property) == 0) ||
4226 (LocaleCompare("max",property) == 0) ||
4227 (LocaleCompare("mean",property) == 0) ||
4228 (LocaleCompare("min",property) == 0) ||
4229 (LocaleCompare("min",property) == 0) )
4231 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4232 "SetReadOnlyProperty","`%s'",property);
4233 return(MagickFalse);
4235 break; /* not an attribute, add as a property */
4238 if (LocaleCompare("opaque",property) == 0)
4240 (void) ThrowMagickException(exception,GetMagickModule(),
4241 OptionError,"SetReadOnlyProperty","`%s'",property);
4242 return(MagickFalse);
4244 break; /* not an attribute, add as a property */
4248 if (LocaleCompare("page",property) == 0)
4253 geometry=GetPageGeometry(value);
4254 flags=ParseAbsoluteGeometry(geometry,&image->page);
4255 geometry=DestroyString(geometry);
4258 #if 0 /* Percent escape's sets values with this prefix: for later use
4259 Throwing an exception causes this setting to fail */
4260 if (LocaleNCompare("pixel:",property,6) == 0)
4262 (void) ThrowMagickException(exception,GetMagickModule(),
4263 OptionError,"SetReadOnlyProperty","`%s'",property);
4264 return(MagickFalse);
4267 if (LocaleCompare("profile",property) == 0)
4275 image_info=AcquireImageInfo();
4276 (void) CopyMagickString(image_info->filename,value,MagickPathExtent);
4277 (void) SetImageInfo(image_info,1,exception);
4278 profile=FileToStringInfo(image_info->filename,~0UL,exception);
4279 if (profile != (StringInfo *) NULL)
4280 status=SetImageProfile(image,image_info->magick,profile,exception);
4281 image_info=DestroyImageInfo(image_info);
4284 break; /* not an attribute, add as a property */
4289 if (LocaleCompare("rendering-intent",property) == 0)
4294 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4296 if (rendering_intent < 0)
4297 return(MagickFalse); /* FUTURE: value exception?? */
4298 image->rendering_intent=(RenderingIntent) rendering_intent;
4301 break; /* not an attribute, add as a property */
4305 if ( (LocaleCompare("size",property) == 0) ||
4306 (LocaleCompare("skewness",property) == 0) ||
4307 (LocaleCompare("scenes",property) == 0) ||
4308 (LocaleCompare("standard-deviation",property) == 0) )
4310 (void) ThrowMagickException(exception,GetMagickModule(),
4311 OptionError,"SetReadOnlyProperty","`%s'",property);
4312 return(MagickFalse);
4314 break; /* not an attribute, add as a property */
4318 if (LocaleCompare("tile-offset",property) == 0)
4323 geometry=GetPageGeometry(value);
4324 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4325 geometry=DestroyString(geometry);
4328 break; /* not an attribute, add as a property */
4333 if (LocaleCompare("units",property) == 0)
4338 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4340 return(MagickFalse); /* FUTURE: value exception?? */
4341 image->units=(ResolutionType) units;
4344 break; /* not an attribute, add as a property */
4349 if (LocaleCompare("version",property) == 0)
4351 (void) ThrowMagickException(exception,GetMagickModule(),
4352 OptionError,"SetReadOnlyProperty","`%s'",property);
4353 return(MagickFalse);
4355 break; /* not an attribute, add as a property */
4360 if (LocaleCompare("width",property) == 0)
4362 (void) ThrowMagickException(exception,GetMagickModule(),
4363 OptionError,"SetReadOnlyProperty","`%s'",property);
4364 return(MagickFalse);
4366 break; /* not an attribute, add as a property */
4368 #if 0 /* Percent escape's sets values with this prefix: for later use
4369 Throwing an exception causes this setting to fail */
4373 if (LocaleNCompare("xmp:",property,4) == 0)
4375 (void) ThrowMagickException(exception,GetMagickModule(),
4376 OptionError,"SetReadOnlyProperty","`%s'",property);
4377 return(MagickFalse);
4379 break; /* not an attribute, add as a property */
4383 /* Default: not an attribute, add as a property */
4384 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4385 ConstantString(property),ConstantString(value));
4386 /* FUTURE: error if status is bad? */