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)
103#if defined(MAGICKCORE_LCMS_DELEGATE)
104#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
105#define cmsUInt32Number DWORD
136 *(*CloneKeyFunc)(
const char *),
137 *(*CloneValueFunc)(
const char *);
139static inline void *ClonePropertyKey(
void *key)
141 return((
void *) ((CloneKeyFunc) ConstantString)((
const char *) key));
144static inline void *ClonePropertyValue(
void *value)
146 return((
void *) ((CloneValueFunc) ConstantString)((
const char *) value));
149MagickExport MagickBooleanType CloneImageProperties(Image *image,
150 const Image *clone_image)
152 assert(image != (Image *) NULL);
153 assert(image->signature == MagickCoreSignature);
154 assert(clone_image != (
const Image *) NULL);
155 assert(clone_image->signature == MagickCoreSignature);
156 if (IsEventLogging() != MagickFalse)
158 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
159 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
160 clone_image->filename);
162 (void) CopyMagickString(image->filename,clone_image->filename,
164 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
166 image->compression=clone_image->compression;
167 image->quality=clone_image->quality;
168 image->depth=clone_image->depth;
169 image->matte_color=clone_image->matte_color;
170 image->background_color=clone_image->background_color;
171 image->border_color=clone_image->border_color;
172 image->transparent_color=clone_image->transparent_color;
173 image->gamma=clone_image->gamma;
174 image->chromaticity=clone_image->chromaticity;
175 image->rendering_intent=clone_image->rendering_intent;
176 image->black_point_compensation=clone_image->black_point_compensation;
177 image->units=clone_image->units;
178 image->montage=(
char *) NULL;
179 image->directory=(
char *) NULL;
180 (void) CloneString(&image->geometry,clone_image->geometry);
181 image->offset=clone_image->offset;
182 image->resolution.x=clone_image->resolution.x;
183 image->resolution.y=clone_image->resolution.y;
184 image->page=clone_image->page;
185 image->tile_offset=clone_image->tile_offset;
186 image->extract_info=clone_image->extract_info;
187 image->filter=clone_image->filter;
188 image->fuzz=clone_image->fuzz;
189 image->intensity=clone_image->intensity;
190 image->interlace=clone_image->interlace;
191 image->interpolate=clone_image->interpolate;
192 image->endian=clone_image->endian;
193 image->gravity=clone_image->gravity;
194 image->compose=clone_image->compose;
195 image->orientation=clone_image->orientation;
196 image->scene=clone_image->scene;
197 image->dispose=clone_image->dispose;
198 image->delay=clone_image->delay;
199 image->ticks_per_second=clone_image->ticks_per_second;
200 image->iterations=clone_image->iterations;
201 image->total_colors=clone_image->total_colors;
202 image->taint=clone_image->taint;
203 image->progress_monitor=clone_image->progress_monitor;
204 image->client_data=clone_image->client_data;
205 image->start_loop=clone_image->start_loop;
206 image->error=clone_image->error;
207 image->signature=clone_image->signature;
208 if (clone_image->properties != (
void *) NULL)
210 if (image->properties != (
void *) NULL)
211 DestroyImageProperties(image);
212 image->properties=CloneSplayTree((SplayTreeInfo *)
213 clone_image->properties,ClonePropertyKey,ClonePropertyValue);
247MagickExport MagickBooleanType DefineImageProperty(Image *image,
248 const char *property,ExceptionInfo *exception)
251 key[MagickPathExtent],
252 value[MagickPathExtent];
257 assert(image != (Image *) NULL);
258 assert(property != (
const char *) NULL);
259 (void) CopyMagickString(key,property,MagickPathExtent-1);
260 for (p=key; *p !=
'\0'; p++)
265 (void) CopyMagickString(value,p+1,MagickPathExtent);
267 return(SetImageProperty(image,key,value,exception));
294MagickExport MagickBooleanType DeleteImageProperty(Image *image,
295 const char *property)
297 assert(image != (Image *) NULL);
298 assert(image->signature == MagickCoreSignature);
299 if (IsEventLogging() != MagickFalse)
300 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
301 if (image->properties == (
void *) NULL)
303 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
329MagickExport
void DestroyImageProperties(Image *image)
331 assert(image != (Image *) NULL);
332 assert(image->signature == MagickCoreSignature);
333 if (IsEventLogging() != MagickFalse)
334 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
335 if (image->properties != (
void *) NULL)
336 image->properties=(
void *) DestroySplayTree((SplayTreeInfo *)
369MagickExport MagickBooleanType FormatImageProperty(Image *image,
370 const char *property,
const char *format,...)
373 value[MagickPathExtent];
387 va_start(operands,format);
388 n=FormatLocaleStringList(value,MagickPathExtent,format,operands);
391 exception=AcquireExceptionInfo();
392 status=SetImageProperty(image,property,value,exception);
393 exception=DestroyExceptionInfo(exception);
433 *TracePSClippath(
const unsigned char *,
size_t),
434 *TraceSVGClippath(
const unsigned char *,
size_t,
const size_t,
437static void GetIPTCProperty(
const Image *image,
const char *key,
438 ExceptionInfo *exception)
458 profile=GetImageProfile(image,
"iptc");
459 if (profile == (StringInfo *) NULL)
460 profile=GetImageProfile(image,
"8bim");
461 if (profile == (StringInfo *) NULL)
463 count=MagickSscanf(key,
"IPTC:%ld:%ld",&dataset,&record);
466 attribute=(
char *) NULL;
467 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
470 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
472 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
473 length|=GetStringInfoDatum(profile)[i+4];
474 if (((
long) GetStringInfoDatum(profile)[i+1] == dataset) &&
475 ((
long) GetStringInfoDatum(profile)[i+2] == record))
477 message=(
char *) NULL;
479 message=(
char *) AcquireQuantumMemory(length+1UL,
sizeof(*message));
480 if (message != (
char *) NULL)
482 (void) CopyMagickString(message,(
char *) GetStringInfoDatum(
483 profile)+i+5,length+1);
484 (void) ConcatenateString(&attribute,message);
485 (void) ConcatenateString(&attribute,
";");
486 message=DestroyString(message);
491 if ((attribute == (
char *) NULL) || (*attribute ==
';'))
493 if (attribute != (
char *) NULL)
494 attribute=DestroyString(attribute);
497 attribute[strlen(attribute)-1]=
'\0';
498 (void) SetImageProperty((Image *) image,key,(
const char *) attribute,
500 attribute=DestroyString(attribute);
503static inline int ReadPropertyByte(
const unsigned char **p,
size_t *length)
515static inline signed int ReadPropertyMSBLong(
const unsigned char **p,
541 for (i=0; i < 4; i++)
545 buffer[i]=(
unsigned char) c;
547 value=(
unsigned int) buffer[0] << 24;
548 value|=(
unsigned int) buffer[1] << 16;
549 value|=(
unsigned int) buffer[2] << 8;
550 value|=(
unsigned int) buffer[3];
551 quantum.unsigned_value=value & 0xffffffff;
552 return(quantum.signed_value);
555static inline signed short ReadPropertyMSBShort(
const unsigned char **p,
581 for (i=0; i < 2; i++)
585 buffer[i]=(
unsigned char) c;
587 value=(
unsigned short) buffer[0] << 8;
588 value|=(
unsigned short) buffer[1];
589 quantum.unsigned_value=value & 0xffff;
590 return(quantum.signed_value);
593static void Get8BIMProperty(
const Image *image,
const char *key,
594 ExceptionInfo *exception)
598 format[MagickPathExtent],
599 name[MagickPathExtent],
627 profile=GetImageProfile(image,
"8bim");
628 if (profile == (StringInfo *) NULL)
630 count=(ssize_t) MagickSscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",
631 &start,&stop,name,format);
632 if ((count != 2) && (count != 3) && (count != 4))
635 (void) CopyMagickString(format,
"SVG",MagickPathExtent);
640 sub_number=(ssize_t) StringToLong(&name[1]);
641 sub_number=MagickMax(sub_number,1L);
642 resource=(
char *) NULL;
644 length=GetStringInfoLength(profile);
645 info=GetStringInfoDatum(profile);
646 while ((length > 0) && (status == MagickFalse))
648 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'8')
650 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'B')
652 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'I')
654 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'M')
656 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
657 if (
id < (ssize_t) start)
659 if (
id > (ssize_t) stop)
661 if (resource != (
char *) NULL)
662 resource=DestroyString(resource);
663 count=(ssize_t) ReadPropertyByte(&info,&length);
664 if ((count != 0) && ((
size_t) count <= length))
666 resource=(
char *) NULL;
667 if (~((
size_t) count) >= (MagickPathExtent-1))
668 resource=(
char *) AcquireQuantumMemory((
size_t) count+
669 MagickPathExtent,
sizeof(*resource));
670 if (resource != (
char *) NULL)
672 for (i=0; i < (ssize_t) count; i++)
673 resource[i]=(
char) ReadPropertyByte(&info,&length);
674 resource[count]=
'\0';
677 if ((count & 0x01) == 0)
678 (void) ReadPropertyByte(&info,&length);
679 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
680 if ((count < 0) || ((
size_t) count > length))
685 if ((*name !=
'\0') && (*name !=
'#'))
686 if ((resource == (
char *) NULL) || (LocaleCompare(name,resource) != 0))
692 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
695 if ((*name ==
'#') && (sub_number != 1))
702 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
708 attribute=(
char *) NULL;
709 if (~((
size_t) count) >= (MagickPathExtent-1))
710 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MagickPathExtent,
712 if (attribute != (
char *) NULL)
714 (void) memcpy(attribute,(
char *) info,(
size_t) count);
715 attribute[count]=
'\0';
717 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
718 if ((
id <= 1999) || (
id >= 2999))
719 (void) SetImageProperty((Image *) image,key,(
const char *) attribute,
726 if (LocaleCompare(format,
"svg") == 0)
727 path=TraceSVGClippath((
unsigned char *) attribute,(
size_t) count,
728 image->columns,image->rows);
730 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count);
731 (void) SetImageProperty((Image *) image,key,(
const char *) path,
733 path=DestroyString(path);
735 attribute=DestroyString(attribute);
739 if (resource != (
char *) NULL)
740 resource=DestroyString(resource);
743static inline signed int ReadPropertySignedLong(
const EndianType endian,
744 const unsigned char *buffer)
758 if (endian == LSBEndian)
760 value=(
unsigned int) buffer[3] << 24;
761 value|=(
unsigned int) buffer[2] << 16;
762 value|=(
unsigned int) buffer[1] << 8;
763 value|=(
unsigned int) buffer[0];
764 quantum.unsigned_value=value & 0xffffffff;
765 return(quantum.signed_value);
767 value=(
unsigned int) buffer[0] << 24;
768 value|=(
unsigned int) buffer[1] << 16;
769 value|=(
unsigned int) buffer[2] << 8;
770 value|=(
unsigned int) buffer[3];
771 quantum.unsigned_value=value & 0xffffffff;
772 return(quantum.signed_value);
775static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
776 const unsigned char *buffer)
781 if (endian == LSBEndian)
783 value=(
unsigned int) buffer[3] << 24;
784 value|=(
unsigned int) buffer[2] << 16;
785 value|=(
unsigned int) buffer[1] << 8;
786 value|=(
unsigned int) buffer[0];
787 return(value & 0xffffffff);
789 value=(
unsigned int) buffer[0] << 24;
790 value|=(
unsigned int) buffer[1] << 16;
791 value|=(
unsigned int) buffer[2] << 8;
792 value|=(
unsigned int) buffer[3];
793 return(value & 0xffffffff);
796static inline signed short ReadPropertySignedShort(
const EndianType endian,
797 const unsigned char *buffer)
811 if (endian == LSBEndian)
813 value=(
unsigned short) buffer[1] << 8;
814 value|=(
unsigned short) buffer[0];
815 quantum.unsigned_value=value & 0xffff;
816 return(quantum.signed_value);
818 value=(
unsigned short) buffer[0] << 8;
819 value|=(
unsigned short) buffer[1];
820 quantum.unsigned_value=value & 0xffff;
821 return(quantum.signed_value);
824static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
825 const unsigned char *buffer)
830 if (endian == LSBEndian)
832 value=(
unsigned short) buffer[1] << 8;
833 value|=(
unsigned short) buffer[0];
834 return(value & 0xffff);
836 value=(
unsigned short) buffer[0] << 8;
837 value|=(
unsigned short) buffer[1];
838 return(value & 0xffff);
841static void GetEXIFProperty(
const Image *image,
const char *property,
842 ExceptionInfo *exception)
844#define MaxDirectoryStack 16
845#define EXIF_DELIMITER "\n"
846#define EXIF_NUM_FORMATS 12
847#define EXIF_FMT_BYTE 1
848#define EXIF_FMT_STRING 2
849#define EXIF_FMT_USHORT 3
850#define EXIF_FMT_ULONG 4
851#define EXIF_FMT_URATIONAL 5
852#define EXIF_FMT_SBYTE 6
853#define EXIF_FMT_UNDEFINED 7
854#define EXIF_FMT_SSHORT 8
855#define EXIF_FMT_SLONG 9
856#define EXIF_FMT_SRATIONAL 10
857#define EXIF_FMT_SINGLE 11
858#define EXIF_FMT_DOUBLE 12
859#define GPS_LATITUDE 0x10002
860#define GPS_LONGITUDE 0x10004
861#define GPS_TIMESTAMP 0x10007
862#define TAG_EXIF_OFFSET 0x8769
863#define TAG_GPS_OFFSET 0x8825
864#define TAG_INTEROP_OFFSET 0xa005
866#define EXIFGPSFractions(format,arg1,arg2,arg3,arg4,arg5,arg6) \
874 for ( ; component < components; component++) \
876 if (component != 0) \
877 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
879 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
880 extent,format,(arg1),(arg2),(arg3),(arg4),(arg5),(arg6)); \
881 if (extent >= (MagickPathExtent-1)) \
882 extent=MagickPathExtent-1; \
884 buffer[extent]='\0'; \
885 value=AcquireString(buffer); \
888#define EXIFMultipleValues(format,arg) \
896 for ( ; component < components; component++) \
898 if (component != 0) \
899 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
901 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
902 extent,format,arg); \
903 if (extent >= (MagickPathExtent-1)) \
904 extent=MagickPathExtent-1; \
906 buffer[extent]='\0'; \
907 value=AcquireString(buffer); \
910#define EXIFMultipleFractions(format,arg1,arg2) \
918 for ( ; component < components; component++) \
920 if (component != 0) \
921 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent-\
923 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
924 extent,format,(arg1),(arg2)); \
925 if (extent >= (MagickPathExtent-1)) \
926 extent=MagickPathExtent-1; \
928 buffer[extent]='\0'; \
929 value=AcquireString(buffer); \
932 typedef struct _DirectoryInfo
944 typedef struct _TagInfo
956 { 0x001,
"exif:InteroperabilityIndex" },
957 { 0x002,
"exif:InteroperabilityVersion" },
958 { 0x100,
"exif:ImageWidth" },
959 { 0x101,
"exif:ImageLength" },
960 { 0x102,
"exif:BitsPerSample" },
961 { 0x103,
"exif:Compression" },
962 { 0x106,
"exif:PhotometricInterpretation" },
963 { 0x10a,
"exif:FillOrder" },
964 { 0x10d,
"exif:DocumentName" },
965 { 0x10e,
"exif:ImageDescription" },
966 { 0x10f,
"exif:Make" },
967 { 0x110,
"exif:Model" },
968 { 0x111,
"exif:StripOffsets" },
969 { 0x112,
"exif:Orientation" },
970 { 0x115,
"exif:SamplesPerPixel" },
971 { 0x116,
"exif:RowsPerStrip" },
972 { 0x117,
"exif:StripByteCounts" },
973 { 0x11a,
"exif:XResolution" },
974 { 0x11b,
"exif:YResolution" },
975 { 0x11c,
"exif:PlanarConfiguration" },
976 { 0x11d,
"exif:PageName" },
977 { 0x11e,
"exif:XPosition" },
978 { 0x11f,
"exif:YPosition" },
979 { 0x118,
"exif:MinSampleValue" },
980 { 0x119,
"exif:MaxSampleValue" },
981 { 0x120,
"exif:FreeOffsets" },
982 { 0x121,
"exif:FreeByteCounts" },
983 { 0x122,
"exif:GrayResponseUnit" },
984 { 0x123,
"exif:GrayResponseCurve" },
985 { 0x124,
"exif:T4Options" },
986 { 0x125,
"exif:T6Options" },
987 { 0x128,
"exif:ResolutionUnit" },
988 { 0x12d,
"exif:TransferFunction" },
989 { 0x131,
"exif:Software" },
990 { 0x132,
"exif:DateTime" },
991 { 0x13b,
"exif:Artist" },
992 { 0x13e,
"exif:WhitePoint" },
993 { 0x13f,
"exif:PrimaryChromaticities" },
994 { 0x140,
"exif:ColorMap" },
995 { 0x141,
"exif:HalfToneHints" },
996 { 0x142,
"exif:TileWidth" },
997 { 0x143,
"exif:TileLength" },
998 { 0x144,
"exif:TileOffsets" },
999 { 0x145,
"exif:TileByteCounts" },
1000 { 0x14a,
"exif:SubIFD" },
1001 { 0x14c,
"exif:InkSet" },
1002 { 0x14d,
"exif:InkNames" },
1003 { 0x14e,
"exif:NumberOfInks" },
1004 { 0x150,
"exif:DotRange" },
1005 { 0x151,
"exif:TargetPrinter" },
1006 { 0x152,
"exif:ExtraSample" },
1007 { 0x153,
"exif:SampleFormat" },
1008 { 0x154,
"exif:SMinSampleValue" },
1009 { 0x155,
"exif:SMaxSampleValue" },
1010 { 0x156,
"exif:TransferRange" },
1011 { 0x157,
"exif:ClipPath" },
1012 { 0x158,
"exif:XClipPathUnits" },
1013 { 0x159,
"exif:YClipPathUnits" },
1014 { 0x15a,
"exif:Indexed" },
1015 { 0x15b,
"exif:JPEGTables" },
1016 { 0x15f,
"exif:OPIProxy" },
1017 { 0x200,
"exif:JPEGProc" },
1018 { 0x201,
"exif:JPEGInterchangeFormat" },
1019 { 0x202,
"exif:JPEGInterchangeFormatLength" },
1020 { 0x203,
"exif:JPEGRestartInterval" },
1021 { 0x205,
"exif:JPEGLosslessPredictors" },
1022 { 0x206,
"exif:JPEGPointTransforms" },
1023 { 0x207,
"exif:JPEGQTables" },
1024 { 0x208,
"exif:JPEGDCTables" },
1025 { 0x209,
"exif:JPEGACTables" },
1026 { 0x211,
"exif:YCbCrCoefficients" },
1027 { 0x212,
"exif:YCbCrSubSampling" },
1028 { 0x213,
"exif:YCbCrPositioning" },
1029 { 0x214,
"exif:ReferenceBlackWhite" },
1030 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1031 { 0x301,
"exif:Gamma" },
1032 { 0x302,
"exif:ICCProfileDescriptor" },
1033 { 0x303,
"exif:SRGBRenderingIntent" },
1034 { 0x320,
"exif:ImageTitle" },
1035 { 0x5001,
"exif:ResolutionXUnit" },
1036 { 0x5002,
"exif:ResolutionYUnit" },
1037 { 0x5003,
"exif:ResolutionXLengthUnit" },
1038 { 0x5004,
"exif:ResolutionYLengthUnit" },
1039 { 0x5005,
"exif:PrintFlags" },
1040 { 0x5006,
"exif:PrintFlagsVersion" },
1041 { 0x5007,
"exif:PrintFlagsCrop" },
1042 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1043 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1044 { 0x500A,
"exif:HalftoneLPI" },
1045 { 0x500B,
"exif:HalftoneLPIUnit" },
1046 { 0x500C,
"exif:HalftoneDegree" },
1047 { 0x500D,
"exif:HalftoneShape" },
1048 { 0x500E,
"exif:HalftoneMisc" },
1049 { 0x500F,
"exif:HalftoneScreen" },
1050 { 0x5010,
"exif:JPEGQuality" },
1051 { 0x5011,
"exif:GridSize" },
1052 { 0x5012,
"exif:ThumbnailFormat" },
1053 { 0x5013,
"exif:ThumbnailWidth" },
1054 { 0x5014,
"exif:ThumbnailHeight" },
1055 { 0x5015,
"exif:ThumbnailColorDepth" },
1056 { 0x5016,
"exif:ThumbnailPlanes" },
1057 { 0x5017,
"exif:ThumbnailRawBytes" },
1058 { 0x5018,
"exif:ThumbnailSize" },
1059 { 0x5019,
"exif:ThumbnailCompressedSize" },
1060 { 0x501a,
"exif:ColorTransferFunction" },
1061 { 0x501b,
"exif:ThumbnailData" },
1062 { 0x5020,
"exif:ThumbnailImageWidth" },
1063 { 0x5021,
"exif:ThumbnailImageHeight" },
1064 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1065 { 0x5023,
"exif:ThumbnailCompression" },
1066 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1067 { 0x5025,
"exif:ThumbnailImageDescription" },
1068 { 0x5026,
"exif:ThumbnailEquipMake" },
1069 { 0x5027,
"exif:ThumbnailEquipModel" },
1070 { 0x5028,
"exif:ThumbnailStripOffsets" },
1071 { 0x5029,
"exif:ThumbnailOrientation" },
1072 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1073 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1074 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1075 { 0x502d,
"exif:ThumbnailResolutionX" },
1076 { 0x502e,
"exif:ThumbnailResolutionY" },
1077 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1078 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1079 { 0x5031,
"exif:ThumbnailTransferFunction" },
1080 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1081 { 0x5033,
"exif:ThumbnailDateTime" },
1082 { 0x5034,
"exif:ThumbnailArtist" },
1083 { 0x5035,
"exif:ThumbnailWhitePoint" },
1084 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1085 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1086 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1087 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1088 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1089 { 0x503B,
"exif:ThumbnailCopyRight" },
1090 { 0x5090,
"exif:LuminanceTable" },
1091 { 0x5091,
"exif:ChrominanceTable" },
1092 { 0x5100,
"exif:FrameDelay" },
1093 { 0x5101,
"exif:LoopCount" },
1094 { 0x5110,
"exif:PixelUnit" },
1095 { 0x5111,
"exif:PixelPerUnitX" },
1096 { 0x5112,
"exif:PixelPerUnitY" },
1097 { 0x5113,
"exif:PaletteHistogram" },
1098 { 0x1000,
"exif:RelatedImageFileFormat" },
1099 { 0x1001,
"exif:RelatedImageLength" },
1100 { 0x1002,
"exif:RelatedImageWidth" },
1101 { 0x800d,
"exif:ImageID" },
1102 { 0x80e3,
"exif:Matteing" },
1103 { 0x80e4,
"exif:DataType" },
1104 { 0x80e5,
"exif:ImageDepth" },
1105 { 0x80e6,
"exif:TileDepth" },
1106 { 0x828d,
"exif:CFARepeatPatternDim" },
1107 { 0x828e,
"exif:CFAPattern2" },
1108 { 0x828f,
"exif:BatteryLevel" },
1109 { 0x8298,
"exif:Copyright" },
1110 { 0x829a,
"exif:ExposureTime" },
1111 { 0x829d,
"exif:FNumber" },
1112 { 0x83bb,
"exif:IPTC/NAA" },
1113 { 0x84e3,
"exif:IT8RasterPadding" },
1114 { 0x84e5,
"exif:IT8ColorTable" },
1115 { 0x8649,
"exif:ImageResourceInformation" },
1116 { 0x8769,
"exif:ExifOffset" },
1117 { 0x8773,
"exif:InterColorProfile" },
1118 { 0x8822,
"exif:ExposureProgram" },
1119 { 0x8824,
"exif:SpectralSensitivity" },
1120 { 0x8825,
"exif:GPSInfo" },
1121 { 0x8827,
"exif:PhotographicSensitivity" },
1122 { 0x8828,
"exif:OECF" },
1123 { 0x8829,
"exif:Interlace" },
1124 { 0x882a,
"exif:TimeZoneOffset" },
1125 { 0x882b,
"exif:SelfTimerMode" },
1126 { 0x8830,
"exif:SensitivityType" },
1127 { 0x8831,
"exif:StandardOutputSensitivity" },
1128 { 0x8832,
"exif:RecommendedExposureIndex" },
1129 { 0x8833,
"exif:ISOSpeed" },
1130 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1131 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1132 { 0x9000,
"exif:ExifVersion" },
1133 { 0x9003,
"exif:DateTimeOriginal" },
1134 { 0x9004,
"exif:DateTimeDigitized" },
1135 { 0x9010,
"exif:OffsetTime" },
1136 { 0x9011,
"exif:OffsetTimeOriginal" },
1137 { 0x9012,
"exif:OffsetTimeDigitized" },
1138 { 0x9101,
"exif:ComponentsConfiguration" },
1139 { 0x9102,
"exif:CompressedBitsPerPixel" },
1140 { 0x9201,
"exif:ShutterSpeedValue" },
1141 { 0x9202,
"exif:ApertureValue" },
1142 { 0x9203,
"exif:BrightnessValue" },
1143 { 0x9204,
"exif:ExposureBiasValue" },
1144 { 0x9205,
"exif:MaxApertureValue" },
1145 { 0x9206,
"exif:SubjectDistance" },
1146 { 0x9207,
"exif:MeteringMode" },
1147 { 0x9208,
"exif:LightSource" },
1148 { 0x9209,
"exif:Flash" },
1149 { 0x920a,
"exif:FocalLength" },
1150 { 0x920b,
"exif:FlashEnergy" },
1151 { 0x920c,
"exif:SpatialFrequencyResponse" },
1152 { 0x920d,
"exif:Noise" },
1153 { 0x9214,
"exif:SubjectArea" },
1154 { 0x9290,
"exif:SubSecTime" },
1155 { 0x9291,
"exif:SubSecTimeOriginal" },
1156 { 0x9292,
"exif:SubSecTimeDigitized" },
1157 { 0x9211,
"exif:ImageNumber" },
1158 { 0x9212,
"exif:SecurityClassification" },
1159 { 0x9213,
"exif:ImageHistory" },
1160 { 0x9214,
"exif:SubjectArea" },
1161 { 0x9215,
"exif:ExposureIndex" },
1162 { 0x9216,
"exif:TIFF-EPStandardID" },
1163 { 0x927c,
"exif:MakerNote" },
1164 { 0x9286,
"exif:UserComment" },
1165 { 0x9290,
"exif:SubSecTime" },
1166 { 0x9291,
"exif:SubSecTimeOriginal" },
1167 { 0x9292,
"exif:SubSecTimeDigitized" },
1168 { 0x9400,
"exif:Temperature" },
1169 { 0x9401,
"exif:Humidity" },
1170 { 0x9402,
"exif:Pressure" },
1171 { 0x9403,
"exif:WaterDepth" },
1172 { 0x9404,
"exif:Acceleration" },
1173 { 0x9405,
"exif:CameraElevationAngle" },
1174 { 0x9C9b,
"exif:WinXP-Title" },
1175 { 0x9C9c,
"exif:WinXP-Comments" },
1176 { 0x9C9d,
"exif:WinXP-Author" },
1177 { 0x9C9e,
"exif:WinXP-Keywords" },
1178 { 0x9C9f,
"exif:WinXP-Subject" },
1179 { 0xa000,
"exif:FlashPixVersion" },
1180 { 0xa001,
"exif:ColorSpace" },
1181 { 0xa002,
"exif:PixelXDimension" },
1182 { 0xa003,
"exif:PixelYDimension" },
1183 { 0xa004,
"exif:RelatedSoundFile" },
1184 { 0xa005,
"exif:InteroperabilityOffset" },
1185 { 0xa20b,
"exif:FlashEnergy" },
1186 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1187 { 0xa20d,
"exif:Noise" },
1188 { 0xa20e,
"exif:FocalPlaneXResolution" },
1189 { 0xa20f,
"exif:FocalPlaneYResolution" },
1190 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1191 { 0xa214,
"exif:SubjectLocation" },
1192 { 0xa215,
"exif:ExposureIndex" },
1193 { 0xa216,
"exif:TIFF/EPStandardID" },
1194 { 0xa217,
"exif:SensingMethod" },
1195 { 0xa300,
"exif:FileSource" },
1196 { 0xa301,
"exif:SceneType" },
1197 { 0xa302,
"exif:CFAPattern" },
1198 { 0xa401,
"exif:CustomRendered" },
1199 { 0xa402,
"exif:ExposureMode" },
1200 { 0xa403,
"exif:WhiteBalance" },
1201 { 0xa404,
"exif:DigitalZoomRatio" },
1202 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1203 { 0xa406,
"exif:SceneCaptureType" },
1204 { 0xa407,
"exif:GainControl" },
1205 { 0xa408,
"exif:Contrast" },
1206 { 0xa409,
"exif:Saturation" },
1207 { 0xa40a,
"exif:Sharpness" },
1208 { 0xa40b,
"exif:DeviceSettingDescription" },
1209 { 0xa40c,
"exif:SubjectDistanceRange" },
1210 { 0xa420,
"exif:ImageUniqueID" },
1211 { 0xa430,
"exif:CameraOwnerName" },
1212 { 0xa431,
"exif:BodySerialNumber" },
1213 { 0xa432,
"exif:LensSpecification" },
1214 { 0xa433,
"exif:LensMake" },
1215 { 0xa434,
"exif:LensModel" },
1216 { 0xa435,
"exif:LensSerialNumber" },
1217 { 0xc4a5,
"exif:PrintImageMatching" },
1218 { 0xa500,
"exif:Gamma" },
1219 { 0xc640,
"exif:CR2Slice" },
1220 { 0x10000,
"exif:GPSVersionID" },
1221 { 0x10001,
"exif:GPSLatitudeRef" },
1222 { 0x10002,
"exif:GPSLatitude" },
1223 { 0x10003,
"exif:GPSLongitudeRef" },
1224 { 0x10004,
"exif:GPSLongitude" },
1225 { 0x10005,
"exif:GPSAltitudeRef" },
1226 { 0x10006,
"exif:GPSAltitude" },
1227 { 0x10007,
"exif:GPSTimeStamp" },
1228 { 0x10008,
"exif:GPSSatellites" },
1229 { 0x10009,
"exif:GPSStatus" },
1230 { 0x1000a,
"exif:GPSMeasureMode" },
1231 { 0x1000b,
"exif:GPSDop" },
1232 { 0x1000c,
"exif:GPSSpeedRef" },
1233 { 0x1000d,
"exif:GPSSpeed" },
1234 { 0x1000e,
"exif:GPSTrackRef" },
1235 { 0x1000f,
"exif:GPSTrack" },
1236 { 0x10010,
"exif:GPSImgDirectionRef" },
1237 { 0x10011,
"exif:GPSImgDirection" },
1238 { 0x10012,
"exif:GPSMapDatum" },
1239 { 0x10013,
"exif:GPSDestLatitudeRef" },
1240 { 0x10014,
"exif:GPSDestLatitude" },
1241 { 0x10015,
"exif:GPSDestLongitudeRef" },
1242 { 0x10016,
"exif:GPSDestLongitude" },
1243 { 0x10017,
"exif:GPSDestBearingRef" },
1244 { 0x10018,
"exif:GPSDestBearing" },
1245 { 0x10019,
"exif:GPSDestDistanceRef" },
1246 { 0x1001a,
"exif:GPSDestDistance" },
1247 { 0x1001b,
"exif:GPSProcessingMethod" },
1248 { 0x1001c,
"exif:GPSAreaInformation" },
1249 { 0x1001d,
"exif:GPSDateStamp" },
1250 { 0x1001e,
"exif:GPSDifferential" },
1251 { 0x1001f,
"exif:GPSHPositioningError" },
1263 directory_stack[MaxDirectoryStack] = { { 0, 0, 0 } };
1287 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1292 profile=GetImageProfile(image,
"exif");
1293 if (profile == (
const StringInfo *) NULL)
1295 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1297 while (isspace((
int) ((
unsigned char) *property)) != 0)
1299 if (strlen(property) <= 5)
1303 switch (*(property+5))
1332 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1343 for (i=(ssize_t) n-1L; i >= 0; i--)
1347 if ((c >=
'0') && (c <=
'9'))
1348 tag|=(size_t) (c-
'0');
1350 if ((c >=
'A') && (c <=
'F'))
1351 tag|=(size_t) (c-(
'A'-10));
1353 if ((c >=
'a') && (c <=
'f'))
1354 tag|=(size_t) (c-(
'a'-10));
1358 }
while (*property !=
'\0');
1368 if (EXIFTag[i].tag == 0)
1370 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1372 tag=(size_t) EXIFTag[i].tag;
1381 length=GetStringInfoLength(profile);
1384 exif=GetStringInfoDatum(profile);
1387 if (ReadPropertyByte(&exif,&length) != 0x45)
1389 if (ReadPropertyByte(&exif,&length) != 0x78)
1391 if (ReadPropertyByte(&exif,&length) != 0x69)
1393 if (ReadPropertyByte(&exif,&length) != 0x66)
1395 if (ReadPropertyByte(&exif,&length) != 0x00)
1397 if (ReadPropertyByte(&exif,&length) != 0x00)
1403 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1412 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1417 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1418 if ((offset < 0) || (
size_t) offset >= length)
1423 directory=exif+offset;
1427 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1428 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1437 directory=directory_stack[level].directory;
1438 entry=directory_stack[level].entry;
1439 tag_offset=directory_stack[level].offset;
1441 if ((directory < exif) || (directory > (exif+length-2)))
1446 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1447 for ( ; entry < number_entries; entry++)
1460 q=(
unsigned char *) (directory+(12*entry)+2);
1461 if (q > (exif+length-12))
1463 if (GetValueFromSplayTree(exif_resources,q) == q)
1465 (void) AddValueToSplayTree(exif_resources,q,q);
1466 tag_value=(size_t) (ReadPropertyUnsignedShort(endian,q)+(ssize_t)
1468 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1469 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1473 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1476 number_bytes=components*(ssize_t) tag_bytes[format];
1477 if (number_bytes < components)
1479 if (number_bytes <= 4)
1489 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1490 if ((dir_offset < 0) || (
size_t) dir_offset >= length)
1492 if (((
size_t) dir_offset+(
size_t) number_bytes) < (
size_t) dir_offset)
1494 if ((
size_t) (dir_offset+(ssize_t) number_bytes) > length)
1496 p=(
unsigned char *) (exif+dir_offset);
1498 if ((all != 0) || (tag == (
size_t) tag_value))
1501 buffer[6*
sizeof(double)+MagickPathExtent],
1504 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1506 value=(
char *) NULL;
1512 value=(
char *) NULL;
1513 if (~((
size_t) number_bytes) >= 1)
1514 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1516 if (value != (
char *) NULL)
1518 for (i=0; i < (ssize_t) number_bytes; i++)
1521 if (isprint((
int) p[i]) != 0)
1522 value[i]=(char) p[i];
1528 case EXIF_FMT_SBYTE:
1530 EXIFMultipleValues(
"%.20g",(
double) (*(
signed char *) p));
1533 case EXIF_FMT_SSHORT:
1535 EXIFMultipleValues(
"%hd",ReadPropertySignedShort(endian,p));
1538 case EXIF_FMT_USHORT:
1540 EXIFMultipleValues(
"%hu",ReadPropertyUnsignedShort(endian,p));
1543 case EXIF_FMT_ULONG:
1545 EXIFMultipleValues(
"%.20g",(
double)
1546 ReadPropertyUnsignedLong(endian,p));
1549 case EXIF_FMT_SLONG:
1551 EXIFMultipleValues(
"%.20g",(
double)
1552 ReadPropertySignedLong(endian,p));
1555 case EXIF_FMT_URATIONAL:
1557 if ((tag_value == GPS_LATITUDE) || (tag_value == GPS_LONGITUDE) ||
1558 (tag_value == GPS_TIMESTAMP))
1561 EXIFGPSFractions(
"%.20g/%.20g,%.20g/%.20g,%.20g/%.20g",
1562 (
double) ReadPropertyUnsignedLong(endian,p),
1563 (
double) ReadPropertyUnsignedLong(endian,p+4),
1564 (
double) ReadPropertyUnsignedLong(endian,p+8),
1565 (
double) ReadPropertyUnsignedLong(endian,p+12),
1566 (
double) ReadPropertyUnsignedLong(endian,p+16),
1567 (
double) ReadPropertyUnsignedLong(endian,p+20));
1570 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1571 ReadPropertyUnsignedLong(endian,p),(
double)
1572 ReadPropertyUnsignedLong(endian,p+4));
1575 case EXIF_FMT_SRATIONAL:
1577 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1578 ReadPropertySignedLong(endian,p),(
double)
1579 ReadPropertySignedLong(endian,p+4));
1582 case EXIF_FMT_SINGLE:
1584 EXIFMultipleValues(
"%.20g",(
double)
1585 ReadPropertySignedLong(endian,p));
1588 case EXIF_FMT_DOUBLE:
1590 EXIFMultipleValues(
"%.20g",(
double)
1591 ReadPropertySignedLong(endian,p));
1594 case EXIF_FMT_STRING:
1595 case EXIF_FMT_UNDEFINED:
1598 if ((p < exif) || (p > (exif+length-number_bytes)))
1600 value=(
char *) NULL;
1601 if (~((
size_t) number_bytes) >= 1)
1602 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1604 if (value != (
char *) NULL)
1606 for (i=0; i < (ssize_t) number_bytes; i++)
1609 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1610 value[i]=(char) p[i];
1617 if (value != (
char *) NULL)
1622 key=AcquireString(property);
1630 description=
"unknown";
1633 if (EXIFTag[i].tag == 0)
1635 if (EXIFTag[i].tag == tag_value)
1637 description=EXIFTag[i].description;
1641 (void) FormatLocaleString(key,MagickPathExtent,
"%s",
1644 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1649 if (tag_value < 0x10000)
1650 (void) FormatLocaleString(key,MagickPathExtent,
"#%04lx",
1651 (
unsigned long) tag_value);
1653 if (tag_value < 0x20000)
1654 (void) FormatLocaleString(key,MagickPathExtent,
"@%04lx",
1655 (
unsigned long) (tag_value & 0xffff));
1657 (
void) FormatLocaleString(key,MagickPathExtent,
"unknown");
1663 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1666 if ((image->properties == (
void *) NULL) ||
1667 (GetValueFromSplayTree((SplayTreeInfo *) image->properties,key) == (
const void *) NULL))
1668 (void) SetImageProperty((Image *) image,key,value,exception);
1669 value=DestroyString(value);
1670 key=DestroyString(key);
1673 if ((tag_value == TAG_EXIF_OFFSET) ||
1674 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1679 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,p);
1680 if (((
size_t) tag_offset1 < length) &&
1681 (level < (MaxDirectoryStack-2)))
1686 tag_offset2=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1688 directory_stack[level].directory=directory;
1690 directory_stack[level].entry=entry;
1691 directory_stack[level].offset=tag_offset;
1696 for (i=0; i < level; i++)
1697 if (directory_stack[i].directory == (exif+tag_offset1))
1701 directory_stack[level].directory=exif+tag_offset1;
1702 directory_stack[level].offset=tag_offset2;
1703 directory_stack[level].entry=0;
1705 if ((directory+2+(12*number_entries)+4) > (exif+length))
1707 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,directory+
1708 2+(12*number_entries));
1709 if ((tag_offset1 != 0) && ((
size_t) tag_offset1 < length) &&
1710 (level < (MaxDirectoryStack-2)))
1712 directory_stack[level].directory=exif+tag_offset1;
1713 directory_stack[level].entry=0;
1714 directory_stack[level].offset=tag_offset2;
1721 }
while (level > 0);
1722 exif_resources=DestroySplayTree(exif_resources);
1725#if defined(MAGICKCORE_LCMS_DELEGATE)
1726static void GetICCProperty(
const Image *image,ExceptionInfo *exception)
1738 profile=GetImageProfile(image,
"icc");
1739 if (profile == (StringInfo *) NULL)
1740 profile=GetImageProfile(image,
"icm");
1741 if (profile == (StringInfo *) NULL)
1743 if (GetStringInfoLength(profile) < 128)
1745 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1746 (cmsUInt32Number) GetStringInfoLength(profile));
1747 if (icc_profile != (cmsHPROFILE *) NULL)
1749#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1753 name=cmsTakeProductName(icc_profile);
1754 if (name != (
const char *) NULL)
1755 (void) SetImageProperty((Image *) image,
"icc:name",name,exception);
1763 info=AcquireStringInfo(0);
1764 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1768 SetStringInfoLength(info,extent+1);
1769 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1770 "US",(
char *) GetStringInfoDatum(info),extent);
1772 (void) SetImageProperty((Image *) image,
"icc:description",
1773 (
char *) GetStringInfoDatum(info),exception);
1775 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1779 SetStringInfoLength(info,extent+1);
1780 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1781 "US",(
char *) GetStringInfoDatum(info),extent);
1783 (void) SetImageProperty((Image *) image,
"icc:manufacturer",
1784 (
char *) GetStringInfoDatum(info),exception);
1786 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1790 SetStringInfoLength(info,extent+1);
1791 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1792 (
char *) GetStringInfoDatum(info),extent);
1794 (void) SetImageProperty((Image *) image,
"icc:model",
1795 (
char *) GetStringInfoDatum(info),exception);
1797 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1801 SetStringInfoLength(info,extent+1);
1802 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1803 "US",(
char *) GetStringInfoDatum(info),extent);
1805 (void) SetImageProperty((Image *) image,
"icc:copyright",
1806 (
char *) GetStringInfoDatum(info),exception);
1808 info=DestroyStringInfo(info);
1810 (void) cmsCloseProfile(icc_profile);
1815static MagickBooleanType SkipXMPValue(
const char *value)
1817 if (value == (
const char*) NULL)
1819 while (*value !=
'\0')
1821 if (isspace((
int) ((
unsigned char) *value)) == 0)
1822 return(MagickFalse);
1828static void GetXMPProperty(
const Image *image,
const char *property)
1852 profile=GetImageProfile(image,
"xmp");
1853 if (profile == (StringInfo *) NULL)
1855 if (GetStringInfoLength(profile) < 17)
1857 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1859 xmp_profile=StringInfoToString(profile);
1860 if (xmp_profile == (
char *) NULL)
1862 for (p=xmp_profile; *p !=
'\0'; p++)
1863 if ((*p ==
'<') && (*(p+1) ==
'x'))
1865 exception=AcquireExceptionInfo();
1866 xmp=NewXMLTree((
char *) p,exception);
1867 xmp_profile=DestroyString(xmp_profile);
1868 exception=DestroyExceptionInfo(exception);
1869 if (xmp == (XMLTreeInfo *) NULL)
1871 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1872 if (rdf != (XMLTreeInfo *) NULL)
1874 if (image->properties == (
void *) NULL)
1875 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1876 RelinquishMagickMemory,RelinquishMagickMemory);
1877 description=GetXMLTreeChild(rdf,
"rdf:Description");
1878 while (description != (XMLTreeInfo *) NULL)
1883 node=GetXMLTreeChild(description,(
const char *) NULL);
1884 while (node != (XMLTreeInfo *) NULL)
1886 child=GetXMLTreeChild(node,(
const char *) NULL);
1887 content=GetXMLTreeContent(node);
1888 if ((child == (XMLTreeInfo *) NULL) &&
1889 (SkipXMPValue(content) == MagickFalse))
1891 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1892 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1893 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1894 xmp_namespace,ConstantString(content));
1896 while (child != (XMLTreeInfo *) NULL)
1898 content=GetXMLTreeContent(child);
1899 if (SkipXMPValue(content) == MagickFalse)
1901 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1902 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1903 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1904 xmp_namespace,ConstantString(content));
1906 child=GetXMLTreeSibling(child);
1908 node=GetXMLTreeSibling(node);
1910 description=GetNextXMLTreeTag(description);
1913 xmp=DestroyXMLTree(xmp);
1916static char *TracePSClippath(
const unsigned char *blob,
size_t length)
1939 path=AcquireString((
char *) NULL);
1940 if (path == (
char *) NULL)
1941 return((
char *) NULL);
1942 message=AcquireString((
char *) NULL);
1943 (void) FormatLocaleString(message,MagickPathExtent,
"/ClipImage\n");
1944 (void) ConcatenateString(&path,message);
1945 (void) FormatLocaleString(message,MagickPathExtent,
"{\n");
1946 (void) ConcatenateString(&path,message);
1947 (void) FormatLocaleString(message,MagickPathExtent,
1948 " /c {curveto} bind def\n");
1949 (void) ConcatenateString(&path,message);
1950 (void) FormatLocaleString(message,MagickPathExtent,
1951 " /l {lineto} bind def\n");
1952 (void) ConcatenateString(&path,message);
1953 (void) FormatLocaleString(message,MagickPathExtent,
1954 " /m {moveto} bind def\n");
1955 (void) ConcatenateString(&path,message);
1956 (void) FormatLocaleString(message,MagickPathExtent,
1957 " /v {currentpoint 6 2 roll curveto} bind def\n");
1958 (void) ConcatenateString(&path,message);
1959 (void) FormatLocaleString(message,MagickPathExtent,
1960 " /y {2 copy curveto} bind def\n");
1961 (void) ConcatenateString(&path,message);
1962 (void) FormatLocaleString(message,MagickPathExtent,
1963 " /z {closepath} bind def\n");
1964 (void) ConcatenateString(&path,message);
1965 (void) FormatLocaleString(message,MagickPathExtent,
" newpath\n");
1966 (void) ConcatenateString(&path,message);
1971 (void) memset(point,0,
sizeof(point));
1972 (void) memset(first,0,
sizeof(first));
1973 (void) memset(last,0,
sizeof(last));
1975 in_subpath=MagickFalse;
1978 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1984 if (knot_count != 0)
1987 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
1993 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1995 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2003 if (knot_count == 0)
2009 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2015 for (i=0; i < 3; i++)
2017 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2018 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2019 point[i].x=(double) x/4096.0/4096.0;
2020 point[i].y=1.0-(double) y/4096.0/4096.0;
2022 if (in_subpath == MagickFalse)
2024 (void) FormatLocaleString(message,MagickPathExtent,
" %g %g m\n",
2025 point[1].x,point[1].y);
2026 for (i=0; i < 3; i++)
2038 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2039 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2040 (void) FormatLocaleString(message,MagickPathExtent,
2041 " %g %g l\n",point[1].x,point[1].y);
2043 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2044 (void) FormatLocaleString(message,MagickPathExtent,
2045 " %g %g %g %g v\n",point[0].x,point[0].y,
2046 point[1].x,point[1].y);
2048 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2049 (void) FormatLocaleString(message,MagickPathExtent,
2050 " %g %g %g %g y\n",last[2].x,last[2].y,
2051 point[1].x,point[1].y);
2053 (
void) FormatLocaleString(message,MagickPathExtent,
2054 " %g %g %g %g %g %g c\n",last[2].x,
2055 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2056 for (i=0; i < 3; i++)
2059 (void) ConcatenateString(&path,message);
2060 in_subpath=MagickTrue;
2065 if (knot_count == 0)
2071 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2072 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2073 (void) FormatLocaleString(message,MagickPathExtent,
2074 " %g %g l z\n",first[1].x,first[1].y);
2076 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2077 (void) FormatLocaleString(message,MagickPathExtent,
2078 " %g %g %g %g v z\n",first[0].x,first[0].y,
2079 first[1].x,first[1].y);
2081 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2082 (void) FormatLocaleString(message,MagickPathExtent,
2083 " %g %g %g %g y z\n",last[2].x,last[2].y,
2084 first[1].x,first[1].y);
2086 (
void) FormatLocaleString(message,MagickPathExtent,
2087 " %g %g %g %g %g %g c z\n",last[2].x,
2088 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2089 (void) ConcatenateString(&path,message);
2090 in_subpath=MagickFalse;
2100 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2108 (void) FormatLocaleString(message,MagickPathExtent,
" eoclip\n");
2109 (void) ConcatenateString(&path,message);
2110 (void) FormatLocaleString(message,MagickPathExtent,
"} bind def");
2111 (void) ConcatenateString(&path,message);
2112 message=DestroyString(message);
2116static inline void TraceBezierCurve(
char *message,PointInfo *last,
2123 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2124 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2125 (void) FormatLocaleString(message,MagickPathExtent,
2126 "L %g %g\n",point[1].x,point[1].y);
2128 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2129 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2132static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2133 const size_t columns,
const size_t rows)
2156 path=AcquireString((
char *) NULL);
2157 if (path == (
char *) NULL)
2158 return((
char *) NULL);
2159 message=AcquireString((
char *) NULL);
2160 (void) FormatLocaleString(message,MagickPathExtent,(
2161 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2162 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2163 " width=\"%.20g\" height=\"%.20g\">\n"
2165 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2166 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(
double) columns,
2168 (void) ConcatenateString(&path,message);
2169 (void) memset(point,0,
sizeof(point));
2170 (void) memset(first,0,
sizeof(first));
2171 (void) memset(last,0,
sizeof(last));
2173 in_subpath=MagickFalse;
2176 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2182 if (knot_count != 0)
2185 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2191 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2193 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2201 if (knot_count == 0)
2207 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2213 for (i=0; i < 3; i++)
2215 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2216 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2217 point[i].x=(double) x*columns/4096.0/4096.0;
2218 point[i].y=(double) y*rows/4096.0/4096.0;
2220 if (in_subpath == MagickFalse)
2222 (void) FormatLocaleString(message,MagickPathExtent,
"M %g %g\n",
2223 point[1].x,point[1].y);
2224 for (i=0; i < 3; i++)
2232 TraceBezierCurve(message,last,point);
2233 for (i=0; i < 3; i++)
2236 (void) ConcatenateString(&path,message);
2237 in_subpath=MagickTrue;
2242 if (knot_count == 0)
2244 TraceBezierCurve(message,last,first);
2245 (void) ConcatenateString(&path,message);
2246 in_subpath=MagickFalse;
2256 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2264 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2265 message=DestroyString(message);
2269MagickExport
const char *GetImageProperty(
const Image *image,
2270 const char *property,ExceptionInfo *exception)
2273 read_from_properties;
2281 assert(image != (Image *) NULL);
2282 assert(image->signature == MagickCoreSignature);
2283 if (IsEventLogging() != MagickFalse)
2284 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2285 if ((property == (
const char *) NULL) || (*property ==
'\0'))
2286 return((
const char *) NULL);
2287 read_from_properties=MagickTrue;
2288 property_length=strlen(property);
2289 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
2290 (*(property+(property_length-1)) ==
'*'))
2291 read_from_properties=MagickFalse;
2292 if (read_from_properties != MagickFalse)
2294 p=(
const char *) NULL;
2295 if (image->properties != (
void *) NULL)
2297 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2298 image->properties,property);
2299 if (p != (
const char *) NULL)
2302 if (strchr(property,
':') == (
char *) NULL)
2309 if (LocaleNCompare(
"8bim:",property,5) == 0)
2311 Get8BIMProperty(image,property,exception);
2319 if (LocaleNCompare(
"exif:",property,5) == 0)
2321 GetEXIFProperty(image,property,exception);
2329 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2330 (LocaleNCompare(
"icm:",property,4) == 0))
2332#if defined(MAGICKCORE_LCMS_DELEGATE)
2333 GetICCProperty(image,exception);
2337 if (LocaleNCompare(
"iptc:",property,5) == 0)
2339 GetIPTCProperty(image,property,exception);
2347 if (LocaleNCompare(
"xmp:",property,4) == 0)
2349 GetXMPProperty(image,property);
2357 if ((image->properties != (
void *) NULL) &&
2358 (read_from_properties != MagickFalse))
2360 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2361 image->properties,property);
2364 return((
const char *) NULL);
2458static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2459 Image *image,
const char letter,ExceptionInfo *exception)
2461#define WarnNoImageReturn(format,arg) \
2462 if (image == (Image *) NULL ) { \
2463 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2464 "NoImageForProperty",format,arg); \
2465 return((const char *) NULL); \
2467#define WarnNoImageInfoReturn(format,arg) \
2468 if (image_info == (ImageInfo *) NULL ) { \
2469 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2470 "NoImageInfoForProperty",format,arg); \
2471 return((const char *) NULL); \
2475 value[MagickPathExtent];
2480 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2481 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2483 if ((image_info != (ImageInfo *) NULL) &&
2484 (IsEventLogging() != MagickFalse))
2485 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2487 string=(
char *) NULL;
2495 WarnNoImageReturn(
"\"%%%c\"",letter);
2496 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
2498 if (image->extent == 0)
2499 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
2500 MagickPathExtent,value);
2505 WarnNoImageReturn(
"\"%%%c\"",letter);
2506 string=GetImageProperty(image,
"comment",exception);
2507 if (
string == (
const char *) NULL )
2513 WarnNoImageReturn(
"\"%%%c\"",letter);
2514 GetPathComponent(image->magick_filename,HeadPath,value);
2521 WarnNoImageReturn(
"\"%%%c\"",letter);
2522 GetPathComponent(image->magick_filename,ExtensionPath,value);
2529 WarnNoImageReturn(
"\"%%%c\"",letter);
2530 GetPathComponent(image->magick_filename,TailPath,value);
2537 WarnNoImageReturn(
"\"%%%c\"",letter);
2538 (void) FormatLocaleString(value,MagickPathExtent,
2539 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(
double)
2540 image->page.height,(
double) image->page.x,(
double) image->page.y);
2545 WarnNoImageReturn(
"\"%%%c\"",letter);
2546 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2547 (image->rows != 0 ? image->rows : image->magick_rows));
2552 WarnNoImageReturn(
"\"%%%c\"",letter);
2553 string=image->filename;
2561 WarnNoImageReturn(
"\"%%%c\"",letter);
2562 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2563 GetNumberColors(image,(FILE *) NULL,exception));
2568 WarnNoImageReturn(
"\"%%%c\"",letter);
2569 string=GetImageProperty(image,
"label",exception);
2570 if (
string == (
const char *) NULL)
2576 WarnNoImageReturn(
"\"%%%c\"",letter);
2577 string=image->magick;
2582 if ( image != (Image *) NULL )
2583 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2584 GetImageListLength(image));
2591 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2592 string=image_info->filename;
2597 WarnNoImageReturn(
"\"%%%c\"",letter);
2598 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2599 GetImageIndexInList(image));
2604 WarnNoImageReturn(
"\"%%%c\"",letter);
2605 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2606 MAGICKCORE_QUANTUM_DEPTH);
2614 WarnNoImageReturn(
"\"%%%c\"",letter);
2615 colorspace=image->colorspace;
2616 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
2617 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2618 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2619 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2626 if (image_info->number_scenes != 0)
2627 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2629 else if (image != (Image *) NULL)
2630 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2635 WarnNoImageReturn(
"\"%%%c\"",letter);
2636 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2643 WarnNoImageReturn(
"\"%%%c\"",letter);
2644 GetPathComponent(image->magick_filename,BasePath,value);
2651 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2652 string=image_info->unique;
2657 WarnNoImageReturn(
"\"%%%c\"",letter);
2658 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2659 (image->columns != 0 ? image->columns : image->magick_columns));
2664 WarnNoImageReturn(
"\"%%%c\"",letter);
2665 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2666 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
2667 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2673 WarnNoImageReturn(
"\"%%%c\"",letter);
2674 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2675 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
2676 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2682 WarnNoImageReturn(
"\"%%%c\"",letter);
2683 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2689 WarnNoImageReturn(
"\"%%%c\"",letter);
2690 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2691 image->alpha_trait);
2696 WarnNoImageReturn(
"\"%%%c\"",letter);
2697 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2699 if (image->extent == 0)
2700 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2701 GetBlobSize(image));
2706 WarnNoImageReturn(
"\"%%%c\"",letter);
2707 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2708 image->compression);
2713 WarnNoImageReturn(
"\"%%%c\"",letter);
2714 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2720 WarnNoImageReturn(
"\"%%%c\"",letter);
2721 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2722 image->magick_columns,(
double) image->magick_rows);
2727 WarnNoImageReturn(
"\"%%%c\"",letter);
2728 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2729 image->page.height);
2734 WarnNoImageReturn(
"\"%%%c\"",letter);
2735 string=image->magick_filename;
2740 if ((image != (Image *) NULL) && (image->next == (Image *) NULL))
2741 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2742 GetImageListLength(image));
2749 WarnNoImageReturn(
"\"%%%c\"",letter);
2750 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
2751 image->page.x,(
long) image->page.y);
2756 WarnNoImageReturn(
"\"%%%c\"",letter);
2757 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2758 image->page.width,(
double) image->page.height);
2763 WarnNoImageReturn(
"\"%%%c\"",letter);
2764 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2765 (image->quality == 0 ? 92 : image->quality));
2770 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2772 if (image_info->number_scenes == 0)
2773 string=
"2147483647";
2774 else if ( image != (Image *) NULL )
2775 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2776 image_info->scene+image_info->number_scenes);
2780 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2781 (image_info->number_scenes == 0 ? 2147483647 :
2782 image_info->number_scenes));
2788 WarnNoImageReturn(
"\"%%%c\"",letter);
2789 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2795 WarnNoImageReturn(
"\"%%%c\"",letter);
2796 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2802 WarnNoImageReturn(
"\"%%%c\"",letter);
2803 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2809 WarnNoImageReturn(
"\"%%%c\"",letter);
2810 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2816 WarnNoImageReturn(
"\"%%%c\"",letter);
2817 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2831 WarnNoImageReturn(
"\"%%%c\"",letter);
2832 page=GetImageBoundingBox(image,exception);
2833 (void) FormatLocaleString(value,MagickPathExtent,
2834 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(
double) page.height,
2835 (
double) page.x,(
double)page.y);
2843 WarnNoImageReturn(
"\"%%%c\"",letter);
2844 if ((image->columns != 0) && (image->rows != 0))
2845 (void) SignatureImage(image,exception);
2846 string=GetImageProperty(image,
"signature",exception);
2850 if (
string != (
char *) NULL)
2857 if (image != (Image *) NULL)
2859 (void) SetImageArtifact(image,
"magick-property",value);
2860 return(GetImageArtifact(image,
"magick-property"));
2864 (void) SetImageOption(image_info,
"magick-property",value);
2865 return(GetImageOption(image_info,
"magick-property"));
2868 return((
char *) NULL);
2871MagickExport
const char *GetMagickProperty(ImageInfo *image_info,
2872 Image *image,
const char *property,ExceptionInfo *exception)
2875 value[MagickPathExtent];
2880 assert(property != (
const char *) NULL);
2881 assert(property[0] !=
'\0');
2882 assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2883 if (property[1] ==
'\0')
2884 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2885 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2886 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2888 if ((image_info != (ImageInfo *) NULL) &&
2889 (IsEventLogging() != MagickFalse))
2890 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2892 string=(
char *) NULL;
2897 if (LocaleCompare(
"basename",property) == 0)
2899 WarnNoImageReturn(
"\"%%[%s]\"",property);
2900 GetPathComponent(image->magick_filename,BasePath,value);
2905 if (LocaleCompare(
"bit-depth",property) == 0)
2907 WarnNoImageReturn(
"\"%%[%s]\"",property);
2908 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2909 GetImageDepth(image,exception));
2912 if (LocaleCompare(
"bounding-box",property) == 0)
2917 WarnNoImageReturn(
"\"%%[%s]\"",property);
2918 geometry=GetImageBoundingBox(image,exception);
2919 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g",
2920 (
double) geometry.x,(
double) geometry.y,
2921 (
double) geometry.x+geometry.width,
2922 (
double) geometry.y+geometry.height);
2929 if (LocaleCompare(
"channels",property) == 0)
2931 WarnNoImageReturn(
"\"%%[%s]\"",property);
2932 (void) FormatLocaleString(value,MagickPathExtent,
"%s%s %g.%g",
2933 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2934 image->colorspace),image->alpha_trait != UndefinedPixelTrait ?
2935 "a" :
" ",(
double) image->number_channels,(
double)
2936 image->number_meta_channels);
2940 if (LocaleCompare(
"colors",property) == 0)
2942 WarnNoImageReturn(
"\"%%[%s]\"",property);
2943 image->colors=GetNumberColors(image,(FILE *) NULL,exception);
2944 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2948 if (LocaleCompare(
"colorspace",property) == 0)
2950 WarnNoImageReturn(
"\"%%[%s]\"",property);
2951 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2955 if (LocaleCompare(
"compose",property) == 0)
2957 WarnNoImageReturn(
"\"%%[%s]\"",property);
2958 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2962 if (LocaleCompare(
"compression",property) == 0)
2964 WarnNoImageReturn(
"\"%%[%s]\"",property);
2965 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2966 image->compression);
2969 if (LocaleCompare(
"convex-hull",property) == 0)
2983 WarnNoImageReturn(
"\"%%[%s]\"",property);
2984 convex_hull=GetImageConvexHull(image,&number_points,exception);
2985 if (convex_hull == (PointInfo *) NULL)
2987 points=AcquireString(
"");
2988 for (n=0; n < (ssize_t) number_points; n++)
2990 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
2991 convex_hull[n].x,convex_hull[n].y);
2992 (void) ConcatenateString(&points,value);
2994 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
2995 (void) SetImageProperty(image,
"convex-hull",points,exception);
2996 points=DestroyString(points);
2997 string=GetImageProperty(image,
"convex-hull",exception);
3000 if (LocaleCompare(
"convex-hull:extreme-points",property) == 0)
3015 WarnNoImageReturn(
"\"%%[%s]\"",property);
3016 convex_hull=GetImageConvexHull(image,&number_points,exception);
3017 if (convex_hull == (PointInfo *) NULL)
3019 points=AcquireString(
"");
3020 extreme=convex_hull[0];
3021 for (n=0; n < (ssize_t) number_points; n++)
3023 if (convex_hull[n].y < extreme.y)
3025 extreme=convex_hull[n];
3028 if (convex_hull[n].y != extreme.y)
3030 if (convex_hull[n].x < extreme.x)
3031 extreme=convex_hull[n];
3033 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3034 extreme.x,extreme.y);
3035 (void) ConcatenateString(&points,value);
3036 extreme=convex_hull[0];
3037 for (n=0; n < (ssize_t) number_points; n++)
3039 if (convex_hull[n].x > extreme.x)
3041 extreme=convex_hull[n];
3044 if (convex_hull[n].x != extreme.x)
3046 if (convex_hull[n].y < extreme.y)
3047 extreme=convex_hull[n];
3049 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3050 extreme.x,extreme.y);
3051 (void) ConcatenateString(&points,value);
3052 extreme=convex_hull[0];
3053 for (n=0; n < (ssize_t) number_points; n++)
3055 if (convex_hull[n].y > extreme.y)
3057 extreme=convex_hull[n];
3060 if (convex_hull[n].y != extreme.y)
3062 if (convex_hull[n].x > extreme.x)
3063 extreme=convex_hull[n];
3065 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3066 extreme.x,extreme.y);
3067 (void) ConcatenateString(&points,value);
3068 extreme=convex_hull[0];
3069 for (n=0; n < (ssize_t) number_points; n++)
3071 if (convex_hull[n].x < extreme.x)
3073 extreme=convex_hull[n];
3076 if (convex_hull[n].x != extreme.x)
3078 if (convex_hull[n].y > extreme.y)
3079 extreme=convex_hull[n];
3081 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3082 extreme.x,extreme.y);
3083 (void) ConcatenateString(&points,value);
3084 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
3085 (void) SetImageProperty(image,
"convex-hull:extreme-points",points,
3087 points=DestroyString(points);
3088 string=GetImageProperty(image,
"convex-hull:extreme-points",exception);
3091 if (LocaleCompare(
"copyright",property) == 0)
3093 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
3100 if (LocaleCompare(
"depth",property) == 0)
3102 WarnNoImageReturn(
"\"%%[%s]\"",property);
3103 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3107 if (LocaleCompare(
"directory",property) == 0)
3109 WarnNoImageReturn(
"\"%%[%s]\"",property);
3110 GetPathComponent(image->magick_filename,HeadPath,value);
3119 if (LocaleCompare(
"entropy",property) == 0)
3124 WarnNoImageReturn(
"\"%%[%s]\"",property);
3125 (void) GetImageEntropy(image,&entropy,exception);
3126 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3127 GetMagickPrecision(),entropy);
3130 if (LocaleCompare(
"extension",property) == 0)
3132 WarnNoImageReturn(
"\"%%[%s]\"",property);
3133 GetPathComponent(image->magick_filename,ExtensionPath,value);
3142 if (LocaleCompare(
"gamma",property) == 0)
3144 WarnNoImageReturn(
"\"%%[%s]\"",property);
3145 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3146 GetMagickPrecision(),image->gamma);
3153 if (LocaleCompare(
"height",property) == 0)
3155 WarnNoImageReturn(
"\"%%[%s]\"",property);
3156 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
3157 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3164 if (LocaleCompare(
"input",property) == 0)
3166 WarnNoImageReturn(
"\"%%[%s]\"",property);
3167 string=image->filename;
3170 if (LocaleCompare(
"interlace",property) == 0)
3172 WarnNoImageReturn(
"\"%%[%s]\"",property);
3173 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3181 if (LocaleCompare(
"kurtosis",property) == 0)
3187 WarnNoImageReturn(
"\"%%[%s]\"",property);
3188 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3189 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3190 GetMagickPrecision(),kurtosis);
3197 if (LocaleCompare(
"magick",property) == 0)
3199 WarnNoImageReturn(
"\"%%[%s]\"",property);
3200 string=image->magick;
3203 if ((LocaleCompare(
"maxima",property) == 0) ||
3204 (LocaleCompare(
"max",property) == 0))
3210 WarnNoImageReturn(
"\"%%[%s]\"",property);
3211 (void) GetImageRange(image,&minimum,&maximum,exception);
3212 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3213 GetMagickPrecision(),maximum);
3216 if (LocaleCompare(
"mean",property) == 0)
3222 WarnNoImageReturn(
"\"%%[%s]\"",property);
3223 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3224 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3225 GetMagickPrecision(),mean);
3228 if (LocaleCompare(
"median",property) == 0)
3233 WarnNoImageReturn(
"\"%%[%s]\"",property);
3234 (void) GetImageMedian(image,&median,exception);
3235 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3236 GetMagickPrecision(),median);
3239 if (LocaleCompare(
"mime:type",property) == 0)
3244 magick_info=GetMagickInfo(image->magick,exception);
3245 if ((magick_info != (
const MagickInfo *) NULL) &&
3246 (GetMagickMimeType(magick_info) != (
const char *) NULL))
3247 (void) CopyMagickString(value,GetMagickMimeType(magick_info),
3251 if ((LocaleCompare(
"minima",property) == 0) ||
3252 (LocaleCompare(
"min",property) == 0))
3258 WarnNoImageReturn(
"\"%%[%s]\"",property);
3259 (void) GetImageRange(image,&minimum,&maximum,exception);
3260 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3261 GetMagickPrecision(),minimum);
3264 if (LocaleNCompare(
"minimum-bounding-box",property,20) == 0)
3278 WarnNoImageReturn(
"\"%%[%s]\"",property);
3279 bounding_box=GetImageMinimumBoundingBox(image,&number_points,
3281 if (bounding_box == (PointInfo *) NULL)
3283 points=AcquireString(
"");
3284 for (n=0; n < (ssize_t) number_points; n++)
3286 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3287 bounding_box[n].x,bounding_box[n].y);
3288 (void) ConcatenateString(&points,value);
3290 bounding_box=(PointInfo *) RelinquishMagickMemory(bounding_box);
3291 (void) SetImageProperty(image,
"minimum-bounding-box",points,
3293 points=DestroyString(points);
3294 string=GetImageProperty(image,property,exception);
3301 if (LocaleCompare(
"opaque",property) == 0)
3303 WarnNoImageReturn(
"\"%%[%s]\"",property);
3304 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
3305 IsImageOpaque(image,exception));
3308 if (LocaleCompare(
"orientation",property) == 0)
3310 WarnNoImageReturn(
"\"%%[%s]\"",property);
3311 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3312 image->orientation);
3315 if (LocaleCompare(
"output",property) == 0)
3317 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3318 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
3325 if (LocaleCompare(
"page",property) == 0)
3327 WarnNoImageReturn(
"\"%%[%s]\"",property);
3328 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3329 (
double) image->page.width,(
double) image->page.height);
3332 if (LocaleNCompare(
"papersize:",property,10) == 0)
3337 WarnNoImageReturn(
"\"%%[%s]\"",property);
3339 papersize=GetPageGeometry(property+10);
3340 if (papersize != (
const char *) NULL)
3343 page = { 0, 0, 0, 0 };
3345 (void) ParseAbsoluteGeometry(papersize,&page);
3346 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3347 (
double) page.width,(
double) page.height);
3348 papersize=DestroyString(papersize);
3352#if defined(MAGICKCORE_LCMS_DELEGATE)
3353 if (LocaleCompare(
"profile:icc",property) == 0 ||
3354 LocaleCompare(
"profile:icm",property) == 0)
3356#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3357#define cmsUInt32Number DWORD
3366 WarnNoImageReturn(
"\"%%[%s]\"",property);
3367 profile=GetImageProfile(image,property+8);
3368 if (profile == (StringInfo *) NULL)
3370 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3371 (cmsUInt32Number) GetStringInfoLength(profile));
3372 if (icc_profile != (cmsHPROFILE *) NULL)
3374#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3375 string=cmsTakeProductName(icc_profile);
3377 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3378 "en",
"US",value,MagickPathExtent);
3380 (void) cmsCloseProfile(icc_profile);
3384 if (LocaleCompare(
"printsize.x",property) == 0)
3386 WarnNoImageReturn(
"\"%%[%s]\"",property);
3387 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3388 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3389 image->resolution.x)*image->columns);
3392 if (LocaleCompare(
"printsize.y",property) == 0)
3394 WarnNoImageReturn(
"\"%%[%s]\"",property);
3395 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3396 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3397 image->resolution.y)*image->rows);
3400 if (LocaleCompare(
"profiles",property) == 0)
3405 WarnNoImageReturn(
"\"%%[%s]\"",property);
3406 ResetImageProfileIterator(image);
3407 name=GetNextImageProfile(image);
3408 if (name != (
char *) NULL)
3410 (void) CopyMagickString(value,name,MagickPathExtent);
3411 name=GetNextImageProfile(image);
3412 while (name != (
char *) NULL)
3414 ConcatenateMagickString(value,
",",MagickPathExtent);
3415 ConcatenateMagickString(value,name,MagickPathExtent);
3416 name=GetNextImageProfile(image);
3425 if (LocaleCompare(
"quality",property) == 0)
3427 WarnNoImageReturn(
"\"%%[%s]\"",property);
3428 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3436 if (LocaleCompare(
"resolution.x",property) == 0)
3438 WarnNoImageReturn(
"\"%%[%s]\"",property);
3439 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3440 image->resolution.x);
3443 if (LocaleCompare(
"resolution.y",property) == 0)
3445 WarnNoImageReturn(
"\"%%[%s]\"",property);
3446 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3447 image->resolution.y);
3454 if (LocaleCompare(
"scene",property) == 0)
3456 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3457 if (image_info->number_scenes != 0)
3458 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3461 WarnNoImageReturn(
"\"%%[%s]\"",property);
3462 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3467 if (LocaleCompare(
"scenes",property) == 0)
3470 WarnNoImageReturn(
"\"%%[%s]\"",property);
3471 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3472 GetImageListLength(image));
3475 if (LocaleCompare(
"size",property) == 0)
3477 WarnNoImageReturn(
"\"%%[%s]\"",property);
3478 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
3479 MagickPathExtent,value);
3482 if (LocaleCompare(
"skewness",property) == 0)
3488 WarnNoImageReturn(
"\"%%[%s]\"",property);
3489 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3490 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3491 GetMagickPrecision(),skewness);
3494 if (LocaleCompare(
"standard-deviation",property) == 0)
3500 WarnNoImageReturn(
"\"%%[%s]\"",property);
3501 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3502 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3503 GetMagickPrecision(),standard_deviation);
3510 if (LocaleCompare(
"type",property) == 0)
3512 WarnNoImageReturn(
"\"%%[%s]\"",property);
3513 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3514 IdentifyImageType(image,exception));
3521 if (LocaleCompare(
"unique",property) == 0)
3523 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3524 string=image_info->unique;
3527 if (LocaleCompare(
"units",property) == 0)
3529 WarnNoImageReturn(
"\"%%[%s]\"",property);
3530 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3538 if (LocaleCompare(
"version",property) == 0)
3540 string=GetMagickVersion((
size_t *) NULL);
3547 if (LocaleCompare(
"width",property) == 0)
3549 WarnNoImageReturn(
"\"%%[%s]\"",property);
3550 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3551 (image->magick_columns != 0 ? image->magick_columns : 256));
3557 if (
string != (
char *) NULL)
3564 if (image != (Image *) NULL)
3566 (void) SetImageArtifact(image,
"magick-property",value);
3567 return(GetImageArtifact(image,
"magick-property"));
3571 (void) SetImageOption(image_info,
"magick-property",value);
3572 return(GetImageOption(image_info,
"magick-property"));
3575 return((
char *) NULL);
3577#undef WarnNoImageReturn
3601MagickExport
const char *GetNextImageProperty(
const Image *image)
3603 assert(image != (Image *) NULL);
3604 assert(image->signature == MagickCoreSignature);
3605 if (IsEventLogging() != MagickFalse)
3606 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3608 if (image->properties == (
void *) NULL)
3609 return((
const char *) NULL);
3610 return((
const char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3667MagickExport
char *InterpretImageProperties(ImageInfo *image_info,Image *image,
3668 const char *embed_text,ExceptionInfo *exception)
3670#define ExtendInterpretText(string_length) \
3672 size_t length=(string_length); \
3673 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3676 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3677 MagickPathExtent,sizeof(*interpret_text)); \
3678 if (interpret_text == (char *) NULL) \
3680 if (property_image != image) \
3681 property_image=DestroyImage(property_image); \
3682 if (property_info != image_info) \
3683 property_info=DestroyImageInfo(property_info); \
3684 return((char *) NULL); \
3686 q=interpret_text+strlen(interpret_text); \
3690#define AppendKeyValue2Text(key,value)\
3692 size_t length=strlen(key)+strlen(value)+2; \
3693 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3696 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3697 MagickPathExtent,sizeof(*interpret_text)); \
3698 if (interpret_text == (char *) NULL) \
3700 if (property_image != image) \
3701 property_image=DestroyImage(property_image); \
3702 if (property_info != image_info) \
3703 property_info=DestroyImageInfo(property_info); \
3704 return((char *) NULL); \
3706 q=interpret_text+strlen(interpret_text); \
3708 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3711#define AppendString2Text(string) \
3713 size_t length = strlen((string)); \
3714 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3717 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3718 MagickPathExtent,sizeof(*interpret_text)); \
3719 if (interpret_text == (char *) NULL) \
3721 if (property_image != image) \
3722 property_image=DestroyImage(property_image); \
3723 if (property_info != image_info) \
3724 property_info=DestroyImageInfo(property_info); \
3725 return((char *) NULL); \
3727 q=interpret_text+strlen(interpret_text); \
3729 (void) CopyMagickString(q,(string),extent); \
3730 q+=(ptrdiff_t) length; \
3752 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
3753 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3755 if ((image_info != (ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
3756 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3757 image_info->filename);
3759 if (IsEventLogging() != MagickFalse)
3760 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no image");
3761 if (embed_text == (
const char *) NULL)
3762 return(ConstantString(
""));
3764 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3767 return(ConstantString(
""));
3768 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3773 interpret_text=FileToString(p,~0UL,exception);
3774 if (interpret_text != (
char *) NULL)
3775 return(interpret_text);
3780 if (image_info != (ImageInfo *) NULL)
3781 property_info=image_info;
3783 property_info=CloneImageInfo(image_info);
3784 if ((image != (Image *) NULL) && (image->columns != 0) && (image->rows != 0))
3785 property_image=image;
3788 property_image=AcquireImage(image_info,exception);
3789 (void) SetImageExtent(property_image,1,1,exception);
3790 (void) SetImageBackgroundColor(property_image,exception);
3792 interpret_text=AcquireString(embed_text);
3793 extent=MagickPathExtent;
3795 for (q=interpret_text; *p!=
'\0'; number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
3801 ExtendInterpretText(MagickPathExtent);
3844 if (LocaleNCompare(
"<",p,4) == 0)
3850 if (LocaleNCompare(
">",p,4) == 0)
3856 if (LocaleNCompare(
"&",p,5) == 0)
3877 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3892 if (number != MagickFalse)
3901 string=GetMagickPropertyLetter(property_info,image,*p,exception);
3902 if (
string != (
char *) NULL)
3904 AppendString2Text(
string);
3905 (void) DeleteImageArtifact(property_image,
"magick-property");
3906 (void) DeleteImageOption(property_info,
"magick-property");
3909 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3910 "UnknownImageProperty",
"\"%%%c\"",*p);
3915 pattern[2*MagickPathExtent] =
"\0";
3934 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3935 "UnknownImageProperty",
"\"%%[]\"");
3938 for (len=0; len < (MagickPathExtent-1L) && (*p !=
'\0'); )
3940 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3945 pattern[len++]=(*p++);
3946 pattern[len++]=(*p++);
3955 pattern[len++]=(*p++);
3970 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3971 "UnbalancedBraces",
"\"%%[%s\"",pattern);
3972 interpret_text=DestroyString(interpret_text);
3973 if (property_image != image)
3974 property_image=DestroyImage(property_image);
3975 if (property_info != image_info)
3976 property_info=DestroyImageInfo(property_info);
3977 return((
char *) NULL);
3982 if (LocaleNCompare(
"fx:",pattern,3) == 0)
3996 fx_info=AcquireFxInfo(property_image,pattern+3,exception);
3997 if (fx_info == (FxInfo *) NULL)
3999 status=FxEvaluateChannelExpression(fx_info,CompositePixelChannel,0,0,
4001 fx_info=DestroyFxInfo(fx_info);
4002 if (status != MagickFalse)
4005 result[MagickPathExtent];
4007 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
4008 GetMagickPrecision(),(
double) value);
4009 AppendString2Text(result);
4013 if (LocaleNCompare(
"hex:",pattern,4) == 0)
4030 GetPixelInfo(property_image,&pixel);
4031 fx_info=AcquireFxInfo(property_image,pattern+4,exception);
4032 if (fx_info == (FxInfo *) NULL)
4034 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4036 pixel.red=(double) QuantumRange*value;
4037 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4038 GreenPixelChannel,0,0,&value,exception);
4039 pixel.green=(double) QuantumRange*value;
4040 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4041 BluePixelChannel,0,0,&value,exception);
4042 pixel.blue=(double) QuantumRange*value;
4043 if (property_image->colorspace == CMYKColorspace)
4045 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4046 BlackPixelChannel,0,0,&value,exception);
4047 pixel.black=(double) QuantumRange*value;
4049 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4050 AlphaPixelChannel,0,0,&value,exception);
4051 pixel.alpha=(double) QuantumRange*value;
4052 fx_info=DestroyFxInfo(fx_info);
4053 if (status != MagickFalse)
4056 hex[MagickPathExtent];
4058 GetColorTuple(&pixel,MagickTrue,hex);
4059 AppendString2Text(hex+1);
4063 if (LocaleNCompare(
"pixel:",pattern,6) == 0)
4080 GetPixelInfo(property_image,&pixel);
4081 fx_info=AcquireFxInfo(property_image,pattern+6,exception);
4082 if (fx_info == (FxInfo *) NULL)
4084 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4086 pixel.red=(double) QuantumRange*value;
4087 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4088 GreenPixelChannel,0,0,&value,exception);
4089 pixel.green=(double) QuantumRange*value;
4090 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4091 BluePixelChannel,0,0,&value,exception);
4092 pixel.blue=(double) QuantumRange*value;
4093 if (property_image->colorspace == CMYKColorspace)
4095 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4096 BlackPixelChannel,0,0,&value,exception);
4097 pixel.black=(double) QuantumRange*value;
4099 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4100 AlphaPixelChannel,0,0,&value,exception);
4101 pixel.alpha=(double) QuantumRange*value;
4102 fx_info=DestroyFxInfo(fx_info);
4103 if (status != MagickFalse)
4106 name[MagickPathExtent];
4108 GetColorTuple(&pixel,MagickFalse,name);
4109 string=GetImageArtifact(property_image,
"pixel:compliance");
4110 if (
string != (
char *) NULL)
4112 ComplianceType compliance=(ComplianceType) ParseCommandOption(
4113 MagickComplianceOptions,MagickFalse,
string);
4114 (void) QueryColorname(property_image,&pixel,compliance,name,
4117 AppendString2Text(name);
4121 if (LocaleNCompare(
"option:",pattern,7) == 0)
4126 if (IsGlob(pattern+7) != MagickFalse)
4128 ResetImageOptionIterator(property_info);
4129 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4130 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4132 string=GetImageOption(property_info,key);
4133 if (
string != (
const char *) NULL)
4134 AppendKeyValue2Text(key,
string);
4139 string=GetImageOption(property_info,pattern+7);
4140 if (
string == (
char *) NULL)
4141 goto PropertyLookupFailure;
4142 AppendString2Text(
string);
4145 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4150 if (IsGlob(pattern+9) != MagickFalse)
4152 ResetImageArtifactIterator(property_image);
4153 while ((key=GetNextImageArtifact(property_image)) != (
const char *) NULL)
4154 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4156 string=GetImageArtifact(property_image,key);
4157 if (
string != (
const char *) NULL)
4158 AppendKeyValue2Text(key,
string);
4163 string=GetImageArtifact(property_image,pattern+9);
4164 if (
string == (
char *) NULL)
4165 goto PropertyLookupFailure;
4166 AppendString2Text(
string);
4169 if (LocaleNCompare(
"property:",pattern,9) == 0)
4174 if (IsGlob(pattern+9) != MagickFalse)
4176 ResetImagePropertyIterator(property_image);
4177 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4178 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4180 string=GetImageProperty(property_image,key,exception);
4181 if (
string != (
const char *) NULL)
4182 AppendKeyValue2Text(key,
string);
4187 string=GetImageProperty(property_image,pattern+9,exception);
4188 if (
string == (
char *) NULL)
4189 goto PropertyLookupFailure;
4190 AppendString2Text(
string);
4198 string=GetImageProperty(property_image,pattern,exception);
4199 if (
string != (
const char *) NULL)
4201 AppendString2Text(
string);
4202 (void) DeleteImageArtifact(property_image,
"magick-property");
4203 (void) DeleteImageOption(property_info,
"magick-property");
4206 if (IsGlob(pattern) != MagickFalse)
4212 ResetImagePropertyIterator(property_image);
4213 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4214 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4216 string=GetImageProperty(property_image,key,exception);
4217 if (
string != (
const char *) NULL)
4218 AppendKeyValue2Text(key,
string);
4228 string=GetMagickProperty(property_info,property_image,pattern,exception);
4229 if (
string != (
const char *) NULL)
4231 AppendString2Text(
string);
4238 string=GetImageArtifact(property_image,pattern);
4239 if (
string != (
char *) NULL)
4241 AppendString2Text(
string);
4247 string=GetImageOption(property_info,pattern);
4248 if (
string != (
char *) NULL)
4250 AppendString2Text(
string);
4253PropertyLookupFailure:
4264 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4265 "UnknownImageProperty",
"\"%%[%s]\"",pattern);
4269 if (property_image != image)
4270 property_image=DestroyImage(property_image);
4271 if (property_info != image_info)
4272 property_info=DestroyImageInfo(property_info);
4273 return(interpret_text);
4304MagickExport
char *RemoveImageProperty(Image *image,
const char *property)
4309 assert(image != (Image *) NULL);
4310 assert(image->signature == MagickCoreSignature);
4311 if (IsEventLogging() != MagickFalse)
4312 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4313 if (image->properties == (
void *) NULL)
4314 return((
char *) NULL);
4315 value=(
char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
4344MagickExport
void ResetImagePropertyIterator(
const Image *image)
4346 assert(image != (Image *) NULL);
4347 assert(image->signature == MagickCoreSignature);
4348 if (IsEventLogging() != MagickFalse)
4349 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4350 if (image->properties == (
void *) NULL)
4352 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
4388MagickExport MagickBooleanType SetImageProperty(Image *image,
4389 const char *property,
const char *value,ExceptionInfo *exception)
4400 assert(image != (Image *) NULL);
4401 assert(image->signature == MagickCoreSignature);
4402 if (IsEventLogging() != MagickFalse)
4403 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4404 if (image->properties == (
void *) NULL)
4405 image->properties=NewSplayTree(CompareSplayTreeString,
4406 RelinquishMagickMemory,RelinquishMagickMemory);
4407 if (value == (
const char *) NULL)
4408 return(DeleteImageProperty(image,property));
4409 if (strlen(property) <= 1)
4414 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4415 "SetReadOnlyProperty",
"`%s'",property);
4416 return(MagickFalse);
4418 property_length=strlen(property);
4419 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4420 (*(property+(property_length-1)) ==
'*'))
4422 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4423 "SetReadOnlyProperty",
"`%s'",property);
4424 return(MagickFalse);
4438 if (LocaleNCompare(
"8bim:",property,5) == 0)
4440 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4441 "SetReadOnlyProperty",
"`%s'",property);
4442 return(MagickFalse);
4450 if (LocaleCompare(
"background",property) == 0)
4452 (void) QueryColorCompliance(value,AllCompliance,
4453 &image->background_color,exception);
4462 if (LocaleCompare(
"channels",property) == 0)
4464 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4465 "SetReadOnlyProperty",
"`%s'",property);
4466 return(MagickFalse);
4468 if (LocaleCompare(
"colorspace",property) == 0)
4473 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4476 return(MagickFalse);
4477 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4479 if (LocaleCompare(
"compose",property) == 0)
4484 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4486 return(MagickFalse);
4487 image->compose=(CompositeOperator) compose;
4490 if (LocaleCompare(
"compress",property) == 0)
4495 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4497 if (compression < 0)
4498 return(MagickFalse);
4499 image->compression=(CompressionType) compression;
4507 if (LocaleCompare(
"delay",property) == 0)
4512 flags=ParseGeometry(value,&geometry_info);
4513 if ((flags & GreaterValue) != 0)
4515 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4516 image->delay=(size_t) floor(geometry_info.rho+0.5);
4519 if ((flags & LessValue) != 0)
4521 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4522 image->delay=(size_t) CastDoubleToSsizeT(floor(
4523 geometry_info.sigma+0.5));
4526 image->delay=(size_t) floor(geometry_info.rho+0.5);
4527 if ((flags & SigmaValue) != 0)
4528 image->ticks_per_second=CastDoubleToSsizeT(floor(
4529 geometry_info.sigma+0.5));
4532 if (LocaleCompare(
"delay_units",property) == 0)
4534 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4535 "SetReadOnlyProperty",
"`%s'",property);
4536 return(MagickFalse);
4538 if (LocaleCompare(
"density",property) == 0)
4543 flags=ParseGeometry(value,&geometry_info);
4544 if ((flags & RhoValue) != 0)
4545 image->resolution.x=geometry_info.rho;
4546 image->resolution.y=image->resolution.x;
4547 if ((flags & SigmaValue) != 0)
4548 image->resolution.y=geometry_info.sigma;
4551 if (LocaleCompare(
"depth",property) == 0)
4553 image->depth=StringToUnsignedLong(value);
4556 if (LocaleCompare(
"dispose",property) == 0)
4561 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4563 return(MagickFalse);
4564 image->dispose=(DisposeType) dispose;
4574 if (LocaleNCompare(
"exif:",property,5) == 0)
4576 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4577 "SetReadOnlyProperty",
"`%s'",property);
4578 return(MagickFalse);
4585 if (LocaleNCompare(
"fx:",property,3) == 0)
4587 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4588 "SetReadOnlyProperty",
"`%s'",property);
4589 return(MagickFalse);
4597 if (LocaleCompare(
"gamma",property) == 0)
4599 image->gamma=StringToDouble(value,(
char **) NULL);
4602 if (LocaleCompare(
"gravity",property) == 0)
4607 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4609 return(MagickFalse);
4610 image->gravity=(GravityType) gravity;
4618 if (LocaleCompare(
"height",property) == 0)
4620 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4621 "SetReadOnlyProperty",
"`%s'",property);
4622 return(MagickFalse);
4629 if (LocaleCompare(
"intensity",property) == 0)
4634 intensity=ParseCommandOption(MagickIntensityOptions,MagickFalse,
4637 return(MagickFalse);
4638 image->intensity=(PixelIntensityMethod) intensity;
4641 if (LocaleCompare(
"intent",property) == 0)
4646 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4648 if (rendering_intent < 0)
4649 return(MagickFalse);
4650 image->rendering_intent=(RenderingIntent) rendering_intent;
4653 if (LocaleCompare(
"interpolate",property) == 0)
4658 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4660 if (interpolate < 0)
4661 return(MagickFalse);
4662 image->interpolate=(PixelInterpolateMethod) interpolate;
4667 if (LocaleNCompare(
"iptc:",property,5) == 0)
4669 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4670 "SetReadOnlyProperty",
"`%s'",property);
4671 return(MagickFalse);
4678 if (LocaleCompare(
"kurtosis",property) == 0)
4680 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4681 "SetReadOnlyProperty",
"`%s'",property);
4682 return(MagickFalse);
4688 if (LocaleCompare(
"loop",property) == 0)
4690 image->iterations=StringToUnsignedLong(value);
4697 if ((LocaleCompare(
"magick",property) == 0) ||
4698 (LocaleCompare(
"max",property) == 0) ||
4699 (LocaleCompare(
"mean",property) == 0) ||
4700 (LocaleCompare(
"min",property) == 0) ||
4701 (LocaleCompare(
"min",property) == 0))
4703 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4704 "SetReadOnlyProperty",
"`%s'",property);
4705 return(MagickFalse);
4710 if (LocaleCompare(
"opaque",property) == 0)
4712 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4713 "SetReadOnlyProperty",
"`%s'",property);
4714 return(MagickFalse);
4720 if (LocaleCompare(
"page",property) == 0)
4725 geometry=GetPageGeometry(value);
4726 flags=ParseAbsoluteGeometry(geometry,&image->page);
4727 geometry=DestroyString(geometry);
4732 if (LocaleNCompare(
"pixel:",property,6) == 0)
4734 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4735 "SetReadOnlyProperty",
"`%s'",property);
4736 return(MagickFalse);
4744 if (LocaleCompare(
"rendering-intent",property) == 0)
4749 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4751 if (rendering_intent < 0)
4752 return(MagickFalse);
4753 image->rendering_intent=(RenderingIntent) rendering_intent;
4760 if ((LocaleCompare(
"size",property) == 0) ||
4761 (LocaleCompare(
"skewness",property) == 0) ||
4762 (LocaleCompare(
"scenes",property) == 0) ||
4763 (LocaleCompare(
"standard-deviation",property) == 0))
4765 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4766 "SetReadOnlyProperty",
"`%s'",property);
4767 return(MagickFalse);
4773 if (LocaleCompare(
"tile-offset",property) == 0)
4778 geometry=GetPageGeometry(value);
4779 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4780 geometry=DestroyString(geometry);
4783 if (LocaleCompare(
"type",property) == 0)
4788 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4790 return(MagickFalse);
4791 image->type=(ImageType) type;
4799 if (LocaleCompare(
"units",property) == 0)
4804 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4806 return(MagickFalse);
4807 image->units=(ResolutionType) units;
4815 if (LocaleCompare(
"version",property) == 0)
4817 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4818 "SetReadOnlyProperty",
"`%s'",property);
4819 return(MagickFalse);
4826 if (LocaleCompare(
"width",property) == 0)
4828 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4829 "SetReadOnlyProperty",
"`%s'",property);
4830 return(MagickFalse);
4839 if (LocaleNCompare(
"xmp:",property,4) == 0)
4841 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4842 "SetReadOnlyProperty",
"`%s'",property);
4843 return(MagickFalse);
4850 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4851 ConstantString(property),ConstantString(value));