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/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)
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 *);
136static inline void *ClonePropertyKey(
void *key)
138 return((
void *) ((CloneKeyFunc) ConstantString)((
const char *) key));
141static inline void *ClonePropertyValue(
void *value)
143 return((
void *) ((CloneValueFunc) ConstantString)((
const char *) value));
146MagickExport 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);
210 image->properties=CloneSplayTree((SplayTreeInfo *)
211 clone_image->properties,ClonePropertyKey,ClonePropertyValue);
243MagickExport 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));
290MagickExport 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));
325MagickExport
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 *)
365MagickExport 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,
422static MagickBooleanType GetIPTCProperty(
const Image *image,
const char *key)
442 profile=GetImageProfile(image,
"iptc");
443 if (profile == (StringInfo *) NULL)
444 profile=GetImageProfile(image,
"8bim");
445 if (profile == (StringInfo *) NULL)
447 count=sscanf(key,
"IPTC:%ld:%ld",&dataset,&record);
450 attribute=(
char *) NULL;
451 for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
454 if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
456 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
457 length|=GetStringInfoDatum(profile)[i+4];
458 if (((
long) GetStringInfoDatum(profile)[i+1] == dataset) &&
459 ((
long) GetStringInfoDatum(profile)[i+2] == record))
461 message=(
char *) NULL;
463 message=(
char *) AcquireQuantumMemory(length+1UL,
sizeof(*message));
464 if (message != (
char *) NULL)
466 (void) CopyMagickString(message,(
char *) GetStringInfoDatum(
467 profile)+i+5,length+1);
468 (void) ConcatenateString(&attribute,message);
469 (void) ConcatenateString(&attribute,
";");
470 message=DestroyString(message);
475 if ((attribute == (
char *) NULL) || (*attribute ==
';'))
477 if (attribute != (
char *) NULL)
478 attribute=DestroyString(attribute);
481 attribute[strlen(attribute)-1]=
'\0';
482 (void) SetImageProperty((Image *) image,key,(
const char *) attribute);
483 attribute=DestroyString(attribute);
487static inline int ReadPropertyByte(
const unsigned char **p,
size_t *length)
499static inline signed int ReadPropertyMSBLong(
const unsigned char **p,
525 for (i=0; i < 4; i++)
529 buffer[i]=(
unsigned char) c;
531 value=(
unsigned int) buffer[0] << 24;
532 value|=(
unsigned int) buffer[1] << 16;
533 value|=(
unsigned int) buffer[2] << 8;
534 value|=(
unsigned int) buffer[3];
535 quantum.unsigned_value=value & 0xffffffff;
536 return(quantum.signed_value);
539static inline signed short ReadPropertyMSBShort(
const unsigned char **p,
564 return((
unsigned short) ~0);
565 for (i=0; i < 2; i++)
569 buffer[i]=(
unsigned char) c;
571 value=(
unsigned short) buffer[0] << 8;
572 value|=(
unsigned short) buffer[1];
573 quantum.unsigned_value=value & 0xffff;
574 return(quantum.signed_value);
577static MagickBooleanType Get8BIMProperty(
const Image *image,
const char *key)
581 format[MaxTextExtent],
582 *macroman_resource = (
char *) NULL,
584 *resource = (
char *) NULL;
613 profile=GetImageProfile(image,
"8bim");
614 if (profile == (StringInfo *) NULL)
616 count=(ssize_t) sscanf(key,
"8BIM:%ld,%ld:%1024[^\n]\n%1024[^\n]",&start,&stop,
618 if ((count != 2) && (count != 3) && (count != 4))
621 (void) CopyMagickString(format,
"SVG",MaxTextExtent);
626 sub_number=(ssize_t) StringToLong(&name[1]);
627 sub_number=MagickMax(sub_number,1L);
629 length=GetStringInfoLength(profile);
630 info=GetStringInfoDatum(profile);
631 while ((length > 0) && (status == MagickFalse))
633 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'8')
635 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'B')
637 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'I')
639 if (ReadPropertyByte(&info,&length) != (
unsigned char)
'M')
641 id=(ssize_t) ReadPropertyMSBShort(&info,&length);
642 if (
id < (ssize_t) start)
644 if (
id > (ssize_t) stop)
646 if (macroman_resource != (
char *) NULL)
647 macroman_resource=DestroyString(macroman_resource);
648 if (resource != (
char *) NULL)
649 resource=DestroyString(resource);
650 count=(ssize_t) ReadPropertyByte(&info,&length);
651 if ((count != 0) && ((
size_t) count <= length))
653 resource=(
char *) NULL;
654 if (~((
size_t) count) >= (MaxTextExtent-1))
655 resource=(
char *) AcquireQuantumMemory((
size_t) count+MaxTextExtent,
657 if (resource != (
char *) NULL)
659 for (i=0; i < (ssize_t) count; i++)
660 resource[i]=(
char) ReadPropertyByte(&info,&length);
661 resource[count]=
'\0';
664 if ((count & 0x01) == 0)
665 (void) ReadPropertyByte(&info,&length);
666 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
667 if ((count < 0) || ((
size_t) count > length))
672 macroman_resource=(
char *) ConvertMacRomanToUTF8((
unsigned char *)
674 if ((*name !=
'\0') && (*name !=
'#'))
675 if ((resource == (
char *) NULL) || (macroman_resource == (
char *) NULL) ||
676 ((LocaleCompare(name,resource) != 0) &&
677 (LocaleCompare(name,macroman_resource) != 0)))
683 length-=MagickMin(count,(ssize_t) length);
686 if ((*name ==
'#') && (sub_number != 1))
693 length-=MagickMin(count,(ssize_t) length);
699 attribute=(
char *) NULL;
700 if (~((
size_t) count) >= (MaxTextExtent-1))
701 attribute=(
char *) AcquireQuantumMemory((
size_t) count+MaxTextExtent,
703 if (attribute != (
char *) NULL)
705 (void) memcpy(attribute,(
char *) info,(
size_t) count);
706 attribute[count]=
'\0';
708 length-=MagickMin(count,(ssize_t) length);
709 if ((
id <= 1999) || (
id >= 2999))
710 (void) SetImageProperty((Image *) image,key,(
const char *) attribute);
716 if (LocaleCompare(format,
"svg") == 0)
717 path=TraceSVGClippath((
unsigned char *) attribute,(
size_t) count,
718 image->columns,image->rows);
720 path=TracePSClippath((
unsigned char *) attribute,(
size_t) count,
721 image->columns,image->rows);
722 (void) SetImageProperty((Image *) image,key,(
const char *) path);
723 path=DestroyString(path);
725 attribute=DestroyString(attribute);
729 if (macroman_resource != (
char *) NULL)
730 macroman_resource=DestroyString(macroman_resource);
731 if (resource != (
char *) NULL)
732 resource=DestroyString(resource);
736static inline signed int ReadPropertySignedLong(
const EndianType endian,
737 const unsigned char *buffer)
751 if (endian == LSBEndian)
753 value=(
unsigned int) buffer[3] << 24;
754 value|=(
unsigned int) buffer[2] << 16;
755 value|=(
unsigned int) buffer[1] << 8;
756 value|=(
unsigned int) buffer[0];
757 quantum.unsigned_value=value & 0xffffffff;
758 return(quantum.signed_value);
760 value=(
unsigned int) buffer[0] << 24;
761 value|=(
unsigned int) buffer[1] << 16;
762 value|=(
unsigned int) buffer[2] << 8;
763 value|=(
unsigned int) buffer[3];
764 quantum.unsigned_value=value & 0xffffffff;
765 return(quantum.signed_value);
768static inline unsigned int ReadPropertyUnsignedLong(
const EndianType endian,
769 const unsigned char *buffer)
774 if (endian == LSBEndian)
776 value=(
unsigned int) buffer[3] << 24;
777 value|=(
unsigned int) buffer[2] << 16;
778 value|=(
unsigned int) buffer[1] << 8;
779 value|=(
unsigned int) buffer[0];
780 return(value & 0xffffffff);
782 value=(
unsigned int) buffer[0] << 24;
783 value|=(
unsigned int) buffer[1] << 16;
784 value|=(
unsigned int) buffer[2] << 8;
785 value|=(
unsigned int) buffer[3];
786 return(value & 0xffffffff);
789static inline signed short ReadPropertySignedShort(
const EndianType endian,
790 const unsigned char *buffer)
804 if (endian == LSBEndian)
806 value=(
unsigned short) buffer[1] << 8;
807 value|=(
unsigned short) buffer[0];
808 quantum.unsigned_value=value & 0xffff;
809 return(quantum.signed_value);
811 value=(
unsigned short) buffer[0] << 8;
812 value|=(
unsigned short) buffer[1];
813 quantum.unsigned_value=value & 0xffff;
814 return(quantum.signed_value);
817static inline unsigned short ReadPropertyUnsignedShort(
const EndianType endian,
818 const unsigned char *buffer)
823 if (endian == LSBEndian)
825 value=(
unsigned short) buffer[1] << 8;
826 value|=(
unsigned short) buffer[0];
827 return(value & 0xffff);
829 value=(
unsigned short) buffer[0] << 8;
830 value|=(
unsigned short) buffer[1];
831 return(value & 0xffff);
834static MagickBooleanType GetEXIFProperty(
const Image *image,
835 const char *property)
837#define MaxDirectoryStack 16
838#define EXIF_DELIMITER "\n"
839#define EXIF_NUM_FORMATS 12
840#define EXIF_FMT_BYTE 1
841#define EXIF_FMT_STRING 2
842#define EXIF_FMT_USHORT 3
843#define EXIF_FMT_ULONG 4
844#define EXIF_FMT_URATIONAL 5
845#define EXIF_FMT_SBYTE 6
846#define EXIF_FMT_UNDEFINED 7
847#define EXIF_FMT_SSHORT 8
848#define EXIF_FMT_SLONG 9
849#define EXIF_FMT_SRATIONAL 10
850#define EXIF_FMT_SINGLE 11
851#define EXIF_FMT_DOUBLE 12
852#define GPS_LATITUDE 0x10002
853#define GPS_LONGITUDE 0x10004
854#define GPS_TIMESTAMP 0x10007
855#define TAG_EXIF_OFFSET 0x8769
856#define TAG_GPS_OFFSET 0x8825
857#define TAG_INTEROP_OFFSET 0xa005
860#define EXIFGPSFractions(format,arg1,arg2,arg3,arg4,arg5,arg6) \
868 for ( ; component < components; component++) \
870 if (component != 0) \
871 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
873 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
874 extent,format,(arg1),(arg2),(arg3),(arg4),(arg5),(arg6)); \
875 if (extent >= (MagickPathExtent-1)) \
876 extent=MagickPathExtent-1; \
878 buffer[extent]='\0'; \
879 value=AcquireString(buffer); \
882#define EXIFMultipleValues(format,arg) \
890 for ( ; component < components; component++) \
892 if (component != 0) \
893 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
895 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
896 extent,format,arg); \
897 if (extent >= (MagickPathExtent-1)) \
898 extent=MagickPathExtent-1; \
900 buffer[extent]='\0'; \
901 value=AcquireString(buffer); \
904#define EXIFMultipleFractions(format,arg1,arg2) \
912 for ( ; component < components; component++) \
914 if (component != 0) \
915 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent-\
917 extent+=(size_t) FormatLocaleString(buffer+extent,MagickPathExtent- \
918 extent,format,(arg1),(arg2)); \
919 if (extent >= (MagickPathExtent-1)) \
920 extent=MagickPathExtent-1; \
922 buffer[extent]='\0'; \
923 value=AcquireString(buffer); \
926 typedef struct _DirectoryInfo
938 typedef struct _TagInfo
950 { 0x001,
"exif:InteroperabilityIndex" },
951 { 0x002,
"exif:InteroperabilityVersion" },
952 { 0x100,
"exif:ImageWidth" },
953 { 0x101,
"exif:ImageLength" },
954 { 0x102,
"exif:BitsPerSample" },
955 { 0x103,
"exif:Compression" },
956 { 0x106,
"exif:PhotometricInterpretation" },
957 { 0x10a,
"exif:FillOrder" },
958 { 0x10d,
"exif:DocumentName" },
959 { 0x10e,
"exif:ImageDescription" },
960 { 0x10f,
"exif:Make" },
961 { 0x110,
"exif:Model" },
962 { 0x111,
"exif:StripOffsets" },
963 { 0x112,
"exif:Orientation" },
964 { 0x115,
"exif:SamplesPerPixel" },
965 { 0x116,
"exif:RowsPerStrip" },
966 { 0x117,
"exif:StripByteCounts" },
967 { 0x11a,
"exif:XResolution" },
968 { 0x11b,
"exif:YResolution" },
969 { 0x11c,
"exif:PlanarConfiguration" },
970 { 0x11d,
"exif:PageName" },
971 { 0x11e,
"exif:XPosition" },
972 { 0x11f,
"exif:YPosition" },
973 { 0x118,
"exif:MinSampleValue" },
974 { 0x119,
"exif:MaxSampleValue" },
975 { 0x120,
"exif:FreeOffsets" },
976 { 0x121,
"exif:FreeByteCounts" },
977 { 0x122,
"exif:GrayResponseUnit" },
978 { 0x123,
"exif:GrayResponseCurve" },
979 { 0x124,
"exif:T4Options" },
980 { 0x125,
"exif:T6Options" },
981 { 0x128,
"exif:ResolutionUnit" },
982 { 0x12d,
"exif:TransferFunction" },
983 { 0x131,
"exif:Software" },
984 { 0x132,
"exif:DateTime" },
985 { 0x13b,
"exif:Artist" },
986 { 0x13e,
"exif:WhitePoint" },
987 { 0x13f,
"exif:PrimaryChromaticities" },
988 { 0x140,
"exif:ColorMap" },
989 { 0x141,
"exif:HalfToneHints" },
990 { 0x142,
"exif:TileWidth" },
991 { 0x143,
"exif:TileLength" },
992 { 0x144,
"exif:TileOffsets" },
993 { 0x145,
"exif:TileByteCounts" },
994 { 0x14a,
"exif:SubIFD" },
995 { 0x14c,
"exif:InkSet" },
996 { 0x14d,
"exif:InkNames" },
997 { 0x14e,
"exif:NumberOfInks" },
998 { 0x150,
"exif:DotRange" },
999 { 0x151,
"exif:TargetPrinter" },
1000 { 0x152,
"exif:ExtraSample" },
1001 { 0x153,
"exif:SampleFormat" },
1002 { 0x154,
"exif:SMinSampleValue" },
1003 { 0x155,
"exif:SMaxSampleValue" },
1004 { 0x156,
"exif:TransferRange" },
1005 { 0x157,
"exif:ClipPath" },
1006 { 0x158,
"exif:XClipPathUnits" },
1007 { 0x159,
"exif:YClipPathUnits" },
1008 { 0x15a,
"exif:Indexed" },
1009 { 0x15b,
"exif:JPEGTables" },
1010 { 0x15f,
"exif:OPIProxy" },
1011 { 0x200,
"exif:JPEGProc" },
1012 { 0x201,
"exif:JPEGInterchangeFormat" },
1013 { 0x202,
"exif:JPEGInterchangeFormatLength" },
1014 { 0x203,
"exif:JPEGRestartInterval" },
1015 { 0x205,
"exif:JPEGLosslessPredictors" },
1016 { 0x206,
"exif:JPEGPointTransforms" },
1017 { 0x207,
"exif:JPEGQTables" },
1018 { 0x208,
"exif:JPEGDCTables" },
1019 { 0x209,
"exif:JPEGACTables" },
1020 { 0x211,
"exif:YCbCrCoefficients" },
1021 { 0x212,
"exif:YCbCrSubSampling" },
1022 { 0x213,
"exif:YCbCrPositioning" },
1023 { 0x214,
"exif:ReferenceBlackWhite" },
1024 { 0x2bc,
"exif:ExtensibleMetadataPlatform" },
1025 { 0x301,
"exif:Gamma" },
1026 { 0x302,
"exif:ICCProfileDescriptor" },
1027 { 0x303,
"exif:SRGBRenderingIntent" },
1028 { 0x320,
"exif:ImageTitle" },
1029 { 0x5001,
"exif:ResolutionXUnit" },
1030 { 0x5002,
"exif:ResolutionYUnit" },
1031 { 0x5003,
"exif:ResolutionXLengthUnit" },
1032 { 0x5004,
"exif:ResolutionYLengthUnit" },
1033 { 0x5005,
"exif:PrintFlags" },
1034 { 0x5006,
"exif:PrintFlagsVersion" },
1035 { 0x5007,
"exif:PrintFlagsCrop" },
1036 { 0x5008,
"exif:PrintFlagsBleedWidth" },
1037 { 0x5009,
"exif:PrintFlagsBleedWidthScale" },
1038 { 0x500A,
"exif:HalftoneLPI" },
1039 { 0x500B,
"exif:HalftoneLPIUnit" },
1040 { 0x500C,
"exif:HalftoneDegree" },
1041 { 0x500D,
"exif:HalftoneShape" },
1042 { 0x500E,
"exif:HalftoneMisc" },
1043 { 0x500F,
"exif:HalftoneScreen" },
1044 { 0x5010,
"exif:JPEGQuality" },
1045 { 0x5011,
"exif:GridSize" },
1046 { 0x5012,
"exif:ThumbnailFormat" },
1047 { 0x5013,
"exif:ThumbnailWidth" },
1048 { 0x5014,
"exif:ThumbnailHeight" },
1049 { 0x5015,
"exif:ThumbnailColorDepth" },
1050 { 0x5016,
"exif:ThumbnailPlanes" },
1051 { 0x5017,
"exif:ThumbnailRawBytes" },
1052 { 0x5018,
"exif:ThumbnailSize" },
1053 { 0x5019,
"exif:ThumbnailCompressedSize" },
1054 { 0x501a,
"exif:ColorTransferFunction" },
1055 { 0x501b,
"exif:ThumbnailData" },
1056 { 0x5020,
"exif:ThumbnailImageWidth" },
1057 { 0x5021,
"exif:ThumbnailImageHeight" },
1058 { 0x5022,
"exif:ThumbnailBitsPerSample" },
1059 { 0x5023,
"exif:ThumbnailCompression" },
1060 { 0x5024,
"exif:ThumbnailPhotometricInterp" },
1061 { 0x5025,
"exif:ThumbnailImageDescription" },
1062 { 0x5026,
"exif:ThumbnailEquipMake" },
1063 { 0x5027,
"exif:ThumbnailEquipModel" },
1064 { 0x5028,
"exif:ThumbnailStripOffsets" },
1065 { 0x5029,
"exif:ThumbnailOrientation" },
1066 { 0x502a,
"exif:ThumbnailSamplesPerPixel" },
1067 { 0x502b,
"exif:ThumbnailRowsPerStrip" },
1068 { 0x502c,
"exif:ThumbnailStripBytesCount" },
1069 { 0x502d,
"exif:ThumbnailResolutionX" },
1070 { 0x502e,
"exif:ThumbnailResolutionY" },
1071 { 0x502f,
"exif:ThumbnailPlanarConfig" },
1072 { 0x5030,
"exif:ThumbnailResolutionUnit" },
1073 { 0x5031,
"exif:ThumbnailTransferFunction" },
1074 { 0x5032,
"exif:ThumbnailSoftwareUsed" },
1075 { 0x5033,
"exif:ThumbnailDateTime" },
1076 { 0x5034,
"exif:ThumbnailArtist" },
1077 { 0x5035,
"exif:ThumbnailWhitePoint" },
1078 { 0x5036,
"exif:ThumbnailPrimaryChromaticities" },
1079 { 0x5037,
"exif:ThumbnailYCbCrCoefficients" },
1080 { 0x5038,
"exif:ThumbnailYCbCrSubsampling" },
1081 { 0x5039,
"exif:ThumbnailYCbCrPositioning" },
1082 { 0x503A,
"exif:ThumbnailRefBlackWhite" },
1083 { 0x503B,
"exif:ThumbnailCopyRight" },
1084 { 0x5090,
"exif:LuminanceTable" },
1085 { 0x5091,
"exif:ChrominanceTable" },
1086 { 0x5100,
"exif:FrameDelay" },
1087 { 0x5101,
"exif:LoopCount" },
1088 { 0x5110,
"exif:PixelUnit" },
1089 { 0x5111,
"exif:PixelPerUnitX" },
1090 { 0x5112,
"exif:PixelPerUnitY" },
1091 { 0x5113,
"exif:PaletteHistogram" },
1092 { 0x1000,
"exif:RelatedImageFileFormat" },
1093 { 0x1001,
"exif:RelatedImageLength" },
1094 { 0x1002,
"exif:RelatedImageWidth" },
1095 { 0x800d,
"exif:ImageID" },
1096 { 0x80e3,
"exif:Matteing" },
1097 { 0x80e4,
"exif:DataType" },
1098 { 0x80e5,
"exif:ImageDepth" },
1099 { 0x80e6,
"exif:TileDepth" },
1100 { 0x828d,
"exif:CFARepeatPatternDim" },
1101 { 0x828e,
"exif:CFAPattern2" },
1102 { 0x828f,
"exif:BatteryLevel" },
1103 { 0x8298,
"exif:Copyright" },
1104 { 0x829a,
"exif:ExposureTime" },
1105 { 0x829d,
"exif:FNumber" },
1106 { 0x83bb,
"exif:IPTC/NAA" },
1107 { 0x84e3,
"exif:IT8RasterPadding" },
1108 { 0x84e5,
"exif:IT8ColorTable" },
1109 { 0x8649,
"exif:ImageResourceInformation" },
1110 { 0x8769,
"exif:ExifOffset" },
1111 { 0x8773,
"exif:InterColorProfile" },
1112 { 0x8822,
"exif:ExposureProgram" },
1113 { 0x8824,
"exif:SpectralSensitivity" },
1114 { 0x8825,
"exif:GPSInfo" },
1115 { 0x8827,
"exif:PhotographicSensitivity" },
1116 { 0x8828,
"exif:OECF" },
1117 { 0x8829,
"exif:Interlace" },
1118 { 0x882a,
"exif:TimeZoneOffset" },
1119 { 0x882b,
"exif:SelfTimerMode" },
1120 { 0x8830,
"exif:SensitivityType" },
1121 { 0x8831,
"exif:StandardOutputSensitivity" },
1122 { 0x8832,
"exif:RecommendedExposureIndex" },
1123 { 0x8833,
"exif:ISOSpeed" },
1124 { 0x8834,
"exif:ISOSpeedLatitudeyyy" },
1125 { 0x8835,
"exif:ISOSpeedLatitudezzz" },
1126 { 0x9000,
"exif:ExifVersion" },
1127 { 0x9003,
"exif:DateTimeOriginal" },
1128 { 0x9004,
"exif:DateTimeDigitized" },
1129 { 0x9010,
"exif:OffsetTime" },
1130 { 0x9011,
"exif:OffsetTimeOriginal" },
1131 { 0x9012,
"exif:OffsetTimeDigitized" },
1132 { 0x9101,
"exif:ComponentsConfiguration" },
1133 { 0x9102,
"exif:CompressedBitsPerPixel" },
1134 { 0x9201,
"exif:ShutterSpeedValue" },
1135 { 0x9202,
"exif:ApertureValue" },
1136 { 0x9203,
"exif:BrightnessValue" },
1137 { 0x9204,
"exif:ExposureBiasValue" },
1138 { 0x9205,
"exif:MaxApertureValue" },
1139 { 0x9206,
"exif:SubjectDistance" },
1140 { 0x9207,
"exif:MeteringMode" },
1141 { 0x9208,
"exif:LightSource" },
1142 { 0x9209,
"exif:Flash" },
1143 { 0x920a,
"exif:FocalLength" },
1144 { 0x920b,
"exif:FlashEnergy" },
1145 { 0x920c,
"exif:SpatialFrequencyResponse" },
1146 { 0x920d,
"exif:Noise" },
1147 { 0x9214,
"exif:SubjectArea" },
1148 { 0x9290,
"exif:SubSecTime" },
1149 { 0x9291,
"exif:SubSecTimeOriginal" },
1150 { 0x9292,
"exif:SubSecTimeDigitized" },
1151 { 0x9211,
"exif:ImageNumber" },
1152 { 0x9212,
"exif:SecurityClassification" },
1153 { 0x9213,
"exif:ImageHistory" },
1154 { 0x9214,
"exif:SubjectArea" },
1155 { 0x9215,
"exif:ExposureIndex" },
1156 { 0x9216,
"exif:TIFF-EPStandardID" },
1157 { 0x927c,
"exif:MakerNote" },
1158 { 0x9286,
"exif:UserComment" },
1159 { 0x9290,
"exif:SubSecTime" },
1160 { 0x9291,
"exif:SubSecTimeOriginal" },
1161 { 0x9292,
"exif:SubSecTimeDigitized" },
1162 { 0x9400,
"exif:Temperature" },
1163 { 0x9401,
"exif:Humidity" },
1164 { 0x9402,
"exif:Pressure" },
1165 { 0x9403,
"exif:WaterDepth" },
1166 { 0x9404,
"exif:Acceleration" },
1167 { 0x9405,
"exif:CameraElevationAngle" },
1168 { 0x9C9b,
"exif:WinXP-Title" },
1169 { 0x9C9c,
"exif:WinXP-Comments" },
1170 { 0x9C9d,
"exif:WinXP-Author" },
1171 { 0x9C9e,
"exif:WinXP-Keywords" },
1172 { 0x9C9f,
"exif:WinXP-Subject" },
1173 { 0xa000,
"exif:FlashPixVersion" },
1174 { 0xa001,
"exif:ColorSpace" },
1175 { 0xa002,
"exif:PixelXDimension" },
1176 { 0xa003,
"exif:PixelYDimension" },
1177 { 0xa004,
"exif:RelatedSoundFile" },
1178 { 0xa005,
"exif:InteroperabilityOffset" },
1179 { 0xa20b,
"exif:FlashEnergy" },
1180 { 0xa20c,
"exif:SpatialFrequencyResponse" },
1181 { 0xa20d,
"exif:Noise" },
1182 { 0xa20e,
"exif:FocalPlaneXResolution" },
1183 { 0xa20f,
"exif:FocalPlaneYResolution" },
1184 { 0xa210,
"exif:FocalPlaneResolutionUnit" },
1185 { 0xa214,
"exif:SubjectLocation" },
1186 { 0xa215,
"exif:ExposureIndex" },
1187 { 0xa216,
"exif:TIFF/EPStandardID" },
1188 { 0xa217,
"exif:SensingMethod" },
1189 { 0xa300,
"exif:FileSource" },
1190 { 0xa301,
"exif:SceneType" },
1191 { 0xa302,
"exif:CFAPattern" },
1192 { 0xa401,
"exif:CustomRendered" },
1193 { 0xa402,
"exif:ExposureMode" },
1194 { 0xa403,
"exif:WhiteBalance" },
1195 { 0xa404,
"exif:DigitalZoomRatio" },
1196 { 0xa405,
"exif:FocalLengthIn35mmFilm" },
1197 { 0xa406,
"exif:SceneCaptureType" },
1198 { 0xa407,
"exif:GainControl" },
1199 { 0xa408,
"exif:Contrast" },
1200 { 0xa409,
"exif:Saturation" },
1201 { 0xa40a,
"exif:Sharpness" },
1202 { 0xa40b,
"exif:DeviceSettingDescription" },
1203 { 0xa40c,
"exif:SubjectDistanceRange" },
1204 { 0xa420,
"exif:ImageUniqueID" },
1205 { 0xa430,
"exif:CameraOwnerName" },
1206 { 0xa431,
"exif:BodySerialNumber" },
1207 { 0xa432,
"exif:LensSpecification" },
1208 { 0xa433,
"exif:LensMake" },
1209 { 0xa434,
"exif:LensModel" },
1210 { 0xa435,
"exif:LensSerialNumber" },
1211 { 0xc4a5,
"exif:PrintImageMatching" },
1212 { 0xa500,
"exif:Gamma" },
1213 { 0xc640,
"exif:CR2Slice" },
1214 { 0x10000,
"exif:GPSVersionID" },
1215 { 0x10001,
"exif:GPSLatitudeRef" },
1216 { 0x10002,
"exif:GPSLatitude" },
1217 { 0x10003,
"exif:GPSLongitudeRef" },
1218 { 0x10004,
"exif:GPSLongitude" },
1219 { 0x10005,
"exif:GPSAltitudeRef" },
1220 { 0x10006,
"exif:GPSAltitude" },
1221 { 0x10007,
"exif:GPSTimeStamp" },
1222 { 0x10008,
"exif:GPSSatellites" },
1223 { 0x10009,
"exif:GPSStatus" },
1224 { 0x1000a,
"exif:GPSMeasureMode" },
1225 { 0x1000b,
"exif:GPSDop" },
1226 { 0x1000c,
"exif:GPSSpeedRef" },
1227 { 0x1000d,
"exif:GPSSpeed" },
1228 { 0x1000e,
"exif:GPSTrackRef" },
1229 { 0x1000f,
"exif:GPSTrack" },
1230 { 0x10010,
"exif:GPSImgDirectionRef" },
1231 { 0x10011,
"exif:GPSImgDirection" },
1232 { 0x10012,
"exif:GPSMapDatum" },
1233 { 0x10013,
"exif:GPSDestLatitudeRef" },
1234 { 0x10014,
"exif:GPSDestLatitude" },
1235 { 0x10015,
"exif:GPSDestLongitudeRef" },
1236 { 0x10016,
"exif:GPSDestLongitude" },
1237 { 0x10017,
"exif:GPSDestBearingRef" },
1238 { 0x10018,
"exif:GPSDestBearing" },
1239 { 0x10019,
"exif:GPSDestDistanceRef" },
1240 { 0x1001a,
"exif:GPSDestDistance" },
1241 { 0x1001b,
"exif:GPSProcessingMethod" },
1242 { 0x1001c,
"exif:GPSAreaInformation" },
1243 { 0x1001d,
"exif:GPSDateStamp" },
1244 { 0x1001e,
"exif:GPSDifferential" },
1245 { 0x1001f,
"exif:GPSHPositioningError" },
1257 directory_stack[MaxDirectoryStack] = { { 0, 0, 0 } };
1286 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1291 profile=GetImageProfile(image,
"exif");
1292 if (profile == (
const StringInfo *) NULL)
1293 return(MagickFalse);
1294 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1295 return(MagickFalse);
1296 while (isspace((
int) ((
unsigned char) *property)) != 0)
1298 if (strlen(property) <= 5)
1299 return(MagickFalse);
1302 switch (*(property+5))
1331 tag=(*(
property+5) ==
'@') ? 1UL : 0UL;
1335 return(MagickFalse);
1342 for (i=(ssize_t) n-1L; i >= 0; i--)
1346 if ((c >=
'0') && (c <=
'9'))
1349 if ((c >=
'A') && (c <=
'F'))
1352 if ((c >=
'a') && (c <=
'f'))
1355 return(MagickFalse);
1357 }
while (*property !=
'\0');
1367 if (EXIFTag[i].tag == 0)
1369 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1371 tag=(size_t) EXIFTag[i].tag;
1379 return(MagickFalse);
1380 length=GetStringInfoLength(profile);
1382 return(MagickFalse);
1383 exif=GetStringInfoDatum(profile);
1386 if (ReadPropertyByte(&exif,&length) != 0x45)
1388 if (ReadPropertyByte(&exif,&length) != 0x78)
1390 if (ReadPropertyByte(&exif,&length) != 0x69)
1392 if (ReadPropertyByte(&exif,&length) != 0x66)
1394 if (ReadPropertyByte(&exif,&length) != 0x00)
1396 if (ReadPropertyByte(&exif,&length) != 0x00)
1401 return(MagickFalse);
1402 id=(ssize_t) ReadPropertySignedShort(LSBEndian,exif);
1410 return(MagickFalse);
1411 if (ReadPropertyUnsignedShort(endian,exif+2) != 0x002a)
1412 return(MagickFalse);
1416 offset=(ssize_t) ReadPropertySignedLong(endian,exif+4);
1417 if ((offset < 0) || (
size_t) offset >= length)
1418 return(MagickFalse);
1423 directory=exif+offset;
1427 exif_resources=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
1428 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
1437 directory=directory_stack[level].directory;
1438 entry=directory_stack[level].entry;
1439 tag_offset=directory_stack[level].offset;
1441 if ((directory < exif) || (directory > (exif+length-2)))
1446 number_entries=(size_t) ReadPropertyUnsignedShort(endian,directory);
1447 for ( ; entry < number_entries; entry++)
1460 q=(
unsigned char *) (directory+(12*entry)+2);
1461 if (q > (exif+length-12))
1463 if (GetValueFromSplayTree(exif_resources,q) == q)
1465 (void) AddValueToSplayTree(exif_resources,q,q);
1466 tag_value=(size_t) ReadPropertyUnsignedShort(endian,q)+tag_offset;
1467 format=(size_t) ReadPropertyUnsignedShort(endian,q+2);
1468 if (format >= (
sizeof(tag_bytes)/
sizeof(*tag_bytes)))
1472 components=(ssize_t) ReadPropertySignedLong(endian,q+4);
1475 number_bytes=(size_t) components*tag_bytes[format];
1476 if (number_bytes < components)
1478 if (number_bytes <= 4)
1488 dir_offset=(ssize_t) ReadPropertySignedLong(endian,q+8);
1489 if ((dir_offset < 0) || (
size_t) dir_offset >= length)
1491 if (((
size_t) dir_offset+number_bytes) < (
size_t) dir_offset)
1493 if (((
size_t) dir_offset+number_bytes) > length)
1495 p=(
unsigned char *) (exif+dir_offset);
1497 if ((all != 0) || (tag == (
size_t) tag_value))
1500 buffer[6*
sizeof(double)+MaxTextExtent],
1503 if ((p < exif) || (p > (exif+length-tag_bytes[format])))
1505 value=(
char *) NULL;
1511 value=(
char *) NULL;
1512 if (~((
size_t) number_bytes) >= 1)
1513 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1515 if (value != (
char *) NULL)
1517 for (i=0; i < (ssize_t) number_bytes; i++)
1520 if (isprint((
int) p[i]) != 0)
1521 value[i]=(char) p[i];
1527 case EXIF_FMT_SBYTE:
1529 EXIFMultipleValues(
"%.20g",(
double) (*(
signed char *) p));
1532 case EXIF_FMT_SSHORT:
1534 EXIFMultipleValues(
"%hd",ReadPropertySignedShort(endian,p));
1537 case EXIF_FMT_USHORT:
1539 EXIFMultipleValues(
"%hu",ReadPropertyUnsignedShort(endian,p));
1542 case EXIF_FMT_ULONG:
1544 EXIFMultipleValues(
"%.20g",(
double)
1545 ReadPropertyUnsignedLong(endian,p));
1548 case EXIF_FMT_SLONG:
1550 EXIFMultipleValues(
"%.20g",(
double)
1551 ReadPropertySignedLong(endian,p));
1554 case EXIF_FMT_URATIONAL:
1556 if ((tag_value == GPS_LATITUDE) || (tag_value == GPS_LONGITUDE) ||
1557 (tag_value == GPS_TIMESTAMP))
1560 EXIFGPSFractions(
"%.20g/%.20g,%.20g/%.20g,%.20g/%.20g",
1561 (
double) ReadPropertyUnsignedLong(endian,p),
1562 (
double) ReadPropertyUnsignedLong(endian,p+4),
1563 (
double) ReadPropertyUnsignedLong(endian,p+8),
1564 (
double) ReadPropertyUnsignedLong(endian,p+12),
1565 (
double) ReadPropertyUnsignedLong(endian,p+16),
1566 (
double) ReadPropertyUnsignedLong(endian,p+20));
1569 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1570 ReadPropertyUnsignedLong(endian,p),(
double)
1571 ReadPropertyUnsignedLong(endian,p+4));
1574 case EXIF_FMT_SRATIONAL:
1576 EXIFMultipleFractions(
"%.20g/%.20g",(
double)
1577 ReadPropertySignedLong(endian,p),(
double)
1578 ReadPropertySignedLong(endian,p+4));
1581 case EXIF_FMT_SINGLE:
1583 EXIFMultipleValues(
"%.20g",(
double)
1584 ReadPropertySignedLong(endian,p));
1587 case EXIF_FMT_DOUBLE:
1589 EXIFMultipleValues(
"%.20g",(
double)
1590 ReadPropertySignedLong(endian,p));
1593 case EXIF_FMT_STRING:
1594 case EXIF_FMT_UNDEFINED:
1597 if ((p < exif) || (p > (exif+length-number_bytes)))
1599 value=(
char *) NULL;
1600 if (~((
size_t) number_bytes) >= 1)
1601 value=(
char *) AcquireQuantumMemory((
size_t) number_bytes+1UL,
1603 if (value != (
char *) NULL)
1608 for (i=0; i < (ssize_t) number_bytes; i++)
1611 if ((isprint((
int) p[i]) != 0) || (p[i] ==
'\0'))
1612 value[i]=(char) p[i];
1619 if (value != (
char *) NULL)
1627 key=AcquireString(property);
1638 description=
"unknown";
1641 if (EXIFTag[i].tag == 0)
1643 if (EXIFTag[i].tag == tag_value)
1645 description=EXIFTag[i].description;
1649 (void) FormatLocaleString(key,MaxTextExtent,
"%s",
1652 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1657 if (tag_value < 0x10000)
1658 (void) FormatLocaleString(key,MaxTextExtent,
"#%04lx",
1659 (
unsigned long) tag_value);
1661 if (tag_value < 0x20000)
1662 (void) FormatLocaleString(key,MaxTextExtent,
"@%04lx",
1663 (
unsigned long) (tag_value & 0xffff));
1665 (
void) FormatLocaleString(key,MaxTextExtent,
"unknown");
1671 (void) SubstituteString(&key,
"exif:",
"exif:thumbnail:");
1674 p=(
const char *) NULL;
1675 if (image->properties != (
void *) NULL)
1676 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
1677 image->properties,key);
1678 if (p == (
const char *) NULL)
1679 (void) SetImageProperty((Image *) image,key,value);
1680 value=DestroyString(value);
1681 key=DestroyString(key);
1685 if ((tag_value == TAG_EXIF_OFFSET) ||
1686 (tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1691 offset=(ssize_t) ReadPropertySignedLong(endian,p);
1692 if (((
size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1697 tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1699 directory_stack[level].directory=directory;
1701 directory_stack[level].entry=entry;
1702 directory_stack[level].offset=tag_offset;
1707 for (i=0; i < level; i++)
1708 if (directory_stack[i].directory == (exif+tag_offset1))
1712 directory_stack[level].directory=exif+offset;
1713 directory_stack[level].offset=tag_offset1;
1714 directory_stack[level].entry=0;
1716 if ((directory+2+(12*number_entries)+4) > (exif+length))
1718 offset=(ssize_t) ReadPropertySignedLong(endian,directory+2+(12*
1720 if ((offset != 0) && ((
size_t) offset < length) &&
1721 (level < (MaxDirectoryStack-2)))
1723 directory_stack[level].directory=exif+offset;
1724 directory_stack[level].entry=0;
1725 directory_stack[level].offset=tag_offset1;
1732 }
while (level > 0);
1733 exif_resources=DestroySplayTree(exif_resources);
1737static MagickBooleanType GetICCProperty(
const Image *image)
1745 profile=GetImageProfile(image,
"icc");
1746 if (profile == (StringInfo *) NULL)
1747 profile=GetImageProfile(image,
"icm");
1748 if (profile == (StringInfo *) NULL)
1749 return(MagickFalse);
1750 if (GetStringInfoLength(profile) < 128)
1751 return(MagickFalse);
1752#if defined(MAGICKCORE_LCMS_DELEGATE)
1757 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
1758 (cmsUInt32Number) GetStringInfoLength(profile));
1759 if (icc_profile != (cmsHPROFILE *) NULL)
1761#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
1765 name=cmsTakeProductName(icc_profile);
1766 if (name != (
const char *) NULL)
1767 (void) SetImageProperty((Image *) image,
"icc:name",name);
1775 info=AcquireStringInfo(0);
1776 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
"US",
1780 SetStringInfoLength(info,extent+1);
1781 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
"en",
1782 "US",(
char *) GetStringInfoDatum(info),extent);
1784 (void) SetImageProperty((Image *) image,
"icc:description",
1785 (
char *) GetStringInfoDatum(info));
1787 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
"US",
1791 SetStringInfoLength(info,extent+1);
1792 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoManufacturer,
"en",
1793 "US",(
char *) GetStringInfoDatum(info),extent);
1795 (void) SetImageProperty((Image *) image,
"icc:manufacturer",
1796 (
char *) GetStringInfoDatum(info));
1798 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1802 SetStringInfoLength(info,extent+1);
1803 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoModel,
"en",
"US",
1804 (
char *) GetStringInfoDatum(info),extent);
1806 (void) SetImageProperty((Image *) image,
"icc:model",
1807 (
char *) GetStringInfoDatum(info));
1809 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
"US",
1813 SetStringInfoLength(info,extent+1);
1814 extent=cmsGetProfileInfoASCII(icc_profile,cmsInfoCopyright,
"en",
1815 "US",(
char *) GetStringInfoDatum(info),extent);
1817 (void) SetImageProperty((Image *) image,
"icc:copyright",
1818 (
char *) GetStringInfoDatum(info));
1820 info=DestroyStringInfo(info);
1822 (void) cmsCloseProfile(icc_profile);
1829static MagickBooleanType SkipXMPValue(
const char *value)
1831 if (value == (
const char*) NULL)
1833 while (*value !=
'\0')
1835 if (isspace((
int) ((
unsigned char) *value)) == 0)
1836 return(MagickFalse);
1842static MagickBooleanType GetXMPProperty(
const Image *image,
const char *property)
1869 profile=GetImageProfile(image,
"xmp");
1870 if (profile == (StringInfo *) NULL)
1871 return(MagickFalse);
1872 if (GetStringInfoLength(profile) < 17)
1873 return(MagickFalse);
1874 if ((property == (
const char *) NULL) || (*property ==
'\0'))
1875 return(MagickFalse);
1876 xmp_profile=StringInfoToString(profile);
1877 if (xmp_profile == (
char *) NULL)
1878 return(MagickFalse);
1879 for (p=xmp_profile; *p !=
'\0'; p++)
1880 if ((*p ==
'<') && (*(p+1) ==
'x'))
1882 exception=AcquireExceptionInfo();
1883 xmp=NewXMLTree((
char *) p,exception);
1884 xmp_profile=DestroyString(xmp_profile);
1885 exception=DestroyExceptionInfo(exception);
1886 if (xmp == (XMLTreeInfo *) NULL)
1887 return(MagickFalse);
1889 rdf=GetXMLTreeChild(xmp,
"rdf:RDF");
1890 if (rdf != (XMLTreeInfo *) NULL)
1892 if (image->properties == (
void *) NULL)
1893 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1894 RelinquishMagickMemory,RelinquishMagickMemory);
1895 description=GetXMLTreeChild(rdf,
"rdf:Description");
1896 while (description != (XMLTreeInfo *) NULL)
1898 node=GetXMLTreeChild(description,(
const char *) NULL);
1899 while (node != (XMLTreeInfo *) NULL)
1905 xmp_namespace_length;
1907 child=GetXMLTreeChild(node,(
const char *) NULL);
1908 content=GetXMLTreeContent(node);
1909 if ((child == (XMLTreeInfo *) NULL) &&
1910 (SkipXMPValue(content) == MagickFalse))
1912 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1913 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1914 xmp_namespace_length=strlen(xmp_namespace);
1915 if ((xmp_namespace_length <= 2) ||
1916 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1917 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1918 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1919 ConstantString(xmp_namespace),ConstantString(content));
1920 xmp_namespace=DestroyString(xmp_namespace);
1922 while (child != (XMLTreeInfo *) NULL)
1924 content=GetXMLTreeContent(child);
1925 if (SkipXMPValue(content) == MagickFalse)
1927 xmp_namespace=ConstantString(GetXMLTreeTag(node));
1928 (void) SubstituteString(&xmp_namespace,
"exif:",
"xmp:");
1929 xmp_namespace_length=strlen(xmp_namespace);
1930 if ((xmp_namespace_length <= 2) ||
1931 (*(xmp_namespace+(xmp_namespace_length-2)) !=
':') ||
1932 (*(xmp_namespace+(xmp_namespace_length-1)) !=
'*'))
1933 (void) AddValueToSplayTree((SplayTreeInfo *)
1934 image->properties,ConstantString(xmp_namespace),
1935 ConstantString(content));
1936 xmp_namespace=DestroyString(xmp_namespace);
1938 child=GetXMLTreeSibling(child);
1940 node=GetXMLTreeSibling(node);
1942 description=GetNextXMLTreeTag(description);
1945 xmp=DestroyXMLTree(xmp);
1949static char *TracePSClippath(
const unsigned char *blob,
size_t length,
1950 const size_t magick_unused(columns),
const size_t magick_unused(rows))
1973 magick_unreferenced(columns);
1974 magick_unreferenced(rows);
1976 path=AcquireString((
char *) NULL);
1977 if (path == (
char *) NULL)
1978 return((
char *) NULL);
1979 message=AcquireString((
char *) NULL);
1980 (void) FormatLocaleString(message,MaxTextExtent,
"/ClipImage\n");
1981 (void) ConcatenateString(&path,message);
1982 (void) FormatLocaleString(message,MaxTextExtent,
"{\n");
1983 (void) ConcatenateString(&path,message);
1984 (void) FormatLocaleString(message,MaxTextExtent,
" /c {curveto} bind def\n");
1985 (void) ConcatenateString(&path,message);
1986 (void) FormatLocaleString(message,MaxTextExtent,
" /l {lineto} bind def\n");
1987 (void) ConcatenateString(&path,message);
1988 (void) FormatLocaleString(message,MaxTextExtent,
" /m {moveto} bind def\n");
1989 (void) ConcatenateString(&path,message);
1990 (void) FormatLocaleString(message,MaxTextExtent,
1991 " /v {currentpoint 6 2 roll curveto} bind def\n");
1992 (void) ConcatenateString(&path,message);
1993 (void) FormatLocaleString(message,MaxTextExtent,
1994 " /y {2 copy curveto} bind def\n");
1995 (void) ConcatenateString(&path,message);
1996 (void) FormatLocaleString(message,MaxTextExtent,
1997 " /z {closepath} bind def\n");
1998 (void) ConcatenateString(&path,message);
1999 (void) FormatLocaleString(message,MaxTextExtent,
" newpath\n");
2000 (void) ConcatenateString(&path,message);
2005 (void) memset(point,0,
sizeof(point));
2006 (void) memset(first,0,
sizeof(first));
2007 (void) memset(last,0,
sizeof(last));
2009 in_subpath=MagickFalse;
2012 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2018 if (knot_count != 0)
2021 length-=MagickMin(24,(ssize_t) length);
2027 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2029 length-=MagickMin(22,(ssize_t) length);
2037 if (knot_count == 0)
2043 length-=MagickMin(24,(ssize_t) length);
2049 for (i=0; i < 3; i++)
2051 y=(size_t) ReadPropertyMSBLong(&blob,&length);
2052 x=(size_t) ReadPropertyMSBLong(&blob,&length);
2053 point[i].x=(double) x/4096.0/4096.0;
2054 point[i].y=1.0-(double) y/4096.0/4096.0;
2056 if (in_subpath == MagickFalse)
2058 (void) FormatLocaleString(message,MaxTextExtent,
" %g %g m\n",
2059 point[1].x,point[1].y);
2060 for (i=0; i < 3; i++)
2072 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2073 (point[0].x == point[1].x) && (point[0].y == point[1].y))
2074 (void) FormatLocaleString(message,MaxTextExtent,
2075 " %g %g l\n",point[1].x,point[1].y);
2077 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2078 (void) FormatLocaleString(message,MaxTextExtent,
2079 " %g %g %g %g v\n",point[0].x,point[0].y,
2080 point[1].x,point[1].y);
2082 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
2083 (void) FormatLocaleString(message,MaxTextExtent,
2084 " %g %g %g %g y\n",last[2].x,last[2].y,
2085 point[1].x,point[1].y);
2087 (
void) FormatLocaleString(message,MaxTextExtent,
2088 " %g %g %g %g %g %g c\n",last[2].x,
2089 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
2090 for (i=0; i < 3; i++)
2093 (void) ConcatenateString(&path,message);
2094 in_subpath=MagickTrue;
2099 if (knot_count == 0)
2105 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
2106 (first[0].x == first[1].x) && (first[0].y == first[1].y))
2107 (void) FormatLocaleString(message,MaxTextExtent,
2108 " %g %g l z\n",first[1].x,first[1].y);
2110 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
2111 (void) FormatLocaleString(message,MaxTextExtent,
2112 " %g %g %g %g v z\n",first[0].x,first[0].y,
2113 first[1].x,first[1].y);
2115 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
2116 (void) FormatLocaleString(message,MaxTextExtent,
2117 " %g %g %g %g y z\n",last[2].x,last[2].y,
2118 first[1].x,first[1].y);
2120 (
void) FormatLocaleString(message,MaxTextExtent,
2121 " %g %g %g %g %g %g c z\n",last[2].x,
2122 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
2123 (void) ConcatenateString(&path,message);
2124 in_subpath=MagickFalse;
2134 length-=MagickMin(24,(ssize_t) length);
2142 (void) FormatLocaleString(message,MaxTextExtent,
" eoclip\n");
2143 (void) ConcatenateString(&path,message);
2144 (void) FormatLocaleString(message,MaxTextExtent,
"} bind def");
2145 (void) ConcatenateString(&path,message);
2146 message=DestroyString(message);
2150static inline void TraceBezierCurve(
char *message,PointInfo *last,
2157 if (((last+1)->x == (last+2)->x) && ((last+1)->y == (last+2)->y) &&
2158 (point->x == (point+1)->x) && (point->y == (point+1)->y))
2159 (void) FormatLocaleString(message,MagickPathExtent,
2160 "L %g %g\n",point[1].x,point[1].y);
2162 (
void) FormatLocaleString(message,MagickPathExtent,
"C %g %g %g %g %g %g\n",
2163 (last+2)->x,(last+2)->y,point->x,point->y,(point+1)->x,(point+1)->y);
2166static char *TraceSVGClippath(
const unsigned char *blob,
size_t length,
2167 const size_t columns,
const size_t rows)
2190 path=AcquireString((
char *) NULL);
2191 if (path == (
char *) NULL)
2192 return((
char *) NULL);
2193 message=AcquireString((
char *) NULL);
2194 (void) FormatLocaleString(message,MaxTextExtent,(
2195 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n"
2196 "<svg xmlns=\"http://www.w3.org/2000/svg\""
2197 " width=\"%.20g\" height=\"%.20g\">\n"
2199 "<path fill-rule=\"evenodd\" style=\"fill:#000000;stroke:#000000;"
2200 "stroke-width:0;stroke-antialiasing:false\" d=\"\n"),(
double) columns,
2202 (void) ConcatenateString(&path,message);
2203 (void) memset(point,0,
sizeof(point));
2204 (void) memset(first,0,
sizeof(first));
2205 (void) memset(last,0,
sizeof(last));
2207 in_subpath=MagickFalse;
2210 selector=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2216 if (knot_count != 0)
2219 length-=MagickMin(24,(ssize_t) length);
2225 knot_count=(ssize_t) ReadPropertyMSBShort(&blob,&length);
2227 length-=MagickMin(22,(ssize_t) length);
2235 if (knot_count == 0)
2241 length-=MagickMin(24,(ssize_t) length);
2247 for (i=0; i < 3; i++)
2249 y=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2250 x=(ssize_t) ReadPropertyMSBLong(&blob,&length);
2251 point[i].x=(double) x*columns/4096.0/4096.0;
2252 point[i].y=(double) y*rows/4096.0/4096.0;
2254 if (in_subpath == MagickFalse)
2256 (void) FormatLocaleString(message,MaxTextExtent,
"M %g %g\n",
2257 point[1].x,point[1].y);
2258 for (i=0; i < 3; i++)
2266 TraceBezierCurve(message,last,point);
2267 for (i=0; i < 3; i++)
2270 (void) ConcatenateString(&path,message);
2271 in_subpath=MagickTrue;
2276 if (knot_count == 0)
2278 TraceBezierCurve(message,last,first);
2279 (void) ConcatenateString(&path,message);
2280 in_subpath=MagickFalse;
2290 length-=MagickMin(24,(ssize_t) length);
2298 (void) ConcatenateString(&path,
"\"/>\n</g>\n</svg>\n");
2299 message=DestroyString(message);
2303MagickExport
const char *GetImageProperty(
const Image *image,
2304 const char *property)
2321 assert(image != (Image *) NULL);
2322 assert(image->signature == MagickCoreSignature);
2323 if (IsEventLogging() != MagickFalse)
2324 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2325 p=(
const char *) NULL;
2326 if (image->properties != (
void *) NULL)
2328 if (property == (
const char *) NULL)
2330 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
2331 p=(
const char *) GetNextValueInSplayTree((SplayTreeInfo *)
2335 if (LocaleNCompare(
"fx:",property,3) != 0)
2337 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2338 image->properties,property);
2339 if (p != (
const char *) NULL)
2343 if ((property == (
const char *) NULL) ||
2344 (strchr(property,
':') == (
char *) NULL))
2346 exception=(&((Image *) image)->exception);
2351 if (LocaleNCompare(
"8bim:",property,5) == 0)
2353 (void) Get8BIMProperty(image,property);
2361 if (LocaleNCompare(
"exif:",property,5) == 0)
2363 (void) GetEXIFProperty(image,property);
2371 if (LocaleNCompare(
"fx:",property,3) == 0)
2373 if ((image->columns == 0) || (image->rows == 0))
2375 fx_info=AcquireFxInfo(image,property+3);
2376 status=FxEvaluateChannelExpression(fx_info,DefaultChannels,0,0,&alpha,
2378 fx_info=DestroyFxInfo(fx_info);
2379 if (status != MagickFalse)
2382 value[MaxTextExtent];
2384 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
2385 GetMagickPrecision(),(
double) alpha);
2386 (void) SetImageProperty((Image *) image,property,value);
2395 if (LocaleNCompare(
"hex:",property,4) == 0)
2400 if ((image->columns == 0) || (image->rows == 0))
2402 GetMagickPixelPacket(image,&pixel);
2403 fx_info=AcquireFxInfo(image,property+4);
2404 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2406 pixel.red=(MagickRealType) QuantumRange*alpha;
2407 status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2409 pixel.green=(MagickRealType) QuantumRange*alpha;
2410 status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2412 pixel.blue=(MagickRealType) QuantumRange*alpha;
2413 status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2415 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2416 if (image->colorspace == CMYKColorspace)
2418 status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2420 pixel.index=(MagickRealType) QuantumRange*alpha;
2422 fx_info=DestroyFxInfo(fx_info);
2423 if (status != MagickFalse)
2428 GetColorTuple(&pixel,MagickTrue,hex);
2429 (void) SetImageProperty((Image *) image,property,hex+1);
2438 if ((LocaleNCompare(
"icc:",property,4) == 0) ||
2439 (LocaleNCompare(
"icm:",property,4) == 0))
2441 (void) GetICCProperty(image);
2444 if (LocaleNCompare(
"iptc:",property,5) == 0)
2446 (void) GetIPTCProperty(image,property);
2454 if (LocaleNCompare(
"pixel:",property,6) == 0)
2459 GetMagickPixelPacket(image,&pixel);
2460 fx_info=AcquireFxInfo(image,property+6);
2461 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2463 pixel.red=(MagickRealType) QuantumRange*alpha;
2464 status&=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2466 pixel.green=(MagickRealType) QuantumRange*alpha;
2467 status&=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2469 pixel.blue=(MagickRealType) QuantumRange*alpha;
2470 status&=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2472 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2473 if (image->colorspace == CMYKColorspace)
2475 status&=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2477 pixel.index=(MagickRealType) QuantumRange*alpha;
2479 fx_info=DestroyFxInfo(fx_info);
2480 if (status != MagickFalse)
2483 name[MaxTextExtent];
2488 GetColorTuple(&pixel,MagickFalse,name);
2489 value=GetImageArtifact(image,
"pixel:compliance");
2490 if (value != (
char *) NULL)
2492 ComplianceType compliance=(ComplianceType) ParseCommandOption(
2493 MagickComplianceOptions,MagickFalse,value);
2494 (void) QueryMagickColorname(image,&pixel,compliance,name,
2497 (void) SetImageProperty((Image *) image,property,name);
2506 if (LocaleNCompare(
"xmp:",property,4) == 0)
2508 (void) GetXMPProperty(image,property);
2516 if (image->properties != (
void *) NULL)
2518 p=(
const char *) GetValueFromSplayTree((SplayTreeInfo *)
2519 image->properties,property);
2522 return((
const char *) NULL);
2611static const char *GetMagickPropertyLetter(
const ImageInfo *image_info,
2612 Image *image,
const char letter)
2614#define WarnNoImageInfoReturn(format,arg) \
2615 if (image_info == (ImageInfo *) NULL ) { \
2616 (void) ThrowMagickException(&image->exception,GetMagickModule(), \
2617 OptionWarning,"NoImageInfoForProperty",format,arg); \
2618 return((const char *) NULL); \
2622 value[MaxTextExtent];
2627 assert(image != (Image *) NULL);
2628 assert(image->signature == MagickCoreSignature);
2629 if (IsEventLogging() != MagickFalse)
2630 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
2632 string=(
char *) NULL;
2640 (void) FormatMagickSize(image->extent,MagickFalse,value);
2641 if (image->extent == 0)
2642 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,value);
2650 string=GetImageProperty(image,
"comment");
2651 if (
string == (
const char *) NULL)
2660 GetPathComponent(image->magick_filename,HeadPath,value);
2670 GetPathComponent(image->magick_filename,ExtensionPath,value);
2680 GetPathComponent(image->magick_filename,TailPath,value);
2690 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g%+.20g%+.20g",
2691 (
double) image->page.width,(
double) image->page.height,
2692 (
double) image->page.x,(
double) image->page.y);
2700 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2701 (image->rows != 0 ? image->rows : image->magick_rows));
2709 string=image->filename;
2717 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2718 GetNumberColors(image,(FILE *) NULL,&image->exception));
2726 string=GetImageProperty(image,
"label");
2727 if (
string == (
const char *) NULL)
2736 string=image->magick;
2744 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2745 GetImageListLength(image));
2753 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2754 string=image_info->filename;
2762 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2763 GetImageIndexInList(image));
2771 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2772 MAGICKCORE_QUANTUM_DEPTH);
2783 colorspace=image->colorspace;
2784 if ((image->columns != 0) && (image->rows != 0) &&
2785 (SetImageGray(image,&image->exception) != MagickFalse))
2786 colorspace=GRAYColorspace;
2787 (void) FormatLocaleString(value,MaxTextExtent,
"%s %s %s",
2788 CommandOptionToMnemonic(MagickClassOptions,(ssize_t)
2789 image->storage_class),CommandOptionToMnemonic(MagickColorspaceOptions,
2790 (ssize_t) colorspace),image->matte != MagickFalse ?
"Matte" :
"" );
2798 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2799 if (image_info->number_scenes != 0)
2800 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2803 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2812 GetPathComponent(image->magick_filename,BasePath,value);
2822 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2823 string=image_info->unique;
2831 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2832 (image->columns != 0 ? image->columns : image->magick_columns));
2840 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
2841 fabs(image->x_resolution) > MagickEpsilon ? image->x_resolution :
2842 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2851 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
2852 fabs(image->y_resolution) > MagickEpsilon ? image->y_resolution :
2853 image->units == PixelsPerCentimeterResolution ? DefaultResolution/2.54 :
2862 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2871 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2872 CommandOptionToMnemonic(MagickBooleanOptions,(ssize_t) image->matte));
2880 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2882 if (image->extent == 0)
2883 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2884 GetBlobSize(image));
2892 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2893 CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
2894 image->compression));
2902 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
2903 CommandOptionToMnemonic(MagickDisposeOptions,(ssize_t) image->dispose));
2916 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
2917 "$-_.+!*'(),{}|\\^~[]`\"><#%;/?:@&=";
2922 (void) CopyMagickString(value,image->magick_filename,MaxTextExtent);
2924 q=value+strlen(value);
2925 for (p+=strspn(p,allowlist); p != q; p+=(ptrdiff_t) strspn(p,allowlist))
2934 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
2935 image->magick_columns,(
double) image->magick_rows);
2943 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2944 image->page.height);
2952 string=image->magick_filename;
2957 if ((image != (Image *) NULL) && (image->next == (Image *) NULL))
2958 (void) FormatLocaleString(value,MagickPathExtent,
"%.20g\n",(
double)
2959 GetImageListLength(image));
2969 (void) FormatLocaleString(value,MaxTextExtent,
"%+ld%+ld",(
long)
2970 image->page.x,(
long) image->page.y);
2978 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
2979 image->page.width,(
double) image->page.height);
2987 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
2988 (image->quality == 0 ? 92 : image->quality));
2996 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
2997 if (image_info->number_scenes == 0)
2998 string=
"2147483647";
3000 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3001 image_info->scene+image_info->number_scenes);
3009 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3018 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
3019 CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3028 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3037 (void) FormatLocaleString(value,MaxTextExtent,
"%+.20g",(
double)
3046 (void) FormatLocaleString(value,MaxTextExtent,
"%+.20g",(
double)
3055 WarnNoImageInfoReturn(
"\"%%%c\"",letter);
3056 string=image_info->zero;
3067 page=GetImageBoundingBox(image,&image->exception);
3068 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g%+.20g%+.20g",
3069 (
double) page.width,(
double) page.height,(
double) page.x,(
double)
3078 if ((image->columns != 0) && (image->rows != 0))
3079 (void) SignatureImage(image);
3080 string=GetImageProperty(image,
"signature");
3094 if (
string != (
char *) NULL)
3096 (void) SetImageArtifact(image,
"get-property",
string);
3097 return(GetImageArtifact(image,
"get-property"));
3099 return((
char *) NULL);
3102MagickExport
const char *GetMagickProperty(
const ImageInfo *image_info,
3103 Image *image,
const char *property)
3106 value[MaxTextExtent];
3111 assert(property != (
const char *) NULL);
3112 assert(property[0] !=
'\0');
3113 if (property[1] ==
'\0')
3114 return(GetMagickPropertyLetter(image_info,image,*property));
3116 string=(
char *) NULL;
3121 if ((LocaleCompare(
"base",property) == 0) ||
3122 (LocaleCompare(
"basename",property) == 0) )
3124 GetPathComponent(image->magick_filename,BasePath,value);
3127 if (LocaleCompare(
"bit-depth",property) == 0)
3129 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3130 GetImageDepth(image,&image->exception));
3133 if (LocaleCompare(
"bounding-box",property) == 0)
3138 geometry=GetImageBoundingBox(image,&image->exception);
3139 (void) FormatLocaleString(value,MagickPathExtent,
"%g,%g %g,%g\n",
3140 (
double) geometry.x,(
double) geometry.y,
3141 (
double) geometry.x+geometry.width,
3142 (
double) geometry.y+geometry.height);
3149 if (LocaleCompare(
"channels",property) == 0)
3154 (void) FormatLocaleString(value,MaxTextExtent,
"%s",
3155 CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
3156 image->colorspace));
3158 if (image->matte != MagickFalse)
3159 (void) ConcatenateMagickString(value,
"a",MaxTextExtent);
3162 if (LocaleCompare(
"colors",property) == 0)
3164 image->colors=GetNumberColors(image,(FILE *) NULL,&image->exception);
3165 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3169 if (LocaleCompare(
"colorspace",property) == 0)
3171 string=CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
3175 if (LocaleCompare(
"compose",property) == 0)
3177 string=CommandOptionToMnemonic(MagickComposeOptions,(ssize_t)
3181 if (LocaleCompare(
"compression",property) == 0)
3183 string=CommandOptionToMnemonic(MagickCompressOptions,(ssize_t)
3184 image->compression);
3187 if (LocaleCompare(
"copyright",property) == 0)
3189 (void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
3196 if (LocaleCompare(
"depth",property) == 0)
3198 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3202 if (LocaleCompare(
"directory",property) == 0)
3204 GetPathComponent(image->magick_filename,HeadPath,value);
3211 if (LocaleCompare(
"entropy",property) == 0)
3216 (void) GetImageChannelEntropy(image,image_info->channel,&entropy,
3218 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3219 GetMagickPrecision(),entropy);
3222 if (LocaleCompare(
"extension",property) == 0)
3224 GetPathComponent(image->magick_filename,ExtensionPath,value);
3231 if (LocaleCompare(
"gamma",property) == 0)
3233 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3234 GetMagickPrecision(),image->gamma);
3237 if ((image_info != (ImageInfo *) NULL) &&
3238 (LocaleCompare(
"group",property) == 0))
3240 (void) FormatLocaleString(value,MaxTextExtent,
"0x%lx",(
unsigned long)
3248 if (LocaleCompare(
"height",property) == 0)
3250 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3251 image->magick_rows != 0 ? (
double) image->magick_rows : 256.0);
3258 if (LocaleCompare(
"input",property) == 0)
3260 string=image->filename;
3263 if (LocaleCompare(
"interlace",property) == 0)
3265 string=CommandOptionToMnemonic(MagickInterlaceOptions,(ssize_t)
3273 if (LocaleCompare(
"kurtosis",property) == 0)
3279 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
3280 &skewness,&image->exception);
3281 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3282 GetMagickPrecision(),kurtosis);
3289 if (LocaleCompare(
"magick",property) == 0)
3291 string=image->magick;
3294 if ((LocaleCompare(
"max",property) == 0) ||
3295 (LocaleCompare(
"maxima",property) == 0))
3301 (void) GetImageChannelRange(image,image_info->channel,&minimum,
3302 &maximum,&image->exception);
3303 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3304 GetMagickPrecision(),maximum);
3307 if (LocaleCompare(
"mean",property) == 0)
3313 (void) GetImageChannelMean(image,image_info->channel,&mean,
3314 &standard_deviation,&image->exception);
3315 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3316 GetMagickPrecision(),mean);
3319 if ((LocaleCompare(
"min",property) == 0) ||
3320 (LocaleCompare(
"minima",property) == 0))
3326 (void) GetImageChannelRange(image,image_info->channel,&minimum,
3327 &maximum,&image->exception);
3328 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3329 GetMagickPrecision(),minimum);
3336 if (LocaleCompare(
"opaque",property) == 0)
3341 opaque=IsOpaqueImage(image,&image->exception);
3342 (void) CopyMagickString(value,opaque != MagickFalse ?
"true" :
3343 "false",MaxTextExtent);
3346 if (LocaleCompare(
"orientation",property) == 0)
3348 string=CommandOptionToMnemonic(MagickOrientationOptions,(ssize_t)
3349 image->orientation);
3352 if ((image_info != (ImageInfo *) NULL) &&
3353 (LocaleCompare(
"output",property) == 0))
3355 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
3362 if (LocaleCompare(
"page",property) == 0)
3364 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",(
double)
3365 image->page.width,(
double) image->page.height);
3368 if (LocaleNCompare(
"papersize:",property,10) == 0)
3374 papersize=GetPageGeometry(property+10);
3375 if (papersize != (
const char *) NULL)
3378 page = { 0, 0, 0, 0 };
3380 (void) ParseAbsoluteGeometry(papersize,&page);
3381 (void) FormatLocaleString(value,MaxTextExtent,
"%.20gx%.20g",
3382 (
double) page.width,(
double) page.height);
3383 papersize=DestroyString(papersize);
3387#if defined(MAGICKCORE_LCMS_DELEGATE)
3388 if (LocaleCompare(
"profile:icc",property) == 0 ||
3389 LocaleCompare(
"profile:icm",property) == 0)
3391#if !defined(LCMS_VERSION) || (LCMS_VERSION < 2000)
3392#define cmsUInt32Number DWORD
3401 profile=GetImageProfile(image,property+8);
3402 if (profile == (StringInfo *) NULL)
3405 icc_profile=cmsOpenProfileFromMem(GetStringInfoDatum(profile),
3406 (cmsUInt32Number) GetStringInfoLength(profile));
3407 if (icc_profile != (cmsHPROFILE *) NULL)
3409#if defined(LCMS_VERSION) && (LCMS_VERSION < 2000)
3410 string=cmsTakeProductName(icc_profile);
3412 (void) cmsGetProfileInfoASCII(icc_profile,cmsInfoDescription,
3413 "en",
"US",value,MaxTextExtent);
3415 (void) cmsCloseProfile(icc_profile);
3419 if (LocaleCompare(
"printsize.x",property) == 0)
3421 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3422 GetMagickPrecision(),MagickSafeReciprocal(image->x_resolution)*
3426 if (LocaleCompare(
"printsize.y",property) == 0)
3428 (void) FormatLocaleString(value,MagickPathExtent,
"%.*g",
3429 GetMagickPrecision(),MagickSafeReciprocal(image->y_resolution)*
3433 if (LocaleCompare(
"profiles",property) == 0)
3438 ResetImageProfileIterator(image);
3439 name=GetNextImageProfile(image);
3440 if (name != (
char *) NULL)
3442 (void) CopyMagickString(value,name,MaxTextExtent);
3443 name=GetNextImageProfile(image);
3444 while (name != (
char *) NULL)
3446 ConcatenateMagickString(value,
",",MaxTextExtent);
3447 ConcatenateMagickString(value,name,MaxTextExtent);
3448 name=GetNextImageProfile(image);
3457 if (LocaleCompare(
"quality",property) == 0)
3459 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3467 if (LocaleCompare(
"rendering-intent",property) == 0)
3469 string=CommandOptionToMnemonic(MagickIntentOptions,(ssize_t)
3470 image->rendering_intent);
3473 if (LocaleCompare(
"resolution.x",property) == 0)
3475 (void) FormatLocaleString(value,MaxTextExtent,
"%g",
3476 image->x_resolution);
3479 if (LocaleCompare(
"resolution.y",property) == 0)
3481 (void) FormatLocaleString(value,MaxTextExtent,
"%g",
3482 image->y_resolution);
3489 if (LocaleCompare(
"scene",property) == 0)
3491 if ((image_info != (ImageInfo *) NULL) &&
3492 (image_info->number_scenes != 0))
3493 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3496 (
void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3500 if (LocaleCompare(
"scenes",property) == 0)
3502 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3503 GetImageListLength(image));
3506 if (LocaleCompare(
"size",property) == 0)
3508 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,value);
3511 if (LocaleCompare(
"skewness",property) == 0)
3517 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
3518 &skewness,&image->exception);
3519 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3520 GetMagickPrecision(),skewness);
3523 if ((LocaleCompare(
"standard-deviation",property) == 0) ||
3524 (LocaleCompare(
"standard_deviation",property) == 0))
3530 (void) GetImageChannelMean(image,image_info->channel,&mean,
3531 &standard_deviation,&image->exception);
3532 (void) FormatLocaleString(value,MaxTextExtent,
"%.*g",
3533 GetMagickPrecision(),standard_deviation);
3540 if (LocaleCompare(
"type",property) == 0)
3542 string=CommandOptionToMnemonic(MagickTypeOptions,(ssize_t)
3543 IdentifyImageType(image,&image->exception));
3550 if ((image_info != (ImageInfo *) NULL) &&
3551 (LocaleCompare(
"unique",property) == 0))
3553 string=image_info->unique;
3556 if (LocaleCompare(
"units",property) == 0)
3561 string=CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
3569 if (LocaleCompare(
"version",property) == 0)
3571 string=GetMagickVersion((
size_t *) NULL);
3578 if (LocaleCompare(
"width",property) == 0)
3580 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",(
double)
3581 (image->magick_columns != 0 ? image->magick_columns : 256));
3588 if ((LocaleCompare(
"xresolution",property) == 0) ||
3589 (LocaleCompare(
"x-resolution",property) == 0) )
3591 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3592 image->x_resolution);
3599 if ((LocaleCompare(
"yresolution",property) == 0) ||
3600 (LocaleCompare(
"y-resolution",property) == 0) )
3602 (void) FormatLocaleString(value,MaxTextExtent,
"%.20g",
3603 image->y_resolution);
3610 if ((image_info != (ImageInfo *) NULL) &&
3611 (LocaleCompare(
"zero",property) == 0))
3613 string=image_info->zero;
3621 if (
string != (
char *) NULL)
3623 (void) SetImageArtifact(image,
"get-property",
string);
3624 return(GetImageArtifact(image,
"get-property"));
3626 return((
char *) NULL);
3651MagickExport
char *GetNextImageProperty(
const Image *image)
3653 assert(image != (Image *) NULL);
3654 assert(image->signature == MagickCoreSignature);
3655 if (IsEventLogging() != MagickFalse)
3656 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
3658 if (image->properties == (
void *) NULL)
3659 return((
char *) NULL);
3660 return((
char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
3715MagickExport
char *InterpretImageProperties(
const ImageInfo *image_info,
3716 Image *image,
const char *embed_text)
3718#define ExtendInterpretText(string_length) \
3720 size_t length=(string_length); \
3721 if ((size_t) (q-interpret_text+length+1) >= extent) \
3724 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3725 MaxTextExtent,sizeof(*interpret_text)); \
3726 if (interpret_text == (char *) NULL) \
3728 if (property_info != image_info) \
3729 property_info=DestroyImageInfo(property_info); \
3730 return((char *) NULL); \
3732 q=interpret_text+strlen(interpret_text); \
3736#define AppendKeyValue2Text(key,value)\
3738 size_t length=strlen(key)+strlen(value)+2; \
3739 if ((size_t) (q-interpret_text+length+1) >= extent) \
3742 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3743 MaxTextExtent,sizeof(*interpret_text)); \
3744 if (interpret_text == (char *) NULL) \
3746 if (property_info != image_info) \
3747 property_info=DestroyImageInfo(property_info); \
3748 return((char *) NULL); \
3750 q=interpret_text+strlen(interpret_text); \
3752 q+=(ptrdiff_t) FormatLocaleString(q,extent,"%s=%s\n",(key),(value)); \
3755#define AppendString2Text(string) \
3757 size_t length=strlen((string)); \
3758 if ((size_t) (q-interpret_text+length+1) >= extent) \
3761 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+ \
3762 MaxTextExtent,sizeof(*interpret_text)); \
3763 if (interpret_text == (char *) NULL) \
3765 if (property_info != image_info) \
3766 property_info=DestroyImageInfo(property_info); \
3767 return((char *) NULL); \
3769 q=interpret_text+strlen(interpret_text); \
3771 (void) CopyMagickString(q,(string),extent); \
3772 q+=(ptrdiff_t) length; \
3793 assert(image != (Image *) NULL);
3794 assert(image->signature == MagickCoreSignature);
3795 if (IsEventLogging() != MagickFalse)
3796 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",image->filename);
3797 if (embed_text == (
const char *) NULL)
3798 return(ConstantString(
""));
3800 while ((isspace((
int) ((
unsigned char) *p)) != 0) && (*p !=
'\0'))
3803 return(ConstantString(
""));
3804 if ((*p ==
'@') && (IsPathAccessible(p+1) != MagickFalse))
3809 if (IsRightsAuthorized(PathPolicyDomain,ReadPolicyRights,p) == MagickFalse)
3812 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3813 PolicyError,
"NotAuthorized",
"`%s'",p);
3814 return(ConstantString(
""));
3816 interpret_text=FileToString(p,~0UL,&image->exception);
3817 if (interpret_text != (
char *) NULL)
3818 return(interpret_text);
3823 if (image_info != (ImageInfo *) NULL)
3824 property_info=(ImageInfo *) image_info;
3826 property_info=CloneImageInfo(image_info);
3827 interpret_text=AcquireString(embed_text);
3828 extent=MaxTextExtent;
3830 for (q=interpret_text; *p!=
'\0';
3831 number=(isdigit((
int) ((
unsigned char) *p))) ? MagickTrue : MagickFalse,p++)
3837 ExtendInterpretText(MaxTextExtent);
3880 if (LocaleNCompare(
"<",p,4) == 0)
3886 if (LocaleNCompare(
">",p,4) == 0)
3892 if (LocaleNCompare(
"&",p,5) == 0)
3913 if ((*p ==
'\0') || (*p ==
'\'') || (*p ==
'"'))
3929 if (number != MagickFalse)
3935 value=GetMagickPropertyLetter(property_info,image,*p);
3936 if (value != (
char *) NULL)
3938 AppendString2Text(value);
3941 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3942 OptionWarning,
"UnknownImageProperty",
"\"%%%c\"",*p);
3947 pattern[2*MaxTextExtent] =
"\0";
3966 (void) ThrowMagickException(&image->exception,GetMagickModule(),
3967 OptionWarning,
"UnknownImageProperty",
"\"%%[]\"");
3970 for (len=0; len<(MaxTextExtent-1L) && (*p !=
'\0');)
3972 if ((*p ==
'\\') && (*(p+1) !=
'\0'))
3977 pattern[len++]=(*p++);
3978 pattern[len++]=(*p++);
3987 pattern[len++]=(*p++);
4002 (void) ThrowMagickException(&image->exception,GetMagickModule(),
4003 OptionError,
"UnbalancedBraces",
"\"%%[%s\"",pattern);
4004 interpret_text=DestroyString(interpret_text);
4005 if (property_info != image_info)
4006 property_info=DestroyImageInfo(property_info);
4007 return((
char *) NULL);
4012 if (LocaleNCompare(
"fx:",pattern,3) == 0)
4026 fx_info=AcquireFxInfo(image,pattern+3);
4027 status=FxEvaluateChannelExpression(fx_info,property_info->channel,0,0,
4028 &value,&image->exception);
4029 fx_info=DestroyFxInfo(fx_info);
4030 if (status != MagickFalse)
4033 result[MagickPathExtent];
4035 (void) FormatLocaleString(result,MagickPathExtent,
"%.*g",
4036 GetMagickPrecision(),(
double) value);
4037 AppendString2Text(result);
4041 if (LocaleNCompare(
"option:",pattern,7) == 0)
4046 if (IsGlob(pattern+7) != MagickFalse)
4048 ResetImageOptionIterator(property_info);
4049 while ((key=GetNextImageOption(property_info)) != (
const char *) NULL)
4050 if (GlobExpression(key,pattern+7,MagickTrue) != MagickFalse)
4052 value=GetImageOption(property_info,key);
4053 if (value != (
const char *) NULL)
4054 AppendKeyValue2Text(key,value);
4059 value=GetImageOption(property_info,pattern+7);
4060 if (value != (
char *) NULL)
4061 AppendString2Text(value);
4065 if (LocaleNCompare(
"artifact:",pattern,9) == 0)
4070 if (IsGlob(pattern+9) != MagickFalse)
4072 ResetImageArtifactIterator(image);
4073 while ((key=GetNextImageArtifact(image)) != (
const char *) NULL)
4074 if (GlobExpression(key,pattern+9,MagickTrue) != MagickFalse)
4076 value=GetImageArtifact(image,key);
4077 if (value != (
const char *) NULL)
4078 AppendKeyValue2Text(key,value);
4083 value=GetImageArtifact(image,pattern+9);
4084 if (value != (
char *) NULL)
4085 AppendString2Text(value);
4095 value=GetImageProperty(image,pattern);
4096 if (value != (
const char *) NULL)
4098 AppendString2Text(value);
4105 if (IsGlob(pattern) != MagickFalse)
4107 ResetImagePropertyIterator(image);
4108 while ((key=GetNextImageProperty(image)) != (
const char *) NULL)
4109 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
4111 value=GetImageProperty(image,key);
4112 if (value != (
const char *) NULL)
4113 AppendKeyValue2Text(key,value);
4123 value=GetMagickProperty(property_info,image,pattern);
4124 if (value != (
const char *) NULL)
4126 AppendString2Text(value);
4132 value=GetImageArtifact(image,pattern);
4133 if (value != (
char *) NULL)
4135 AppendString2Text(value);
4141 value=GetImageOption(property_info,pattern);
4142 if (value != (
char *) NULL)
4144 AppendString2Text(value);
4157 (void) ThrowMagickException(&image->exception,GetMagickModule(),
4158 OptionWarning,
"UnknownImageProperty",
"\"%%[%s]\"",pattern);
4163 if (property_info != image_info)
4164 property_info=DestroyImageInfo(property_info);
4165 return(interpret_text);
4196MagickExport
char *RemoveImageProperty(Image *image,
const char *property)
4201 assert(image != (Image *) NULL);
4202 assert(image->signature == MagickCoreSignature);
4203 if (IsEventLogging() != MagickFalse)
4204 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4206 if (image->properties == (
void *) NULL)
4207 return((
char *) NULL);
4208 value=(
char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
4237MagickExport
void ResetImagePropertyIterator(
const Image *image)
4239 assert(image != (Image *) NULL);
4240 assert(image->signature == MagickCoreSignature);
4241 if (IsEventLogging() != MagickFalse)
4242 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4244 if (image->properties == (
void *) NULL)
4246 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
4277MagickExport MagickBooleanType SetImageProperty(Image *image,
4278 const char *property,
const char *value)
4293 assert(image != (Image *) NULL);
4294 assert(image->signature == MagickCoreSignature);
4295 if (IsEventLogging() != MagickFalse)
4296 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
4298 if (image->properties == (
void *) NULL)
4299 image->properties=NewSplayTree(CompareSplayTreeString,
4300 RelinquishMagickMemory,RelinquishMagickMemory);
4301 if (value == (
const char *) NULL)
4302 return(DeleteImageProperty(image,property));
4303 exception=(&image->exception);
4304 property_length=strlen(property);
4305 if ((property_length > 2) && (*(property+(property_length-2)) ==
':') &&
4306 (*(property+(property_length-1)) ==
'*'))
4308 (void) ThrowMagickException(exception,GetMagickModule(),
4309 OptionWarning,
"SetReadOnlyProperty",
"`%s'",property);
4310 return(MagickFalse);
4325 if (LocaleCompare(
"background",property) == 0)
4327 (void) QueryColorDatabase(value,&image->background_color,exception);
4330 if (LocaleCompare(
"bias",property) == 0)
4332 image->bias=StringToDoubleInterval(value,(
double) QuantumRange+1.0);
4335 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4336 ConstantString(property),ConstantString(value));
4342 if (LocaleCompare(
"colorspace",property) == 0)
4347 colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
4351 status=SetImageColorspace(image,(ColorspaceType) colorspace);
4354 if (LocaleCompare(
"compose",property) == 0)
4359 compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
4362 image->compose=(CompositeOperator) compose;
4365 if (LocaleCompare(
"compress",property) == 0)
4370 compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
4372 if (compression < 0)
4374 image->compression=(CompressionType) compression;
4377 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4378 ConstantString(property),ConstantString(value));
4384 if (LocaleCompare(
"delay",property) == 0)
4389 flags=ParseGeometry(value,&geometry_info);
4390 if ((flags & GreaterValue) != 0)
4392 if (image->delay > (
size_t) floor(geometry_info.rho+0.5))
4393 image->delay=(size_t) floor(geometry_info.rho+0.5);
4396 if ((flags & LessValue) != 0)
4398 if ((
double) image->delay < floor(geometry_info.rho+0.5))
4399 image->ticks_per_second=CastDoubleToLong(
4400 floor(geometry_info.sigma+0.5));
4403 image->delay=(size_t) floor(geometry_info.rho+0.5);
4404 if ((flags & SigmaValue) != 0)
4405 image->ticks_per_second=CastDoubleToLong(floor(
4406 geometry_info.sigma+0.5));
4409 if (LocaleCompare(
"density",property) == 0)
4414 flags=ParseGeometry(value,&geometry_info);
4415 if ((flags & RhoValue) != 0)
4416 image->x_resolution=geometry_info.rho;
4417 image->y_resolution=image->x_resolution;
4418 if ((flags & SigmaValue) != 0)
4419 image->y_resolution=geometry_info.sigma;
4421 if (LocaleCompare(
"depth",property) == 0)
4423 image->depth=StringToUnsignedLong(value);
4426 if (LocaleCompare(
"dispose",property) == 0)
4431 dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
4434 image->dispose=(DisposeType) dispose;
4437 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4438 ConstantString(property),ConstantString(value));
4444 if (LocaleCompare(
"gamma",property) == 0)
4446 image->gamma=StringToDouble(value,(
char **) NULL);
4449 if (LocaleCompare(
"gravity",property) == 0)
4454 gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
4457 image->gravity=(GravityType) gravity;
4460 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4461 ConstantString(property),ConstantString(value));
4467 if (LocaleCompare(
"intensity",property) == 0)
4472 intensity=ParseCommandOption(MagickPixelIntensityOptions,MagickFalse,
4476 image->intensity=(PixelIntensityMethod) intensity;
4479 if (LocaleCompare(
"interpolate",property) == 0)
4484 interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
4486 if (interpolate < 0)
4488 image->interpolate=(InterpolatePixelMethod) interpolate;
4491 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4492 ConstantString(property),ConstantString(value));
4498 if (LocaleCompare(
"loop",property) == 0)
4500 image->iterations=StringToUnsignedLong(value);
4503 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4504 ConstantString(property),ConstantString(value));
4510 if (LocaleCompare(
"page",property) == 0)
4515 geometry=GetPageGeometry(value);
4516 flags=ParseAbsoluteGeometry(geometry,&image->page);
4517 geometry=DestroyString(geometry);
4520 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4521 ConstantString(property),ConstantString(value));
4527 if (LocaleCompare(
"rendering-intent",property) == 0)
4532 rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
4534 if (rendering_intent < 0)
4536 image->rendering_intent=(RenderingIntent) rendering_intent;
4539 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4540 ConstantString(property),ConstantString(value));
4546 if (LocaleCompare(
"tile-offset",property) == 0)
4551 geometry=GetPageGeometry(value);
4552 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
4553 geometry=DestroyString(geometry);
4556 if (LocaleCompare(
"type",property) == 0)
4561 type=ParseCommandOption(MagickTypeOptions,MagickFalse,value);
4563 return(MagickFalse);
4564 image->type=(ImageType) type;
4567 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4568 ConstantString(property),ConstantString(value));
4574 if (LocaleCompare(
"units",property) == 0)
4579 units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
4582 image->units=(ResolutionType) units;
4585 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4586 ConstantString(property),ConstantString(value));
4591 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
4592 ConstantString(property),ConstantString(value));