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-2011 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/attribute.h"
45 #include "MagickCore/cache.h"
46 #include "MagickCore/color.h"
47 #include "MagickCore/compare.h"
48 #include "MagickCore/constitute.h"
49 #include "MagickCore/draw.h"
50 #include "MagickCore/effect.h"
51 #include "MagickCore/exception.h"
52 #include "MagickCore/exception-private.h"
53 #include "MagickCore/fx.h"
54 #include "MagickCore/fx-private.h"
55 #include "MagickCore/gem.h"
56 #include "MagickCore/geometry.h"
57 #include "MagickCore/histogram.h"
58 #include "MagickCore/image.h"
59 #include "MagickCore/image.h"
60 #include "MagickCore/layer.h"
61 #include "MagickCore/list.h"
62 #include "MagickCore/magick.h"
63 #include "MagickCore/memory_.h"
64 #include "MagickCore/monitor.h"
65 #include "MagickCore/montage.h"
66 #include "MagickCore/option.h"
67 #include "MagickCore/profile.h"
68 #include "MagickCore/property.h"
69 #include "MagickCore/quantum.h"
70 #include "MagickCore/resource_.h"
71 #include "MagickCore/splay-tree.h"
72 #include "MagickCore/signature-private.h"
73 #include "MagickCore/statistic.h"
74 #include "MagickCore/string_.h"
75 #include "MagickCore/string-private.h"
76 #include "MagickCore/token.h"
77 #include "MagickCore/utility.h"
78 #include "MagickCore/utility-private.h"
79 #include "MagickCore/version.h"
80 #include "MagickCore/xml-tree.h"
81 #include "MagickCore/xml-tree-private.h"
84 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
88 % C l o n e I m a g e P r o p e r t i e s %
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
94 % CloneImageProperties() clones one or more image properties.
96 % The format of the CloneImageProperties method is:
98 % MagickBooleanType CloneImageProperties(Image *image,
99 % const Image *clone_image)
101 % A description of each parameter follows:
103 % o image: the image.
105 % o clone_image: the clone image.
108 MagickExport MagickBooleanType CloneImageProperties(Image *image,
109 const Image *clone_image)
111 assert(image != (Image *) NULL);
112 assert(image->signature == MagickSignature);
113 if (image->debug != MagickFalse)
114 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
115 assert(clone_image != (const Image *) NULL);
116 assert(clone_image->signature == MagickSignature);
117 if (clone_image->debug != MagickFalse)
118 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
119 clone_image->filename);
120 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
121 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
123 image->compression=clone_image->compression;
124 image->quality=clone_image->quality;
125 image->depth=clone_image->depth;
126 image->background_color=clone_image->background_color;
127 image->border_color=clone_image->border_color;
128 image->matte_color=clone_image->matte_color;
129 image->transparent_color=clone_image->transparent_color;
130 image->gamma=clone_image->gamma;
131 image->chromaticity=clone_image->chromaticity;
132 image->rendering_intent=clone_image->rendering_intent;
133 image->black_point_compensation=clone_image->black_point_compensation;
134 image->units=clone_image->units;
135 image->montage=(char *) NULL;
136 image->directory=(char *) NULL;
137 (void) CloneString(&image->geometry,clone_image->geometry);
138 image->offset=clone_image->offset;
139 image->x_resolution=clone_image->x_resolution;
140 image->y_resolution=clone_image->y_resolution;
141 image->page=clone_image->page;
142 image->tile_offset=clone_image->tile_offset;
143 image->extract_info=clone_image->extract_info;
144 image->bias=clone_image->bias;
145 image->filter=clone_image->filter;
146 image->blur=clone_image->blur;
147 image->fuzz=clone_image->fuzz;
148 image->interlace=clone_image->interlace;
149 image->interpolate=clone_image->interpolate;
150 image->endian=clone_image->endian;
151 image->gravity=clone_image->gravity;
152 image->compose=clone_image->compose;
153 image->scene=clone_image->scene;
154 image->orientation=clone_image->orientation;
155 image->dispose=clone_image->dispose;
156 image->delay=clone_image->delay;
157 image->ticks_per_second=clone_image->ticks_per_second;
158 image->iterations=clone_image->iterations;
159 image->total_colors=clone_image->total_colors;
160 image->taint=clone_image->taint;
161 image->progress_monitor=clone_image->progress_monitor;
162 image->client_data=clone_image->client_data;
163 image->start_loop=clone_image->start_loop;
164 image->error=clone_image->error;
165 image->signature=clone_image->signature;
166 if (clone_image->properties != (void *) NULL)
168 if (image->properties != (void *) NULL)
169 DestroyImageProperties(image);
170 image->properties=CloneSplayTree((SplayTreeInfo *)
171 clone_image->properties,(void *(*)(void *)) ConstantString,
172 (void *(*)(void *)) ConstantString);
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
182 % D e f i n e I m a g e P r o p e r t y %
186 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
188 % DefineImageProperty() associates a key/value pair with an image property.
190 % The format of the DefineImageProperty method is:
192 % MagickBooleanType DefineImageProperty(Image *image,
193 % const char *property)
195 % A description of each parameter follows:
197 % o image: the image.
199 % o property: the image property.
202 MagickExport MagickBooleanType DefineImageProperty(Image *image,
203 const char *property)
207 value[MaxTextExtent];
212 assert(image != (Image *) NULL);
213 assert(property != (const char *) NULL);
214 (void) CopyMagickString(key,property,MaxTextExtent-1);
215 for (p=key; *p != '\0'; p++)
220 (void) CopyMagickString(value,p+1,MaxTextExtent);
222 return(SetImageProperty(image,key,value));
226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
230 % D e l e t e I m a g e P r o p e r t y %
234 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
236 % DeleteImageProperty() deletes an image property.
238 % The format of the DeleteImageProperty method is:
240 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
242 % A description of each parameter follows:
244 % o image: the image.
246 % o property: the image property.
249 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
250 const char *property)
252 assert(image != (Image *) NULL);
253 assert(image->signature == MagickSignature);
254 if (image->debug != MagickFalse)
255 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
257 if (image->properties == (void *) NULL)
259 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
267 % D e s t r o y I m a g e P r o p e r t i e s %
271 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273 % DestroyImageProperties() releases memory associated with image property
276 % The format of the DestroyDefines method is:
278 % void DestroyImageProperties(Image *image)
280 % A description of each parameter follows:
282 % o image: the image.
285 MagickExport void DestroyImageProperties(Image *image)
287 assert(image != (Image *) NULL);
288 assert(image->signature == MagickSignature);
289 if (image->debug != MagickFalse)
290 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
292 if (image->properties != (void *) NULL)
293 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
302 % F o r m a t I m a g e P r o p e r t y %
306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308 % FormatImageProperty() permits formatted property/value pairs to be saved as
311 % The format of the FormatImageProperty method is:
313 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
314 % const char *format,...)
316 % A description of each parameter follows.
318 % o image: The image.
320 % o property: The attribute property.
322 % o format: A string describing the format to use to write the remaining
326 MagickExport MagickBooleanType FormatImageProperty(Image *image,
327 const char *property,const char *format,...)
330 value[MaxTextExtent];
338 va_start(operands,format);
339 n=FormatLocaleStringList(value,MaxTextExtent,format,operands);
342 return(SetImageProperty(image,property,value));
346 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
350 % G e t I m a g e P r o p e r t y %
354 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
356 % GetImageProperty() gets a value associated with an image property.
358 % The format of the GetImageProperty method is:
360 % const char *GetImageProperty(const Image *image,const char *key)
362 % A description of each parameter follows:
364 % o image: the image.
371 *TracePSClippath(const unsigned char *,size_t,const size_t,
373 *TraceSVGClippath(const unsigned char *,size_t,const size_t,
376 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
396 profile=GetImageProfile(image,"iptc");
397 if (profile == (StringInfo *) NULL)
398 profile=GetImageProfile(image,"8bim");
399 if (profile == (StringInfo *) NULL)
401 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
404 attribute=(char *) NULL;
405 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
408 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
410 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
411 length|=GetStringInfoDatum(profile)[i+4];
412 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
413 ((long) GetStringInfoDatum(profile)[i+2] == record))
415 message=(char *) NULL;
417 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
418 if (message != (char *) NULL)
420 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
421 profile)+i+5,length+1);
422 (void) ConcatenateString(&attribute,message);
423 (void) ConcatenateString(&attribute,";");
424 message=DestroyString(message);
429 if ((attribute == (char *) NULL) || (*attribute == ';'))
431 if (attribute != (char *) NULL)
432 attribute=DestroyString(attribute);
435 attribute[strlen(attribute)-1]='\0';
436 (void) SetImageProperty((Image *) image,key,(const char *) attribute);
437 attribute=DestroyString(attribute);
441 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
448 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
460 static inline size_t ReadPropertyMSBLong(const unsigned char **p,
477 for (i=0; i < 4; i++)
481 buffer[i]=(unsigned char) c;
483 value=(size_t) (buffer[0] << 24);
484 value|=buffer[1] << 16;
485 value|=buffer[2] << 8;
487 return(value & 0xffffffff);
490 static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
506 return((unsigned short) ~0U);
507 for (i=0; i < 2; i++)
511 buffer[i]=(unsigned char) c;
513 value=(unsigned short) (buffer[0] << 8);
515 return((unsigned short) (value & 0xffff));
518 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
522 format[MaxTextExtent],
551 There are no newlines in path names, so it's safe as terminator.
553 profile=GetImageProfile(image,"8bim");
554 if (profile == (StringInfo *) NULL)
556 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name,
558 if ((count != 2) && (count != 3) && (count != 4))
561 (void) CopyMagickString(format,"SVG",MaxTextExtent);
566 sub_number=(ssize_t) StringToLong(&name[1]);
567 sub_number=MagickMax(sub_number,1L);
568 resource=(char *) NULL;
570 length=GetStringInfoLength(profile);
571 info=GetStringInfoDatum(profile);
572 while ((length > 0) && (status == MagickFalse))
574 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
576 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
578 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
580 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
582 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
583 if (id < (ssize_t) start)
585 if (id > (ssize_t) stop)
587 if (resource != (char *) NULL)
588 resource=DestroyString(resource);
589 count=(ssize_t) ReadPropertyByte(&info,&length);
590 if ((count != 0) && ((size_t) count <= length))
592 resource=(char *) NULL;
593 if (~(1UL*count) >= (MaxTextExtent-1))
594 resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
596 if (resource != (char *) NULL)
598 for (i=0; i < (ssize_t) count; i++)
599 resource[i]=(char) ReadPropertyByte(&info,&length);
600 resource[count]='\0';
603 if ((count & 0x01) == 0)
604 (void) ReadPropertyByte(&info,&length);
605 count=(ssize_t) ((int) ReadPropertyMSBLong(&info,&length));
606 if ((*name != '\0') && (*name != '#'))
607 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
610 No name match, scroll forward and try next.
616 if ((*name == '#') && (sub_number != 1))
619 No numbered match, scroll forward and try next.
627 We have the resource of interest.
629 attribute=(char *) NULL;
630 if (~(1UL*count) >= (MaxTextExtent-1))
631 attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
633 if (attribute != (char *) NULL)
635 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
636 attribute[count]='\0';
639 if ((id <= 1999) || (id >= 2999))
640 (void) SetImageProperty((Image *) image,key,(const char *)
647 if (LocaleCompare(format,"svg") == 0)
648 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
649 image->columns,image->rows);
651 path=TracePSClippath((unsigned char *) attribute,(size_t) count,
652 image->columns,image->rows);
653 (void) SetImageProperty((Image *) image,key,(const char *) path);
654 path=DestroyString(path);
656 attribute=DestroyString(attribute);
660 if (resource != (char *) NULL)
661 resource=DestroyString(resource);
665 static inline unsigned short ReadPropertyShort(const EndianType endian,
666 const unsigned char *buffer)
671 if (endian == MSBEndian)
673 value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
674 ((unsigned char *) buffer)[1]);
675 return((unsigned short) (value & 0xffff));
677 value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
678 return((unsigned short) (value & 0xffff));
681 static inline size_t ReadPropertyLong(const EndianType endian,
682 const unsigned char *buffer)
687 if (endian == MSBEndian)
689 value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
690 (buffer[2] << 8) | buffer[3]);
691 return((size_t) (value & 0xffffffff));
693 value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
694 (buffer[1] << 8 ) | (buffer[0]));
695 return((size_t) (value & 0xffffffff));
698 static MagickBooleanType GetEXIFProperty(const Image *image,
699 const char *property)
701 #define MaxDirectoryStack 16
702 #define EXIF_DELIMITER "\n"
703 #define EXIF_NUM_FORMATS 12
704 #define EXIF_FMT_BYTE 1
705 #define EXIF_FMT_STRING 2
706 #define EXIF_FMT_USHORT 3
707 #define EXIF_FMT_ULONG 4
708 #define EXIF_FMT_URATIONAL 5
709 #define EXIF_FMT_SBYTE 6
710 #define EXIF_FMT_UNDEFINED 7
711 #define EXIF_FMT_SSHORT 8
712 #define EXIF_FMT_SLONG 9
713 #define EXIF_FMT_SRATIONAL 10
714 #define EXIF_FMT_SINGLE 11
715 #define EXIF_FMT_DOUBLE 12
716 #define TAG_EXIF_OFFSET 0x8769
717 #define TAG_GPS_OFFSET 0x8825
718 #define TAG_INTEROP_OFFSET 0xa005
720 #define EXIFMultipleValues(size, format, arg) \
733 for (component=0; component < components; component++) \
735 length+=FormatLocaleString(buffer+length,MaxTextExtent-length, \
737 if (length >= (MaxTextExtent-1)) \
738 length=MaxTextExtent-1; \
742 buffer[length-2]='\0'; \
743 value=AcquireString(buffer); \
746 #define EXIFMultipleFractions(size, format, arg1, arg2) \
759 for (component=0; component < components; component++) \
761 length+=FormatLocaleString(buffer+length,MaxTextExtent-length, \
762 format", ",arg1, arg2); \
763 if (length >= (MaxTextExtent-1)) \
764 length=MaxTextExtent-1; \
768 buffer[length-2]='\0'; \
769 value=AcquireString(buffer); \
772 typedef struct _DirectoryInfo
782 typedef struct _TagInfo
794 { 0x001, "exif:InteroperabilityIndex" },
795 { 0x002, "exif:InteroperabilityVersion" },
796 { 0x100, "exif:ImageWidth" },
797 { 0x101, "exif:ImageLength" },
798 { 0x102, "exif:BitsPerSample" },
799 { 0x103, "exif:Compression" },
800 { 0x106, "exif:PhotometricInterpretation" },
801 { 0x10a, "exif:FillOrder" },
802 { 0x10d, "exif:DocumentName" },
803 { 0x10e, "exif:ImageDescription" },
804 { 0x10f, "exif:Make" },
805 { 0x110, "exif:Model" },
806 { 0x111, "exif:StripOffsets" },
807 { 0x112, "exif:Orientation" },
808 { 0x115, "exif:SamplesPerPixel" },
809 { 0x116, "exif:RowsPerStrip" },
810 { 0x117, "exif:StripByteCounts" },
811 { 0x11a, "exif:XResolution" },
812 { 0x11b, "exif:YResolution" },
813 { 0x11c, "exif:PlanarConfiguration" },
814 { 0x11d, "exif:PageName" },
815 { 0x11e, "exif:XPosition" },
816 { 0x11f, "exif:YPosition" },
817 { 0x118, "exif:MinSampleValue" },
818 { 0x119, "exif:MaxSampleValue" },
819 { 0x120, "exif:FreeOffsets" },
820 { 0x121, "exif:FreeByteCounts" },
821 { 0x122, "exif:GrayResponseUnit" },
822 { 0x123, "exif:GrayResponseCurve" },
823 { 0x124, "exif:T4Options" },
824 { 0x125, "exif:T6Options" },
825 { 0x128, "exif:ResolutionUnit" },
826 { 0x12d, "exif:TransferFunction" },
827 { 0x131, "exif:Software" },
828 { 0x132, "exif:DateTime" },
829 { 0x13b, "exif:Artist" },
830 { 0x13e, "exif:WhitePoint" },
831 { 0x13f, "exif:PrimaryChromaticities" },
832 { 0x140, "exif:ColorMap" },
833 { 0x141, "exif:HalfToneHints" },
834 { 0x142, "exif:TileWidth" },
835 { 0x143, "exif:TileLength" },
836 { 0x144, "exif:TileOffsets" },
837 { 0x145, "exif:TileByteCounts" },
838 { 0x14a, "exif:SubIFD" },
839 { 0x14c, "exif:InkSet" },
840 { 0x14d, "exif:InkNames" },
841 { 0x14e, "exif:NumberOfInks" },
842 { 0x150, "exif:DotRange" },
843 { 0x151, "exif:TargetPrinter" },
844 { 0x152, "exif:ExtraSample" },
845 { 0x153, "exif:SampleFormat" },
846 { 0x154, "exif:SMinSampleValue" },
847 { 0x155, "exif:SMaxSampleValue" },
848 { 0x156, "exif:TransferRange" },
849 { 0x157, "exif:ClipPath" },
850 { 0x158, "exif:XClipPathUnits" },
851 { 0x159, "exif:YClipPathUnits" },
852 { 0x15a, "exif:Indexed" },
853 { 0x15b, "exif:JPEGTables" },
854 { 0x15f, "exif:OPIProxy" },
855 { 0x200, "exif:JPEGProc" },
856 { 0x201, "exif:JPEGInterchangeFormat" },
857 { 0x202, "exif:JPEGInterchangeFormatLength" },
858 { 0x203, "exif:JPEGRestartInterval" },
859 { 0x205, "exif:JPEGLosslessPredictors" },
860 { 0x206, "exif:JPEGPointTransforms" },
861 { 0x207, "exif:JPEGQTables" },
862 { 0x208, "exif:JPEGDCTables" },
863 { 0x209, "exif:JPEGACTables" },
864 { 0x211, "exif:YCbCrCoefficients" },
865 { 0x212, "exif:YCbCrSubSampling" },
866 { 0x213, "exif:YCbCrPositioning" },
867 { 0x214, "exif:ReferenceBlackWhite" },
868 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
869 { 0x301, "exif:Gamma" },
870 { 0x302, "exif:ICCProfileDescriptor" },
871 { 0x303, "exif:SRGBRenderingIntent" },
872 { 0x320, "exif:ImageTitle" },
873 { 0x5001, "exif:ResolutionXUnit" },
874 { 0x5002, "exif:ResolutionYUnit" },
875 { 0x5003, "exif:ResolutionXLengthUnit" },
876 { 0x5004, "exif:ResolutionYLengthUnit" },
877 { 0x5005, "exif:PrintFlags" },
878 { 0x5006, "exif:PrintFlagsVersion" },
879 { 0x5007, "exif:PrintFlagsCrop" },
880 { 0x5008, "exif:PrintFlagsBleedWidth" },
881 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
882 { 0x500A, "exif:HalftoneLPI" },
883 { 0x500B, "exif:HalftoneLPIUnit" },
884 { 0x500C, "exif:HalftoneDegree" },
885 { 0x500D, "exif:HalftoneShape" },
886 { 0x500E, "exif:HalftoneMisc" },
887 { 0x500F, "exif:HalftoneScreen" },
888 { 0x5010, "exif:JPEGQuality" },
889 { 0x5011, "exif:GridSize" },
890 { 0x5012, "exif:ThumbnailFormat" },
891 { 0x5013, "exif:ThumbnailWidth" },
892 { 0x5014, "exif:ThumbnailHeight" },
893 { 0x5015, "exif:ThumbnailColorDepth" },
894 { 0x5016, "exif:ThumbnailPlanes" },
895 { 0x5017, "exif:ThumbnailRawBytes" },
896 { 0x5018, "exif:ThumbnailSize" },
897 { 0x5019, "exif:ThumbnailCompressedSize" },
898 { 0x501a, "exif:ColorTransferFunction" },
899 { 0x501b, "exif:ThumbnailData" },
900 { 0x5020, "exif:ThumbnailImageWidth" },
901 { 0x5021, "exif:ThumbnailImageHeight" },
902 { 0x5022, "exif:ThumbnailBitsPerSample" },
903 { 0x5023, "exif:ThumbnailCompression" },
904 { 0x5024, "exif:ThumbnailPhotometricInterp" },
905 { 0x5025, "exif:ThumbnailImageDescription" },
906 { 0x5026, "exif:ThumbnailEquipMake" },
907 { 0x5027, "exif:ThumbnailEquipModel" },
908 { 0x5028, "exif:ThumbnailStripOffsets" },
909 { 0x5029, "exif:ThumbnailOrientation" },
910 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
911 { 0x502b, "exif:ThumbnailRowsPerStrip" },
912 { 0x502c, "exif:ThumbnailStripBytesCount" },
913 { 0x502d, "exif:ThumbnailResolutionX" },
914 { 0x502e, "exif:ThumbnailResolutionY" },
915 { 0x502f, "exif:ThumbnailPlanarConfig" },
916 { 0x5030, "exif:ThumbnailResolutionUnit" },
917 { 0x5031, "exif:ThumbnailTransferFunction" },
918 { 0x5032, "exif:ThumbnailSoftwareUsed" },
919 { 0x5033, "exif:ThumbnailDateTime" },
920 { 0x5034, "exif:ThumbnailArtist" },
921 { 0x5035, "exif:ThumbnailWhitePoint" },
922 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
923 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
924 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
925 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
926 { 0x503A, "exif:ThumbnailRefBlackWhite" },
927 { 0x503B, "exif:ThumbnailCopyRight" },
928 { 0x5090, "exif:LuminanceTable" },
929 { 0x5091, "exif:ChrominanceTable" },
930 { 0x5100, "exif:FrameDelay" },
931 { 0x5101, "exif:LoopCount" },
932 { 0x5110, "exif:PixelUnit" },
933 { 0x5111, "exif:PixelPerUnitX" },
934 { 0x5112, "exif:PixelPerUnitY" },
935 { 0x5113, "exif:PaletteHistogram" },
936 { 0x1000, "exif:RelatedImageFileFormat" },
937 { 0x1001, "exif:RelatedImageLength" },
938 { 0x1002, "exif:RelatedImageWidth" },
939 { 0x800d, "exif:ImageID" },
940 { 0x80e3, "exif:Matteing" },
941 { 0x80e4, "exif:DataType" },
942 { 0x80e5, "exif:ImageDepth" },
943 { 0x80e6, "exif:TileDepth" },
944 { 0x828d, "exif:CFARepeatPatternDim" },
945 { 0x828e, "exif:CFAPattern2" },
946 { 0x828f, "exif:BatteryLevel" },
947 { 0x8298, "exif:Copyright" },
948 { 0x829a, "exif:ExposureTime" },
949 { 0x829d, "exif:FNumber" },
950 { 0x83bb, "exif:IPTC/NAA" },
951 { 0x84e3, "exif:IT8RasterPadding" },
952 { 0x84e5, "exif:IT8ColorTable" },
953 { 0x8649, "exif:ImageResourceInformation" },
954 { 0x8769, "exif:ExifOffset" },
955 { 0x8773, "exif:InterColorProfile" },
956 { 0x8822, "exif:ExposureProgram" },
957 { 0x8824, "exif:SpectralSensitivity" },
958 { 0x8825, "exif:GPSInfo" },
959 { 0x8827, "exif:ISOSpeedRatings" },
960 { 0x8828, "exif:OECF" },
961 { 0x8829, "exif:Interlace" },
962 { 0x882a, "exif:TimeZoneOffset" },
963 { 0x882b, "exif:SelfTimerMode" },
964 { 0x9000, "exif:ExifVersion" },
965 { 0x9003, "exif:DateTimeOriginal" },
966 { 0x9004, "exif:DateTimeDigitized" },
967 { 0x9101, "exif:ComponentsConfiguration" },
968 { 0x9102, "exif:CompressedBitsPerPixel" },
969 { 0x9201, "exif:ShutterSpeedValue" },
970 { 0x9202, "exif:ApertureValue" },
971 { 0x9203, "exif:BrightnessValue" },
972 { 0x9204, "exif:ExposureBiasValue" },
973 { 0x9205, "exif:MaxApertureValue" },
974 { 0x9206, "exif:SubjectDistance" },
975 { 0x9207, "exif:MeteringMode" },
976 { 0x9208, "exif:LightSource" },
977 { 0x9209, "exif:Flash" },
978 { 0x920a, "exif:FocalLength" },
979 { 0x920b, "exif:FlashEnergy" },
980 { 0x920c, "exif:SpatialFrequencyResponse" },
981 { 0x920d, "exif:Noise" },
982 { 0x9211, "exif:ImageNumber" },
983 { 0x9212, "exif:SecurityClassification" },
984 { 0x9213, "exif:ImageHistory" },
985 { 0x9214, "exif:SubjectArea" },
986 { 0x9215, "exif:ExposureIndex" },
987 { 0x9216, "exif:TIFF-EPStandardID" },
988 { 0x927c, "exif:MakerNote" },
989 { 0x9C9b, "exif:WinXP-Title" },
990 { 0x9C9c, "exif:WinXP-Comments" },
991 { 0x9C9d, "exif:WinXP-Author" },
992 { 0x9C9e, "exif:WinXP-Keywords" },
993 { 0x9C9f, "exif:WinXP-Subject" },
994 { 0x9286, "exif:UserComment" },
995 { 0x9290, "exif:SubSecTime" },
996 { 0x9291, "exif:SubSecTimeOriginal" },
997 { 0x9292, "exif:SubSecTimeDigitized" },
998 { 0xa000, "exif:FlashPixVersion" },
999 { 0xa001, "exif:ColorSpace" },
1000 { 0xa002, "exif:ExifImageWidth" },
1001 { 0xa003, "exif:ExifImageLength" },
1002 { 0xa004, "exif:RelatedSoundFile" },
1003 { 0xa005, "exif:InteroperabilityOffset" },
1004 { 0xa20b, "exif:FlashEnergy" },
1005 { 0xa20c, "exif:SpatialFrequencyResponse" },
1006 { 0xa20d, "exif:Noise" },
1007 { 0xa20e, "exif:FocalPlaneXResolution" },
1008 { 0xa20f, "exif:FocalPlaneYResolution" },
1009 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1010 { 0xa214, "exif:SubjectLocation" },
1011 { 0xa215, "exif:ExposureIndex" },
1012 { 0xa216, "exif:TIFF/EPStandardID" },
1013 { 0xa217, "exif:SensingMethod" },
1014 { 0xa300, "exif:FileSource" },
1015 { 0xa301, "exif:SceneType" },
1016 { 0xa302, "exif:CFAPattern" },
1017 { 0xa401, "exif:CustomRendered" },
1018 { 0xa402, "exif:ExposureMode" },
1019 { 0xa403, "exif:WhiteBalance" },
1020 { 0xa404, "exif:DigitalZoomRatio" },
1021 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1022 { 0xa406, "exif:SceneCaptureType" },
1023 { 0xa407, "exif:GainControl" },
1024 { 0xa408, "exif:Contrast" },
1025 { 0xa409, "exif:Saturation" },
1026 { 0xa40a, "exif:Sharpness" },
1027 { 0xa40b, "exif:DeviceSettingDescription" },
1028 { 0xa40c, "exif:SubjectDistanceRange" },
1029 { 0xa420, "exif:ImageUniqueID" },
1030 { 0xc4a5, "exif:PrintImageMatching" },
1031 { 0xa500, "exif:Gamma" },
1032 { 0xc640, "exif:CR2Slice" },
1033 { 0x10000, "exif:GPSVersionID" },
1034 { 0x10001, "exif:GPSLatitudeRef" },
1035 { 0x10002, "exif:GPSLatitude" },
1036 { 0x10003, "exif:GPSLongitudeRef" },
1037 { 0x10004, "exif:GPSLongitude" },
1038 { 0x10005, "exif:GPSAltitudeRef" },
1039 { 0x10006, "exif:GPSAltitude" },
1040 { 0x10007, "exif:GPSTimeStamp" },
1041 { 0x10008, "exif:GPSSatellites" },
1042 { 0x10009, "exif:GPSStatus" },
1043 { 0x1000a, "exif:GPSMeasureMode" },
1044 { 0x1000b, "exif:GPSDop" },
1045 { 0x1000c, "exif:GPSSpeedRef" },
1046 { 0x1000d, "exif:GPSSpeed" },
1047 { 0x1000e, "exif:GPSTrackRef" },
1048 { 0x1000f, "exif:GPSTrack" },
1049 { 0x10010, "exif:GPSImgDirectionRef" },
1050 { 0x10011, "exif:GPSImgDirection" },
1051 { 0x10012, "exif:GPSMapDatum" },
1052 { 0x10013, "exif:GPSDestLatitudeRef" },
1053 { 0x10014, "exif:GPSDestLatitude" },
1054 { 0x10015, "exif:GPSDestLongitudeRef" },
1055 { 0x10016, "exif:GPSDestLongitude" },
1056 { 0x10017, "exif:GPSDestBearingRef" },
1057 { 0x10018, "exif:GPSDestBearing" },
1058 { 0x10019, "exif:GPSDestDistanceRef" },
1059 { 0x1001a, "exif:GPSDestDistance" },
1060 { 0x1001b, "exif:GPSProcessingMethod" },
1061 { 0x1001c, "exif:GPSAreaInformation" },
1062 { 0x1001d, "exif:GPSDateStamp" },
1063 { 0x1001e, "exif:GPSDifferential" },
1075 directory_stack[MaxDirectoryStack];
1101 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1104 If EXIF data exists, then try to parse the request for a tag.
1106 profile=GetImageProfile(image,"exif");
1107 if (profile == (StringInfo *) NULL)
1108 return(MagickFalse);
1109 if ((property == (const char *) NULL) || (*property == '\0'))
1110 return(MagickFalse);
1111 while (isspace((int) ((unsigned char) *property)) != 0)
1115 switch (*(property+5))
1120 Caller has asked for all the tags in the EXIF data.
1123 all=1; /* return the data in description=value format */
1129 all=2; /* return the data in tagid=value format */
1142 Check for a hex based tag specification first.
1144 tag=(*(property+5) == '@') ? 1UL : 0UL;
1148 return(MagickFalse);
1150 Parse tag specification as a hex number.
1155 for (i=(ssize_t) n-1L; i >= 0; i--)
1159 if ((c >= '0') && (c <= '9'))
1162 if ((c >= 'A') && (c <= 'F'))
1165 if ((c >= 'a') && (c <= 'f'))
1168 return(MagickFalse);
1170 } while (*property != '\0');
1176 Try to match the text with a tag name instead.
1180 if (EXIFTag[i].tag == 0)
1182 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1184 tag=(size_t) EXIFTag[i].tag;
1192 return(MagickFalse);
1193 length=GetStringInfoLength(profile);
1194 exif=GetStringInfoDatum(profile);
1197 if (ReadPropertyByte(&exif,&length) != 0x45)
1199 if (ReadPropertyByte(&exif,&length) != 0x78)
1201 if (ReadPropertyByte(&exif,&length) != 0x69)
1203 if (ReadPropertyByte(&exif,&length) != 0x66)
1205 if (ReadPropertyByte(&exif,&length) != 0x00)
1207 if (ReadPropertyByte(&exif,&length) != 0x00)
1212 return(MagickFalse);
1213 id=(ssize_t) ReadPropertyShort(LSBEndian,exif);
1221 return(MagickFalse);
1222 if (ReadPropertyShort(endian,exif+2) != 0x002a)
1223 return(MagickFalse);
1225 This the offset to the first IFD.
1227 offset=(ssize_t) ((int) ReadPropertyLong(endian,exif+4));
1228 if ((size_t) offset >= length)
1229 return(MagickFalse);
1231 Set the pointer to the first IFD and follow it were it leads.
1234 directory=exif+offset;
1241 If there is anything on the stack then pop it off.
1246 directory=directory_stack[level].directory;
1247 entry=directory_stack[level].entry;
1248 tag_offset=directory_stack[level].offset;
1251 Determine how many entries there are in the current IFD.
1253 number_entries=ReadPropertyShort(endian,directory);
1254 for ( ; entry < number_entries; entry++)
1256 register unsigned char
1267 q=(unsigned char *) (directory+2+(12*entry));
1268 tag_value=(ssize_t) (ReadPropertyShort(endian,q)+tag_offset);
1269 format=(size_t) ReadPropertyShort(endian,q+2);
1270 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1272 components=(ssize_t) ((int) ReadPropertyLong(endian,q+4));
1273 number_bytes=(size_t) components*tag_bytes[format];
1274 if (number_bytes <= 4)
1282 The directory entry contains an offset.
1284 offset=(ssize_t) ((int) ReadPropertyLong(endian,q+8));
1285 if ((size_t) (offset+number_bytes) > length)
1287 p=(unsigned char *) (exif+offset);
1289 if ((all != 0) || (tag == (size_t) tag_value))
1292 buffer[MaxTextExtent],
1298 case EXIF_FMT_UNDEFINED:
1300 EXIFMultipleValues(1,"%.20g",(double) (*(unsigned char *) p1));
1303 case EXIF_FMT_SBYTE:
1305 EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1308 case EXIF_FMT_SSHORT:
1310 EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1));
1313 case EXIF_FMT_USHORT:
1315 EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1));
1318 case EXIF_FMT_ULONG:
1320 EXIFMultipleValues(4,"%.20g",(double)
1321 ReadPropertyLong(endian,p1));
1324 case EXIF_FMT_SLONG:
1326 EXIFMultipleValues(4,"%.20g",(double)
1327 ReadPropertyLong(endian,p1));
1330 case EXIF_FMT_URATIONAL:
1332 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1333 ReadPropertyLong(endian,p1),(double)
1334 ReadPropertyLong(endian,p1+4));
1337 case EXIF_FMT_SRATIONAL:
1339 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1340 ReadPropertyLong(endian,p1),(double)
1341 ReadPropertyLong(endian,p1+4));
1344 case EXIF_FMT_SINGLE:
1346 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1349 case EXIF_FMT_DOUBLE:
1351 EXIFMultipleValues(8,"%f",*(double *) p1);
1355 case EXIF_FMT_STRING:
1357 value=(char *) NULL;
1358 if (~(1UL*number_bytes) >= 1)
1359 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1361 if (value != (char *) NULL)
1366 for (i=0; i < (ssize_t) number_bytes; i++)
1369 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1370 value[i]=(char) p[i];
1377 if (value != (char *) NULL)
1385 (void) CopyMagickString(key,property,MaxTextExtent);
1396 description="unknown";
1399 if (EXIFTag[i].tag == 0)
1401 if ((ssize_t) EXIFTag[i].tag == tag_value)
1403 description=EXIFTag[i].description;
1407 (void) FormatLocaleString(key,MaxTextExtent,"%s",
1413 if (tag_value < 0x10000)
1414 (void) FormatLocaleString(key,MaxTextExtent,"#%04lx",
1415 (unsigned long) tag_value);
1417 if (tag_value < 0x20000)
1418 (void) FormatLocaleString(key,MaxTextExtent,"@%04lx",
1419 (unsigned long) (tag_value & 0xffff));
1421 (void) FormatLocaleString(key,MaxTextExtent,"unknown");
1425 p=(const char *) NULL;
1426 if (image->properties != (void *) NULL)
1427 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1428 image->properties,key);
1429 if (p == (const char *) NULL)
1430 (void) SetImageProperty((Image *) image,key,value);
1431 value=DestroyString(value);
1435 if ((tag_value == TAG_EXIF_OFFSET) ||
1436 (tag_value == TAG_INTEROP_OFFSET) ||
1437 (tag_value == TAG_GPS_OFFSET))
1442 offset=(size_t) ReadPropertyLong(endian,p);
1443 if ((offset < length) && (level < (MaxDirectoryStack-2)))
1448 tag_offset1=(tag_value == TAG_GPS_OFFSET) ? 0x10000UL : 0UL;
1449 directory_stack[level].directory=directory;
1451 directory_stack[level].entry=entry;
1452 directory_stack[level].offset=tag_offset;
1454 directory_stack[level].directory=exif+offset;
1455 directory_stack[level].offset=tag_offset1;
1456 directory_stack[level].entry=0;
1458 if ((directory+2+(12*number_entries)) > (exif+length))
1460 offset=(size_t) ReadPropertyLong(endian,directory+2+(12*
1462 if ((offset != 0) && (offset < length) &&
1463 (level < (MaxDirectoryStack-2)))
1465 directory_stack[level].directory=exif+offset;
1466 directory_stack[level].entry=0;
1467 directory_stack[level].offset=tag_offset1;
1474 } while (level > 0);
1478 static MagickBooleanType GetXMPProperty(const Image *image,const char *property)
1502 profile=GetImageProfile(image,"xmp");
1503 if (profile == (StringInfo *) NULL)
1504 return(MagickFalse);
1505 if ((property == (const char *) NULL) || (*property == '\0'))
1506 return(MagickFalse);
1507 xmp_profile=StringInfoToString(profile);
1508 if (xmp_profile == (char *) NULL)
1509 return(MagickFalse);
1510 for (p=xmp_profile; *p != '\0'; p++)
1511 if ((*p == '<') && (*(p+1) == 'x'))
1513 exception=AcquireExceptionInfo();
1514 xmp=NewXMLTree((char *) p,exception);
1515 xmp_profile=DestroyString(xmp_profile);
1516 exception=DestroyExceptionInfo(exception);
1517 if (xmp == (XMLTreeInfo *) NULL)
1518 return(MagickFalse);
1520 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1521 if (rdf != (XMLTreeInfo *) NULL)
1523 if (image->properties == (void *) NULL)
1524 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1525 RelinquishMagickMemory,RelinquishMagickMemory);
1526 description=GetXMLTreeChild(rdf,"rdf:Description");
1527 while (description != (XMLTreeInfo *) NULL)
1529 node=GetXMLTreeChild(description,(const char *) NULL);
1530 while (node != (XMLTreeInfo *) NULL)
1532 child=GetXMLTreeChild(node,(const char *) NULL);
1533 if (child == (XMLTreeInfo *) NULL)
1534 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1535 ConstantString(GetXMLTreeTag(node)),
1536 ConstantString(GetXMLTreeContent(node)));
1537 while (child != (XMLTreeInfo *) NULL)
1539 if (LocaleCompare(GetXMLTreeTag(child),"rdf:Seq") != 0)
1540 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1541 ConstantString(GetXMLTreeTag(child)),
1542 ConstantString(GetXMLTreeContent(child)));
1543 child=GetXMLTreeSibling(child);
1545 node=GetXMLTreeSibling(node);
1547 description=GetNextXMLTreeTag(description);
1550 xmp=DestroyXMLTree(xmp);
1554 static char *TracePSClippath(const unsigned char *blob,size_t length,
1555 const size_t magick_unused(columns),
1556 const size_t magick_unused(rows))
1579 path=AcquireString((char *) NULL);
1580 if (path == (char *) NULL)
1581 return((char *) NULL);
1582 message=AcquireString((char *) NULL);
1583 (void) FormatLocaleString(message,MaxTextExtent,"/ClipImage\n");
1584 (void) ConcatenateString(&path,message);
1585 (void) FormatLocaleString(message,MaxTextExtent,"{\n");
1586 (void) ConcatenateString(&path,message);
1587 (void) FormatLocaleString(message,MaxTextExtent," /c {curveto} bind def\n");
1588 (void) ConcatenateString(&path,message);
1589 (void) FormatLocaleString(message,MaxTextExtent," /l {lineto} bind def\n");
1590 (void) ConcatenateString(&path,message);
1591 (void) FormatLocaleString(message,MaxTextExtent," /m {moveto} bind def\n");
1592 (void) ConcatenateString(&path,message);
1593 (void) FormatLocaleString(message,MaxTextExtent,
1594 " /v {currentpoint 6 2 roll curveto} bind def\n");
1595 (void) ConcatenateString(&path,message);
1596 (void) FormatLocaleString(message,MaxTextExtent,
1597 " /y {2 copy curveto} bind def\n");
1598 (void) ConcatenateString(&path,message);
1599 (void) FormatLocaleString(message,MaxTextExtent,
1600 " /z {closepath} bind def\n");
1601 (void) ConcatenateString(&path,message);
1602 (void) FormatLocaleString(message,MaxTextExtent," newpath\n");
1603 (void) ConcatenateString(&path,message);
1605 The clipping path format is defined in "Adobe Photoshop File
1606 Formats Specification" version 6.0 downloadable from adobe.com.
1608 (void) ResetMagickMemory(point,0,sizeof(point));
1609 (void) ResetMagickMemory(first,0,sizeof(first));
1610 (void) ResetMagickMemory(last,0,sizeof(last));
1612 in_subpath=MagickFalse;
1615 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1621 if (knot_count != 0)
1628 Expected subpath length record.
1630 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1640 if (knot_count == 0)
1643 Unexpected subpath knot
1652 for (i=0; i < 3; i++)
1658 yy=ReadPropertyMSBLong(&blob,&length);
1659 xx=ReadPropertyMSBLong(&blob,&length);
1661 if (xx > 2147483647)
1662 x=(ssize_t) xx-4294967295U-1;
1664 if (yy > 2147483647)
1665 y=(ssize_t) yy-4294967295U-1;
1666 point[i].x=(double) x/4096/4096;
1667 point[i].y=1.0-(double) y/4096/4096;
1669 if (in_subpath == MagickFalse)
1671 (void) FormatLocaleString(message,MaxTextExtent," %g %g m\n",
1672 point[1].x,point[1].y);
1673 for (i=0; i < 3; i++)
1682 Handle special cases when Bezier curves are used to describe
1683 corners and straight lines.
1685 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1686 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1687 (void) FormatLocaleString(message,MaxTextExtent,
1688 " %g %g l\n",point[1].x,point[1].y);
1690 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1691 (void) FormatLocaleString(message,MaxTextExtent,
1692 " %g %g %g %g v\n",point[0].x,point[0].y,
1693 point[1].x,point[1].y);
1695 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1696 (void) FormatLocaleString(message,MaxTextExtent,
1697 " %g %g %g %g y\n",last[2].x,last[2].y,
1698 point[1].x,point[1].y);
1700 (void) FormatLocaleString(message,MaxTextExtent,
1701 " %g %g %g %g %g %g c\n",last[2].x,
1702 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1703 for (i=0; i < 3; i++)
1706 (void) ConcatenateString(&path,message);
1707 in_subpath=MagickTrue;
1710 Close the subpath if there are no more knots.
1712 if (knot_count == 0)
1715 Same special handling as above except we compare to the
1716 first point in the path and close the path.
1718 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1719 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1720 (void) FormatLocaleString(message,MaxTextExtent,
1721 " %g %g l z\n",first[1].x,first[1].y);
1723 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1724 (void) FormatLocaleString(message,MaxTextExtent,
1725 " %g %g %g %g v z\n",first[0].x,first[0].y,
1726 first[1].x,first[1].y);
1728 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1729 (void) FormatLocaleString(message,MaxTextExtent,
1730 " %g %g %g %g y z\n",last[2].x,last[2].y,
1731 first[1].x,first[1].y);
1733 (void) FormatLocaleString(message,MaxTextExtent,
1734 " %g %g %g %g %g %g c z\n",last[2].x,
1735 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1736 (void) ConcatenateString(&path,message);
1737 in_subpath=MagickFalse;
1753 Returns an empty PS path if the path has no knots.
1755 (void) FormatLocaleString(message,MaxTextExtent," eoclip\n");
1756 (void) ConcatenateString(&path,message);
1757 (void) FormatLocaleString(message,MaxTextExtent,"} bind def");
1758 (void) ConcatenateString(&path,message);
1759 message=DestroyString(message);
1763 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1764 const size_t columns,const size_t rows)
1787 path=AcquireString((char *) NULL);
1788 if (path == (char *) NULL)
1789 return((char *) NULL);
1790 message=AcquireString((char *) NULL);
1791 (void) FormatLocaleString(message,MaxTextExtent,
1792 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
1793 (void) ConcatenateString(&path,message);
1794 (void) FormatLocaleString(message,MaxTextExtent,
1795 "<svg width=\"%.20g\" height=\"%.20g\">\n",(double) columns,(double) rows);
1796 (void) ConcatenateString(&path,message);
1797 (void) FormatLocaleString(message,MaxTextExtent,"<g>\n");
1798 (void) ConcatenateString(&path,message);
1799 (void) FormatLocaleString(message,MaxTextExtent,
1800 "<path style=\"fill:#00000000;stroke:#00000000;");
1801 (void) ConcatenateString(&path,message);
1802 (void) FormatLocaleString(message,MaxTextExtent,
1803 "stroke-width:0;stroke-antialiasing:false\" d=\"\n");
1804 (void) ConcatenateString(&path,message);
1805 (void) ResetMagickMemory(point,0,sizeof(point));
1806 (void) ResetMagickMemory(first,0,sizeof(first));
1807 (void) ResetMagickMemory(last,0,sizeof(last));
1809 in_subpath=MagickFalse;
1812 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1818 if (knot_count != 0)
1825 Expected subpath length record.
1827 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1837 if (knot_count == 0)
1840 Unexpected subpath knot.
1849 for (i=0; i < 3; i++)
1855 yy=ReadPropertyMSBLong(&blob,&length);
1856 xx=ReadPropertyMSBLong(&blob,&length);
1858 if (xx > 2147483647)
1859 x=(ssize_t) xx-4294967295U-1;
1861 if (yy > 2147483647)
1862 y=(ssize_t) yy-4294967295U-1;
1863 point[i].x=(double) x*columns/4096/4096;
1864 point[i].y=(double) y*rows/4096/4096;
1866 if (in_subpath == MagickFalse)
1868 (void) FormatLocaleString(message,MaxTextExtent,"M %g,%g\n",
1869 point[1].x,point[1].y);
1870 for (i=0; i < 3; i++)
1878 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1879 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1880 (void) FormatLocaleString(message,MaxTextExtent,"L %g,%g\n",
1881 point[1].x,point[1].y);
1883 (void) FormatLocaleString(message,MaxTextExtent,
1884 "C %g,%g %g,%g %g,%g\n",last[2].x,last[2].y,
1885 point[0].x,point[0].y,point[1].x,point[1].y);
1886 for (i=0; i < 3; i++)
1889 (void) ConcatenateString(&path,message);
1890 in_subpath=MagickTrue;
1893 Close the subpath if there are no more knots.
1895 if (knot_count == 0)
1897 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1898 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1899 (void) FormatLocaleString(message,MaxTextExtent,
1900 "L %g,%g Z\n",first[1].x,first[1].y);
1903 (void) FormatLocaleString(message,MaxTextExtent,
1904 "C %g,%g %g,%g %g,%g Z\n",last[2].x,
1905 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1906 (void) ConcatenateString(&path,message);
1908 in_subpath=MagickFalse;
1924 Return an empty SVG image if the path does not have knots.
1926 (void) FormatLocaleString(message,MaxTextExtent,"\"/>\n");
1927 (void) ConcatenateString(&path,message);
1928 (void) FormatLocaleString(message,MaxTextExtent,"</g>\n");
1929 (void) ConcatenateString(&path,message);
1930 (void) FormatLocaleString(message,MaxTextExtent,"</svg>\n");
1931 (void) ConcatenateString(&path,message);
1932 message=DestroyString(message);
1936 MagickExport const char *GetImageProperty(const Image *image,
1937 const char *property)
1954 assert(image != (Image *) NULL);
1955 assert(image->signature == MagickSignature);
1956 if (image->debug != MagickFalse)
1957 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1958 p=(const char *) NULL;
1959 if (image->properties != (void *) NULL)
1961 if (property == (const char *) NULL)
1963 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
1964 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
1968 if (LocaleNCompare("fx:",property,3) != 0)
1970 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1971 image->properties,property);
1972 if (p != (const char *) NULL)
1976 if ((property == (const char *) NULL) ||
1977 (strchr(property,':') == (char *) NULL))
1979 exception=(&((Image *) image)->exception);
1984 if (LocaleNCompare("8bim:",property,5) == 0)
1986 if ((Get8BIMProperty(image,property) != MagickFalse) &&
1987 (image->properties != (void *) NULL))
1989 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1990 image->properties,property);
1999 if (LocaleNCompare("exif:",property,5) == 0)
2001 if ((GetEXIFProperty(image,property) != MagickFalse) &&
2002 (image->properties != (void *) NULL))
2004 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2005 image->properties,property);
2014 if (LocaleNCompare("fx:",property,3) == 0)
2016 fx_info=AcquireFxInfo(image,property+3);
2017 status=FxEvaluateChannelExpression(fx_info,IntensityPixelChannel,0,0,
2019 fx_info=DestroyFxInfo(fx_info);
2020 if (status != MagickFalse)
2023 value[MaxTextExtent];
2025 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2026 GetMagickPrecision(),(double) alpha);
2027 (void) SetImageProperty((Image *) image,property,value);
2029 if (image->properties != (void *) NULL)
2031 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2032 image->properties,property);
2041 if (LocaleNCompare("iptc:",property,5) == 0)
2043 if ((GetIPTCProperty(image,property) != MagickFalse) &&
2044 (image->properties != (void *) NULL))
2046 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2047 image->properties,property);
2056 if (LocaleNCompare("pixel:",property,6) == 0)
2061 GetPixelInfo(image,&pixel);
2062 fx_info=AcquireFxInfo(image,property+6);
2063 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
2065 pixel.red=(MagickRealType) QuantumRange*alpha;
2066 status|=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
2068 pixel.green=(MagickRealType) QuantumRange*alpha;
2069 status|=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
2071 pixel.blue=(MagickRealType) QuantumRange*alpha;
2072 if (image->colorspace == CMYKColorspace)
2074 status|=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
2076 pixel.black=(MagickRealType) QuantumRange*alpha;
2078 status|=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
2080 pixel.alpha=(MagickRealType) QuantumRange*(1.0-alpha);
2081 fx_info=DestroyFxInfo(fx_info);
2082 if (status != MagickFalse)
2085 name[MaxTextExtent];
2087 (void) QueryMagickColorname(image,&pixel,SVGCompliance,name,
2089 (void) SetImageProperty((Image *) image,property,name);
2090 return(GetImageProperty(image,property));
2098 if (LocaleNCompare("xmp:",property,4) == 0)
2100 if ((GetXMPProperty(image,property) != MagickFalse) &&
2101 (image->properties != (void *) NULL))
2103 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2104 image->properties,property);
2117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2121 + G e t M a g i c k P r o p e r t y %
2125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2127 % GetMagickProperty() gets a value associated with an image property.
2129 % The format of the GetMagickProperty method is:
2131 % const char *GetMagickProperty(const ImageInfo *image_info,Image *image,
2134 % A description of each parameter follows:
2136 % o image_info: the image info.
2138 % o image: the image.
2143 MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
2144 Image *image,const char *property)
2147 value[MaxTextExtent],
2148 filename[MaxTextExtent];
2155 if (LocaleNCompare("base",property,4) == 0)
2157 GetPathComponent(image->magick_filename,BasePath,filename);
2158 (void) CopyMagickString(value,filename,MaxTextExtent);
2165 if (LocaleNCompare("channels",property,8) == 0)
2170 (void) FormatLocaleString(value,MaxTextExtent,"%s",
2171 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2172 image->colorspace));
2174 if (image->matte != MagickFalse)
2175 (void) ConcatenateMagickString(value,"a",MaxTextExtent);
2178 if (LocaleNCompare("colorspace",property,10) == 0)
2184 Image storage class and colorspace.
2186 colorspace=image->colorspace;
2187 if (IsImageGray(image,&image->exception) != MagickFalse)
2188 colorspace=GRAYColorspace;
2189 (void) FormatLocaleString(value,MaxTextExtent,"%s",
2190 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2194 if (LocaleNCompare("copyright",property,9) == 0)
2196 (void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
2203 if (LocaleNCompare("depth",property,5) == 0)
2205 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2209 if (LocaleNCompare("directory",property,9) == 0)
2211 GetPathComponent(image->magick_filename,HeadPath,filename);
2212 (void) CopyMagickString(value,filename,MaxTextExtent);
2219 if (LocaleNCompare("extension",property,9) == 0)
2221 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2222 (void) CopyMagickString(value,filename,MaxTextExtent);
2229 if (LocaleNCompare("group",property,5) == 0)
2231 (void) FormatLocaleString(value,MaxTextExtent,"0x%lx",
2232 (unsigned long) image_info->group);
2239 if (LocaleNCompare("height",property,6) == 0)
2241 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",
2242 image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2249 if (LocaleNCompare("input",property,5) == 0)
2251 (void) CopyMagickString(value,image->filename,MaxTextExtent);
2258 if (LocaleNCompare("kurtosis",property,8) == 0)
2264 (void) GetImageKurtosis(image,&kurtosis,&skewness,&image->exception);
2265 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2266 GetMagickPrecision(),kurtosis);
2273 if (LocaleNCompare("magick",property,6) == 0)
2275 (void) CopyMagickString(value,image->magick,MaxTextExtent);
2278 if (LocaleNCompare("max",property,3) == 0)
2284 (void) GetImageRange(image,&minimum,&maximum,&image->exception);
2285 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2286 GetMagickPrecision(),maximum);
2289 if (LocaleNCompare("mean",property,4) == 0)
2295 (void) GetImageMean(image,&mean,&standard_deviation,
2297 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2298 GetMagickPrecision(),mean);
2301 if (LocaleNCompare("min",property,3) == 0)
2307 (void) GetImageRange(image,&minimum,&maximum,&image->exception);
2308 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2309 GetMagickPrecision(),minimum);
2316 if (LocaleNCompare("name",property,4) == 0)
2318 (void) CopyMagickString(value,filename,MaxTextExtent);
2325 if (LocaleNCompare("opaque",property,6) == 0)
2330 opaque=IsImageOpaque(image,&image->exception);
2331 (void) CopyMagickString(value,opaque == MagickFalse ? "false" :
2332 "true",MaxTextExtent);
2335 if (LocaleNCompare("output",property,6) == 0)
2337 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
2344 if (LocaleNCompare("page",property,4) == 0)
2346 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2347 GetImageIndexInList(image)+1);
2354 if (LocaleNCompare("size",property,4) == 0)
2357 format[MaxTextExtent];
2359 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
2360 (void) FormatLocaleString(value,MaxTextExtent,"%sB",format);
2363 if (LocaleNCompare("scenes",property,6) == 0)
2365 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2366 GetImageListLength(image));
2369 if (LocaleNCompare("scene",property,5) == 0)
2371 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2373 if (image_info->number_scenes != 0)
2374 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2378 if (LocaleNCompare("skewness",property,8) == 0)
2384 (void) GetImageKurtosis(image,&kurtosis,&skewness,&image->exception);
2385 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2386 GetMagickPrecision(),skewness);
2389 if (LocaleNCompare("standard-deviation",property,18) == 0)
2395 (void) GetImageMean(image,&mean,&standard_deviation,
2397 (void) FormatLocaleString(value,MaxTextExtent,"%.*g",
2398 GetMagickPrecision(),standard_deviation);
2405 if (LocaleNCompare("unique",property,6) == 0)
2407 (void) CopyMagickString(filename,image_info->unique,MaxTextExtent);
2408 (void) CopyMagickString(value,filename,MaxTextExtent);
2415 if (LocaleNCompare("version",property,7) == 0)
2417 (void) CopyMagickString(value,GetMagickVersion((size_t *) NULL),
2425 if (LocaleNCompare("width",property,5) == 0)
2427 (void) FormatLocaleString(value,MaxTextExtent,"%.20g",(double)
2428 (image->magick_columns != 0 ? image->magick_columns : 256));
2435 if (LocaleNCompare("xresolution",property,11) == 0)
2437 (void) FormatLocaleString(value,MaxTextExtent,"%g",
2438 image->x_resolution);
2445 if (LocaleNCompare("yresolution",property,11) == 0)
2447 (void) FormatLocaleString(value,MaxTextExtent,"%g",
2448 image->y_resolution);
2455 if (LocaleNCompare("zero",property,4) == 0)
2457 (void) CopyMagickString(filename,image_info->zero,MaxTextExtent);
2458 (void) CopyMagickString(value,filename,MaxTextExtent);
2466 if (image->properties == (void *) NULL)
2467 image->properties=NewSplayTree(CompareSplayTreeString,
2468 RelinquishMagickMemory,RelinquishMagickMemory);
2469 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
2470 ConstantString(property),ConstantString(value));
2472 return(GetImageProperty(image,property));
2476 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2480 % G e t N e x t I m a g e P r o p e r t y %
2484 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2486 % GetNextImageProperty() gets the next image property value.
2488 % The format of the GetNextImageProperty method is:
2490 % char *GetNextImageProperty(const Image *image)
2492 % A description of each parameter follows:
2494 % o image: the image.
2497 MagickExport char *GetNextImageProperty(const Image *image)
2499 assert(image != (Image *) NULL);
2500 assert(image->signature == MagickSignature);
2501 if (image->debug != MagickFalse)
2502 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2504 if (image->properties == (void *) NULL)
2505 return((char *) NULL);
2506 return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
2510 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2514 % I n t e r p r e t I m a g e P r o p e r t i e s %
2518 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2520 % InterpretImageProperties() replaces any embedded formatting characters with
2521 % the appropriate image property and returns the interpreted text.
2523 % The format of the InterpretImageProperties method is:
2525 % char *InterpretImageProperties(const ImageInfo *image_info,Image *image,
2526 % const char *embed_text,ExceptionInfo *exception)
2528 % A description of each parameter follows:
2530 % o image_info: the image info.
2532 % o image: the image.
2534 % o embed_text: the address of a character string containing the embedded
2535 % formatting characters.
2537 % o exception: return any errors or warnings in this structure.
2540 MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
2541 Image *image,const char *embed_text,ExceptionInfo *exception)
2544 filename[MaxTextExtent],
2564 assert(image != (Image *) NULL);
2565 assert(image->signature == MagickSignature);
2566 if (image->debug != MagickFalse)
2567 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2568 if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))
2569 return((char *) NULL);
2570 text=(char *) embed_text;
2571 if ((*text == '@') && ((*(text+1) == '-') ||
2572 (IsPathAccessible(text+1) != MagickFalse)))
2573 return(FileToString(embed_text+1,~0,&image->exception));
2575 Translate any embedded format characters.
2577 interpret_text=AcquireString(text);
2578 extent=MaxTextExtent;
2580 for (q=interpret_text; *p != '\0'; p++)
2583 if ((size_t) (q-interpret_text+MaxTextExtent) >= extent)
2585 extent+=MaxTextExtent;
2586 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2587 MaxTextExtent+1,sizeof(*interpret_text));
2588 if (interpret_text == (char *) NULL)
2590 q=interpret_text+strlen(interpret_text);
2593 Process formatting characters in text.
2595 if ((*p == '\\') && (*(p+1) == 'r'))
2601 if ((*p == '\\') && (*(p+1) == 'n'))
2624 format[MaxTextExtent];
2629 (void) FormatLocaleString(format,MaxTextExtent,"%.20g",(double)
2630 ((MagickOffsetType) image->extent));
2631 if (image->extent != (MagickSizeType) ((size_t) image->extent))
2632 (void) FormatMagickSize(image->extent,MagickFalse,format);
2633 q+=ConcatenateMagickString(q,format,extent);
2634 q+=ConcatenateMagickString(q,"B",extent);
2642 value=GetImageProperty(image,"comment");
2643 if (value == (const char *) NULL)
2645 length=strlen(value);
2646 if ((size_t) (q-interpret_text+length+1) >= extent)
2649 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2650 MaxTextExtent,sizeof(*interpret_text));
2651 if (interpret_text == (char *) NULL)
2653 q=interpret_text+strlen(interpret_text);
2655 (void) CopyMagickString(q,value,extent);
2665 Label segment is the base of the filename.
2667 if (*image->magick_filename == '\0')
2676 GetPathComponent(image->magick_filename,HeadPath,filename);
2677 q+=CopyMagickString(q,filename,extent);
2685 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2686 q+=CopyMagickString(q,filename,extent);
2694 GetPathComponent(image->magick_filename,TailPath,filename);
2695 q+=CopyMagickString(q,filename,extent);
2703 GetPathComponent(image->magick_filename,BasePath,filename);
2704 q+=CopyMagickString(q,filename,extent);
2715 q+=FormatLocaleString(q,extent,"%.20gx%.20g%+.20g%+.20g",(double)
2716 image->page.width,(double) image->page.height,(double) image->page.x,
2717 (double) image->page.y);
2725 q+=FormatLocaleString(q,extent,"%.20g",(double) (image->rows != 0 ?
2726 image->rows : image->magick_rows));
2734 q+=CopyMagickString(q,image->filename,extent);
2740 Number of unique colors.
2742 q+=FormatLocaleString(q,extent,"%.20g",(double) GetNumberColors(image,
2743 (FILE *) NULL,&image->exception));
2751 value=GetImageProperty(image,"label");
2752 if (value == (const char *) NULL)
2754 length=strlen(value);
2755 if ((size_t) (q-interpret_text+length+1) >= extent)
2758 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2759 MaxTextExtent,sizeof(*interpret_text));
2760 if (interpret_text == (char *) NULL)
2762 q=interpret_text+strlen(interpret_text);
2764 q+=CopyMagickString(q,value,extent);
2772 q+=CopyMagickString(q,image->magick,extent);
2778 Image magick filename.
2780 q+=CopyMagickString(q,image->magick_filename,extent);
2786 Number of images in the list.
2788 q+=FormatLocaleString(q,extent,"%.20g",(double)
2789 GetImageListLength(image));
2795 Image output filename.
2797 q+=CopyMagickString(q,image_info->filename,extent);
2803 Image index in list.
2805 q+=FormatLocaleString(q,extent,"%.20g",(double)
2806 GetImageIndexInList(image));
2814 q+=FormatLocaleString(q,extent,"%.20g",(double)
2815 MAGICKCORE_QUANTUM_DEPTH);
2824 Image storage class and colorspace.
2826 colorspace=image->colorspace;
2827 if (IsImageGray(image,&image->exception) != MagickFalse)
2828 colorspace=GRAYColorspace;
2829 q+=FormatLocaleString(q,extent,"%s%s%s",CommandOptionToMnemonic(
2830 MagickClassOptions,(ssize_t) image->storage_class),
2831 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
2832 image->matte != MagickFalse ? "Matte" : "");
2840 if (image_info->number_scenes == 0)
2841 q+=FormatLocaleString(q,extent,"%.20g",(double) image->scene);
2843 q+=FormatLocaleString(q,extent,"%.20g",(double) image_info->scene);
2851 (void) CopyMagickString(filename,image_info->unique,extent);
2852 q+=CopyMagickString(q,filename,extent);
2860 q+=FormatLocaleString(q,extent,"%.20g",(double) (image->columns != 0 ?
2861 image->columns : image->magick_columns));
2867 Image horizontal resolution.
2869 q+=FormatLocaleString(q,extent,"%g %s",image->x_resolution,
2870 CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2877 Image vertical resolution.
2879 q+=FormatLocaleString(q,extent,"%g %s",image->y_resolution,
2880 CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2889 q+=FormatLocaleString(q,extent,"%.20g",(double) image->depth);
2895 Image alpha channel.
2897 q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
2898 MagickBooleanOptions,(ssize_t) image->matte));
2904 Image compression method.
2906 q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
2907 MagickCompressOptions,(ssize_t) image->compression));
2913 Image dispose method.
2915 q+=FormatLocaleString(q,extent,"%s",CommandOptionToMnemonic(
2916 MagickDisposeOptions,(ssize_t) image->dispose));
2921 q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double)
2922 image->magick_columns,(double) image->magick_rows);
2927 q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.height);
2932 q+=FormatLocaleString(q,extent,"%+ld%+ld",(long) image->page.x,(long)
2938 q+=FormatLocaleString(q,extent,"%.20gx%.20g",(double) image->page.width,
2939 (double) image->page.height);
2944 q+=FormatLocaleString(q,extent,"%.20g",(double) image->quality);
2952 if (image_info->number_scenes == 0)
2953 q+=CopyMagickString(q,"2147483647",extent);
2955 q+=FormatLocaleString(q,extent,"%.20g",(double) (image_info->scene+
2956 image_info->number_scenes));
2961 q+=FormatLocaleString(q,extent,"%.20g",(double) image->delay);
2966 q+=FormatLocaleString(q,extent,"%.20g",(double) image->page.width);
2971 q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.x);
2976 q+=FormatLocaleString(q,extent,"%+.20g",(double) image->page.y);
2984 (void) CopyMagickString(filename,image_info->zero,extent);
2985 q+=CopyMagickString(q,filename,extent);
2991 pattern[MaxTextExtent];
3003 if (strchr(p,']') == (char *) NULL)
3007 for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
3018 value=GetImageProperty(image,pattern);
3019 if (value != (const char *) NULL)
3021 length=strlen(value);
3022 if ((size_t) (q-interpret_text+length+1) >= extent)
3025 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3026 extent+MaxTextExtent,sizeof(*interpret_text));
3027 if (interpret_text == (char *) NULL)
3029 q=interpret_text+strlen(interpret_text);
3031 (void) CopyMagickString(q,value,extent);
3036 if (IsGlob(pattern) != MagickFalse)
3039 Iterate over image properties.
3041 ResetImagePropertyIterator(image);
3042 key=GetNextImageProperty(image);
3043 while (key != (const char *) NULL)
3045 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3047 value=GetImageProperty(image,key);
3048 if (value != (const char *) NULL)
3050 length=strlen(key)+strlen(value)+2;
3051 if ((size_t) (q-interpret_text+length+1) >= extent)
3054 interpret_text=(char *) ResizeQuantumMemory(
3055 interpret_text,extent+MaxTextExtent,
3056 sizeof(*interpret_text));
3057 if (interpret_text == (char *) NULL)
3059 q=interpret_text+strlen(interpret_text);
3061 q+=FormatLocaleString(q,extent,"%s=%s\n",key,value);
3064 key=GetNextImageProperty(image);
3067 value=GetMagickProperty(image_info,image,pattern);
3068 if (value != (const char *) NULL)
3070 length=strlen(value);
3071 if ((size_t) (q-interpret_text+length+1) >= extent)
3074 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3075 extent+MaxTextExtent,sizeof(*interpret_text));
3076 if (interpret_text == (char *) NULL)
3078 q=interpret_text+strlen(interpret_text);
3080 (void) CopyMagickString(q,value,extent);
3084 if (image_info == (ImageInfo *) NULL)
3086 value=GetImageOption(image_info,pattern);
3087 if (value != (char *) NULL)
3089 length=strlen(value);
3090 if ((size_t) (q-interpret_text+length+1) >= extent)
3093 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3094 extent+MaxTextExtent,sizeof(*interpret_text));
3095 if (interpret_text == (char *) NULL)
3097 q=interpret_text+strlen(interpret_text);
3099 (void) CopyMagickString(q,value,extent);
3113 page=GetImageBoundingBox(image,exception);
3114 q+=FormatLocaleString(q,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
3115 (double) page.width,(double) page.height,(double) page.x,(double)
3124 (void) SignatureImage(image,exception);
3125 value=GetImageProperty(image,"signature");
3126 if (value == (const char *) NULL)
3128 q+=CopyMagickString(q,value,extent);
3145 if (text != (const char *) embed_text)
3146 text=DestroyString(text);
3147 (void) SubstituteString(&interpret_text,"<","<");
3148 (void) SubstituteString(&interpret_text,">",">");
3149 return(interpret_text);
3153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3157 % R e m o v e I m a g e P r o p e r t y %
3161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3163 % RemoveImageProperty() removes a property from the image and returns its
3166 % The format of the RemoveImageProperty method is:
3168 % char *RemoveImageProperty(Image *image,const char *property)
3170 % A description of each parameter follows:
3172 % o image: the image.
3174 % o property: the image property.
3177 MagickExport char *RemoveImageProperty(Image *image,
3178 const char *property)
3183 assert(image != (Image *) NULL);
3184 assert(image->signature == MagickSignature);
3185 if (image->debug != MagickFalse)
3186 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3188 if (image->properties == (void *) NULL)
3189 return((char *) NULL);
3190 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3196 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3200 % 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 %
3204 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3206 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3207 % in conjunction with GetNextImageProperty() to iterate over all the values
3208 % associated with an image property.
3210 % The format of the ResetImagePropertyIterator method is:
3212 % ResetImagePropertyIterator(Image *image)
3214 % A description of each parameter follows:
3216 % o image: the image.
3219 MagickExport void ResetImagePropertyIterator(const Image *image)
3221 assert(image != (Image *) NULL);
3222 assert(image->signature == MagickSignature);
3223 if (image->debug != MagickFalse)
3224 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3226 if (image->properties == (void *) NULL)
3228 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3236 % S e t I m a g e P r o p e r t y %
3240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3242 % SetImageProperty() associates an value with an image property.
3244 % The format of the SetImageProperty method is:
3246 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3247 % const char *value)
3249 % A description of each parameter follows:
3251 % o image: the image.
3253 % o property: the image property.
3255 % o values: the image property values.
3258 MagickExport MagickBooleanType SetImageProperty(Image *image,
3259 const char *property,const char *value)
3270 assert(image != (Image *) NULL);
3271 assert(image->signature == MagickSignature);
3272 if (image->debug != MagickFalse)
3273 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3275 if (image->properties == (void *) NULL)
3276 image->properties=NewSplayTree(CompareSplayTreeString,
3277 RelinquishMagickMemory,RelinquishMagickMemory);
3278 if ((value == (const char *) NULL) || (*value == '\0'))
3279 return(DeleteImageProperty(image,property));
3281 exception=(&image->exception);
3287 if (LocaleCompare(property,"background") == 0)
3289 (void) QueryColorDatabase(value,&image->background_color,exception);
3292 if (LocaleCompare(property,"bias") == 0)
3294 image->bias=SiPrefixToDouble(value,QuantumRange);
3297 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3298 ConstantString(property),ConstantString(value));
3304 if (LocaleCompare(property,"colorspace") == 0)
3309 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
3313 (void) SetImageColorspace(image,(ColorspaceType) colorspace,
3317 if (LocaleCompare(property,"compose") == 0)
3322 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
3325 image->compose=(CompositeOperator) compose;
3328 if (LocaleCompare(property,"compress") == 0)
3333 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
3335 if (compression < 0)
3337 image->compression=(CompressionType) compression;
3340 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3341 ConstantString(property),ConstantString(value));
3347 if (LocaleCompare(property,"delay") == 0)
3352 flags=ParseGeometry(value,&geometry_info);
3353 if ((flags & GreaterValue) != 0)
3355 if (image->delay > (size_t) floor(geometry_info.rho+0.5))
3356 image->delay=(size_t) floor(geometry_info.rho+0.5);
3359 if ((flags & LessValue) != 0)
3361 if (image->delay < (size_t) floor(geometry_info.rho+0.5))
3362 image->ticks_per_second=(ssize_t)
3363 floor(geometry_info.sigma+0.5);
3366 image->delay=(size_t) floor(geometry_info.rho+0.5);
3367 if ((flags & SigmaValue) != 0)
3368 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
3371 if (LocaleCompare(property,"density") == 0)
3376 flags=ParseGeometry(value,&geometry_info);
3377 image->x_resolution=geometry_info.rho;
3378 image->y_resolution=geometry_info.sigma;
3379 if ((flags & SigmaValue) == 0)
3380 image->y_resolution=image->x_resolution;
3382 if (LocaleCompare(property,"depth") == 0)
3384 image->depth=StringToUnsignedLong(value);
3387 if (LocaleCompare(property,"dispose") == 0)
3392 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
3395 image->dispose=(DisposeType) dispose;
3398 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3399 ConstantString(property),ConstantString(value));
3405 if (LocaleCompare(property,"gravity") == 0)
3410 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
3413 image->gravity=(GravityType) gravity;
3416 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3417 ConstantString(property),ConstantString(value));
3423 if (LocaleCompare(property,"intent") == 0)
3428 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
3430 if (rendering_intent < 0)
3432 image->rendering_intent=(RenderingIntent) rendering_intent;
3435 if (LocaleCompare(property,"interpolate") == 0)
3440 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
3442 if (interpolate < 0)
3444 image->interpolate=(InterpolatePixelMethod) interpolate;
3447 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3448 ConstantString(property),ConstantString(value));
3454 if (LocaleCompare(property,"loop") == 0)
3456 image->iterations=StringToUnsignedLong(value);
3459 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3460 ConstantString(property),ConstantString(value));
3466 if (LocaleCompare(property,"page") == 0)
3471 geometry=GetPageGeometry(value);
3472 flags=ParseAbsoluteGeometry(geometry,&image->page);
3473 geometry=DestroyString(geometry);
3476 if (LocaleCompare(property,"profile") == 0)
3484 image_info=AcquireImageInfo();
3485 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
3486 (void) SetImageInfo(image_info,1,exception);
3487 profile=FileToStringInfo(image_info->filename,~0UL,exception);
3488 if (profile != (StringInfo *) NULL)
3489 status=SetImageProfile(image,image_info->magick,profile);
3490 image_info=DestroyImageInfo(image_info);
3493 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3494 ConstantString(property),ConstantString(value));
3500 if (LocaleCompare(property,"rendering-intent") == 0)
3505 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
3507 if (rendering_intent < 0)
3509 image->rendering_intent=(RenderingIntent) rendering_intent;
3512 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3513 ConstantString(property),ConstantString(value));
3519 if (LocaleCompare(property,"tile-offset") == 0)
3524 geometry=GetPageGeometry(value);
3525 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3526 geometry=DestroyString(geometry);
3529 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3530 ConstantString(property),ConstantString(value));
3536 if (LocaleCompare(property,"units") == 0)
3541 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
3544 image->units=(ResolutionType) units;
3547 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3548 ConstantString(property),ConstantString(value));
3553 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3554 ConstantString(property),ConstantString(value));