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)
454 profile=GetImageProfile(image,
"iptc");
455 if (profile == (StringInfo *) NULL)
456 profile=GetImageProfile(image,
"8bim");
457 if (profile == (StringInfo *) NULL)
459 count=MagickSscanf(key,
"IPTC:%ld:%ld",&dataset,&record);
462 attribute=(
char *) NULL;
463 for (i=0; i < (ssize_t) GetStringInfoLength(profile)-5; )
465 const unsigned char *p = GetStringInfoDatum(profile)+i;
475 if (((
long) p[1] == dataset) && ((
long) p[2] == record))
478 *message = (
char *) NULL;
480 size_t declared = ((size_t) p[3] << 8) | (
size_t) p[4];
481 size_t remaining = GetStringInfoLength(profile)-(i+5);
482 size_t length = MagickMin(declared,remaining);
484 message=(
char *) AcquireQuantumMemory(length+1UL,
sizeof(*message));
485 if (message != (
char *) NULL)
490 (void) memcpy(message,p+5,length);
491 message[length]=
'\0';
492 (void) ConcatenateString(&attribute,message);
493 (void) ConcatenateString(&attribute,
";");
494 message=DestroyString(message);
500 i+=(((size_t) p[3] << 8) | (size_t) p[4])+5;
502 if ((attribute == (
char *) NULL) || (*attribute ==
';'))
504 if (attribute != (
char *) NULL)
505 attribute=DestroyString(attribute);
508 attribute[strlen(attribute)-1]=
'\0';
509 (void) SetImageProperty((Image *) image,key,(
const char *) attribute,
511 attribute=DestroyString(attribute);
514static inline int ReadPropertyByte(
const unsigned char **p,
size_t *length)
526static inline signed int ReadPropertyMSBLong(
const unsigned char **p,
552 for (i=0; i < 4; i++)
556 buffer[i]=(
unsigned char) c;
558 value=(
unsigned int) buffer[0] << 24;
559 value|=(
unsigned int) buffer[1] << 16;
560 value|=(
unsigned int) buffer[2] << 8;
561 value|=(
unsigned int) buffer[3];
562 quantum.unsigned_value=value & 0xffffffff;
563 return(quantum.signed_value);
566static inline signed short ReadPropertyMSBShort(
const unsigned char **p,
592 for (i=0; i < 2; i++)
596 buffer[i]=(
unsigned char) c;
598 value=(
unsigned short) buffer[0] << 8;
599 value|=(
unsigned short) buffer[1];
600 quantum.unsigned_value=value & 0xffff;
601 return(quantum.signed_value);
604static void Get8BIMProperty(
const Image *image,
const char *key,
605 ExceptionInfo *exception)
609 format[MagickPathExtent],
610 *macroman_resource = (
char *) NULL,
611 name[MagickPathExtent],
612 *resource = (
char *) NULL;
639 profile=GetImageProfile(image,
"8bim");
640 if (profile == (StringInfo *) NULL)
642 count=(ssize_t) MagickSscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",
643 &start,&stop,name,format);
644 if ((count != 2) && (count != 3) && (count != 4))
647 (void) CopyMagickString(format,
"SVG",MagickPathExtent);
652 sub_number=(ssize_t) StringToLong(&name[1]);
653 sub_number=MagickMax(sub_number,1L);
655 length=GetStringInfoLength(profile);
656 info=GetStringInfoDatum(profile);
657 while ((length > 0) && (status == MagickFalse))
659 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'8')
661 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'B')
663 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'I')
665 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'M')
667 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
668 if (
id < (ssize_t) start)
670 if (
id > (ssize_t) stop)
672 if (macroman_resource != (
char *) NULL)
673 macroman_resource=DestroyString(macroman_resource);
674 if (resource != (
char *) NULL)
675 resource=DestroyString(resource);
676 count=(ssize_t) ReadPropertyByte(&info,&length);
677 if ((count != 0) && ((
size_t) count <= length))
679 if (~((
size_t) count) >= (MagickPathExtent-1))
680 resource=(
char *) AcquireQuantumMemory((
size_t) count+
681 MagickPathExtent,
sizeof(*resource));
682 if (resource != (
char *) NULL)
684 for (i=0; i < (ssize_t) count; i++)
685 resource[i]=(
char) ReadPropertyByte(&info,&length);
686 resource[count]=
'\0';
689 if ((count & 0x01) == 0)
690 (void) ReadPropertyByte(&info,&length);
691 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
692 if ((count < 0) || ((
size_t) count > length))
697 if (resource != (
char *) NULL)
698 macroman_resource=(
char *) ConvertMacRomanToUTF8((
unsigned char *)
700 if ((*name !=
'\0') && (*name !=
'#'))
701 if ((resource == (
char *) NULL) || (macroman_resource == (
char *) NULL) ||
702 ((LocaleCompare(name,resource) != 0) &&
703 (LocaleCompare(name,macroman_resource) != 0)))
709 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
712 if ((*name ==
'#') && (sub_number != 1))
719 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
725 attribute=(
char *) NULL;
726 if (~((
size_t) count) >= (MagickPathExtent-1))
727 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MagickPathExtent,
729 if (attribute != (
char *) NULL)
731 (void) memcpy(attribute,(
char *) info,(
size_t) count);
732 attribute[count]=
'\0';
734 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
735 if ((
id <= 1999) || (
id >= 2999))
736 (void) SetImageProperty((Image *) image,key,(
const char *) attribute,
743 if (LocaleCompare(format,
"svg") == 0)
744 path=TraceSVGClippath((
unsigned char *) attribute,(
size_t) count,
745 image->columns,image->rows);
747 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count);
748 (void) SetImageProperty((Image *) image,key,(
const char *) path,
750 path=DestroyString(path);
752 attribute=DestroyString(attribute);
756 if (macroman_resource != (
char *) NULL)
757 macroman_resource=DestroyString(macroman_resource);
758 if (resource != (
char *) NULL)
759 resource=DestroyString(resource);
762static inline signed int ReadPropertySignedLong(
const EndianType endian,
763 const unsigned char *buffer)
777 if (endian == LSBEndian)
779 value=(
unsigned int) buffer[3] << 24;
780 value|=(
unsigned int) buffer[2] << 16;
781 value|=(
unsigned int) buffer[1] << 8;
782 value|=(
unsigned int) buffer[0];
783 quantum.unsigned_value=value & 0xffffffff;
784 return(quantum.signed_value);
786 value=(
unsigned int) buffer[0] << 24;
787 value|=(
unsigned int) buffer[1] << 16;
788 value|=(
unsigned int) buffer[2] << 8;
789 value|=(
unsigned int) buffer[3];
790 quantum.unsigned_value=value & 0xffffffff;
791 return(quantum.signed_value);
794static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
795 const unsigned char *buffer)
800 if (endian == LSBEndian)
802 value=(
unsigned int) buffer[3] << 24;
803 value|=(
unsigned int) buffer[2] << 16;
804 value|=(
unsigned int) buffer[1] << 8;
805 value|=(
unsigned int) buffer[0];
806 return(value & 0xffffffff);
808 value=(
unsigned int) buffer[0] << 24;
809 value|=(
unsigned int) buffer[1] << 16;
810 value|=(
unsigned int) buffer[2] << 8;
811 value|=(
unsigned int) buffer[3];
812 return(value & 0xffffffff);
815static inline signed short ReadPropertySignedShort(
const EndianType endian,
816 const unsigned char *buffer)
830 if (endian == LSBEndian)
832 value=(
unsigned short) buffer[1] << 8;
833 value|=(
unsigned short) buffer[0];
834 quantum.unsigned_value=value & 0xffff;
835 return(quantum.signed_value);
837 value=(
unsigned short) buffer[0] << 8;
838 value|=(
unsigned short) buffer[1];
839 quantum.unsigned_value=value & 0xffff;
840 return(quantum.signed_value);
843static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
844 const unsigned char *buffer)
849 if (endian == LSBEndian)
851 value=(
unsigned short) buffer[1] << 8;
852 value|=(
unsigned short) buffer[0];
853 return(value & 0xffff);
855 value=(
unsigned short) buffer[0] << 8;
856 value|=(
unsigned short) buffer[1];
857 return(value & 0xffff);
860static void GetEXIFProperty(
const Image *image,
const char *property,
861 ExceptionInfo *exception)
863#define MaxDirectoryStack 16
864#define EXIF_DELIMITER "\n"
865#define EXIF_NUM_FORMATS 12
866#define EXIF_FMT_BYTE 1
867#define EXIF_FMT_STRING 2
868#define EXIF_FMT_USHORT 3
869#define EXIF_FMT_ULONG 4
870#define EXIF_FMT_URATIONAL 5
871#define EXIF_FMT_SBYTE 6
872#define EXIF_FMT_UNDEFINED 7
873#define EXIF_FMT_SSHORT 8
874#define EXIF_FMT_SLONG 9
875#define EXIF_FMT_SRATIONAL 10
876#define EXIF_FMT_SINGLE 11
877#define EXIF_FMT_DOUBLE 12
878#define GPS_LATITUDE 0x10002
879#define GPS_LONGITUDE 0x10004
880#define GPS_TIMESTAMP 0x10007
881#define TAG_EXIF_OFFSET 0x8769
882#define TAG_GPS_OFFSET 0x8825
883#define TAG_INTEROP_OFFSET 0xa005
885#define EXIFGPSFractions(format,arg1,arg2,arg3,arg4,arg5,arg6) \
893 for ( ; component < components; component++) \
895 if (component != 0) \
896 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
898 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
899 extent,format,(arg1),(arg2),(arg3),(arg4),(arg5),(arg6)); \
900 if (extent >= (MagickPathExtent-1)) \
901 extent=MagickPathExtent-1; \
903 buffer[extent]='\0'; \
904 value=AcquireString(buffer); \
907#define EXIFMultipleValues(format,arg) \
915 for ( ; component < components; component++) \
917 if (component != 0) \
918 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
920 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
921 extent,format,arg); \
922 if (extent >= (MagickPathExtent-1)) \
923 extent=MagickPathExtent-1; \
925 buffer[extent]='\0'; \
926 value=AcquireString(buffer); \
929#define EXIFMultipleFractions(format,arg1,arg2) \
937 for ( ; component < components; component++) \
939 if (component != 0) \
940 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent-\
942 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
943 extent,format,(arg1),(arg2)); \
944 if (extent >= (MagickPathExtent-1)) \
945 extent=MagickPathExtent-1; \
947 buffer[extent]='\0'; \
948 value=AcquireString(buffer); \
951 typedef struct _DirectoryInfo
963 typedef struct _TagInfo
975 { 0x001,
"exif:InteroperabilityIndex" },
976 { 0x002,
"exif:InteroperabilityVersion" },
977 { 0x100,
"exif:ImageWidth" },
978 { 0x101,
"exif:ImageLength" },
979 { 0x102,
"exif:BitsPerSample" },
980 { 0x103,
"exif:Compression" },
981 { 0x106,
"exif:PhotometricInterpretation" },
982 { 0x10a,
"exif:FillOrder" },
983 { 0x10d,
"exif:DocumentName" },
984 { 0x10e,
"exif:ImageDescription" },
985 { 0x10f,
"exif:Make" },
986 { 0x110,
"exif:Model" },
987 { 0x111,
"exif:StripOffsets" },
988 { 0x112,
"exif:Orientation" },
989 { 0x115,
"exif:SamplesPerPixel" },
990 { 0x116,
"exif:RowsPerStrip" },
991 { 0x117,
"exif:StripByteCounts" },
992 { 0x11a,
"exif:XResolution" },
993 { 0x11b,
"exif:YResolution" },
994 { 0x11c,
"exif:PlanarConfiguration" },
995 { 0x11d,
"exif:PageName" },
996 { 0x11e,
"exif:XPosition" },
997 { 0x11f,
"exif:YPosition" },
998 { 0x118,
"exif:MinSampleValue" },
999 { 0x119,
"exif:MaxSampleValue" },
1000 { 0x120,
"exif:FreeOffsets" },
1001 { 0x121,
"exif:FreeByteCounts" },
1002 { 0x122,
"exif:GrayResponseUnit" },
1003 { 0x123,
"exif:GrayResponseCurve" },
1004 { 0x124,
"exif:T4Options" },
1005 { 0x125,
"exif:T6Options" },
1006 { 0x128,
"exif:ResolutionUnit" },
1007 { 0x12d,
"exif:TransferFunction" },
1008 { 0x131,
"exif:Software" },
1009 { 0x132,
"exif:DateTime" },
1010 { 0x13b,
"exif:Artist" },
1011 { 0x13e,
"exif:WhitePoint" },
1012 { 0x13f,
"exif:PrimaryChromaticities" },
1013 { 0x140,
"exif:ColorMap" },
1014 { 0x141,
"exif:HalfToneHints" },
1015 { 0x142,
"exif:TileWidth" },
1016 { 0x143,
"exif:TileLength" },
1017 { 0x144,
"exif:TileOffsets" },
1018 { 0x145,
"exif:TileByteCounts" },
1019 { 0x14a,
"exif:SubIFD" },
1020 { 0x14c,
"exif:InkSet" },
1021 { 0x14d,
"exif:InkNames" },
1022 { 0x14e,
"exif:NumberOfInks" },
1023 { 0x150,
"exif:DotRange" },
1024 { 0x151,
"exif:TargetPrinter" },
1025 { 0x152,
"exif:ExtraSample" },
1026 { 0x153,
"exif:SampleFormat" },
1027 { 0x154,
"exif:SMinSampleValue" },
1028 { 0x155,
"exif:SMaxSampleValue" },
1029 { 0x156,
"exif:TransferRange" },
1030 { 0x157,
"exif:ClipPath" },
1031 { 0x158,
"exif:XClipPathUnits" },
1032 { 0x159,
"exif:YClipPathUnits" },
1033 { 0x15a,
"exif:Indexed" },
1034 { 0x15b,
"exif:JPEGTables" },
1035 { 0x15f,
"exif:OPIProxy" },
1036 { 0x200,
"exif:JPEGProc" },
1037 { 0x201,
"exif:JPEGInterchangeFormat" },
1038 { 0x202,
"exif:JPEGInterchangeFormatLength" },
1039 { 0x203,
"exif:JPEGRestartInterval" },
1040 { 0x205,
"exif:JPEGLosslessPredictors" },
1041 { 0x206,
"exif:JPEGPointTransforms" },
1042 { 0x207,
"exif:JPEGQTables" },
1043 { 0x208,
"exif:JPEGDCTables" },
1044 { 0x209,
"exif:JPEGACTables" },
1045 { 0x211,
"exif:YCbCrCoefficients" },
1046 { 0x212,
"exif:YCbCrSubSampling" },
1047 { 0x213,
"exif:YCbCrPositioning" },
1048 { 0x214,
"exif:ReferenceBlackWhite" },
1049 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1050 { 0x301,
"exif:Gamma" },
1051 { 0x302,
"exif:ICCProfileDescriptor" },
1052 { 0x303,
"exif:SRGBRenderingIntent" },
1053 { 0x320,
"exif:ImageTitle" },
1054 { 0x5001,
"exif:ResolutionXUnit" },
1055 { 0x5002,
"exif:ResolutionYUnit" },
1056 { 0x5003,
"exif:ResolutionXLengthUnit" },
1057 { 0x5004,
"exif:ResolutionYLengthUnit" },
1058 { 0x5005,
"exif:PrintFlags" },
1059 { 0x5006,
"exif:PrintFlagsVersion" },
1060 { 0x5007,
"exif:PrintFlagsCrop" },
1061 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1062 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1063 { 0x500A,
"exif:HalftoneLPI" },
1064 { 0x500B,
"exif:HalftoneLPIUnit" },
1065 { 0x500C,
"exif:HalftoneDegree" },
1066 { 0x500D,
"exif:HalftoneShape" },
1067 { 0x500E,
"exif:HalftoneMisc" },
1068 { 0x500F,
"exif:HalftoneScreen" },
1069 { 0x5010,
"exif:JPEGQuality" },
1070 { 0x5011,
"exif:GridSize" },
1071 { 0x5012,
"exif:ThumbnailFormat" },
1072 { 0x5013,
"exif:ThumbnailWidth" },
1073 { 0x5014,
"exif:ThumbnailHeight" },
1074 { 0x5015,
"exif:ThumbnailColorDepth" },
1075 { 0x5016,
"exif:ThumbnailPlanes" },
1076 { 0x5017,
"exif:ThumbnailRawBytes" },
1077 { 0x5018,
"exif:ThumbnailSize" },
1078 { 0x5019,
"exif:ThumbnailCompressedSize" },
1079 { 0x501a,
"exif:ColorTransferFunction" },
1080 { 0x501b,
"exif:ThumbnailData" },
1081 { 0x5020,
"exif:ThumbnailImageWidth" },
1082 { 0x5021,
"exif:ThumbnailImageHeight" },
1083 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1084 { 0x5023,
"exif:ThumbnailCompression" },
1085 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1086 { 0x5025,
"exif:ThumbnailImageDescription" },
1087 { 0x5026,
"exif:ThumbnailEquipMake" },
1088 { 0x5027,
"exif:ThumbnailEquipModel" },
1089 { 0x5028,
"exif:ThumbnailStripOffsets" },
1090 { 0x5029,
"exif:ThumbnailOrientation" },
1091 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1092 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1093 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1094 { 0x502d,
"exif:ThumbnailResolutionX" },
1095 { 0x502e,
"exif:ThumbnailResolutionY" },
1096 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1097 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1098 { 0x5031,
"exif:ThumbnailTransferFunction" },
1099 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1100 { 0x5033,
"exif:ThumbnailDateTime" },
1101 { 0x5034,
"exif:ThumbnailArtist" },
1102 { 0x5035,
"exif:ThumbnailWhitePoint" },
1103 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1104 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1105 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1106 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1107 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1108 { 0x503B,
"exif:ThumbnailCopyRight" },
1109 { 0x5090,
"exif:LuminanceTable" },
1110 { 0x5091,
"exif:ChrominanceTable" },
1111 { 0x5100,
"exif:FrameDelay" },
1112 { 0x5101,
"exif:LoopCount" },
1113 { 0x5110,
"exif:PixelUnit" },
1114 { 0x5111,
"exif:PixelPerUnitX" },
1115 { 0x5112,
"exif:PixelPerUnitY" },
1116 { 0x5113,
"exif:PaletteHistogram" },
1117 { 0x1000,
"exif:RelatedImageFileFormat" },
1118 { 0x1001,
"exif:RelatedImageLength" },
1119 { 0x1002,
"exif:RelatedImageWidth" },
1120 { 0x800d,
"exif:ImageID" },
1121 { 0x80e3,
"exif:Matteing" },
1122 { 0x80e4,
"exif:DataType" },
1123 { 0x80e5,
"exif:ImageDepth" },
1124 { 0x80e6,
"exif:TileDepth" },
1125 { 0x828d,
"exif:CFARepeatPatternDim" },
1126 { 0x828e,
"exif:CFAPattern2" },
1127 { 0x828f,
"exif:BatteryLevel" },
1128 { 0x8298,
"exif:Copyright" },
1129 { 0x829a,
"exif:ExposureTime" },
1130 { 0x829d,
"exif:FNumber" },
1131 { 0x83bb,
"exif:IPTC/NAA" },
1132 { 0x84e3,
"exif:IT8RasterPadding" },
1133 { 0x84e5,
"exif:IT8ColorTable" },
1134 { 0x8649,
"exif:ImageResourceInformation" },
1135 { 0x8769,
"exif:ExifOffset" },
1136 { 0x8773,
"exif:InterColorProfile" },
1137 { 0x8822,
"exif:ExposureProgram" },
1138 { 0x8824,
"exif:SpectralSensitivity" },
1139 { 0x8825,
"exif:GPSInfo" },
1140 { 0x8827,
"exif:PhotographicSensitivity" },
1141 { 0x8828,
"exif:OECF" },
1142 { 0x8829,
"exif:Interlace" },
1143 { 0x882a,
"exif:TimeZoneOffset" },
1144 { 0x882b,
"exif:SelfTimerMode" },
1145 { 0x8830,
"exif:SensitivityType" },
1146 { 0x8831,
"exif:StandardOutputSensitivity" },
1147 { 0x8832,
"exif:RecommendedExposureIndex" },
1148 { 0x8833,
"exif:ISOSpeed" },
1149 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1150 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1151 { 0x9000,
"exif:ExifVersion" },
1152 { 0x9003,
"exif:DateTimeOriginal" },
1153 { 0x9004,
"exif:DateTimeDigitized" },
1154 { 0x9010,
"exif:OffsetTime" },
1155 { 0x9011,
"exif:OffsetTimeOriginal" },
1156 { 0x9012,
"exif:OffsetTimeDigitized" },
1157 { 0x9101,
"exif:ComponentsConfiguration" },
1158 { 0x9102,
"exif:CompressedBitsPerPixel" },
1159 { 0x9201,
"exif:ShutterSpeedValue" },
1160 { 0x9202,
"exif:ApertureValue" },
1161 { 0x9203,
"exif:BrightnessValue" },
1162 { 0x9204,
"exif:ExposureBiasValue" },
1163 { 0x9205,
"exif:MaxApertureValue" },
1164 { 0x9206,
"exif:SubjectDistance" },
1165 { 0x9207,
"exif:MeteringMode" },
1166 { 0x9208,
"exif:LightSource" },
1167 { 0x9209,
"exif:Flash" },
1168 { 0x920a,
"exif:FocalLength" },
1169 { 0x920b,
"exif:FlashEnergy" },
1170 { 0x920c,
"exif:SpatialFrequencyResponse" },
1171 { 0x920d,
"exif:Noise" },
1172 { 0x9214,
"exif:SubjectArea" },
1173 { 0x9290,
"exif:SubSecTime" },
1174 { 0x9291,
"exif:SubSecTimeOriginal" },
1175 { 0x9292,
"exif:SubSecTimeDigitized" },
1176 { 0x9211,
"exif:ImageNumber" },
1177 { 0x9212,
"exif:SecurityClassification" },
1178 { 0x9213,
"exif:ImageHistory" },
1179 { 0x9214,
"exif:SubjectArea" },
1180 { 0x9215,
"exif:ExposureIndex" },
1181 { 0x9216,
"exif:TIFF-EPStandardID" },
1182 { 0x927c,
"exif:MakerNote" },
1183 { 0x9286,
"exif:UserComment" },
1184 { 0x9290,
"exif:SubSecTime" },
1185 { 0x9291,
"exif:SubSecTimeOriginal" },
1186 { 0x9292,
"exif:SubSecTimeDigitized" },
1187 { 0x9400,
"exif:Temperature" },
1188 { 0x9401,
"exif:Humidity" },
1189 { 0x9402,
"exif:Pressure" },
1190 { 0x9403,
"exif:WaterDepth" },
1191 { 0x9404,
"exif:Acceleration" },
1192 { 0x9405,
"exif:CameraElevationAngle" },
1193 { 0x9C9b,
"exif:WinXP-Title" },
1194 { 0x9C9c,
"exif:WinXP-Comments" },
1195 { 0x9C9d,
"exif:WinXP-Author" },
1196 { 0x9C9e,
"exif:WinXP-Keywords" },
1197 { 0x9C9f,
"exif:WinXP-Subject" },
1198 { 0xa000,
"exif:FlashPixVersion" },
1199 { 0xa001,
"exif:ColorSpace" },
1200 { 0xa002,
"exif:PixelXDimension" },
1201 { 0xa003,
"exif:PixelYDimension" },
1202 { 0xa004,
"exif:RelatedSoundFile" },
1203 { 0xa005,
"exif:InteroperabilityOffset" },
1204 { 0xa20b,
"exif:FlashEnergy" },
1205 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1206 { 0xa20d,
"exif:Noise" },
1207 { 0xa20e,
"exif:FocalPlaneXResolution" },
1208 { 0xa20f,
"exif:FocalPlaneYResolution" },
1209 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1210 { 0xa214,
"exif:SubjectLocation" },
1211 { 0xa215,
"exif:ExposureIndex" },
1212 { 0xa216,
"exif:TIFF/EPStandardID" },
1213 { 0xa217,
"exif:SensingMethod" },
1214 { 0xa300,
"exif:FileSource" },
1215 { 0xa301,
"exif:SceneType" },
1216 { 0xa302,
"exif:CFAPattern" },
1217 { 0xa401,
"exif:CustomRendered" },
1218 { 0xa402,
"exif:ExposureMode" },
1219 { 0xa403,
"exif:WhiteBalance" },
1220 { 0xa404,
"exif:DigitalZoomRatio" },
1221 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1222 { 0xa406,
"exif:SceneCaptureType" },
1223 { 0xa407,
"exif:GainControl" },
1224 { 0xa408,
"exif:Contrast" },
1225 { 0xa409,
"exif:Saturation" },
1226 { 0xa40a,
"exif:Sharpness" },
1227 { 0xa40b,
"exif:DeviceSettingDescription" },
1228 { 0xa40c,
"exif:SubjectDistanceRange" },
1229 { 0xa420,
"exif:ImageUniqueID" },
1230 { 0xa430,
"exif:CameraOwnerName" },
1231 { 0xa431,
"exif:BodySerialNumber" },
1232 { 0xa432,
"exif:LensSpecification" },
1233 { 0xa433,
"exif:LensMake" },
1234 { 0xa434,
"exif:LensModel" },
1235 { 0xa435,
"exif:LensSerialNumber" },
1236 { 0xc4a5,
"exif:PrintImageMatching" },
1237 { 0xa500,
"exif:Gamma" },
1238 { 0xc640,
"exif:CR2Slice" },
1239 { 0x10000,
"exif:GPSVersionID" },
1240 { 0x10001,
"exif:GPSLatitudeRef" },
1241 { 0x10002,
"exif:GPSLatitude" },
1242 { 0x10003,
"exif:GPSLongitudeRef" },
1243 { 0x10004,
"exif:GPSLongitude" },
1244 { 0x10005,
"exif:GPSAltitudeRef" },
1245 { 0x10006,
"exif:GPSAltitude" },
1246 { 0x10007,
"exif:GPSTimeStamp" },
1247 { 0x10008,
"exif:GPSSatellites" },
1248 { 0x10009,
"exif:GPSStatus" },
1249 { 0x1000a,
"exif:GPSMeasureMode" },
1250 { 0x1000b,
"exif:GPSDop" },
1251 { 0x1000c,
"exif:GPSSpeedRef" },
1252 { 0x1000d,
"exif:GPSSpeed" },
1253 { 0x1000e,
"exif:GPSTrackRef" },
1254 { 0x1000f,
"exif:GPSTrack" },
1255 { 0x10010,
"exif:GPSImgDirectionRef" },
1256 { 0x10011,
"exif:GPSImgDirection" },
1257 { 0x10012,
"exif:GPSMapDatum" },
1258 { 0x10013,
"exif:GPSDestLatitudeRef" },
1259 { 0x10014,
"exif:GPSDestLatitude" },
1260 { 0x10015,
"exif:GPSDestLongitudeRef" },
1261 { 0x10016,
"exif:GPSDestLongitude" },
1262 { 0x10017,
"exif:GPSDestBearingRef" },
1263 { 0x10018,
"exif:GPSDestBearing" },
1264 { 0x10019,
"exif:GPSDestDistanceRef" },
1265 { 0x1001a,
"exif:GPSDestDistance" },
1266 { 0x1001b,
"exif:GPSProcessingMethod" },
1267 { 0x1001c,
"exif:GPSAreaInformation" },
1268 { 0x1001d,
"exif:GPSDateStamp" },
1269 { 0x1001e,
"exif:GPSDifferential" },
1270 { 0x1001f,
"exif:GPSHPositioningError" },
1282 directory_stack[MaxDirectoryStack] = { { 0, 0, 0 } };
1306 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1311 profile=GetImageProfile(image,
"exif");
1312 if (profile == (
const StringInfo *) NULL)
1314 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1316 while (isspace((
int) ((
unsigned char) *property)) != 0)
1318 if (strlen(property) <= 5)
1322 switch (*(property+5))
1351 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1362 for (i=(ssize_t) n-1L; i >= 0; i--)
1366 if ((c >=
'0') && (c <=
'9'))
1367 tag|=(size_t) (c-
'0');
1369 if ((c >=
'A') && (c <=
'F'))
1370 tag|=(size_t) (c-(
'A'-10));
1372 if ((c >=
'a') && (c <=
'f'))
1373 tag|=(size_t) (c-(
'a'-10));
1377 }
while (*property !=
'\0');
1387 if (EXIFTag[i].tag == 0)
1389 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1391 tag=(size_t) EXIFTag[i].tag;
1400 length=GetStringInfoLength(profile);
1403 exif=GetStringInfoDatum(profile);
1406 if (ReadPropertyByte(&exif,&length) != 0x45)
1408 if (ReadPropertyByte(&exif,&length) != 0x78)
1410 if (ReadPropertyByte(&exif,&length) != 0x69)
1412 if (ReadPropertyByte(&exif,&length) != 0x66)
1414 if (ReadPropertyByte(&exif,&length) != 0x00)
1416 if (ReadPropertyByte(&exif,&length) != 0x00)
1422 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1431 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1436 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1437 if ((offset < 0) || (
size_t) offset >= length)
1442 directory=exif+offset;
1446 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1447 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1456 directory=directory_stack[level].directory;
1457 entry=directory_stack[level].entry;
1458 tag_offset=directory_stack[level].offset;
1460 if ((directory < exif) || (directory > (exif+length-2)))
1465 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1466 for ( ; entry < number_entries; entry++)
1479 q=(
unsigned char *) (directory+(12*entry)+2);
1480 if (q > (exif+length-12))
1482 if (GetValueFromSplayTree(exif_resources,q) == q)
1484 (void) AddValueToSplayTree(exif_resources,q,q);
1485 tag_value=(size_t) (ReadPropertyUnsignedShort(endian,q)+(ssize_t)
1487 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1488 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1492 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1495 number_bytes=components*(ssize_t) tag_bytes[format];
1496 if (number_bytes < components)
1498 if (number_bytes <= 4)
1508 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1509 if ((dir_offset < 0) || (
size_t) dir_offset >= length)
1511 if (((
size_t) dir_offset+(
size_t) number_bytes) < (
size_t) dir_offset)
1513 if ((
size_t) (dir_offset+(ssize_t) number_bytes) > length)
1515 p=(
unsigned char *) (exif+dir_offset);
1517 if ((all != 0) || (tag == (
size_t) tag_value))
1520 buffer[6*
sizeof(double)+MagickPathExtent],
1523 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1525 value=(
char *) NULL;
1531 value=(
char *) NULL;
1532 if (~((
size_t) number_bytes) >= 1)
1533 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1535 if (value != (
char *) NULL)
1537 for (i=0; i < (ssize_t) number_bytes; i++)
1540 if (isprint((
int) p[i]) != 0)
1541 value[i]=(char) p[i];
1547 case EXIF_FMT_SBYTE:
1549 EXIFMultipleValues(
"%.20g",(
double) (*(
signed char *) p));
1552 case EXIF_FMT_SSHORT:
1554 EXIFMultipleValues(
"%hd",ReadPropertySignedShort(endian,p));
1557 case EXIF_FMT_USHORT:
1559 EXIFMultipleValues(
"%hu",ReadPropertyUnsignedShort(endian,p));
1562 case EXIF_FMT_ULONG:
1564 EXIFMultipleValues(
"%.20g",(
double)
1565 ReadPropertyUnsignedLong(endian,p));
1568 case EXIF_FMT_SLONG:
1570 EXIFMultipleValues(
"%.20g",(
double)
1571 ReadPropertySignedLong(endian,p));
1574 case EXIF_FMT_URATIONAL:
1576 if ((tag_value == GPS_LATITUDE) || (tag_value == GPS_LONGITUDE) ||
1577 (tag_value == GPS_TIMESTAMP))
1579 if (number_bytes < 24)
1582 EXIFGPSFractions(
"%.20g/%.20g,%.20g/%.20g,%.20g/%.20g",
1583 (
double) ReadPropertyUnsignedLong(endian,p),
1584 (
double) ReadPropertyUnsignedLong(endian,p+4),
1585 (
double) ReadPropertyUnsignedLong(endian,p+8),
1586 (
double) ReadPropertyUnsignedLong(endian,p+12),
1587 (
double) ReadPropertyUnsignedLong(endian,p+16),
1588 (
double) ReadPropertyUnsignedLong(endian,p+20));
1591 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1592 ReadPropertyUnsignedLong(endian,p),(
double)
1593 ReadPropertyUnsignedLong(endian,p+4));
1596 case EXIF_FMT_SRATIONAL:
1598 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1599 ReadPropertySignedLong(endian,p),(
double)
1600 ReadPropertySignedLong(endian,p+4));
1603 case EXIF_FMT_SINGLE:
1605 EXIFMultipleValues(
"%.20g",(
double)
1606 ReadPropertySignedLong(endian,p));
1609 case EXIF_FMT_DOUBLE:
1611 EXIFMultipleValues(
"%.20g",(
double)
1612 ReadPropertySignedLong(endian,p));
1615 case EXIF_FMT_STRING:
1616 case EXIF_FMT_UNDEFINED:
1619 if ((p < exif) || (p > (exif+length-number_bytes)))
1621 value=(
char *) NULL;
1622 if (~((
size_t) number_bytes) >= 1)
1623 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1625 if (value != (
char *) NULL)
1627 for (i=0; i < (ssize_t) number_bytes; i++)
1630 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1631 value[i]=(char) p[i];
1638 if (value != (
char *) NULL)
1643 key=AcquireString(property);
1651 description=
"unknown";
1654 if (EXIFTag[i].tag == 0)
1656 if (EXIFTag[i].tag == tag_value)
1658 description=EXIFTag[i].description;
1662 (void) FormatLocaleString(key,MagickPathExtent,
"%s",
1665 (void) SubstituteString(&key,
"exif:",
"exif:Thumbnail.");
1670 if (tag_value < 0x10000)
1671 (void) FormatLocaleString(key,MagickPathExtent,
"#%04lx",
1672 (
unsigned long) tag_value);
1674 if (tag_value < 0x20000)
1675 (void) FormatLocaleString(key,MagickPathExtent,
"@%04lx",
1676 (
unsigned long) (tag_value & 0xffff));
1678 (
void) FormatLocaleString(key,MagickPathExtent,
"unknown");
1684 (void) SubstituteString(&key,
"exif:",
"exif:Thumbnail.");
1687 if ((image->properties == (
void *) NULL) ||
1688 (GetValueFromSplayTree((SplayTreeInfo *) image->properties,key) == (
const void *) NULL))
1689 (void) SetImageProperty((Image *) image,key,value,exception);
1690 value=DestroyString(value);
1691 key=DestroyString(key);
1694 if ((tag_value == TAG_EXIF_OFFSET) ||
1695 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1700 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,p);
1701 if (((
size_t) tag_offset1 < length) &&
1702 (level < (MaxDirectoryStack-2)))
1707 tag_offset2=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1709 directory_stack[level].directory=directory;
1711 directory_stack[level].entry=entry;
1712 directory_stack[level].offset=tag_offset;
1717 for (i=0; i < level; i++)
1718 if (directory_stack[i].directory == (exif+tag_offset1))
1722 directory_stack[level].directory=exif+tag_offset1;
1723 directory_stack[level].offset=tag_offset2;
1724 directory_stack[level].entry=0;
1726 if ((directory+2+(12*number_entries)+4) > (exif+length))
1728 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,directory+
1729 2+(12*number_entries));
1730 if ((tag_offset1 != 0) && ((
size_t) tag_offset1 < length) &&
1731 (level < (MaxDirectoryStack-2)))
1733 directory_stack[level].directory=exif+tag_offset1;
1734 directory_stack[level].entry=0;
1735 directory_stack[level].offset=tag_offset2;
1742 }
while (level > 0);
1743 exif_resources=DestroySplayTree(exif_resources);
1746#if defined(MAGICKCORE_LCMS_DELEGATE)
1747static void GetICCProperty(
const Image *image,ExceptionInfo *exception)
1759 profile=GetImageProfile(image,
"icc");
1760 if (profile == (StringInfo *) NULL)
1761 profile=GetImageProfile(image,
"icm");
1762 if (profile == (StringInfo *) NULL)
1764 if (GetStringInfoLength(profile) < 128)
1766 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1767 (cmsUInt32Number) GetStringInfoLength(profile));
1768 if (icc_profile != (cmsHPROFILE *) NULL)
1770#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1774 name=cmsTakeProductName(icc_profile);
1775 if (name != (
const char *) NULL)
1776 (void) SetImageProperty((Image *) image,
"icc:name",name,exception);
1784 info=AcquireStringInfo(0);
1785 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1789 SetStringInfoLength(info,extent+1);
1790 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1791 "US",(
char *) GetStringInfoDatum(info),extent);
1793 (void) SetImageProperty((Image *) image,
"icc:description",
1794 (
char *) GetStringInfoDatum(info),exception);
1796 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1800 SetStringInfoLength(info,extent+1);
1801 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1802 "US",(
char *) GetStringInfoDatum(info),extent);
1804 (void) SetImageProperty((Image *) image,
"icc:manufacturer",
1805 (
char *) GetStringInfoDatum(info),exception);
1807 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1811 SetStringInfoLength(info,extent+1);
1812 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1813 (
char *) GetStringInfoDatum(info),extent);
1815 (void) SetImageProperty((Image *) image,
"icc:model",
1816 (
char *) GetStringInfoDatum(info),exception);
1818 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1822 SetStringInfoLength(info,extent+1);
1823 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1824 "US",(
char *) GetStringInfoDatum(info),extent);
1826 (void) SetImageProperty((Image *) image,
"icc:copyright",
1827 (
char *) GetStringInfoDatum(info),exception);
1829 info=DestroyStringInfo(info);
1831 (void) cmsCloseProfile(icc_profile);
1836static MagickBooleanType SkipXMPValue(
const char *value)
1838 if (value == (
const char*) NULL)
1840 while (*value !=
'\0')
1842 if (isspace((
int) ((
unsigned char) *value)) == 0)
1843 return(MagickFalse);
1849static void GetXMPProperty(
const Image *image,
const char *property)
1873 profile=GetImageProfile(image,
"xmp");
1874 if (profile == (StringInfo *) NULL)
1876 if (GetStringInfoLength(profile) < 17)
1878 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1880 xmp_profile=StringInfoToString(profile);
1881 if (xmp_profile == (
char *) NULL)
1883 for (p=xmp_profile; *p !=
'\0'; p++)
1884 if ((*p ==
'<') && (*(p+1) ==
'x'))
1886 exception=AcquireExceptionInfo();
1887 xmp=NewXMLTree((
char *) p,exception);
1888 xmp_profile=DestroyString(xmp_profile);
1889 exception=DestroyExceptionInfo(exception);
1890 if (xmp == (XMLTreeInfo *) NULL)
1892 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1893 if (rdf != (XMLTreeInfo *) NULL)
1895 if (image->properties == (
void *) NULL)
1896 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1897 RelinquishMagickMemory,RelinquishMagickMemory);
1898 description=GetXMLTreeChild(rdf,
"rdf:Description");
1899 while (description != (XMLTreeInfo *) NULL)
1905 xmp_namespace_length;
1907 node=GetXMLTreeChild(description,(
const char *) NULL);
1908 while (node != (XMLTreeInfo *) NULL)
1910 child=GetXMLTreeChild(node,(
const char *) NULL);
1911 content=GetXMLTreeContent(node);
1912 if ((child == (XMLTreeInfo *) NULL) &&
1913 (SkipXMPValue(content) == MagickFalse))
1915 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1916 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1917 xmp_namespace_length=strlen(xmp_namespace);
1918 if ((xmp_namespace_length <= 2) ||
1919 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1920 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1921 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1922 ConstantString(xmp_namespace),ConstantString(content));
1923 xmp_namespace=DestroyString(xmp_namespace);
1925 while (child != (XMLTreeInfo *) NULL)
1927 content=GetXMLTreeContent(child);
1928 if (SkipXMPValue(content) == MagickFalse)
1930 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1931 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1932 xmp_namespace_length=strlen(xmp_namespace);
1933 if ((xmp_namespace_length <= 2) ||
1934 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1935 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1936 (void) AddValueToSplayTree((SplayTreeInfo *)
1937 image->properties,ConstantString(xmp_namespace),
1938 ConstantString(content));
1939 xmp_namespace=DestroyString(xmp_namespace);
1941 child=GetXMLTreeSibling(child);
1943 node=GetXMLTreeSibling(node);
1945 description=GetNextXMLTreeTag(description);
1948 xmp=DestroyXMLTree(xmp);
1951static char *TracePSClippath(
const unsigned char *blob,
size_t length)
1974 path=AcquireString((
char *) NULL);
1975 if (path == (
char *) NULL)
1976 return((
char *) NULL);
1977 message=AcquireString((
char *) NULL);
1978 (void) FormatLocaleString(message,MagickPathExtent,
"/ClipImage\n");
1979 (void) ConcatenateString(&path,message);
1980 (void) FormatLocaleString(message,MagickPathExtent,
"{\n");
1981 (void) ConcatenateString(&path,message);
1982 (void) FormatLocaleString(message,MagickPathExtent,
1983 " /c {curveto} bind def\n");
1984 (void) ConcatenateString(&path,message);
1985 (void) FormatLocaleString(message,MagickPathExtent,
1986 " /l {lineto} bind def\n");
1987 (void) ConcatenateString(&path,message);
1988 (void) FormatLocaleString(message,MagickPathExtent,
1989 " /m {moveto} bind def\n");
1990 (void) ConcatenateString(&path,message);
1991 (void) FormatLocaleString(message,MagickPathExtent,
1992 " /v {currentpoint 6 2 roll curveto} bind def\n");
1993 (void) ConcatenateString(&path,message);
1994 (void) FormatLocaleString(message,MagickPathExtent,
1995 " /y {2 copy curveto} bind def\n");
1996 (void) ConcatenateString(&path,message);
1997 (void) FormatLocaleString(message,MagickPathExtent,
1998 " /z {closepath} bind def\n");
1999 (void) ConcatenateString(&path,message);
2000 (void) FormatLocaleString(message,MagickPathExtent,
" newpath\n");
2001 (void) ConcatenateString(&path,message);
2006 (void) memset(point,0,
sizeof(point));
2007 (void) memset(first,0,
sizeof(first));
2008 (void) memset(last,0,
sizeof(last));
2010 in_subpath=MagickFalse;
2013 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2019 if (knot_count != 0)
2022 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2028 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2030 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2038 if (knot_count == 0)
2044 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2050 for (i=0; i < 3; i++)
2052 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2053 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2054 point[i].x=(double) x/4096.0/4096.0;
2055 point[i].y=1.0-(double) y/4096.0/4096.0;
2057 if (in_subpath == MagickFalse)
2059 (void) FormatLocaleString(message,MagickPathExtent,
" %g %g m\n",
2060 point[1].x,point[1].y);
2061 for (i=0; i < 3; i++)
2073 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2074 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2075 (void) FormatLocaleString(message,MagickPathExtent,
2076 " %g %g l\n",point[1].x,point[1].y);
2078 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2079 (void) FormatLocaleString(message,MagickPathExtent,
2080 " %g %g %g %g v\n",point[0].x,point[0].y,
2081 point[1].x,point[1].y);
2083 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2084 (void) FormatLocaleString(message,MagickPathExtent,
2085 " %g %g %g %g y\n",last[2].x,last[2].y,
2086 point[1].x,point[1].y);
2088 (
void) FormatLocaleString(message,MagickPathExtent,
2089 " %g %g %g %g %g %g c\n",last[2].x,
2090 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2091 for (i=0; i < 3; i++)
2094 (void) ConcatenateString(&path,message);
2095 in_subpath=MagickTrue;
2100 if (knot_count == 0)
2106 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2107 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2108 (void) FormatLocaleString(message,MagickPathExtent,
2109 " %g %g l z\n",first[1].x,first[1].y);
2111 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2112 (void) FormatLocaleString(message,MagickPathExtent,
2113 " %g %g %g %g v z\n",first[0].x,first[0].y,
2114 first[1].x,first[1].y);
2116 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2117 (void) FormatLocaleString(message,MagickPathExtent,
2118 " %g %g %g %g y z\n",last[2].x,last[2].y,
2119 first[1].x,first[1].y);
2121 (
void) FormatLocaleString(message,MagickPathExtent,
2122 " %g %g %g %g %g %g c z\n",last[2].x,
2123 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2124 (void) ConcatenateString(&path,message);
2125 in_subpath=MagickFalse;
2135 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2143 (void) FormatLocaleString(message,MagickPathExtent,
" eoclip\n");
2144 (void) ConcatenateString(&path,message);
2145 (void) FormatLocaleString(message,MagickPathExtent,
"} bind def");
2146 (void) ConcatenateString(&path,message);
2147 message=DestroyString(message);
2151static inline void TraceBezierCurve(
char *message,PointInfo *last,
2158 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2159 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2160 (void) FormatLocaleString(message,MagickPathExtent,
2161 "L %g %g\n",point[1].x,point[1].y);
2163 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2164 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2167static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2168 const size_t columns,
const size_t rows)
2191 path=AcquireString((
char *) NULL);
2192 if (path == (
char *) NULL)
2193 return((
char *) NULL);
2194 message=AcquireString((
char *) NULL);
2195 (void) FormatLocaleString(message,MagickPathExtent,(
2196 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2197 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2198 " width=\"%.20g\" height=\"%.20g\">\n"
2200 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2201 "stroke-width:0;shape-rendering:crispEdges\" d=\"\n"),(
double) columns,
2203 (void) ConcatenateString(&path,message);
2204 (void) memset(point,0,
sizeof(point));
2205 (void) memset(first,0,
sizeof(first));
2206 (void) memset(last,0,
sizeof(last));
2208 in_subpath=MagickFalse;
2211 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2217 if (knot_count != 0)
2220 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2226 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2228 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2236 if (knot_count == 0)
2242 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2248 for (i=0; i < 3; i++)
2250 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2251 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2252 point[i].x=(double) x*columns/4096.0/4096.0;
2253 point[i].y=(double) y*rows/4096.0/4096.0;
2255 if (in_subpath == MagickFalse)
2257 (void) FormatLocaleString(message,MagickPathExtent,
"M %g %g\n",
2258 point[1].x,point[1].y);
2259 for (i=0; i < 3; i++)
2267 TraceBezierCurve(message,last,point);
2268 for (i=0; i < 3; i++)
2271 (void) ConcatenateString(&path,message);
2272 in_subpath=MagickTrue;
2277 if (knot_count == 0)
2279 TraceBezierCurve(message,last,first);
2280 (void) ConcatenateString(&path,message);
2281 in_subpath=MagickFalse;
2291 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2299 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2300 message=DestroyString(message);
2304MagickExport
const char *GetImageProperty(
const Image *image,
2305 const char *property,ExceptionInfo *exception)
2308 read_from_properties;
2316 assert(image != (Image *) NULL);
2317 assert(image->signature == MagickCoreSignature);
2318 if (IsEventLogging() != MagickFalse)
2319 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2320 if ((property == (
const char *) NULL) || (*property ==
'\0'))
2321 return((
const char *) NULL);
2322 read_from_properties=MagickTrue;
2323 property_length=strlen(property);
2324 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
2325 (*(property+(property_length-1)) ==
'*'))
2326 read_from_properties=MagickFalse;
2327 if (read_from_properties != MagickFalse)
2329 p=(
const char *) NULL;
2330 if (image->properties != (
void *) NULL)
2332 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2333 image->properties,property);
2334 if (p != (
const char *) NULL)
2337 if (strchr(property,
':') == (
char *) NULL)
2344 if (LocaleNCompare(
"8bim:",property,5) == 0)
2346 Get8BIMProperty(image,property,exception);
2354 if (LocaleNCompare(
"exif:",property,5) == 0)
2356 GetEXIFProperty(image,property,exception);
2364 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2365 (LocaleNCompare(
"icm:",property,4) == 0))
2367#if defined(MAGICKCORE_LCMS_DELEGATE)
2368 GetICCProperty(image,exception);
2372 if (LocaleNCompare(
"iptc:",property,5) == 0)
2374 GetIPTCProperty(image,property,exception);
2382 if (LocaleNCompare(
"xmp:",property,4) == 0)
2384 GetXMPProperty(image,property);
2392 if ((image->properties != (
void *) NULL) &&
2393 (read_from_properties != MagickFalse))
2395 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2396 image->properties,property);
2399 return((
const char *) NULL);
2493static const char *GetMagickPropertyLetter(ImageInfo *image_info,
2494 Image *image,
const char letter,ExceptionInfo *exception)
2496#define WarnNoImageReturn(format,arg) \
2497 if (image == (Image *) NULL ) { \
2498 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2499 "NoImageForProperty",format,arg); \
2500 return((const char *) NULL); \
2502#define WarnNoImageInfoReturn(format,arg) \
2503 if (image_info == (ImageInfo *) NULL ) { \
2504 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2505 "NoImageInfoForProperty",format,arg); \
2506 return((const char *) NULL); \
2510 value[MagickPathExtent];
2515 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2516 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2518 if ((image_info != (ImageInfo *) NULL) &&
2519 (IsEventLogging() != MagickFalse))
2520 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2522 string=(
char *) NULL;
2530 WarnNoImageReturn(
"\"%%%c\"",letter);
2531 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
2533 if (image->extent == 0)
2534 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
2535 MagickPathExtent,value);
2540 WarnNoImageReturn(
"\"%%%c\"",letter);
2541 string=GetImageProperty(image,
"comment",exception);
2542 if (
string == (
const char *) NULL )
2548 WarnNoImageReturn(
"\"%%%c\"",letter);
2549 GetPathComponent(image->magick_filename,HeadPath,value);
2556 WarnNoImageReturn(
"\"%%%c\"",letter);
2557 GetPathComponent(image->magick_filename,ExtensionPath,value);
2564 WarnNoImageReturn(
"\"%%%c\"",letter);
2565 GetPathComponent(image->magick_filename,TailPath,value);
2572 WarnNoImageReturn(
"\"%%%c\"",letter);
2573 (void) FormatLocaleString(value,MagickPathExtent,
2574 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(
double)
2575 image->page.height,(
double) image->page.x,(
double) image->page.y);
2580 WarnNoImageReturn(
"\"%%%c\"",letter);
2581 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2582 (image->rows != 0 ? image->rows : image->magick_rows));
2587 WarnNoImageReturn(
"\"%%%c\"",letter);
2588 string=image->filename;
2596 WarnNoImageReturn(
"\"%%%c\"",letter);
2597 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2598 GetNumberColors(image,(FILE *) NULL,exception));
2603 WarnNoImageReturn(
"\"%%%c\"",letter);
2604 string=GetImageProperty(image,
"label",exception);
2605 if (
string == (
const char *) NULL)
2611 WarnNoImageReturn(
"\"%%%c\"",letter);
2612 string=image->magick;
2617 if ( image != (Image *) NULL )
2618 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2619 GetImageListLength(image));
2626 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2627 string=image_info->filename;
2632 WarnNoImageReturn(
"\"%%%c\"",letter);
2633 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2634 GetImageIndexInList(image));
2639 WarnNoImageReturn(
"\"%%%c\"",letter);
2640 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2641 MAGICKCORE_QUANTUM_DEPTH);
2649 WarnNoImageReturn(
"\"%%%c\"",letter);
2650 colorspace=image->colorspace;
2651 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
2652 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2653 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2654 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2661 if (image_info->number_scenes != 0)
2662 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2664 else if (image != (Image *) NULL)
2665 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2670 WarnNoImageReturn(
"\"%%%c\"",letter);
2671 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2678 WarnNoImageReturn(
"\"%%%c\"",letter);
2679 GetPathComponent(image->magick_filename,BasePath,value);
2686 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2687 string=image_info->unique;
2692 WarnNoImageReturn(
"\"%%%c\"",letter);
2693 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2694 (image->columns != 0 ? image->columns : image->magick_columns));
2699 WarnNoImageReturn(
"\"%%%c\"",letter);
2700 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2701 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
2702 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2708 WarnNoImageReturn(
"\"%%%c\"",letter);
2709 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2710 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
2711 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2717 WarnNoImageReturn(
"\"%%%c\"",letter);
2718 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2724 WarnNoImageReturn(
"\"%%%c\"",letter);
2725 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2726 image->alpha_trait);
2731 WarnNoImageReturn(
"\"%%%c\"",letter);
2732 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2734 if (image->extent == 0)
2735 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2736 GetBlobSize(image));
2741 WarnNoImageReturn(
"\"%%%c\"",letter);
2742 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2743 image->compression);
2748 WarnNoImageReturn(
"\"%%%c\"",letter);
2749 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2755 WarnNoImageReturn(
"\"%%%c\"",letter);
2756 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2757 image->magick_columns,(
double) image->magick_rows);
2762 WarnNoImageReturn(
"\"%%%c\"",letter);
2763 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2764 image->page.height);
2769 WarnNoImageReturn(
"\"%%%c\"",letter);
2770 string=image->magick_filename;
2775 if ((image != (Image *) NULL) && (image->next == (Image *) NULL))
2776 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2777 GetImageListLength(image));
2784 WarnNoImageReturn(
"\"%%%c\"",letter);
2785 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
2786 image->page.x,(
long) image->page.y);
2791 WarnNoImageReturn(
"\"%%%c\"",letter);
2792 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2793 image->page.width,(
double) image->page.height);
2798 WarnNoImageReturn(
"\"%%%c\"",letter);
2799 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2800 (image->quality == 0 ? 92 : image->quality));
2805 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2807 if (image_info->number_scenes == 0)
2808 string=
"2147483647";
2809 else if ( image != (Image *) NULL )
2810 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2811 image_info->scene+image_info->number_scenes);
2815 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2816 (image_info->number_scenes == 0 ? 2147483647 :
2817 image_info->number_scenes));
2823 WarnNoImageReturn(
"\"%%%c\"",letter);
2824 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2830 WarnNoImageReturn(
"\"%%%c\"",letter);
2831 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2837 WarnNoImageReturn(
"\"%%%c\"",letter);
2838 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2844 WarnNoImageReturn(
"\"%%%c\"",letter);
2845 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2851 WarnNoImageReturn(
"\"%%%c\"",letter);
2852 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2866 WarnNoImageReturn(
"\"%%%c\"",letter);
2867 page=GetImageBoundingBox(image,exception);
2868 (void) FormatLocaleString(value,MagickPathExtent,
2869 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(
double) page.height,
2870 (
double) page.x,(
double)page.y);
2878 WarnNoImageReturn(
"\"%%%c\"",letter);
2879 if ((image->columns != 0) && (image->rows != 0))
2880 (void) SignatureImage(image,exception);
2881 string=GetImageProperty(image,
"signature",exception);
2885 if (
string != (
char *) NULL)
2892 if (image != (Image *) NULL)
2894 (void) SetImageArtifact(image,
"magick-property",value);
2895 return(GetImageArtifact(image,
"magick-property"));
2899 (void) SetImageOption(image_info,
"magick-property",value);
2900 return(GetImageOption(image_info,
"magick-property"));
2903 return((
char *) NULL);
2906MagickExport
const char *GetMagickProperty(ImageInfo *image_info,
2907 Image *image,
const char *property,ExceptionInfo *exception)
2910 value[MagickPathExtent];
2915 assert(property != (
const char *) NULL);
2916 assert(property[0] !=
'\0');
2917 assert(image != (Image *) NULL || image_info != (ImageInfo *) NULL );
2918 if (property[1] ==
'\0')
2919 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2920 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
2921 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2923 if ((image_info != (ImageInfo *) NULL) &&
2924 (IsEventLogging() != MagickFalse))
2925 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2927 string=(
char *) NULL;
2932 if (LocaleCompare(
"basename",property) == 0)
2934 WarnNoImageReturn(
"\"%%[%s]\"",property);
2935 GetPathComponent(image->magick_filename,BasePath,value);
2940 if (LocaleCompare(
"bit-depth",property) == 0)
2942 WarnNoImageReturn(
"\"%%[%s]\"",property);
2943 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2944 GetImageDepth(image,exception));
2947 if (LocaleCompare(
"bounding-box",property) == 0)
2952 WarnNoImageReturn(
"\"%%[%s]\"",property);
2953 geometry=GetImageBoundingBox(image,exception);
2954 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g",
2955 (
double) geometry.x,(
double) geometry.y,
2956 (
double) geometry.x+geometry.width,
2957 (
double) geometry.y+geometry.height);
2964 if (LocaleCompare(
"channels",property) == 0)
2966 WarnNoImageReturn(
"\"%%[%s]\"",property);
2967 (void) FormatLocaleString(value,MagickPathExtent,
"%s%s %g.%g",
2968 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2969 image->colorspace),image->alpha_trait != UndefinedPixelTrait ?
2970 "a" :
" ",(
double) image->number_channels,(
double)
2971 image->number_meta_channels);
2975 if (LocaleCompare(
"colors",property) == 0)
2977 WarnNoImageReturn(
"\"%%[%s]\"",property);
2978 image->colors=GetNumberColors(image,(FILE *) NULL,exception);
2979 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2983 if (LocaleCompare(
"colorspace",property) == 0)
2985 WarnNoImageReturn(
"\"%%[%s]\"",property);
2986 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2990 if (LocaleCompare(
"compose",property) == 0)
2992 WarnNoImageReturn(
"\"%%[%s]\"",property);
2993 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2997 if (LocaleCompare(
"compression",property) == 0)
2999 WarnNoImageReturn(
"\"%%[%s]\"",property);
3000 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
3001 image->compression);
3004 if (LocaleCompare(
"convex-hull",property) == 0)
3018 WarnNoImageReturn(
"\"%%[%s]\"",property);
3019 convex_hull=GetImageConvexHull(image,&number_points,exception);
3020 if (convex_hull == (PointInfo *) NULL)
3022 points=AcquireString(
"");
3023 for (n=0; n < (ssize_t) number_points; n++)
3025 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3026 convex_hull[n].x,convex_hull[n].y);
3027 (void) ConcatenateString(&points,value);
3029 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
3030 (void) SetImageProperty(image,
"convex-hull",points,exception);
3031 points=DestroyString(points);
3032 string=GetImageProperty(image,
"convex-hull",exception);
3035 if (LocaleCompare(
"convex-hull:extreme-points",property) == 0)
3050 WarnNoImageReturn(
"\"%%[%s]\"",property);
3051 convex_hull=GetImageConvexHull(image,&number_points,exception);
3052 if (convex_hull == (PointInfo *) NULL)
3054 points=AcquireString(
"");
3055 extreme=convex_hull[0];
3056 for (n=0; n < (ssize_t) number_points; n++)
3058 if (convex_hull[n].y < extreme.y)
3060 extreme=convex_hull[n];
3063 if (convex_hull[n].y != extreme.y)
3065 if (convex_hull[n].x < extreme.x)
3066 extreme=convex_hull[n];
3068 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3069 extreme.x,extreme.y);
3070 (void) ConcatenateString(&points,value);
3071 extreme=convex_hull[0];
3072 for (n=0; n < (ssize_t) number_points; n++)
3074 if (convex_hull[n].x > extreme.x)
3076 extreme=convex_hull[n];
3079 if (convex_hull[n].x != extreme.x)
3081 if (convex_hull[n].y < extreme.y)
3082 extreme=convex_hull[n];
3084 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3085 extreme.x,extreme.y);
3086 (void) ConcatenateString(&points,value);
3087 extreme=convex_hull[0];
3088 for (n=0; n < (ssize_t) number_points; n++)
3090 if (convex_hull[n].y > extreme.y)
3092 extreme=convex_hull[n];
3095 if (convex_hull[n].y != extreme.y)
3097 if (convex_hull[n].x > extreme.x)
3098 extreme=convex_hull[n];
3100 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3101 extreme.x,extreme.y);
3102 (void) ConcatenateString(&points,value);
3103 extreme=convex_hull[0];
3104 for (n=0; n < (ssize_t) number_points; n++)
3106 if (convex_hull[n].x < extreme.x)
3108 extreme=convex_hull[n];
3111 if (convex_hull[n].x != extreme.x)
3113 if (convex_hull[n].y > extreme.y)
3114 extreme=convex_hull[n];
3116 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3117 extreme.x,extreme.y);
3118 (void) ConcatenateString(&points,value);
3119 convex_hull=(PointInfo *) RelinquishMagickMemory(convex_hull);
3120 (void) SetImageProperty(image,
"convex-hull:extreme-points",points,
3122 points=DestroyString(points);
3123 string=GetImageProperty(image,
"convex-hull:extreme-points",exception);
3126 if (LocaleCompare(
"copyright",property) == 0)
3128 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
3135 if (LocaleCompare(
"depth",property) == 0)
3137 WarnNoImageReturn(
"\"%%[%s]\"",property);
3138 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3142 if (LocaleCompare(
"directory",property) == 0)
3144 WarnNoImageReturn(
"\"%%[%s]\"",property);
3145 GetPathComponent(image->magick_filename,HeadPath,value);
3154 if (LocaleCompare(
"entropy",property) == 0)
3159 WarnNoImageReturn(
"\"%%[%s]\"",property);
3160 (void) GetImageEntropy(image,&entropy,exception);
3161 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3162 GetMagickPrecision(),entropy);
3165 if (LocaleCompare(
"extension",property) == 0)
3167 WarnNoImageReturn(
"\"%%[%s]\"",property);
3168 GetPathComponent(image->magick_filename,ExtensionPath,value);
3177 if (LocaleCompare(
"gamma",property) == 0)
3179 WarnNoImageReturn(
"\"%%[%s]\"",property);
3180 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3181 GetMagickPrecision(),image->gamma);
3188 if (LocaleCompare(
"height",property) == 0)
3190 WarnNoImageReturn(
"\"%%[%s]\"",property);
3191 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
3192 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3199 if (LocaleCompare(
"input",property) == 0)
3201 WarnNoImageReturn(
"\"%%[%s]\"",property);
3202 string=image->filename;
3205 if (LocaleCompare(
"interlace",property) == 0)
3207 WarnNoImageReturn(
"\"%%[%s]\"",property);
3208 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3216 if (LocaleCompare(
"kurtosis",property) == 0)
3222 WarnNoImageReturn(
"\"%%[%s]\"",property);
3223 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3224 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3225 GetMagickPrecision(),kurtosis);
3232 if (LocaleCompare(
"magick",property) == 0)
3234 WarnNoImageReturn(
"\"%%[%s]\"",property);
3235 string=image->magick;
3238 if ((LocaleCompare(
"maxima",property) == 0) ||
3239 (LocaleCompare(
"max",property) == 0))
3245 WarnNoImageReturn(
"\"%%[%s]\"",property);
3246 (void) GetImageRange(image,&minimum,&maximum,exception);
3247 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3248 GetMagickPrecision(),maximum);
3251 if (LocaleCompare(
"mean",property) == 0)
3257 WarnNoImageReturn(
"\"%%[%s]\"",property);
3258 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3259 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3260 GetMagickPrecision(),mean);
3263 if (LocaleCompare(
"median",property) == 0)
3268 WarnNoImageReturn(
"\"%%[%s]\"",property);
3269 (void) GetImageMedian(image,&median,exception);
3270 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3271 GetMagickPrecision(),median);
3274 if (LocaleCompare(
"mime:type",property) == 0)
3279 magick_info=GetMagickInfo(image->magick,exception);
3280 if ((magick_info != (
const MagickInfo *) NULL) &&
3281 (GetMagickMimeType(magick_info) != (
const char *) NULL))
3282 (void) CopyMagickString(value,GetMagickMimeType(magick_info),
3286 if ((LocaleCompare(
"minima",property) == 0) ||
3287 (LocaleCompare(
"min",property) == 0))
3293 WarnNoImageReturn(
"\"%%[%s]\"",property);
3294 (void) GetImageRange(image,&minimum,&maximum,exception);
3295 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3296 GetMagickPrecision(),minimum);
3299 if (LocaleNCompare(
"minimum-bounding-box",property,20) == 0)
3313 WarnNoImageReturn(
"\"%%[%s]\"",property);
3314 bounding_box=GetImageMinimumBoundingBox(image,&number_points,
3316 if (bounding_box == (PointInfo *) NULL)
3318 points=AcquireString(
"");
3319 for (n=0; n < (ssize_t) number_points; n++)
3321 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3322 bounding_box[n].x,bounding_box[n].y);
3323 (void) ConcatenateString(&points,value);
3325 bounding_box=(PointInfo *) RelinquishMagickMemory(bounding_box);
3326 (void) SetImageProperty(image,
"minimum-bounding-box",points,
3328 points=DestroyString(points);
3329 string=GetImageProperty(image,property,exception);
3336 if (LocaleCompare(
"opaque",property) == 0)
3338 WarnNoImageReturn(
"\"%%[%s]\"",property);
3339 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
3340 IsImageOpaque(image,exception));
3343 if (LocaleCompare(
"orientation",property) == 0)
3345 WarnNoImageReturn(
"\"%%[%s]\"",property);
3346 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3347 image->orientation);
3350 if (LocaleCompare(
"output",property) == 0)
3352 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3353 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
3360 if (LocaleCompare(
"page",property) == 0)
3362 WarnNoImageReturn(
"\"%%[%s]\"",property);
3363 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3364 (
double) image->page.width,(
double) image->page.height);
3367 if (LocaleNCompare(
"papersize:",property,10) == 0)
3372 WarnNoImageReturn(
"\"%%[%s]\"",property);
3374 papersize=GetPageGeometry(property+10);
3375 if (papersize != (
const char *) NULL)
3378 page = { 0, 0, 0, 0 };
3380 (void) ParseAbsoluteGeometry(papersize,&page);
3381 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3382 (
double) page.width,(
double) page.height);
3383 papersize=DestroyString(papersize);
3387#if defined(MAGICKCORE_LCMS_DELEGATE)
3388 if (LocaleCompare(
"profile:icc",property) == 0 ||
3389 LocaleCompare(
"profile:icm",property) == 0)
3391#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3392#define cmsUInt32Number DWORD
3401 WarnNoImageReturn(
"\"%%[%s]\"",property);
3402 profile=GetImageProfile(image,property+8);
3403 if (profile == (StringInfo *) NULL)
3405 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3406 (cmsUInt32Number) GetStringInfoLength(profile));
3407 if (icc_profile != (cmsHPROFILE *) NULL)
3409#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3410 string=cmsTakeProductName(icc_profile);
3412 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3413 "en",
"US",value,MagickPathExtent);
3415 (void) cmsCloseProfile(icc_profile);
3419 if (LocaleCompare(
"printsize.x",property) == 0)
3421 WarnNoImageReturn(
"\"%%[%s]\"",property);
3422 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3423 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3424 image->resolution.x)*image->columns);
3427 if (LocaleCompare(
"printsize.y",property) == 0)
3429 WarnNoImageReturn(
"\"%%[%s]\"",property);
3430 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3431 GetMagickPrecision(),(
double) MagickSafeReciprocal(
3432 image->resolution.y)*image->rows);
3435 if (LocaleCompare(
"profiles",property) == 0)
3440 WarnNoImageReturn(
"\"%%[%s]\"",property);
3441 ResetImageProfileIterator(image);
3442 name=GetNextImageProfile(image);
3443 if (name != (
char *) NULL)
3445 (void) CopyMagickString(value,name,MagickPathExtent);
3446 name=GetNextImageProfile(image);
3447 while (name != (
char *) NULL)
3449 ConcatenateMagickString(value,
",",MagickPathExtent);
3450 ConcatenateMagickString(value,name,MagickPathExtent);
3451 name=GetNextImageProfile(image);
3460 if (LocaleCompare(
"quality",property) == 0)
3462 WarnNoImageReturn(
"\"%%[%s]\"",property);
3463 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3471 if (LocaleCompare(
"resolution.x",property) == 0)
3473 WarnNoImageReturn(
"\"%%[%s]\"",property);
3474 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3475 image->resolution.x);
3478 if (LocaleCompare(
"resolution.y",property) == 0)
3480 WarnNoImageReturn(
"\"%%[%s]\"",property);
3481 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3482 image->resolution.y);
3489 if (LocaleCompare(
"scene",property) == 0)
3491 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3492 if (image_info->number_scenes != 0)
3493 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3496 WarnNoImageReturn(
"\"%%[%s]\"",property);
3497 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3502 if (LocaleCompare(
"scenes",property) == 0)
3505 WarnNoImageReturn(
"\"%%[%s]\"",property);
3506 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3507 GetImageListLength(image));
3510 if (LocaleCompare(
"size",property) == 0)
3512 WarnNoImageReturn(
"\"%%[%s]\"",property);
3513 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
3514 MagickPathExtent,value);
3517 if (LocaleCompare(
"skewness",property) == 0)
3523 WarnNoImageReturn(
"\"%%[%s]\"",property);
3524 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3525 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3526 GetMagickPrecision(),skewness);
3529 if (LocaleCompare(
"standard-deviation",property) == 0)
3535 WarnNoImageReturn(
"\"%%[%s]\"",property);
3536 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3537 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3538 GetMagickPrecision(),standard_deviation);
3545 if (LocaleCompare(
"type",property) == 0)
3547 WarnNoImageReturn(
"\"%%[%s]\"",property);
3548 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3549 IdentifyImageType(image,exception));
3556 if (LocaleCompare(
"unique",property) == 0)
3558 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3559 string=image_info->unique;
3562 if (LocaleCompare(
"units",property) == 0)
3564 WarnNoImageReturn(
"\"%%[%s]\"",property);
3565 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3573 if (LocaleCompare(
"version",property) == 0)
3575 string=GetMagickVersion((
size_t *) NULL);
3582 if (LocaleCompare(
"width",property) == 0)
3584 WarnNoImageReturn(
"\"%%[%s]\"",property);
3585 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3586 (image->magick_columns != 0 ? image->magick_columns : 256));
3592 if (
string != (
char *) NULL)
3599 if (image != (Image *) NULL)
3601 (void) SetImageArtifact(image,
"magick-property",value);
3602 return(GetImageArtifact(image,
"magick-property"));
3606 (void) SetImageOption(image_info,
"magick-property",value);
3607 return(GetImageOption(image_info,
"magick-property"));
3610 return((
char *) NULL);
3612#undef WarnNoImageReturn
3636MagickExport
const char *GetNextImageProperty(
const Image *image)
3638 assert(image != (Image *) NULL);
3639 assert(image->signature == MagickCoreSignature);
3640 if (IsEventLogging() != MagickFalse)
3641 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3643 if (image->properties == (
void *) NULL)
3644 return((
const char *) NULL);
3645 return((
const char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3702MagickExport
char *InterpretImageProperties(ImageInfo *image_info,Image *image,
3703 const char *embed_text,ExceptionInfo *exception)
3705#define ExtendInterpretText(string_length) \
3707 size_t length=(string_length); \
3708 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3711 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3712 MagickPathExtent,sizeof(*interpret_text)); \
3713 if (interpret_text == (char *) NULL) \
3715 if (property_image != image) \
3716 property_image=DestroyImage(property_image); \
3717 if (property_info != image_info) \
3718 property_info=DestroyImageInfo(property_info); \
3719 return((char *) NULL); \
3721 q=interpret_text+strlen(interpret_text); \
3725#define AppendKeyValue2Text(key,value)\
3727 size_t length=strlen(key)+strlen(value)+2; \
3728 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3731 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3732 MagickPathExtent,sizeof(*interpret_text)); \
3733 if (interpret_text == (char *) NULL) \
3735 if (property_image != image) \
3736 property_image=DestroyImage(property_image); \
3737 if (property_info != image_info) \
3738 property_info=DestroyImageInfo(property_info); \
3739 return((char *) NULL); \
3741 q=interpret_text+strlen(interpret_text); \
3743 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3746#define AppendString2Text(string) \
3748 size_t length = strlen((string)); \
3749 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3752 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3753 MagickPathExtent,sizeof(*interpret_text)); \
3754 if (interpret_text == (char *) NULL) \
3756 if (property_image != image) \
3757 property_image=DestroyImage(property_image); \
3758 if (property_info != image_info) \
3759 property_info=DestroyImageInfo(property_info); \
3760 return((char *) NULL); \
3762 q=interpret_text+strlen(interpret_text); \
3764 (void) CopyMagickString(q,(string),extent); \
3765 q+=(ptrdiff_t) length; \
3787 if ((image != (Image *) NULL) && (IsEventLogging() != MagickFalse))
3788 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3790 if ((image_info != (ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
3791 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3792 image_info->filename);
3794 if (IsEventLogging() != MagickFalse)
3795 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no image");
3796 if (embed_text == (
const char *) NULL)
3797 return(ConstantString(
""));
3799 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3802 return(ConstantString(
""));
3803 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3808 interpret_text=FileToString(p,~0UL,exception);
3809 if (interpret_text != (
char *) NULL)
3810 return(interpret_text);
3815 if (image_info != (ImageInfo *) NULL)
3816 property_info=image_info;
3818 property_info=CloneImageInfo(image_info);
3819 if ((image != (Image *) NULL) && (image->columns != 0) && (image->rows != 0))
3820 property_image=image;
3823 property_image=AcquireImage(image_info,exception);
3824 (void) SetImageExtent(property_image,1,1,exception);
3825 (void) SetImageBackgroundColor(property_image,exception);
3827 interpret_text=AcquireString(embed_text);
3828 extent=MagickPathExtent;
3830 for (q=interpret_text; *p!=
'\0'; number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
3836 ExtendInterpretText(MagickPathExtent);
3879 if (LocaleNCompare(
"<",p,4) == 0)
3885 if (LocaleNCompare(
">",p,4) == 0)
3891 if (LocaleNCompare(
"&",p,5) == 0)
3912 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3927 if (number != MagickFalse)
3936 string=GetMagickPropertyLetter(property_info,image,*p,exception);
3937 if (
string != (
char *) NULL)
3939 AppendString2Text(
string);
3940 (void) DeleteImageArtifact(property_image,
"magick-property");
3941 (void) DeleteImageOption(property_info,
"magick-property");
3944 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3945 "UnknownImageProperty",
"\"%%%c\"",*p);
3950 pattern[2*MagickPathExtent] =
"\0";
3969 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3970 "UnknownImageProperty",
"\"%%[]\"");
3973 for (len=0; len < (MagickPathExtent-1L) && (*p !=
'\0'); )
3975 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3980 pattern[len++]=(*p++);
3981 pattern[len++]=(*p++);
3990 pattern[len++]=(*p++);
4005 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4006 "UnbalancedBraces",
"\"%%[%s\"",pattern);
4007 interpret_text=DestroyString(interpret_text);
4008 if (property_image != image)
4009 property_image=DestroyImage(property_image);
4010 if (property_info != image_info)
4011 property_info=DestroyImageInfo(property_info);
4012 return((
char *) NULL);
4017 if (LocaleNCompare(
"fx:",pattern,3) == 0)
4031 fx_info=AcquireFxInfo(property_image,pattern+3,exception);
4032 if (fx_info == (FxInfo *) NULL)
4034 status=FxEvaluateChannelExpression(fx_info,CompositePixelChannel,0,0,
4036 fx_info=DestroyFxInfo(fx_info);
4037 if (status != MagickFalse)
4040 result[MagickPathExtent];
4042 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
4043 GetMagickPrecision(),(
double) value);
4044 AppendString2Text(result);
4048 if (LocaleNCompare(
"hex:",pattern,4) == 0)
4065 GetPixelInfo(property_image,&pixel);
4066 fx_info=AcquireFxInfo(property_image,pattern+4,exception);
4067 if (fx_info == (FxInfo *) NULL)
4069 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4071 pixel.red=(double) QuantumRange*value;
4072 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4073 GreenPixelChannel,0,0,&value,exception);
4074 pixel.green=(double) QuantumRange*value;
4075 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4076 BluePixelChannel,0,0,&value,exception);
4077 pixel.blue=(double) QuantumRange*value;
4078 if (property_image->colorspace == CMYKColorspace)
4080 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4081 BlackPixelChannel,0,0,&value,exception);
4082 pixel.black=(double) QuantumRange*value;
4084 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4085 AlphaPixelChannel,0,0,&value,exception);
4086 pixel.alpha=(double) QuantumRange*value;
4087 fx_info=DestroyFxInfo(fx_info);
4088 if (status != MagickFalse)
4091 hex[MagickPathExtent];
4093 GetColorTuple(&pixel,MagickTrue,hex);
4094 AppendString2Text(hex+1);
4098 if (LocaleNCompare(
"pixel:",pattern,6) == 0)
4115 GetPixelInfo(property_image,&pixel);
4116 fx_info=AcquireFxInfo(property_image,pattern+6,exception);
4117 if (fx_info == (FxInfo *) NULL)
4119 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4121 pixel.red=(double) QuantumRange*value;
4122 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4123 GreenPixelChannel,0,0,&value,exception);
4124 pixel.green=(double) QuantumRange*value;
4125 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4126 BluePixelChannel,0,0,&value,exception);
4127 pixel.blue=(double) QuantumRange*value;
4128 if (property_image->colorspace == CMYKColorspace)
4130 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4131 BlackPixelChannel,0,0,&value,exception);
4132 pixel.black=(double) QuantumRange*value;
4134 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4135 AlphaPixelChannel,0,0,&value,exception);
4136 pixel.alpha=(double) QuantumRange*value;
4137 fx_info=DestroyFxInfo(fx_info);
4138 if (status != MagickFalse)
4141 name[MagickPathExtent];
4143 GetColorTuple(&pixel,MagickFalse,name);
4144 string=GetImageArtifact(property_image,
"pixel:compliance");
4145 if (
string != (
char *) NULL)
4147 ComplianceType compliance=(ComplianceType) ParseCommandOption(
4148 MagickComplianceOptions,MagickFalse,
string);
4149 (void) QueryColorname(property_image,&pixel,compliance,name,
4152 AppendString2Text(name);
4156 if (LocaleNCompare(
"option:",pattern,7) == 0)
4161 if (IsGlob(pattern+7) != MagickFalse)
4163 ResetImageOptionIterator(property_info);
4164 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4165 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4167 string=GetImageOption(property_info,key);
4168 if (
string != (
const char *) NULL)
4169 AppendKeyValue2Text(key,
string);
4174 string=GetImageOption(property_info,pattern+7);
4175 if (
string == (
char *) NULL)
4176 goto PropertyLookupFailure;
4177 AppendString2Text(
string);
4180 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4185 if (IsGlob(pattern+9) != MagickFalse)
4187 ResetImageArtifactIterator(property_image);
4188 while ((key=GetNextImageArtifact(property_image)) != (
const char *) NULL)
4189 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4191 string=GetImageArtifact(property_image,key);
4192 if (
string != (
const char *) NULL)
4193 AppendKeyValue2Text(key,
string);
4198 string=GetImageArtifact(property_image,pattern+9);
4199 if (
string == (
char *) NULL)
4200 goto PropertyLookupFailure;
4201 AppendString2Text(
string);
4204 if (LocaleNCompare(
"property:",pattern,9) == 0)
4209 if (IsGlob(pattern+9) != MagickFalse)
4211 ResetImagePropertyIterator(property_image);
4212 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4213 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4215 string=GetImageProperty(property_image,key,exception);
4216 if (
string != (
const char *) NULL)
4217 AppendKeyValue2Text(key,
string);
4222 string=GetImageProperty(property_image,pattern+9,exception);
4223 if (
string == (
char *) NULL)
4224 goto PropertyLookupFailure;
4225 AppendString2Text(
string);
4233 string=GetImageProperty(property_image,pattern,exception);
4234 if (
string != (
const char *) NULL)
4236 AppendString2Text(
string);
4237 (void) DeleteImageArtifact(property_image,
"magick-property");
4238 (void) DeleteImageOption(property_info,
"magick-property");
4241 if (IsGlob(pattern) != MagickFalse)
4247 ResetImagePropertyIterator(property_image);
4248 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4249 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4251 string=GetImageProperty(property_image,key,exception);
4252 if (
string != (
const char *) NULL)
4253 AppendKeyValue2Text(key,
string);
4263 string=GetMagickProperty(property_info,property_image,pattern,exception);
4264 if (
string != (
const char *) NULL)
4266 AppendString2Text(
string);
4273 string=GetImageArtifact(property_image,pattern);
4274 if (
string != (
char *) NULL)
4276 AppendString2Text(
string);
4282 string=GetImageOption(property_info,pattern);
4283 if (
string != (
char *) NULL)
4285 AppendString2Text(
string);
4288PropertyLookupFailure:
4299 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4300 "UnknownImageProperty",
"\"%%[%s]\"",pattern);
4304 if (property_image != image)
4305 property_image=DestroyImage(property_image);
4306 if (property_info != image_info)
4307 property_info=DestroyImageInfo(property_info);
4308 return(interpret_text);
4339MagickExport
char *RemoveImageProperty(Image *image,
const char *property)
4344 assert(image != (Image *) NULL);
4345 assert(image->signature == MagickCoreSignature);
4346 if (IsEventLogging() != MagickFalse)
4347 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4348 if (image->properties == (
void *) NULL)
4349 return((
char *) NULL);
4350 value=(
char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
4379MagickExport
void ResetImagePropertyIterator(
const Image *image)
4381 assert(image != (Image *) NULL);
4382 assert(image->signature == MagickCoreSignature);
4383 if (IsEventLogging() != MagickFalse)
4384 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4385 if (image->properties == (
void *) NULL)
4387 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
4423MagickExport MagickBooleanType SetImageProperty(Image *image,
4424 const char *property,
const char *value,ExceptionInfo *exception)
4435 assert(image != (Image *) NULL);
4436 assert(image->signature == MagickCoreSignature);
4437 if (IsEventLogging() != MagickFalse)
4438 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4439 if (image->properties == (
void *) NULL)
4440 image->properties=NewSplayTree(CompareSplayTreeString,
4441 RelinquishMagickMemory,RelinquishMagickMemory);
4442 if (value == (
const char *) NULL)
4443 return(DeleteImageProperty(image,property));
4444 if (strlen(property) <= 1)
4449 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4450 "SetReadOnlyProperty",
"`%s'",property);
4451 return(MagickFalse);
4453 property_length=strlen(property);
4454 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4455 (*(property+(property_length-1)) ==
'*'))
4457 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4458 "SetReadOnlyProperty",
"`%s'",property);
4459 return(MagickFalse);
4473 if (LocaleNCompare(
"8bim:",property,5) == 0)
4475 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4476 "SetReadOnlyProperty",
"`%s'",property);
4477 return(MagickFalse);
4485 if (LocaleCompare(
"background",property) == 0)
4487 (void) QueryColorCompliance(value,AllCompliance,
4488 &image->background_color,exception);
4497 if (LocaleCompare(
"channels",property) == 0)
4499 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4500 "SetReadOnlyProperty",
"`%s'",property);
4501 return(MagickFalse);
4503 if (LocaleCompare(
"colorspace",property) == 0)
4508 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4511 return(MagickFalse);
4512 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4514 if (LocaleCompare(
"compose",property) == 0)
4519 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4521 return(MagickFalse);
4522 image->compose=(CompositeOperator) compose;
4525 if (LocaleCompare(
"compress",property) == 0)
4530 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4532 if (compression < 0)
4533 return(MagickFalse);
4534 image->compression=(CompressionType) compression;
4542 if (LocaleCompare(
"delay",property) == 0)
4547 flags=ParseGeometry(value,&geometry_info);
4548 if ((flags & GreaterValue) != 0)
4550 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4551 image->delay=(size_t) floor(geometry_info.rho+0.5);
4554 if ((flags & LessValue) != 0)
4556 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4557 image->delay=(size_t) CastDoubleToSsizeT(floor(
4558 geometry_info.sigma+0.5));
4561 image->delay=(size_t) floor(geometry_info.rho+0.5);
4562 if ((flags & SigmaValue) != 0)
4563 image->ticks_per_second=CastDoubleToSsizeT(floor(
4564 geometry_info.sigma+0.5));
4567 if (LocaleCompare(
"delay_units",property) == 0)
4569 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4570 "SetReadOnlyProperty",
"`%s'",property);
4571 return(MagickFalse);
4573 if (LocaleCompare(
"density",property) == 0)
4578 flags=ParseGeometry(value,&geometry_info);
4579 if ((flags & RhoValue) != 0)
4580 image->resolution.x=geometry_info.rho;
4581 image->resolution.y=image->resolution.x;
4582 if ((flags & SigmaValue) != 0)
4583 image->resolution.y=geometry_info.sigma;
4586 if (LocaleCompare(
"depth",property) == 0)
4588 image->depth=StringToUnsignedLong(value);
4591 if (LocaleCompare(
"dispose",property) == 0)
4596 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4598 return(MagickFalse);
4599 image->dispose=(DisposeType) dispose;
4609 if (LocaleNCompare(
"exif:",property,5) == 0)
4611 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4612 "SetReadOnlyProperty",
"`%s'",property);
4613 return(MagickFalse);
4620 if (LocaleNCompare(
"fx:",property,3) == 0)
4622 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4623 "SetReadOnlyProperty",
"`%s'",property);
4624 return(MagickFalse);
4632 if (LocaleCompare(
"gamma",property) == 0)
4634 image->gamma=StringToDouble(value,(
char **) NULL);
4637 if (LocaleCompare(
"gravity",property) == 0)
4642 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4644 return(MagickFalse);
4645 image->gravity=(GravityType) gravity;
4653 if (LocaleCompare(
"height",property) == 0)
4655 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4656 "SetReadOnlyProperty",
"`%s'",property);
4657 return(MagickFalse);
4664 if (LocaleCompare(
"intensity",property) == 0)
4669 intensity=ParseCommandOption(MagickIntensityOptions,MagickFalse,
4672 return(MagickFalse);
4673 image->intensity=(PixelIntensityMethod) intensity;
4676 if (LocaleCompare(
"intent",property) == 0)
4681 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4683 if (rendering_intent < 0)
4684 return(MagickFalse);
4685 image->rendering_intent=(RenderingIntent) rendering_intent;
4688 if (LocaleCompare(
"interpolate",property) == 0)
4693 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4695 if (interpolate < 0)
4696 return(MagickFalse);
4697 image->interpolate=(PixelInterpolateMethod) interpolate;
4702 if (LocaleNCompare(
"iptc:",property,5) == 0)
4704 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4705 "SetReadOnlyProperty",
"`%s'",property);
4706 return(MagickFalse);
4713 if (LocaleCompare(
"kurtosis",property) == 0)
4715 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4716 "SetReadOnlyProperty",
"`%s'",property);
4717 return(MagickFalse);
4723 if (LocaleCompare(
"loop",property) == 0)
4725 image->iterations=StringToUnsignedLong(value);
4732 if ((LocaleCompare(
"magick",property) == 0) ||
4733 (LocaleCompare(
"max",property) == 0) ||
4734 (LocaleCompare(
"mean",property) == 0) ||
4735 (LocaleCompare(
"min",property) == 0) ||
4736 (LocaleCompare(
"min",property) == 0))
4738 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4739 "SetReadOnlyProperty",
"`%s'",property);
4740 return(MagickFalse);
4745 if (LocaleCompare(
"opaque",property) == 0)
4747 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4748 "SetReadOnlyProperty",
"`%s'",property);
4749 return(MagickFalse);
4755 if (LocaleCompare(
"page",property) == 0)
4760 geometry=GetPageGeometry(value);
4761 flags=ParseAbsoluteGeometry(geometry,&image->page);
4762 geometry=DestroyString(geometry);
4767 if (LocaleNCompare(
"pixel:",property,6) == 0)
4769 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4770 "SetReadOnlyProperty",
"`%s'",property);
4771 return(MagickFalse);
4779 if (LocaleCompare(
"rendering-intent",property) == 0)
4784 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4786 if (rendering_intent < 0)
4787 return(MagickFalse);
4788 image->rendering_intent=(RenderingIntent) rendering_intent;
4795 if ((LocaleCompare(
"size",property) == 0) ||
4796 (LocaleCompare(
"skewness",property) == 0) ||
4797 (LocaleCompare(
"scenes",property) == 0) ||
4798 (LocaleCompare(
"standard-deviation",property) == 0))
4800 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4801 "SetReadOnlyProperty",
"`%s'",property);
4802 return(MagickFalse);
4808 if (LocaleCompare(
"tile-offset",property) == 0)
4813 geometry=GetPageGeometry(value);
4814 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4815 geometry=DestroyString(geometry);
4818 if (LocaleCompare(
"type",property) == 0)
4823 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4825 return(MagickFalse);
4826 image->type=(ImageType) type;
4834 if (LocaleCompare(
"units",property) == 0)
4839 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4841 return(MagickFalse);
4842 image->units=(ResolutionType) units;
4850 if (LocaleCompare(
"version",property) == 0)
4852 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4853 "SetReadOnlyProperty",
"`%s'",property);
4854 return(MagickFalse);
4861 if (LocaleCompare(
"width",property) == 0)
4863 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4864 "SetReadOnlyProperty",
"`%s'",property);
4865 return(MagickFalse);
4874 if (LocaleNCompare(
"xmp:",property,4) == 0)
4876 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4877 "SetReadOnlyProperty",
"`%s'",property);
4878 return(MagickFalse);
4885 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4886 ConstantString(property),ConstantString(value));