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"
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/utility.h"
82#include "magick/version.h"
83#include "magick/xml-tree.h"
84#if defined(MAGICKCORE_LCMS_DELEGATE)
85#if defined(MAGICKCORE_HAVE_LCMS2_LCMS2_H)
86#include <lcms2/lcms2.h>
87#elif defined(MAGICKCORE_HAVE_LCMS2_H)
89#elif defined(MAGICKCORE_HAVE_LCMS_LCMS_H)
99#if defined(MAGICKCORE_LCMS_DELEGATE)
100#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
101#define cmsUInt32Number DWORD
132 *(*CloneKeyFunc)(
const char *),
133 *(*CloneValueFunc)(
const char *);
135static inline void *ClonePropertyKey(
void *key)
137 return((
void *) ((CloneKeyFunc) ConstantString)((
const char *) key));
140static inline void *ClonePropertyValue(
void *value)
142 return((
void *) ((CloneValueFunc) ConstantString)((
const char *) value));
145MagickExport MagickBooleanType CloneImageProperties(Image *image,
146 const Image *clone_image)
148 assert(image != (Image *) NULL);
149 assert(image->signature == MagickCoreSignature);
150 assert(clone_image != (
const Image *) NULL);
151 assert(clone_image->signature == MagickCoreSignature);
152 if (IsEventLogging() != MagickFalse)
154 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
155 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
156 clone_image->filename);
158 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
159 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
161 image->compression=clone_image->compression;
162 image->quality=clone_image->quality;
163 image->depth=clone_image->depth;
164 image->background_color=clone_image->background_color;
165 image->border_color=clone_image->border_color;
166 image->matte_color=clone_image->matte_color;
167 image->transparent_color=clone_image->transparent_color;
168 image->gamma=clone_image->gamma;
169 image->chromaticity=clone_image->chromaticity;
170 image->rendering_intent=clone_image->rendering_intent;
171 image->black_point_compensation=clone_image->black_point_compensation;
172 image->units=clone_image->units;
173 image->montage=(
char *) NULL;
174 image->directory=(
char *) NULL;
175 (void) CloneString(&image->geometry,clone_image->geometry);
176 image->offset=clone_image->offset;
177 image->x_resolution=clone_image->x_resolution;
178 image->y_resolution=clone_image->y_resolution;
179 image->page=clone_image->page;
180 image->tile_offset=clone_image->tile_offset;
181 image->extract_info=clone_image->extract_info;
182 image->bias=clone_image->bias;
183 image->filter=clone_image->filter;
184 image->blur=clone_image->blur;
185 image->fuzz=clone_image->fuzz;
186 image->intensity=clone_image->intensity;
187 image->interlace=clone_image->interlace;
188 image->interpolate=clone_image->interpolate;
189 image->endian=clone_image->endian;
190 image->gravity=clone_image->gravity;
191 image->compose=clone_image->compose;
192 image->orientation=clone_image->orientation;
193 image->scene=clone_image->scene;
194 image->dispose=clone_image->dispose;
195 image->delay=clone_image->delay;
196 image->ticks_per_second=clone_image->ticks_per_second;
197 image->iterations=clone_image->iterations;
198 image->total_colors=clone_image->total_colors;
199 image->taint=clone_image->taint;
200 image->progress_monitor=clone_image->progress_monitor;
201 image->client_data=clone_image->client_data;
202 image->start_loop=clone_image->start_loop;
203 image->error=clone_image->error;
204 image->signature=clone_image->signature;
205 if (clone_image->properties != (
void *) NULL)
207 if (image->properties != (
void *) NULL)
208 DestroyImageProperties(image);
209 image->properties=CloneSplayTree((SplayTreeInfo *)
210 clone_image->properties,ClonePropertyKey,ClonePropertyValue);
242MagickExport MagickBooleanType DefineImageProperty(Image *image,
243 const char *property)
247 value[MaxTextExtent];
252 assert(image != (Image *) NULL);
253 assert(property != (
const char *) NULL);
254 (void) CopyMagickString(key,property,MaxTextExtent-1);
255 for (p=key; *p !=
'\0'; p++)
260 (void) CopyMagickString(value,p+1,MaxTextExtent);
262 return(SetImageProperty(image,key,value));
289MagickExport MagickBooleanType DeleteImageProperty(Image *image,
290 const char *property)
292 assert(image != (Image *) NULL);
293 assert(image->signature == MagickCoreSignature);
294 if (IsEventLogging() != MagickFalse)
295 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
296 if (image->properties == (
void *) NULL)
298 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
324MagickExport
void DestroyImageProperties(Image *image)
326 assert(image != (Image *) NULL);
327 assert(image->signature == MagickCoreSignature);
328 if (IsEventLogging() != MagickFalse)
329 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
330 if (image->properties != (
void *) NULL)
331 image->properties=(
void *) DestroySplayTree((SplayTreeInfo *)
364MagickExport MagickBooleanType FormatImageProperty(Image *image,
365 const char *property,
const char *format,...)
368 value[MaxTextExtent];
376 va_start(operands,format);
377 n=FormatLocaleStringList(value,MaxTextExtent,format,operands);
380 return(SetImageProperty(image,property,value));
416 *TracePSClippath(
const unsigned char *,
size_t,
const size_t,
418 *TraceSVGClippath(
const unsigned char *,
size_t,
const size_t,
421static MagickBooleanType GetIPTCProperty(
const Image *image,
const char *key)
441 profile=GetImageProfile(image,
"iptc");
442 if (profile == (StringInfo *) NULL)
443 profile=GetImageProfile(image,
"8bim");
444 if (profile == (StringInfo *) NULL)
446 count=sscanf(key,
"IPTC:%ld:%ld",&dataset,&record);
449 attribute=(
char *) NULL;
450 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
453 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
455 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
456 length|=GetStringInfoDatum(profile)[i+4];
457 if (((
long) GetStringInfoDatum(profile)[i+1] == dataset) &&
458 ((
long) GetStringInfoDatum(profile)[i+2] == record))
460 message=(
char *) NULL;
462 message=(
char *) AcquireQuantumMemory(length+1UL,
sizeof(*message));
463 if (message != (
char *) NULL)
465 (void) CopyMagickString(message,(
char *) GetStringInfoDatum(
466 profile)+i+5,length+1);
467 (void) ConcatenateString(&attribute,message);
468 (void) ConcatenateString(&attribute,
";");
469 message=DestroyString(message);
474 if ((attribute == (
char *) NULL) || (*attribute ==
';'))
476 if (attribute != (
char *) NULL)
477 attribute=DestroyString(attribute);
480 attribute[strlen(attribute)-1]=
'\0';
481 (void) SetImageProperty((Image *) image,key,(
const char *) attribute);
482 attribute=DestroyString(attribute);
486static inline int ReadPropertyByte(
const unsigned char **p,
size_t *length)
498static inline signed int ReadPropertyMSBLong(
const unsigned char **p,
524 for (i=0; i < 4; i++)
528 buffer[i]=(
unsigned char) c;
530 value=(
unsigned int) buffer[0] << 24;
531 value|=(
unsigned int) buffer[1] << 16;
532 value|=(
unsigned int) buffer[2] << 8;
533 value|=(
unsigned int) buffer[3];
534 quantum.unsigned_value=value & 0xffffffff;
535 return(quantum.signed_value);
538static inline signed short ReadPropertyMSBShort(
const unsigned char **p,
563 return((
unsigned short) ~0);
564 for (i=0; i < 2; i++)
568 buffer[i]=(
unsigned char) c;
570 value=(
unsigned short) buffer[0] << 8;
571 value|=(
unsigned short) buffer[1];
572 quantum.unsigned_value=value & 0xffff;
573 return(quantum.signed_value);
576static MagickBooleanType Get8BIMProperty(
const Image *image,
const char *key)
580 format[MaxTextExtent],
611 profile=GetImageProfile(image,
"8bim");
612 if (profile == (StringInfo *) NULL)
614 count=(ssize_t) sscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
616 if ((count != 2) && (count != 3) && (count != 4))
619 (void) CopyMagickString(format,
"SVG",MaxTextExtent);
624 sub_number=(ssize_t) StringToLong(&name[1]);
625 sub_number=MagickMax(sub_number,1L);
626 resource=(
char *) NULL;
628 length=GetStringInfoLength(profile);
629 info=GetStringInfoDatum(profile);
630 while ((length > 0) && (status == MagickFalse))
632 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'8')
634 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'B')
636 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'I')
638 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'M')
640 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
641 if (
id < (ssize_t) start)
643 if (
id > (ssize_t) stop)
645 if (resource != (
char *) NULL)
646 resource=DestroyString(resource);
647 count=(ssize_t) ReadPropertyByte(&info,&length);
648 if ((count != 0) && ((
size_t) count <= length))
650 resource=(
char *) NULL;
651 if (~((
size_t) count) >= (MaxTextExtent-1))
652 resource=(
char *) AcquireQuantumMemory((
size_t) count+MaxTextExtent,
654 if (resource != (
char *) NULL)
656 for (i=0; i < (ssize_t) count; i++)
657 resource[i]=(
char) ReadPropertyByte(&info,&length);
658 resource[count]=
'\0';
661 if ((count & 0x01) == 0)
662 (void) ReadPropertyByte(&info,&length);
663 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
664 if ((count < 0) || ((
size_t) count > length))
669 if ((*name !=
'\0') && (*name !=
'#'))
670 if ((resource == (
char *) NULL) || (LocaleCompare(name,resource) != 0))
676 length-=MagickMin(count,(ssize_t) length);
679 if ((*name ==
'#') && (sub_number != 1))
686 length-=MagickMin(count,(ssize_t) length);
692 attribute=(
char *) NULL;
693 if (~((
size_t) count) >= (MaxTextExtent-1))
694 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MaxTextExtent,
696 if (attribute != (
char *) NULL)
698 (void) memcpy(attribute,(
char *) info,(
size_t) count);
699 attribute[count]=
'\0';
701 length-=MagickMin(count,(ssize_t) length);
702 if ((
id <= 1999) || (
id >= 2999))
703 (void) SetImageProperty((Image *) image,key,(
const char *) attribute);
709 if (LocaleCompare(format,
"svg") == 0)
710 path=TraceSVGClippath((
unsigned char *) attribute,(
size_t) count,
711 image->columns,image->rows);
713 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count,
714 image->columns,image->rows);
715 (void) SetImageProperty((Image *) image,key,(
const char *) path);
716 path=DestroyString(path);
718 attribute=DestroyString(attribute);
722 if (resource != (
char *) NULL)
723 resource=DestroyString(resource);
727static inline signed int ReadPropertySignedLong(
const EndianType endian,
728 const unsigned char *buffer)
742 if (endian == LSBEndian)
744 value=(
unsigned int) buffer[3] << 24;
745 value|=(
unsigned int) buffer[2] << 16;
746 value|=(
unsigned int) buffer[1] << 8;
747 value|=(
unsigned int) buffer[0];
748 quantum.unsigned_value=value & 0xffffffff;
749 return(quantum.signed_value);
751 value=(
unsigned int) buffer[0] << 24;
752 value|=(
unsigned int) buffer[1] << 16;
753 value|=(
unsigned int) buffer[2] << 8;
754 value|=(
unsigned int) buffer[3];
755 quantum.unsigned_value=value & 0xffffffff;
756 return(quantum.signed_value);
759static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
760 const unsigned char *buffer)
765 if (endian == LSBEndian)
767 value=(
unsigned int) buffer[3] << 24;
768 value|=(
unsigned int) buffer[2] << 16;
769 value|=(
unsigned int) buffer[1] << 8;
770 value|=(
unsigned int) buffer[0];
771 return(value & 0xffffffff);
773 value=(
unsigned int) buffer[0] << 24;
774 value|=(
unsigned int) buffer[1] << 16;
775 value|=(
unsigned int) buffer[2] << 8;
776 value|=(
unsigned int) buffer[3];
777 return(value & 0xffffffff);
780static inline signed short ReadPropertySignedShort(
const EndianType endian,
781 const unsigned char *buffer)
795 if (endian == LSBEndian)
797 value=(
unsigned short) buffer[1] << 8;
798 value|=(
unsigned short) buffer[0];
799 quantum.unsigned_value=value & 0xffff;
800 return(quantum.signed_value);
802 value=(
unsigned short) buffer[0] << 8;
803 value|=(
unsigned short) buffer[1];
804 quantum.unsigned_value=value & 0xffff;
805 return(quantum.signed_value);
808static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
809 const unsigned char *buffer)
814 if (endian == LSBEndian)
816 value=(
unsigned short) buffer[1] << 8;
817 value|=(
unsigned short) buffer[0];
818 return(value & 0xffff);
820 value=(
unsigned short) buffer[0] << 8;
821 value|=(
unsigned short) buffer[1];
822 return(value & 0xffff);
825static MagickBooleanType GetEXIFProperty(
const Image *image,
826 const char *property)
828#define MaxDirectoryStack 16
829#define EXIF_DELIMITER "\n"
830#define EXIF_NUM_FORMATS 12
831#define EXIF_FMT_BYTE 1
832#define EXIF_FMT_STRING 2
833#define EXIF_FMT_USHORT 3
834#define EXIF_FMT_ULONG 4
835#define EXIF_FMT_URATIONAL 5
836#define EXIF_FMT_SBYTE 6
837#define EXIF_FMT_UNDEFINED 7
838#define EXIF_FMT_SSHORT 8
839#define EXIF_FMT_SLONG 9
840#define EXIF_FMT_SRATIONAL 10
841#define EXIF_FMT_SINGLE 11
842#define EXIF_FMT_DOUBLE 12
843#define GPS_LATITUDE 0x10002
844#define GPS_LONGITUDE 0x10004
845#define GPS_TIMESTAMP 0x10007
846#define TAG_EXIF_OFFSET 0x8769
847#define TAG_GPS_OFFSET 0x8825
848#define TAG_INTEROP_OFFSET 0xa005
851#define EXIFGPSFractions(format,arg1,arg2,arg3,arg4,arg5,arg6) \
859 for ( ; component < components; component++) \
861 if (component != 0) \
862 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
864 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
865 extent,format,(arg1),(arg2),(arg3),(arg4),(arg5),(arg6)); \
866 if (extent >= (MagickPathExtent-1)) \
867 extent=MagickPathExtent-1; \
869 buffer[extent]='\0'; \
870 value=AcquireString(buffer); \
873#define EXIFMultipleValues(format,arg) \
881 for ( ; component < components; component++) \
883 if (component != 0) \
884 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
886 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
887 extent,format,arg); \
888 if (extent >= (MagickPathExtent-1)) \
889 extent=MagickPathExtent-1; \
891 buffer[extent]='\0'; \
892 value=AcquireString(buffer); \
895#define EXIFMultipleFractions(format,arg1,arg2) \
903 for ( ; component < components; component++) \
905 if (component != 0) \
906 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent-\
908 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
909 extent,format,(arg1),(arg2)); \
910 if (extent >= (MagickPathExtent-1)) \
911 extent=MagickPathExtent-1; \
913 buffer[extent]='\0'; \
914 value=AcquireString(buffer); \
917 typedef struct _DirectoryInfo
929 typedef struct _TagInfo
941 { 0x001,
"exif:InteroperabilityIndex" },
942 { 0x002,
"exif:InteroperabilityVersion" },
943 { 0x100,
"exif:ImageWidth" },
944 { 0x101,
"exif:ImageLength" },
945 { 0x102,
"exif:BitsPerSample" },
946 { 0x103,
"exif:Compression" },
947 { 0x106,
"exif:PhotometricInterpretation" },
948 { 0x10a,
"exif:FillOrder" },
949 { 0x10d,
"exif:DocumentName" },
950 { 0x10e,
"exif:ImageDescription" },
951 { 0x10f,
"exif:Make" },
952 { 0x110,
"exif:Model" },
953 { 0x111,
"exif:StripOffsets" },
954 { 0x112,
"exif:Orientation" },
955 { 0x115,
"exif:SamplesPerPixel" },
956 { 0x116,
"exif:RowsPerStrip" },
957 { 0x117,
"exif:StripByteCounts" },
958 { 0x11a,
"exif:XResolution" },
959 { 0x11b,
"exif:YResolution" },
960 { 0x11c,
"exif:PlanarConfiguration" },
961 { 0x11d,
"exif:PageName" },
962 { 0x11e,
"exif:XPosition" },
963 { 0x11f,
"exif:YPosition" },
964 { 0x118,
"exif:MinSampleValue" },
965 { 0x119,
"exif:MaxSampleValue" },
966 { 0x120,
"exif:FreeOffsets" },
967 { 0x121,
"exif:FreeByteCounts" },
968 { 0x122,
"exif:GrayResponseUnit" },
969 { 0x123,
"exif:GrayResponseCurve" },
970 { 0x124,
"exif:T4Options" },
971 { 0x125,
"exif:T6Options" },
972 { 0x128,
"exif:ResolutionUnit" },
973 { 0x12d,
"exif:TransferFunction" },
974 { 0x131,
"exif:Software" },
975 { 0x132,
"exif:DateTime" },
976 { 0x13b,
"exif:Artist" },
977 { 0x13e,
"exif:WhitePoint" },
978 { 0x13f,
"exif:PrimaryChromaticities" },
979 { 0x140,
"exif:ColorMap" },
980 { 0x141,
"exif:HalfToneHints" },
981 { 0x142,
"exif:TileWidth" },
982 { 0x143,
"exif:TileLength" },
983 { 0x144,
"exif:TileOffsets" },
984 { 0x145,
"exif:TileByteCounts" },
985 { 0x14a,
"exif:SubIFD" },
986 { 0x14c,
"exif:InkSet" },
987 { 0x14d,
"exif:InkNames" },
988 { 0x14e,
"exif:NumberOfInks" },
989 { 0x150,
"exif:DotRange" },
990 { 0x151,
"exif:TargetPrinter" },
991 { 0x152,
"exif:ExtraSample" },
992 { 0x153,
"exif:SampleFormat" },
993 { 0x154,
"exif:SMinSampleValue" },
994 { 0x155,
"exif:SMaxSampleValue" },
995 { 0x156,
"exif:TransferRange" },
996 { 0x157,
"exif:ClipPath" },
997 { 0x158,
"exif:XClipPathUnits" },
998 { 0x159,
"exif:YClipPathUnits" },
999 { 0x15a,
"exif:Indexed" },
1000 { 0x15b,
"exif:JPEGTables" },
1001 { 0x15f,
"exif:OPIProxy" },
1002 { 0x200,
"exif:JPEGProc" },
1003 { 0x201,
"exif:JPEGInterchangeFormat" },
1004 { 0x202,
"exif:JPEGInterchangeFormatLength" },
1005 { 0x203,
"exif:JPEGRestartInterval" },
1006 { 0x205,
"exif:JPEGLosslessPredictors" },
1007 { 0x206,
"exif:JPEGPointTransforms" },
1008 { 0x207,
"exif:JPEGQTables" },
1009 { 0x208,
"exif:JPEGDCTables" },
1010 { 0x209,
"exif:JPEGACTables" },
1011 { 0x211,
"exif:YCbCrCoefficients" },
1012 { 0x212,
"exif:YCbCrSubSampling" },
1013 { 0x213,
"exif:YCbCrPositioning" },
1014 { 0x214,
"exif:ReferenceBlackWhite" },
1015 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1016 { 0x301,
"exif:Gamma" },
1017 { 0x302,
"exif:ICCProfileDescriptor" },
1018 { 0x303,
"exif:SRGBRenderingIntent" },
1019 { 0x320,
"exif:ImageTitle" },
1020 { 0x5001,
"exif:ResolutionXUnit" },
1021 { 0x5002,
"exif:ResolutionYUnit" },
1022 { 0x5003,
"exif:ResolutionXLengthUnit" },
1023 { 0x5004,
"exif:ResolutionYLengthUnit" },
1024 { 0x5005,
"exif:PrintFlags" },
1025 { 0x5006,
"exif:PrintFlagsVersion" },
1026 { 0x5007,
"exif:PrintFlagsCrop" },
1027 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1028 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1029 { 0x500A,
"exif:HalftoneLPI" },
1030 { 0x500B,
"exif:HalftoneLPIUnit" },
1031 { 0x500C,
"exif:HalftoneDegree" },
1032 { 0x500D,
"exif:HalftoneShape" },
1033 { 0x500E,
"exif:HalftoneMisc" },
1034 { 0x500F,
"exif:HalftoneScreen" },
1035 { 0x5010,
"exif:JPEGQuality" },
1036 { 0x5011,
"exif:GridSize" },
1037 { 0x5012,
"exif:ThumbnailFormat" },
1038 { 0x5013,
"exif:ThumbnailWidth" },
1039 { 0x5014,
"exif:ThumbnailHeight" },
1040 { 0x5015,
"exif:ThumbnailColorDepth" },
1041 { 0x5016,
"exif:ThumbnailPlanes" },
1042 { 0x5017,
"exif:ThumbnailRawBytes" },
1043 { 0x5018,
"exif:ThumbnailSize" },
1044 { 0x5019,
"exif:ThumbnailCompressedSize" },
1045 { 0x501a,
"exif:ColorTransferFunction" },
1046 { 0x501b,
"exif:ThumbnailData" },
1047 { 0x5020,
"exif:ThumbnailImageWidth" },
1048 { 0x5021,
"exif:ThumbnailImageHeight" },
1049 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1050 { 0x5023,
"exif:ThumbnailCompression" },
1051 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1052 { 0x5025,
"exif:ThumbnailImageDescription" },
1053 { 0x5026,
"exif:ThumbnailEquipMake" },
1054 { 0x5027,
"exif:ThumbnailEquipModel" },
1055 { 0x5028,
"exif:ThumbnailStripOffsets" },
1056 { 0x5029,
"exif:ThumbnailOrientation" },
1057 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1058 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1059 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1060 { 0x502d,
"exif:ThumbnailResolutionX" },
1061 { 0x502e,
"exif:ThumbnailResolutionY" },
1062 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1063 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1064 { 0x5031,
"exif:ThumbnailTransferFunction" },
1065 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1066 { 0x5033,
"exif:ThumbnailDateTime" },
1067 { 0x5034,
"exif:ThumbnailArtist" },
1068 { 0x5035,
"exif:ThumbnailWhitePoint" },
1069 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1070 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1071 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1072 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1073 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1074 { 0x503B,
"exif:ThumbnailCopyRight" },
1075 { 0x5090,
"exif:LuminanceTable" },
1076 { 0x5091,
"exif:ChrominanceTable" },
1077 { 0x5100,
"exif:FrameDelay" },
1078 { 0x5101,
"exif:LoopCount" },
1079 { 0x5110,
"exif:PixelUnit" },
1080 { 0x5111,
"exif:PixelPerUnitX" },
1081 { 0x5112,
"exif:PixelPerUnitY" },
1082 { 0x5113,
"exif:PaletteHistogram" },
1083 { 0x1000,
"exif:RelatedImageFileFormat" },
1084 { 0x1001,
"exif:RelatedImageLength" },
1085 { 0x1002,
"exif:RelatedImageWidth" },
1086 { 0x800d,
"exif:ImageID" },
1087 { 0x80e3,
"exif:Matteing" },
1088 { 0x80e4,
"exif:DataType" },
1089 { 0x80e5,
"exif:ImageDepth" },
1090 { 0x80e6,
"exif:TileDepth" },
1091 { 0x828d,
"exif:CFARepeatPatternDim" },
1092 { 0x828e,
"exif:CFAPattern2" },
1093 { 0x828f,
"exif:BatteryLevel" },
1094 { 0x8298,
"exif:Copyright" },
1095 { 0x829a,
"exif:ExposureTime" },
1096 { 0x829d,
"exif:FNumber" },
1097 { 0x83bb,
"exif:IPTC/NAA" },
1098 { 0x84e3,
"exif:IT8RasterPadding" },
1099 { 0x84e5,
"exif:IT8ColorTable" },
1100 { 0x8649,
"exif:ImageResourceInformation" },
1101 { 0x8769,
"exif:ExifOffset" },
1102 { 0x8773,
"exif:InterColorProfile" },
1103 { 0x8822,
"exif:ExposureProgram" },
1104 { 0x8824,
"exif:SpectralSensitivity" },
1105 { 0x8825,
"exif:GPSInfo" },
1106 { 0x8827,
"exif:PhotographicSensitivity" },
1107 { 0x8828,
"exif:OECF" },
1108 { 0x8829,
"exif:Interlace" },
1109 { 0x882a,
"exif:TimeZoneOffset" },
1110 { 0x882b,
"exif:SelfTimerMode" },
1111 { 0x8830,
"exif:SensitivityType" },
1112 { 0x8831,
"exif:StandardOutputSensitivity" },
1113 { 0x8832,
"exif:RecommendedExposureIndex" },
1114 { 0x8833,
"exif:ISOSpeed" },
1115 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1116 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1117 { 0x9000,
"exif:ExifVersion" },
1118 { 0x9003,
"exif:DateTimeOriginal" },
1119 { 0x9004,
"exif:DateTimeDigitized" },
1120 { 0x9010,
"exif:OffsetTime" },
1121 { 0x9011,
"exif:OffsetTimeOriginal" },
1122 { 0x9012,
"exif:OffsetTimeDigitized" },
1123 { 0x9101,
"exif:ComponentsConfiguration" },
1124 { 0x9102,
"exif:CompressedBitsPerPixel" },
1125 { 0x9201,
"exif:ShutterSpeedValue" },
1126 { 0x9202,
"exif:ApertureValue" },
1127 { 0x9203,
"exif:BrightnessValue" },
1128 { 0x9204,
"exif:ExposureBiasValue" },
1129 { 0x9205,
"exif:MaxApertureValue" },
1130 { 0x9206,
"exif:SubjectDistance" },
1131 { 0x9207,
"exif:MeteringMode" },
1132 { 0x9208,
"exif:LightSource" },
1133 { 0x9209,
"exif:Flash" },
1134 { 0x920a,
"exif:FocalLength" },
1135 { 0x920b,
"exif:FlashEnergy" },
1136 { 0x920c,
"exif:SpatialFrequencyResponse" },
1137 { 0x920d,
"exif:Noise" },
1138 { 0x9214,
"exif:SubjectArea" },
1139 { 0x9290,
"exif:SubSecTime" },
1140 { 0x9291,
"exif:SubSecTimeOriginal" },
1141 { 0x9292,
"exif:SubSecTimeDigitized" },
1142 { 0x9211,
"exif:ImageNumber" },
1143 { 0x9212,
"exif:SecurityClassification" },
1144 { 0x9213,
"exif:ImageHistory" },
1145 { 0x9214,
"exif:SubjectArea" },
1146 { 0x9215,
"exif:ExposureIndex" },
1147 { 0x9216,
"exif:TIFF-EPStandardID" },
1148 { 0x927c,
"exif:MakerNote" },
1149 { 0x9286,
"exif:UserComment" },
1150 { 0x9290,
"exif:SubSecTime" },
1151 { 0x9291,
"exif:SubSecTimeOriginal" },
1152 { 0x9292,
"exif:SubSecTimeDigitized" },
1153 { 0x9400,
"exif:Temperature" },
1154 { 0x9401,
"exif:Humidity" },
1155 { 0x9402,
"exif:Pressure" },
1156 { 0x9403,
"exif:WaterDepth" },
1157 { 0x9404,
"exif:Acceleration" },
1158 { 0x9405,
"exif:CameraElevationAngle" },
1159 { 0x9C9b,
"exif:WinXP-Title" },
1160 { 0x9C9c,
"exif:WinXP-Comments" },
1161 { 0x9C9d,
"exif:WinXP-Author" },
1162 { 0x9C9e,
"exif:WinXP-Keywords" },
1163 { 0x9C9f,
"exif:WinXP-Subject" },
1164 { 0xa000,
"exif:FlashPixVersion" },
1165 { 0xa001,
"exif:ColorSpace" },
1166 { 0xa002,
"exif:PixelXDimension" },
1167 { 0xa003,
"exif:PixelYDimension" },
1168 { 0xa004,
"exif:RelatedSoundFile" },
1169 { 0xa005,
"exif:InteroperabilityOffset" },
1170 { 0xa20b,
"exif:FlashEnergy" },
1171 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1172 { 0xa20d,
"exif:Noise" },
1173 { 0xa20e,
"exif:FocalPlaneXResolution" },
1174 { 0xa20f,
"exif:FocalPlaneYResolution" },
1175 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1176 { 0xa214,
"exif:SubjectLocation" },
1177 { 0xa215,
"exif:ExposureIndex" },
1178 { 0xa216,
"exif:TIFF/EPStandardID" },
1179 { 0xa217,
"exif:SensingMethod" },
1180 { 0xa300,
"exif:FileSource" },
1181 { 0xa301,
"exif:SceneType" },
1182 { 0xa302,
"exif:CFAPattern" },
1183 { 0xa401,
"exif:CustomRendered" },
1184 { 0xa402,
"exif:ExposureMode" },
1185 { 0xa403,
"exif:WhiteBalance" },
1186 { 0xa404,
"exif:DigitalZoomRatio" },
1187 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1188 { 0xa406,
"exif:SceneCaptureType" },
1189 { 0xa407,
"exif:GainControl" },
1190 { 0xa408,
"exif:Contrast" },
1191 { 0xa409,
"exif:Saturation" },
1192 { 0xa40a,
"exif:Sharpness" },
1193 { 0xa40b,
"exif:DeviceSettingDescription" },
1194 { 0xa40c,
"exif:SubjectDistanceRange" },
1195 { 0xa420,
"exif:ImageUniqueID" },
1196 { 0xa430,
"exif:CameraOwnerName" },
1197 { 0xa431,
"exif:BodySerialNumber" },
1198 { 0xa432,
"exif:LensSpecification" },
1199 { 0xa433,
"exif:LensMake" },
1200 { 0xa434,
"exif:LensModel" },
1201 { 0xa435,
"exif:LensSerialNumber" },
1202 { 0xc4a5,
"exif:PrintImageMatching" },
1203 { 0xa500,
"exif:Gamma" },
1204 { 0xc640,
"exif:CR2Slice" },
1205 { 0x10000,
"exif:GPSVersionID" },
1206 { 0x10001,
"exif:GPSLatitudeRef" },
1207 { 0x10002,
"exif:GPSLatitude" },
1208 { 0x10003,
"exif:GPSLongitudeRef" },
1209 { 0x10004,
"exif:GPSLongitude" },
1210 { 0x10005,
"exif:GPSAltitudeRef" },
1211 { 0x10006,
"exif:GPSAltitude" },
1212 { 0x10007,
"exif:GPSTimeStamp" },
1213 { 0x10008,
"exif:GPSSatellites" },
1214 { 0x10009,
"exif:GPSStatus" },
1215 { 0x1000a,
"exif:GPSMeasureMode" },
1216 { 0x1000b,
"exif:GPSDop" },
1217 { 0x1000c,
"exif:GPSSpeedRef" },
1218 { 0x1000d,
"exif:GPSSpeed" },
1219 { 0x1000e,
"exif:GPSTrackRef" },
1220 { 0x1000f,
"exif:GPSTrack" },
1221 { 0x10010,
"exif:GPSImgDirectionRef" },
1222 { 0x10011,
"exif:GPSImgDirection" },
1223 { 0x10012,
"exif:GPSMapDatum" },
1224 { 0x10013,
"exif:GPSDestLatitudeRef" },
1225 { 0x10014,
"exif:GPSDestLatitude" },
1226 { 0x10015,
"exif:GPSDestLongitudeRef" },
1227 { 0x10016,
"exif:GPSDestLongitude" },
1228 { 0x10017,
"exif:GPSDestBearingRef" },
1229 { 0x10018,
"exif:GPSDestBearing" },
1230 { 0x10019,
"exif:GPSDestDistanceRef" },
1231 { 0x1001a,
"exif:GPSDestDistance" },
1232 { 0x1001b,
"exif:GPSProcessingMethod" },
1233 { 0x1001c,
"exif:GPSAreaInformation" },
1234 { 0x1001d,
"exif:GPSDateStamp" },
1235 { 0x1001e,
"exif:GPSDifferential" },
1236 { 0x1001f,
"exif:GPSHPositioningError" },
1248 directory_stack[MaxDirectoryStack] = { { 0, 0, 0 } };
1277 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1282 profile=GetImageProfile(image,
"exif");
1283 if (profile == (
const StringInfo *) NULL)
1284 return(MagickFalse);
1285 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1286 return(MagickFalse);
1287 while (isspace((
int) ((
unsigned char) *property)) != 0)
1289 if (strlen(property) <= 5)
1290 return(MagickFalse);
1293 switch (*(property+5))
1322 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1326 return(MagickFalse);
1333 for (i=(ssize_t) n-1L; i >= 0; i--)
1337 if ((c >=
'0') && (c <=
'9'))
1340 if ((c >=
'A') && (c <=
'F'))
1343 if ((c >=
'a') && (c <=
'f'))
1346 return(MagickFalse);
1348 }
while (*property !=
'\0');
1358 if (EXIFTag[i].tag == 0)
1360 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1362 tag=(size_t) EXIFTag[i].tag;
1370 return(MagickFalse);
1371 length=GetStringInfoLength(profile);
1373 return(MagickFalse);
1374 exif=GetStringInfoDatum(profile);
1377 if (ReadPropertyByte(&exif,&length) != 0x45)
1379 if (ReadPropertyByte(&exif,&length) != 0x78)
1381 if (ReadPropertyByte(&exif,&length) != 0x69)
1383 if (ReadPropertyByte(&exif,&length) != 0x66)
1385 if (ReadPropertyByte(&exif,&length) != 0x00)
1387 if (ReadPropertyByte(&exif,&length) != 0x00)
1392 return(MagickFalse);
1393 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1401 return(MagickFalse);
1402 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1403 return(MagickFalse);
1407 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1408 if ((offset < 0) || (
size_t) offset >= length)
1409 return(MagickFalse);
1414 directory=exif+offset;
1418 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1419 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1428 directory=directory_stack[level].directory;
1429 entry=directory_stack[level].entry;
1430 tag_offset=directory_stack[level].offset;
1432 if ((directory < exif) || (directory > (exif+length-2)))
1437 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1438 for ( ; entry < number_entries; entry++)
1451 q=(
unsigned char *) (directory+(12*entry)+2);
1452 if (q > (exif+length-12))
1454 if (GetValueFromSplayTree(exif_resources,q) == q)
1456 (void) AddValueToSplayTree(exif_resources,q,q);
1457 tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;
1458 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1459 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1463 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1466 number_bytes=(size_t) components*tag_bytes[format];
1467 if (number_bytes < components)
1469 if (number_bytes <= 4)
1479 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1480 if ((dir_offset < 0) || (
size_t) dir_offset >= length)
1482 if (((
size_t) dir_offset+number_bytes) < (
size_t) dir_offset)
1484 if (((
size_t) dir_offset+number_bytes) > length)
1486 p=(
unsigned char *) (exif+dir_offset);
1488 if ((all != 0) || (tag == (
size_t) tag_value))
1491 buffer[6*
sizeof(double)+MaxTextExtent],
1494 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1496 value=(
char *) NULL;
1502 value=(
char *) NULL;
1503 if (~((
size_t) number_bytes) >= 1)
1504 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1506 if (value != (
char *) NULL)
1508 for (i=0; i < (ssize_t) number_bytes; i++)
1511 if (isprint((
int) p[i]) != 0)
1512 value[i]=(char) p[i];
1518 case EXIF_FMT_SBYTE:
1520 EXIFMultipleValues(
"%.20g",(
double) (*(
signed char *) p));
1523 case EXIF_FMT_SSHORT:
1525 EXIFMultipleValues(
"%hd",ReadPropertySignedShort(endian,p));
1528 case EXIF_FMT_USHORT:
1530 EXIFMultipleValues(
"%hu",ReadPropertyUnsignedShort(endian,p));
1533 case EXIF_FMT_ULONG:
1535 EXIFMultipleValues(
"%.20g",(
double)
1536 ReadPropertyUnsignedLong(endian,p));
1539 case EXIF_FMT_SLONG:
1541 EXIFMultipleValues(
"%.20g",(
double)
1542 ReadPropertySignedLong(endian,p));
1545 case EXIF_FMT_URATIONAL:
1547 if ((tag_value == GPS_LATITUDE) || (tag_value == GPS_LONGITUDE) ||
1548 (tag_value == GPS_TIMESTAMP))
1551 EXIFGPSFractions(
"%.20g/%.20g,%.20g/%.20g,%.20g/%.20g",
1552 (
double) ReadPropertyUnsignedLong(endian,p),
1553 (
double) ReadPropertyUnsignedLong(endian,p+4),
1554 (
double) ReadPropertyUnsignedLong(endian,p+8),
1555 (
double) ReadPropertyUnsignedLong(endian,p+12),
1556 (
double) ReadPropertyUnsignedLong(endian,p+16),
1557 (
double) ReadPropertyUnsignedLong(endian,p+20));
1560 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1561 ReadPropertyUnsignedLong(endian,p),(
double)
1562 ReadPropertyUnsignedLong(endian,p+4));
1565 case EXIF_FMT_SRATIONAL:
1567 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1568 ReadPropertySignedLong(endian,p),(
double)
1569 ReadPropertySignedLong(endian,p+4));
1572 case EXIF_FMT_SINGLE:
1574 EXIFMultipleValues(
"%.20g",(
double)
1575 ReadPropertySignedLong(endian,p));
1578 case EXIF_FMT_DOUBLE:
1580 EXIFMultipleValues(
"%.20g",(
double)
1581 ReadPropertySignedLong(endian,p));
1584 case EXIF_FMT_STRING:
1585 case EXIF_FMT_UNDEFINED:
1588 if ((p < exif) || (p > (exif+length-number_bytes)))
1590 value=(
char *) NULL;
1591 if (~((
size_t) number_bytes) >= 1)
1592 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1594 if (value != (
char *) NULL)
1599 for (i=0; i < (ssize_t) number_bytes; i++)
1602 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1603 value[i]=(char) p[i];
1610 if (value != (
char *) NULL)
1618 key=AcquireString(property);
1629 description=
"unknown";
1632 if (EXIFTag[i].tag == 0)
1634 if (EXIFTag[i].tag == tag_value)
1636 description=EXIFTag[i].description;
1640 (void) FormatLocaleString(key,MaxTextExtent,
"%s",
1643 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1648 if (tag_value < 0x10000)
1649 (void) FormatLocaleString(key,MaxTextExtent,
"#%04lx",
1650 (
unsigned long) tag_value);
1652 if (tag_value < 0x20000)
1653 (void) FormatLocaleString(key,MaxTextExtent,
"@%04lx",
1654 (
unsigned long) (tag_value & 0xffff));
1656 (
void) FormatLocaleString(key,MaxTextExtent,
"unknown");
1662 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1665 p=(
const char *) NULL;
1666 if (image->properties != (
void *) NULL)
1667 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
1668 image->properties,key);
1669 if (p == (
const char *) NULL)
1670 (void) SetImageProperty((Image *) image,key,value);
1671 value=DestroyString(value);
1672 key=DestroyString(key);
1676 if ((tag_value == TAG_EXIF_OFFSET) ||
1677 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1682 offset=(ssize_t) ReadPropertySignedLong(endian,p);
1683 if (((
size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1688 tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1690 directory_stack[level].directory=directory;
1692 directory_stack[level].entry=entry;
1693 directory_stack[level].offset=tag_offset;
1698 for (i=0; i < level; i++)
1699 if (directory_stack[i].directory == (exif+tag_offset1))
1703 directory_stack[level].directory=exif+offset;
1704 directory_stack[level].offset=tag_offset1;
1705 directory_stack[level].entry=0;
1707 if ((directory+2+(12*number_entries)+4) > (exif+length))
1709 offset=(ssize_t) ReadPropertySignedLong(endian,directory+2+(12*
1711 if ((offset != 0) && ((
size_t) offset < length) &&
1712 (level < (MaxDirectoryStack-2)))
1714 directory_stack[level].directory=exif+offset;
1715 directory_stack[level].entry=0;
1716 directory_stack[level].offset=tag_offset1;
1723 }
while (level > 0);
1724 exif_resources=DestroySplayTree(exif_resources);
1728static MagickBooleanType GetICCProperty(
const Image *image)
1736 profile=GetImageProfile(image,
"icc");
1737 if (profile == (StringInfo *) NULL)
1738 profile=GetImageProfile(image,
"icm");
1739 if (profile == (StringInfo *) NULL)
1740 return(MagickFalse);
1741 if (GetStringInfoLength(profile) < 128)
1742 return(MagickFalse);
1743#if defined(MAGICKCORE_LCMS_DELEGATE)
1748 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1749 (cmsUInt32Number) GetStringInfoLength(profile));
1750 if (icc_profile != (cmsHPROFILE *) NULL)
1752#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1756 name=cmsTakeProductName(icc_profile);
1757 if (name != (
const char *) NULL)
1758 (void) SetImageProperty((Image *) image,
"icc:name",name);
1766 info=AcquireStringInfo(0);
1767 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1771 SetStringInfoLength(info,extent+1);
1772 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1773 "US",(
char *) GetStringInfoDatum(info),extent);
1775 (void) SetImageProperty((Image *) image,
"icc:description",
1776 (
char *) GetStringInfoDatum(info));
1778 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1782 SetStringInfoLength(info,extent+1);
1783 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1784 "US",(
char *) GetStringInfoDatum(info),extent);
1786 (void) SetImageProperty((Image *) image,
"icc:manufacturer",
1787 (
char *) GetStringInfoDatum(info));
1789 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1793 SetStringInfoLength(info,extent+1);
1794 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1795 (
char *) GetStringInfoDatum(info),extent);
1797 (void) SetImageProperty((Image *) image,
"icc:model",
1798 (
char *) GetStringInfoDatum(info));
1800 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1804 SetStringInfoLength(info,extent+1);
1805 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1806 "US",(
char *) GetStringInfoDatum(info),extent);
1808 (void) SetImageProperty((Image *) image,
"icc:copyright",
1809 (
char *) GetStringInfoDatum(info));
1811 info=DestroyStringInfo(info);
1813 (void) cmsCloseProfile(icc_profile);
1820static MagickBooleanType SkipXMPValue(
const char *value)
1822 if (value == (
const char*) NULL)
1824 while (*value !=
'\0')
1826 if (isspace((
int) ((
unsigned char) *value)) == 0)
1827 return(MagickFalse);
1833static MagickBooleanType GetXMPProperty(
const Image *image,
const char *property)
1860 profile=GetImageProfile(image,
"xmp");
1861 if (profile == (StringInfo *) NULL)
1862 return(MagickFalse);
1863 if (GetStringInfoLength(profile) < 17)
1864 return(MagickFalse);
1865 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1866 return(MagickFalse);
1867 xmp_profile=StringInfoToString(profile);
1868 if (xmp_profile == (
char *) NULL)
1869 return(MagickFalse);
1870 for (p=xmp_profile; *p !=
'\0'; p++)
1871 if ((*p ==
'<') && (*(p+1) ==
'x'))
1873 exception=AcquireExceptionInfo();
1874 xmp=NewXMLTree((
char *) p,exception);
1875 xmp_profile=DestroyString(xmp_profile);
1876 exception=DestroyExceptionInfo(exception);
1877 if (xmp == (XMLTreeInfo *) NULL)
1878 return(MagickFalse);
1880 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1881 if (rdf != (XMLTreeInfo *) NULL)
1883 if (image->properties == (
void *) NULL)
1884 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1885 RelinquishMagickMemory,RelinquishMagickMemory);
1886 description=GetXMLTreeChild(rdf,
"rdf:Description");
1887 while (description != (XMLTreeInfo *) NULL)
1889 node=GetXMLTreeChild(description,(
const char *) NULL);
1890 while (node != (XMLTreeInfo *) NULL)
1895 child=GetXMLTreeChild(node,(
const char *) NULL);
1896 content=GetXMLTreeContent(node);
1897 if ((child == (XMLTreeInfo *) NULL) &&
1898 (SkipXMPValue(content) == MagickFalse))
1900 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1901 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1902 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1903 xmp_namespace,ConstantString(content));
1905 while (child != (XMLTreeInfo *) NULL)
1907 content=GetXMLTreeContent(child);
1908 if (SkipXMPValue(content) == MagickFalse)
1910 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1911 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1912 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1913 xmp_namespace,ConstantString(content));
1915 child=GetXMLTreeSibling(child);
1917 node=GetXMLTreeSibling(node);
1919 description=GetNextXMLTreeTag(description);
1922 xmp=DestroyXMLTree(xmp);
1926static char *TracePSClippath(
const unsigned char *blob,
size_t length,
1927 const size_t magick_unused(columns),
const size_t magick_unused(rows))
1950 magick_unreferenced(columns);
1951 magick_unreferenced(rows);
1953 path=AcquireString((
char *) NULL);
1954 if (path == (
char *) NULL)
1955 return((
char *) NULL);
1956 message=AcquireString((
char *) NULL);
1957 (void) FormatLocaleString(message,MaxTextExtent,
"/ClipImage\n");
1958 (void) ConcatenateString(&path,message);
1959 (void) FormatLocaleString(message,MaxTextExtent,
"{\n");
1960 (void) ConcatenateString(&path,message);
1961 (void) FormatLocaleString(message,MaxTextExtent,
" /c {curveto} bind def\n");
1962 (void) ConcatenateString(&path,message);
1963 (void) FormatLocaleString(message,MaxTextExtent,
" /l {lineto} bind def\n");
1964 (void) ConcatenateString(&path,message);
1965 (void) FormatLocaleString(message,MaxTextExtent,
" /m {moveto} bind def\n");
1966 (void) ConcatenateString(&path,message);
1967 (void) FormatLocaleString(message,MaxTextExtent,
1968 " /v {currentpoint 6 2 roll curveto} bind def\n");
1969 (void) ConcatenateString(&path,message);
1970 (void) FormatLocaleString(message,MaxTextExtent,
1971 " /y {2 copy curveto} bind def\n");
1972 (void) ConcatenateString(&path,message);
1973 (void) FormatLocaleString(message,MaxTextExtent,
1974 " /z {closepath} bind def\n");
1975 (void) ConcatenateString(&path,message);
1976 (void) FormatLocaleString(message,MaxTextExtent,
" newpath\n");
1977 (void) ConcatenateString(&path,message);
1982 (void) memset(point,0,
sizeof(point));
1983 (void) memset(first,0,
sizeof(first));
1984 (void) memset(last,0,
sizeof(last));
1986 in_subpath=MagickFalse;
1989 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
1995 if (knot_count != 0)
1998 length-=MagickMin(24,(ssize_t) length);
2004 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2006 length-=MagickMin(22,(ssize_t) length);
2014 if (knot_count == 0)
2020 length-=MagickMin(24,(ssize_t) length);
2026 for (i=0; i < 3; i++)
2028 y=(size_t) ReadPropertyMSBLong(&blob,&length);
2029 x=(size_t) ReadPropertyMSBLong(&blob,&length);
2030 point[i].x=(double) x/4096.0/4096.0;
2031 point[i].y=1.0-(double) y/4096.0/4096.0;
2033 if (in_subpath == MagickFalse)
2035 (void) FormatLocaleString(message,MaxTextExtent,
" %g %g m\n",
2036 point[1].x,point[1].y);
2037 for (i=0; i < 3; i++)
2049 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2050 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2051 (void) FormatLocaleString(message,MaxTextExtent,
2052 " %g %g l\n",point[1].x,point[1].y);
2054 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2055 (void) FormatLocaleString(message,MaxTextExtent,
2056 " %g %g %g %g v\n",point[0].x,point[0].y,
2057 point[1].x,point[1].y);
2059 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2060 (void) FormatLocaleString(message,MaxTextExtent,
2061 " %g %g %g %g y\n",last[2].x,last[2].y,
2062 point[1].x,point[1].y);
2064 (
void) FormatLocaleString(message,MaxTextExtent,
2065 " %g %g %g %g %g %g c\n",last[2].x,
2066 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2067 for (i=0; i < 3; i++)
2070 (void) ConcatenateString(&path,message);
2071 in_subpath=MagickTrue;
2076 if (knot_count == 0)
2082 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2083 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2084 (void) FormatLocaleString(message,MaxTextExtent,
2085 " %g %g l z\n",first[1].x,first[1].y);
2087 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2088 (void) FormatLocaleString(message,MaxTextExtent,
2089 " %g %g %g %g v z\n",first[0].x,first[0].y,
2090 first[1].x,first[1].y);
2092 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2093 (void) FormatLocaleString(message,MaxTextExtent,
2094 " %g %g %g %g y z\n",last[2].x,last[2].y,
2095 first[1].x,first[1].y);
2097 (
void) FormatLocaleString(message,MaxTextExtent,
2098 " %g %g %g %g %g %g c z\n",last[2].x,
2099 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2100 (void) ConcatenateString(&path,message);
2101 in_subpath=MagickFalse;
2111 length-=MagickMin(24,(ssize_t) length);
2119 (void) FormatLocaleString(message,MaxTextExtent,
" eoclip\n");
2120 (void) ConcatenateString(&path,message);
2121 (void) FormatLocaleString(message,MaxTextExtent,
"} bind def");
2122 (void) ConcatenateString(&path,message);
2123 message=DestroyString(message);
2127static inline void TraceBezierCurve(
char *message,PointInfo *last,
2134 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2135 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2136 (void) FormatLocaleString(message,MagickPathExtent,
2137 "L %g %g\n",point[1].x,point[1].y);
2139 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2140 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2143static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2144 const size_t columns,
const size_t rows)
2167 path=AcquireString((
char *) NULL);
2168 if (path == (
char *) NULL)
2169 return((
char *) NULL);
2170 message=AcquireString((
char *) NULL);
2171 (void) FormatLocaleString(message,MaxTextExtent,(
2172 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2173 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2174 " width=\"%.20g\" height=\"%.20g\">\n"
2176 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2177 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(
double) columns,
2179 (void) ConcatenateString(&path,message);
2180 (void) memset(point,0,
sizeof(point));
2181 (void) memset(first,0,
sizeof(first));
2182 (void) memset(last,0,
sizeof(last));
2184 in_subpath=MagickFalse;
2187 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2193 if (knot_count != 0)
2196 length-=MagickMin(24,(ssize_t) length);
2202 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2204 length-=MagickMin(22,(ssize_t) length);
2212 if (knot_count == 0)
2218 length-=MagickMin(24,(ssize_t) length);
2224 for (i=0; i < 3; i++)
2226 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2227 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2228 point[i].x=(double) x*columns/4096.0/4096.0;
2229 point[i].y=(double) y*rows/4096.0/4096.0;
2231 if (in_subpath == MagickFalse)
2233 (void) FormatLocaleString(message,MaxTextExtent,
"M %g %g\n",
2234 point[1].x,point[1].y);
2235 for (i=0; i < 3; i++)
2243 TraceBezierCurve(message,last,point);
2244 for (i=0; i < 3; i++)
2247 (void) ConcatenateString(&path,message);
2248 in_subpath=MagickTrue;
2253 if (knot_count == 0)
2255 TraceBezierCurve(message,last,first);
2256 (void) ConcatenateString(&path,message);
2257 in_subpath=MagickFalse;
2267 length-=MagickMin(24,(ssize_t) length);
2275 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2276 message=DestroyString(message);
2280MagickExport
const char *GetImageProperty(
const Image *image,
2281 const char *property)
2298 assert(image != (Image *) NULL);
2299 assert(image->signature == MagickCoreSignature);
2300 if (IsEventLogging() != MagickFalse)
2301 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2302 p=(
const char *) NULL;
2303 if (image->properties != (
void *) NULL)
2305 if (property == (
const char *) NULL)
2307 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
2308 p=(
const char *) GetNextValueInSplayTree((SplayTreeInfo *)
2312 if (LocaleNCompare(
"fx:",property,3) != 0)
2314 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2315 image->properties,property);
2316 if (p != (
const char *) NULL)
2320 if ((property == (
const char *) NULL) ||
2321 (strchr(property,
':') == (
char *) NULL))
2323 exception=(&((Image *) image)->exception);
2328 if (LocaleNCompare(
"8bim:",property,5) == 0)
2330 (void) Get8BIMProperty(image,property);
2338 if (LocaleNCompare(
"exif:",property,5) == 0)
2340 (void) GetEXIFProperty(image,property);
2348 if (LocaleNCompare(
"fx:",property,3) == 0)
2350 if ((image->columns == 0) || (image->rows == 0))
2352 fx_info=AcquireFxInfo(image,property+3);
2353 status=FxEvaluateChannelExpression(fx_info,DefaultChannels,0,0,&alpha,
2355 fx_info=DestroyFxInfo(fx_info);
2356 if (status != MagickFalse)
2359 value[MaxTextExtent];
2361 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
2362 GetMagickPrecision(),(
double) alpha);
2363 (void) SetImageProperty((Image *) image,property,value);
2372 if (LocaleNCompare(
"hex:",property,4) == 0)
2377 if ((image->columns == 0) || (image->rows == 0))
2379 GetMagickPixelPacket(image,&pixel);
2380 fx_info=AcquireFxInfo(image,property+4);
2381 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2383 pixel.red=(MagickRealType) QuantumRange*alpha;
2384 status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2386 pixel.green=(MagickRealType) QuantumRange*alpha;
2387 status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2389 pixel.blue=(MagickRealType) QuantumRange*alpha;
2390 status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2392 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2393 if (image->colorspace == CMYKColorspace)
2395 status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2397 pixel.index=(MagickRealType) QuantumRange*alpha;
2399 fx_info=DestroyFxInfo(fx_info);
2400 if (status != MagickFalse)
2405 GetColorTuple(&pixel,MagickTrue,hex);
2406 (void) SetImageProperty((Image *) image,property,hex+1);
2415 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2416 (LocaleNCompare(
"icm:",property,4) == 0))
2418 (void) GetICCProperty(image);
2421 if (LocaleNCompare(
"iptc:",property,5) == 0)
2423 (void) GetIPTCProperty(image,property);
2431 if (LocaleNCompare(
"pixel:",property,6) == 0)
2436 GetMagickPixelPacket(image,&pixel);
2437 fx_info=AcquireFxInfo(image,property+6);
2438 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2440 pixel.red=(MagickRealType) QuantumRange*alpha;
2441 status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2443 pixel.green=(MagickRealType) QuantumRange*alpha;
2444 status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2446 pixel.blue=(MagickRealType) QuantumRange*alpha;
2447 status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2449 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2450 if (image->colorspace == CMYKColorspace)
2452 status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2454 pixel.index=(MagickRealType) QuantumRange*alpha;
2456 fx_info=DestroyFxInfo(fx_info);
2457 if (status != MagickFalse)
2460 name[MaxTextExtent];
2465 GetColorTuple(&pixel,MagickFalse,name);
2466 value=GetImageArtifact(image,
"pixel:compliance");
2467 if (value != (
char *) NULL)
2469 ComplianceType compliance=(ComplianceType) ParseCommandOption(
2470 MagickComplianceOptions,MagickFalse,value);
2471 (void) QueryMagickColorname(image,&pixel,compliance,name,
2474 (void) SetImageProperty((Image *) image,property,name);
2483 if (LocaleNCompare(
"xmp:",property,4) == 0)
2485 (void) GetXMPProperty(image,property);
2493 if (image->properties != (
void *) NULL)
2495 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2496 image->properties,property);
2499 return((
const char *) NULL);
2588static const char *GetMagickPropertyLetter(
const ImageInfo *image_info,
2589 Image *image,
const char letter)
2591#define WarnNoImageInfoReturn(format,arg) \
2592 if (image_info == (ImageInfo *) NULL ) { \
2593 (void) ThrowMagickException(&image->exception,GetMagickModule(), \
2594 OptionWarning,"NoImageInfoForProperty",format,arg); \
2595 return((const char *) NULL); \
2599 value[MaxTextExtent];
2604 assert(image != (Image *) NULL);
2605 assert(image->signature == MagickCoreSignature);
2606 if (IsEventLogging() != MagickFalse)
2607 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2609 string=(
char *) NULL;
2617 (void) FormatMagickSize(image->extent,MagickFalse,value);
2618 if (image->extent == 0)
2619 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,value);
2627 string=GetImageProperty(image,
"comment");
2628 if (
string == (
const char *) NULL)
2637 GetPathComponent(image->magick_filename,HeadPath,value);
2647 GetPathComponent(image->magick_filename,ExtensionPath,value);
2657 GetPathComponent(image->magick_filename,TailPath,value);
2667 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g%+.20g%+.20g",
2668 (
double) image->page.width,(
double) image->page.height,
2669 (
double) image->page.x,(
double) image->page.y);
2677 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2678 (image->rows != 0 ? image->rows : image->magick_rows));
2686 string=image->filename;
2694 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2695 GetNumberColors(image,(FILE *) NULL,&image->exception));
2703 string=GetImageProperty(image,
"label");
2704 if (
string == (
const char *) NULL)
2713 string=image->magick;
2721 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2722 GetImageListLength(image));
2730 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2731 string=image_info->filename;
2739 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2740 GetImageIndexInList(image));
2748 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2749 MAGICKCORE_QUANTUM_DEPTH);
2760 colorspace=image->colorspace;
2761 if ((image->columns != 0) && (image->rows != 0) &&
2762 (SetImageGray(image,&image->exception) != MagickFalse))
2763 colorspace=GRAYColorspace;
2764 (void) FormatLocaleString(value,MaxTextExtent,
"%s %s %s",
2765 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2766 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2767 (ssize_t) colorspace),image->matte != MagickFalse ?
"Matte" :
"" );
2775 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2776 if (image_info->number_scenes != 0)
2777 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2780 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2789 GetPathComponent(image->magick_filename,BasePath,value);
2799 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2800 string=image_info->unique;
2808 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2809 (image->columns != 0 ? image->columns : image->magick_columns));
2817 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
2818 fabs(image->x_resolution) > MagickEpsilon ? image->x_resolution :
2819 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2828 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
2829 fabs(image->y_resolution) > MagickEpsilon ? image->y_resolution :
2830 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2839 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2848 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2849 CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->matte));
2857 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2859 if (image->extent == 0)
2860 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2861 GetBlobSize(image));
2869 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2870 CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2871 image->compression));
2879 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2880 CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t) image->dispose));
2893 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
2894 "$-_.+!*'(),{}|\\^~[]`\"><#%;/?:@&=";
2899 (void) CopyMagickString(value,image->magick_filename,MaxTextExtent);
2901 q=value+strlen(value);
2902 for (p+=strspn(p,allowlist); p != q; p+=(ptrdiff_t) strspn(p,allowlist))
2911 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
2912 image->magick_columns,(
double) image->magick_rows);
2920 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2921 image->page.height);
2929 string=image->magick_filename;
2934 if ((image != (Image *) NULL) && (image->next == (Image *) NULL))
2935 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2936 GetImageListLength(image));
2946 (void) FormatLocaleString(value,MaxTextExtent,
"%+ld%+ld",(
long)
2947 image->page.x,(
long) image->page.y);
2955 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
2956 image->page.width,(
double) image->page.height);
2964 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2965 (image->quality == 0 ? 92 : image->quality));
2973 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2974 if (image_info->number_scenes == 0)
2975 string=
"2147483647";
2977 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2978 image_info->scene+image_info->number_scenes);
2986 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2995 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2996 CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3005 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3014 (void) FormatLocaleString(value,MaxTextExtent,
"%+.20g",(
double)
3023 (void) FormatLocaleString(value,MaxTextExtent,
"%+.20g",(
double)
3032 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
3033 string=image_info->zero;
3044 page=GetImageBoundingBox(image,&image->exception);
3045 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g%+.20g%+.20g",
3046 (
double) page.width,(
double) page.height,(
double) page.x,(
double)
3055 if ((image->columns != 0) && (image->rows != 0))
3056 (void) SignatureImage(image);
3057 string=GetImageProperty(image,
"signature");
3071 if (
string != (
char *) NULL)
3073 (void) SetImageArtifact(image,
"get-property",
string);
3074 return(GetImageArtifact(image,
"get-property"));
3076 return((
char *) NULL);
3079MagickExport
const char *GetMagickProperty(
const ImageInfo *image_info,
3080 Image *image,
const char *property)
3083 value[MaxTextExtent];
3088 assert(property != (
const char *) NULL);
3089 assert(property[0] !=
'\0');
3090 if (property[1] ==
'\0')
3091 return(GetMagickPropertyLetter(image_info,image,*property));
3093 string=(
char *) NULL;
3098 if ((LocaleCompare(
"base",property) == 0) ||
3099 (LocaleCompare(
"basename",property) == 0) )
3101 GetPathComponent(image->magick_filename,BasePath,value);
3104 if (LocaleCompare(
"bit-depth",property) == 0)
3106 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3107 GetImageDepth(image,&image->exception));
3110 if (LocaleCompare(
"bounding-box",property) == 0)
3115 geometry=GetImageBoundingBox(image,&image->exception);
3116 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g\n",
3117 (
double) geometry.x,(
double) geometry.y,
3118 (
double) geometry.x+geometry.width,
3119 (
double) geometry.y+geometry.height);
3126 if (LocaleCompare(
"channels",property) == 0)
3131 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
3132 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
3133 image->colorspace));
3135 if (image->matte != MagickFalse)
3136 (void) ConcatenateMagickString(value,
"a",MaxTextExtent);
3139 if (LocaleCompare(
"colors",property) == 0)
3141 image->colors=GetNumberColors(image,(FILE *) NULL,&image->exception);
3142 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3146 if (LocaleCompare(
"colorspace",property) == 0)
3148 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
3152 if (LocaleCompare(
"compose",property) == 0)
3154 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
3158 if (LocaleCompare(
"compression",property) == 0)
3160 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
3161 image->compression);
3164 if (LocaleCompare(
"copyright",property) == 0)
3166 (void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
3173 if (LocaleCompare(
"depth",property) == 0)
3175 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3179 if (LocaleCompare(
"directory",property) == 0)
3181 GetPathComponent(image->magick_filename,HeadPath,value);
3188 if (LocaleCompare(
"entropy",property) == 0)
3193 (void) GetImageChannelEntropy(image,image_info->channel,&entropy,
3195 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3196 GetMagickPrecision(),entropy);
3199 if (LocaleCompare(
"extension",property) == 0)
3201 GetPathComponent(image->magick_filename,ExtensionPath,value);
3208 if (LocaleCompare(
"gamma",property) == 0)
3210 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3211 GetMagickPrecision(),image->gamma);
3214 if ((image_info != (ImageInfo *) NULL) &&
3215 (LocaleCompare(
"group",property) == 0))
3217 (void) FormatLocaleString(value,MaxTextExtent,
"0x%lx",(
unsigned long)
3225 if (LocaleCompare(
"height",property) == 0)
3227 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3228 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3235 if (LocaleCompare(
"input",property) == 0)
3237 string=image->filename;
3240 if (LocaleCompare(
"interlace",property) == 0)
3242 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3250 if (LocaleCompare(
"kurtosis",property) == 0)
3256 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
3257 &skewness,&image->exception);
3258 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3259 GetMagickPrecision(),kurtosis);
3266 if (LocaleCompare(
"magick",property) == 0)
3268 string=image->magick;
3271 if ((LocaleCompare(
"max",property) == 0) ||
3272 (LocaleCompare(
"maxima",property) == 0))
3278 (void) GetImageChannelRange(image,image_info->channel,&minimum,
3279 &maximum,&image->exception);
3280 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3281 GetMagickPrecision(),maximum);
3284 if (LocaleCompare(
"mean",property) == 0)
3290 (void) GetImageChannelMean(image,image_info->channel,&mean,
3291 &standard_deviation,&image->exception);
3292 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3293 GetMagickPrecision(),mean);
3296 if ((LocaleCompare(
"min",property) == 0) ||
3297 (LocaleCompare(
"minima",property) == 0))
3303 (void) GetImageChannelRange(image,image_info->channel,&minimum,
3304 &maximum,&image->exception);
3305 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3306 GetMagickPrecision(),minimum);
3313 if (LocaleCompare(
"opaque",property) == 0)
3318 opaque=IsOpaqueImage(image,&image->exception);
3319 (void) CopyMagickString(value,opaque != MagickFalse ?
"true" :
3320 "false",MaxTextExtent);
3323 if (LocaleCompare(
"orientation",property) == 0)
3325 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3326 image->orientation);
3329 if ((image_info != (ImageInfo *) NULL) &&
3330 (LocaleCompare(
"output",property) == 0))
3332 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
3339 if (LocaleCompare(
"page",property) == 0)
3341 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
3342 image->page.width,(
double) image->page.height);
3345 if (LocaleNCompare(
"papersize:",property,10) == 0)
3351 papersize=GetPageGeometry(property+10);
3352 if (papersize != (
const char *) NULL)
3355 page = { 0, 0, 0, 0 };
3357 (void) ParseAbsoluteGeometry(papersize,&page);
3358 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",
3359 (
double) page.width,(
double) page.height);
3360 papersize=DestroyString(papersize);
3364#if defined(MAGICKCORE_LCMS_DELEGATE)
3365 if (LocaleCompare(
"profile:icc",property) == 0 ||
3366 LocaleCompare(
"profile:icm",property) == 0)
3368#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3369#define cmsUInt32Number DWORD
3378 profile=GetImageProfile(image,property+8);
3379 if (profile == (StringInfo *) NULL)
3382 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3383 (cmsUInt32Number) GetStringInfoLength(profile));
3384 if (icc_profile != (cmsHPROFILE *) NULL)
3386#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3387 string=cmsTakeProductName(icc_profile);
3389 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3390 "en",
"US",value,MaxTextExtent);
3392 (void) cmsCloseProfile(icc_profile);
3396 if (LocaleCompare(
"printsize.x",property) == 0)
3398 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3399 GetMagickPrecision(),MagickSafeReciprocal(image->x_resolution)*
3403 if (LocaleCompare(
"printsize.y",property) == 0)
3405 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3406 GetMagickPrecision(),MagickSafeReciprocal(image->y_resolution)*
3410 if (LocaleCompare(
"profiles",property) == 0)
3415 ResetImageProfileIterator(image);
3416 name=GetNextImageProfile(image);
3417 if (name != (
char *) NULL)
3419 (void) CopyMagickString(value,name,MaxTextExtent);
3420 name=GetNextImageProfile(image);
3421 while (name != (
char *) NULL)
3423 ConcatenateMagickString(value,
",",MaxTextExtent);
3424 ConcatenateMagickString(value,name,MaxTextExtent);
3425 name=GetNextImageProfile(image);
3434 if (LocaleCompare(
"quality",property) == 0)
3436 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3444 if (LocaleCompare(
"rendering-intent",property) == 0)
3446 string=CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
3447 image->rendering_intent);
3450 if (LocaleCompare(
"resolution.x",property) == 0)
3452 (void) FormatLocaleString(value,MaxTextExtent,
"%g",
3453 image->x_resolution);
3456 if (LocaleCompare(
"resolution.y",property) == 0)
3458 (void) FormatLocaleString(value,MaxTextExtent,
"%g",
3459 image->y_resolution);
3466 if (LocaleCompare(
"scene",property) == 0)
3468 if ((image_info != (ImageInfo *) NULL) &&
3469 (image_info->number_scenes != 0))
3470 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3473 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3477 if (LocaleCompare(
"scenes",property) == 0)
3479 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3480 GetImageListLength(image));
3483 if (LocaleCompare(
"size",property) == 0)
3485 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,value);
3488 if (LocaleCompare(
"skewness",property) == 0)
3494 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
3495 &skewness,&image->exception);
3496 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3497 GetMagickPrecision(),skewness);
3500 if ((LocaleCompare(
"standard-deviation",property) == 0) ||
3501 (LocaleCompare(
"standard_deviation",property) == 0))
3507 (void) GetImageChannelMean(image,image_info->channel,&mean,
3508 &standard_deviation,&image->exception);
3509 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3510 GetMagickPrecision(),standard_deviation);
3517 if (LocaleCompare(
"type",property) == 0)
3519 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3520 IdentifyImageType(image,&image->exception));
3527 if ((image_info != (ImageInfo *) NULL) &&
3528 (LocaleCompare(
"unique",property) == 0))
3530 string=image_info->unique;
3533 if (LocaleCompare(
"units",property) == 0)
3538 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3546 if (LocaleCompare(
"version",property) == 0)
3548 string=GetMagickVersion((
size_t *) NULL);
3555 if (LocaleCompare(
"width",property) == 0)
3557 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3558 (image->magick_columns != 0 ? image->magick_columns : 256));
3565 if ((LocaleCompare(
"xresolution",property) == 0) ||
3566 (LocaleCompare(
"x-resolution",property) == 0) )
3568 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3569 image->x_resolution);
3576 if ((LocaleCompare(
"yresolution",property) == 0) ||
3577 (LocaleCompare(
"y-resolution",property) == 0) )
3579 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3580 image->y_resolution);
3587 if ((image_info != (ImageInfo *) NULL) &&
3588 (LocaleCompare(
"zero",property) == 0))
3590 string=image_info->zero;
3598 if (
string != (
char *) NULL)
3600 (void) SetImageArtifact(image,
"get-property",
string);
3601 return(GetImageArtifact(image,
"get-property"));
3603 return((
char *) NULL);
3628MagickExport
char *GetNextImageProperty(
const Image *image)
3630 assert(image != (Image *) NULL);
3631 assert(image->signature == MagickCoreSignature);
3632 if (IsEventLogging() != MagickFalse)
3633 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3635 if (image->properties == (
void *) NULL)
3636 return((
char *) NULL);
3637 return((
char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3692MagickExport
char *InterpretImageProperties(
const ImageInfo *image_info,
3693 Image *image,
const char *embed_text)
3695#define ExtendInterpretText(string_length) \
3697 size_t length=(string_length); \
3698 if ((size_t) (q-interpret_text+length+1) >= extent) \
3701 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3702 MaxTextExtent,sizeof(*interpret_text)); \
3703 if (interpret_text == (char *) NULL) \
3705 if (property_info != image_info) \
3706 property_info=DestroyImageInfo(property_info); \
3707 return((char *) NULL); \
3709 q=interpret_text+strlen(interpret_text); \
3713#define AppendKeyValue2Text(key,value)\
3715 size_t length=strlen(key)+strlen(value)+2; \
3716 if ((size_t) (q-interpret_text+length+1) >= extent) \
3719 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3720 MaxTextExtent,sizeof(*interpret_text)); \
3721 if (interpret_text == (char *) NULL) \
3723 if (property_info != image_info) \
3724 property_info=DestroyImageInfo(property_info); \
3725 return((char *) NULL); \
3727 q=interpret_text+strlen(interpret_text); \
3729 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3732#define AppendString2Text(string) \
3734 size_t length=strlen((string)); \
3735 if ((size_t) (q-interpret_text+length+1) >= extent) \
3738 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3739 MaxTextExtent,sizeof(*interpret_text)); \
3740 if (interpret_text == (char *) NULL) \
3742 if (property_info != image_info) \
3743 property_info=DestroyImageInfo(property_info); \
3744 return((char *) NULL); \
3746 q=interpret_text+strlen(interpret_text); \
3748 (void) CopyMagickString(q,(string),extent); \
3749 q+=(ptrdiff_t) length; \
3770 assert(image != (Image *) NULL);
3771 assert(image->signature == MagickCoreSignature);
3772 if (IsEventLogging() != MagickFalse)
3773 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3774 if (embed_text == (
const char *) NULL)
3775 return(ConstantString(
""));
3777 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3780 return(ConstantString(
""));
3781 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3786 if (IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,p) == MagickFalse)
3789 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3790 PolicyError,
"NotAuthorized",
"`%s'",p);
3791 return(ConstantString(
""));
3793 interpret_text=FileToString(p,~0UL,&image->exception);
3794 if (interpret_text != (
char *) NULL)
3795 return(interpret_text);
3800 if (image_info != (ImageInfo *) NULL)
3801 property_info=(ImageInfo *) image_info;
3803 property_info=CloneImageInfo(image_info);
3804 interpret_text=AcquireString(embed_text);
3805 extent=MaxTextExtent;
3807 for (q=interpret_text; *p!=
'\0';
3808 number=(isdigit((
int) ((
unsigned char) *p))) ? MagickTrue : MagickFalse,p++)
3814 ExtendInterpretText(MaxTextExtent);
3857 if (LocaleNCompare(
"<",p,4) == 0)
3863 if (LocaleNCompare(
">",p,4) == 0)
3869 if (LocaleNCompare(
"&",p,5) == 0)
3890 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3906 if (number != MagickFalse)
3912 value=GetMagickPropertyLetter(property_info,image,*p);
3913 if (value != (
char *) NULL)
3915 AppendString2Text(value);
3918 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3919 OptionWarning,
"UnknownImageProperty",
"\"%%%c\"",*p);
3924 pattern[2*MaxTextExtent] =
"\0";
3943 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3944 OptionWarning,
"UnknownImageProperty",
"\"%%[]\"");
3947 for (len=0; len<(MaxTextExtent-1L) && (*p !=
'\0');)
3949 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3954 pattern[len++]=(*p++);
3955 pattern[len++]=(*p++);
3964 pattern[len++]=(*p++);
3979 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3980 OptionError,
"UnbalancedBraces",
"\"%%[%s\"",pattern);
3981 interpret_text=DestroyString(interpret_text);
3982 if (property_info != image_info)
3983 property_info=DestroyImageInfo(property_info);
3984 return((
char *) NULL);
3989 if (LocaleNCompare(
"fx:",pattern,3) == 0)
4003 fx_info=AcquireFxInfo(image,pattern+3);
4004 status=FxEvaluateChannelExpression(fx_info,property_info->channel,0,0,
4005 &value,&image->exception);
4006 fx_info=DestroyFxInfo(fx_info);
4007 if (status != MagickFalse)
4010 result[MagickPathExtent];
4012 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
4013 GetMagickPrecision(),(
double) value);
4014 AppendString2Text(result);
4018 if (LocaleNCompare(
"option:",pattern,7) == 0)
4023 if (IsGlob(pattern+7) != MagickFalse)
4025 ResetImageOptionIterator(property_info);
4026 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4027 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4029 value=GetImageOption(property_info,key);
4030 if (value != (
const char *) NULL)
4031 AppendKeyValue2Text(key,value);
4036 value=GetImageOption(property_info,pattern+7);
4037 if (value != (
char *) NULL)
4038 AppendString2Text(value);
4042 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4047 if (IsGlob(pattern+9) != MagickFalse)
4049 ResetImageArtifactIterator(image);
4050 while ((key=GetNextImageArtifact(image)) != (
const char *) NULL)
4051 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4053 value=GetImageArtifact(image,key);
4054 if (value != (
const char *) NULL)
4055 AppendKeyValue2Text(key,value);
4060 value=GetImageArtifact(image,pattern+9);
4061 if (value != (
char *) NULL)
4062 AppendString2Text(value);
4072 value=GetImageProperty(image,pattern);
4073 if (value != (
const char *) NULL)
4075 AppendString2Text(value);
4082 if (IsGlob(pattern) != MagickFalse)
4084 ResetImagePropertyIterator(image);
4085 while ((key=GetNextImageProperty(image)) != (
const char *) NULL)
4086 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4088 value=GetImageProperty(image,key);
4089 if (value != (
const char *) NULL)
4090 AppendKeyValue2Text(key,value);
4100 value=GetMagickProperty(property_info,image,pattern);
4101 if (value != (
const char *) NULL)
4103 AppendString2Text(value);
4109 value=GetImageArtifact(image,pattern);
4110 if (value != (
char *) NULL)
4112 AppendString2Text(value);
4118 value=GetImageOption(property_info,pattern);
4119 if (value != (
char *) NULL)
4121 AppendString2Text(value);
4134 (void) ThrowMagickException(&image->exception,GetMagickModule(),
4135 OptionWarning,
"UnknownImageProperty",
"\"%%[%s]\"",pattern);
4140 if (property_info != image_info)
4141 property_info=DestroyImageInfo(property_info);
4142 return(interpret_text);
4173MagickExport
char *RemoveImageProperty(Image *image,
const char *property)
4178 assert(image != (Image *) NULL);
4179 assert(image->signature == MagickCoreSignature);
4180 if (IsEventLogging() != MagickFalse)
4181 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4183 if (image->properties == (
void *) NULL)
4184 return((
char *) NULL);
4185 value=(
char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
4214MagickExport
void ResetImagePropertyIterator(
const Image *image)
4216 assert(image != (Image *) NULL);
4217 assert(image->signature == MagickCoreSignature);
4218 if (IsEventLogging() != MagickFalse)
4219 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4221 if (image->properties == (
void *) NULL)
4223 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
4254MagickExport MagickBooleanType SetImageProperty(Image *image,
4255 const char *property,
const char *value)
4270 assert(image != (Image *) NULL);
4271 assert(image->signature == MagickCoreSignature);
4272 if (IsEventLogging() != MagickFalse)
4273 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4275 if (image->properties == (
void *) NULL)
4276 image->properties=NewSplayTree(CompareSplayTreeString,
4277 RelinquishMagickMemory,RelinquishMagickMemory);
4278 if (value == (
const char *) NULL)
4279 return(DeleteImageProperty(image,property));
4280 exception=(&image->exception);
4281 property_length=strlen(property);
4282 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4283 (*(property+(property_length-1)) ==
'*'))
4285 (void) ThrowMagickException(exception,GetMagickModule(),
4286 OptionWarning,
"SetReadOnlyProperty",
"`%s'",property);
4287 return(MagickFalse);
4302 if (LocaleCompare(
"background",property) == 0)
4304 (void) QueryColorDatabase(value,&image->background_color,exception);
4307 if (LocaleCompare(
"bias",property) == 0)
4309 image->bias=StringToDoubleInterval(value,(
double) QuantumRange+1.0);
4312 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4313 ConstantString(property),ConstantString(value));
4319 if (LocaleCompare(
"colorspace",property) == 0)
4324 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4328 status=SetImageColorspace(image,(ColorspaceType) colorspace);
4331 if (LocaleCompare(
"compose",property) == 0)
4336 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4339 image->compose=(CompositeOperator) compose;
4342 if (LocaleCompare(
"compress",property) == 0)
4347 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4349 if (compression < 0)
4351 image->compression=(CompressionType) compression;
4354 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4355 ConstantString(property),ConstantString(value));
4361 if (LocaleCompare(
"delay",property) == 0)
4366 flags=ParseGeometry(value,&geometry_info);
4367 if ((flags & GreaterValue) != 0)
4369 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4370 image->delay=(size_t) floor(geometry_info.rho+0.5);
4373 if ((flags & LessValue) != 0)
4375 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4376 image->ticks_per_second=CastDoubleToLong(
4377 floor(geometry_info.sigma+0.5));
4380 image->delay=(size_t) floor(geometry_info.rho+0.5);
4381 if ((flags & SigmaValue) != 0)
4382 image->ticks_per_second=CastDoubleToLong(floor(
4383 geometry_info.sigma+0.5));
4386 if (LocaleCompare(
"density",property) == 0)
4391 flags=ParseGeometry(value,&geometry_info);
4392 if ((flags & RhoValue) != 0)
4393 image->x_resolution=geometry_info.rho;
4394 image->y_resolution=image->x_resolution;
4395 if ((flags & SigmaValue) != 0)
4396 image->y_resolution=geometry_info.sigma;
4398 if (LocaleCompare(
"depth",property) == 0)
4400 image->depth=StringToUnsignedLong(value);
4403 if (LocaleCompare(
"dispose",property) == 0)
4408 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4411 image->dispose=(DisposeType) dispose;
4414 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4415 ConstantString(property),ConstantString(value));
4421 if (LocaleCompare(
"gamma",property) == 0)
4423 image->gamma=StringToDouble(value,(
char **) NULL);
4426 if (LocaleCompare(
"gravity",property) == 0)
4431 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4434 image->gravity=(GravityType) gravity;
4437 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4438 ConstantString(property),ConstantString(value));
4444 if (LocaleCompare(
"intensity",property) == 0)
4449 intensity=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4453 image->intensity=(PixelIntensityMethod) intensity;
4456 if (LocaleCompare(
"interpolate",property) == 0)
4461 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4463 if (interpolate < 0)
4465 image->interpolate=(InterpolatePixelMethod) interpolate;
4468 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4469 ConstantString(property),ConstantString(value));
4475 if (LocaleCompare(
"loop",property) == 0)
4477 image->iterations=StringToUnsignedLong(value);
4480 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4481 ConstantString(property),ConstantString(value));
4487 if (LocaleCompare(
"page",property) == 0)
4492 geometry=GetPageGeometry(value);
4493 flags=ParseAbsoluteGeometry(geometry,&image->page);
4494 geometry=DestroyString(geometry);
4497 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4498 ConstantString(property),ConstantString(value));
4504 if (LocaleCompare(
"rendering-intent",property) == 0)
4509 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4511 if (rendering_intent < 0)
4513 image->rendering_intent=(RenderingIntent) rendering_intent;
4516 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4517 ConstantString(property),ConstantString(value));
4523 if (LocaleCompare(
"tile-offset",property) == 0)
4528 geometry=GetPageGeometry(value);
4529 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4530 geometry=DestroyString(geometry);
4533 if (LocaleCompare(
"type",property) == 0)
4538 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4540 return(MagickFalse);
4541 image->type=(ImageType) type;
4544 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4545 ConstantString(property),ConstantString(value));
4551 if (LocaleCompare(
"units",property) == 0)
4556 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4559 image->units=(ResolutionType) units;
4562 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4563 ConstantString(property),ConstantString(value));
4568 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4569 ConstantString(property),ConstantString(value));