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 "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/magick.h"
63 #include "magick/memory_.h"
64 #include "magick/monitor.h"
65 #include "magick/montage.h"
66 #include "magick/option.h"
67 #include "magick/profile.h"
68 #include "magick/property.h"
69 #include "magick/quantum.h"
70 #include "magick/resource_.h"
71 #include "magick/splay-tree.h"
72 #include "magick/signature-private.h"
73 #include "magick/statistic.h"
74 #include "magick/string_.h"
75 #include "magick/string-private.h"
76 #include "magick/token.h"
77 #include "magick/utility.h"
78 #include "magick/version.h"
79 #include "magick/xml-tree.h"
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86 % C l o n e I m a g e P r o p e r t i e s %
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 % CloneImageProperties() clones one or more image properties.
94 % The format of the CloneImageProperties method is:
96 % MagickBooleanType CloneImageProperties(Image *image,
97 % const Image *clone_image)
99 % A description of each parameter follows:
101 % o image: the image.
103 % o clone_image: the clone image.
106 MagickExport MagickBooleanType CloneImageProperties(Image *image,
107 const Image *clone_image)
109 assert(image != (Image *) NULL);
110 assert(image->signature == MagickSignature);
111 if (image->debug != MagickFalse)
112 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
113 assert(clone_image != (const Image *) NULL);
114 assert(clone_image->signature == MagickSignature);
115 if (clone_image->debug != MagickFalse)
116 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
117 clone_image->filename);
118 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
119 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
121 image->compression=clone_image->compression;
122 image->quality=clone_image->quality;
123 image->depth=clone_image->depth;
124 image->background_color=clone_image->background_color;
125 image->border_color=clone_image->border_color;
126 image->matte_color=clone_image->matte_color;
127 image->transparent_color=clone_image->transparent_color;
128 image->gamma=clone_image->gamma;
129 image->chromaticity=clone_image->chromaticity;
130 image->rendering_intent=clone_image->rendering_intent;
131 image->black_point_compensation=clone_image->black_point_compensation;
132 image->units=clone_image->units;
133 image->montage=(char *) NULL;
134 image->directory=(char *) NULL;
135 (void) CloneString(&image->geometry,clone_image->geometry);
136 image->offset=clone_image->offset;
137 image->x_resolution=clone_image->x_resolution;
138 image->y_resolution=clone_image->y_resolution;
139 image->page=clone_image->page;
140 image->tile_offset=clone_image->tile_offset;
141 image->extract_info=clone_image->extract_info;
142 image->bias=clone_image->bias;
143 image->filter=clone_image->filter;
144 image->blur=clone_image->blur;
145 image->fuzz=clone_image->fuzz;
146 image->interlace=clone_image->interlace;
147 image->interpolate=clone_image->interpolate;
148 image->endian=clone_image->endian;
149 image->gravity=clone_image->gravity;
150 image->compose=clone_image->compose;
151 image->scene=clone_image->scene;
152 image->orientation=clone_image->orientation;
153 image->dispose=clone_image->dispose;
154 image->delay=clone_image->delay;
155 image->ticks_per_second=clone_image->ticks_per_second;
156 image->iterations=clone_image->iterations;
157 image->total_colors=clone_image->total_colors;
158 image->taint=clone_image->taint;
159 image->progress_monitor=clone_image->progress_monitor;
160 image->client_data=clone_image->client_data;
161 image->start_loop=clone_image->start_loop;
162 image->error=clone_image->error;
163 image->signature=clone_image->signature;
164 if (clone_image->properties != (void *) NULL)
166 if (image->properties != (void *) NULL)
167 DestroyImageProperties(image);
168 image->properties=CloneSplayTree((SplayTreeInfo *)
169 clone_image->properties,(void *(*)(void *)) ConstantString,
170 (void *(*)(void *)) ConstantString);
176 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 % D e f i n e I m a g e P r o p e r t y %
184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186 % DefineImageProperty() associates a key/value pair with an image property.
188 % The format of the DefineImageProperty method is:
190 % MagickBooleanType DefineImageProperty(Image *image,
191 % const char *property)
193 % A description of each parameter follows:
195 % o image: the image.
197 % o property: the image property.
200 MagickExport MagickBooleanType DefineImageProperty(Image *image,
201 const char *property)
205 value[MaxTextExtent];
210 assert(image != (Image *) NULL);
211 assert(property != (const char *) NULL);
212 (void) CopyMagickString(key,property,MaxTextExtent-1);
213 for (p=key; *p != '\0'; p++)
218 (void) CopyMagickString(value,p+1,MaxTextExtent);
220 return(SetImageProperty(image,key,value));
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228 % D e l e t e I m a g e P r o p e r t y %
232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234 % DeleteImageProperty() deletes an image property.
236 % The format of the DeleteImageProperty method is:
238 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
240 % A description of each parameter follows:
242 % o image: the image.
244 % o property: the image property.
247 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
248 const char *property)
250 assert(image != (Image *) NULL);
251 assert(image->signature == MagickSignature);
252 if (image->debug != MagickFalse)
253 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
255 if (image->properties == (void *) NULL)
257 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
261 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265 % D e s t r o y I m a g e P r o p e r t i e s %
269 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271 % DestroyImageProperties() releases memory associated with image property
274 % The format of the DestroyDefines method is:
276 % void DestroyImageProperties(Image *image)
278 % A description of each parameter follows:
280 % o image: the image.
283 MagickExport void DestroyImageProperties(Image *image)
285 assert(image != (Image *) NULL);
286 assert(image->signature == MagickSignature);
287 if (image->debug != MagickFalse)
288 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
290 if (image->properties != (void *) NULL)
291 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
300 % F o r m a t I m a g e P r o p e r t y %
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306 % FormatImageProperty() permits formatted property/value pairs to be saved as
309 % The format of the FormatImageProperty method is:
311 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
312 % const char *format,...)
314 % A description of each parameter follows.
316 % o image: The image.
318 % o property: The attribute property.
320 % o format: A string describing the format to use to write the remaining
325 MagickExport MagickBooleanType FormatImagePropertyList(Image *image,
326 const char *property,const char *format,va_list operands)
329 value[MaxTextExtent];
334 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
335 n=vsnprintf(value,MaxTextExtent,format,operands);
337 n=vsprintf(value,format,operands);
340 value[MaxTextExtent-1]='\0';
341 return(SetImageProperty(image,property,value));
344 MagickExport MagickBooleanType FormatImageProperty(Image *image,
345 const char *property,const char *format,...)
353 va_start(operands,format);
354 status=FormatImagePropertyList(image,property,format,operands);
360 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364 % G e t I m a g e P r o p e r t y %
368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370 % GetImageProperty() gets a value associated with an image property.
372 % The format of the GetImageProperty method is:
374 % const char *GetImageProperty(const Image *image,const char *key)
376 % A description of each parameter follows:
378 % o image: the image.
385 *TracePSClippath(const unsigned char *,size_t,const size_t,
387 *TraceSVGClippath(const unsigned char *,size_t,const size_t,
390 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
410 profile=GetImageProfile(image,"iptc");
411 if (profile == (StringInfo *) NULL)
412 profile=GetImageProfile(image,"8bim");
413 if (profile == (StringInfo *) NULL)
415 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
418 attribute=(char *) NULL;
419 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
422 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
424 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
425 length|=GetStringInfoDatum(profile)[i+4];
426 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
427 ((long) GetStringInfoDatum(profile)[i+2] == record))
429 message=(char *) NULL;
431 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
432 if (message != (char *) NULL)
434 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
435 profile)+i+5,length+1);
436 (void) ConcatenateString(&attribute,message);
437 (void) ConcatenateString(&attribute,";");
438 message=DestroyString(message);
443 if ((attribute == (char *) NULL) || (*attribute == ';'))
445 if (attribute != (char *) NULL)
446 attribute=DestroyString(attribute);
449 attribute[strlen(attribute)-1]='\0';
450 (void) SetImageProperty((Image *) image,key,(const char *) attribute);
451 attribute=DestroyString(attribute);
455 static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
462 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
474 static inline size_t ReadPropertyMSBLong(const unsigned char **p,
491 for (i=0; i < 4; i++)
495 buffer[i]=(unsigned char) c;
497 value=(size_t) (buffer[0] << 24);
498 value|=buffer[1] << 16;
499 value|=buffer[2] << 8;
501 return(value & 0xffffffff);
504 static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
520 return((unsigned short) ~0U);
521 for (i=0; i < 2; i++)
525 buffer[i]=(unsigned char) c;
527 value=(unsigned short) (buffer[0] << 8);
529 return((unsigned short) (value & 0xffff));
532 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
536 format[MaxTextExtent],
565 There are no newlines in path names, so it's safe as terminator.
567 profile=GetImageProfile(image,"8bim");
568 if (profile == (StringInfo *) NULL)
570 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name,
572 if ((count != 2) && (count != 3) && (count != 4))
575 (void) CopyMagickString(format,"SVG",MaxTextExtent);
580 sub_number=(ssize_t) StringToLong(&name[1]);
581 sub_number=MagickMax(sub_number,1L);
582 resource=(char *) NULL;
584 length=GetStringInfoLength(profile);
585 info=GetStringInfoDatum(profile);
586 while ((length > 0) && (status == MagickFalse))
588 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
590 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
592 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
594 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
596 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
597 if (id < (ssize_t) start)
599 if (id > (ssize_t) stop)
601 if (resource != (char *) NULL)
602 resource=DestroyString(resource);
603 count=(ssize_t) ReadPropertyByte(&info,&length);
604 if ((count != 0) && ((size_t) count <= length))
606 resource=(char *) NULL;
607 if (~(1UL*count) >= MaxTextExtent)
608 resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
610 if (resource != (char *) NULL)
612 for (i=0; i < (ssize_t) count; i++)
613 resource[i]=(char) ReadPropertyByte(&info,&length);
614 resource[count]='\0';
617 if ((count & 0x01) == 0)
618 (void) ReadPropertyByte(&info,&length);
619 count=(ssize_t) ((int) ReadPropertyMSBLong(&info,&length));
620 if ((*name != '\0') && (*name != '#'))
621 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
624 No name match, scroll forward and try next.
630 if ((*name == '#') && (sub_number != 1))
633 No numbered match, scroll forward and try next.
641 We have the resource of interest.
643 attribute=(char *) NULL;
644 if (~(1UL*count) >= MaxTextExtent)
645 attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
647 if (attribute != (char *) NULL)
649 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
650 attribute[count]='\0';
653 if ((id <= 1999) || (id >= 2999))
654 (void) SetImageProperty((Image *) image,key,(const char *)
661 if (LocaleCompare(format,"svg") == 0)
662 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
663 image->columns,image->rows);
665 path=TracePSClippath((unsigned char *) attribute,(size_t) count,
666 image->columns,image->rows);
667 (void) SetImageProperty((Image *) image,key,(const char *) path);
668 path=DestroyString(path);
670 attribute=DestroyString(attribute);
674 if (resource != (char *) NULL)
675 resource=DestroyString(resource);
679 static inline unsigned short ReadPropertyShort(const EndianType endian,
680 const unsigned char *buffer)
685 if (endian == MSBEndian)
687 value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
688 ((unsigned char *) buffer)[1]);
689 return((unsigned short) (value & 0xffff));
691 value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
692 return((unsigned short) (value & 0xffff));
695 static inline size_t ReadPropertyLong(const EndianType endian,
696 const unsigned char *buffer)
701 if (endian == MSBEndian)
703 value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
704 (buffer[2] << 8) | buffer[3]);
705 return((size_t) (value & 0xffffffff));
707 value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
708 (buffer[1] << 8 ) | (buffer[0]));
709 return((size_t) (value & 0xffffffff));
712 static MagickBooleanType GetEXIFProperty(const Image *image,
713 const char *property)
715 #define MaxDirectoryStack 16
716 #define EXIF_DELIMITER "\n"
717 #define EXIF_NUM_FORMATS 12
718 #define EXIF_FMT_BYTE 1
719 #define EXIF_FMT_STRING 2
720 #define EXIF_FMT_USHORT 3
721 #define EXIF_FMT_ULONG 4
722 #define EXIF_FMT_URATIONAL 5
723 #define EXIF_FMT_SBYTE 6
724 #define EXIF_FMT_UNDEFINED 7
725 #define EXIF_FMT_SSHORT 8
726 #define EXIF_FMT_SLONG 9
727 #define EXIF_FMT_SRATIONAL 10
728 #define EXIF_FMT_SINGLE 11
729 #define EXIF_FMT_DOUBLE 12
730 #define TAG_EXIF_OFFSET 0x8769
731 #define TAG_GPS_OFFSET 0x8825
732 #define TAG_INTEROP_OFFSET 0xa005
734 #define EXIFMultipleValues(size, format, arg) \
747 for (component=0; component < components; component++) \
749 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
751 if (length >= MaxTextExtent - 1) \
752 length=MaxTextExtent-1; \
756 buffer[length-2]='\0'; \
757 value=AcquireString(buffer); \
760 #define EXIFMultipleFractions(size, format, arg1, arg2) \
773 for (component=0; component < components; component++) \
775 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
776 format", ",arg1, arg2); \
777 if (length >= MaxTextExtent - 1) \
778 length=MaxTextExtent-1; \
782 buffer[length-2]='\0'; \
783 value=AcquireString(buffer); \
786 typedef struct _DirectoryInfo
796 typedef struct _TagInfo
808 { 0x001, "exif:InteroperabilityIndex" },
809 { 0x002, "exif:InteroperabilityVersion" },
810 { 0x100, "exif:ImageWidth" },
811 { 0x101, "exif:ImageLength" },
812 { 0x102, "exif:BitsPerSample" },
813 { 0x103, "exif:Compression" },
814 { 0x106, "exif:PhotometricInterpretation" },
815 { 0x10a, "exif:FillOrder" },
816 { 0x10d, "exif:DocumentName" },
817 { 0x10e, "exif:ImageDescription" },
818 { 0x10f, "exif:Make" },
819 { 0x110, "exif:Model" },
820 { 0x111, "exif:StripOffsets" },
821 { 0x112, "exif:Orientation" },
822 { 0x115, "exif:SamplesPerPixel" },
823 { 0x116, "exif:RowsPerStrip" },
824 { 0x117, "exif:StripByteCounts" },
825 { 0x11a, "exif:XResolution" },
826 { 0x11b, "exif:YResolution" },
827 { 0x11c, "exif:PlanarConfiguration" },
828 { 0x11d, "exif:PageName" },
829 { 0x11e, "exif:XPosition" },
830 { 0x11f, "exif:YPosition" },
831 { 0x118, "exif:MinSampleValue" },
832 { 0x119, "exif:MaxSampleValue" },
833 { 0x120, "exif:FreeOffsets" },
834 { 0x121, "exif:FreeByteCounts" },
835 { 0x122, "exif:GrayResponseUnit" },
836 { 0x123, "exif:GrayResponseCurve" },
837 { 0x124, "exif:T4Options" },
838 { 0x125, "exif:T6Options" },
839 { 0x128, "exif:ResolutionUnit" },
840 { 0x12d, "exif:TransferFunction" },
841 { 0x131, "exif:Software" },
842 { 0x132, "exif:DateTime" },
843 { 0x13b, "exif:Artist" },
844 { 0x13e, "exif:WhitePoint" },
845 { 0x13f, "exif:PrimaryChromaticities" },
846 { 0x140, "exif:ColorMap" },
847 { 0x141, "exif:HalfToneHints" },
848 { 0x142, "exif:TileWidth" },
849 { 0x143, "exif:TileLength" },
850 { 0x144, "exif:TileOffsets" },
851 { 0x145, "exif:TileByteCounts" },
852 { 0x14a, "exif:SubIFD" },
853 { 0x14c, "exif:InkSet" },
854 { 0x14d, "exif:InkNames" },
855 { 0x14e, "exif:NumberOfInks" },
856 { 0x150, "exif:DotRange" },
857 { 0x151, "exif:TargetPrinter" },
858 { 0x152, "exif:ExtraSample" },
859 { 0x153, "exif:SampleFormat" },
860 { 0x154, "exif:SMinSampleValue" },
861 { 0x155, "exif:SMaxSampleValue" },
862 { 0x156, "exif:TransferRange" },
863 { 0x157, "exif:ClipPath" },
864 { 0x158, "exif:XClipPathUnits" },
865 { 0x159, "exif:YClipPathUnits" },
866 { 0x15a, "exif:Indexed" },
867 { 0x15b, "exif:JPEGTables" },
868 { 0x15f, "exif:OPIProxy" },
869 { 0x200, "exif:JPEGProc" },
870 { 0x201, "exif:JPEGInterchangeFormat" },
871 { 0x202, "exif:JPEGInterchangeFormatLength" },
872 { 0x203, "exif:JPEGRestartInterval" },
873 { 0x205, "exif:JPEGLosslessPredictors" },
874 { 0x206, "exif:JPEGPointTransforms" },
875 { 0x207, "exif:JPEGQTables" },
876 { 0x208, "exif:JPEGDCTables" },
877 { 0x209, "exif:JPEGACTables" },
878 { 0x211, "exif:YCbCrCoefficients" },
879 { 0x212, "exif:YCbCrSubSampling" },
880 { 0x213, "exif:YCbCrPositioning" },
881 { 0x214, "exif:ReferenceBlackWhite" },
882 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
883 { 0x301, "exif:Gamma" },
884 { 0x302, "exif:ICCProfileDescriptor" },
885 { 0x303, "exif:SRGBRenderingIntent" },
886 { 0x320, "exif:ImageTitle" },
887 { 0x5001, "exif:ResolutionXUnit" },
888 { 0x5002, "exif:ResolutionYUnit" },
889 { 0x5003, "exif:ResolutionXLengthUnit" },
890 { 0x5004, "exif:ResolutionYLengthUnit" },
891 { 0x5005, "exif:PrintFlags" },
892 { 0x5006, "exif:PrintFlagsVersion" },
893 { 0x5007, "exif:PrintFlagsCrop" },
894 { 0x5008, "exif:PrintFlagsBleedWidth" },
895 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
896 { 0x500A, "exif:HalftoneLPI" },
897 { 0x500B, "exif:HalftoneLPIUnit" },
898 { 0x500C, "exif:HalftoneDegree" },
899 { 0x500D, "exif:HalftoneShape" },
900 { 0x500E, "exif:HalftoneMisc" },
901 { 0x500F, "exif:HalftoneScreen" },
902 { 0x5010, "exif:JPEGQuality" },
903 { 0x5011, "exif:GridSize" },
904 { 0x5012, "exif:ThumbnailFormat" },
905 { 0x5013, "exif:ThumbnailWidth" },
906 { 0x5014, "exif:ThumbnailHeight" },
907 { 0x5015, "exif:ThumbnailColorDepth" },
908 { 0x5016, "exif:ThumbnailPlanes" },
909 { 0x5017, "exif:ThumbnailRawBytes" },
910 { 0x5018, "exif:ThumbnailSize" },
911 { 0x5019, "exif:ThumbnailCompressedSize" },
912 { 0x501a, "exif:ColorTransferFunction" },
913 { 0x501b, "exif:ThumbnailData" },
914 { 0x5020, "exif:ThumbnailImageWidth" },
915 { 0x5021, "exif:ThumbnailImageHeight" },
916 { 0x5022, "exif:ThumbnailBitsPerSample" },
917 { 0x5023, "exif:ThumbnailCompression" },
918 { 0x5024, "exif:ThumbnailPhotometricInterp" },
919 { 0x5025, "exif:ThumbnailImageDescription" },
920 { 0x5026, "exif:ThumbnailEquipMake" },
921 { 0x5027, "exif:ThumbnailEquipModel" },
922 { 0x5028, "exif:ThumbnailStripOffsets" },
923 { 0x5029, "exif:ThumbnailOrientation" },
924 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
925 { 0x502b, "exif:ThumbnailRowsPerStrip" },
926 { 0x502c, "exif:ThumbnailStripBytesCount" },
927 { 0x502d, "exif:ThumbnailResolutionX" },
928 { 0x502e, "exif:ThumbnailResolutionY" },
929 { 0x502f, "exif:ThumbnailPlanarConfig" },
930 { 0x5030, "exif:ThumbnailResolutionUnit" },
931 { 0x5031, "exif:ThumbnailTransferFunction" },
932 { 0x5032, "exif:ThumbnailSoftwareUsed" },
933 { 0x5033, "exif:ThumbnailDateTime" },
934 { 0x5034, "exif:ThumbnailArtist" },
935 { 0x5035, "exif:ThumbnailWhitePoint" },
936 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
937 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
938 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
939 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
940 { 0x503A, "exif:ThumbnailRefBlackWhite" },
941 { 0x503B, "exif:ThumbnailCopyRight" },
942 { 0x5090, "exif:LuminanceTable" },
943 { 0x5091, "exif:ChrominanceTable" },
944 { 0x5100, "exif:FrameDelay" },
945 { 0x5101, "exif:LoopCount" },
946 { 0x5110, "exif:PixelUnit" },
947 { 0x5111, "exif:PixelPerUnitX" },
948 { 0x5112, "exif:PixelPerUnitY" },
949 { 0x5113, "exif:PaletteHistogram" },
950 { 0x1000, "exif:RelatedImageFileFormat" },
951 { 0x1001, "exif:RelatedImageLength" },
952 { 0x1002, "exif:RelatedImageWidth" },
953 { 0x800d, "exif:ImageID" },
954 { 0x80e3, "exif:Matteing" },
955 { 0x80e4, "exif:DataType" },
956 { 0x80e5, "exif:ImageDepth" },
957 { 0x80e6, "exif:TileDepth" },
958 { 0x828d, "exif:CFARepeatPatternDim" },
959 { 0x828e, "exif:CFAPattern2" },
960 { 0x828f, "exif:BatteryLevel" },
961 { 0x8298, "exif:Copyright" },
962 { 0x829a, "exif:ExposureTime" },
963 { 0x829d, "exif:FNumber" },
964 { 0x83bb, "exif:IPTC/NAA" },
965 { 0x84e3, "exif:IT8RasterPadding" },
966 { 0x84e5, "exif:IT8ColorTable" },
967 { 0x8649, "exif:ImageResourceInformation" },
968 { 0x8769, "exif:ExifOffset" },
969 { 0x8773, "exif:InterColorProfile" },
970 { 0x8822, "exif:ExposureProgram" },
971 { 0x8824, "exif:SpectralSensitivity" },
972 { 0x8825, "exif:GPSInfo" },
973 { 0x8827, "exif:ISOSpeedRatings" },
974 { 0x8828, "exif:OECF" },
975 { 0x8829, "exif:Interlace" },
976 { 0x882a, "exif:TimeZoneOffset" },
977 { 0x882b, "exif:SelfTimerMode" },
978 { 0x9000, "exif:ExifVersion" },
979 { 0x9003, "exif:DateTimeOriginal" },
980 { 0x9004, "exif:DateTimeDigitized" },
981 { 0x9101, "exif:ComponentsConfiguration" },
982 { 0x9102, "exif:CompressedBitsPerPixel" },
983 { 0x9201, "exif:ShutterSpeedValue" },
984 { 0x9202, "exif:ApertureValue" },
985 { 0x9203, "exif:BrightnessValue" },
986 { 0x9204, "exif:ExposureBiasValue" },
987 { 0x9205, "exif:MaxApertureValue" },
988 { 0x9206, "exif:SubjectDistance" },
989 { 0x9207, "exif:MeteringMode" },
990 { 0x9208, "exif:LightSource" },
991 { 0x9209, "exif:Flash" },
992 { 0x920a, "exif:FocalLength" },
993 { 0x920b, "exif:FlashEnergy" },
994 { 0x920c, "exif:SpatialFrequencyResponse" },
995 { 0x920d, "exif:Noise" },
996 { 0x9211, "exif:ImageNumber" },
997 { 0x9212, "exif:SecurityClassification" },
998 { 0x9213, "exif:ImageHistory" },
999 { 0x9214, "exif:SubjectArea" },
1000 { 0x9215, "exif:ExposureIndex" },
1001 { 0x9216, "exif:TIFF-EPStandardID" },
1002 { 0x927c, "exif:MakerNote" },
1003 { 0x9C9b, "exif:WinXP-Title" },
1004 { 0x9C9c, "exif:WinXP-Comments" },
1005 { 0x9C9d, "exif:WinXP-Author" },
1006 { 0x9C9e, "exif:WinXP-Keywords" },
1007 { 0x9C9f, "exif:WinXP-Subject" },
1008 { 0x9286, "exif:UserComment" },
1009 { 0x9290, "exif:SubSecTime" },
1010 { 0x9291, "exif:SubSecTimeOriginal" },
1011 { 0x9292, "exif:SubSecTimeDigitized" },
1012 { 0xa000, "exif:FlashPixVersion" },
1013 { 0xa001, "exif:ColorSpace" },
1014 { 0xa002, "exif:ExifImageWidth" },
1015 { 0xa003, "exif:ExifImageLength" },
1016 { 0xa004, "exif:RelatedSoundFile" },
1017 { 0xa005, "exif:InteroperabilityOffset" },
1018 { 0xa20b, "exif:FlashEnergy" },
1019 { 0xa20c, "exif:SpatialFrequencyResponse" },
1020 { 0xa20d, "exif:Noise" },
1021 { 0xa20e, "exif:FocalPlaneXResolution" },
1022 { 0xa20f, "exif:FocalPlaneYResolution" },
1023 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1024 { 0xa214, "exif:SubjectLocation" },
1025 { 0xa215, "exif:ExposureIndex" },
1026 { 0xa216, "exif:TIFF/EPStandardID" },
1027 { 0xa217, "exif:SensingMethod" },
1028 { 0xa300, "exif:FileSource" },
1029 { 0xa301, "exif:SceneType" },
1030 { 0xa302, "exif:CFAPattern" },
1031 { 0xa401, "exif:CustomRendered" },
1032 { 0xa402, "exif:ExposureMode" },
1033 { 0xa403, "exif:WhiteBalance" },
1034 { 0xa404, "exif:DigitalZoomRatio" },
1035 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1036 { 0xa406, "exif:SceneCaptureType" },
1037 { 0xa407, "exif:GainControl" },
1038 { 0xa408, "exif:Contrast" },
1039 { 0xa409, "exif:Saturation" },
1040 { 0xa40a, "exif:Sharpness" },
1041 { 0xa40b, "exif:DeviceSettingDescription" },
1042 { 0xa40c, "exif:SubjectDistanceRange" },
1043 { 0xa420, "exif:ImageUniqueID" },
1044 { 0xc4a5, "exif:PrintImageMatching" },
1045 { 0xa500, "exif:Gamma" },
1046 { 0xc640, "exif:CR2Slice" },
1047 { 0x10000, "exif:GPSVersionID" },
1048 { 0x10001, "exif:GPSLatitudeRef" },
1049 { 0x10002, "exif:GPSLatitude" },
1050 { 0x10003, "exif:GPSLongitudeRef" },
1051 { 0x10004, "exif:GPSLongitude" },
1052 { 0x10005, "exif:GPSAltitudeRef" },
1053 { 0x10006, "exif:GPSAltitude" },
1054 { 0x10007, "exif:GPSTimeStamp" },
1055 { 0x10008, "exif:GPSSatellites" },
1056 { 0x10009, "exif:GPSStatus" },
1057 { 0x1000a, "exif:GPSMeasureMode" },
1058 { 0x1000b, "exif:GPSDop" },
1059 { 0x1000c, "exif:GPSSpeedRef" },
1060 { 0x1000d, "exif:GPSSpeed" },
1061 { 0x1000e, "exif:GPSTrackRef" },
1062 { 0x1000f, "exif:GPSTrack" },
1063 { 0x10010, "exif:GPSImgDirectionRef" },
1064 { 0x10011, "exif:GPSImgDirection" },
1065 { 0x10012, "exif:GPSMapDatum" },
1066 { 0x10013, "exif:GPSDestLatitudeRef" },
1067 { 0x10014, "exif:GPSDestLatitude" },
1068 { 0x10015, "exif:GPSDestLongitudeRef" },
1069 { 0x10016, "exif:GPSDestLongitude" },
1070 { 0x10017, "exif:GPSDestBearingRef" },
1071 { 0x10018, "exif:GPSDestBearing" },
1072 { 0x10019, "exif:GPSDestDistanceRef" },
1073 { 0x1001a, "exif:GPSDestDistance" },
1074 { 0x1001b, "exif:GPSProcessingMethod" },
1075 { 0x1001c, "exif:GPSAreaInformation" },
1076 { 0x1001d, "exif:GPSDateStamp" },
1077 { 0x1001e, "exif:GPSDifferential" },
1089 directory_stack[MaxDirectoryStack];
1115 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1118 If EXIF data exists, then try to parse the request for a tag.
1120 profile=GetImageProfile(image,"exif");
1121 if (profile == (StringInfo *) NULL)
1122 return(MagickFalse);
1123 if ((property == (const char *) NULL) || (*property == '\0'))
1124 return(MagickFalse);
1125 while (isspace((int) ((unsigned char) *property)) != 0)
1129 switch (*(property+5))
1134 Caller has asked for all the tags in the EXIF data.
1137 all=1; /* return the data in description=value format */
1143 all=2; /* return the data in tagid=value format */
1156 Check for a hex based tag specification first.
1158 tag=(*(property+5) == '@') ? 1UL : 0UL;
1162 return(MagickFalse);
1164 Parse tag specification as a hex number.
1169 for (i=(ssize_t) n-1L; i >= 0; i--)
1173 if ((c >= '0') && (c <= '9'))
1176 if ((c >= 'A') && (c <= 'F'))
1179 if ((c >= 'a') && (c <= 'f'))
1182 return(MagickFalse);
1184 } while (*property != '\0');
1190 Try to match the text with a tag name instead.
1194 if (EXIFTag[i].tag == 0)
1196 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1198 tag=(size_t) EXIFTag[i].tag;
1206 return(MagickFalse);
1207 length=GetStringInfoLength(profile);
1208 exif=GetStringInfoDatum(profile);
1211 if (ReadPropertyByte(&exif,&length) != 0x45)
1213 if (ReadPropertyByte(&exif,&length) != 0x78)
1215 if (ReadPropertyByte(&exif,&length) != 0x69)
1217 if (ReadPropertyByte(&exif,&length) != 0x66)
1219 if (ReadPropertyByte(&exif,&length) != 0x00)
1221 if (ReadPropertyByte(&exif,&length) != 0x00)
1226 return(MagickFalse);
1227 id=(ssize_t) ReadPropertyShort(LSBEndian,exif);
1235 return(MagickFalse);
1236 if (ReadPropertyShort(endian,exif+2) != 0x002a)
1237 return(MagickFalse);
1239 This the offset to the first IFD.
1241 offset=(ssize_t) ((int) ReadPropertyLong(endian,exif+4));
1242 if ((size_t) offset >= length)
1243 return(MagickFalse);
1245 Set the pointer to the first IFD and follow it were it leads.
1248 directory=exif+offset;
1255 If there is anything on the stack then pop it off.
1260 directory=directory_stack[level].directory;
1261 entry=directory_stack[level].entry;
1262 tag_offset=directory_stack[level].offset;
1265 Determine how many entries there are in the current IFD.
1267 number_entries=ReadPropertyShort(endian,directory);
1268 for ( ; entry < number_entries; entry++)
1270 register unsigned char
1281 q=(unsigned char *) (directory+2+(12*entry));
1282 tag_value=(ssize_t) (ReadPropertyShort(endian,q)+tag_offset);
1283 format=(size_t) ReadPropertyShort(endian,q+2);
1284 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1286 components=(ssize_t) ((int) ReadPropertyLong(endian,q+4));
1287 number_bytes=(size_t) components*tag_bytes[format];
1288 if (number_bytes <= 4)
1296 The directory entry contains an offset.
1298 offset=(ssize_t) ((int) ReadPropertyLong(endian,q+8));
1299 if ((size_t) (offset+number_bytes) > length)
1301 p=(unsigned char *) (exif+offset);
1303 if ((all != 0) || (tag == (size_t) tag_value))
1306 buffer[MaxTextExtent],
1312 case EXIF_FMT_UNDEFINED:
1314 EXIFMultipleValues(1,"%.20g",(double)
1315 (*(unsigned char *) p1));
1318 case EXIF_FMT_SBYTE:
1320 EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1323 case EXIF_FMT_SSHORT:
1325 EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1));
1328 case EXIF_FMT_USHORT:
1330 EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1));
1333 case EXIF_FMT_ULONG:
1335 EXIFMultipleValues(4,"%.20g",(double)
1336 ReadPropertyLong(endian,p1));
1339 case EXIF_FMT_SLONG:
1341 EXIFMultipleValues(4,"%.20g",(double)
1342 ReadPropertyLong(endian,p1));
1345 case EXIF_FMT_URATIONAL:
1347 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1348 ReadPropertyLong(endian,p1),(double)
1349 ReadPropertyLong(endian,p1+4));
1352 case EXIF_FMT_SRATIONAL:
1354 EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1355 ReadPropertyLong(endian,p1),(double)
1356 ReadPropertyLong(endian,p1+4));
1359 case EXIF_FMT_SINGLE:
1361 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1364 case EXIF_FMT_DOUBLE:
1366 EXIFMultipleValues(8,"%f",*(double *) p1);
1370 case EXIF_FMT_STRING:
1372 value=(char *) NULL;
1373 if (~(1UL*number_bytes) >= 1)
1374 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1376 if (value != (char *) NULL)
1381 for (i=0; i < (ssize_t) number_bytes; i++)
1384 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1385 value[i]=(char) p[i];
1392 if (value != (char *) NULL)
1400 (void) CopyMagickString(key,property,MaxTextExtent);
1411 description="unknown";
1414 if (EXIFTag[i].tag == 0)
1416 if ((ssize_t) EXIFTag[i].tag == tag_value)
1418 description=EXIFTag[i].description;
1422 (void) FormatMagickString(key,MaxTextExtent,"%s",
1428 if (tag_value < 0x10000)
1429 (void) FormatMagickString(key,MaxTextExtent,"#%04lx",
1430 (unsigned long) tag_value);
1432 if (tag_value < 0x20000)
1433 (void) FormatMagickString(key,MaxTextExtent,"@%04lx",
1434 (unsigned long) (tag_value & 0xffff));
1436 (void) FormatMagickString(key,MaxTextExtent,"unknown");
1440 p=(const char *) NULL;
1441 if (image->properties != (void *) NULL)
1442 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1443 image->properties,key);
1444 if (p == (const char *) NULL)
1445 (void) SetImageProperty((Image *) image,key,value);
1446 value=DestroyString(value);
1450 if ((tag_value == TAG_EXIF_OFFSET) ||
1451 (tag_value == TAG_INTEROP_OFFSET) ||
1452 (tag_value == TAG_GPS_OFFSET))
1457 offset=(size_t) ReadPropertyLong(endian,p);
1458 if ((offset < length) && (level < (MaxDirectoryStack-2)))
1463 tag_offset1=(tag_value == TAG_GPS_OFFSET) ? 0x10000UL : 0UL;
1464 directory_stack[level].directory=directory;
1466 directory_stack[level].entry=entry;
1467 directory_stack[level].offset=tag_offset;
1469 directory_stack[level].directory=exif+offset;
1470 directory_stack[level].offset=tag_offset1;
1471 directory_stack[level].entry=0;
1473 if ((directory+2+(12*number_entries)) > (exif+length))
1475 offset=(size_t) ReadPropertyLong(endian,directory+2+(12*
1477 if ((offset != 0) && (offset < length) &&
1478 (level < (MaxDirectoryStack-2)))
1480 directory_stack[level].directory=exif+offset;
1481 directory_stack[level].entry=0;
1482 directory_stack[level].offset=tag_offset1;
1489 } while (level > 0);
1493 static MagickBooleanType GetXMPProperty(const Image *image,
1494 const char *property)
1518 profile=GetImageProfile(image,"xmp");
1519 if (profile == (StringInfo *) NULL)
1520 return(MagickFalse);
1521 if ((property == (const char *) NULL) || (*property == '\0'))
1522 return(MagickFalse);
1523 xmp_profile=StringInfoToString(profile);
1524 if (xmp_profile == (char *) NULL)
1525 return(MagickFalse);
1526 for (p=xmp_profile; *p != '\0'; p++)
1527 if ((*p == '<') && (*(p+1) == 'x'))
1529 exception=AcquireExceptionInfo();
1530 xmp=NewXMLTree((char *) p,exception);
1531 xmp_profile=DestroyString(xmp_profile);
1532 exception=DestroyExceptionInfo(exception);
1533 if (xmp == (XMLTreeInfo *) NULL)
1534 return(MagickFalse);
1536 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1537 if (rdf != (XMLTreeInfo *) NULL)
1539 if (image->properties == (void *) NULL)
1540 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1541 RelinquishMagickMemory,RelinquishMagickMemory);
1542 description=GetXMLTreeChild(rdf,"rdf:Description");
1543 while (description != (XMLTreeInfo *) NULL)
1545 node=GetXMLTreeChild(description,(const char *) NULL);
1546 while (node != (XMLTreeInfo *) NULL)
1548 child=GetXMLTreeChild(node,(const char *) NULL);
1549 if (child == (XMLTreeInfo *) NULL)
1550 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1551 ConstantString(GetXMLTreeTag(node)),
1552 ConstantString(GetXMLTreeContent(node)));
1553 while (child != (XMLTreeInfo *) NULL)
1555 if (LocaleCompare(GetXMLTreeTag(child),"rdf:Seq") != 0)
1556 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1557 ConstantString(GetXMLTreeTag(child)),
1558 ConstantString(GetXMLTreeContent(child)));
1559 child=GetXMLTreeSibling(child);
1561 node=GetXMLTreeSibling(node);
1563 description=GetNextXMLTreeTag(description);
1566 xmp=DestroyXMLTree(xmp);
1570 static char *TracePSClippath(const unsigned char *blob,size_t length,
1571 const size_t magick_unused(columns),
1572 const size_t magick_unused(rows))
1595 path=AcquireString((char *) NULL);
1596 if (path == (char *) NULL)
1597 return((char *) NULL);
1598 message=AcquireString((char *) NULL);
1599 (void) FormatMagickString(message,MaxTextExtent,"/ClipImage\n");
1600 (void) ConcatenateString(&path,message);
1601 (void) FormatMagickString(message,MaxTextExtent,"{\n");
1602 (void) ConcatenateString(&path,message);
1603 (void) FormatMagickString(message,MaxTextExtent," /c {curveto} bind def\n");
1604 (void) ConcatenateString(&path,message);
1605 (void) FormatMagickString(message,MaxTextExtent," /l {lineto} bind def\n");
1606 (void) ConcatenateString(&path,message);
1607 (void) FormatMagickString(message,MaxTextExtent," /m {moveto} bind def\n");
1608 (void) ConcatenateString(&path,message);
1609 (void) FormatMagickString(message,MaxTextExtent,
1610 " /v {currentpoint 6 2 roll curveto} bind def\n");
1611 (void) ConcatenateString(&path,message);
1612 (void) FormatMagickString(message,MaxTextExtent,
1613 " /y {2 copy curveto} bind def\n");
1614 (void) ConcatenateString(&path,message);
1615 (void) FormatMagickString(message,MaxTextExtent,
1616 " /z {closepath} bind def\n");
1617 (void) ConcatenateString(&path,message);
1618 (void) FormatMagickString(message,MaxTextExtent," newpath\n");
1619 (void) ConcatenateString(&path,message);
1621 The clipping path format is defined in "Adobe Photoshop File
1622 Formats Specification" version 6.0 downloadable from adobe.com.
1624 (void) ResetMagickMemory(point,0,sizeof(point));
1625 (void) ResetMagickMemory(first,0,sizeof(first));
1626 (void) ResetMagickMemory(last,0,sizeof(last));
1628 in_subpath=MagickFalse;
1631 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1637 if (knot_count != 0)
1644 Expected subpath length record.
1646 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1656 if (knot_count == 0)
1659 Unexpected subpath knot
1668 for (i=0; i < 3; i++)
1674 yy=ReadPropertyMSBLong(&blob,&length);
1675 xx=ReadPropertyMSBLong(&blob,&length);
1677 if (xx > 2147483647)
1678 x=(ssize_t) xx-4294967295-1;
1680 if (yy > 2147483647)
1681 y=(ssize_t) yy-4294967295-1;
1682 point[i].x=(double) x/4096/4096;
1683 point[i].y=1.0-(double) y/4096/4096;
1685 if (in_subpath == MagickFalse)
1687 (void) FormatMagickString(message,MaxTextExtent," %g %g m\n",
1688 point[1].x,point[1].y);
1689 for (i=0; i < 3; i++)
1698 Handle special cases when Bezier curves are used to describe
1699 corners and straight lines.
1701 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1702 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1703 (void) FormatMagickString(message,MaxTextExtent,
1704 " %g %g l\n",point[1].x,point[1].y);
1706 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1707 (void) FormatMagickString(message,MaxTextExtent,
1708 " %g %g %g %g v\n",point[0].x,point[0].y,
1709 point[1].x,point[1].y);
1711 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1712 (void) FormatMagickString(message,MaxTextExtent,
1713 " %g %g %g %g y\n",last[2].x,last[2].y,
1714 point[1].x,point[1].y);
1716 (void) FormatMagickString(message,MaxTextExtent,
1717 " %g %g %g %g %g %g c\n",last[2].x,
1718 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1719 for (i=0; i < 3; i++)
1722 (void) ConcatenateString(&path,message);
1723 in_subpath=MagickTrue;
1726 Close the subpath if there are no more knots.
1728 if (knot_count == 0)
1731 Same special handling as above except we compare to the
1732 first point in the path and close the path.
1734 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1735 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1736 (void) FormatMagickString(message,MaxTextExtent,
1737 " %g %g l z\n",first[1].x,first[1].y);
1739 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1740 (void) FormatMagickString(message,MaxTextExtent,
1741 " %g %g %g %g v z\n",first[0].x,first[0].y,
1742 first[1].x,first[1].y);
1744 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1745 (void) FormatMagickString(message,MaxTextExtent,
1746 " %g %g %g %g y z\n",last[2].x,last[2].y,
1747 first[1].x,first[1].y);
1749 (void) FormatMagickString(message,MaxTextExtent,
1750 " %g %g %g %g %g %g c z\n",last[2].x,
1751 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1752 (void) ConcatenateString(&path,message);
1753 in_subpath=MagickFalse;
1769 Returns an empty PS path if the path has no knots.
1771 (void) FormatMagickString(message,MaxTextExtent," eoclip\n");
1772 (void) ConcatenateString(&path,message);
1773 (void) FormatMagickString(message,MaxTextExtent,"} bind def");
1774 (void) ConcatenateString(&path,message);
1775 message=DestroyString(message);
1779 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1780 const size_t columns,const size_t rows)
1803 path=AcquireString((char *) NULL);
1804 if (path == (char *) NULL)
1805 return((char *) NULL);
1806 message=AcquireString((char *) NULL);
1807 (void) FormatMagickString(message,MaxTextExtent,
1808 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
1809 (void) ConcatenateString(&path,message);
1810 (void) FormatMagickString(message,MaxTextExtent,
1811 "<svg width=\"%.20g\" height=\"%.20g\">\n",(double) columns,(double) rows);
1812 (void) ConcatenateString(&path,message);
1813 (void) FormatMagickString(message,MaxTextExtent,"<g>\n");
1814 (void) ConcatenateString(&path,message);
1815 (void) FormatMagickString(message,MaxTextExtent,
1816 "<path style=\"fill:#00000000;stroke:#00000000;");
1817 (void) ConcatenateString(&path,message);
1818 (void) FormatMagickString(message,MaxTextExtent,
1819 "stroke-width:0;stroke-antialiasing:false\" d=\"\n");
1820 (void) ConcatenateString(&path,message);
1821 (void) ResetMagickMemory(point,0,sizeof(point));
1822 (void) ResetMagickMemory(first,0,sizeof(first));
1823 (void) ResetMagickMemory(last,0,sizeof(last));
1825 in_subpath=MagickFalse;
1828 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1834 if (knot_count != 0)
1841 Expected subpath length record.
1843 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1853 if (knot_count == 0)
1856 Unexpected subpath knot.
1865 for (i=0; i < 3; i++)
1871 yy=ReadPropertyMSBLong(&blob,&length);
1872 xx=ReadPropertyMSBLong(&blob,&length);
1874 if (xx > 2147483647)
1875 x=(ssize_t) xx-4294967295-1;
1877 if (yy > 2147483647)
1878 y=(ssize_t) yy-4294967295-1;
1879 point[i].x=(double) x*columns/4096/4096;
1880 point[i].y=(double) y*rows/4096/4096;
1882 if (in_subpath == MagickFalse)
1884 (void) FormatMagickString(message,MaxTextExtent,"M %g,%g\n",
1885 point[1].x,point[1].y);
1886 for (i=0; i < 3; i++)
1894 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1895 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1896 (void) FormatMagickString(message,MaxTextExtent,"L %g,%g\n",
1897 point[1].x,point[1].y);
1899 (void) FormatMagickString(message,MaxTextExtent,
1900 "C %g,%g %g,%g %g,%g\n",last[2].x,last[2].y,
1901 point[0].x,point[0].y,point[1].x,point[1].y);
1902 for (i=0; i < 3; i++)
1905 (void) ConcatenateString(&path,message);
1906 in_subpath=MagickTrue;
1909 Close the subpath if there are no more knots.
1911 if (knot_count == 0)
1913 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1914 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1915 (void) FormatMagickString(message,MaxTextExtent,
1916 "L %g,%g Z\n",first[1].x,first[1].y);
1919 (void) FormatMagickString(message,MaxTextExtent,
1920 "C %g,%g %g,%g %g,%g Z\n",last[2].x,
1921 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1922 (void) ConcatenateString(&path,message);
1924 in_subpath=MagickFalse;
1940 Return an empty SVG image if the path does not have knots.
1942 (void) FormatMagickString(message,MaxTextExtent,"\"/>\n");
1943 (void) ConcatenateString(&path,message);
1944 (void) FormatMagickString(message,MaxTextExtent,"</g>\n");
1945 (void) ConcatenateString(&path,message);
1946 (void) FormatMagickString(message,MaxTextExtent,"</svg>\n");
1947 (void) ConcatenateString(&path,message);
1948 message=DestroyString(message);
1952 MagickExport const char *GetImageProperty(const Image *image,
1953 const char *property)
1970 assert(image != (Image *) NULL);
1971 assert(image->signature == MagickSignature);
1972 if (image->debug != MagickFalse)
1973 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1974 p=(const char *) NULL;
1975 if (image->properties != (void *) NULL)
1977 if (property == (const char *) NULL)
1979 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
1980 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
1984 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1985 image->properties,property);
1986 if (p != (const char *) NULL)
1989 if ((property == (const char *) NULL) ||
1990 (strchr(property,':') == (char *) NULL))
1992 exception=(&((Image *) image)->exception);
1997 if (LocaleNCompare("8bim:",property,5) == 0)
1999 if ((Get8BIMProperty(image,property) != MagickFalse) &&
2000 (image->properties != (void *) NULL))
2002 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2003 image->properties,property);
2012 if (LocaleNCompare("exif:",property,5) == 0)
2014 if ((GetEXIFProperty(image,property) != MagickFalse) &&
2015 (image->properties != (void *) NULL))
2017 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2018 image->properties,property);
2027 if (LocaleNCompare("fx:",property,3) == 0)
2029 fx_info=AcquireFxInfo(image,property+3);
2030 status=FxEvaluateChannelExpression(fx_info,DefaultChannels,0,0,&alpha,
2032 fx_info=DestroyFxInfo(fx_info);
2033 if (status != MagickFalse)
2036 value[MaxTextExtent];
2038 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2039 GetMagickPrecision(),(double) alpha);
2040 (void) SetImageProperty((Image *) image,property,value);
2042 if (image->properties != (void *) NULL)
2044 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2045 image->properties,property);
2054 if (LocaleNCompare("iptc:",property,5) == 0)
2056 if ((GetIPTCProperty(image,property) != MagickFalse) &&
2057 (image->properties != (void *) NULL))
2059 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2060 image->properties,property);
2069 if (LocaleNCompare("pixel:",property,6) == 0)
2074 GetMagickPixelPacket(image,&pixel);
2075 fx_info=AcquireFxInfo(image,property+6);
2076 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2078 pixel.red=(MagickRealType) QuantumRange*alpha;
2079 status|=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2081 pixel.green=(MagickRealType) QuantumRange*alpha;
2082 status|=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2084 pixel.blue=(MagickRealType) QuantumRange*alpha;
2085 status|=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2087 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2088 if (image->colorspace == CMYKColorspace)
2090 status|=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2092 pixel.index=(MagickRealType) QuantumRange*alpha;
2094 fx_info=DestroyFxInfo(fx_info);
2095 if (status != MagickFalse)
2098 name[MaxTextExtent];
2100 (void) QueryMagickColorname(image,&pixel,SVGCompliance,name,
2102 (void) SetImageProperty((Image *) image,property,name);
2103 return(GetImageProperty(image,property));
2111 if (LocaleNCompare("xmp:",property,4) == 0)
2113 if ((GetXMPProperty(image,property) != MagickFalse) &&
2114 (image->properties != (void *) NULL))
2116 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2117 image->properties,property);
2130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2134 + G e t M a g i c k P r o p e r t y %
2138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2140 % GetMagickProperty() gets a value associated with an image property.
2142 % The format of the GetMagickProperty method is:
2144 % const char *GetMagickProperty(const ImageInfo *image_info,
2145 % Image *image,const char *key)
2147 % A description of each parameter follows:
2149 % o image_info: the image info.
2151 % o image: the image.
2156 MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
2157 Image *image,const char *property)
2160 value[MaxTextExtent],
2161 filename[MaxTextExtent];
2168 if (LocaleNCompare("base",property,4) == 0)
2170 GetPathComponent(image->magick_filename,BasePath,filename);
2171 (void) CopyMagickString(value,filename,MaxTextExtent);
2178 if (LocaleNCompare("channels",property,8) == 0)
2183 (void) FormatMagickString(value,MaxTextExtent,"%s",
2184 MagickOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2185 image->colorspace));
2187 if (image->matte != MagickFalse)
2188 (void) ConcatenateMagickString(value,"a",MaxTextExtent);
2191 if (LocaleNCompare("colorspace",property,10) == 0)
2197 Image storage class and colorspace.
2199 colorspace=image->colorspace;
2200 if (IsGrayImage(image,&image->exception) != MagickFalse)
2201 colorspace=GRAYColorspace;
2202 (void) FormatMagickString(value,MaxTextExtent,"%s",
2203 MagickOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2207 if (LocaleNCompare("copyright",property,9) == 0)
2209 (void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
2216 if (LocaleNCompare("depth",property,5) == 0)
2218 (void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2222 if (LocaleNCompare("directory",property,9) == 0)
2224 GetPathComponent(image->magick_filename,HeadPath,filename);
2225 (void) CopyMagickString(value,filename,MaxTextExtent);
2232 if (LocaleNCompare("extension",property,9) == 0)
2234 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2235 (void) CopyMagickString(value,filename,MaxTextExtent);
2242 if (LocaleNCompare("group",property,5) == 0)
2244 (void) FormatMagickString(value,MaxTextExtent,"0x%lx",
2245 (unsigned long) image_info->group);
2252 if (LocaleNCompare("height",property,6) == 0)
2254 (void) FormatMagickString(value,MaxTextExtent,"%.20g",
2255 image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2262 if (LocaleNCompare("input",property,5) == 0)
2264 (void) CopyMagickString(value,image->filename,MaxTextExtent);
2271 if (LocaleNCompare("kurtosis",property,8) == 0)
2277 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2278 &skewness,&image->exception);
2279 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2280 GetMagickPrecision(),kurtosis);
2287 if (LocaleNCompare("magick",property,6) == 0)
2289 (void) CopyMagickString(value,image->magick,MaxTextExtent);
2292 if (LocaleNCompare("max",property,3) == 0)
2298 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2299 &maximum,&image->exception);
2300 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2301 GetMagickPrecision(),maximum);
2304 if (LocaleNCompare("mean",property,4) == 0)
2310 (void) GetImageChannelMean(image,image_info->channel,&mean,
2311 &standard_deviation,&image->exception);
2312 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2313 GetMagickPrecision(),mean);
2316 if (LocaleNCompare("min",property,3) == 0)
2322 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2323 &maximum,&image->exception);
2324 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2325 GetMagickPrecision(),minimum);
2332 if (LocaleNCompare("name",property,4) == 0)
2334 (void) CopyMagickString(value,filename,MaxTextExtent);
2341 if (LocaleNCompare("output",property,6) == 0)
2343 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
2350 if (LocaleNCompare("page",property,4) == 0)
2352 register const Image
2359 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2360 p=GetPreviousImageInList(p);
2361 (void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2369 if (LocaleNCompare("size",property,4) == 0)
2372 format[MaxTextExtent];
2374 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
2375 (void) FormatMagickString(value,MaxTextExtent,"%sB",format);
2378 if (LocaleNCompare("scenes",property,6) == 0)
2380 (void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2381 GetImageListLength(image));
2384 if (LocaleNCompare("scene",property,5) == 0)
2386 (void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2388 if (image_info->number_scenes != 0)
2389 (void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2393 if (LocaleNCompare("skewness",property,8) == 0)
2399 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2400 &skewness,&image->exception);
2401 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2402 GetMagickPrecision(),skewness);
2405 if ((LocaleNCompare("standard-deviation",property,18) == 0) ||
2406 (LocaleNCompare("standard_deviation",property,18) == 0))
2412 (void) GetImageChannelMean(image,image_info->channel,&mean,
2413 &standard_deviation,&image->exception);
2414 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2415 GetMagickPrecision(),standard_deviation);
2422 if (LocaleNCompare("unique",property,6) == 0)
2424 (void) CopyMagickString(filename,image_info->unique,MaxTextExtent);
2425 (void) CopyMagickString(value,filename,MaxTextExtent);
2432 if (LocaleNCompare("version",property,7) == 0)
2434 (void) CopyMagickString(value,GetMagickVersion((size_t *) NULL),
2442 if (LocaleNCompare("width",property,5) == 0)
2444 (void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2445 (image->magick_columns != 0 ? image->magick_columns : 256));
2452 if (LocaleNCompare("xresolution",property,11) == 0)
2454 (void) FormatMagickString(value,MaxTextExtent,"%g",
2455 image->x_resolution);
2462 if (LocaleNCompare("yresolution",property,11) == 0)
2464 (void) FormatMagickString(value,MaxTextExtent,"%g",
2465 image->y_resolution);
2472 if (LocaleNCompare("zero",property,4) == 0)
2474 (void) CopyMagickString(filename,image_info->zero,MaxTextExtent);
2475 (void) CopyMagickString(value,filename,MaxTextExtent);
2483 if (image->properties == (void *) NULL)
2484 image->properties=NewSplayTree(CompareSplayTreeString,
2485 RelinquishMagickMemory,RelinquishMagickMemory);
2486 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
2487 ConstantString(property),ConstantString(value));
2489 return(GetImageProperty(image,property));
2493 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2497 % G e t N e x t I m a g e P r o p e r t y %
2501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2503 % GetNextImageProperty() gets the next image property value.
2505 % The format of the GetNextImageProperty method is:
2507 % char *GetNextImageProperty(const Image *image)
2509 % A description of each parameter follows:
2511 % o image: the image.
2514 MagickExport char *GetNextImageProperty(const Image *image)
2516 assert(image != (Image *) NULL);
2517 assert(image->signature == MagickSignature);
2518 if (image->debug != MagickFalse)
2519 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2521 if (image->properties == (void *) NULL)
2522 return((char *) NULL);
2523 return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
2527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2531 % I n t e r p r e t I m a g e P r o p e r t i e s %
2535 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2537 % InterpretImageProperties() replaces any embedded formatting characters with
2538 % the appropriate image property and returns the interpretted text.
2540 % The format of the InterpretImageProperties method is:
2542 % char *InterpretImageProperties(const ImageInfo *image_info,Image *image,
2543 % const char *embed_text)
2545 % A description of each parameter follows:
2547 % o image_info: the image info.
2549 % o image: the image.
2551 % o embed_text: the address of a character string containing the embedded
2552 % formatting characters.
2555 MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
2556 Image *image,const char *embed_text)
2559 filename[MaxTextExtent],
2582 assert(image != (Image *) NULL);
2583 assert(image->signature == MagickSignature);
2584 if (image->debug != MagickFalse)
2585 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2586 if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))
2587 return((char *) NULL);
2588 text=(char *) embed_text;
2589 if ((*text == '@') && ((*(text+1) == '-') ||
2590 (IsPathAccessible(text+1) != MagickFalse)))
2591 return(FileToString(embed_text+1,~0,&image->exception));
2593 Translate any embedded format characters.
2595 text_info=CloneImageInfo(image_info);
2596 interpret_text=AcquireString(text);
2597 extent=MaxTextExtent;
2599 for (q=interpret_text; *p != '\0'; p++)
2602 if ((size_t) (q-interpret_text+MaxTextExtent) >= extent)
2604 extent+=MaxTextExtent;
2605 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2606 MaxTextExtent+1,sizeof(*interpret_text));
2607 if (interpret_text == (char *) NULL)
2609 q=interpret_text+strlen(interpret_text);
2612 Process formatting characters in text.
2614 if ((*p == '\\') && (*(p+1) == 'r'))
2620 if ((*p == '\\') && (*(p+1) == 'n'))
2643 format[MaxTextExtent];
2648 (void) FormatMagickString(format,MaxTextExtent,"%.20g",(double)
2650 if (image->extent != (MagickSizeType) ((size_t) image->extent))
2651 (void) FormatMagickSize(image->extent,MagickFalse,format);
2652 q+=ConcatenateMagickString(q,format,extent);
2653 q+=ConcatenateMagickString(q,"B",extent);
2661 value=GetImageProperty(image,"comment");
2662 if (value == (const char *) NULL)
2664 length=strlen(value);
2665 if ((size_t) (q-interpret_text+length+1) >= extent)
2668 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2669 MaxTextExtent,sizeof(*interpret_text));
2670 if (interpret_text == (char *) NULL)
2672 q=interpret_text+strlen(interpret_text);
2674 (void) CopyMagickString(q,value,extent);
2684 Label segment is the base of the filename.
2686 if (*image->magick_filename == '\0')
2695 GetPathComponent(image->magick_filename,HeadPath,filename);
2696 q+=CopyMagickString(q,filename,extent);
2704 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2705 q+=CopyMagickString(q,filename,extent);
2713 GetPathComponent(image->magick_filename,TailPath,filename);
2714 q+=CopyMagickString(q,filename,extent);
2722 GetPathComponent(image->magick_filename,BasePath,filename);
2723 q+=CopyMagickString(q,filename,extent);
2734 q+=FormatMagickString(q,extent,"%.20gx%.20g%+.20g%+.20g",(double)
2735 image->page.width,(double) image->page.height,(double) image->page.x,
2736 (double) image->page.y);
2744 q+=FormatMagickString(q,extent,"%.20g",(double) (image->rows != 0 ?
2745 image->rows : image->magick_rows));
2753 q+=CopyMagickString(q,image->filename,extent);
2759 Number of unique colors.
2761 q+=FormatMagickString(q,extent,"%.20g",(double) GetNumberColors(image,
2762 (FILE *) NULL,&image->exception));
2770 value=GetImageProperty(image,"label");
2771 if (value == (const char *) NULL)
2773 length=strlen(value);
2774 if ((size_t) (q-interpret_text+length+1) >= extent)
2777 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2778 MaxTextExtent,sizeof(*interpret_text));
2779 if (interpret_text == (char *) NULL)
2781 q=interpret_text+strlen(interpret_text);
2783 q+=CopyMagickString(q,value,extent);
2791 q+=CopyMagickString(q,image->magick,extent);
2797 Image magick filename.
2799 q+=CopyMagickString(q,image->magick_filename,extent);
2805 Number of images in the list.
2807 q+=FormatMagickString(q,extent,"%.20g",(double) GetImageListLength(
2814 Image output filename.
2816 q+=CopyMagickString(q,text_info->filename,extent);
2821 register const Image
2831 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2832 p=GetPreviousImageInList(p);
2833 q+=FormatMagickString(q,extent,"%.20g",(double) page);
2841 q+=FormatMagickString(q,extent,"%.20g",(double)
2842 MAGICKCORE_QUANTUM_DEPTH);
2851 Image storage class and colorspace.
2853 colorspace=image->colorspace;
2854 if (IsGrayImage(image,&image->exception) != MagickFalse)
2855 colorspace=GRAYColorspace;
2856 q+=FormatMagickString(q,extent,"%s%s%s",MagickOptionToMnemonic(
2857 MagickClassOptions,(ssize_t) image->storage_class),
2858 MagickOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
2859 image->matte != MagickFalse ? "Matte" : "");
2867 if (text_info->number_scenes == 0)
2868 q+=FormatMagickString(q,extent,"%.20g",(double) image->scene);
2870 q+=FormatMagickString(q,extent,"%.20g",(double) text_info->scene);
2878 (void) CopyMagickString(filename,text_info->unique,extent);
2879 q+=CopyMagickString(q,filename,extent);
2887 q+=FormatMagickString(q,extent,"%.20g",(double) (image->columns != 0 ?
2888 image->columns : image->magick_columns));
2894 Image horizontal resolution.
2896 q+=FormatMagickString(q,extent,"%g %s",image->x_resolution,
2897 MagickOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2904 Image vertical resolution.
2906 q+=FormatMagickString(q,extent,"%g %s",image->y_resolution,
2907 MagickOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2916 q+=FormatMagickString(q,extent,"%.20g",(double) image->depth);
2922 Image alpha channel.
2924 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2925 MagickBooleanOptions,(ssize_t) image->matte));
2931 Image compression method.
2933 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2934 MagickCompressOptions,(ssize_t) image->compression));
2940 Image dispose method.
2942 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2943 MagickDisposeOptions,(ssize_t) image->dispose));
2948 q+=FormatMagickString(q,extent,"%.20gx%.20g",(double)
2949 image->magick_columns,(double) image->magick_rows);
2954 q+=FormatMagickString(q,extent,"%.20g",(double) image->page.height);
2959 q+=FormatMagickString(q,extent,"%+ld%+ld",(long) image->page.x,(long)
2965 q+=FormatMagickString(q,extent,"%.20gx%.20g",(double) image->page.width,
2966 (double) image->page.height);
2971 q+=FormatMagickString(q,extent,"%.20g",(double) image->quality);
2979 if (text_info->number_scenes == 0)
2980 q+=CopyMagickString(q,"2147483647",extent);
2982 q+=FormatMagickString(q,extent,"%.20g",(double) (text_info->scene+
2983 text_info->number_scenes));
2988 q+=FormatMagickString(q,extent,"%.20g",(double) image->delay);
2993 q+=FormatMagickString(q,extent,"%.20g",(double) image->page.width);
2998 q+=FormatMagickString(q,extent,"%+.20g",(double) image->page.x);
3003 q+=FormatMagickString(q,extent,"%+.20g",(double) image->page.y);
3011 (void) CopyMagickString(filename,text_info->zero,extent);
3012 q+=CopyMagickString(q,filename,extent);
3018 pattern[MaxTextExtent];
3030 if (strchr(p,']') == (char *) NULL)
3034 for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
3045 value=GetImageProperty(image,pattern);
3046 if (value != (const char *) NULL)
3048 length=strlen(value);
3049 if ((size_t) (q-interpret_text+length+1) >= extent)
3052 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3053 extent+MaxTextExtent,sizeof(*interpret_text));
3054 if (interpret_text == (char *) NULL)
3056 q=interpret_text+strlen(interpret_text);
3058 (void) CopyMagickString(q,value,extent);
3063 if (IsGlob(pattern) != MagickFalse)
3066 Iterate over image properties.
3068 ResetImagePropertyIterator(image);
3069 key=GetNextImageProperty(image);
3070 while (key != (const char *) NULL)
3072 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3074 value=GetImageProperty(image,key);
3075 if (value != (const char *) NULL)
3077 length=strlen(key)+strlen(value)+2;
3078 if ((size_t) (q-interpret_text+length+1) >= extent)
3081 interpret_text=(char *) ResizeQuantumMemory(
3082 interpret_text,extent+MaxTextExtent,
3083 sizeof(*interpret_text));
3084 if (interpret_text == (char *) NULL)
3086 q=interpret_text+strlen(interpret_text);
3088 q+=FormatMagickString(q,extent,"%s=%s\n",key,value);
3091 key=GetNextImageProperty(image);
3094 value=GetMagickProperty(text_info,image,pattern);
3095 if (value != (const char *) NULL)
3097 length=strlen(value);
3098 if ((size_t) (q-interpret_text+length+1) >= extent)
3101 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3102 extent+MaxTextExtent,sizeof(*interpret_text));
3103 if (interpret_text == (char *) NULL)
3105 q=interpret_text+strlen(interpret_text);
3107 (void) CopyMagickString(q,value,extent);
3111 if (image_info == (ImageInfo *) NULL)
3113 value=GetImageOption(image_info,pattern);
3114 if (value != (char *) NULL)
3116 length=strlen(value);
3117 if ((size_t) (q-interpret_text+length+1) >= extent)
3120 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3121 extent+MaxTextExtent,sizeof(*interpret_text));
3122 if (interpret_text == (char *) NULL)
3124 q=interpret_text+strlen(interpret_text);
3126 (void) CopyMagickString(q,value,extent);
3140 page=GetImageBoundingBox(image,&image->exception);
3141 q+=FormatMagickString(q,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
3142 (double) page.width,(double) page.height,(double) page.x,(double)
3151 (void) SignatureImage(image);
3152 value=GetImageProperty(image,"signature");
3153 if (value == (const char *) NULL)
3155 q+=CopyMagickString(q,value,extent);
3172 text_info=DestroyImageInfo(text_info);
3173 if (text != (const char *) embed_text)
3174 text=DestroyString(text);
3175 (void) SubstituteString(&interpret_text,"<","<");
3176 (void) SubstituteString(&interpret_text,">",">");
3177 return(interpret_text);
3181 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3185 % R e m o v e I m a g e P r o p e r t y %
3189 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3191 % RemoveImageProperty() removes a property from the image and returns its
3194 % The format of the RemoveImageProperty method is:
3196 % char *RemoveImageProperty(Image *image,const char *property)
3198 % A description of each parameter follows:
3200 % o image: the image.
3202 % o property: the image property.
3205 MagickExport char *RemoveImageProperty(Image *image,
3206 const char *property)
3211 assert(image != (Image *) NULL);
3212 assert(image->signature == MagickSignature);
3213 if (image->debug != MagickFalse)
3214 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3216 if (image->properties == (void *) NULL)
3217 return((char *) NULL);
3218 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3228 % 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 %
3232 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3234 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3235 % in conjunction with GetNextImageProperty() to iterate over all the values
3236 % associated with an image property.
3238 % The format of the ResetImagePropertyIterator method is:
3240 % ResetImagePropertyIterator(Image *image)
3242 % A description of each parameter follows:
3244 % o image: the image.
3247 MagickExport void ResetImagePropertyIterator(const Image *image)
3249 assert(image != (Image *) NULL);
3250 assert(image->signature == MagickSignature);
3251 if (image->debug != MagickFalse)
3252 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3254 if (image->properties == (void *) NULL)
3256 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3260 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3264 % S e t I m a g e P r o p e r t y %
3268 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3270 % SetImageProperty() associates an value with an image property.
3272 % The format of the SetImageProperty method is:
3274 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3275 % const char *value)
3277 % A description of each parameter follows:
3279 % o image: the image.
3281 % o property: the image property.
3283 % o values: the image property values.
3286 MagickExport MagickBooleanType SetImageProperty(Image *image,
3287 const char *property,const char *value)
3298 assert(image != (Image *) NULL);
3299 assert(image->signature == MagickSignature);
3300 if (image->debug != MagickFalse)
3301 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3303 if (image->properties == (void *) NULL)
3304 image->properties=NewSplayTree(CompareSplayTreeString,
3305 RelinquishMagickMemory,RelinquishMagickMemory);
3306 if ((value == (const char *) NULL) || (*value == '\0'))
3307 return(DeleteImageProperty(image,property));
3309 exception=(&image->exception);
3315 if (LocaleCompare(property,"background") == 0)
3317 (void) QueryColorDatabase(value,&image->background_color,exception);
3320 if (LocaleCompare(property,"bias") == 0)
3322 image->bias=SiPrefixToDouble(value,QuantumRange);
3325 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3326 ConstantString(property),ConstantString(value));
3332 if (LocaleCompare(property,"colorspace") == 0)
3337 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
3341 (void) SetImageColorspace(image,(ColorspaceType) colorspace);
3344 if (LocaleCompare(property,"compose") == 0)
3349 compose=ParseMagickOption(MagickComposeOptions,MagickFalse,value);
3352 image->compose=(CompositeOperator) compose;
3355 if (LocaleCompare(property,"compress") == 0)
3360 compression=ParseMagickOption(MagickCompressOptions,MagickFalse,
3362 if (compression < 0)
3364 image->compression=(CompressionType) compression;
3367 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3368 ConstantString(property),ConstantString(value));
3374 if (LocaleCompare(property,"delay") == 0)
3379 flags=ParseGeometry(value,&geometry_info);
3380 if ((flags & GreaterValue) != 0)
3382 if (image->delay > (size_t) floor(geometry_info.rho+0.5))
3383 image->delay=(size_t) floor(geometry_info.rho+0.5);
3386 if ((flags & LessValue) != 0)
3388 if (image->delay < (size_t) floor(geometry_info.rho+0.5))
3389 image->ticks_per_second=(ssize_t)
3390 floor(geometry_info.sigma+0.5);
3393 image->delay=(size_t) floor(geometry_info.rho+0.5);
3394 if ((flags & SigmaValue) != 0)
3395 image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
3398 if (LocaleCompare(property,"density") == 0)
3403 flags=ParseGeometry(value,&geometry_info);
3404 image->x_resolution=geometry_info.rho;
3405 image->y_resolution=geometry_info.sigma;
3406 if ((flags & SigmaValue) == 0)
3407 image->y_resolution=image->x_resolution;
3409 if (LocaleCompare(property,"depth") == 0)
3411 image->depth=StringToUnsignedLong(value);
3414 if (LocaleCompare(property,"dispose") == 0)
3419 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,value);
3422 image->dispose=(DisposeType) dispose;
3425 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3426 ConstantString(property),ConstantString(value));
3432 if (LocaleCompare(property,"gravity") == 0)
3437 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
3440 image->gravity=(GravityType) gravity;
3443 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3444 ConstantString(property),ConstantString(value));
3450 if (LocaleCompare(property,"intent") == 0)
3455 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3457 if (rendering_intent < 0)
3459 image->rendering_intent=(RenderingIntent) rendering_intent;
3462 if (LocaleCompare(property,"interpolate") == 0)
3467 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
3469 if (interpolate < 0)
3471 image->interpolate=(InterpolatePixelMethod) interpolate;
3474 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3475 ConstantString(property),ConstantString(value));
3481 if (LocaleCompare(property,"loop") == 0)
3483 image->iterations=StringToUnsignedLong(value);
3486 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3487 ConstantString(property),ConstantString(value));
3493 if (LocaleCompare(property,"page") == 0)
3498 geometry=GetPageGeometry(value);
3499 flags=ParseAbsoluteGeometry(geometry,&image->page);
3500 geometry=DestroyString(geometry);
3503 if (LocaleCompare(property,"profile") == 0)
3511 image_info=AcquireImageInfo();
3512 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
3513 (void) SetImageInfo(image_info,1,exception);
3514 profile=FileToStringInfo(image_info->filename,~0UL,exception);
3515 if (profile != (StringInfo *) NULL)
3516 status=SetImageProfile(image,image_info->magick,profile);
3517 image_info=DestroyImageInfo(image_info);
3520 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3521 ConstantString(property),ConstantString(value));
3527 if (LocaleCompare(property,"rendering-intent") == 0)
3532 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3534 if (rendering_intent < 0)
3536 image->rendering_intent=(RenderingIntent) rendering_intent;
3539 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3540 ConstantString(property),ConstantString(value));
3546 if (LocaleCompare(property,"tile-offset") == 0)
3551 geometry=GetPageGeometry(value);
3552 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3553 geometry=DestroyString(geometry);
3556 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3557 ConstantString(property),ConstantString(value));
3563 if (LocaleCompare(property,"units") == 0)
3568 units=ParseMagickOption(MagickResolutionOptions,MagickFalse,value);
3571 image->units=(ResolutionType) units;
3574 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3575 ConstantString(property),ConstantString(value));
3580 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3581 ConstantString(property),ConstantString(value));