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
134MagickExport MagickBooleanType CloneImageProperties(
Image *image,
135 const Image *clone_image)
137 assert(image != (
Image *) NULL);
138 assert(image->signature == MagickCoreSignature);
139 assert(clone_image != (
const Image *) NULL);
140 assert(clone_image->signature == MagickCoreSignature);
141 if (IsEventLogging() != MagickFalse)
143 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
144 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
145 clone_image->filename);
147 (void) CopyMagickString(image->filename,clone_image->filename,
149 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
151 image->compression=clone_image->compression;
152 image->quality=clone_image->quality;
153 image->depth=clone_image->depth;
154 image->matte_color=clone_image->matte_color;
155 image->background_color=clone_image->background_color;
156 image->border_color=clone_image->border_color;
157 image->transparent_color=clone_image->transparent_color;
158 image->gamma=clone_image->gamma;
159 image->chromaticity=clone_image->chromaticity;
160 image->rendering_intent=clone_image->rendering_intent;
161 image->black_point_compensation=clone_image->black_point_compensation;
162 image->units=clone_image->units;
163 image->montage=(
char *) NULL;
164 image->directory=(
char *) NULL;
165 (void) CloneString(&image->geometry,clone_image->geometry);
166 image->offset=clone_image->offset;
167 image->resolution.x=clone_image->resolution.x;
168 image->resolution.y=clone_image->resolution.y;
169 image->page=clone_image->page;
170 image->tile_offset=clone_image->tile_offset;
171 image->extract_info=clone_image->extract_info;
172 image->filter=clone_image->filter;
173 image->fuzz=clone_image->fuzz;
174 image->intensity=clone_image->intensity;
175 image->interlace=clone_image->interlace;
176 image->interpolate=clone_image->interpolate;
177 image->endian=clone_image->endian;
178 image->gravity=clone_image->gravity;
179 image->compose=clone_image->compose;
180 image->orientation=clone_image->orientation;
181 image->scene=clone_image->scene;
182 image->dispose=clone_image->dispose;
183 image->delay=clone_image->delay;
184 image->ticks_per_second=clone_image->ticks_per_second;
185 image->iterations=clone_image->iterations;
186 image->total_colors=clone_image->total_colors;
187 image->taint=clone_image->taint;
188 image->progress_monitor=clone_image->progress_monitor;
189 image->client_data=clone_image->client_data;
190 image->start_loop=clone_image->start_loop;
191 image->error=clone_image->error;
192 image->signature=clone_image->signature;
193 if (clone_image->properties != (
void *) NULL)
195 if (image->properties != (
void *) NULL)
196 DestroyImageProperties(image);
198 clone_image->properties,(
void *(*)(
void *)) ConstantString,
199 (
void *(*)(
void *)) ConstantString);
233MagickExport MagickBooleanType DefineImageProperty(
Image *image,
237 key[MagickPathExtent],
238 value[MagickPathExtent];
243 assert(image != (
Image *) NULL);
244 assert(property != (
const char *) NULL);
245 (void) CopyMagickString(key,property,MagickPathExtent-1);
246 for (p=key; *p !=
'\0'; p++)
251 (void) CopyMagickString(value,p+1,MagickPathExtent);
253 return(SetImageProperty(image,key,value,exception));
280MagickExport MagickBooleanType DeleteImageProperty(
Image *image,
281 const char *property)
283 assert(image != (
Image *) NULL);
284 assert(image->signature == MagickCoreSignature);
285 if (IsEventLogging() != MagickFalse)
286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
287 if (image->properties == (
void *) NULL)
289 return(DeleteNodeFromSplayTree((
SplayTreeInfo *) image->properties,property));
315MagickExport
void DestroyImageProperties(
Image *image)
317 assert(image != (
Image *) NULL);
318 assert(image->signature == MagickCoreSignature);
319 if (IsEventLogging() != MagickFalse)
320 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
321 if (image->properties != (
void *) NULL)
322 image->properties=(
void *) DestroySplayTree((
SplayTreeInfo *)
355MagickExport MagickBooleanType FormatImageProperty(
Image *image,
356 const char *property,
const char *format,...)
359 value[MagickPathExtent];
373 va_start(operands,format);
374 n=FormatLocaleStringList(value,MagickPathExtent,format,operands);
377 exception=AcquireExceptionInfo();
378 status=SetImageProperty(image,property,value,exception);
379 exception=DestroyExceptionInfo(exception);
419 *TracePSClippath(
const unsigned char *,
size_t),
420 *TraceSVGClippath(
const unsigned char *,
size_t,
const size_t,
423static void GetIPTCProperty(
const Image *image,
const char *key,
444 profile=GetImageProfile(image,
"iptc");
446 profile=GetImageProfile(image,
"8bim");
449 count=sscanf(key,
"IPTC:%ld:%ld",&dataset,&record);
452 attribute=(
char *) NULL;
453 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
456 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
458 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
459 length|=GetStringInfoDatum(profile)[i+4];
460 if (((
long) GetStringInfoDatum(profile)[i+1] == dataset) &&
461 ((
long) GetStringInfoDatum(profile)[i+2] == record))
463 message=(
char *) NULL;
465 message=(
char *) AcquireQuantumMemory(length+1UL,
sizeof(*message));
466 if (message != (
char *) NULL)
468 (void) CopyMagickString(message,(
char *) GetStringInfoDatum(
469 profile)+i+5,length+1);
470 (void) ConcatenateString(&attribute,message);
471 (void) ConcatenateString(&attribute,
";");
472 message=DestroyString(message);
477 if ((attribute == (
char *) NULL) || (*attribute ==
';'))
479 if (attribute != (
char *) NULL)
480 attribute=DestroyString(attribute);
483 attribute[strlen(attribute)-1]=
'\0';
484 (void) SetImageProperty((
Image *) image,key,(
const char *) attribute,
486 attribute=DestroyString(attribute);
489static inline int ReadPropertyByte(
const unsigned char **p,
size_t *length)
501static inline signed int ReadPropertyMSBLong(
const unsigned char **p,
527 for (i=0; i < 4; i++)
531 buffer[i]=(
unsigned char) c;
533 value=(
unsigned int) buffer[0] << 24;
534 value|=(
unsigned int) buffer[1] << 16;
535 value|=(
unsigned int) buffer[2] << 8;
536 value|=(
unsigned int) buffer[3];
537 quantum.unsigned_value=value & 0xffffffff;
538 return(quantum.signed_value);
541static inline signed short ReadPropertyMSBShort(
const unsigned char **p,
567 for (i=0; i < 2; i++)
571 buffer[i]=(
unsigned char) c;
573 value=(
unsigned short) buffer[0] << 8;
574 value|=(
unsigned short) buffer[1];
575 quantum.unsigned_value=value & 0xffff;
576 return(quantum.signed_value);
579static void Get8BIMProperty(
const Image *image,
const char *key,
584 format[MagickPathExtent],
585 name[MagickPathExtent],
613 profile=GetImageProfile(image,
"8bim");
616 count=(ssize_t) sscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
618 if ((count != 2) && (count != 3) && (count != 4))
621 (void) CopyMagickString(format,
"SVG",MagickPathExtent);
626 sub_number=(ssize_t) StringToLong(&name[1]);
627 sub_number=MagickMax(sub_number,1L);
628 resource=(
char *) NULL;
630 length=GetStringInfoLength(profile);
631 info=GetStringInfoDatum(profile);
632 while ((length > 0) && (status == MagickFalse))
634 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'8')
636 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'B')
638 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'I')
640 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'M')
642 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
643 if (
id < (ssize_t) start)
645 if (
id > (ssize_t) stop)
647 if (resource != (
char *) NULL)
648 resource=DestroyString(resource);
649 count=(ssize_t) ReadPropertyByte(&info,&length);
650 if ((count != 0) && ((
size_t) count <= length))
652 resource=(
char *) NULL;
653 if (~((
size_t) count) >= (MagickPathExtent-1))
654 resource=(
char *) AcquireQuantumMemory((
size_t) count+
655 MagickPathExtent,
sizeof(*resource));
656 if (resource != (
char *) NULL)
658 for (i=0; i < (ssize_t) count; i++)
659 resource[i]=(
char) ReadPropertyByte(&info,&length);
660 resource[count]=
'\0';
663 if ((count & 0x01) == 0)
664 (void) ReadPropertyByte(&info,&length);
665 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
666 if ((count < 0) || ((
size_t) count > length))
671 if ((*name !=
'\0') && (*name !=
'#'))
672 if ((resource == (
char *) NULL) || (LocaleCompare(name,resource) != 0))
678 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
681 if ((*name ==
'#') && (sub_number != 1))
688 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
694 attribute=(
char *) NULL;
695 if (~((
size_t) count) >= (MagickPathExtent-1))
696 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MagickPathExtent,
698 if (attribute != (
char *) NULL)
700 (void) memcpy(attribute,(
char *) info,(
size_t) count);
701 attribute[count]=
'\0';
703 length=(size_t) ((ssize_t) length-MagickMin(count,(ssize_t) length));
704 if ((
id <= 1999) || (
id >= 2999))
705 (void) SetImageProperty((
Image *) image,key,(
const char *) attribute,
712 if (LocaleCompare(format,
"svg") == 0)
713 path=TraceSVGClippath((
unsigned char *) attribute,(
size_t) count,
714 image->columns,image->rows);
716 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count);
717 (void) SetImageProperty((
Image *) image,key,(
const char *) path,
719 path=DestroyString(path);
721 attribute=DestroyString(attribute);
725 if (resource != (
char *) NULL)
726 resource=DestroyString(resource);
729static inline signed int ReadPropertySignedLong(
const EndianType endian,
730 const unsigned char *buffer)
744 if (endian == LSBEndian)
746 value=(
unsigned int) buffer[3] << 24;
747 value|=(
unsigned int) buffer[2] << 16;
748 value|=(
unsigned int) buffer[1] << 8;
749 value|=(
unsigned int) buffer[0];
750 quantum.unsigned_value=value & 0xffffffff;
751 return(quantum.signed_value);
753 value=(
unsigned int) buffer[0] << 24;
754 value|=(
unsigned int) buffer[1] << 16;
755 value|=(
unsigned int) buffer[2] << 8;
756 value|=(
unsigned int) buffer[3];
757 quantum.unsigned_value=value & 0xffffffff;
758 return(quantum.signed_value);
761static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
762 const unsigned char *buffer)
767 if (endian == LSBEndian)
769 value=(
unsigned int) buffer[3] << 24;
770 value|=(
unsigned int) buffer[2] << 16;
771 value|=(
unsigned int) buffer[1] << 8;
772 value|=(
unsigned int) buffer[0];
773 return(value & 0xffffffff);
775 value=(
unsigned int) buffer[0] << 24;
776 value|=(
unsigned int) buffer[1] << 16;
777 value|=(
unsigned int) buffer[2] << 8;
778 value|=(
unsigned int) buffer[3];
779 return(value & 0xffffffff);
782static inline signed short ReadPropertySignedShort(
const EndianType endian,
783 const unsigned char *buffer)
797 if (endian == LSBEndian)
799 value=(
unsigned short) buffer[1] << 8;
800 value|=(
unsigned short) buffer[0];
801 quantum.unsigned_value=value & 0xffff;
802 return(quantum.signed_value);
804 value=(
unsigned short) buffer[0] << 8;
805 value|=(
unsigned short) buffer[1];
806 quantum.unsigned_value=value & 0xffff;
807 return(quantum.signed_value);
810static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
811 const unsigned char *buffer)
816 if (endian == LSBEndian)
818 value=(
unsigned short) buffer[1] << 8;
819 value|=(
unsigned short) buffer[0];
820 return(value & 0xffff);
822 value=(
unsigned short) buffer[0] << 8;
823 value|=(
unsigned short) buffer[1];
824 return(value & 0xffff);
827static void GetEXIFProperty(
const Image *image,
const char *property,
830#define MaxDirectoryStack 16
831#define EXIF_DELIMITER "\n"
832#define EXIF_NUM_FORMATS 12
833#define EXIF_FMT_BYTE 1
834#define EXIF_FMT_STRING 2
835#define EXIF_FMT_USHORT 3
836#define EXIF_FMT_ULONG 4
837#define EXIF_FMT_URATIONAL 5
838#define EXIF_FMT_SBYTE 6
839#define EXIF_FMT_UNDEFINED 7
840#define EXIF_FMT_SSHORT 8
841#define EXIF_FMT_SLONG 9
842#define EXIF_FMT_SRATIONAL 10
843#define EXIF_FMT_SINGLE 11
844#define EXIF_FMT_DOUBLE 12
845#define GPS_LATITUDE 0x10002
846#define GPS_LONGITUDE 0x10004
847#define GPS_TIMESTAMP 0x10007
848#define TAG_EXIF_OFFSET 0x8769
849#define TAG_GPS_OFFSET 0x8825
850#define TAG_INTEROP_OFFSET 0xa005
852#define EXIFGPSFractions(format,arg1,arg2,arg3,arg4,arg5,arg6) \
860 for ( ; component < components; component++) \
862 if (component != 0) \
863 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
865 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
866 extent,format,(arg1),(arg2),(arg3),(arg4),(arg5),(arg6)); \
867 if (extent >= (MagickPathExtent-1)) \
868 extent=MagickPathExtent-1; \
870 buffer[extent]='\0'; \
871 value=AcquireString(buffer); \
874#define EXIFMultipleValues(format,arg) \
882 for ( ; component < components; component++) \
884 if (component != 0) \
885 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
887 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
888 extent,format,arg); \
889 if (extent >= (MagickPathExtent-1)) \
890 extent=MagickPathExtent-1; \
892 buffer[extent]='\0'; \
893 value=AcquireString(buffer); \
896#define EXIFMultipleFractions(format,arg1,arg2) \
904 for ( ; component < components; component++) \
906 if (component != 0) \
907 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent-\
909 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
910 extent,format,(arg1),(arg2)); \
911 if (extent >= (MagickPathExtent-1)) \
912 extent=MagickPathExtent-1; \
914 buffer[extent]='\0'; \
915 value=AcquireString(buffer); \
918 typedef struct _DirectoryInfo
930 typedef struct _TagInfo
942 { 0x001,
"exif:InteroperabilityIndex" },
943 { 0x002,
"exif:InteroperabilityVersion" },
944 { 0x100,
"exif:ImageWidth" },
945 { 0x101,
"exif:ImageLength" },
946 { 0x102,
"exif:BitsPerSample" },
947 { 0x103,
"exif:Compression" },
948 { 0x106,
"exif:PhotometricInterpretation" },
949 { 0x10a,
"exif:FillOrder" },
950 { 0x10d,
"exif:DocumentName" },
951 { 0x10e,
"exif:ImageDescription" },
952 { 0x10f,
"exif:Make" },
953 { 0x110,
"exif:Model" },
954 { 0x111,
"exif:StripOffsets" },
955 { 0x112,
"exif:Orientation" },
956 { 0x115,
"exif:SamplesPerPixel" },
957 { 0x116,
"exif:RowsPerStrip" },
958 { 0x117,
"exif:StripByteCounts" },
959 { 0x11a,
"exif:XResolution" },
960 { 0x11b,
"exif:YResolution" },
961 { 0x11c,
"exif:PlanarConfiguration" },
962 { 0x11d,
"exif:PageName" },
963 { 0x11e,
"exif:XPosition" },
964 { 0x11f,
"exif:YPosition" },
965 { 0x118,
"exif:MinSampleValue" },
966 { 0x119,
"exif:MaxSampleValue" },
967 { 0x120,
"exif:FreeOffsets" },
968 { 0x121,
"exif:FreeByteCounts" },
969 { 0x122,
"exif:GrayResponseUnit" },
970 { 0x123,
"exif:GrayResponseCurve" },
971 { 0x124,
"exif:T4Options" },
972 { 0x125,
"exif:T6Options" },
973 { 0x128,
"exif:ResolutionUnit" },
974 { 0x12d,
"exif:TransferFunction" },
975 { 0x131,
"exif:Software" },
976 { 0x132,
"exif:DateTime" },
977 { 0x13b,
"exif:Artist" },
978 { 0x13e,
"exif:WhitePoint" },
979 { 0x13f,
"exif:PrimaryChromaticities" },
980 { 0x140,
"exif:ColorMap" },
981 { 0x141,
"exif:HalfToneHints" },
982 { 0x142,
"exif:TileWidth" },
983 { 0x143,
"exif:TileLength" },
984 { 0x144,
"exif:TileOffsets" },
985 { 0x145,
"exif:TileByteCounts" },
986 { 0x14a,
"exif:SubIFD" },
987 { 0x14c,
"exif:InkSet" },
988 { 0x14d,
"exif:InkNames" },
989 { 0x14e,
"exif:NumberOfInks" },
990 { 0x150,
"exif:DotRange" },
991 { 0x151,
"exif:TargetPrinter" },
992 { 0x152,
"exif:ExtraSample" },
993 { 0x153,
"exif:SampleFormat" },
994 { 0x154,
"exif:SMinSampleValue" },
995 { 0x155,
"exif:SMaxSampleValue" },
996 { 0x156,
"exif:TransferRange" },
997 { 0x157,
"exif:ClipPath" },
998 { 0x158,
"exif:XClipPathUnits" },
999 { 0x159,
"exif:YClipPathUnits" },
1000 { 0x15a,
"exif:Indexed" },
1001 { 0x15b,
"exif:JPEGTables" },
1002 { 0x15f,
"exif:OPIProxy" },
1003 { 0x200,
"exif:JPEGProc" },
1004 { 0x201,
"exif:JPEGInterchangeFormat" },
1005 { 0x202,
"exif:JPEGInterchangeFormatLength" },
1006 { 0x203,
"exif:JPEGRestartInterval" },
1007 { 0x205,
"exif:JPEGLosslessPredictors" },
1008 { 0x206,
"exif:JPEGPointTransforms" },
1009 { 0x207,
"exif:JPEGQTables" },
1010 { 0x208,
"exif:JPEGDCTables" },
1011 { 0x209,
"exif:JPEGACTables" },
1012 { 0x211,
"exif:YCbCrCoefficients" },
1013 { 0x212,
"exif:YCbCrSubSampling" },
1014 { 0x213,
"exif:YCbCrPositioning" },
1015 { 0x214,
"exif:ReferenceBlackWhite" },
1016 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1017 { 0x301,
"exif:Gamma" },
1018 { 0x302,
"exif:ICCProfileDescriptor" },
1019 { 0x303,
"exif:SRGBRenderingIntent" },
1020 { 0x320,
"exif:ImageTitle" },
1021 { 0x5001,
"exif:ResolutionXUnit" },
1022 { 0x5002,
"exif:ResolutionYUnit" },
1023 { 0x5003,
"exif:ResolutionXLengthUnit" },
1024 { 0x5004,
"exif:ResolutionYLengthUnit" },
1025 { 0x5005,
"exif:PrintFlags" },
1026 { 0x5006,
"exif:PrintFlagsVersion" },
1027 { 0x5007,
"exif:PrintFlagsCrop" },
1028 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1029 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1030 { 0x500A,
"exif:HalftoneLPI" },
1031 { 0x500B,
"exif:HalftoneLPIUnit" },
1032 { 0x500C,
"exif:HalftoneDegree" },
1033 { 0x500D,
"exif:HalftoneShape" },
1034 { 0x500E,
"exif:HalftoneMisc" },
1035 { 0x500F,
"exif:HalftoneScreen" },
1036 { 0x5010,
"exif:JPEGQuality" },
1037 { 0x5011,
"exif:GridSize" },
1038 { 0x5012,
"exif:ThumbnailFormat" },
1039 { 0x5013,
"exif:ThumbnailWidth" },
1040 { 0x5014,
"exif:ThumbnailHeight" },
1041 { 0x5015,
"exif:ThumbnailColorDepth" },
1042 { 0x5016,
"exif:ThumbnailPlanes" },
1043 { 0x5017,
"exif:ThumbnailRawBytes" },
1044 { 0x5018,
"exif:ThumbnailSize" },
1045 { 0x5019,
"exif:ThumbnailCompressedSize" },
1046 { 0x501a,
"exif:ColorTransferFunction" },
1047 { 0x501b,
"exif:ThumbnailData" },
1048 { 0x5020,
"exif:ThumbnailImageWidth" },
1049 { 0x5021,
"exif:ThumbnailImageHeight" },
1050 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1051 { 0x5023,
"exif:ThumbnailCompression" },
1052 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1053 { 0x5025,
"exif:ThumbnailImageDescription" },
1054 { 0x5026,
"exif:ThumbnailEquipMake" },
1055 { 0x5027,
"exif:ThumbnailEquipModel" },
1056 { 0x5028,
"exif:ThumbnailStripOffsets" },
1057 { 0x5029,
"exif:ThumbnailOrientation" },
1058 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1059 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1060 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1061 { 0x502d,
"exif:ThumbnailResolutionX" },
1062 { 0x502e,
"exif:ThumbnailResolutionY" },
1063 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1064 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1065 { 0x5031,
"exif:ThumbnailTransferFunction" },
1066 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1067 { 0x5033,
"exif:ThumbnailDateTime" },
1068 { 0x5034,
"exif:ThumbnailArtist" },
1069 { 0x5035,
"exif:ThumbnailWhitePoint" },
1070 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1071 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1072 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1073 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1074 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1075 { 0x503B,
"exif:ThumbnailCopyRight" },
1076 { 0x5090,
"exif:LuminanceTable" },
1077 { 0x5091,
"exif:ChrominanceTable" },
1078 { 0x5100,
"exif:FrameDelay" },
1079 { 0x5101,
"exif:LoopCount" },
1080 { 0x5110,
"exif:PixelUnit" },
1081 { 0x5111,
"exif:PixelPerUnitX" },
1082 { 0x5112,
"exif:PixelPerUnitY" },
1083 { 0x5113,
"exif:PaletteHistogram" },
1084 { 0x1000,
"exif:RelatedImageFileFormat" },
1085 { 0x1001,
"exif:RelatedImageLength" },
1086 { 0x1002,
"exif:RelatedImageWidth" },
1087 { 0x800d,
"exif:ImageID" },
1088 { 0x80e3,
"exif:Matteing" },
1089 { 0x80e4,
"exif:DataType" },
1090 { 0x80e5,
"exif:ImageDepth" },
1091 { 0x80e6,
"exif:TileDepth" },
1092 { 0x828d,
"exif:CFARepeatPatternDim" },
1093 { 0x828e,
"exif:CFAPattern2" },
1094 { 0x828f,
"exif:BatteryLevel" },
1095 { 0x8298,
"exif:Copyright" },
1096 { 0x829a,
"exif:ExposureTime" },
1097 { 0x829d,
"exif:FNumber" },
1098 { 0x83bb,
"exif:IPTC/NAA" },
1099 { 0x84e3,
"exif:IT8RasterPadding" },
1100 { 0x84e5,
"exif:IT8ColorTable" },
1101 { 0x8649,
"exif:ImageResourceInformation" },
1102 { 0x8769,
"exif:ExifOffset" },
1103 { 0x8773,
"exif:InterColorProfile" },
1104 { 0x8822,
"exif:ExposureProgram" },
1105 { 0x8824,
"exif:SpectralSensitivity" },
1106 { 0x8825,
"exif:GPSInfo" },
1107 { 0x8827,
"exif:PhotographicSensitivity" },
1108 { 0x8828,
"exif:OECF" },
1109 { 0x8829,
"exif:Interlace" },
1110 { 0x882a,
"exif:TimeZoneOffset" },
1111 { 0x882b,
"exif:SelfTimerMode" },
1112 { 0x8830,
"exif:SensitivityType" },
1113 { 0x8831,
"exif:StandardOutputSensitivity" },
1114 { 0x8832,
"exif:RecommendedExposureIndex" },
1115 { 0x8833,
"exif:ISOSpeed" },
1116 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1117 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1118 { 0x9000,
"exif:ExifVersion" },
1119 { 0x9003,
"exif:DateTimeOriginal" },
1120 { 0x9004,
"exif:DateTimeDigitized" },
1121 { 0x9010,
"exif:OffsetTime" },
1122 { 0x9011,
"exif:OffsetTimeOriginal" },
1123 { 0x9012,
"exif:OffsetTimeDigitized" },
1124 { 0x9101,
"exif:ComponentsConfiguration" },
1125 { 0x9102,
"exif:CompressedBitsPerPixel" },
1126 { 0x9201,
"exif:ShutterSpeedValue" },
1127 { 0x9202,
"exif:ApertureValue" },
1128 { 0x9203,
"exif:BrightnessValue" },
1129 { 0x9204,
"exif:ExposureBiasValue" },
1130 { 0x9205,
"exif:MaxApertureValue" },
1131 { 0x9206,
"exif:SubjectDistance" },
1132 { 0x9207,
"exif:MeteringMode" },
1133 { 0x9208,
"exif:LightSource" },
1134 { 0x9209,
"exif:Flash" },
1135 { 0x920a,
"exif:FocalLength" },
1136 { 0x920b,
"exif:FlashEnergy" },
1137 { 0x920c,
"exif:SpatialFrequencyResponse" },
1138 { 0x920d,
"exif:Noise" },
1139 { 0x9214,
"exif:SubjectArea" },
1140 { 0x9290,
"exif:SubSecTime" },
1141 { 0x9291,
"exif:SubSecTimeOriginal" },
1142 { 0x9292,
"exif:SubSecTimeDigitized" },
1143 { 0x9211,
"exif:ImageNumber" },
1144 { 0x9212,
"exif:SecurityClassification" },
1145 { 0x9213,
"exif:ImageHistory" },
1146 { 0x9214,
"exif:SubjectArea" },
1147 { 0x9215,
"exif:ExposureIndex" },
1148 { 0x9216,
"exif:TIFF-EPStandardID" },
1149 { 0x927c,
"exif:MakerNote" },
1150 { 0x9286,
"exif:UserComment" },
1151 { 0x9290,
"exif:SubSecTime" },
1152 { 0x9291,
"exif:SubSecTimeOriginal" },
1153 { 0x9292,
"exif:SubSecTimeDigitized" },
1154 { 0x9400,
"exif:Temperature" },
1155 { 0x9401,
"exif:Humidity" },
1156 { 0x9402,
"exif:Pressure" },
1157 { 0x9403,
"exif:WaterDepth" },
1158 { 0x9404,
"exif:Acceleration" },
1159 { 0x9405,
"exif:CameraElevationAngle" },
1160 { 0x9C9b,
"exif:WinXP-Title" },
1161 { 0x9C9c,
"exif:WinXP-Comments" },
1162 { 0x9C9d,
"exif:WinXP-Author" },
1163 { 0x9C9e,
"exif:WinXP-Keywords" },
1164 { 0x9C9f,
"exif:WinXP-Subject" },
1165 { 0xa000,
"exif:FlashPixVersion" },
1166 { 0xa001,
"exif:ColorSpace" },
1167 { 0xa002,
"exif:PixelXDimension" },
1168 { 0xa003,
"exif:PixelYDimension" },
1169 { 0xa004,
"exif:RelatedSoundFile" },
1170 { 0xa005,
"exif:InteroperabilityOffset" },
1171 { 0xa20b,
"exif:FlashEnergy" },
1172 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1173 { 0xa20d,
"exif:Noise" },
1174 { 0xa20e,
"exif:FocalPlaneXResolution" },
1175 { 0xa20f,
"exif:FocalPlaneYResolution" },
1176 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1177 { 0xa214,
"exif:SubjectLocation" },
1178 { 0xa215,
"exif:ExposureIndex" },
1179 { 0xa216,
"exif:TIFF/EPStandardID" },
1180 { 0xa217,
"exif:SensingMethod" },
1181 { 0xa300,
"exif:FileSource" },
1182 { 0xa301,
"exif:SceneType" },
1183 { 0xa302,
"exif:CFAPattern" },
1184 { 0xa401,
"exif:CustomRendered" },
1185 { 0xa402,
"exif:ExposureMode" },
1186 { 0xa403,
"exif:WhiteBalance" },
1187 { 0xa404,
"exif:DigitalZoomRatio" },
1188 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1189 { 0xa406,
"exif:SceneCaptureType" },
1190 { 0xa407,
"exif:GainControl" },
1191 { 0xa408,
"exif:Contrast" },
1192 { 0xa409,
"exif:Saturation" },
1193 { 0xa40a,
"exif:Sharpness" },
1194 { 0xa40b,
"exif:DeviceSettingDescription" },
1195 { 0xa40c,
"exif:SubjectDistanceRange" },
1196 { 0xa420,
"exif:ImageUniqueID" },
1197 { 0xa430,
"exif:CameraOwnerName" },
1198 { 0xa431,
"exif:BodySerialNumber" },
1199 { 0xa432,
"exif:LensSpecification" },
1200 { 0xa433,
"exif:LensMake" },
1201 { 0xa434,
"exif:LensModel" },
1202 { 0xa435,
"exif:LensSerialNumber" },
1203 { 0xc4a5,
"exif:PrintImageMatching" },
1204 { 0xa500,
"exif:Gamma" },
1205 { 0xc640,
"exif:CR2Slice" },
1206 { 0x10000,
"exif:GPSVersionID" },
1207 { 0x10001,
"exif:GPSLatitudeRef" },
1208 { 0x10002,
"exif:GPSLatitude" },
1209 { 0x10003,
"exif:GPSLongitudeRef" },
1210 { 0x10004,
"exif:GPSLongitude" },
1211 { 0x10005,
"exif:GPSAltitudeRef" },
1212 { 0x10006,
"exif:GPSAltitude" },
1213 { 0x10007,
"exif:GPSTimeStamp" },
1214 { 0x10008,
"exif:GPSSatellites" },
1215 { 0x10009,
"exif:GPSStatus" },
1216 { 0x1000a,
"exif:GPSMeasureMode" },
1217 { 0x1000b,
"exif:GPSDop" },
1218 { 0x1000c,
"exif:GPSSpeedRef" },
1219 { 0x1000d,
"exif:GPSSpeed" },
1220 { 0x1000e,
"exif:GPSTrackRef" },
1221 { 0x1000f,
"exif:GPSTrack" },
1222 { 0x10010,
"exif:GPSImgDirectionRef" },
1223 { 0x10011,
"exif:GPSImgDirection" },
1224 { 0x10012,
"exif:GPSMapDatum" },
1225 { 0x10013,
"exif:GPSDestLatitudeRef" },
1226 { 0x10014,
"exif:GPSDestLatitude" },
1227 { 0x10015,
"exif:GPSDestLongitudeRef" },
1228 { 0x10016,
"exif:GPSDestLongitude" },
1229 { 0x10017,
"exif:GPSDestBearingRef" },
1230 { 0x10018,
"exif:GPSDestBearing" },
1231 { 0x10019,
"exif:GPSDestDistanceRef" },
1232 { 0x1001a,
"exif:GPSDestDistance" },
1233 { 0x1001b,
"exif:GPSProcessingMethod" },
1234 { 0x1001c,
"exif:GPSAreaInformation" },
1235 { 0x1001d,
"exif:GPSDateStamp" },
1236 { 0x1001e,
"exif:GPSDifferential" },
1237 { 0x1001f,
"exif:GPSHPositioningError" },
1249 directory_stack[MaxDirectoryStack] = { { 0, 0, 0 } };
1273 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1278 profile=GetImageProfile(image,
"exif");
1281 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1283 while (isspace((
int) ((
unsigned char) *property)) != 0)
1285 if (strlen(property) <= 5)
1289 switch (*(property+5))
1318 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1329 for (i=(ssize_t) n-1L; i >= 0; i--)
1333 if ((c >=
'0') && (c <=
'9'))
1334 tag|=(size_t) (c-
'0');
1336 if ((c >=
'A') && (c <=
'F'))
1337 tag|=(size_t) (c-(
'A'-10));
1339 if ((c >=
'a') && (c <=
'f'))
1340 tag|=(size_t) (c-(
'a'-10));
1344 }
while (*property !=
'\0');
1354 if (EXIFTag[i].tag == 0)
1356 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1358 tag=(size_t) EXIFTag[i].tag;
1367 length=GetStringInfoLength(profile);
1370 exif=GetStringInfoDatum(profile);
1373 if (ReadPropertyByte(&exif,&length) != 0x45)
1375 if (ReadPropertyByte(&exif,&length) != 0x78)
1377 if (ReadPropertyByte(&exif,&length) != 0x69)
1379 if (ReadPropertyByte(&exif,&length) != 0x66)
1381 if (ReadPropertyByte(&exif,&length) != 0x00)
1383 if (ReadPropertyByte(&exif,&length) != 0x00)
1389 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1398 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1403 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1404 if ((offset < 0) || (
size_t) offset >= length)
1409 directory=exif+offset;
1413 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1414 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1423 directory=directory_stack[level].directory;
1424 entry=directory_stack[level].entry;
1425 tag_offset=directory_stack[level].offset;
1427 if ((directory < exif) || (directory > (exif+length-2)))
1432 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1433 for ( ; entry < number_entries; entry++)
1446 q=(
unsigned char *) (directory+(12*entry)+2);
1447 if (q > (exif+length-12))
1449 if (GetValueFromSplayTree(exif_resources,q) == q)
1451 (void) AddValueToSplayTree(exif_resources,q,q);
1452 tag_value=(size_t) (ReadPropertyUnsignedShort(endian,q)+(ssize_t)
1454 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1455 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1459 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1462 number_bytes=components*(ssize_t) tag_bytes[format];
1463 if (number_bytes < components)
1465 if (number_bytes <= 4)
1475 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1476 if ((dir_offset < 0) || (
size_t) dir_offset >= length)
1478 if (((
size_t) dir_offset+(
size_t) number_bytes) < (
size_t) dir_offset)
1480 if ((
size_t) (dir_offset+(ssize_t) number_bytes) > length)
1482 p=(
unsigned char *) (exif+dir_offset);
1484 if ((all != 0) || (tag == (
size_t) tag_value))
1487 buffer[6*
sizeof(double)+MagickPathExtent],
1490 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1492 value=(
char *) NULL;
1498 value=(
char *) NULL;
1499 if (~((
size_t) number_bytes) >= 1)
1500 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1502 if (value != (
char *) NULL)
1504 for (i=0; i < (ssize_t) number_bytes; i++)
1507 if (isprint((
int) p[i]) != 0)
1508 value[i]=(char) p[i];
1514 case EXIF_FMT_SBYTE:
1516 EXIFMultipleValues(
"%.20g",(
double) (*(
signed char *) p));
1519 case EXIF_FMT_SSHORT:
1521 EXIFMultipleValues(
"%hd",ReadPropertySignedShort(endian,p));
1524 case EXIF_FMT_USHORT:
1526 EXIFMultipleValues(
"%hu",ReadPropertyUnsignedShort(endian,p));
1529 case EXIF_FMT_ULONG:
1531 EXIFMultipleValues(
"%.20g",(
double)
1532 ReadPropertyUnsignedLong(endian,p));
1535 case EXIF_FMT_SLONG:
1537 EXIFMultipleValues(
"%.20g",(
double)
1538 ReadPropertySignedLong(endian,p));
1541 case EXIF_FMT_URATIONAL:
1543 if ((tag_value == GPS_LATITUDE) || (tag_value == GPS_LONGITUDE) ||
1544 (tag_value == GPS_TIMESTAMP))
1547 EXIFGPSFractions(
"%.20g/%.20g,%.20g/%.20g,%.20g/%.20g",
1548 (
double) ReadPropertyUnsignedLong(endian,p),
1549 (
double) ReadPropertyUnsignedLong(endian,p+4),
1550 (
double) ReadPropertyUnsignedLong(endian,p+8),
1551 (
double) ReadPropertyUnsignedLong(endian,p+12),
1552 (
double) ReadPropertyUnsignedLong(endian,p+16),
1553 (
double) ReadPropertyUnsignedLong(endian,p+20));
1556 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1557 ReadPropertyUnsignedLong(endian,p),(
double)
1558 ReadPropertyUnsignedLong(endian,p+4));
1561 case EXIF_FMT_SRATIONAL:
1563 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1564 ReadPropertySignedLong(endian,p),(
double)
1565 ReadPropertySignedLong(endian,p+4));
1568 case EXIF_FMT_SINGLE:
1570 EXIFMultipleValues(
"%.20g",(
double)
1571 ReadPropertySignedLong(endian,p));
1574 case EXIF_FMT_DOUBLE:
1576 EXIFMultipleValues(
"%.20g",(
double)
1577 ReadPropertySignedLong(endian,p));
1580 case EXIF_FMT_STRING:
1581 case EXIF_FMT_UNDEFINED:
1584 if ((p < exif) || (p > (exif+length-number_bytes)))
1586 value=(
char *) NULL;
1587 if (~((
size_t) number_bytes) >= 1)
1588 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1590 if (value != (
char *) NULL)
1592 for (i=0; i < (ssize_t) number_bytes; i++)
1595 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1596 value[i]=(char) p[i];
1603 if (value != (
char *) NULL)
1608 key=AcquireString(property);
1616 description=
"unknown";
1619 if (EXIFTag[i].tag == 0)
1621 if (EXIFTag[i].tag == tag_value)
1623 description=EXIFTag[i].description;
1627 (void) FormatLocaleString(key,MagickPathExtent,
"%s",
1630 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1635 if (tag_value < 0x10000)
1636 (void) FormatLocaleString(key,MagickPathExtent,
"#%04lx",
1637 (
unsigned long) tag_value);
1639 if (tag_value < 0x20000)
1640 (void) FormatLocaleString(key,MagickPathExtent,
"@%04lx",
1641 (
unsigned long) (tag_value & 0xffff));
1643 (
void) FormatLocaleString(key,MagickPathExtent,
"unknown");
1649 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1652 if ((image->properties == (
void *) NULL) ||
1653 (GetValueFromSplayTree((
SplayTreeInfo *) image->properties,key) == (
const void *) NULL))
1654 (void) SetImageProperty((
Image *) image,key,value,exception);
1655 value=DestroyString(value);
1656 key=DestroyString(key);
1659 if ((tag_value == TAG_EXIF_OFFSET) ||
1660 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1665 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,p);
1666 if (((
size_t) tag_offset1 < length) &&
1667 (level < (MaxDirectoryStack-2)))
1672 tag_offset2=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1674 directory_stack[level].directory=directory;
1676 directory_stack[level].entry=entry;
1677 directory_stack[level].offset=tag_offset;
1682 for (i=0; i < level; i++)
1683 if (directory_stack[i].directory == (exif+tag_offset1))
1687 directory_stack[level].directory=exif+tag_offset1;
1688 directory_stack[level].offset=tag_offset2;
1689 directory_stack[level].entry=0;
1691 if ((directory+2+(12*number_entries)+4) > (exif+length))
1693 tag_offset1=(ssize_t) ReadPropertySignedLong(endian,directory+
1694 2+(12*number_entries));
1695 if ((tag_offset1 != 0) && ((
size_t) tag_offset1 < length) &&
1696 (level < (MaxDirectoryStack-2)))
1698 directory_stack[level].directory=exif+tag_offset1;
1699 directory_stack[level].entry=0;
1700 directory_stack[level].offset=tag_offset2;
1707 }
while (level > 0);
1708 exif_resources=DestroySplayTree(exif_resources);
1711#if defined(MAGICKCORE_LCMS_DELEGATE)
1724 profile=GetImageProfile(image,
"icc");
1726 profile=GetImageProfile(image,
"icm");
1729 if (GetStringInfoLength(profile) < 128)
1731 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1732 (cmsUInt32Number) GetStringInfoLength(profile));
1733 if (icc_profile != (cmsHPROFILE *) NULL)
1735#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1739 name=cmsTakeProductName(icc_profile);
1740 if (name != (
const char *) NULL)
1741 (void) SetImageProperty((
Image *) image,
"icc:name",name,exception);
1749 info=AcquireStringInfo(0);
1750 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1754 SetStringInfoLength(info,extent+1);
1755 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1756 "US",(
char *) GetStringInfoDatum(info),extent);
1758 (void) SetImageProperty((
Image *) image,
"icc:description",
1759 (
char *) GetStringInfoDatum(info),exception);
1761 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1765 SetStringInfoLength(info,extent+1);
1766 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1767 "US",(
char *) GetStringInfoDatum(info),extent);
1769 (void) SetImageProperty((
Image *) image,
"icc:manufacturer",
1770 (
char *) GetStringInfoDatum(info),exception);
1772 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1776 SetStringInfoLength(info,extent+1);
1777 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1778 (
char *) GetStringInfoDatum(info),extent);
1780 (void) SetImageProperty((
Image *) image,
"icc:model",
1781 (
char *) GetStringInfoDatum(info),exception);
1783 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1787 SetStringInfoLength(info,extent+1);
1788 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1789 "US",(
char *) GetStringInfoDatum(info),extent);
1791 (void) SetImageProperty((
Image *) image,
"icc:copyright",
1792 (
char *) GetStringInfoDatum(info),exception);
1794 info=DestroyStringInfo(info);
1796 (void) cmsCloseProfile(icc_profile);
1801static MagickBooleanType SkipXMPValue(
const char *value)
1803 if (value == (
const char*) NULL)
1805 while (*value !=
'\0')
1807 if (isspace((
int) ((
unsigned char) *value)) == 0)
1808 return(MagickFalse);
1814static void GetXMPProperty(
const Image *image,
const char *property)
1838 profile=GetImageProfile(image,
"xmp");
1841 if (GetStringInfoLength(profile) < 17)
1843 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1845 xmp_profile=StringInfoToString(profile);
1846 if (xmp_profile == (
char *) NULL)
1848 for (p=xmp_profile; *p !=
'\0'; p++)
1849 if ((*p ==
'<') && (*(p+1) ==
'x'))
1851 exception=AcquireExceptionInfo();
1852 xmp=NewXMLTree((
char *) p,exception);
1853 xmp_profile=DestroyString(xmp_profile);
1854 exception=DestroyExceptionInfo(exception);
1857 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1860 if (image->properties == (
void *) NULL)
1861 ((
Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1862 RelinquishMagickMemory,RelinquishMagickMemory);
1863 description=GetXMLTreeChild(rdf,
"rdf:Description");
1869 node=GetXMLTreeChild(description,(
const char *) NULL);
1872 child=GetXMLTreeChild(node,(
const char *) NULL);
1873 content=GetXMLTreeContent(node);
1875 (SkipXMPValue(content) == MagickFalse))
1877 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1878 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1879 (void) AddValueToSplayTree((
SplayTreeInfo *) image->properties,
1880 xmp_namespace,ConstantString(content));
1884 content=GetXMLTreeContent(child);
1885 if (SkipXMPValue(content) == MagickFalse)
1887 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1888 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1889 (void) AddValueToSplayTree((
SplayTreeInfo *) image->properties,
1890 xmp_namespace,ConstantString(content));
1892 child=GetXMLTreeSibling(child);
1894 node=GetXMLTreeSibling(node);
1896 description=GetNextXMLTreeTag(description);
1899 xmp=DestroyXMLTree(xmp);
1902static char *TracePSClippath(
const unsigned char *blob,
size_t length)
1925 path=AcquireString((
char *) NULL);
1926 if (path == (
char *) NULL)
1927 return((
char *) NULL);
1928 message=AcquireString((
char *) NULL);
1929 (void) FormatLocaleString(message,MagickPathExtent,
"/ClipImage\n");
1930 (void) ConcatenateString(&path,message);
1931 (void) FormatLocaleString(message,MagickPathExtent,
"{\n");
1932 (void) ConcatenateString(&path,message);
1933 (void) FormatLocaleString(message,MagickPathExtent,
1934 " /c {curveto} bind def\n");
1935 (void) ConcatenateString(&path,message);
1936 (void) FormatLocaleString(message,MagickPathExtent,
1937 " /l {lineto} bind def\n");
1938 (void) ConcatenateString(&path,message);
1939 (void) FormatLocaleString(message,MagickPathExtent,
1940 " /m {moveto} bind def\n");
1941 (void) ConcatenateString(&path,message);
1942 (void) FormatLocaleString(message,MagickPathExtent,
1943 " /v {currentpoint 6 2 roll curveto} bind def\n");
1944 (void) ConcatenateString(&path,message);
1945 (void) FormatLocaleString(message,MagickPathExtent,
1946 " /y {2 copy curveto} bind def\n");
1947 (void) ConcatenateString(&path,message);
1948 (void) FormatLocaleString(message,MagickPathExtent,
1949 " /z {closepath} bind def\n");
1950 (void) ConcatenateString(&path,message);
1951 (void) FormatLocaleString(message,MagickPathExtent,
" newpath\n");
1952 (void) ConcatenateString(&path,message);
1957 (void) memset(point,0,
sizeof(point));
1958 (void) memset(first,0,
sizeof(first));
1959 (void) memset(last,0,
sizeof(last));
1961 in_subpath=MagickFalse;
1964 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1970 if (knot_count != 0)
1973 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
1979 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1981 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
1989 if (knot_count == 0)
1995 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2001 for (i=0; i < 3; i++)
2003 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2004 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2005 point[i].x=(double) x/4096.0/4096.0;
2006 point[i].y=1.0-(double) y/4096.0/4096.0;
2008 if (in_subpath == MagickFalse)
2010 (void) FormatLocaleString(message,MagickPathExtent,
" %g %g m\n",
2011 point[1].x,point[1].y);
2012 for (i=0; i < 3; i++)
2024 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2025 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2026 (void) FormatLocaleString(message,MagickPathExtent,
2027 " %g %g l\n",point[1].x,point[1].y);
2029 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2030 (void) FormatLocaleString(message,MagickPathExtent,
2031 " %g %g %g %g v\n",point[0].x,point[0].y,
2032 point[1].x,point[1].y);
2034 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2035 (void) FormatLocaleString(message,MagickPathExtent,
2036 " %g %g %g %g y\n",last[2].x,last[2].y,
2037 point[1].x,point[1].y);
2039 (
void) FormatLocaleString(message,MagickPathExtent,
2040 " %g %g %g %g %g %g c\n",last[2].x,
2041 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2042 for (i=0; i < 3; i++)
2045 (void) ConcatenateString(&path,message);
2046 in_subpath=MagickTrue;
2051 if (knot_count == 0)
2057 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2058 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2059 (void) FormatLocaleString(message,MagickPathExtent,
2060 " %g %g l z\n",first[1].x,first[1].y);
2062 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2063 (void) FormatLocaleString(message,MagickPathExtent,
2064 " %g %g %g %g v z\n",first[0].x,first[0].y,
2065 first[1].x,first[1].y);
2067 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2068 (void) FormatLocaleString(message,MagickPathExtent,
2069 " %g %g %g %g y z\n",last[2].x,last[2].y,
2070 first[1].x,first[1].y);
2072 (
void) FormatLocaleString(message,MagickPathExtent,
2073 " %g %g %g %g %g %g c z\n",last[2].x,
2074 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2075 (void) ConcatenateString(&path,message);
2076 in_subpath=MagickFalse;
2086 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2094 (void) FormatLocaleString(message,MagickPathExtent,
" eoclip\n");
2095 (void) ConcatenateString(&path,message);
2096 (void) FormatLocaleString(message,MagickPathExtent,
"} bind def");
2097 (void) ConcatenateString(&path,message);
2098 message=DestroyString(message);
2102static inline void TraceBezierCurve(
char *message,
PointInfo *last,
2109 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2110 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2111 (void) FormatLocaleString(message,MagickPathExtent,
2112 "L %g %g\n",point[1].x,point[1].y);
2114 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2115 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2118static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2119 const size_t columns,
const size_t rows)
2142 path=AcquireString((
char *) NULL);
2143 if (path == (
char *) NULL)
2144 return((
char *) NULL);
2145 message=AcquireString((
char *) NULL);
2146 (void) FormatLocaleString(message,MagickPathExtent,(
2147 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2148 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2149 " width=\"%.20g\" height=\"%.20g\">\n"
2151 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2152 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(
double) columns,
2154 (void) ConcatenateString(&path,message);
2155 (void) memset(point,0,
sizeof(point));
2156 (void) memset(first,0,
sizeof(first));
2157 (void) memset(last,0,
sizeof(last));
2159 in_subpath=MagickFalse;
2162 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2168 if (knot_count != 0)
2171 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2177 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2179 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2187 if (knot_count == 0)
2193 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2199 for (i=0; i < 3; i++)
2201 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2202 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2203 point[i].x=(double) x*columns/4096.0/4096.0;
2204 point[i].y=(double) y*rows/4096.0/4096.0;
2206 if (in_subpath == MagickFalse)
2208 (void) FormatLocaleString(message,MagickPathExtent,
"M %g %g\n",
2209 point[1].x,point[1].y);
2210 for (i=0; i < 3; i++)
2218 TraceBezierCurve(message,last,point);
2219 for (i=0; i < 3; i++)
2222 (void) ConcatenateString(&path,message);
2223 in_subpath=MagickTrue;
2228 if (knot_count == 0)
2230 TraceBezierCurve(message,last,first);
2231 (void) ConcatenateString(&path,message);
2232 in_subpath=MagickFalse;
2242 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2250 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2251 message=DestroyString(message);
2255MagickExport
const char *GetImageProperty(
const Image *image,
2259 read_from_properties;
2267 assert(image != (
Image *) NULL);
2268 assert(image->signature == MagickCoreSignature);
2269 if (IsEventLogging() != MagickFalse)
2270 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2271 if ((property == (
const char *) NULL) || (*property ==
'\0'))
2272 return((
const char *) NULL);
2273 read_from_properties=MagickTrue;
2274 property_length=strlen(property);
2275 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
2276 (*(property+(property_length-1)) ==
'*'))
2277 read_from_properties=MagickFalse;
2278 if (read_from_properties != MagickFalse)
2280 p=(
const char *) NULL;
2281 if (image->properties != (
void *) NULL)
2284 image->properties,property);
2285 if (p != (
const char *) NULL)
2288 if (strchr(property,
':') == (
char *) NULL)
2295 if (LocaleNCompare(
"8bim:",property,5) == 0)
2297 Get8BIMProperty(image,property,exception);
2305 if (LocaleNCompare(
"exif:",property,5) == 0)
2307 GetEXIFProperty(image,property,exception);
2315 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2316 (LocaleNCompare(
"icm:",property,4) == 0))
2318#if defined(MAGICKCORE_LCMS_DELEGATE)
2319 GetICCProperty(image,exception);
2323 if (LocaleNCompare(
"iptc:",property,5) == 0)
2325 GetIPTCProperty(image,property,exception);
2333 if (LocaleNCompare(
"xmp:",property,4) == 0)
2335 GetXMPProperty(image,property);
2343 if ((image->properties != (
void *) NULL) &&
2344 (read_from_properties != MagickFalse))
2347 image->properties,property);
2350 return((
const char *) NULL);
2444static const char *GetMagickPropertyLetter(
ImageInfo *image_info,
2447#define WarnNoImageReturn(format,arg) \
2448 if (image == (Image *) NULL ) { \
2449 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2450 "NoImageForProperty",format,arg); \
2451 return((const char *) NULL); \
2453#define WarnNoImageInfoReturn(format,arg) \
2454 if (image_info == (ImageInfo *) NULL ) { \
2455 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2456 "NoImageInfoForProperty",format,arg); \
2457 return((const char *) NULL); \
2461 value[MagickPathExtent];
2466 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
2467 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2469 if ((image_info != (
ImageInfo *) NULL) &&
2470 (IsEventLogging() != MagickFalse))
2471 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2473 string=(
char *) NULL;
2481 WarnNoImageReturn(
"\"%%%c\"",letter);
2482 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
2484 if (image->extent == 0)
2485 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
2486 MagickPathExtent,value);
2491 WarnNoImageReturn(
"\"%%%c\"",letter);
2492 string=GetImageProperty(image,
"comment",exception);
2493 if (
string == (
const char *) NULL )
2499 WarnNoImageReturn(
"\"%%%c\"",letter);
2500 GetPathComponent(image->magick_filename,HeadPath,value);
2507 WarnNoImageReturn(
"\"%%%c\"",letter);
2508 GetPathComponent(image->magick_filename,ExtensionPath,value);
2515 WarnNoImageReturn(
"\"%%%c\"",letter);
2516 GetPathComponent(image->magick_filename,TailPath,value);
2523 WarnNoImageReturn(
"\"%%%c\"",letter);
2524 (void) FormatLocaleString(value,MagickPathExtent,
2525 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(
double)
2526 image->page.height,(
double) image->page.x,(
double) image->page.y);
2531 WarnNoImageReturn(
"\"%%%c\"",letter);
2532 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2533 (image->rows != 0 ? image->rows : image->magick_rows));
2538 WarnNoImageReturn(
"\"%%%c\"",letter);
2539 string=image->filename;
2547 WarnNoImageReturn(
"\"%%%c\"",letter);
2548 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2549 GetNumberColors(image,(FILE *) NULL,exception));
2554 WarnNoImageReturn(
"\"%%%c\"",letter);
2555 string=GetImageProperty(image,
"label",exception);
2556 if (
string == (
const char *) NULL)
2562 WarnNoImageReturn(
"\"%%%c\"",letter);
2563 string=image->magick;
2568 if ( image != (
Image *) NULL )
2569 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2570 GetImageListLength(image));
2577 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2578 string=image_info->filename;
2583 WarnNoImageReturn(
"\"%%%c\"",letter);
2584 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2585 GetImageIndexInList(image));
2590 WarnNoImageReturn(
"\"%%%c\"",letter);
2591 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2592 MAGICKCORE_QUANTUM_DEPTH);
2600 WarnNoImageReturn(
"\"%%%c\"",letter);
2601 colorspace=image->colorspace;
2602 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
2603 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2604 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2605 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2612 if (image_info->number_scenes != 0)
2613 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2615 else if (image != (
Image *) NULL)
2616 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2621 WarnNoImageReturn(
"\"%%%c\"",letter);
2622 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2629 WarnNoImageReturn(
"\"%%%c\"",letter);
2630 GetPathComponent(image->magick_filename,BasePath,value);
2637 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2638 string=image_info->unique;
2643 WarnNoImageReturn(
"\"%%%c\"",letter);
2644 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2645 (image->columns != 0 ? image->columns : image->magick_columns));
2650 WarnNoImageReturn(
"\"%%%c\"",letter);
2651 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2652 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
2653 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2659 WarnNoImageReturn(
"\"%%%c\"",letter);
2660 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2661 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
2662 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2668 WarnNoImageReturn(
"\"%%%c\"",letter);
2669 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2675 WarnNoImageReturn(
"\"%%%c\"",letter);
2676 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2677 image->alpha_trait);
2682 WarnNoImageReturn(
"\"%%%c\"",letter);
2683 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2685 if (image->extent == 0)
2686 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2687 GetBlobSize(image));
2692 WarnNoImageReturn(
"\"%%%c\"",letter);
2693 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2694 image->compression);
2699 WarnNoImageReturn(
"\"%%%c\"",letter);
2700 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2706 WarnNoImageReturn(
"\"%%%c\"",letter);
2707 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2708 image->magick_columns,(
double) image->magick_rows);
2713 WarnNoImageReturn(
"\"%%%c\"",letter);
2714 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2715 image->page.height);
2720 WarnNoImageReturn(
"\"%%%c\"",letter);
2721 string=image->magick_filename;
2726 if ((image != (
Image *) NULL) && (image->next == (
Image *) NULL))
2727 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2728 GetImageListLength(image));
2735 WarnNoImageReturn(
"\"%%%c\"",letter);
2736 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
2737 image->page.x,(
long) image->page.y);
2742 WarnNoImageReturn(
"\"%%%c\"",letter);
2743 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2744 image->page.width,(
double) image->page.height);
2749 WarnNoImageReturn(
"\"%%%c\"",letter);
2750 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2751 (image->quality == 0 ? 92 : image->quality));
2756 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2758 if (image_info->number_scenes == 0)
2759 string=
"2147483647";
2760 else if ( image != (
Image *) NULL )
2761 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2762 image_info->scene+image_info->number_scenes);
2766 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2767 (image_info->number_scenes == 0 ? 2147483647 :
2768 image_info->number_scenes));
2774 WarnNoImageReturn(
"\"%%%c\"",letter);
2775 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2781 WarnNoImageReturn(
"\"%%%c\"",letter);
2782 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2788 WarnNoImageReturn(
"\"%%%c\"",letter);
2789 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2795 WarnNoImageReturn(
"\"%%%c\"",letter);
2796 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2802 WarnNoImageReturn(
"\"%%%c\"",letter);
2803 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2817 WarnNoImageReturn(
"\"%%%c\"",letter);
2818 page=GetImageBoundingBox(image,exception);
2819 (void) FormatLocaleString(value,MagickPathExtent,
2820 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(
double) page.height,
2821 (
double) page.x,(
double)page.y);
2829 WarnNoImageReturn(
"\"%%%c\"",letter);
2830 if ((image->columns != 0) && (image->rows != 0))
2831 (void) SignatureImage(image,exception);
2832 string=GetImageProperty(image,
"signature",exception);
2836 if (
string != (
char *) NULL)
2843 if (image != (
Image *) NULL)
2845 (void) SetImageArtifact(image,
"magick-property",value);
2846 return(GetImageArtifact(image,
"magick-property"));
2850 (void) SetImageOption(image_info,
"magick-property",value);
2851 return(GetImageOption(image_info,
"magick-property"));
2854 return((
char *) NULL);
2857MagickExport
const char *GetMagickProperty(
ImageInfo *image_info,
2861 value[MagickPathExtent];
2866 assert(property != (
const char *) NULL);
2867 assert(property[0] !=
'\0');
2868 assert(image != (
Image *) NULL || image_info != (
ImageInfo *) NULL );
2869 if (property[1] ==
'\0')
2870 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2871 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
2872 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2874 if ((image_info != (
ImageInfo *) NULL) &&
2875 (IsEventLogging() != MagickFalse))
2876 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2878 string=(
char *) NULL;
2883 if (LocaleCompare(
"basename",property) == 0)
2885 WarnNoImageReturn(
"\"%%[%s]\"",property);
2886 GetPathComponent(image->magick_filename,BasePath,value);
2891 if (LocaleCompare(
"bit-depth",property) == 0)
2893 WarnNoImageReturn(
"\"%%[%s]\"",property);
2894 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2895 GetImageDepth(image,exception));
2898 if (LocaleCompare(
"bounding-box",property) == 0)
2903 WarnNoImageReturn(
"\"%%[%s]\"",property);
2904 geometry=GetImageBoundingBox(image,exception);
2905 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g",
2906 (
double) geometry.x,(
double) geometry.y,
2907 (
double) geometry.x+geometry.width,
2908 (
double) geometry.y+geometry.height);
2915 if (LocaleCompare(
"channels",property) == 0)
2917 WarnNoImageReturn(
"\"%%[%s]\"",property);
2918 (void) FormatLocaleString(value,MagickPathExtent,
"%s%s %g.%g",
2919 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2920 image->colorspace),image->alpha_trait != UndefinedPixelTrait ?
2921 "a" :
" ",(
double) image->number_channels,(
double)
2922 image->number_meta_channels);
2926 if (LocaleCompare(
"colors",property) == 0)
2928 WarnNoImageReturn(
"\"%%[%s]\"",property);
2929 image->colors=GetNumberColors(image,(FILE *) NULL,exception);
2930 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2934 if (LocaleCompare(
"colorspace",property) == 0)
2936 WarnNoImageReturn(
"\"%%[%s]\"",property);
2937 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2941 if (LocaleCompare(
"compose",property) == 0)
2943 WarnNoImageReturn(
"\"%%[%s]\"",property);
2944 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2948 if (LocaleCompare(
"compression",property) == 0)
2950 WarnNoImageReturn(
"\"%%[%s]\"",property);
2951 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2952 image->compression);
2955 if (LocaleCompare(
"convex-hull",property) == 0)
2969 WarnNoImageReturn(
"\"%%[%s]\"",property);
2970 convex_hull=GetImageConvexHull(image,&number_points,exception);
2973 points=AcquireString(
"");
2974 for (n=0; n < (ssize_t) number_points; n++)
2976 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
2977 convex_hull[n].x,convex_hull[n].y);
2978 (void) ConcatenateString(&points,value);
2980 convex_hull=(
PointInfo *) RelinquishMagickMemory(convex_hull);
2981 (void) SetImageProperty(image,
"convex-hull",points,exception);
2982 points=DestroyString(points);
2983 string=GetImageProperty(image,
"convex-hull",exception);
2986 if (LocaleCompare(
"convex-hull:extreme-points",property) == 0)
3001 WarnNoImageReturn(
"\"%%[%s]\"",property);
3002 convex_hull=GetImageConvexHull(image,&number_points,exception);
3005 points=AcquireString(
"");
3006 extreme=convex_hull[0];
3007 for (n=0; n < (ssize_t) number_points; n++)
3009 if (convex_hull[n].y < extreme.y)
3011 extreme=convex_hull[n];
3014 if (convex_hull[n].y != extreme.y)
3016 if (convex_hull[n].x < extreme.x)
3017 extreme=convex_hull[n];
3019 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3020 extreme.x,extreme.y);
3021 (void) ConcatenateString(&points,value);
3022 extreme=convex_hull[0];
3023 for (n=0; n < (ssize_t) number_points; n++)
3025 if (convex_hull[n].x > extreme.x)
3027 extreme=convex_hull[n];
3030 if (convex_hull[n].x != extreme.x)
3032 if (convex_hull[n].y < extreme.y)
3033 extreme=convex_hull[n];
3035 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3036 extreme.x,extreme.y);
3037 (void) ConcatenateString(&points,value);
3038 extreme=convex_hull[0];
3039 for (n=0; n < (ssize_t) number_points; n++)
3041 if (convex_hull[n].y > extreme.y)
3043 extreme=convex_hull[n];
3046 if (convex_hull[n].y != extreme.y)
3048 if (convex_hull[n].x > extreme.x)
3049 extreme=convex_hull[n];
3051 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3052 extreme.x,extreme.y);
3053 (void) ConcatenateString(&points,value);
3054 extreme=convex_hull[0];
3055 for (n=0; n < (ssize_t) number_points; n++)
3057 if (convex_hull[n].x < extreme.x)
3059 extreme=convex_hull[n];
3062 if (convex_hull[n].x != extreme.x)
3064 if (convex_hull[n].y > extreme.y)
3065 extreme=convex_hull[n];
3067 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3068 extreme.x,extreme.y);
3069 (void) ConcatenateString(&points,value);
3070 convex_hull=(
PointInfo *) RelinquishMagickMemory(convex_hull);
3071 (void) SetImageProperty(image,
"convex-hull:extreme-points",points,
3073 points=DestroyString(points);
3074 string=GetImageProperty(image,
"convex-hull:extreme-points",exception);
3077 if (LocaleCompare(
"copyright",property) == 0)
3079 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
3086 if (LocaleCompare(
"depth",property) == 0)
3088 WarnNoImageReturn(
"\"%%[%s]\"",property);
3089 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3093 if (LocaleCompare(
"directory",property) == 0)
3095 WarnNoImageReturn(
"\"%%[%s]\"",property);
3096 GetPathComponent(image->magick_filename,HeadPath,value);
3105 if (LocaleCompare(
"entropy",property) == 0)
3110 WarnNoImageReturn(
"\"%%[%s]\"",property);
3111 (void) GetImageEntropy(image,&entropy,exception);
3112 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3113 GetMagickPrecision(),entropy);
3116 if (LocaleCompare(
"extension",property) == 0)
3118 WarnNoImageReturn(
"\"%%[%s]\"",property);
3119 GetPathComponent(image->magick_filename,ExtensionPath,value);
3128 if (LocaleCompare(
"gamma",property) == 0)
3130 WarnNoImageReturn(
"\"%%[%s]\"",property);
3131 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3132 GetMagickPrecision(),image->gamma);
3139 if (LocaleCompare(
"height",property) == 0)
3141 WarnNoImageReturn(
"\"%%[%s]\"",property);
3142 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
3143 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3150 if (LocaleCompare(
"input",property) == 0)
3152 WarnNoImageReturn(
"\"%%[%s]\"",property);
3153 string=image->filename;
3156 if (LocaleCompare(
"interlace",property) == 0)
3158 WarnNoImageReturn(
"\"%%[%s]\"",property);
3159 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3167 if (LocaleCompare(
"kurtosis",property) == 0)
3173 WarnNoImageReturn(
"\"%%[%s]\"",property);
3174 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3175 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3176 GetMagickPrecision(),kurtosis);
3183 if (LocaleCompare(
"magick",property) == 0)
3185 WarnNoImageReturn(
"\"%%[%s]\"",property);
3186 string=image->magick;
3189 if ((LocaleCompare(
"maxima",property) == 0) ||
3190 (LocaleCompare(
"max",property) == 0))
3196 WarnNoImageReturn(
"\"%%[%s]\"",property);
3197 (void) GetImageRange(image,&minimum,&maximum,exception);
3198 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3199 GetMagickPrecision(),maximum);
3202 if (LocaleCompare(
"mean",property) == 0)
3208 WarnNoImageReturn(
"\"%%[%s]\"",property);
3209 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3210 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3211 GetMagickPrecision(),mean);
3214 if (LocaleCompare(
"median",property) == 0)
3219 WarnNoImageReturn(
"\"%%[%s]\"",property);
3220 (void) GetImageMedian(image,&median,exception);
3221 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3222 GetMagickPrecision(),median);
3225 if ((LocaleCompare(
"minima",property) == 0) ||
3226 (LocaleCompare(
"min",property) == 0))
3232 WarnNoImageReturn(
"\"%%[%s]\"",property);
3233 (void) GetImageRange(image,&minimum,&maximum,exception);
3234 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3235 GetMagickPrecision(),minimum);
3238 if (LocaleNCompare(
"minimum-bounding-box",property,20) == 0)
3252 WarnNoImageReturn(
"\"%%[%s]\"",property);
3253 bounding_box=GetImageMinimumBoundingBox(image,&number_points,
3257 points=AcquireString(
"");
3258 for (n=0; n < (ssize_t) number_points; n++)
3260 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3261 bounding_box[n].x,bounding_box[n].y);
3262 (void) ConcatenateString(&points,value);
3264 bounding_box=(
PointInfo *) RelinquishMagickMemory(bounding_box);
3265 (void) SetImageProperty(image,
"minimum-bounding-box",points,
3267 points=DestroyString(points);
3268 string=GetImageProperty(image,property,exception);
3275 if (LocaleCompare(
"opaque",property) == 0)
3277 WarnNoImageReturn(
"\"%%[%s]\"",property);
3278 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
3279 IsImageOpaque(image,exception));
3282 if (LocaleCompare(
"orientation",property) == 0)
3284 WarnNoImageReturn(
"\"%%[%s]\"",property);
3285 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3286 image->orientation);
3289 if (LocaleCompare(
"output",property) == 0)
3291 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3292 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
3299 if (LocaleCompare(
"page",property) == 0)
3301 WarnNoImageReturn(
"\"%%[%s]\"",property);
3302 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3303 (
double) image->page.width,(
double) image->page.height);
3306 if (LocaleNCompare(
"papersize:",property,10) == 0)
3311 WarnNoImageReturn(
"\"%%[%s]\"",property);
3313 papersize=GetPageGeometry(property+10);
3314 if (papersize != (
const char *) NULL)
3317 page = { 0, 0, 0, 0 };
3319 (void) ParseAbsoluteGeometry(papersize,&page);
3320 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3321 (
double) page.width,(
double) page.height);
3322 papersize=DestroyString(papersize);
3326#if defined(MAGICKCORE_LCMS_DELEGATE)
3327 if (LocaleCompare(
"profile:icc",property) == 0 ||
3328 LocaleCompare(
"profile:icm",property) == 0)
3330#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3331#define cmsUInt32Number DWORD
3340 WarnNoImageReturn(
"\"%%[%s]\"",property);
3341 profile=GetImageProfile(image,property+8);
3344 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3345 (cmsUInt32Number) GetStringInfoLength(profile));
3346 if (icc_profile != (cmsHPROFILE *) NULL)
3348#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3349 string=cmsTakeProductName(icc_profile);
3351 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3352 "en",
"US",value,MagickPathExtent);
3354 (void) cmsCloseProfile(icc_profile);
3358 if (LocaleCompare(
"printsize.x",property) == 0)
3360 WarnNoImageReturn(
"\"%%[%s]\"",property);
3361 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3362 GetMagickPrecision(),(
double) PerceptibleReciprocal(
3363 image->resolution.x)*image->columns);
3366 if (LocaleCompare(
"printsize.y",property) == 0)
3368 WarnNoImageReturn(
"\"%%[%s]\"",property);
3369 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3370 GetMagickPrecision(),(
double) PerceptibleReciprocal(
3371 image->resolution.y)*image->rows);
3374 if (LocaleCompare(
"profiles",property) == 0)
3379 WarnNoImageReturn(
"\"%%[%s]\"",property);
3380 ResetImageProfileIterator(image);
3381 name=GetNextImageProfile(image);
3382 if (name != (
char *) NULL)
3384 (void) CopyMagickString(value,name,MagickPathExtent);
3385 name=GetNextImageProfile(image);
3386 while (name != (
char *) NULL)
3388 ConcatenateMagickString(value,
",",MagickPathExtent);
3389 ConcatenateMagickString(value,name,MagickPathExtent);
3390 name=GetNextImageProfile(image);
3399 if (LocaleCompare(
"quality",property) == 0)
3401 WarnNoImageReturn(
"\"%%[%s]\"",property);
3402 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3410 if (LocaleCompare(
"resolution.x",property) == 0)
3412 WarnNoImageReturn(
"\"%%[%s]\"",property);
3413 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3414 image->resolution.x);
3417 if (LocaleCompare(
"resolution.y",property) == 0)
3419 WarnNoImageReturn(
"\"%%[%s]\"",property);
3420 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3421 image->resolution.y);
3428 if (LocaleCompare(
"scene",property) == 0)
3430 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3431 if (image_info->number_scenes != 0)
3432 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3435 WarnNoImageReturn(
"\"%%[%s]\"",property);
3436 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3441 if (LocaleCompare(
"scenes",property) == 0)
3444 WarnNoImageReturn(
"\"%%[%s]\"",property);
3445 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3446 GetImageListLength(image));
3449 if (LocaleCompare(
"size",property) == 0)
3451 WarnNoImageReturn(
"\"%%[%s]\"",property);
3452 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
3453 MagickPathExtent,value);
3456 if (LocaleCompare(
"skewness",property) == 0)
3462 WarnNoImageReturn(
"\"%%[%s]\"",property);
3463 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3464 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3465 GetMagickPrecision(),skewness);
3468 if (LocaleCompare(
"standard-deviation",property) == 0)
3474 WarnNoImageReturn(
"\"%%[%s]\"",property);
3475 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3476 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3477 GetMagickPrecision(),standard_deviation);
3484 if (LocaleCompare(
"type",property) == 0)
3486 WarnNoImageReturn(
"\"%%[%s]\"",property);
3487 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3488 IdentifyImageType(image,exception));
3495 if (LocaleCompare(
"unique",property) == 0)
3497 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3498 string=image_info->unique;
3501 if (LocaleCompare(
"units",property) == 0)
3503 WarnNoImageReturn(
"\"%%[%s]\"",property);
3504 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3512 if (LocaleCompare(
"version",property) == 0)
3514 string=GetMagickVersion((
size_t *) NULL);
3521 if (LocaleCompare(
"width",property) == 0)
3523 WarnNoImageReturn(
"\"%%[%s]\"",property);
3524 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3525 (image->magick_columns != 0 ? image->magick_columns : 256));
3531 if (
string != (
char *) NULL)
3538 if (image != (
Image *) NULL)
3540 (void) SetImageArtifact(image,
"magick-property",value);
3541 return(GetImageArtifact(image,
"magick-property"));
3545 (void) SetImageOption(image_info,
"magick-property",value);
3546 return(GetImageOption(image_info,
"magick-property"));
3549 return((
char *) NULL);
3551#undef WarnNoImageReturn
3575MagickExport
const char *GetNextImageProperty(
const Image *image)
3577 assert(image != (
Image *) NULL);
3578 assert(image->signature == MagickCoreSignature);
3579 if (IsEventLogging() != MagickFalse)
3580 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3582 if (image->properties == (
void *) NULL)
3583 return((
const char *) NULL);
3584 return((
const char *) GetNextKeyInSplayTree((
SplayTreeInfo *) image->properties));
3641MagickExport
char *InterpretImageProperties(
ImageInfo *image_info,
Image *image,
3644#define ExtendInterpretText(string_length) \
3646 size_t length=(string_length); \
3647 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3650 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3651 MagickPathExtent,sizeof(*interpret_text)); \
3652 if (interpret_text == (char *) NULL) \
3654 if (property_image != image) \
3655 property_image=DestroyImage(property_image); \
3656 if (property_info != image_info) \
3657 property_info=DestroyImageInfo(property_info); \
3658 return((char *) NULL); \
3660 q=interpret_text+strlen(interpret_text); \
3664#define AppendKeyValue2Text(key,value)\
3666 size_t length=strlen(key)+strlen(value)+2; \
3667 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3670 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3671 MagickPathExtent,sizeof(*interpret_text)); \
3672 if (interpret_text == (char *) NULL) \
3674 if (property_image != image) \
3675 property_image=DestroyImage(property_image); \
3676 if (property_info != image_info) \
3677 property_info=DestroyImageInfo(property_info); \
3678 return((char *) NULL); \
3680 q=interpret_text+strlen(interpret_text); \
3682 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3685#define AppendString2Text(string) \
3687 size_t length = strlen((string)); \
3688 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3691 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3692 MagickPathExtent,sizeof(*interpret_text)); \
3693 if (interpret_text == (char *) NULL) \
3695 if (property_image != image) \
3696 property_image=DestroyImage(property_image); \
3697 if (property_info != image_info) \
3698 property_info=DestroyImageInfo(property_info); \
3699 return((char *) NULL); \
3701 q=interpret_text+strlen(interpret_text); \
3703 (void) CopyMagickString(q,(string),extent); \
3704 q+=(ptrdiff_t) length; \
3726 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
3727 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3729 if ((image_info != (
ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
3730 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3731 image_info->filename);
3733 if (IsEventLogging() != MagickFalse)
3734 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no image");
3735 if (embed_text == (
const char *) NULL)
3736 return(ConstantString(
""));
3738 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3741 return(ConstantString(
""));
3742 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3747 interpret_text=FileToString(p,~0UL,exception);
3748 if (interpret_text != (
char *) NULL)
3749 return(interpret_text);
3755 property_info=image_info;
3757 property_info=CloneImageInfo(image_info);
3758 if ((image != (
Image *) NULL) && (image->columns != 0) && (image->rows != 0))
3759 property_image=image;
3762 property_image=AcquireImage(image_info,exception);
3763 (void) SetImageExtent(property_image,1,1,exception);
3764 (void) SetImageBackgroundColor(property_image,exception);
3766 interpret_text=AcquireString(embed_text);
3767 extent=MagickPathExtent;
3769 for (q=interpret_text; *p!=
'\0'; number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
3775 ExtendInterpretText(MagickPathExtent);
3818 if (LocaleNCompare(
"<",p,4) == 0)
3824 if (LocaleNCompare(
">",p,4) == 0)
3830 if (LocaleNCompare(
"&",p,5) == 0)
3851 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3866 if (number != MagickFalse)
3875 string=GetMagickPropertyLetter(property_info,image,*p,exception);
3876 if (
string != (
char *) NULL)
3878 AppendString2Text(
string);
3879 (void) DeleteImageArtifact(property_image,
"magick-property");
3880 (void) DeleteImageOption(property_info,
"magick-property");
3883 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3884 "UnknownImageProperty",
"\"%%%c\"",*p);
3889 pattern[2*MagickPathExtent] =
"\0";
3908 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3909 "UnknownImageProperty",
"\"%%[]\"");
3912 for (len=0; len < (MagickPathExtent-1L) && (*p !=
'\0'); )
3914 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3919 pattern[len++]=(*p++);
3920 pattern[len++]=(*p++);
3929 pattern[len++]=(*p++);
3944 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3945 "UnbalancedBraces",
"\"%%[%s\"",pattern);
3946 interpret_text=DestroyString(interpret_text);
3947 if (property_image != image)
3948 property_image=DestroyImage(property_image);
3949 if (property_info != image_info)
3950 property_info=DestroyImageInfo(property_info);
3951 return((
char *) NULL);
3956 if (LocaleNCompare(
"fx:",pattern,3) == 0)
3970 fx_info=AcquireFxInfo(property_image,pattern+3,exception);
3971 if (fx_info == (
FxInfo *) NULL)
3973 status=FxEvaluateChannelExpression(fx_info,CompositePixelChannel,0,0,
3975 fx_info=DestroyFxInfo(fx_info);
3976 if (status != MagickFalse)
3979 result[MagickPathExtent];
3981 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
3982 GetMagickPrecision(),(
double) value);
3983 AppendString2Text(result);
3987 if (LocaleNCompare(
"hex:",pattern,4) == 0)
4004 GetPixelInfo(property_image,&pixel);
4005 fx_info=AcquireFxInfo(property_image,pattern+4,exception);
4006 if (fx_info == (
FxInfo *) NULL)
4008 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4010 pixel.red=(double) QuantumRange*value;
4011 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4012 GreenPixelChannel,0,0,&value,exception);
4013 pixel.green=(double) QuantumRange*value;
4014 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4015 BluePixelChannel,0,0,&value,exception);
4016 pixel.blue=(double) QuantumRange*value;
4017 if (property_image->colorspace == CMYKColorspace)
4019 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4020 BlackPixelChannel,0,0,&value,exception);
4021 pixel.black=(double) QuantumRange*value;
4023 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4024 AlphaPixelChannel,0,0,&value,exception);
4025 pixel.alpha=(double) QuantumRange*value;
4026 fx_info=DestroyFxInfo(fx_info);
4027 if (status != MagickFalse)
4030 hex[MagickPathExtent];
4032 GetColorTuple(&pixel,MagickTrue,hex);
4033 AppendString2Text(hex+1);
4037 if (LocaleNCompare(
"pixel:",pattern,6) == 0)
4054 GetPixelInfo(property_image,&pixel);
4055 fx_info=AcquireFxInfo(property_image,pattern+6,exception);
4056 if (fx_info == (
FxInfo *) NULL)
4058 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4060 pixel.red=(double) QuantumRange*value;
4061 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4062 GreenPixelChannel,0,0,&value,exception);
4063 pixel.green=(double) QuantumRange*value;
4064 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4065 BluePixelChannel,0,0,&value,exception);
4066 pixel.blue=(double) QuantumRange*value;
4067 if (property_image->colorspace == CMYKColorspace)
4069 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4070 BlackPixelChannel,0,0,&value,exception);
4071 pixel.black=(double) QuantumRange*value;
4073 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4074 AlphaPixelChannel,0,0,&value,exception);
4075 pixel.alpha=(double) QuantumRange*value;
4076 fx_info=DestroyFxInfo(fx_info);
4077 if (status != MagickFalse)
4080 name[MagickPathExtent];
4082 GetColorTuple(&pixel,MagickFalse,name);
4083 string=GetImageArtifact(property_image,
"pixel:compliance");
4084 if (
string != (
char *) NULL)
4086 ComplianceType compliance=(ComplianceType) ParseCommandOption(
4087 MagickComplianceOptions,MagickFalse,
string);
4088 (void) QueryColorname(property_image,&pixel,compliance,name,
4091 AppendString2Text(name);
4095 if (LocaleNCompare(
"option:",pattern,7) == 0)
4100 if (IsGlob(pattern+7) != MagickFalse)
4102 ResetImageOptionIterator(property_info);
4103 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4104 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4106 string=GetImageOption(property_info,key);
4107 if (
string != (
const char *) NULL)
4108 AppendKeyValue2Text(key,
string);
4113 string=GetImageOption(property_info,pattern+7);
4114 if (
string == (
char *) NULL)
4115 goto PropertyLookupFailure;
4116 AppendString2Text(
string);
4119 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4124 if (IsGlob(pattern+9) != MagickFalse)
4126 ResetImageArtifactIterator(property_image);
4127 while ((key=GetNextImageArtifact(property_image)) != (
const char *) NULL)
4128 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4130 string=GetImageArtifact(property_image,key);
4131 if (
string != (
const char *) NULL)
4132 AppendKeyValue2Text(key,
string);
4137 string=GetImageArtifact(property_image,pattern+9);
4138 if (
string == (
char *) NULL)
4139 goto PropertyLookupFailure;
4140 AppendString2Text(
string);
4143 if (LocaleNCompare(
"property:",pattern,9) == 0)
4148 if (IsGlob(pattern+9) != MagickFalse)
4150 ResetImagePropertyIterator(property_image);
4151 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4152 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4154 string=GetImageProperty(property_image,key,exception);
4155 if (
string != (
const char *) NULL)
4156 AppendKeyValue2Text(key,
string);
4161 string=GetImageProperty(property_image,pattern+9,exception);
4162 if (
string == (
char *) NULL)
4163 goto PropertyLookupFailure;
4164 AppendString2Text(
string);
4172 string=GetImageProperty(property_image,pattern,exception);
4173 if (
string != (
const char *) NULL)
4175 AppendString2Text(
string);
4176 (void) DeleteImageArtifact(property_image,
"magick-property");
4177 (void) DeleteImageOption(property_info,
"magick-property");
4180 if (IsGlob(pattern) != MagickFalse)
4186 ResetImagePropertyIterator(property_image);
4187 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4188 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4190 string=GetImageProperty(property_image,key,exception);
4191 if (
string != (
const char *) NULL)
4192 AppendKeyValue2Text(key,
string);
4202 string=GetMagickProperty(property_info,property_image,pattern,exception);
4203 if (
string != (
const char *) NULL)
4205 AppendString2Text(
string);
4212 string=GetImageArtifact(property_image,pattern);
4213 if (
string != (
char *) NULL)
4215 AppendString2Text(
string);
4221 string=GetImageOption(property_info,pattern);
4222 if (
string != (
char *) NULL)
4224 AppendString2Text(
string);
4227PropertyLookupFailure:
4238 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4239 "UnknownImageProperty",
"\"%%[%s]\"",pattern);
4243 if (property_image != image)
4244 property_image=DestroyImage(property_image);
4245 if (property_info != image_info)
4246 property_info=DestroyImageInfo(property_info);
4247 return(interpret_text);
4278MagickExport
char *RemoveImageProperty(
Image *image,
const char *property)
4283 assert(image != (
Image *) NULL);
4284 assert(image->signature == MagickCoreSignature);
4285 if (IsEventLogging() != MagickFalse)
4286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4287 if (image->properties == (
void *) NULL)
4288 return((
char *) NULL);
4289 value=(
char *) RemoveNodeFromSplayTree((
SplayTreeInfo *) image->properties,
4318MagickExport
void ResetImagePropertyIterator(
const Image *image)
4320 assert(image != (
Image *) NULL);
4321 assert(image->signature == MagickCoreSignature);
4322 if (IsEventLogging() != MagickFalse)
4323 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4324 if (image->properties == (
void *) NULL)
4326 ResetSplayTreeIterator((
SplayTreeInfo *) image->properties);
4362MagickExport MagickBooleanType SetImageProperty(
Image *image,
4363 const char *property,
const char *value,
ExceptionInfo *exception)
4374 assert(image != (
Image *) NULL);
4375 assert(image->signature == MagickCoreSignature);
4376 if (IsEventLogging() != MagickFalse)
4377 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4378 if (image->properties == (
void *) NULL)
4379 image->properties=NewSplayTree(CompareSplayTreeString,
4380 RelinquishMagickMemory,RelinquishMagickMemory);
4381 if (value == (
const char *) NULL)
4382 return(DeleteImageProperty(image,property));
4383 if (strlen(property) <= 1)
4388 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4389 "SetReadOnlyProperty",
"`%s'",property);
4390 return(MagickFalse);
4392 property_length=strlen(property);
4393 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4394 (*(property+(property_length-1)) ==
'*'))
4396 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4397 "SetReadOnlyProperty",
"`%s'",property);
4398 return(MagickFalse);
4412 if (LocaleNCompare(
"8bim:",property,5) == 0)
4414 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4415 "SetReadOnlyProperty",
"`%s'",property);
4416 return(MagickFalse);
4424 if (LocaleCompare(
"background",property) == 0)
4426 (void) QueryColorCompliance(value,AllCompliance,
4427 &image->background_color,exception);
4436 if (LocaleCompare(
"channels",property) == 0)
4438 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4439 "SetReadOnlyProperty",
"`%s'",property);
4440 return(MagickFalse);
4442 if (LocaleCompare(
"colorspace",property) == 0)
4447 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4450 return(MagickFalse);
4451 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4453 if (LocaleCompare(
"compose",property) == 0)
4458 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4460 return(MagickFalse);
4461 image->compose=(CompositeOperator) compose;
4464 if (LocaleCompare(
"compress",property) == 0)
4469 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4471 if (compression < 0)
4472 return(MagickFalse);
4473 image->compression=(CompressionType) compression;
4481 if (LocaleCompare(
"delay",property) == 0)
4486 flags=ParseGeometry(value,&geometry_info);
4487 if ((flags & GreaterValue) != 0)
4489 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4490 image->delay=(size_t) floor(geometry_info.rho+0.5);
4493 if ((flags & LessValue) != 0)
4495 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4496 image->delay=(size_t) CastDoubleToLong(
4497 floor(geometry_info.sigma+0.5));
4500 image->delay=(size_t) floor(geometry_info.rho+0.5);
4501 if ((flags & SigmaValue) != 0)
4502 image->ticks_per_second=CastDoubleToLong(floor(
4503 geometry_info.sigma+0.5));
4506 if (LocaleCompare(
"delay_units",property) == 0)
4508 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4509 "SetReadOnlyProperty",
"`%s'",property);
4510 return(MagickFalse);
4512 if (LocaleCompare(
"density",property) == 0)
4517 flags=ParseGeometry(value,&geometry_info);
4518 if ((flags & RhoValue) != 0)
4519 image->resolution.x=geometry_info.rho;
4520 image->resolution.y=image->resolution.x;
4521 if ((flags & SigmaValue) != 0)
4522 image->resolution.y=geometry_info.sigma;
4525 if (LocaleCompare(
"depth",property) == 0)
4527 image->depth=StringToUnsignedLong(value);
4530 if (LocaleCompare(
"dispose",property) == 0)
4535 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4537 return(MagickFalse);
4538 image->dispose=(DisposeType) dispose;
4548 if (LocaleNCompare(
"exif:",property,5) == 0)
4550 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4551 "SetReadOnlyProperty",
"`%s'",property);
4552 return(MagickFalse);
4559 if (LocaleNCompare(
"fx:",property,3) == 0)
4561 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4562 "SetReadOnlyProperty",
"`%s'",property);
4563 return(MagickFalse);
4571 if (LocaleCompare(
"gamma",property) == 0)
4573 image->gamma=StringToDouble(value,(
char **) NULL);
4576 if (LocaleCompare(
"gravity",property) == 0)
4581 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4583 return(MagickFalse);
4584 image->gravity=(GravityType) gravity;
4592 if (LocaleCompare(
"height",property) == 0)
4594 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4595 "SetReadOnlyProperty",
"`%s'",property);
4596 return(MagickFalse);
4603 if (LocaleCompare(
"intensity",property) == 0)
4608 intensity=ParseCommandOption(MagickIntensityOptions,MagickFalse,
4611 return(MagickFalse);
4612 image->intensity=(PixelIntensityMethod) intensity;
4615 if (LocaleCompare(
"intent",property) == 0)
4620 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4622 if (rendering_intent < 0)
4623 return(MagickFalse);
4624 image->rendering_intent=(RenderingIntent) rendering_intent;
4627 if (LocaleCompare(
"interpolate",property) == 0)
4632 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4634 if (interpolate < 0)
4635 return(MagickFalse);
4636 image->interpolate=(PixelInterpolateMethod) interpolate;
4641 if (LocaleNCompare(
"iptc:",property,5) == 0)
4643 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4644 "SetReadOnlyProperty",
"`%s'",property);
4645 return(MagickFalse);
4652 if (LocaleCompare(
"kurtosis",property) == 0)
4654 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4655 "SetReadOnlyProperty",
"`%s'",property);
4656 return(MagickFalse);
4662 if (LocaleCompare(
"loop",property) == 0)
4664 image->iterations=StringToUnsignedLong(value);
4671 if ((LocaleCompare(
"magick",property) == 0) ||
4672 (LocaleCompare(
"max",property) == 0) ||
4673 (LocaleCompare(
"mean",property) == 0) ||
4674 (LocaleCompare(
"min",property) == 0) ||
4675 (LocaleCompare(
"min",property) == 0))
4677 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4678 "SetReadOnlyProperty",
"`%s'",property);
4679 return(MagickFalse);
4684 if (LocaleCompare(
"opaque",property) == 0)
4686 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4687 "SetReadOnlyProperty",
"`%s'",property);
4688 return(MagickFalse);
4694 if (LocaleCompare(
"page",property) == 0)
4699 geometry=GetPageGeometry(value);
4700 flags=ParseAbsoluteGeometry(geometry,&image->page);
4701 geometry=DestroyString(geometry);
4706 if (LocaleNCompare(
"pixel:",property,6) == 0)
4708 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4709 "SetReadOnlyProperty",
"`%s'",property);
4710 return(MagickFalse);
4718 if (LocaleCompare(
"rendering-intent",property) == 0)
4723 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4725 if (rendering_intent < 0)
4726 return(MagickFalse);
4727 image->rendering_intent=(RenderingIntent) rendering_intent;
4734 if ((LocaleCompare(
"size",property) == 0) ||
4735 (LocaleCompare(
"skewness",property) == 0) ||
4736 (LocaleCompare(
"scenes",property) == 0) ||
4737 (LocaleCompare(
"standard-deviation",property) == 0))
4739 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4740 "SetReadOnlyProperty",
"`%s'",property);
4741 return(MagickFalse);
4747 if (LocaleCompare(
"tile-offset",property) == 0)
4752 geometry=GetPageGeometry(value);
4753 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4754 geometry=DestroyString(geometry);
4757 if (LocaleCompare(
"type",property) == 0)
4762 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4764 return(MagickFalse);
4765 image->type=(ImageType) type;
4773 if (LocaleCompare(
"units",property) == 0)
4778 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4780 return(MagickFalse);
4781 image->units=(ResolutionType) units;
4789 if (LocaleCompare(
"version",property) == 0)
4791 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4792 "SetReadOnlyProperty",
"`%s'",property);
4793 return(MagickFalse);
4800 if (LocaleCompare(
"width",property) == 0)
4802 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4803 "SetReadOnlyProperty",
"`%s'",property);
4804 return(MagickFalse);
4813 if (LocaleNCompare(
"xmp:",property,4) == 0)
4815 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4816 "SetReadOnlyProperty",
"`%s'",property);
4817 return(MagickFalse);
4824 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4825 ConstantString(property),ConstantString(value));