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-2012 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/color.h"
48 #include "MagickCore/compare.h"
49 #include "MagickCore/constitute.h"
50 #include "MagickCore/draw.h"
51 #include "MagickCore/effect.h"
52 #include "MagickCore/exception.h"
53 #include "MagickCore/exception-private.h"
54 #include "MagickCore/fx.h"
55 #include "MagickCore/fx-private.h"
56 #include "MagickCore/gem.h"
57 #include "MagickCore/geometry.h"
58 #include "MagickCore/histogram.h"
59 #include "MagickCore/image.h"
60 #include "MagickCore/image.h"
61 #include "MagickCore/layer.h"
62 #include "MagickCore/locale-private.h"
63 #include "MagickCore/list.h"
64 #include "MagickCore/magick.h"
65 #include "MagickCore/memory_.h"
66 #include "MagickCore/monitor.h"
67 #include "MagickCore/montage.h"
68 #include "MagickCore/option.h"
69 #include "MagickCore/profile.h"
70 #include "MagickCore/property.h"
71 #include "MagickCore/quantum.h"
72 #include "MagickCore/resource_.h"
73 #include "MagickCore/splay-tree.h"
74 #include "MagickCore/signature.h"
75 #include "MagickCore/statistic.h"
76 #include "MagickCore/string_.h"
77 #include "MagickCore/string-private.h"
78 #include "MagickCore/token.h"
79 #include "MagickCore/token-private.h"
80 #include "MagickCore/utility.h"
81 #include "MagickCore/utility-private.h"
82 #include "MagickCore/version.h"
83 #include "MagickCore/xml-tree.h"
84 #include "MagickCore/xml-tree-private.h"
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 % C l o n e I m a g e P r o p e r t i e s %
95 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
97 % CloneImageProperties() clones one or more image properties.
99 % The format of the CloneImageProperties method is:
101 % MagickBooleanType CloneImageProperties(Image *image,
102 % const Image *clone_image)
104 % A description of each parameter follows:
106 % o image: the image.
108 % o clone_image: the clone image.
111 MagickExport MagickBooleanType CloneImageProperties(Image *image,
112 const Image *clone_image)
114 assert(image != (Image *) NULL);
115 assert(image->signature == MagickSignature);
116 if( IfMagickTrue(image->debug) )
117 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
118 assert(clone_image != (const Image *) NULL);
119 assert(clone_image->signature == MagickSignature);
120 if( IfMagickTrue(clone_image->debug) )
121 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
122 clone_image->filename);
123 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
124 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
126 image->compression=clone_image->compression;
127 image->quality=clone_image->quality;
128 image->depth=clone_image->depth;
129 image->background_color=clone_image->background_color;
130 image->border_color=clone_image->border_color;
131 image->matte_color=clone_image->matte_color;
132 image->transparent_color=clone_image->transparent_color;
133 image->gamma=clone_image->gamma;
134 image->chromaticity=clone_image->chromaticity;
135 image->rendering_intent=clone_image->rendering_intent;
136 image->black_point_compensation=clone_image->black_point_compensation;
137 image->units=clone_image->units;
138 image->montage=(char *) NULL;
139 image->directory=(char *) NULL;
140 (void) CloneString(&image->geometry,clone_image->geometry);
141 image->offset=clone_image->offset;
142 image->resolution.x=clone_image->resolution.x;
143 image->resolution.y=clone_image->resolution.y;
144 image->page=clone_image->page;
145 image->tile_offset=clone_image->tile_offset;
146 image->extract_info=clone_image->extract_info;
147 image->filter=clone_image->filter;
148 image->fuzz=clone_image->fuzz;
149 image->interlace=clone_image->interlace;
150 image->interpolate=clone_image->interpolate;
151 image->endian=clone_image->endian;
152 image->gravity=clone_image->gravity;
153 image->compose=clone_image->compose;
154 image->scene=clone_image->scene;
155 image->orientation=clone_image->orientation;
156 image->dispose=clone_image->dispose;
157 image->delay=clone_image->delay;
158 image->ticks_per_second=clone_image->ticks_per_second;
159 image->iterations=clone_image->iterations;
160 image->total_colors=clone_image->total_colors;
161 image->taint=clone_image->taint;
162 image->progress_monitor=clone_image->progress_monitor;
163 image->client_data=clone_image->client_data;
164 image->start_loop=clone_image->start_loop;
165 image->error=clone_image->error;
166 image->signature=clone_image->signature;
167 if (clone_image->properties != (void *) NULL)
169 if (image->properties != (void *) NULL)
170 DestroyImageProperties(image);
171 image->properties=CloneSplayTree((SplayTreeInfo *)
172 clone_image->properties,(void *(*)(void *)) ConstantString,
173 (void *(*)(void *)) ConstantString);
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 % D e f i n e I m a g e P r o p e r t y %
187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
189 % DefineImageProperty() associates a key/value pair with an image property.
191 % The format of the DefineImageProperty method is:
193 % MagickBooleanType DefineImageProperty(Image *image,
194 % const char *property,ExceptionInfo *exception)
196 % A description of each parameter follows:
198 % o image: the image.
200 % o property: the image property.
202 % o exception: return any errors or warnings in this structure.
205 MagickExport MagickBooleanType DefineImageProperty(Image *image,
206 const char *property,ExceptionInfo *exception)
210 value[MaxTextExtent];
215 assert(image != (Image *) NULL);
216 assert(property != (const char *) NULL);
217 (void) CopyMagickString(key,property,MaxTextExtent-1);
218 for (p=key; *p != '\0'; p++)
223 (void) CopyMagickString(value,p+1,MaxTextExtent);
225 return(SetImageProperty(image,key,value,exception));
229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
233 % D e l e t e I m a g e P r o p e r t y %
237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 % DeleteImageProperty() deletes an image property.
241 % The format of the DeleteImageProperty method is:
243 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
245 % A description of each parameter follows:
247 % o image: the image.
249 % o property: the image property.
252 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
253 const char *property)
255 assert(image != (Image *) NULL);
256 assert(image->signature == MagickSignature);
257 if( IfMagickTrue(image->debug) )
258 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
260 if (image->properties == (void *) NULL)
262 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
270 % D e s t r o y I m a g e P r o p e r t i e s %
274 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276 % DestroyImageProperties() releases memory associated with image property
279 % The format of the DestroyDefines method is:
281 % void DestroyImageProperties(Image *image)
283 % A description of each parameter follows:
285 % o image: the image.
288 MagickExport void DestroyImageProperties(Image *image)
290 assert(image != (Image *) NULL);
291 assert(image->signature == MagickSignature);
292 if( IfMagickTrue(image->debug) )
293 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
295 if (image->properties != (void *) NULL)
296 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 % F o r m a t I m a g e P r o p e r t y %
309 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
311 % FormatImageProperty() permits formatted property/value pairs to be saved as
314 % The format of the FormatImageProperty method is:
316 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
317 % const char *format,...)
319 % A description of each parameter follows.
321 % o image: The image.
323 % o property: The attribute property.
325 % o format: A string describing the format to use to write the remaining
329 MagickExport MagickBooleanType FormatImageProperty(Image *image,
330 const char *property,const char *format,...)
333 value[MaxTextExtent];
347 va_start(operands,format);
348 n=FormatLocaleStringList(value,MaxTextExtent,format,operands);
351 exception=AcquireExceptionInfo();
352 status=SetImageProperty(image,property,value,exception);
353 exception=DestroyExceptionInfo(exception);
358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362 % G e t I m a g e P r o p e r t y %
366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368 % GetImageProperty() gets a value associated with an image property.
370 % The format of the GetImageProperty method is:
372 % const char *GetImageProperty(const Image *image,const char *key,
373 % ExceptionInfo *exception)
375 % A description of each parameter follows:
377 % o image: the image.
381 % o exception: return any errors or warnings in this structure.
386 *TracePSClippath(const unsigned char *,size_t,const size_t,
388 *TraceSVGClippath(const unsigned char *,size_t,const size_t,
391 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key,
392 ExceptionInfo *exception)
412 profile=GetImageProfile(image,"iptc");
413 if (profile == (StringInfo *) NULL)
414 profile=GetImageProfile(image,"8bim");
415 if (profile == (StringInfo *) NULL)
417 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
420 attribute=(char *) NULL;
421 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
424 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
426 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
427 length|=GetStringInfoDatum(profile)[i+4];
428 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
429 ((long) GetStringInfoDatum(profile)[i+2] == record))
431 message=(char *) NULL;
433 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
434 if (message != (char *) NULL)
436 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
437 profile)+i+5,length+1);
438 (void) ConcatenateString(&attribute,message);
439 (void) ConcatenateString(&attribute,";");
440 message=DestroyString(message);
445 if ((attribute == (char *) NULL) || (*attribute == ';'))
447 if (attribute != (char *) NULL)
448 attribute=DestroyString(attribute);
451 attribute[strlen(attribute)-1]='\0';
452 (void) SetImageProperty((Image *) image,key,(const char *) attribute,
454 attribute=DestroyString(attribute);
458 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
465 static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
472 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
484 static inline size_t ReadPropertyMSBLong(const unsigned char **p,
501 for (i=0; i < 4; i++)
505 buffer[i]=(unsigned char) c;
507 value=(size_t) (buffer[0] << 24);
508 value|=buffer[1] << 16;
509 value|=buffer[2] << 8;
511 return(value & 0xffffffff);
514 static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
530 return((unsigned short) ~0U);
531 for (i=0; i < 2; i++)
535 buffer[i]=(unsigned char) c;
537 value=(unsigned short) (buffer[0] << 8);
539 return((unsigned short) (value & 0xffff));
542 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key,
543 ExceptionInfo *exception)
547 format[MaxTextExtent],
576 There are no newlines in path names, so it's safe as terminator.
578 profile=GetImageProfile(image,"8bim");
579 if (profile == (StringInfo *) NULL)
581 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name,
583 if ((count != 2) && (count != 3) && (count != 4))
586 (void) CopyMagickString(format,"SVG",MaxTextExtent);
591 sub_number=(ssize_t) StringToLong(&name[1]);
592 sub_number=MagickMax(sub_number,1L);
593 resource=(char *) NULL;
595 length=GetStringInfoLength(profile);
596 info=GetStringInfoDatum(profile);
597 while ((length > 0) && IfMagickFalse(status))
599 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
601 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
603 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
605 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
607 id=(ssize_t) ((int) ReadPropertyMSBShort(&info,&length));
608 if (id < (ssize_t) start)
610 if (id > (ssize_t) stop)
612 if (resource != (char *) NULL)
613 resource=DestroyString(resource);
614 count=(ssize_t) ReadPropertyByte(&info,&length);
615 if ((count != 0) && ((size_t) count <= length))
617 resource=(char *) NULL;
618 if (~(1UL*count) >= (MaxTextExtent-1))
619 resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
621 if (resource != (char *) NULL)
623 for (i=0; i < (ssize_t) count; i++)
624 resource[i]=(char) ReadPropertyByte(&info,&length);
625 resource[count]='\0';
628 if ((count & 0x01) == 0)
629 (void) ReadPropertyByte(&info,&length);
630 count=(ssize_t) ((int) ReadPropertyMSBLong(&info,&length));
631 if ((*name != '\0') && (*name != '#'))
632 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
635 No name match, scroll forward and try next.
638 length-=MagickMin(count,(ssize_t) length);
641 if ((*name == '#') && (sub_number != 1))
644 No numbered match, scroll forward and try next.
648 length-=MagickMin(count,(ssize_t) length);
652 We have the resource of interest.
654 attribute=(char *) NULL;
655 if (~(1UL*count) >= (MaxTextExtent-1))
656 attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
658 if (attribute != (char *) NULL)
660 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
661 attribute[count]='\0';
663 length-=MagickMin(count,(ssize_t) length);
664 if ((id <= 1999) || (id >= 2999))
665 (void) SetImageProperty((Image *) image,key,(const char *)
666 attribute,exception);
672 if (LocaleCompare(format,"svg") == 0)
673 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
674 image->columns,image->rows);
676 path=TracePSClippath((unsigned char *) attribute,(size_t) count,
677 image->columns,image->rows);
678 (void) SetImageProperty((Image *) image,key,(const char *) path,
680 path=DestroyString(path);
682 attribute=DestroyString(attribute);
686 if (resource != (char *) NULL)
687 resource=DestroyString(resource);
691 static inline unsigned short ReadPropertyShort(const EndianType endian,
692 const unsigned char *buffer)
697 if (endian == MSBEndian)
699 value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
700 ((unsigned char *) buffer)[1]);
701 return((unsigned short) (value & 0xffff));
703 value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
704 return((unsigned short) (value & 0xffff));
707 static inline size_t ReadPropertyLong(const EndianType endian,
708 const unsigned char *buffer)
713 if (endian == MSBEndian)
715 value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
716 (buffer[2] << 8) | buffer[3]);
717 return((size_t) (value & 0xffffffff));
719 value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
720 (buffer[1] << 8 ) | (buffer[0]));
721 return((size_t) (value & 0xffffffff));
724 static MagickBooleanType GetEXIFProperty(const Image *image,
725 const char *property,ExceptionInfo *exception)
727 #define MaxDirectoryStack 16
728 #define EXIF_DELIMITER "\n"
729 #define EXIF_NUM_FORMATS 12
730 #define EXIF_FMT_BYTE 1
731 #define EXIF_FMT_STRING 2
732 #define EXIF_FMT_USHORT 3
733 #define EXIF_FMT_ULONG 4
734 #define EXIF_FMT_URATIONAL 5
735 #define EXIF_FMT_SBYTE 6
736 #define EXIF_FMT_UNDEFINED 7
737 #define EXIF_FMT_SSHORT 8
738 #define EXIF_FMT_SLONG 9
739 #define EXIF_FMT_SRATIONAL 10
740 #define EXIF_FMT_SINGLE 11
741 #define EXIF_FMT_DOUBLE 12
742 #define TAG_EXIF_OFFSET 0x8769
743 #define TAG_GPS_OFFSET 0x8825
744 #define TAG_INTEROP_OFFSET 0xa005
746 #define EXIFMultipleValues(size,format,arg) \
759 for (component=0; component < components; component++) \
761 length+=FormatLocaleString(buffer+length,MaxTextExtent-length, \
763 if (length >= (MaxTextExtent-1)) \
764 length=MaxTextExtent-1; \
768 buffer[length-2]='\0'; \
769 value=AcquireString(buffer); \
772 #define EXIFMultipleFractions(size,format,arg1,arg2) \
785 for (component=0; component < components; component++) \
787 length+=FormatLocaleString(buffer+length,MaxTextExtent-length, \
788 format", ",(arg1),(arg2)); \
789 if (length >= (MaxTextExtent-1)) \
790 length=MaxTextExtent-1; \
794 buffer[length-2]='\0'; \
795 value=AcquireString(buffer); \
798 typedef struct _DirectoryInfo
810 typedef struct _TagInfo
822 { 0x001, "exif:InteroperabilityIndex" },
823 { 0x002, "exif:InteroperabilityVersion" },
824 { 0x100, "exif:ImageWidth" },
825 { 0x101, "exif:ImageLength" },
826 { 0x102, "exif:BitsPerSample" },
827 { 0x103, "exif:Compression" },
828 { 0x106, "exif:PhotometricInterpretation" },
829 { 0x10a, "exif:FillOrder" },
830 { 0x10d, "exif:DocumentName" },
831 { 0x10e, "exif:ImageDescription" },
832 { 0x10f, "exif:Make" },
833 { 0x110, "exif:Model" },
834 { 0x111, "exif:StripOffsets" },
835 { 0x112, "exif:Orientation" },
836 { 0x115, "exif:SamplesPerPixel" },
837 { 0x116, "exif:RowsPerStrip" },
838 { 0x117, "exif:StripByteCounts" },
839 { 0x11a, "exif:XResolution" },
840 { 0x11b, "exif:YResolution" },
841 { 0x11c, "exif:PlanarConfiguration" },
842 { 0x11d, "exif:PageName" },
843 { 0x11e, "exif:XPosition" },
844 { 0x11f, "exif:YPosition" },
845 { 0x118, "exif:MinSampleValue" },
846 { 0x119, "exif:MaxSampleValue" },
847 { 0x120, "exif:FreeOffsets" },
848 { 0x121, "exif:FreeByteCounts" },
849 { 0x122, "exif:GrayResponseUnit" },
850 { 0x123, "exif:GrayResponseCurve" },
851 { 0x124, "exif:T4Options" },
852 { 0x125, "exif:T6Options" },
853 { 0x128, "exif:ResolutionUnit" },
854 { 0x12d, "exif:TransferFunction" },
855 { 0x131, "exif:Software" },
856 { 0x132, "exif:DateTime" },
857 { 0x13b, "exif:Artist" },
858 { 0x13e, "exif:WhitePoint" },
859 { 0x13f, "exif:PrimaryChromaticities" },
860 { 0x140, "exif:ColorMap" },
861 { 0x141, "exif:HalfToneHints" },
862 { 0x142, "exif:TileWidth" },
863 { 0x143, "exif:TileLength" },
864 { 0x144, "exif:TileOffsets" },
865 { 0x145, "exif:TileByteCounts" },
866 { 0x14a, "exif:SubIFD" },
867 { 0x14c, "exif:InkSet" },
868 { 0x14d, "exif:InkNames" },
869 { 0x14e, "exif:NumberOfInks" },
870 { 0x150, "exif:DotRange" },
871 { 0x151, "exif:TargetPrinter" },
872 { 0x152, "exif:ExtraSample" },
873 { 0x153, "exif:SampleFormat" },
874 { 0x154, "exif:SMinSampleValue" },
875 { 0x155, "exif:SMaxSampleValue" },
876 { 0x156, "exif:TransferRange" },
877 { 0x157, "exif:ClipPath" },
878 { 0x158, "exif:XClipPathUnits" },
879 { 0x159, "exif:YClipPathUnits" },
880 { 0x15a, "exif:Indexed" },
881 { 0x15b, "exif:JPEGTables" },
882 { 0x15f, "exif:OPIProxy" },
883 { 0x200, "exif:JPEGProc" },
884 { 0x201, "exif:JPEGInterchangeFormat" },
885 { 0x202, "exif:JPEGInterchangeFormatLength" },
886 { 0x203, "exif:JPEGRestartInterval" },
887 { 0x205, "exif:JPEGLosslessPredictors" },
888 { 0x206, "exif:JPEGPointTransforms" },
889 { 0x207, "exif:JPEGQTables" },
890 { 0x208, "exif:JPEGDCTables" },
891 { 0x209, "exif:JPEGACTables" },
892 { 0x211, "exif:YCbCrCoefficients" },
893 { 0x212, "exif:YCbCrSubSampling" },
894 { 0x213, "exif:YCbCrPositioning" },
895 { 0x214, "exif:ReferenceBlackWhite" },
896 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
897 { 0x301, "exif:Gamma" },
898 { 0x302, "exif:ICCProfileDescriptor" },
899 { 0x303, "exif:SRGBRenderingIntent" },
900 { 0x320, "exif:ImageTitle" },
901 { 0x5001, "exif:ResolutionXUnit" },
902 { 0x5002, "exif:ResolutionYUnit" },
903 { 0x5003, "exif:ResolutionXLengthUnit" },
904 { 0x5004, "exif:ResolutionYLengthUnit" },
905 { 0x5005, "exif:PrintFlags" },
906 { 0x5006, "exif:PrintFlagsVersion" },
907 { 0x5007, "exif:PrintFlagsCrop" },
908 { 0x5008, "exif:PrintFlagsBleedWidth" },
909 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
910 { 0x500A, "exif:HalftoneLPI" },
911 { 0x500B, "exif:HalftoneLPIUnit" },
912 { 0x500C, "exif:HalftoneDegree" },
913 { 0x500D, "exif:HalftoneShape" },
914 { 0x500E, "exif:HalftoneMisc" },
915 { 0x500F, "exif:HalftoneScreen" },
916 { 0x5010, "exif:JPEGQuality" },
917 { 0x5011, "exif:GridSize" },
918 { 0x5012, "exif:ThumbnailFormat" },
919 { 0x5013, "exif:ThumbnailWidth" },
920 { 0x5014, "exif:ThumbnailHeight" },
921 { 0x5015, "exif:ThumbnailColorDepth" },
922 { 0x5016, "exif:ThumbnailPlanes" },
923 { 0x5017, "exif:ThumbnailRawBytes" },
924 { 0x5018, "exif:ThumbnailSize" },
925 { 0x5019, "exif:ThumbnailCompressedSize" },
926 { 0x501a, "exif:ColorTransferFunction" },
927 { 0x501b, "exif:ThumbnailData" },
928 { 0x5020, "exif:ThumbnailImageWidth" },
929 { 0x5021, "exif:ThumbnailImageHeight" },
930 { 0x5022, "exif:ThumbnailBitsPerSample" },
931 { 0x5023, "exif:ThumbnailCompression" },
932 { 0x5024, "exif:ThumbnailPhotometricInterp" },
933 { 0x5025, "exif:ThumbnailImageDescription" },
934 { 0x5026, "exif:ThumbnailEquipMake" },
935 { 0x5027, "exif:ThumbnailEquipModel" },
936 { 0x5028, "exif:ThumbnailStripOffsets" },
937 { 0x5029, "exif:ThumbnailOrientation" },
938 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
939 { 0x502b, "exif:ThumbnailRowsPerStrip" },
940 { 0x502c, "exif:ThumbnailStripBytesCount" },
941 { 0x502d, "exif:ThumbnailResolutionX" },
942 { 0x502e, "exif:ThumbnailResolutionY" },
943 { 0x502f, "exif:ThumbnailPlanarConfig" },
944 { 0x5030, "exif:ThumbnailResolutionUnit" },
945 { 0x5031, "exif:ThumbnailTransferFunction" },
946 { 0x5032, "exif:ThumbnailSoftwareUsed" },
947 { 0x5033, "exif:ThumbnailDateTime" },
948 { 0x5034, "exif:ThumbnailArtist" },
949 { 0x5035, "exif:ThumbnailWhitePoint" },
950 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
951 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
952 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
953 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
954 { 0x503A, "exif:ThumbnailRefBlackWhite" },
955 { 0x503B, "exif:ThumbnailCopyRight" },
956 { 0x5090, "exif:LuminanceTable" },
957 { 0x5091, "exif:ChrominanceTable" },
958 { 0x5100, "exif:FrameDelay" },
959 { 0x5101, "exif:LoopCount" },
960 { 0x5110, "exif:PixelUnit" },
961 { 0x5111, "exif:PixelPerUnitX" },
962 { 0x5112, "exif:PixelPerUnitY" },
963 { 0x5113, "exif:PaletteHistogram" },
964 { 0x1000, "exif:RelatedImageFileFormat" },
965 { 0x1001, "exif:RelatedImageLength" },
966 { 0x1002, "exif:RelatedImageWidth" },
967 { 0x800d, "exif:ImageID" },
968 { 0x80e3, "exif:Matteing" },
969 { 0x80e4, "exif:DataType" },
970 { 0x80e5, "exif:ImageDepth" },
971 { 0x80e6, "exif:TileDepth" },
972 { 0x828d, "exif:CFARepeatPatternDim" },
973 { 0x828e, "exif:CFAPattern2" },
974 { 0x828f, "exif:BatteryLevel" },
975 { 0x8298, "exif:Copyright" },
976 { 0x829a, "exif:ExposureTime" },
977 { 0x829d, "exif:FNumber" },
978 { 0x83bb, "exif:IPTC/NAA" },
979 { 0x84e3, "exif:IT8RasterPadding" },
980 { 0x84e5, "exif:IT8ColorTable" },
981 { 0x8649, "exif:ImageResourceInformation" },
982 { 0x8769, "exif:ExifOffset" },
983 { 0x8773, "exif:InterColorProfile" },
984 { 0x8822, "exif:ExposureProgram" },
985 { 0x8824, "exif:SpectralSensitivity" },
986 { 0x8825, "exif:GPSInfo" },
987 { 0x8827, "exif:ISOSpeedRatings" },
988 { 0x8828, "exif:OECF" },
989 { 0x8829, "exif:Interlace" },
990 { 0x882a, "exif:TimeZoneOffset" },
991 { 0x882b, "exif:SelfTimerMode" },
992 { 0x9000, "exif:ExifVersion" },
993 { 0x9003, "exif:DateTimeOriginal" },
994 { 0x9004, "exif:DateTimeDigitized" },
995 { 0x9101, "exif:ComponentsConfiguration" },
996 { 0x9102, "exif:CompressedBitsPerPixel" },
997 { 0x9201, "exif:ShutterSpeedValue" },
998 { 0x9202, "exif:ApertureValue" },
999 { 0x9203, "exif:BrightnessValue" },
1000 { 0x9204, "exif:ExposureBiasValue" },
1001 { 0x9205, "exif:MaxApertureValue" },
1002 { 0x9206, "exif:SubjectDistance" },
1003 { 0x9207, "exif:MeteringMode" },
1004 { 0x9208, "exif:LightSource" },
1005 { 0x9209, "exif:Flash" },
1006 { 0x920a, "exif:FocalLength" },
1007 { 0x920b, "exif:FlashEnergy" },
1008 { 0x920c, "exif:SpatialFrequencyResponse" },
1009 { 0x920d, "exif:Noise" },
1010 { 0x9211, "exif:ImageNumber" },
1011 { 0x9212, "exif:SecurityClassification" },
1012 { 0x9213, "exif:ImageHistory" },
1013 { 0x9214, "exif:SubjectArea" },
1014 { 0x9215, "exif:ExposureIndex" },
1015 { 0x9216, "exif:TIFF-EPStandardID" },
1016 { 0x927c, "exif:MakerNote" },
1017 { 0x9C9b, "exif:WinXP-Title" },
1018 { 0x9C9c, "exif:WinXP-Comments" },
1019 { 0x9C9d, "exif:WinXP-Author" },
1020 { 0x9C9e, "exif:WinXP-Keywords" },
1021 { 0x9C9f, "exif:WinXP-Subject" },
1022 { 0x9286, "exif:UserComment" },
1023 { 0x9290, "exif:SubSecTime" },
1024 { 0x9291, "exif:SubSecTimeOriginal" },
1025 { 0x9292, "exif:SubSecTimeDigitized" },
1026 { 0xa000, "exif:FlashPixVersion" },
1027 { 0xa001, "exif:ColorSpace" },
1028 { 0xa002, "exif:ExifImageWidth" },
1029 { 0xa003, "exif:ExifImageLength" },
1030 { 0xa004, "exif:RelatedSoundFile" },
1031 { 0xa005, "exif:InteroperabilityOffset" },
1032 { 0xa20b, "exif:FlashEnergy" },
1033 { 0xa20c, "exif:SpatialFrequencyResponse" },
1034 { 0xa20d, "exif:Noise" },
1035 { 0xa20e, "exif:FocalPlaneXResolution" },
1036 { 0xa20f, "exif:FocalPlaneYResolution" },
1037 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1038 { 0xa214, "exif:SubjectLocation" },
1039 { 0xa215, "exif:ExposureIndex" },
1040 { 0xa216, "exif:TIFF/EPStandardID" },
1041 { 0xa217, "exif:SensingMethod" },
1042 { 0xa300, "exif:FileSource" },
1043 { 0xa301, "exif:SceneType" },
1044 { 0xa302, "exif:CFAPattern" },
1045 { 0xa401, "exif:CustomRendered" },
1046 { 0xa402, "exif:ExposureMode" },
1047 { 0xa403, "exif:WhiteBalance" },
1048 { 0xa404, "exif:DigitalZoomRatio" },
1049 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1050 { 0xa406, "exif:SceneCaptureType" },
1051 { 0xa407, "exif:GainControl" },
1052 { 0xa408, "exif:Contrast" },
1053 { 0xa409, "exif:Saturation" },
1054 { 0xa40a, "exif:Sharpness" },
1055 { 0xa40b, "exif:DeviceSettingDescription" },
1056 { 0xa40c, "exif:SubjectDistanceRange" },
1057 { 0xa420, "exif:ImageUniqueID" },
1058 { 0xc4a5, "exif:PrintImageMatching" },
1059 { 0xa500, "exif:Gamma" },
1060 { 0xc640, "exif:CR2Slice" },
1061 { 0x10000, "exif:GPSVersionID" },
1062 { 0x10001, "exif:GPSLatitudeRef" },
1063 { 0x10002, "exif:GPSLatitude" },
1064 { 0x10003, "exif:GPSLongitudeRef" },
1065 { 0x10004, "exif:GPSLongitude" },
1066 { 0x10005, "exif:GPSAltitudeRef" },
1067 { 0x10006, "exif:GPSAltitude" },
1068 { 0x10007, "exif:GPSTimeStamp" },
1069 { 0x10008, "exif:GPSSatellites" },
1070 { 0x10009, "exif:GPSStatus" },
1071 { 0x1000a, "exif:GPSMeasureMode" },
1072 { 0x1000b, "exif:GPSDop" },
1073 { 0x1000c, "exif:GPSSpeedRef" },
1074 { 0x1000d, "exif:GPSSpeed" },
1075 { 0x1000e, "exif:GPSTrackRef" },
1076 { 0x1000f, "exif:GPSTrack" },
1077 { 0x10010, "exif:GPSImgDirectionRef" },
1078 { 0x10011, "exif:GPSImgDirection" },
1079 { 0x10012, "exif:GPSMapDatum" },
1080 { 0x10013, "exif:GPSDestLatitudeRef" },
1081 { 0x10014, "exif:GPSDestLatitude" },
1082 { 0x10015, "exif:GPSDestLongitudeRef" },
1083 { 0x10016, "exif:GPSDestLongitude" },
1084 { 0x10017, "exif:GPSDestBearingRef" },
1085 { 0x10018, "exif:GPSDestBearing" },
1086 { 0x10019, "exif:GPSDestDistanceRef" },
1087 { 0x1001a, "exif:GPSDestDistance" },
1088 { 0x1001b, "exif:GPSProcessingMethod" },
1089 { 0x1001c, "exif:GPSAreaInformation" },
1090 { 0x1001d, "exif:GPSDateStamp" },
1091 { 0x1001e, "exif:GPSDifferential" },
1103 directory_stack[MaxDirectoryStack];
1132 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1135 If EXIF data exists, then try to parse the request for a tag.
1137 profile=GetImageProfile(image,"exif");
1138 if (profile == (StringInfo *) NULL)
1139 return(MagickFalse);
1140 if ((property == (const char *) NULL) || (*property == '\0'))
1141 return(MagickFalse);
1142 while (isspace((int) ((unsigned char) *property)) != 0)
1146 switch (*(property+5))
1151 Caller has asked for all the tags in the EXIF data.
1154 all=1; /* return the data in description=value format */
1160 all=2; /* return the data in tagid=value format */
1173 Check for a hex based tag specification first.
1175 tag=(*(property+5) == '@') ? 1UL : 0UL;
1179 return(MagickFalse);
1181 Parse tag specification as a hex number.
1186 for (i=(ssize_t) n-1L; i >= 0; i--)
1190 if ((c >= '0') && (c <= '9'))
1193 if ((c >= 'A') && (c <= 'F'))
1196 if ((c >= 'a') && (c <= 'f'))
1199 return(MagickFalse);
1201 } while (*property != '\0');
1207 Try to match the text with a tag name instead.
1211 if (EXIFTag[i].tag == 0)
1213 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1215 tag=(size_t) EXIFTag[i].tag;
1223 return(MagickFalse);
1224 length=GetStringInfoLength(profile);
1225 exif=GetStringInfoDatum(profile);
1228 if (ReadPropertyByte(&exif,&length) != 0x45)
1230 if (ReadPropertyByte(&exif,&length) != 0x78)
1232 if (ReadPropertyByte(&exif,&length) != 0x69)
1234 if (ReadPropertyByte(&exif,&length) != 0x66)
1236 if (ReadPropertyByte(&exif,&length) != 0x00)
1238 if (ReadPropertyByte(&exif,&length) != 0x00)
1243 return(MagickFalse);
1244 id=(ssize_t) ((int) ReadPropertyShort(LSBEndian,exif));
1252 return(MagickFalse);
1253 if (ReadPropertyShort(endian,exif+2) != 0x002a)
1254 return(MagickFalse);
1256 This the offset to the first IFD.
1258 offset=(ssize_t) ((int) ReadPropertyLong(endian,exif+4));
1259 if ((offset < 0) || (size_t) offset >= length)
1260 return(MagickFalse);
1262 Set the pointer to the first IFD and follow it were it leads.
1265 directory=exif+offset;
1269 exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,
1270 (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
1274 If there is anything on the stack then pop it off.
1279 directory=directory_stack[level].directory;
1280 entry=directory_stack[level].entry;
1281 tag_offset=directory_stack[level].offset;
1284 Determine how many entries there are in the current IFD.
1286 number_entries=(size_t) ((int) ReadPropertyShort(endian,directory));
1287 for ( ; entry < number_entries; entry++)
1289 register unsigned char
1300 q=(unsigned char *) (directory+(12*entry)+2);
1301 if (GetValueFromSplayTree(exif_resources,q) == q)
1303 (void) AddValueToSplayTree(exif_resources,q,q);
1304 tag_value=(ssize_t) ((int) ReadPropertyShort(endian,q)+tag_offset);
1305 format=(size_t) ((int) ReadPropertyShort(endian,q+2));
1306 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1308 components=(ssize_t) ((int) ReadPropertyLong(endian,q+4));
1309 number_bytes=(size_t) components*tag_bytes[format];
1310 if (number_bytes < components)
1311 break; /* prevent overflow */
1312 if (number_bytes <= 4)
1320 The directory entry contains an offset.
1322 offset=(ssize_t) ((int) ReadPropertyLong(endian,q+8));
1323 if ((ssize_t) (offset+number_bytes) < offset)
1324 continue; /* prevent overflow */
1325 if ((size_t) (offset+number_bytes) > length)
1327 p=(unsigned char *) (exif+offset);
1329 if ((all != 0) || (tag == (size_t) tag_value))
1332 buffer[MaxTextExtent],
1335 value=(char *) NULL;
1340 case EXIF_FMT_UNDEFINED:
1342 EXIFMultipleValues(1,"%.20g",(double) (*(unsigned char *) p1));
1345 case EXIF_FMT_SBYTE:
1347 EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1350 case EXIF_FMT_SSHORT:
1352 EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1));
1355 case EXIF_FMT_USHORT:
1357 EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1));
1360 case EXIF_FMT_ULONG:
1362 EXIFMultipleValues(4,"%.20g",(double)
1363 ((int) ReadPropertyLong(endian,p1)));
1366 case EXIF_FMT_SLONG:
1368 EXIFMultipleValues(4,"%.20g",(double)
1369 ((int) ReadPropertyLong(endian,p1)));
1372 case EXIF_FMT_URATIONAL:
1374 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1375 ((int) ReadPropertyLong(endian,p1)),(double)
1376 ((int) ReadPropertyLong(endian,p1+4)));
1379 case EXIF_FMT_SRATIONAL:
1381 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1382 ((int) ReadPropertyLong(endian,p1)),(double)
1383 ((int) ReadPropertyLong(endian,p1+4)));
1386 case EXIF_FMT_SINGLE:
1388 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1391 case EXIF_FMT_DOUBLE:
1393 EXIFMultipleValues(8,"%f",*(double *) p1);
1397 case EXIF_FMT_STRING:
1399 value=(char *) NULL;
1400 if (~(1UL*number_bytes) >= 1)
1401 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1403 if (value != (char *) NULL)
1408 for (i=0; i < (ssize_t) number_bytes; i++)
1411 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1412 value[i]=(char) p[i];
1419 if (value != (char *) NULL)
1427 (void) CopyMagickString(key,property,MaxTextExtent);
1438 description="unknown";
1441 if (EXIFTag[i].tag == 0)
1443 if ((ssize_t) EXIFTag[i].tag == tag_value)
1445 description=EXIFTag[i].description;
1449 (void) FormatLocaleString(key,MaxTextExtent,"%s",description);
1454 if (tag_value < 0x10000)
1455 (void) FormatLocaleString(key,MaxTextExtent,"#%04lx",
1456 (unsigned long) tag_value);
1458 if (tag_value < 0x20000)
1459 (void) FormatLocaleString(key,MaxTextExtent,"@%04lx",
1460 (unsigned long) (tag_value & 0xffff));
1462 (void) FormatLocaleString(key,MaxTextExtent,"unknown");
1466 p=(const char *) NULL;
1467 if (image->properties != (void *) NULL)
1468 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1469 image->properties,key);
1470 if (p == (const char *) NULL)
1471 (void) SetImageProperty((Image *) image,key,value,exception);
1472 value=DestroyString(value);
1476 if ((tag_value == TAG_EXIF_OFFSET) ||
1477 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1482 offset=(ssize_t) ((int) ReadPropertyLong(endian,p));
1483 if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1488 tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1490 directory_stack[level].directory=directory;
1492 directory_stack[level].entry=entry;
1493 directory_stack[level].offset=tag_offset;
1495 directory_stack[level].directory=exif+offset;
1496 directory_stack[level].offset=tag_offset1;
1497 directory_stack[level].entry=0;
1499 if ((directory+2+(12*number_entries)) > (exif+length))
1501 offset=(ssize_t) ((int) ReadPropertyLong(endian,directory+2+(12*
1503 if ((offset != 0) && ((size_t) offset < length) &&
1504 (level < (MaxDirectoryStack-2)))
1506 directory_stack[level].directory=exif+offset;
1507 directory_stack[level].entry=0;
1508 directory_stack[level].offset=tag_offset1;
1515 } while (level > 0);
1516 exif_resources=DestroySplayTree(exif_resources);
1520 static MagickBooleanType GetXMPProperty(const Image *image,const char *property)
1544 profile=GetImageProfile(image,"xmp");
1545 if (profile == (StringInfo *) NULL)
1546 return(MagickFalse);
1547 if ((property == (const char *) NULL) || (*property == '\0'))
1548 return(MagickFalse);
1549 xmp_profile=StringInfoToString(profile);
1550 if (xmp_profile == (char *) NULL)
1551 return(MagickFalse);
1552 for (p=xmp_profile; *p != '\0'; p++)
1553 if ((*p == '<') && (*(p+1) == 'x'))
1555 exception=AcquireExceptionInfo();
1556 xmp=NewXMLTree((char *) p,exception);
1557 xmp_profile=DestroyString(xmp_profile);
1558 exception=DestroyExceptionInfo(exception);
1559 if (xmp == (XMLTreeInfo *) NULL)
1560 return(MagickFalse);
1562 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1563 if (rdf != (XMLTreeInfo *) NULL)
1565 if (image->properties == (void *) NULL)
1566 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1567 RelinquishMagickMemory,RelinquishMagickMemory);
1568 description=GetXMLTreeChild(rdf,"rdf:Description");
1569 while (description != (XMLTreeInfo *) NULL)
1571 node=GetXMLTreeChild(description,(const char *) NULL);
1572 while (node != (XMLTreeInfo *) NULL)
1574 child=GetXMLTreeChild(node,(const char *) NULL);
1575 if (child == (XMLTreeInfo *) NULL)
1576 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1577 ConstantString(GetXMLTreeTag(node)),
1578 ConstantString(GetXMLTreeContent(node)));
1579 while (child != (XMLTreeInfo *) NULL)
1581 if (LocaleCompare(GetXMLTreeTag(child),"rdf:Seq") != 0)
1582 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1583 ConstantString(GetXMLTreeTag(child)),
1584 ConstantString(GetXMLTreeContent(child)));
1585 child=GetXMLTreeSibling(child);
1587 node=GetXMLTreeSibling(node);
1589 description=GetNextXMLTreeTag(description);
1592 xmp=DestroyXMLTree(xmp);
1596 static char *TracePSClippath(const unsigned char *blob,size_t length,
1597 const size_t magick_unused(columns),const size_t magick_unused(rows))
1620 path=AcquireString((char *) NULL);
1621 if (path == (char *) NULL)
1622 return((char *) NULL);
1623 message=AcquireString((char *) NULL);
1624 (void) FormatLocaleString(message,MaxTextExtent,"/ClipImage\n");
1625 (void) ConcatenateString(&path,message);
1626 (void) FormatLocaleString(message,MaxTextExtent,"{\n");
1627 (void) ConcatenateString(&path,message);
1628 (void) FormatLocaleString(message,MaxTextExtent," /c {curveto} bind def\n");
1629 (void) ConcatenateString(&path,message);
1630 (void) FormatLocaleString(message,MaxTextExtent," /l {lineto} bind def\n");
1631 (void) ConcatenateString(&path,message);
1632 (void) FormatLocaleString(message,MaxTextExtent," /m {moveto} bind def\n");
1633 (void) ConcatenateString(&path,message);
1634 (void) FormatLocaleString(message,MaxTextExtent,
1635 " /v {currentpoint 6 2 roll curveto} bind def\n");
1636 (void) ConcatenateString(&path,message);
1637 (void) FormatLocaleString(message,MaxTextExtent,
1638 " /y {2 copy curveto} bind def\n");
1639 (void) ConcatenateString(&path,message);
1640 (void) FormatLocaleString(message,MaxTextExtent,
1641 " /z {closepath} bind def\n");
1642 (void) ConcatenateString(&path,message);
1643 (void) FormatLocaleString(message,MaxTextExtent," newpath\n");
1644 (void) ConcatenateString(&path,message);
1646 The clipping path format is defined in "Adobe Photoshop File
1647 Formats Specification" version 6.0 downloadable from adobe.com.
1649 (void) ResetMagickMemory(point,0,sizeof(point));
1650 (void) ResetMagickMemory(first,0,sizeof(first));
1651 (void) ResetMagickMemory(last,0,sizeof(last));
1653 in_subpath=MagickFalse;
1656 selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1662 if (knot_count != 0)
1665 length-=MagickMin(24,(ssize_t) length);
1669 Expected subpath length record.
1671 knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1673 length-=MagickMin(22,(ssize_t) length);
1681 if (knot_count == 0)
1684 Unexpected subpath knot
1687 length-=MagickMin(24,(ssize_t) length);
1693 for (i=0; i < 3; i++)
1699 yy=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1700 xx=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1702 if (xx > 2147483647)
1703 x=(ssize_t) xx-4294967295U-1;
1705 if (yy > 2147483647)
1706 y=(ssize_t) yy-4294967295U-1;
1707 point[i].x=(double) x/4096/4096;
1708 point[i].y=1.0-(double) y/4096/4096;
1710 if( IfMagickFalse(in_subpath) )
1712 (void) FormatLocaleString(message,MaxTextExtent," %g %g m\n",
1713 point[1].x,point[1].y);
1714 for (i=0; i < 3; i++)
1723 Handle special cases when Bezier curves are used to describe
1724 corners and straight lines.
1726 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1727 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1728 (void) FormatLocaleString(message,MaxTextExtent,
1729 " %g %g l\n",point[1].x,point[1].y);
1731 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1732 (void) FormatLocaleString(message,MaxTextExtent,
1733 " %g %g %g %g v\n",point[0].x,point[0].y,
1734 point[1].x,point[1].y);
1736 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1737 (void) FormatLocaleString(message,MaxTextExtent,
1738 " %g %g %g %g y\n",last[2].x,last[2].y,
1739 point[1].x,point[1].y);
1741 (void) FormatLocaleString(message,MaxTextExtent,
1742 " %g %g %g %g %g %g c\n",last[2].x,
1743 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1744 for (i=0; i < 3; i++)
1747 (void) ConcatenateString(&path,message);
1748 in_subpath=MagickTrue;
1751 Close the subpath if there are no more knots.
1753 if (knot_count == 0)
1756 Same special handling as above except we compare to the
1757 first point in the path and close the path.
1759 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1760 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1761 (void) FormatLocaleString(message,MaxTextExtent,
1762 " %g %g l z\n",first[1].x,first[1].y);
1764 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1765 (void) FormatLocaleString(message,MaxTextExtent,
1766 " %g %g %g %g v z\n",first[0].x,first[0].y,
1767 first[1].x,first[1].y);
1769 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1770 (void) FormatLocaleString(message,MaxTextExtent,
1771 " %g %g %g %g y z\n",last[2].x,last[2].y,
1772 first[1].x,first[1].y);
1774 (void) FormatLocaleString(message,MaxTextExtent,
1775 " %g %g %g %g %g %g c z\n",last[2].x,
1776 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1777 (void) ConcatenateString(&path,message);
1778 in_subpath=MagickFalse;
1788 length-=MagickMin(24,(ssize_t) length);
1794 Returns an empty PS path if the path has no knots.
1796 (void) FormatLocaleString(message,MaxTextExtent," eoclip\n");
1797 (void) ConcatenateString(&path,message);
1798 (void) FormatLocaleString(message,MaxTextExtent,"} bind def");
1799 (void) ConcatenateString(&path,message);
1800 message=DestroyString(message);
1804 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1805 const size_t columns,const size_t rows)
1828 path=AcquireString((char *) NULL);
1829 if (path == (char *) NULL)
1830 return((char *) NULL);
1831 message=AcquireString((char *) NULL);
1832 (void) FormatLocaleString(message,MaxTextExtent,
1833 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
1834 (void) ConcatenateString(&path,message);
1835 (void) FormatLocaleString(message,MaxTextExtent,
1836 "<svg width=\"%.20g\" height=\"%.20g\">\n",(double) columns,(double) rows);
1837 (void) ConcatenateString(&path,message);
1838 (void) FormatLocaleString(message,MaxTextExtent,"<g>\n");
1839 (void) ConcatenateString(&path,message);
1840 (void) FormatLocaleString(message,MaxTextExtent,
1841 "<path style=\"fill:#00000000;stroke:#00000000;");
1842 (void) ConcatenateString(&path,message);
1843 (void) FormatLocaleString(message,MaxTextExtent,
1844 "stroke-width:0;stroke-antialiasing:false\" d=\"\n");
1845 (void) ConcatenateString(&path,message);
1846 (void) ResetMagickMemory(point,0,sizeof(point));
1847 (void) ResetMagickMemory(first,0,sizeof(first));
1848 (void) ResetMagickMemory(last,0,sizeof(last));
1850 in_subpath=MagickFalse;
1853 selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1859 if (knot_count != 0)
1862 length-=MagickMin(24,(ssize_t) length);
1866 Expected subpath length record.
1868 knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1870 length-=MagickMin(22,(ssize_t) length);
1878 if (knot_count == 0)
1881 Unexpected subpath knot.
1884 length-=MagickMin(24,(ssize_t) length);
1890 for (i=0; i < 3; i++)
1896 yy=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1897 xx=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1899 if (xx > 2147483647)
1900 x=(ssize_t) xx-4294967295U-1;
1902 if (yy > 2147483647)
1903 y=(ssize_t) yy-4294967295U-1;
1904 point[i].x=(double) x*columns/4096/4096;
1905 point[i].y=(double) y*rows/4096/4096;
1907 if( IfMagickFalse(in_subpath) )
1909 (void) FormatLocaleString(message,MaxTextExtent,"M %g,%g\n",
1910 point[1].x,point[1].y);
1911 for (i=0; i < 3; i++)
1919 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1920 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1921 (void) FormatLocaleString(message,MaxTextExtent,"L %g,%g\n",
1922 point[1].x,point[1].y);
1924 (void) FormatLocaleString(message,MaxTextExtent,
1925 "C %g,%g %g,%g %g,%g\n",last[2].x,last[2].y,
1926 point[0].x,point[0].y,point[1].x,point[1].y);
1927 for (i=0; i < 3; i++)
1930 (void) ConcatenateString(&path,message);
1931 in_subpath=MagickTrue;
1934 Close the subpath if there are no more knots.
1936 if (knot_count == 0)
1938 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1939 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1940 (void) FormatLocaleString(message,MaxTextExtent,
1941 "L %g,%g Z\n",first[1].x,first[1].y);
1944 (void) FormatLocaleString(message,MaxTextExtent,
1945 "C %g,%g %g,%g %g,%g Z\n",last[2].x,
1946 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1947 (void) ConcatenateString(&path,message);
1949 in_subpath=MagickFalse;
1959 length-=MagickMin(24,(ssize_t) length);
1965 Return an empty SVG image if the path does not have knots.
1967 (void) FormatLocaleString(message,MaxTextExtent,"\"/>\n");
1968 (void) ConcatenateString(&path,message);
1969 (void) FormatLocaleString(message,MaxTextExtent,"</g>\n");
1970 (void) ConcatenateString(&path,message);
1971 (void) FormatLocaleString(message,MaxTextExtent,"</svg>\n");
1972 (void) ConcatenateString(&path,message);
1973 message=DestroyString(message);
1977 MagickExport const char *GetImageProperty(const Image *image,
1978 const char *property,ExceptionInfo *exception)
1992 assert(image != (Image *) NULL);
1993 assert(image->signature == MagickSignature);
1994 if( IfMagickTrue(image->debug) )
1995 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1996 p=(const char *) NULL;
1997 if (image->properties != (void *) NULL)
1999 if (property == (const char *) NULL)
2001 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
2002 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
2006 if (LocaleNCompare("fx:",property,3) != 0) /* NOT fx: !!!! */
2008 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2009 image->properties,property);
2010 if (p != (const char *) NULL)
2014 if ((property == (const char *) NULL) ||
2015 (strchr(property,':') == (char *) NULL))
2021 if (LocaleNCompare("8bim:",property,5) == 0)
2023 if( IfMagickTrue(Get8BIMProperty(image,property,exception)) &&
2024 (image->properties != (void *) NULL))
2026 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2027 image->properties,property);
2036 if (LocaleNCompare("exif:",property,5) == 0)
2038 if( IfMagickTrue(GetEXIFProperty(image,property,exception)) &&
2039 (image->properties != (void *) NULL))
2041 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2042 image->properties,property);
2051 if (LocaleNCompare("fx:",property,3) == 0)
2053 fx_info=AcquireFxInfo(image,property+3,exception);
2054 status=FxEvaluateChannelExpression(fx_info,IntensityPixelChannel,0,0,
2056 fx_info=DestroyFxInfo(fx_info);
2057 if( IfMagickTrue(status) )
2060 value[MaxTextExtent];
2062 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2063 GetMagickPrecision(),(double) alpha);
2064 (void) SetImageProperty((Image *) image,property,value,exception);
2066 if (image->properties != (void *) NULL)
2068 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2069 image->properties,property);
2078 if (LocaleNCompare("iptc:",property,5) == 0)
2080 if( IfMagickTrue(GetIPTCProperty(image,property,exception)) &&
2081 (image->properties != (void *) NULL))
2083 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2084 image->properties,property);
2093 if (LocaleNCompare("pixel:",property,6) == 0)
2098 GetPixelInfo(image,&pixel);
2099 fx_info=AcquireFxInfo(image,property+6,exception);
2100 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
2102 pixel.red=(MagickRealType) QuantumRange*alpha;
2103 status|=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
2105 pixel.green=(MagickRealType) QuantumRange*alpha;
2106 status|=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
2108 pixel.blue=(MagickRealType) QuantumRange*alpha;
2109 if (image->colorspace == CMYKColorspace)
2111 status|=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
2113 pixel.black=(MagickRealType) QuantumRange*alpha;
2115 status|=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
2117 pixel.alpha=(MagickRealType) QuantumRange*(1.0-alpha);
2118 fx_info=DestroyFxInfo(fx_info);
2119 if( IfMagickTrue(status) )
2122 name[MaxTextExtent];
2124 (void) QueryColorname(image,&pixel,SVGCompliance,name,
2126 (void) SetImageProperty((Image *) image,property,name,exception);
2127 return(GetImageProperty(image,property,exception));
2135 if (LocaleNCompare("xmp:",property,4) == 0)
2137 if( IfMagickTrue(GetXMPProperty(image,property)) &&
2138 (image->properties != (void *) NULL))
2140 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2141 image->properties,property);
2154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2158 + G e t M a g i c k P r o p e r t y %
2162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2164 % GetMagickProperty() gets attributes or calculated values that is associated
2165 % with a fixed known property name, or single letter properity.
2167 % This does not return, special profile or properity expressions. Nor does it
2168 % return free-form properity strings, unless referenced by a single letter
2171 % The returned string is stored as the image artifact 'get-property' (not as
2172 % another property), and as such should not be freed. Later calls however
2173 % will overwrite this value so if needed for a longer period a copy should be
2174 % made. This artifact can be deleted when no longer required.
2176 % The format of the GetMagickProperty method is:
2178 % const char *GetMagickProperty(const ImageInfo *image_info,Image *image,
2179 % const char *properity,ExceptionInfo *exception)
2181 % A description of each parameter follows:
2183 % o image_info: the image info.
2185 % o image: the image.
2189 % o exception: return any errors or warnings in this structure.
2192 static const char *GetMagickPropertyLetter(const ImageInfo *image_info,
2193 Image *image,const char letter,ExceptionInfo *exception)
2196 value[MaxTextExtent];
2201 if (image != (Image *) NULL && IfMagickTrue(image->debug))
2202 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2205 *value='\0'; /* formated string */
2206 string=(char *)NULL; /* constant string reference */
2210 case 'b': /* image size read in - in bytes */
2212 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2213 ((MagickOffsetType) image->extent));
2214 if (image->extent != (MagickSizeType) ((size_t) image->extent))
2215 (void) FormatMagickSize(image->extent,MagickFalse,value);
2216 ConcatenateMagickString(value,"B",MaxTextExtent);
2219 case 'c': /* image comment property - empty string by default */
2221 string=GetImageProperty(image,"comment",exception);
2222 if ( string == (const char *)NULL)
2226 case 'd': /* Directory component of filename */
2228 GetPathComponent(image->magick_filename,HeadPath,value);
2231 case 'e': /* Filename extension (suffix) of image file */
2233 GetPathComponent(image->magick_filename,ExtensionPath,value);
2236 case 'f': /* Filename without directory component */
2238 GetPathComponent(image->magick_filename,TailPath,value);
2241 case 'g': /* Image geometry, canvas and offset %Wx%H+%X+%Y */
2243 (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
2244 (double) image->page.width,(double) image->page.height,
2245 (double) image->page.x,(double) image->page.y);
2248 case 'h': /* Image height (current) */
2250 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
2251 (double) (image->rows != 0 ? image->rows : image->magick_rows));
2254 case 'i': /* Filename last used for image (read or write) */
2256 string=image->filename;
2259 case 'k': /* Number of unique colors */
2261 /* FUTURE: ensure this does not generate the formated comment! */
2262 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2263 GetNumberColors(image,(FILE *) NULL,exception));
2266 case 'l': /* Image label properity - empty string by default */
2268 string=GetImageProperty(image,"label",exception);
2269 if ( string == (const char *)NULL)
2273 case 'm': /* Image format (file magick) */
2275 string=image->magick;
2278 case 'n': /* Number of images in the list. */
2280 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2281 GetImageListLength(image));
2284 case 'o': /* Output Filename - for delegate use only */
2286 string=image_info->filename;
2289 case 'p': /* Image index in current image list -- As 'n' OBSOLETE */
2291 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2292 GetImageIndexInList(image));
2295 case 'q': /* Quantum depth of image in memory */
2297 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2298 MAGICKCORE_QUANTUM_DEPTH);
2301 case 'r': /* Image storage class and colorspace. */
2306 colorspace=image->colorspace;
2307 if (IfMagickTrue(IsImageGray(image,exception)))
2308 colorspace=GRAYColorspace;
2309 (void) FormatLocaleString(value,MaxTextExtent,"%s %s %s",
2310 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)image->storage_class),
2311 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
2312 IfMagickTrue(image->matte)?"Matte":"");
2315 case 's': /* Image scene number */
2317 if (image_info->number_scenes != 0)
2318 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2321 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2325 case 't': /* Base filename without directory or extention */
2327 GetPathComponent(image->magick_filename,BasePath,value);
2330 case 'u': /* Unique filename */
2332 string=image_info->unique;
2335 case 'w': /* Image width (current) */
2337 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2338 (image->columns != 0 ? image->columns : image->magick_columns));
2341 case 'x': /* Image horizontal resolution (with units) */
2343 (void) FormatLocaleString(value,MaxTextExtent,"%g %s",
2344 image->resolution.x,CommandOptionToMnemonic(
2345 MagickResolutionOptions,(ssize_t)image->units));
2348 case 'y': /* Image vertical resolution (with units) */
2350 (void) FormatLocaleString(value,MaxTextExtent,"%g %s",
2351 image->resolution.y,CommandOptionToMnemonic(
2352 MagickResolutionOptions,(ssize_t)image->units));
2355 case 'z': /* Image depth as read in */
2357 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2361 case 'A': /* Image alpha channel */
2363 (void) FormatLocaleString(value,MaxTextExtent,"%s",
2364 CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
2368 case 'C': /* Image compression method. */
2370 (void) FormatLocaleString(value,MaxTextExtent,"%s",
2371 CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2372 image->compression));
2375 case 'D': /* Image dispose method. */
2377 (void) FormatLocaleString(value,MaxTextExtent,"%s",
2378 CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2382 case 'G': /* Image size as geometry = "%wx%h" */
2384 (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g",
2385 (double)image->magick_columns,(double) image->magick_rows);
2388 case 'H': /* layer canvas height */
2390 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2391 image->page.height);
2394 case 'M': /* Magick filename - filename given incl. coder & read mods */
2396 string=image->magick_filename;
2399 case 'O': /* layer canvas offset with sign = "+%X+%Y" */
2401 (void) FormatLocaleString(value,MaxTextExtent,"%+ld%+ld",
2402 (long) image->page.x,(long) image->page.y);
2405 case 'P': /* layer canvas page size = "%Wx%H" */
2407 (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g",
2408 (double) image->page.width,(double) image->page.height);
2411 case 'Q': /* image compression quality */
2413 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2417 case 'S': /* Image scenes ???? */
2419 if (image_info->number_scenes == 0)
2420 string="2147483647";
2422 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2423 image_info->scene+image_info->number_scenes);
2426 case 'T': /* image time delay for animations */
2428 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2432 case 'W': /* layer canvas width */
2434 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2438 case 'X': /* layer canvas X offset */
2440 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2444 case 'Y': /* layer canvas Y offset */
2446 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2450 case 'Z': /* Zero filename ??? */
2452 string=image_info->zero;
2455 case '@': /* Trim bounding box, without Trimming! */
2460 page=GetImageBoundingBox(image,exception);
2461 (void) FormatLocaleString(value,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
2462 (double) page.width,(double) page.height,
2463 (double) page.x,(double) page.y);
2466 case '#': /* Image signature */
2468 (void) SignatureImage(image,exception);
2469 string=GetImageProperty(image,"signature",exception);
2472 case '%': /* percent escaped */
2480 if (string != (char *)NULL) {
2481 (void) SetImageArtifact(image, "get-properity", string);
2482 return(GetImageArtifact(image, "get-properity"));
2484 return((char *)NULL);
2487 MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
2488 Image *image,const char *property,ExceptionInfo *exception)
2491 value[MaxTextExtent];
2496 assert(property[0] != '\0');
2497 if ( property[1] == '\0') /* single letter properity request */
2498 return( GetMagickPropertyLetter(image_info,image,*property,exception) );
2500 if (image != (Image *) NULL && IfMagickTrue(image->debug))
2501 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2504 *value='\0'; /* formated string */
2505 string=(char *)NULL; /* constant string reference */
2510 if ((LocaleCompare("base",property) == 0) ||
2511 (LocaleCompare("basename",property) == 0) )
2513 GetPathComponent(image->magick_filename,BasePath,value);
2520 if (LocaleCompare("channels",property) == 0)
2522 /* FUTURE: return actual image channels */
2523 (void) FormatLocaleString(value,MaxTextExtent,"%s",
2524 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2525 image->colorspace));
2527 if( IfMagickTrue(image->matte) )
2528 (void) ConcatenateMagickString(value,"a",MaxTextExtent);
2531 if (LocaleCompare("colorspace",property) == 0)
2536 /* FUTURE: return actual colorspace - no 'gray' stuff */
2537 colorspace=image->colorspace;
2538 if( IfMagickTrue(IsImageGray(image,exception)) )
2539 colorspace=GRAYColorspace;
2540 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2544 if (LocaleCompare("copyright",property) == 0)
2546 (void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
2553 if (LocaleCompare("depth",property) == 0)
2555 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2559 if (LocaleCompare("directory",property) == 0)
2561 GetPathComponent(image->magick_filename,HeadPath,value);
2568 if (LocaleCompare("extension",property) == 0)
2570 GetPathComponent(image->magick_filename,ExtensionPath,value);
2577 if (LocaleCompare("gamma",property) == 0)
2579 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2580 GetMagickPrecision(),image->gamma);
2583 if ( (image_info != (ImageInfo *) NULL) &&
2584 (LocaleCompare("group",property) == 0) )
2586 (void) FormatLocaleString(value,MaxTextExtent,"0x%lx",
2587 (unsigned long) image_info->group);
2594 if (LocaleCompare("height",property) == 0)
2596 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
2597 image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2604 if (LocaleCompare("input",property) == 0)
2606 string=image->filename;
2613 if (LocaleCompare("kurtosis",property) == 0)
2619 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
2620 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2621 GetMagickPrecision(),kurtosis);
2628 if (LocaleCompare("magick",property) == 0)
2630 string=image->magick;
2633 if (LocaleCompare("max",property) == 0)
2639 (void) GetImageRange(image,&minimum,&maximum,exception);
2640 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2641 GetMagickPrecision(),maximum);
2644 if (LocaleCompare("mean",property) == 0)
2650 (void) GetImageMean(image,&mean,&standard_deviation,
2652 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2653 GetMagickPrecision(),mean);
2656 if (LocaleCompare("min",property) == 0)
2662 (void) GetImageRange(image,&minimum,&maximum,exception);
2663 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2664 GetMagickPrecision(),minimum);
2671 if (LocaleCompare("opaque",property) == 0)
2676 opaque=IsImageOpaque(image,exception);
2677 (void) CopyMagickString(value,IfMagickTrue(opaque)?"true":"false",
2681 if (LocaleCompare("orientation",property) == 0)
2683 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
2684 image->orientation);
2687 if ( (image_info != (ImageInfo *) NULL) &&
2688 (LocaleCompare("output",property) == 0) )
2690 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
2697 if (LocaleCompare("page",property) == 0)
2699 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2700 GetImageIndexInList(image)+1);
2707 /* This matches %[fx:resolution.x] */
2708 if (LocaleCompare("resolution.x",property) == 0)
2710 (void) FormatLocaleString(value,MaxTextExtent,"%g",
2711 image->resolution.x);
2714 /* This matches %[fx:resolution.y] */
2715 if (LocaleCompare("resolution.y",property) == 0)
2717 (void) FormatLocaleString(value,MaxTextExtent,"%g",
2718 image->resolution.y);
2725 if (LocaleCompare("scene",property) == 0)
2727 if ( (image_info != (ImageInfo *) NULL) &&
2728 (image_info->number_scenes != 0) )
2729 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2732 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2736 if (LocaleCompare("scenes",property) == 0)
2738 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2739 GetImageListLength(image));
2742 if (LocaleCompare("size",property) == 0)
2745 format[MaxTextExtent];
2747 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
2748 (void) FormatLocaleString(value,MaxTextExtent,"%sB",format);
2751 if (LocaleCompare("skewness",property) == 0)
2757 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
2758 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2759 GetMagickPrecision(),skewness);
2762 if (LocaleCompare("standard-deviation",property) == 0)
2768 (void) GetImageMean(image,&mean,&standard_deviation,
2770 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2771 GetMagickPrecision(),standard_deviation);
2778 if ( (image_info != (ImageInfo *) NULL) &&
2779 (LocaleCompare("unique",property) == 0) )
2781 string=image_info->unique;
2788 if (LocaleCompare("version",property) == 0)
2790 string=GetMagickVersion((size_t *) NULL);
2797 if (LocaleCompare("width",property) == 0)
2799 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2800 (image->magick_columns != 0 ? image->magick_columns : 256));
2805 case 'x': /* FUTURE: Obsolete X resolution */
2807 if ((LocaleCompare("xresolution",property) == 0) ||
2808 (LocaleCompare("x-resolution",property) == 0) )
2810 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
2811 image->resolution.x);
2816 case 'y': /* FUTURE: Obsolete Y resolution */
2818 if ((LocaleCompare("yresolution",property) == 0) ||
2819 (LocaleCompare("y-resolution",property) == 0) )
2821 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
2822 image->resolution.y);
2829 if ( (image_info != (ImageInfo *) NULL) &&
2830 (LocaleCompare("zero",property) == 0) )
2832 string=image_info->zero;
2840 if (string != (char *)NULL) {
2841 (void) SetImageArtifact(image, "get-properity", string);
2842 return(GetImageArtifact(image, "get-properity"));
2844 return((char *)NULL);
2848 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2852 % G e t N e x t I m a g e P r o p e r t y %
2856 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2858 % GetNextImageProperty() gets the next free-form string properity name.
2860 % The format of the GetNextImageProperty method is:
2862 % char *GetNextImageProperty(const Image *image)
2864 % A description of each parameter follows:
2866 % o image: the image.
2869 MagickExport char *GetNextImageProperty(const Image *image)
2871 assert(image != (Image *) NULL);
2872 assert(image->signature == MagickSignature);
2873 if( IfMagickTrue(image->debug) )
2874 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2876 if (image->properties == (void *) NULL)
2877 return((char *) NULL);
2878 return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
2882 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2886 % I n t e r p r e t I m a g e P r o p e r t i e s %
2890 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2892 % InterpretImageProperties() replaces any embedded formatting characters with
2893 % the appropriate image property and returns the interpreted text.
2895 % This searches for and replaces
2896 % \n \r \% replaced by newline, return, and percent resp.
2897 % < > & replaced by '<', '>', '&' resp.
2898 % %% replaced by percent
2900 % %x where 'x' is a single letter, case sensitive).
2901 % %[type:name] where 'type' is specifically known prefix.
2902 % %[name] where 'name' is a specifically known attribute, calculated
2903 % value, or a per-image properity string name, or a per-image
2904 % 'artifact' (as generated from a global option)
2906 % Single letter % substitutions will only happen if the preceeding character
2907 % is NOT a number. But braced substitutions will always be performed. This
2908 % prevents typical usage of percent in 'geometry arguments' from being
2909 % substituted unexpectedly.
2911 % If 'glob-expresions' ('*' or '?' characters) is used for 'name' it may be
2912 % used as a search pattern to print multiple lines of "name=value\n" pairs of
2913 % the associacted set of properities.
2915 % The returned string must be freed using DestoryString().
2917 % The format of the InterpretImageProperties method is:
2919 % char *InterpretImageProperties(const ImageInfo *image_info,
2920 % Image *image,const char *embed_text,ExceptionInfo *exception)
2922 % A description of each parameter follows:
2924 % o image_info: the image info.
2926 % o image: the image.
2928 % o embed_text: the address of a character string containing the embedded
2929 % formatting characters.
2931 % o exception: return any errors or warnings in this structure.
2934 MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
2935 Image *image,const char *embed_text,ExceptionInfo *exception)
2953 assert(image != (Image *) NULL);
2954 assert(image->signature == MagickSignature);
2955 if( IfMagickTrue(image->debug) )
2956 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2958 if ((embed_text == (const char *) NULL))
2959 return((char *) NULL);
2963 return(ConstantString(""));
2965 /* handle a '@' replace string from file */
2968 if (*p != '-' && IfMagickFalse(IsPathAccessible(p)) ) {
2969 (void) ThrowMagickException(exception,GetMagickModule(),
2970 OptionError,"UnableToAccessPath","%s",p);
2971 return((char *) NULL);
2973 return(FileToString(p,~0,exception));
2977 Translate any embedded format characters.
2979 interpret_text=AcquireString(embed_text); /* new string with extra space */
2980 extent=MaxTextExtent; /* how many extra space */
2981 number=MagickFalse; /* is last char a number? */
2982 for (q=interpret_text; *p!='\0'; number=IsMagickTrue(isdigit(*p)),p++)
2985 if ((size_t) (q-interpret_text+MaxTextExtent) >= extent)
2987 extent+=MaxTextExtent;
2988 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2989 MaxTextExtent+1,sizeof(*interpret_text));
2990 if (interpret_text == (char *) NULL)
2991 return((char *) NULL);
2992 q=interpret_text+strlen(interpret_text);
2995 Look for percent escapes, (and handle other specials)
3002 case 'r': /* convert to RETURN */
3006 case 'n': /* convert to NEWLINE */
3010 case '\n': /* EOL removal UNIX,MacOSX */
3013 case '\r': /* EOL removal DOS,Windows */
3015 if (*p == '\n') /* return-newline EOL */
3023 continue; /* never reached! */
3025 if (LocaleNCompare("<",p,4) == 0)
3027 else if (LocaleNCompare(">",p,4) == 0)
3029 else if (LocaleNCompare("&",p,5) == 0)
3035 break; /* continue to next set of handlers */
3037 *q++=(*p); /* any thing else is 'as normal' */
3040 p++; /* advance beyond the percent */
3043 Doubled Percent - or percent at end of string
3053 Single letter escapes
3059 /* But only if not preceeded by a number! */
3060 if ( IfMagickTrue(number) ) {
3061 *q++='%'; /* do NOT substitute the percent */
3062 p--; /* back up one */
3065 value=GetMagickPropertyLetter(image_info,image,*p, exception);
3066 if (value != (char *) NULL) {
3067 length=strlen(value);
3068 if ((size_t) (q-interpret_text+length+1) >= extent)
3071 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3072 extent+MaxTextExtent,sizeof(*interpret_text));
3073 if (interpret_text == (char *) NULL)
3074 return((char *)NULL);
3075 q=interpret_text+strlen(interpret_text);
3077 (void) CopyMagickString(q,value,extent);
3081 (void) ThrowMagickException(exception,GetMagickModule(),
3082 OptionWarning,"UnknownImageProperty","\"%%%c\"",*p);
3087 Braced Percent Escape
3091 pattern[MaxTextExtent];
3103 /* get the string framed by the %[...] */
3104 p++; /* advance p to just inside the opening brace */
3107 (void) ThrowMagickException(exception,GetMagickModule(),
3108 OptionWarning,"UnknownImageProperty","\"%%[]\"");
3111 for (len=0; len<(MaxTextExtent-1L) && (*p != '\0');)
3113 /* skip escaped braces within braced pattern */
3114 if ( (*p == '\\') && (*(p+1) != '\0') ) {
3115 pattern[len++]=(*p++);
3116 pattern[len++]=(*p++);
3125 pattern[len++]=(*p++);
3128 /* Check for unmatched final ']' for "%[...]" */
3130 if (len >= 64) { /* truncate string for error message */
3136 (void) ThrowMagickException(exception,GetMagickModule(),
3137 OptionError,"UnbalancedBraces","\"%%[%s\"",pattern);
3138 interpret_text=DestroyString(interpret_text);
3139 return((char *)NULL);
3143 Special Property Prefixes
3144 such as: %[exif:...] %[fx:...] %[pixel:...]
3145 Otherwise a free-form properity string
3147 value=GetImageProperty(image,pattern,exception);
3148 if (value != (const char *) NULL)
3150 length=strlen(value);
3151 if ((size_t) (q-interpret_text+length+1) >= extent)
3154 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3155 extent+MaxTextExtent,sizeof(*interpret_text));
3156 if (interpret_text == (char *) NULL)
3157 return((char *)NULL);
3158 q=interpret_text+strlen(interpret_text);
3160 (void) CopyMagickString(q,value,extent);
3165 Handle properity 'glob' patterns
3166 Such as: %[*] %[user:array_??] %[filename:e*]
3168 if( IfMagickTrue(IsGlob(pattern)) )
3170 ResetImagePropertyIterator(image);
3171 key=GetNextImageProperty(image);
3172 while (key != (const char *) NULL)
3174 if( IfMagickTrue(GlobExpression(key,pattern,MagickTrue)) )
3176 value=GetImageProperty(image,key,exception);
3177 if (value != (const char *) NULL)
3179 length=strlen(key)+strlen(value)+2;
3180 if ((size_t) (q-interpret_text+length+1) >= extent)
3183 interpret_text=(char *) ResizeQuantumMemory(
3184 interpret_text,extent+MaxTextExtent,
3185 sizeof(*interpret_text));
3186 if (interpret_text == (char *) NULL)
3187 return((char *)NULL);
3188 q=interpret_text+strlen(interpret_text);
3190 q+=FormatLocaleString(q,extent,"%s=%s\n",key,value);
3193 key=GetNextImageProperty(image);
3198 Look for a known property or image attribute
3199 Such as %[basename] %[denisty] %[delay]
3200 Also does wrapped single letters: %[b] %[G] %[g]
3202 value=GetMagickProperty(image_info,image,pattern,exception);
3203 if (value != (const char *) NULL)
3205 length=strlen(value);
3206 if ((size_t) (q-interpret_text+length+1) >= extent)
3209 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3210 extent+MaxTextExtent,sizeof(*interpret_text));
3211 if (interpret_text == (char *) NULL)
3212 return((char *)NULL);
3213 q=interpret_text+strlen(interpret_text);
3215 (void) CopyMagickString(q,value,extent);
3220 Look for a per-image Artifact (user option, post-interpreted)
3222 value=GetImageArtifact(image,pattern);
3223 if (value != (char *) NULL)
3225 length=strlen(value);
3226 if ((size_t) (q-interpret_text+length+1) >= extent)
3229 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3230 extent+MaxTextExtent,sizeof(*interpret_text));
3231 if (interpret_text == (char *) NULL)
3232 return((char *)NULL);
3233 q=interpret_text+strlen(interpret_text);
3235 (void) CopyMagickString(q,value,extent);
3240 Look for user option of this name (should never match in CLI usage)
3242 if (image_info != (ImageInfo *) NULL) {
3243 value=GetImageOption(image_info,pattern);
3244 if (value != (char *) NULL)
3246 length=strlen(value);
3247 if ((size_t) (q-interpret_text+length+1) >= extent)
3250 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3251 extent+MaxTextExtent,sizeof(*interpret_text));
3252 if (interpret_text == (char *) NULL)
3253 return((char *)NULL);
3254 q=interpret_text+strlen(interpret_text);
3256 (void) CopyMagickString(q,value,extent);
3262 Failed to find any match anywhere!
3264 if (len >= 64) { /* truncate string for error message */
3270 (void) ThrowMagickException(exception,GetMagickModule(),
3271 OptionWarning,"UnknownImageProperty","\"%%[%s]\"",pattern);
3273 } /* Braced Percent Escape */
3275 } /* for each char in 'embed_text' */
3277 return(interpret_text);
3281 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3285 % R e m o v e I m a g e P r o p e r t y %
3289 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3291 % RemoveImageProperty() removes a property from the image and returns its
3294 % The format of the RemoveImageProperty method is:
3296 % char *RemoveImageProperty(Image *image,const char *property)
3298 % A description of each parameter follows:
3300 % o image: the image.
3302 % o property: the image property.
3305 MagickExport char *RemoveImageProperty(Image *image,
3306 const char *property)
3311 assert(image != (Image *) NULL);
3312 assert(image->signature == MagickSignature);
3313 if( IfMagickTrue(image->debug) )
3314 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3316 if (image->properties == (void *) NULL)
3317 return((char *) NULL);
3318 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3328 % 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 %
3332 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3334 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3335 % in conjunction with GetNextImageProperty() to iterate over all the values
3336 % associated with an image property.
3338 % The format of the ResetImagePropertyIterator method is:
3340 % ResetImagePropertyIterator(Image *image)
3342 % A description of each parameter follows:
3344 % o image: the image.
3347 MagickExport void ResetImagePropertyIterator(const Image *image)
3349 assert(image != (Image *) NULL);
3350 assert(image->signature == MagickSignature);
3351 if( IfMagickTrue(image->debug) )
3352 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3354 if (image->properties == (void *) NULL)
3356 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3364 % S e t I m a g e P r o p e r t y %
3368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3370 % SetImageProperty() saves the given string value either to specific known
3371 % attribute or to a freeform properity string.
3373 % Attempting to set a properity that is normally calculated will produce
3376 % The format of the SetImageProperty method is:
3378 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3379 % const char *value,ExceptionInfo *exception)
3381 % A description of each parameter follows:
3383 % o image: the image.
3385 % o property: the image property.
3387 % o values: the image property values.
3389 % o exception: return any errors or warnings in this structure.
3392 MagickExport MagickBooleanType SetImageProperty(Image *image,
3393 const char *property,const char *value,ExceptionInfo *exception)
3401 assert(image != (Image *) NULL);
3402 assert(image->signature == MagickSignature);
3403 if( IfMagickTrue(image->debug) )
3404 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
3406 /* Create splay-tree */
3407 if (image->properties == (void *) NULL)
3408 image->properties=NewSplayTree(CompareSplayTreeString,
3409 RelinquishMagickMemory,RelinquishMagickMemory);
3411 /* Delete properity if NULL -- empty string values are valid! */
3412 if ((value == (const char *) NULL))
3413 return(DeleteImageProperty(image,property));
3416 /* Do not 'set' single letter properties - read only shorthand */
3417 if (strlen(property) <= 1)
3419 (void) ThrowMagickException(exception,GetMagickModule(),
3420 OptionError,"SetReadOnlyProperty","'%s'",property);
3421 return(MagickFalse);
3424 /* FUTURE: These should produce 'illegal settings'
3425 + binary chars in p[roperty key
3426 + single letter property keys (read only)
3427 + known special prefix (read only, they don't get saved!)
3435 if (LocaleCompare("background",property) == 0)
3437 (void) QueryColorCompliance(value,AllCompliance,
3438 &image->background_color,exception);
3441 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3442 ConstantString(property),ConstantString(value));
3443 /* FUTURE: error if status is bad? */
3449 if (LocaleCompare("channels",property) == 0)
3451 (void) ThrowMagickException(exception,GetMagickModule(),
3452 OptionError,"SetReadOnlyProperty","'%s'",property);
3456 if (LocaleCompare("colorspace",property) == 0)
3461 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
3465 image->colorspace=(ColorspaceType) colorspace;
3468 if (LocaleCompare("compose",property) == 0)
3473 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
3476 image->compose=(CompositeOperator) compose;
3479 if (LocaleCompare("compress",property) == 0)
3484 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
3486 if (compression < 0)
3488 image->compression=(CompressionType) compression;
3491 if (LocaleCompare("copyright",property) == 0)
3493 (void) ThrowMagickException(exception,GetMagickModule(),
3494 OptionError,"SetReadOnlyProperty","'%s'",property);
3498 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3499 ConstantString(property),ConstantString(value));
3505 if (LocaleCompare("delay",property) == 0)
3510 flags=ParseGeometry(value,&geometry_info);
3511 if ((flags & GreaterValue) != 0)
3513 if (image->delay > (size_t) floor(geometry_info.rho+0.5))
3514 image->delay=(size_t) floor(geometry_info.rho+0.5);
3517 if ((flags & LessValue) != 0)
3519 if (image->delay < (size_t) floor(geometry_info.rho+0.5))
3520 image->ticks_per_second=(ssize_t)
3521 floor(geometry_info.sigma+0.5);
3524 image->delay=(size_t) floor(geometry_info.rho+0.5);
3525 if ((flags & SigmaValue) != 0)
3526 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
3529 if (LocaleCompare("density",property) == 0)
3534 flags=ParseGeometry(value,&geometry_info);
3535 image->resolution.x=geometry_info.rho;
3536 image->resolution.y=geometry_info.sigma;
3537 if ((flags & SigmaValue) == 0)
3538 image->resolution.y=image->resolution.x;
3540 if (LocaleCompare("depth",property) == 0)
3542 image->depth=StringToUnsignedLong(value);
3545 if (LocaleCompare("dispose",property) == 0)
3550 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
3553 image->dispose=(DisposeType) dispose;
3556 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3557 ConstantString(property),ConstantString(value));
3563 if (LocaleCompare("gamma",property) == 0)
3565 image->gamma=StringToDouble(value,(char **) NULL);
3568 if (LocaleCompare("gravity",property) == 0)
3573 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
3576 image->gravity=(GravityType) gravity;
3579 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3580 ConstantString(property),ConstantString(value));
3585 if (LocaleCompare("height",property) == 0)
3587 (void) ThrowMagickException(exception,GetMagickModule(),
3588 OptionError,"SetReadOnlyProperty","'%s'",property);
3595 if (LocaleCompare("intent",property) == 0)
3600 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
3602 if (rendering_intent < 0)
3604 image->rendering_intent=(RenderingIntent) rendering_intent;
3607 if (LocaleCompare("interpolate",property) == 0)
3612 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
3614 if (interpolate < 0)
3616 image->interpolate=(PixelInterpolateMethod) interpolate;
3619 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3620 ConstantString(property),ConstantString(value));
3625 if (LocaleCompare("kurtosis",property) == 0)
3627 (void) ThrowMagickException(exception,GetMagickModule(),
3628 OptionError,"SetReadOnlyProperty","'%s'",property);
3635 if (LocaleCompare("loop",property) == 0)
3637 image->iterations=StringToUnsignedLong(value);
3640 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3641 ConstantString(property),ConstantString(value));
3646 if ( (LocaleCompare("magick",property) == 0) ||
3647 (LocaleCompare("max",property) == 0) ||
3648 (LocaleCompare("mean",property) == 0) ||
3649 (LocaleCompare("min",property) == 0) ||
3650 (LocaleCompare("min",property) == 0) )
3652 (void) ThrowMagickException(exception,GetMagickModule(),
3653 OptionError,"SetReadOnlyProperty","'%s'",property);
3659 if (LocaleCompare("opaque",property) == 0)
3661 (void) ThrowMagickException(exception,GetMagickModule(),
3662 OptionError,"SetReadOnlyProperty","'%s'",property);
3669 if (LocaleCompare("page",property) == 0)
3674 geometry=GetPageGeometry(value);
3675 flags=ParseAbsoluteGeometry(geometry,&image->page);
3676 geometry=DestroyString(geometry);
3679 if (LocaleCompare("profile",property) == 0)
3687 image_info=AcquireImageInfo();
3688 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
3689 (void) SetImageInfo(image_info,1,exception);
3690 profile=FileToStringInfo(image_info->filename,~0UL,exception);
3691 if (profile != (StringInfo *) NULL)
3692 status=SetImageProfile(image,image_info->magick,profile,exception);
3693 image_info=DestroyImageInfo(image_info);
3696 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3697 ConstantString(property),ConstantString(value));
3703 if (LocaleCompare("rendering-intent",property) == 0)
3708 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
3710 if (rendering_intent < 0)
3713 image->rendering_intent=(RenderingIntent) rendering_intent;
3716 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3717 ConstantString(property),ConstantString(value));
3722 if ( (LocaleCompare("size",property) == 0) ||
3723 (LocaleCompare("skewness",property) == 0) ||
3724 (LocaleCompare("scenes",property) == 0) ||
3725 (LocaleCompare("standard-deviation",property) == 0) )
3727 (void) ThrowMagickException(exception,GetMagickModule(),
3728 OptionError,"SetReadOnlyProperty","'%s'",property);
3735 if (LocaleCompare("tile-offset",property) == 0)
3740 geometry=GetPageGeometry(value);
3741 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3742 geometry=DestroyString(geometry);
3745 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3746 ConstantString(property),ConstantString(value));
3752 if (LocaleCompare("units",property) == 0)
3757 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
3760 image->units=(ResolutionType) units;
3763 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3764 ConstantString(property),ConstantString(value));
3769 if (LocaleCompare("version",property) == 0)
3771 (void) ThrowMagickException(exception,GetMagickModule(),
3772 OptionError,"SetReadOnlyProperty","'%s'",property);
3778 if (LocaleCompare("width",property) == 0)
3780 (void) ThrowMagickException(exception,GetMagickModule(),
3781 OptionError,"SetReadOnlyProperty","'%s'",property);
3787 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3788 ConstantString(property),ConstantString(value));