43 #include "magick/studio.h"
44 #include "magick/artifact.h"
45 #include "magick/attribute.h"
46 #include "magick/cache.h"
47 #include "magick/cache-private.h"
48 #include "magick/color.h"
49 #include "magick/colorspace-private.h"
50 #include "magick/compare.h"
51 #include "magick/constitute.h"
52 #include "magick/draw.h"
53 #include "magick/effect.h"
54 #include "magick/exception.h"
55 #include "magick/exception-private.h"
56 #include "magick/fx.h"
57 #include "magick/fx-private.h"
58 #include "magick/gem.h"
59 #include "magick/geometry.h"
60 #include "magick/histogram.h"
61 #include "magick/image.h"
62 #include "magick/image.h"
63 #include "magick/layer.h"
64 #include "magick/list.h"
65 #include "magick/magick.h"
66 #include "magick/memory_.h"
67 #include "magick/monitor.h"
68 #include "magick/montage.h"
69 #include "magick/option.h"
70 #include "magick/policy.h"
71 #include "magick/profile.h"
72 #include "magick/property.h"
73 #include "magick/quantum.h"
74 #include "magick/resource_.h"
75 #include "magick/splay-tree.h"
76 #include "magick/signature-private.h"
77 #include "magick/statistic.h"
78 #include "magick/string_.h"
79 #include "magick/string-private.h"
80 #include "magick/token.h"
81 #include "magick/token-private.h"
82 #include "magick/utility.h"
83 #include "magick/version.h"
84 #include "magick/xml-tree.h"
85 #if defined(MAGICKCORE_LCMS_DELEGATE)
86 #if defined(MAGICKCORE_HAVE_LCMS2_LCMS2_H)
87 #include <lcms2/lcms2.h>
88 #elif defined(MAGICKCORE_HAVE_LCMS2_H)
90 #elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
91 #include <lcms/lcms.h>
100 #if defined(MAGICKCORE_LCMS_DELEGATE)
101 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
102 #define cmsUInt32Number DWORD
133 *(*CloneKeyFunc)(
const char *),
134 *(*CloneValueFunc)(
const char *);
136 static inline void *ClonePropertyKey(
void *key)
138 return((
void *) ((CloneKeyFunc) ConstantString)((
const char *) key));
141 static inline void *ClonePropertyValue(
void *value)
143 return((
void *) ((CloneValueFunc) ConstantString)((
const char *) value));
146 MagickExport MagickBooleanType CloneImageProperties(
Image *image,
147 const Image *clone_image)
149 assert(image != (
Image *) NULL);
150 assert(image->signature == MagickCoreSignature);
151 assert(clone_image != (
const Image *) NULL);
152 assert(clone_image->signature == MagickCoreSignature);
153 if (IsEventLogging() != MagickFalse)
155 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
156 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
157 clone_image->filename);
159 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
160 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
162 image->compression=clone_image->compression;
163 image->quality=clone_image->quality;
164 image->depth=clone_image->depth;
165 image->background_color=clone_image->background_color;
166 image->border_color=clone_image->border_color;
167 image->matte_color=clone_image->matte_color;
168 image->transparent_color=clone_image->transparent_color;
169 image->gamma=clone_image->gamma;
170 image->chromaticity=clone_image->chromaticity;
171 image->rendering_intent=clone_image->rendering_intent;
172 image->black_point_compensation=clone_image->black_point_compensation;
173 image->units=clone_image->units;
174 image->montage=(
char *) NULL;
175 image->directory=(
char *) NULL;
176 (void) CloneString(&image->geometry,clone_image->geometry);
177 image->offset=clone_image->offset;
178 image->x_resolution=clone_image->x_resolution;
179 image->y_resolution=clone_image->y_resolution;
180 image->page=clone_image->page;
181 image->tile_offset=clone_image->tile_offset;
182 image->extract_info=clone_image->extract_info;
183 image->bias=clone_image->bias;
184 image->filter=clone_image->filter;
185 image->blur=clone_image->blur;
186 image->fuzz=clone_image->fuzz;
187 image->intensity=clone_image->intensity;
188 image->interlace=clone_image->interlace;
189 image->interpolate=clone_image->interpolate;
190 image->endian=clone_image->endian;
191 image->gravity=clone_image->gravity;
192 image->compose=clone_image->compose;
193 image->orientation=clone_image->orientation;
194 image->scene=clone_image->scene;
195 image->dispose=clone_image->dispose;
196 image->delay=clone_image->delay;
197 image->ticks_per_second=clone_image->ticks_per_second;
198 image->iterations=clone_image->iterations;
199 image->total_colors=clone_image->total_colors;
200 image->taint=clone_image->taint;
201 image->progress_monitor=clone_image->progress_monitor;
202 image->client_data=clone_image->client_data;
203 image->start_loop=clone_image->start_loop;
204 image->error=clone_image->error;
205 image->signature=clone_image->signature;
206 if (clone_image->properties != (
void *) NULL)
208 if (image->properties != (
void *) NULL)
209 DestroyImageProperties(image);
211 clone_image->properties,ClonePropertyKey,ClonePropertyValue);
243 MagickExport MagickBooleanType DefineImageProperty(
Image *image,
244 const char *property)
248 value[MaxTextExtent];
253 assert(image != (
Image *) NULL);
254 assert(property != (
const char *) NULL);
255 (void) CopyMagickString(key,property,MaxTextExtent-1);
256 for (p=key; *p !=
'\0'; p++)
261 (void) CopyMagickString(value,p+1,MaxTextExtent);
263 return(SetImageProperty(image,key,value));
290 MagickExport MagickBooleanType DeleteImageProperty(
Image *image,
291 const char *property)
293 assert(image != (
Image *) NULL);
294 assert(image->signature == MagickCoreSignature);
295 if (IsEventLogging() != MagickFalse)
296 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
297 if (image->properties == (
void *) NULL)
299 return(DeleteNodeFromSplayTree((
SplayTreeInfo *) image->properties,property));
325 MagickExport
void DestroyImageProperties(
Image *image)
327 assert(image != (
Image *) NULL);
328 assert(image->signature == MagickCoreSignature);
329 if (IsEventLogging() != MagickFalse)
330 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
331 if (image->properties != (
void *) NULL)
332 image->properties=(
void *) DestroySplayTree((
SplayTreeInfo *)
365 MagickExport MagickBooleanType FormatImageProperty(
Image *image,
366 const char *property,
const char *format,...)
369 value[MaxTextExtent];
377 va_start(operands,format);
378 n=FormatLocaleStringList(value,MaxTextExtent,format,operands);
381 return(SetImageProperty(image,property,value));
417 *TracePSClippath(
const unsigned char *,
size_t,
const size_t,
419 *TraceSVGClippath(
const unsigned char *,
size_t,
const size_t,
422 static MagickBooleanType GetIPTCProperty(
const Image *image,
const char *key)
438 profile=GetImageProfile(image,
"iptc");
440 profile=GetImageProfile(image,
"8bim");
443 count=sscanf(key,
"IPTC:%ld:%ld",&dataset,&record);
446 attribute=(
char *) NULL;
447 for (i=0; i < (ssize_t) GetStringInfoLength(profile)-5; )
449 const unsigned char *p = GetStringInfoDatum(profile)+i;
459 if (((
long) p[1] == dataset) && ((
long) p[2] == record))
462 *message = (
char *) NULL;
464 size_t declared = ((size_t) p[3] << 8) | (size_t) p[4];
465 size_t remaining = GetStringInfoLength(profile)-(i+5);
466 size_t length = MagickMin(declared,remaining);
468 message=(
char *) AcquireQuantumMemory(length+1UL,
sizeof(*message));
469 if (message != (
char *) NULL)
474 (void) memcpy(message,p+5,length);
475 message[length]=
'\0';
476 (void) ConcatenateString(&attribute,message);
477 (void) ConcatenateString(&attribute,
";");
478 message=DestroyString(message);
484 i+=(((size_t) p[3] << 8) | (size_t) p[4])+5;
486 if ((attribute == (
char *) NULL) || (*attribute ==
';'))
488 if (attribute != (
char *) NULL)
489 attribute=DestroyString(attribute);
492 attribute[strlen(attribute)-1]=
'\0';
493 (void) SetImageProperty((
Image *) image,key,(
const char *) attribute);
494 attribute=DestroyString(attribute);
498 static inline int ReadPropertyByte(
const unsigned char **p,
size_t *length)
510 static inline signed int ReadPropertyMSBLong(
const unsigned char **p,
536 for (i=0; i < 4; i++)
540 buffer[i]=(
unsigned char) c;
542 value=(
unsigned int) buffer[0] << 24;
543 value|=(
unsigned int) buffer[1] << 16;
544 value|=(
unsigned int) buffer[2] << 8;
545 value|=(
unsigned int) buffer[3];
546 quantum.unsigned_value=value & 0xffffffff;
547 return(quantum.signed_value);
550 static inline signed short ReadPropertyMSBShort(
const unsigned char **p,
575 return((
unsigned short) ~0);
576 for (i=0; i < 2; i++)
580 buffer[i]=(
unsigned char) c;
582 value=(
unsigned short) buffer[0] << 8;
583 value|=(
unsigned short) buffer[1];
584 quantum.unsigned_value=value & 0xffff;
585 return(quantum.signed_value);
588 static MagickBooleanType Get8BIMProperty(
const Image *image,
const char *key)
592 format[MaxTextExtent],
593 *macroman_resource = (
char *) NULL,
595 *resource = (
char *) NULL;
624 profile=GetImageProfile(image,
"8bim");
627 count=(ssize_t) sscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
629 if ((count != 2) && (count != 3) && (count != 4))
632 (void) CopyMagickString(format,
"SVG",MaxTextExtent);
637 sub_number=(ssize_t) StringToLong(&name[1]);
638 sub_number=MagickMax(sub_number,1L);
640 length=GetStringInfoLength(profile);
641 info=GetStringInfoDatum(profile);
642 while ((length > 0) && (status == MagickFalse))
644 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'8')
646 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'B')
648 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'I')
650 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'M')
652 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
653 if (
id < (ssize_t) start)
655 if (
id > (ssize_t) stop)
657 if (macroman_resource != (
char *) NULL)
658 macroman_resource=DestroyString(macroman_resource);
659 if (resource != (
char *) NULL)
660 resource=DestroyString(resource);
661 count=(ssize_t) ReadPropertyByte(&info,&length);
662 if ((count != 0) && ((size_t) count <= length))
664 if (~((
size_t) count) >= (MaxTextExtent-1))
665 resource=(
char *) AcquireQuantumMemory((
size_t) count+MaxTextExtent,
667 if (resource != (
char *) NULL)
669 for (i=0; i < (ssize_t) count; i++)
670 resource[i]=(
char) ReadPropertyByte(&info,&length);
671 resource[count]=
'\0';
674 if ((count & 0x01) == 0)
675 (void) ReadPropertyByte(&info,&length);
676 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
677 if ((count < 0) || ((size_t) count > length))
682 if (resource != (
char *) NULL)
683 macroman_resource=(
char *) ConvertMacRomanToUTF8((
unsigned char *)
685 if ((*name !=
'\0') && (*name !=
'#'))
686 if ((resource == (
char *) NULL) || (macroman_resource == (
char *) NULL) ||
687 ((LocaleCompare(name,resource) != 0) &&
688 (LocaleCompare(name,macroman_resource) != 0)))
694 length-=MagickMin(count,(ssize_t) length);
697 if ((*name ==
'#') && (sub_number != 1))
704 length-=MagickMin(count,(ssize_t) length);
710 attribute=(
char *) NULL;
711 if (~((
size_t) count) >= (MaxTextExtent-1))
712 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MaxTextExtent,
714 if (attribute != (
char *) NULL)
716 (void) memcpy(attribute,(
char *) info,(size_t) count);
717 attribute[count]=
'\0';
719 length-=MagickMin(count,(ssize_t) length);
720 if ((
id <= 1999) || (
id >= 2999))
721 (void) SetImageProperty((
Image *) image,key,(
const char *) attribute);
727 if (LocaleCompare(format,
"svg") == 0)
728 path=TraceSVGClippath((
unsigned char *) attribute,(size_t) count,
729 image->columns,image->rows);
731 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count,
732 image->columns,image->rows);
733 (void) SetImageProperty((
Image *) image,key,(
const char *) path);
734 path=DestroyString(path);
736 attribute=DestroyString(attribute);
740 if (macroman_resource != (
char *) NULL)
741 macroman_resource=DestroyString(macroman_resource);
742 if (resource != (
char *) NULL)
743 resource=DestroyString(resource);
747 static inline signed int ReadPropertySignedLong(
const EndianType endian,
748 const unsigned char *buffer)
762 if (endian == LSBEndian)
764 value=(
unsigned int) buffer[3] << 24;
765 value|=(
unsigned int) buffer[2] << 16;
766 value|=(
unsigned int) buffer[1] << 8;
767 value|=(
unsigned int) buffer[0];
768 quantum.unsigned_value=value & 0xffffffff;
769 return(quantum.signed_value);
771 value=(
unsigned int) buffer[0] << 24;
772 value|=(
unsigned int) buffer[1] << 16;
773 value|=(
unsigned int) buffer[2] << 8;
774 value|=(
unsigned int) buffer[3];
775 quantum.unsigned_value=value & 0xffffffff;
776 return(quantum.signed_value);
779 static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
780 const unsigned char *buffer)
785 if (endian == LSBEndian)
787 value=(
unsigned int) buffer[3] << 24;
788 value|=(
unsigned int) buffer[2] << 16;
789 value|=(
unsigned int) buffer[1] << 8;
790 value|=(
unsigned int) buffer[0];
791 return(value & 0xffffffff);
793 value=(
unsigned int) buffer[0] << 24;
794 value|=(
unsigned int) buffer[1] << 16;
795 value|=(
unsigned int) buffer[2] << 8;
796 value|=(
unsigned int) buffer[3];
797 return(value & 0xffffffff);
800 static inline signed short ReadPropertySignedShort(
const EndianType endian,
801 const unsigned char *buffer)
815 if (endian == LSBEndian)
817 value=(
unsigned short) buffer[1] << 8;
818 value|=(
unsigned short) buffer[0];
819 quantum.unsigned_value=value & 0xffff;
820 return(quantum.signed_value);
822 value=(
unsigned short) buffer[0] << 8;
823 value|=(
unsigned short) buffer[1];
824 quantum.unsigned_value=value & 0xffff;
825 return(quantum.signed_value);
828 static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
829 const unsigned char *buffer)
834 if (endian == LSBEndian)
836 value=(
unsigned short) buffer[1] << 8;
837 value|=(
unsigned short) buffer[0];
838 return(value & 0xffff);
840 value=(
unsigned short) buffer[0] << 8;
841 value|=(
unsigned short) buffer[1];
842 return(value & 0xffff);
845 static MagickBooleanType GetEXIFProperty(
const Image *image,
846 const char *property)
848 #define MaxDirectoryStack 16
849 #define EXIF_DELIMITER "\n"
850 #define EXIF_NUM_FORMATS 12
851 #define EXIF_FMT_BYTE 1
852 #define EXIF_FMT_STRING 2
853 #define EXIF_FMT_USHORT 3
854 #define EXIF_FMT_ULONG 4
855 #define EXIF_FMT_URATIONAL 5
856 #define EXIF_FMT_SBYTE 6
857 #define EXIF_FMT_UNDEFINED 7
858 #define EXIF_FMT_SSHORT 8
859 #define EXIF_FMT_SLONG 9
860 #define EXIF_FMT_SRATIONAL 10
861 #define EXIF_FMT_SINGLE 11
862 #define EXIF_FMT_DOUBLE 12
863 #define GPS_LATITUDE 0x10002
864 #define GPS_LONGITUDE 0x10004
865 #define GPS_TIMESTAMP 0x10007
866 #define TAG_EXIF_OFFSET 0x8769
867 #define TAG_GPS_OFFSET 0x8825
868 #define TAG_INTEROP_OFFSET 0xa005
871 #define EXIFGPSFractions(format,arg1,arg2,arg3,arg4,arg5,arg6) \
879 for ( ; component < components; component++) \
881 if (component != 0) \
882 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
884 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
885 extent,format,(arg1),(arg2),(arg3),(arg4),(arg5),(arg6)); \
886 if (extent >= (MagickPathExtent-1)) \
887 extent=MagickPathExtent-1; \
889 buffer[extent]='\0'; \
890 value=AcquireString(buffer); \
893 #define EXIFMultipleValues(format,arg) \
901 for ( ; component < components; component++) \
903 if (component != 0) \
904 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
906 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
907 extent,format,arg); \
908 if (extent >= (MagickPathExtent-1)) \
909 extent=MagickPathExtent-1; \
911 buffer[extent]='\0'; \
912 value=AcquireString(buffer); \
915 #define EXIFMultipleFractions(format,arg1,arg2) \
923 for ( ; component < components; component++) \
925 if (component != 0) \
926 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent-\
928 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
929 extent,format,(arg1),(arg2)); \
930 if (extent >= (MagickPathExtent-1)) \
931 extent=MagickPathExtent-1; \
933 buffer[extent]='\0'; \
934 value=AcquireString(buffer); \
937 typedef struct _DirectoryInfo
949 typedef struct _TagInfo
961 { 0x001,
"exif:InteroperabilityIndex" },
962 { 0x002,
"exif:InteroperabilityVersion" },
963 { 0x100,
"exif:ImageWidth" },
964 { 0x101,
"exif:ImageLength" },
965 { 0x102,
"exif:BitsPerSample" },
966 { 0x103,
"exif:Compression" },
967 { 0x106,
"exif:PhotometricInterpretation" },
968 { 0x10a,
"exif:FillOrder" },
969 { 0x10d,
"exif:DocumentName" },
970 { 0x10e,
"exif:ImageDescription" },
971 { 0x10f,
"exif:Make" },
972 { 0x110,
"exif:Model" },
973 { 0x111,
"exif:StripOffsets" },
974 { 0x112,
"exif:Orientation" },
975 { 0x115,
"exif:SamplesPerPixel" },
976 { 0x116,
"exif:RowsPerStrip" },
977 { 0x117,
"exif:StripByteCounts" },
978 { 0x11a,
"exif:XResolution" },
979 { 0x11b,
"exif:YResolution" },
980 { 0x11c,
"exif:PlanarConfiguration" },
981 { 0x11d,
"exif:PageName" },
982 { 0x11e,
"exif:XPosition" },
983 { 0x11f,
"exif:YPosition" },
984 { 0x118,
"exif:MinSampleValue" },
985 { 0x119,
"exif:MaxSampleValue" },
986 { 0x120,
"exif:FreeOffsets" },
987 { 0x121,
"exif:FreeByteCounts" },
988 { 0x122,
"exif:GrayResponseUnit" },
989 { 0x123,
"exif:GrayResponseCurve" },
990 { 0x124,
"exif:T4Options" },
991 { 0x125,
"exif:T6Options" },
992 { 0x128,
"exif:ResolutionUnit" },
993 { 0x12d,
"exif:TransferFunction" },
994 { 0x131,
"exif:Software" },
995 { 0x132,
"exif:DateTime" },
996 { 0x13b,
"exif:Artist" },
997 { 0x13e,
"exif:WhitePoint" },
998 { 0x13f,
"exif:PrimaryChromaticities" },
999 { 0x140,
"exif:ColorMap" },
1000 { 0x141,
"exif:HalfToneHints" },
1001 { 0x142,
"exif:TileWidth" },
1002 { 0x143,
"exif:TileLength" },
1003 { 0x144,
"exif:TileOffsets" },
1004 { 0x145,
"exif:TileByteCounts" },
1005 { 0x14a,
"exif:SubIFD" },
1006 { 0x14c,
"exif:InkSet" },
1007 { 0x14d,
"exif:InkNames" },
1008 { 0x14e,
"exif:NumberOfInks" },
1009 { 0x150,
"exif:DotRange" },
1010 { 0x151,
"exif:TargetPrinter" },
1011 { 0x152,
"exif:ExtraSample" },
1012 { 0x153,
"exif:SampleFormat" },
1013 { 0x154,
"exif:SMinSampleValue" },
1014 { 0x155,
"exif:SMaxSampleValue" },
1015 { 0x156,
"exif:TransferRange" },
1016 { 0x157,
"exif:ClipPath" },
1017 { 0x158,
"exif:XClipPathUnits" },
1018 { 0x159,
"exif:YClipPathUnits" },
1019 { 0x15a,
"exif:Indexed" },
1020 { 0x15b,
"exif:JPEGTables" },
1021 { 0x15f,
"exif:OPIProxy" },
1022 { 0x200,
"exif:JPEGProc" },
1023 { 0x201,
"exif:JPEGInterchangeFormat" },
1024 { 0x202,
"exif:JPEGInterchangeFormatLength" },
1025 { 0x203,
"exif:JPEGRestartInterval" },
1026 { 0x205,
"exif:JPEGLosslessPredictors" },
1027 { 0x206,
"exif:JPEGPointTransforms" },
1028 { 0x207,
"exif:JPEGQTables" },
1029 { 0x208,
"exif:JPEGDCTables" },
1030 { 0x209,
"exif:JPEGACTables" },
1031 { 0x211,
"exif:YCbCrCoefficients" },
1032 { 0x212,
"exif:YCbCrSubSampling" },
1033 { 0x213,
"exif:YCbCrPositioning" },
1034 { 0x214,
"exif:ReferenceBlackWhite" },
1035 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1036 { 0x301,
"exif:Gamma" },
1037 { 0x302,
"exif:ICCProfileDescriptor" },
1038 { 0x303,
"exif:SRGBRenderingIntent" },
1039 { 0x320,
"exif:ImageTitle" },
1040 { 0x5001,
"exif:ResolutionXUnit" },
1041 { 0x5002,
"exif:ResolutionYUnit" },
1042 { 0x5003,
"exif:ResolutionXLengthUnit" },
1043 { 0x5004,
"exif:ResolutionYLengthUnit" },
1044 { 0x5005,
"exif:PrintFlags" },
1045 { 0x5006,
"exif:PrintFlagsVersion" },
1046 { 0x5007,
"exif:PrintFlagsCrop" },
1047 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1048 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1049 { 0x500A,
"exif:HalftoneLPI" },
1050 { 0x500B,
"exif:HalftoneLPIUnit" },
1051 { 0x500C,
"exif:HalftoneDegree" },
1052 { 0x500D,
"exif:HalftoneShape" },
1053 { 0x500E,
"exif:HalftoneMisc" },
1054 { 0x500F,
"exif:HalftoneScreen" },
1055 { 0x5010,
"exif:JPEGQuality" },
1056 { 0x5011,
"exif:GridSize" },
1057 { 0x5012,
"exif:ThumbnailFormat" },
1058 { 0x5013,
"exif:ThumbnailWidth" },
1059 { 0x5014,
"exif:ThumbnailHeight" },
1060 { 0x5015,
"exif:ThumbnailColorDepth" },
1061 { 0x5016,
"exif:ThumbnailPlanes" },
1062 { 0x5017,
"exif:ThumbnailRawBytes" },
1063 { 0x5018,
"exif:ThumbnailSize" },
1064 { 0x5019,
"exif:ThumbnailCompressedSize" },
1065 { 0x501a,
"exif:ColorTransferFunction" },
1066 { 0x501b,
"exif:ThumbnailData" },
1067 { 0x5020,
"exif:ThumbnailImageWidth" },
1068 { 0x5021,
"exif:ThumbnailImageHeight" },
1069 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1070 { 0x5023,
"exif:ThumbnailCompression" },
1071 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1072 { 0x5025,
"exif:ThumbnailImageDescription" },
1073 { 0x5026,
"exif:ThumbnailEquipMake" },
1074 { 0x5027,
"exif:ThumbnailEquipModel" },
1075 { 0x5028,
"exif:ThumbnailStripOffsets" },
1076 { 0x5029,
"exif:ThumbnailOrientation" },
1077 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1078 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1079 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1080 { 0x502d,
"exif:ThumbnailResolutionX" },
1081 { 0x502e,
"exif:ThumbnailResolutionY" },
1082 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1083 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1084 { 0x5031,
"exif:ThumbnailTransferFunction" },
1085 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1086 { 0x5033,
"exif:ThumbnailDateTime" },
1087 { 0x5034,
"exif:ThumbnailArtist" },
1088 { 0x5035,
"exif:ThumbnailWhitePoint" },
1089 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1090 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1091 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1092 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1093 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1094 { 0x503B,
"exif:ThumbnailCopyRight" },
1095 { 0x5090,
"exif:LuminanceTable" },
1096 { 0x5091,
"exif:ChrominanceTable" },
1097 { 0x5100,
"exif:FrameDelay" },
1098 { 0x5101,
"exif:LoopCount" },
1099 { 0x5110,
"exif:PixelUnit" },
1100 { 0x5111,
"exif:PixelPerUnitX" },
1101 { 0x5112,
"exif:PixelPerUnitY" },
1102 { 0x5113,
"exif:PaletteHistogram" },
1103 { 0x1000,
"exif:RelatedImageFileFormat" },
1104 { 0x1001,
"exif:RelatedImageLength" },
1105 { 0x1002,
"exif:RelatedImageWidth" },
1106 { 0x800d,
"exif:ImageID" },
1107 { 0x80e3,
"exif:Matteing" },
1108 { 0x80e4,
"exif:DataType" },
1109 { 0x80e5,
"exif:ImageDepth" },
1110 { 0x80e6,
"exif:TileDepth" },
1111 { 0x828d,
"exif:CFARepeatPatternDim" },
1112 { 0x828e,
"exif:CFAPattern2" },
1113 { 0x828f,
"exif:BatteryLevel" },
1114 { 0x8298,
"exif:Copyright" },
1115 { 0x829a,
"exif:ExposureTime" },
1116 { 0x829d,
"exif:FNumber" },
1117 { 0x83bb,
"exif:IPTC/NAA" },
1118 { 0x84e3,
"exif:IT8RasterPadding" },
1119 { 0x84e5,
"exif:IT8ColorTable" },
1120 { 0x8649,
"exif:ImageResourceInformation" },
1121 { 0x8769,
"exif:ExifOffset" },
1122 { 0x8773,
"exif:InterColorProfile" },
1123 { 0x8822,
"exif:ExposureProgram" },
1124 { 0x8824,
"exif:SpectralSensitivity" },
1125 { 0x8825,
"exif:GPSInfo" },
1126 { 0x8827,
"exif:PhotographicSensitivity" },
1127 { 0x8828,
"exif:OECF" },
1128 { 0x8829,
"exif:Interlace" },
1129 { 0x882a,
"exif:TimeZoneOffset" },
1130 { 0x882b,
"exif:SelfTimerMode" },
1131 { 0x8830,
"exif:SensitivityType" },
1132 { 0x8831,
"exif:StandardOutputSensitivity" },
1133 { 0x8832,
"exif:RecommendedExposureIndex" },
1134 { 0x8833,
"exif:ISOSpeed" },
1135 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1136 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1137 { 0x9000,
"exif:ExifVersion" },
1138 { 0x9003,
"exif:DateTimeOriginal" },
1139 { 0x9004,
"exif:DateTimeDigitized" },
1140 { 0x9010,
"exif:OffsetTime" },
1141 { 0x9011,
"exif:OffsetTimeOriginal" },
1142 { 0x9012,
"exif:OffsetTimeDigitized" },
1143 { 0x9101,
"exif:ComponentsConfiguration" },
1144 { 0x9102,
"exif:CompressedBitsPerPixel" },
1145 { 0x9201,
"exif:ShutterSpeedValue" },
1146 { 0x9202,
"exif:ApertureValue" },
1147 { 0x9203,
"exif:BrightnessValue" },
1148 { 0x9204,
"exif:ExposureBiasValue" },
1149 { 0x9205,
"exif:MaxApertureValue" },
1150 { 0x9206,
"exif:SubjectDistance" },
1151 { 0x9207,
"exif:MeteringMode" },
1152 { 0x9208,
"exif:LightSource" },
1153 { 0x9209,
"exif:Flash" },
1154 { 0x920a,
"exif:FocalLength" },
1155 { 0x920b,
"exif:FlashEnergy" },
1156 { 0x920c,
"exif:SpatialFrequencyResponse" },
1157 { 0x920d,
"exif:Noise" },
1158 { 0x9214,
"exif:SubjectArea" },
1159 { 0x9290,
"exif:SubSecTime" },
1160 { 0x9291,
"exif:SubSecTimeOriginal" },
1161 { 0x9292,
"exif:SubSecTimeDigitized" },
1162 { 0x9211,
"exif:ImageNumber" },
1163 { 0x9212,
"exif:SecurityClassification" },
1164 { 0x9213,
"exif:ImageHistory" },
1165 { 0x9214,
"exif:SubjectArea" },
1166 { 0x9215,
"exif:ExposureIndex" },
1167 { 0x9216,
"exif:TIFF-EPStandardID" },
1168 { 0x927c,
"exif:MakerNote" },
1169 { 0x9286,
"exif:UserComment" },
1170 { 0x9290,
"exif:SubSecTime" },
1171 { 0x9291,
"exif:SubSecTimeOriginal" },
1172 { 0x9292,
"exif:SubSecTimeDigitized" },
1173 { 0x9400,
"exif:Temperature" },
1174 { 0x9401,
"exif:Humidity" },
1175 { 0x9402,
"exif:Pressure" },
1176 { 0x9403,
"exif:WaterDepth" },
1177 { 0x9404,
"exif:Acceleration" },
1178 { 0x9405,
"exif:CameraElevationAngle" },
1179 { 0x9C9b,
"exif:WinXP-Title" },
1180 { 0x9C9c,
"exif:WinXP-Comments" },
1181 { 0x9C9d,
"exif:WinXP-Author" },
1182 { 0x9C9e,
"exif:WinXP-Keywords" },
1183 { 0x9C9f,
"exif:WinXP-Subject" },
1184 { 0xa000,
"exif:FlashPixVersion" },
1185 { 0xa001,
"exif:ColorSpace" },
1186 { 0xa002,
"exif:PixelXDimension" },
1187 { 0xa003,
"exif:PixelYDimension" },
1188 { 0xa004,
"exif:RelatedSoundFile" },
1189 { 0xa005,
"exif:InteroperabilityOffset" },
1190 { 0xa20b,
"exif:FlashEnergy" },
1191 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1192 { 0xa20d,
"exif:Noise" },
1193 { 0xa20e,
"exif:FocalPlaneXResolution" },
1194 { 0xa20f,
"exif:FocalPlaneYResolution" },
1195 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1196 { 0xa214,
"exif:SubjectLocation" },
1197 { 0xa215,
"exif:ExposureIndex" },
1198 { 0xa216,
"exif:TIFF/EPStandardID" },
1199 { 0xa217,
"exif:SensingMethod" },
1200 { 0xa300,
"exif:FileSource" },
1201 { 0xa301,
"exif:SceneType" },
1202 { 0xa302,
"exif:CFAPattern" },
1203 { 0xa401,
"exif:CustomRendered" },
1204 { 0xa402,
"exif:ExposureMode" },
1205 { 0xa403,
"exif:WhiteBalance" },
1206 { 0xa404,
"exif:DigitalZoomRatio" },
1207 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1208 { 0xa406,
"exif:SceneCaptureType" },
1209 { 0xa407,
"exif:GainControl" },
1210 { 0xa408,
"exif:Contrast" },
1211 { 0xa409,
"exif:Saturation" },
1212 { 0xa40a,
"exif:Sharpness" },
1213 { 0xa40b,
"exif:DeviceSettingDescription" },
1214 { 0xa40c,
"exif:SubjectDistanceRange" },
1215 { 0xa420,
"exif:ImageUniqueID" },
1216 { 0xa430,
"exif:CameraOwnerName" },
1217 { 0xa431,
"exif:BodySerialNumber" },
1218 { 0xa432,
"exif:LensSpecification" },
1219 { 0xa433,
"exif:LensMake" },
1220 { 0xa434,
"exif:LensModel" },
1221 { 0xa435,
"exif:LensSerialNumber" },
1222 { 0xc4a5,
"exif:PrintImageMatching" },
1223 { 0xa500,
"exif:Gamma" },
1224 { 0xc640,
"exif:CR2Slice" },
1225 { 0x10000,
"exif:GPSVersionID" },
1226 { 0x10001,
"exif:GPSLatitudeRef" },
1227 { 0x10002,
"exif:GPSLatitude" },
1228 { 0x10003,
"exif:GPSLongitudeRef" },
1229 { 0x10004,
"exif:GPSLongitude" },
1230 { 0x10005,
"exif:GPSAltitudeRef" },
1231 { 0x10006,
"exif:GPSAltitude" },
1232 { 0x10007,
"exif:GPSTimeStamp" },
1233 { 0x10008,
"exif:GPSSatellites" },
1234 { 0x10009,
"exif:GPSStatus" },
1235 { 0x1000a,
"exif:GPSMeasureMode" },
1236 { 0x1000b,
"exif:GPSDop" },
1237 { 0x1000c,
"exif:GPSSpeedRef" },
1238 { 0x1000d,
"exif:GPSSpeed" },
1239 { 0x1000e,
"exif:GPSTrackRef" },
1240 { 0x1000f,
"exif:GPSTrack" },
1241 { 0x10010,
"exif:GPSImgDirectionRef" },
1242 { 0x10011,
"exif:GPSImgDirection" },
1243 { 0x10012,
"exif:GPSMapDatum" },
1244 { 0x10013,
"exif:GPSDestLatitudeRef" },
1245 { 0x10014,
"exif:GPSDestLatitude" },
1246 { 0x10015,
"exif:GPSDestLongitudeRef" },
1247 { 0x10016,
"exif:GPSDestLongitude" },
1248 { 0x10017,
"exif:GPSDestBearingRef" },
1249 { 0x10018,
"exif:GPSDestBearing" },
1250 { 0x10019,
"exif:GPSDestDistanceRef" },
1251 { 0x1001a,
"exif:GPSDestDistance" },
1252 { 0x1001b,
"exif:GPSProcessingMethod" },
1253 { 0x1001c,
"exif:GPSAreaInformation" },
1254 { 0x1001d,
"exif:GPSDateStamp" },
1255 { 0x1001e,
"exif:GPSDifferential" },
1256 { 0x1001f,
"exif:GPSHPositioningError" },
1268 directory_stack[MaxDirectoryStack] = { { 0, 0, 0 } };
1297 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1302 profile=GetImageProfile(image,
"exif");
1304 return(MagickFalse);
1305 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1306 return(MagickFalse);
1307 while (isspace((
int) ((
unsigned char) *property)) != 0)
1309 if (strlen(property) <= 5)
1310 return(MagickFalse);
1313 switch (*(property+5))
1342 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1346 return(MagickFalse);
1353 for (i=(ssize_t) n-1L; i >= 0; i--)
1357 if ((c >=
'0') && (c <=
'9'))
1360 if ((c >=
'A') && (c <=
'F'))
1363 if ((c >=
'a') && (c <=
'f'))
1366 return(MagickFalse);
1368 }
while (*property !=
'\0');
1378 if (EXIFTag[i].tag == 0)
1380 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1382 tag=(size_t) EXIFTag[i].tag;
1390 return(MagickFalse);
1391 length=GetStringInfoLength(profile);
1393 return(MagickFalse);
1394 exif=GetStringInfoDatum(profile);
1397 if (ReadPropertyByte(&exif,&length) != 0x45)
1399 if (ReadPropertyByte(&exif,&length) != 0x78)
1401 if (ReadPropertyByte(&exif,&length) != 0x69)
1403 if (ReadPropertyByte(&exif,&length) != 0x66)
1405 if (ReadPropertyByte(&exif,&length) != 0x00)
1407 if (ReadPropertyByte(&exif,&length) != 0x00)
1412 return(MagickFalse);
1413 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1421 return(MagickFalse);
1422 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1423 return(MagickFalse);
1427 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1428 if ((offset < 0) || (size_t) offset >= length)
1429 return(MagickFalse);
1434 directory=exif+offset;
1438 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1439 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1448 directory=directory_stack[level].directory;
1449 entry=directory_stack[level].entry;
1450 tag_offset=directory_stack[level].offset;
1452 if ((directory < exif) || (directory > (exif+length-2)))
1457 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1458 for ( ; entry < number_entries; entry++)
1471 q=(
unsigned char *) (directory+(12*entry)+2);
1472 if (q > (exif+length-12))
1474 if (GetValueFromSplayTree(exif_resources,q) == q)
1476 (void) AddValueToSplayTree(exif_resources,q,q);
1477 tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;
1478 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1479 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1483 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1486 number_bytes=(size_t) components*tag_bytes[format];
1487 if (number_bytes < components)
1489 if (number_bytes <= 4)
1499 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1500 if ((dir_offset < 0) || (size_t) dir_offset >= length)
1502 if (((
size_t) dir_offset+number_bytes) < (
size_t) dir_offset)
1504 if (((
size_t) dir_offset+number_bytes) > length)
1506 p=(
unsigned char *) (exif+dir_offset);
1508 if ((all != 0) || (tag == (size_t) tag_value))
1511 buffer[6*
sizeof(double)+MaxTextExtent],
1514 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1516 value=(
char *) NULL;
1522 value=(
char *) NULL;
1523 if (~((
size_t) number_bytes) >= 1)
1524 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1526 if (value != (
char *) NULL)
1528 for (i=0; i < (ssize_t) number_bytes; i++)
1531 if (isprint((
int) p[i]) != 0)
1532 value[i]=(char) p[i];
1538 case EXIF_FMT_SBYTE:
1540 EXIFMultipleValues(
"%.20g",(
double) (*(
signed char *) p));
1543 case EXIF_FMT_SSHORT:
1545 EXIFMultipleValues(
"%hd",ReadPropertySignedShort(endian,p));
1548 case EXIF_FMT_USHORT:
1550 EXIFMultipleValues(
"%hu",ReadPropertyUnsignedShort(endian,p));
1553 case EXIF_FMT_ULONG:
1555 EXIFMultipleValues(
"%.20g",(
double)
1556 ReadPropertyUnsignedLong(endian,p));
1559 case EXIF_FMT_SLONG:
1561 EXIFMultipleValues(
"%.20g",(
double)
1562 ReadPropertySignedLong(endian,p));
1565 case EXIF_FMT_URATIONAL:
1567 if ((tag_value == GPS_LATITUDE) || (tag_value == GPS_LONGITUDE) ||
1568 (tag_value == GPS_TIMESTAMP))
1570 if (number_bytes < 24)
1573 EXIFGPSFractions(
"%.20g/%.20g,%.20g/%.20g,%.20g/%.20g",
1574 (
double) ReadPropertyUnsignedLong(endian,p),
1575 (
double) ReadPropertyUnsignedLong(endian,p+4),
1576 (
double) ReadPropertyUnsignedLong(endian,p+8),
1577 (
double) ReadPropertyUnsignedLong(endian,p+12),
1578 (
double) ReadPropertyUnsignedLong(endian,p+16),
1579 (
double) ReadPropertyUnsignedLong(endian,p+20));
1582 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1583 ReadPropertyUnsignedLong(endian,p),(
double)
1584 ReadPropertyUnsignedLong(endian,p+4));
1587 case EXIF_FMT_SRATIONAL:
1589 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1590 ReadPropertySignedLong(endian,p),(
double)
1591 ReadPropertySignedLong(endian,p+4));
1594 case EXIF_FMT_SINGLE:
1596 EXIFMultipleValues(
"%.20g",(
double)
1597 ReadPropertySignedLong(endian,p));
1600 case EXIF_FMT_DOUBLE:
1602 EXIFMultipleValues(
"%.20g",(
double)
1603 ReadPropertySignedLong(endian,p));
1606 case EXIF_FMT_STRING:
1607 case EXIF_FMT_UNDEFINED:
1610 if ((p < exif) || (p > (exif+length-number_bytes)))
1612 value=(
char *) NULL;
1613 if (~((
size_t) number_bytes) >= 1)
1614 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1616 if (value != (
char *) NULL)
1621 for (i=0; i < (ssize_t) number_bytes; i++)
1624 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1625 value[i]=(char) p[i];
1632 if (value != (
char *) NULL)
1640 key=AcquireString(property);
1651 description=
"unknown";
1654 if (EXIFTag[i].tag == 0)
1656 if (EXIFTag[i].tag == tag_value)
1658 description=EXIFTag[i].description;
1662 (void) FormatLocaleString(key,MaxTextExtent,
"%s",
1665 (void) SubstituteString(&key,
"exif:",
"exif:Thumbnail.");
1670 if (tag_value < 0x10000)
1671 (void) FormatLocaleString(key,MaxTextExtent,
"#%04lx",
1672 (
unsigned long) tag_value);
1674 if (tag_value < 0x20000)
1675 (void) FormatLocaleString(key,MaxTextExtent,
"@%04lx",
1676 (
unsigned long) (tag_value & 0xffff));
1678 (
void) FormatLocaleString(key,MaxTextExtent,
"unknown");
1684 (void) SubstituteString(&key,
"exif:",
"exif:Thumbnail.");
1687 p=(
const char *) NULL;
1688 if (image->properties != (
void *) NULL)
1690 image->properties,key);
1691 if (p == (
const char *) NULL)
1692 (void) SetImageProperty((
Image *) image,key,value);
1693 value=DestroyString(value);
1694 key=DestroyString(key);
1698 if ((tag_value == TAG_EXIF_OFFSET) ||
1699 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1704 offset=(ssize_t) ReadPropertySignedLong(endian,p);
1705 if (((
size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1710 tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1712 directory_stack[level].directory=directory;
1714 directory_stack[level].entry=entry;
1715 directory_stack[level].offset=tag_offset;
1720 for (i=0; i < level; i++)
1721 if (directory_stack[i].directory == (exif+tag_offset1))
1725 directory_stack[level].directory=exif+offset;
1726 directory_stack[level].offset=tag_offset1;
1727 directory_stack[level].entry=0;
1729 if ((directory+2+(12*number_entries)+4) > (exif+length))
1731 offset=(ssize_t) ReadPropertySignedLong(endian,directory+2+(12*
1733 if ((offset != 0) && ((size_t) offset < length) &&
1734 (level < (MaxDirectoryStack-2)))
1736 directory_stack[level].directory=exif+offset;
1737 directory_stack[level].entry=0;
1738 directory_stack[level].offset=tag_offset1;
1745 }
while (level > 0);
1746 exif_resources=DestroySplayTree(exif_resources);
1750 static MagickBooleanType GetICCProperty(
const Image *image)
1758 profile=GetImageProfile(image,
"icc");
1760 profile=GetImageProfile(image,
"icm");
1762 return(MagickFalse);
1763 if (GetStringInfoLength(profile) < 128)
1764 return(MagickFalse);
1765 #if defined(MAGICKCORE_LCMS_DELEGATE)
1770 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1771 (cmsUInt32Number) GetStringInfoLength(profile));
1772 if (icc_profile != (cmsHPROFILE *) NULL)
1774 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1778 name=cmsTakeProductName(icc_profile);
1779 if (name != (
const char *) NULL)
1780 (void) SetImageProperty((
Image *) image,
"icc:name",name);
1788 info=AcquireStringInfo(0);
1789 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1793 SetStringInfoLength(info,extent+1);
1794 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1795 "US",(
char *) GetStringInfoDatum(info),extent);
1797 (void) SetImageProperty((
Image *) image,
"icc:description",
1798 (
char *) GetStringInfoDatum(info));
1800 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1804 SetStringInfoLength(info,extent+1);
1805 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1806 "US",(
char *) GetStringInfoDatum(info),extent);
1808 (void) SetImageProperty((
Image *) image,
"icc:manufacturer",
1809 (
char *) GetStringInfoDatum(info));
1811 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1815 SetStringInfoLength(info,extent+1);
1816 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1817 (
char *) GetStringInfoDatum(info),extent);
1819 (void) SetImageProperty((
Image *) image,
"icc:model",
1820 (
char *) GetStringInfoDatum(info));
1822 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1826 SetStringInfoLength(info,extent+1);
1827 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1828 "US",(
char *) GetStringInfoDatum(info),extent);
1830 (void) SetImageProperty((
Image *) image,
"icc:copyright",
1831 (
char *) GetStringInfoDatum(info));
1833 info=DestroyStringInfo(info);
1835 (void) cmsCloseProfile(icc_profile);
1842 static MagickBooleanType SkipXMPValue(
const char *value)
1844 if (value == (
const char*) NULL)
1846 while (*value !=
'\0')
1848 if (isspace((
int) ((
unsigned char) *value)) == 0)
1849 return(MagickFalse);
1855 static MagickBooleanType GetXMPProperty(
const Image *image,
const char *property)
1882 profile=GetImageProfile(image,
"xmp");
1884 return(MagickFalse);
1885 if (GetStringInfoLength(profile) < 17)
1886 return(MagickFalse);
1887 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1888 return(MagickFalse);
1889 xmp_profile=StringInfoToString(profile);
1890 if (xmp_profile == (
char *) NULL)
1891 return(MagickFalse);
1892 for (p=xmp_profile; *p !=
'\0'; p++)
1893 if ((*p ==
'<') && (*(p+1) ==
'x'))
1895 exception=AcquireExceptionInfo();
1896 xmp=NewXMLTree((
char *) p,exception);
1897 xmp_profile=DestroyString(xmp_profile);
1898 exception=DestroyExceptionInfo(exception);
1900 return(MagickFalse);
1902 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1905 if (image->properties == (
void *) NULL)
1906 ((
Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1907 RelinquishMagickMemory,RelinquishMagickMemory);
1908 description=GetXMLTreeChild(rdf,
"rdf:Description");
1911 node=GetXMLTreeChild(description,(
const char *) NULL);
1918 xmp_namespace_length;
1920 child=GetXMLTreeChild(node,(
const char *) NULL);
1921 content=GetXMLTreeContent(node);
1923 (SkipXMPValue(content) == MagickFalse))
1925 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1926 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1927 xmp_namespace_length=strlen(xmp_namespace);
1928 if ((xmp_namespace_length <= 2) ||
1929 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1930 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1931 (void) AddValueToSplayTree((
SplayTreeInfo *) image->properties,
1932 ConstantString(xmp_namespace),ConstantString(content));
1933 xmp_namespace=DestroyString(xmp_namespace);
1937 content=GetXMLTreeContent(child);
1938 if (SkipXMPValue(content) == MagickFalse)
1940 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1941 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1942 xmp_namespace_length=strlen(xmp_namespace);
1943 if ((xmp_namespace_length <= 2) ||
1944 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1945 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1947 image->properties,ConstantString(xmp_namespace),
1948 ConstantString(content));
1949 xmp_namespace=DestroyString(xmp_namespace);
1951 child=GetXMLTreeSibling(child);
1953 node=GetXMLTreeSibling(node);
1955 description=GetNextXMLTreeTag(description);
1958 xmp=DestroyXMLTree(xmp);
1962 static char *TracePSClippath(
const unsigned char *blob,
size_t length,
1963 const size_t magick_unused(columns),
const size_t magick_unused(rows))
1986 magick_unreferenced(columns);
1987 magick_unreferenced(rows);
1989 path=AcquireString((
char *) NULL);
1990 if (path == (
char *) NULL)
1991 return((
char *) NULL);
1992 message=AcquireString((
char *) NULL);
1993 (void) FormatLocaleString(message,MaxTextExtent,
"/ClipImage\n");
1994 (void) ConcatenateString(&path,message);
1995 (void) FormatLocaleString(message,MaxTextExtent,
"{\n");
1996 (void) ConcatenateString(&path,message);
1997 (void) FormatLocaleString(message,MaxTextExtent,
" /c {curveto} bind def\n");
1998 (void) ConcatenateString(&path,message);
1999 (void) FormatLocaleString(message,MaxTextExtent,
" /l {lineto} bind def\n");
2000 (void) ConcatenateString(&path,message);
2001 (void) FormatLocaleString(message,MaxTextExtent,
" /m {moveto} bind def\n");
2002 (void) ConcatenateString(&path,message);
2003 (void) FormatLocaleString(message,MaxTextExtent,
2004 " /v {currentpoint 6 2 roll curveto} bind def\n");
2005 (void) ConcatenateString(&path,message);
2006 (void) FormatLocaleString(message,MaxTextExtent,
2007 " /y {2 copy curveto} bind def\n");
2008 (void) ConcatenateString(&path,message);
2009 (void) FormatLocaleString(message,MaxTextExtent,
2010 " /z {closepath} bind def\n");
2011 (void) ConcatenateString(&path,message);
2012 (void) FormatLocaleString(message,MaxTextExtent,
" newpath\n");
2013 (void) ConcatenateString(&path,message);
2018 (void) memset(point,0,
sizeof(point));
2019 (void) memset(first,0,
sizeof(first));
2020 (void) memset(last,0,
sizeof(last));
2022 in_subpath=MagickFalse;
2025 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2031 if (knot_count != 0)
2034 length-=MagickMin(24,(ssize_t) length);
2040 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2042 length-=MagickMin(22,(ssize_t) length);
2050 if (knot_count == 0)
2056 length-=MagickMin(24,(ssize_t) length);
2062 for (i=0; i < 3; i++)
2064 y=(size_t) ReadPropertyMSBLong(&blob,&length);
2065 x=(size_t) ReadPropertyMSBLong(&blob,&length);
2066 point[i].x=(double) x/4096.0/4096.0;
2067 point[i].y=1.0-(double) y/4096.0/4096.0;
2069 if (in_subpath == MagickFalse)
2071 (void) FormatLocaleString(message,MaxTextExtent,
" %g %g m\n",
2072 point[1].x,point[1].y);
2073 for (i=0; i < 3; i++)
2085 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2086 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2087 (void) FormatLocaleString(message,MaxTextExtent,
2088 " %g %g l\n",point[1].x,point[1].y);
2090 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2091 (void) FormatLocaleString(message,MaxTextExtent,
2092 " %g %g %g %g v\n",point[0].x,point[0].y,
2093 point[1].x,point[1].y);
2095 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2096 (void) FormatLocaleString(message,MaxTextExtent,
2097 " %g %g %g %g y\n",last[2].x,last[2].y,
2098 point[1].x,point[1].y);
2100 (
void) FormatLocaleString(message,MaxTextExtent,
2101 " %g %g %g %g %g %g c\n",last[2].x,
2102 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2103 for (i=0; i < 3; i++)
2106 (void) ConcatenateString(&path,message);
2107 in_subpath=MagickTrue;
2112 if (knot_count == 0)
2118 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2119 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2120 (void) FormatLocaleString(message,MaxTextExtent,
2121 " %g %g l z\n",first[1].x,first[1].y);
2123 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2124 (void) FormatLocaleString(message,MaxTextExtent,
2125 " %g %g %g %g v z\n",first[0].x,first[0].y,
2126 first[1].x,first[1].y);
2128 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2129 (void) FormatLocaleString(message,MaxTextExtent,
2130 " %g %g %g %g y z\n",last[2].x,last[2].y,
2131 first[1].x,first[1].y);
2133 (
void) FormatLocaleString(message,MaxTextExtent,
2134 " %g %g %g %g %g %g c z\n",last[2].x,
2135 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2136 (void) ConcatenateString(&path,message);
2137 in_subpath=MagickFalse;
2147 length-=MagickMin(24,(ssize_t) length);
2155 (void) FormatLocaleString(message,MaxTextExtent,
" eoclip\n");
2156 (void) ConcatenateString(&path,message);
2157 (void) FormatLocaleString(message,MaxTextExtent,
"} bind def");
2158 (void) ConcatenateString(&path,message);
2159 message=DestroyString(message);
2163 static inline void TraceBezierCurve(
char *message,
PointInfo *last,
2170 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2171 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2172 (void) FormatLocaleString(message,MagickPathExtent,
2173 "L %g %g\n",point[1].x,point[1].y);
2175 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2176 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2179 static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2180 const size_t columns,
const size_t rows)
2203 path=AcquireString((
char *) NULL);
2204 if (path == (
char *) NULL)
2205 return((
char *) NULL);
2206 message=AcquireString((
char *) NULL);
2207 (void) FormatLocaleString(message,MaxTextExtent,(
2208 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2209 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2210 " width=\"%.20g\" height=\"%.20g\">\n"
2212 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2213 "stroke-width:0;shape-rendering:crispEdges\" d=\"\n"),(double) columns,
2215 (void) ConcatenateString(&path,message);
2216 (void) memset(point,0,
sizeof(point));
2217 (void) memset(first,0,
sizeof(first));
2218 (void) memset(last,0,
sizeof(last));
2220 in_subpath=MagickFalse;
2223 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2229 if (knot_count != 0)
2232 length-=MagickMin(24,(ssize_t) length);
2238 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2240 length-=MagickMin(22,(ssize_t) length);
2248 if (knot_count == 0)
2254 length-=MagickMin(24,(ssize_t) length);
2260 for (i=0; i < 3; i++)
2262 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2263 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2264 point[i].x=(double) x*columns/4096.0/4096.0;
2265 point[i].y=(double) y*rows/4096.0/4096.0;
2267 if (in_subpath == MagickFalse)
2269 (void) FormatLocaleString(message,MaxTextExtent,
"M %g %g\n",
2270 point[1].x,point[1].y);
2271 for (i=0; i < 3; i++)
2279 TraceBezierCurve(message,last,point);
2280 for (i=0; i < 3; i++)
2283 (void) ConcatenateString(&path,message);
2284 in_subpath=MagickTrue;
2289 if (knot_count == 0)
2291 TraceBezierCurve(message,last,first);
2292 (void) ConcatenateString(&path,message);
2293 in_subpath=MagickFalse;
2303 length-=MagickMin(24,(ssize_t) length);
2311 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2312 message=DestroyString(message);
2316 MagickExport
const char *GetImageProperty(
const Image *image,
2317 const char *property)
2334 assert(image != (
Image *) NULL);
2335 assert(image->signature == MagickCoreSignature);
2336 if (IsEventLogging() != MagickFalse)
2337 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2338 p=(
const char *) NULL;
2339 if (image->properties != (
void *) NULL)
2341 if (property == (
const char *) NULL)
2343 ResetSplayTreeIterator((
SplayTreeInfo *) image->properties);
2348 if (LocaleNCompare(
"fx:",property,3) != 0)
2351 image->properties,property);
2352 if (p != (
const char *) NULL)
2356 if ((property == (
const char *) NULL) ||
2357 (strchr(property,
':') == (
char *) NULL))
2359 exception=(&((
Image *) image)->exception);
2364 if (LocaleNCompare(
"8bim:",property,5) == 0)
2366 (void) Get8BIMProperty(image,property);
2374 if (LocaleNCompare(
"exif:",property,5) == 0)
2376 (void) GetEXIFProperty(image,property);
2384 if (LocaleNCompare(
"fx:",property,3) == 0)
2386 if ((image->columns == 0) || (image->rows == 0))
2388 fx_info=AcquireFxInfo(image,property+3);
2389 status=FxEvaluateChannelExpression(fx_info,DefaultChannels,0,0,&alpha,
2391 fx_info=DestroyFxInfo(fx_info);
2392 if (status != MagickFalse)
2395 value[MaxTextExtent];
2397 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
2398 GetMagickPrecision(),(double) alpha);
2399 (void) SetImageProperty((
Image *) image,property,value);
2408 if (LocaleNCompare(
"hex:",property,4) == 0)
2413 if ((image->columns == 0) || (image->rows == 0))
2415 GetMagickPixelPacket(image,&pixel);
2416 fx_info=AcquireFxInfo(image,property+4);
2417 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2419 pixel.red=(MagickRealType) QuantumRange*alpha;
2420 status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2422 pixel.green=(MagickRealType) QuantumRange*alpha;
2423 status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2425 pixel.blue=(MagickRealType) QuantumRange*alpha;
2426 status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2428 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2429 if (image->colorspace == CMYKColorspace)
2431 status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2433 pixel.index=(MagickRealType) QuantumRange*alpha;
2435 fx_info=DestroyFxInfo(fx_info);
2436 if (status != MagickFalse)
2441 GetColorTuple(&pixel,MagickTrue,hex);
2442 (void) SetImageProperty((
Image *) image,property,hex+1);
2451 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2452 (LocaleNCompare(
"icm:",property,4) == 0))
2454 (void) GetICCProperty(image);
2457 if (LocaleNCompare(
"iptc:",property,5) == 0)
2459 (void) GetIPTCProperty(image,property);
2467 if (LocaleNCompare(
"pixel:",property,6) == 0)
2472 GetMagickPixelPacket(image,&pixel);
2473 fx_info=AcquireFxInfo(image,property+6);
2474 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2476 pixel.red=(MagickRealType) QuantumRange*alpha;
2477 status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2479 pixel.green=(MagickRealType) QuantumRange*alpha;
2480 status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2482 pixel.blue=(MagickRealType) QuantumRange*alpha;
2483 status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2485 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2486 if (image->colorspace == CMYKColorspace)
2488 status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2490 pixel.index=(MagickRealType) QuantumRange*alpha;
2492 fx_info=DestroyFxInfo(fx_info);
2493 if (status != MagickFalse)
2496 name[MaxTextExtent];
2501 GetColorTuple(&pixel,MagickFalse,name);
2502 value=GetImageArtifact(image,
"pixel:compliance");
2503 if (value != (
char *) NULL)
2505 ComplianceType compliance=(ComplianceType) ParseCommandOption(
2506 MagickComplianceOptions,MagickFalse,value);
2507 (void) QueryMagickColorname(image,&pixel,compliance,name,
2510 (void) SetImageProperty((
Image *) image,property,name);
2519 if (LocaleNCompare(
"xmp:",property,4) == 0)
2521 (void) GetXMPProperty(image,property);
2529 if (image->properties != (
void *) NULL)
2532 image->properties,property);
2535 return((
const char *) NULL);
2624 static const char *GetMagickPropertyLetter(
const ImageInfo *image_info,
2625 Image *image,
const char letter)
2627 #define WarnNoImageInfoReturn(format,arg) \
2628 if (image_info == (ImageInfo *) NULL ) { \
2629 (void) ThrowMagickException(&image->exception,GetMagickModule(), \
2630 OptionWarning,"NoImageInfoForProperty",format,arg); \
2631 return((const char *) NULL); \
2635 value[MaxTextExtent];
2640 assert(image != (
Image *) NULL);
2641 assert(image->signature == MagickCoreSignature);
2642 if (IsEventLogging() != MagickFalse)
2643 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2645 string=(
char *) NULL;
2653 (void) FormatMagickSize(image->extent,MagickFalse,value);
2654 if (image->extent == 0)
2655 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,value);
2663 string=GetImageProperty(image,
"comment");
2664 if (
string == (
const char *) NULL)
2673 GetPathComponent(image->magick_filename,HeadPath,value);
2683 GetPathComponent(image->magick_filename,ExtensionPath,value);
2693 GetPathComponent(image->magick_filename,TailPath,value);
2703 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g%+.20g%+.20g",
2704 (
double) image->page.width,(double) image->page.height,
2705 (
double) image->page.x,(double) image->page.y);
2713 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2714 (image->rows != 0 ? image->rows : image->magick_rows));
2722 string=image->filename;
2730 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2731 GetNumberColors(image,(FILE *) NULL,&image->exception));
2739 string=GetImageProperty(image,
"label");
2740 if (
string == (
const char *) NULL)
2749 string=image->magick;
2757 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2758 GetImageListLength(image));
2766 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2767 string=image_info->filename;
2775 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2776 GetImageIndexInList(image));
2784 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2785 MAGICKCORE_QUANTUM_DEPTH);
2796 colorspace=image->colorspace;
2797 if ((image->columns != 0) && (image->rows != 0) &&
2798 (SetImageGray(image,&image->exception) != MagickFalse))
2799 colorspace=GRAYColorspace;
2800 (void) FormatLocaleString(value,MaxTextExtent,
"%s %s %s",
2801 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2802 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2803 (ssize_t) colorspace),image->matte != MagickFalse ?
"Matte" :
"" );
2811 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2812 if (image_info->number_scenes != 0)
2813 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2816 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2825 GetPathComponent(image->magick_filename,BasePath,value);
2835 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2836 string=image_info->unique;
2844 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2845 (image->columns != 0 ? image->columns : image->magick_columns));
2853 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
2854 fabs(image->x_resolution) > MagickEpsilon ? image->x_resolution :
2855 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2864 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
2865 fabs(image->y_resolution) > MagickEpsilon ? image->y_resolution :
2866 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2875 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2884 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2885 CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->matte));
2893 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2895 if (image->extent == 0)
2896 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2897 GetBlobSize(image));
2905 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2906 CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2907 image->compression));
2915 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2916 CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t) image->dispose));
2929 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
2930 "$-_.+!*'(),{}|\\^~[]`\"><#%;/?:@&=";
2935 (void) CopyMagickString(value,image->magick_filename,MaxTextExtent);
2937 q=value+strlen(value);
2938 for (p+=strspn(p,allowlist); p != q; p+=(ptrdiff_t) strspn(p,allowlist))
2947 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
2948 image->magick_columns,(double) image->magick_rows);
2956 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2957 image->page.height);
2965 string=image->magick_filename;
2970 if ((image != (
Image *) NULL) && (image->next == (
Image *) NULL))
2971 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2972 GetImageListLength(image));
2982 (void) FormatLocaleString(value,MaxTextExtent,
"%+ld%+ld",(
long)
2983 image->page.x,(long) image->page.y);
2991 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
2992 image->page.width,(double) image->page.height);
3000 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3001 (image->quality == 0 ? 92 : image->quality));
3009 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
3010 if (image_info->number_scenes == 0)
3011 string=
"2147483647";
3013 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3014 image_info->scene+image_info->number_scenes);
3022 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3031 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
3032 CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3041 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3050 (void) FormatLocaleString(value,MaxTextExtent,
"%+.20g",(
double)
3059 (void) FormatLocaleString(value,MaxTextExtent,
"%+.20g",(
double)
3068 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
3069 string=image_info->zero;
3080 page=GetImageBoundingBox(image,&image->exception);
3081 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g%+.20g%+.20g",
3082 (
double) page.width,(double) page.height,(
double) page.x,(double)
3091 if ((image->columns != 0) && (image->rows != 0))
3092 (void) SignatureImage(image);
3093 string=GetImageProperty(image,
"signature");
3107 if (
string != (
char *) NULL)
3109 (void) SetImageArtifact(image,
"get-property",
string);
3110 return(GetImageArtifact(image,
"get-property"));
3112 return((
char *) NULL);
3115 MagickExport
const char *GetMagickProperty(
const ImageInfo *image_info,
3116 Image *image,
const char *property)
3119 value[MaxTextExtent];
3124 assert(property != (
const char *) NULL);
3125 assert(property[0] !=
'\0');
3126 if (property[1] ==
'\0')
3127 return(GetMagickPropertyLetter(image_info,image,*property));
3129 string=(
char *) NULL;
3134 if ((LocaleCompare(
"base",property) == 0) ||
3135 (LocaleCompare(
"basename",property) == 0) )
3137 GetPathComponent(image->magick_filename,BasePath,value);
3140 if (LocaleCompare(
"bit-depth",property) == 0)
3142 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3143 GetImageDepth(image,&image->exception));
3146 if (LocaleCompare(
"bounding-box",property) == 0)
3151 geometry=GetImageBoundingBox(image,&image->exception);
3152 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g\n",
3153 (
double) geometry.x,(double) geometry.y,
3154 (
double) geometry.x+geometry.width,
3155 (double) geometry.y+geometry.height);
3162 if (LocaleCompare(
"channels",property) == 0)
3167 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
3168 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
3169 image->colorspace));
3171 if (image->matte != MagickFalse)
3172 (void) ConcatenateMagickString(value,
"a",MaxTextExtent);
3175 if (LocaleCompare(
"colors",property) == 0)
3177 image->colors=GetNumberColors(image,(FILE *) NULL,&image->exception);
3178 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3182 if (LocaleCompare(
"colorspace",property) == 0)
3184 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
3188 if (LocaleCompare(
"compose",property) == 0)
3190 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
3194 if (LocaleCompare(
"compression",property) == 0)
3196 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
3197 image->compression);
3200 if (LocaleCompare(
"copyright",property) == 0)
3202 (void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
3209 if (LocaleCompare(
"depth",property) == 0)
3211 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3215 if (LocaleCompare(
"directory",property) == 0)
3217 GetPathComponent(image->magick_filename,HeadPath,value);
3224 if (LocaleCompare(
"entropy",property) == 0)
3229 (void) GetImageChannelEntropy(image,image_info->channel,&entropy,
3231 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3232 GetMagickPrecision(),entropy);
3235 if (LocaleCompare(
"extension",property) == 0)
3237 GetPathComponent(image->magick_filename,ExtensionPath,value);
3244 if (LocaleCompare(
"gamma",property) == 0)
3246 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3247 GetMagickPrecision(),image->gamma);
3250 if ((image_info != (
ImageInfo *) NULL) &&
3251 (LocaleCompare(
"group",property) == 0))
3253 (void) FormatLocaleString(value,MaxTextExtent,
"0x%lx",(
unsigned long)
3261 if (LocaleCompare(
"height",property) == 0)
3263 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3264 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3271 if (LocaleCompare(
"input",property) == 0)
3273 string=image->filename;
3276 if (LocaleCompare(
"interlace",property) == 0)
3278 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3286 if (LocaleCompare(
"kurtosis",property) == 0)
3292 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
3293 &skewness,&image->exception);
3294 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3295 GetMagickPrecision(),kurtosis);
3302 if (LocaleCompare(
"magick",property) == 0)
3304 string=image->magick;
3307 if ((LocaleCompare(
"max",property) == 0) ||
3308 (LocaleCompare(
"maxima",property) == 0))
3314 (void) GetImageChannelRange(image,image_info->channel,&minimum,
3315 &maximum,&image->exception);
3316 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3317 GetMagickPrecision(),maximum);
3320 if (LocaleCompare(
"mean",property) == 0)
3326 (void) GetImageChannelMean(image,image_info->channel,&mean,
3327 &standard_deviation,&image->exception);
3328 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3329 GetMagickPrecision(),mean);
3332 if ((LocaleCompare(
"min",property) == 0) ||
3333 (LocaleCompare(
"minima",property) == 0))
3339 (void) GetImageChannelRange(image,image_info->channel,&minimum,
3340 &maximum,&image->exception);
3341 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3342 GetMagickPrecision(),minimum);
3349 if (LocaleCompare(
"opaque",property) == 0)
3354 opaque=IsOpaqueImage(image,&image->exception);
3355 (void) CopyMagickString(value,opaque != MagickFalse ?
"true" :
3356 "false",MaxTextExtent);
3359 if (LocaleCompare(
"orientation",property) == 0)
3361 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3362 image->orientation);
3365 if ((image_info != (
ImageInfo *) NULL) &&
3366 (LocaleCompare(
"output",property) == 0))
3368 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
3375 if (LocaleCompare(
"page",property) == 0)
3377 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
3378 image->page.width,(double) image->page.height);
3381 if (LocaleNCompare(
"papersize:",property,10) == 0)
3387 papersize=GetPageGeometry(property+10);
3388 if (papersize != (
const char *) NULL)
3391 page = { 0, 0, 0, 0 };
3393 (void) ParseAbsoluteGeometry(papersize,&page);
3394 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",
3395 (
double) page.width,(double) page.height);
3396 papersize=DestroyString(papersize);
3400 #if defined(MAGICKCORE_LCMS_DELEGATE)
3401 if (LocaleCompare(
"profile:icc",property) == 0 ||
3402 LocaleCompare(
"profile:icm",property) == 0)
3404 #if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3405 #define cmsUInt32Number DWORD
3414 profile=GetImageProfile(image,property+8);
3418 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3419 (cmsUInt32Number) GetStringInfoLength(profile));
3420 if (icc_profile != (cmsHPROFILE *) NULL)
3422 #if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3423 string=cmsTakeProductName(icc_profile);
3425 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3426 "en",
"US",value,MaxTextExtent);
3428 (void) cmsCloseProfile(icc_profile);
3432 if (LocaleCompare(
"printsize.x",property) == 0)
3434 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3435 GetMagickPrecision(),MagickSafeReciprocal(image->x_resolution)*
3439 if (LocaleCompare(
"printsize.y",property) == 0)
3441 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3442 GetMagickPrecision(),MagickSafeReciprocal(image->y_resolution)*
3446 if (LocaleCompare(
"profiles",property) == 0)
3451 ResetImageProfileIterator(image);
3452 name=GetNextImageProfile(image);
3453 if (name != (
char *) NULL)
3455 (void) CopyMagickString(value,name,MaxTextExtent);
3456 name=GetNextImageProfile(image);
3457 while (name != (
char *) NULL)
3459 ConcatenateMagickString(value,
",",MaxTextExtent);
3460 ConcatenateMagickString(value,name,MaxTextExtent);
3461 name=GetNextImageProfile(image);
3470 if (LocaleCompare(
"quality",property) == 0)
3472 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3480 if (LocaleCompare(
"rendering-intent",property) == 0)
3482 string=CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
3483 image->rendering_intent);
3486 if (LocaleCompare(
"resolution.x",property) == 0)
3488 (void) FormatLocaleString(value,MaxTextExtent,
"%g",
3489 image->x_resolution);
3492 if (LocaleCompare(
"resolution.y",property) == 0)
3494 (void) FormatLocaleString(value,MaxTextExtent,
"%g",
3495 image->y_resolution);
3502 if (LocaleCompare(
"scene",property) == 0)
3504 if ((image_info != (
ImageInfo *) NULL) &&
3505 (image_info->number_scenes != 0))
3506 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3509 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3513 if (LocaleCompare(
"scenes",property) == 0)
3515 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3516 GetImageListLength(image));
3519 if (LocaleCompare(
"size",property) == 0)
3521 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,value);
3524 if (LocaleCompare(
"skewness",property) == 0)
3530 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
3531 &skewness,&image->exception);
3532 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3533 GetMagickPrecision(),skewness);
3536 if ((LocaleCompare(
"standard-deviation",property) == 0) ||
3537 (LocaleCompare(
"standard_deviation",property) == 0))
3543 (void) GetImageChannelMean(image,image_info->channel,&mean,
3544 &standard_deviation,&image->exception);
3545 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3546 GetMagickPrecision(),standard_deviation);
3553 if (LocaleCompare(
"type",property) == 0)
3555 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3556 IdentifyImageType(image,&image->exception));
3563 if ((image_info != (
ImageInfo *) NULL) &&
3564 (LocaleCompare(
"unique",property) == 0))
3566 string=image_info->unique;
3569 if (LocaleCompare(
"units",property) == 0)
3574 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3582 if (LocaleCompare(
"version",property) == 0)
3584 string=GetMagickVersion((
size_t *) NULL);
3591 if (LocaleCompare(
"width",property) == 0)
3593 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3594 (image->magick_columns != 0 ? image->magick_columns : 256));
3601 if ((LocaleCompare(
"xresolution",property) == 0) ||
3602 (LocaleCompare(
"x-resolution",property) == 0) )
3604 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3605 image->x_resolution);
3612 if ((LocaleCompare(
"yresolution",property) == 0) ||
3613 (LocaleCompare(
"y-resolution",property) == 0) )
3615 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3616 image->y_resolution);
3623 if ((image_info != (
ImageInfo *) NULL) &&
3624 (LocaleCompare(
"zero",property) == 0))
3626 string=image_info->zero;
3634 if (
string != (
char *) NULL)
3636 (void) SetImageArtifact(image,
"get-property",
string);
3637 return(GetImageArtifact(image,
"get-property"));
3639 return((
char *) NULL);
3664 MagickExport
char *GetNextImageProperty(
const Image *image)
3666 assert(image != (
Image *) NULL);
3667 assert(image->signature == MagickCoreSignature);
3668 if (IsEventLogging() != MagickFalse)
3669 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3671 if (image->properties == (
void *) NULL)
3672 return((
char *) NULL);
3673 return((
char *) GetNextKeyInSplayTree((
SplayTreeInfo *) image->properties));
3728 MagickExport
char *InterpretImageProperties(
const ImageInfo *image_info,
3729 Image *image,
const char *embed_text)
3731 #define ExtendInterpretText(string_length) \
3733 size_t length=(string_length); \
3734 if ((size_t) (q-interpret_text+length+1) >= extent) \
3737 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3738 MaxTextExtent,sizeof(*interpret_text)); \
3739 if (interpret_text == (char *) NULL) \
3741 if (property_info != image_info) \
3742 property_info=DestroyImageInfo(property_info); \
3743 return((char *) NULL); \
3745 q=interpret_text+strlen(interpret_text); \
3749 #define AppendKeyValue2Text(key,value)\
3751 size_t length=strlen(key)+strlen(value)+2; \
3752 if ((size_t) (q-interpret_text+length+1) >= extent) \
3755 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3756 MaxTextExtent,sizeof(*interpret_text)); \
3757 if (interpret_text == (char *) NULL) \
3759 if (property_info != image_info) \
3760 property_info=DestroyImageInfo(property_info); \
3761 return((char *) NULL); \
3763 q=interpret_text+strlen(interpret_text); \
3765 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3768 #define AppendString2Text(string) \
3770 size_t length=strlen((string)); \
3771 if ((size_t) (q-interpret_text+length+1) >= extent) \
3774 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3775 MaxTextExtent,sizeof(*interpret_text)); \
3776 if (interpret_text == (char *) NULL) \
3778 if (property_info != image_info) \
3779 property_info=DestroyImageInfo(property_info); \
3780 return((char *) NULL); \
3782 q=interpret_text+strlen(interpret_text); \
3784 (void) CopyMagickString(q,(string),extent); \
3785 q+=(ptrdiff_t) length; \
3806 assert(image != (
Image *) NULL);
3807 assert(image->signature == MagickCoreSignature);
3808 if (IsEventLogging() != MagickFalse)
3809 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3810 if (embed_text == (
const char *) NULL)
3811 return(ConstantString(
""));
3813 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3816 return(ConstantString(
""));
3817 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3822 if (IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,p) == MagickFalse)
3825 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3826 PolicyError,
"NotAuthorized",
"`%s'",p);
3827 return(ConstantString(
""));
3829 interpret_text=FileToString(p,~0UL,&image->exception);
3830 if (interpret_text != (
char *) NULL)
3831 return(interpret_text);
3839 property_info=CloneImageInfo(image_info);
3840 interpret_text=AcquireString(embed_text);
3841 extent=MaxTextExtent;
3843 for (q=interpret_text; *p!=
'\0';
3844 number=(isdigit((
int) ((
unsigned char) *p))) ? MagickTrue : MagickFalse,p++)
3850 ExtendInterpretText(MaxTextExtent);
3893 if (LocaleNCompare(
"<",p,4) == 0)
3899 if (LocaleNCompare(
">",p,4) == 0)
3905 if (LocaleNCompare(
"&",p,5) == 0)
3926 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3942 if (number != MagickFalse)
3948 value=GetMagickPropertyLetter(property_info,image,*p);
3949 if (value != (
char *) NULL)
3951 AppendString2Text(value);
3954 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3955 OptionWarning,
"UnknownImageProperty",
"\"%%%c\"",*p);
3960 pattern[2*MaxTextExtent] =
"\0";
3979 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3980 OptionWarning,
"UnknownImageProperty",
"\"%%[]\"");
3983 for (len=0; len<(MaxTextExtent-1L) && (*p !=
'\0');)
3985 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3990 pattern[len++]=(*p++);
3991 pattern[len++]=(*p++);
4000 pattern[len++]=(*p++);
4015 (void) ThrowMagickException(&image->exception,GetMagickModule(),
4016 OptionError,
"UnbalancedBraces",
"\"%%[%s\"",pattern);
4017 interpret_text=DestroyString(interpret_text);
4018 if (property_info != image_info)
4019 property_info=DestroyImageInfo(property_info);
4020 return((
char *) NULL);
4025 if (LocaleNCompare(
"fx:",pattern,3) == 0)
4039 fx_info=AcquireFxInfo(image,pattern+3);
4040 status=FxEvaluateChannelExpression(fx_info,property_info->channel,0,0,
4041 &value,&image->exception);
4042 fx_info=DestroyFxInfo(fx_info);
4043 if (status != MagickFalse)
4046 result[MagickPathExtent];
4048 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
4049 GetMagickPrecision(),(double) value);
4050 AppendString2Text(result);
4054 if (LocaleNCompare(
"option:",pattern,7) == 0)
4059 if (IsGlob(pattern+7) != MagickFalse)
4061 ResetImageOptionIterator(property_info);
4062 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4063 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4065 value=GetImageOption(property_info,key);
4066 if (value != (
const char *) NULL)
4067 AppendKeyValue2Text(key,value);
4072 value=GetImageOption(property_info,pattern+7);
4073 if (value != (
char *) NULL)
4074 AppendString2Text(value);
4078 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4083 if (IsGlob(pattern+9) != MagickFalse)
4085 ResetImageArtifactIterator(image);
4086 while ((key=GetNextImageArtifact(image)) != (
const char *) NULL)
4087 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4089 value=GetImageArtifact(image,key);
4090 if (value != (
const char *) NULL)
4091 AppendKeyValue2Text(key,value);
4096 value=GetImageArtifact(image,pattern+9);
4097 if (value != (
char *) NULL)
4098 AppendString2Text(value);
4108 value=GetImageProperty(image,pattern);
4109 if (value != (
const char *) NULL)
4111 AppendString2Text(value);
4118 if (IsGlob(pattern) != MagickFalse)
4120 ResetImagePropertyIterator(image);
4121 while ((key=GetNextImageProperty(image)) != (
const char *) NULL)
4122 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4124 value=GetImageProperty(image,key);
4125 if (value != (
const char *) NULL)
4126 AppendKeyValue2Text(key,value);
4136 value=GetMagickProperty(property_info,image,pattern);
4137 if (value != (
const char *) NULL)
4139 AppendString2Text(value);
4145 value=GetImageArtifact(image,pattern);
4146 if (value != (
char *) NULL)
4148 AppendString2Text(value);
4154 value=GetImageOption(property_info,pattern);
4155 if (value != (
char *) NULL)
4157 AppendString2Text(value);
4170 (void) ThrowMagickException(&image->exception,GetMagickModule(),
4171 OptionWarning,
"UnknownImageProperty",
"\"%%[%s]\"",pattern);
4176 if (property_info != image_info)
4177 property_info=DestroyImageInfo(property_info);
4178 return(interpret_text);
4209 MagickExport
char *RemoveImageProperty(
Image *image,
const char *property)
4214 assert(image != (
Image *) NULL);
4215 assert(image->signature == MagickCoreSignature);
4216 if (IsEventLogging() != MagickFalse)
4217 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4219 if (image->properties == (
void *) NULL)
4220 return((
char *) NULL);
4221 value=(
char *) RemoveNodeFromSplayTree((
SplayTreeInfo *) image->properties,
4250 MagickExport
void ResetImagePropertyIterator(
const Image *image)
4252 assert(image != (
Image *) NULL);
4253 assert(image->signature == MagickCoreSignature);
4254 if (IsEventLogging() != MagickFalse)
4255 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4257 if (image->properties == (
void *) NULL)
4259 ResetSplayTreeIterator((
SplayTreeInfo *) image->properties);
4290 MagickExport MagickBooleanType SetImageProperty(
Image *image,
4291 const char *property,
const char *value)
4306 assert(image != (
Image *) NULL);
4307 assert(image->signature == MagickCoreSignature);
4308 if (IsEventLogging() != MagickFalse)
4309 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4311 if (image->properties == (
void *) NULL)
4312 image->properties=NewSplayTree(CompareSplayTreeString,
4313 RelinquishMagickMemory,RelinquishMagickMemory);
4314 if (value == (
const char *) NULL)
4315 return(DeleteImageProperty(image,property));
4316 exception=(&image->exception);
4317 property_length=strlen(property);
4318 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4319 (*(property+(property_length-1)) ==
'*'))
4321 (void) ThrowMagickException(exception,GetMagickModule(),
4322 OptionWarning,
"SetReadOnlyProperty",
"`%s'",property);
4323 return(MagickFalse);
4338 if (LocaleCompare(
"background",property) == 0)
4340 (void) QueryColorDatabase(value,&image->background_color,exception);
4343 if (LocaleCompare(
"bias",property) == 0)
4345 image->bias=StringToDoubleInterval(value,(
double) QuantumRange+1.0);
4348 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4349 ConstantString(property),ConstantString(value));
4355 if (LocaleCompare(
"colorspace",property) == 0)
4360 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4364 status=SetImageColorspace(image,(ColorspaceType) colorspace);
4367 if (LocaleCompare(
"compose",property) == 0)
4372 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4375 image->compose=(CompositeOperator) compose;
4378 if (LocaleCompare(
"compress",property) == 0)
4383 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4385 if (compression < 0)
4387 image->compression=(CompressionType) compression;
4390 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4391 ConstantString(property),ConstantString(value));
4397 if (LocaleCompare(
"delay",property) == 0)
4402 flags=ParseGeometry(value,&geometry_info);
4403 if ((flags & GreaterValue) != 0)
4405 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4406 image->delay=(size_t) floor(geometry_info.rho+0.5);
4409 if ((flags & LessValue) != 0)
4411 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4412 image->ticks_per_second=CastDoubleToLong(
4413 floor(geometry_info.sigma+0.5));
4416 image->delay=(size_t) floor(geometry_info.rho+0.5);
4417 if ((flags & SigmaValue) != 0)
4418 image->ticks_per_second=CastDoubleToLong(floor(
4419 geometry_info.sigma+0.5));
4422 if (LocaleCompare(
"density",property) == 0)
4427 flags=ParseGeometry(value,&geometry_info);
4428 if ((flags & RhoValue) != 0)
4429 image->x_resolution=geometry_info.rho;
4430 image->y_resolution=image->x_resolution;
4431 if ((flags & SigmaValue) != 0)
4432 image->y_resolution=geometry_info.sigma;
4434 if (LocaleCompare(
"depth",property) == 0)
4436 image->depth=StringToUnsignedLong(value);
4439 if (LocaleCompare(
"dispose",property) == 0)
4444 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4447 image->dispose=(DisposeType) dispose;
4450 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4451 ConstantString(property),ConstantString(value));
4457 if (LocaleCompare(
"gamma",property) == 0)
4459 image->gamma=StringToDouble(value,(
char **) NULL);
4462 if (LocaleCompare(
"gravity",property) == 0)
4467 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4470 image->gravity=(GravityType) gravity;
4473 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4474 ConstantString(property),ConstantString(value));
4480 if (LocaleCompare(
"intensity",property) == 0)
4485 intensity=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4489 image->intensity=(PixelIntensityMethod) intensity;
4492 if (LocaleCompare(
"interpolate",property) == 0)
4497 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4499 if (interpolate < 0)
4501 image->interpolate=(InterpolatePixelMethod) interpolate;
4504 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4505 ConstantString(property),ConstantString(value));
4511 if (LocaleCompare(
"loop",property) == 0)
4513 image->iterations=StringToUnsignedLong(value);
4516 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4517 ConstantString(property),ConstantString(value));
4523 if (LocaleCompare(
"page",property) == 0)
4528 geometry=GetPageGeometry(value);
4529 flags=ParseAbsoluteGeometry(geometry,&image->page);
4530 geometry=DestroyString(geometry);
4533 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4534 ConstantString(property),ConstantString(value));
4540 if (LocaleCompare(
"rendering-intent",property) == 0)
4545 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4547 if (rendering_intent < 0)
4549 image->rendering_intent=(RenderingIntent) rendering_intent;
4552 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4553 ConstantString(property),ConstantString(value));
4559 if (LocaleCompare(
"tile-offset",property) == 0)
4564 geometry=GetPageGeometry(value);
4565 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4566 geometry=DestroyString(geometry);
4569 if (LocaleCompare(
"type",property) == 0)
4574 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4576 return(MagickFalse);
4577 image->type=(ImageType) type;
4580 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4581 ConstantString(property),ConstantString(value));
4587 if (LocaleCompare(
"units",property) == 0)
4592 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4595 image->units=(ResolutionType) units;
4598 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4599 ConstantString(property),ConstantString(value));
4604 status=AddValueToSplayTree((
SplayTreeInfo *) image->properties,
4605 ConstantString(property),ConstantString(value));