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 *macroman_resource = (
char *) NULL,
600 name[MagickPathExtent],
601 *resource = (
char *) NULL;
628 profile=GetImageProfile(image,
"8bim");
629 if (profile == (StringInfo *) NULL)
631 count=(ssize_t) MagickSscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",
632 &start,&stop,name,format);
633 if ((count != 2) && (count != 3) && (count != 4))
636 (void) CopyMagickString(format,
"SVG",MagickPathExtent);
641 sub_number=(ssize_t) StringToLong(&name[1]);
642 sub_number=MagickMax(sub_number,1L);
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 (macroman_resource != (
char *) NULL)
662 macroman_resource=DestroyString(macroman_resource);
663 if (resource != (
char *) NULL)
664 resource=DestroyString(resource);
665 count=(ssize_t) ReadPropertyByte(&info,&length);
666 if ((count != 0) && ((
size_t) count <= length))
668 resource=(
char *) NULL;
669 if (~((
size_t) count) >= (MagickPathExtent-1))
670 resource=(
char *) AcquireQuantumMemory((
size_t) count+
671 MagickPathExtent,
sizeof(*resource));
672 if (resource != (
char *) NULL)
674 for (i=0; i < (ssize_t) count; i++)
675 resource[i]=(
char) ReadPropertyByte(&info,&length);
676 resource[count]=
'\0';
679 if ((count & 0x01) == 0)
680 (void) ReadPropertyByte(&info,&length);
681 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
682 if ((count < 0) || ((
size_t) count > length))
687 macroman_resource=(
char *) ConvertMacRomanToUTF8((
unsigned char *)
689 if ((*name !=
'\0') && (*name !=
'#'))
690 if ((resource == (
char *) NULL) || (macroman_resource == (
char *) NULL) ||
691 ((LocaleCompare(name,resource) != 0) &&
692 (LocaleCompare(name,macroman_resource) != 0)))
698 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
701 if ((*name ==
'#') && (sub_number != 1))
708 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
714 attribute=(
char *) NULL;
715 if (~((
size_t) count) >= (MagickPathExtent-1))
716 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MagickPathExtent,
718 if (attribute != (
char *) NULL)
720 (void) memcpy(attribute,(
char *) info,(
size_t) count);
721 attribute[count]=
'\0';
723 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
724 if ((
id <= 1999) || (
id >= 2999))
725 (void) SetImageProperty((Image *) image,key,(
const char *) attribute,
732 if (LocaleCompare(format,
"svg") == 0)
733 path=TraceSVGClippath((
unsigned char *) attribute,(
size_t) count,
734 image->columns,image->rows);
736 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count);
737 (void) SetImageProperty((Image *) image,key,(
const char *) path,
739 path=DestroyString(path);
741 attribute=DestroyString(attribute);
745 if (macroman_resource != (
char *) NULL)
746 macroman_resource=DestroyString(macroman_resource);
747 if (resource != (
char *) NULL)
748 resource=DestroyString(resource);
751static inline signed int ReadPropertySignedLong(
const EndianType endian,
752 const unsigned char *buffer)
766 if (endian == LSBEndian)
768 value=(
unsigned int) buffer[3] << 24;
769 value|=(
unsigned int) buffer[2] << 16;
770 value|=(
unsigned int) buffer[1] << 8;
771 value|=(
unsigned int) buffer[0];
772 quantum.unsigned_value=value & 0xffffffff;
773 return(quantum.signed_value);
775 value=(
unsigned int) buffer[0] << 24;
776 value|=(
unsigned int) buffer[1] << 16;
777 value|=(
unsigned int) buffer[2] << 8;
778 value|=(
unsigned int) buffer[3];
779 quantum.unsigned_value=value & 0xffffffff;
780 return(quantum.signed_value);
783static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
784 const unsigned char *buffer)
789 if (endian == LSBEndian)
791 value=(
unsigned int) buffer[3] << 24;
792 value|=(
unsigned int) buffer[2] << 16;
793 value|=(
unsigned int) buffer[1] << 8;
794 value|=(
unsigned int) buffer[0];
795 return(value & 0xffffffff);
797 value=(
unsigned int) buffer[0] << 24;
798 value|=(
unsigned int) buffer[1] << 16;
799 value|=(
unsigned int) buffer[2] << 8;
800 value|=(
unsigned int) buffer[3];
801 return(value & 0xffffffff);
804static inline signed short ReadPropertySignedShort(
const EndianType endian,
805 const unsigned char *buffer)
819 if (endian == LSBEndian)
821 value=(
unsigned short) buffer[1] << 8;
822 value|=(
unsigned short) buffer[0];
823 quantum.unsigned_value=value & 0xffff;
824 return(quantum.signed_value);
826 value=(
unsigned short) buffer[0] << 8;
827 value|=(
unsigned short) buffer[1];
828 quantum.unsigned_value=value & 0xffff;
829 return(quantum.signed_value);
832static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
833 const unsigned char *buffer)
838 if (endian == LSBEndian)
840 value=(
unsigned short) buffer[1] << 8;
841 value|=(
unsigned short) buffer[0];
842 return(value & 0xffff);
844 value=(
unsigned short) buffer[0] << 8;
845 value|=(
unsigned short) buffer[1];
846 return(value & 0xffff);
849static void GetEXIFProperty(
const Image *image,
const char *property,
850 ExceptionInfo *exception)
852#define MaxDirectoryStack 16
853#define EXIF_DELIMITER "\n"
854#define EXIF_NUM_FORMATS 12
855#define EXIF_FMT_BYTE 1
856#define EXIF_FMT_STRING 2
857#define EXIF_FMT_USHORT 3
858#define EXIF_FMT_ULONG 4
859#define EXIF_FMT_URATIONAL 5
860#define EXIF_FMT_SBYTE 6
861#define EXIF_FMT_UNDEFINED 7
862#define EXIF_FMT_SSHORT 8
863#define EXIF_FMT_SLONG 9
864#define EXIF_FMT_SRATIONAL 10
865#define EXIF_FMT_SINGLE 11
866#define EXIF_FMT_DOUBLE 12
867#define GPS_LATITUDE 0x10002
868#define GPS_LONGITUDE 0x10004
869#define GPS_TIMESTAMP 0x10007
870#define TAG_EXIF_OFFSET 0x8769
871#define TAG_GPS_OFFSET 0x8825
872#define TAG_INTEROP_OFFSET 0xa005
874#define EXIFGPSFractions(format,arg1,arg2,arg3,arg4,arg5,arg6) \
882 for ( ; component < components; component++) \
884 if (component != 0) \
885 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
887 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
888 extent,format,(arg1),(arg2),(arg3),(arg4),(arg5),(arg6)); \
889 if (extent >= (MagickPathExtent-1)) \
890 extent=MagickPathExtent-1; \
892 buffer[extent]='\0'; \
893 value=AcquireString(buffer); \
896#define EXIFMultipleValues(format,arg) \
904 for ( ; component < components; component++) \
906 if (component != 0) \
907 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
909 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
910 extent,format,arg); \
911 if (extent >= (MagickPathExtent-1)) \
912 extent=MagickPathExtent-1; \
914 buffer[extent]='\0'; \
915 value=AcquireString(buffer); \
918#define EXIFMultipleFractions(format,arg1,arg2) \
926 for ( ; component < components; component++) \
928 if (component != 0) \
929 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent-\
931 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
932 extent,format,(arg1),(arg2)); \
933 if (extent >= (MagickPathExtent-1)) \
934 extent=MagickPathExtent-1; \
936 buffer[extent]='\0'; \
937 value=AcquireString(buffer); \
940 typedef struct _DirectoryInfo
952 typedef struct _TagInfo
964 { 0x001,
"exif:InteroperabilityIndex" },
965 { 0x002,
"exif:InteroperabilityVersion" },
966 { 0x100,
"exif:ImageWidth" },
967 { 0x101,
"exif:ImageLength" },
968 { 0x102,
"exif:BitsPerSample" },
969 { 0x103,
"exif:Compression" },
970 { 0x106,
"exif:PhotometricInterpretation" },
971 { 0x10a,
"exif:FillOrder" },
972 { 0x10d,
"exif:DocumentName" },
973 { 0x10e,
"exif:ImageDescription" },
974 { 0x10f,
"exif:Make" },
975 { 0x110,
"exif:Model" },
976 { 0x111,
"exif:StripOffsets" },
977 { 0x112,
"exif:Orientation" },
978 { 0x115,
"exif:SamplesPerPixel" },
979 { 0x116,
"exif:RowsPerStrip" },
980 { 0x117,
"exif:StripByteCounts" },
981 { 0x11a,
"exif:XResolution" },
982 { 0x11b,
"exif:YResolution" },
983 { 0x11c,
"exif:PlanarConfiguration" },
984 { 0x11d,
"exif:PageName" },
985 { 0x11e,
"exif:XPosition" },
986 { 0x11f,
"exif:YPosition" },
987 { 0x118,
"exif:MinSampleValue" },
988 { 0x119,
"exif:MaxSampleValue" },
989 { 0x120,
"exif:FreeOffsets" },
990 { 0x121,
"exif:FreeByteCounts" },
991 { 0x122,
"exif:GrayResponseUnit" },
992 { 0x123,
"exif:GrayResponseCurve" },
993 { 0x124,
"exif:T4Options" },
994 { 0x125,
"exif:T6Options" },
995 { 0x128,
"exif:ResolutionUnit" },
996 { 0x12d,
"exif:TransferFunction" },
997 { 0x131,
"exif:Software" },
998 { 0x132,
"exif:DateTime" },
999 { 0x13b,
"exif:Artist" },
1000 { 0x13e,
"exif:WhitePoint" },
1001 { 0x13f,
"exif:PrimaryChromaticities" },
1002 { 0x140,
"exif:ColorMap" },
1003 { 0x141,
"exif:HalfToneHints" },
1004 { 0x142,
"exif:TileWidth" },
1005 { 0x143,
"exif:TileLength" },
1006 { 0x144,
"exif:TileOffsets" },
1007 { 0x145,
"exif:TileByteCounts" },
1008 { 0x14a,
"exif:SubIFD" },
1009 { 0x14c,
"exif:InkSet" },
1010 { 0x14d,
"exif:InkNames" },
1011 { 0x14e,
"exif:NumberOfInks" },
1012 { 0x150,
"exif:DotRange" },
1013 { 0x151,
"exif:TargetPrinter" },
1014 { 0x152,
"exif:ExtraSample" },
1015 { 0x153,
"exif:SampleFormat" },
1016 { 0x154,
"exif:SMinSampleValue" },
1017 { 0x155,
"exif:SMaxSampleValue" },
1018 { 0x156,
"exif:TransferRange" },
1019 { 0x157,
"exif:ClipPath" },
1020 { 0x158,
"exif:XClipPathUnits" },
1021 { 0x159,
"exif:YClipPathUnits" },
1022 { 0x15a,
"exif:Indexed" },
1023 { 0x15b,
"exif:JPEGTables" },
1024 { 0x15f,
"exif:OPIProxy" },
1025 { 0x200,
"exif:JPEGProc" },
1026 { 0x201,
"exif:JPEGInterchangeFormat" },
1027 { 0x202,
"exif:JPEGInterchangeFormatLength" },
1028 { 0x203,
"exif:JPEGRestartInterval" },
1029 { 0x205,
"exif:JPEGLosslessPredictors" },
1030 { 0x206,
"exif:JPEGPointTransforms" },
1031 { 0x207,
"exif:JPEGQTables" },
1032 { 0x208,
"exif:JPEGDCTables" },
1033 { 0x209,
"exif:JPEGACTables" },
1034 { 0x211,
"exif:YCbCrCoefficients" },
1035 { 0x212,
"exif:YCbCrSubSampling" },
1036 { 0x213,
"exif:YCbCrPositioning" },
1037 { 0x214,
"exif:ReferenceBlackWhite" },
1038 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1039 { 0x301,
"exif:Gamma" },
1040 { 0x302,
"exif:ICCProfileDescriptor" },
1041 { 0x303,
"exif:SRGBRenderingIntent" },
1042 { 0x320,
"exif:ImageTitle" },
1043 { 0x5001,
"exif:ResolutionXUnit" },
1044 { 0x5002,
"exif:ResolutionYUnit" },
1045 { 0x5003,
"exif:ResolutionXLengthUnit" },
1046 { 0x5004,
"exif:ResolutionYLengthUnit" },
1047 { 0x5005,
"exif:PrintFlags" },
1048 { 0x5006,
"exif:PrintFlagsVersion" },
1049 { 0x5007,
"exif:PrintFlagsCrop" },
1050 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1051 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1052 { 0x500A,
"exif:HalftoneLPI" },
1053 { 0x500B,
"exif:HalftoneLPIUnit" },
1054 { 0x500C,
"exif:HalftoneDegree" },
1055 { 0x500D,
"exif:HalftoneShape" },
1056 { 0x500E,
"exif:HalftoneMisc" },
1057 { 0x500F,
"exif:HalftoneScreen" },
1058 { 0x5010,
"exif:JPEGQuality" },
1059 { 0x5011,
"exif:GridSize" },
1060 { 0x5012,
"exif:ThumbnailFormat" },
1061 { 0x5013,
"exif:ThumbnailWidth" },
1062 { 0x5014,
"exif:ThumbnailHeight" },
1063 { 0x5015,
"exif:ThumbnailColorDepth" },
1064 { 0x5016,
"exif:ThumbnailPlanes" },
1065 { 0x5017,
"exif:ThumbnailRawBytes" },
1066 { 0x5018,
"exif:ThumbnailSize" },
1067 { 0x5019,
"exif:ThumbnailCompressedSize" },
1068 { 0x501a,
"exif:ColorTransferFunction" },
1069 { 0x501b,
"exif:ThumbnailData" },
1070 { 0x5020,
"exif:ThumbnailImageWidth" },
1071 { 0x5021,
"exif:ThumbnailImageHeight" },
1072 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1073 { 0x5023,
"exif:ThumbnailCompression" },
1074 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1075 { 0x5025,
"exif:ThumbnailImageDescription" },
1076 { 0x5026,
"exif:ThumbnailEquipMake" },
1077 { 0x5027,
"exif:ThumbnailEquipModel" },
1078 { 0x5028,
"exif:ThumbnailStripOffsets" },
1079 { 0x5029,
"exif:ThumbnailOrientation" },
1080 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1081 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1082 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1083 { 0x502d,
"exif:ThumbnailResolutionX" },
1084 { 0x502e,
"exif:ThumbnailResolutionY" },
1085 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1086 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1087 { 0x5031,
"exif:ThumbnailTransferFunction" },
1088 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1089 { 0x5033,
"exif:ThumbnailDateTime" },
1090 { 0x5034,
"exif:ThumbnailArtist" },
1091 { 0x5035,
"exif:ThumbnailWhitePoint" },
1092 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1093 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1094 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1095 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1096 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1097 { 0x503B,
"exif:ThumbnailCopyRight" },
1098 { 0x5090,
"exif:LuminanceTable" },
1099 { 0x5091,
"exif:ChrominanceTable" },
1100 { 0x5100,
"exif:FrameDelay" },
1101 { 0x5101,
"exif:LoopCount" },
1102 { 0x5110,
"exif:PixelUnit" },
1103 { 0x5111,
"exif:PixelPerUnitX" },
1104 { 0x5112,
"exif:PixelPerUnitY" },
1105 { 0x5113,
"exif:PaletteHistogram" },
1106 { 0x1000,
"exif:RelatedImageFileFormat" },
1107 { 0x1001,
"exif:RelatedImageLength" },
1108 { 0x1002,
"exif:RelatedImageWidth" },
1109 { 0x800d,
"exif:ImageID" },
1110 { 0x80e3,
"exif:Matteing" },
1111 { 0x80e4,
"exif:DataType" },
1112 { 0x80e5,
"exif:ImageDepth" },
1113 { 0x80e6,
"exif:TileDepth" },
1114 { 0x828d,
"exif:CFARepeatPatternDim" },
1115 { 0x828e,
"exif:CFAPattern2" },
1116 { 0x828f,
"exif:BatteryLevel" },
1117 { 0x8298,
"exif:Copyright" },
1118 { 0x829a,
"exif:ExposureTime" },
1119 { 0x829d,
"exif:FNumber" },
1120 { 0x83bb,
"exif:IPTC/NAA" },
1121 { 0x84e3,
"exif:IT8RasterPadding" },
1122 { 0x84e5,
"exif:IT8ColorTable" },
1123 { 0x8649,
"exif:ImageResourceInformation" },
1124 { 0x8769,
"exif:ExifOffset" },
1125 { 0x8773,
"exif:InterColorProfile" },
1126 { 0x8822,
"exif:ExposureProgram" },
1127 { 0x8824,
"exif:SpectralSensitivity" },
1128 { 0x8825,
"exif:GPSInfo" },
1129 { 0x8827,
"exif:PhotographicSensitivity" },
1130 { 0x8828,
"exif:OECF" },
1131 { 0x8829,
"exif:Interlace" },
1132 { 0x882a,
"exif:TimeZoneOffset" },
1133 { 0x882b,
"exif:SelfTimerMode" },
1134 { 0x8830,
"exif:SensitivityType" },
1135 { 0x8831,
"exif:StandardOutputSensitivity" },
1136 { 0x8832,
"exif:RecommendedExposureIndex" },
1137 { 0x8833,
"exif:ISOSpeed" },
1138 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1139 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1140 { 0x9000,
"exif:ExifVersion" },
1141 { 0x9003,
"exif:DateTimeOriginal" },
1142 { 0x9004,
"exif:DateTimeDigitized" },
1143 { 0x9010,
"exif:OffsetTime" },
1144 { 0x9011,
"exif:OffsetTimeOriginal" },
1145 { 0x9012,
"exif:OffsetTimeDigitized" },
1146 { 0x9101,
"exif:ComponentsConfiguration" },
1147 { 0x9102,
"exif:CompressedBitsPerPixel" },
1148 { 0x9201,
"exif:ShutterSpeedValue" },
1149 { 0x9202,
"exif:ApertureValue" },
1150 { 0x9203,
"exif:BrightnessValue" },
1151 { 0x9204,
"exif:ExposureBiasValue" },
1152 { 0x9205,
"exif:MaxApertureValue" },
1153 { 0x9206,
"exif:SubjectDistance" },
1154 { 0x9207,
"exif:MeteringMode" },
1155 { 0x9208,
"exif:LightSource" },
1156 { 0x9209,
"exif:Flash" },
1157 { 0x920a,
"exif:FocalLength" },
1158 { 0x920b,
"exif:FlashEnergy" },
1159 { 0x920c,
"exif:SpatialFrequencyResponse" },
1160 { 0x920d,
"exif:Noise" },
1161 { 0x9214,
"exif:SubjectArea" },
1162 { 0x9290,
"exif:SubSecTime" },
1163 { 0x9291,
"exif:SubSecTimeOriginal" },
1164 { 0x9292,
"exif:SubSecTimeDigitized" },
1165 { 0x9211,
"exif:ImageNumber" },
1166 { 0x9212,
"exif:SecurityClassification" },
1167 { 0x9213,
"exif:ImageHistory" },
1168 { 0x9214,
"exif:SubjectArea" },
1169 { 0x9215,
"exif:ExposureIndex" },
1170 { 0x9216,
"exif:TIFF-EPStandardID" },
1171 { 0x927c,
"exif:MakerNote" },
1172 { 0x9286,
"exif:UserComment" },
1173 { 0x9290,
"exif:SubSecTime" },
1174 { 0x9291,
"exif:SubSecTimeOriginal" },
1175 { 0x9292,
"exif:SubSecTimeDigitized" },
1176 { 0x9400,
"exif:Temperature" },
1177 { 0x9401,
"exif:Humidity" },
1178 { 0x9402,
"exif:Pressure" },
1179 { 0x9403,
"exif:WaterDepth" },
1180 { 0x9404,
"exif:Acceleration" },
1181 { 0x9405,
"exif:CameraElevationAngle" },
1182 { 0x9C9b,
"exif:WinXP-Title" },
1183 { 0x9C9c,
"exif:WinXP-Comments" },
1184 { 0x9C9d,
"exif:WinXP-Author" },
1185 { 0x9C9e,
"exif:WinXP-Keywords" },
1186 { 0x9C9f,
"exif:WinXP-Subject" },
1187 { 0xa000,
"exif:FlashPixVersion" },
1188 { 0xa001,
"exif:ColorSpace" },
1189 { 0xa002,
"exif:PixelXDimension" },
1190 { 0xa003,
"exif:PixelYDimension" },
1191 { 0xa004,
"exif:RelatedSoundFile" },
1192 { 0xa005,
"exif:InteroperabilityOffset" },
1193 { 0xa20b,
"exif:FlashEnergy" },
1194 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1195 { 0xa20d,
"exif:Noise" },
1196 { 0xa20e,
"exif:FocalPlaneXResolution" },
1197 { 0xa20f,
"exif:FocalPlaneYResolution" },
1198 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1199 { 0xa214,
"exif:SubjectLocation" },
1200 { 0xa215,
"exif:ExposureIndex" },
1201 { 0xa216,
"exif:TIFF/EPStandardID" },
1202 { 0xa217,
"exif:SensingMethod" },
1203 { 0xa300,
"exif:FileSource" },
1204 { 0xa301,
"exif:SceneType" },
1205 { 0xa302,
"exif:CFAPattern" },
1206 { 0xa401,
"exif:CustomRendered" },
1207 { 0xa402,
"exif:ExposureMode" },
1208 { 0xa403,
"exif:WhiteBalance" },
1209 { 0xa404,
"exif:DigitalZoomRatio" },
1210 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1211 { 0xa406,
"exif:SceneCaptureType" },
1212 { 0xa407,
"exif:GainControl" },
1213 { 0xa408,
"exif:Contrast" },
1214 { 0xa409,
"exif:Saturation" },
1215 { 0xa40a,
"exif:Sharpness" },
1216 { 0xa40b,
"exif:DeviceSettingDescription" },
1217 { 0xa40c,
"exif:SubjectDistanceRange" },
1218 { 0xa420,
"exif:ImageUniqueID" },
1219 { 0xa430,
"exif:CameraOwnerName" },
1220 { 0xa431,
"exif:BodySerialNumber" },
1221 { 0xa432,
"exif:LensSpecification" },
1222 { 0xa433,
"exif:LensMake" },
1223 { 0xa434,
"exif:LensModel" },
1224 { 0xa435,
"exif:LensSerialNumber" },
1225 { 0xc4a5,
"exif:PrintImageMatching" },
1226 { 0xa500,
"exif:Gamma" },
1227 { 0xc640,
"exif:CR2Slice" },
1228 { 0x10000,
"exif:GPSVersionID" },
1229 { 0x10001,
"exif:GPSLatitudeRef" },
1230 { 0x10002,
"exif:GPSLatitude" },
1231 { 0x10003,
"exif:GPSLongitudeRef" },
1232 { 0x10004,
"exif:GPSLongitude" },
1233 { 0x10005,
"exif:GPSAltitudeRef" },
1234 { 0x10006,
"exif:GPSAltitude" },
1235 { 0x10007,
"exif:GPSTimeStamp" },
1236 { 0x10008,
"exif:GPSSatellites" },
1237 { 0x10009,
"exif:GPSStatus" },
1238 { 0x1000a,
"exif:GPSMeasureMode" },
1239 { 0x1000b,
"exif:GPSDop" },
1240 { 0x1000c,
"exif:GPSSpeedRef" },
1241 { 0x1000d,
"exif:GPSSpeed" },
1242 { 0x1000e,
"exif:GPSTrackRef" },
1243 { 0x1000f,
"exif:GPSTrack" },
1244 { 0x10010,
"exif:GPSImgDirectionRef" },
1245 { 0x10011,
"exif:GPSImgDirection" },
1246 { 0x10012,
"exif:GPSMapDatum" },
1247 { 0x10013,
"exif:GPSDestLatitudeRef" },
1248 { 0x10014,
"exif:GPSDestLatitude" },
1249 { 0x10015,
"exif:GPSDestLongitudeRef" },
1250 { 0x10016,
"exif:GPSDestLongitude" },
1251 { 0x10017,
"exif:GPSDestBearingRef" },
1252 { 0x10018,
"exif:GPSDestBearing" },
1253 { 0x10019,
"exif:GPSDestDistanceRef" },
1254 { 0x1001a,
"exif:GPSDestDistance" },
1255 { 0x1001b,
"exif:GPSProcessingMethod" },
1256 { 0x1001c,
"exif:GPSAreaInformation" },
1257 { 0x1001d,
"exif:GPSDateStamp" },
1258 { 0x1001e,
"exif:GPSDifferential" },
1259 { 0x1001f,
"exif:GPSHPositioningError" },
1271 directory_stack[MaxDirectoryStack] = { { 0, 0, 0 } };
1295 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1300 profile=GetImageProfile(image,
"exif");
1301 if (profile == (
const StringInfo *) NULL)
1303 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1305 while (isspace((
int) ((
unsigned char) *property)) != 0)
1307 if (strlen(property) <= 5)
1311 switch (*(property+5))
1340 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1351 for (i=(ssize_t) n-1L; i >= 0; i--)
1355 if ((c >=
'0') && (c <=
'9'))
1356 tag|=(size_t) (c-
'0');
1358 if ((c >=
'A') && (c <=
'F'))
1359 tag|=(size_t) (c-(
'A'-10));
1361 if ((c >=
'a') && (c <=
'f'))
1362 tag|=(size_t) (c-(
'a'-10));
1366 }
while (*property !=
'\0');
1376 if (EXIFTag[i].tag == 0)
1378 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1380 tag=(size_t) EXIFTag[i].tag;
1389 length=GetStringInfoLength(profile);
1392 exif=GetStringInfoDatum(profile);
1395 if (ReadPropertyByte(&exif,&length) != 0x45)
1397 if (ReadPropertyByte(&exif,&length) != 0x78)
1399 if (ReadPropertyByte(&exif,&length) != 0x69)
1401 if (ReadPropertyByte(&exif,&length) != 0x66)
1403 if (ReadPropertyByte(&exif,&length) != 0x00)
1405 if (ReadPropertyByte(&exif,&length) != 0x00)
1411 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1420 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1425 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1426 if ((offset < 0) || (
size_t) offset >= length)
1431 directory=exif+offset;
1435 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1436 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1445 directory=directory_stack[level].directory;
1446 entry=directory_stack[level].entry;
1447 tag_offset=directory_stack[level].offset;
1449 if ((directory < exif) || (directory > (exif+length-2)))
1454 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1455 for ( ; entry < number_entries; entry++)
1468 q=(
unsigned char *) (directory+(12*entry)+2);
1469 if (q > (exif+length-12))
1471 if (GetValueFromSplayTree(exif_resources,q) == q)
1473 (void) AddValueToSplayTree(exif_resources,q,q);
1474 tag_value=(size_t) (ReadPropertyUnsignedShort(endian,q)+(ssize_t)
1476 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1477 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1481 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1484 number_bytes=components*(ssize_t) tag_bytes[format];
1485 if (number_bytes < components)
1487 if (number_bytes <= 4)
1497 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1498 if ((dir_offset < 0) || (
size_t) dir_offset >= length)
1500 if (((
size_t) dir_offset+(
size_t) number_bytes) < (
size_t) dir_offset)
1502 if ((
size_t) (dir_offset+(ssize_t) number_bytes) > length)
1504 p=(
unsigned char *) (exif+dir_offset);
1506 if ((all != 0) || (tag == (
size_t) tag_value))
1509 buffer[6*
sizeof(double)+MagickPathExtent],
1512 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1514 value=(
char *) NULL;
1520 value=(
char *) NULL;
1521 if (~((
size_t) number_bytes) >= 1)
1522 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1524 if (value != (
char *) NULL)
1526 for (i=0; i < (ssize_t) number_bytes; i++)
1529 if (isprint((
int) p[i]) != 0)
1530 value[i]=(char) p[i];
1536 case EXIF_FMT_SBYTE:
1538 EXIFMultipleValues(
"%.20g",(
double) (*(
signed char *) p));
1541 case EXIF_FMT_SSHORT:
1543 EXIFMultipleValues(
"%hd",ReadPropertySignedShort(endian,p));
1546 case EXIF_FMT_USHORT:
1548 EXIFMultipleValues(
"%hu",ReadPropertyUnsignedShort(endian,p));
1551 case EXIF_FMT_ULONG:
1553 EXIFMultipleValues(
"%.20g",(
double)
1554 ReadPropertyUnsignedLong(endian,p));
1557 case EXIF_FMT_SLONG:
1559 EXIFMultipleValues(
"%.20g",(
double)
1560 ReadPropertySignedLong(endian,p));
1563 case EXIF_FMT_URATIONAL:
1565 if ((tag_value == GPS_LATITUDE) || (tag_value == GPS_LONGITUDE) ||
1566 (tag_value == GPS_TIMESTAMP))
1569 EXIFGPSFractions(
"%.20g/%.20g,%.20g/%.20g,%.20g/%.20g",
1570 (
double) ReadPropertyUnsignedLong(endian,p),
1571 (
double) ReadPropertyUnsignedLong(endian,p+4),
1572 (
double) ReadPropertyUnsignedLong(endian,p+8),
1573 (
double) ReadPropertyUnsignedLong(endian,p+12),
1574 (
double) ReadPropertyUnsignedLong(endian,p+16),
1575 (
double) ReadPropertyUnsignedLong(endian,p+20));
1578 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1579 ReadPropertyUnsignedLong(endian,p),(
double)
1580 ReadPropertyUnsignedLong(endian,p+4));
1583 case EXIF_FMT_SRATIONAL:
1585 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1586 ReadPropertySignedLong(endian,p),(
double)
1587 ReadPropertySignedLong(endian,p+4));
1590 case EXIF_FMT_SINGLE:
1592 EXIFMultipleValues(
"%.20g",(
double)
1593 ReadPropertySignedLong(endian,p));
1596 case EXIF_FMT_DOUBLE:
1598 EXIFMultipleValues(
"%.20g",(
double)
1599 ReadPropertySignedLong(endian,p));
1602 case EXIF_FMT_STRING:
1603 case EXIF_FMT_UNDEFINED:
1606 if ((p < exif) || (p > (exif+length-number_bytes)))
1608 value=(
char *) NULL;
1609 if (~((
size_t) number_bytes) >= 1)
1610 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1612 if (value != (
char *) NULL)
1614 for (i=0; i < (ssize_t) number_bytes; i++)
1617 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1618 value[i]=(char) p[i];
1625 if (value != (
char *) NULL)
1630 key=AcquireString(property);
1638 description=
"unknown";
1641 if (EXIFTag[i].tag == 0)
1643 if (EXIFTag[i].tag == tag_value)
1645 description=EXIFTag[i].description;
1649 (void) FormatLocaleString(key,MagickPathExtent,
"%s",
1652 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1657 if (tag_value < 0x10000)
1658 (void) FormatLocaleString(key,MagickPathExtent,
"#%04lx",
1659 (
unsigned long) tag_value);
1661 if (tag_value < 0x20000)
1662 (void) FormatLocaleString(key,MagickPathExtent,
"@%04lx",
1663 (
unsigned long) (tag_value & 0xffff));
1665 (
void) FormatLocaleString(key,MagickPathExtent,
"unknown");
1671 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1674 if ((image->properties == (
void *) NULL) ||
1675 (GetValueFromSplayTree((SplayTreeInfo *) image->properties,key) == (
const void *) NULL))
1676 (void) SetImageProperty((Image *) image,key,value,exception);
1677 value=DestroyString(value);
1678 key=DestroyString(key);
1681 if ((tag_value == TAG_EXIF_OFFSET) ||
1682 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1687 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,p);
1688 if (((
size_t) tag_offset1 < length) &&
1689 (level < (MaxDirectoryStack-2)))
1694 tag_offset2=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1696 directory_stack[level].directory=directory;
1698 directory_stack[level].entry=entry;
1699 directory_stack[level].offset=tag_offset;
1704 for (i=0; i < level; i++)
1705 if (directory_stack[i].directory == (exif+tag_offset1))
1709 directory_stack[level].directory=exif+tag_offset1;
1710 directory_stack[level].offset=tag_offset2;
1711 directory_stack[level].entry=0;
1713 if ((directory+2+(12*number_entries)+4) > (exif+length))
1715 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,directory+
1716 2+(12*number_entries));
1717 if ((tag_offset1 != 0) && ((
size_t) tag_offset1 < length) &&
1718 (level < (MaxDirectoryStack-2)))
1720 directory_stack[level].directory=exif+tag_offset1;
1721 directory_stack[level].entry=0;
1722 directory_stack[level].offset=tag_offset2;
1729 }
while (level > 0);
1730 exif_resources=DestroySplayTree(exif_resources);
1733#if defined(MAGICKCORE_LCMS_DELEGATE)
1734static void GetICCProperty(
const Image *image,ExceptionInfo *exception)
1746 profile=GetImageProfile(image,
"icc");
1747 if (profile == (StringInfo *) NULL)
1748 profile=GetImageProfile(image,
"icm");
1749 if (profile == (StringInfo *) NULL)
1751 if (GetStringInfoLength(profile) < 128)
1753 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1754 (cmsUInt32Number) GetStringInfoLength(profile));
1755 if (icc_profile != (cmsHPROFILE *) NULL)
1757#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1761 name=cmsTakeProductName(icc_profile);
1762 if (name != (
const char *) NULL)
1763 (void) SetImageProperty((Image *) image,
"icc:name",name,exception);
1771 info=AcquireStringInfo(0);
1772 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1776 SetStringInfoLength(info,extent+1);
1777 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1778 "US",(
char *) GetStringInfoDatum(info),extent);
1780 (void) SetImageProperty((Image *) image,
"icc:description",
1781 (
char *) GetStringInfoDatum(info),exception);
1783 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1787 SetStringInfoLength(info,extent+1);
1788 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1789 "US",(
char *) GetStringInfoDatum(info),extent);
1791 (void) SetImageProperty((Image *) image,
"icc:manufacturer",
1792 (
char *) GetStringInfoDatum(info),exception);
1794 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1798 SetStringInfoLength(info,extent+1);
1799 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1800 (
char *) GetStringInfoDatum(info),extent);
1802 (void) SetImageProperty((Image *) image,
"icc:model",
1803 (
char *) GetStringInfoDatum(info),exception);
1805 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1809 SetStringInfoLength(info,extent+1);
1810 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1811 "US",(
char *) GetStringInfoDatum(info),extent);
1813 (void) SetImageProperty((Image *) image,
"icc:copyright",
1814 (
char *) GetStringInfoDatum(info),exception);
1816 info=DestroyStringInfo(info);
1818 (void) cmsCloseProfile(icc_profile);
1823static MagickBooleanType SkipXMPValue(
const char *value)
1825 if (value == (
const char*) NULL)
1827 while (*value !=
'\0')
1829 if (isspace((
int) ((
unsigned char) *value)) == 0)
1830 return(MagickFalse);
1836static void GetXMPProperty(
const Image *image,
const char *property)
1860 profile=GetImageProfile(image,
"xmp");
1861 if (profile == (StringInfo *) NULL)
1863 if (GetStringInfoLength(profile) < 17)
1865 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1867 xmp_profile=StringInfoToString(profile);
1868 if (xmp_profile == (
char *) NULL)
1870 for (p=xmp_profile; *p !=
'\0'; p++)
1871 if ((*p ==
'<') && (*(p+1) ==
'x'))
1873 exception=AcquireExceptionInfo();
1874 xmp=NewXMLTree((
char *) p,exception);
1875 xmp_profile=DestroyString(xmp_profile);
1876 exception=DestroyExceptionInfo(exception);
1877 if (xmp == (XMLTreeInfo *) NULL)
1879 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1880 if (rdf != (XMLTreeInfo *) NULL)
1882 if (image->properties == (
void *) NULL)
1883 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1884 RelinquishMagickMemory,RelinquishMagickMemory);
1885 description=GetXMLTreeChild(rdf,
"rdf:Description");
1886 while (description != (XMLTreeInfo *) NULL)
1891 node=GetXMLTreeChild(description,(
const char *) NULL);
1892 while (node != (XMLTreeInfo *) NULL)
1894 child=GetXMLTreeChild(node,(
const char *) NULL);
1895 content=GetXMLTreeContent(node);
1896 if ((child == (XMLTreeInfo *) NULL) &&
1897 (SkipXMPValue(content) == MagickFalse))
1899 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1900 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1901 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1902 xmp_namespace,ConstantString(content));
1904 while (child != (XMLTreeInfo *) NULL)
1906 content=GetXMLTreeContent(child);
1907 if (SkipXMPValue(content) == MagickFalse)
1909 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1910 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1911 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1912 xmp_namespace,ConstantString(content));
1914 child=GetXMLTreeSibling(child);
1916 node=GetXMLTreeSibling(node);
1918 description=GetNextXMLTreeTag(description);
1921 xmp=DestroyXMLTree(xmp);
1924static char *TracePSClippath(
const unsigned char *blob,
size_t length)
1947 path=AcquireString((
char *) NULL);
1948 if (path == (
char *) NULL)
1949 return((
char *) NULL);
1950 message=AcquireString((
char *) NULL);
1951 (void) FormatLocaleString(message,MagickPathExtent,
"/ClipImage\n");
1952 (void) ConcatenateString(&path,message);
1953 (void) FormatLocaleString(message,MagickPathExtent,
"{\n");
1954 (void) ConcatenateString(&path,message);
1955 (void) FormatLocaleString(message,MagickPathExtent,
1956 " /c {curveto} bind def\n");
1957 (void) ConcatenateString(&path,message);
1958 (void) FormatLocaleString(message,MagickPathExtent,
1959 " /l {lineto} bind def\n");
1960 (void) ConcatenateString(&path,message);
1961 (void) FormatLocaleString(message,MagickPathExtent,
1962 " /m {moveto} bind def\n");
1963 (void) ConcatenateString(&path,message);
1964 (void) FormatLocaleString(message,MagickPathExtent,
1965 " /v {currentpoint 6 2 roll curveto} bind def\n");
1966 (void) ConcatenateString(&path,message);
1967 (void) FormatLocaleString(message,MagickPathExtent,
1968 " /y {2 copy curveto} bind def\n");
1969 (void) ConcatenateString(&path,message);
1970 (void) FormatLocaleString(message,MagickPathExtent,
1971 " /z {closepath} bind def\n");
1972 (void) ConcatenateString(&path,message);
1973 (void) FormatLocaleString(message,MagickPathExtent,
" newpath\n");
1974 (void) ConcatenateString(&path,message);
1979 (void) memset(point,0,
sizeof(point));
1980 (void) memset(first,0,
sizeof(first));
1981 (void) memset(last,0,
sizeof(last));
1983 in_subpath=MagickFalse;
1986 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1992 if (knot_count != 0)
1995 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2001 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2003 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2011 if (knot_count == 0)
2017 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2023 for (i=0; i < 3; i++)
2025 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2026 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2027 point[i].x=(double) x/4096.0/4096.0;
2028 point[i].y=1.0-(double) y/4096.0/4096.0;
2030 if (in_subpath == MagickFalse)
2032 (void) FormatLocaleString(message,MagickPathExtent,
" %g %g m\n",
2033 point[1].x,point[1].y);
2034 for (i=0; i < 3; i++)
2046 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2047 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2048 (void) FormatLocaleString(message,MagickPathExtent,
2049 " %g %g l\n",point[1].x,point[1].y);
2051 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2052 (void) FormatLocaleString(message,MagickPathExtent,
2053 " %g %g %g %g v\n",point[0].x,point[0].y,
2054 point[1].x,point[1].y);
2056 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2057 (void) FormatLocaleString(message,MagickPathExtent,
2058 " %g %g %g %g y\n",last[2].x,last[2].y,
2059 point[1].x,point[1].y);
2061 (
void) FormatLocaleString(message,MagickPathExtent,
2062 " %g %g %g %g %g %g c\n",last[2].x,
2063 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2064 for (i=0; i < 3; i++)
2067 (void) ConcatenateString(&path,message);
2068 in_subpath=MagickTrue;
2073 if (knot_count == 0)
2079 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2080 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2081 (void) FormatLocaleString(message,MagickPathExtent,
2082 " %g %g l z\n",first[1].x,first[1].y);
2084 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2085 (void) FormatLocaleString(message,MagickPathExtent,
2086 " %g %g %g %g v z\n",first[0].x,first[0].y,
2087 first[1].x,first[1].y);
2089 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2090 (void) FormatLocaleString(message,MagickPathExtent,
2091 " %g %g %g %g y z\n",last[2].x,last[2].y,
2092 first[1].x,first[1].y);
2094 (
void) FormatLocaleString(message,MagickPathExtent,
2095 " %g %g %g %g %g %g c z\n",last[2].x,
2096 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2097 (void) ConcatenateString(&path,message);
2098 in_subpath=MagickFalse;
2108 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2116 (void) FormatLocaleString(message,MagickPathExtent,
" eoclip\n");
2117 (void) ConcatenateString(&path,message);
2118 (void) FormatLocaleString(message,MagickPathExtent,
"} bind def");
2119 (void) ConcatenateString(&path,message);
2120 message=DestroyString(message);
2124static inline void TraceBezierCurve(
char *message,PointInfo *last,
2131 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2132 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2133 (void) FormatLocaleString(message,MagickPathExtent,
2134 "L %g %g\n",point[1].x,point[1].y);
2136 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2137 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2140static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2141 const size_t columns,
const size_t rows)
2164 path=AcquireString((
char *) NULL);
2165 if (path == (
char *) NULL)
2166 return((
char *) NULL);
2167 message=AcquireString((
char *) NULL);
2168 (void) FormatLocaleString(message,MagickPathExtent,(
2169 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2170 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2171 " width=\"%.20g\" height=\"%.20g\">\n"
2173 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2174 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(
double) columns,
2176 (void) ConcatenateString(&path,message);
2177 (void) memset(point,0,
sizeof(point));
2178 (void) memset(first,0,
sizeof(first));
2179 (void) memset(last,0,
sizeof(last));
2181 in_subpath=MagickFalse;
2184 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2190 if (knot_count != 0)
2193 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2199 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2201 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2209 if (knot_count == 0)
2215 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2221 for (i=0; i < 3; i++)
2223 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2224 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2225 point[i].x=(double) x*columns/4096.0/4096.0;
2226 point[i].y=(double) y*rows/4096.0/4096.0;
2228 if (in_subpath == MagickFalse)
2230 (void) FormatLocaleString(message,MagickPathExtent,
"M %g %g\n",
2231 point[1].x,point[1].y);
2232 for (i=0; i < 3; i++)
2240 TraceBezierCurve(message,last,point);
2241 for (i=0; i < 3; i++)
2244 (void) ConcatenateString(&path,message);
2245 in_subpath=MagickTrue;
2250 if (knot_count == 0)
2252 TraceBezierCurve(message,last,first);
2253 (void) ConcatenateString(&path,message);
2254 in_subpath=MagickFalse;
2264 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2272 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2273 message=DestroyString(message);
2277MagickExport
const char *GetImageProperty(
const Image *image,
2278 const char *property,ExceptionInfo *exception)
2281 read_from_properties;
2289 assert(image != (Image *) NULL);
2290 assert(image->signature == MagickCoreSignature);
2291 if (IsEventLogging() != MagickFalse)
2292 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2293 if ((property == (
const char *) NULL) || (*property ==
'\0'))
2294 return((
const char *) NULL);
2295 read_from_properties=MagickTrue;
2296 property_length=strlen(property);
2297 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
2298 (*(property+(property_length-1)) ==
'*'))
2299 read_from_properties=MagickFalse;
2300 if (read_from_properties != MagickFalse)
2302 p=(
const char *) NULL;
2303 if (image->properties != (
void *) NULL)
2305 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2306 image->properties,property);
2307 if (p != (
const char *) NULL)
2310 if (strchr(property,
':') == (
char *) NULL)
2317 if (LocaleNCompare(
"8bim:",property,5) == 0)
2319 Get8BIMProperty(image,property,exception);
2327 if (LocaleNCompare(
"exif:",property,5) == 0)
2329 GetEXIFProperty(image,property,exception);
2337 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2338 (LocaleNCompare(
"icm:",property,4) == 0))
2340#if defined(MAGICKCORE_LCMS_DELEGATE)
2341 GetICCProperty(image,exception);
2345 if (LocaleNCompare(
"iptc:",property,5) == 0)
2347 GetIPTCProperty(image,property,exception);
2355 if (LocaleNCompare(
"xmp:",property,4) == 0)
2357 GetXMPProperty(image,property);
2365 if ((image->properties != (
void *) NULL) &&
2366 (read_from_properties != MagickFalse))
2368 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2369 image->properties,property);
2372 return((
const char *) NULL);
2466static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2467 Image *image,
const char letter,ExceptionInfo *exception)
2469#define WarnNoImageReturn(format,arg) \
2470 if (image == (Image *) NULL ) { \
2471 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2472 "NoImageForProperty",format,arg); \
2473 return((const char *) NULL); \
2475#define WarnNoImageInfoReturn(format,arg) \
2476 if (image_info == (ImageInfo *) NULL ) { \
2477 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2478 "NoImageInfoForProperty",format,arg); \
2479 return((const char *) NULL); \
2483 value[MagickPathExtent];
2488 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2489 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2491 if ((image_info != (ImageInfo *) NULL) &&
2492 (IsEventLogging() != MagickFalse))
2493 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2495 string=(
char *) NULL;
2503 WarnNoImageReturn(
"\"%%%c\"",letter);
2504 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
2506 if (image->extent == 0)
2507 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
2508 MagickPathExtent,value);
2513 WarnNoImageReturn(
"\"%%%c\"",letter);
2514 string=GetImageProperty(image,
"comment",exception);
2515 if (
string == (
const char *) NULL )
2521 WarnNoImageReturn(
"\"%%%c\"",letter);
2522 GetPathComponent(image->magick_filename,HeadPath,value);
2529 WarnNoImageReturn(
"\"%%%c\"",letter);
2530 GetPathComponent(image->magick_filename,ExtensionPath,value);
2537 WarnNoImageReturn(
"\"%%%c\"",letter);
2538 GetPathComponent(image->magick_filename,TailPath,value);
2545 WarnNoImageReturn(
"\"%%%c\"",letter);
2546 (void) FormatLocaleString(value,MagickPathExtent,
2547 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(
double)
2548 image->page.height,(
double) image->page.x,(
double) image->page.y);
2553 WarnNoImageReturn(
"\"%%%c\"",letter);
2554 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2555 (image->rows != 0 ? image->rows : image->magick_rows));
2560 WarnNoImageReturn(
"\"%%%c\"",letter);
2561 string=image->filename;
2569 WarnNoImageReturn(
"\"%%%c\"",letter);
2570 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2571 GetNumberColors(image,(FILE *) NULL,exception));
2576 WarnNoImageReturn(
"\"%%%c\"",letter);
2577 string=GetImageProperty(image,
"label",exception);
2578 if (
string == (
const char *) NULL)
2584 WarnNoImageReturn(
"\"%%%c\"",letter);
2585 string=image->magick;
2590 if ( image != (Image *) NULL )
2591 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2592 GetImageListLength(image));
2599 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2600 string=image_info->filename;
2605 WarnNoImageReturn(
"\"%%%c\"",letter);
2606 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2607 GetImageIndexInList(image));
2612 WarnNoImageReturn(
"\"%%%c\"",letter);
2613 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2614 MAGICKCORE_QUANTUM_DEPTH);
2622 WarnNoImageReturn(
"\"%%%c\"",letter);
2623 colorspace=image->colorspace;
2624 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
2625 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2626 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2627 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2634 if (image_info->number_scenes != 0)
2635 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2637 else if (image != (Image *) NULL)
2638 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2643 WarnNoImageReturn(
"\"%%%c\"",letter);
2644 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2651 WarnNoImageReturn(
"\"%%%c\"",letter);
2652 GetPathComponent(image->magick_filename,BasePath,value);
2659 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2660 string=image_info->unique;
2665 WarnNoImageReturn(
"\"%%%c\"",letter);
2666 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2667 (image->columns != 0 ? image->columns : image->magick_columns));
2672 WarnNoImageReturn(
"\"%%%c\"",letter);
2673 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2674 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
2675 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2681 WarnNoImageReturn(
"\"%%%c\"",letter);
2682 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2683 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
2684 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2690 WarnNoImageReturn(
"\"%%%c\"",letter);
2691 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2697 WarnNoImageReturn(
"\"%%%c\"",letter);
2698 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2699 image->alpha_trait);
2704 WarnNoImageReturn(
"\"%%%c\"",letter);
2705 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2707 if (image->extent == 0)
2708 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2709 GetBlobSize(image));
2714 WarnNoImageReturn(
"\"%%%c\"",letter);
2715 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2716 image->compression);
2721 WarnNoImageReturn(
"\"%%%c\"",letter);
2722 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2728 WarnNoImageReturn(
"\"%%%c\"",letter);
2729 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2730 image->magick_columns,(
double) image->magick_rows);
2735 WarnNoImageReturn(
"\"%%%c\"",letter);
2736 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2737 image->page.height);
2742 WarnNoImageReturn(
"\"%%%c\"",letter);
2743 string=image->magick_filename;
2748 if ((image != (Image *) NULL) && (image->next == (Image *) NULL))
2749 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2750 GetImageListLength(image));
2757 WarnNoImageReturn(
"\"%%%c\"",letter);
2758 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
2759 image->page.x,(
long) image->page.y);
2764 WarnNoImageReturn(
"\"%%%c\"",letter);
2765 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2766 image->page.width,(
double) image->page.height);
2771 WarnNoImageReturn(
"\"%%%c\"",letter);
2772 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2773 (image->quality == 0 ? 92 : image->quality));
2778 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2780 if (image_info->number_scenes == 0)
2781 string=
"2147483647";
2782 else if ( image != (Image *) NULL )
2783 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2784 image_info->scene+image_info->number_scenes);
2788 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2789 (image_info->number_scenes == 0 ? 2147483647 :
2790 image_info->number_scenes));
2796 WarnNoImageReturn(
"\"%%%c\"",letter);
2797 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2803 WarnNoImageReturn(
"\"%%%c\"",letter);
2804 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2810 WarnNoImageReturn(
"\"%%%c\"",letter);
2811 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2817 WarnNoImageReturn(
"\"%%%c\"",letter);
2818 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2824 WarnNoImageReturn(
"\"%%%c\"",letter);
2825 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2839 WarnNoImageReturn(
"\"%%%c\"",letter);
2840 page=GetImageBoundingBox(image,exception);
2841 (void) FormatLocaleString(value,MagickPathExtent,
2842 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(
double) page.height,
2843 (
double) page.x,(
double)page.y);
2851 WarnNoImageReturn(
"\"%%%c\"",letter);
2852 if ((image->columns != 0) && (image->rows != 0))
2853 (void) SignatureImage(image,exception);
2854 string=GetImageProperty(image,
"signature",exception);
2858 if (
string != (
char *) NULL)
2865 if (image != (Image *) NULL)
2867 (void) SetImageArtifact(image,
"magick-property",value);
2868 return(GetImageArtifact(image,
"magick-property"));
2872 (void) SetImageOption(image_info,
"magick-property",value);
2873 return(GetImageOption(image_info,
"magick-property"));
2876 return((
char *) NULL);
2879MagickExport
const char *GetMagickProperty(ImageInfo *image_info,
2880 Image *image,
const char *property,ExceptionInfo *exception)
2883 value[MagickPathExtent];
2888 assert(property != (
const char *) NULL);
2889 assert(property[0] !=
'\0');
2890 assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2891 if (property[1] ==
'\0')
2892 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2893 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2894 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2896 if ((image_info != (ImageInfo *) NULL) &&
2897 (IsEventLogging() != MagickFalse))
2898 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2900 string=(
char *) NULL;
2905 if (LocaleCompare(
"basename",property) == 0)
2907 WarnNoImageReturn(
"\"%%[%s]\"",property);
2908 GetPathComponent(image->magick_filename,BasePath,value);
2913 if (LocaleCompare(
"bit-depth",property) == 0)
2915 WarnNoImageReturn(
"\"%%[%s]\"",property);
2916 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2917 GetImageDepth(image,exception));
2920 if (LocaleCompare(
"bounding-box",property) == 0)
2925 WarnNoImageReturn(
"\"%%[%s]\"",property);
2926 geometry=GetImageBoundingBox(image,exception);
2927 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g",
2928 (
double) geometry.x,(
double) geometry.y,
2929 (
double) geometry.x+geometry.width,
2930 (
double) geometry.y+geometry.height);
2937 if (LocaleCompare(
"channels",property) == 0)
2939 WarnNoImageReturn(
"\"%%[%s]\"",property);
2940 (void) FormatLocaleString(value,MagickPathExtent,
"%s%s %g.%g",
2941 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2942 image->colorspace),image->alpha_trait != UndefinedPixelTrait ?
2943 "a" :
" ",(
double) image->number_channels,(
double)
2944 image->number_meta_channels);
2948 if (LocaleCompare(
"colors",property) == 0)
2950 WarnNoImageReturn(
"\"%%[%s]\"",property);
2951 image->colors=GetNumberColors(image,(FILE *) NULL,exception);
2952 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2956 if (LocaleCompare(
"colorspace",property) == 0)
2958 WarnNoImageReturn(
"\"%%[%s]\"",property);
2959 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2963 if (LocaleCompare(
"compose",property) == 0)
2965 WarnNoImageReturn(
"\"%%[%s]\"",property);
2966 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2970 if (LocaleCompare(
"compression",property) == 0)
2972 WarnNoImageReturn(
"\"%%[%s]\"",property);
2973 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2974 image->compression);
2977 if (LocaleCompare(
"convex-hull",property) == 0)
2991 WarnNoImageReturn(
"\"%%[%s]\"",property);
2992 convex_hull=GetImageConvexHull(image,&number_points,exception);
2993 if (convex_hull == (PointInfo *) NULL)
2995 points=AcquireString(
"");
2996 for (n=0; n < (ssize_t) number_points; n++)
2998 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
2999 convex_hull[n].x,convex_hull[n].y);
3000 (void) ConcatenateString(&points,value);
3002 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
3003 (void) SetImageProperty(image,
"convex-hull",points,exception);
3004 points=DestroyString(points);
3005 string=GetImageProperty(image,
"convex-hull",exception);
3008 if (LocaleCompare(
"convex-hull:extreme-points",property) == 0)
3023 WarnNoImageReturn(
"\"%%[%s]\"",property);
3024 convex_hull=GetImageConvexHull(image,&number_points,exception);
3025 if (convex_hull == (PointInfo *) NULL)
3027 points=AcquireString(
"");
3028 extreme=convex_hull[0];
3029 for (n=0; n < (ssize_t) number_points; n++)
3031 if (convex_hull[n].y < extreme.y)
3033 extreme=convex_hull[n];
3036 if (convex_hull[n].y != extreme.y)
3038 if (convex_hull[n].x < extreme.x)
3039 extreme=convex_hull[n];
3041 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3042 extreme.x,extreme.y);
3043 (void) ConcatenateString(&points,value);
3044 extreme=convex_hull[0];
3045 for (n=0; n < (ssize_t) number_points; n++)
3047 if (convex_hull[n].x > extreme.x)
3049 extreme=convex_hull[n];
3052 if (convex_hull[n].x != extreme.x)
3054 if (convex_hull[n].y < extreme.y)
3055 extreme=convex_hull[n];
3057 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3058 extreme.x,extreme.y);
3059 (void) ConcatenateString(&points,value);
3060 extreme=convex_hull[0];
3061 for (n=0; n < (ssize_t) number_points; n++)
3063 if (convex_hull[n].y > extreme.y)
3065 extreme=convex_hull[n];
3068 if (convex_hull[n].y != extreme.y)
3070 if (convex_hull[n].x > extreme.x)
3071 extreme=convex_hull[n];
3073 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3074 extreme.x,extreme.y);
3075 (void) ConcatenateString(&points,value);
3076 extreme=convex_hull[0];
3077 for (n=0; n < (ssize_t) number_points; n++)
3079 if (convex_hull[n].x < extreme.x)
3081 extreme=convex_hull[n];
3084 if (convex_hull[n].x != extreme.x)
3086 if (convex_hull[n].y > extreme.y)
3087 extreme=convex_hull[n];
3089 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3090 extreme.x,extreme.y);
3091 (void) ConcatenateString(&points,value);
3092 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
3093 (void) SetImageProperty(image,
"convex-hull:extreme-points",points,
3095 points=DestroyString(points);
3096 string=GetImageProperty(image,
"convex-hull:extreme-points",exception);
3099 if (LocaleCompare(
"copyright",property) == 0)
3101 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
3108 if (LocaleCompare(
"depth",property) == 0)
3110 WarnNoImageReturn(
"\"%%[%s]\"",property);
3111 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3115 if (LocaleCompare(
"directory",property) == 0)
3117 WarnNoImageReturn(
"\"%%[%s]\"",property);
3118 GetPathComponent(image->magick_filename,HeadPath,value);
3127 if (LocaleCompare(
"entropy",property) == 0)
3132 WarnNoImageReturn(
"\"%%[%s]\"",property);
3133 (void) GetImageEntropy(image,&entropy,exception);
3134 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3135 GetMagickPrecision(),entropy);
3138 if (LocaleCompare(
"extension",property) == 0)
3140 WarnNoImageReturn(
"\"%%[%s]\"",property);
3141 GetPathComponent(image->magick_filename,ExtensionPath,value);
3150 if (LocaleCompare(
"gamma",property) == 0)
3152 WarnNoImageReturn(
"\"%%[%s]\"",property);
3153 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3154 GetMagickPrecision(),image->gamma);
3161 if (LocaleCompare(
"height",property) == 0)
3163 WarnNoImageReturn(
"\"%%[%s]\"",property);
3164 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
3165 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3172 if (LocaleCompare(
"input",property) == 0)
3174 WarnNoImageReturn(
"\"%%[%s]\"",property);
3175 string=image->filename;
3178 if (LocaleCompare(
"interlace",property) == 0)
3180 WarnNoImageReturn(
"\"%%[%s]\"",property);
3181 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3189 if (LocaleCompare(
"kurtosis",property) == 0)
3195 WarnNoImageReturn(
"\"%%[%s]\"",property);
3196 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3197 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3198 GetMagickPrecision(),kurtosis);
3205 if (LocaleCompare(
"magick",property) == 0)
3207 WarnNoImageReturn(
"\"%%[%s]\"",property);
3208 string=image->magick;
3211 if ((LocaleCompare(
"maxima",property) == 0) ||
3212 (LocaleCompare(
"max",property) == 0))
3218 WarnNoImageReturn(
"\"%%[%s]\"",property);
3219 (void) GetImageRange(image,&minimum,&maximum,exception);
3220 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3221 GetMagickPrecision(),maximum);
3224 if (LocaleCompare(
"mean",property) == 0)
3230 WarnNoImageReturn(
"\"%%[%s]\"",property);
3231 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3232 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3233 GetMagickPrecision(),mean);
3236 if (LocaleCompare(
"median",property) == 0)
3241 WarnNoImageReturn(
"\"%%[%s]\"",property);
3242 (void) GetImageMedian(image,&median,exception);
3243 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3244 GetMagickPrecision(),median);
3247 if (LocaleCompare(
"mime:type",property) == 0)
3252 magick_info=GetMagickInfo(image->magick,exception);
3253 if ((magick_info != (
const MagickInfo *) NULL) &&
3254 (GetMagickMimeType(magick_info) != (
const char *) NULL))
3255 (void) CopyMagickString(value,GetMagickMimeType(magick_info),
3259 if ((LocaleCompare(
"minima",property) == 0) ||
3260 (LocaleCompare(
"min",property) == 0))
3266 WarnNoImageReturn(
"\"%%[%s]\"",property);
3267 (void) GetImageRange(image,&minimum,&maximum,exception);
3268 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3269 GetMagickPrecision(),minimum);
3272 if (LocaleNCompare(
"minimum-bounding-box",property,20) == 0)
3286 WarnNoImageReturn(
"\"%%[%s]\"",property);
3287 bounding_box=GetImageMinimumBoundingBox(image,&number_points,
3289 if (bounding_box == (PointInfo *) NULL)
3291 points=AcquireString(
"");
3292 for (n=0; n < (ssize_t) number_points; n++)
3294 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3295 bounding_box[n].x,bounding_box[n].y);
3296 (void) ConcatenateString(&points,value);
3298 bounding_box=(PointInfo *) RelinquishMagickMemory(bounding_box);
3299 (void) SetImageProperty(image,
"minimum-bounding-box",points,
3301 points=DestroyString(points);
3302 string=GetImageProperty(image,property,exception);
3309 if (LocaleCompare(
"opaque",property) == 0)
3311 WarnNoImageReturn(
"\"%%[%s]\"",property);
3312 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
3313 IsImageOpaque(image,exception));
3316 if (LocaleCompare(
"orientation",property) == 0)
3318 WarnNoImageReturn(
"\"%%[%s]\"",property);
3319 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3320 image->orientation);
3323 if (LocaleCompare(
"output",property) == 0)
3325 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3326 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
3333 if (LocaleCompare(
"page",property) == 0)
3335 WarnNoImageReturn(
"\"%%[%s]\"",property);
3336 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3337 (
double) image->page.width,(
double) image->page.height);
3340 if (LocaleNCompare(
"papersize:",property,10) == 0)
3345 WarnNoImageReturn(
"\"%%[%s]\"",property);
3347 papersize=GetPageGeometry(property+10);
3348 if (papersize != (
const char *) NULL)
3351 page = { 0, 0, 0, 0 };
3353 (void) ParseAbsoluteGeometry(papersize,&page);
3354 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3355 (
double) page.width,(
double) page.height);
3356 papersize=DestroyString(papersize);
3360#if defined(MAGICKCORE_LCMS_DELEGATE)
3361 if (LocaleCompare(
"profile:icc",property) == 0 ||
3362 LocaleCompare(
"profile:icm",property) == 0)
3364#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3365#define cmsUInt32Number DWORD
3374 WarnNoImageReturn(
"\"%%[%s]\"",property);
3375 profile=GetImageProfile(image,property+8);
3376 if (profile == (StringInfo *) NULL)
3378 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3379 (cmsUInt32Number) GetStringInfoLength(profile));
3380 if (icc_profile != (cmsHPROFILE *) NULL)
3382#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3383 string=cmsTakeProductName(icc_profile);
3385 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3386 "en",
"US",value,MagickPathExtent);
3388 (void) cmsCloseProfile(icc_profile);
3392 if (LocaleCompare(
"printsize.x",property) == 0)
3394 WarnNoImageReturn(
"\"%%[%s]\"",property);
3395 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3396 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3397 image->resolution.x)*image->columns);
3400 if (LocaleCompare(
"printsize.y",property) == 0)
3402 WarnNoImageReturn(
"\"%%[%s]\"",property);
3403 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3404 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3405 image->resolution.y)*image->rows);
3408 if (LocaleCompare(
"profiles",property) == 0)
3413 WarnNoImageReturn(
"\"%%[%s]\"",property);
3414 ResetImageProfileIterator(image);
3415 name=GetNextImageProfile(image);
3416 if (name != (
char *) NULL)
3418 (void) CopyMagickString(value,name,MagickPathExtent);
3419 name=GetNextImageProfile(image);
3420 while (name != (
char *) NULL)
3422 ConcatenateMagickString(value,
",",MagickPathExtent);
3423 ConcatenateMagickString(value,name,MagickPathExtent);
3424 name=GetNextImageProfile(image);
3433 if (LocaleCompare(
"quality",property) == 0)
3435 WarnNoImageReturn(
"\"%%[%s]\"",property);
3436 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3444 if (LocaleCompare(
"resolution.x",property) == 0)
3446 WarnNoImageReturn(
"\"%%[%s]\"",property);
3447 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3448 image->resolution.x);
3451 if (LocaleCompare(
"resolution.y",property) == 0)
3453 WarnNoImageReturn(
"\"%%[%s]\"",property);
3454 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3455 image->resolution.y);
3462 if (LocaleCompare(
"scene",property) == 0)
3464 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3465 if (image_info->number_scenes != 0)
3466 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3469 WarnNoImageReturn(
"\"%%[%s]\"",property);
3470 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3475 if (LocaleCompare(
"scenes",property) == 0)
3478 WarnNoImageReturn(
"\"%%[%s]\"",property);
3479 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3480 GetImageListLength(image));
3483 if (LocaleCompare(
"size",property) == 0)
3485 WarnNoImageReturn(
"\"%%[%s]\"",property);
3486 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
3487 MagickPathExtent,value);
3490 if (LocaleCompare(
"skewness",property) == 0)
3496 WarnNoImageReturn(
"\"%%[%s]\"",property);
3497 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3498 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3499 GetMagickPrecision(),skewness);
3502 if (LocaleCompare(
"standard-deviation",property) == 0)
3508 WarnNoImageReturn(
"\"%%[%s]\"",property);
3509 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3510 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3511 GetMagickPrecision(),standard_deviation);
3518 if (LocaleCompare(
"type",property) == 0)
3520 WarnNoImageReturn(
"\"%%[%s]\"",property);
3521 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3522 IdentifyImageType(image,exception));
3529 if (LocaleCompare(
"unique",property) == 0)
3531 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3532 string=image_info->unique;
3535 if (LocaleCompare(
"units",property) == 0)
3537 WarnNoImageReturn(
"\"%%[%s]\"",property);
3538 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3546 if (LocaleCompare(
"version",property) == 0)
3548 string=GetMagickVersion((
size_t *) NULL);
3555 if (LocaleCompare(
"width",property) == 0)
3557 WarnNoImageReturn(
"\"%%[%s]\"",property);
3558 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3559 (image->magick_columns != 0 ? image->magick_columns : 256));
3565 if (
string != (
char *) NULL)
3572 if (image != (Image *) NULL)
3574 (void) SetImageArtifact(image,
"magick-property",value);
3575 return(GetImageArtifact(image,
"magick-property"));
3579 (void) SetImageOption(image_info,
"magick-property",value);
3580 return(GetImageOption(image_info,
"magick-property"));
3583 return((
char *) NULL);
3585#undef WarnNoImageReturn
3609MagickExport
const char *GetNextImageProperty(
const Image *image)
3611 assert(image != (Image *) NULL);
3612 assert(image->signature == MagickCoreSignature);
3613 if (IsEventLogging() != MagickFalse)
3614 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3616 if (image->properties == (
void *) NULL)
3617 return((
const char *) NULL);
3618 return((
const char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3675MagickExport
char *InterpretImageProperties(ImageInfo *image_info,Image *image,
3676 const char *embed_text,ExceptionInfo *exception)
3678#define ExtendInterpretText(string_length) \
3680 size_t length=(string_length); \
3681 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3684 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3685 MagickPathExtent,sizeof(*interpret_text)); \
3686 if (interpret_text == (char *) NULL) \
3688 if (property_image != image) \
3689 property_image=DestroyImage(property_image); \
3690 if (property_info != image_info) \
3691 property_info=DestroyImageInfo(property_info); \
3692 return((char *) NULL); \
3694 q=interpret_text+strlen(interpret_text); \
3698#define AppendKeyValue2Text(key,value)\
3700 size_t length=strlen(key)+strlen(value)+2; \
3701 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3704 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3705 MagickPathExtent,sizeof(*interpret_text)); \
3706 if (interpret_text == (char *) NULL) \
3708 if (property_image != image) \
3709 property_image=DestroyImage(property_image); \
3710 if (property_info != image_info) \
3711 property_info=DestroyImageInfo(property_info); \
3712 return((char *) NULL); \
3714 q=interpret_text+strlen(interpret_text); \
3716 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3719#define AppendString2Text(string) \
3721 size_t length = strlen((string)); \
3722 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3725 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3726 MagickPathExtent,sizeof(*interpret_text)); \
3727 if (interpret_text == (char *) NULL) \
3729 if (property_image != image) \
3730 property_image=DestroyImage(property_image); \
3731 if (property_info != image_info) \
3732 property_info=DestroyImageInfo(property_info); \
3733 return((char *) NULL); \
3735 q=interpret_text+strlen(interpret_text); \
3737 (void) CopyMagickString(q,(string),extent); \
3738 q+=(ptrdiff_t) length; \
3760 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
3761 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3763 if ((image_info != (ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
3764 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3765 image_info->filename);
3767 if (IsEventLogging() != MagickFalse)
3768 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no image");
3769 if (embed_text == (
const char *) NULL)
3770 return(ConstantString(
""));
3772 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3775 return(ConstantString(
""));
3776 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3781 interpret_text=FileToString(p,~0UL,exception);
3782 if (interpret_text != (
char *) NULL)
3783 return(interpret_text);
3788 if (image_info != (ImageInfo *) NULL)
3789 property_info=image_info;
3791 property_info=CloneImageInfo(image_info);
3792 if ((image != (Image *) NULL) && (image->columns != 0) && (image->rows != 0))
3793 property_image=image;
3796 property_image=AcquireImage(image_info,exception);
3797 (void) SetImageExtent(property_image,1,1,exception);
3798 (void) SetImageBackgroundColor(property_image,exception);
3800 interpret_text=AcquireString(embed_text);
3801 extent=MagickPathExtent;
3803 for (q=interpret_text; *p!=
'\0'; number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
3809 ExtendInterpretText(MagickPathExtent);
3852 if (LocaleNCompare(
"<",p,4) == 0)
3858 if (LocaleNCompare(
">",p,4) == 0)
3864 if (LocaleNCompare(
"&",p,5) == 0)
3885 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3900 if (number != MagickFalse)
3909 string=GetMagickPropertyLetter(property_info,image,*p,exception);
3910 if (
string != (
char *) NULL)
3912 AppendString2Text(
string);
3913 (void) DeleteImageArtifact(property_image,
"magick-property");
3914 (void) DeleteImageOption(property_info,
"magick-property");
3917 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3918 "UnknownImageProperty",
"\"%%%c\"",*p);
3923 pattern[2*MagickPathExtent] =
"\0";
3942 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3943 "UnknownImageProperty",
"\"%%[]\"");
3946 for (len=0; len < (MagickPathExtent-1L) && (*p !=
'\0'); )
3948 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3953 pattern[len++]=(*p++);
3954 pattern[len++]=(*p++);
3963 pattern[len++]=(*p++);
3978 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3979 "UnbalancedBraces",
"\"%%[%s\"",pattern);
3980 interpret_text=DestroyString(interpret_text);
3981 if (property_image != image)
3982 property_image=DestroyImage(property_image);
3983 if (property_info != image_info)
3984 property_info=DestroyImageInfo(property_info);
3985 return((
char *) NULL);
3990 if (LocaleNCompare(
"fx:",pattern,3) == 0)
4004 fx_info=AcquireFxInfo(property_image,pattern+3,exception);
4005 if (fx_info == (FxInfo *) NULL)
4007 status=FxEvaluateChannelExpression(fx_info,CompositePixelChannel,0,0,
4009 fx_info=DestroyFxInfo(fx_info);
4010 if (status != MagickFalse)
4013 result[MagickPathExtent];
4015 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
4016 GetMagickPrecision(),(
double) value);
4017 AppendString2Text(result);
4021 if (LocaleNCompare(
"hex:",pattern,4) == 0)
4038 GetPixelInfo(property_image,&pixel);
4039 fx_info=AcquireFxInfo(property_image,pattern+4,exception);
4040 if (fx_info == (FxInfo *) NULL)
4042 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4044 pixel.red=(double) QuantumRange*value;
4045 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4046 GreenPixelChannel,0,0,&value,exception);
4047 pixel.green=(double) QuantumRange*value;
4048 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4049 BluePixelChannel,0,0,&value,exception);
4050 pixel.blue=(double) QuantumRange*value;
4051 if (property_image->colorspace == CMYKColorspace)
4053 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4054 BlackPixelChannel,0,0,&value,exception);
4055 pixel.black=(double) QuantumRange*value;
4057 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4058 AlphaPixelChannel,0,0,&value,exception);
4059 pixel.alpha=(double) QuantumRange*value;
4060 fx_info=DestroyFxInfo(fx_info);
4061 if (status != MagickFalse)
4064 hex[MagickPathExtent];
4066 GetColorTuple(&pixel,MagickTrue,hex);
4067 AppendString2Text(hex+1);
4071 if (LocaleNCompare(
"pixel:",pattern,6) == 0)
4088 GetPixelInfo(property_image,&pixel);
4089 fx_info=AcquireFxInfo(property_image,pattern+6,exception);
4090 if (fx_info == (FxInfo *) NULL)
4092 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4094 pixel.red=(double) QuantumRange*value;
4095 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4096 GreenPixelChannel,0,0,&value,exception);
4097 pixel.green=(double) QuantumRange*value;
4098 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4099 BluePixelChannel,0,0,&value,exception);
4100 pixel.blue=(double) QuantumRange*value;
4101 if (property_image->colorspace == CMYKColorspace)
4103 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4104 BlackPixelChannel,0,0,&value,exception);
4105 pixel.black=(double) QuantumRange*value;
4107 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4108 AlphaPixelChannel,0,0,&value,exception);
4109 pixel.alpha=(double) QuantumRange*value;
4110 fx_info=DestroyFxInfo(fx_info);
4111 if (status != MagickFalse)
4114 name[MagickPathExtent];
4116 GetColorTuple(&pixel,MagickFalse,name);
4117 string=GetImageArtifact(property_image,
"pixel:compliance");
4118 if (
string != (
char *) NULL)
4120 ComplianceType compliance=(ComplianceType) ParseCommandOption(
4121 MagickComplianceOptions,MagickFalse,
string);
4122 (void) QueryColorname(property_image,&pixel,compliance,name,
4125 AppendString2Text(name);
4129 if (LocaleNCompare(
"option:",pattern,7) == 0)
4134 if (IsGlob(pattern+7) != MagickFalse)
4136 ResetImageOptionIterator(property_info);
4137 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4138 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4140 string=GetImageOption(property_info,key);
4141 if (
string != (
const char *) NULL)
4142 AppendKeyValue2Text(key,
string);
4147 string=GetImageOption(property_info,pattern+7);
4148 if (
string == (
char *) NULL)
4149 goto PropertyLookupFailure;
4150 AppendString2Text(
string);
4153 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4158 if (IsGlob(pattern+9) != MagickFalse)
4160 ResetImageArtifactIterator(property_image);
4161 while ((key=GetNextImageArtifact(property_image)) != (
const char *) NULL)
4162 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4164 string=GetImageArtifact(property_image,key);
4165 if (
string != (
const char *) NULL)
4166 AppendKeyValue2Text(key,
string);
4171 string=GetImageArtifact(property_image,pattern+9);
4172 if (
string == (
char *) NULL)
4173 goto PropertyLookupFailure;
4174 AppendString2Text(
string);
4177 if (LocaleNCompare(
"property:",pattern,9) == 0)
4182 if (IsGlob(pattern+9) != MagickFalse)
4184 ResetImagePropertyIterator(property_image);
4185 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4186 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4188 string=GetImageProperty(property_image,key,exception);
4189 if (
string != (
const char *) NULL)
4190 AppendKeyValue2Text(key,
string);
4195 string=GetImageProperty(property_image,pattern+9,exception);
4196 if (
string == (
char *) NULL)
4197 goto PropertyLookupFailure;
4198 AppendString2Text(
string);
4206 string=GetImageProperty(property_image,pattern,exception);
4207 if (
string != (
const char *) NULL)
4209 AppendString2Text(
string);
4210 (void) DeleteImageArtifact(property_image,
"magick-property");
4211 (void) DeleteImageOption(property_info,
"magick-property");
4214 if (IsGlob(pattern) != MagickFalse)
4220 ResetImagePropertyIterator(property_image);
4221 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4222 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4224 string=GetImageProperty(property_image,key,exception);
4225 if (
string != (
const char *) NULL)
4226 AppendKeyValue2Text(key,
string);
4236 string=GetMagickProperty(property_info,property_image,pattern,exception);
4237 if (
string != (
const char *) NULL)
4239 AppendString2Text(
string);
4246 string=GetImageArtifact(property_image,pattern);
4247 if (
string != (
char *) NULL)
4249 AppendString2Text(
string);
4255 string=GetImageOption(property_info,pattern);
4256 if (
string != (
char *) NULL)
4258 AppendString2Text(
string);
4261PropertyLookupFailure:
4272 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4273 "UnknownImageProperty",
"\"%%[%s]\"",pattern);
4277 if (property_image != image)
4278 property_image=DestroyImage(property_image);
4279 if (property_info != image_info)
4280 property_info=DestroyImageInfo(property_info);
4281 return(interpret_text);
4312MagickExport
char *RemoveImageProperty(Image *image,
const char *property)
4317 assert(image != (Image *) NULL);
4318 assert(image->signature == MagickCoreSignature);
4319 if (IsEventLogging() != MagickFalse)
4320 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4321 if (image->properties == (
void *) NULL)
4322 return((
char *) NULL);
4323 value=(
char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
4352MagickExport
void ResetImagePropertyIterator(
const Image *image)
4354 assert(image != (Image *) NULL);
4355 assert(image->signature == MagickCoreSignature);
4356 if (IsEventLogging() != MagickFalse)
4357 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4358 if (image->properties == (
void *) NULL)
4360 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
4396MagickExport MagickBooleanType SetImageProperty(Image *image,
4397 const char *property,
const char *value,ExceptionInfo *exception)
4408 assert(image != (Image *) NULL);
4409 assert(image->signature == MagickCoreSignature);
4410 if (IsEventLogging() != MagickFalse)
4411 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4412 if (image->properties == (
void *) NULL)
4413 image->properties=NewSplayTree(CompareSplayTreeString,
4414 RelinquishMagickMemory,RelinquishMagickMemory);
4415 if (value == (
const char *) NULL)
4416 return(DeleteImageProperty(image,property));
4417 if (strlen(property) <= 1)
4422 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4423 "SetReadOnlyProperty",
"`%s'",property);
4424 return(MagickFalse);
4426 property_length=strlen(property);
4427 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4428 (*(property+(property_length-1)) ==
'*'))
4430 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4431 "SetReadOnlyProperty",
"`%s'",property);
4432 return(MagickFalse);
4446 if (LocaleNCompare(
"8bim:",property,5) == 0)
4448 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4449 "SetReadOnlyProperty",
"`%s'",property);
4450 return(MagickFalse);
4458 if (LocaleCompare(
"background",property) == 0)
4460 (void) QueryColorCompliance(value,AllCompliance,
4461 &image->background_color,exception);
4470 if (LocaleCompare(
"channels",property) == 0)
4472 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4473 "SetReadOnlyProperty",
"`%s'",property);
4474 return(MagickFalse);
4476 if (LocaleCompare(
"colorspace",property) == 0)
4481 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4484 return(MagickFalse);
4485 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4487 if (LocaleCompare(
"compose",property) == 0)
4492 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4494 return(MagickFalse);
4495 image->compose=(CompositeOperator) compose;
4498 if (LocaleCompare(
"compress",property) == 0)
4503 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4505 if (compression < 0)
4506 return(MagickFalse);
4507 image->compression=(CompressionType) compression;
4515 if (LocaleCompare(
"delay",property) == 0)
4520 flags=ParseGeometry(value,&geometry_info);
4521 if ((flags & GreaterValue) != 0)
4523 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4524 image->delay=(size_t) floor(geometry_info.rho+0.5);
4527 if ((flags & LessValue) != 0)
4529 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4530 image->delay=(size_t) CastDoubleToSsizeT(floor(
4531 geometry_info.sigma+0.5));
4534 image->delay=(size_t) floor(geometry_info.rho+0.5);
4535 if ((flags & SigmaValue) != 0)
4536 image->ticks_per_second=CastDoubleToSsizeT(floor(
4537 geometry_info.sigma+0.5));
4540 if (LocaleCompare(
"delay_units",property) == 0)
4542 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4543 "SetReadOnlyProperty",
"`%s'",property);
4544 return(MagickFalse);
4546 if (LocaleCompare(
"density",property) == 0)
4551 flags=ParseGeometry(value,&geometry_info);
4552 if ((flags & RhoValue) != 0)
4553 image->resolution.x=geometry_info.rho;
4554 image->resolution.y=image->resolution.x;
4555 if ((flags & SigmaValue) != 0)
4556 image->resolution.y=geometry_info.sigma;
4559 if (LocaleCompare(
"depth",property) == 0)
4561 image->depth=StringToUnsignedLong(value);
4564 if (LocaleCompare(
"dispose",property) == 0)
4569 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4571 return(MagickFalse);
4572 image->dispose=(DisposeType) dispose;
4582 if (LocaleNCompare(
"exif:",property,5) == 0)
4584 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4585 "SetReadOnlyProperty",
"`%s'",property);
4586 return(MagickFalse);
4593 if (LocaleNCompare(
"fx:",property,3) == 0)
4595 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4596 "SetReadOnlyProperty",
"`%s'",property);
4597 return(MagickFalse);
4605 if (LocaleCompare(
"gamma",property) == 0)
4607 image->gamma=StringToDouble(value,(
char **) NULL);
4610 if (LocaleCompare(
"gravity",property) == 0)
4615 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4617 return(MagickFalse);
4618 image->gravity=(GravityType) gravity;
4626 if (LocaleCompare(
"height",property) == 0)
4628 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4629 "SetReadOnlyProperty",
"`%s'",property);
4630 return(MagickFalse);
4637 if (LocaleCompare(
"intensity",property) == 0)
4642 intensity=ParseCommandOption(MagickIntensityOptions,MagickFalse,
4645 return(MagickFalse);
4646 image->intensity=(PixelIntensityMethod) intensity;
4649 if (LocaleCompare(
"intent",property) == 0)
4654 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4656 if (rendering_intent < 0)
4657 return(MagickFalse);
4658 image->rendering_intent=(RenderingIntent) rendering_intent;
4661 if (LocaleCompare(
"interpolate",property) == 0)
4666 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4668 if (interpolate < 0)
4669 return(MagickFalse);
4670 image->interpolate=(PixelInterpolateMethod) interpolate;
4675 if (LocaleNCompare(
"iptc:",property,5) == 0)
4677 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4678 "SetReadOnlyProperty",
"`%s'",property);
4679 return(MagickFalse);
4686 if (LocaleCompare(
"kurtosis",property) == 0)
4688 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4689 "SetReadOnlyProperty",
"`%s'",property);
4690 return(MagickFalse);
4696 if (LocaleCompare(
"loop",property) == 0)
4698 image->iterations=StringToUnsignedLong(value);
4705 if ((LocaleCompare(
"magick",property) == 0) ||
4706 (LocaleCompare(
"max",property) == 0) ||
4707 (LocaleCompare(
"mean",property) == 0) ||
4708 (LocaleCompare(
"min",property) == 0) ||
4709 (LocaleCompare(
"min",property) == 0))
4711 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4712 "SetReadOnlyProperty",
"`%s'",property);
4713 return(MagickFalse);
4718 if (LocaleCompare(
"opaque",property) == 0)
4720 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4721 "SetReadOnlyProperty",
"`%s'",property);
4722 return(MagickFalse);
4728 if (LocaleCompare(
"page",property) == 0)
4733 geometry=GetPageGeometry(value);
4734 flags=ParseAbsoluteGeometry(geometry,&image->page);
4735 geometry=DestroyString(geometry);
4740 if (LocaleNCompare(
"pixel:",property,6) == 0)
4742 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4743 "SetReadOnlyProperty",
"`%s'",property);
4744 return(MagickFalse);
4752 if (LocaleCompare(
"rendering-intent",property) == 0)
4757 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4759 if (rendering_intent < 0)
4760 return(MagickFalse);
4761 image->rendering_intent=(RenderingIntent) rendering_intent;
4768 if ((LocaleCompare(
"size",property) == 0) ||
4769 (LocaleCompare(
"skewness",property) == 0) ||
4770 (LocaleCompare(
"scenes",property) == 0) ||
4771 (LocaleCompare(
"standard-deviation",property) == 0))
4773 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4774 "SetReadOnlyProperty",
"`%s'",property);
4775 return(MagickFalse);
4781 if (LocaleCompare(
"tile-offset",property) == 0)
4786 geometry=GetPageGeometry(value);
4787 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4788 geometry=DestroyString(geometry);
4791 if (LocaleCompare(
"type",property) == 0)
4796 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4798 return(MagickFalse);
4799 image->type=(ImageType) type;
4807 if (LocaleCompare(
"units",property) == 0)
4812 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4814 return(MagickFalse);
4815 image->units=(ResolutionType) units;
4823 if (LocaleCompare(
"version",property) == 0)
4825 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4826 "SetReadOnlyProperty",
"`%s'",property);
4827 return(MagickFalse);
4834 if (LocaleCompare(
"width",property) == 0)
4836 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4837 "SetReadOnlyProperty",
"`%s'",property);
4838 return(MagickFalse);
4847 if (LocaleNCompare(
"xmp:",property,4) == 0)
4849 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4850 "SetReadOnlyProperty",
"`%s'",property);
4851 return(MagickFalse);
4858 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4859 ConstantString(property),ConstantString(value));