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");
1872 node=GetXMLTreeChild(description,(
const char *) NULL);
1875 child=GetXMLTreeChild(node,(
const char *) NULL);
1876 content=GetXMLTreeContent(node);
1878 (SkipXMPValue(content) == MagickFalse))
1880 property=ConstantString(GetXMLTreeTag(node));
1881 (void) SubstituteString(&property,
"exif:",
"xmp:");
1882 property_length=strlen(property);
1883 if ((property_length <= 2) || (*(property+(property_length-2)) !=
':') ||
1884 (*(property+(property_length-1)) !=
'*'))
1885 (void) AddValueToSplayTree((
SplayTreeInfo *) image->properties,
1886 ConstantString(property),ConstantString(content));
1887 property=DestroyString(property);
1891 content=GetXMLTreeContent(child);
1892 if (SkipXMPValue(content) == MagickFalse)
1894 property=ConstantString(GetXMLTreeTag(node));
1895 (void) SubstituteString(&property,
"exif:",
"xmp:");
1896 property_length=strlen(property);
1897 if ((property_length <= 2) || (*(property+(property_length-2)) !=
':') ||
1898 (*(property+(property_length-1)) !=
'*'))
1899 (void) AddValueToSplayTree((
SplayTreeInfo *) image->properties,
1900 ConstantString(property),ConstantString(content));
1901 property=DestroyString(property);
1903 child=GetXMLTreeSibling(child);
1905 node=GetXMLTreeSibling(node);
1907 description=GetNextXMLTreeTag(description);
1910 xmp=DestroyXMLTree(xmp);
1913static char *TracePSClippath(
const unsigned char *blob,
size_t length)
1936 path=AcquireString((
char *) NULL);
1937 if (path == (
char *) NULL)
1938 return((
char *) NULL);
1939 message=AcquireString((
char *) NULL);
1940 (void) FormatLocaleString(message,MagickPathExtent,
"/ClipImage\n");
1941 (void) ConcatenateString(&path,message);
1942 (void) FormatLocaleString(message,MagickPathExtent,
"{\n");
1943 (void) ConcatenateString(&path,message);
1944 (void) FormatLocaleString(message,MagickPathExtent,
1945 " /c {curveto} bind def\n");
1946 (void) ConcatenateString(&path,message);
1947 (void) FormatLocaleString(message,MagickPathExtent,
1948 " /l {lineto} bind def\n");
1949 (void) ConcatenateString(&path,message);
1950 (void) FormatLocaleString(message,MagickPathExtent,
1951 " /m {moveto} bind def\n");
1952 (void) ConcatenateString(&path,message);
1953 (void) FormatLocaleString(message,MagickPathExtent,
1954 " /v {currentpoint 6 2 roll curveto} bind def\n");
1955 (void) ConcatenateString(&path,message);
1956 (void) FormatLocaleString(message,MagickPathExtent,
1957 " /y {2 copy curveto} bind def\n");
1958 (void) ConcatenateString(&path,message);
1959 (void) FormatLocaleString(message,MagickPathExtent,
1960 " /z {closepath} bind def\n");
1961 (void) ConcatenateString(&path,message);
1962 (void) FormatLocaleString(message,MagickPathExtent,
" newpath\n");
1963 (void) ConcatenateString(&path,message);
1968 (void) memset(point,0,
sizeof(point));
1969 (void) memset(first,0,
sizeof(first));
1970 (void) memset(last,0,
sizeof(last));
1972 in_subpath=MagickFalse;
1975 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1981 if (knot_count != 0)
1984 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
1990 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1992 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2000 if (knot_count == 0)
2006 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2012 for (i=0; i < 3; i++)
2014 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2015 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2016 point[i].x=(double) x/4096.0/4096.0;
2017 point[i].y=1.0-(double) y/4096.0/4096.0;
2019 if (in_subpath == MagickFalse)
2021 (void) FormatLocaleString(message,MagickPathExtent,
" %g %g m\n",
2022 point[1].x,point[1].y);
2023 for (i=0; i < 3; i++)
2035 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2036 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2037 (void) FormatLocaleString(message,MagickPathExtent,
2038 " %g %g l\n",point[1].x,point[1].y);
2040 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2041 (void) FormatLocaleString(message,MagickPathExtent,
2042 " %g %g %g %g v\n",point[0].x,point[0].y,
2043 point[1].x,point[1].y);
2045 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2046 (void) FormatLocaleString(message,MagickPathExtent,
2047 " %g %g %g %g y\n",last[2].x,last[2].y,
2048 point[1].x,point[1].y);
2050 (
void) FormatLocaleString(message,MagickPathExtent,
2051 " %g %g %g %g %g %g c\n",last[2].x,
2052 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2053 for (i=0; i < 3; i++)
2056 (void) ConcatenateString(&path,message);
2057 in_subpath=MagickTrue;
2062 if (knot_count == 0)
2068 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2069 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2070 (void) FormatLocaleString(message,MagickPathExtent,
2071 " %g %g l z\n",first[1].x,first[1].y);
2073 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2074 (void) FormatLocaleString(message,MagickPathExtent,
2075 " %g %g %g %g v z\n",first[0].x,first[0].y,
2076 first[1].x,first[1].y);
2078 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2079 (void) FormatLocaleString(message,MagickPathExtent,
2080 " %g %g %g %g y z\n",last[2].x,last[2].y,
2081 first[1].x,first[1].y);
2083 (
void) FormatLocaleString(message,MagickPathExtent,
2084 " %g %g %g %g %g %g c z\n",last[2].x,
2085 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2086 (void) ConcatenateString(&path,message);
2087 in_subpath=MagickFalse;
2097 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2105 (void) FormatLocaleString(message,MagickPathExtent,
" eoclip\n");
2106 (void) ConcatenateString(&path,message);
2107 (void) FormatLocaleString(message,MagickPathExtent,
"} bind def");
2108 (void) ConcatenateString(&path,message);
2109 message=DestroyString(message);
2113static inline void TraceBezierCurve(
char *message,
PointInfo *last,
2120 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2121 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2122 (void) FormatLocaleString(message,MagickPathExtent,
2123 "L %g %g\n",point[1].x,point[1].y);
2125 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2126 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2129static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2130 const size_t columns,
const size_t rows)
2153 path=AcquireString((
char *) NULL);
2154 if (path == (
char *) NULL)
2155 return((
char *) NULL);
2156 message=AcquireString((
char *) NULL);
2157 (void) FormatLocaleString(message,MagickPathExtent,(
2158 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2159 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2160 " width=\"%.20g\" height=\"%.20g\">\n"
2162 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2163 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(double) columns,
2165 (void) ConcatenateString(&path,message);
2166 (void) memset(point,0,
sizeof(point));
2167 (void) memset(first,0,
sizeof(first));
2168 (void) memset(last,0,
sizeof(last));
2170 in_subpath=MagickFalse;
2173 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2179 if (knot_count != 0)
2182 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2188 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2190 length=(size_t) ((ssize_t) length-MagickMin(22,(ssize_t) length));
2198 if (knot_count == 0)
2204 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2210 for (i=0; i < 3; i++)
2212 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2213 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2214 point[i].x=(double) x*columns/4096.0/4096.0;
2215 point[i].y=(double) y*rows/4096.0/4096.0;
2217 if (in_subpath == MagickFalse)
2219 (void) FormatLocaleString(message,MagickPathExtent,
"M %g %g\n",
2220 point[1].x,point[1].y);
2221 for (i=0; i < 3; i++)
2229 TraceBezierCurve(message,last,point);
2230 for (i=0; i < 3; i++)
2233 (void) ConcatenateString(&path,message);
2234 in_subpath=MagickTrue;
2239 if (knot_count == 0)
2241 TraceBezierCurve(message,last,first);
2242 (void) ConcatenateString(&path,message);
2243 in_subpath=MagickFalse;
2253 length=(size_t) ((ssize_t) length-MagickMin(24,(ssize_t) length));
2261 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2262 message=DestroyString(message);
2266MagickExport
const char *GetImageProperty(
const Image *image,
2270 read_from_properties;
2278 assert(image != (
Image *) NULL);
2279 assert(image->signature == MagickCoreSignature);
2280 if (IsEventLogging() != MagickFalse)
2281 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2282 if ((property == (
const char *) NULL) || (*
property ==
'\0'))
2283 return((
const char *) NULL);
2284 read_from_properties=MagickTrue;
2285 property_length=strlen(property);
2286 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
2287 (*(property+(property_length-1)) ==
'*'))
2288 read_from_properties=MagickFalse;
2289 if (read_from_properties != MagickFalse)
2291 p=(
const char *) NULL;
2292 if (image->properties != (
void *) NULL)
2295 image->properties,property);
2296 if (p != (
const char *) NULL)
2299 if (strchr(property,
':') == (
char *) NULL)
2306 if (LocaleNCompare(
"8bim:",property,5) == 0)
2308 Get8BIMProperty(image,property,exception);
2316 if (LocaleNCompare(
"exif:",property,5) == 0)
2318 GetEXIFProperty(image,property,exception);
2326 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2327 (LocaleNCompare(
"icm:",property,4) == 0))
2329#if defined(MAGICKCORE_LCMS_DELEGATE)
2330 GetICCProperty(image,exception);
2334 if (LocaleNCompare(
"iptc:",property,5) == 0)
2336 GetIPTCProperty(image,property,exception);
2344 if (LocaleNCompare(
"xmp:",property,4) == 0)
2346 GetXMPProperty(image,property);
2354 if ((image->properties != (
void *) NULL) &&
2355 (read_from_properties != MagickFalse))
2358 image->properties,property);
2361 return((
const char *) NULL);
2455static const char *GetMagickPropertyLetter(
ImageInfo *image_info,
2458#define WarnNoImageReturn(format,arg) \
2459 if (image == (Image *) NULL ) { \
2460 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2461 "NoImageForProperty",format,arg); \
2462 return((const char *) NULL); \
2464#define WarnNoImageInfoReturn(format,arg) \
2465 if (image_info == (ImageInfo *) NULL ) { \
2466 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning, \
2467 "NoImageInfoForProperty",format,arg); \
2468 return((const char *) NULL); \
2472 value[MagickPathExtent];
2477 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
2478 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2480 if ((image_info != (
ImageInfo *) NULL) &&
2481 (IsEventLogging() != MagickFalse))
2482 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2484 string=(
char *) NULL;
2492 WarnNoImageReturn(
"\"%%%c\"",letter);
2493 (void) FormatMagickSize(image->extent,MagickFalse,
"B",MagickPathExtent,
2495 if (image->extent == 0)
2496 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
2497 MagickPathExtent,value);
2502 WarnNoImageReturn(
"\"%%%c\"",letter);
2503 string=GetImageProperty(image,
"comment",exception);
2504 if (
string == (
const char *) NULL )
2510 WarnNoImageReturn(
"\"%%%c\"",letter);
2511 GetPathComponent(image->magick_filename,HeadPath,value);
2518 WarnNoImageReturn(
"\"%%%c\"",letter);
2519 GetPathComponent(image->magick_filename,ExtensionPath,value);
2526 WarnNoImageReturn(
"\"%%%c\"",letter);
2527 GetPathComponent(image->magick_filename,TailPath,value);
2534 WarnNoImageReturn(
"\"%%%c\"",letter);
2535 (void) FormatLocaleString(value,MagickPathExtent,
2536 "%.20gx%.20g%+.20g%+.20g",(
double) image->page.width,(double)
2537 image->page.height,(
double) image->page.x,(double) image->page.y);
2542 WarnNoImageReturn(
"\"%%%c\"",letter);
2543 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2544 (image->rows != 0 ? image->rows : image->magick_rows));
2549 WarnNoImageReturn(
"\"%%%c\"",letter);
2550 string=image->filename;
2558 WarnNoImageReturn(
"\"%%%c\"",letter);
2559 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2560 GetNumberColors(image,(FILE *) NULL,exception));
2565 WarnNoImageReturn(
"\"%%%c\"",letter);
2566 string=GetImageProperty(image,
"label",exception);
2567 if (
string == (
const char *) NULL)
2573 WarnNoImageReturn(
"\"%%%c\"",letter);
2574 string=image->magick;
2579 if ( image != (
Image *) NULL )
2580 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2581 GetImageListLength(image));
2588 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2589 string=image_info->filename;
2594 WarnNoImageReturn(
"\"%%%c\"",letter);
2595 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2596 GetImageIndexInList(image));
2601 WarnNoImageReturn(
"\"%%%c\"",letter);
2602 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2603 MAGICKCORE_QUANTUM_DEPTH);
2611 WarnNoImageReturn(
"\"%%%c\"",letter);
2612 colorspace=image->colorspace;
2613 (void) FormatLocaleString(value,MagickPathExtent,
"%s %s %s",
2614 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2615 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2616 (ssize_t) colorspace),image->alpha_trait != UndefinedPixelTrait ?
2623 if (image_info->number_scenes != 0)
2624 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2626 else if (image != (
Image *) NULL)
2627 (
void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2632 WarnNoImageReturn(
"\"%%%c\"",letter);
2633 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2640 WarnNoImageReturn(
"\"%%%c\"",letter);
2641 GetPathComponent(image->magick_filename,BasePath,value);
2648 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2649 string=image_info->unique;
2654 WarnNoImageReturn(
"\"%%%c\"",letter);
2655 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2656 (image->columns != 0 ? image->columns : image->magick_columns));
2661 WarnNoImageReturn(
"\"%%%c\"",letter);
2662 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2663 fabs(image->resolution.x) > MagickEpsilon ? image->resolution.x :
2664 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2670 WarnNoImageReturn(
"\"%%%c\"",letter);
2671 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
2672 fabs(image->resolution.y) > MagickEpsilon ? image->resolution.y :
2673 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2679 WarnNoImageReturn(
"\"%%%c\"",letter);
2680 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2686 WarnNoImageReturn(
"\"%%%c\"",letter);
2687 string=CommandOptionToMnemonic(MagickPixelTraitOptions,(ssize_t)
2688 image->alpha_trait);
2693 WarnNoImageReturn(
"\"%%%c\"",letter);
2694 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2696 if (image->extent == 0)
2697 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2698 GetBlobSize(image));
2703 WarnNoImageReturn(
"\"%%%c\"",letter);
2704 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2705 image->compression);
2710 WarnNoImageReturn(
"\"%%%c\"",letter);
2711 string=CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t)
2717 WarnNoImageReturn(
"\"%%%c\"",letter);
2718 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2719 image->magick_columns,(double) image->magick_rows);
2724 WarnNoImageReturn(
"\"%%%c\"",letter);
2725 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2726 image->page.height);
2731 WarnNoImageReturn(
"\"%%%c\"",letter);
2732 string=image->magick_filename;
2737 if ((image != (
Image *) NULL) && (image->next == (
Image *) NULL))
2738 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2739 GetImageListLength(image));
2746 WarnNoImageReturn(
"\"%%%c\"",letter);
2747 (void) FormatLocaleString(value,MagickPathExtent,
"%+ld%+ld",(
long)
2748 image->page.x,(long) image->page.y);
2753 WarnNoImageReturn(
"\"%%%c\"",letter);
2754 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",(
double)
2755 image->page.width,(double) image->page.height);
2760 WarnNoImageReturn(
"\"%%%c\"",letter);
2761 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2762 (image->quality == 0 ? 92 : image->quality));
2767 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2769 if (image_info->number_scenes == 0)
2770 string=
"2147483647";
2771 else if ( image != (
Image *) NULL )
2772 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2773 image_info->scene+image_info->number_scenes);
2777 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2778 (image_info->number_scenes == 0 ? 2147483647 :
2779 image_info->number_scenes));
2785 WarnNoImageReturn(
"\"%%%c\"",letter);
2786 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2792 WarnNoImageReturn(
"\"%%%c\"",letter);
2793 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2799 WarnNoImageReturn(
"\"%%%c\"",letter);
2800 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2806 WarnNoImageReturn(
"\"%%%c\"",letter);
2807 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2813 WarnNoImageReturn(
"\"%%%c\"",letter);
2814 (void) FormatLocaleString(value,MagickPathExtent,
"%+.20g",(
double)
2828 WarnNoImageReturn(
"\"%%%c\"",letter);
2829 page=GetImageBoundingBox(image,exception);
2830 (void) FormatLocaleString(value,MagickPathExtent,
2831 "%.20gx%.20g%+.20g%+.20g",(
double) page.width,(double) page.height,
2832 (
double) page.x,(double)page.y);
2840 WarnNoImageReturn(
"\"%%%c\"",letter);
2841 if ((image->columns != 0) && (image->rows != 0))
2842 (void) SignatureImage(image,exception);
2843 string=GetImageProperty(image,
"signature",exception);
2847 if (
string != (
char *) NULL)
2854 if (image != (
Image *) NULL)
2856 (void) SetImageArtifact(image,
"magick-property",value);
2857 return(GetImageArtifact(image,
"magick-property"));
2861 (void) SetImageOption(image_info,
"magick-property",value);
2862 return(GetImageOption(image_info,
"magick-property"));
2865 return((
char *) NULL);
2868MagickExport
const char *GetMagickProperty(
ImageInfo *image_info,
2872 value[MagickPathExtent];
2877 assert(property != (
const char *) NULL);
2878 assert(property[0] !=
'\0');
2879 assert(image != (
Image *) NULL || image_info != (
ImageInfo *) NULL );
2880 if (property[1] ==
'\0')
2881 return(GetMagickPropertyLetter(image_info,image,*property,exception));
2882 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
2883 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2885 if ((image_info != (
ImageInfo *) NULL) &&
2886 (IsEventLogging() != MagickFalse))
2887 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no-images");
2889 string=(
char *) NULL;
2894 if (LocaleCompare(
"basename",property) == 0)
2896 WarnNoImageReturn(
"\"%%[%s]\"",property);
2897 GetPathComponent(image->magick_filename,BasePath,value);
2902 if (LocaleCompare(
"bit-depth",property) == 0)
2904 WarnNoImageReturn(
"\"%%[%s]\"",property);
2905 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2906 GetImageDepth(image,exception));
2909 if (LocaleCompare(
"bounding-box",property) == 0)
2914 WarnNoImageReturn(
"\"%%[%s]\"",property);
2915 geometry=GetImageBoundingBox(image,exception);
2916 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g",
2917 (
double) geometry.x,(double) geometry.y,
2918 (
double) geometry.x+geometry.width,
2919 (double) geometry.y+geometry.height);
2926 if (LocaleCompare(
"channels",property) == 0)
2928 WarnNoImageReturn(
"\"%%[%s]\"",property);
2929 (void) FormatLocaleString(value,MagickPathExtent,
"%s%s %g.%g",
2930 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2931 image->colorspace),image->alpha_trait != UndefinedPixelTrait ?
2932 "a" :
" ",(double) image->number_channels,(
double)
2933 image->number_meta_channels);
2937 if (LocaleCompare(
"colors",property) == 0)
2939 WarnNoImageReturn(
"\"%%[%s]\"",property);
2940 image->colors=GetNumberColors(image,(FILE *) NULL,exception);
2941 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
2945 if (LocaleCompare(
"colorspace",property) == 0)
2947 WarnNoImageReturn(
"\"%%[%s]\"",property);
2948 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2952 if (LocaleCompare(
"compose",property) == 0)
2954 WarnNoImageReturn(
"\"%%[%s]\"",property);
2955 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
2959 if (LocaleCompare(
"compression",property) == 0)
2961 WarnNoImageReturn(
"\"%%[%s]\"",property);
2962 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2963 image->compression);
2966 if (LocaleCompare(
"convex-hull",property) == 0)
2980 WarnNoImageReturn(
"\"%%[%s]\"",property);
2981 convex_hull=GetImageConvexHull(image,&number_points,exception);
2984 points=AcquireString(
"");
2985 for (n=0; n < (ssize_t) number_points; n++)
2987 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
2988 convex_hull[n].x,convex_hull[n].y);
2989 (void) ConcatenateString(&points,value);
2991 convex_hull=(
PointInfo *) RelinquishMagickMemory(convex_hull);
2992 (void) SetImageProperty(image,
"convex-hull",points,exception);
2993 points=DestroyString(points);
2994 string=GetImageProperty(image,
"convex-hull",exception);
2997 if (LocaleCompare(
"convex-hull:extreme-points",property) == 0)
3012 WarnNoImageReturn(
"\"%%[%s]\"",property);
3013 convex_hull=GetImageConvexHull(image,&number_points,exception);
3016 points=AcquireString(
"");
3017 extreme=convex_hull[0];
3018 for (n=0; n < (ssize_t) number_points; n++)
3020 if (convex_hull[n].y < extreme.y)
3022 extreme=convex_hull[n];
3025 if (convex_hull[n].y != extreme.y)
3027 if (convex_hull[n].x < extreme.x)
3028 extreme=convex_hull[n];
3030 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3031 extreme.x,extreme.y);
3032 (void) ConcatenateString(&points,value);
3033 extreme=convex_hull[0];
3034 for (n=0; n < (ssize_t) number_points; n++)
3036 if (convex_hull[n].x > extreme.x)
3038 extreme=convex_hull[n];
3041 if (convex_hull[n].x != extreme.x)
3043 if (convex_hull[n].y < extreme.y)
3044 extreme=convex_hull[n];
3046 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3047 extreme.x,extreme.y);
3048 (void) ConcatenateString(&points,value);
3049 extreme=convex_hull[0];
3050 for (n=0; n < (ssize_t) number_points; n++)
3052 if (convex_hull[n].y > extreme.y)
3054 extreme=convex_hull[n];
3057 if (convex_hull[n].y != extreme.y)
3059 if (convex_hull[n].x > extreme.x)
3060 extreme=convex_hull[n];
3062 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3063 extreme.x,extreme.y);
3064 (void) ConcatenateString(&points,value);
3065 extreme=convex_hull[0];
3066 for (n=0; n < (ssize_t) number_points; n++)
3068 if (convex_hull[n].x < extreme.x)
3070 extreme=convex_hull[n];
3073 if (convex_hull[n].x != extreme.x)
3075 if (convex_hull[n].y > extreme.y)
3076 extreme=convex_hull[n];
3078 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3079 extreme.x,extreme.y);
3080 (void) ConcatenateString(&points,value);
3081 convex_hull=(
PointInfo *) RelinquishMagickMemory(convex_hull);
3082 (void) SetImageProperty(image,
"convex-hull:extreme-points",points,
3084 points=DestroyString(points);
3085 string=GetImageProperty(image,
"convex-hull:extreme-points",exception);
3088 if (LocaleCompare(
"copyright",property) == 0)
3090 (void) CopyMagickString(value,GetMagickCopyright(),MagickPathExtent);
3097 if (LocaleCompare(
"depth",property) == 0)
3099 WarnNoImageReturn(
"\"%%[%s]\"",property);
3100 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3104 if (LocaleCompare(
"directory",property) == 0)
3106 WarnNoImageReturn(
"\"%%[%s]\"",property);
3107 GetPathComponent(image->magick_filename,HeadPath,value);
3116 if (LocaleCompare(
"entropy",property) == 0)
3121 WarnNoImageReturn(
"\"%%[%s]\"",property);
3122 (void) GetImageEntropy(image,&entropy,exception);
3123 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3124 GetMagickPrecision(),entropy);
3127 if (LocaleCompare(
"extension",property) == 0)
3129 WarnNoImageReturn(
"\"%%[%s]\"",property);
3130 GetPathComponent(image->magick_filename,ExtensionPath,value);
3139 if (LocaleCompare(
"gamma",property) == 0)
3141 WarnNoImageReturn(
"\"%%[%s]\"",property);
3142 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3143 GetMagickPrecision(),image->gamma);
3150 if (LocaleCompare(
"height",property) == 0)
3152 WarnNoImageReturn(
"\"%%[%s]\"",property);
3153 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",
3154 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3161 if (LocaleCompare(
"input",property) == 0)
3163 WarnNoImageReturn(
"\"%%[%s]\"",property);
3164 string=image->filename;
3167 if (LocaleCompare(
"interlace",property) == 0)
3169 WarnNoImageReturn(
"\"%%[%s]\"",property);
3170 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3178 if (LocaleCompare(
"kurtosis",property) == 0)
3184 WarnNoImageReturn(
"\"%%[%s]\"",property);
3185 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3186 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3187 GetMagickPrecision(),kurtosis);
3194 if (LocaleCompare(
"magick",property) == 0)
3196 WarnNoImageReturn(
"\"%%[%s]\"",property);
3197 string=image->magick;
3200 if ((LocaleCompare(
"maxima",property) == 0) ||
3201 (LocaleCompare(
"max",property) == 0))
3207 WarnNoImageReturn(
"\"%%[%s]\"",property);
3208 (void) GetImageRange(image,&minimum,&maximum,exception);
3209 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3210 GetMagickPrecision(),maximum);
3213 if (LocaleCompare(
"mean",property) == 0)
3219 WarnNoImageReturn(
"\"%%[%s]\"",property);
3220 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3221 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3222 GetMagickPrecision(),mean);
3225 if (LocaleCompare(
"median",property) == 0)
3230 WarnNoImageReturn(
"\"%%[%s]\"",property);
3231 (void) GetImageMedian(image,&median,exception);
3232 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3233 GetMagickPrecision(),median);
3236 if ((LocaleCompare(
"minima",property) == 0) ||
3237 (LocaleCompare(
"min",property) == 0))
3243 WarnNoImageReturn(
"\"%%[%s]\"",property);
3244 (void) GetImageRange(image,&minimum,&maximum,exception);
3245 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3246 GetMagickPrecision(),minimum);
3249 if (LocaleNCompare(
"minimum-bounding-box",property,20) == 0)
3263 WarnNoImageReturn(
"\"%%[%s]\"",property);
3264 bounding_box=GetImageMinimumBoundingBox(image,&number_points,
3268 points=AcquireString(
"");
3269 for (n=0; n < (ssize_t) number_points; n++)
3271 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g ",
3272 bounding_box[n].x,bounding_box[n].y);
3273 (void) ConcatenateString(&points,value);
3275 bounding_box=(
PointInfo *) RelinquishMagickMemory(bounding_box);
3276 (void) SetImageProperty(image,
"minimum-bounding-box",points,
3278 points=DestroyString(points);
3279 string=GetImageProperty(image,property,exception);
3286 if (LocaleCompare(
"opaque",property) == 0)
3288 WarnNoImageReturn(
"\"%%[%s]\"",property);
3289 string=CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t)
3290 IsImageOpaque(image,exception));
3293 if (LocaleCompare(
"orientation",property) == 0)
3295 WarnNoImageReturn(
"\"%%[%s]\"",property);
3296 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3297 image->orientation);
3300 if (LocaleCompare(
"output",property) == 0)
3302 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3303 (void) CopyMagickString(value,image_info->filename,MagickPathExtent);
3310 if (LocaleCompare(
"page",property) == 0)
3312 WarnNoImageReturn(
"\"%%[%s]\"",property);
3313 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3314 (
double) image->page.width,(double) image->page.height);
3317 if (LocaleNCompare(
"papersize:",property,10) == 0)
3322 WarnNoImageReturn(
"\"%%[%s]\"",property);
3324 papersize=GetPageGeometry(property+10);
3325 if (papersize != (
const char *) NULL)
3328 page = { 0, 0, 0, 0 };
3330 (void) ParseAbsoluteGeometry(papersize,&page);
3331 (void) FormatLocaleString(value,MagickPathExtent,
"%.20gx%.20g",
3332 (
double) page.width,(double) page.height);
3333 papersize=DestroyString(papersize);
3337#if defined(MAGICKCORE_LCMS_DELEGATE)
3338 if (LocaleCompare(
"profile:icc",property) == 0 ||
3339 LocaleCompare(
"profile:icm",property) == 0)
3341#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3342#define cmsUInt32Number DWORD
3351 WarnNoImageReturn(
"\"%%[%s]\"",property);
3352 profile=GetImageProfile(image,property+8);
3355 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3356 (cmsUInt32Number) GetStringInfoLength(profile));
3357 if (icc_profile != (cmsHPROFILE *) NULL)
3359#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3360 string=cmsTakeProductName(icc_profile);
3362 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3363 "en",
"US",value,MagickPathExtent);
3365 (void) cmsCloseProfile(icc_profile);
3369 if (LocaleCompare(
"printsize.x",property) == 0)
3371 WarnNoImageReturn(
"\"%%[%s]\"",property);
3372 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3373 GetMagickPrecision(),(double) PerceptibleReciprocal(
3374 image->resolution.x)*image->columns);
3377 if (LocaleCompare(
"printsize.y",property) == 0)
3379 WarnNoImageReturn(
"\"%%[%s]\"",property);
3380 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3381 GetMagickPrecision(),(double) PerceptibleReciprocal(
3382 image->resolution.y)*image->rows);
3385 if (LocaleCompare(
"profiles",property) == 0)
3390 WarnNoImageReturn(
"\"%%[%s]\"",property);
3391 ResetImageProfileIterator(image);
3392 name=GetNextImageProfile(image);
3393 if (name != (
char *) NULL)
3395 (void) CopyMagickString(value,name,MagickPathExtent);
3396 name=GetNextImageProfile(image);
3397 while (name != (
char *) NULL)
3399 ConcatenateMagickString(value,
",",MagickPathExtent);
3400 ConcatenateMagickString(value,name,MagickPathExtent);
3401 name=GetNextImageProfile(image);
3410 if (LocaleCompare(
"quality",property) == 0)
3412 WarnNoImageReturn(
"\"%%[%s]\"",property);
3413 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3421 if (LocaleCompare(
"resolution.x",property) == 0)
3423 WarnNoImageReturn(
"\"%%[%s]\"",property);
3424 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3425 image->resolution.x);
3428 if (LocaleCompare(
"resolution.y",property) == 0)
3430 WarnNoImageReturn(
"\"%%[%s]\"",property);
3431 (void) FormatLocaleString(value,MagickPathExtent,
"%g",
3432 image->resolution.y);
3439 if (LocaleCompare(
"scene",property) == 0)
3441 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3442 if (image_info->number_scenes != 0)
3443 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3446 WarnNoImageReturn(
"\"%%[%s]\"",property);
3447 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3452 if (LocaleCompare(
"scenes",property) == 0)
3455 WarnNoImageReturn(
"\"%%[%s]\"",property);
3456 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3457 GetImageListLength(image));
3460 if (LocaleCompare(
"size",property) == 0)
3462 WarnNoImageReturn(
"\"%%[%s]\"",property);
3463 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,
"B",
3464 MagickPathExtent,value);
3467 if (LocaleCompare(
"skewness",property) == 0)
3473 WarnNoImageReturn(
"\"%%[%s]\"",property);
3474 (void) GetImageKurtosis(image,&kurtosis,&skewness,exception);
3475 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3476 GetMagickPrecision(),skewness);
3479 if (LocaleCompare(
"standard-deviation",property) == 0)
3485 WarnNoImageReturn(
"\"%%[%s]\"",property);
3486 (void) GetImageMean(image,&mean,&standard_deviation,exception);
3487 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3488 GetMagickPrecision(),standard_deviation);
3495 if (LocaleCompare(
"type",property) == 0)
3497 WarnNoImageReturn(
"\"%%[%s]\"",property);
3498 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3499 IdentifyImageType(image,exception));
3506 if (LocaleCompare(
"unique",property) == 0)
3508 WarnNoImageInfoReturn(
"\"%%[%s]\"",property);
3509 string=image_info->unique;
3512 if (LocaleCompare(
"units",property) == 0)
3514 WarnNoImageReturn(
"\"%%[%s]\"",property);
3515 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3523 if (LocaleCompare(
"version",property) == 0)
3525 string=GetMagickVersion((
size_t *) NULL);
3532 if (LocaleCompare(
"width",property) == 0)
3534 WarnNoImageReturn(
"\"%%[%s]\"",property);
3535 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g",(
double)
3536 (image->magick_columns != 0 ? image->magick_columns : 256));
3542 if (
string != (
char *) NULL)
3549 if (image != (
Image *) NULL)
3551 (void) SetImageArtifact(image,
"magick-property",value);
3552 return(GetImageArtifact(image,
"magick-property"));
3556 (void) SetImageOption(image_info,
"magick-property",value);
3557 return(GetImageOption(image_info,
"magick-property"));
3560 return((
char *) NULL);
3562#undef WarnNoImageReturn
3586MagickExport
const char *GetNextImageProperty(
const Image *image)
3588 assert(image != (
Image *) NULL);
3589 assert(image->signature == MagickCoreSignature);
3590 if (IsEventLogging() != MagickFalse)
3591 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3593 if (image->properties == (
void *) NULL)
3594 return((
const char *) NULL);
3595 return((
const char *) GetNextKeyInSplayTree((
SplayTreeInfo *) image->properties));
3652MagickExport
char *InterpretImageProperties(
ImageInfo *image_info,
Image *image,
3655#define ExtendInterpretText(string_length) \
3657 size_t length=(string_length); \
3658 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3661 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3662 MagickPathExtent,sizeof(*interpret_text)); \
3663 if (interpret_text == (char *) NULL) \
3665 if (property_image != image) \
3666 property_image=DestroyImage(property_image); \
3667 if (property_info != image_info) \
3668 property_info=DestroyImageInfo(property_info); \
3669 return((char *) NULL); \
3671 q=interpret_text+strlen(interpret_text); \
3675#define AppendKeyValue2Text(key,value)\
3677 size_t length=strlen(key)+strlen(value)+2; \
3678 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3681 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3682 MagickPathExtent,sizeof(*interpret_text)); \
3683 if (interpret_text == (char *) NULL) \
3685 if (property_image != image) \
3686 property_image=DestroyImage(property_image); \
3687 if (property_info != image_info) \
3688 property_info=DestroyImageInfo(property_info); \
3689 return((char *) NULL); \
3691 q=interpret_text+strlen(interpret_text); \
3693 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3696#define AppendString2Text(string) \
3698 size_t length = strlen((string)); \
3699 if ((size_t) (q-interpret_text+(ssize_t) length+1) >= extent) \
3702 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3703 MagickPathExtent,sizeof(*interpret_text)); \
3704 if (interpret_text == (char *) NULL) \
3706 if (property_image != image) \
3707 property_image=DestroyImage(property_image); \
3708 if (property_info != image_info) \
3709 property_info=DestroyImageInfo(property_info); \
3710 return((char *) NULL); \
3712 q=interpret_text+strlen(interpret_text); \
3714 (void) CopyMagickString(q,(string),extent); \
3715 q+=(ptrdiff_t) length; \
3737 if ((image != (
Image *) NULL) && (IsEventLogging() != MagickFalse))
3738 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3740 if ((image_info != (
ImageInfo *) NULL) && (IsEventLogging() != MagickFalse))
3741 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3742 image_info->filename);
3744 if (IsEventLogging() != MagickFalse)
3745 (
void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
"no image");
3746 if (embed_text == (
const char *) NULL)
3747 return(ConstantString(
""));
3749 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3752 return(ConstantString(
""));
3753 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3758 interpret_text=FileToString(p,~0UL,exception);
3759 if (interpret_text != (
char *) NULL)
3760 return(interpret_text);
3766 property_info=image_info;
3768 property_info=CloneImageInfo(image_info);
3769 if ((image != (
Image *) NULL) && (image->columns != 0) && (image->rows != 0))
3770 property_image=image;
3773 property_image=AcquireImage(image_info,exception);
3774 (void) SetImageExtent(property_image,1,1,exception);
3775 (void) SetImageBackgroundColor(property_image,exception);
3777 interpret_text=AcquireString(embed_text);
3778 extent=MagickPathExtent;
3780 for (q=interpret_text; *p!=
'\0'; number=isdigit((
int) ((
unsigned char) *p)) ? MagickTrue : MagickFalse,p++)
3786 ExtendInterpretText(MagickPathExtent);
3829 if (LocaleNCompare(
"<",p,4) == 0)
3835 if (LocaleNCompare(
">",p,4) == 0)
3841 if (LocaleNCompare(
"&",p,5) == 0)
3862 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3877 if (number != MagickFalse)
3886 string=GetMagickPropertyLetter(property_info,image,*p,exception);
3887 if (
string != (
char *) NULL)
3889 AppendString2Text(
string);
3890 (void) DeleteImageArtifact(property_image,
"magick-property");
3891 (void) DeleteImageOption(property_info,
"magick-property");
3894 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3895 "UnknownImageProperty",
"\"%%%c\"",*p);
3900 pattern[2*MagickPathExtent] =
"\0";
3919 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
3920 "UnknownImageProperty",
"\"%%[]\"");
3923 for (len=0; len < (MagickPathExtent-1L) && (*p !=
'\0'); )
3925 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3930 pattern[len++]=(*p++);
3931 pattern[len++]=(*p++);
3940 pattern[len++]=(*p++);
3955 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
3956 "UnbalancedBraces",
"\"%%[%s\"",pattern);
3957 interpret_text=DestroyString(interpret_text);
3958 if (property_image != image)
3959 property_image=DestroyImage(property_image);
3960 if (property_info != image_info)
3961 property_info=DestroyImageInfo(property_info);
3962 return((
char *) NULL);
3967 if (LocaleNCompare(
"fx:",pattern,3) == 0)
3981 fx_info=AcquireFxInfo(property_image,pattern+3,exception);
3982 if (fx_info == (
FxInfo *) NULL)
3984 status=FxEvaluateChannelExpression(fx_info,CompositePixelChannel,0,0,
3986 fx_info=DestroyFxInfo(fx_info);
3987 if (status != MagickFalse)
3990 result[MagickPathExtent];
3992 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
3993 GetMagickPrecision(),(double) value);
3994 AppendString2Text(result);
3998 if (LocaleNCompare(
"hex:",pattern,4) == 0)
4015 GetPixelInfo(property_image,&pixel);
4016 fx_info=AcquireFxInfo(property_image,pattern+4,exception);
4017 if (fx_info == (
FxInfo *) NULL)
4019 status=FxEvaluateChannelExpression(fx_info,RedPixelChannel,0,0,
4021 pixel.red=(double) QuantumRange*value;
4022 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4023 GreenPixelChannel,0,0,&value,exception);
4024 pixel.green=(double) QuantumRange*value;
4025 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4026 BluePixelChannel,0,0,&value,exception);
4027 pixel.blue=(double) QuantumRange*value;
4028 if (property_image->colorspace == CMYKColorspace)
4030 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4031 BlackPixelChannel,0,0,&value,exception);
4032 pixel.black=(double) QuantumRange*value;
4034 status&=(MagickStatusType) FxEvaluateChannelExpression(fx_info,
4035 AlphaPixelChannel,0,0,&value,exception);
4036 pixel.alpha=(double) QuantumRange*value;
4037 fx_info=DestroyFxInfo(fx_info);
4038 if (status != MagickFalse)
4041 hex[MagickPathExtent];
4043 GetColorTuple(&pixel,MagickTrue,hex);
4044 AppendString2Text(hex+1);
4048 if (LocaleNCompare(
"pixel:",pattern,6) == 0)
4065 GetPixelInfo(property_image,&pixel);
4066 fx_info=AcquireFxInfo(property_image,pattern+6,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 name[MagickPathExtent];
4093 GetColorTuple(&pixel,MagickFalse,name);
4094 string=GetImageArtifact(property_image,
"pixel:compliance");
4095 if (
string != (
char *) NULL)
4097 ComplianceType compliance=(ComplianceType) ParseCommandOption(
4098 MagickComplianceOptions,MagickFalse,
string);
4099 (void) QueryColorname(property_image,&pixel,compliance,name,
4102 AppendString2Text(name);
4106 if (LocaleNCompare(
"option:",pattern,7) == 0)
4111 if (IsGlob(pattern+7) != MagickFalse)
4113 ResetImageOptionIterator(property_info);
4114 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4115 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4117 string=GetImageOption(property_info,key);
4118 if (
string != (
const char *) NULL)
4119 AppendKeyValue2Text(key,
string);
4124 string=GetImageOption(property_info,pattern+7);
4125 if (
string == (
char *) NULL)
4126 goto PropertyLookupFailure;
4127 AppendString2Text(
string);
4130 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4135 if (IsGlob(pattern+9) != MagickFalse)
4137 ResetImageArtifactIterator(property_image);
4138 while ((key=GetNextImageArtifact(property_image)) != (
const char *) NULL)
4139 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4141 string=GetImageArtifact(property_image,key);
4142 if (
string != (
const char *) NULL)
4143 AppendKeyValue2Text(key,
string);
4148 string=GetImageArtifact(property_image,pattern+9);
4149 if (
string == (
char *) NULL)
4150 goto PropertyLookupFailure;
4151 AppendString2Text(
string);
4154 if (LocaleNCompare(
"property:",pattern,9) == 0)
4159 if (IsGlob(pattern+9) != MagickFalse)
4161 ResetImagePropertyIterator(property_image);
4162 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4163 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4165 string=GetImageProperty(property_image,key,exception);
4166 if (
string != (
const char *) NULL)
4167 AppendKeyValue2Text(key,
string);
4172 string=GetImageProperty(property_image,pattern+9,exception);
4173 if (
string == (
char *) NULL)
4174 goto PropertyLookupFailure;
4175 AppendString2Text(
string);
4183 string=GetImageProperty(property_image,pattern,exception);
4184 if (
string != (
const char *) NULL)
4186 AppendString2Text(
string);
4187 (void) DeleteImageArtifact(property_image,
"magick-property");
4188 (void) DeleteImageOption(property_info,
"magick-property");
4191 if (IsGlob(pattern) != MagickFalse)
4197 ResetImagePropertyIterator(property_image);
4198 while ((key=GetNextImageProperty(property_image)) != (
const char *) NULL)
4199 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4201 string=GetImageProperty(property_image,key,exception);
4202 if (
string != (
const char *) NULL)
4203 AppendKeyValue2Text(key,
string);
4213 string=GetMagickProperty(property_info,property_image,pattern,exception);
4214 if (
string != (
const char *) NULL)
4216 AppendString2Text(
string);
4223 string=GetImageArtifact(property_image,pattern);
4224 if (
string != (
char *) NULL)
4226 AppendString2Text(
string);
4232 string=GetImageOption(property_info,pattern);
4233 if (
string != (
char *) NULL)
4235 AppendString2Text(
string);
4238PropertyLookupFailure:
4249 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4250 "UnknownImageProperty",
"\"%%[%s]\"",pattern);
4254 if (property_image != image)
4255 property_image=DestroyImage(property_image);
4256 if (property_info != image_info)
4257 property_info=DestroyImageInfo(property_info);
4258 return(interpret_text);
4289MagickExport
char *RemoveImageProperty(
Image *image,
const char *property)
4294 assert(image != (
Image *) NULL);
4295 assert(image->signature == MagickCoreSignature);
4296 if (IsEventLogging() != MagickFalse)
4297 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4298 if (image->properties == (
void *) NULL)
4299 return((
char *) NULL);
4300 value=(
char *) RemoveNodeFromSplayTree((
SplayTreeInfo *) image->properties,
4329MagickExport
void ResetImagePropertyIterator(
const Image *image)
4331 assert(image != (
Image *) NULL);
4332 assert(image->signature == MagickCoreSignature);
4333 if (IsEventLogging() != MagickFalse)
4334 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4335 if (image->properties == (
void *) NULL)
4337 ResetSplayTreeIterator((
SplayTreeInfo *) image->properties);
4373MagickExport MagickBooleanType SetImageProperty(
Image *image,
4374 const char *property,
const char *value,
ExceptionInfo *exception)
4385 assert(image != (
Image *) NULL);
4386 assert(image->signature == MagickCoreSignature);
4387 if (IsEventLogging() != MagickFalse)
4388 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
4389 if (image->properties == (
void *) NULL)
4390 image->properties=NewSplayTree(CompareSplayTreeString,
4391 RelinquishMagickMemory,RelinquishMagickMemory);
4392 if (value == (
const char *) NULL)
4393 return(DeleteImageProperty(image,property));
4394 if (strlen(property) <= 1)
4399 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4400 "SetReadOnlyProperty",
"`%s'",property);
4401 return(MagickFalse);
4403 property_length=strlen(property);
4404 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4405 (*(property+(property_length-1)) ==
'*'))
4407 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4408 "SetReadOnlyProperty",
"`%s'",property);
4409 return(MagickFalse);
4423 if (LocaleNCompare(
"8bim:",property,5) == 0)
4425 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
4426 "SetReadOnlyProperty",
"`%s'",property);
4427 return(MagickFalse);
4435 if (LocaleCompare(
"background",property) == 0)
4437 (void) QueryColorCompliance(value,AllCompliance,
4438 &image->background_color,exception);
4447 if (LocaleCompare(
"channels",property) == 0)
4449 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4450 "SetReadOnlyProperty",
"`%s'",property);
4451 return(MagickFalse);
4453 if (LocaleCompare(
"colorspace",property) == 0)
4458 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4461 return(MagickFalse);
4462 return(SetImageColorspace(image,(ColorspaceType) colorspace,exception));
4464 if (LocaleCompare(
"compose",property) == 0)
4469 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4471 return(MagickFalse);
4472 image->compose=(CompositeOperator) compose;
4475 if (LocaleCompare(
"compress",property) == 0)
4480 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4482 if (compression < 0)
4483 return(MagickFalse);
4484 image->compression=(CompressionType) compression;
4492 if (LocaleCompare(
"delay",property) == 0)
4497 flags=ParseGeometry(value,&geometry_info);
4498 if ((flags & GreaterValue) != 0)
4500 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4501 image->delay=(size_t) floor(geometry_info.rho+0.5);
4504 if ((flags & LessValue) != 0)
4506 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4507 image->delay=(
size_t) CastDoubleToLong(
4508 floor(geometry_info.sigma+0.5));
4511 image->delay=(size_t) floor(geometry_info.rho+0.5);
4512 if ((flags & SigmaValue) != 0)
4513 image->ticks_per_second=CastDoubleToLong(floor(
4514 geometry_info.sigma+0.5));
4517 if (LocaleCompare(
"delay_units",property) == 0)
4519 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4520 "SetReadOnlyProperty",
"`%s'",property);
4521 return(MagickFalse);
4523 if (LocaleCompare(
"density",property) == 0)
4528 flags=ParseGeometry(value,&geometry_info);
4529 if ((flags & RhoValue) != 0)
4530 image->resolution.x=geometry_info.rho;
4531 image->resolution.y=image->resolution.x;
4532 if ((flags & SigmaValue) != 0)
4533 image->resolution.y=geometry_info.sigma;
4536 if (LocaleCompare(
"depth",property) == 0)
4538 image->depth=StringToUnsignedLong(value);
4541 if (LocaleCompare(
"dispose",property) == 0)
4546 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4548 return(MagickFalse);
4549 image->dispose=(DisposeType) dispose;
4559 if (LocaleNCompare(
"exif:",property,5) == 0)
4561 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4562 "SetReadOnlyProperty",
"`%s'",property);
4563 return(MagickFalse);
4570 if (LocaleNCompare(
"fx:",property,3) == 0)
4572 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4573 "SetReadOnlyProperty",
"`%s'",property);
4574 return(MagickFalse);
4582 if (LocaleCompare(
"gamma",property) == 0)
4584 image->gamma=StringToDouble(value,(
char **) NULL);
4587 if (LocaleCompare(
"gravity",property) == 0)
4592 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4594 return(MagickFalse);
4595 image->gravity=(GravityType) gravity;
4603 if (LocaleCompare(
"height",property) == 0)
4605 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4606 "SetReadOnlyProperty",
"`%s'",property);
4607 return(MagickFalse);
4614 if (LocaleCompare(
"intensity",property) == 0)
4619 intensity=ParseCommandOption(MagickIntensityOptions,MagickFalse,
4622 return(MagickFalse);
4623 image->intensity=(PixelIntensityMethod) intensity;
4626 if (LocaleCompare(
"intent",property) == 0)
4631 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4633 if (rendering_intent < 0)
4634 return(MagickFalse);
4635 image->rendering_intent=(RenderingIntent) rendering_intent;
4638 if (LocaleCompare(
"interpolate",property) == 0)
4643 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4645 if (interpolate < 0)
4646 return(MagickFalse);
4647 image->interpolate=(PixelInterpolateMethod) interpolate;
4652 if (LocaleNCompare(
"iptc:",property,5) == 0)
4654 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4655 "SetReadOnlyProperty",
"`%s'",property);
4656 return(MagickFalse);
4663 if (LocaleCompare(
"kurtosis",property) == 0)
4665 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4666 "SetReadOnlyProperty",
"`%s'",property);
4667 return(MagickFalse);
4673 if (LocaleCompare(
"loop",property) == 0)
4675 image->iterations=StringToUnsignedLong(value);
4682 if ((LocaleCompare(
"magick",property) == 0) ||
4683 (LocaleCompare(
"max",property) == 0) ||
4684 (LocaleCompare(
"mean",property) == 0) ||
4685 (LocaleCompare(
"min",property) == 0) ||
4686 (LocaleCompare(
"min",property) == 0))
4688 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4689 "SetReadOnlyProperty",
"`%s'",property);
4690 return(MagickFalse);
4695 if (LocaleCompare(
"opaque",property) == 0)
4697 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4698 "SetReadOnlyProperty",
"`%s'",property);
4699 return(MagickFalse);
4705 if (LocaleCompare(
"page",property) == 0)
4710 geometry=GetPageGeometry(value);
4711 flags=ParseAbsoluteGeometry(geometry,&image->page);
4712 geometry=DestroyString(geometry);
4717 if (LocaleNCompare(
"pixel:",property,6) == 0)
4719 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4720 "SetReadOnlyProperty",
"`%s'",property);
4721 return(MagickFalse);
4729 if (LocaleCompare(
"rendering-intent",property) == 0)
4734 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4736 if (rendering_intent < 0)
4737 return(MagickFalse);
4738 image->rendering_intent=(RenderingIntent) rendering_intent;
4745 if ((LocaleCompare(
"size",property) == 0) ||
4746 (LocaleCompare(
"skewness",property) == 0) ||
4747 (LocaleCompare(
"scenes",property) == 0) ||
4748 (LocaleCompare(
"standard-deviation",property) == 0))
4750 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4751 "SetReadOnlyProperty",
"`%s'",property);
4752 return(MagickFalse);
4758 if (LocaleCompare(
"tile-offset",property) == 0)
4763 geometry=GetPageGeometry(value);
4764 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4765 geometry=DestroyString(geometry);
4768 if (LocaleCompare(
"type",property) == 0)
4773 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4775 return(MagickFalse);
4776 image->type=(ImageType) type;
4784 if (LocaleCompare(
"units",property) == 0)
4789 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4791 return(MagickFalse);
4792 image->units=(ResolutionType) units;
4800 if (LocaleCompare(
"version",property) == 0)
4802 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4803 "SetReadOnlyProperty",
"`%s'",property);
4804 return(MagickFalse);
4811 if (LocaleCompare(
"width",property) == 0)
4813 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4814 "SetReadOnlyProperty",
"`%s'",property);
4815 return(MagickFalse);
4824 if (LocaleNCompare(
"xmp:",property,4) == 0)
4826 (void) ThrowMagickException(exception,GetMagickModule(),OptionWarning,
4827 "SetReadOnlyProperty",
"`%s'",property);
4828 return(MagickFalse);
4835 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4836 ConstantString(property),ConstantString(value));