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)
1892 xmp_namespace_length;
1894 node=GetXMLTreeChild(description,(
const char *) NULL);
1895 while (node != (XMLTreeInfo *) NULL)
1897 child=GetXMLTreeChild(node,(
const char *) NULL);
1898 content=GetXMLTreeContent(node);
1899 if ((child == (XMLTreeInfo *) NULL) &&
1900 (SkipXMPValue(content) == MagickFalse))
1902 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1903 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1904 xmp_namespace_length=strlen(xmp_namespace);
1905 if ((xmp_namespace_length <= 2) ||
1906 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1907 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1908 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1909 ConstantString(xmp_namespace),ConstantString(content));
1910 xmp_namespace=DestroyString(xmp_namespace);
1912 while (child != (XMLTreeInfo *) NULL)
1914 content=GetXMLTreeContent(child);
1915 if (SkipXMPValue(content) == MagickFalse)
1917 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1918 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1919 xmp_namespace_length=strlen(xmp_namespace);
1920 if ((xmp_namespace_length <= 2) ||
1921 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1922 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1923 (void) AddValueToSplayTree((SplayTreeInfo *)
1924 image->properties,ConstantString(xmp_namespace),
1925 ConstantString(content));
1926 xmp_namespace=DestroyString(xmp_namespace);
1928 child=GetXMLTreeSibling(child);
1930 node=GetXMLTreeSibling(node);
1932 description=GetNextXMLTreeTag(description);
1935 xmp=DestroyXMLTree(xmp);
1938static char *TracePSClippath(
const unsigned char *blob,
size_t length)
1961 path=AcquireString((
char *) NULL);
1962 if (path == (
char *) NULL)
1963 return((
char *) NULL);
1964 message=AcquireString((
char *) NULL);
1965 (void) FormatLocaleString(message,MagickPathExtent,
"/ClipImage\n");
1966 (void) ConcatenateString(&path,message);
1967 (void) FormatLocaleString(message,MagickPathExtent,
"{\n");
1968 (void) ConcatenateString(&path,message);
1969 (void) FormatLocaleString(message,MagickPathExtent,
1970 " /c {curveto} bind def\n");
1971 (void) ConcatenateString(&path,message);
1972 (void) FormatLocaleString(message,MagickPathExtent,
1973 " /l {lineto} bind def\n");
1974 (void) ConcatenateString(&path,message);
1975 (void) FormatLocaleString(message,MagickPathExtent,
1976 " /m {moveto} bind def\n");
1977 (void) ConcatenateString(&path,message);
1978 (void) FormatLocaleString(message,MagickPathExtent,
1979 " /v {currentpoint 6 2 roll curveto} bind def\n");
1980 (void) ConcatenateString(&path,message);
1981 (void) FormatLocaleString(message,MagickPathExtent,
1982 " /y {2 copy curveto} bind def\n");
1983 (void) ConcatenateString(&path,message);
1984 (void) FormatLocaleString(message,MagickPathExtent,
1985 " /z {closepath} bind def\n");
1986 (void) ConcatenateString(&path,message);
1987 (void) FormatLocaleString(message,MagickPathExtent,
" newpath\n");
1988 (void) ConcatenateString(&path,message);
1993 (void) memset(point,0,
sizeof(point));
1994 (void) memset(first,0,
sizeof(first));
1995 (void) memset(last,0,
sizeof(last));
1997 in_subpath=MagickFalse;
2000 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2006 if (knot_count != 0)
2009 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2015 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2017 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2025 if (knot_count == 0)
2031 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2037 for (i=0; i < 3; i++)
2039 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2040 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2041 point[i].x=(double) x/4096.0/4096.0;
2042 point[i].y=1.0-(double) y/4096.0/4096.0;
2044 if (in_subpath == MagickFalse)
2046 (void) FormatLocaleString(message,MagickPathExtent,
" %g %g m\n",
2047 point[1].x,point[1].y);
2048 for (i=0; i < 3; i++)
2060 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2061 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2062 (void) FormatLocaleString(message,MagickPathExtent,
2063 " %g %g l\n",point[1].x,point[1].y);
2065 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2066 (void) FormatLocaleString(message,MagickPathExtent,
2067 " %g %g %g %g v\n",point[0].x,point[0].y,
2068 point[1].x,point[1].y);
2070 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2071 (void) FormatLocaleString(message,MagickPathExtent,
2072 " %g %g %g %g y\n",last[2].x,last[2].y,
2073 point[1].x,point[1].y);
2075 (
void) FormatLocaleString(message,MagickPathExtent,
2076 " %g %g %g %g %g %g c\n",last[2].x,
2077 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2078 for (i=0; i < 3; i++)
2081 (void) ConcatenateString(&path,message);
2082 in_subpath=MagickTrue;
2087 if (knot_count == 0)
2093 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2094 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2095 (void) FormatLocaleString(message,MagickPathExtent,
2096 " %g %g l z\n",first[1].x,first[1].y);
2098 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2099 (void) FormatLocaleString(message,MagickPathExtent,
2100 " %g %g %g %g v z\n",first[0].x,first[0].y,
2101 first[1].x,first[1].y);
2103 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2104 (void) FormatLocaleString(message,MagickPathExtent,
2105 " %g %g %g %g y z\n",last[2].x,last[2].y,
2106 first[1].x,first[1].y);
2108 (
void) FormatLocaleString(message,MagickPathExtent,
2109 " %g %g %g %g %g %g c z\n",last[2].x,
2110 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2111 (void) ConcatenateString(&path,message);
2112 in_subpath=MagickFalse;
2122 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2130 (void) FormatLocaleString(message,MagickPathExtent,
" eoclip\n");
2131 (void) ConcatenateString(&path,message);
2132 (void) FormatLocaleString(message,MagickPathExtent,
"} bind def");
2133 (void) ConcatenateString(&path,message);
2134 message=DestroyString(message);
2138static inline void TraceBezierCurve(
char *message,PointInfo *last,
2145 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2146 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2147 (void) FormatLocaleString(message,MagickPathExtent,
2148 "L %g %g\n",point[1].x,point[1].y);
2150 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2151 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2154static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2155 const size_t columns,
const size_t rows)
2178 path=AcquireString((
char *) NULL);
2179 if (path == (
char *) NULL)
2180 return((
char *) NULL);
2181 message=AcquireString((
char *) NULL);
2182 (void) FormatLocaleString(message,MagickPathExtent,(
2183 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2184 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2185 " width=\"%.20g\" height=\"%.20g\">\n"
2187 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2188 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(
double) columns,
2190 (void) ConcatenateString(&path,message);
2191 (void) memset(point,0,
sizeof(point));
2192 (void) memset(first,0,
sizeof(first));
2193 (void) memset(last,0,
sizeof(last));
2195 in_subpath=MagickFalse;
2198 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2204 if (knot_count != 0)
2207 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2213 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2215 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2223 if (knot_count == 0)
2229 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2235 for (i=0; i < 3; i++)
2237 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2238 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2239 point[i].x=(double) x*columns/4096.0/4096.0;
2240 point[i].y=(double) y*rows/4096.0/4096.0;
2242 if (in_subpath == MagickFalse)
2244 (void) FormatLocaleString(message,MagickPathExtent,
"M %g %g\n",
2245 point[1].x,point[1].y);
2246 for (i=0; i < 3; i++)
2254 TraceBezierCurve(message,last,point);
2255 for (i=0; i < 3; i++)
2258 (void) ConcatenateString(&path,message);
2259 in_subpath=MagickTrue;
2264 if (knot_count == 0)
2266 TraceBezierCurve(message,last,first);
2267 (void) ConcatenateString(&path,message);
2268 in_subpath=MagickFalse;
2278 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2286 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2287 message=DestroyString(message);
2291MagickExport
const char *GetImageProperty(
const Image *image,
2292 const char *property,ExceptionInfo *exception)
2295 read_from_properties;
2303 assert(image != (Image *) NULL);
2304 assert(image->signature == MagickCoreSignature);
2305 if (IsEventLogging() != MagickFalse)
2306 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2307 if ((property == (
const char *) NULL) || (*property ==
'\0'))
2308 return((
const char *) NULL);
2309 read_from_properties=MagickTrue;
2310 property_length=strlen(property);
2311 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
2312 (*(property+(property_length-1)) ==
'*'))
2313 read_from_properties=MagickFalse;
2314 if (read_from_properties != MagickFalse)
2316 p=(
const char *) NULL;
2317 if (image->properties != (
void *) NULL)
2319 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2320 image->properties,property);
2321 if (p != (
const char *) NULL)
2324 if (strchr(property,
':') == (
char *) NULL)
2331 if (LocaleNCompare(
"8bim:",property,5) == 0)
2333 Get8BIMProperty(image,property,exception);
2341 if (LocaleNCompare(
"exif:",property,5) == 0)
2343 GetEXIFProperty(image,property,exception);
2351 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2352 (LocaleNCompare(
"icm:",property,4) == 0))
2354#if defined(MAGICKCORE_LCMS_DELEGATE)
2355 GetICCProperty(image,exception);
2359 if (LocaleNCompare(
"iptc:",property,5) == 0)
2361 GetIPTCProperty(image,property,exception);
2369 if (LocaleNCompare(
"xmp:",property,4) == 0)
2371 GetXMPProperty(image,property);
2379 if ((image->properties != (
void *) NULL) &&
2380 (read_from_properties != MagickFalse))
2382 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2383 image->properties,property);
2386 return((
const char *) NULL);
2480static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2481 Image *image,
const char letter,ExceptionInfo *exception)
2483#define WarnNoImageReturn(format,arg) \
2484 if (image == (Image *) NULL ) { \
2485 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2486 "NoImageForProperty",format,arg); \
2487 return((const char *) NULL); \
2489#define WarnNoImageInfoReturn(format,arg) \
2490 if (image_info == (ImageInfo *) NULL ) { \
2491 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2492 "NoImageInfoForProperty",format,arg); \
2493 return((const char *) NULL); \
2497 value[MagickPathExtent];
2502 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2503 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2505 if ((image_info != (ImageInfo *) NULL) &&
2506 (IsEventLogging() != MagickFalse))
2507 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2509 string=(
char *) NULL;
2517 WarnNoImageReturn(
"\"%%%c\"",letter);
2518 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
2520 if (image->extent == 0)
2521 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
2522 MagickPathExtent,value);
2527 WarnNoImageReturn(
"\"%%%c\"",letter);
2528 string=GetImageProperty(image,
"comment",exception);
2529 if (
string == (
const char *) NULL )
2535 WarnNoImageReturn(
"\"%%%c\"",letter);
2536 GetPathComponent(image->magick_filename,HeadPath,value);
2543 WarnNoImageReturn(
"\"%%%c\"",letter);
2544 GetPathComponent(image->magick_filename,ExtensionPath,value);
2551 WarnNoImageReturn(
"\"%%%c\"",letter);
2552 GetPathComponent(image->magick_filename,TailPath,value);
2559 WarnNoImageReturn(
"\"%%%c\"",letter);
2560 (void) FormatLocaleString(value,MagickPathExtent,
2561 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(
double)
2562 image->page.height,(
double) image->page.x,(
double) image->page.y);
2567 WarnNoImageReturn(
"\"%%%c\"",letter);
2568 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2569 (image->rows != 0 ? image->rows : image->magick_rows));
2574 WarnNoImageReturn(
"\"%%%c\"",letter);
2575 string=image->filename;
2583 WarnNoImageReturn(
"\"%%%c\"",letter);
2584 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2585 GetNumberColors(image,(FILE *) NULL,exception));
2590 WarnNoImageReturn(
"\"%%%c\"",letter);
2591 string=GetImageProperty(image,
"label",exception);
2592 if (
string == (
const char *) NULL)
2598 WarnNoImageReturn(
"\"%%%c\"",letter);
2599 string=image->magick;
2604 if ( image != (Image *) NULL )
2605 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2606 GetImageListLength(image));
2613 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2614 string=image_info->filename;
2619 WarnNoImageReturn(
"\"%%%c\"",letter);
2620 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2621 GetImageIndexInList(image));
2626 WarnNoImageReturn(
"\"%%%c\"",letter);
2627 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2628 MAGICKCORE_QUANTUM_DEPTH);
2636 WarnNoImageReturn(
"\"%%%c\"",letter);
2637 colorspace=image->colorspace;
2638 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
2639 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2640 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2641 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2648 if (image_info->number_scenes != 0)
2649 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2651 else if (image != (Image *) NULL)
2652 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2657 WarnNoImageReturn(
"\"%%%c\"",letter);
2658 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2665 WarnNoImageReturn(
"\"%%%c\"",letter);
2666 GetPathComponent(image->magick_filename,BasePath,value);
2673 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2674 string=image_info->unique;
2679 WarnNoImageReturn(
"\"%%%c\"",letter);
2680 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2681 (image->columns != 0 ? image->columns : image->magick_columns));
2686 WarnNoImageReturn(
"\"%%%c\"",letter);
2687 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2688 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
2689 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2695 WarnNoImageReturn(
"\"%%%c\"",letter);
2696 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2697 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
2698 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2704 WarnNoImageReturn(
"\"%%%c\"",letter);
2705 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2711 WarnNoImageReturn(
"\"%%%c\"",letter);
2712 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2713 image->alpha_trait);
2718 WarnNoImageReturn(
"\"%%%c\"",letter);
2719 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2721 if (image->extent == 0)
2722 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2723 GetBlobSize(image));
2728 WarnNoImageReturn(
"\"%%%c\"",letter);
2729 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2730 image->compression);
2735 WarnNoImageReturn(
"\"%%%c\"",letter);
2736 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2742 WarnNoImageReturn(
"\"%%%c\"",letter);
2743 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2744 image->magick_columns,(
double) image->magick_rows);
2749 WarnNoImageReturn(
"\"%%%c\"",letter);
2750 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2751 image->page.height);
2756 WarnNoImageReturn(
"\"%%%c\"",letter);
2757 string=image->magick_filename;
2762 if ((image != (Image *) NULL) && (image->next == (Image *) NULL))
2763 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2764 GetImageListLength(image));
2771 WarnNoImageReturn(
"\"%%%c\"",letter);
2772 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
2773 image->page.x,(
long) image->page.y);
2778 WarnNoImageReturn(
"\"%%%c\"",letter);
2779 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2780 image->page.width,(
double) image->page.height);
2785 WarnNoImageReturn(
"\"%%%c\"",letter);
2786 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2787 (image->quality == 0 ? 92 : image->quality));
2792 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2794 if (image_info->number_scenes == 0)
2795 string=
"2147483647";
2796 else if ( image != (Image *) NULL )
2797 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2798 image_info->scene+image_info->number_scenes);
2802 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2803 (image_info->number_scenes == 0 ? 2147483647 :
2804 image_info->number_scenes));
2810 WarnNoImageReturn(
"\"%%%c\"",letter);
2811 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2817 WarnNoImageReturn(
"\"%%%c\"",letter);
2818 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2824 WarnNoImageReturn(
"\"%%%c\"",letter);
2825 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2831 WarnNoImageReturn(
"\"%%%c\"",letter);
2832 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2838 WarnNoImageReturn(
"\"%%%c\"",letter);
2839 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2853 WarnNoImageReturn(
"\"%%%c\"",letter);
2854 page=GetImageBoundingBox(image,exception);
2855 (void) FormatLocaleString(value,MagickPathExtent,
2856 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(
double) page.height,
2857 (
double) page.x,(
double)page.y);
2865 WarnNoImageReturn(
"\"%%%c\"",letter);
2866 if ((image->columns != 0) && (image->rows != 0))
2867 (void) SignatureImage(image,exception);
2868 string=GetImageProperty(image,
"signature",exception);
2872 if (
string != (
char *) NULL)
2879 if (image != (Image *) NULL)
2881 (void) SetImageArtifact(image,
"magick-property",value);
2882 return(GetImageArtifact(image,
"magick-property"));
2886 (void) SetImageOption(image_info,
"magick-property",value);
2887 return(GetImageOption(image_info,
"magick-property"));
2890 return((
char *) NULL);
2893MagickExport
const char *GetMagickProperty(ImageInfo *image_info,
2894 Image *image,
const char *property,ExceptionInfo *exception)
2897 value[MagickPathExtent];
2902 assert(property != (
const char *) NULL);
2903 assert(property[0] !=
'\0');
2904 assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2905 if (property[1] ==
'\0')
2906 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2907 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2908 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2910 if ((image_info != (ImageInfo *) NULL) &&
2911 (IsEventLogging() != MagickFalse))
2912 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2914 string=(
char *) NULL;
2919 if (LocaleCompare(
"basename",property) == 0)
2921 WarnNoImageReturn(
"\"%%[%s]\"",property);
2922 GetPathComponent(image->magick_filename,BasePath,value);
2927 if (LocaleCompare(
"bit-depth",property) == 0)
2929 WarnNoImageReturn(
"\"%%[%s]\"",property);
2930 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2931 GetImageDepth(image,exception));
2934 if (LocaleCompare(
"bounding-box",property) == 0)
2939 WarnNoImageReturn(
"\"%%[%s]\"",property);
2940 geometry=GetImageBoundingBox(image,exception);
2941 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g",
2942 (
double) geometry.x,(
double) geometry.y,
2943 (
double) geometry.x+geometry.width,
2944 (
double) geometry.y+geometry.height);
2951 if (LocaleCompare(
"channels",property) == 0)
2953 WarnNoImageReturn(
"\"%%[%s]\"",property);
2954 (void) FormatLocaleString(value,MagickPathExtent,
"%s%s %g.%g",
2955 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2956 image->colorspace),image->alpha_trait != UndefinedPixelTrait ?
2957 "a" :
" ",(
double) image->number_channels,(
double)
2958 image->number_meta_channels);
2962 if (LocaleCompare(
"colors",property) == 0)
2964 WarnNoImageReturn(
"\"%%[%s]\"",property);
2965 image->colors=GetNumberColors(image,(FILE *) NULL,exception);
2966 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2970 if (LocaleCompare(
"colorspace",property) == 0)
2972 WarnNoImageReturn(
"\"%%[%s]\"",property);
2973 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2977 if (LocaleCompare(
"compose",property) == 0)
2979 WarnNoImageReturn(
"\"%%[%s]\"",property);
2980 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2984 if (LocaleCompare(
"compression",property) == 0)
2986 WarnNoImageReturn(
"\"%%[%s]\"",property);
2987 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2988 image->compression);
2991 if (LocaleCompare(
"convex-hull",property) == 0)
3005 WarnNoImageReturn(
"\"%%[%s]\"",property);
3006 convex_hull=GetImageConvexHull(image,&number_points,exception);
3007 if (convex_hull == (PointInfo *) NULL)
3009 points=AcquireString(
"");
3010 for (n=0; n < (ssize_t) number_points; n++)
3012 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3013 convex_hull[n].x,convex_hull[n].y);
3014 (void) ConcatenateString(&points,value);
3016 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
3017 (void) SetImageProperty(image,
"convex-hull",points,exception);
3018 points=DestroyString(points);
3019 string=GetImageProperty(image,
"convex-hull",exception);
3022 if (LocaleCompare(
"convex-hull:extreme-points",property) == 0)
3037 WarnNoImageReturn(
"\"%%[%s]\"",property);
3038 convex_hull=GetImageConvexHull(image,&number_points,exception);
3039 if (convex_hull == (PointInfo *) NULL)
3041 points=AcquireString(
"");
3042 extreme=convex_hull[0];
3043 for (n=0; n < (ssize_t) number_points; n++)
3045 if (convex_hull[n].y < extreme.y)
3047 extreme=convex_hull[n];
3050 if (convex_hull[n].y != extreme.y)
3052 if (convex_hull[n].x < extreme.x)
3053 extreme=convex_hull[n];
3055 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3056 extreme.x,extreme.y);
3057 (void) ConcatenateString(&points,value);
3058 extreme=convex_hull[0];
3059 for (n=0; n < (ssize_t) number_points; n++)
3061 if (convex_hull[n].x > extreme.x)
3063 extreme=convex_hull[n];
3066 if (convex_hull[n].x != extreme.x)
3068 if (convex_hull[n].y < extreme.y)
3069 extreme=convex_hull[n];
3071 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3072 extreme.x,extreme.y);
3073 (void) ConcatenateString(&points,value);
3074 extreme=convex_hull[0];
3075 for (n=0; n < (ssize_t) number_points; n++)
3077 if (convex_hull[n].y > extreme.y)
3079 extreme=convex_hull[n];
3082 if (convex_hull[n].y != extreme.y)
3084 if (convex_hull[n].x > extreme.x)
3085 extreme=convex_hull[n];
3087 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3088 extreme.x,extreme.y);
3089 (void) ConcatenateString(&points,value);
3090 extreme=convex_hull[0];
3091 for (n=0; n < (ssize_t) number_points; n++)
3093 if (convex_hull[n].x < extreme.x)
3095 extreme=convex_hull[n];
3098 if (convex_hull[n].x != extreme.x)
3100 if (convex_hull[n].y > extreme.y)
3101 extreme=convex_hull[n];
3103 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3104 extreme.x,extreme.y);
3105 (void) ConcatenateString(&points,value);
3106 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
3107 (void) SetImageProperty(image,
"convex-hull:extreme-points",points,
3109 points=DestroyString(points);
3110 string=GetImageProperty(image,
"convex-hull:extreme-points",exception);
3113 if (LocaleCompare(
"copyright",property) == 0)
3115 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
3122 if (LocaleCompare(
"depth",property) == 0)
3124 WarnNoImageReturn(
"\"%%[%s]\"",property);
3125 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3129 if (LocaleCompare(
"directory",property) == 0)
3131 WarnNoImageReturn(
"\"%%[%s]\"",property);
3132 GetPathComponent(image->magick_filename,HeadPath,value);
3141 if (LocaleCompare(
"entropy",property) == 0)
3146 WarnNoImageReturn(
"\"%%[%s]\"",property);
3147 (void) GetImageEntropy(image,&entropy,exception);
3148 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3149 GetMagickPrecision(),entropy);
3152 if (LocaleCompare(
"extension",property) == 0)
3154 WarnNoImageReturn(
"\"%%[%s]\"",property);
3155 GetPathComponent(image->magick_filename,ExtensionPath,value);
3164 if (LocaleCompare(
"gamma",property) == 0)
3166 WarnNoImageReturn(
"\"%%[%s]\"",property);
3167 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3168 GetMagickPrecision(),image->gamma);
3175 if (LocaleCompare(
"height",property) == 0)
3177 WarnNoImageReturn(
"\"%%[%s]\"",property);
3178 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
3179 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3186 if (LocaleCompare(
"input",property) == 0)
3188 WarnNoImageReturn(
"\"%%[%s]\"",property);
3189 string=image->filename;
3192 if (LocaleCompare(
"interlace",property) == 0)
3194 WarnNoImageReturn(
"\"%%[%s]\"",property);
3195 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3203 if (LocaleCompare(
"kurtosis",property) == 0)
3209 WarnNoImageReturn(
"\"%%[%s]\"",property);
3210 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3211 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3212 GetMagickPrecision(),kurtosis);
3219 if (LocaleCompare(
"magick",property) == 0)
3221 WarnNoImageReturn(
"\"%%[%s]\"",property);
3222 string=image->magick;
3225 if ((LocaleCompare(
"maxima",property) == 0) ||
3226 (LocaleCompare(
"max",property) == 0))
3232 WarnNoImageReturn(
"\"%%[%s]\"",property);
3233 (void) GetImageRange(image,&minimum,&maximum,exception);
3234 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3235 GetMagickPrecision(),maximum);
3238 if (LocaleCompare(
"mean",property) == 0)
3244 WarnNoImageReturn(
"\"%%[%s]\"",property);
3245 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3246 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3247 GetMagickPrecision(),mean);
3250 if (LocaleCompare(
"median",property) == 0)
3255 WarnNoImageReturn(
"\"%%[%s]\"",property);
3256 (void) GetImageMedian(image,&median,exception);
3257 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3258 GetMagickPrecision(),median);
3261 if (LocaleCompare(
"mime:type",property) == 0)
3266 magick_info=GetMagickInfo(image->magick,exception);
3267 if ((magick_info != (
const MagickInfo *) NULL) &&
3268 (GetMagickMimeType(magick_info) != (
const char *) NULL))
3269 (void) CopyMagickString(value,GetMagickMimeType(magick_info),
3273 if ((LocaleCompare(
"minima",property) == 0) ||
3274 (LocaleCompare(
"min",property) == 0))
3280 WarnNoImageReturn(
"\"%%[%s]\"",property);
3281 (void) GetImageRange(image,&minimum,&maximum,exception);
3282 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3283 GetMagickPrecision(),minimum);
3286 if (LocaleNCompare(
"minimum-bounding-box",property,20) == 0)
3300 WarnNoImageReturn(
"\"%%[%s]\"",property);
3301 bounding_box=GetImageMinimumBoundingBox(image,&number_points,
3303 if (bounding_box == (PointInfo *) NULL)
3305 points=AcquireString(
"");
3306 for (n=0; n < (ssize_t) number_points; n++)
3308 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3309 bounding_box[n].x,bounding_box[n].y);
3310 (void) ConcatenateString(&points,value);
3312 bounding_box=(PointInfo *) RelinquishMagickMemory(bounding_box);
3313 (void) SetImageProperty(image,
"minimum-bounding-box",points,
3315 points=DestroyString(points);
3316 string=GetImageProperty(image,property,exception);
3323 if (LocaleCompare(
"opaque",property) == 0)
3325 WarnNoImageReturn(
"\"%%[%s]\"",property);
3326 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
3327 IsImageOpaque(image,exception));
3330 if (LocaleCompare(
"orientation",property) == 0)
3332 WarnNoImageReturn(
"\"%%[%s]\"",property);
3333 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3334 image->orientation);
3337 if (LocaleCompare(
"output",property) == 0)
3339 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3340 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
3347 if (LocaleCompare(
"page",property) == 0)
3349 WarnNoImageReturn(
"\"%%[%s]\"",property);
3350 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3351 (
double) image->page.width,(
double) image->page.height);
3354 if (LocaleNCompare(
"papersize:",property,10) == 0)
3359 WarnNoImageReturn(
"\"%%[%s]\"",property);
3361 papersize=GetPageGeometry(property+10);
3362 if (papersize != (
const char *) NULL)
3365 page = { 0, 0, 0, 0 };
3367 (void) ParseAbsoluteGeometry(papersize,&page);
3368 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3369 (
double) page.width,(
double) page.height);
3370 papersize=DestroyString(papersize);
3374#if defined(MAGICKCORE_LCMS_DELEGATE)
3375 if (LocaleCompare(
"profile:icc",property) == 0 ||
3376 LocaleCompare(
"profile:icm",property) == 0)
3378#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3379#define cmsUInt32Number DWORD
3388 WarnNoImageReturn(
"\"%%[%s]\"",property);
3389 profile=GetImageProfile(image,property+8);
3390 if (profile == (StringInfo *) NULL)
3392 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3393 (cmsUInt32Number) GetStringInfoLength(profile));
3394 if (icc_profile != (cmsHPROFILE *) NULL)
3396#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3397 string=cmsTakeProductName(icc_profile);
3399 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3400 "en",
"US",value,MagickPathExtent);
3402 (void) cmsCloseProfile(icc_profile);
3406 if (LocaleCompare(
"printsize.x",property) == 0)
3408 WarnNoImageReturn(
"\"%%[%s]\"",property);
3409 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3410 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3411 image->resolution.x)*image->columns);
3414 if (LocaleCompare(
"printsize.y",property) == 0)
3416 WarnNoImageReturn(
"\"%%[%s]\"",property);
3417 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3418 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3419 image->resolution.y)*image->rows);
3422 if (LocaleCompare(
"profiles",property) == 0)
3427 WarnNoImageReturn(
"\"%%[%s]\"",property);
3428 ResetImageProfileIterator(image);
3429 name=GetNextImageProfile(image);
3430 if (name != (
char *) NULL)
3432 (void) CopyMagickString(value,name,MagickPathExtent);
3433 name=GetNextImageProfile(image);
3434 while (name != (
char *) NULL)
3436 ConcatenateMagickString(value,
",",MagickPathExtent);
3437 ConcatenateMagickString(value,name,MagickPathExtent);
3438 name=GetNextImageProfile(image);
3447 if (LocaleCompare(
"quality",property) == 0)
3449 WarnNoImageReturn(
"\"%%[%s]\"",property);
3450 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3458 if (LocaleCompare(
"resolution.x",property) == 0)
3460 WarnNoImageReturn(
"\"%%[%s]\"",property);
3461 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3462 image->resolution.x);
3465 if (LocaleCompare(
"resolution.y",property) == 0)
3467 WarnNoImageReturn(
"\"%%[%s]\"",property);
3468 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3469 image->resolution.y);
3476 if (LocaleCompare(
"scene",property) == 0)
3478 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3479 if (image_info->number_scenes != 0)
3480 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3483 WarnNoImageReturn(
"\"%%[%s]\"",property);
3484 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3489 if (LocaleCompare(
"scenes",property) == 0)
3492 WarnNoImageReturn(
"\"%%[%s]\"",property);
3493 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3494 GetImageListLength(image));
3497 if (LocaleCompare(
"size",property) == 0)
3499 WarnNoImageReturn(
"\"%%[%s]\"",property);
3500 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
3501 MagickPathExtent,value);
3504 if (LocaleCompare(
"skewness",property) == 0)
3510 WarnNoImageReturn(
"\"%%[%s]\"",property);
3511 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3512 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3513 GetMagickPrecision(),skewness);
3516 if (LocaleCompare(
"standard-deviation",property) == 0)
3522 WarnNoImageReturn(
"\"%%[%s]\"",property);
3523 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3524 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3525 GetMagickPrecision(),standard_deviation);
3532 if (LocaleCompare(
"type",property) == 0)
3534 WarnNoImageReturn(
"\"%%[%s]\"",property);
3535 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3536 IdentifyImageType(image,exception));
3543 if (LocaleCompare(
"unique",property) == 0)
3545 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3546 string=image_info->unique;
3549 if (LocaleCompare(
"units",property) == 0)
3551 WarnNoImageReturn(
"\"%%[%s]\"",property);
3552 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3560 if (LocaleCompare(
"version",property) == 0)
3562 string=GetMagickVersion((
size_t *) NULL);
3569 if (LocaleCompare(
"width",property) == 0)
3571 WarnNoImageReturn(
"\"%%[%s]\"",property);
3572 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3573 (image->magick_columns != 0 ? image->magick_columns : 256));
3579 if (
string != (
char *) NULL)
3586 if (image != (Image *) NULL)
3588 (void) SetImageArtifact(image,
"magick-property",value);
3589 return(GetImageArtifact(image,
"magick-property"));
3593 (void) SetImageOption(image_info,
"magick-property",value);
3594 return(GetImageOption(image_info,
"magick-property"));
3597 return((
char *) NULL);
3599#undef WarnNoImageReturn
3623MagickExport
const char *GetNextImageProperty(
const Image *image)
3625 assert(image != (Image *) NULL);
3626 assert(image->signature == MagickCoreSignature);
3627 if (IsEventLogging() != MagickFalse)
3628 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3630 if (image->properties == (
void *) NULL)
3631 return((
const char *) NULL);
3632 return((
const char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3689MagickExport
char *InterpretImageProperties(ImageInfo *image_info,Image *image,
3690 const char *embed_text,ExceptionInfo *exception)
3692#define ExtendInterpretText(string_length) \
3694 size_t length=(string_length); \
3695 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3698 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3699 MagickPathExtent,sizeof(*interpret_text)); \
3700 if (interpret_text == (char *) NULL) \
3702 if (property_image != image) \
3703 property_image=DestroyImage(property_image); \
3704 if (property_info != image_info) \
3705 property_info=DestroyImageInfo(property_info); \
3706 return((char *) NULL); \
3708 q=interpret_text+strlen(interpret_text); \
3712#define AppendKeyValue2Text(key,value)\
3714 size_t length=strlen(key)+strlen(value)+2; \
3715 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3718 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3719 MagickPathExtent,sizeof(*interpret_text)); \
3720 if (interpret_text == (char *) NULL) \
3722 if (property_image != image) \
3723 property_image=DestroyImage(property_image); \
3724 if (property_info != image_info) \
3725 property_info=DestroyImageInfo(property_info); \
3726 return((char *) NULL); \
3728 q=interpret_text+strlen(interpret_text); \
3730 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3733#define AppendString2Text(string) \
3735 size_t length = strlen((string)); \
3736 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3739 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3740 MagickPathExtent,sizeof(*interpret_text)); \
3741 if (interpret_text == (char *) NULL) \
3743 if (property_image != image) \
3744 property_image=DestroyImage(property_image); \
3745 if (property_info != image_info) \
3746 property_info=DestroyImageInfo(property_info); \
3747 return((char *) NULL); \
3749 q=interpret_text+strlen(interpret_text); \
3751 (void) CopyMagickString(q,(string),extent); \
3752 q+=(ptrdiff_t) length; \
3774 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
3775 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3777 if ((image_info != (ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
3778 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3779 image_info->filename);
3781 if (IsEventLogging() != MagickFalse)
3782 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no image");
3783 if (embed_text == (
const char *) NULL)
3784 return(ConstantString(
""));
3786 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3789 return(ConstantString(
""));
3790 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3795 interpret_text=FileToString(p,~0UL,exception);
3796 if (interpret_text != (
char *) NULL)
3797 return(interpret_text);
3802 if (image_info != (ImageInfo *) NULL)
3803 property_info=image_info;
3805 property_info=CloneImageInfo(image_info);
3806 if ((image != (Image *) NULL) && (image->columns != 0) && (image->rows != 0))
3807 property_image=image;
3810 property_image=AcquireImage(image_info,exception);
3811 (void) SetImageExtent(property_image,1,1,exception);
3812 (void) SetImageBackgroundColor(property_image,exception);
3814 interpret_text=AcquireString(embed_text);
3815 extent=MagickPathExtent;
3817 for (q=interpret_text; *p!=
'\0'; number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
3823 ExtendInterpretText(MagickPathExtent);
3866 if (LocaleNCompare(
"<",p,4) == 0)
3872 if (LocaleNCompare(
">",p,4) == 0)
3878 if (LocaleNCompare(
"&",p,5) == 0)
3899 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3914 if (number != MagickFalse)
3923 string=GetMagickPropertyLetter(property_info,image,*p,exception);
3924 if (
string != (
char *) NULL)
3926 AppendString2Text(
string);
3927 (void) DeleteImageArtifact(property_image,
"magick-property");
3928 (void) DeleteImageOption(property_info,
"magick-property");
3931 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3932 "UnknownImageProperty",
"\"%%%c\"",*p);
3937 pattern[2*MagickPathExtent] =
"\0";
3956 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3957 "UnknownImageProperty",
"\"%%[]\"");
3960 for (len=0; len < (MagickPathExtent-1L) && (*p !=
'\0'); )
3962 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3967 pattern[len++]=(*p++);
3968 pattern[len++]=(*p++);
3977 pattern[len++]=(*p++);
3992 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3993 "UnbalancedBraces",
"\"%%[%s\"",pattern);
3994 interpret_text=DestroyString(interpret_text);
3995 if (property_image != image)
3996 property_image=DestroyImage(property_image);
3997 if (property_info != image_info)
3998 property_info=DestroyImageInfo(property_info);
3999 return((
char *) NULL);
4004 if (LocaleNCompare(
"fx:",pattern,3) == 0)
4018 fx_info=AcquireFxInfo(property_image,pattern+3,exception);
4019 if (fx_info == (FxInfo *) NULL)
4021 status=FxEvaluateChannelExpression(fx_info,CompositePixelChannel,0,0,
4023 fx_info=DestroyFxInfo(fx_info);
4024 if (status != MagickFalse)
4027 result[MagickPathExtent];
4029 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
4030 GetMagickPrecision(),(
double) value);
4031 AppendString2Text(result);
4035 if (LocaleNCompare(
"hex:",pattern,4) == 0)
4052 GetPixelInfo(property_image,&pixel);
4053 fx_info=AcquireFxInfo(property_image,pattern+4,exception);
4054 if (fx_info == (FxInfo *) NULL)
4056 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4058 pixel.red=(double) QuantumRange*value;
4059 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4060 GreenPixelChannel,0,0,&value,exception);
4061 pixel.green=(double) QuantumRange*value;
4062 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4063 BluePixelChannel,0,0,&value,exception);
4064 pixel.blue=(double) QuantumRange*value;
4065 if (property_image->colorspace == CMYKColorspace)
4067 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4068 BlackPixelChannel,0,0,&value,exception);
4069 pixel.black=(double) QuantumRange*value;
4071 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4072 AlphaPixelChannel,0,0,&value,exception);
4073 pixel.alpha=(double) QuantumRange*value;
4074 fx_info=DestroyFxInfo(fx_info);
4075 if (status != MagickFalse)
4078 hex[MagickPathExtent];
4080 GetColorTuple(&pixel,MagickTrue,hex);
4081 AppendString2Text(hex+1);
4085 if (LocaleNCompare(
"pixel:",pattern,6) == 0)
4102 GetPixelInfo(property_image,&pixel);
4103 fx_info=AcquireFxInfo(property_image,pattern+6,exception);
4104 if (fx_info == (FxInfo *) NULL)
4106 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4108 pixel.red=(double) QuantumRange*value;
4109 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4110 GreenPixelChannel,0,0,&value,exception);
4111 pixel.green=(double) QuantumRange*value;
4112 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4113 BluePixelChannel,0,0,&value,exception);
4114 pixel.blue=(double) QuantumRange*value;
4115 if (property_image->colorspace == CMYKColorspace)
4117 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4118 BlackPixelChannel,0,0,&value,exception);
4119 pixel.black=(double) QuantumRange*value;
4121 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4122 AlphaPixelChannel,0,0,&value,exception);
4123 pixel.alpha=(double) QuantumRange*value;
4124 fx_info=DestroyFxInfo(fx_info);
4125 if (status != MagickFalse)
4128 name[MagickPathExtent];
4130 GetColorTuple(&pixel,MagickFalse,name);
4131 string=GetImageArtifact(property_image,
"pixel:compliance");
4132 if (
string != (
char *) NULL)
4134 ComplianceType compliance=(ComplianceType) ParseCommandOption(
4135 MagickComplianceOptions,MagickFalse,
string);
4136 (void) QueryColorname(property_image,&pixel,compliance,name,
4139 AppendString2Text(name);
4143 if (LocaleNCompare(
"option:",pattern,7) == 0)
4148 if (IsGlob(pattern+7) != MagickFalse)
4150 ResetImageOptionIterator(property_info);
4151 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4152 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4154 string=GetImageOption(property_info,key);
4155 if (
string != (
const char *) NULL)
4156 AppendKeyValue2Text(key,
string);
4161 string=GetImageOption(property_info,pattern+7);
4162 if (
string == (
char *) NULL)
4163 goto PropertyLookupFailure;
4164 AppendString2Text(
string);
4167 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4172 if (IsGlob(pattern+9) != MagickFalse)
4174 ResetImageArtifactIterator(property_image);
4175 while ((key=GetNextImageArtifact(property_image)) != (
const char *) NULL)
4176 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4178 string=GetImageArtifact(property_image,key);
4179 if (
string != (
const char *) NULL)
4180 AppendKeyValue2Text(key,
string);
4185 string=GetImageArtifact(property_image,pattern+9);
4186 if (
string == (
char *) NULL)
4187 goto PropertyLookupFailure;
4188 AppendString2Text(
string);
4191 if (LocaleNCompare(
"property:",pattern,9) == 0)
4196 if (IsGlob(pattern+9) != MagickFalse)
4198 ResetImagePropertyIterator(property_image);
4199 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4200 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4202 string=GetImageProperty(property_image,key,exception);
4203 if (
string != (
const char *) NULL)
4204 AppendKeyValue2Text(key,
string);
4209 string=GetImageProperty(property_image,pattern+9,exception);
4210 if (
string == (
char *) NULL)
4211 goto PropertyLookupFailure;
4212 AppendString2Text(
string);
4220 string=GetImageProperty(property_image,pattern,exception);
4221 if (
string != (
const char *) NULL)
4223 AppendString2Text(
string);
4224 (void) DeleteImageArtifact(property_image,
"magick-property");
4225 (void) DeleteImageOption(property_info,
"magick-property");
4228 if (IsGlob(pattern) != MagickFalse)
4234 ResetImagePropertyIterator(property_image);
4235 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4236 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4238 string=GetImageProperty(property_image,key,exception);
4239 if (
string != (
const char *) NULL)
4240 AppendKeyValue2Text(key,
string);
4250 string=GetMagickProperty(property_info,property_image,pattern,exception);
4251 if (
string != (
const char *) NULL)
4253 AppendString2Text(
string);
4260 string=GetImageArtifact(property_image,pattern);
4261 if (
string != (
char *) NULL)
4263 AppendString2Text(
string);
4269 string=GetImageOption(property_info,pattern);
4270 if (
string != (
char *) NULL)
4272 AppendString2Text(
string);
4275PropertyLookupFailure:
4286 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4287 "UnknownImageProperty",
"\"%%[%s]\"",pattern);
4291 if (property_image != image)
4292 property_image=DestroyImage(property_image);
4293 if (property_info != image_info)
4294 property_info=DestroyImageInfo(property_info);
4295 return(interpret_text);
4326MagickExport
char *RemoveImageProperty(Image *image,
const char *property)
4331 assert(image != (Image *) NULL);
4332 assert(image->signature == MagickCoreSignature);
4333 if (IsEventLogging() != MagickFalse)
4334 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4335 if (image->properties == (
void *) NULL)
4336 return((
char *) NULL);
4337 value=(
char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
4366MagickExport
void ResetImagePropertyIterator(
const Image *image)
4368 assert(image != (Image *) NULL);
4369 assert(image->signature == MagickCoreSignature);
4370 if (IsEventLogging() != MagickFalse)
4371 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4372 if (image->properties == (
void *) NULL)
4374 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
4410MagickExport MagickBooleanType SetImageProperty(Image *image,
4411 const char *property,
const char *value,ExceptionInfo *exception)
4422 assert(image != (Image *) NULL);
4423 assert(image->signature == MagickCoreSignature);
4424 if (IsEventLogging() != MagickFalse)
4425 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4426 if (image->properties == (
void *) NULL)
4427 image->properties=NewSplayTree(CompareSplayTreeString,
4428 RelinquishMagickMemory,RelinquishMagickMemory);
4429 if (value == (
const char *) NULL)
4430 return(DeleteImageProperty(image,property));
4431 if (strlen(property) <= 1)
4436 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4437 "SetReadOnlyProperty",
"`%s'",property);
4438 return(MagickFalse);
4440 property_length=strlen(property);
4441 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4442 (*(property+(property_length-1)) ==
'*'))
4444 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4445 "SetReadOnlyProperty",
"`%s'",property);
4446 return(MagickFalse);
4460 if (LocaleNCompare(
"8bim:",property,5) == 0)
4462 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4463 "SetReadOnlyProperty",
"`%s'",property);
4464 return(MagickFalse);
4472 if (LocaleCompare(
"background",property) == 0)
4474 (void) QueryColorCompliance(value,AllCompliance,
4475 &image->background_color,exception);
4484 if (LocaleCompare(
"channels",property) == 0)
4486 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4487 "SetReadOnlyProperty",
"`%s'",property);
4488 return(MagickFalse);
4490 if (LocaleCompare(
"colorspace",property) == 0)
4495 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4498 return(MagickFalse);
4499 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4501 if (LocaleCompare(
"compose",property) == 0)
4506 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4508 return(MagickFalse);
4509 image->compose=(CompositeOperator) compose;
4512 if (LocaleCompare(
"compress",property) == 0)
4517 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4519 if (compression < 0)
4520 return(MagickFalse);
4521 image->compression=(CompressionType) compression;
4529 if (LocaleCompare(
"delay",property) == 0)
4534 flags=ParseGeometry(value,&geometry_info);
4535 if ((flags & GreaterValue) != 0)
4537 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4538 image->delay=(size_t) floor(geometry_info.rho+0.5);
4541 if ((flags & LessValue) != 0)
4543 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4544 image->delay=(size_t) CastDoubleToSsizeT(floor(
4545 geometry_info.sigma+0.5));
4548 image->delay=(size_t) floor(geometry_info.rho+0.5);
4549 if ((flags & SigmaValue) != 0)
4550 image->ticks_per_second=CastDoubleToSsizeT(floor(
4551 geometry_info.sigma+0.5));
4554 if (LocaleCompare(
"delay_units",property) == 0)
4556 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4557 "SetReadOnlyProperty",
"`%s'",property);
4558 return(MagickFalse);
4560 if (LocaleCompare(
"density",property) == 0)
4565 flags=ParseGeometry(value,&geometry_info);
4566 if ((flags & RhoValue) != 0)
4567 image->resolution.x=geometry_info.rho;
4568 image->resolution.y=image->resolution.x;
4569 if ((flags & SigmaValue) != 0)
4570 image->resolution.y=geometry_info.sigma;
4573 if (LocaleCompare(
"depth",property) == 0)
4575 image->depth=StringToUnsignedLong(value);
4578 if (LocaleCompare(
"dispose",property) == 0)
4583 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4585 return(MagickFalse);
4586 image->dispose=(DisposeType) dispose;
4596 if (LocaleNCompare(
"exif:",property,5) == 0)
4598 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4599 "SetReadOnlyProperty",
"`%s'",property);
4600 return(MagickFalse);
4607 if (LocaleNCompare(
"fx:",property,3) == 0)
4609 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4610 "SetReadOnlyProperty",
"`%s'",property);
4611 return(MagickFalse);
4619 if (LocaleCompare(
"gamma",property) == 0)
4621 image->gamma=StringToDouble(value,(
char **) NULL);
4624 if (LocaleCompare(
"gravity",property) == 0)
4629 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4631 return(MagickFalse);
4632 image->gravity=(GravityType) gravity;
4640 if (LocaleCompare(
"height",property) == 0)
4642 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4643 "SetReadOnlyProperty",
"`%s'",property);
4644 return(MagickFalse);
4651 if (LocaleCompare(
"intensity",property) == 0)
4656 intensity=ParseCommandOption(MagickIntensityOptions,MagickFalse,
4659 return(MagickFalse);
4660 image->intensity=(PixelIntensityMethod) intensity;
4663 if (LocaleCompare(
"intent",property) == 0)
4668 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4670 if (rendering_intent < 0)
4671 return(MagickFalse);
4672 image->rendering_intent=(RenderingIntent) rendering_intent;
4675 if (LocaleCompare(
"interpolate",property) == 0)
4680 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4682 if (interpolate < 0)
4683 return(MagickFalse);
4684 image->interpolate=(PixelInterpolateMethod) interpolate;
4689 if (LocaleNCompare(
"iptc:",property,5) == 0)
4691 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4692 "SetReadOnlyProperty",
"`%s'",property);
4693 return(MagickFalse);
4700 if (LocaleCompare(
"kurtosis",property) == 0)
4702 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4703 "SetReadOnlyProperty",
"`%s'",property);
4704 return(MagickFalse);
4710 if (LocaleCompare(
"loop",property) == 0)
4712 image->iterations=StringToUnsignedLong(value);
4719 if ((LocaleCompare(
"magick",property) == 0) ||
4720 (LocaleCompare(
"max",property) == 0) ||
4721 (LocaleCompare(
"mean",property) == 0) ||
4722 (LocaleCompare(
"min",property) == 0) ||
4723 (LocaleCompare(
"min",property) == 0))
4725 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4726 "SetReadOnlyProperty",
"`%s'",property);
4727 return(MagickFalse);
4732 if (LocaleCompare(
"opaque",property) == 0)
4734 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4735 "SetReadOnlyProperty",
"`%s'",property);
4736 return(MagickFalse);
4742 if (LocaleCompare(
"page",property) == 0)
4747 geometry=GetPageGeometry(value);
4748 flags=ParseAbsoluteGeometry(geometry,&image->page);
4749 geometry=DestroyString(geometry);
4754 if (LocaleNCompare(
"pixel:",property,6) == 0)
4756 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4757 "SetReadOnlyProperty",
"`%s'",property);
4758 return(MagickFalse);
4766 if (LocaleCompare(
"rendering-intent",property) == 0)
4771 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4773 if (rendering_intent < 0)
4774 return(MagickFalse);
4775 image->rendering_intent=(RenderingIntent) rendering_intent;
4782 if ((LocaleCompare(
"size",property) == 0) ||
4783 (LocaleCompare(
"skewness",property) == 0) ||
4784 (LocaleCompare(
"scenes",property) == 0) ||
4785 (LocaleCompare(
"standard-deviation",property) == 0))
4787 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4788 "SetReadOnlyProperty",
"`%s'",property);
4789 return(MagickFalse);
4795 if (LocaleCompare(
"tile-offset",property) == 0)
4800 geometry=GetPageGeometry(value);
4801 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4802 geometry=DestroyString(geometry);
4805 if (LocaleCompare(
"type",property) == 0)
4810 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4812 return(MagickFalse);
4813 image->type=(ImageType) type;
4821 if (LocaleCompare(
"units",property) == 0)
4826 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4828 return(MagickFalse);
4829 image->units=(ResolutionType) units;
4837 if (LocaleCompare(
"version",property) == 0)
4839 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4840 "SetReadOnlyProperty",
"`%s'",property);
4841 return(MagickFalse);
4848 if (LocaleCompare(
"width",property) == 0)
4850 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4851 "SetReadOnlyProperty",
"`%s'",property);
4852 return(MagickFalse);
4861 if (LocaleNCompare(
"xmp:",property,4) == 0)
4863 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4864 "SetReadOnlyProperty",
"`%s'",property);
4865 return(MagickFalse);
4872 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4873 ConstantString(property),ConstantString(value));