43 #include "MagickCore/studio.h"
44 #include "MagickCore/artifact.h"
45 #include "MagickCore/attribute.h"
46 #include "MagickCore/cache.h"
47 #include "MagickCore/cache-private.h"
48 #include "MagickCore/color.h"
49 #include "MagickCore/color-private.h"
50 #include "MagickCore/colorspace-private.h"
51 #include "MagickCore/compare.h"
52 #include "MagickCore/constitute.h"
53 #include "MagickCore/draw.h"
54 #include "MagickCore/effect.h"
55 #include "MagickCore/exception.h"
56 #include "MagickCore/exception-private.h"
57 #include "MagickCore/fx.h"
58 #include "MagickCore/fx-private.h"
59 #include "MagickCore/gem.h"
60 #include "MagickCore/geometry.h"
61 #include "MagickCore/histogram.h"
62 #include "MagickCore/image.h"
63 #include "MagickCore/layer.h"
64 #include "MagickCore/locale-private.h"
65 #include "MagickCore/list.h"
66 #include "MagickCore/magick.h"
67 #include "MagickCore/memory_.h"
68 #include "MagickCore/monitor.h"
69 #include "MagickCore/montage.h"
70 #include "MagickCore/option.h"
71 #include "MagickCore/policy.h"
72 #include "MagickCore/profile.h"
73 #include "MagickCore/property.h"
74 #include "MagickCore/quantum.h"
75 #include "MagickCore/resource_.h"
76 #include "MagickCore/splay-tree.h"
77 #include "MagickCore/signature.h"
78 #include "MagickCore/statistic.h"
79 #include "MagickCore/string_.h"
80 #include "MagickCore/string-private.h"
81 #include "MagickCore/token.h"
82 #include "MagickCore/token-private.h"
83 #include "MagickCore/utility.h"
84 #include "MagickCore/utility-private.h"
85 #include "MagickCore/version.h"
86 #include "MagickCore/xml-tree.h"
87 #include "MagickCore/xml-tree-private.h"
88 #if defined(MAGICKCORE_LCMS_DELEGATE)
89 #if defined(MAGICKCORE_HAVE_LCMS2_LCMS2_H)
90 #include <lcms2/lcms2.h>
91 #elif defined(MAGICKCORE_HAVE_LCMS2_H)
93 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
94 #include <lcms/lcms.h>
103 #if defined(MAGICKCORE_LCMS_DELEGATE)
104 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
105 #define cmsUInt32Number DWORD
134 MagickExport MagickBooleanType CloneImageProperties(
Image *image,
135 const Image *clone_image)
137 assert(image != (
Image *) NULL);
138 assert(image->signature == MagickCoreSignature);
139 assert(clone_image != (
const Image *) NULL);
140 assert(clone_image->signature == MagickCoreSignature);
141 if (IsEventLogging() != MagickFalse)
143 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
144 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
145 clone_image->filename);
147 (void) CopyMagickString(image->filename,clone_image->filename,
149 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
151 image->compression=clone_image->compression;
152 image->quality=clone_image->quality;
153 image->depth=clone_image->depth;
154 image->matte_color=clone_image->matte_color;
155 image->background_color=clone_image->background_color;
156 image->border_color=clone_image->border_color;
157 image->transparent_color=clone_image->transparent_color;
158 image->gamma=clone_image->gamma;
159 image->chromaticity=clone_image->chromaticity;
160 image->rendering_intent=clone_image->rendering_intent;
161 image->black_point_compensation=clone_image->black_point_compensation;
162 image->units=clone_image->units;
163 image->montage=(
char *) NULL;
164 image->directory=(
char *) NULL;
165 (void) CloneString(&image->geometry,clone_image->geometry);
166 image->offset=clone_image->offset;
167 image->resolution.x=clone_image->resolution.x;
168 image->resolution.y=clone_image->resolution.y;
169 image->page=clone_image->page;
170 image->tile_offset=clone_image->tile_offset;
171 image->extract_info=clone_image->extract_info;
172 image->filter=clone_image->filter;
173 image->fuzz=clone_image->fuzz;
174 image->intensity=clone_image->intensity;
175 image->interlace=clone_image->interlace;
176 image->interpolate=clone_image->interpolate;
177 image->endian=clone_image->endian;
178 image->gravity=clone_image->gravity;
179 image->compose=clone_image->compose;
180 image->orientation=clone_image->orientation;
181 image->scene=clone_image->scene;
182 image->dispose=clone_image->dispose;
183 image->delay=clone_image->delay;
184 image->ticks_per_second=clone_image->ticks_per_second;
185 image->iterations=clone_image->iterations;
186 image->total_colors=clone_image->total_colors;
187 image->taint=clone_image->taint;
188 image->progress_monitor=clone_image->progress_monitor;
189 image->client_data=clone_image->client_data;
190 image->start_loop=clone_image->start_loop;
191 image->error=clone_image->error;
192 image->signature=clone_image->signature;
193 if (clone_image->properties != (
void *) NULL)
195 if (image->properties != (
void *) NULL)
196 DestroyImageProperties(image);
198 clone_image->properties,(
void *(*)(
void *)) ConstantString,
199 (
void *(*)(
void *)) ConstantString);
233 MagickExport MagickBooleanType DefineImageProperty(
Image *image,
237 key[MagickPathExtent],
238 value[MagickPathExtent];
243 assert(image != (
Image *) NULL);
244 assert(property != (
const char *) NULL);
245 (void) CopyMagickString(key,property,MagickPathExtent-1);
246 for (p=key; *p !=
'\0'; p++)
251 (void) CopyMagickString(value,p+1,MagickPathExtent);
253 return(SetImageProperty(image,key,value,exception));
280 MagickExport MagickBooleanType DeleteImageProperty(
Image *image,
281 const char *property)
283 assert(image != (
Image *) NULL);
284 assert(image->signature == MagickCoreSignature);
285 if (IsEventLogging() != MagickFalse)
286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
287 if (image->properties == (
void *) NULL)
289 return(DeleteNodeFromSplayTree((
SplayTreeInfo *) image->properties,property));
315 MagickExport
void DestroyImageProperties(
Image *image)
317 assert(image != (
Image *) NULL);
318 assert(image->signature == MagickCoreSignature);
319 if (IsEventLogging() != MagickFalse)
320 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
321 if (image->properties != (
void *) NULL)
322 image->properties=(
void *) DestroySplayTree((
SplayTreeInfo *)
355 MagickExport MagickBooleanType FormatImageProperty(
Image *image,
356 const char *property,
const char *format,...)
359 value[MagickPathExtent];
373 va_start(operands,format);
374 n=FormatLocaleStringList(value,MagickPathExtent,format,operands);
377 exception=AcquireExceptionInfo();
378 status=SetImageProperty(image,property,value,exception);
379 exception=DestroyExceptionInfo(exception);
419 *TracePSClippath(
const unsigned char *,
size_t),
420 *TraceSVGClippath(
const unsigned char *,
size_t,
const size_t,
423 static MagickBooleanType GetIPTCProperty(
const Image *image,
const char *key,
444 profile=GetImageProfile(image,
"iptc");
446 profile=GetImageProfile(image,
"8bim");
449 count=sscanf(key,
"IPTC:%ld:%ld",&dataset,&record);
452 attribute=(
char *) NULL;
453 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
456 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
458 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
459 length|=GetStringInfoDatum(profile)[i+4];
460 if (((
long) GetStringInfoDatum(profile)[i+1] == dataset) &&
461 ((
long) GetStringInfoDatum(profile)[i+2] == record))
463 message=(
char *) NULL;
465 message=(
char *) AcquireQuantumMemory(length+1UL,
sizeof(*message));
466 if (message != (
char *) NULL)
468 (void) CopyMagickString(message,(
char *) GetStringInfoDatum(
469 profile)+i+5,length+1);
470 (void) ConcatenateString(&attribute,message);
471 (void) ConcatenateString(&attribute,
";");
472 message=DestroyString(message);
477 if ((attribute == (
char *) NULL) || (*attribute ==
';'))
479 if (attribute != (
char *) NULL)
480 attribute=DestroyString(attribute);
483 attribute[strlen(attribute)-1]=
'\0';
484 (void) SetImageProperty((
Image *) image,key,(
const char *) attribute,
486 attribute=DestroyString(attribute);
490 static inline int ReadPropertyByte(
const unsigned char **p,
size_t *length)
502 static inline signed int ReadPropertyMSBLong(
const unsigned char **p,
528 for (i=0; i < 4; i++)
532 buffer[i]=(
unsigned char) c;
534 value=(
unsigned int) buffer[0] << 24;
535 value|=(
unsigned int) buffer[1] << 16;
536 value|=(
unsigned int) buffer[2] << 8;
537 value|=(
unsigned int) buffer[3];
538 quantum.unsigned_value=value & 0xffffffff;
539 return(quantum.signed_value);
542 static inline signed short ReadPropertyMSBShort(
const unsigned char **p,
567 return((
unsigned short) ~0);
568 for (i=0; i < 2; i++)
572 buffer[i]=(
unsigned char) c;
574 value=(
unsigned short) buffer[0] << 8;
575 value|=(
unsigned short) buffer[1];
576 quantum.unsigned_value=value & 0xffff;
577 return(quantum.signed_value);
580 static MagickBooleanType Get8BIMProperty(
const Image *image,
const char *key,
585 format[MagickPathExtent],
586 name[MagickPathExtent],
616 profile=GetImageProfile(image,
"8bim");
619 count=(ssize_t) sscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
621 if ((count != 2) && (count != 3) && (count != 4))
624 (void) CopyMagickString(format,
"SVG",MagickPathExtent);
629 sub_number=(ssize_t) StringToLong(&name[1]);
630 sub_number=MagickMax(sub_number,1L);
631 resource=(
char *) NULL;
633 length=GetStringInfoLength(profile);
634 info=GetStringInfoDatum(profile);
635 while ((length > 0) && (status == MagickFalse))
637 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'8')
639 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'B')
641 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'I')
643 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'M')
645 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
646 if (
id < (ssize_t) start)
648 if (
id > (ssize_t) stop)
650 if (resource != (
char *) NULL)
651 resource=DestroyString(resource);
652 count=(ssize_t) ReadPropertyByte(&info,&length);
653 if ((count != 0) && ((size_t) count <= length))
655 resource=(
char *) NULL;
656 if (~((
size_t) count) >= (MagickPathExtent-1))
657 resource=(
char *) AcquireQuantumMemory((
size_t) count+
658 MagickPathExtent,
sizeof(*resource));
659 if (resource != (
char *) NULL)
661 for (i=0; i < (ssize_t) count; i++)
662 resource[i]=(
char) ReadPropertyByte(&info,&length);
663 resource[count]=
'\0';
666 if ((count & 0x01) == 0)
667 (void) ReadPropertyByte(&info,&length);
668 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
669 if ((count < 0) || ((size_t) count > length))
674 if ((*name !=
'\0') && (*name !=
'#'))
675 if ((resource == (
char *) NULL) || (LocaleCompare(name,resource) != 0))
681 length-=MagickMin(count,(ssize_t) length);
684 if ((*name ==
'#') && (sub_number != 1))
691 length-=MagickMin(count,(ssize_t) length);
697 attribute=(
char *) NULL;
698 if (~((
size_t) count) >= (MagickPathExtent-1))
699 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MagickPathExtent,
701 if (attribute != (
char *) NULL)
703 (void) memcpy(attribute,(
char *) info,(size_t) count);
704 attribute[count]=
'\0';
706 length-=MagickMin(count,(ssize_t) length);
707 if ((
id <= 1999) || (
id >= 2999))
708 (void) SetImageProperty((
Image *) image,key,(
const char *) attribute,
715 if (LocaleCompare(format,
"svg") == 0)
716 path=TraceSVGClippath((
unsigned char *) attribute,(size_t) count,
717 image->columns,image->rows);
719 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count);
720 (void) SetImageProperty((
Image *) image,key,(
const char *) path,
722 path=DestroyString(path);
724 attribute=DestroyString(attribute);
728 if (resource != (
char *) NULL)
729 resource=DestroyString(resource);
733 static inline signed int ReadPropertySignedLong(
const EndianType endian,
734 const unsigned char *buffer)
748 if (endian == LSBEndian)
750 value=(
unsigned int) buffer[3] << 24;
751 value|=(
unsigned int) buffer[2] << 16;
752 value|=(
unsigned int) buffer[1] << 8;
753 value|=(
unsigned int) buffer[0];
754 quantum.unsigned_value=value & 0xffffffff;
755 return(quantum.signed_value);
757 value=(
unsigned int) buffer[0] << 24;
758 value|=(
unsigned int) buffer[1] << 16;
759 value|=(
unsigned int) buffer[2] << 8;
760 value|=(
unsigned int) buffer[3];
761 quantum.unsigned_value=value & 0xffffffff;
762 return(quantum.signed_value);
765 static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
766 const unsigned char *buffer)
771 if (endian == LSBEndian)
773 value=(
unsigned int) buffer[3] << 24;
774 value|=(
unsigned int) buffer[2] << 16;
775 value|=(
unsigned int) buffer[1] << 8;
776 value|=(
unsigned int) buffer[0];
777 return(value & 0xffffffff);
779 value=(
unsigned int) buffer[0] << 24;
780 value|=(
unsigned int) buffer[1] << 16;
781 value|=(
unsigned int) buffer[2] << 8;
782 value|=(
unsigned int) buffer[3];
783 return(value & 0xffffffff);
786 static inline signed short ReadPropertySignedShort(
const EndianType endian,
787 const unsigned char *buffer)
801 if (endian == LSBEndian)
803 value=(
unsigned short) buffer[1] << 8;
804 value|=(
unsigned short) buffer[0];
805 quantum.unsigned_value=value & 0xffff;
806 return(quantum.signed_value);
808 value=(
unsigned short) buffer[0] << 8;
809 value|=(
unsigned short) buffer[1];
810 quantum.unsigned_value=value & 0xffff;
811 return(quantum.signed_value);
814 static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
815 const unsigned char *buffer)
820 if (endian == LSBEndian)
822 value=(
unsigned short) buffer[1] << 8;
823 value|=(
unsigned short) buffer[0];
824 return(value & 0xffff);
826 value=(
unsigned short) buffer[0] << 8;
827 value|=(
unsigned short) buffer[1];
828 return(value & 0xffff);
831 static MagickBooleanType GetEXIFProperty(
const Image *image,
834 #define MaxDirectoryStack 16
835 #define EXIF_DELIMITER "\n"
836 #define EXIF_NUM_FORMATS 12
837 #define EXIF_FMT_BYTE 1
838 #define EXIF_FMT_STRING 2
839 #define EXIF_FMT_USHORT 3
840 #define EXIF_FMT_ULONG 4
841 #define EXIF_FMT_URATIONAL 5
842 #define EXIF_FMT_SBYTE 6
843 #define EXIF_FMT_UNDEFINED 7
844 #define EXIF_FMT_SSHORT 8
845 #define EXIF_FMT_SLONG 9
846 #define EXIF_FMT_SRATIONAL 10
847 #define EXIF_FMT_SINGLE 11
848 #define EXIF_FMT_DOUBLE 12
849 #define TAG_EXIF_OFFSET 0x8769
850 #define TAG_GPS_OFFSET 0x8825
851 #define TAG_INTEROP_OFFSET 0xa005
853 #define EXIFMultipleValues(size,format,arg) \
866 for (component=0; component < components; component++) \
868 len+=FormatLocaleString(buffer+len,MagickPathExtent-len,format", ",arg); \
869 if (len >= (MagickPathExtent-1)) \
870 len=MagickPathExtent-1; \
874 buffer[len-2]='\0'; \
875 value=AcquireString(buffer); \
878 #define EXIFMultipleFractions(size,format,arg1,arg2) \
891 for (component=0; component < components; component++) \
893 len+=FormatLocaleString(buffer+len,MagickPathExtent-len,format", ", \
895 if (len >= (MagickPathExtent-1)) \
896 len=MagickPathExtent-1; \
900 buffer[len-2]='\0'; \
901 value=AcquireString(buffer); \
904 typedef struct _DirectoryInfo
916 typedef struct _TagInfo
928 { 0x001,
"exif:InteroperabilityIndex" },
929 { 0x002,
"exif:InteroperabilityVersion" },
930 { 0x100,
"exif:ImageWidth" },
931 { 0x101,
"exif:ImageLength" },
932 { 0x102,
"exif:BitsPerSample" },
933 { 0x103,
"exif:Compression" },
934 { 0x106,
"exif:PhotometricInterpretation" },
935 { 0x10a,
"exif:FillOrder" },
936 { 0x10d,
"exif:DocumentName" },
937 { 0x10e,
"exif:ImageDescription" },
938 { 0x10f,
"exif:Make" },
939 { 0x110,
"exif:Model" },
940 { 0x111,
"exif:StripOffsets" },
941 { 0x112,
"exif:Orientation" },
942 { 0x115,
"exif:SamplesPerPixel" },
943 { 0x116,
"exif:RowsPerStrip" },
944 { 0x117,
"exif:StripByteCounts" },
945 { 0x11a,
"exif:XResolution" },
946 { 0x11b,
"exif:YResolution" },
947 { 0x11c,
"exif:PlanarConfiguration" },
948 { 0x11d,
"exif:PageName" },
949 { 0x11e,
"exif:XPosition" },
950 { 0x11f,
"exif:YPosition" },
951 { 0x118,
"exif:MinSampleValue" },
952 { 0x119,
"exif:MaxSampleValue" },
953 { 0x120,
"exif:FreeOffsets" },
954 { 0x121,
"exif:FreeByteCounts" },
955 { 0x122,
"exif:GrayResponseUnit" },
956 { 0x123,
"exif:GrayResponseCurve" },
957 { 0x124,
"exif:T4Options" },
958 { 0x125,
"exif:T6Options" },
959 { 0x128,
"exif:ResolutionUnit" },
960 { 0x12d,
"exif:TransferFunction" },
961 { 0x131,
"exif:Software" },
962 { 0x132,
"exif:DateTime" },
963 { 0x13b,
"exif:Artist" },
964 { 0x13e,
"exif:WhitePoint" },
965 { 0x13f,
"exif:PrimaryChromaticities" },
966 { 0x140,
"exif:ColorMap" },
967 { 0x141,
"exif:HalfToneHints" },
968 { 0x142,
"exif:TileWidth" },
969 { 0x143,
"exif:TileLength" },
970 { 0x144,
"exif:TileOffsets" },
971 { 0x145,
"exif:TileByteCounts" },
972 { 0x14a,
"exif:SubIFD" },
973 { 0x14c,
"exif:InkSet" },
974 { 0x14d,
"exif:InkNames" },
975 { 0x14e,
"exif:NumberOfInks" },
976 { 0x150,
"exif:DotRange" },
977 { 0x151,
"exif:TargetPrinter" },
978 { 0x152,
"exif:ExtraSample" },
979 { 0x153,
"exif:SampleFormat" },
980 { 0x154,
"exif:SMinSampleValue" },
981 { 0x155,
"exif:SMaxSampleValue" },
982 { 0x156,
"exif:TransferRange" },
983 { 0x157,
"exif:ClipPath" },
984 { 0x158,
"exif:XClipPathUnits" },
985 { 0x159,
"exif:YClipPathUnits" },
986 { 0x15a,
"exif:Indexed" },
987 { 0x15b,
"exif:JPEGTables" },
988 { 0x15f,
"exif:OPIProxy" },
989 { 0x200,
"exif:JPEGProc" },
990 { 0x201,
"exif:JPEGInterchangeFormat" },
991 { 0x202,
"exif:JPEGInterchangeFormatLength" },
992 { 0x203,
"exif:JPEGRestartInterval" },
993 { 0x205,
"exif:JPEGLosslessPredictors" },
994 { 0x206,
"exif:JPEGPointTransforms" },
995 { 0x207,
"exif:JPEGQTables" },
996 { 0x208,
"exif:JPEGDCTables" },
997 { 0x209,
"exif:JPEGACTables" },
998 { 0x211,
"exif:YCbCrCoefficients" },
999 { 0x212,
"exif:YCbCrSubSampling" },
1000 { 0x213,
"exif:YCbCrPositioning" },
1001 { 0x214,
"exif:ReferenceBlackWhite" },
1002 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1003 { 0x301,
"exif:Gamma" },
1004 { 0x302,
"exif:ICCProfileDescriptor" },
1005 { 0x303,
"exif:SRGBRenderingIntent" },
1006 { 0x320,
"exif:ImageTitle" },
1007 { 0x5001,
"exif:ResolutionXUnit" },
1008 { 0x5002,
"exif:ResolutionYUnit" },
1009 { 0x5003,
"exif:ResolutionXLengthUnit" },
1010 { 0x5004,
"exif:ResolutionYLengthUnit" },
1011 { 0x5005,
"exif:PrintFlags" },
1012 { 0x5006,
"exif:PrintFlagsVersion" },
1013 { 0x5007,
"exif:PrintFlagsCrop" },
1014 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1015 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1016 { 0x500A,
"exif:HalftoneLPI" },
1017 { 0x500B,
"exif:HalftoneLPIUnit" },
1018 { 0x500C,
"exif:HalftoneDegree" },
1019 { 0x500D,
"exif:HalftoneShape" },
1020 { 0x500E,
"exif:HalftoneMisc" },
1021 { 0x500F,
"exif:HalftoneScreen" },
1022 { 0x5010,
"exif:JPEGQuality" },
1023 { 0x5011,
"exif:GridSize" },
1024 { 0x5012,
"exif:ThumbnailFormat" },
1025 { 0x5013,
"exif:ThumbnailWidth" },
1026 { 0x5014,
"exif:ThumbnailHeight" },
1027 { 0x5015,
"exif:ThumbnailColorDepth" },
1028 { 0x5016,
"exif:ThumbnailPlanes" },
1029 { 0x5017,
"exif:ThumbnailRawBytes" },
1030 { 0x5018,
"exif:ThumbnailSize" },
1031 { 0x5019,
"exif:ThumbnailCompressedSize" },
1032 { 0x501a,
"exif:ColorTransferFunction" },
1033 { 0x501b,
"exif:ThumbnailData" },
1034 { 0x5020,
"exif:ThumbnailImageWidth" },
1035 { 0x5021,
"exif:ThumbnailImageHeight" },
1036 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1037 { 0x5023,
"exif:ThumbnailCompression" },
1038 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1039 { 0x5025,
"exif:ThumbnailImageDescription" },
1040 { 0x5026,
"exif:ThumbnailEquipMake" },
1041 { 0x5027,
"exif:ThumbnailEquipModel" },
1042 { 0x5028,
"exif:ThumbnailStripOffsets" },
1043 { 0x5029,
"exif:ThumbnailOrientation" },
1044 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1045 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1046 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1047 { 0x502d,
"exif:ThumbnailResolutionX" },
1048 { 0x502e,
"exif:ThumbnailResolutionY" },
1049 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1050 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1051 { 0x5031,
"exif:ThumbnailTransferFunction" },
1052 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1053 { 0x5033,
"exif:ThumbnailDateTime" },
1054 { 0x5034,
"exif:ThumbnailArtist" },
1055 { 0x5035,
"exif:ThumbnailWhitePoint" },
1056 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1057 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1058 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1059 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1060 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1061 { 0x503B,
"exif:ThumbnailCopyRight" },
1062 { 0x5090,
"exif:LuminanceTable" },
1063 { 0x5091,
"exif:ChrominanceTable" },
1064 { 0x5100,
"exif:FrameDelay" },
1065 { 0x5101,
"exif:LoopCount" },
1066 { 0x5110,
"exif:PixelUnit" },
1067 { 0x5111,
"exif:PixelPerUnitX" },
1068 { 0x5112,
"exif:PixelPerUnitY" },
1069 { 0x5113,
"exif:PaletteHistogram" },
1070 { 0x1000,
"exif:RelatedImageFileFormat" },
1071 { 0x1001,
"exif:RelatedImageLength" },
1072 { 0x1002,
"exif:RelatedImageWidth" },
1073 { 0x800d,
"exif:ImageID" },
1074 { 0x80e3,
"exif:Matteing" },
1075 { 0x80e4,
"exif:DataType" },
1076 { 0x80e5,
"exif:ImageDepth" },
1077 { 0x80e6,
"exif:TileDepth" },
1078 { 0x828d,
"exif:CFARepeatPatternDim" },
1079 { 0x828e,
"exif:CFAPattern2" },
1080 { 0x828f,
"exif:BatteryLevel" },
1081 { 0x8298,
"exif:Copyright" },
1082 { 0x829a,
"exif:ExposureTime" },
1083 { 0x829d,
"exif:FNumber" },
1084 { 0x83bb,
"exif:IPTC/NAA" },
1085 { 0x84e3,
"exif:IT8RasterPadding" },
1086 { 0x84e5,
"exif:IT8ColorTable" },
1087 { 0x8649,
"exif:ImageResourceInformation" },
1088 { 0x8769,
"exif:ExifOffset" },
1089 { 0x8773,
"exif:InterColorProfile" },
1090 { 0x8822,
"exif:ExposureProgram" },
1091 { 0x8824,
"exif:SpectralSensitivity" },
1092 { 0x8825,
"exif:GPSInfo" },
1093 { 0x8827,
"exif:PhotographicSensitivity" },
1094 { 0x8828,
"exif:OECF" },
1095 { 0x8829,
"exif:Interlace" },
1096 { 0x882a,
"exif:TimeZoneOffset" },
1097 { 0x882b,
"exif:SelfTimerMode" },
1098 { 0x8830,
"exif:SensitivityType" },
1099 { 0x8831,
"exif:StandardOutputSensitivity" },
1100 { 0x8832,
"exif:RecommendedExposureIndex" },
1101 { 0x8833,
"exif:ISOSpeed" },
1102 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1103 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1104 { 0x9000,
"exif:ExifVersion" },
1105 { 0x9003,
"exif:DateTimeOriginal" },
1106 { 0x9004,
"exif:DateTimeDigitized" },
1107 { 0x9010,
"exif:OffsetTime" },
1108 { 0x9011,
"exif:OffsetTimeOriginal" },
1109 { 0x9012,
"exif:OffsetTimeDigitized" },
1110 { 0x9101,
"exif:ComponentsConfiguration" },
1111 { 0x9102,
"exif:CompressedBitsPerPixel" },
1112 { 0x9201,
"exif:ShutterSpeedValue" },
1113 { 0x9202,
"exif:ApertureValue" },
1114 { 0x9203,
"exif:BrightnessValue" },
1115 { 0x9204,
"exif:ExposureBiasValue" },
1116 { 0x9205,
"exif:MaxApertureValue" },
1117 { 0x9206,
"exif:SubjectDistance" },
1118 { 0x9207,
"exif:MeteringMode" },
1119 { 0x9208,
"exif:LightSource" },
1120 { 0x9209,
"exif:Flash" },
1121 { 0x920a,
"exif:FocalLength" },
1122 { 0x920b,
"exif:FlashEnergy" },
1123 { 0x920c,
"exif:SpatialFrequencyResponse" },
1124 { 0x920d,
"exif:Noise" },
1125 { 0x9214,
"exif:SubjectArea" },
1126 { 0x9290,
"exif:SubSecTime" },
1127 { 0x9291,
"exif:SubSecTimeOriginal" },
1128 { 0x9292,
"exif:SubSecTimeDigitized" },
1129 { 0x9211,
"exif:ImageNumber" },
1130 { 0x9212,
"exif:SecurityClassification" },
1131 { 0x9213,
"exif:ImageHistory" },
1132 { 0x9214,
"exif:SubjectArea" },
1133 { 0x9215,
"exif:ExposureIndex" },
1134 { 0x9216,
"exif:TIFF-EPStandardID" },
1135 { 0x927c,
"exif:MakerNote" },
1136 { 0x9286,
"exif:UserComment" },
1137 { 0x9290,
"exif:SubSecTime" },
1138 { 0x9291,
"exif:SubSecTimeOriginal" },
1139 { 0x9292,
"exif:SubSecTimeDigitized" },
1140 { 0x9400,
"exif:Temperature" },
1141 { 0x9401,
"exif:Humidity" },
1142 { 0x9402,
"exif:Pressure" },
1143 { 0x9403,
"exif:WaterDepth" },
1144 { 0x9404,
"exif:Acceleration" },
1145 { 0x9405,
"exif:CameraElevationAngle" },
1146 { 0x9C9b,
"exif:WinXP-Title" },
1147 { 0x9C9c,
"exif:WinXP-Comments" },
1148 { 0x9C9d,
"exif:WinXP-Author" },
1149 { 0x9C9e,
"exif:WinXP-Keywords" },
1150 { 0x9C9f,
"exif:WinXP-Subject" },
1151 { 0xa000,
"exif:FlashPixVersion" },
1152 { 0xa001,
"exif:ColorSpace" },
1153 { 0xa002,
"exif:PixelXDimension" },
1154 { 0xa003,
"exif:PixelYDimension" },
1155 { 0xa004,
"exif:RelatedSoundFile" },
1156 { 0xa005,
"exif:InteroperabilityOffset" },
1157 { 0xa20b,
"exif:FlashEnergy" },
1158 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1159 { 0xa20d,
"exif:Noise" },
1160 { 0xa20e,
"exif:FocalPlaneXResolution" },
1161 { 0xa20f,
"exif:FocalPlaneYResolution" },
1162 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1163 { 0xa214,
"exif:SubjectLocation" },
1164 { 0xa215,
"exif:ExposureIndex" },
1165 { 0xa216,
"exif:TIFF/EPStandardID" },
1166 { 0xa217,
"exif:SensingMethod" },
1167 { 0xa300,
"exif:FileSource" },
1168 { 0xa301,
"exif:SceneType" },
1169 { 0xa302,
"exif:CFAPattern" },
1170 { 0xa401,
"exif:CustomRendered" },
1171 { 0xa402,
"exif:ExposureMode" },
1172 { 0xa403,
"exif:WhiteBalance" },
1173 { 0xa404,
"exif:DigitalZoomRatio" },
1174 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1175 { 0xa406,
"exif:SceneCaptureType" },
1176 { 0xa407,
"exif:GainControl" },
1177 { 0xa408,
"exif:Contrast" },
1178 { 0xa409,
"exif:Saturation" },
1179 { 0xa40a,
"exif:Sharpness" },
1180 { 0xa40b,
"exif:DeviceSettingDescription" },
1181 { 0xa40c,
"exif:SubjectDistanceRange" },
1182 { 0xa420,
"exif:ImageUniqueID" },
1183 { 0xa430,
"exif:CameraOwnerName" },
1184 { 0xa431,
"exif:BodySerialNumber" },
1185 { 0xa432,
"exif:LensSpecification" },
1186 { 0xa433,
"exif:LensMake" },
1187 { 0xa434,
"exif:LensModel" },
1188 { 0xa435,
"exif:LensSerialNumber" },
1189 { 0xc4a5,
"exif:PrintImageMatching" },
1190 { 0xa500,
"exif:Gamma" },
1191 { 0xc640,
"exif:CR2Slice" },
1192 { 0x10000,
"exif:GPSVersionID" },
1193 { 0x10001,
"exif:GPSLatitudeRef" },
1194 { 0x10002,
"exif:GPSLatitude" },
1195 { 0x10003,
"exif:GPSLongitudeRef" },
1196 { 0x10004,
"exif:GPSLongitude" },
1197 { 0x10005,
"exif:GPSAltitudeRef" },
1198 { 0x10006,
"exif:GPSAltitude" },
1199 { 0x10007,
"exif:GPSTimeStamp" },
1200 { 0x10008,
"exif:GPSSatellites" },
1201 { 0x10009,
"exif:GPSStatus" },
1202 { 0x1000a,
"exif:GPSMeasureMode" },
1203 { 0x1000b,
"exif:GPSDop" },
1204 { 0x1000c,
"exif:GPSSpeedRef" },
1205 { 0x1000d,
"exif:GPSSpeed" },
1206 { 0x1000e,
"exif:GPSTrackRef" },
1207 { 0x1000f,
"exif:GPSTrack" },
1208 { 0x10010,
"exif:GPSImgDirectionRef" },
1209 { 0x10011,
"exif:GPSImgDirection" },
1210 { 0x10012,
"exif:GPSMapDatum" },
1211 { 0x10013,
"exif:GPSDestLatitudeRef" },
1212 { 0x10014,
"exif:GPSDestLatitude" },
1213 { 0x10015,
"exif:GPSDestLongitudeRef" },
1214 { 0x10016,
"exif:GPSDestLongitude" },
1215 { 0x10017,
"exif:GPSDestBearingRef" },
1216 { 0x10018,
"exif:GPSDestBearing" },
1217 { 0x10019,
"exif:GPSDestDistanceRef" },
1218 { 0x1001a,
"exif:GPSDestDistance" },
1219 { 0x1001b,
"exif:GPSProcessingMethod" },
1220 { 0x1001c,
"exif:GPSAreaInformation" },
1221 { 0x1001d,
"exif:GPSDateStamp" },
1222 { 0x1001e,
"exif:GPSDifferential" },
1223 { 0x1001f,
"exif:GPSHPositioningError" },
1235 directory_stack[MaxDirectoryStack] = { 0 };
1264 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1269 profile=GetImageProfile(image,
"exif");
1271 return(MagickFalse);
1272 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1273 return(MagickFalse);
1274 while (isspace((
int) ((
unsigned char) *property)) != 0)
1276 if (strlen(property) <= 5)
1277 return(MagickFalse);
1280 switch (*(property+5))
1309 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1313 return(MagickFalse);
1320 for (i=(ssize_t) n-1L; i >= 0; i--)
1324 if ((c >=
'0') && (c <=
'9'))
1327 if ((c >=
'A') && (c <=
'F'))
1330 if ((c >=
'a') && (c <=
'f'))
1333 return(MagickFalse);
1335 }
while (*property !=
'\0');
1345 if (EXIFTag[i].tag == 0)
1347 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1349 tag=(size_t) EXIFTag[i].tag;
1357 return(MagickFalse);
1358 length=GetStringInfoLength(profile);
1360 return(MagickFalse);
1361 exif=GetStringInfoDatum(profile);
1364 if (ReadPropertyByte(&exif,&length) != 0x45)
1366 if (ReadPropertyByte(&exif,&length) != 0x78)
1368 if (ReadPropertyByte(&exif,&length) != 0x69)
1370 if (ReadPropertyByte(&exif,&length) != 0x66)
1372 if (ReadPropertyByte(&exif,&length) != 0x00)
1374 if (ReadPropertyByte(&exif,&length) != 0x00)
1379 return(MagickFalse);
1380 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1388 return(MagickFalse);
1389 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1390 return(MagickFalse);
1394 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1395 if ((offset < 0) || (size_t) offset >= length)
1396 return(MagickFalse);
1401 directory=exif+offset;
1405 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1406 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1415 directory=directory_stack[level].directory;
1416 entry=directory_stack[level].entry;
1417 tag_offset=directory_stack[level].offset;
1419 if ((directory < exif) || (directory > (exif+length-2)))
1424 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1425 for ( ; entry < number_entries; entry++)
1438 q=(
unsigned char *) (directory+(12*entry)+2);
1439 if (q > (exif+length-12))
1441 if (GetValueFromSplayTree(exif_resources,q) == q)
1443 (void) AddValueToSplayTree(exif_resources,q,q);
1444 tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;
1445 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1446 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1450 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1453 number_bytes=(size_t) components*tag_bytes[format];
1454 if (number_bytes < components)
1456 if (number_bytes <= 4)
1466 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1467 if ((dir_offset < 0) || (size_t) dir_offset >= length)
1469 if (((
size_t) dir_offset+number_bytes) < (
size_t) dir_offset)
1471 if (((
size_t) dir_offset+number_bytes) > length)
1473 p=(
unsigned char *) (exif+dir_offset);
1475 if ((all != 0) || (tag == (size_t) tag_value))
1478 buffer[MagickPathExtent],
1481 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1483 value=(
char *) NULL;
1488 case EXIF_FMT_UNDEFINED:
1490 value=(
char *) NULL;
1491 if (~((
size_t) number_bytes) >= 1)
1492 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1494 if (value != (
char *) NULL)
1496 for (i=0; i < (ssize_t) number_bytes; i++)
1499 if (isprint((
int) p[i]) != 0)
1500 value[i]=(char) p[i];
1506 case EXIF_FMT_SBYTE:
1508 EXIFMultipleValues(1,
"%.20g",(
double) (*(
signed char *) p1));
1511 case EXIF_FMT_SSHORT:
1513 EXIFMultipleValues(2,
"%hd",ReadPropertySignedShort(endian,p1));
1516 case EXIF_FMT_USHORT:
1518 EXIFMultipleValues(2,
"%hu",ReadPropertyUnsignedShort(endian,p1));
1521 case EXIF_FMT_ULONG:
1523 EXIFMultipleValues(4,
"%.20g",(
double)
1524 ReadPropertyUnsignedLong(endian,p1));
1527 case EXIF_FMT_SLONG:
1529 EXIFMultipleValues(4,
"%.20g",(
double)
1530 ReadPropertySignedLong(endian,p1));
1533 case EXIF_FMT_URATIONAL:
1535 EXIFMultipleFractions(8,
"%.20g/%.20g",(
double)
1536 ReadPropertyUnsignedLong(endian,p1),(
double)
1537 ReadPropertyUnsignedLong(endian,p1+4));
1540 case EXIF_FMT_SRATIONAL:
1542 EXIFMultipleFractions(8,
"%.20g/%.20g",(
double)
1543 ReadPropertySignedLong(endian,p1),(
double)
1544 ReadPropertySignedLong(endian,p1+4));
1547 case EXIF_FMT_SINGLE:
1549 EXIFMultipleValues(4,
"%.20g",(
double)
1550 ReadPropertySignedLong(endian,p1));
1553 case EXIF_FMT_DOUBLE:
1555 EXIFMultipleValues(8,
"%.20g",(
double)
1556 ReadPropertySignedLong(endian,p1));
1559 case EXIF_FMT_STRING:
1562 if ((p < exif) || (p > (exif+length-number_bytes)))
1564 value=(
char *) NULL;
1565 if (~((
size_t) number_bytes) >= 1)
1566 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1568 if (value != (
char *) NULL)
1570 for (i=0; i < (ssize_t) number_bytes; i++)
1573 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1574 value[i]=(char) p[i];
1581 if (value != (
char *) NULL)
1586 key=AcquireString(property);
1594 description=
"unknown";
1597 if (EXIFTag[i].tag == 0)
1599 if (EXIFTag[i].tag == tag_value)
1601 description=EXIFTag[i].description;
1605 (void) FormatLocaleString(key,MagickPathExtent,
"%s",
1608 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1613 if (tag_value < 0x10000)
1614 (void) FormatLocaleString(key,MagickPathExtent,
"#%04lx",
1615 (
unsigned long) tag_value);
1617 if (tag_value < 0x20000)
1618 (void) FormatLocaleString(key,MagickPathExtent,
"@%04lx",
1619 (
unsigned long) (tag_value & 0xffff));
1621 (
void) FormatLocaleString(key,MagickPathExtent,
"unknown");
1627 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1630 if ((image->properties == (
void *) NULL) ||
1632 key) == (
const void *) NULL))
1633 (
void) SetImageProperty((
Image *) image,key,value,exception);
1634 value=DestroyString(value);
1635 key=DestroyString(key);
1639 if ((tag_value == TAG_EXIF_OFFSET) ||
1640 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1645 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,p);
1646 if (((
size_t) tag_offset1 < length) &&
1647 (level < (MaxDirectoryStack-2)))
1652 tag_offset2=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1654 directory_stack[level].directory=directory;
1656 directory_stack[level].entry=entry;
1657 directory_stack[level].offset=tag_offset;
1662 for (i=0; i < level; i++)
1663 if (directory_stack[i].directory == (exif+tag_offset1))
1667 directory_stack[level].directory=exif+tag_offset1;
1668 directory_stack[level].offset=tag_offset2;
1669 directory_stack[level].entry=0;
1671 if ((directory+2+(12*number_entries)+4) > (exif+length))
1673 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,directory+
1674 2+(12*number_entries));
1675 if ((tag_offset1 != 0) && ((size_t) tag_offset1 < length) &&
1676 (level < (MaxDirectoryStack-2)))
1678 directory_stack[level].directory=exif+tag_offset1;
1679 directory_stack[level].entry=0;
1680 directory_stack[level].offset=tag_offset2;
1687 }
while (level > 0);
1688 exif_resources=DestroySplayTree(exif_resources);
1692 static MagickBooleanType GetICCProperty(
const Image *image,
const char *property,
1701 magick_unreferenced(property);
1702 profile=GetImageProfile(image,
"icc");
1704 profile=GetImageProfile(image,
"icm");
1706 return(MagickFalse);
1707 if (GetStringInfoLength(profile) < 128)
1708 return(MagickFalse);
1709 #if defined(MAGICKCORE_LCMS_DELEGATE)
1714 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1715 (cmsUInt32Number) GetStringInfoLength(profile));
1716 if (icc_profile != (cmsHPROFILE *) NULL)
1718 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1722 name=cmsTakeProductName(icc_profile);
1723 if (name != (
const char *) NULL)
1724 (void) SetImageProperty((
Image *) image,
"icc:name",name,exception);
1732 info=AcquireStringInfo(0);
1733 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1737 SetStringInfoLength(info,extent+1);
1738 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1739 "US",(
char *) GetStringInfoDatum(info),extent);
1741 (void) SetImageProperty((
Image *) image,
"icc:description",
1742 (
char *) GetStringInfoDatum(info),exception);
1744 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1748 SetStringInfoLength(info,extent+1);
1749 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1750 "US",(
char *) GetStringInfoDatum(info),extent);
1752 (void) SetImageProperty((
Image *) image,
"icc:manufacturer",
1753 (
char *) GetStringInfoDatum(info),exception);
1755 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1759 SetStringInfoLength(info,extent+1);
1760 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1761 (
char *) GetStringInfoDatum(info),extent);
1763 (void) SetImageProperty((
Image *) image,
"icc:model",
1764 (
char *) GetStringInfoDatum(info),exception);
1766 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1770 SetStringInfoLength(info,extent+1);
1771 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1772 "US",(
char *) GetStringInfoDatum(info),extent);
1774 (void) SetImageProperty((
Image *) image,
"icc:copyright",
1775 (
char *) GetStringInfoDatum(info),exception);
1777 info=DestroyStringInfo(info);
1779 (void) cmsCloseProfile(icc_profile);
1786 static MagickBooleanType SkipXMPValue(
const char *value)
1788 if (value == (
const char*) NULL)
1790 while (*value !=
'\0')
1792 if (isspace((
int) ((
unsigned char) *value)) == 0)
1793 return(MagickFalse);
1799 static MagickBooleanType GetXMPProperty(
const Image *image,
const char *property)
1826 profile=GetImageProfile(image,
"xmp");
1828 return(MagickFalse);
1829 if (GetStringInfoLength(profile) < 17)
1830 return(MagickFalse);
1831 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1832 return(MagickFalse);
1833 xmp_profile=StringInfoToString(profile);
1834 if (xmp_profile == (
char *) NULL)
1835 return(MagickFalse);
1836 for (p=xmp_profile; *p !=
'\0'; p++)
1837 if ((*p ==
'<') && (*(p+1) ==
'x'))
1839 exception=AcquireExceptionInfo();
1840 xmp=NewXMLTree((
char *) p,exception);
1841 xmp_profile=DestroyString(xmp_profile);
1842 exception=DestroyExceptionInfo(exception);
1844 return(MagickFalse);
1846 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1849 if (image->properties == (
void *) NULL)
1850 ((
Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1851 RelinquishMagickMemory,RelinquishMagickMemory);
1852 description=GetXMLTreeChild(rdf,
"rdf:Description");
1858 node=GetXMLTreeChild(description,(
const char *) NULL);
1861 child=GetXMLTreeChild(node,(
const char *) NULL);
1862 content=GetXMLTreeContent(node);
1864 (SkipXMPValue(content) == MagickFalse))
1866 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1867 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1868 (void) AddValueToSplayTree((
SplayTreeInfo *) image->properties,
1869 xmp_namespace,ConstantString(content));
1873 content=GetXMLTreeContent(child);
1874 if (SkipXMPValue(content) == MagickFalse)
1876 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1877 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1878 (void) AddValueToSplayTree((
SplayTreeInfo *) image->properties,
1879 xmp_namespace,ConstantString(content));
1881 child=GetXMLTreeSibling(child);
1883 node=GetXMLTreeSibling(node);
1885 description=GetNextXMLTreeTag(description);
1888 xmp=DestroyXMLTree(xmp);
1892 static char *TracePSClippath(
const unsigned char *blob,
size_t length)
1915 path=AcquireString((
char *) NULL);
1916 if (path == (
char *) NULL)
1917 return((
char *) NULL);
1918 message=AcquireString((
char *) NULL);
1919 (void) FormatLocaleString(message,MagickPathExtent,
"/ClipImage\n");
1920 (void) ConcatenateString(&path,message);
1921 (void) FormatLocaleString(message,MagickPathExtent,
"{\n");
1922 (void) ConcatenateString(&path,message);
1923 (void) FormatLocaleString(message,MagickPathExtent,
1924 " /c {curveto} bind def\n");
1925 (void) ConcatenateString(&path,message);
1926 (void) FormatLocaleString(message,MagickPathExtent,
1927 " /l {lineto} bind def\n");
1928 (void) ConcatenateString(&path,message);
1929 (void) FormatLocaleString(message,MagickPathExtent,
1930 " /m {moveto} bind def\n");
1931 (void) ConcatenateString(&path,message);
1932 (void) FormatLocaleString(message,MagickPathExtent,
1933 " /v {currentpoint 6 2 roll curveto} bind def\n");
1934 (void) ConcatenateString(&path,message);
1935 (void) FormatLocaleString(message,MagickPathExtent,
1936 " /y {2 copy curveto} bind def\n");
1937 (void) ConcatenateString(&path,message);
1938 (void) FormatLocaleString(message,MagickPathExtent,
1939 " /z {closepath} bind def\n");
1940 (void) ConcatenateString(&path,message);
1941 (void) FormatLocaleString(message,MagickPathExtent,
" newpath\n");
1942 (void) ConcatenateString(&path,message);
1947 (void) memset(point,0,
sizeof(point));
1948 (void) memset(first,0,
sizeof(first));
1949 (void) memset(last,0,
sizeof(last));
1951 in_subpath=MagickFalse;
1954 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1960 if (knot_count != 0)
1963 length-=MagickMin(24,(ssize_t) length);
1969 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1971 length-=MagickMin(22,(ssize_t) length);
1979 if (knot_count == 0)
1985 length-=MagickMin(24,(ssize_t) length);
1991 for (i=0; i < 3; i++)
1993 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
1994 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
1995 point[i].x=(double) x/4096.0/4096.0;
1996 point[i].y=1.0-(double) y/4096.0/4096.0;
1998 if (in_subpath == MagickFalse)
2000 (void) FormatLocaleString(message,MagickPathExtent,
" %g %g m\n",
2001 point[1].x,point[1].y);
2002 for (i=0; i < 3; i++)
2014 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2015 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2016 (void) FormatLocaleString(message,MagickPathExtent,
2017 " %g %g l\n",point[1].x,point[1].y);
2019 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2020 (void) FormatLocaleString(message,MagickPathExtent,
2021 " %g %g %g %g v\n",point[0].x,point[0].y,
2022 point[1].x,point[1].y);
2024 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2025 (void) FormatLocaleString(message,MagickPathExtent,
2026 " %g %g %g %g y\n",last[2].x,last[2].y,
2027 point[1].x,point[1].y);
2029 (
void) FormatLocaleString(message,MagickPathExtent,
2030 " %g %g %g %g %g %g c\n",last[2].x,
2031 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2032 for (i=0; i < 3; i++)
2035 (void) ConcatenateString(&path,message);
2036 in_subpath=MagickTrue;
2041 if (knot_count == 0)
2047 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2048 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2049 (void) FormatLocaleString(message,MagickPathExtent,
2050 " %g %g l z\n",first[1].x,first[1].y);
2052 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2053 (void) FormatLocaleString(message,MagickPathExtent,
2054 " %g %g %g %g v z\n",first[0].x,first[0].y,
2055 first[1].x,first[1].y);
2057 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2058 (void) FormatLocaleString(message,MagickPathExtent,
2059 " %g %g %g %g y z\n",last[2].x,last[2].y,
2060 first[1].x,first[1].y);
2062 (
void) FormatLocaleString(message,MagickPathExtent,
2063 " %g %g %g %g %g %g c z\n",last[2].x,
2064 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2065 (void) ConcatenateString(&path,message);
2066 in_subpath=MagickFalse;
2076 length-=MagickMin(24,(ssize_t) length);
2084 (void) FormatLocaleString(message,MagickPathExtent,
" eoclip\n");
2085 (void) ConcatenateString(&path,message);
2086 (void) FormatLocaleString(message,MagickPathExtent,
"} bind def");
2087 (void) ConcatenateString(&path,message);
2088 message=DestroyString(message);
2092 static inline void TraceBezierCurve(
char *message,
PointInfo *last,
2099 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2100 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2101 (void) FormatLocaleString(message,MagickPathExtent,
2102 "L %g %g\n",point[1].x,point[1].y);
2104 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2105 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2108 static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2109 const size_t columns,
const size_t rows)
2132 path=AcquireString((
char *) NULL);
2133 if (path == (
char *) NULL)
2134 return((
char *) NULL);
2135 message=AcquireString((
char *) NULL);
2136 (void) FormatLocaleString(message,MagickPathExtent,(
2137 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2138 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2139 " width=\"%.20g\" height=\"%.20g\">\n"
2141 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2142 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(double) columns,
2144 (void) ConcatenateString(&path,message);
2145 (void) memset(point,0,
sizeof(point));
2146 (void) memset(first,0,
sizeof(first));
2147 (void) memset(last,0,
sizeof(last));
2149 in_subpath=MagickFalse;
2152 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2158 if (knot_count != 0)
2161 length-=MagickMin(24,(ssize_t) length);
2167 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2169 length-=MagickMin(22,(ssize_t) length);
2177 if (knot_count == 0)
2183 length-=MagickMin(24,(ssize_t) length);
2189 for (i=0; i < 3; i++)
2191 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2192 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2193 point[i].x=(double) x*columns/4096.0/4096.0;
2194 point[i].y=(double) y*rows/4096.0/4096.0;
2196 if (in_subpath == MagickFalse)
2198 (void) FormatLocaleString(message,MagickPathExtent,
"M %g %g\n",
2199 point[1].x,point[1].y);
2200 for (i=0; i < 3; i++)
2208 TraceBezierCurve(message,last,point);
2209 for (i=0; i < 3; i++)
2212 (void) ConcatenateString(&path,message);
2213 in_subpath=MagickTrue;
2218 if (knot_count == 0)
2220 TraceBezierCurve(message,last,first);
2221 (void) ConcatenateString(&path,message);
2222 in_subpath=MagickFalse;
2232 length-=MagickMin(24,(ssize_t) length);
2240 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2241 message=DestroyString(message);
2245 MagickExport
const char *GetImageProperty(
const Image *image,
2249 read_from_properties;
2257 assert(image != (
Image *) NULL);
2258 assert(image->signature == MagickCoreSignature);
2259 if (IsEventLogging() != MagickFalse)
2260 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2261 if ((property == (
const char *) NULL) || (*
property ==
'\0'))
2262 return((
const char *) NULL);
2263 read_from_properties=MagickTrue;
2264 property_length=strlen(property);
2265 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
2266 (*(property+(property_length-1)) ==
'*'))
2267 read_from_properties=MagickFalse;
2268 if (read_from_properties != MagickFalse)
2270 p=(
const char *) NULL;
2271 if (image->properties != (
void *) NULL)
2274 image->properties,property);
2275 if (p != (
const char *) NULL)
2278 if ((property == (
const char *) NULL) ||
2279 (strchr(property,
':') == (
char *) NULL))
2286 if (LocaleNCompare(
"8bim:",property,5) == 0)
2288 (void) Get8BIMProperty(image,property,exception);
2296 if (LocaleNCompare(
"exif:",property,5) == 0)
2298 (void) GetEXIFProperty(image,property,exception);
2306 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2307 (LocaleNCompare(
"icm:",property,4) == 0))
2309 (void) GetICCProperty(image,property,exception);
2312 if (LocaleNCompare(
"iptc:",property,5) == 0)
2314 (void) GetIPTCProperty(image,property,exception);
2322 if (LocaleNCompare(
"xmp:",property,4) == 0)
2324 (void) GetXMPProperty(image,property);
2332 if ((image->properties != (
void *) NULL) &&
2333 (read_from_properties != MagickFalse))
2336 image->properties,property);
2339 return((
const char *) NULL);
2433 static const char *GetMagickPropertyLetter(
ImageInfo *image_info,
2436 #define WarnNoImageReturn(format,arg) \
2437 if (image == (Image *) NULL ) { \
2438 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2439 "NoImageForProperty",format,arg); \
2440 return((const char *) NULL); \
2442 #define WarnNoImageInfoReturn(format,arg) \
2443 if (image_info == (ImageInfo *) NULL ) { \
2444 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2445 "NoImageInfoForProperty",format,arg); \
2446 return((const char *) NULL); \
2450 value[MagickPathExtent];
2455 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
2456 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2458 if ((image_info != (
ImageInfo *) NULL) &&
2459 (IsEventLogging() != MagickFalse))
2460 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2462 string=(
char *) NULL;
2470 WarnNoImageReturn(
"\"%%%c\"",letter);
2471 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
2473 if (image->extent == 0)
2474 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
2475 MagickPathExtent,value);
2480 WarnNoImageReturn(
"\"%%%c\"",letter);
2481 string=GetImageProperty(image,
"comment",exception);
2482 if (
string == (
const char *) NULL )
2488 WarnNoImageReturn(
"\"%%%c\"",letter);
2489 GetPathComponent(image->magick_filename,HeadPath,value);
2496 WarnNoImageReturn(
"\"%%%c\"",letter);
2497 GetPathComponent(image->magick_filename,ExtensionPath,value);
2504 WarnNoImageReturn(
"\"%%%c\"",letter);
2505 GetPathComponent(image->magick_filename,TailPath,value);
2512 WarnNoImageReturn(
"\"%%%c\"",letter);
2513 (void) FormatLocaleString(value,MagickPathExtent,
2514 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(double)
2515 image->page.height,(
double) image->page.x,(double) image->page.y);
2520 WarnNoImageReturn(
"\"%%%c\"",letter);
2521 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2522 (image->rows != 0 ? image->rows : image->magick_rows));
2527 WarnNoImageReturn(
"\"%%%c\"",letter);
2528 string=image->filename;
2536 WarnNoImageReturn(
"\"%%%c\"",letter);
2537 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2538 GetNumberColors(image,(FILE *) NULL,exception));
2543 WarnNoImageReturn(
"\"%%%c\"",letter);
2544 string=GetImageProperty(image,
"label",exception);
2545 if (
string == (
const char *) NULL)
2551 WarnNoImageReturn(
"\"%%%c\"",letter);
2552 string=image->magick;
2557 if ( image != (
Image *) NULL )
2558 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2559 GetImageListLength(image));
2566 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2567 string=image_info->filename;
2572 WarnNoImageReturn(
"\"%%%c\"",letter);
2573 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2574 GetImageIndexInList(image));
2579 WarnNoImageReturn(
"\"%%%c\"",letter);
2580 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2581 MAGICKCORE_QUANTUM_DEPTH);
2589 WarnNoImageReturn(
"\"%%%c\"",letter);
2590 colorspace=image->colorspace;
2591 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
2592 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2593 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2594 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2601 if (image_info->number_scenes != 0)
2602 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2604 else if (image != (
Image *) NULL)
2605 (
void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2610 WarnNoImageReturn(
"\"%%%c\"",letter);
2611 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2618 WarnNoImageReturn(
"\"%%%c\"",letter);
2619 GetPathComponent(image->magick_filename,BasePath,value);
2626 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2627 string=image_info->unique;
2632 WarnNoImageReturn(
"\"%%%c\"",letter);
2633 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2634 (image->columns != 0 ? image->columns : image->magick_columns));
2639 WarnNoImageReturn(
"\"%%%c\"",letter);
2640 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2641 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
2642 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2648 WarnNoImageReturn(
"\"%%%c\"",letter);
2649 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2650 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
2651 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2657 WarnNoImageReturn(
"\"%%%c\"",letter);
2658 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2664 WarnNoImageReturn(
"\"%%%c\"",letter);
2665 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2666 image->alpha_trait);
2671 WarnNoImageReturn(
"\"%%%c\"",letter);
2672 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2674 if (image->extent == 0)
2675 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2676 GetBlobSize(image));
2681 WarnNoImageReturn(
"\"%%%c\"",letter);
2682 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2683 image->compression);
2688 WarnNoImageReturn(
"\"%%%c\"",letter);
2689 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2695 WarnNoImageReturn(
"\"%%%c\"",letter);
2696 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2697 image->magick_columns,(double) image->magick_rows);
2702 WarnNoImageReturn(
"\"%%%c\"",letter);
2703 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2704 image->page.height);
2709 WarnNoImageReturn(
"\"%%%c\"",letter);
2710 string=image->magick_filename;
2715 if ((image != (
Image *) NULL) && (image->next == (
Image *) NULL))
2716 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2717 GetImageListLength(image));
2724 WarnNoImageReturn(
"\"%%%c\"",letter);
2725 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
2726 image->page.x,(long) image->page.y);
2731 WarnNoImageReturn(
"\"%%%c\"",letter);
2732 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2733 image->page.width,(double) image->page.height);
2738 WarnNoImageReturn(
"\"%%%c\"",letter);
2739 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2740 (image->quality == 0 ? 92 : image->quality));
2745 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2747 if (image_info->number_scenes == 0)
2748 string=
"2147483647";
2749 else if ( image != (
Image *) NULL )
2750 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2751 image_info->scene+image_info->number_scenes);
2755 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2756 (image_info->number_scenes == 0 ? 2147483647 :
2757 image_info->number_scenes));
2763 WarnNoImageReturn(
"\"%%%c\"",letter);
2764 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2770 WarnNoImageReturn(
"\"%%%c\"",letter);
2771 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2777 WarnNoImageReturn(
"\"%%%c\"",letter);
2778 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2784 WarnNoImageReturn(
"\"%%%c\"",letter);
2785 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2791 WarnNoImageReturn(
"\"%%%c\"",letter);
2792 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2806 WarnNoImageReturn(
"\"%%%c\"",letter);
2807 page=GetImageBoundingBox(image,exception);
2808 (void) FormatLocaleString(value,MagickPathExtent,
2809 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(double) page.height,
2810 (
double) page.x,(double)page.y);
2818 WarnNoImageReturn(
"\"%%%c\"",letter);
2819 if ((image->columns != 0) && (image->rows != 0))
2820 (void) SignatureImage(image,exception);
2821 string=GetImageProperty(image,
"signature",exception);
2825 if (
string != (
char *) NULL)
2832 if (image != (
Image *) NULL)
2834 (void) SetImageArtifact(image,
"magick-property",value);
2835 return(GetImageArtifact(image,
"magick-property"));
2839 (void) SetImageOption(image_info,
"magick-property",value);
2840 return(GetImageOption(image_info,
"magick-property"));
2843 return((
char *) NULL);
2846 MagickExport
const char *GetMagickProperty(
ImageInfo *image_info,
2850 value[MagickPathExtent];
2855 assert(property[0] !=
'\0');
2856 assert(image != (
Image *) NULL || image_info != (
ImageInfo *) NULL );
2857 if (property[1] ==
'\0')
2858 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2859 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
2860 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2862 if ((image_info != (
ImageInfo *) NULL) &&
2863 (IsEventLogging() != MagickFalse))
2864 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2866 string=(
char *) NULL;
2871 if (LocaleCompare(
"basename",property) == 0)
2873 WarnNoImageReturn(
"\"%%[%s]\"",property);
2874 GetPathComponent(image->magick_filename,BasePath,value);
2879 if (LocaleCompare(
"bit-depth",property) == 0)
2881 WarnNoImageReturn(
"\"%%[%s]\"",property);
2882 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2883 GetImageDepth(image,exception));
2886 if (LocaleCompare(
"bounding-box",property) == 0)
2891 WarnNoImageReturn(
"\"%%[%s]\"",property);
2892 geometry=GetImageBoundingBox(image,exception);
2893 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g",
2894 (
double) geometry.x,(double) geometry.y,
2895 (
double) geometry.x+geometry.width,
2896 (double) geometry.y+geometry.height);
2903 if (LocaleCompare(
"channels",property) == 0)
2905 WarnNoImageReturn(
"\"%%[%s]\"",property);
2907 (void) FormatLocaleString(value,MagickPathExtent,
"%s",
2908 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2909 image->colorspace));
2911 if( image->alpha_trait != UndefinedPixelTrait )
2912 (void) ConcatenateMagickString(value,
"a",MagickPathExtent);
2915 if (LocaleCompare(
"colors",property) == 0)
2917 WarnNoImageReturn(
"\"%%[%s]\"",property);
2918 image->colors=GetNumberColors(image,(FILE *) NULL,exception);
2919 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2923 if (LocaleCompare(
"colorspace",property) == 0)
2925 WarnNoImageReturn(
"\"%%[%s]\"",property);
2926 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2930 if (LocaleCompare(
"compose",property) == 0)
2932 WarnNoImageReturn(
"\"%%[%s]\"",property);
2933 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2937 if (LocaleCompare(
"compression",property) == 0)
2939 WarnNoImageReturn(
"\"%%[%s]\"",property);
2940 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2941 image->compression);
2944 if (LocaleCompare(
"convex-hull",property) == 0)
2958 WarnNoImageReturn(
"\"%%[%s]\"",property);
2959 convex_hull=GetImageConvexHull(image,&number_points,exception);
2962 points=AcquireString(
"");
2963 for (n=0; n < (ssize_t) number_points; n++)
2965 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
2966 convex_hull[n].x,convex_hull[n].y);
2967 (void) ConcatenateString(&points,value);
2969 convex_hull=(
PointInfo *) RelinquishMagickMemory(convex_hull);
2970 (void) SetImageProperty(image,
"convex-hull",points,exception);
2971 points=DestroyString(points);
2972 string=GetImageProperty(image,
"convex-hull",exception);
2975 if (LocaleCompare(
"convex-hull:extreme-points",property) == 0)
2990 WarnNoImageReturn(
"\"%%[%s]\"",property);
2991 convex_hull=GetImageConvexHull(image,&number_points,exception);
2994 points=AcquireString(
"");
2995 extreme=convex_hull[0];
2996 for (n=0; n < (ssize_t) number_points; n++)
2998 if (convex_hull[n].y < extreme.y)
3000 extreme=convex_hull[n];
3003 if (convex_hull[n].y != extreme.y)
3005 if (convex_hull[n].x < extreme.x)
3006 extreme=convex_hull[n];
3008 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3009 extreme.x,extreme.y);
3010 (void) ConcatenateString(&points,value);
3011 extreme=convex_hull[0];
3012 for (n=0; n < (ssize_t) number_points; n++)
3014 if (convex_hull[n].x > extreme.x)
3016 extreme=convex_hull[n];
3019 if (convex_hull[n].x != extreme.x)
3021 if (convex_hull[n].y < extreme.y)
3022 extreme=convex_hull[n];
3024 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3025 extreme.x,extreme.y);
3026 (void) ConcatenateString(&points,value);
3027 extreme=convex_hull[0];
3028 for (n=0; n < (ssize_t) number_points; n++)
3030 if (convex_hull[n].y > extreme.y)
3032 extreme=convex_hull[n];
3035 if (convex_hull[n].y != extreme.y)
3037 if (convex_hull[n].x > extreme.x)
3038 extreme=convex_hull[n];
3040 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3041 extreme.x,extreme.y);
3042 (void) ConcatenateString(&points,value);
3043 extreme=convex_hull[0];
3044 for (n=0; n < (ssize_t) number_points; n++)
3046 if (convex_hull[n].x < extreme.x)
3048 extreme=convex_hull[n];
3051 if (convex_hull[n].x != extreme.x)
3053 if (convex_hull[n].y > extreme.y)
3054 extreme=convex_hull[n];
3056 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3057 extreme.x,extreme.y);
3058 (void) ConcatenateString(&points,value);
3059 convex_hull=(
PointInfo *) RelinquishMagickMemory(convex_hull);
3060 (void) SetImageProperty(image,
"convex-hull:extreme-points",points,
3062 points=DestroyString(points);
3063 string=GetImageProperty(image,
"convex-hull:extreme-points",exception);
3066 if (LocaleCompare(
"copyright",property) == 0)
3068 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
3075 if (LocaleCompare(
"depth",property) == 0)
3077 WarnNoImageReturn(
"\"%%[%s]\"",property);
3078 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3082 if (LocaleCompare(
"directory",property) == 0)
3084 WarnNoImageReturn(
"\"%%[%s]\"",property);
3085 GetPathComponent(image->magick_filename,HeadPath,value);
3094 if (LocaleCompare(
"entropy",property) == 0)
3099 WarnNoImageReturn(
"\"%%[%s]\"",property);
3100 (void) GetImageEntropy(image,&entropy,exception);
3101 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3102 GetMagickPrecision(),entropy);
3105 if (LocaleCompare(
"extension",property) == 0)
3107 WarnNoImageReturn(
"\"%%[%s]\"",property);
3108 GetPathComponent(image->magick_filename,ExtensionPath,value);
3117 if (LocaleCompare(
"gamma",property) == 0)
3119 WarnNoImageReturn(
"\"%%[%s]\"",property);
3120 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3121 GetMagickPrecision(),image->gamma);
3128 if (LocaleCompare(
"height",property) == 0)
3130 WarnNoImageReturn(
"\"%%[%s]\"",property);
3131 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
3132 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3139 if (LocaleCompare(
"input",property) == 0)
3141 WarnNoImageReturn(
"\"%%[%s]\"",property);
3142 string=image->filename;
3145 if (LocaleCompare(
"interlace",property) == 0)
3147 WarnNoImageReturn(
"\"%%[%s]\"",property);
3148 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3156 if (LocaleCompare(
"kurtosis",property) == 0)
3162 WarnNoImageReturn(
"\"%%[%s]\"",property);
3163 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3164 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3165 GetMagickPrecision(),kurtosis);
3172 if (LocaleCompare(
"magick",property) == 0)
3174 WarnNoImageReturn(
"\"%%[%s]\"",property);
3175 string=image->magick;
3178 if ((LocaleCompare(
"maxima",property) == 0) ||
3179 (LocaleCompare(
"max",property) == 0))
3185 WarnNoImageReturn(
"\"%%[%s]\"",property);
3186 (void) GetImageRange(image,&minimum,&maximum,exception);
3187 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3188 GetMagickPrecision(),maximum);
3191 if (LocaleCompare(
"mean",property) == 0)
3197 WarnNoImageReturn(
"\"%%[%s]\"",property);
3198 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3199 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3200 GetMagickPrecision(),mean);
3203 if (LocaleCompare(
"median",property) == 0)
3208 WarnNoImageReturn(
"\"%%[%s]\"",property);
3209 (void) GetImageMedian(image,&median,exception);
3210 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3211 GetMagickPrecision(),median);
3214 if ((LocaleCompare(
"minima",property) == 0) ||
3215 (LocaleCompare(
"min",property) == 0))
3221 WarnNoImageReturn(
"\"%%[%s]\"",property);
3222 (void) GetImageRange(image,&minimum,&maximum,exception);
3223 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3224 GetMagickPrecision(),minimum);
3227 if (LocaleNCompare(
"minimum-bounding-box",property,20) == 0)
3241 WarnNoImageReturn(
"\"%%[%s]\"",property);
3242 bounding_box=GetImageMinimumBoundingBox(image,&number_points,
3246 points=AcquireString(
"");
3247 for (n=0; n < (ssize_t) number_points; n++)
3249 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3250 bounding_box[n].x,bounding_box[n].y);
3251 (void) ConcatenateString(&points,value);
3253 bounding_box=(
PointInfo *) RelinquishMagickMemory(bounding_box);
3254 (void) SetImageProperty(image,
"minimum-bounding-box",points,
3256 points=DestroyString(points);
3257 string=GetImageProperty(image,property,exception);
3264 if (LocaleCompare(
"opaque",property) == 0)
3266 WarnNoImageReturn(
"\"%%[%s]\"",property);
3267 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
3268 IsImageOpaque(image,exception));
3271 if (LocaleCompare(
"orientation",property) == 0)
3273 WarnNoImageReturn(
"\"%%[%s]\"",property);
3274 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3275 image->orientation);
3278 if (LocaleCompare(
"output",property) == 0)
3280 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3281 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
3288 if (LocaleCompare(
"page",property) == 0)
3290 WarnNoImageReturn(
"\"%%[%s]\"",property);
3291 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3292 (
double) image->page.width,(double) image->page.height);
3295 if (LocaleNCompare(
"papersize:",property,10) == 0)
3300 WarnNoImageReturn(
"\"%%[%s]\"",property);
3302 papersize=GetPageGeometry(property+10);
3303 if (papersize != (
const char *) NULL)
3306 page = { 0, 0, 0, 0 };
3308 (void) ParseAbsoluteGeometry(papersize,&page);
3309 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3310 (
double) page.width,(double) page.height);
3311 papersize=DestroyString(papersize);
3315 #if defined(MAGICKCORE_LCMS_DELEGATE)
3316 if (LocaleCompare(
"profile:icc",property) == 0 ||
3317 LocaleCompare(
"profile:icm",property) == 0)
3319 #if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3320 #define cmsUInt32Number DWORD
3329 WarnNoImageReturn(
"\"%%[%s]\"",property);
3330 profile=GetImageProfile(image,property+8);
3333 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3334 (cmsUInt32Number) GetStringInfoLength(profile));
3335 if (icc_profile != (cmsHPROFILE *) NULL)
3337 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3338 string=cmsTakeProductName(icc_profile);
3340 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3341 "en",
"US",value,MagickPathExtent);
3343 (void) cmsCloseProfile(icc_profile);
3347 if (LocaleCompare(
"printsize.x",property) == 0)
3349 WarnNoImageReturn(
"\"%%[%s]\"",property);
3350 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3351 GetMagickPrecision(),PerceptibleReciprocal(image->resolution.x)*
3355 if (LocaleCompare(
"printsize.y",property) == 0)
3357 WarnNoImageReturn(
"\"%%[%s]\"",property);
3358 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3359 GetMagickPrecision(),PerceptibleReciprocal(image->resolution.y)*
3363 if (LocaleCompare(
"profiles",property) == 0)
3368 WarnNoImageReturn(
"\"%%[%s]\"",property);
3369 ResetImageProfileIterator(image);
3370 name=GetNextImageProfile(image);
3371 if (name != (
char *) NULL)
3373 (void) CopyMagickString(value,name,MagickPathExtent);
3374 name=GetNextImageProfile(image);
3375 while (name != (
char *) NULL)
3377 ConcatenateMagickString(value,
",",MagickPathExtent);
3378 ConcatenateMagickString(value,name,MagickPathExtent);
3379 name=GetNextImageProfile(image);
3388 if (LocaleCompare(
"quality",property) == 0)
3390 WarnNoImageReturn(
"\"%%[%s]\"",property);
3391 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3399 if (LocaleCompare(
"resolution.x",property) == 0)
3401 WarnNoImageReturn(
"\"%%[%s]\"",property);
3402 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3403 image->resolution.x);
3406 if (LocaleCompare(
"resolution.y",property) == 0)
3408 WarnNoImageReturn(
"\"%%[%s]\"",property);
3409 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3410 image->resolution.y);
3417 if (LocaleCompare(
"scene",property) == 0)
3419 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3420 if (image_info->number_scenes != 0)
3421 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3424 WarnNoImageReturn(
"\"%%[%s]\"",property);
3425 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3430 if (LocaleCompare(
"scenes",property) == 0)
3433 WarnNoImageReturn(
"\"%%[%s]\"",property);
3434 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3435 GetImageListLength(image));
3438 if (LocaleCompare(
"size",property) == 0)
3440 WarnNoImageReturn(
"\"%%[%s]\"",property);
3441 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
3442 MagickPathExtent,value);
3445 if (LocaleCompare(
"skewness",property) == 0)
3451 WarnNoImageReturn(
"\"%%[%s]\"",property);
3452 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3453 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3454 GetMagickPrecision(),skewness);
3457 if (LocaleCompare(
"standard-deviation",property) == 0)
3463 WarnNoImageReturn(
"\"%%[%s]\"",property);
3464 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3465 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3466 GetMagickPrecision(),standard_deviation);
3473 if (LocaleCompare(
"type",property) == 0)
3475 WarnNoImageReturn(
"\"%%[%s]\"",property);
3476 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3477 IdentifyImageType(image,exception));
3484 if (LocaleCompare(
"unique",property) == 0)
3486 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3487 string=image_info->unique;
3490 if (LocaleCompare(
"units",property) == 0)
3492 WarnNoImageReturn(
"\"%%[%s]\"",property);
3493 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3501 if (LocaleCompare(
"version",property) == 0)
3503 string=GetMagickVersion((
size_t *) NULL);
3510 if (LocaleCompare(
"width",property) == 0)
3512 WarnNoImageReturn(
"\"%%[%s]\"",property);
3513 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3514 (image->magick_columns != 0 ? image->magick_columns : 256));
3520 if (
string != (
char *) NULL)
3527 if (image != (
Image *) NULL)
3529 (void) SetImageArtifact(image,
"magick-property",value);
3530 return(GetImageArtifact(image,
"magick-property"));
3534 (void) SetImageOption(image_info,
"magick-property",value);
3535 return(GetImageOption(image_info,
"magick-property"));
3538 return((
char *) NULL);
3540 #undef WarnNoImageReturn
3564 MagickExport
const char *GetNextImageProperty(
const Image *image)
3566 assert(image != (
Image *) NULL);
3567 assert(image->signature == MagickCoreSignature);
3568 if (IsEventLogging() != MagickFalse)
3569 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3571 if (image->properties == (
void *) NULL)
3572 return((
const char *) NULL);
3573 return((
const char *) GetNextKeyInSplayTree((
SplayTreeInfo *) image->properties));
3630 MagickExport
char *InterpretImageProperties(
ImageInfo *image_info,
Image *image,
3633 #define ExtendInterpretText(string_length) \
3635 size_t length=(string_length); \
3636 if ((size_t) (q-interpret_text+length+1) >= extent) \
3639 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3640 MagickPathExtent,sizeof(*interpret_text)); \
3641 if (interpret_text == (char *) NULL) \
3643 if (property_image != image) \
3644 property_image=DestroyImage(property_image); \
3645 if (property_info != image_info) \
3646 property_info=DestroyImageInfo(property_info); \
3647 return((char *) NULL); \
3649 q=interpret_text+strlen(interpret_text); \
3653 #define AppendKeyValue2Text(key,value)\
3655 size_t length=strlen(key)+strlen(value)+2; \
3656 if ((size_t) (q-interpret_text+length+1) >= extent) \
3659 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3660 MagickPathExtent,sizeof(*interpret_text)); \
3661 if (interpret_text == (char *) NULL) \
3663 if (property_image != image) \
3664 property_image=DestroyImage(property_image); \
3665 if (property_info != image_info) \
3666 property_info=DestroyImageInfo(property_info); \
3667 return((char *) NULL); \
3669 q=interpret_text+strlen(interpret_text); \
3671 q+=FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3674 #define AppendString2Text(string) \
3676 size_t length=strlen((string)); \
3677 if ((size_t) (q-interpret_text+length+1) >= extent) \
3680 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3681 MagickPathExtent,sizeof(*interpret_text)); \
3682 if (interpret_text == (char *) NULL) \
3684 if (property_image != image) \
3685 property_image=DestroyImage(property_image); \
3686 if (property_info != image_info) \
3687 property_info=DestroyImageInfo(property_info); \
3688 return((char *) NULL); \
3690 q=interpret_text+strlen(interpret_text); \
3692 (void) CopyMagickString(q,(string),extent); \
3717 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
3718 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3720 if ((image_info != (
ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
3721 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3722 image_info->filename);
3724 if (IsEventLogging() != MagickFalse)
3725 (
void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no image");
3726 if (embed_text == (
const char *) NULL)
3727 return(ConstantString(
""));
3729 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3732 return(ConstantString(
""));
3733 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3738 if (IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,p) == MagickFalse)
3741 (void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
3742 "NotAuthorized",
"`%s'",p);
3743 return(ConstantString(
""));
3745 interpret_text=FileToString(p+1,~0UL,exception);
3746 if (interpret_text != (
char *) NULL)
3747 return(interpret_text);
3753 property_info=image_info;
3755 property_info=CloneImageInfo(image_info);
3756 if ((image != (
Image *) NULL) && (image->columns != 0) && (image->rows != 0))
3757 property_image=image;
3760 property_image=AcquireImage(image_info,exception);
3761 (void) SetImageExtent(property_image,1,1,exception);
3762 (void) SetImageBackgroundColor(property_image,exception);
3764 interpret_text=AcquireString(embed_text);
3765 extent=MagickPathExtent;
3767 for (q=interpret_text; *p!=
'\0'; number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
3773 ExtendInterpretText(MagickPathExtent);
3816 if (LocaleNCompare(
"<",p,4) == 0)
3822 if (LocaleNCompare(
">",p,4) == 0)
3828 if (LocaleNCompare(
"&",p,5) == 0)
3849 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3864 if (number != MagickFalse)
3873 string=GetMagickPropertyLetter(property_info,image,*p,exception);
3874 if (
string != (
char *) NULL)
3876 AppendString2Text(
string);
3877 (void) DeleteImageArtifact(property_image,
"magick-property");
3878 (void) DeleteImageOption(property_info,
"magick-property");
3881 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3882 "UnknownImageProperty",
"\"%%%c\"",*p);
3887 pattern[2*MagickPathExtent];
3906 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3907 "UnknownImageProperty",
"\"%%[]\"");
3910 for (len=0; len < (MagickPathExtent-1L) && (*p !=
'\0'); )
3912 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3917 pattern[len++]=(*p++);
3918 pattern[len++]=(*p++);
3927 pattern[len++]=(*p++);
3942 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3943 "UnbalancedBraces",
"\"%%[%s\"",pattern);
3944 interpret_text=DestroyString(interpret_text);
3945 if (property_image != image)
3946 property_image=DestroyImage(property_image);
3947 if (property_info != image_info)
3948 property_info=DestroyImageInfo(property_info);
3949 return((
char *) NULL);
3954 if (LocaleNCompare(
"fx:",pattern,3) == 0)
3968 fx_info=AcquireFxInfo(property_image,pattern+3,exception);
3969 if (fx_info == (
FxInfo *) NULL)
3971 status=FxEvaluateChannelExpression(fx_info,CompositePixelChannel,0,0,
3973 fx_info=DestroyFxInfo(fx_info);
3974 if (status != MagickFalse)
3977 result[MagickPathExtent];
3979 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
3980 GetMagickPrecision(),(double) value);
3981 AppendString2Text(result);
3985 if (LocaleNCompare(
"hex:",pattern,4) == 0)
4002 GetPixelInfo(property_image,&pixel);
4003 fx_info=AcquireFxInfo(property_image,pattern+4,exception);
4004 if (fx_info == (
FxInfo *) NULL)
4006 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4008 pixel.red=(double) QuantumRange*value;
4009 status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
4011 pixel.green=(double) QuantumRange*value;
4012 status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
4014 pixel.blue=(double) QuantumRange*value;
4015 if (property_image->colorspace == CMYKColorspace)
4017 status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
4019 pixel.black=(double) QuantumRange*value;
4021 status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
4023 pixel.alpha=(double) QuantumRange*value;
4024 fx_info=DestroyFxInfo(fx_info);
4025 if (status != MagickFalse)
4028 hex[MagickPathExtent];
4030 GetColorTuple(&pixel,MagickTrue,hex);
4031 AppendString2Text(hex+1);
4035 if (LocaleNCompare(
"pixel:",pattern,6) == 0)
4052 GetPixelInfo(property_image,&pixel);
4053 fx_info=AcquireFxInfo(property_image,pattern+6,exception);
4054 if (fx_info == (
FxInfo *) NULL)
4056 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4058 pixel.red=(double) QuantumRange*value;
4059 status&=FxEvaluateChannelExpression(fx_info,GreenPixelChannel,0,0,
4061 pixel.green=(double) QuantumRange*value;
4062 status&=FxEvaluateChannelExpression(fx_info,BluePixelChannel,0,0,
4064 pixel.blue=(double) QuantumRange*value;
4065 if (property_image->colorspace == CMYKColorspace)
4067 status&=FxEvaluateChannelExpression(fx_info,BlackPixelChannel,0,0,
4069 pixel.black=(double) QuantumRange*value;
4071 status&=FxEvaluateChannelExpression(fx_info,AlphaPixelChannel,0,0,
4073 pixel.alpha=(double) QuantumRange*value;
4074 fx_info=DestroyFxInfo(fx_info);
4075 if (status != MagickFalse)
4078 name[MagickPathExtent];
4080 GetColorTuple(&pixel,MagickFalse,name);
4081 string=GetImageArtifact(property_image,
"pixel:compliance");
4082 if (
string != (
char *) NULL)
4084 ComplianceType compliance=(ComplianceType) ParseCommandOption(
4085 MagickComplianceOptions,MagickFalse,
string);
4086 (void) QueryColorname(property_image,&pixel,compliance,name,
4089 AppendString2Text(name);
4093 if (LocaleNCompare(
"option:",pattern,7) == 0)
4098 if (IsGlob(pattern+7) != MagickFalse)
4100 ResetImageOptionIterator(property_info);
4101 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4102 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4104 string=GetImageOption(property_info,key);
4105 if (
string != (
const char *) NULL)
4106 AppendKeyValue2Text(key,
string);
4111 string=GetImageOption(property_info,pattern+7);
4112 if (
string == (
char *) NULL)
4113 goto PropertyLookupFailure;
4114 AppendString2Text(
string);
4117 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4122 if (IsGlob(pattern+9) != MagickFalse)
4124 ResetImageArtifactIterator(property_image);
4125 while ((key=GetNextImageArtifact(property_image)) != (
const char *) NULL)
4126 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4128 string=GetImageArtifact(property_image,key);
4129 if (
string != (
const char *) NULL)
4130 AppendKeyValue2Text(key,
string);
4135 string=GetImageArtifact(property_image,pattern+9);
4136 if (
string == (
char *) NULL)
4137 goto PropertyLookupFailure;
4138 AppendString2Text(
string);
4141 if (LocaleNCompare(
"property:",pattern,9) == 0)
4146 if (IsGlob(pattern+9) != MagickFalse)
4148 ResetImagePropertyIterator(property_image);
4149 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4150 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4152 string=GetImageProperty(property_image,key,exception);
4153 if (
string != (
const char *) NULL)
4154 AppendKeyValue2Text(key,
string);
4159 string=GetImageProperty(property_image,pattern+9,exception);
4160 if (
string == (
char *) NULL)
4161 goto PropertyLookupFailure;
4162 AppendString2Text(
string);
4170 string=GetImageProperty(property_image,pattern,exception);
4171 if (
string != (
const char *) NULL)
4173 AppendString2Text(
string);
4174 (void) DeleteImageArtifact(property_image,
"magick-property");
4175 (void) DeleteImageOption(property_info,
"magick-property");
4178 if (IsGlob(pattern) != MagickFalse)
4184 ResetImagePropertyIterator(property_image);
4185 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4186 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4188 string=GetImageProperty(property_image,key,exception);
4189 if (
string != (
const char *) NULL)
4190 AppendKeyValue2Text(key,
string);
4200 string=GetMagickProperty(property_info,property_image,pattern,exception);
4201 if (
string != (
const char *) NULL)
4203 AppendString2Text(
string);
4210 string=GetImageArtifact(property_image,pattern);
4211 if (
string != (
char *) NULL)
4213 AppendString2Text(
string);
4219 string=GetImageOption(property_info,pattern);
4220 if (
string != (
char *) NULL)
4222 AppendString2Text(
string);
4225 PropertyLookupFailure:
4236 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4237 "UnknownImageProperty",
"\"%%[%s]\"",pattern);
4241 if (property_image != image)
4242 property_image=DestroyImage(property_image);
4243 if (property_info != image_info)
4244 property_info=DestroyImageInfo(property_info);
4245 return(interpret_text);
4276 MagickExport
char *RemoveImageProperty(
Image *image,
const char *property)
4281 assert(image != (
Image *) NULL);
4282 assert(image->signature == MagickCoreSignature);
4283 if (IsEventLogging() != MagickFalse)
4284 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4285 if (image->properties == (
void *) NULL)
4286 return((
char *) NULL);
4287 value=(
char *) RemoveNodeFromSplayTree((
SplayTreeInfo *) image->properties,
4316 MagickExport
void ResetImagePropertyIterator(
const Image *image)
4318 assert(image != (
Image *) NULL);
4319 assert(image->signature == MagickCoreSignature);
4320 if (IsEventLogging() != MagickFalse)
4321 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4322 if (image->properties == (
void *) NULL)
4324 ResetSplayTreeIterator((
SplayTreeInfo *) image->properties);
4360 MagickExport MagickBooleanType SetImageProperty(
Image *image,
4361 const char *property,
const char *value,
ExceptionInfo *exception)
4372 assert(image != (
Image *) NULL);
4373 assert(image->signature == MagickCoreSignature);
4374 if (IsEventLogging() != MagickFalse)
4375 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4376 if (image->properties == (
void *) NULL)
4377 image->properties=NewSplayTree(CompareSplayTreeString,
4378 RelinquishMagickMemory,RelinquishMagickMemory);
4379 if (value == (
const char *) NULL)
4380 return(DeleteImageProperty(image,property));
4381 if (strlen(property) <= 1)
4386 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4387 "SetReadOnlyProperty",
"`%s'",property);
4388 return(MagickFalse);
4390 property_length=strlen(property);
4391 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4392 (*(property+(property_length-1)) ==
'*'))
4394 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4395 "SetReadOnlyProperty",
"`%s'",property);
4396 return(MagickFalse);
4410 if (LocaleNCompare(
"8bim:",property,5) == 0)
4412 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4413 "SetReadOnlyProperty",
"`%s'",property);
4414 return(MagickFalse);
4422 if (LocaleCompare(
"background",property) == 0)
4424 (void) QueryColorCompliance(value,AllCompliance,
4425 &image->background_color,exception);
4434 if (LocaleCompare(
"channels",property) == 0)
4436 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4437 "SetReadOnlyProperty",
"`%s'",property);
4438 return(MagickFalse);
4440 if (LocaleCompare(
"colorspace",property) == 0)
4445 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4448 return(MagickFalse);
4449 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4451 if (LocaleCompare(
"compose",property) == 0)
4456 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4458 return(MagickFalse);
4459 image->compose=(CompositeOperator) compose;
4462 if (LocaleCompare(
"compress",property) == 0)
4467 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4469 if (compression < 0)
4470 return(MagickFalse);
4471 image->compression=(CompressionType) compression;
4479 if (LocaleCompare(
"delay",property) == 0)
4484 flags=ParseGeometry(value,&geometry_info);
4485 if ((flags & GreaterValue) != 0)
4487 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4488 image->delay=(size_t) floor(geometry_info.rho+0.5);
4491 if ((flags & LessValue) != 0)
4493 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4494 image->delay=CastDoubleToLong(
4495 floor(geometry_info.sigma+0.5));
4498 image->delay=(size_t) floor(geometry_info.rho+0.5);
4499 if ((flags & SigmaValue) != 0)
4500 image->ticks_per_second=CastDoubleToLong(floor(
4501 geometry_info.sigma+0.5));
4504 if (LocaleCompare(
"delay_units",property) == 0)
4506 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4507 "SetReadOnlyProperty",
"`%s'",property);
4508 return(MagickFalse);
4510 if (LocaleCompare(
"density",property) == 0)
4515 flags=ParseGeometry(value,&geometry_info);
4516 if ((flags & RhoValue) != 0)
4517 image->resolution.x=geometry_info.rho;
4518 image->resolution.y=image->resolution.x;
4519 if ((flags & SigmaValue) != 0)
4520 image->resolution.y=geometry_info.sigma;
4523 if (LocaleCompare(
"depth",property) == 0)
4525 image->depth=StringToUnsignedLong(value);
4528 if (LocaleCompare(
"dispose",property) == 0)
4533 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4535 return(MagickFalse);
4536 image->dispose=(DisposeType) dispose;
4546 if (LocaleNCompare(
"exif:",property,5) == 0)
4548 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4549 "SetReadOnlyProperty",
"`%s'",property);
4550 return(MagickFalse);
4557 if (LocaleNCompare(
"fx:",property,3) == 0)
4559 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4560 "SetReadOnlyProperty",
"`%s'",property);
4561 return(MagickFalse);
4569 if (LocaleCompare(
"gamma",property) == 0)
4571 image->gamma=StringToDouble(value,(
char **) NULL);
4574 if (LocaleCompare(
"gravity",property) == 0)
4579 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4581 return(MagickFalse);
4582 image->gravity=(GravityType) gravity;
4590 if (LocaleCompare(
"height",property) == 0)
4592 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4593 "SetReadOnlyProperty",
"`%s'",property);
4594 return(MagickFalse);
4601 if (LocaleCompare(
"intensity",property) == 0)
4606 intensity=ParseCommandOption(MagickIntensityOptions,MagickFalse,
4609 return(MagickFalse);
4610 image->intensity=(PixelIntensityMethod) intensity;
4613 if (LocaleCompare(
"intent",property) == 0)
4618 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4620 if (rendering_intent < 0)
4621 return(MagickFalse);
4622 image->rendering_intent=(RenderingIntent) rendering_intent;
4625 if (LocaleCompare(
"interpolate",property) == 0)
4630 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4632 if (interpolate < 0)
4633 return(MagickFalse);
4634 image->interpolate=(PixelInterpolateMethod) interpolate;
4639 if (LocaleNCompare(
"iptc:",property,5) == 0)
4641 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4642 "SetReadOnlyProperty",
"`%s'",property);
4643 return(MagickFalse);
4650 if (LocaleCompare(
"kurtosis",property) == 0)
4652 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4653 "SetReadOnlyProperty",
"`%s'",property);
4654 return(MagickFalse);
4660 if (LocaleCompare(
"loop",property) == 0)
4662 image->iterations=StringToUnsignedLong(value);
4669 if ((LocaleCompare(
"magick",property) == 0) ||
4670 (LocaleCompare(
"max",property) == 0) ||
4671 (LocaleCompare(
"mean",property) == 0) ||
4672 (LocaleCompare(
"min",property) == 0) ||
4673 (LocaleCompare(
"min",property) == 0))
4675 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4676 "SetReadOnlyProperty",
"`%s'",property);
4677 return(MagickFalse);
4682 if (LocaleCompare(
"opaque",property) == 0)
4684 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4685 "SetReadOnlyProperty",
"`%s'",property);
4686 return(MagickFalse);
4692 if (LocaleCompare(
"page",property) == 0)
4697 geometry=GetPageGeometry(value);
4698 flags=ParseAbsoluteGeometry(geometry,&image->page);
4699 geometry=DestroyString(geometry);
4704 if (LocaleNCompare(
"pixel:",property,6) == 0)
4706 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4707 "SetReadOnlyProperty",
"`%s'",property);
4708 return(MagickFalse);
4711 if (LocaleCompare(
"profile",property) == 0)
4719 image_info=AcquireImageInfo();
4720 (void) CopyMagickString(image_info->filename,value,MagickPathExtent);
4721 (void) SetImageInfo(image_info,1,exception);
4722 profile=FileToStringInfo(image_info->filename,~0UL,exception);
4725 status=SetImageProfile(image,image_info->magick,profile,
4727 profile=DestroyStringInfo(profile);
4729 image_info=DestroyImageInfo(image_info);
4737 if (LocaleCompare(
"rendering-intent",property) == 0)
4742 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4744 if (rendering_intent < 0)
4745 return(MagickFalse);
4746 image->rendering_intent=(RenderingIntent) rendering_intent;
4753 if ((LocaleCompare(
"size",property) == 0) ||
4754 (LocaleCompare(
"skewness",property) == 0) ||
4755 (LocaleCompare(
"scenes",property) == 0) ||
4756 (LocaleCompare(
"standard-deviation",property) == 0))
4758 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4759 "SetReadOnlyProperty",
"`%s'",property);
4760 return(MagickFalse);
4766 if (LocaleCompare(
"tile-offset",property) == 0)
4771 geometry=GetPageGeometry(value);
4772 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4773 geometry=DestroyString(geometry);
4776 if (LocaleCompare(
"type",property) == 0)
4781 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4783 return(MagickFalse);
4784 image->type=(ImageType) type;
4792 if (LocaleCompare(
"units",property) == 0)
4797 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4799 return(MagickFalse);
4800 image->units=(ResolutionType) units;
4808 if (LocaleCompare(
"version",property) == 0)
4810 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4811 "SetReadOnlyProperty",
"`%s'",property);
4812 return(MagickFalse);
4819 if (LocaleCompare(
"width",property) == 0)
4821 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4822 "SetReadOnlyProperty",
"`%s'",property);
4823 return(MagickFalse);
4832 if (LocaleNCompare(
"xmp:",property,4) == 0)
4834 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4835 "SetReadOnlyProperty",
"`%s'",property);
4836 return(MagickFalse);
4843 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4844 ConstantString(property),ConstantString(value));