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-2009 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 "magick/studio.h"
44 #include "magick/attribute.h"
45 #include "magick/cache.h"
46 #include "magick/color.h"
47 #include "magick/compare.h"
48 #include "magick/constitute.h"
49 #include "magick/draw.h"
50 #include "magick/effect.h"
51 #include "magick/exception.h"
52 #include "magick/exception-private.h"
53 #include "magick/fx.h"
54 #include "magick/fx-private.h"
55 #include "magick/gem.h"
56 #include "magick/geometry.h"
57 #include "magick/histogram.h"
58 #include "magick/image.h"
59 #include "magick/image.h"
60 #include "magick/layer.h"
61 #include "magick/list.h"
62 #include "magick/memory_.h"
63 #include "magick/monitor.h"
64 #include "magick/montage.h"
65 #include "magick/option.h"
66 #include "magick/profile.h"
67 #include "magick/property.h"
68 #include "magick/quantum.h"
69 #include "magick/resource_.h"
70 #include "magick/splay-tree.h"
71 #include "magick/signature-private.h"
72 #include "magick/statistic.h"
73 #include "magick/string_.h"
74 #include "magick/token.h"
75 #include "magick/utility.h"
76 #include "magick/xml-tree.h"
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83 % C l o n e I m a g e P r o p e r t i e s %
87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 % CloneImageProperties() clones one or more image properties.
91 % The format of the CloneImageProperties method is:
93 % MagickBooleanType CloneImageProperties(Image *image,
94 % const Image *clone_image)
96 % A description of each parameter follows:
100 % o clone_image: the clone image.
103 MagickExport MagickBooleanType CloneImageProperties(Image *image,
104 const Image *clone_image)
106 assert(image != (Image *) NULL);
107 assert(image->signature == MagickSignature);
108 if (image->debug != MagickFalse)
109 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
110 assert(clone_image != (const Image *) NULL);
111 assert(clone_image->signature == MagickSignature);
112 if (clone_image->debug != MagickFalse)
113 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
114 clone_image->filename);
115 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
116 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
118 image->compression=clone_image->compression;
119 image->quality=clone_image->quality;
120 image->depth=clone_image->depth;
121 image->background_color=clone_image->background_color;
122 image->border_color=clone_image->border_color;
123 image->matte_color=clone_image->matte_color;
124 image->transparent_color=clone_image->transparent_color;
125 image->gamma=clone_image->gamma;
126 image->chromaticity=clone_image->chromaticity;
127 image->rendering_intent=clone_image->rendering_intent;
128 image->black_point_compensation=clone_image->black_point_compensation;
129 image->units=clone_image->units;
130 image->montage=(char *) NULL;
131 image->directory=(char *) NULL;
132 (void) CloneString(&image->geometry,clone_image->geometry);
133 image->offset=clone_image->offset;
134 image->x_resolution=clone_image->x_resolution;
135 image->y_resolution=clone_image->y_resolution;
136 image->page=clone_image->page;
137 image->tile_offset=clone_image->tile_offset;
138 image->extract_info=clone_image->extract_info;
139 image->bias=clone_image->bias;
140 image->filter=clone_image->filter;
141 image->blur=clone_image->blur;
142 image->fuzz=clone_image->fuzz;
143 image->interlace=clone_image->interlace;
144 image->interpolate=clone_image->interpolate;
145 image->endian=clone_image->endian;
146 image->gravity=clone_image->gravity;
147 image->compose=clone_image->compose;
148 image->scene=clone_image->scene;
149 image->orientation=clone_image->orientation;
150 image->dispose=clone_image->dispose;
151 image->delay=clone_image->delay;
152 image->ticks_per_second=clone_image->ticks_per_second;
153 image->iterations=clone_image->iterations;
154 image->total_colors=clone_image->total_colors;
155 image->taint=clone_image->taint;
156 image->progress_monitor=clone_image->progress_monitor;
157 image->client_data=clone_image->client_data;
158 image->start_loop=clone_image->start_loop;
159 image->error=clone_image->error;
160 image->signature=clone_image->signature;
161 if (clone_image->properties != (void *) NULL)
163 if (image->properties != (void *) NULL)
164 DestroyImageProperties(image);
165 image->properties=CloneSplayTree((SplayTreeInfo *)
166 clone_image->properties,(void *(*)(void *)) ConstantString,
167 (void *(*)(void *)) ConstantString);
173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177 % D e f i n e I m a g e P r o p e r t y %
181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 % DefineImageProperty() associates a key/value pair with an image property.
185 % The format of the DefineImageProperty method is:
187 % MagickBooleanType DefineImageProperty(Image *image,
188 % const char *property)
190 % A description of each parameter follows:
192 % o image: the image.
194 % o property: the image property.
197 MagickExport MagickBooleanType DefineImageProperty(Image *image,
198 const char *property)
202 value[MaxTextExtent];
207 assert(image != (Image *) NULL);
208 assert(property != (const char *) NULL);
209 (void) CopyMagickString(key,property,MaxTextExtent-1);
210 for (p=key; *p != '\0'; p++)
215 (void) CopyMagickString(value,p+1,MaxTextExtent);
217 return(SetImageProperty(image,key,value));
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
225 % D e l e t e I m a g e P r o p e r t y %
229 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
231 % DeleteImageProperty() deletes an image property.
233 % The format of the DeleteImageProperty method is:
235 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
237 % A description of each parameter follows:
239 % o image: the image.
241 % o property: the image property.
244 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
245 const char *property)
247 assert(image != (Image *) NULL);
248 assert(image->signature == MagickSignature);
249 if (image->debug != MagickFalse)
250 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
252 if (image->properties == (void *) NULL)
254 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
258 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
262 % D e s t r o y I m a g e P r o p e r t i e s %
266 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
268 % DestroyImageProperties() releases memory associated with image property
271 % The format of the DestroyDefines method is:
273 % void DestroyImageProperties(Image *image)
275 % A description of each parameter follows:
277 % o image: the image.
280 MagickExport void DestroyImageProperties(Image *image)
282 assert(image != (Image *) NULL);
283 assert(image->signature == MagickSignature);
284 if (image->debug != MagickFalse)
285 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
287 if (image->properties != (void *) NULL)
288 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
297 % F o r m a t I m a g e P r o p e r t y %
301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
303 % FormatImageProperty() permits formatted property/value pairs to be saved as
306 % The format of the FormatImageProperty method is:
308 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
309 % const char *format,...)
311 % A description of each parameter follows.
313 % o image: The image.
315 % o property: The attribute property.
317 % o format: A string describing the format to use to write the remaining
322 MagickExport MagickBooleanType FormatImagePropertyList(Image *image,
323 const char *property,const char *format,va_list operands)
326 value[MaxTextExtent];
331 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
332 n=vsnprintf(value,MaxTextExtent,format,operands);
334 n=vsprintf(value,format,operands);
337 value[MaxTextExtent-1]='\0';
338 return(SetImageProperty(image,property,value));
341 MagickExport MagickBooleanType FormatImageProperty(Image *image,
342 const char *property,const char *format,...)
350 va_start(operands,format);
351 status=FormatImagePropertyList(image,property,format,operands);
357 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
361 % G e t I m a g e P r o p e r t y %
365 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
367 % GetImageProperty() gets a value associated with an image property.
369 % The format of the GetImageProperty method is:
371 % const char *GetImageProperty(const Image *image,const char *key)
373 % A description of each parameter follows:
375 % o image: the image.
382 *TracePSClippath(const unsigned char *,size_t,const unsigned long,
383 const unsigned long),
384 *TraceSVGClippath(const unsigned char *,size_t,const unsigned long,
385 const unsigned long);
387 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
407 profile=GetImageProfile(image,"iptc");
408 if (profile == (StringInfo *) NULL)
409 profile=GetImageProfile(image,"8bim");
410 if (profile == (StringInfo *) NULL)
412 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
415 attribute=(char *) NULL;
416 for (i=0; i < (long) GetStringInfoLength(profile); i+=(long) length)
419 if ((long) GetStringInfoDatum(profile)[i] != 0x1c)
421 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
422 length|=GetStringInfoDatum(profile)[i+4];
423 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
424 ((long) GetStringInfoDatum(profile)[i+2] == record))
426 message=(char *) NULL;
428 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
429 if (message != (char *) NULL)
431 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
432 profile)+i+5,length+1);
433 (void) ConcatenateString(&attribute,message);
434 (void) ConcatenateString(&attribute,";");
435 message=DestroyString(message);
440 if ((attribute == (char *) NULL) || (*attribute == ';'))
442 if (attribute != (char *) NULL)
443 attribute=DestroyString(attribute);
446 attribute[strlen(attribute)-1]='\0';
447 (void) SetImageProperty((Image *) image,key,(const char *) attribute);
448 attribute=DestroyString(attribute);
452 static inline long MagickMax(const long x,const long y)
459 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
471 static inline unsigned long ReadPropertyMSBLong(const unsigned char **p,
488 for (i=0; i < 4; i++)
492 buffer[i]=(unsigned char) c;
494 value=(unsigned long) (buffer[0] << 24);
495 value|=buffer[1] << 16;
496 value|=buffer[2] << 8;
498 return(value & 0xffffffff);
501 static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
517 return((unsigned short) ~0U);
518 for (i=0; i < 2; i++)
522 buffer[i]=(unsigned char) c;
524 value=(unsigned short) (buffer[0] << 8);
526 return((unsigned short) (value & 0xffff));
529 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
533 format[MaxTextExtent],
562 There's no newlines in path names, so it's safe as terminator.
564 profile=GetImageProfile(image,"8bim");
565 if (profile == (StringInfo *) NULL)
567 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name,
569 if ((count != 2) && (count != 3) && (count != 4))
572 (void) CopyMagickString(format,"SVG",MaxTextExtent);
577 sub_number=atol(&name[1]);
578 sub_number=MagickMax(sub_number,1L);
579 resource=(char *) NULL;
581 length=GetStringInfoLength(profile);
582 info=GetStringInfoDatum(profile);
583 while ((length > 0) && (status == MagickFalse))
585 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
587 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
589 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
591 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
593 id=(long) ReadPropertyMSBShort(&info,&length);
598 if (resource != (char *) NULL)
599 resource=DestroyString(resource);
600 count=(ssize_t) ReadPropertyByte(&info,&length);
601 if ((count != 0) && ((size_t) count <= length))
603 resource=(char *) NULL;
604 if (~(1UL*count) >= MaxTextExtent)
605 resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
607 if (resource != (char *) NULL)
609 for (i=0; i < (long) count; i++)
610 resource[i]=(char) ReadPropertyByte(&info,&length);
611 resource[count]='\0';
614 if ((count & 0x01) == 0)
615 (void) ReadPropertyByte(&info,&length);
616 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
617 if ((*name != '\0') && (*name != '#'))
618 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
621 No name match, scroll forward and try next.
627 if ((*name == '#') && (sub_number != 1))
630 No numbered match, scroll forward and try next.
638 We have the resource of interest.
640 attribute=(char *) NULL;
641 if (~(1UL*count) >= MaxTextExtent)
642 attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
644 if (attribute != (char *) NULL)
646 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
647 attribute[count]='\0';
650 if ((id <= 1999) || (id >= 2999))
651 (void) SetImageProperty((Image *) image,key,(const char *)
658 if (LocaleCompare(format,"svg") == 0)
659 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
660 image->columns,image->rows);
662 path=TracePSClippath((unsigned char *) attribute,(size_t) count,
663 image->columns,image->rows);
664 (void) SetImageProperty((Image *) image,key,(const char *) path);
665 path=DestroyString(path);
667 attribute=DestroyString(attribute);
671 if (resource != (char *) NULL)
672 resource=DestroyString(resource);
676 static inline unsigned short ReadPropertyShort(const EndianType endian,
677 const unsigned char *buffer)
682 if (endian == MSBEndian)
684 value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
685 ((unsigned char *) buffer)[1]);
686 return((unsigned short) (value & 0xffff));
688 value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
689 return((unsigned short) (value & 0xffff));
692 static inline unsigned long ReadPropertyLong(const EndianType endian,
693 const unsigned char *buffer)
698 if (endian == MSBEndian)
700 value=(unsigned long) ((buffer[0] << 24) | (buffer[1] << 16) |
701 (buffer[2] << 8) | buffer[3]);
702 return((unsigned long) (value & 0xffffffff));
704 value=(unsigned long) ((buffer[3] << 24) | (buffer[2] << 16) |
705 (buffer[1] << 8 ) | (buffer[0]));
706 return((unsigned long) (value & 0xffffffff));
709 static MagickBooleanType GetEXIFProperty(const Image *image,
710 const char *property)
712 #define MaxDirectoryStack 16
713 #define EXIF_DELIMITER "\n"
714 #define EXIF_NUM_FORMATS 12
715 #define EXIF_FMT_BYTE 1
716 #define EXIF_FMT_STRING 2
717 #define EXIF_FMT_USHORT 3
718 #define EXIF_FMT_ULONG 4
719 #define EXIF_FMT_URATIONAL 5
720 #define EXIF_FMT_SBYTE 6
721 #define EXIF_FMT_UNDEFINED 7
722 #define EXIF_FMT_SSHORT 8
723 #define EXIF_FMT_SLONG 9
724 #define EXIF_FMT_SRATIONAL 10
725 #define EXIF_FMT_SINGLE 11
726 #define EXIF_FMT_DOUBLE 12
727 #define TAG_EXIF_OFFSET 0x8769
728 #define TAG_GPS_OFFSET 0x8825
729 #define TAG_INTEROP_OFFSET 0xa005
731 #define EXIFMultipleValues(size, format, arg) \
744 for (component=0; component < components; component++) \
746 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
748 if (length >= MaxTextExtent - 1) \
749 length=MaxTextExtent-1; \
753 buffer[length-2]='\0'; \
754 value=AcquireString(buffer); \
757 #define EXIFMultipleFractions(size, format, arg1, arg2) \
770 for (component=0; component < components; component++) \
772 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
773 format", ",arg1, arg2); \
774 if (length >= MaxTextExtent - 1) \
775 length=MaxTextExtent-1; \
779 buffer[length-2]='\0'; \
780 value=AcquireString(buffer); \
783 typedef struct _DirectoryInfo
793 typedef struct _TagInfo
805 { 0x001, "exif:InteroperabilityIndex" },
806 { 0x002, "exif:InteroperabilityVersion" },
807 { 0x100, "exif:ImageWidth" },
808 { 0x101, "exif:ImageLength" },
809 { 0x102, "exif:BitsPerSample" },
810 { 0x103, "exif:Compression" },
811 { 0x106, "exif:PhotometricInterpretation" },
812 { 0x10a, "exif:FillOrder" },
813 { 0x10d, "exif:DocumentName" },
814 { 0x10e, "exif:ImageDescription" },
815 { 0x10f, "exif:Make" },
816 { 0x110, "exif:Model" },
817 { 0x111, "exif:StripOffsets" },
818 { 0x112, "exif:Orientation" },
819 { 0x115, "exif:SamplesPerPixel" },
820 { 0x116, "exif:RowsPerStrip" },
821 { 0x117, "exif:StripByteCounts" },
822 { 0x11a, "exif:XResolution" },
823 { 0x11b, "exif:YResolution" },
824 { 0x11c, "exif:PlanarConfiguration" },
825 { 0x11d, "exif:PageName" },
826 { 0x11e, "exif:XPosition" },
827 { 0x11f, "exif:YPosition" },
828 { 0x118, "exif:MinSampleValue" },
829 { 0x119, "exif:MaxSampleValue" },
830 { 0x120, "exif:FreeOffsets" },
831 { 0x121, "exif:FreeByteCounts" },
832 { 0x122, "exif:GrayResponseUnit" },
833 { 0x123, "exif:GrayResponseCurve" },
834 { 0x124, "exif:T4Options" },
835 { 0x125, "exif:T6Options" },
836 { 0x128, "exif:ResolutionUnit" },
837 { 0x12d, "exif:TransferFunction" },
838 { 0x131, "exif:Software" },
839 { 0x132, "exif:DateTime" },
840 { 0x13b, "exif:Artist" },
841 { 0x13e, "exif:WhitePoint" },
842 { 0x13f, "exif:PrimaryChromaticities" },
843 { 0x140, "exif:ColorMap" },
844 { 0x141, "exif:HalfToneHints" },
845 { 0x142, "exif:TileWidth" },
846 { 0x143, "exif:TileLength" },
847 { 0x144, "exif:TileOffsets" },
848 { 0x145, "exif:TileByteCounts" },
849 { 0x14a, "exif:SubIFD" },
850 { 0x14c, "exif:InkSet" },
851 { 0x14d, "exif:InkNames" },
852 { 0x14e, "exif:NumberOfInks" },
853 { 0x150, "exif:DotRange" },
854 { 0x151, "exif:TargetPrinter" },
855 { 0x152, "exif:ExtraSample" },
856 { 0x153, "exif:SampleFormat" },
857 { 0x154, "exif:SMinSampleValue" },
858 { 0x155, "exif:SMaxSampleValue" },
859 { 0x156, "exif:TransferRange" },
860 { 0x157, "exif:ClipPath" },
861 { 0x158, "exif:XClipPathUnits" },
862 { 0x159, "exif:YClipPathUnits" },
863 { 0x15a, "exif:Indexed" },
864 { 0x15b, "exif:JPEGTables" },
865 { 0x15f, "exif:OPIProxy" },
866 { 0x200, "exif:JPEGProc" },
867 { 0x201, "exif:JPEGInterchangeFormat" },
868 { 0x202, "exif:JPEGInterchangeFormatLength" },
869 { 0x203, "exif:JPEGRestartInterval" },
870 { 0x205, "exif:JPEGLosslessPredictors" },
871 { 0x206, "exif:JPEGPointTransforms" },
872 { 0x207, "exif:JPEGQTables" },
873 { 0x208, "exif:JPEGDCTables" },
874 { 0x209, "exif:JPEGACTables" },
875 { 0x211, "exif:YCbCrCoefficients" },
876 { 0x212, "exif:YCbCrSubSampling" },
877 { 0x213, "exif:YCbCrPositioning" },
878 { 0x214, "exif:ReferenceBlackWhite" },
879 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
880 { 0x301, "exif:Gamma" },
881 { 0x302, "exif:ICCProfileDescriptor" },
882 { 0x303, "exif:SRGBRenderingIntent" },
883 { 0x320, "exif:ImageTitle" },
884 { 0x5001, "exif:ResolutionXUnit" },
885 { 0x5002, "exif:ResolutionYUnit" },
886 { 0x5003, "exif:ResolutionXLengthUnit" },
887 { 0x5004, "exif:ResolutionYLengthUnit" },
888 { 0x5005, "exif:PrintFlags" },
889 { 0x5006, "exif:PrintFlagsVersion" },
890 { 0x5007, "exif:PrintFlagsCrop" },
891 { 0x5008, "exif:PrintFlagsBleedWidth" },
892 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
893 { 0x500A, "exif:HalftoneLPI" },
894 { 0x500B, "exif:HalftoneLPIUnit" },
895 { 0x500C, "exif:HalftoneDegree" },
896 { 0x500D, "exif:HalftoneShape" },
897 { 0x500E, "exif:HalftoneMisc" },
898 { 0x500F, "exif:HalftoneScreen" },
899 { 0x5010, "exif:JPEGQuality" },
900 { 0x5011, "exif:GridSize" },
901 { 0x5012, "exif:ThumbnailFormat" },
902 { 0x5013, "exif:ThumbnailWidth" },
903 { 0x5014, "exif:ThumbnailHeight" },
904 { 0x5015, "exif:ThumbnailColorDepth" },
905 { 0x5016, "exif:ThumbnailPlanes" },
906 { 0x5017, "exif:ThumbnailRawBytes" },
907 { 0x5018, "exif:ThumbnailSize" },
908 { 0x5019, "exif:ThumbnailCompressedSize" },
909 { 0x501a, "exif:ColorTransferFunction" },
910 { 0x501b, "exif:ThumbnailData" },
911 { 0x5020, "exif:ThumbnailImageWidth" },
912 { 0x5021, "exif:ThumbnailImageHeight" },
913 { 0x5022, "exif:ThumbnailBitsPerSample" },
914 { 0x5023, "exif:ThumbnailCompression" },
915 { 0x5024, "exif:ThumbnailPhotometricInterp" },
916 { 0x5025, "exif:ThumbnailImageDescription" },
917 { 0x5026, "exif:ThumbnailEquipMake" },
918 { 0x5027, "exif:ThumbnailEquipModel" },
919 { 0x5028, "exif:ThumbnailStripOffsets" },
920 { 0x5029, "exif:ThumbnailOrientation" },
921 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
922 { 0x502b, "exif:ThumbnailRowsPerStrip" },
923 { 0x502c, "exif:ThumbnailStripBytesCount" },
924 { 0x502d, "exif:ThumbnailResolutionX" },
925 { 0x502e, "exif:ThumbnailResolutionY" },
926 { 0x502f, "exif:ThumbnailPlanarConfig" },
927 { 0x5030, "exif:ThumbnailResolutionUnit" },
928 { 0x5031, "exif:ThumbnailTransferFunction" },
929 { 0x5032, "exif:ThumbnailSoftwareUsed" },
930 { 0x5033, "exif:ThumbnailDateTime" },
931 { 0x5034, "exif:ThumbnailArtist" },
932 { 0x5035, "exif:ThumbnailWhitePoint" },
933 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
934 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
935 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
936 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
937 { 0x503A, "exif:ThumbnailRefBlackWhite" },
938 { 0x503B, "exif:ThumbnailCopyRight" },
939 { 0x5090, "exif:LuminanceTable" },
940 { 0x5091, "exif:ChrominanceTable" },
941 { 0x5100, "exif:FrameDelay" },
942 { 0x5101, "exif:LoopCount" },
943 { 0x5110, "exif:PixelUnit" },
944 { 0x5111, "exif:PixelPerUnitX" },
945 { 0x5112, "exif:PixelPerUnitY" },
946 { 0x5113, "exif:PaletteHistogram" },
947 { 0x1000, "exif:RelatedImageFileFormat" },
948 { 0x1001, "exif:RelatedImageLength" },
949 { 0x1002, "exif:RelatedImageWidth" },
950 { 0x800d, "exif:ImageID" },
951 { 0x80e3, "exif:Matteing" },
952 { 0x80e4, "exif:DataType" },
953 { 0x80e5, "exif:ImageDepth" },
954 { 0x80e6, "exif:TileDepth" },
955 { 0x828d, "exif:CFARepeatPatternDim" },
956 { 0x828e, "exif:CFAPattern2" },
957 { 0x828f, "exif:BatteryLevel" },
958 { 0x8298, "exif:Copyright" },
959 { 0x829a, "exif:ExposureTime" },
960 { 0x829d, "exif:FNumber" },
961 { 0x83bb, "exif:IPTC/NAA" },
962 { 0x84e3, "exif:IT8RasterPadding" },
963 { 0x84e5, "exif:IT8ColorTable" },
964 { 0x8649, "exif:ImageResourceInformation" },
965 { 0x8769, "exif:ExifOffset" },
966 { 0x8773, "exif:InterColorProfile" },
967 { 0x8822, "exif:ExposureProgram" },
968 { 0x8824, "exif:SpectralSensitivity" },
969 { 0x8825, "exif:GPSInfo" },
970 { 0x8827, "exif:ISOSpeedRatings" },
971 { 0x8828, "exif:OECF" },
972 { 0x8829, "exif:Interlace" },
973 { 0x882a, "exif:TimeZoneOffset" },
974 { 0x882b, "exif:SelfTimerMode" },
975 { 0x9000, "exif:ExifVersion" },
976 { 0x9003, "exif:DateTimeOriginal" },
977 { 0x9004, "exif:DateTimeDigitized" },
978 { 0x9101, "exif:ComponentsConfiguration" },
979 { 0x9102, "exif:CompressedBitsPerPixel" },
980 { 0x9201, "exif:ShutterSpeedValue" },
981 { 0x9202, "exif:ApertureValue" },
982 { 0x9203, "exif:BrightnessValue" },
983 { 0x9204, "exif:ExposureBiasValue" },
984 { 0x9205, "exif:MaxApertureValue" },
985 { 0x9206, "exif:SubjectDistance" },
986 { 0x9207, "exif:MeteringMode" },
987 { 0x9208, "exif:LightSource" },
988 { 0x9209, "exif:Flash" },
989 { 0x920a, "exif:FocalLength" },
990 { 0x920b, "exif:FlashEnergy" },
991 { 0x920c, "exif:SpatialFrequencyResponse" },
992 { 0x920d, "exif:Noise" },
993 { 0x9211, "exif:ImageNumber" },
994 { 0x9212, "exif:SecurityClassification" },
995 { 0x9213, "exif:ImageHistory" },
996 { 0x9214, "exif:SubjectArea" },
997 { 0x9215, "exif:ExposureIndex" },
998 { 0x9216, "exif:TIFF-EPStandardID" },
999 { 0x927c, "exif:MakerNote" },
1000 { 0x9C9b, "exif:WinXP-Title" },
1001 { 0x9C9c, "exif:WinXP-Comments" },
1002 { 0x9C9d, "exif:WinXP-Author" },
1003 { 0x9C9e, "exif:WinXP-Keywords" },
1004 { 0x9C9f, "exif:WinXP-Subject" },
1005 { 0x9286, "exif:UserComment" },
1006 { 0x9290, "exif:SubSecTime" },
1007 { 0x9291, "exif:SubSecTimeOriginal" },
1008 { 0x9292, "exif:SubSecTimeDigitized" },
1009 { 0xa000, "exif:FlashPixVersion" },
1010 { 0xa001, "exif:ColorSpace" },
1011 { 0xa002, "exif:ExifImageWidth" },
1012 { 0xa003, "exif:ExifImageLength" },
1013 { 0xa004, "exif:RelatedSoundFile" },
1014 { 0xa005, "exif:InteroperabilityOffset" },
1015 { 0xa20b, "exif:FlashEnergy" },
1016 { 0xa20c, "exif:SpatialFrequencyResponse" },
1017 { 0xa20d, "exif:Noise" },
1018 { 0xa20e, "exif:FocalPlaneXResolution" },
1019 { 0xa20f, "exif:FocalPlaneYResolution" },
1020 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1021 { 0xa214, "exif:SubjectLocation" },
1022 { 0xa215, "exif:ExposureIndex" },
1023 { 0xa216, "exif:TIFF/EPStandardID" },
1024 { 0xa217, "exif:SensingMethod" },
1025 { 0xa300, "exif:FileSource" },
1026 { 0xa301, "exif:SceneType" },
1027 { 0xa302, "exif:CFAPattern" },
1028 { 0xa401, "exif:CustomRendered" },
1029 { 0xa402, "exif:ExposureMode" },
1030 { 0xa403, "exif:WhiteBalance" },
1031 { 0xa404, "exif:DigitalZoomRatio" },
1032 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1033 { 0xa406, "exif:SceneCaptureType" },
1034 { 0xa407, "exif:GainControl" },
1035 { 0xa408, "exif:Contrast" },
1036 { 0xa409, "exif:Saturation" },
1037 { 0xa40a, "exif:Sharpness" },
1038 { 0xa40b, "exif:DeviceSettingDescription" },
1039 { 0xa40c, "exif:SubjectDistanceRange" },
1040 { 0xa420, "exif:ImageUniqueID" },
1041 { 0xc4a5, "exif:PrintImageMatching" },
1042 { 0x10000, "exif:GPSVersionID" },
1043 { 0x10001, "exif:GPSLatitudeRef" },
1044 { 0x10002, "exif:GPSLatitude" },
1045 { 0x10003, "exif:GPSLongitudeRef" },
1046 { 0x10004, "exif:GPSLongitude" },
1047 { 0x10005, "exif:GPSAltitudeRef" },
1048 { 0x10006, "exif:GPSAltitude" },
1049 { 0x10007, "exif:GPSTimeStamp" },
1050 { 0x10008, "exif:GPSSatellites" },
1051 { 0x10009, "exif:GPSStatus" },
1052 { 0x1000a, "exif:GPSMeasureMode" },
1053 { 0x1000b, "exif:GPSDop" },
1054 { 0x1000c, "exif:GPSSpeedRef" },
1055 { 0x1000d, "exif:GPSSpeed" },
1056 { 0x1000e, "exif:GPSTrackRef" },
1057 { 0x1000f, "exif:GPSTrack" },
1058 { 0x10010, "exif:GPSImgDirectionRef" },
1059 { 0x10011, "exif:GPSImgDirection" },
1060 { 0x10012, "exif:GPSMapDatum" },
1061 { 0x10013, "exif:GPSDestLatitudeRef" },
1062 { 0x10014, "exif:GPSDestLatitude" },
1063 { 0x10015, "exif:GPSDestLongitudeRef" },
1064 { 0x10016, "exif:GPSDestLongitude" },
1065 { 0x10017, "exif:GPSDestBearingRef" },
1066 { 0x10018, "exif:GPSDestBearing" },
1067 { 0x10019, "exif:GPSDestDistanceRef" },
1068 { 0x1001a, "exif:GPSDestDistance" },
1069 { 0x1001b, "exif:GPSProcessingMethod" },
1070 { 0x1001c, "exif:GPSAreaInformation" },
1071 { 0x1001d, "exif:GPSDateStamp" },
1072 { 0x1001e, "exif:GPSDifferential" },
1084 directory_stack[MaxDirectoryStack];
1105 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1114 If EXIF data exists, then try to parse the request for a tag.
1116 profile=GetImageProfile(image,"exif");
1117 if (profile == (StringInfo *) NULL)
1118 return(MagickFalse);
1119 if ((property == (const char *) NULL) || (*property == '\0'))
1120 return(MagickFalse);
1121 while (isspace((int) ((unsigned char) *property)) != 0)
1125 switch (*(property+5))
1130 Caller has asked for all the tags in the EXIF data.
1133 all=1; /* return the data in description=value format */
1139 all=2; /* return the data in tagid=value format */
1152 Check for a hex based tag specification first.
1154 tag=(*(property+5) == '@') ? 1UL : 0UL;
1158 return(MagickFalse);
1160 Parse tag specification as a hex number.
1165 for (i=(long) n-1L; i >= 0; i--)
1169 if ((c >= '0') && (c <= '9'))
1172 if ((c >= 'A') && (c <= 'F'))
1175 if ((c >= 'a') && (c <= 'f'))
1178 return(MagickFalse);
1180 } while (*property != '\0');
1186 Try to match the text with a tag name instead.
1190 if (EXIFTag[i].tag == 0)
1192 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1194 tag=(unsigned long) EXIFTag[i].tag;
1202 return(MagickFalse);
1203 length=GetStringInfoLength(profile);
1204 exif=GetStringInfoDatum(profile);
1207 if (ReadPropertyByte(&exif,&length) != 0x45)
1209 if (ReadPropertyByte(&exif,&length) != 0x78)
1211 if (ReadPropertyByte(&exif,&length) != 0x69)
1213 if (ReadPropertyByte(&exif,&length) != 0x66)
1215 if (ReadPropertyByte(&exif,&length) != 0x00)
1217 if (ReadPropertyByte(&exif,&length) != 0x00)
1222 return(MagickFalse);
1223 id=(long) ReadPropertyShort(LSBEndian,exif);
1231 return(MagickFalse);
1232 if (ReadPropertyShort(endian,exif+2) != 0x002a)
1233 return(MagickFalse);
1235 This the offset to the first IFD.
1237 offset=(ssize_t) ReadPropertyLong(endian,exif+4);
1238 if ((size_t) offset >= length)
1239 return(MagickFalse);
1241 Set the pointer to the first IFD and follow it were it leads.
1243 directory=exif+offset;
1250 If there is anything on the stack then pop it off.
1255 directory=directory_stack[level].directory;
1256 entry=directory_stack[level].entry;
1257 tag_offset=directory_stack[level].offset;
1260 Determine how many entries there are in the current IFD.
1262 number_entries=ReadPropertyShort(endian,directory);
1263 for ( ; entry < number_entries; entry++)
1268 register unsigned char
1278 q=(unsigned char *) (directory+2+(12*entry));
1279 tag_value=(long) ReadPropertyShort(endian,q)+tag_offset;
1280 format=(unsigned long) ReadPropertyShort(endian,q+2);
1281 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1283 components=(long) ReadPropertyLong(endian,q+4);
1284 number_bytes=(size_t) components*tag_bytes[format];
1285 if (number_bytes <= 4)
1293 The directory entry contains an offset.
1295 offset=(ssize_t) ReadPropertyLong(endian,q+8);
1296 if ((size_t) (offset+number_bytes) > length)
1298 p=(unsigned char *) (exif+offset);
1300 if ((all != 0) || (tag == (unsigned long) tag_value))
1303 buffer[MaxTextExtent],
1309 case EXIF_FMT_UNDEFINED:
1311 EXIFMultipleValues(1,"%lu",(unsigned long)
1312 (*(unsigned char *) p1));
1315 case EXIF_FMT_SBYTE:
1317 EXIFMultipleValues(1,"%ld",(long) (*(signed char *) p1));
1320 case EXIF_FMT_SSHORT:
1322 EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1));
1325 case EXIF_FMT_USHORT:
1327 EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1));
1330 case EXIF_FMT_ULONG:
1332 EXIFMultipleValues(4,"%lu",ReadPropertyLong(endian,p1));
1335 case EXIF_FMT_SLONG:
1337 EXIFMultipleValues(4,"%ld",ReadPropertyLong(endian,p1));
1340 case EXIF_FMT_URATIONAL:
1342 EXIFMultipleFractions(8,"%ld/%ld",ReadPropertyLong(endian,p1),
1343 ReadPropertyLong(endian,p1+4));
1346 case EXIF_FMT_SRATIONAL:
1348 EXIFMultipleFractions(8,"%ld/%ld",ReadPropertyLong(endian,p1),
1349 ReadPropertyLong(endian,p1+4));
1352 case EXIF_FMT_SINGLE:
1354 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1357 case EXIF_FMT_DOUBLE:
1359 EXIFMultipleValues(8,"%f",*(double *) p1);
1363 case EXIF_FMT_STRING:
1365 value=(char *) NULL;
1366 if (~(1UL*number_bytes) >= 1)
1367 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1369 if (value != (char *) NULL)
1374 for (i=0; i < (long) number_bytes; i++)
1377 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1378 value[i]=(char) p[i];
1385 if (value != (char *) NULL)
1393 (void) CopyMagickString(key,property,MaxTextExtent);
1404 description="unknown";
1407 if (EXIFTag[i].tag == 0)
1409 if ((long) EXIFTag[i].tag == tag_value)
1411 description=EXIFTag[i].description;
1415 (void) FormatMagickString(key,MaxTextExtent,"%s",
1421 if (tag_value < 0x10000)
1422 (void) FormatMagickString(key,MaxTextExtent,"#%04lx",
1425 if (tag_value < 0x20000)
1426 (void) FormatMagickString(key,MaxTextExtent,"@%04lx",
1427 tag_value & 0xffff);
1429 (void) FormatMagickString(key,MaxTextExtent,"unknown");
1433 p=(const char *) NULL;
1434 if (image->properties != (void *) NULL)
1435 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1436 image->properties,key);
1437 if (p == (const char *) NULL)
1438 (void) SetImageProperty((Image *) image,key,value);
1439 value=DestroyString(value);
1442 if ((tag_value == TAG_EXIF_OFFSET) ||
1443 (tag_value == TAG_INTEROP_OFFSET) ||
1444 (tag_value == TAG_GPS_OFFSET))
1449 offset=(size_t) ReadPropertyLong(endian,p);
1450 if ((offset < length) && (level < (MaxDirectoryStack-2)))
1455 tag_offset1=(tag_value == TAG_GPS_OFFSET) ? 0x10000UL : 0UL;
1456 directory_stack[level].directory=directory;
1458 directory_stack[level].entry=entry;
1459 directory_stack[level].offset=tag_offset;
1461 directory_stack[level].directory=exif+offset;
1462 directory_stack[level].offset=tag_offset1;
1463 directory_stack[level].entry=0;
1465 if ((directory+2+(12*number_entries)) > (exif+length))
1467 offset=(size_t) ReadPropertyLong(endian,directory+2+(12*
1469 if ((offset != 0) && (offset < length) &&
1470 (level < (MaxDirectoryStack-2)))
1472 directory_stack[level].directory=exif+offset;
1473 directory_stack[level].entry=0;
1474 directory_stack[level].offset=tag_offset1;
1481 } while (level > 0);
1485 static MagickBooleanType GetXMPProperty(const Image *image,
1486 const char *property)
1510 profile=GetImageProfile(image,"xmp");
1511 if (profile == (StringInfo *) NULL)
1512 return(MagickFalse);
1513 if ((property == (const char *) NULL) || (*property == '\0'))
1514 return(MagickFalse);
1515 xmp_profile=StringInfoToString(profile);
1516 if (xmp_profile == (char *) NULL)
1517 return(MagickFalse);
1518 for (p=xmp_profile; *p != '\0'; p++)
1519 if ((*p == '<') && (*(p+1) == 'x'))
1521 exception=AcquireExceptionInfo();
1522 xmp=NewXMLTree((char *) p,exception);
1523 xmp_profile=DestroyString(xmp_profile);
1524 exception=DestroyExceptionInfo(exception);
1525 if (xmp == (XMLTreeInfo *) NULL)
1526 return(MagickFalse);
1528 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1529 if (rdf != (XMLTreeInfo *) NULL)
1531 if (image->properties == (void *) NULL)
1532 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1533 RelinquishMagickMemory,RelinquishMagickMemory);
1534 description=GetXMLTreeChild(rdf,"rdf:Description");
1535 while (description != (XMLTreeInfo *) NULL)
1537 node=GetXMLTreeChild(description,(const char *) NULL);
1538 while (node != (XMLTreeInfo *) NULL)
1540 child=GetXMLTreeChild(node,(const char *) NULL);
1541 if (child == (XMLTreeInfo *) NULL)
1542 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1543 ConstantString(GetXMLTreeTag(node)),
1544 ConstantString(GetXMLTreeContent(node)));
1545 while (child != (XMLTreeInfo *) NULL)
1547 if (LocaleCompare(GetXMLTreeTag(child),"rdf:Seq") != 0)
1548 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1549 ConstantString(GetXMLTreeTag(child)),
1550 ConstantString(GetXMLTreeContent(child)));
1551 child=GetXMLTreeSibling(child);
1553 node=GetXMLTreeSibling(node);
1555 description=GetNextXMLTreeTag(description);
1558 xmp=DestroyXMLTree(xmp);
1562 static char *TracePSClippath(const unsigned char *blob,size_t length,
1563 const unsigned long magick_unused(columns),
1564 const unsigned long magick_unused(rows))
1587 path=AcquireString((char *) NULL);
1588 if (path == (char *) NULL)
1589 return((char *) NULL);
1590 message=AcquireString((char *) NULL);
1591 (void) FormatMagickString(message,MaxTextExtent,"/ClipImage\n");
1592 (void) ConcatenateString(&path,message);
1593 (void) FormatMagickString(message,MaxTextExtent,"{\n");
1594 (void) ConcatenateString(&path,message);
1595 (void) FormatMagickString(message,MaxTextExtent," /c {curveto} bind def\n");
1596 (void) ConcatenateString(&path,message);
1597 (void) FormatMagickString(message,MaxTextExtent," /l {lineto} bind def\n");
1598 (void) ConcatenateString(&path,message);
1599 (void) FormatMagickString(message,MaxTextExtent," /m {moveto} bind def\n");
1600 (void) ConcatenateString(&path,message);
1601 (void) FormatMagickString(message,MaxTextExtent,
1602 " /v {currentpoint 6 2 roll curveto} bind def\n");
1603 (void) ConcatenateString(&path,message);
1604 (void) FormatMagickString(message,MaxTextExtent,
1605 " /y {2 copy curveto} bind def\n");
1606 (void) ConcatenateString(&path,message);
1607 (void) FormatMagickString(message,MaxTextExtent,
1608 " /z {closepath} bind def\n");
1609 (void) ConcatenateString(&path,message);
1610 (void) FormatMagickString(message,MaxTextExtent," newpath\n");
1611 (void) ConcatenateString(&path,message);
1613 The clipping path format is defined in "Adobe Photoshop File
1614 Formats Specification" version 6.0 downloadable from adobe.com.
1616 (void) ResetMagickMemory(point,0,sizeof(point));
1617 (void) ResetMagickMemory(first,0,sizeof(first));
1618 (void) ResetMagickMemory(last,0,sizeof(last));
1620 in_subpath=MagickFalse;
1623 selector=(long) ReadPropertyMSBShort(&blob,&length);
1629 if (knot_count != 0)
1636 Expected subpath length record.
1638 knot_count=(long) ReadPropertyMSBShort(&blob,&length);
1648 if (knot_count == 0)
1651 Unexpected subpath knot
1660 for (i=0; i < 3; i++)
1666 yy=ReadPropertyMSBLong(&blob,&length);
1667 xx=ReadPropertyMSBLong(&blob,&length);
1669 if (xx > 2147483647)
1672 if (yy > 2147483647)
1674 point[i].x=(double) x/4096/4096;
1675 point[i].y=1.0-(double) y/4096/4096;
1677 if (in_subpath == MagickFalse)
1679 (void) FormatMagickString(message,MaxTextExtent," %g %g m\n",
1680 point[1].x,point[1].y);
1681 for (i=0; i < 3; i++)
1690 Handle special cases when Bezier curves are used to describe
1691 corners and straight lines.
1693 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1694 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1695 (void) FormatMagickString(message,MaxTextExtent," %g %g l\n",
1696 point[1].x,point[1].y);
1698 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1699 (void) FormatMagickString(message,MaxTextExtent,
1700 " %g %g %g %g v\n",point[0].x,point[0].y,point[1].x,
1703 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1704 (void) FormatMagickString(message,MaxTextExtent,
1705 " %g %g %g %g y\n",last[2].x,last[2].y,point[1].x,
1708 (void) FormatMagickString(message,MaxTextExtent,
1709 " %g %g %g %g %g %g c\n",last[2].x,last[2].y,point[0].x,
1710 point[0].y,point[1].x,point[1].y);
1711 for (i=0; i < 3; i++)
1714 (void) ConcatenateString(&path,message);
1715 in_subpath=MagickTrue;
1718 Close the subpath if there are no more knots.
1720 if (knot_count == 0)
1723 Same special handling as above except we compare to the
1724 first point in the path and close the path.
1726 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1727 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1728 (void) FormatMagickString(message,MaxTextExtent," %g %g l z\n",
1729 first[1].x,first[1].y);
1731 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1732 (void) FormatMagickString(message,MaxTextExtent,
1733 " %g %g %g %g v z\n",first[0].x,first[0].y,first[1].x,
1736 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1737 (void) FormatMagickString(message,MaxTextExtent,
1738 " %g %g %g %g y z\n",last[2].x,last[2].y,first[1].x,
1741 (void) FormatMagickString(message,MaxTextExtent,
1742 " %g %g %g %g %g %g c z\n",last[2].x,last[2].y,first[0].x,
1743 first[0].y,first[1].x,first[1].y);
1744 (void) ConcatenateString(&path,message);
1745 in_subpath=MagickFalse;
1761 Returns an empty PS path if the path has no knots.
1763 (void) FormatMagickString(message,MaxTextExtent," eoclip\n");
1764 (void) ConcatenateString(&path,message);
1765 (void) FormatMagickString(message,MaxTextExtent,"} bind def");
1766 (void) ConcatenateString(&path,message);
1767 message=DestroyString(message);
1771 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1772 const unsigned long columns,const unsigned long rows)
1795 path=AcquireString((char *) NULL);
1796 if (path == (char *) NULL)
1797 return((char *) NULL);
1798 message=AcquireString((char *) NULL);
1799 (void) FormatMagickString(message,MaxTextExtent,
1800 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
1801 (void) ConcatenateString(&path,message);
1802 (void) FormatMagickString(message,MaxTextExtent,
1803 "<svg width=\"%lu\" height=\"%lu\">\n",columns,rows);
1804 (void) ConcatenateString(&path,message);
1805 (void) FormatMagickString(message,MaxTextExtent,"<g>\n");
1806 (void) ConcatenateString(&path,message);
1807 (void) FormatMagickString(message,MaxTextExtent,
1808 "<path style=\"fill:#00000000;stroke:#00000000;");
1809 (void) ConcatenateString(&path,message);
1810 (void) FormatMagickString(message,MaxTextExtent,
1811 "stroke-width:0;stroke-antialiasing:false\" d=\"\n");
1812 (void) ConcatenateString(&path,message);
1813 (void) ResetMagickMemory(point,0,sizeof(point));
1814 (void) ResetMagickMemory(first,0,sizeof(first));
1815 (void) ResetMagickMemory(last,0,sizeof(last));
1817 in_subpath=MagickFalse;
1820 selector=(long) ReadPropertyMSBShort(&blob,&length);
1826 if (knot_count != 0)
1833 Expected subpath length record.
1835 knot_count=(long) ReadPropertyMSBShort(&blob,&length);
1845 if (knot_count == 0)
1848 Unexpected subpath knot.
1857 for (i=0; i < 3; i++)
1863 yy=ReadPropertyMSBLong(&blob,&length);
1864 xx=ReadPropertyMSBLong(&blob,&length);
1866 if (xx > 2147483647)
1869 if (yy > 2147483647)
1871 point[i].x=(double) x*columns/4096/4096;
1872 point[i].y=(double) y*rows/4096/4096;
1874 if (in_subpath == MagickFalse)
1876 (void) FormatMagickString(message,MaxTextExtent,"M %g,%g\n",
1877 point[1].x,point[1].y);
1878 for (i=0; i < 3; i++)
1886 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1887 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1888 (void) FormatMagickString(message,MaxTextExtent,"L %g,%g\n",
1889 point[1].x,point[1].y);
1891 (void) FormatMagickString(message,MaxTextExtent,
1892 "C %g,%g %g,%g %g,%g\n",last[2].x,last[2].y,
1893 point[0].x,point[0].y,point[1].x,point[1].y);
1894 for (i=0; i < 3; i++)
1897 (void) ConcatenateString(&path,message);
1898 in_subpath=MagickTrue;
1901 Close the subpath if there are no more knots.
1903 if (knot_count == 0)
1905 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1906 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1907 (void) FormatMagickString(message,MaxTextExtent,"L %g,%g Z\n",
1908 first[1].x,first[1].y);
1911 (void) FormatMagickString(message,MaxTextExtent,
1912 "C %g,%g %g,%g %g,%g Z\n",last[2].x,last[2].y,
1913 first[0].x,first[0].y,first[1].x,first[1].y);
1914 (void) ConcatenateString(&path,message);
1916 in_subpath=MagickFalse;
1932 Return an empty SVG image if the path does not have knots.
1934 (void) FormatMagickString(message,MaxTextExtent,"\"/>\n");
1935 (void) ConcatenateString(&path,message);
1936 (void) FormatMagickString(message,MaxTextExtent,"</g>\n");
1937 (void) ConcatenateString(&path,message);
1938 (void) FormatMagickString(message,MaxTextExtent,"</svg>\n");
1939 (void) ConcatenateString(&path,message);
1940 message=DestroyString(message);
1944 MagickExport const char *GetImageProperty(const Image *image,
1945 const char *property)
1962 assert(image != (Image *) NULL);
1963 assert(image->signature == MagickSignature);
1964 if (image->debug != MagickFalse)
1965 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1966 p=(const char *) NULL;
1967 if (property == (const char *) NULL)
1969 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
1970 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
1974 if ((image->properties != (void *) NULL) &&
1975 (LocaleNCompare("fx:",property,3) != 0))
1977 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1978 image->properties,property);
1979 if (p != (const char *) NULL)
1982 if (strchr(property,':') == (char *) NULL)
1984 exception=(&((Image *) image)->exception);
1989 if (LocaleNCompare("8bim:",property,5) == 0)
1991 if (Get8BIMProperty(image,property) != MagickFalse)
1993 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1994 image->properties,property);
2003 if (LocaleNCompare("exif:",property,5) == 0)
2005 if (GetEXIFProperty(image,property) != MagickFalse)
2007 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2008 image->properties,property);
2017 if (LocaleNCompare("fx:",property,3) == 0)
2019 fx_info=AcquireFxInfo(image,property+3);
2020 status=FxEvaluateExpression(fx_info,&alpha,exception);
2021 fx_info=DestroyFxInfo(fx_info);
2022 if (status != MagickFalse)
2025 value[MaxTextExtent];
2027 (void) FormatMagickString(value,MaxTextExtent,"%g",(double)
2029 (void) SetImageProperty((Image *) image,property,value);
2031 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2032 image->properties,property);
2040 if (LocaleNCompare("iptc:",property,5) == 0)
2042 if (GetIPTCProperty(image,property) != MagickFalse)
2044 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2045 image->properties,property);
2054 if (LocaleNCompare("pixel:",property,6) == 0)
2059 GetMagickPixelPacket(image,&pixel);
2060 fx_info=AcquireFxInfo(image,property+6);
2061 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2063 pixel.red=(MagickRealType) QuantumRange*alpha;
2064 status|=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2066 pixel.green=(MagickRealType) QuantumRange*alpha;
2067 status|=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2069 pixel.blue=(MagickRealType) QuantumRange*alpha;
2070 status|=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2072 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2073 if (image->colorspace == CMYKColorspace)
2075 status|=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2077 pixel.index=(MagickRealType) QuantumRange*alpha;
2079 fx_info=DestroyFxInfo(fx_info);
2080 if (status != MagickFalse)
2083 name[MaxTextExtent];
2085 (void) QueryMagickColorname(image,&pixel,SVGCompliance,name,
2087 (void) SetImageProperty((Image *) image,property,name);
2088 return(GetImageProperty(image,property));
2096 if (LocaleNCompare("xmp:",property,4) == 0)
2098 if (GetXMPProperty(image,property) != MagickFalse)
2100 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2101 image->properties,property);
2112 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2116 + G e t M a g i c k P r o p e r t y %
2120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2122 % GetMagickProperty() gets a value associated with an image property.
2124 % The format of the GetMagickProperty method is:
2126 % const char *GetMagickProperty(const ImageInfo *image_info,
2127 % Image *image,const char *key)
2129 % A description of each parameter follows:
2131 % o image_info: the image info.
2133 % o image: the image.
2138 MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
2139 Image *image,const char *property)
2142 value[MaxTextExtent],
2143 filename[MaxTextExtent];
2146 switch (*(property))
2150 if (LocaleNCompare("base",property,4) == 0)
2152 GetPathComponent(image->magick_filename,BasePath,filename);
2153 (void) CopyMagickString(value,filename,MaxTextExtent);
2160 if (LocaleNCompare("channels",property,8) == 0)
2165 (void) FormatMagickString(value,MaxTextExtent,"%s",
2166 MagickOptionToMnemonic(MagickColorspaceOptions,(long)
2167 image->colorspace));
2169 if (image->matte != MagickFalse)
2170 (void) ConcatenateMagickString(value,"a",MaxTextExtent);
2173 if (LocaleNCompare("colorspace",property,10) == 0)
2179 Image storage class and colorspace.
2181 colorspace=image->colorspace;
2182 if (IsGrayImage(image,&image->exception) != MagickFalse)
2183 colorspace=GRAYColorspace;
2184 (void) FormatMagickString(value,MaxTextExtent,"%s",
2185 MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace));
2192 if (LocaleNCompare("depth",property,5) == 0)
2194 (void) FormatMagickString(value,MaxTextExtent,"%lu",image->depth);
2197 if (LocaleNCompare("directory",property,9) == 0)
2199 GetPathComponent(image->magick_filename,HeadPath,filename);
2200 (void) CopyMagickString(value,filename,MaxTextExtent);
2207 if (LocaleNCompare("extension",property,9) == 0)
2209 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2210 (void) CopyMagickString(value,filename,MaxTextExtent);
2217 if (LocaleNCompare("group",property,5) == 0)
2219 (void) FormatMagickString(value,MaxTextExtent,"0x%lx",
2227 if (LocaleNCompare("height",property,6) == 0)
2229 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2230 image->magick_rows != 0 ? image->magick_rows : 256UL);
2237 if (LocaleNCompare("input",property,5) == 0)
2239 (void) CopyMagickString(value,image->filename,MaxTextExtent);
2246 if (LocaleNCompare("kurtosis",property,8) == 0)
2252 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2253 &skewness,&image->exception);
2254 (void) FormatMagickString(value,MaxTextExtent,"%g",kurtosis);
2261 if (LocaleNCompare("magick",property,6) == 0)
2263 (void) CopyMagickString(value,image->magick,MaxTextExtent);
2266 if (LocaleNCompare("max",property,3) == 0)
2272 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2273 &maximum,&image->exception);
2274 (void) FormatMagickString(value,MaxTextExtent,"%g",maximum);
2277 if (LocaleNCompare("mean",property,4) == 0)
2283 (void) GetImageChannelMean(image,image_info->channel,&mean,
2284 &standard_deviation,&image->exception);
2285 (void) FormatMagickString(value,MaxTextExtent,"%g",mean);
2288 if (LocaleNCompare("min",property,3) == 0)
2294 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2295 &maximum,&image->exception);
2296 (void) FormatMagickString(value,MaxTextExtent,"%g",minimum);
2303 if (LocaleNCompare("name",property,4) == 0)
2305 (void) CopyMagickString(value,filename,MaxTextExtent);
2312 if (LocaleNCompare("output",property,6) == 0)
2314 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
2321 if (LocaleNCompare("page",property,4) == 0)
2323 register const Image
2330 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2331 p=GetPreviousImageInList(p);
2332 (void) FormatMagickString(value,MaxTextExtent,"%lu",page);
2339 if (LocaleNCompare("size",property,4) == 0)
2342 format[MaxTextExtent];
2344 (void) FormatMagickSize(GetBlobSize(image),format);
2345 (void) FormatMagickString(value,MaxTextExtent,"%s",format);
2348 if (LocaleNCompare("scenes",property,6) == 0)
2350 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2351 (unsigned long) GetImageListLength(image));
2354 if (LocaleNCompare("scene",property,5) == 0)
2356 (void) FormatMagickString(value,MaxTextExtent,"%lu",image->scene);
2357 if (image_info->number_scenes != 0)
2358 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2362 if (LocaleNCompare("skewness",property,8) == 0)
2368 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2369 &skewness,&image->exception);
2370 (void) FormatMagickString(value,MaxTextExtent,"%g",skewness);
2373 if ((LocaleNCompare("standard-deviation",property,18) == 0) ||
2374 (LocaleNCompare("standard_deviation",property,18) == 0))
2380 (void) GetImageChannelMean(image,image_info->channel,&mean,
2381 &standard_deviation,&image->exception);
2382 (void) FormatMagickString(value,MaxTextExtent,"%g",
2383 standard_deviation);
2390 if (LocaleNCompare("unique",property,6) == 0)
2392 (void) CopyMagickString(filename,image_info->unique,MaxTextExtent);
2393 (void) CopyMagickString(value,filename,MaxTextExtent);
2400 if (LocaleNCompare("width",property,5) == 0)
2402 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2403 image->magick_columns != 0 ? image->magick_columns : 256UL);
2410 if (LocaleNCompare("xresolution",property,11) == 0)
2412 (void) FormatMagickString(value,MaxTextExtent,"%g",
2413 image->x_resolution);
2420 if (LocaleNCompare("yresolution",property,11) == 0)
2422 (void) FormatMagickString(value,MaxTextExtent,"%g",
2423 image->y_resolution);
2430 if (LocaleNCompare("zero",property,4) == 0)
2432 (void) CopyMagickString(filename,image_info->zero,MaxTextExtent);
2433 (void) CopyMagickString(value,filename,MaxTextExtent);
2441 if (image->properties == (void *) NULL)
2442 image->properties=NewSplayTree(CompareSplayTreeString,
2443 RelinquishMagickMemory,RelinquishMagickMemory);
2444 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
2445 ConstantString(property),ConstantString(value));
2447 return(GetImageProperty(image,property));
2451 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2455 % G e t N e x t I m a g e P r o p e r t y %
2459 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2461 % GetNextImageProperty() gets the next image property value.
2463 % The format of the GetNextImageProperty method is:
2465 % char *GetNextImageProperty(const Image *image)
2467 % A description of each parameter follows:
2469 % o image: the image.
2472 MagickExport char *GetNextImageProperty(const Image *image)
2474 assert(image != (Image *) NULL);
2475 assert(image->signature == MagickSignature);
2476 if (image->debug != MagickFalse)
2477 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2479 if (image->properties == (void *) NULL)
2480 return((char *) NULL);
2481 return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
2485 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2489 % I n t e r p r e t I m a g e P r o p e r t i e s %
2493 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2495 % InterpretImageProperties() replaces any embedded formatting characters with
2496 % the appropriate image property and returns the interpretted text.
2498 % The format of the InterpretImageProperties method is:
2500 % char *InterpretImageProperties(const ImageInfo *image_info,Image *image,
2501 % const char *embed_text)
2503 % A description of each parameter follows:
2505 % o image_info: the image info.
2507 % o image: the image.
2509 % o embed_text: the address of a character string containing the embedded
2510 % formatting characters.
2513 MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
2514 Image *image,const char *embed_text)
2517 filename[MaxTextExtent],
2540 assert(image != (Image *) NULL);
2541 assert(image->signature == MagickSignature);
2542 if (image->debug != MagickFalse)
2543 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2544 if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))
2545 return((char *) NULL);
2546 text=(char *) embed_text;
2547 if ((*text == '@') && ((*(text+1) == '-') ||
2548 (IsPathAccessible(text+1) != MagickFalse)))
2549 return(FileToString(embed_text+1,~0,&image->exception));
2551 Translate any embedded format characters.
2553 text_info=CloneImageInfo(image_info);
2554 interpret_text=AcquireString(text);
2555 extent=MaxTextExtent;
2557 for (q=interpret_text; *p != '\0'; p++)
2560 if ((size_t) (q-interpret_text+MaxTextExtent) >= extent)
2562 extent+=MaxTextExtent;
2563 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2564 MaxTextExtent+1,sizeof(*interpret_text));
2565 if (interpret_text == (char *) NULL)
2567 q=interpret_text+strlen(interpret_text);
2570 Process formatting characters in text.
2572 if ((*p == '\\') && (*(p+1) == 'r'))
2578 if ((*p == '\\') && (*(p+1) == 'n'))
2601 format[MaxTextExtent];
2609 length=GetBlobSize(image);
2610 (void) FormatMagickString(format,MaxTextExtent,"%lu",(unsigned long)
2612 if (length != (MagickSizeType) ((size_t) length))
2613 (void) FormatMagickSize(length,format);
2614 q+=ConcatenateMagickString(q,format,extent);
2622 value=GetImageProperty(image,"comment");
2623 if (value == (const char *) NULL)
2625 length=strlen(value);
2626 if ((size_t) (q-interpret_text+length+1) >= extent)
2629 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
2630 extent+MaxTextExtent,sizeof(*interpret_text));
2631 if (interpret_text == (char *) NULL)
2633 q=interpret_text+strlen(interpret_text);
2635 (void) CopyMagickString(q,value,extent);
2645 Label segment is the base of the filename.
2647 if (*image->magick_filename == '\0')
2656 GetPathComponent(image->magick_filename,HeadPath,filename);
2657 q+=CopyMagickString(q,filename,extent);
2665 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2666 q+=CopyMagickString(q,filename,extent);
2674 GetPathComponent(image->magick_filename,TailPath,filename);
2675 q+=CopyMagickString(q,filename,extent);
2683 GetPathComponent(image->magick_filename,BasePath,filename);
2684 q+=CopyMagickString(q,filename,extent);
2695 q+=FormatMagickString(q,extent,"%lux%lu%+ld%+ld",image->page.width,
2696 image->page.height,image->page.x,image->page.y);
2704 q+=FormatMagickString(q,extent,"%lu",image->rows != 0 ? image->rows :
2705 image->magick_rows);
2713 q+=CopyMagickString(q,image->filename,extent);
2719 Number of unique colors.
2721 q+=FormatMagickString(q,extent,"%lu",GetNumberColors(image,
2722 (FILE *) NULL,&image->exception));
2730 value=GetImageProperty(image,"label");
2731 if (value == (const char *) NULL)
2733 length=strlen(value);
2734 if ((size_t) (q-interpret_text+length+1) >= extent)
2737 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
2738 extent+MaxTextExtent,sizeof(*interpret_text));
2739 if (interpret_text == (char *) NULL)
2741 q=interpret_text+strlen(interpret_text);
2743 q+=CopyMagickString(q,value,extent);
2751 q+=CopyMagickString(q,image->magick,extent);
2757 Image magick filename.
2759 q+=CopyMagickString(q,image->magick_filename,extent);
2765 Number of images in the list.
2767 q+=FormatMagickString(q,extent,"%lu",(unsigned long)
2768 GetImageListLength(image));
2774 Image output filename.
2776 q+=CopyMagickString(q,text_info->filename,extent);
2781 register const Image
2791 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2792 p=GetPreviousImageInList(p);
2793 q+=FormatMagickString(q,extent,"%lu",page);
2801 q+=FormatMagickString(q,extent,"%lu",image->depth);
2810 Image storage class and colorspace.
2812 colorspace=image->colorspace;
2813 if (IsGrayImage(image,&image->exception) != MagickFalse)
2814 colorspace=GRAYColorspace;
2815 q+=FormatMagickString(q,extent,"%s%s%s",MagickOptionToMnemonic(
2816 MagickClassOptions,(long) image->storage_class),
2817 MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace),
2818 image->matte != MagickFalse ? "Matte" : "");
2826 if (text_info->number_scenes == 0)
2827 q+=FormatMagickString(q,extent,"%lu",image->scene);
2829 q+=FormatMagickString(q,extent,"%lu",text_info->scene);
2837 (void) CopyMagickString(filename,text_info->unique,extent);
2838 q+=CopyMagickString(q,filename,extent);
2846 q+=FormatMagickString(q,extent,"%lu",image->columns != 0 ?
2847 image->columns : image->magick_columns);
2853 Image horizontal resolution.
2855 q+=FormatMagickString(q,extent,"%g %s",image->x_resolution,
2856 MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
2862 Image vertical resolution.
2864 q+=FormatMagickString(q,extent,"%g %s",image->y_resolution,
2865 MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
2873 q+=FormatMagickString(q,extent,"%lu",image->depth);
2879 Image alpha channel.
2881 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2882 MagickBooleanOptions,(long) image->matte));
2888 Image compression method.
2890 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2891 MagickCompressOptions,(long) image->compression));
2897 Image dispose method.
2899 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2900 MagickDisposeOptions,(long) image->dispose));
2905 q+=FormatMagickString(q,extent,"%lux%lu",image->magick_columns,
2906 image->magick_rows);
2911 q+=FormatMagickString(q,extent,"%ld",image->page.height);
2916 q+=FormatMagickString(q,extent,"%+ld%+ld",image->page.x,image->page.y);
2921 q+=FormatMagickString(q,extent,"%lux%lu",image->page.width,
2922 image->page.height);
2927 q+=FormatMagickString(q,extent,"%lu",image->quality);
2935 if (text_info->number_scenes == 0)
2936 q+=CopyMagickString(q,"2147483647",extent);
2938 q+=FormatMagickString(q,extent,"%lu",text_info->scene+
2939 text_info->number_scenes);
2944 q+=FormatMagickString(q,extent,"%lu",image->delay);
2949 q+=FormatMagickString(q,extent,"%ld",image->page.width);
2954 q+=FormatMagickString(q,extent,"%+ld",image->page.x);
2959 q+=FormatMagickString(q,extent,"%+ld",image->page.y);
2967 (void) CopyMagickString(filename,text_info->zero,extent);
2968 q+=CopyMagickString(q,filename,extent);
2974 pattern[MaxTextExtent];
2986 if (strchr(p,']') == (char *) NULL)
2990 for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
3001 value=GetImageProperty(image,pattern);
3002 if (value != (const char *) NULL)
3004 length=strlen(value);
3005 if ((size_t) (q-interpret_text+length+1) >= extent)
3008 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3009 extent+MaxTextExtent,sizeof(*interpret_text));
3010 if (interpret_text == (char *) NULL)
3012 q=interpret_text+strlen(interpret_text);
3014 (void) CopyMagickString(q,value,extent);
3019 if (IsGlob(pattern) != MagickFalse)
3022 Iterate over image properties.
3024 ResetImagePropertyIterator(image);
3025 key=GetNextImageProperty(image);
3026 while (key != (const char *) NULL)
3028 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3030 value=GetImageProperty(image,key);
3031 if (value != (const char *) NULL)
3033 length=strlen(key)+strlen(value)+2;
3034 if ((size_t) (q-interpret_text+length+1) >= extent)
3037 interpret_text=(char *) ResizeQuantumMemory(
3038 interpret_text,extent+MaxTextExtent,
3039 sizeof(*interpret_text));
3040 if (interpret_text == (char *) NULL)
3042 q=interpret_text+strlen(interpret_text);
3044 q+=FormatMagickString(q,extent,"%s=%s\n",key,value);
3047 key=GetNextImageProperty(image);
3050 value=GetMagickProperty(text_info,image,pattern);
3051 if (value != (const char *) NULL)
3053 length=strlen(value);
3054 if ((size_t) (q-interpret_text+length+1) >= extent)
3057 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3058 extent+MaxTextExtent,sizeof(*interpret_text));
3059 if (interpret_text == (char *) NULL)
3061 q=interpret_text+strlen(interpret_text);
3063 (void) CopyMagickString(q,value,extent);
3066 if (image_info == (ImageInfo *) NULL)
3068 value=GetImageOption(image_info,pattern);
3069 if (value != (char *) NULL)
3071 length=strlen(value);
3072 if ((size_t) (q-interpret_text+length+1) >= extent)
3075 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3076 extent+MaxTextExtent,sizeof(*interpret_text));
3077 if (interpret_text == (char *) NULL)
3079 q=interpret_text+strlen(interpret_text);
3081 (void) CopyMagickString(q,value,extent);
3094 page=GetImageBoundingBox(image,&image->exception);
3095 q+=FormatMagickString(q,MaxTextExtent,"%lux%lu%+ld%+ld",page.width,
3096 page.height,page.x,page.y);
3104 (void) SignatureImage(image);
3105 value=GetImageProperty(image,"signature");
3106 if (value == (const char *) NULL)
3108 q+=CopyMagickString(q,value,extent);
3125 text_info=DestroyImageInfo(text_info);
3126 if (text != (const char *) embed_text)
3127 text=DestroyString(text);
3128 (void) SubstituteString(&interpret_text,"<","<");
3129 (void) SubstituteString(&interpret_text,">",">");
3130 return(interpret_text);
3134 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3138 % R e m o v e I m a g e P r o p e r t y %
3142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3144 % RemoveImageProperty() removes a property from the image and returns its
3147 % The format of the RemoveImageProperty method is:
3149 % char *RemoveImageProperty(Image *image,const char *property)
3151 % A description of each parameter follows:
3153 % o image: the image.
3155 % o property: the image property.
3158 MagickExport char *RemoveImageProperty(Image *image,
3159 const char *property)
3164 assert(image != (Image *) NULL);
3165 assert(image->signature == MagickSignature);
3166 if (image->debug != MagickFalse)
3167 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3169 if (image->properties == (void *) NULL)
3170 return((char *) NULL);
3171 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3177 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3181 % 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 %
3185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3187 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3188 % in conjunction with GetNextImageProperty() to iterate over all the values
3189 % associated with an image property.
3191 % The format of the ResetImagePropertyIterator method is:
3193 % ResetImagePropertyIterator(Image *image)
3195 % A description of each parameter follows:
3197 % o image: the image.
3200 MagickExport void ResetImagePropertyIterator(const Image *image)
3202 assert(image != (Image *) NULL);
3203 assert(image->signature == MagickSignature);
3204 if (image->debug != MagickFalse)
3205 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3207 if (image->properties == (void *) NULL)
3209 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3217 % S e t I m a g e P r o p e r t y %
3221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3223 % SetImageProperty() associates an value with an image property.
3225 % The format of the SetImageProperty method is:
3227 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3228 % const char *value)
3230 % A description of each parameter follows:
3232 % o image: the image.
3234 % o property: the image property.
3236 % o values: the image property values.
3239 MagickExport MagickBooleanType SetImageProperty(Image *image,
3240 const char *property,const char *value)
3248 assert(image != (Image *) NULL);
3249 assert(image->signature == MagickSignature);
3250 if (image->debug != MagickFalse)
3251 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3253 if (image->properties == (void *) NULL)
3254 image->properties=NewSplayTree(CompareSplayTreeString,
3255 RelinquishMagickMemory,RelinquishMagickMemory);
3256 if ((value == (const char *) NULL) || (*value == '\0'))
3257 return(DeleteImageProperty(image,property));
3264 if (LocaleCompare(property,"bias") == 0)
3266 image->bias=StringToDouble(value,QuantumRange);
3269 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3270 ConstantString(property),ConstantString(value));
3276 if (LocaleCompare(property,"colorspace") == 0)
3281 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
3285 (void) SetImageColorspace(image,(ColorspaceType) colorspace);
3288 if (LocaleCompare(property,"compose") == 0)
3293 compose=ParseMagickOption(MagickComposeOptions,MagickFalse,value);
3296 image->compose=(CompositeOperator) compose;
3299 if (LocaleCompare(property,"compress") == 0)
3304 compression=ParseMagickOption(MagickCompressOptions,MagickFalse,
3306 if (compression < 0)
3308 image->compression=(CompressionType) compression;
3311 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3312 ConstantString(property),ConstantString(value));
3318 if (LocaleCompare(property,"delay") == 0)
3323 flags=ParseGeometry(value,&geometry_info);
3324 if ((flags & GreaterValue) != 0)
3326 if (image->delay > (unsigned long) (geometry_info.rho+0.5))
3327 image->delay=(unsigned long) (geometry_info.rho+0.5);
3330 if ((flags & LessValue) != 0)
3332 if (image->delay < (unsigned long) (geometry_info.rho+0.5))
3333 image->ticks_per_second=(long) (geometry_info.sigma+0.5);
3336 image->delay=(unsigned long) (geometry_info.rho+0.5);
3337 if ((flags & SigmaValue) != 0)
3338 image->ticks_per_second=(long) (geometry_info.sigma+0.5);
3341 if (LocaleCompare(property,"depth") == 0)
3343 image->depth=(unsigned long) atol(value);
3346 if (LocaleCompare(property,"dispose") == 0)
3351 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,value);
3354 image->dispose=(DisposeType) dispose;
3357 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3358 ConstantString(property),ConstantString(value));
3364 if (LocaleCompare(property,"gravity") == 0)
3369 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
3372 image->gravity=(GravityType) gravity;
3375 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3376 ConstantString(property),ConstantString(value));
3382 if (LocaleCompare(property,"intent") == 0)
3387 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3389 if (rendering_intent < 0)
3391 image->rendering_intent=(RenderingIntent) rendering_intent;
3394 if (LocaleCompare(property,"interpolate") == 0)
3399 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
3401 if (interpolate < 0)
3403 image->interpolate=(InterpolatePixelMethod) interpolate;
3406 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3407 ConstantString(property),ConstantString(value));
3413 if (LocaleCompare(property,"loop") == 0)
3415 image->iterations=(unsigned long) atol(value);
3418 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3419 ConstantString(property),ConstantString(value));
3425 if (LocaleCompare(property,"page") == 0)
3430 geometry=GetPageGeometry(value);
3431 flags=ParseAbsoluteGeometry(geometry,&image->page);
3432 geometry=DestroyString(geometry);
3435 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3436 ConstantString(property),ConstantString(value));
3442 if (LocaleCompare(property,"rendering-intent") == 0)
3447 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3449 if (rendering_intent < 0)
3451 image->rendering_intent=(RenderingIntent) rendering_intent;
3454 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3455 ConstantString(property),ConstantString(value));
3461 if (LocaleCompare(property,"tile-offset") == 0)
3466 geometry=GetPageGeometry(value);
3467 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3468 geometry=DestroyString(geometry);
3471 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3472 ConstantString(property),ConstantString(value));
3477 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3478 ConstantString(property),ConstantString(value));