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-2017 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 % https://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,
148 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
150 image->compression=clone_image->compression;
151 image->quality=clone_image->quality;
152 image->depth=clone_image->depth;
153 image->matte_color=clone_image->matte_color;
154 image->background_color=clone_image->background_color;
155 image->border_color=clone_image->border_color;
156 image->transparent_color=clone_image->transparent_color;
157 image->gamma=clone_image->gamma;
158 image->chromaticity=clone_image->chromaticity;
159 image->rendering_intent=clone_image->rendering_intent;
160 image->black_point_compensation=clone_image->black_point_compensation;
161 image->units=clone_image->units;
162 image->montage=(char *) NULL;
163 image->directory=(char *) NULL;
164 (void) CloneString(&image->geometry,clone_image->geometry);
165 image->offset=clone_image->offset;
166 image->resolution.x=clone_image->resolution.x;
167 image->resolution.y=clone_image->resolution.y;
168 image->page=clone_image->page;
169 image->tile_offset=clone_image->tile_offset;
170 image->extract_info=clone_image->extract_info;
171 image->filter=clone_image->filter;
172 image->fuzz=clone_image->fuzz;
173 image->intensity=clone_image->intensity;
174 image->interlace=clone_image->interlace;
175 image->interpolate=clone_image->interpolate;
176 image->endian=clone_image->endian;
177 image->gravity=clone_image->gravity;
178 image->compose=clone_image->compose;
179 image->orientation=clone_image->orientation;
180 image->scene=clone_image->scene;
181 image->dispose=clone_image->dispose;
182 image->delay=clone_image->delay;
183 image->ticks_per_second=clone_image->ticks_per_second;
184 image->iterations=clone_image->iterations;
185 image->total_colors=clone_image->total_colors;
186 image->taint=clone_image->taint;
187 image->progress_monitor=clone_image->progress_monitor;
188 image->client_data=clone_image->client_data;
189 image->start_loop=clone_image->start_loop;
190 image->error=clone_image->error;
191 image->signature=clone_image->signature;
192 if (clone_image->properties != (void *) NULL)
194 if (image->properties != (void *) NULL)
195 DestroyImageProperties(image);
196 image->properties=CloneSplayTree((SplayTreeInfo *)
197 clone_image->properties,(void *(*)(void *)) ConstantString,
198 (void *(*)(void *)) ConstantString);
204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
208 % D e f i n e I m a g e P r o p e r t y %
212 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
214 % DefineImageProperty() associates an assignment string of the form
215 % "key=value" with an artifact or options. It is equivelent to
216 % SetImageProperty().
218 % The format of the DefineImageProperty method is:
220 % MagickBooleanType DefineImageProperty(Image *image,const char *property,
221 % ExceptionInfo *exception)
223 % A description of each parameter follows:
225 % o image: the image.
227 % o property: the image property.
229 % o exception: return any errors or warnings in this structure.
232 MagickExport MagickBooleanType DefineImageProperty(Image *image,
233 const char *property,ExceptionInfo *exception)
236 key[MagickPathExtent],
237 value[MagickPathExtent];
242 assert(image != (Image *) NULL);
243 assert(property != (const char *) NULL);
244 (void) CopyMagickString(key,property,MagickPathExtent-1);
245 for (p=key; *p != '\0'; p++)
250 (void) CopyMagickString(value,p+1,MagickPathExtent);
252 return(SetImageProperty(image,key,value,exception));
256 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
260 % D e l e t e I m a g e P r o p e r t y %
264 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
266 % DeleteImageProperty() deletes an image property.
268 % The format of the DeleteImageProperty method is:
270 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
272 % A description of each parameter follows:
274 % o image: the image.
276 % o property: the image property.
279 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
280 const char *property)
282 assert(image != (Image *) NULL);
283 assert(image->signature == MagickCoreSignature);
284 if (image->debug != MagickFalse)
285 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
286 if (image->properties == (void *) NULL)
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",image->filename);
320 if (image->properties != (void *) NULL)
321 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
326 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
330 % F o r m a t I m a g e P r o p e r t y %
334 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
336 % FormatImageProperty() permits formatted property/value pairs to be saved as
339 % The format of the FormatImageProperty method is:
341 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
342 % const char *format,...)
344 % A description of each parameter follows.
346 % o image: The image.
348 % o property: The attribute property.
350 % o format: A string describing the format to use to write the remaining
354 MagickExport MagickBooleanType FormatImageProperty(Image *image,
355 const char *property,const char *format,...)
358 value[MagickPathExtent];
372 va_start(operands,format);
373 n=FormatLocaleStringList(value,MagickPathExtent,format,operands);
376 exception=AcquireExceptionInfo();
377 status=SetImageProperty(image,property,value,exception);
378 exception=DestroyExceptionInfo(exception);
383 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
387 % G e t I m a g e P r o p e r t y %
391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
393 % GetImageProperty() gets a value associated with an image property.
395 % This includes, profile prefixes, such as "exif:", "iptc:" and "8bim:"
396 % It does not handle non-prifile prefixes, such as "fx:", "option:", or
399 % The returned string is stored as a properity of the same name for faster
400 % lookup later. It should NOT be freed by the caller.
402 % The format of the GetImageProperty method is:
404 % const char *GetImageProperty(const Image *image,const char *key,
405 % ExceptionInfo *exception)
407 % A description of each parameter follows:
409 % o image: the image.
413 % o exception: return any errors or warnings in this structure.
418 *TracePSClippath(const unsigned char *,size_t),
419 *TraceSVGClippath(const unsigned char *,size_t,const size_t,
422 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key,
423 ExceptionInfo *exception)
443 profile=GetImageProfile(image,"iptc");
444 if (profile == (StringInfo *) NULL)
445 profile=GetImageProfile(image,"8bim");
446 if (profile == (StringInfo *) NULL)
448 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
451 attribute=(char *) NULL;
452 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
455 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
457 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
458 length|=GetStringInfoDatum(profile)[i+4];
459 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
460 ((long) GetStringInfoDatum(profile)[i+2] == record))
462 message=(char *) NULL;
464 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
465 if (message != (char *) NULL)
467 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
468 profile)+i+5,length+1);
469 (void) ConcatenateString(&attribute,message);
470 (void) ConcatenateString(&attribute,";");
471 message=DestroyString(message);
476 if ((attribute == (char *) NULL) || (*attribute == ';'))
478 if (attribute != (char *) NULL)
479 attribute=DestroyString(attribute);
482 attribute[strlen(attribute)-1]='\0';
483 (void) SetImageProperty((Image *) image,key,(const char *) attribute,
485 attribute=DestroyString(attribute);
489 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
501 static inline signed int ReadPropertyMSBLong(const unsigned char **p,
527 for (i=0; i < 4; i++)
531 buffer[i]=(unsigned char) c;
533 value=(unsigned int) buffer[0] << 24;
534 value|=(unsigned int) buffer[1] << 16;
535 value|=(unsigned int) buffer[2] << 8;
536 value|=(unsigned int) buffer[3];
537 quantum.unsigned_value=value & 0xffffffff;
538 return(quantum.signed_value);
541 static inline signed short ReadPropertyMSBShort(const unsigned char **p,
566 return((unsigned short) ~0);
567 for (i=0; i < 2; i++)
571 buffer[i]=(unsigned char) c;
573 value=(unsigned short) buffer[0] << 8;
574 value|=(unsigned short) buffer[1];
575 quantum.unsigned_value=value & 0xffff;
576 return(quantum.signed_value);
579 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
580 ExceptionInfo *exception)
584 format[MagickPathExtent],
585 name[MagickPathExtent],
613 There are no newlines in path names, so it's safe as terminator.
615 profile=GetImageProfile(image,"8bim");
616 if (profile == (StringInfo *) NULL)
618 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
620 if ((count != 2) && (count != 3) && (count != 4))
623 (void) CopyMagickString(format,"SVG",MagickPathExtent);
628 sub_number=(ssize_t) StringToLong(&name[1]);
629 sub_number=MagickMax(sub_number,1L);
630 resource=(char *) NULL;
632 length=GetStringInfoLength(profile);
633 info=GetStringInfoDatum(profile);
634 while ((length > 0) && (status == MagickFalse))
636 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
638 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
640 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
642 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
644 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
645 if (id < (ssize_t) start)
647 if (id > (ssize_t) stop)
649 if (resource != (char *) NULL)
650 resource=DestroyString(resource);
651 count=(ssize_t) ReadPropertyByte(&info,&length);
652 if ((count != 0) && ((size_t) count <= length))
654 resource=(char *) NULL;
655 if (~((size_t) count) >= (MagickPathExtent-1))
656 resource=(char *) AcquireQuantumMemory((size_t) count+
657 MagickPathExtent,sizeof(*resource));
658 if (resource != (char *) NULL)
660 for (i=0; i < (ssize_t) count; i++)
661 resource[i]=(char) ReadPropertyByte(&info,&length);
662 resource[count]='\0';
665 if ((count & 0x01) == 0)
666 (void) ReadPropertyByte(&info,&length);
667 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
668 if ((count < 0) || ((size_t) count > length))
673 if ((*name != '\0') && (*name != '#'))
674 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
677 No name match, scroll forward and try next.
680 length-=MagickMin(count,(ssize_t) length);
683 if ((*name == '#') && (sub_number != 1))
686 No numbered match, scroll forward and try next.
690 length-=MagickMin(count,(ssize_t) length);
694 We have the resource of interest.
696 attribute=(char *) NULL;
697 if (~((size_t) count) >= (MagickPathExtent-1))
698 attribute=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent,
700 if (attribute != (char *) NULL)
702 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
703 attribute[count]='\0';
705 length-=MagickMin(count,(ssize_t) length);
706 if ((id <= 1999) || (id >= 2999))
707 (void) SetImageProperty((Image *) image,key,(const char *) attribute,
714 if (LocaleCompare(format,"svg") == 0)
715 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
716 image->columns,image->rows);
718 path=TracePSClippath((unsigned char *) attribute,(size_t) count);
719 (void) SetImageProperty((Image *) image,key,(const char *) path,
721 path=DestroyString(path);
723 attribute=DestroyString(attribute);
727 if (resource != (char *) NULL)
728 resource=DestroyString(resource);
732 static inline signed int ReadPropertySignedLong(const EndianType endian,
733 const unsigned char *buffer)
747 if (endian == LSBEndian)
749 value=(unsigned int) buffer[3] << 24;
750 value|=(unsigned int) buffer[2] << 16;
751 value|=(unsigned int) buffer[1] << 8;
752 value|=(unsigned int) buffer[0];
753 quantum.unsigned_value=value & 0xffffffff;
754 return(quantum.signed_value);
756 value=(unsigned int) buffer[0] << 24;
757 value|=(unsigned int) buffer[1] << 16;
758 value|=(unsigned int) buffer[2] << 8;
759 value|=(unsigned int) buffer[3];
760 quantum.unsigned_value=value & 0xffffffff;
761 return(quantum.signed_value);
764 static inline unsigned int ReadPropertyUnsignedLong(const EndianType endian,
765 const unsigned char *buffer)
770 if (endian == LSBEndian)
772 value=(unsigned int) buffer[3] << 24;
773 value|=(unsigned int) buffer[2] << 16;
774 value|=(unsigned int) buffer[1] << 8;
775 value|=(unsigned int) buffer[0];
776 return(value & 0xffffffff);
778 value=(unsigned int) buffer[0] << 24;
779 value|=(unsigned int) buffer[1] << 16;
780 value|=(unsigned int) buffer[2] << 8;
781 value|=(unsigned int) buffer[3];
782 return(value & 0xffffffff);
785 static inline signed short ReadPropertySignedShort(const EndianType endian,
786 const unsigned char *buffer)
800 if (endian == LSBEndian)
802 value=(unsigned short) buffer[1] << 8;
803 value|=(unsigned short) buffer[0];
804 quantum.unsigned_value=value & 0xffff;
805 return(quantum.signed_value);
807 value=(unsigned short) buffer[0] << 8;
808 value|=(unsigned short) buffer[1];
809 quantum.unsigned_value=value & 0xffff;
810 return(quantum.signed_value);
813 static inline unsigned short ReadPropertyUnsignedShort(const EndianType endian,
814 const unsigned char *buffer)
819 if (endian == LSBEndian)
821 value=(unsigned short) buffer[1] << 8;
822 value|=(unsigned short) buffer[0];
823 return(value & 0xffff);
825 value=(unsigned short) buffer[0] << 8;
826 value|=(unsigned short) buffer[1];
827 return(value & 0xffff);
830 static MagickBooleanType GetEXIFProperty(const Image *image,
831 const char *property,ExceptionInfo *exception)
833 #define MaxDirectoryStack 16
834 #define EXIF_DELIMITER "\n"
835 #define EXIF_NUM_FORMATS 12
836 #define EXIF_FMT_BYTE 1
837 #define EXIF_FMT_STRING 2
838 #define EXIF_FMT_USHORT 3
839 #define EXIF_FMT_ULONG 4
840 #define EXIF_FMT_URATIONAL 5
841 #define EXIF_FMT_SBYTE 6
842 #define EXIF_FMT_UNDEFINED 7
843 #define EXIF_FMT_SSHORT 8
844 #define EXIF_FMT_SLONG 9
845 #define EXIF_FMT_SRATIONAL 10
846 #define EXIF_FMT_SINGLE 11
847 #define EXIF_FMT_DOUBLE 12
848 #define TAG_EXIF_OFFSET 0x8769
849 #define TAG_GPS_OFFSET 0x8825
850 #define TAG_INTEROP_OFFSET 0xa005
852 #define EXIFMultipleValues(size,format,arg) \
865 for (component=0; component < components; component++) \
867 length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
869 if (length >= (MagickPathExtent-1)) \
870 length=MagickPathExtent-1; \
874 buffer[length-2]='\0'; \
875 value=AcquireString(buffer); \
878 #define EXIFMultipleFractions(size,format,arg1,arg2) \
891 for (component=0; component < components; component++) \
893 length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
894 format", ",(arg1),(arg2)); \
895 if (length >= (MagickPathExtent-1)) \
896 length=MagickPathExtent-1; \
900 buffer[length-2]='\0'; \
901 value=AcquireString(buffer); \
904 typedef struct _DirectoryInfo
916 typedef struct _TagInfo
928 { 0x001, "exif:InteroperabilityIndex" },
929 { 0x002, "exif:InteroperabilityVersion" },
930 { 0x100, "exif:ImageWidth" },
931 { 0x101, "exif:ImageLength" },
932 { 0x102, "exif:BitsPerSample" },
933 { 0x103, "exif:Compression" },
934 { 0x106, "exif:PhotometricInterpretation" },
935 { 0x10a, "exif:FillOrder" },
936 { 0x10d, "exif:DocumentName" },
937 { 0x10e, "exif:ImageDescription" },
938 { 0x10f, "exif:Make" },
939 { 0x110, "exif:Model" },
940 { 0x111, "exif:StripOffsets" },
941 { 0x112, "exif:Orientation" },
942 { 0x115, "exif:SamplesPerPixel" },
943 { 0x116, "exif:RowsPerStrip" },
944 { 0x117, "exif:StripByteCounts" },
945 { 0x11a, "exif:XResolution" },
946 { 0x11b, "exif:YResolution" },
947 { 0x11c, "exif:PlanarConfiguration" },
948 { 0x11d, "exif:PageName" },
949 { 0x11e, "exif:XPosition" },
950 { 0x11f, "exif:YPosition" },
951 { 0x118, "exif:MinSampleValue" },
952 { 0x119, "exif:MaxSampleValue" },
953 { 0x120, "exif:FreeOffsets" },
954 { 0x121, "exif:FreeByteCounts" },
955 { 0x122, "exif:GrayResponseUnit" },
956 { 0x123, "exif:GrayResponseCurve" },
957 { 0x124, "exif:T4Options" },
958 { 0x125, "exif:T6Options" },
959 { 0x128, "exif:ResolutionUnit" },
960 { 0x12d, "exif:TransferFunction" },
961 { 0x131, "exif:Software" },
962 { 0x132, "exif:DateTime" },
963 { 0x13b, "exif:Artist" },
964 { 0x13e, "exif:WhitePoint" },
965 { 0x13f, "exif:PrimaryChromaticities" },
966 { 0x140, "exif:ColorMap" },
967 { 0x141, "exif:HalfToneHints" },
968 { 0x142, "exif:TileWidth" },
969 { 0x143, "exif:TileLength" },
970 { 0x144, "exif:TileOffsets" },
971 { 0x145, "exif:TileByteCounts" },
972 { 0x14a, "exif:SubIFD" },
973 { 0x14c, "exif:InkSet" },
974 { 0x14d, "exif:InkNames" },
975 { 0x14e, "exif:NumberOfInks" },
976 { 0x150, "exif:DotRange" },
977 { 0x151, "exif:TargetPrinter" },
978 { 0x152, "exif:ExtraSample" },
979 { 0x153, "exif:SampleFormat" },
980 { 0x154, "exif:SMinSampleValue" },
981 { 0x155, "exif:SMaxSampleValue" },
982 { 0x156, "exif:TransferRange" },
983 { 0x157, "exif:ClipPath" },
984 { 0x158, "exif:XClipPathUnits" },
985 { 0x159, "exif:YClipPathUnits" },
986 { 0x15a, "exif:Indexed" },
987 { 0x15b, "exif:JPEGTables" },
988 { 0x15f, "exif:OPIProxy" },
989 { 0x200, "exif:JPEGProc" },
990 { 0x201, "exif:JPEGInterchangeFormat" },
991 { 0x202, "exif:JPEGInterchangeFormatLength" },
992 { 0x203, "exif:JPEGRestartInterval" },
993 { 0x205, "exif:JPEGLosslessPredictors" },
994 { 0x206, "exif:JPEGPointTransforms" },
995 { 0x207, "exif:JPEGQTables" },
996 { 0x208, "exif:JPEGDCTables" },
997 { 0x209, "exif:JPEGACTables" },
998 { 0x211, "exif:YCbCrCoefficients" },
999 { 0x212, "exif:YCbCrSubSampling" },
1000 { 0x213, "exif:YCbCrPositioning" },
1001 { 0x214, "exif:ReferenceBlackWhite" },
1002 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
1003 { 0x301, "exif:Gamma" },
1004 { 0x302, "exif:ICCProfileDescriptor" },
1005 { 0x303, "exif:SRGBRenderingIntent" },
1006 { 0x320, "exif:ImageTitle" },
1007 { 0x5001, "exif:ResolutionXUnit" },
1008 { 0x5002, "exif:ResolutionYUnit" },
1009 { 0x5003, "exif:ResolutionXLengthUnit" },
1010 { 0x5004, "exif:ResolutionYLengthUnit" },
1011 { 0x5005, "exif:PrintFlags" },
1012 { 0x5006, "exif:PrintFlagsVersion" },
1013 { 0x5007, "exif:PrintFlagsCrop" },
1014 { 0x5008, "exif:PrintFlagsBleedWidth" },
1015 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
1016 { 0x500A, "exif:HalftoneLPI" },
1017 { 0x500B, "exif:HalftoneLPIUnit" },
1018 { 0x500C, "exif:HalftoneDegree" },
1019 { 0x500D, "exif:HalftoneShape" },
1020 { 0x500E, "exif:HalftoneMisc" },
1021 { 0x500F, "exif:HalftoneScreen" },
1022 { 0x5010, "exif:JPEGQuality" },
1023 { 0x5011, "exif:GridSize" },
1024 { 0x5012, "exif:ThumbnailFormat" },
1025 { 0x5013, "exif:ThumbnailWidth" },
1026 { 0x5014, "exif:ThumbnailHeight" },
1027 { 0x5015, "exif:ThumbnailColorDepth" },
1028 { 0x5016, "exif:ThumbnailPlanes" },
1029 { 0x5017, "exif:ThumbnailRawBytes" },
1030 { 0x5018, "exif:ThumbnailSize" },
1031 { 0x5019, "exif:ThumbnailCompressedSize" },
1032 { 0x501a, "exif:ColorTransferFunction" },
1033 { 0x501b, "exif:ThumbnailData" },
1034 { 0x5020, "exif:ThumbnailImageWidth" },
1035 { 0x5021, "exif:ThumbnailImageHeight" },
1036 { 0x5022, "exif:ThumbnailBitsPerSample" },
1037 { 0x5023, "exif:ThumbnailCompression" },
1038 { 0x5024, "exif:ThumbnailPhotometricInterp" },
1039 { 0x5025, "exif:ThumbnailImageDescription" },
1040 { 0x5026, "exif:ThumbnailEquipMake" },
1041 { 0x5027, "exif:ThumbnailEquipModel" },
1042 { 0x5028, "exif:ThumbnailStripOffsets" },
1043 { 0x5029, "exif:ThumbnailOrientation" },
1044 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
1045 { 0x502b, "exif:ThumbnailRowsPerStrip" },
1046 { 0x502c, "exif:ThumbnailStripBytesCount" },
1047 { 0x502d, "exif:ThumbnailResolutionX" },
1048 { 0x502e, "exif:ThumbnailResolutionY" },
1049 { 0x502f, "exif:ThumbnailPlanarConfig" },
1050 { 0x5030, "exif:ThumbnailResolutionUnit" },
1051 { 0x5031, "exif:ThumbnailTransferFunction" },
1052 { 0x5032, "exif:ThumbnailSoftwareUsed" },
1053 { 0x5033, "exif:ThumbnailDateTime" },
1054 { 0x5034, "exif:ThumbnailArtist" },
1055 { 0x5035, "exif:ThumbnailWhitePoint" },
1056 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
1057 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
1058 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
1059 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
1060 { 0x503A, "exif:ThumbnailRefBlackWhite" },
1061 { 0x503B, "exif:ThumbnailCopyRight" },
1062 { 0x5090, "exif:LuminanceTable" },
1063 { 0x5091, "exif:ChrominanceTable" },
1064 { 0x5100, "exif:FrameDelay" },
1065 { 0x5101, "exif:LoopCount" },
1066 { 0x5110, "exif:PixelUnit" },
1067 { 0x5111, "exif:PixelPerUnitX" },
1068 { 0x5112, "exif:PixelPerUnitY" },
1069 { 0x5113, "exif:PaletteHistogram" },
1070 { 0x1000, "exif:RelatedImageFileFormat" },
1071 { 0x1001, "exif:RelatedImageLength" },
1072 { 0x1002, "exif:RelatedImageWidth" },
1073 { 0x800d, "exif:ImageID" },
1074 { 0x80e3, "exif:Matteing" },
1075 { 0x80e4, "exif:DataType" },
1076 { 0x80e5, "exif:ImageDepth" },
1077 { 0x80e6, "exif:TileDepth" },
1078 { 0x828d, "exif:CFARepeatPatternDim" },
1079 { 0x828e, "exif:CFAPattern2" },
1080 { 0x828f, "exif:BatteryLevel" },
1081 { 0x8298, "exif:Copyright" },
1082 { 0x829a, "exif:ExposureTime" },
1083 { 0x829d, "exif:FNumber" },
1084 { 0x83bb, "exif:IPTC/NAA" },
1085 { 0x84e3, "exif:IT8RasterPadding" },
1086 { 0x84e5, "exif:IT8ColorTable" },
1087 { 0x8649, "exif:ImageResourceInformation" },
1088 { 0x8769, "exif:ExifOffset" },
1089 { 0x8773, "exif:InterColorProfile" },
1090 { 0x8822, "exif:ExposureProgram" },
1091 { 0x8824, "exif:SpectralSensitivity" },
1092 { 0x8825, "exif:GPSInfo" },
1093 { 0x8827, "exif:ISOSpeedRatings" },
1094 { 0x8828, "exif:OECF" },
1095 { 0x8829, "exif:Interlace" },
1096 { 0x882a, "exif:TimeZoneOffset" },
1097 { 0x882b, "exif:SelfTimerMode" },
1098 { 0x9000, "exif:ExifVersion" },
1099 { 0x9003, "exif:DateTimeOriginal" },
1100 { 0x9004, "exif:DateTimeDigitized" },
1101 { 0x9101, "exif:ComponentsConfiguration" },
1102 { 0x9102, "exif:CompressedBitsPerPixel" },
1103 { 0x9201, "exif:ShutterSpeedValue" },
1104 { 0x9202, "exif:ApertureValue" },
1105 { 0x9203, "exif:BrightnessValue" },
1106 { 0x9204, "exif:ExposureBiasValue" },
1107 { 0x9205, "exif:MaxApertureValue" },
1108 { 0x9206, "exif:SubjectDistance" },
1109 { 0x9207, "exif:MeteringMode" },
1110 { 0x9208, "exif:LightSource" },
1111 { 0x9209, "exif:Flash" },
1112 { 0x920a, "exif:FocalLength" },
1113 { 0x920b, "exif:FlashEnergy" },
1114 { 0x920c, "exif:SpatialFrequencyResponse" },
1115 { 0x920d, "exif:Noise" },
1116 { 0x9211, "exif:ImageNumber" },
1117 { 0x9212, "exif:SecurityClassification" },
1118 { 0x9213, "exif:ImageHistory" },
1119 { 0x9214, "exif:SubjectArea" },
1120 { 0x9215, "exif:ExposureIndex" },
1121 { 0x9216, "exif:TIFF-EPStandardID" },
1122 { 0x927c, "exif:MakerNote" },
1123 { 0x9C9b, "exif:WinXP-Title" },
1124 { 0x9C9c, "exif:WinXP-Comments" },
1125 { 0x9C9d, "exif:WinXP-Author" },
1126 { 0x9C9e, "exif:WinXP-Keywords" },
1127 { 0x9C9f, "exif:WinXP-Subject" },
1128 { 0x9286, "exif:UserComment" },
1129 { 0x9290, "exif:SubSecTime" },
1130 { 0x9291, "exif:SubSecTimeOriginal" },
1131 { 0x9292, "exif:SubSecTimeDigitized" },
1132 { 0xa000, "exif:FlashPixVersion" },
1133 { 0xa001, "exif:ColorSpace" },
1134 { 0xa002, "exif:ExifImageWidth" },
1135 { 0xa003, "exif:ExifImageLength" },
1136 { 0xa004, "exif:RelatedSoundFile" },
1137 { 0xa005, "exif:InteroperabilityOffset" },
1138 { 0xa20b, "exif:FlashEnergy" },
1139 { 0xa20c, "exif:SpatialFrequencyResponse" },
1140 { 0xa20d, "exif:Noise" },
1141 { 0xa20e, "exif:FocalPlaneXResolution" },
1142 { 0xa20f, "exif:FocalPlaneYResolution" },
1143 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1144 { 0xa214, "exif:SubjectLocation" },
1145 { 0xa215, "exif:ExposureIndex" },
1146 { 0xa216, "exif:TIFF/EPStandardID" },
1147 { 0xa217, "exif:SensingMethod" },
1148 { 0xa300, "exif:FileSource" },
1149 { 0xa301, "exif:SceneType" },
1150 { 0xa302, "exif:CFAPattern" },
1151 { 0xa401, "exif:CustomRendered" },
1152 { 0xa402, "exif:ExposureMode" },
1153 { 0xa403, "exif:WhiteBalance" },
1154 { 0xa404, "exif:DigitalZoomRatio" },
1155 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1156 { 0xa406, "exif:SceneCaptureType" },
1157 { 0xa407, "exif:GainControl" },
1158 { 0xa408, "exif:Contrast" },
1159 { 0xa409, "exif:Saturation" },
1160 { 0xa40a, "exif:Sharpness" },
1161 { 0xa40b, "exif:DeviceSettingDescription" },
1162 { 0xa40c, "exif:SubjectDistanceRange" },
1163 { 0xa420, "exif:ImageUniqueID" },
1164 { 0xc4a5, "exif:PrintImageMatching" },
1165 { 0xa500, "exif:Gamma" },
1166 { 0xc640, "exif:CR2Slice" },
1167 { 0x10000, "exif:GPSVersionID" },
1168 { 0x10001, "exif:GPSLatitudeRef" },
1169 { 0x10002, "exif:GPSLatitude" },
1170 { 0x10003, "exif:GPSLongitudeRef" },
1171 { 0x10004, "exif:GPSLongitude" },
1172 { 0x10005, "exif:GPSAltitudeRef" },
1173 { 0x10006, "exif:GPSAltitude" },
1174 { 0x10007, "exif:GPSTimeStamp" },
1175 { 0x10008, "exif:GPSSatellites" },
1176 { 0x10009, "exif:GPSStatus" },
1177 { 0x1000a, "exif:GPSMeasureMode" },
1178 { 0x1000b, "exif:GPSDop" },
1179 { 0x1000c, "exif:GPSSpeedRef" },
1180 { 0x1000d, "exif:GPSSpeed" },
1181 { 0x1000e, "exif:GPSTrackRef" },
1182 { 0x1000f, "exif:GPSTrack" },
1183 { 0x10010, "exif:GPSImgDirectionRef" },
1184 { 0x10011, "exif:GPSImgDirection" },
1185 { 0x10012, "exif:GPSMapDatum" },
1186 { 0x10013, "exif:GPSDestLatitudeRef" },
1187 { 0x10014, "exif:GPSDestLatitude" },
1188 { 0x10015, "exif:GPSDestLongitudeRef" },
1189 { 0x10016, "exif:GPSDestLongitude" },
1190 { 0x10017, "exif:GPSDestBearingRef" },
1191 { 0x10018, "exif:GPSDestBearing" },
1192 { 0x10019, "exif:GPSDestDistanceRef" },
1193 { 0x1001a, "exif:GPSDestDistance" },
1194 { 0x1001b, "exif:GPSProcessingMethod" },
1195 { 0x1001c, "exif:GPSAreaInformation" },
1196 { 0x1001d, "exif:GPSDateStamp" },
1197 { 0x1001e, "exif:GPSDifferential" },
1198 { 0x00000, (const char *) NULL }
1209 directory_stack[MaxDirectoryStack];
1238 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1241 If EXIF data exists, then try to parse the request for a tag.
1243 profile=GetImageProfile(image,"exif");
1244 if (profile == (const StringInfo *) NULL)
1245 return(MagickFalse);
1246 if ((property == (const char *) NULL) || (*property == '\0'))
1247 return(MagickFalse);
1248 while (isspace((int) ((unsigned char) *property)) != 0)
1250 if (strlen(property) <= 5)
1251 return(MagickFalse);
1254 switch (*(property+5))
1259 Caller has asked for all the tags in the EXIF data.
1262 all=1; /* return the data in description=value format */
1268 all=2; /* return the data in tagid=value format */
1281 Check for a hex based tag specification first.
1283 tag=(*(property+5) == '@') ? 1UL : 0UL;
1287 return(MagickFalse);
1289 Parse tag specification as a hex number.
1294 for (i=(ssize_t) n-1L; i >= 0; i--)
1298 if ((c >= '0') && (c <= '9'))
1301 if ((c >= 'A') && (c <= 'F'))
1304 if ((c >= 'a') && (c <= 'f'))
1307 return(MagickFalse);
1309 } while (*property != '\0');
1315 Try to match the text with a tag name instead.
1319 if (EXIFTag[i].tag == 0)
1321 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1323 tag=(size_t) EXIFTag[i].tag;
1331 return(MagickFalse);
1332 length=GetStringInfoLength(profile);
1333 exif=GetStringInfoDatum(profile);
1336 if (ReadPropertyByte(&exif,&length) != 0x45)
1338 if (ReadPropertyByte(&exif,&length) != 0x78)
1340 if (ReadPropertyByte(&exif,&length) != 0x69)
1342 if (ReadPropertyByte(&exif,&length) != 0x66)
1344 if (ReadPropertyByte(&exif,&length) != 0x00)
1346 if (ReadPropertyByte(&exif,&length) != 0x00)
1351 return(MagickFalse);
1352 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1360 return(MagickFalse);
1361 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1362 return(MagickFalse);
1364 This the offset to the first IFD.
1366 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1367 if ((offset < 0) || (size_t) offset >= length)
1368 return(MagickFalse);
1370 Set the pointer to the first IFD and follow it were it leads.
1373 directory=exif+offset;
1377 exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,
1378 (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
1382 If there is anything on the stack then pop it off.
1387 directory=directory_stack[level].directory;
1388 entry=directory_stack[level].entry;
1389 tag_offset=directory_stack[level].offset;
1391 if ((directory < exif) || (directory > (exif+length-2)))
1394 Determine how many entries there are in the current IFD.
1396 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1397 for ( ; entry < number_entries; entry++)
1399 register unsigned char
1410 q=(unsigned char *) (directory+(12*entry)+2);
1411 if (q > (exif+length-12))
1412 break; /* corrupt EXIF */
1413 if (GetValueFromSplayTree(exif_resources,q) == q)
1415 (void) AddValueToSplayTree(exif_resources,q,q);
1416 tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;
1417 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1418 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1420 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1422 break; /* corrupt EXIF */
1423 number_bytes=(size_t) components*tag_bytes[format];
1424 if (number_bytes < components)
1425 break; /* prevent overflow */
1426 if (number_bytes <= 4)
1434 The directory entry contains an offset.
1436 offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1437 if ((offset < 0) || (size_t) offset >= length)
1439 if ((ssize_t) (offset+number_bytes) < offset)
1440 continue; /* prevent overflow */
1441 if ((size_t) (offset+number_bytes) > length)
1443 p=(unsigned char *) (exif+offset);
1445 if ((all != 0) || (tag == (size_t) tag_value))
1448 buffer[MagickPathExtent],
1451 value=(char *) NULL;
1456 case EXIF_FMT_UNDEFINED:
1458 EXIFMultipleValues(1,"%.20g",(double) (*(unsigned char *) p1));
1461 case EXIF_FMT_SBYTE:
1463 EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1466 case EXIF_FMT_SSHORT:
1468 EXIFMultipleValues(2,"%hd",ReadPropertySignedShort(endian,p1));
1471 case EXIF_FMT_USHORT:
1473 EXIFMultipleValues(2,"%hu",ReadPropertyUnsignedShort(endian,p1));
1476 case EXIF_FMT_ULONG:
1478 EXIFMultipleValues(4,"%.20g",(double)
1479 ReadPropertyUnsignedLong(endian,p1));
1482 case EXIF_FMT_SLONG:
1484 EXIFMultipleValues(4,"%.20g",(double)
1485 ReadPropertySignedLong(endian,p1));
1488 case EXIF_FMT_URATIONAL:
1490 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1491 ReadPropertyUnsignedLong(endian,p1),(double)
1492 ReadPropertyUnsignedLong(endian,p1+4));
1495 case EXIF_FMT_SRATIONAL:
1497 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1498 ReadPropertySignedLong(endian,p1),(double)
1499 ReadPropertySignedLong(endian,p1+4));
1502 case EXIF_FMT_SINGLE:
1504 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1507 case EXIF_FMT_DOUBLE:
1509 EXIFMultipleValues(8,"%f",*(double *) p1);
1513 case EXIF_FMT_STRING:
1515 value=(char *) NULL;
1516 if (~((size_t) number_bytes) >= 1)
1517 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1519 if (value != (char *) NULL)
1524 for (i=0; i < (ssize_t) number_bytes; i++)
1527 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1528 value[i]=(char) p[i];
1535 if (value != (char *) NULL)
1543 key=AcquireString(property);
1554 description="unknown";
1557 if (EXIFTag[i].tag == 0)
1559 if (EXIFTag[i].tag == tag_value)
1561 description=EXIFTag[i].description;
1565 (void) FormatLocaleString(key,MagickPathExtent,"%s",
1568 (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1573 if (tag_value < 0x10000)
1574 (void) FormatLocaleString(key,MagickPathExtent,"#%04lx",
1575 (unsigned long) tag_value);
1577 if (tag_value < 0x20000)
1578 (void) FormatLocaleString(key,MagickPathExtent,"@%04lx",
1579 (unsigned long) (tag_value & 0xffff));
1581 (void) FormatLocaleString(key,MagickPathExtent,"unknown");
1587 (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1590 p=(const char *) NULL;
1591 if (image->properties != (void *) NULL)
1592 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1593 image->properties,key);
1594 if (p == (const char *) NULL)
1595 (void) SetImageProperty((Image *) image,key,value,exception);
1596 value=DestroyString(value);
1597 key=DestroyString(key);
1601 if ((tag_value == TAG_EXIF_OFFSET) ||
1602 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1607 offset=(ssize_t) ReadPropertySignedLong(endian,p);
1608 if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1613 tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1615 directory_stack[level].directory=directory;
1617 directory_stack[level].entry=entry;
1618 directory_stack[level].offset=tag_offset;
1620 directory_stack[level].directory=exif+offset;
1621 directory_stack[level].offset=tag_offset1;
1622 directory_stack[level].entry=0;
1624 if ((directory+2+(12*number_entries)) > (exif+length))
1626 offset=(ssize_t) ReadPropertySignedLong(endian,directory+2+(12*
1628 if ((offset != 0) && ((size_t) offset < length) &&
1629 (level < (MaxDirectoryStack-2)))
1631 directory_stack[level].directory=exif+offset;
1632 directory_stack[level].entry=0;
1633 directory_stack[level].offset=tag_offset1;
1640 } while (level > 0);
1641 exif_resources=DestroySplayTree(exif_resources);
1645 static MagickBooleanType GetICCProperty(const Image *image,const char *property,
1646 ExceptionInfo *exception)
1651 magick_unreferenced(property);
1653 profile=GetImageProfile(image,"icc");
1654 if (profile == (StringInfo *) NULL)
1655 profile=GetImageProfile(image,"icm");
1656 if (profile == (StringInfo *) NULL)
1657 return(MagickFalse);
1658 if (GetStringInfoLength(profile) < 128)
1659 return(MagickFalse); /* minimum ICC profile length */
1660 #if defined(MAGICKCORE_LCMS_DELEGATE)
1665 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1666 (cmsUInt32Number) GetStringInfoLength(profile));
1667 if (icc_profile != (cmsHPROFILE *) NULL)
1669 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1673 name=cmsTakeProductName(icc_profile);
1674 if (name != (const char *) NULL)
1675 (void) SetImageProperty((Image *) image,"icc:name",name,exception);
1678 info[MagickPathExtent];
1680 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,"en","US",
1681 info,MagickPathExtent);
1682 (void) SetImageProperty((Image *) image,"icc:description",info,
1684 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,"en","US",
1685 info,MagickPathExtent);
1686 (void) SetImageProperty((Image *) image,"icc:manufacturer",info,
1688 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en","US",info,
1690 (void) SetImageProperty((Image *) image,"icc:model",info,exception);
1691 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,"en","US",
1692 info,MagickPathExtent);
1693 (void) SetImageProperty((Image *) image,"icc:copyright",info,exception);
1695 (void) cmsCloseProfile(icc_profile);
1702 static MagickBooleanType SkipXMPValue(const char *value)
1704 if (value == (const char*) NULL)
1706 while (*value != '\0')
1708 if (isspace((int) ((unsigned char) *value)) == 0)
1709 return(MagickFalse);
1715 static MagickBooleanType GetXMPProperty(const Image *image,const char *property)
1742 profile=GetImageProfile(image,"xmp");
1743 if (profile == (StringInfo *) NULL)
1744 return(MagickFalse);
1745 if ((property == (const char *) NULL) || (*property == '\0'))
1746 return(MagickFalse);
1747 xmp_profile=StringInfoToString(profile);
1748 if (xmp_profile == (char *) NULL)
1749 return(MagickFalse);
1750 for (p=xmp_profile; *p != '\0'; p++)
1751 if ((*p == '<') && (*(p+1) == 'x'))
1753 exception=AcquireExceptionInfo();
1754 xmp=NewXMLTree((char *) p,exception);
1755 xmp_profile=DestroyString(xmp_profile);
1756 exception=DestroyExceptionInfo(exception);
1757 if (xmp == (XMLTreeInfo *) NULL)
1758 return(MagickFalse);
1760 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1761 if (rdf != (XMLTreeInfo *) NULL)
1763 if (image->properties == (void *) NULL)
1764 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1765 RelinquishMagickMemory,RelinquishMagickMemory);
1766 description=GetXMLTreeChild(rdf,"rdf:Description");
1767 while (description != (XMLTreeInfo *) NULL)
1772 node=GetXMLTreeChild(description,(const char *) NULL);
1773 while (node != (XMLTreeInfo *) NULL)
1775 child=GetXMLTreeChild(node,(const char *) NULL);
1776 content=GetXMLTreeContent(node);
1777 if ((child == (XMLTreeInfo *) NULL) &&
1778 (SkipXMPValue(content) == MagickFalse))
1780 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1781 (void) SubstituteString(&xmp_namespace,"exif:","xmp:");
1782 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1783 xmp_namespace,ConstantString(content));
1785 while (child != (XMLTreeInfo *) NULL)
1787 content=GetXMLTreeContent(child);
1788 if (SkipXMPValue(content) == MagickFalse)
1790 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1791 (void) SubstituteString(&xmp_namespace,"exif:","xmp:");
1792 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1793 xmp_namespace,ConstantString(content));
1795 child=GetXMLTreeSibling(child);
1797 node=GetXMLTreeSibling(node);
1799 description=GetNextXMLTreeTag(description);
1802 xmp=DestroyXMLTree(xmp);
1806 static char *TracePSClippath(const unsigned char *blob,size_t length)
1829 path=AcquireString((char *) NULL);
1830 if (path == (char *) NULL)
1831 return((char *) NULL);
1832 message=AcquireString((char *) NULL);
1833 (void) FormatLocaleString(message,MagickPathExtent,"/ClipImage\n");
1834 (void) ConcatenateString(&path,message);
1835 (void) FormatLocaleString(message,MagickPathExtent,"{\n");
1836 (void) ConcatenateString(&path,message);
1837 (void) FormatLocaleString(message,MagickPathExtent,
1838 " /c {curveto} bind def\n");
1839 (void) ConcatenateString(&path,message);
1840 (void) FormatLocaleString(message,MagickPathExtent,
1841 " /l {lineto} bind def\n");
1842 (void) ConcatenateString(&path,message);
1843 (void) FormatLocaleString(message,MagickPathExtent,
1844 " /m {moveto} bind def\n");
1845 (void) ConcatenateString(&path,message);
1846 (void) FormatLocaleString(message,MagickPathExtent,
1847 " /v {currentpoint 6 2 roll curveto} bind def\n");
1848 (void) ConcatenateString(&path,message);
1849 (void) FormatLocaleString(message,MagickPathExtent,
1850 " /y {2 copy curveto} bind def\n");
1851 (void) ConcatenateString(&path,message);
1852 (void) FormatLocaleString(message,MagickPathExtent,
1853 " /z {closepath} bind def\n");
1854 (void) ConcatenateString(&path,message);
1855 (void) FormatLocaleString(message,MagickPathExtent," newpath\n");
1856 (void) ConcatenateString(&path,message);
1858 The clipping path format is defined in "Adobe Photoshop File Formats
1859 Specification" version 6.0 downloadable from adobe.com.
1861 (void) ResetMagickMemory(point,0,sizeof(point));
1862 (void) ResetMagickMemory(first,0,sizeof(first));
1863 (void) ResetMagickMemory(last,0,sizeof(last));
1865 in_subpath=MagickFalse;
1868 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1874 if (knot_count != 0)
1877 length-=MagickMin(24,(ssize_t) length);
1881 Expected subpath length record.
1883 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1885 length-=MagickMin(22,(ssize_t) length);
1893 if (knot_count == 0)
1896 Unexpected subpath knot
1899 length-=MagickMin(24,(ssize_t) length);
1905 for (i=0; i < 3; i++)
1911 yy=(size_t) ReadPropertyMSBLong(&blob,&length);
1912 xx=(size_t) ReadPropertyMSBLong(&blob,&length);
1914 if (xx > 2147483647)
1915 x=(ssize_t) xx-4294967295U-1;
1917 if (yy > 2147483647)
1918 y=(ssize_t) yy-4294967295U-1;
1919 point[i].x=(double) x/4096/4096;
1920 point[i].y=1.0-(double) y/4096/4096;
1922 if (in_subpath == MagickFalse)
1924 (void) FormatLocaleString(message,MagickPathExtent," %g %g m\n",
1925 point[1].x,point[1].y);
1926 for (i=0; i < 3; i++)
1935 Handle special cases when Bezier curves are used to describe
1936 corners and straight lines.
1938 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1939 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1940 (void) FormatLocaleString(message,MagickPathExtent,
1941 " %g %g l\n",point[1].x,point[1].y);
1943 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1944 (void) FormatLocaleString(message,MagickPathExtent,
1945 " %g %g %g %g v\n",point[0].x,point[0].y,
1946 point[1].x,point[1].y);
1948 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1949 (void) FormatLocaleString(message,MagickPathExtent,
1950 " %g %g %g %g y\n",last[2].x,last[2].y,
1951 point[1].x,point[1].y);
1953 (void) FormatLocaleString(message,MagickPathExtent,
1954 " %g %g %g %g %g %g c\n",last[2].x,
1955 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1956 for (i=0; i < 3; i++)
1959 (void) ConcatenateString(&path,message);
1960 in_subpath=MagickTrue;
1963 Close the subpath if there are no more knots.
1965 if (knot_count == 0)
1968 Same special handling as above except we compare to the
1969 first point in the path and close the path.
1971 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1972 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1973 (void) FormatLocaleString(message,MagickPathExtent,
1974 " %g %g l z\n",first[1].x,first[1].y);
1976 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1977 (void) FormatLocaleString(message,MagickPathExtent,
1978 " %g %g %g %g v z\n",first[0].x,first[0].y,
1979 first[1].x,first[1].y);
1981 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1982 (void) FormatLocaleString(message,MagickPathExtent,
1983 " %g %g %g %g y z\n",last[2].x,last[2].y,
1984 first[1].x,first[1].y);
1986 (void) FormatLocaleString(message,MagickPathExtent,
1987 " %g %g %g %g %g %g c z\n",last[2].x,
1988 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1989 (void) ConcatenateString(&path,message);
1990 in_subpath=MagickFalse;
2000 length-=MagickMin(24,(ssize_t) length);
2006 Returns an empty PS path if the path has no knots.
2008 (void) FormatLocaleString(message,MagickPathExtent," eoclip\n");
2009 (void) ConcatenateString(&path,message);
2010 (void) FormatLocaleString(message,MagickPathExtent,"} bind def");
2011 (void) ConcatenateString(&path,message);
2012 message=DestroyString(message);
2016 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
2017 const size_t columns,const size_t rows)
2040 path=AcquireString((char *) NULL);
2041 if (path == (char *) NULL)
2042 return((char *) NULL);
2043 message=AcquireString((char *) NULL);
2044 (void) FormatLocaleString(message,MagickPathExtent,(
2045 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2046 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2047 " width=\"%.20g\" height=\"%.20g\">\n"
2049 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2050 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(double) columns,
2052 (void) ConcatenateString(&path,message);
2053 (void) ResetMagickMemory(point,0,sizeof(point));
2054 (void) ResetMagickMemory(first,0,sizeof(first));
2055 (void) ResetMagickMemory(last,0,sizeof(last));
2057 in_subpath=MagickFalse;
2060 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2066 if (knot_count != 0)
2069 length-=MagickMin(24,(ssize_t) length);
2073 Expected subpath length record.
2075 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2077 length-=MagickMin(22,(ssize_t) length);
2085 if (knot_count == 0)
2088 Unexpected subpath knot.
2091 length-=MagickMin(24,(ssize_t) length);
2097 for (i=0; i < 3; i++)
2103 yy=(unsigned int) ReadPropertyMSBLong(&blob,&length);
2104 xx=(unsigned int) ReadPropertyMSBLong(&blob,&length);
2106 if (xx > 2147483647)
2107 x=(ssize_t) xx-4294967295U-1;
2109 if (yy > 2147483647)
2110 y=(ssize_t) yy-4294967295U-1;
2111 point[i].x=(double) x*columns/4096/4096;
2112 point[i].y=(double) y*rows/4096/4096;
2114 if (in_subpath == MagickFalse)
2116 (void) FormatLocaleString(message,MagickPathExtent,"M %g %g\n",
2117 point[1].x,point[1].y);
2118 for (i=0; i < 3; i++)
2127 Handle special cases when Bezier curves are used to describe
2128 corners and straight lines.
2130 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2131 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2132 (void) FormatLocaleString(message,MagickPathExtent,
2133 "L %g %g\n",point[1].x,point[1].y);
2135 (void) FormatLocaleString(message,MagickPathExtent,
2136 "C %g %g %g %g %g %g\n",last[2].x,
2137 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2138 for (i=0; i < 3; i++)
2141 (void) ConcatenateString(&path,message);
2142 in_subpath=MagickTrue;
2145 Close the subpath if there are no more knots.
2147 if (knot_count == 0)
2150 Same special handling as above except we compare to the
2151 first point in the path and close the path.
2153 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2154 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2155 (void) FormatLocaleString(message,MagickPathExtent,
2156 "L %g %g Z\n",first[1].x,first[1].y);
2158 (void) FormatLocaleString(message,MagickPathExtent,
2159 "C %g %g %g %g %g %g Z\n",last[2].x,
2160 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2161 (void) ConcatenateString(&path,message);
2162 in_subpath=MagickFalse;
2172 length-=MagickMin(24,(ssize_t) length);
2178 Return an empty SVG image if the path does not have knots.
2180 (void) ConcatenateString(&path,"\"/>\n</g>\n</svg>\n");
2181 message=DestroyString(message);
2185 MagickExport const char *GetImageProperty(const Image *image,
2186 const char *property,ExceptionInfo *exception)
2191 assert(image != (Image *) NULL);
2192 assert(image->signature == MagickCoreSignature);
2193 if (image->debug != MagickFalse)
2194 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2195 p=(const char *) NULL;
2196 if (image->properties != (void *) NULL)
2198 if (property == (const char *) NULL)
2200 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
2201 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
2205 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2206 image->properties,property);
2207 if (p != (const char *) NULL)
2210 if ((property == (const char *) NULL) ||
2211 (strchr(property,':') == (char *) NULL))
2217 if (LocaleNCompare("8bim:",property,5) == 0)
2219 (void) Get8BIMProperty(image,property,exception);
2227 if (LocaleNCompare("exif:",property,5) == 0)
2229 (void) GetEXIFProperty(image,property,exception);
2237 if ((LocaleNCompare("icc:",property,4) == 0) ||
2238 (LocaleNCompare("icm:",property,4) == 0))
2240 (void) GetICCProperty(image,property,exception);
2243 if (LocaleNCompare("iptc:",property,5) == 0)
2245 (void) GetIPTCProperty(image,property,exception);
2253 if (LocaleNCompare("xmp:",property,4) == 0)
2255 (void) GetXMPProperty(image,property);
2263 if (image->properties != (void *) NULL)
2265 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2266 image->properties,property);
2269 return((const char *) NULL);
2273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2277 + G e t M a g i c k P r o p e r t y %
2281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2283 % GetMagickProperty() gets attributes or calculated values that is associated
2284 % with a fixed known property name, or single letter property. It may be
2285 % called if no image is defined (IMv7), in which case only global image_info
2286 % values are available:
2289 % \r carriage return
2290 % < less-than character.
2291 % > greater-than character.
2292 % & ampersand character.
2294 % %b file size of image read in
2295 % %c comment meta-data property
2296 % %d directory component of path
2297 % %e filename extension or suffix
2298 % %f filename (including suffix)
2299 % %g layer canvas page geometry (equivalent to "%Wx%H%X%Y")
2300 % %h current image height in pixels
2301 % %i image filename (note: becomes output filename for "info:")
2302 % %k CALCULATED: number of unique colors
2303 % %l label meta-data property
2304 % %m image file format (file magic)
2305 % %n number of images in current image sequence
2306 % %o output filename (used for delegates)
2307 % %p index of image in current image list
2308 % %q quantum depth (compile-time constant)
2309 % %r image class and colorspace
2310 % %s scene number (from input unless re-assigned)
2311 % %t filename without directory or extension (suffix)
2312 % %u unique temporary filename (used for delegates)
2313 % %w current width in pixels
2314 % %x x resolution (density)
2315 % %y y resolution (density)
2316 % %z image depth (as read in unless modified, image save depth)
2317 % %A image transparency channel enabled (true/false)
2318 % %C image compression type
2319 % %D image GIF dispose method
2320 % %G original image size (%wx%h; before any resizes)
2321 % %H page (canvas) height
2322 % %M Magick filename (original file exactly as given, including read mods)
2323 % %O page (canvas) offset ( = %X%Y )
2324 % %P page (canvas) size ( = %Wx%H )
2325 % %Q image compression quality ( 0 = default )
2327 % %T image time delay (in centi-seconds)
2328 % %U image resolution units
2329 % %W page (canvas) width
2330 % %X page (canvas) x offset (including sign)
2331 % %Y page (canvas) y offset (including sign)
2332 % %Z unique filename (used for delegates)
2333 % %@ CALCULATED: trim bounding box (without actually trimming)
2334 % %# CALCULATED: 'signature' hash of image values
2336 % This routine only handles specifically known properties. It does not
2337 % handle special prefixed properties, profiles, or expressions. Nor does
2338 % it return any free-form property strings.
2340 % The returned string is stored in a structure somewhere, and should not be
2341 % directly freed. If the string was generated (common) the string will be
2342 % stored as as either as artifact or option 'get-property'. These may be
2343 % deleted (cleaned up) when no longer required, but neither artifact or
2344 % option is guranteed to exist.
2346 % The format of the GetMagickProperty method is:
2348 % const char *GetMagickProperty(ImageInfo *image_info,Image *image,
2349 % const char *property,ExceptionInfo *exception)
2351 % A description of each parameter follows:
2353 % o image_info: the image info (optional)
2355 % o image: the image (optional)
2359 % o exception: return any errors or warnings in this structure.
2362 static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2363 Image *image,const char letter,ExceptionInfo *exception)
2365 #define WarnNoImageReturn(format,arg) \
2366 if (image == (Image *) NULL ) { \
2367 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2368 "NoImageForProperty",format,arg); \
2369 return((const char *) NULL); \
2371 #define WarnNoImageInfoReturn(format,arg) \
2372 if (image_info == (ImageInfo *) NULL ) { \
2373 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2374 "NoImageInfoForProperty",format,arg); \
2375 return((const char *) NULL); \
2379 value[MagickPathExtent]; /* formatted string to store as an artifact */
2382 *string; /* return a string already stored somewher */
2384 if ((image != (Image *) NULL) && (image->debug != MagickFalse))
2385 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2387 if ((image_info != (ImageInfo *) NULL) &&
2388 (image_info->debug != MagickFalse))
2389 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2390 *value='\0'; /* formatted string */
2391 string=(char *) NULL; /* constant string reference */
2393 Get properities that are directly defined by images.
2397 case 'b': /* image size read in - in bytes */
2399 WarnNoImageReturn("\"%%%c\"",letter);
2400 (void) FormatMagickSize(image->extent,MagickFalse,"B",MagickPathExtent,
2402 if (image->extent == 0)
2403 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
2404 MagickPathExtent,value);
2407 case 'c': /* image comment property - empty string by default */
2409 WarnNoImageReturn("\"%%%c\"",letter);
2410 string=GetImageProperty(image,"comment",exception);
2411 if ( string == (const char *) NULL )
2415 case 'd': /* Directory component of filename */
2417 WarnNoImageReturn("\"%%%c\"",letter);
2418 GetPathComponent(image->magick_filename,HeadPath,value);
2423 case 'e': /* Filename extension (suffix) of image file */
2425 WarnNoImageReturn("\"%%%c\"",letter);
2426 GetPathComponent(image->magick_filename,ExtensionPath,value);
2431 case 'f': /* Filename without directory component */
2433 WarnNoImageReturn("\"%%%c\"",letter);
2434 GetPathComponent(image->magick_filename,TailPath,value);
2439 case 'g': /* Image geometry, canvas and offset %Wx%H+%X+%Y */
2441 WarnNoImageReturn("\"%%%c\"",letter);
2442 (void) FormatLocaleString(value,MagickPathExtent,
2443 "%.20gx%.20g%+.20g%+.20g",(double) image->page.width,(double)
2444 image->page.height,(double) image->page.x,(double) image->page.y);
2447 case 'h': /* Image height (current) */
2449 WarnNoImageReturn("\"%%%c\"",letter);
2450 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2451 (image->rows != 0 ? image->rows : image->magick_rows));
2454 case 'i': /* Filename last used for an image (read or write) */
2456 WarnNoImageReturn("\"%%%c\"",letter);
2457 string=image->filename;
2460 case 'k': /* Number of unique colors */
2463 FUTURE: ensure this does not generate the formatted comment!
2465 WarnNoImageReturn("\"%%%c\"",letter);
2466 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2467 GetNumberColors(image,(FILE *) NULL,exception));
2470 case 'l': /* Image label property - empty string by default */
2472 WarnNoImageReturn("\"%%%c\"",letter);
2473 string=GetImageProperty(image,"label",exception);
2474 if (string == (const char *) NULL)
2478 case 'm': /* Image format (file magick) */
2480 WarnNoImageReturn("\"%%%c\"",letter);
2481 string=image->magick;
2484 case 'n': /* Number of images in the list. */
2486 if ( image != (Image *) NULL )
2487 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2488 GetImageListLength(image));
2490 string="0"; /* no images or scenes */
2493 case 'o': /* Output Filename - for delegate use only */
2494 WarnNoImageInfoReturn("\"%%%c\"",letter);
2495 string=image_info->filename;
2497 case 'p': /* Image index in current image list */
2499 WarnNoImageReturn("\"%%%c\"",letter);
2500 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2501 GetImageIndexInList(image));
2504 case 'q': /* Quantum depth of image in memory */
2506 WarnNoImageReturn("\"%%%c\"",letter);
2507 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2508 MAGICKCORE_QUANTUM_DEPTH);
2511 case 'r': /* Image storage class, colorspace, and alpha enabled. */
2516 WarnNoImageReturn("\"%%%c\"",letter);
2517 colorspace=image->colorspace;
2518 if (SetImageGray(image,exception) != MagickFalse)
2519 colorspace=GRAYColorspace; /* FUTURE: this is IMv6 not IMv7 */
2520 (void) FormatLocaleString(value,MagickPathExtent,"%s %s %s",
2521 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2522 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2523 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2527 case 's': /* Image scene number */
2529 #if 0 /* this seems non-sensical -- simplifing */
2530 if (image_info->number_scenes != 0)
2531 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2533 else if (image != (Image *) NULL)
2534 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2539 WarnNoImageReturn("\"%%%c\"",letter);
2540 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2545 case 't': /* Base filename without directory or extention */
2547 WarnNoImageReturn("\"%%%c\"",letter);
2548 GetPathComponent(image->magick_filename,BasePath,value);
2553 case 'u': /* Unique filename */
2555 WarnNoImageInfoReturn("\"%%%c\"",letter);
2556 string=image_info->unique;
2559 case 'w': /* Image width (current) */
2561 WarnNoImageReturn("\"%%%c\"",letter);
2562 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2563 (image->columns != 0 ? image->columns : image->magick_columns));
2566 case 'x': /* Image horizontal resolution (with units) */
2568 WarnNoImageReturn("\"%%%c\"",letter);
2569 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2570 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x : 72.0);
2573 case 'y': /* Image vertical resolution (with units) */
2575 WarnNoImageReturn("\"%%%c\"",letter);
2576 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2577 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y : 72.0);
2580 case 'z': /* Image depth as read in */
2582 WarnNoImageReturn("\"%%%c\"",letter);
2583 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2587 case 'A': /* Image alpha channel */
2589 WarnNoImageReturn("\"%%%c\"",letter);
2590 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2591 image->alpha_trait);
2594 case 'C': /* Image compression method. */
2596 WarnNoImageReturn("\"%%%c\"",letter);
2597 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2598 image->compression);
2601 case 'D': /* Image dispose method. */
2603 WarnNoImageReturn("\"%%%c\"",letter);
2604 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2608 case 'G': /* Image size as geometry = "%wx%h" */
2610 WarnNoImageReturn("\"%%%c\"",letter);
2611 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",(double)
2612 image->magick_columns,(double) image->magick_rows);
2615 case 'H': /* layer canvas height */
2617 WarnNoImageReturn("\"%%%c\"",letter);
2618 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2619 image->page.height);
2622 case 'M': /* Magick filename - filename given incl. coder & read mods */
2624 WarnNoImageReturn("\"%%%c\"",letter);
2625 string=image->magick_filename;
2628 case 'O': /* layer canvas offset with sign = "+%X+%Y" */
2630 WarnNoImageReturn("\"%%%c\"",letter);
2631 (void) FormatLocaleString(value,MagickPathExtent,"%+ld%+ld",(long)
2632 image->page.x,(long) image->page.y);
2635 case 'P': /* layer canvas page size = "%Wx%H" */
2637 WarnNoImageReturn("\"%%%c\"",letter);
2638 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",(double)
2639 image->page.width,(double) image->page.height);
2642 case 'Q': /* image compression quality */
2644 WarnNoImageReturn("\"%%%c\"",letter);
2645 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2646 (image->quality == 0 ? 92 : image->quality));
2649 case 'S': /* Number of scenes in image list. */
2651 WarnNoImageInfoReturn("\"%%%c\"",letter);
2652 #if 0 /* What is this number? -- it makes no sense - simplifing */
2653 if (image_info->number_scenes == 0)
2654 string="2147483647";
2655 else if ( image != (Image *) NULL )
2656 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2657 image_info->scene+image_info->number_scenes);
2661 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2662 (image_info->number_scenes == 0 ? 2147483647 :
2663 image_info->number_scenes));
2667 case 'T': /* image time delay for animations */
2669 WarnNoImageReturn("\"%%%c\"",letter);
2670 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2674 case 'U': /* Image resolution units. */
2676 WarnNoImageReturn("\"%%%c\"",letter);
2677 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2681 case 'W': /* layer canvas width */
2683 WarnNoImageReturn("\"%%%c\"",letter);
2684 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2688 case 'X': /* layer canvas X offset */
2690 WarnNoImageReturn("\"%%%c\"",letter);
2691 (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2695 case 'Y': /* layer canvas Y offset */
2697 WarnNoImageReturn("\"%%%c\"",letter);
2698 (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2702 case '%': /* percent escaped */
2707 case '@': /* Trim bounding box, without actually Trimming! */
2712 WarnNoImageReturn("\"%%%c\"",letter);
2713 page=GetImageBoundingBox(image,exception);
2714 (void) FormatLocaleString(value,MagickPathExtent,
2715 "%.20gx%.20g%+.20g%+.20g",(double) page.width,(double) page.height,
2716 (double) page.x,(double)page.y);
2724 WarnNoImageReturn("\"%%%c\"",letter);
2725 (void) SignatureImage(image,exception);
2726 string=GetImageProperty(image,"signature",exception);
2730 if (string != (char *) NULL)
2735 Create a cloned copy of result.
2737 if (image != (Image *) NULL)
2739 (void) SetImageArtifact(image,"get-property",value);
2740 return(GetImageArtifact(image,"get-property"));
2744 (void) SetImageOption(image_info,"get-property",value);
2745 return(GetImageOption(image_info,"get-property"));
2748 return((char *) NULL);
2751 MagickExport const char *GetMagickProperty(ImageInfo *image_info,
2752 Image *image,const char *property,ExceptionInfo *exception)
2755 value[MagickPathExtent];
2760 assert(property[0] != '\0');
2761 assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2762 if (property[1] == '\0') /* single letter property request */
2763 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2764 if ((image != (Image *) NULL) && (image->debug != MagickFalse))
2765 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2767 if ((image_info != (ImageInfo *) NULL) &&
2768 (image_info->debug != MagickFalse))
2769 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2770 *value='\0'; /* formated string */
2771 string=(char *) NULL; /* constant string reference */
2776 if (LocaleCompare("basename",property) == 0)
2778 WarnNoImageReturn("\"%%[%s]\"",property);
2779 GetPathComponent(image->magick_filename,BasePath,value);
2784 if (LocaleCompare("bit-depth",property) == 0)
2786 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2787 GetImageDepth(image,exception));
2794 if (LocaleCompare("channels",property) == 0)
2796 WarnNoImageReturn("\"%%[%s]\"",property);
2797 /* FUTURE: return actual image channels */
2798 (void) FormatLocaleString(value,MagickPathExtent,"%s",
2799 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2800 image->colorspace));
2802 if( image->alpha_trait != UndefinedPixelTrait )
2803 (void) ConcatenateMagickString(value,"a",MagickPathExtent);
2806 if (LocaleCompare("colorspace",property) == 0)
2808 WarnNoImageReturn("\"%%[%s]\"",property);
2809 /* FUTURE: return actual colorspace - no 'gray' stuff */
2810 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2814 if (LocaleCompare("compose",property) == 0)
2816 WarnNoImageReturn("\"%%[%s]\"",property);
2817 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2821 if (LocaleCompare("copyright",property) == 0)
2823 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
2830 if (LocaleCompare("depth",property) == 0)
2832 WarnNoImageReturn("\"%%[%s]\"",property);
2833 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2837 if (LocaleCompare("directory",property) == 0)
2839 WarnNoImageReturn("\"%%[%s]\"",property);
2840 GetPathComponent(image->magick_filename,HeadPath,value);
2849 if (LocaleCompare("entropy",property) == 0)
2854 WarnNoImageReturn("\"%%[%s]\"",property);
2855 (void) GetImageEntropy(image,&entropy,exception);
2856 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2857 GetMagickPrecision(),entropy);
2860 if (LocaleCompare("extension",property) == 0)
2862 WarnNoImageReturn("\"%%[%s]\"",property);
2863 GetPathComponent(image->magick_filename,ExtensionPath,value);
2872 if (LocaleCompare("gamma",property) == 0)
2874 WarnNoImageReturn("\"%%[%s]\"",property);
2875 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2876 GetMagickPrecision(),image->gamma);
2883 if (LocaleCompare("height",property) == 0)
2885 WarnNoImageReturn("\"%%[%s]\"",property);
2886 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2887 image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2894 if (LocaleCompare("input",property) == 0)
2896 WarnNoImageReturn("\"%%[%s]\"",property);
2897 string=image->filename;
2904 if (LocaleCompare("kurtosis",property) == 0)
2910 WarnNoImageReturn("\"%%[%s]\"",property);
2911 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
2912 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2913 GetMagickPrecision(),kurtosis);
2920 if (LocaleCompare("magick",property) == 0)
2922 WarnNoImageReturn("\"%%[%s]\"",property);
2923 string=image->magick;
2926 if ((LocaleCompare("maxima",property) == 0) ||
2927 (LocaleCompare("max",property) == 0))
2933 WarnNoImageReturn("\"%%[%s]\"",property);
2934 (void) GetImageRange(image,&minimum,&maximum,exception);
2935 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2936 GetMagickPrecision(),maximum);
2939 if (LocaleCompare("mean",property) == 0)
2945 WarnNoImageReturn("\"%%[%s]\"",property);
2946 (void) GetImageMean(image,&mean,&standard_deviation,exception);
2947 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2948 GetMagickPrecision(),mean);
2951 if ((LocaleCompare("minima",property) == 0) ||
2952 (LocaleCompare("min",property) == 0))
2958 WarnNoImageReturn("\"%%[%s]\"",property);
2959 (void) GetImageRange(image,&minimum,&maximum,exception);
2960 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2961 GetMagickPrecision(),minimum);
2968 if (LocaleCompare("opaque",property) == 0)
2970 WarnNoImageReturn("\"%%[%s]\"",property);
2971 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
2972 IsImageOpaque(image,exception));
2975 if (LocaleCompare("orientation",property) == 0)
2977 WarnNoImageReturn("\"%%[%s]\"",property);
2978 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
2979 image->orientation);
2982 if (LocaleCompare("output",property) == 0)
2984 WarnNoImageInfoReturn("\"%%[%s]\"",property);
2985 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
2992 #if defined(MAGICKCORE_LCMS_DELEGATE)
2993 if (LocaleCompare("profile:icc",property) == 0 ||
2994 LocaleCompare("profile:icm",property) == 0)
2996 #if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
2997 #define cmsUInt32Number DWORD
3006 profile=GetImageProfile(image,property+8);
3007 if (profile == (StringInfo *) NULL)
3009 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3010 (cmsUInt32Number) GetStringInfoLength(profile));
3011 if (icc_profile != (cmsHPROFILE *) NULL)
3013 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3014 string=cmsTakeProductName(icc_profile);
3016 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3017 "en","US",value,MagickPathExtent);
3019 (void) cmsCloseProfile(icc_profile);
3023 if (LocaleCompare("profiles",property) == 0)
3028 ResetImageProfileIterator(image);
3029 name=GetNextImageProfile(image);
3030 if (name != (char *) NULL)
3032 (void) CopyMagickString(value,name,MagickPathExtent);
3033 name=GetNextImageProfile(image);
3034 while (name != (char *) NULL)
3036 ConcatenateMagickString(value,",",MagickPathExtent);
3037 ConcatenateMagickString(value,name,MagickPathExtent);
3038 name=GetNextImageProfile(image);
3047 if (LocaleCompare("resolution.x",property) == 0)
3049 WarnNoImageReturn("\"%%[%s]\"",property);
3050 (void) FormatLocaleString(value,MagickPathExtent,"%g",
3051 image->resolution.x);
3054 if (LocaleCompare("resolution.y",property) == 0)
3056 WarnNoImageReturn("\"%%[%s]\"",property);
3057 (void) FormatLocaleString(value,MagickPathExtent,"%g",
3058 image->resolution.y);
3065 if (LocaleCompare("scene",property) == 0)
3067 WarnNoImageInfoReturn("\"%%[%s]\"",property);
3068 if (image_info->number_scenes != 0)
3069 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3072 WarnNoImageReturn("\"%%[%s]\"",property);
3073 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3078 if (LocaleCompare("scenes",property) == 0)
3080 /* FUTURE: equivelent to %n? */
3081 WarnNoImageReturn("\"%%[%s]\"",property);
3082 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3083 GetImageListLength(image));
3086 if (LocaleCompare("size",property) == 0)
3088 WarnNoImageReturn("\"%%[%s]\"",property);
3089 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
3090 MagickPathExtent,value);
3093 if (LocaleCompare("skewness",property) == 0)
3099 WarnNoImageReturn("\"%%[%s]\"",property);
3100 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3101 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
3102 GetMagickPrecision(),skewness);
3105 if (LocaleCompare("standard-deviation",property) == 0)
3111 WarnNoImageReturn("\"%%[%s]\"",property);
3112 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3113 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
3114 GetMagickPrecision(),standard_deviation);
3121 if (LocaleCompare("type",property) == 0)
3123 WarnNoImageReturn("\"%%[%s]\"",property);
3124 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3125 IdentifyImageType(image,exception));
3132 if (LocaleCompare("unique",property) == 0)
3134 WarnNoImageInfoReturn("\"%%[%s]\"",property);
3135 string=image_info->unique;
3138 if (LocaleCompare("units",property) == 0)
3140 WarnNoImageReturn("\"%%[%s]\"",property);
3141 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3149 if (LocaleCompare("version",property) == 0)
3151 string=GetMagickVersion((size_t *) NULL);
3158 if (LocaleCompare("width",property) == 0)
3160 WarnNoImageReturn("\"%%[%s]\"",property);
3161 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3162 (image->magick_columns != 0 ? image->magick_columns : 256));
3168 if (string != (char *) NULL)
3173 Create a cloned copy of result, that will get cleaned up, eventually.
3175 if (image != (Image *) NULL)
3177 (void) SetImageArtifact(image,"get-property",value);
3178 return(GetImageArtifact(image,"get-property"));
3182 (void) SetImageOption(image_info,"get-property",value);
3183 return(GetImageOption(image_info,"get-property"));
3186 return((char *) NULL);
3188 #undef WarnNoImageReturn
3191 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3195 % G e t N e x t I m a g e P r o p e r t y %
3199 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3201 % GetNextImageProperty() gets the next free-form string property name.
3203 % The format of the GetNextImageProperty method is:
3205 % char *GetNextImageProperty(const Image *image)
3207 % A description of each parameter follows:
3209 % o image: the image.
3212 MagickExport const char *GetNextImageProperty(const Image *image)
3214 assert(image != (Image *) NULL);
3215 assert(image->signature == MagickCoreSignature);
3216 if (image->debug != MagickFalse)
3217 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3219 if (image->properties == (void *) NULL)
3220 return((const char *) NULL);
3221 return((const char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3225 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3229 % I n t e r p r e t I m a g e P r o p e r t i e s %
3233 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3235 % InterpretImageProperties() replaces any embedded formatting characters with
3236 % the appropriate image property and returns the interpreted text.
3238 % This searches for and replaces
3239 % \n \r \% replaced by newline, return, and percent resp.
3240 % < > & replaced by '<', '>', '&' resp.
3241 % %% replaced by percent
3243 % %x %[x] where 'x' is a single letter properity, case sensitive).
3244 % %[type:name] where 'type' a is special and known prefix.
3245 % %[name] where 'name' is a specifically known attribute, calculated
3246 % value, or a per-image property string name, or a per-image
3247 % 'artifact' (as generated from a global option).
3248 % It may contain ':' as long as the prefix is not special.
3250 % Single letter % substitutions will only happen if the character before the
3251 % percent is NOT a number. But braced substitutions will always be performed.
3252 % This prevents the typical usage of percent in a interpreted geometry
3253 % argument from being substituted when the percent is a geometry flag.
3255 % If 'glob-expresions' ('*' or '?' characters) is used for 'name' it may be
3256 % used as a search pattern to print multiple lines of "name=value\n" pairs of
3257 % the associacted set of properties.
3259 % The returned string must be freed using DestoryString() by the caller.
3261 % The format of the InterpretImageProperties method is:
3263 % char *InterpretImageProperties(ImageInfo *image_info,
3264 % Image *image,const char *embed_text,ExceptionInfo *exception)
3266 % A description of each parameter follows:
3268 % o image_info: the image info. (required)
3270 % o image: the image. (optional)
3272 % o embed_text: the address of a character string containing the embedded
3273 % formatting characters.
3275 % o exception: return any errors or warnings in this structure.
3278 MagickExport char *InterpretImageProperties(ImageInfo *image_info,Image *image,
3279 const char *embed_text,ExceptionInfo *exception)
3281 #define ExtendInterpretText(string_length) \
3282 DisableMSCWarning(4127) \
3284 size_t length=(string_length); \
3285 if ((size_t) (q-interpret_text+length+1) >= extent) \
3288 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3289 MaxTextExtent,sizeof(*interpret_text)); \
3290 if (interpret_text == (char *) NULL) \
3291 return((char *) NULL); \
3292 q=interpret_text+strlen(interpret_text); \
3297 #define AppendKeyValue2Text(key,value)\
3298 DisableMSCWarning(4127) \
3300 size_t length=strlen(key)+strlen(value)+2; \
3301 if ((size_t) (q-interpret_text+length+1) >= extent) \
3304 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3305 MaxTextExtent,sizeof(*interpret_text)); \
3306 if (interpret_text == (char *) NULL) \
3307 return((char *) NULL); \
3308 q=interpret_text+strlen(interpret_text); \
3310 q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3314 #define AppendString2Text(string) \
3315 DisableMSCWarning(4127) \
3317 size_t length=strlen((string)); \
3318 if ((size_t) (q-interpret_text+length+1) >= extent) \
3321 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3322 MaxTextExtent,sizeof(*interpret_text)); \
3323 if (interpret_text == (char *) NULL) \
3324 return((char *) NULL); \
3325 q=interpret_text+strlen(interpret_text); \
3327 (void) CopyMagickString(q,(string),extent); \
3339 *q; /* current position in interpret_text */
3342 *p; /* position in embed_text string being expanded */
3345 extent; /* allocated length of interpret_text */
3347 assert(image == NULL || image->signature == MagickCoreSignature);
3348 assert(image_info == NULL || image_info->signature == MagickCoreSignature);
3349 if ((image != (Image *) NULL) && (image->debug != MagickFalse))
3350 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3352 if ((image_info != (ImageInfo *) NULL) && (image_info->debug != MagickFalse))
3353 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-image");
3354 if (embed_text == (const char *) NULL)
3355 return(ConstantString(""));
3357 while ((isspace((int) ((unsigned char) *p)) != 0) && (*p != '\0'))
3360 return(ConstantString(""));
3361 if ((*p == '@') && (IsPathAccessible(p+1) != MagickFalse))
3364 Handle a '@' replace string from file.
3366 if (IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,p) == MagickFalse)
3369 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
3370 "NotAuthorized","`%s'",p);
3371 return(ConstantString(""));
3373 interpret_text=FileToString(p+1,~0UL,exception);
3374 if (interpret_text != (char *) NULL)
3375 return(interpret_text);
3378 Translate any embedded format characters.
3380 interpret_text=AcquireString(embed_text); /* new string with extra space */
3381 extent=MagickPathExtent; /* allocated space in string */
3382 number=MagickFalse; /* is last char a number? */
3383 for (q=interpret_text; *p!='\0'; number=isdigit(*p) ? MagickTrue : MagickFalse,p++)
3386 Look for the various escapes, (and handle other specials)
3389 ExtendInterpretText(MagickPathExtent);
3398 case 'r': /* convert to RETURN */
3404 case 'n': /* convert to NEWLINE */
3410 case '\n': /* EOL removal UNIX,MacOSX */
3415 case '\r': /* EOL removal DOS,Windows */
3418 if (*p == '\n') /* return-newline EOL */
3432 if (LocaleNCompare("<",p,4) == 0)
3438 if (LocaleNCompare(">",p,4) == 0)
3444 if (LocaleNCompare("&",p,5) == 0)
3454 break; /* continue to next set of handlers */
3457 *q++=(*p); /* any thing else is 'as normal' */
3461 p++; /* advance beyond the percent */
3463 Doubled Percent - or percent at end of string.
3465 if ((*p == '\0') || (*p == '\'') || (*p == '"'))
3473 Single letter escapes %c.
3480 if (number != MagickFalse)
3483 But only if not preceeded by a number!
3485 *q++='%'; /* do NOT substitute the percent */
3486 p--; /* back up one */
3489 string=GetMagickPropertyLetter(image_info,image,*p, exception);
3490 if (string != (char *) NULL)
3492 AppendString2Text(string);
3493 if (image != (Image *) NULL)
3494 (void) DeleteImageArtifact(image,"get-property");
3495 if (image_info != (ImageInfo *) NULL)
3496 (void) DeleteImageOption(image_info,"get-property");
3499 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3500 "UnknownImageProperty","\"%%%c\"",*p);
3505 pattern[2*MagickPathExtent];
3518 Braced Percent Escape %[...].
3520 p++; /* advance p to just inside the opening brace */
3524 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3525 "UnknownImageProperty","\"%%[]\"");
3528 for (len=0; len<(MagickPathExtent-1L) && (*p != '\0');)
3530 if ((*p == '\\') && (*(p+1) != '\0'))
3533 Skip escaped braces within braced pattern.
3535 pattern[len++]=(*p++);
3536 pattern[len++]=(*p++);
3545 pattern[len++]=(*p++);
3551 Check for unmatched final ']' for "%[...]".
3555 pattern[61] = '.'; /* truncate string for error message */
3560 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3561 "UnbalancedBraces","\"%%[%s\"",pattern);
3562 interpret_text=DestroyString(interpret_text);
3563 return((char *) NULL);
3566 Special Lookup Prefixes %[prefix:...].
3568 if (LocaleNCompare("fx:",pattern,3) == 0)
3580 FX - value calculator.
3582 if (image == (Image *) NULL )
3584 (void) ThrowMagickException(exception,GetMagickModule(),
3585 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3586 continue; /* else no image to retrieve artifact */
3588 fx_info=AcquireFxInfo(image,pattern+3,exception);
3589 status=FxEvaluateChannelExpression(fx_info,IntensityPixelChannel,0,0,
3591 fx_info=DestroyFxInfo(fx_info);
3592 if (status != MagickFalse)
3595 result[MagickPathExtent];
3597 (void) FormatLocaleString(result,MagickPathExtent,"%.*g",
3598 GetMagickPrecision(),(double) value);
3599 AppendString2Text(result);
3603 if (LocaleNCompare("hex:",pattern,4) == 0)
3618 Pixel - color value calculator.
3620 if (image == (Image *) NULL)
3622 (void) ThrowMagickException(exception,GetMagickModule(),
3623 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3624 continue; /* else no image to retrieve artifact */
3626 GetPixelInfo(image,&pixel);
3627 fx_info=AcquireFxInfo(image,pattern+4,exception);
3628 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
3630 pixel.red=(double) QuantumRange*value;
3631 status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
3633 pixel.green=(double) QuantumRange*value;
3634 status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
3636 pixel.blue=(double) QuantumRange*value;
3637 if (image->colorspace == CMYKColorspace)
3639 status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
3641 pixel.black=(double) QuantumRange*value;
3643 status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
3645 pixel.alpha=(double) QuantumRange*value;
3646 fx_info=DestroyFxInfo(fx_info);
3647 if (status != MagickFalse)
3650 hex[MagickPathExtent],
3651 name[MagickPathExtent];
3653 (void) QueryColorname(image,&pixel,SVGCompliance,name,exception);
3654 GetColorTuple(&pixel,MagickTrue,hex);
3655 AppendString2Text(hex+1);
3659 if (LocaleNCompare("pixel:",pattern,6) == 0)
3674 Pixel - color value calculator.
3676 if (image == (Image *) NULL)
3678 (void) ThrowMagickException(exception,GetMagickModule(),
3679 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3680 continue; /* else no image to retrieve artifact */
3682 GetPixelInfo(image,&pixel);
3683 fx_info=AcquireFxInfo(image,pattern+6,exception);
3684 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
3686 pixel.red=(double) QuantumRange*value;
3687 status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
3689 pixel.green=(double) QuantumRange*value;
3690 status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
3692 pixel.blue=(double) QuantumRange*value;
3693 if (image->colorspace == CMYKColorspace)
3695 status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
3697 pixel.black=(double) QuantumRange*value;
3699 status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
3701 pixel.alpha=(double) QuantumRange*value;
3702 fx_info=DestroyFxInfo(fx_info);
3703 if (status != MagickFalse)
3706 name[MagickPathExtent];
3708 (void) QueryColorname(image,&pixel,SVGCompliance,name,exception);
3709 AppendString2Text(name);
3713 if (LocaleNCompare("option:",pattern,7) == 0)
3716 Option - direct global option lookup (with globbing).
3718 if (image_info == (ImageInfo *) NULL )
3720 (void) ThrowMagickException(exception,GetMagickModule(),
3721 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3722 continue; /* else no image to retrieve artifact */
3724 if (IsGlob(pattern+7) != MagickFalse)
3726 ResetImageOptionIterator(image_info);
3727 while ((key=GetNextImageOption(image_info)) != (const char *) NULL)
3728 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
3730 string=GetImageOption(image_info,key);
3731 if (string != (const char *) NULL)
3732 AppendKeyValue2Text(key,string);
3733 /* else - assertion failure? key found but no string value! */
3737 string=GetImageOption(image_info,pattern+7);
3738 if (string == (char *) NULL)
3739 goto PropertyLookupFailure; /* no artifact of this specifc name */
3740 AppendString2Text(string);
3743 if (LocaleNCompare("artifact:",pattern,9) == 0)
3746 Artifact - direct image artifact lookup (with glob).
3748 if (image == (Image *) NULL)
3750 (void) ThrowMagickException(exception,GetMagickModule(),
3751 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3752 continue; /* else no image to retrieve artifact */
3754 if (IsGlob(pattern+9) != MagickFalse)
3756 ResetImageArtifactIterator(image);
3757 while ((key=GetNextImageArtifact(image)) != (const char *) NULL)
3758 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
3760 string=GetImageArtifact(image,key);
3761 if (string != (const char *) NULL)
3762 AppendKeyValue2Text(key,string);
3763 /* else - assertion failure? key found but no string value! */
3767 string=GetImageArtifact(image,pattern+9);
3768 if (string == (char *) NULL)
3769 goto PropertyLookupFailure; /* no artifact of this specifc name */
3770 AppendString2Text(string);
3773 if (LocaleNCompare("property:",pattern,9) == 0)
3776 Property - direct image property lookup (with glob).
3778 if (image == (Image *) NULL)
3780 (void) ThrowMagickException(exception,GetMagickModule(),
3781 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3782 continue; /* else no image to retrieve artifact */
3784 if (IsGlob(pattern+9) != MagickFalse)
3786 ResetImagePropertyIterator(image);
3787 while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3788 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3790 string=GetImageProperty(image,key,exception);
3791 if (string != (const char *) NULL)
3792 AppendKeyValue2Text(key,string);
3793 /* else - assertion failure? */
3797 string=GetImageProperty(image,pattern+9,exception);
3798 if (string == (char *) NULL)
3799 goto PropertyLookupFailure; /* no artifact of this specifc name */
3800 AppendString2Text(string);
3803 if (image != (Image *) NULL)
3806 Properties without special prefix. This handles attributes,
3807 properties, and profiles such as %[exif:...]. Note the profile
3808 properties may also include a glob expansion pattern.
3810 string=GetImageProperty(image,pattern,exception);
3811 if (string != (const char *) NULL)
3813 AppendString2Text(string);
3814 if (image != (Image *) NULL)
3815 (void)DeleteImageArtifact(image,"get-property");
3816 if (image_info != (ImageInfo *) NULL)
3817 (void)DeleteImageOption(image_info,"get-property");
3821 if (IsGlob(pattern) != MagickFalse)
3824 Handle property 'glob' patterns such as:
3825 %[*] %[user:array_??] %[filename:e*]>
3827 if (image == (Image *) NULL)
3828 continue; /* else no image to retrieve proprty - no list */
3829 ResetImagePropertyIterator(image);
3830 while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3831 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3833 string=GetImageProperty(image,key,exception);
3834 if (string != (const char *) NULL)
3835 AppendKeyValue2Text(key,string);
3836 /* else - assertion failure? */
3841 Look for a known property or image attribute such as
3842 %[basename] %[denisty] %[delay]. Also handles a braced single
3843 letter: %[b] %[G] %[g].
3845 string=GetMagickProperty(image_info,image,pattern,exception);
3846 if (string != (const char *) NULL)
3848 AppendString2Text(string);
3852 Look for a per-image artifact. This includes option lookup
3853 (FUTURE: interpreted according to image).
3855 if (image != (Image *) NULL)
3857 string=GetImageArtifact(image,pattern);
3858 if (string != (char *) NULL)
3860 AppendString2Text(string);
3865 if (image_info != (ImageInfo *) NULL)
3868 No image, so direct 'option' lookup (no delayed percent escapes).
3870 string=GetImageOption(image_info,pattern);
3871 if (string != (char *) NULL)
3873 AppendString2Text(string);
3877 PropertyLookupFailure:
3879 Failed to find any match anywhere!
3883 pattern[61] = '.'; /* truncate string for error message */
3888 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3889 "UnknownImageProperty","\"%%[%s]\"",pattern);
3893 return(interpret_text);
3897 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3901 % R e m o v e I m a g e P r o p e r t y %
3905 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3907 % RemoveImageProperty() removes a property from the image and returns its
3910 % In this case the ConstantString() value returned should be freed by the
3911 % caller when finished.
3913 % The format of the RemoveImageProperty method is:
3915 % char *RemoveImageProperty(Image *image,const char *property)
3917 % A description of each parameter follows:
3919 % o image: the image.
3921 % o property: the image property.
3924 MagickExport char *RemoveImageProperty(Image *image,const char *property)
3929 assert(image != (Image *) NULL);
3930 assert(image->signature == MagickCoreSignature);
3931 if (image->debug != MagickFalse)
3932 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3933 if (image->properties == (void *) NULL)
3934 return((char *) NULL);
3935 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3941 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3945 % 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 %
3949 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3951 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3952 % in conjunction with GetNextImageProperty() to iterate over all the values
3953 % associated with an image property.
3955 % The format of the ResetImagePropertyIterator method is:
3957 % ResetImagePropertyIterator(Image *image)
3959 % A description of each parameter follows:
3961 % o image: the image.
3964 MagickExport void ResetImagePropertyIterator(const Image *image)
3966 assert(image != (Image *) NULL);
3967 assert(image->signature == MagickCoreSignature);
3968 if (image->debug != MagickFalse)
3969 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3970 if (image->properties == (void *) NULL)
3972 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3976 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3980 % S e t I m a g e P r o p e r t y %
3984 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3986 % SetImageProperty() saves the given string value either to specific known
3987 % attribute or to a freeform property string.
3989 % Attempting to set a property that is normally calculated will produce
3992 % The format of the SetImageProperty method is:
3994 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3995 % const char *value,ExceptionInfo *exception)
3997 % A description of each parameter follows:
3999 % o image: the image.
4001 % o property: the image property.
4003 % o values: the image property values.
4005 % o exception: return any errors or warnings in this structure.
4008 MagickExport MagickBooleanType SetImageProperty(Image *image,
4009 const char *property,const char *value,ExceptionInfo *exception)
4017 assert(image != (Image *) NULL);
4018 assert(image->signature == MagickCoreSignature);
4019 if (image->debug != MagickFalse)
4020 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
4021 if (image->properties == (void *) NULL)
4022 image->properties=NewSplayTree(CompareSplayTreeString,
4023 RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */
4024 if (value == (const char *) NULL)
4025 return(DeleteImageProperty(image,property)); /* delete if NULL */
4027 if (strlen(property) <= 1)
4030 Do not 'set' single letter properties - read only shorthand.
4032 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4033 "SetReadOnlyProperty","`%s'",property);
4034 return(MagickFalse);
4037 /* FUTURE: binary chars or quotes in key should produce a error */
4038 /* Set attributes with known names or special prefixes
4039 return result is found, or break to set a free form properity
4043 #if 0 /* Percent escape's sets values with this prefix: for later use
4044 Throwing an exception causes this setting to fail */
4047 if (LocaleNCompare("8bim:",property,5) == 0)
4049 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4050 "SetReadOnlyProperty","`%s'",property);
4051 return(MagickFalse);
4059 if (LocaleCompare("background",property) == 0)
4061 (void) QueryColorCompliance(value,AllCompliance,
4062 &image->background_color,exception);
4063 /* check for FUTURE: value exception?? */
4064 /* also add user input to splay tree */
4066 break; /* not an attribute, add as a property */
4071 if (LocaleCompare("channels",property) == 0)
4073 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4074 "SetReadOnlyProperty","`%s'",property);
4075 return(MagickFalse);
4077 if (LocaleCompare("colorspace",property) == 0)
4082 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4085 return(MagickFalse); /* FUTURE: value exception?? */
4086 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4088 if (LocaleCompare("compose",property) == 0)
4093 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4095 return(MagickFalse); /* FUTURE: value exception?? */
4096 image->compose=(CompositeOperator) compose;
4099 if (LocaleCompare("compress",property) == 0)
4104 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4106 if (compression < 0)
4107 return(MagickFalse); /* FUTURE: value exception?? */
4108 image->compression=(CompressionType) compression;
4111 break; /* not an attribute, add as a property */
4116 if (LocaleCompare("delay",property) == 0)
4121 flags=ParseGeometry(value,&geometry_info);
4122 if ((flags & GreaterValue) != 0)
4124 if (image->delay > (size_t) floor(geometry_info.rho+0.5))
4125 image->delay=(size_t) floor(geometry_info.rho+0.5);
4128 if ((flags & LessValue) != 0)
4130 if (image->delay < (size_t) floor(geometry_info.rho+0.5))
4131 image->delay=(ssize_t)
4132 floor(geometry_info.sigma+0.5);
4135 image->delay=(size_t) floor(geometry_info.rho+0.5);
4136 if ((flags & SigmaValue) != 0)
4137 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
4140 if (LocaleCompare("delay_units",property) == 0)
4142 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4143 "SetReadOnlyProperty","`%s'",property);
4144 return(MagickFalse);
4146 if (LocaleCompare("density",property) == 0)
4151 flags=ParseGeometry(value,&geometry_info);
4152 image->resolution.x=geometry_info.rho;
4153 image->resolution.y=geometry_info.sigma;
4154 if ((flags & SigmaValue) == 0)
4155 image->resolution.y=image->resolution.x;
4158 if (LocaleCompare("depth",property) == 0)
4160 image->depth=StringToUnsignedLong(value);
4163 if (LocaleCompare("dispose",property) == 0)
4168 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4170 return(MagickFalse); /* FUTURE: value exception?? */
4171 image->dispose=(DisposeType) dispose;
4174 break; /* not an attribute, add as a property */
4176 #if 0 /* Percent escape's sets values with this prefix: for later use
4177 Throwing an exception causes this setting to fail */
4181 if (LocaleNCompare("exif:",property,5) == 0)
4183 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4184 "SetReadOnlyProperty","`%s'",property);
4185 return(MagickFalse);
4187 break; /* not an attribute, add as a property */
4192 if (LocaleNCompare("fx:",property,3) == 0)
4194 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4195 "SetReadOnlyProperty","`%s'",property);
4196 return(MagickFalse);
4198 break; /* not an attribute, add as a property */
4204 if (LocaleCompare("gamma",property) == 0)
4206 image->gamma=StringToDouble(value,(char **) NULL);
4209 if (LocaleCompare("gravity",property) == 0)
4214 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4216 return(MagickFalse); /* FUTURE: value exception?? */
4217 image->gravity=(GravityType) gravity;
4220 break; /* not an attribute, add as a property */
4225 if (LocaleCompare("height",property) == 0)
4227 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4228 "SetReadOnlyProperty","`%s'",property);
4229 return(MagickFalse);
4231 break; /* not an attribute, add as a property */
4236 if (LocaleCompare("intensity",property) == 0)
4241 intensity=ParseCommandOption(MagickIntentOptions,MagickFalse,value);
4243 return(MagickFalse);
4244 image->intensity=(PixelIntensityMethod) intensity;
4247 if (LocaleCompare("intent",property) == 0)
4252 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4254 if (rendering_intent < 0)
4255 return(MagickFalse); /* FUTURE: value exception?? */
4256 image->rendering_intent=(RenderingIntent) rendering_intent;
4259 if (LocaleCompare("interpolate",property) == 0)
4264 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4266 if (interpolate < 0)
4267 return(MagickFalse); /* FUTURE: value exception?? */
4268 image->interpolate=(PixelInterpolateMethod) interpolate;
4271 #if 0 /* Percent escape's sets values with this prefix: for later use
4272 Throwing an exception causes this setting to fail */
4273 if (LocaleNCompare("iptc:",property,5) == 0)
4275 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4276 "SetReadOnlyProperty","`%s'",property);
4277 return(MagickFalse);
4280 break; /* not an attribute, add as a property */
4284 if (LocaleCompare("kurtosis",property) == 0)
4286 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4287 "SetReadOnlyProperty","`%s'",property);
4288 return(MagickFalse);
4290 break; /* not an attribute, add as a property */
4294 if (LocaleCompare("loop",property) == 0)
4296 image->iterations=StringToUnsignedLong(value);
4299 break; /* not an attribute, add as a property */
4303 if ((LocaleCompare("magick",property) == 0) ||
4304 (LocaleCompare("max",property) == 0) ||
4305 (LocaleCompare("mean",property) == 0) ||
4306 (LocaleCompare("min",property) == 0) ||
4307 (LocaleCompare("min",property) == 0))
4309 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4310 "SetReadOnlyProperty","`%s'",property);
4311 return(MagickFalse);
4313 break; /* not an attribute, add as a property */
4316 if (LocaleCompare("opaque",property) == 0)
4318 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4319 "SetReadOnlyProperty","`%s'",property);
4320 return(MagickFalse);
4322 break; /* not an attribute, add as a property */
4326 if (LocaleCompare("page",property) == 0)
4331 geometry=GetPageGeometry(value);
4332 flags=ParseAbsoluteGeometry(geometry,&image->page);
4333 geometry=DestroyString(geometry);
4336 #if 0 /* Percent escape's sets values with this prefix: for later use
4337 Throwing an exception causes this setting to fail */
4338 if (LocaleNCompare("pixel:",property,6) == 0)
4340 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4341 "SetReadOnlyProperty","`%s'",property);
4342 return(MagickFalse);
4345 if (LocaleCompare("profile",property) == 0)
4353 image_info=AcquireImageInfo();
4354 (void) CopyMagickString(image_info->filename,value,MagickPathExtent);
4355 (void) SetImageInfo(image_info,1,exception);
4356 profile=FileToStringInfo(image_info->filename,~0UL,exception);
4357 if (profile != (StringInfo *) NULL)
4358 status=SetImageProfile(image,image_info->magick,profile,exception);
4359 image_info=DestroyImageInfo(image_info);
4362 break; /* not an attribute, add as a property */
4367 if (LocaleCompare("rendering-intent",property) == 0)
4372 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4374 if (rendering_intent < 0)
4375 return(MagickFalse); /* FUTURE: value exception?? */
4376 image->rendering_intent=(RenderingIntent) rendering_intent;
4379 break; /* not an attribute, add as a property */
4383 if ((LocaleCompare("size",property) == 0) ||
4384 (LocaleCompare("skewness",property) == 0) ||
4385 (LocaleCompare("scenes",property) == 0) ||
4386 (LocaleCompare("standard-deviation",property) == 0))
4388 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4389 "SetReadOnlyProperty","`%s'",property);
4390 return(MagickFalse);
4392 break; /* not an attribute, add as a property */
4396 if (LocaleCompare("tile-offset",property) == 0)
4401 geometry=GetPageGeometry(value);
4402 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4403 geometry=DestroyString(geometry);
4406 break; /* not an attribute, add as a property */
4411 if (LocaleCompare("units",property) == 0)
4416 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4418 return(MagickFalse); /* FUTURE: value exception?? */
4419 image->units=(ResolutionType) units;
4422 break; /* not an attribute, add as a property */
4427 if (LocaleCompare("version",property) == 0)
4429 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4430 "SetReadOnlyProperty","`%s'",property);
4431 return(MagickFalse);
4433 break; /* not an attribute, add as a property */
4438 if (LocaleCompare("width",property) == 0)
4440 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4441 "SetReadOnlyProperty","`%s'",property);
4442 return(MagickFalse);
4444 break; /* not an attribute, add as a property */
4446 #if 0 /* Percent escape's sets values with this prefix: for later use
4447 Throwing an exception causes this setting to fail */
4451 if (LocaleNCompare("xmp:",property,4) == 0)
4453 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4454 "SetReadOnlyProperty","`%s'",property);
4455 return(MagickFalse);
4457 break; /* not an attribute, add as a property */
4461 /* Default: not an attribute, add as a property */
4462 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4463 ConstantString(property),ConstantString(value));
4464 /* FUTURE: error if status is bad? */