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-2010 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "magick/studio.h"
44 #include "magick/attribute.h"
45 #include "magick/cache.h"
46 #include "magick/color.h"
47 #include "magick/compare.h"
48 #include "magick/constitute.h"
49 #include "magick/draw.h"
50 #include "magick/effect.h"
51 #include "magick/exception.h"
52 #include "magick/exception-private.h"
53 #include "magick/fx.h"
54 #include "magick/fx-private.h"
55 #include "magick/gem.h"
56 #include "magick/geometry.h"
57 #include "magick/histogram.h"
58 #include "magick/image.h"
59 #include "magick/image.h"
60 #include "magick/layer.h"
61 #include "magick/list.h"
62 #include "magick/memory_.h"
63 #include "magick/monitor.h"
64 #include "magick/montage.h"
65 #include "magick/option.h"
66 #include "magick/profile.h"
67 #include "magick/property.h"
68 #include "magick/quantum.h"
69 #include "magick/resource_.h"
70 #include "magick/splay-tree.h"
71 #include "magick/signature-private.h"
72 #include "magick/statistic.h"
73 #include "magick/string_.h"
74 #include "magick/string-private.h"
75 #include "magick/token.h"
76 #include "magick/utility.h"
77 #include "magick/xml-tree.h"
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 % C l o n e I m a g e P r o p e r t i e s %
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 % CloneImageProperties() clones one or more image properties.
92 % The format of the CloneImageProperties method is:
94 % MagickBooleanType CloneImageProperties(Image *image,
95 % const Image *clone_image)
97 % A description of each parameter follows:
101 % o clone_image: the clone image.
104 MagickExport MagickBooleanType CloneImageProperties(Image *image,
105 const Image *clone_image)
107 assert(image != (Image *) NULL);
108 assert(image->signature == MagickSignature);
109 if (image->debug != MagickFalse)
110 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
111 assert(clone_image != (const Image *) NULL);
112 assert(clone_image->signature == MagickSignature);
113 if (clone_image->debug != MagickFalse)
114 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
115 clone_image->filename);
116 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
117 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
119 image->compression=clone_image->compression;
120 image->quality=clone_image->quality;
121 image->depth=clone_image->depth;
122 image->background_color=clone_image->background_color;
123 image->border_color=clone_image->border_color;
124 image->matte_color=clone_image->matte_color;
125 image->transparent_color=clone_image->transparent_color;
126 image->gamma=clone_image->gamma;
127 image->chromaticity=clone_image->chromaticity;
128 image->rendering_intent=clone_image->rendering_intent;
129 image->black_point_compensation=clone_image->black_point_compensation;
130 image->units=clone_image->units;
131 image->montage=(char *) NULL;
132 image->directory=(char *) NULL;
133 (void) CloneString(&image->geometry,clone_image->geometry);
134 image->offset=clone_image->offset;
135 image->x_resolution=clone_image->x_resolution;
136 image->y_resolution=clone_image->y_resolution;
137 image->page=clone_image->page;
138 image->tile_offset=clone_image->tile_offset;
139 image->extract_info=clone_image->extract_info;
140 image->bias=clone_image->bias;
141 image->filter=clone_image->filter;
142 image->blur=clone_image->blur;
143 image->fuzz=clone_image->fuzz;
144 image->interlace=clone_image->interlace;
145 image->interpolate=clone_image->interpolate;
146 image->endian=clone_image->endian;
147 image->gravity=clone_image->gravity;
148 image->compose=clone_image->compose;
149 image->scene=clone_image->scene;
150 image->orientation=clone_image->orientation;
151 image->dispose=clone_image->dispose;
152 image->delay=clone_image->delay;
153 image->ticks_per_second=clone_image->ticks_per_second;
154 image->iterations=clone_image->iterations;
155 image->total_colors=clone_image->total_colors;
156 image->taint=clone_image->taint;
157 image->progress_monitor=clone_image->progress_monitor;
158 image->client_data=clone_image->client_data;
159 image->start_loop=clone_image->start_loop;
160 image->error=clone_image->error;
161 image->signature=clone_image->signature;
162 if (clone_image->properties != (void *) NULL)
164 if (image->properties != (void *) NULL)
165 DestroyImageProperties(image);
166 image->properties=CloneSplayTree((SplayTreeInfo *)
167 clone_image->properties,(void *(*)(void *)) ConstantString,
168 (void *(*)(void *)) ConstantString);
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
178 % D e f i n e I m a g e P r o p e r t y %
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 % DefineImageProperty() associates a key/value pair with an image property.
186 % The format of the DefineImageProperty method is:
188 % MagickBooleanType DefineImageProperty(Image *image,
189 % const char *property)
191 % A description of each parameter follows:
193 % o image: the image.
195 % o property: the image property.
198 MagickExport MagickBooleanType DefineImageProperty(Image *image,
199 const char *property)
203 value[MaxTextExtent];
208 assert(image != (Image *) NULL);
209 assert(property != (const char *) NULL);
210 (void) CopyMagickString(key,property,MaxTextExtent-1);
211 for (p=key; *p != '\0'; p++)
216 (void) CopyMagickString(value,p+1,MaxTextExtent);
218 return(SetImageProperty(image,key,value));
222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 % D e l e t e I m a g e P r o p e r t y %
230 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232 % DeleteImageProperty() deletes an image property.
234 % The format of the DeleteImageProperty method is:
236 % MagickBooleanType DeleteImageProperty(Image *image,const char *property)
238 % A description of each parameter follows:
240 % o image: the image.
242 % o property: the image property.
245 MagickExport MagickBooleanType DeleteImageProperty(Image *image,
246 const char *property)
248 assert(image != (Image *) NULL);
249 assert(image->signature == MagickSignature);
250 if (image->debug != MagickFalse)
251 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
253 if (image->properties == (void *) NULL)
255 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
263 % D e s t r o y I m a g e P r o p e r t i e s %
267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
269 % DestroyImageProperties() releases memory associated with image property
272 % The format of the DestroyDefines method is:
274 % void DestroyImageProperties(Image *image)
276 % A description of each parameter follows:
278 % o image: the image.
281 MagickExport void DestroyImageProperties(Image *image)
283 assert(image != (Image *) NULL);
284 assert(image->signature == MagickSignature);
285 if (image->debug != MagickFalse)
286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
288 if (image->properties != (void *) NULL)
289 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
294 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
298 % F o r m a t I m a g e P r o p e r t y %
302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304 % FormatImageProperty() permits formatted property/value pairs to be saved as
307 % The format of the FormatImageProperty method is:
309 % MagickBooleanType FormatImageProperty(Image *image,const char *property,
310 % const char *format,...)
312 % A description of each parameter follows.
314 % o image: The image.
316 % o property: The attribute property.
318 % o format: A string describing the format to use to write the remaining
323 MagickExport MagickBooleanType FormatImagePropertyList(Image *image,
324 const char *property,const char *format,va_list operands)
327 value[MaxTextExtent];
332 #if defined(MAGICKCORE_HAVE_VSNPRINTF)
333 n=vsnprintf(value,MaxTextExtent,format,operands);
335 n=vsprintf(value,format,operands);
338 value[MaxTextExtent-1]='\0';
339 return(SetImageProperty(image,property,value));
342 MagickExport MagickBooleanType FormatImageProperty(Image *image,
343 const char *property,const char *format,...)
351 va_start(operands,format);
352 status=FormatImagePropertyList(image,property,format,operands);
358 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
362 % G e t I m a g e P r o p e r t y %
366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368 % GetImageProperty() gets a value associated with an image property.
370 % The format of the GetImageProperty method is:
372 % const char *GetImageProperty(const Image *image,const char *key)
374 % A description of each parameter follows:
376 % o image: the image.
383 *TracePSClippath(const unsigned char *,size_t,const unsigned long,
384 const unsigned long),
385 *TraceSVGClippath(const unsigned char *,size_t,const unsigned long,
386 const unsigned long);
388 static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
408 profile=GetImageProfile(image,"iptc");
409 if (profile == (StringInfo *) NULL)
410 profile=GetImageProfile(image,"8bim");
411 if (profile == (StringInfo *) NULL)
413 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
416 attribute=(char *) NULL;
417 for (i=0; i < (long) GetStringInfoLength(profile); i+=(long) length)
420 if ((long) GetStringInfoDatum(profile)[i] != 0x1c)
422 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
423 length|=GetStringInfoDatum(profile)[i+4];
424 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
425 ((long) GetStringInfoDatum(profile)[i+2] == record))
427 message=(char *) NULL;
429 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
430 if (message != (char *) NULL)
432 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
433 profile)+i+5,length+1);
434 (void) ConcatenateString(&attribute,message);
435 (void) ConcatenateString(&attribute,";");
436 message=DestroyString(message);
441 if ((attribute == (char *) NULL) || (*attribute == ';'))
443 if (attribute != (char *) NULL)
444 attribute=DestroyString(attribute);
447 attribute[strlen(attribute)-1]='\0';
448 (void) SetImageProperty((Image *) image,key,(const char *) attribute);
449 attribute=DestroyString(attribute);
453 static inline long MagickMax(const long x,const long y)
460 static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
472 static inline unsigned long ReadPropertyMSBLong(const unsigned char **p,
489 for (i=0; i < 4; i++)
493 buffer[i]=(unsigned char) c;
495 value=(unsigned long) (buffer[0] << 24);
496 value|=buffer[1] << 16;
497 value|=buffer[2] << 8;
499 return(value & 0xffffffff);
502 static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
518 return((unsigned short) ~0U);
519 for (i=0; i < 2; i++)
523 buffer[i]=(unsigned char) c;
525 value=(unsigned short) (buffer[0] << 8);
527 return((unsigned short) (value & 0xffff));
530 static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
534 format[MaxTextExtent],
563 There's no newlines in path names, so it's safe as terminator.
565 profile=GetImageProfile(image,"8bim");
566 if (profile == (StringInfo *) NULL)
568 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name,
570 if ((count != 2) && (count != 3) && (count != 4))
573 (void) CopyMagickString(format,"SVG",MaxTextExtent);
578 sub_number=StringToLong(&name[1]);
579 sub_number=MagickMax(sub_number,1L);
580 resource=(char *) NULL;
582 length=GetStringInfoLength(profile);
583 info=GetStringInfoDatum(profile);
584 while ((length > 0) && (status == MagickFalse))
586 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
588 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
590 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
592 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
594 id=(long) ReadPropertyMSBShort(&info,&length);
599 if (resource != (char *) NULL)
600 resource=DestroyString(resource);
601 count=(ssize_t) ReadPropertyByte(&info,&length);
602 if ((count != 0) && ((size_t) count <= length))
604 resource=(char *) NULL;
605 if (~(1UL*count) >= MaxTextExtent)
606 resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
608 if (resource != (char *) NULL)
610 for (i=0; i < (long) count; i++)
611 resource[i]=(char) ReadPropertyByte(&info,&length);
612 resource[count]='\0';
615 if ((count & 0x01) == 0)
616 (void) ReadPropertyByte(&info,&length);
617 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
618 if ((*name != '\0') && (*name != '#'))
619 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
622 No name match, scroll forward and try next.
628 if ((*name == '#') && (sub_number != 1))
631 No numbered match, scroll forward and try next.
639 We have the resource of interest.
641 attribute=(char *) NULL;
642 if (~(1UL*count) >= MaxTextExtent)
643 attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
645 if (attribute != (char *) NULL)
647 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
648 attribute[count]='\0';
651 if ((id <= 1999) || (id >= 2999))
652 (void) SetImageProperty((Image *) image,key,(const char *)
659 if (LocaleCompare(format,"svg") == 0)
660 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
661 image->columns,image->rows);
663 path=TracePSClippath((unsigned char *) attribute,(size_t) count,
664 image->columns,image->rows);
665 (void) SetImageProperty((Image *) image,key,(const char *) path);
666 path=DestroyString(path);
668 attribute=DestroyString(attribute);
672 if (resource != (char *) NULL)
673 resource=DestroyString(resource);
677 static inline unsigned short ReadPropertyShort(const EndianType endian,
678 const unsigned char *buffer)
683 if (endian == MSBEndian)
685 value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
686 ((unsigned char *) buffer)[1]);
687 return((unsigned short) (value & 0xffff));
689 value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
690 return((unsigned short) (value & 0xffff));
693 static inline unsigned long ReadPropertyLong(const EndianType endian,
694 const unsigned char *buffer)
699 if (endian == MSBEndian)
701 value=(unsigned long) ((buffer[0] << 24) | (buffer[1] << 16) |
702 (buffer[2] << 8) | buffer[3]);
703 return((unsigned long) (value & 0xffffffff));
705 value=(unsigned long) ((buffer[3] << 24) | (buffer[2] << 16) |
706 (buffer[1] << 8 ) | (buffer[0]));
707 return((unsigned long) (value & 0xffffffff));
710 static MagickBooleanType GetEXIFProperty(const Image *image,
711 const char *property)
713 #define MaxDirectoryStack 16
714 #define EXIF_DELIMITER "\n"
715 #define EXIF_NUM_FORMATS 12
716 #define EXIF_FMT_BYTE 1
717 #define EXIF_FMT_STRING 2
718 #define EXIF_FMT_USHORT 3
719 #define EXIF_FMT_ULONG 4
720 #define EXIF_FMT_URATIONAL 5
721 #define EXIF_FMT_SBYTE 6
722 #define EXIF_FMT_UNDEFINED 7
723 #define EXIF_FMT_SSHORT 8
724 #define EXIF_FMT_SLONG 9
725 #define EXIF_FMT_SRATIONAL 10
726 #define EXIF_FMT_SINGLE 11
727 #define EXIF_FMT_DOUBLE 12
728 #define TAG_EXIF_OFFSET 0x8769
729 #define TAG_GPS_OFFSET 0x8825
730 #define TAG_INTEROP_OFFSET 0xa005
732 #define EXIFMultipleValues(size, format, arg) \
745 for (component=0; component < components; component++) \
747 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
749 if (length >= MaxTextExtent - 1) \
750 length=MaxTextExtent-1; \
754 buffer[length-2]='\0'; \
755 value=AcquireString(buffer); \
758 #define EXIFMultipleFractions(size, format, arg1, arg2) \
771 for (component=0; component < components; component++) \
773 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
774 format", ",arg1, arg2); \
775 if (length >= MaxTextExtent - 1) \
776 length=MaxTextExtent-1; \
780 buffer[length-2]='\0'; \
781 value=AcquireString(buffer); \
784 typedef struct _DirectoryInfo
794 typedef struct _TagInfo
806 { 0x001, "exif:InteroperabilityIndex" },
807 { 0x002, "exif:InteroperabilityVersion" },
808 { 0x100, "exif:ImageWidth" },
809 { 0x101, "exif:ImageLength" },
810 { 0x102, "exif:BitsPerSample" },
811 { 0x103, "exif:Compression" },
812 { 0x106, "exif:PhotometricInterpretation" },
813 { 0x10a, "exif:FillOrder" },
814 { 0x10d, "exif:DocumentName" },
815 { 0x10e, "exif:ImageDescription" },
816 { 0x10f, "exif:Make" },
817 { 0x110, "exif:Model" },
818 { 0x111, "exif:StripOffsets" },
819 { 0x112, "exif:Orientation" },
820 { 0x115, "exif:SamplesPerPixel" },
821 { 0x116, "exif:RowsPerStrip" },
822 { 0x117, "exif:StripByteCounts" },
823 { 0x11a, "exif:XResolution" },
824 { 0x11b, "exif:YResolution" },
825 { 0x11c, "exif:PlanarConfiguration" },
826 { 0x11d, "exif:PageName" },
827 { 0x11e, "exif:XPosition" },
828 { 0x11f, "exif:YPosition" },
829 { 0x118, "exif:MinSampleValue" },
830 { 0x119, "exif:MaxSampleValue" },
831 { 0x120, "exif:FreeOffsets" },
832 { 0x121, "exif:FreeByteCounts" },
833 { 0x122, "exif:GrayResponseUnit" },
834 { 0x123, "exif:GrayResponseCurve" },
835 { 0x124, "exif:T4Options" },
836 { 0x125, "exif:T6Options" },
837 { 0x128, "exif:ResolutionUnit" },
838 { 0x12d, "exif:TransferFunction" },
839 { 0x131, "exif:Software" },
840 { 0x132, "exif:DateTime" },
841 { 0x13b, "exif:Artist" },
842 { 0x13e, "exif:WhitePoint" },
843 { 0x13f, "exif:PrimaryChromaticities" },
844 { 0x140, "exif:ColorMap" },
845 { 0x141, "exif:HalfToneHints" },
846 { 0x142, "exif:TileWidth" },
847 { 0x143, "exif:TileLength" },
848 { 0x144, "exif:TileOffsets" },
849 { 0x145, "exif:TileByteCounts" },
850 { 0x14a, "exif:SubIFD" },
851 { 0x14c, "exif:InkSet" },
852 { 0x14d, "exif:InkNames" },
853 { 0x14e, "exif:NumberOfInks" },
854 { 0x150, "exif:DotRange" },
855 { 0x151, "exif:TargetPrinter" },
856 { 0x152, "exif:ExtraSample" },
857 { 0x153, "exif:SampleFormat" },
858 { 0x154, "exif:SMinSampleValue" },
859 { 0x155, "exif:SMaxSampleValue" },
860 { 0x156, "exif:TransferRange" },
861 { 0x157, "exif:ClipPath" },
862 { 0x158, "exif:XClipPathUnits" },
863 { 0x159, "exif:YClipPathUnits" },
864 { 0x15a, "exif:Indexed" },
865 { 0x15b, "exif:JPEGTables" },
866 { 0x15f, "exif:OPIProxy" },
867 { 0x200, "exif:JPEGProc" },
868 { 0x201, "exif:JPEGInterchangeFormat" },
869 { 0x202, "exif:JPEGInterchangeFormatLength" },
870 { 0x203, "exif:JPEGRestartInterval" },
871 { 0x205, "exif:JPEGLosslessPredictors" },
872 { 0x206, "exif:JPEGPointTransforms" },
873 { 0x207, "exif:JPEGQTables" },
874 { 0x208, "exif:JPEGDCTables" },
875 { 0x209, "exif:JPEGACTables" },
876 { 0x211, "exif:YCbCrCoefficients" },
877 { 0x212, "exif:YCbCrSubSampling" },
878 { 0x213, "exif:YCbCrPositioning" },
879 { 0x214, "exif:ReferenceBlackWhite" },
880 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
881 { 0x301, "exif:Gamma" },
882 { 0x302, "exif:ICCProfileDescriptor" },
883 { 0x303, "exif:SRGBRenderingIntent" },
884 { 0x320, "exif:ImageTitle" },
885 { 0x5001, "exif:ResolutionXUnit" },
886 { 0x5002, "exif:ResolutionYUnit" },
887 { 0x5003, "exif:ResolutionXLengthUnit" },
888 { 0x5004, "exif:ResolutionYLengthUnit" },
889 { 0x5005, "exif:PrintFlags" },
890 { 0x5006, "exif:PrintFlagsVersion" },
891 { 0x5007, "exif:PrintFlagsCrop" },
892 { 0x5008, "exif:PrintFlagsBleedWidth" },
893 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
894 { 0x500A, "exif:HalftoneLPI" },
895 { 0x500B, "exif:HalftoneLPIUnit" },
896 { 0x500C, "exif:HalftoneDegree" },
897 { 0x500D, "exif:HalftoneShape" },
898 { 0x500E, "exif:HalftoneMisc" },
899 { 0x500F, "exif:HalftoneScreen" },
900 { 0x5010, "exif:JPEGQuality" },
901 { 0x5011, "exif:GridSize" },
902 { 0x5012, "exif:ThumbnailFormat" },
903 { 0x5013, "exif:ThumbnailWidth" },
904 { 0x5014, "exif:ThumbnailHeight" },
905 { 0x5015, "exif:ThumbnailColorDepth" },
906 { 0x5016, "exif:ThumbnailPlanes" },
907 { 0x5017, "exif:ThumbnailRawBytes" },
908 { 0x5018, "exif:ThumbnailSize" },
909 { 0x5019, "exif:ThumbnailCompressedSize" },
910 { 0x501a, "exif:ColorTransferFunction" },
911 { 0x501b, "exif:ThumbnailData" },
912 { 0x5020, "exif:ThumbnailImageWidth" },
913 { 0x5021, "exif:ThumbnailImageHeight" },
914 { 0x5022, "exif:ThumbnailBitsPerSample" },
915 { 0x5023, "exif:ThumbnailCompression" },
916 { 0x5024, "exif:ThumbnailPhotometricInterp" },
917 { 0x5025, "exif:ThumbnailImageDescription" },
918 { 0x5026, "exif:ThumbnailEquipMake" },
919 { 0x5027, "exif:ThumbnailEquipModel" },
920 { 0x5028, "exif:ThumbnailStripOffsets" },
921 { 0x5029, "exif:ThumbnailOrientation" },
922 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
923 { 0x502b, "exif:ThumbnailRowsPerStrip" },
924 { 0x502c, "exif:ThumbnailStripBytesCount" },
925 { 0x502d, "exif:ThumbnailResolutionX" },
926 { 0x502e, "exif:ThumbnailResolutionY" },
927 { 0x502f, "exif:ThumbnailPlanarConfig" },
928 { 0x5030, "exif:ThumbnailResolutionUnit" },
929 { 0x5031, "exif:ThumbnailTransferFunction" },
930 { 0x5032, "exif:ThumbnailSoftwareUsed" },
931 { 0x5033, "exif:ThumbnailDateTime" },
932 { 0x5034, "exif:ThumbnailArtist" },
933 { 0x5035, "exif:ThumbnailWhitePoint" },
934 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
935 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
936 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
937 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
938 { 0x503A, "exif:ThumbnailRefBlackWhite" },
939 { 0x503B, "exif:ThumbnailCopyRight" },
940 { 0x5090, "exif:LuminanceTable" },
941 { 0x5091, "exif:ChrominanceTable" },
942 { 0x5100, "exif:FrameDelay" },
943 { 0x5101, "exif:LoopCount" },
944 { 0x5110, "exif:PixelUnit" },
945 { 0x5111, "exif:PixelPerUnitX" },
946 { 0x5112, "exif:PixelPerUnitY" },
947 { 0x5113, "exif:PaletteHistogram" },
948 { 0x1000, "exif:RelatedImageFileFormat" },
949 { 0x1001, "exif:RelatedImageLength" },
950 { 0x1002, "exif:RelatedImageWidth" },
951 { 0x800d, "exif:ImageID" },
952 { 0x80e3, "exif:Matteing" },
953 { 0x80e4, "exif:DataType" },
954 { 0x80e5, "exif:ImageDepth" },
955 { 0x80e6, "exif:TileDepth" },
956 { 0x828d, "exif:CFARepeatPatternDim" },
957 { 0x828e, "exif:CFAPattern2" },
958 { 0x828f, "exif:BatteryLevel" },
959 { 0x8298, "exif:Copyright" },
960 { 0x829a, "exif:ExposureTime" },
961 { 0x829d, "exif:FNumber" },
962 { 0x83bb, "exif:IPTC/NAA" },
963 { 0x84e3, "exif:IT8RasterPadding" },
964 { 0x84e5, "exif:IT8ColorTable" },
965 { 0x8649, "exif:ImageResourceInformation" },
966 { 0x8769, "exif:ExifOffset" },
967 { 0x8773, "exif:InterColorProfile" },
968 { 0x8822, "exif:ExposureProgram" },
969 { 0x8824, "exif:SpectralSensitivity" },
970 { 0x8825, "exif:GPSInfo" },
971 { 0x8827, "exif:ISOSpeedRatings" },
972 { 0x8828, "exif:OECF" },
973 { 0x8829, "exif:Interlace" },
974 { 0x882a, "exif:TimeZoneOffset" },
975 { 0x882b, "exif:SelfTimerMode" },
976 { 0x9000, "exif:ExifVersion" },
977 { 0x9003, "exif:DateTimeOriginal" },
978 { 0x9004, "exif:DateTimeDigitized" },
979 { 0x9101, "exif:ComponentsConfiguration" },
980 { 0x9102, "exif:CompressedBitsPerPixel" },
981 { 0x9201, "exif:ShutterSpeedValue" },
982 { 0x9202, "exif:ApertureValue" },
983 { 0x9203, "exif:BrightnessValue" },
984 { 0x9204, "exif:ExposureBiasValue" },
985 { 0x9205, "exif:MaxApertureValue" },
986 { 0x9206, "exif:SubjectDistance" },
987 { 0x9207, "exif:MeteringMode" },
988 { 0x9208, "exif:LightSource" },
989 { 0x9209, "exif:Flash" },
990 { 0x920a, "exif:FocalLength" },
991 { 0x920b, "exif:FlashEnergy" },
992 { 0x920c, "exif:SpatialFrequencyResponse" },
993 { 0x920d, "exif:Noise" },
994 { 0x9211, "exif:ImageNumber" },
995 { 0x9212, "exif:SecurityClassification" },
996 { 0x9213, "exif:ImageHistory" },
997 { 0x9214, "exif:SubjectArea" },
998 { 0x9215, "exif:ExposureIndex" },
999 { 0x9216, "exif:TIFF-EPStandardID" },
1000 { 0x927c, "exif:MakerNote" },
1001 { 0x9C9b, "exif:WinXP-Title" },
1002 { 0x9C9c, "exif:WinXP-Comments" },
1003 { 0x9C9d, "exif:WinXP-Author" },
1004 { 0x9C9e, "exif:WinXP-Keywords" },
1005 { 0x9C9f, "exif:WinXP-Subject" },
1006 { 0x9286, "exif:UserComment" },
1007 { 0x9290, "exif:SubSecTime" },
1008 { 0x9291, "exif:SubSecTimeOriginal" },
1009 { 0x9292, "exif:SubSecTimeDigitized" },
1010 { 0xa000, "exif:FlashPixVersion" },
1011 { 0xa001, "exif:ColorSpace" },
1012 { 0xa002, "exif:ExifImageWidth" },
1013 { 0xa003, "exif:ExifImageLength" },
1014 { 0xa004, "exif:RelatedSoundFile" },
1015 { 0xa005, "exif:InteroperabilityOffset" },
1016 { 0xa20b, "exif:FlashEnergy" },
1017 { 0xa20c, "exif:SpatialFrequencyResponse" },
1018 { 0xa20d, "exif:Noise" },
1019 { 0xa20e, "exif:FocalPlaneXResolution" },
1020 { 0xa20f, "exif:FocalPlaneYResolution" },
1021 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1022 { 0xa214, "exif:SubjectLocation" },
1023 { 0xa215, "exif:ExposureIndex" },
1024 { 0xa216, "exif:TIFF/EPStandardID" },
1025 { 0xa217, "exif:SensingMethod" },
1026 { 0xa300, "exif:FileSource" },
1027 { 0xa301, "exif:SceneType" },
1028 { 0xa302, "exif:CFAPattern" },
1029 { 0xa401, "exif:CustomRendered" },
1030 { 0xa402, "exif:ExposureMode" },
1031 { 0xa403, "exif:WhiteBalance" },
1032 { 0xa404, "exif:DigitalZoomRatio" },
1033 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1034 { 0xa406, "exif:SceneCaptureType" },
1035 { 0xa407, "exif:GainControl" },
1036 { 0xa408, "exif:Contrast" },
1037 { 0xa409, "exif:Saturation" },
1038 { 0xa40a, "exif:Sharpness" },
1039 { 0xa40b, "exif:DeviceSettingDescription" },
1040 { 0xa40c, "exif:SubjectDistanceRange" },
1041 { 0xa420, "exif:ImageUniqueID" },
1042 { 0xc4a5, "exif:PrintImageMatching" },
1043 { 0xa500, "exif:Gamma" },
1044 { 0xc640, "exif:CR2Slice" },
1045 { 0x10000, "exif:GPSVersionID" },
1046 { 0x10001, "exif:GPSLatitudeRef" },
1047 { 0x10002, "exif:GPSLatitude" },
1048 { 0x10003, "exif:GPSLongitudeRef" },
1049 { 0x10004, "exif:GPSLongitude" },
1050 { 0x10005, "exif:GPSAltitudeRef" },
1051 { 0x10006, "exif:GPSAltitude" },
1052 { 0x10007, "exif:GPSTimeStamp" },
1053 { 0x10008, "exif:GPSSatellites" },
1054 { 0x10009, "exif:GPSStatus" },
1055 { 0x1000a, "exif:GPSMeasureMode" },
1056 { 0x1000b, "exif:GPSDop" },
1057 { 0x1000c, "exif:GPSSpeedRef" },
1058 { 0x1000d, "exif:GPSSpeed" },
1059 { 0x1000e, "exif:GPSTrackRef" },
1060 { 0x1000f, "exif:GPSTrack" },
1061 { 0x10010, "exif:GPSImgDirectionRef" },
1062 { 0x10011, "exif:GPSImgDirection" },
1063 { 0x10012, "exif:GPSMapDatum" },
1064 { 0x10013, "exif:GPSDestLatitudeRef" },
1065 { 0x10014, "exif:GPSDestLatitude" },
1066 { 0x10015, "exif:GPSDestLongitudeRef" },
1067 { 0x10016, "exif:GPSDestLongitude" },
1068 { 0x10017, "exif:GPSDestBearingRef" },
1069 { 0x10018, "exif:GPSDestBearing" },
1070 { 0x10019, "exif:GPSDestDistanceRef" },
1071 { 0x1001a, "exif:GPSDestDistance" },
1072 { 0x1001b, "exif:GPSProcessingMethod" },
1073 { 0x1001c, "exif:GPSAreaInformation" },
1074 { 0x1001d, "exif:GPSDateStamp" },
1075 { 0x1001e, "exif:GPSDifferential" },
1087 directory_stack[MaxDirectoryStack];
1108 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1117 If EXIF data exists, then try to parse the request for a tag.
1119 profile=GetImageProfile(image,"exif");
1120 if (profile == (StringInfo *) NULL)
1121 return(MagickFalse);
1122 if ((property == (const char *) NULL) || (*property == '\0'))
1123 return(MagickFalse);
1124 while (isspace((int) ((unsigned char) *property)) != 0)
1128 switch (*(property+5))
1133 Caller has asked for all the tags in the EXIF data.
1136 all=1; /* return the data in description=value format */
1142 all=2; /* return the data in tagid=value format */
1155 Check for a hex based tag specification first.
1157 tag=(*(property+5) == '@') ? 1UL : 0UL;
1161 return(MagickFalse);
1163 Parse tag specification as a hex number.
1168 for (i=(long) n-1L; i >= 0; i--)
1172 if ((c >= '0') && (c <= '9'))
1175 if ((c >= 'A') && (c <= 'F'))
1178 if ((c >= 'a') && (c <= 'f'))
1181 return(MagickFalse);
1183 } while (*property != '\0');
1189 Try to match the text with a tag name instead.
1193 if (EXIFTag[i].tag == 0)
1195 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1197 tag=(unsigned long) EXIFTag[i].tag;
1205 return(MagickFalse);
1206 length=GetStringInfoLength(profile);
1207 exif=GetStringInfoDatum(profile);
1210 if (ReadPropertyByte(&exif,&length) != 0x45)
1212 if (ReadPropertyByte(&exif,&length) != 0x78)
1214 if (ReadPropertyByte(&exif,&length) != 0x69)
1216 if (ReadPropertyByte(&exif,&length) != 0x66)
1218 if (ReadPropertyByte(&exif,&length) != 0x00)
1220 if (ReadPropertyByte(&exif,&length) != 0x00)
1225 return(MagickFalse);
1226 id=(long) ReadPropertyShort(LSBEndian,exif);
1234 return(MagickFalse);
1235 if (ReadPropertyShort(endian,exif+2) != 0x002a)
1236 return(MagickFalse);
1238 This the offset to the first IFD.
1240 offset=(ssize_t) ReadPropertyLong(endian,exif+4);
1241 if ((size_t) offset >= length)
1242 return(MagickFalse);
1244 Set the pointer to the first IFD and follow it were it leads.
1246 directory=exif+offset;
1253 If there is anything on the stack then pop it off.
1258 directory=directory_stack[level].directory;
1259 entry=directory_stack[level].entry;
1260 tag_offset=directory_stack[level].offset;
1263 Determine how many entries there are in the current IFD.
1265 number_entries=ReadPropertyShort(endian,directory);
1266 for ( ; entry < number_entries; entry++)
1271 register unsigned char
1281 q=(unsigned char *) (directory+2+(12*entry));
1282 tag_value=(long) ReadPropertyShort(endian,q)+tag_offset;
1283 format=(unsigned long) ReadPropertyShort(endian,q+2);
1284 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1286 components=(long) 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) ReadPropertyLong(endian,q+8);
1299 if ((size_t) (offset+number_bytes) > length)
1301 p=(unsigned char *) (exif+offset);
1303 if ((all != 0) || (tag == (unsigned long) tag_value))
1306 buffer[MaxTextExtent],
1312 case EXIF_FMT_UNDEFINED:
1314 EXIFMultipleValues(1,"%lu",(unsigned long)
1315 (*(unsigned char *) p1));
1318 case EXIF_FMT_SBYTE:
1320 EXIFMultipleValues(1,"%ld",(long) (*(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,"%lu",ReadPropertyLong(endian,p1));
1338 case EXIF_FMT_SLONG:
1340 EXIFMultipleValues(4,"%ld",ReadPropertyLong(endian,p1));
1343 case EXIF_FMT_URATIONAL:
1345 EXIFMultipleFractions(8,"%ld/%ld",ReadPropertyLong(endian,p1),
1346 ReadPropertyLong(endian,p1+4));
1349 case EXIF_FMT_SRATIONAL:
1351 EXIFMultipleFractions(8,"%ld/%ld",ReadPropertyLong(endian,p1),
1352 ReadPropertyLong(endian,p1+4));
1355 case EXIF_FMT_SINGLE:
1357 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1360 case EXIF_FMT_DOUBLE:
1362 EXIFMultipleValues(8,"%f",*(double *) p1);
1366 case EXIF_FMT_STRING:
1368 value=(char *) NULL;
1369 if (~(1UL*number_bytes) >= 1)
1370 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1372 if (value != (char *) NULL)
1377 for (i=0; i < (long) number_bytes; i++)
1380 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1381 value[i]=(char) p[i];
1388 if (value != (char *) NULL)
1396 (void) CopyMagickString(key,property,MaxTextExtent);
1407 description="unknown";
1410 if (EXIFTag[i].tag == 0)
1412 if ((long) EXIFTag[i].tag == tag_value)
1414 description=EXIFTag[i].description;
1418 (void) FormatMagickString(key,MaxTextExtent,"%s",
1424 if (tag_value < 0x10000)
1425 (void) FormatMagickString(key,MaxTextExtent,"#%04lx",
1428 if (tag_value < 0x20000)
1429 (void) FormatMagickString(key,MaxTextExtent,"@%04lx",
1430 tag_value & 0xffff);
1432 (void) FormatMagickString(key,MaxTextExtent,"unknown");
1436 p=(const char *) NULL;
1437 if (image->properties != (void *) NULL)
1438 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1439 image->properties,key);
1440 if (p == (const char *) NULL)
1441 (void) SetImageProperty((Image *) image,key,value);
1442 value=DestroyString(value);
1445 if ((tag_value == TAG_EXIF_OFFSET) ||
1446 (tag_value == TAG_INTEROP_OFFSET) ||
1447 (tag_value == TAG_GPS_OFFSET))
1452 offset=(size_t) ReadPropertyLong(endian,p);
1453 if ((offset < length) && (level < (MaxDirectoryStack-2)))
1458 tag_offset1=(tag_value == TAG_GPS_OFFSET) ? 0x10000UL : 0UL;
1459 directory_stack[level].directory=directory;
1461 directory_stack[level].entry=entry;
1462 directory_stack[level].offset=tag_offset;
1464 directory_stack[level].directory=exif+offset;
1465 directory_stack[level].offset=tag_offset1;
1466 directory_stack[level].entry=0;
1468 if ((directory+2+(12*number_entries)) > (exif+length))
1470 offset=(size_t) ReadPropertyLong(endian,directory+2+(12*
1472 if ((offset != 0) && (offset < length) &&
1473 (level < (MaxDirectoryStack-2)))
1475 directory_stack[level].directory=exif+offset;
1476 directory_stack[level].entry=0;
1477 directory_stack[level].offset=tag_offset1;
1484 } while (level > 0);
1488 static MagickBooleanType GetXMPProperty(const Image *image,
1489 const char *property)
1513 profile=GetImageProfile(image,"xmp");
1514 if (profile == (StringInfo *) NULL)
1515 return(MagickFalse);
1516 if ((property == (const char *) NULL) || (*property == '\0'))
1517 return(MagickFalse);
1518 xmp_profile=StringInfoToString(profile);
1519 if (xmp_profile == (char *) NULL)
1520 return(MagickFalse);
1521 for (p=xmp_profile; *p != '\0'; p++)
1522 if ((*p == '<') && (*(p+1) == 'x'))
1524 exception=AcquireExceptionInfo();
1525 xmp=NewXMLTree((char *) p,exception);
1526 xmp_profile=DestroyString(xmp_profile);
1527 exception=DestroyExceptionInfo(exception);
1528 if (xmp == (XMLTreeInfo *) NULL)
1529 return(MagickFalse);
1531 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1532 if (rdf != (XMLTreeInfo *) NULL)
1534 if (image->properties == (void *) NULL)
1535 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1536 RelinquishMagickMemory,RelinquishMagickMemory);
1537 description=GetXMLTreeChild(rdf,"rdf:Description");
1538 while (description != (XMLTreeInfo *) NULL)
1540 node=GetXMLTreeChild(description,(const char *) NULL);
1541 while (node != (XMLTreeInfo *) NULL)
1543 child=GetXMLTreeChild(node,(const char *) NULL);
1544 if (child == (XMLTreeInfo *) NULL)
1545 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1546 ConstantString(GetXMLTreeTag(node)),
1547 ConstantString(GetXMLTreeContent(node)));
1548 while (child != (XMLTreeInfo *) NULL)
1550 if (LocaleCompare(GetXMLTreeTag(child),"rdf:Seq") != 0)
1551 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1552 ConstantString(GetXMLTreeTag(child)),
1553 ConstantString(GetXMLTreeContent(child)));
1554 child=GetXMLTreeSibling(child);
1556 node=GetXMLTreeSibling(node);
1558 description=GetNextXMLTreeTag(description);
1561 xmp=DestroyXMLTree(xmp);
1565 static char *TracePSClippath(const unsigned char *blob,size_t length,
1566 const unsigned long magick_unused(columns),
1567 const unsigned long magick_unused(rows))
1590 path=AcquireString((char *) NULL);
1591 if (path == (char *) NULL)
1592 return((char *) NULL);
1593 message=AcquireString((char *) NULL);
1594 (void) FormatMagickString(message,MaxTextExtent,"/ClipImage\n");
1595 (void) ConcatenateString(&path,message);
1596 (void) FormatMagickString(message,MaxTextExtent,"{\n");
1597 (void) ConcatenateString(&path,message);
1598 (void) FormatMagickString(message,MaxTextExtent," /c {curveto} bind def\n");
1599 (void) ConcatenateString(&path,message);
1600 (void) FormatMagickString(message,MaxTextExtent," /l {lineto} bind def\n");
1601 (void) ConcatenateString(&path,message);
1602 (void) FormatMagickString(message,MaxTextExtent," /m {moveto} bind def\n");
1603 (void) ConcatenateString(&path,message);
1604 (void) FormatMagickString(message,MaxTextExtent,
1605 " /v {currentpoint 6 2 roll curveto} bind def\n");
1606 (void) ConcatenateString(&path,message);
1607 (void) FormatMagickString(message,MaxTextExtent,
1608 " /y {2 copy curveto} bind def\n");
1609 (void) ConcatenateString(&path,message);
1610 (void) FormatMagickString(message,MaxTextExtent,
1611 " /z {closepath} bind def\n");
1612 (void) ConcatenateString(&path,message);
1613 (void) FormatMagickString(message,MaxTextExtent," newpath\n");
1614 (void) ConcatenateString(&path,message);
1616 The clipping path format is defined in "Adobe Photoshop File
1617 Formats Specification" version 6.0 downloadable from adobe.com.
1619 (void) ResetMagickMemory(point,0,sizeof(point));
1620 (void) ResetMagickMemory(first,0,sizeof(first));
1621 (void) ResetMagickMemory(last,0,sizeof(last));
1623 in_subpath=MagickFalse;
1626 selector=(long) ReadPropertyMSBShort(&blob,&length);
1632 if (knot_count != 0)
1639 Expected subpath length record.
1641 knot_count=(long) ReadPropertyMSBShort(&blob,&length);
1651 if (knot_count == 0)
1654 Unexpected subpath knot
1663 for (i=0; i < 3; i++)
1669 yy=ReadPropertyMSBLong(&blob,&length);
1670 xx=ReadPropertyMSBLong(&blob,&length);
1672 if (xx > 2147483647)
1675 if (yy > 2147483647)
1677 point[i].x=(double) x/4096/4096;
1678 point[i].y=1.0-(double) y/4096/4096;
1680 if (in_subpath == MagickFalse)
1682 (void) FormatMagickString(message,MaxTextExtent," %.15g %.15g m\n",
1683 point[1].x,point[1].y);
1684 for (i=0; i < 3; i++)
1693 Handle special cases when Bezier curves are used to describe
1694 corners and straight lines.
1696 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1697 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1698 (void) FormatMagickString(message,MaxTextExtent,
1699 " %.15g %.15g l\n",point[1].x,point[1].y);
1701 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1702 (void) FormatMagickString(message,MaxTextExtent,
1703 " %.15g %.15g %.15g %.15g v\n",point[0].x,point[0].y,
1704 point[1].x,point[1].y);
1706 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1707 (void) FormatMagickString(message,MaxTextExtent,
1708 " %.15g %.15g %.15g %.15g y\n",last[2].x,last[2].y,
1709 point[1].x,point[1].y);
1711 (void) FormatMagickString(message,MaxTextExtent,
1712 " %.15g %.15g %.15g %.15g %.15g %.15g c\n",last[2].x,
1713 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1714 for (i=0; i < 3; i++)
1717 (void) ConcatenateString(&path,message);
1718 in_subpath=MagickTrue;
1721 Close the subpath if there are no more knots.
1723 if (knot_count == 0)
1726 Same special handling as above except we compare to the
1727 first point in the path and close the path.
1729 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1730 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1731 (void) FormatMagickString(message,MaxTextExtent,
1732 " %.15g %.15g l z\n",first[1].x,first[1].y);
1734 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1735 (void) FormatMagickString(message,MaxTextExtent,
1736 " %.15g %.15g %.15g %.15g v z\n",first[0].x,first[0].y,
1737 first[1].x,first[1].y);
1739 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1740 (void) FormatMagickString(message,MaxTextExtent,
1741 " %.15g %.15g %.15g %.15g y z\n",last[2].x,last[2].y,
1742 first[1].x,first[1].y);
1744 (void) FormatMagickString(message,MaxTextExtent,
1745 " %.15g %.15g %.15g %.15g %.15g %.15g c z\n",last[2].x,
1746 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1747 (void) ConcatenateString(&path,message);
1748 in_subpath=MagickFalse;
1764 Returns an empty PS path if the path has no knots.
1766 (void) FormatMagickString(message,MaxTextExtent," eoclip\n");
1767 (void) ConcatenateString(&path,message);
1768 (void) FormatMagickString(message,MaxTextExtent,"} bind def");
1769 (void) ConcatenateString(&path,message);
1770 message=DestroyString(message);
1774 static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1775 const unsigned long columns,const unsigned long rows)
1798 path=AcquireString((char *) NULL);
1799 if (path == (char *) NULL)
1800 return((char *) NULL);
1801 message=AcquireString((char *) NULL);
1802 (void) FormatMagickString(message,MaxTextExtent,
1803 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
1804 (void) ConcatenateString(&path,message);
1805 (void) FormatMagickString(message,MaxTextExtent,
1806 "<svg width=\"%lu\" height=\"%lu\">\n",columns,rows);
1807 (void) ConcatenateString(&path,message);
1808 (void) FormatMagickString(message,MaxTextExtent,"<g>\n");
1809 (void) ConcatenateString(&path,message);
1810 (void) FormatMagickString(message,MaxTextExtent,
1811 "<path style=\"fill:#00000000;stroke:#00000000;");
1812 (void) ConcatenateString(&path,message);
1813 (void) FormatMagickString(message,MaxTextExtent,
1814 "stroke-width:0;stroke-antialiasing:false\" d=\"\n");
1815 (void) ConcatenateString(&path,message);
1816 (void) ResetMagickMemory(point,0,sizeof(point));
1817 (void) ResetMagickMemory(first,0,sizeof(first));
1818 (void) ResetMagickMemory(last,0,sizeof(last));
1820 in_subpath=MagickFalse;
1823 selector=(long) ReadPropertyMSBShort(&blob,&length);
1829 if (knot_count != 0)
1836 Expected subpath length record.
1838 knot_count=(long) ReadPropertyMSBShort(&blob,&length);
1848 if (knot_count == 0)
1851 Unexpected subpath knot.
1860 for (i=0; i < 3; i++)
1866 yy=ReadPropertyMSBLong(&blob,&length);
1867 xx=ReadPropertyMSBLong(&blob,&length);
1869 if (xx > 2147483647)
1872 if (yy > 2147483647)
1874 point[i].x=(double) x*columns/4096/4096;
1875 point[i].y=(double) y*rows/4096/4096;
1877 if (in_subpath == MagickFalse)
1879 (void) FormatMagickString(message,MaxTextExtent,"M %.15g,%.15g\n",
1880 point[1].x,point[1].y);
1881 for (i=0; i < 3; i++)
1889 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1890 (point[0].x == point[1].x) && (point[0].y == point[1].y))
1891 (void) FormatMagickString(message,MaxTextExtent,"L %.15g,%.15g\n",
1892 point[1].x,point[1].y);
1894 (void) FormatMagickString(message,MaxTextExtent,
1895 "C %.15g,%.15g %.15g,%.15g %.15g,%.15g\n",last[2].x,last[2].y,
1896 point[0].x,point[0].y,point[1].x,point[1].y);
1897 for (i=0; i < 3; i++)
1900 (void) ConcatenateString(&path,message);
1901 in_subpath=MagickTrue;
1904 Close the subpath if there are no more knots.
1906 if (knot_count == 0)
1908 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1909 (first[0].x == first[1].x) && (first[0].y == first[1].y))
1910 (void) FormatMagickString(message,MaxTextExtent,
1911 "L %.15g,%.15g Z\n",first[1].x,first[1].y);
1914 (void) FormatMagickString(message,MaxTextExtent,
1915 "C %.15g,%.15g %.15g,%.15g %.15g,%.15g Z\n",last[2].x,
1916 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1917 (void) ConcatenateString(&path,message);
1919 in_subpath=MagickFalse;
1935 Return an empty SVG image if the path does not have knots.
1937 (void) FormatMagickString(message,MaxTextExtent,"\"/>\n");
1938 (void) ConcatenateString(&path,message);
1939 (void) FormatMagickString(message,MaxTextExtent,"</g>\n");
1940 (void) ConcatenateString(&path,message);
1941 (void) FormatMagickString(message,MaxTextExtent,"</svg>\n");
1942 (void) ConcatenateString(&path,message);
1943 message=DestroyString(message);
1947 MagickExport const char *GetImageProperty(const Image *image,
1948 const char *property)
1965 assert(image != (Image *) NULL);
1966 assert(image->signature == MagickSignature);
1967 if (image->debug != MagickFalse)
1968 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1969 p=(const char *) NULL;
1970 if (property == (const char *) NULL)
1972 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
1973 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
1977 if ((image->properties != (void *) NULL) &&
1978 (LocaleNCompare("fx:",property,3) != 0))
1980 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1981 image->properties,property);
1982 if (p != (const char *) NULL)
1985 if (strchr(property,':') == (char *) NULL)
1987 exception=(&((Image *) image)->exception);
1992 if (LocaleNCompare("8bim:",property,5) == 0)
1994 if (Get8BIMProperty(image,property) != MagickFalse)
1996 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1997 image->properties,property);
2006 if (LocaleNCompare("exif:",property,5) == 0)
2008 if (GetEXIFProperty(image,property) != MagickFalse)
2010 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2011 image->properties,property);
2020 if (LocaleNCompare("fx:",property,3) == 0)
2022 fx_info=AcquireFxInfo(image,property+3);
2023 status=FxEvaluateExpression(fx_info,&alpha,exception);
2024 fx_info=DestroyFxInfo(fx_info);
2025 if (status != MagickFalse)
2028 value[MaxTextExtent];
2030 (void) FormatMagickString(value,MaxTextExtent,"%.15g",(double)
2032 (void) SetImageProperty((Image *) image,property,value);
2034 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2035 image->properties,property);
2043 if (LocaleNCompare("iptc:",property,5) == 0)
2045 if (GetIPTCProperty(image,property) != MagickFalse)
2047 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2048 image->properties,property);
2057 if (LocaleNCompare("pixel:",property,6) == 0)
2062 GetMagickPixelPacket(image,&pixel);
2063 fx_info=AcquireFxInfo(image,property+6);
2064 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2066 pixel.red=(MagickRealType) QuantumRange*alpha;
2067 status|=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2069 pixel.green=(MagickRealType) QuantumRange*alpha;
2070 status|=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2072 pixel.blue=(MagickRealType) QuantumRange*alpha;
2073 status|=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2075 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2076 if (image->colorspace == CMYKColorspace)
2078 status|=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2080 pixel.index=(MagickRealType) QuantumRange*alpha;
2082 fx_info=DestroyFxInfo(fx_info);
2083 if (status != MagickFalse)
2086 name[MaxTextExtent];
2088 (void) QueryMagickColorname(image,&pixel,SVGCompliance,name,
2090 (void) SetImageProperty((Image *) image,property,name);
2091 return(GetImageProperty(image,property));
2099 if (LocaleNCompare("xmp:",property,4) == 0)
2101 if (GetXMPProperty(image,property) != MagickFalse)
2103 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2104 image->properties,property);
2115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2119 + G e t M a g i c k P r o p e r t y %
2123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2125 % GetMagickProperty() gets a value associated with an image property.
2127 % The format of the GetMagickProperty method is:
2129 % const char *GetMagickProperty(const ImageInfo *image_info,
2130 % Image *image,const char *key)
2132 % A description of each parameter follows:
2134 % o image_info: the image info.
2136 % o image: the image.
2141 MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
2142 Image *image,const char *property)
2145 value[MaxTextExtent],
2146 filename[MaxTextExtent];
2149 switch (*(property))
2153 if (LocaleNCompare("base",property,4) == 0)
2155 GetPathComponent(image->magick_filename,BasePath,filename);
2156 (void) CopyMagickString(value,filename,MaxTextExtent);
2163 if (LocaleNCompare("channels",property,8) == 0)
2168 (void) FormatMagickString(value,MaxTextExtent,"%s",
2169 MagickOptionToMnemonic(MagickColorspaceOptions,(long)
2170 image->colorspace));
2172 if (image->matte != MagickFalse)
2173 (void) ConcatenateMagickString(value,"a",MaxTextExtent);
2176 if (LocaleNCompare("colorspace",property,10) == 0)
2182 Image storage class and colorspace.
2184 colorspace=image->colorspace;
2185 if (IsGrayImage(image,&image->exception) != MagickFalse)
2186 colorspace=GRAYColorspace;
2187 (void) FormatMagickString(value,MaxTextExtent,"%s",
2188 MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace));
2195 if (LocaleNCompare("depth",property,5) == 0)
2197 (void) FormatMagickString(value,MaxTextExtent,"%lu",image->depth);
2200 if (LocaleNCompare("directory",property,9) == 0)
2202 GetPathComponent(image->magick_filename,HeadPath,filename);
2203 (void) CopyMagickString(value,filename,MaxTextExtent);
2210 if (LocaleNCompare("extension",property,9) == 0)
2212 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2213 (void) CopyMagickString(value,filename,MaxTextExtent);
2220 if (LocaleNCompare("group",property,5) == 0)
2222 (void) FormatMagickString(value,MaxTextExtent,"0x%lx",
2230 if (LocaleNCompare("height",property,6) == 0)
2232 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2233 image->magick_rows != 0 ? image->magick_rows : 256UL);
2240 if (LocaleNCompare("input",property,5) == 0)
2242 (void) CopyMagickString(value,image->filename,MaxTextExtent);
2249 if (LocaleNCompare("kurtosis",property,8) == 0)
2255 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2256 &skewness,&image->exception);
2257 (void) FormatMagickString(value,MaxTextExtent,"%.15g",kurtosis);
2264 if (LocaleNCompare("magick",property,6) == 0)
2266 (void) CopyMagickString(value,image->magick,MaxTextExtent);
2269 if (LocaleNCompare("max",property,3) == 0)
2275 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2276 &maximum,&image->exception);
2277 (void) FormatMagickString(value,MaxTextExtent,"%.15g",maximum);
2280 if (LocaleNCompare("mean",property,4) == 0)
2286 (void) GetImageChannelMean(image,image_info->channel,&mean,
2287 &standard_deviation,&image->exception);
2288 (void) FormatMagickString(value,MaxTextExtent,"%.15g",mean);
2291 if (LocaleNCompare("min",property,3) == 0)
2297 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2298 &maximum,&image->exception);
2299 (void) FormatMagickString(value,MaxTextExtent,"%.15g",minimum);
2306 if (LocaleNCompare("name",property,4) == 0)
2308 (void) CopyMagickString(value,filename,MaxTextExtent);
2315 if (LocaleNCompare("output",property,6) == 0)
2317 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
2324 if (LocaleNCompare("page",property,4) == 0)
2326 register const Image
2333 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2334 p=GetPreviousImageInList(p);
2335 (void) FormatMagickString(value,MaxTextExtent,"%lu",page);
2342 if (LocaleNCompare("size",property,4) == 0)
2345 format[MaxTextExtent];
2347 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
2348 (void) FormatMagickString(value,MaxTextExtent,"%s",format);
2351 if (LocaleNCompare("scenes",property,6) == 0)
2353 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2354 (unsigned long) GetImageListLength(image));
2357 if (LocaleNCompare("scene",property,5) == 0)
2359 (void) FormatMagickString(value,MaxTextExtent,"%lu",image->scene);
2360 if (image_info->number_scenes != 0)
2361 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2365 if (LocaleNCompare("skewness",property,8) == 0)
2371 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2372 &skewness,&image->exception);
2373 (void) FormatMagickString(value,MaxTextExtent,"%.15g",skewness);
2376 if ((LocaleNCompare("standard-deviation",property,18) == 0) ||
2377 (LocaleNCompare("standard_deviation",property,18) == 0))
2383 (void) GetImageChannelMean(image,image_info->channel,&mean,
2384 &standard_deviation,&image->exception);
2385 (void) FormatMagickString(value,MaxTextExtent,"%.15g",
2386 standard_deviation);
2393 if (LocaleNCompare("unique",property,6) == 0)
2395 (void) CopyMagickString(filename,image_info->unique,MaxTextExtent);
2396 (void) CopyMagickString(value,filename,MaxTextExtent);
2403 if (LocaleNCompare("width",property,5) == 0)
2405 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2406 image->magick_columns != 0 ? image->magick_columns : 256UL);
2413 if (LocaleNCompare("xresolution",property,11) == 0)
2415 (void) FormatMagickString(value,MaxTextExtent,"%.15g",
2416 image->x_resolution);
2423 if (LocaleNCompare("yresolution",property,11) == 0)
2425 (void) FormatMagickString(value,MaxTextExtent,"%.15g",
2426 image->y_resolution);
2433 if (LocaleNCompare("zero",property,4) == 0)
2435 (void) CopyMagickString(filename,image_info->zero,MaxTextExtent);
2436 (void) CopyMagickString(value,filename,MaxTextExtent);
2444 if (image->properties == (void *) NULL)
2445 image->properties=NewSplayTree(CompareSplayTreeString,
2446 RelinquishMagickMemory,RelinquishMagickMemory);
2447 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
2448 ConstantString(property),ConstantString(value));
2450 return(GetImageProperty(image,property));
2454 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2458 % G e t N e x t I m a g e P r o p e r t y %
2462 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2464 % GetNextImageProperty() gets the next image property value.
2466 % The format of the GetNextImageProperty method is:
2468 % char *GetNextImageProperty(const Image *image)
2470 % A description of each parameter follows:
2472 % o image: the image.
2475 MagickExport char *GetNextImageProperty(const Image *image)
2477 assert(image != (Image *) NULL);
2478 assert(image->signature == MagickSignature);
2479 if (image->debug != MagickFalse)
2480 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2482 if (image->properties == (void *) NULL)
2483 return((char *) NULL);
2484 return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
2488 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2492 % I n t e r p r e t I m a g e P r o p e r t i e s %
2496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2498 % InterpretImageProperties() replaces any embedded formatting characters with
2499 % the appropriate image property and returns the interpretted text.
2501 % The format of the InterpretImageProperties method is:
2503 % char *InterpretImageProperties(const ImageInfo *image_info,Image *image,
2504 % const char *embed_text)
2506 % A description of each parameter follows:
2508 % o image_info: the image info.
2510 % o image: the image.
2512 % o embed_text: the address of a character string containing the embedded
2513 % formatting characters.
2516 MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
2517 Image *image,const char *embed_text)
2520 filename[MaxTextExtent],
2543 assert(image != (Image *) NULL);
2544 assert(image->signature == MagickSignature);
2545 if (image->debug != MagickFalse)
2546 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2547 if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))
2548 return((char *) NULL);
2549 text=(char *) embed_text;
2550 if ((*text == '@') && ((*(text+1) == '-') ||
2551 (IsPathAccessible(text+1) != MagickFalse)))
2552 return(FileToString(embed_text+1,~0,&image->exception));
2554 Translate any embedded format characters.
2556 text_info=CloneImageInfo(image_info);
2557 interpret_text=AcquireString(text);
2558 extent=MaxTextExtent;
2560 for (q=interpret_text; *p != '\0'; p++)
2563 if ((size_t) (q-interpret_text+MaxTextExtent) >= extent)
2565 extent+=MaxTextExtent;
2566 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2567 MaxTextExtent+1,sizeof(*interpret_text));
2568 if (interpret_text == (char *) NULL)
2570 q=interpret_text+strlen(interpret_text);
2573 Process formatting characters in text.
2575 if ((*p == '\\') && (*(p+1) == 'r'))
2581 if ((*p == '\\') && (*(p+1) == 'n'))
2604 format[MaxTextExtent];
2612 length=GetBlobSize(image);
2613 (void) FormatMagickString(format,MaxTextExtent,"%lu",(unsigned long)
2615 if (length != (MagickSizeType) ((size_t) length))
2616 (void) FormatMagickSize(length,MagickFalse,format);
2617 q+=ConcatenateMagickString(q,format,extent);
2625 value=GetImageProperty(image,"comment");
2626 if (value == (const char *) NULL)
2628 length=strlen(value);
2629 if ((size_t) (q-interpret_text+length+1) >= extent)
2632 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
2633 extent+MaxTextExtent,sizeof(*interpret_text));
2634 if (interpret_text == (char *) NULL)
2636 q=interpret_text+strlen(interpret_text);
2638 (void) CopyMagickString(q,value,extent);
2648 Label segment is the base of the filename.
2650 if (*image->magick_filename == '\0')
2659 GetPathComponent(image->magick_filename,HeadPath,filename);
2660 q+=CopyMagickString(q,filename,extent);
2668 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2669 q+=CopyMagickString(q,filename,extent);
2677 GetPathComponent(image->magick_filename,TailPath,filename);
2678 q+=CopyMagickString(q,filename,extent);
2686 GetPathComponent(image->magick_filename,BasePath,filename);
2687 q+=CopyMagickString(q,filename,extent);
2698 q+=FormatMagickString(q,extent,"%lux%lu%+ld%+ld",image->page.width,
2699 image->page.height,image->page.x,image->page.y);
2707 q+=FormatMagickString(q,extent,"%lu",image->rows != 0 ? image->rows :
2708 image->magick_rows);
2716 q+=CopyMagickString(q,image->filename,extent);
2722 Number of unique colors.
2724 q+=FormatMagickString(q,extent,"%lu",GetNumberColors(image,
2725 (FILE *) NULL,&image->exception));
2733 value=GetImageProperty(image,"label");
2734 if (value == (const char *) NULL)
2736 length=strlen(value);
2737 if ((size_t) (q-interpret_text+length+1) >= extent)
2740 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
2741 extent+MaxTextExtent,sizeof(*interpret_text));
2742 if (interpret_text == (char *) NULL)
2744 q=interpret_text+strlen(interpret_text);
2746 q+=CopyMagickString(q,value,extent);
2754 q+=CopyMagickString(q,image->magick,extent);
2760 Image magick filename.
2762 q+=CopyMagickString(q,image->magick_filename,extent);
2768 Number of images in the list.
2770 q+=FormatMagickString(q,extent,"%lu",(unsigned long)
2771 GetImageListLength(image));
2777 Image output filename.
2779 q+=CopyMagickString(q,text_info->filename,extent);
2784 register const Image
2794 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2795 p=GetPreviousImageInList(p);
2796 q+=FormatMagickString(q,extent,"%lu",page);
2804 q+=FormatMagickString(q,extent,"%lu",image->depth);
2813 Image storage class and colorspace.
2815 colorspace=image->colorspace;
2816 if (IsGrayImage(image,&image->exception) != MagickFalse)
2817 colorspace=GRAYColorspace;
2818 q+=FormatMagickString(q,extent,"%s%s%s",MagickOptionToMnemonic(
2819 MagickClassOptions,(long) image->storage_class),
2820 MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace),
2821 image->matte != MagickFalse ? "Matte" : "");
2829 if (text_info->number_scenes == 0)
2830 q+=FormatMagickString(q,extent,"%lu",image->scene);
2832 q+=FormatMagickString(q,extent,"%lu",text_info->scene);
2840 (void) CopyMagickString(filename,text_info->unique,extent);
2841 q+=CopyMagickString(q,filename,extent);
2849 q+=FormatMagickString(q,extent,"%lu",image->columns != 0 ?
2850 image->columns : image->magick_columns);
2856 Image horizontal resolution.
2858 q+=FormatMagickString(q,extent,"%.15g %s",image->x_resolution,
2859 MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
2865 Image vertical resolution.
2867 q+=FormatMagickString(q,extent,"%.15g %s",image->y_resolution,
2868 MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
2876 q+=FormatMagickString(q,extent,"%lu",image->depth);
2882 Image alpha channel.
2884 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2885 MagickBooleanOptions,(long) image->matte));
2891 Image compression method.
2893 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2894 MagickCompressOptions,(long) image->compression));
2900 Image dispose method.
2902 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2903 MagickDisposeOptions,(long) image->dispose));
2908 q+=FormatMagickString(q,extent,"%lux%lu",image->magick_columns,
2909 image->magick_rows);
2914 q+=FormatMagickString(q,extent,"%ld",image->page.height);
2919 q+=FormatMagickString(q,extent,"%+ld%+ld",image->page.x,image->page.y);
2924 q+=FormatMagickString(q,extent,"%lux%lu",image->page.width,
2925 image->page.height);
2930 q+=FormatMagickString(q,extent,"%lu",image->quality);
2938 if (text_info->number_scenes == 0)
2939 q+=CopyMagickString(q,"2147483647",extent);
2941 q+=FormatMagickString(q,extent,"%lu",text_info->scene+
2942 text_info->number_scenes);
2947 q+=FormatMagickString(q,extent,"%lu",image->delay);
2952 q+=FormatMagickString(q,extent,"%ld",image->page.width);
2957 q+=FormatMagickString(q,extent,"%+ld",image->page.x);
2962 q+=FormatMagickString(q,extent,"%+ld",image->page.y);
2970 (void) CopyMagickString(filename,text_info->zero,extent);
2971 q+=CopyMagickString(q,filename,extent);
2977 pattern[MaxTextExtent];
2989 if (strchr(p,']') == (char *) NULL)
2993 for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
3004 value=GetImageProperty(image,pattern);
3005 if (value != (const char *) NULL)
3007 length=strlen(value);
3008 if ((size_t) (q-interpret_text+length+1) >= extent)
3011 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3012 extent+MaxTextExtent,sizeof(*interpret_text));
3013 if (interpret_text == (char *) NULL)
3015 q=interpret_text+strlen(interpret_text);
3017 (void) CopyMagickString(q,value,extent);
3022 if (IsGlob(pattern) != MagickFalse)
3025 Iterate over image properties.
3027 ResetImagePropertyIterator(image);
3028 key=GetNextImageProperty(image);
3029 while (key != (const char *) NULL)
3031 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3033 value=GetImageProperty(image,key);
3034 if (value != (const char *) NULL)
3036 length=strlen(key)+strlen(value)+2;
3037 if ((size_t) (q-interpret_text+length+1) >= extent)
3040 interpret_text=(char *) ResizeQuantumMemory(
3041 interpret_text,extent+MaxTextExtent,
3042 sizeof(*interpret_text));
3043 if (interpret_text == (char *) NULL)
3045 q=interpret_text+strlen(interpret_text);
3047 q+=FormatMagickString(q,extent,"%s=%s\n",key,value);
3050 key=GetNextImageProperty(image);
3053 value=GetMagickProperty(text_info,image,pattern);
3054 if (value != (const char *) NULL)
3056 length=strlen(value);
3057 if ((size_t) (q-interpret_text+length+1) >= extent)
3060 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3061 extent+MaxTextExtent,sizeof(*interpret_text));
3062 if (interpret_text == (char *) NULL)
3064 q=interpret_text+strlen(interpret_text);
3066 (void) CopyMagickString(q,value,extent);
3069 if (image_info == (ImageInfo *) NULL)
3071 value=GetImageOption(image_info,pattern);
3072 if (value != (char *) NULL)
3074 length=strlen(value);
3075 if ((size_t) (q-interpret_text+length+1) >= extent)
3078 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3079 extent+MaxTextExtent,sizeof(*interpret_text));
3080 if (interpret_text == (char *) NULL)
3082 q=interpret_text+strlen(interpret_text);
3084 (void) CopyMagickString(q,value,extent);
3097 page=GetImageBoundingBox(image,&image->exception);
3098 q+=FormatMagickString(q,MaxTextExtent,"%lux%lu%+ld%+ld",page.width,
3099 page.height,page.x,page.y);
3107 (void) SignatureImage(image);
3108 value=GetImageProperty(image,"signature");
3109 if (value == (const char *) NULL)
3111 q+=CopyMagickString(q,value,extent);
3128 text_info=DestroyImageInfo(text_info);
3129 if (text != (const char *) embed_text)
3130 text=DestroyString(text);
3131 (void) SubstituteString(&interpret_text,"<","<");
3132 (void) SubstituteString(&interpret_text,">",">");
3133 return(interpret_text);
3137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3141 % R e m o v e I m a g e P r o p e r t y %
3145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3147 % RemoveImageProperty() removes a property from the image and returns its
3150 % The format of the RemoveImageProperty method is:
3152 % char *RemoveImageProperty(Image *image,const char *property)
3154 % A description of each parameter follows:
3156 % o image: the image.
3158 % o property: the image property.
3161 MagickExport char *RemoveImageProperty(Image *image,
3162 const char *property)
3167 assert(image != (Image *) NULL);
3168 assert(image->signature == MagickSignature);
3169 if (image->debug != MagickFalse)
3170 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3172 if (image->properties == (void *) NULL)
3173 return((char *) NULL);
3174 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3180 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3184 % 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 %
3188 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3190 % ResetImagePropertyIterator() resets the image properties iterator. Use it
3191 % in conjunction with GetNextImageProperty() to iterate over all the values
3192 % associated with an image property.
3194 % The format of the ResetImagePropertyIterator method is:
3196 % ResetImagePropertyIterator(Image *image)
3198 % A description of each parameter follows:
3200 % o image: the image.
3203 MagickExport void ResetImagePropertyIterator(const Image *image)
3205 assert(image != (Image *) NULL);
3206 assert(image->signature == MagickSignature);
3207 if (image->debug != MagickFalse)
3208 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3210 if (image->properties == (void *) NULL)
3212 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3220 % S e t I m a g e P r o p e r t y %
3224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3226 % SetImageProperty() associates an value with an image property.
3228 % The format of the SetImageProperty method is:
3230 % MagickBooleanType SetImageProperty(Image *image,const char *property,
3231 % const char *value)
3233 % A description of each parameter follows:
3235 % o image: the image.
3237 % o property: the image property.
3239 % o values: the image property values.
3242 MagickExport MagickBooleanType SetImageProperty(Image *image,
3243 const char *property,const char *value)
3251 assert(image != (Image *) NULL);
3252 assert(image->signature == MagickSignature);
3253 if (image->debug != MagickFalse)
3254 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3256 if (image->properties == (void *) NULL)
3257 image->properties=NewSplayTree(CompareSplayTreeString,
3258 RelinquishMagickMemory,RelinquishMagickMemory);
3259 if ((value == (const char *) NULL) || (*value == '\0'))
3260 return(DeleteImageProperty(image,property));
3267 if (LocaleCompare(property,"bias") == 0)
3269 image->bias=SiPrefixToDouble(value,QuantumRange);
3272 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3273 ConstantString(property),ConstantString(value));
3279 if (LocaleCompare(property,"colorspace") == 0)
3284 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
3288 (void) SetImageColorspace(image,(ColorspaceType) colorspace);
3291 if (LocaleCompare(property,"compose") == 0)
3296 compose=ParseMagickOption(MagickComposeOptions,MagickFalse,value);
3299 image->compose=(CompositeOperator) compose;
3302 if (LocaleCompare(property,"compress") == 0)
3307 compression=ParseMagickOption(MagickCompressOptions,MagickFalse,
3309 if (compression < 0)
3311 image->compression=(CompressionType) compression;
3314 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3315 ConstantString(property),ConstantString(value));
3321 if (LocaleCompare(property,"delay") == 0)
3326 flags=ParseGeometry(value,&geometry_info);
3327 if ((flags & GreaterValue) != 0)
3329 if (image->delay > (unsigned long) (geometry_info.rho+0.5))
3330 image->delay=(unsigned long) (geometry_info.rho+0.5);
3333 if ((flags & LessValue) != 0)
3335 if (image->delay < (unsigned long) (geometry_info.rho+0.5))
3336 image->ticks_per_second=(long) (geometry_info.sigma+0.5);
3339 image->delay=(unsigned long) (geometry_info.rho+0.5);
3340 if ((flags & SigmaValue) != 0)
3341 image->ticks_per_second=(long) (geometry_info.sigma+0.5);
3344 if (LocaleCompare(property,"depth") == 0)
3346 image->depth=StringToUnsignedLong(value);
3349 if (LocaleCompare(property,"dispose") == 0)
3354 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,value);
3357 image->dispose=(DisposeType) dispose;
3360 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3361 ConstantString(property),ConstantString(value));
3367 if (LocaleCompare(property,"gravity") == 0)
3372 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
3375 image->gravity=(GravityType) gravity;
3378 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3379 ConstantString(property),ConstantString(value));
3385 if (LocaleCompare(property,"intent") == 0)
3390 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3392 if (rendering_intent < 0)
3394 image->rendering_intent=(RenderingIntent) rendering_intent;
3397 if (LocaleCompare(property,"interpolate") == 0)
3402 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
3404 if (interpolate < 0)
3406 image->interpolate=(InterpolatePixelMethod) interpolate;
3409 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3410 ConstantString(property),ConstantString(value));
3416 if (LocaleCompare(property,"loop") == 0)
3418 image->iterations=StringToUnsignedLong(value);
3421 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3422 ConstantString(property),ConstantString(value));
3428 if (LocaleCompare(property,"page") == 0)
3433 geometry=GetPageGeometry(value);
3434 flags=ParseAbsoluteGeometry(geometry,&image->page);
3435 geometry=DestroyString(geometry);
3438 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3439 ConstantString(property),ConstantString(value));
3445 if (LocaleCompare(property,"rendering-intent") == 0)
3450 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3452 if (rendering_intent < 0)
3454 image->rendering_intent=(RenderingIntent) rendering_intent;
3457 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3458 ConstantString(property),ConstantString(value));
3464 if (LocaleCompare(property,"tile-offset") == 0)
3469 geometry=GetPageGeometry(value);
3470 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3471 geometry=DestroyString(geometry);
3474 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3475 ConstantString(property),ConstantString(value));
3480 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3481 ConstantString(property),ConstantString(value));