2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % PPPP RRRR OOO PPPP EEEEE RRRR TTTTT Y Y %
7 % P P R R O O P P E R R T Y Y %
8 % PPPP RRRR O O PPPP EEE RRRR T Y %
9 % P R R O O P E R R T Y %
10 % P R R OOO P EEEEE R R T Y %
13 % MagickCore Property Methods %
20 % Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "MagickCore/studio.h"
44 #include "MagickCore/artifact.h"
45 #include "MagickCore/attribute.h"
46 #include "MagickCore/cache.h"
47 #include "MagickCore/cache-private.h"
48 #include "MagickCore/color.h"
49 #include "MagickCore/color-private.h"
50 #include "MagickCore/colorspace-private.h"
51 #include "MagickCore/compare.h"
52 #include "MagickCore/constitute.h"
53 #include "MagickCore/draw.h"
54 #include "MagickCore/effect.h"
55 #include "MagickCore/exception.h"
56 #include "MagickCore/exception-private.h"
57 #include "MagickCore/fx.h"
58 #include "MagickCore/fx-private.h"
59 #include "MagickCore/gem.h"
60 #include "MagickCore/geometry.h"
61 #include "MagickCore/histogram.h"
62 #include "MagickCore/image.h"
63 #include "MagickCore/layer.h"
64 #include "MagickCore/locale-private.h"
65 #include "MagickCore/list.h"
66 #include "MagickCore/magick.h"
67 #include "MagickCore/memory_.h"
68 #include "MagickCore/monitor.h"
69 #include "MagickCore/montage.h"
70 #include "MagickCore/option.h"
71 #include "MagickCore/profile.h"
72 #include "MagickCore/property.h"
73 #include "MagickCore/quantum.h"
74 #include "MagickCore/resource_.h"
75 #include "MagickCore/splay-tree.h"
76 #include "MagickCore/signature.h"
77 #include "MagickCore/statistic.h"
78 #include "MagickCore/string_.h"
79 #include "MagickCore/string-private.h"
80 #include "MagickCore/token.h"
81 #include "MagickCore/token-private.h"
82 #include "MagickCore/utility.h"
83 #include "MagickCore/utility-private.h"
84 #include "MagickCore/version.h"
85 #include "MagickCore/xml-tree.h"
86 #include "MagickCore/xml-tree-private.h"
87 #if defined(MAGICKCORE_LCMS_DELEGATE)
88 #if defined(MAGICKCORE_HAVE_LCMS2_LCMS2_H)
89 #include <lcms2/lcms2.h>
90 #elif defined(MAGICKCORE_HAVE_LCMS2_H)
92 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
93 #include <lcms/lcms.h>
102 #if defined(MAGICKCORE_LCMS_DELEGATE)
103 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
104 #define cmsUInt32Number DWORD
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
113 % C l o n e I m a g e P r o p e r t i e s %
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
119 % CloneImageProperties() clones all the image properties to another image.
121 % The format of the CloneImageProperties method is:
123 % MagickBooleanType CloneImageProperties(Image *image,
124 % const Image *clone_image)
126 % A description of each parameter follows:
128 % o image: the image.
130 % o clone_image: the clone image.
133 MagickExport MagickBooleanType CloneImageProperties(Image *image,
134 const Image *clone_image)
136 assert(image != (Image *) NULL);
137 assert(image->signature == MagickCoreSignature);
138 if (image->debug != MagickFalse)
139 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
140 assert(clone_image != (const Image *) NULL);
141 assert(clone_image->signature == MagickCoreSignature);
142 if (clone_image->debug != MagickFalse)
143 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
144 clone_image->filename);
145 (void) CopyMagickString(image->filename,clone_image->filename,MagickPathExtent);
146 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
148 image->compression=clone_image->compression;
149 image->quality=clone_image->quality;
150 image->depth=clone_image->depth;
151 image->alpha_color=clone_image->alpha_color;
152 image->background_color=clone_image->background_color;
153 image->border_color=clone_image->border_color;
154 image->transparent_color=clone_image->transparent_color;
155 image->gamma=clone_image->gamma;
156 image->chromaticity=clone_image->chromaticity;
157 image->rendering_intent=clone_image->rendering_intent;
158 image->black_point_compensation=clone_image->black_point_compensation;
159 image->units=clone_image->units;
160 image->montage=(char *) NULL;
161 image->directory=(char *) NULL;
162 (void) CloneString(&image->geometry,clone_image->geometry);
163 image->offset=clone_image->offset;
164 image->resolution.x=clone_image->resolution.x;
165 image->resolution.y=clone_image->resolution.y;
166 image->page=clone_image->page;
167 image->tile_offset=clone_image->tile_offset;
168 image->extract_info=clone_image->extract_info;
169 image->filter=clone_image->filter;
170 image->fuzz=clone_image->fuzz;
171 image->intensity=clone_image->intensity;
172 image->interlace=clone_image->interlace;
173 image->interpolate=clone_image->interpolate;
174 image->endian=clone_image->endian;
175 image->gravity=clone_image->gravity;
176 image->compose=clone_image->compose;
177 image->orientation=clone_image->orientation;
178 image->scene=clone_image->scene;
179 image->dispose=clone_image->dispose;
180 image->delay=clone_image->delay;
181 image->ticks_per_second=clone_image->ticks_per_second;
182 image->iterations=clone_image->iterations;
183 image->total_colors=clone_image->total_colors;
184 image->taint=clone_image->taint;
185 image->progress_monitor=clone_image->progress_monitor;
186 image->client_data=clone_image->client_data;
187 image->start_loop=clone_image->start_loop;
188 image->error=clone_image->error;
189 image->signature=clone_image->signature;
190 if (clone_image->properties != (void *) NULL)
192 if (image->properties != (void *) NULL)
193 DestroyImageProperties(image);
194 image->properties=CloneSplayTree((SplayTreeInfo *)
195 clone_image->properties,(void *(*)(void *)) ConstantString,
196 (void *(*)(void *)) ConstantString);
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 % D e f i n e I m a g e P r o p e r t y %
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 % DefineImageProperty() associates an assignment string of the form
213 % "key=value" with an artifact or options. It is equivelent to
216 % The format of the DefineImageProperty method is:
218 % MagickBooleanType DefineImageProperty(Image *image,const char *property,
219 % ExceptionInfo *exception)
221 % A description of each parameter follows:
223 % o image: the image.
225 % o property: the image property.
227 % o exception: return any errors or warnings in this structure.
230 MagickExport MagickBooleanType DefineImageProperty(Image *image,
231 const char *property,ExceptionInfo *exception)
234 key[MagickPathExtent],
235 value[MagickPathExtent];
240 assert(image != (Image *) NULL);
241 assert(property != (const char *) NULL);
242 (void) CopyMagickString(key,property,MagickPathExtent-1);
243 for (p=key; *p != '\0'; p++)
248 (void) CopyMagickString(value,p+1,MagickPathExtent);
250 return(SetImageProperty(image,key,value,exception));
254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
258 % D e l e t e I m a g e P r o p e r t y %
262 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
264 % DeleteImageProperty() deletes an image property.
266 % The format of the DeleteImageProperty method is:
268 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
270 % A description of each parameter follows:
272 % o image: the image.
274 % o property: the image property.
277 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
278 const char *property)
280 assert(image != (Image *) NULL);
281 assert(image->signature == MagickCoreSignature);
282 if (image->debug != MagickFalse)
283 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
285 if (image->properties == (void *) NULL)
287 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
291 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295 % D e s t r o y I m a g e P r o p e r t i e s %
299 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301 % DestroyImageProperties() destroys all properties and associated memory
302 % attached to the given image.
304 % The format of the DestroyDefines method is:
306 % void DestroyImageProperties(Image *image)
308 % A description of each parameter follows:
310 % o image: the image.
313 MagickExport void DestroyImageProperties(Image *image)
315 assert(image != (Image *) NULL);
316 assert(image->signature == MagickCoreSignature);
317 if (image->debug != MagickFalse)
318 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
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 size_t ReadPropertyMSBLong(const unsigned char **p,
518 for (i=0; i < 4; i++)
522 buffer[i]=(unsigned char) c;
524 value=(size_t) (buffer[0] << 24);
525 value|=buffer[1] << 16;
526 value|=buffer[2] << 8;
528 return(value & 0xffffffff);
531 static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
547 return((unsigned short) ~0);
548 for (i=0; i < 2; i++)
552 buffer[i]=(unsigned char) c;
554 value=(unsigned short) (buffer[0] << 8);
556 return((unsigned short) (value & 0xffff));
559 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
560 ExceptionInfo *exception)
564 format[MagickPathExtent],
565 name[MagickPathExtent],
593 There are no newlines in path names, so it's safe as terminator.
595 profile=GetImageProfile(image,"8bim");
596 if (profile == (StringInfo *) NULL)
598 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
600 if ((count != 2) && (count != 3) && (count != 4))
603 (void) CopyMagickString(format,"SVG",MagickPathExtent);
608 sub_number=(ssize_t) StringToLong(&name[1]);
609 sub_number=MagickMax(sub_number,1L);
610 resource=(char *) NULL;
612 length=GetStringInfoLength(profile);
613 info=GetStringInfoDatum(profile);
614 while ((length > 0) && (status == MagickFalse))
616 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
618 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
620 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
622 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
624 id=(ssize_t) ((int) ReadPropertyMSBShort(&info,&length));
625 if (id < (ssize_t) start)
627 if (id > (ssize_t) stop)
629 if (resource != (char *) NULL)
630 resource=DestroyString(resource);
631 count=(ssize_t) ReadPropertyByte(&info,&length);
632 if ((count != 0) && ((size_t) count <= length))
634 resource=(char *) NULL;
635 if (~((size_t) count) >= (MagickPathExtent-1))
636 resource=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent,
638 if (resource != (char *) NULL)
640 for (i=0; i < (ssize_t) count; i++)
641 resource[i]=(char) ReadPropertyByte(&info,&length);
642 resource[count]='\0';
645 if ((count & 0x01) == 0)
646 (void) ReadPropertyByte(&info,&length);
647 count=(ssize_t) ((int) ReadPropertyMSBLong(&info,&length));
648 if ((*name != '\0') && (*name != '#'))
649 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
652 No name match, scroll forward and try next.
655 length-=MagickMin(count,(ssize_t) length);
658 if ((*name == '#') && (sub_number != 1))
661 No numbered match, scroll forward and try next.
665 length-=MagickMin(count,(ssize_t) length);
669 We have the resource of interest.
671 attribute=(char *) NULL;
672 if (~((size_t) count) >= (MagickPathExtent-1))
673 attribute=(char *) AcquireQuantumMemory((size_t) count+MagickPathExtent,
675 if (attribute != (char *) NULL)
677 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
678 attribute[count]='\0';
680 length-=MagickMin(count,(ssize_t) length);
681 if ((id <= 1999) || (id >= 2999))
682 (void) SetImageProperty((Image *) image,key,(const char *)
683 attribute,exception);
689 if (LocaleCompare(format,"svg") == 0)
690 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
691 image->columns,image->rows);
693 path=TracePSClippath((unsigned char *) attribute,(size_t) count);
694 (void) SetImageProperty((Image *) image,key,(const char *) path,
696 path=DestroyString(path);
698 attribute=DestroyString(attribute);
702 if (resource != (char *) NULL)
703 resource=DestroyString(resource);
707 static inline unsigned short ReadPropertyShort(const EndianType endian,
708 const unsigned char *buffer)
713 if (endian == LSBEndian)
715 value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
716 return((unsigned short) (value & 0xffff));
718 value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
719 ((unsigned char *) buffer)[1]);
720 return((unsigned short) (value & 0xffff));
723 static inline size_t ReadPropertyLong(const EndianType endian,
724 const unsigned char *buffer)
729 if (endian == LSBEndian)
731 value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
732 (buffer[1] << 8 ) | (buffer[0]));
733 return((size_t) (value & 0xffffffff));
735 value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
736 (buffer[2] << 8) | buffer[3]);
737 return((size_t) (value & 0xffffffff));
740 static MagickBooleanType GetEXIFProperty(const Image *image,
741 const char *property,ExceptionInfo *exception)
743 #define MaxDirectoryStack 16
744 #define EXIF_DELIMITER "\n"
745 #define EXIF_NUM_FORMATS 12
746 #define EXIF_FMT_BYTE 1
747 #define EXIF_FMT_STRING 2
748 #define EXIF_FMT_USHORT 3
749 #define EXIF_FMT_ULONG 4
750 #define EXIF_FMT_URATIONAL 5
751 #define EXIF_FMT_SBYTE 6
752 #define EXIF_FMT_UNDEFINED 7
753 #define EXIF_FMT_SSHORT 8
754 #define EXIF_FMT_SLONG 9
755 #define EXIF_FMT_SRATIONAL 10
756 #define EXIF_FMT_SINGLE 11
757 #define EXIF_FMT_DOUBLE 12
758 #define TAG_EXIF_OFFSET 0x8769
759 #define TAG_GPS_OFFSET 0x8825
760 #define TAG_INTEROP_OFFSET 0xa005
762 #define EXIFMultipleValues(size,format,arg) \
775 for (component=0; component < components; component++) \
777 length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
779 if (length >= (MagickPathExtent-1)) \
780 length=MagickPathExtent-1; \
784 buffer[length-2]='\0'; \
785 value=AcquireString(buffer); \
788 #define EXIFMultipleFractions(size,format,arg1,arg2) \
801 for (component=0; component < components; component++) \
803 length+=FormatLocaleString(buffer+length,MagickPathExtent-length, \
804 format", ",(arg1),(arg2)); \
805 if (length >= (MagickPathExtent-1)) \
806 length=MagickPathExtent-1; \
810 buffer[length-2]='\0'; \
811 value=AcquireString(buffer); \
814 typedef struct _DirectoryInfo
826 typedef struct _TagInfo
838 { 0x001, "exif:InteroperabilityIndex" },
839 { 0x002, "exif:InteroperabilityVersion" },
840 { 0x100, "exif:ImageWidth" },
841 { 0x101, "exif:ImageLength" },
842 { 0x102, "exif:BitsPerSample" },
843 { 0x103, "exif:Compression" },
844 { 0x106, "exif:PhotometricInterpretation" },
845 { 0x10a, "exif:FillOrder" },
846 { 0x10d, "exif:DocumentName" },
847 { 0x10e, "exif:ImageDescription" },
848 { 0x10f, "exif:Make" },
849 { 0x110, "exif:Model" },
850 { 0x111, "exif:StripOffsets" },
851 { 0x112, "exif:Orientation" },
852 { 0x115, "exif:SamplesPerPixel" },
853 { 0x116, "exif:RowsPerStrip" },
854 { 0x117, "exif:StripByteCounts" },
855 { 0x11a, "exif:XResolution" },
856 { 0x11b, "exif:YResolution" },
857 { 0x11c, "exif:PlanarConfiguration" },
858 { 0x11d, "exif:PageName" },
859 { 0x11e, "exif:XPosition" },
860 { 0x11f, "exif:YPosition" },
861 { 0x118, "exif:MinSampleValue" },
862 { 0x119, "exif:MaxSampleValue" },
863 { 0x120, "exif:FreeOffsets" },
864 { 0x121, "exif:FreeByteCounts" },
865 { 0x122, "exif:GrayResponseUnit" },
866 { 0x123, "exif:GrayResponseCurve" },
867 { 0x124, "exif:T4Options" },
868 { 0x125, "exif:T6Options" },
869 { 0x128, "exif:ResolutionUnit" },
870 { 0x12d, "exif:TransferFunction" },
871 { 0x131, "exif:Software" },
872 { 0x132, "exif:DateTime" },
873 { 0x13b, "exif:Artist" },
874 { 0x13e, "exif:WhitePoint" },
875 { 0x13f, "exif:PrimaryChromaticities" },
876 { 0x140, "exif:ColorMap" },
877 { 0x141, "exif:HalfToneHints" },
878 { 0x142, "exif:TileWidth" },
879 { 0x143, "exif:TileLength" },
880 { 0x144, "exif:TileOffsets" },
881 { 0x145, "exif:TileByteCounts" },
882 { 0x14a, "exif:SubIFD" },
883 { 0x14c, "exif:InkSet" },
884 { 0x14d, "exif:InkNames" },
885 { 0x14e, "exif:NumberOfInks" },
886 { 0x150, "exif:DotRange" },
887 { 0x151, "exif:TargetPrinter" },
888 { 0x152, "exif:ExtraSample" },
889 { 0x153, "exif:SampleFormat" },
890 { 0x154, "exif:SMinSampleValue" },
891 { 0x155, "exif:SMaxSampleValue" },
892 { 0x156, "exif:TransferRange" },
893 { 0x157, "exif:ClipPath" },
894 { 0x158, "exif:XClipPathUnits" },
895 { 0x159, "exif:YClipPathUnits" },
896 { 0x15a, "exif:Indexed" },
897 { 0x15b, "exif:JPEGTables" },
898 { 0x15f, "exif:OPIProxy" },
899 { 0x200, "exif:JPEGProc" },
900 { 0x201, "exif:JPEGInterchangeFormat" },
901 { 0x202, "exif:JPEGInterchangeFormatLength" },
902 { 0x203, "exif:JPEGRestartInterval" },
903 { 0x205, "exif:JPEGLosslessPredictors" },
904 { 0x206, "exif:JPEGPointTransforms" },
905 { 0x207, "exif:JPEGQTables" },
906 { 0x208, "exif:JPEGDCTables" },
907 { 0x209, "exif:JPEGACTables" },
908 { 0x211, "exif:YCbCrCoefficients" },
909 { 0x212, "exif:YCbCrSubSampling" },
910 { 0x213, "exif:YCbCrPositioning" },
911 { 0x214, "exif:ReferenceBlackWhite" },
912 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
913 { 0x301, "exif:Gamma" },
914 { 0x302, "exif:ICCProfileDescriptor" },
915 { 0x303, "exif:SRGBRenderingIntent" },
916 { 0x320, "exif:ImageTitle" },
917 { 0x5001, "exif:ResolutionXUnit" },
918 { 0x5002, "exif:ResolutionYUnit" },
919 { 0x5003, "exif:ResolutionXLengthUnit" },
920 { 0x5004, "exif:ResolutionYLengthUnit" },
921 { 0x5005, "exif:PrintFlags" },
922 { 0x5006, "exif:PrintFlagsVersion" },
923 { 0x5007, "exif:PrintFlagsCrop" },
924 { 0x5008, "exif:PrintFlagsBleedWidth" },
925 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
926 { 0x500A, "exif:HalftoneLPI" },
927 { 0x500B, "exif:HalftoneLPIUnit" },
928 { 0x500C, "exif:HalftoneDegree" },
929 { 0x500D, "exif:HalftoneShape" },
930 { 0x500E, "exif:HalftoneMisc" },
931 { 0x500F, "exif:HalftoneScreen" },
932 { 0x5010, "exif:JPEGQuality" },
933 { 0x5011, "exif:GridSize" },
934 { 0x5012, "exif:ThumbnailFormat" },
935 { 0x5013, "exif:ThumbnailWidth" },
936 { 0x5014, "exif:ThumbnailHeight" },
937 { 0x5015, "exif:ThumbnailColorDepth" },
938 { 0x5016, "exif:ThumbnailPlanes" },
939 { 0x5017, "exif:ThumbnailRawBytes" },
940 { 0x5018, "exif:ThumbnailSize" },
941 { 0x5019, "exif:ThumbnailCompressedSize" },
942 { 0x501a, "exif:ColorTransferFunction" },
943 { 0x501b, "exif:ThumbnailData" },
944 { 0x5020, "exif:ThumbnailImageWidth" },
945 { 0x5021, "exif:ThumbnailImageHeight" },
946 { 0x5022, "exif:ThumbnailBitsPerSample" },
947 { 0x5023, "exif:ThumbnailCompression" },
948 { 0x5024, "exif:ThumbnailPhotometricInterp" },
949 { 0x5025, "exif:ThumbnailImageDescription" },
950 { 0x5026, "exif:ThumbnailEquipMake" },
951 { 0x5027, "exif:ThumbnailEquipModel" },
952 { 0x5028, "exif:ThumbnailStripOffsets" },
953 { 0x5029, "exif:ThumbnailOrientation" },
954 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
955 { 0x502b, "exif:ThumbnailRowsPerStrip" },
956 { 0x502c, "exif:ThumbnailStripBytesCount" },
957 { 0x502d, "exif:ThumbnailResolutionX" },
958 { 0x502e, "exif:ThumbnailResolutionY" },
959 { 0x502f, "exif:ThumbnailPlanarConfig" },
960 { 0x5030, "exif:ThumbnailResolutionUnit" },
961 { 0x5031, "exif:ThumbnailTransferFunction" },
962 { 0x5032, "exif:ThumbnailSoftwareUsed" },
963 { 0x5033, "exif:ThumbnailDateTime" },
964 { 0x5034, "exif:ThumbnailArtist" },
965 { 0x5035, "exif:ThumbnailWhitePoint" },
966 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
967 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
968 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
969 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
970 { 0x503A, "exif:ThumbnailRefBlackWhite" },
971 { 0x503B, "exif:ThumbnailCopyRight" },
972 { 0x5090, "exif:LuminanceTable" },
973 { 0x5091, "exif:ChrominanceTable" },
974 { 0x5100, "exif:FrameDelay" },
975 { 0x5101, "exif:LoopCount" },
976 { 0x5110, "exif:PixelUnit" },
977 { 0x5111, "exif:PixelPerUnitX" },
978 { 0x5112, "exif:PixelPerUnitY" },
979 { 0x5113, "exif:PaletteHistogram" },
980 { 0x1000, "exif:RelatedImageFileFormat" },
981 { 0x1001, "exif:RelatedImageLength" },
982 { 0x1002, "exif:RelatedImageWidth" },
983 { 0x800d, "exif:ImageID" },
984 { 0x80e3, "exif:Matteing" },
985 { 0x80e4, "exif:DataType" },
986 { 0x80e5, "exif:ImageDepth" },
987 { 0x80e6, "exif:TileDepth" },
988 { 0x828d, "exif:CFARepeatPatternDim" },
989 { 0x828e, "exif:CFAPattern2" },
990 { 0x828f, "exif:BatteryLevel" },
991 { 0x8298, "exif:Copyright" },
992 { 0x829a, "exif:ExposureTime" },
993 { 0x829d, "exif:FNumber" },
994 { 0x83bb, "exif:IPTC/NAA" },
995 { 0x84e3, "exif:IT8RasterPadding" },
996 { 0x84e5, "exif:IT8ColorTable" },
997 { 0x8649, "exif:ImageResourceInformation" },
998 { 0x8769, "exif:ExifOffset" },
999 { 0x8773, "exif:InterColorProfile" },
1000 { 0x8822, "exif:ExposureProgram" },
1001 { 0x8824, "exif:SpectralSensitivity" },
1002 { 0x8825, "exif:GPSInfo" },
1003 { 0x8827, "exif:ISOSpeedRatings" },
1004 { 0x8828, "exif:OECF" },
1005 { 0x8829, "exif:Interlace" },
1006 { 0x882a, "exif:TimeZoneOffset" },
1007 { 0x882b, "exif:SelfTimerMode" },
1008 { 0x9000, "exif:ExifVersion" },
1009 { 0x9003, "exif:DateTimeOriginal" },
1010 { 0x9004, "exif:DateTimeDigitized" },
1011 { 0x9101, "exif:ComponentsConfiguration" },
1012 { 0x9102, "exif:CompressedBitsPerPixel" },
1013 { 0x9201, "exif:ShutterSpeedValue" },
1014 { 0x9202, "exif:ApertureValue" },
1015 { 0x9203, "exif:BrightnessValue" },
1016 { 0x9204, "exif:ExposureBiasValue" },
1017 { 0x9205, "exif:MaxApertureValue" },
1018 { 0x9206, "exif:SubjectDistance" },
1019 { 0x9207, "exif:MeteringMode" },
1020 { 0x9208, "exif:LightSource" },
1021 { 0x9209, "exif:Flash" },
1022 { 0x920a, "exif:FocalLength" },
1023 { 0x920b, "exif:FlashEnergy" },
1024 { 0x920c, "exif:SpatialFrequencyResponse" },
1025 { 0x920d, "exif:Noise" },
1026 { 0x9211, "exif:ImageNumber" },
1027 { 0x9212, "exif:SecurityClassification" },
1028 { 0x9213, "exif:ImageHistory" },
1029 { 0x9214, "exif:SubjectArea" },
1030 { 0x9215, "exif:ExposureIndex" },
1031 { 0x9216, "exif:TIFF-EPStandardID" },
1032 { 0x927c, "exif:MakerNote" },
1033 { 0x9C9b, "exif:WinXP-Title" },
1034 { 0x9C9c, "exif:WinXP-Comments" },
1035 { 0x9C9d, "exif:WinXP-Author" },
1036 { 0x9C9e, "exif:WinXP-Keywords" },
1037 { 0x9C9f, "exif:WinXP-Subject" },
1038 { 0x9286, "exif:UserComment" },
1039 { 0x9290, "exif:SubSecTime" },
1040 { 0x9291, "exif:SubSecTimeOriginal" },
1041 { 0x9292, "exif:SubSecTimeDigitized" },
1042 { 0xa000, "exif:FlashPixVersion" },
1043 { 0xa001, "exif:ColorSpace" },
1044 { 0xa002, "exif:ExifImageWidth" },
1045 { 0xa003, "exif:ExifImageLength" },
1046 { 0xa004, "exif:RelatedSoundFile" },
1047 { 0xa005, "exif:InteroperabilityOffset" },
1048 { 0xa20b, "exif:FlashEnergy" },
1049 { 0xa20c, "exif:SpatialFrequencyResponse" },
1050 { 0xa20d, "exif:Noise" },
1051 { 0xa20e, "exif:FocalPlaneXResolution" },
1052 { 0xa20f, "exif:FocalPlaneYResolution" },
1053 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1054 { 0xa214, "exif:SubjectLocation" },
1055 { 0xa215, "exif:ExposureIndex" },
1056 { 0xa216, "exif:TIFF/EPStandardID" },
1057 { 0xa217, "exif:SensingMethod" },
1058 { 0xa300, "exif:FileSource" },
1059 { 0xa301, "exif:SceneType" },
1060 { 0xa302, "exif:CFAPattern" },
1061 { 0xa401, "exif:CustomRendered" },
1062 { 0xa402, "exif:ExposureMode" },
1063 { 0xa403, "exif:WhiteBalance" },
1064 { 0xa404, "exif:DigitalZoomRatio" },
1065 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1066 { 0xa406, "exif:SceneCaptureType" },
1067 { 0xa407, "exif:GainControl" },
1068 { 0xa408, "exif:Contrast" },
1069 { 0xa409, "exif:Saturation" },
1070 { 0xa40a, "exif:Sharpness" },
1071 { 0xa40b, "exif:DeviceSettingDescription" },
1072 { 0xa40c, "exif:SubjectDistanceRange" },
1073 { 0xa420, "exif:ImageUniqueID" },
1074 { 0xc4a5, "exif:PrintImageMatching" },
1075 { 0xa500, "exif:Gamma" },
1076 { 0xc640, "exif:CR2Slice" },
1077 { 0x10000, "exif:GPSVersionID" },
1078 { 0x10001, "exif:GPSLatitudeRef" },
1079 { 0x10002, "exif:GPSLatitude" },
1080 { 0x10003, "exif:GPSLongitudeRef" },
1081 { 0x10004, "exif:GPSLongitude" },
1082 { 0x10005, "exif:GPSAltitudeRef" },
1083 { 0x10006, "exif:GPSAltitude" },
1084 { 0x10007, "exif:GPSTimeStamp" },
1085 { 0x10008, "exif:GPSSatellites" },
1086 { 0x10009, "exif:GPSStatus" },
1087 { 0x1000a, "exif:GPSMeasureMode" },
1088 { 0x1000b, "exif:GPSDop" },
1089 { 0x1000c, "exif:GPSSpeedRef" },
1090 { 0x1000d, "exif:GPSSpeed" },
1091 { 0x1000e, "exif:GPSTrackRef" },
1092 { 0x1000f, "exif:GPSTrack" },
1093 { 0x10010, "exif:GPSImgDirectionRef" },
1094 { 0x10011, "exif:GPSImgDirection" },
1095 { 0x10012, "exif:GPSMapDatum" },
1096 { 0x10013, "exif:GPSDestLatitudeRef" },
1097 { 0x10014, "exif:GPSDestLatitude" },
1098 { 0x10015, "exif:GPSDestLongitudeRef" },
1099 { 0x10016, "exif:GPSDestLongitude" },
1100 { 0x10017, "exif:GPSDestBearingRef" },
1101 { 0x10018, "exif:GPSDestBearing" },
1102 { 0x10019, "exif:GPSDestDistanceRef" },
1103 { 0x1001a, "exif:GPSDestDistance" },
1104 { 0x1001b, "exif:GPSProcessingMethod" },
1105 { 0x1001c, "exif:GPSAreaInformation" },
1106 { 0x1001d, "exif:GPSDateStamp" },
1107 { 0x1001e, "exif:GPSDifferential" },
1108 { 0x00000, (const char *) NULL }
1119 directory_stack[MaxDirectoryStack];
1148 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1151 If EXIF data exists, then try to parse the request for a tag.
1153 profile=GetImageProfile(image,"exif");
1154 if (profile == (const StringInfo *) NULL)
1155 return(MagickFalse);
1156 if ((property == (const char *) NULL) || (*property == '\0'))
1157 return(MagickFalse);
1158 while (isspace((int) ((unsigned char) *property)) != 0)
1160 if (strlen(property) <= 5)
1161 return(MagickFalse);
1164 switch (*(property+5))
1169 Caller has asked for all the tags in the EXIF data.
1172 all=1; /* return the data in description=value format */
1178 all=2; /* return the data in tagid=value format */
1191 Check for a hex based tag specification first.
1193 tag=(*(property+5) == '@') ? 1UL : 0UL;
1197 return(MagickFalse);
1199 Parse tag specification as a hex number.
1204 for (i=(ssize_t) n-1L; i >= 0; i--)
1208 if ((c >= '0') && (c <= '9'))
1211 if ((c >= 'A') && (c <= 'F'))
1214 if ((c >= 'a') && (c <= 'f'))
1217 return(MagickFalse);
1219 } while (*property != '\0');
1225 Try to match the text with a tag name instead.
1229 if (EXIFTag[i].tag == 0)
1231 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1233 tag=(size_t) EXIFTag[i].tag;
1241 return(MagickFalse);
1242 length=GetStringInfoLength(profile);
1243 exif=GetStringInfoDatum(profile);
1246 if (ReadPropertyByte(&exif,&length) != 0x45)
1248 if (ReadPropertyByte(&exif,&length) != 0x78)
1250 if (ReadPropertyByte(&exif,&length) != 0x69)
1252 if (ReadPropertyByte(&exif,&length) != 0x66)
1254 if (ReadPropertyByte(&exif,&length) != 0x00)
1256 if (ReadPropertyByte(&exif,&length) != 0x00)
1261 return(MagickFalse);
1262 id=(ssize_t) ((int) ReadPropertyShort(LSBEndian,exif));
1270 return(MagickFalse);
1271 if (ReadPropertyShort(endian,exif+2) != 0x002a)
1272 return(MagickFalse);
1274 This the offset to the first IFD.
1276 offset=(ssize_t) ((int) ReadPropertyLong(endian,exif+4));
1277 if ((offset < 0) || (size_t) offset >= length)
1278 return(MagickFalse);
1280 Set the pointer to the first IFD and follow it were it leads.
1283 directory=exif+offset;
1287 exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,
1288 (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
1292 If there is anything on the stack then pop it off.
1297 directory=directory_stack[level].directory;
1298 entry=directory_stack[level].entry;
1299 tag_offset=directory_stack[level].offset;
1301 if ((directory < exif) || (directory > (exif+length-2)))
1304 Determine how many entries there are in the current IFD.
1306 number_entries=(size_t) ((int) ReadPropertyShort(endian,directory));
1307 for ( ; entry < number_entries; entry++)
1309 register unsigned char
1320 q=(unsigned char *) (directory+(12*entry)+2);
1321 if (GetValueFromSplayTree(exif_resources,q) == q)
1323 (void) AddValueToSplayTree(exif_resources,q,q);
1324 tag_value=(ssize_t) ((int) ReadPropertyShort(endian,q)+tag_offset);
1325 format=(size_t) ((int) ReadPropertyShort(endian,q+2));
1326 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1328 components=(ssize_t) ((int) ReadPropertyLong(endian,q+4));
1329 number_bytes=(size_t) components*tag_bytes[format];
1330 if (number_bytes < components)
1331 break; /* prevent overflow */
1332 if (number_bytes <= 4)
1340 The directory entry contains an offset.
1342 offset=(ssize_t) ((int) ReadPropertyLong(endian,q+8));
1343 if ((offset < 0) || (size_t) offset >= length)
1345 if ((ssize_t) (offset+number_bytes) < offset)
1346 continue; /* prevent overflow */
1347 if ((size_t) (offset+number_bytes) > length)
1349 p=(unsigned char *) (exif+offset);
1351 if ((all != 0) || (tag == (size_t) tag_value))
1354 buffer[MagickPathExtent],
1357 value=(char *) NULL;
1362 case EXIF_FMT_UNDEFINED:
1364 EXIFMultipleValues(1,"%.20g",(double) (*(unsigned char *) p1));
1367 case EXIF_FMT_SBYTE:
1369 EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1372 case EXIF_FMT_SSHORT:
1374 EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1));
1377 case EXIF_FMT_USHORT:
1379 EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1));
1382 case EXIF_FMT_ULONG:
1384 EXIFMultipleValues(4,"%.20g",(double)
1385 ((int) ReadPropertyLong(endian,p1)));
1388 case EXIF_FMT_SLONG:
1390 EXIFMultipleValues(4,"%.20g",(double)
1391 ((int) ReadPropertyLong(endian,p1)));
1394 case EXIF_FMT_URATIONAL:
1396 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1397 ((int) ReadPropertyLong(endian,p1)),(double)
1398 ((int) ReadPropertyLong(endian,p1+4)));
1401 case EXIF_FMT_SRATIONAL:
1403 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1404 ((int) ReadPropertyLong(endian,p1)),(double)
1405 ((int) ReadPropertyLong(endian,p1+4)));
1408 case EXIF_FMT_SINGLE:
1410 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1413 case EXIF_FMT_DOUBLE:
1415 EXIFMultipleValues(8,"%f",*(double *) p1);
1419 case EXIF_FMT_STRING:
1421 value=(char *) NULL;
1422 if (~((size_t) number_bytes) >= 1)
1423 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1425 if (value != (char *) NULL)
1430 for (i=0; i < (ssize_t) number_bytes; i++)
1433 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1434 value[i]=(char) p[i];
1441 if (value != (char *) NULL)
1449 key=AcquireString(property);
1460 description="unknown";
1463 if (EXIFTag[i].tag == 0)
1465 if ((ssize_t) EXIFTag[i].tag == tag_value)
1467 description=EXIFTag[i].description;
1471 (void) FormatLocaleString(key,MagickPathExtent,"%s",description);
1473 (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1478 if (tag_value < 0x10000)
1479 (void) FormatLocaleString(key,MagickPathExtent,"#%04lx",
1480 (unsigned long) tag_value);
1482 if (tag_value < 0x20000)
1483 (void) FormatLocaleString(key,MagickPathExtent,"@%04lx",
1484 (unsigned long) (tag_value & 0xffff));
1486 (void) FormatLocaleString(key,MagickPathExtent,"unknown");
1492 (void) SubstituteString(&key,"exif:","exif:thumbnail:");
1495 p=(const char *) NULL;
1496 if (image->properties != (void *) NULL)
1497 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1498 image->properties,key);
1499 if (p == (const char *) NULL)
1500 (void) SetImageProperty((Image *) image,key,value,exception);
1501 value=DestroyString(value);
1502 key=DestroyString(key);
1506 if ((tag_value == TAG_EXIF_OFFSET) ||
1507 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1512 offset=(ssize_t) ((int) ReadPropertyLong(endian,p));
1513 if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1518 tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1520 directory_stack[level].directory=directory;
1522 directory_stack[level].entry=entry;
1523 directory_stack[level].offset=tag_offset;
1525 directory_stack[level].directory=exif+offset;
1526 directory_stack[level].offset=tag_offset1;
1527 directory_stack[level].entry=0;
1529 if ((directory+2+(12*number_entries)) > (exif+length))
1531 offset=(ssize_t) ((int) ReadPropertyLong(endian,directory+2+(12*
1533 if ((offset != 0) && ((size_t) offset < length) &&
1534 (level < (MaxDirectoryStack-2)))
1536 directory_stack[level].directory=exif+offset;
1537 directory_stack[level].entry=0;
1538 directory_stack[level].offset=tag_offset1;
1545 } while (level > 0);
1546 exif_resources=DestroySplayTree(exif_resources);
1550 static MagickBooleanType GetICCProperty(const Image *image,const char *property,
1551 ExceptionInfo *exception)
1556 magick_unreferenced(property);
1558 profile=GetImageProfile(image,"icc");
1559 if (profile == (StringInfo *) NULL)
1560 profile=GetImageProfile(image,"icm");
1561 if (profile == (StringInfo *) NULL)
1562 return(MagickFalse);
1563 if (GetStringInfoLength(profile) < 128)
1564 return(MagickFalse); /* minimum ICC profile length */
1565 #if defined(MAGICKCORE_LCMS_DELEGATE)
1570 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1571 (cmsUInt32Number) GetStringInfoLength(profile));
1572 if (icc_profile != (cmsHPROFILE *) NULL)
1574 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1578 name=cmsTakeProductName(icc_profile);
1579 if (name != (const char *) NULL)
1580 (void) SetImageProperty((Image *) image,"icc:name",name,exception);
1583 info[MagickPathExtent];
1585 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
1586 "en","US",info,MagickPathExtent);
1587 (void) SetImageProperty((Image *) image,"icc:description",info,
1589 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
1590 "en","US",info,MagickPathExtent);
1591 (void) SetImageProperty((Image *) image,"icc:manufacturer",info,
1593 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,"en",
1594 "US",info,MagickPathExtent);
1595 (void) SetImageProperty((Image *) image,"icc:model",info,exception);
1596 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
1597 "en","US",info,MagickPathExtent);
1598 (void) SetImageProperty((Image *) image,"icc:copyright",info,exception);
1600 (void) cmsCloseProfile(icc_profile);
1607 static MagickBooleanType SkipXMPValue(const char *value)
1609 if (value == (const char*) NULL)
1611 while (*value != '\0')
1613 if (isspace((int) ((unsigned char) *value)) == 0)
1614 return(MagickFalse);
1620 static MagickBooleanType GetXMPProperty(const Image *image,const char *property)
1647 profile=GetImageProfile(image,"xmp");
1648 if (profile == (StringInfo *) NULL)
1649 return(MagickFalse);
1650 if ((property == (const char *) NULL) || (*property == '\0'))
1651 return(MagickFalse);
1652 xmp_profile=StringInfoToString(profile);
1653 if (xmp_profile == (char *) NULL)
1654 return(MagickFalse);
1655 for (p=xmp_profile; *p != '\0'; p++)
1656 if ((*p == '<') && (*(p+1) == 'x'))
1658 exception=AcquireExceptionInfo();
1659 xmp=NewXMLTree((char *) p,exception);
1660 xmp_profile=DestroyString(xmp_profile);
1661 exception=DestroyExceptionInfo(exception);
1662 if (xmp == (XMLTreeInfo *) NULL)
1663 return(MagickFalse);
1665 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1666 if (rdf != (XMLTreeInfo *) NULL)
1668 if (image->properties == (void *) NULL)
1669 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1670 RelinquishMagickMemory,RelinquishMagickMemory);
1671 description=GetXMLTreeChild(rdf,"rdf:Description");
1672 while (description != (XMLTreeInfo *) NULL)
1674 node=GetXMLTreeChild(description,(const char *) NULL);
1675 while (node != (XMLTreeInfo *) NULL)
1677 child=GetXMLTreeChild(node,(const char *) NULL);
1678 content=GetXMLTreeContent(node);
1679 if ((child == (XMLTreeInfo *) NULL) &&
1680 (SkipXMPValue(content) == MagickFalse))
1681 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1682 ConstantString(GetXMLTreeTag(node)),ConstantString(content));
1683 while (child != (XMLTreeInfo *) NULL)
1685 content=GetXMLTreeContent(child);
1686 if (SkipXMPValue(content) == MagickFalse)
1687 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1688 ConstantString(GetXMLTreeTag(child)),ConstantString(content));
1689 child=GetXMLTreeSibling(child);
1691 node=GetXMLTreeSibling(node);
1693 description=GetNextXMLTreeTag(description);
1696 xmp=DestroyXMLTree(xmp);
1700 static char *TracePSClippath(const unsigned char *blob,size_t length)
1723 path=AcquireString((char *) NULL);
1724 if (path == (char *) NULL)
1725 return((char *) NULL);
1726 message=AcquireString((char *) NULL);
1727 (void) FormatLocaleString(message,MagickPathExtent,"/ClipImage\n");
1728 (void) ConcatenateString(&path,message);
1729 (void) FormatLocaleString(message,MagickPathExtent,"{\n");
1730 (void) ConcatenateString(&path,message);
1731 (void) FormatLocaleString(message,MagickPathExtent," /c {curveto} bind def\n");
1732 (void) ConcatenateString(&path,message);
1733 (void) FormatLocaleString(message,MagickPathExtent," /l {lineto} bind def\n");
1734 (void) ConcatenateString(&path,message);
1735 (void) FormatLocaleString(message,MagickPathExtent," /m {moveto} bind def\n");
1736 (void) ConcatenateString(&path,message);
1737 (void) FormatLocaleString(message,MagickPathExtent,
1738 " /v {currentpoint 6 2 roll curveto} bind def\n");
1739 (void) ConcatenateString(&path,message);
1740 (void) FormatLocaleString(message,MagickPathExtent,
1741 " /y {2 copy curveto} bind def\n");
1742 (void) ConcatenateString(&path,message);
1743 (void) FormatLocaleString(message,MagickPathExtent,
1744 " /z {closepath} bind def\n");
1745 (void) ConcatenateString(&path,message);
1746 (void) FormatLocaleString(message,MagickPathExtent," newpath\n");
1747 (void) ConcatenateString(&path,message);
1749 The clipping path format is defined in "Adobe Photoshop File
1750 Formats Specification" version 6.0 downloadable from adobe.com.
1752 (void) ResetMagickMemory(point,0,sizeof(point));
1753 (void) ResetMagickMemory(first,0,sizeof(first));
1754 (void) ResetMagickMemory(last,0,sizeof(last));
1756 in_subpath=MagickFalse;
1759 selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1765 if (knot_count != 0)
1768 length-=MagickMin(24,(ssize_t) length);
1772 Expected subpath length record.
1774 knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1776 length-=MagickMin(22,(ssize_t) length);
1784 if (knot_count == 0)
1787 Unexpected subpath knot
1790 length-=MagickMin(24,(ssize_t) length);
1796 for (i=0; i < 3; i++)
1802 yy=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1803 xx=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1805 if (xx > 2147483647)
1806 x=(ssize_t) xx-4294967295U-1;
1808 if (yy > 2147483647)
1809 y=(ssize_t) yy-4294967295U-1;
1810 point[i].x=(double) x/4096/4096;
1811 point[i].y=1.0-(double) y/4096/4096;
1813 if (in_subpath == MagickFalse)
1815 (void) FormatLocaleString(message,MagickPathExtent," %g %g m\n",
1816 point[1].x,point[1].y);
1817 for (i=0; i < 3; i++)
1826 Handle special cases when Bezier curves are used to describe
1827 corners and straight lines.
1829 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1830 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1831 (void) FormatLocaleString(message,MagickPathExtent,
1832 " %g %g l\n",point[1].x,point[1].y);
1834 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1835 (void) FormatLocaleString(message,MagickPathExtent,
1836 " %g %g %g %g v\n",point[0].x,point[0].y,
1837 point[1].x,point[1].y);
1839 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1840 (void) FormatLocaleString(message,MagickPathExtent,
1841 " %g %g %g %g y\n",last[2].x,last[2].y,
1842 point[1].x,point[1].y);
1844 (void) FormatLocaleString(message,MagickPathExtent,
1845 " %g %g %g %g %g %g c\n",last[2].x,
1846 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1847 for (i=0; i < 3; i++)
1850 (void) ConcatenateString(&path,message);
1851 in_subpath=MagickTrue;
1854 Close the subpath if there are no more knots.
1856 if (knot_count == 0)
1859 Same special handling as above except we compare to the
1860 first point in the path and close the path.
1862 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1863 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1864 (void) FormatLocaleString(message,MagickPathExtent,
1865 " %g %g l z\n",first[1].x,first[1].y);
1867 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1868 (void) FormatLocaleString(message,MagickPathExtent,
1869 " %g %g %g %g v z\n",first[0].x,first[0].y,
1870 first[1].x,first[1].y);
1872 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1873 (void) FormatLocaleString(message,MagickPathExtent,
1874 " %g %g %g %g y z\n",last[2].x,last[2].y,
1875 first[1].x,first[1].y);
1877 (void) FormatLocaleString(message,MagickPathExtent,
1878 " %g %g %g %g %g %g c z\n",last[2].x,
1879 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1880 (void) ConcatenateString(&path,message);
1881 in_subpath=MagickFalse;
1891 length-=MagickMin(24,(ssize_t) length);
1897 Returns an empty PS path if the path has no knots.
1899 (void) FormatLocaleString(message,MagickPathExtent," eoclip\n");
1900 (void) ConcatenateString(&path,message);
1901 (void) FormatLocaleString(message,MagickPathExtent,"} bind def");
1902 (void) ConcatenateString(&path,message);
1903 message=DestroyString(message);
1907 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1908 const size_t columns,const size_t rows)
1931 path=AcquireString((char *) NULL);
1932 if (path == (char *) NULL)
1933 return((char *) NULL);
1934 message=AcquireString((char *) NULL);
1935 (void) FormatLocaleString(message,MagickPathExtent,
1936 ("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
1937 "<svg xmlns=\"http://www.w3.org/2000/svg\""
1938 " width=\"%.20g\" height=\"%.20g\">\n"
1940 "<path fill-rule=\"evenodd\" style=\"fill:#00000000;stroke:#00000000;"
1941 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),
1942 (double) columns,(double) rows);
1943 (void) ConcatenateString(&path,message);
1944 (void) ResetMagickMemory(point,0,sizeof(point));
1945 (void) ResetMagickMemory(first,0,sizeof(first));
1946 (void) ResetMagickMemory(last,0,sizeof(last));
1948 in_subpath=MagickFalse;
1951 selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1957 if (knot_count != 0)
1960 length-=MagickMin(24,(ssize_t) length);
1964 Expected subpath length record.
1966 knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1968 length-=MagickMin(22,(ssize_t) length);
1976 if (knot_count == 0)
1979 Unexpected subpath knot.
1982 length-=MagickMin(24,(ssize_t) length);
1988 for (i=0; i < 3; i++)
1994 yy=(unsigned int) ((int) ReadPropertyMSBLong(&blob,&length));
1995 xx=(unsigned int) ((int) ReadPropertyMSBLong(&blob,&length));
1997 if (xx > 2147483647)
1998 x=(ssize_t) xx-4294967295U-1;
2000 if (yy > 2147483647)
2001 y=(ssize_t) yy-4294967295U-1;
2002 point[i].x=(double) x*columns/4096/4096;
2003 point[i].y=(double) y*rows/4096/4096;
2005 if (in_subpath == MagickFalse)
2007 (void) FormatLocaleString(message,MagickPathExtent,"M %g %g\n",
2008 point[1].x,point[1].y);
2009 for (i=0; i < 3; i++)
2018 Handle special cases when Bezier curves are used to describe
2019 corners and straight lines.
2021 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2022 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2023 (void) FormatLocaleString(message,MagickPathExtent,
2024 "L %g %g\n",point[1].x,point[1].y);
2026 (void) FormatLocaleString(message,MagickPathExtent,
2027 "C %g %g %g %g %g %g\n",last[2].x,
2028 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2029 for (i=0; i < 3; i++)
2032 (void) ConcatenateString(&path,message);
2033 in_subpath=MagickTrue;
2036 Close the subpath if there are no more knots.
2038 if (knot_count == 0)
2041 Same special handling as above except we compare to the
2042 first point in the path and close the path.
2044 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2045 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2046 (void) FormatLocaleString(message,MagickPathExtent,
2047 "L %g %g Z\n",first[1].x,first[1].y);
2049 (void) FormatLocaleString(message,MagickPathExtent,
2050 "C %g %g %g %g %g %g Z\n",last[2].x,
2051 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2052 (void) ConcatenateString(&path,message);
2053 in_subpath=MagickFalse;
2063 length-=MagickMin(24,(ssize_t) length);
2069 Return an empty SVG image if the path does not have knots.
2071 (void) ConcatenateString(&path,"\"/>\n</g>\n</svg>\n");
2072 message=DestroyString(message);
2076 MagickExport const char *GetImageProperty(const Image *image,
2077 const char *property,ExceptionInfo *exception)
2082 assert(image != (Image *) NULL);
2083 assert(image->signature == MagickCoreSignature);
2084 if (image->debug != MagickFalse)
2085 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2086 p=(const char *) NULL;
2087 if (image->properties != (void *) NULL)
2089 if (property == (const char *) NULL)
2091 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
2092 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
2096 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2097 image->properties,property);
2098 if (p != (const char *) NULL)
2101 if ((property == (const char *) NULL) ||
2102 (strchr(property,':') == (char *) NULL))
2108 if (LocaleNCompare("8bim:",property,5) == 0)
2110 (void) Get8BIMProperty(image,property,exception);
2118 if (LocaleNCompare("exif:",property,5) == 0)
2120 (void) GetEXIFProperty(image,property,exception);
2128 if ((LocaleNCompare("icc:",property,4) == 0) ||
2129 (LocaleNCompare("icm:",property,4) == 0))
2131 (void) GetICCProperty(image,property,exception);
2134 if (LocaleNCompare("iptc:",property,5) == 0)
2136 (void) GetIPTCProperty(image,property,exception);
2144 if (LocaleNCompare("xmp:",property,4) == 0)
2146 (void) GetXMPProperty(image,property);
2154 if (image->properties != (void *) NULL)
2156 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2157 image->properties,property);
2160 return((const char *) NULL);
2164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2168 + G e t M a g i c k P r o p e r t y %
2172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2174 % GetMagickProperty() gets attributes or calculated values that is associated
2175 % with a fixed known property name, or single letter property. It may be
2176 % called if no image is defined (IMv7), in which case only global image_info
2177 % values are available:
2180 % \r carriage return
2181 % < less-than character.
2182 % > greater-than character.
2183 % & ampersand character.
2185 % %b file size of image read in
2186 % %c comment meta-data property
2187 % %d directory component of path
2188 % %e filename extension or suffix
2189 % %f filename (including suffix)
2190 % %g layer canvas page geometry (equivalent to "%Wx%H%X%Y")
2191 % %h current image height in pixels
2192 % %i image filename (note: becomes output filename for "info:")
2193 % %k CALCULATED: number of unique colors
2194 % %l label meta-data property
2195 % %m image file format (file magic)
2196 % %n number of images in current image sequence
2197 % %o output filename (used for delegates)
2198 % %p index of image in current image list
2199 % %q quantum depth (compile-time constant)
2200 % %r image class and colorspace
2201 % %s scene number (from input unless re-assigned)
2202 % %t filename without directory or extension (suffix)
2203 % %u unique temporary filename (used for delegates)
2204 % %w current width in pixels
2205 % %x x resolution (density)
2206 % %y y resolution (density)
2207 % %z image depth (as read in unless modified, image save depth)
2208 % %A image transparency channel enabled (true/false)
2209 % %C image compression type
2210 % %D image GIF dispose method
2211 % %G original image size (%wx%h; before any resizes)
2212 % %H page (canvas) height
2213 % %M Magick filename (original file exactly as given, including read mods)
2214 % %O page (canvas) offset ( = %X%Y )
2215 % %P page (canvas) size ( = %Wx%H )
2216 % %Q image compression quality ( 0 = default )
2218 % %T image time delay (in centi-seconds)
2219 % %U image resolution units
2220 % %W page (canvas) width
2221 % %X page (canvas) x offset (including sign)
2222 % %Y page (canvas) y offset (including sign)
2223 % %Z unique filename (used for delegates)
2224 % %@ CALCULATED: trim bounding box (without actually trimming)
2225 % %# CALCULATED: 'signature' hash of image values
2227 % This routine only handles specifically known properties. It does not
2228 % handle special prefixed properties, profiles, or expressions. Nor does
2229 % it return any free-form property strings.
2231 % The returned string is stored in a structure somewhere, and should not be
2232 % directly freed. If the string was generated (common) the string will be
2233 % stored as as either as artifact or option 'get-property'. These may be
2234 % deleted (cleaned up) when no longer required, but neither artifact or
2235 % option is guranteed to exist.
2237 % The format of the GetMagickProperty method is:
2239 % const char *GetMagickProperty(ImageInfo *image_info,Image *image,
2240 % const char *property,ExceptionInfo *exception)
2242 % A description of each parameter follows:
2244 % o image_info: the image info (optional)
2246 % o image: the image (optional)
2250 % o exception: return any errors or warnings in this structure.
2253 #define WarnNoImageReturn(format,arg) \
2254 if (image == (Image *) NULL ) { \
2255 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2256 "NoImageForProperty",format,arg); \
2257 return((const char *) NULL); \
2259 #define WarnNoImageInfoReturn(format,arg) \
2260 if (image_info == (ImageInfo *) NULL ) { \
2261 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2262 "NoImageInfoForProperty",format,arg); \
2263 return((const char *) NULL); \
2266 static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2267 Image *image,const char letter,ExceptionInfo *exception)
2270 value[MagickPathExtent]; /* formated string to store as a returned artifact */
2273 *string; /* return a string already stored somewher */
2275 if (image != (Image *) NULL && image->debug != MagickFalse)
2276 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2277 else if( image_info != (ImageInfo *) NULL && image_info->debug != MagickFalse)
2278 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2280 *value='\0'; /* formatted string */
2281 string=(char *) NULL; /* constant string reference */
2283 /* Get properities that are directly defined by images */
2286 case 'b': /* image size read in - in bytes */
2288 WarnNoImageReturn("\"%%%c\"",letter);
2289 (void) FormatMagickSize(image->extent,MagickFalse,"B",MagickPathExtent,
2291 if (image->extent == 0)
2292 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
2293 MagickPathExtent,value);
2296 case 'c': /* image comment property - empty string by default */
2298 WarnNoImageReturn("\"%%%c\"",letter);
2299 string=GetImageProperty(image,"comment",exception);
2300 if ( string == (const char *) NULL )
2304 case 'd': /* Directory component of filename */
2306 WarnNoImageReturn("\"%%%c\"",letter);
2307 GetPathComponent(image->magick_filename,HeadPath,value);
2308 if (*value == '\0') string="";
2311 case 'e': /* Filename extension (suffix) of image file */
2313 WarnNoImageReturn("\"%%%c\"",letter);
2314 GetPathComponent(image->magick_filename,ExtensionPath,value);
2315 if (*value == '\0') string="";
2318 case 'f': /* Filename without directory component */
2320 WarnNoImageReturn("\"%%%c\"",letter);
2321 GetPathComponent(image->magick_filename,TailPath,value);
2322 if (*value == '\0') string="";
2325 case 'g': /* Image geometry, canvas and offset %Wx%H+%X+%Y */
2327 WarnNoImageReturn("\"%%%c\"",letter);
2328 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g%+.20g%+.20g",
2329 (double) image->page.width,(double) image->page.height,
2330 (double) image->page.x,(double) image->page.y);
2333 case 'h': /* Image height (current) */
2335 WarnNoImageReturn("\"%%%c\"",letter);
2336 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2337 (image->rows != 0 ? image->rows : image->magick_rows));
2340 case 'i': /* Filename last used for an image (read or write) */
2342 WarnNoImageReturn("\"%%%c\"",letter);
2343 string=image->filename;
2346 case 'k': /* Number of unique colors */
2349 FUTURE: ensure this does not generate the formatted comment!
2351 WarnNoImageReturn("\"%%%c\"",letter);
2352 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2353 GetNumberColors(image,(FILE *) NULL,exception));
2356 case 'l': /* Image label property - empty string by default */
2358 WarnNoImageReturn("\"%%%c\"",letter);
2359 string=GetImageProperty(image,"label",exception);
2360 if ( string == (const char *) NULL)
2364 case 'm': /* Image format (file magick) */
2366 WarnNoImageReturn("\"%%%c\"",letter);
2367 string=image->magick;
2370 case 'n': /* Number of images in the list. */
2372 if ( image != (Image *) NULL )
2373 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2374 GetImageListLength(image));
2376 string="0"; /* no images or scenes */
2379 case 'o': /* Output Filename - for delegate use only */
2380 WarnNoImageInfoReturn("\"%%%c\"",letter);
2381 string=image_info->filename;
2383 case 'p': /* Image index in current image list */
2385 WarnNoImageReturn("\"%%%c\"",letter);
2386 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2387 GetImageIndexInList(image));
2390 case 'q': /* Quantum depth of image in memory */
2392 WarnNoImageReturn("\"%%%c\"",letter);
2393 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2394 MAGICKCORE_QUANTUM_DEPTH);
2397 case 'r': /* Image storage class, colorspace, and alpha enabled. */
2402 WarnNoImageReturn("\"%%%c\"",letter);
2403 colorspace=image->colorspace;
2404 if (SetImageGray(image,exception) != MagickFalse)
2405 colorspace=GRAYColorspace; /* FUTURE: this is IMv6 not IMv7 */
2406 (void) FormatLocaleString(value,MagickPathExtent,"%s %s %s",
2407 CommandOptionToMnemonic(MagickClassOptions,(ssize_t) image->storage_class),
2408 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
2409 image->alpha_trait != UndefinedPixelTrait ? "Alpha" : "");
2412 case 's': /* Image scene number */
2414 #if 0 /* this seems non-sensical -- simplifing */
2415 if (image_info->number_scenes != 0)
2416 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2418 else if (image != (Image *) NULL)
2419 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2424 WarnNoImageReturn("\"%%%c\"",letter);
2425 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2430 case 't': /* Base filename without directory or extention */
2432 WarnNoImageReturn("\"%%%c\"",letter);
2433 GetPathComponent(image->magick_filename,BasePath,value);
2434 if (*value == '\0') string="";
2437 case 'u': /* Unique filename */
2438 WarnNoImageInfoReturn("\"%%%c\"",letter);
2439 string=image_info->unique;
2441 case 'w': /* Image width (current) */
2443 WarnNoImageReturn("\"%%%c\"",letter);
2444 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2445 (image->columns != 0 ? image->columns : image->magick_columns));
2448 case 'x': /* Image horizontal resolution (with units) */
2450 WarnNoImageReturn("\"%%%c\"",letter);
2451 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2452 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x : 72.0);
2455 case 'y': /* Image vertical resolution (with units) */
2457 WarnNoImageReturn("\"%%%c\"",letter);
2458 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2459 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y : 72.0);
2462 case 'z': /* Image depth as read in */
2464 WarnNoImageReturn("\"%%%c\"",letter);
2465 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2466 (double) image->depth);
2469 case 'A': /* Image alpha channel */
2471 WarnNoImageReturn("\"%%%c\"",letter);
2472 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2473 image->alpha_trait);
2476 case 'C': /* Image compression method. */
2478 WarnNoImageReturn("\"%%%c\"",letter);
2479 string=CommandOptionToMnemonic(MagickCompressOptions,
2480 (ssize_t) image->compression);
2483 case 'D': /* Image dispose method. */
2485 WarnNoImageReturn("\"%%%c\"",letter);
2486 string=CommandOptionToMnemonic(MagickDisposeOptions,
2487 (ssize_t) image->dispose);
2490 case 'G': /* Image size as geometry = "%wx%h" */
2492 WarnNoImageReturn("\"%%%c\"",letter);
2493 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",
2494 (double)image->magick_columns,(double) image->magick_rows);
2497 case 'H': /* layer canvas height */
2499 WarnNoImageReturn("\"%%%c\"",letter);
2500 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2501 (double) image->page.height);
2504 case 'M': /* Magick filename - filename given incl. coder & read mods */
2506 WarnNoImageReturn("\"%%%c\"",letter);
2507 string=image->magick_filename;
2510 case 'O': /* layer canvas offset with sign = "+%X+%Y" */
2512 WarnNoImageReturn("\"%%%c\"",letter);
2513 (void) FormatLocaleString(value,MagickPathExtent,"%+ld%+ld",(long)
2514 image->page.x,(long) image->page.y);
2517 case 'P': /* layer canvas page size = "%Wx%H" */
2519 WarnNoImageReturn("\"%%%c\"",letter);
2520 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g",
2521 (double) image->page.width,(double) image->page.height);
2524 case 'Q': /* image compression quality */
2526 WarnNoImageReturn("\"%%%c\"",letter);
2527 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2528 (image->quality == 0 ? 92 : image->quality));
2531 case 'S': /* Number of scenes in image list. */
2533 WarnNoImageInfoReturn("\"%%%c\"",letter);
2534 #if 0 /* What is this number? -- it makes no sense - simplifing */
2535 if (image_info->number_scenes == 0)
2536 string="2147483647";
2537 else if ( image != (Image *) NULL )
2538 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2539 image_info->scene+image_info->number_scenes);
2543 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2544 (image_info->number_scenes == 0 ? 2147483647 :
2545 image_info->number_scenes));
2549 case 'T': /* image time delay for animations */
2551 WarnNoImageReturn("\"%%%c\"",letter);
2552 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2556 case 'U': /* Image resolution units. */
2558 WarnNoImageReturn("\"%%%c\"",letter);
2559 string=CommandOptionToMnemonic(MagickResolutionOptions,
2560 (ssize_t) image->units);
2563 case 'W': /* layer canvas width */
2565 WarnNoImageReturn("\"%%%c\"",letter);
2566 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2570 case 'X': /* layer canvas X offset */
2572 WarnNoImageReturn("\"%%%c\"",letter);
2573 (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2577 case 'Y': /* layer canvas Y offset */
2579 WarnNoImageReturn("\"%%%c\"",letter);
2580 (void) FormatLocaleString(value,MagickPathExtent,"%+.20g",(double)
2584 case 'Z': /* Zero filename ??? */
2585 WarnNoImageInfoReturn("\"%%%c\"",letter);
2586 string=image_info->zero;
2588 case '%': /* percent escaped */
2591 case '@': /* Trim bounding box, without actually Trimming! */
2596 WarnNoImageReturn("\"%%%c\"",letter);
2597 page=GetImageBoundingBox(image,exception);
2598 (void) FormatLocaleString(value,MagickPathExtent,"%.20gx%.20g%+.20g%+.20g",
2599 (double) page.width,(double) page.height,(double) page.x,(double)
2608 WarnNoImageReturn("\"%%%c\"",letter);
2609 (void) SignatureImage(image,exception);
2610 string=GetImageProperty(image,"signature",exception);
2614 if (string != (char *) NULL)
2619 Create a cloned copy of result.
2621 if (image != (Image *) NULL)
2623 (void) SetImageArtifact(image,"get-property",value);
2624 return(GetImageArtifact(image,"get-property"));
2628 (void) SetImageOption(image_info,"get-property",value);
2629 return(GetImageOption(image_info,"get-property"));
2632 return((char *) NULL);
2635 MagickExport const char *GetMagickProperty(ImageInfo *image_info,
2636 Image *image,const char *property,ExceptionInfo *exception)
2639 value[MagickPathExtent];
2644 assert(property[0] != '\0');
2645 assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2647 if (property[1] == '\0') /* single letter property request */
2648 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2650 if (image != (Image *) NULL && image->debug != MagickFalse)
2651 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2652 else if( image_info != (ImageInfo *) NULL && image_info->debug != MagickFalse)
2653 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-images");
2655 *value='\0'; /* formated string */
2656 string=(char *) NULL; /* constant string reference */
2661 if (LocaleCompare("basename",property) == 0)
2663 WarnNoImageReturn("\"%%[%s]\"",property);
2664 GetPathComponent(image->magick_filename,BasePath,value);
2665 if (*value == '\0') string="";
2668 if (LocaleCompare("bit-depth",property) == 0)
2670 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2671 GetImageDepth(image, exception));
2678 if (LocaleCompare("channels",property) == 0)
2680 WarnNoImageReturn("\"%%[%s]\"",property);
2681 /* FUTURE: return actual image channels */
2682 (void) FormatLocaleString(value,MagickPathExtent,"%s",
2683 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2684 image->colorspace));
2686 if( image->alpha_trait != UndefinedPixelTrait )
2687 (void) ConcatenateMagickString(value,"a",MagickPathExtent);
2690 if (LocaleCompare("colorspace",property) == 0)
2692 WarnNoImageReturn("\"%%[%s]\"",property);
2693 /* FUTURE: return actual colorspace - no 'gray' stuff */
2694 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2698 if (LocaleCompare("copyright",property) == 0)
2700 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
2707 if (LocaleCompare("depth",property) == 0)
2709 WarnNoImageReturn("\"%%[%s]\"",property);
2710 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2714 if (LocaleCompare("directory",property) == 0)
2716 WarnNoImageReturn("\"%%[%s]\"",property);
2717 GetPathComponent(image->magick_filename,HeadPath,value);
2718 if (*value == '\0') string="";
2725 if (LocaleCompare("entropy",property) == 0)
2730 WarnNoImageReturn("\"%%[%s]\"",property);
2731 (void) GetImageEntropy(image,&entropy,exception);
2732 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2733 GetMagickPrecision(),entropy);
2736 if (LocaleCompare("extension",property) == 0)
2738 WarnNoImageReturn("\"%%[%s]\"",property);
2739 GetPathComponent(image->magick_filename,ExtensionPath,value);
2740 if (*value == '\0') string="";
2747 if (LocaleCompare("gamma",property) == 0)
2749 WarnNoImageReturn("\"%%[%s]\"",property);
2750 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2751 GetMagickPrecision(),image->gamma);
2754 if (LocaleCompare("group",property) == 0)
2756 WarnNoImageInfoReturn("\"%%[%s]\"",property);
2757 (void) FormatLocaleString(value,MagickPathExtent,"0x%lx",(unsigned long)
2765 if (LocaleCompare("height",property) == 0)
2767 WarnNoImageReturn("\"%%[%s]\"",property);
2768 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",
2769 image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2776 if (LocaleCompare("input",property) == 0)
2778 WarnNoImageReturn("\"%%[%s]\"",property);
2779 string=image->filename;
2786 if (LocaleCompare("kurtosis",property) == 0)
2792 WarnNoImageReturn("\"%%[%s]\"",property);
2793 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
2794 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2795 GetMagickPrecision(),kurtosis);
2802 if (LocaleCompare("magick",property) == 0)
2804 WarnNoImageReturn("\"%%[%s]\"",property);
2805 string=image->magick;
2808 if ((LocaleCompare("maxima",property) == 0) ||
2809 (LocaleCompare("max",property) == 0))
2815 WarnNoImageReturn("\"%%[%s]\"",property);
2816 (void) GetImageRange(image,&minimum,&maximum,exception);
2817 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2818 GetMagickPrecision(),maximum);
2821 if (LocaleCompare("mean",property) == 0)
2827 WarnNoImageReturn("\"%%[%s]\"",property);
2828 (void) GetImageMean(image,&mean,&standard_deviation,exception);
2829 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2830 GetMagickPrecision(),mean);
2833 if ((LocaleCompare("minima",property) == 0) ||
2834 (LocaleCompare("min",property) == 0))
2840 WarnNoImageReturn("\"%%[%s]\"",property);
2841 (void) GetImageRange(image,&minimum,&maximum,exception);
2842 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2843 GetMagickPrecision(),minimum);
2850 if (LocaleCompare("opaque",property) == 0)
2852 WarnNoImageReturn("\"%%[%s]\"",property);
2853 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
2854 IsImageOpaque(image,exception));
2857 if (LocaleCompare("orientation",property) == 0)
2859 WarnNoImageReturn("\"%%[%s]\"",property);
2860 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
2861 image->orientation);
2864 if (LocaleCompare("output",property) == 0)
2866 WarnNoImageInfoReturn("\"%%[%s]\"",property);
2867 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
2874 #if defined(MAGICKCORE_LCMS_DELEGATE)
2875 if (LocaleCompare("profile:icc",property) == 0 ||
2876 LocaleCompare("profile:icm",property) == 0)
2878 #if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
2879 #define cmsUInt32Number DWORD
2888 profile=GetImageProfile(image,property+8);
2889 if (profile == (StringInfo *) NULL)
2891 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
2892 (cmsUInt32Number) GetStringInfoLength(profile));
2893 if (icc_profile != (cmsHPROFILE *) NULL)
2895 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
2896 string=cmsTakeProductName(icc_profile);
2898 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
2899 "en","US",value,MagickPathExtent);
2901 (void) cmsCloseProfile(icc_profile);
2905 if (LocaleCompare("profiles",property) == 0)
2910 ResetImageProfileIterator(image);
2911 name=GetNextImageProfile(image);
2912 if (name != (char *) NULL)
2914 (void) CopyMagickString(value,name,MagickPathExtent);
2915 name=GetNextImageProfile(image);
2916 while (name != (char *) NULL)
2918 ConcatenateMagickString(value,",",MagickPathExtent);
2919 ConcatenateMagickString(value,name,MagickPathExtent);
2920 name=GetNextImageProfile(image);
2929 if (LocaleCompare("resolution.x",property) == 0)
2931 WarnNoImageReturn("\"%%[%s]\"",property);
2932 (void) FormatLocaleString(value,MagickPathExtent,"%g",
2933 image->resolution.x);
2936 if (LocaleCompare("resolution.y",property) == 0)
2938 WarnNoImageReturn("\"%%[%s]\"",property);
2939 (void) FormatLocaleString(value,MagickPathExtent,"%g",
2940 image->resolution.y);
2947 if (LocaleCompare("scene",property) == 0)
2949 WarnNoImageInfoReturn("\"%%[%s]\"",property);
2950 if (image_info->number_scenes != 0)
2951 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2954 WarnNoImageReturn("\"%%[%s]\"",property);
2955 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2960 if (LocaleCompare("scenes",property) == 0)
2962 /* FUTURE: equivelent to %n? */
2963 WarnNoImageReturn("\"%%[%s]\"",property);
2964 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
2965 GetImageListLength(image));
2968 if (LocaleCompare("size",property) == 0)
2970 WarnNoImageReturn("\"%%[%s]\"",property);
2971 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,"B",
2972 MagickPathExtent,value);
2975 if (LocaleCompare("skewness",property) == 0)
2981 WarnNoImageReturn("\"%%[%s]\"",property);
2982 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
2983 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2984 GetMagickPrecision(),skewness);
2987 if (LocaleCompare("standard-deviation",property) == 0)
2993 WarnNoImageReturn("\"%%[%s]\"",property);
2994 (void) GetImageMean(image,&mean,&standard_deviation,exception);
2995 (void) FormatLocaleString(value,MagickPathExtent,"%.*g",
2996 GetMagickPrecision(),standard_deviation);
3003 if (LocaleCompare("type",property) == 0)
3005 WarnNoImageReturn("\"%%[%s]\"",property);
3006 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3007 IdentifyImageType(image,exception));
3014 if (LocaleCompare("unique",property) == 0)
3016 WarnNoImageInfoReturn("\"%%[%s]\"",property);
3017 string=image_info->unique;
3020 if (LocaleCompare("units",property) == 0)
3022 WarnNoImageReturn("\"%%[%s]\"",property);
3023 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3027 if (LocaleCompare("copyright",property) == 0)
3032 if (LocaleCompare("version",property) == 0)
3034 string=GetMagickVersion((size_t *) NULL);
3041 if (LocaleCompare("width",property) == 0)
3043 WarnNoImageReturn("\"%%[%s]\"",property);
3044 (void) FormatLocaleString(value,MagickPathExtent,"%.20g",(double)
3045 (image->magick_columns != 0 ? image->magick_columns : 256));
3052 if (LocaleCompare("zero",property) == 0)
3054 WarnNoImageInfoReturn("\"%%[%s]\"",property);
3055 string=image_info->zero;
3061 if (string != (char *) NULL)
3065 /* create a cloned copy of result, that will get cleaned up, eventually */
3066 if (image != (Image *) NULL)
3068 (void) SetImageArtifact(image,"get-property",value);
3069 return(GetImageArtifact(image,"get-property"));
3073 (void) SetImageOption(image_info,"get-property",value);
3074 return(GetImageOption(image_info,"get-property"));
3077 return((char *) NULL);
3079 #undef WarnNoImageReturn
3082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3086 % G e t N e x t I m a g e P r o p e r t y %
3090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3092 % GetNextImageProperty() gets the next free-form string property name.
3094 % The format of the GetNextImageProperty method is:
3096 % char *GetNextImageProperty(const Image *image)
3098 % A description of each parameter follows:
3100 % o image: the image.
3103 MagickExport const char *GetNextImageProperty(const Image *image)
3105 assert(image != (Image *) NULL);
3106 assert(image->signature == MagickCoreSignature);
3107 if (image->debug != MagickFalse)
3108 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3110 if (image->properties == (void *) NULL)
3111 return((const char *) NULL);
3112 return((const char *) GetNextKeyInSplayTree(
3113 (SplayTreeInfo *) image->properties));
3117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3121 % I n t e r p r e t I m a g e P r o p e r t i e s %
3125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3127 % InterpretImageProperties() replaces any embedded formatting characters with
3128 % the appropriate image property and returns the interpreted text.
3130 % This searches for and replaces
3131 % \n \r \% replaced by newline, return, and percent resp.
3132 % < > & replaced by '<', '>', '&' resp.
3133 % %% replaced by percent
3135 % %x %[x] where 'x' is a single letter properity, case sensitive).
3136 % %[type:name] where 'type' a is special and known prefix.
3137 % %[name] where 'name' is a specifically known attribute, calculated
3138 % value, or a per-image property string name, or a per-image
3139 % 'artifact' (as generated from a global option).
3140 % It may contain ':' as long as the prefix is not special.
3142 % Single letter % substitutions will only happen if the character before the
3143 % percent is NOT a number. But braced substitutions will always be performed.
3144 % This prevents the typical usage of percent in a interpreted geometry
3145 % argument from being substituted when the percent is a geometry flag.
3147 % If 'glob-expresions' ('*' or '?' characters) is used for 'name' it may be
3148 % used as a search pattern to print multiple lines of "name=value\n" pairs of
3149 % the associacted set of properties.
3151 % The returned string must be freed using DestoryString() by the caller.
3153 % The format of the InterpretImageProperties method is:
3155 % char *InterpretImageProperties(ImageInfo *image_info,
3156 % Image *image,const char *embed_text,ExceptionInfo *exception)
3158 % A description of each parameter follows:
3160 % o image_info: the image info. (required)
3162 % o image: the image. (optional)
3164 % o embed_text: the address of a character string containing the embedded
3165 % formatting characters.
3167 % o exception: return any errors or warnings in this structure.
3171 /* common inline code to expand the interpreted text string */
3172 #define ExtendInterpretText(string_length) do { \
3173 DisableMSCWarning(4127) \
3174 size_t length=(string_length); \
3175 if ((size_t) (q-interpret_text+length+1) >= extent) \
3177 interpret_text=(char *) ResizeQuantumMemory(interpret_text, \
3178 extent+MagickPathExtent,sizeof(*interpret_text)); \
3179 if (interpret_text == (char *) NULL) \
3180 return((char *) NULL); \
3181 q=interpret_text+strlen(interpret_text); \
3182 } } while (0) /* no trailing ; */ \
3185 /* same but append the given string */
3186 #define AppendString2Text(string) do { \
3187 DisableMSCWarning(4127) \
3188 size_t length=strlen((string)); \
3189 if ((size_t) (q-interpret_text+length+1) >= extent) \
3191 interpret_text=(char *) ResizeQuantumMemory(interpret_text, \
3192 extent+MagickPathExtent,sizeof(*interpret_text)); \
3193 if (interpret_text == (char *) NULL) \
3194 return((char *) NULL); \
3195 q=interpret_text+strlen(interpret_text); \
3197 (void) CopyMagickString(q,(string),extent); \
3199 } while (0) /* no trailing ; */ \
3202 /* same but append a 'key' and 'string' pair */
3203 #define AppendKeyValue2Text(key,string) do { \
3204 DisableMSCWarning(4127) \
3205 size_t length=strlen(key)+strlen(string)+2; \
3206 if ((size_t) (q-interpret_text+length+1) >= extent) \
3208 interpret_text=(char *) ResizeQuantumMemory(interpret_text, \
3209 extent+MagickPathExtent,sizeof(*interpret_text)); \
3210 if (interpret_text == (char *) NULL) \
3211 return((char *) NULL); \
3212 q=interpret_text+strlen(interpret_text); \
3214 q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(string)); \
3215 } while (0) /* no trailing ; */ \
3218 MagickExport char *InterpretImageProperties(ImageInfo *image_info,
3219 Image *image,const char *embed_text,ExceptionInfo *exception)
3225 *q; /* current position in interpret_text */
3228 *p; /* position in embed_text string being expanded */
3231 extent; /* allocated length of interpret_text */
3236 assert(image == NULL || image->signature == MagickCoreSignature);
3237 assert(image_info == NULL || image_info->signature == MagickCoreSignature);
3239 if (image != (Image *) NULL && image->debug != MagickFalse)
3240 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3241 else if( image_info != (ImageInfo *) NULL && image_info->debug != MagickFalse)
3242 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s","no-image");
3244 if (embed_text == (const char *) NULL)
3245 return(ConstantString(""));
3249 return(ConstantString(""));
3251 if ((*p == '@') && (IsPathAccessible(p+1) != MagickFalse))
3253 /* handle a '@' replace string from file */
3254 interpret_text=FileToString(p+1,~0UL,exception);
3255 if (interpret_text != (char *) NULL)
3256 return(interpret_text);
3260 Translate any embedded format characters.
3262 interpret_text=AcquireString(embed_text); /* new string with extra space */
3263 extent=MagickPathExtent; /* allocated space in string */
3264 number=MagickFalse; /* is last char a number? */
3265 for (q=interpret_text; *p!='\0'; number=isdigit(*p) ? MagickTrue : MagickFalse,p++)
3268 ExtendInterpretText(MagickPathExtent);
3270 Look for the various escapes, (and handle other specials)
3277 case 'r': /* convert to RETURN */
3281 case 'n': /* convert to NEWLINE */
3285 case '\n': /* EOL removal UNIX,MacOSX */
3288 case '\r': /* EOL removal DOS,Windows */
3290 if (*p == '\n') /* return-newline EOL */
3299 if (LocaleNCompare("<",p,4) == 0)
3301 else if (LocaleNCompare(">",p,4) == 0)
3303 else if (LocaleNCompare("&",p,5) == 0)
3309 break; /* continue to next set of handlers */
3311 *q++=(*p); /* any thing else is 'as normal' */
3314 p++; /* advance beyond the percent */
3317 Doubled Percent - or percent at end of string
3319 if ((*p == '\0') || (*p == '\'') || (*p == '"'))
3326 Single letter escapes %c
3332 /* But only if not preceeded by a number! */
3333 if (number != MagickFalse) {
3334 *q++='%'; /* do NOT substitute the percent */
3335 p--; /* back up one */
3338 string=GetMagickPropertyLetter(image_info,image,*p, exception);
3339 if (string != (char *) NULL)
3341 AppendString2Text(string);
3342 if (image != (Image *) NULL)
3343 (void)DeleteImageArtifact(image,"get-property");
3344 if (image_info != (ImageInfo *) NULL)
3345 (void)DeleteImageOption(image_info,"get-property");
3348 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3349 "UnknownImageProperty","\"%%%c\"",*p);
3354 Braced Percent Escape %[...]
3358 pattern[2*MagickPathExtent];
3370 /* get the property name framed by the %[...] */
3371 p++; /* advance p to just inside the opening brace */
3374 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3375 "UnknownImageProperty","\"%%[]\"");
3378 for (len=0; len<(MagickPathExtent-1L) && (*p != '\0');)
3380 /* skip escaped braces within braced pattern */
3381 if ( (*p == '\\') && (*(p+1) != '\0') ) {
3382 pattern[len++]=(*p++);
3383 pattern[len++]=(*p++);
3392 pattern[len++]=(*p++);
3395 /* Check for unmatched final ']' for "%[...]" */
3397 if (len >= 64) { /* truncate string for error message */
3403 (void) ThrowMagickException(exception,GetMagickModule(),
3404 OptionError,"UnbalancedBraces","\"%%[%s\"",pattern);
3405 interpret_text=DestroyString(interpret_text);
3406 return((char *) NULL);
3410 Special Lookup Prefixes %[prefix:...]
3412 /* fx - value calculator */
3413 if (LocaleNCompare("fx:",pattern,3) == 0)
3424 if (image == (Image *) NULL ) {
3425 (void) ThrowMagickException(exception,GetMagickModule(),
3426 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3427 continue; /* else no image to retrieve artifact */
3429 fx_info=AcquireFxInfo(image,pattern+3,exception);
3430 status=FxEvaluateChannelExpression(fx_info,IntensityPixelChannel,0,0,
3432 fx_info=DestroyFxInfo(fx_info);
3433 if (status != MagickFalse)
3436 result[MagickPathExtent];
3438 (void) FormatLocaleString(result,MagickPathExtent,"%.*g",
3439 GetMagickPrecision(),(double) value);
3440 AppendString2Text(result);
3444 /* pixel - color value calculator */
3445 if (LocaleNCompare("pixel:",pattern,6) == 0)
3459 if (image == (Image *) NULL ) {
3460 (void) ThrowMagickException(exception,GetMagickModule(),
3461 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3462 continue; /* else no image to retrieve artifact */
3464 GetPixelInfo(image,&pixel);
3465 fx_info=AcquireFxInfo(image,pattern+6,exception);
3466 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
3468 pixel.red=(double) QuantumRange*value;
3469 status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
3471 pixel.green=(double) QuantumRange*value;
3472 status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
3474 pixel.blue=(double) QuantumRange*value;
3475 if (image->colorspace == CMYKColorspace)
3477 status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
3479 pixel.black=(double) QuantumRange*value;
3481 status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
3483 pixel.alpha=(double) QuantumRange*value;
3484 fx_info=DestroyFxInfo(fx_info);
3485 if (status != MagickFalse)
3488 name[MagickPathExtent];
3490 (void) QueryColorname(image,&pixel,SVGCompliance,name,
3492 AppendString2Text(name);
3496 /* option - direct global option lookup (with globbing) */
3497 if (LocaleNCompare("option:",pattern,7) == 0)
3499 if (image_info == (ImageInfo *) NULL ) {
3500 (void) ThrowMagickException(exception,GetMagickModule(),
3501 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3502 continue; /* else no image to retrieve artifact */
3504 if (IsGlob(pattern+7) != MagickFalse)
3506 ResetImageOptionIterator(image_info);
3507 while ((key=GetNextImageOption(image_info)) != (const char *) NULL)
3508 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
3510 string=GetImageOption(image_info,key);
3511 if (string != (const char *) NULL)
3512 AppendKeyValue2Text(key,string);
3513 /* else - assertion failure? key found but no string value! */
3517 string=GetImageOption(image_info,pattern+7);
3518 if (string == (char *) NULL)
3519 goto PropertyLookupFailure; /* no artifact of this specifc name */
3520 AppendString2Text(string);
3523 /* artifact - direct image artifact lookup (with glob) */
3524 if (LocaleNCompare("artifact:",pattern,9) == 0)
3526 if (image == (Image *) NULL ) {
3527 (void) ThrowMagickException(exception,GetMagickModule(),
3528 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3529 continue; /* else no image to retrieve artifact */
3531 if (IsGlob(pattern+9) != MagickFalse)
3533 ResetImageArtifactIterator(image);
3534 while ((key=GetNextImageArtifact(image)) != (const char *) NULL)
3535 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
3537 string=GetImageArtifact(image,key);
3538 if (string != (const char *) NULL)
3539 AppendKeyValue2Text(key,string);
3540 /* else - assertion failure? key found but no string value! */
3544 string=GetImageArtifact(image,pattern+9);
3545 if (string == (char *) NULL)
3546 goto PropertyLookupFailure; /* no artifact of this specifc name */
3547 AppendString2Text(string);
3550 /* property - direct image property lookup (with glob) */
3551 if (LocaleNCompare("property:",pattern,9) == 0)
3553 if (image == (Image *) NULL ) {
3554 (void) ThrowMagickException(exception,GetMagickModule(),
3555 OptionWarning,"NoImageForProperty","\"%%[%s]\"",pattern);
3556 continue; /* else no image to retrieve artifact */
3558 if (IsGlob(pattern+9) != MagickFalse)
3560 ResetImagePropertyIterator(image);
3561 while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3562 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3564 string=GetImageProperty(image,key,exception);
3565 if (string != (const char *) NULL)
3566 AppendKeyValue2Text(key,string);
3567 /* else - assertion failure? */
3571 string=GetImageProperty(image,pattern+9,exception);
3572 if (string == (char *) NULL)
3573 goto PropertyLookupFailure; /* no artifact of this specifc name */
3574 AppendString2Text(string);
3577 /* Properties without special prefix.
3578 This handles attributes, properties, and profiles such as %[exif:...]
3579 Note the profile properties may also include a glob expansion pattern.
3581 if (image != (Image *) NULL)
3583 string=GetImageProperty(image,pattern,exception);
3584 if (string != (const char *) NULL)
3586 AppendString2Text(string);
3587 if (image != (Image *) NULL)
3588 (void)DeleteImageArtifact(image,"get-property");
3589 if (image_info != (ImageInfo *) NULL)
3590 (void)DeleteImageOption(image_info,"get-property");
3595 Handle property 'glob' patterns
3596 Such as: %[*] %[user:array_??] %[filename:e*]
3598 if (IsGlob(pattern) != MagickFalse)
3600 if (image == (Image *) NULL)
3601 continue; /* else no image to retrieve proprty - no list */
3602 ResetImagePropertyIterator(image);
3603 while ((key=GetNextImageProperty(image)) != (const char *) NULL)
3604 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3606 string=GetImageProperty(image,key,exception);
3607 if (string != (const char *) NULL)
3608 AppendKeyValue2Text(key,string);
3609 /* else - assertion failure? */
3614 Look for a known property or image attribute
3615 Such as %[basename] %[denisty] %[delay]
3616 Also handles a braced single letter: %[b] %[G] %[g]
3618 string=GetMagickProperty(image_info,image,pattern,exception);
3619 if (string != (const char *) NULL)
3621 AppendString2Text(string);
3625 Look for a per-image Artifact
3626 This includes option lookup (FUTURE: interpreted according to image)
3628 if (image != (Image *) NULL)
3630 string=GetImageArtifact(image,pattern);
3631 if (string != (char *) NULL)
3633 AppendString2Text(string);
3638 /* no image, so direct 'option' lookup (no delayed percent escapes) */
3639 if (image_info != (ImageInfo *) NULL)
3641 string=GetImageOption(image_info,pattern);
3642 if (string != (char *) NULL)
3644 AppendString2Text(string);
3648 PropertyLookupFailure:
3650 Failed to find any match anywhere!
3652 if (len >= 64) { /* truncate string for error message */
3658 (void) ThrowMagickException(exception,GetMagickModule(),
3659 OptionWarning,"UnknownImageProperty","\"%%[%s]\"",pattern);
3661 } /* Braced Percent Escape */
3663 } /* for each char in 'embed_text' */
3665 return(interpret_text);
3669 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3673 % R e m o v e I m a g e P r o p e r t y %
3677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3679 % RemoveImageProperty() removes a property from the image and returns its
3682 % In this case the ConstantString() value returned should be freed by the
3683 % caller when finished.
3685 % The format of the RemoveImageProperty method is:
3687 % char *RemoveImageProperty(Image *image,const char *property)
3689 % A description of each parameter follows:
3691 % o image: the image.
3693 % o property: the image property.
3696 MagickExport char *RemoveImageProperty(Image *image,
3697 const char *property)
3702 assert(image != (Image *) NULL);
3703 assert(image->signature == MagickCoreSignature);
3704 if (image->debug != MagickFalse)
3705 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3707 if (image->properties == (void *) NULL)
3708 return((char *) NULL);
3709 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3719 % 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 %
3723 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3725 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3726 % in conjunction with GetNextImageProperty() to iterate over all the values
3727 % associated with an image property.
3729 % The format of the ResetImagePropertyIterator method is:
3731 % ResetImagePropertyIterator(Image *image)
3733 % A description of each parameter follows:
3735 % o image: the image.
3738 MagickExport void ResetImagePropertyIterator(const Image *image)
3740 assert(image != (Image *) NULL);
3741 assert(image->signature == MagickCoreSignature);
3742 if (image->debug != MagickFalse)
3743 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3745 if (image->properties == (void *) NULL)
3747 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3751 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3755 % S e t I m a g e P r o p e r t y %
3759 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3761 % SetImageProperty() saves the given string value either to specific known
3762 % attribute or to a freeform property string.
3764 % Attempting to set a property that is normally calculated will produce
3767 % The format of the SetImageProperty method is:
3769 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3770 % const char *value,ExceptionInfo *exception)
3772 % A description of each parameter follows:
3774 % o image: the image.
3776 % o property: the image property.
3778 % o values: the image property values.
3780 % o exception: return any errors or warnings in this structure.
3783 MagickExport MagickBooleanType SetImageProperty(Image *image,
3784 const char *property,const char *value,ExceptionInfo *exception)
3792 assert(image != (Image *) NULL);
3793 assert(image->signature == MagickCoreSignature);
3794 if (image->debug != MagickFalse)
3795 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3796 if (image->properties == (void *) NULL)
3797 image->properties=NewSplayTree(CompareSplayTreeString,
3798 RelinquishMagickMemory,RelinquishMagickMemory); /* create splay-tree */
3799 if (value == (const char *) NULL)
3800 return(DeleteImageProperty(image,property)); /* delete if NULL */
3802 if (strlen(property) <= 1)
3805 Do not 'set' single letter properties - read only shorthand.
3807 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3808 "SetReadOnlyProperty","`%s'",property);
3809 return(MagickFalse);
3812 /* FUTURE: binary chars or quotes in key should produce a error */
3813 /* Set attributes with known names or special prefixes
3814 return result is found, or break to set a free form properity
3818 #if 0 /* Percent escape's sets values with this prefix: for later use
3819 Throwing an exception causes this setting to fail */
3822 if (LocaleNCompare("8bim:",property,5) == 0)
3824 (void) ThrowMagickException(exception,GetMagickModule(),
3825 OptionError,"SetReadOnlyProperty","`%s'",property);
3826 return(MagickFalse);
3834 if (LocaleCompare("background",property) == 0)
3836 (void) QueryColorCompliance(value,AllCompliance,
3837 &image->background_color,exception);
3838 /* check for FUTURE: value exception?? */
3839 /* also add user input to splay tree */
3841 break; /* not an attribute, add as a property */
3846 if (LocaleCompare("channels",property) == 0)
3848 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3849 "SetReadOnlyProperty","`%s'",property);
3850 return(MagickFalse);
3852 if (LocaleCompare("colorspace",property) == 0)
3857 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
3860 return(MagickFalse); /* FUTURE: value exception?? */
3861 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
3863 if (LocaleCompare("compose",property) == 0)
3868 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
3870 return(MagickFalse); /* FUTURE: value exception?? */
3871 image->compose=(CompositeOperator) compose;
3874 if (LocaleCompare("compress",property) == 0)
3879 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
3881 if (compression < 0)
3882 return(MagickFalse); /* FUTURE: value exception?? */
3883 image->compression=(CompressionType) compression;
3886 break; /* not an attribute, add as a property */
3891 if (LocaleCompare("delay",property) == 0)
3896 flags=ParseGeometry(value,&geometry_info);
3897 if ((flags & GreaterValue) != 0)
3899 if (image->delay > (size_t) floor(geometry_info.rho+0.5))
3900 image->delay=(size_t) floor(geometry_info.rho+0.5);
3903 if ((flags & LessValue) != 0)
3905 if (image->delay < (size_t) floor(geometry_info.rho+0.5))
3906 image->delay=(ssize_t)
3907 floor(geometry_info.sigma+0.5);
3910 image->delay=(size_t) floor(geometry_info.rho+0.5);
3911 if ((flags & SigmaValue) != 0)
3912 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
3915 if (LocaleCompare("delay_units",property) == 0)
3917 (void) ThrowMagickException(exception,GetMagickModule(),
3918 OptionError,"SetReadOnlyProperty","`%s'",property);
3919 return(MagickFalse);
3921 if (LocaleCompare("density",property) == 0)
3926 flags=ParseGeometry(value,&geometry_info);
3927 image->resolution.x=geometry_info.rho;
3928 image->resolution.y=geometry_info.sigma;
3929 if ((flags & SigmaValue) == 0)
3930 image->resolution.y=image->resolution.x;
3933 if (LocaleCompare("depth",property) == 0)
3935 image->depth=StringToUnsignedLong(value);
3938 if (LocaleCompare("dispose",property) == 0)
3943 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
3945 return(MagickFalse); /* FUTURE: value exception?? */
3946 image->dispose=(DisposeType) dispose;
3949 break; /* not an attribute, add as a property */
3951 #if 0 /* Percent escape's sets values with this prefix: for later use
3952 Throwing an exception causes this setting to fail */
3956 if (LocaleNCompare("exif:",property,5) == 0)
3958 (void) ThrowMagickException(exception,GetMagickModule(),
3959 OptionError,"SetReadOnlyProperty","`%s'",property);
3960 return(MagickFalse);
3962 break; /* not an attribute, add as a property */
3967 if (LocaleNCompare("fx:",property,3) == 0)
3969 (void) ThrowMagickException(exception,GetMagickModule(),
3970 OptionError,"SetReadOnlyProperty","`%s'",property);
3971 return(MagickFalse);
3973 break; /* not an attribute, add as a property */
3979 if (LocaleCompare("gamma",property) == 0)
3981 image->gamma=StringToDouble(value,(char **) NULL);
3984 if (LocaleCompare("gravity",property) == 0)
3989 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
3991 return(MagickFalse); /* FUTURE: value exception?? */
3992 image->gravity=(GravityType) gravity;
3995 break; /* not an attribute, add as a property */
4000 if (LocaleCompare("height",property) == 0)
4002 (void) ThrowMagickException(exception,GetMagickModule(),
4003 OptionError,"SetReadOnlyProperty","`%s'",property);
4004 return(MagickFalse);
4006 break; /* not an attribute, add as a property */
4011 if (LocaleCompare("intensity",property) == 0)
4016 intensity=ParseCommandOption(MagickIntentOptions,MagickFalse,
4019 return(MagickFalse);
4020 image->intensity=(PixelIntensityMethod) intensity;
4023 if (LocaleCompare("intent",property) == 0)
4028 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4030 if (rendering_intent < 0)
4031 return(MagickFalse); /* FUTURE: value exception?? */
4032 image->rendering_intent=(RenderingIntent) rendering_intent;
4035 if (LocaleCompare("interpolate",property) == 0)
4040 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4042 if (interpolate < 0)
4043 return(MagickFalse); /* FUTURE: value exception?? */
4044 image->interpolate=(PixelInterpolateMethod) interpolate;
4047 #if 0 /* Percent escape's sets values with this prefix: for later use
4048 Throwing an exception causes this setting to fail */
4049 if (LocaleNCompare("iptc:",property,5) == 0)
4051 (void) ThrowMagickException(exception,GetMagickModule(),
4052 OptionError,"SetReadOnlyProperty","`%s'",property);
4053 return(MagickFalse);
4056 break; /* not an attribute, add as a property */
4060 if (LocaleCompare("kurtosis",property) == 0)
4062 (void) ThrowMagickException(exception,GetMagickModule(),
4063 OptionError,"SetReadOnlyProperty","`%s'",property);
4064 return(MagickFalse);
4066 break; /* not an attribute, add as a property */
4070 if (LocaleCompare("loop",property) == 0)
4072 image->iterations=StringToUnsignedLong(value);
4075 break; /* not an attribute, add as a property */
4079 if ( (LocaleCompare("magick",property) == 0) ||
4080 (LocaleCompare("max",property) == 0) ||
4081 (LocaleCompare("mean",property) == 0) ||
4082 (LocaleCompare("min",property) == 0) ||
4083 (LocaleCompare("min",property) == 0) )
4085 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4086 "SetReadOnlyProperty","`%s'",property);
4087 return(MagickFalse);
4089 break; /* not an attribute, add as a property */
4092 if (LocaleCompare("opaque",property) == 0)
4094 (void) ThrowMagickException(exception,GetMagickModule(),
4095 OptionError,"SetReadOnlyProperty","`%s'",property);
4096 return(MagickFalse);
4098 break; /* not an attribute, add as a property */
4102 if (LocaleCompare("page",property) == 0)
4107 geometry=GetPageGeometry(value);
4108 flags=ParseAbsoluteGeometry(geometry,&image->page);
4109 geometry=DestroyString(geometry);
4112 #if 0 /* Percent escape's sets values with this prefix: for later use
4113 Throwing an exception causes this setting to fail */
4114 if (LocaleNCompare("pixel:",property,6) == 0)
4116 (void) ThrowMagickException(exception,GetMagickModule(),
4117 OptionError,"SetReadOnlyProperty","`%s'",property);
4118 return(MagickFalse);
4121 if (LocaleCompare("profile",property) == 0)
4129 image_info=AcquireImageInfo();
4130 (void) CopyMagickString(image_info->filename,value,MagickPathExtent);
4131 (void) SetImageInfo(image_info,1,exception);
4132 profile=FileToStringInfo(image_info->filename,~0UL,exception);
4133 if (profile != (StringInfo *) NULL)
4134 status=SetImageProfile(image,image_info->magick,profile,exception);
4135 image_info=DestroyImageInfo(image_info);
4138 break; /* not an attribute, add as a property */
4143 if (LocaleCompare("rendering-intent",property) == 0)
4148 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4150 if (rendering_intent < 0)
4151 return(MagickFalse); /* FUTURE: value exception?? */
4152 image->rendering_intent=(RenderingIntent) rendering_intent;
4155 break; /* not an attribute, add as a property */
4159 if ( (LocaleCompare("size",property) == 0) ||
4160 (LocaleCompare("skewness",property) == 0) ||
4161 (LocaleCompare("scenes",property) == 0) ||
4162 (LocaleCompare("standard-deviation",property) == 0) )
4164 (void) ThrowMagickException(exception,GetMagickModule(),
4165 OptionError,"SetReadOnlyProperty","`%s'",property);
4166 return(MagickFalse);
4168 break; /* not an attribute, add as a property */
4172 if (LocaleCompare("tile-offset",property) == 0)
4177 geometry=GetPageGeometry(value);
4178 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4179 geometry=DestroyString(geometry);
4182 break; /* not an attribute, add as a property */
4187 if (LocaleCompare("units",property) == 0)
4192 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4194 return(MagickFalse); /* FUTURE: value exception?? */
4195 image->units=(ResolutionType) units;
4198 break; /* not an attribute, add as a property */
4203 if (LocaleCompare("version",property) == 0)
4205 (void) ThrowMagickException(exception,GetMagickModule(),
4206 OptionError,"SetReadOnlyProperty","`%s'",property);
4207 return(MagickFalse);
4209 break; /* not an attribute, add as a property */
4214 if (LocaleCompare("width",property) == 0)
4216 (void) ThrowMagickException(exception,GetMagickModule(),
4217 OptionError,"SetReadOnlyProperty","`%s'",property);
4218 return(MagickFalse);
4220 break; /* not an attribute, add as a property */
4222 #if 0 /* Percent escape's sets values with this prefix: for later use
4223 Throwing an exception causes this setting to fail */
4227 if (LocaleNCompare("xmp:",property,4) == 0)
4229 (void) ThrowMagickException(exception,GetMagickModule(),
4230 OptionError,"SetReadOnlyProperty","`%s'",property);
4231 return(MagickFalse);
4233 break; /* not an attribute, add as a property */
4237 /* Default: not an attribute, add as a property */
4238 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4239 ConstantString(property),ConstantString(value));
4240 /* FUTURE: error if status is bad? */