2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6
% PPPP RRRR OOO PPPP EEEEE RRRR TTTTT Y Y %
7
% P P R R O O P P E R R T Y Y %
8
% PPPP RRRR O O PPPP EEE RRRR T Y %
9
% P R R O O P E R R T Y %
10
% P R R OOO P EEEEE R R T Y %
13
% MagickCore Property Methods %
20
% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21
% dedicated to making software imaging solutions freely available. %
23
% You may not use this file except in compliance with the License. You may %
24
% obtain a copy of the License at %
26
% http://www.imagemagick.org/script/license.php %
28
% Unless required by applicable law or agreed to in writing, software %
29
% distributed under the License is distributed on an "AS IS" BASIS, %
30
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31
% See the License for the specific language governing permissions and %
32
% limitations under the License. %
34
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43
#include "magick/studio.h"
44
#include "magick/attribute.h"
45
#include "magick/cache.h"
46
#include "magick/color.h"
47
#include "magick/compare.h"
48
#include "magick/constitute.h"
49
#include "magick/draw.h"
50
#include "magick/effect.h"
51
#include "magick/exception.h"
52
#include "magick/exception-private.h"
53
#include "magick/fx.h"
54
#include "magick/fx-private.h"
55
#include "magick/gem.h"
56
#include "magick/geometry.h"
57
#include "magick/histogram.h"
58
#include "magick/image.h"
59
#include "magick/image.h"
60
#include "magick/layer.h"
61
#include "magick/list.h"
62
#include "magick/magick.h"
63
#include "magick/memory_.h"
64
#include "magick/monitor.h"
65
#include "magick/montage.h"
66
#include "magick/option.h"
67
#include "magick/profile.h"
68
#include "magick/property.h"
69
#include "magick/quantum.h"
70
#include "magick/resource_.h"
71
#include "magick/splay-tree.h"
72
#include "magick/signature-private.h"
73
#include "magick/statistic.h"
74
#include "magick/string_.h"
75
#include "magick/string-private.h"
76
#include "magick/token.h"
77
#include "magick/utility.h"
78
#include "magick/version.h"
79
#include "magick/xml-tree.h"
82
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
86
% C l o n e I m a g e P r o p e r t i e s %
90
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92
% CloneImageProperties() clones one or more image properties.
94
% The format of the CloneImageProperties method is:
96
% MagickBooleanType CloneImageProperties(Image *image,
97
% const Image *clone_image)
99
% A description of each parameter follows:
101
% o image: the image.
103
% o clone_image: the clone image.
106
MagickExport MagickBooleanType CloneImageProperties(Image *image,
107
const Image *clone_image)
109
assert(image != (Image *) NULL);
110
assert(image->signature == MagickSignature);
111
if (image->debug != MagickFalse)
112
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
113
assert(clone_image != (const Image *) NULL);
114
assert(clone_image->signature == MagickSignature);
115
if (clone_image->debug != MagickFalse)
116
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
117
clone_image->filename);
118
(void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
119
(void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
121
image->compression=clone_image->compression;
122
image->quality=clone_image->quality;
123
image->depth=clone_image->depth;
124
image->background_color=clone_image->background_color;
125
image->border_color=clone_image->border_color;
126
image->matte_color=clone_image->matte_color;
127
image->transparent_color=clone_image->transparent_color;
128
image->gamma=clone_image->gamma;
129
image->chromaticity=clone_image->chromaticity;
130
image->rendering_intent=clone_image->rendering_intent;
131
image->black_point_compensation=clone_image->black_point_compensation;
132
image->units=clone_image->units;
133
image->montage=(char *) NULL;
134
image->directory=(char *) NULL;
135
(void) CloneString(&image->geometry,clone_image->geometry);
136
image->offset=clone_image->offset;
137
image->x_resolution=clone_image->x_resolution;
138
image->y_resolution=clone_image->y_resolution;
139
image->page=clone_image->page;
140
image->tile_offset=clone_image->tile_offset;
141
image->extract_info=clone_image->extract_info;
142
image->bias=clone_image->bias;
143
image->filter=clone_image->filter;
144
image->blur=clone_image->blur;
145
image->fuzz=clone_image->fuzz;
146
image->interlace=clone_image->interlace;
147
image->interpolate=clone_image->interpolate;
148
image->endian=clone_image->endian;
149
image->gravity=clone_image->gravity;
150
image->compose=clone_image->compose;
151
image->scene=clone_image->scene;
152
image->orientation=clone_image->orientation;
153
image->dispose=clone_image->dispose;
154
image->delay=clone_image->delay;
155
image->ticks_per_second=clone_image->ticks_per_second;
156
image->iterations=clone_image->iterations;
157
image->total_colors=clone_image->total_colors;
158
image->taint=clone_image->taint;
159
image->progress_monitor=clone_image->progress_monitor;
160
image->client_data=clone_image->client_data;
161
image->start_loop=clone_image->start_loop;
162
image->error=clone_image->error;
163
image->signature=clone_image->signature;
164
if (clone_image->properties != (void *) NULL)
166
if (image->properties != (void *) NULL)
167
DestroyImageProperties(image);
168
image->properties=CloneSplayTree((SplayTreeInfo *)
169
clone_image->properties,(void *(*)(void *)) ConstantString,
170
(void *(*)(void *)) ConstantString);
176
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180
% D e f i n e I m a g e P r o p e r t y %
184
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186
% DefineImageProperty() associates a key/value pair with an image property.
188
% The format of the DefineImageProperty method is:
190
% MagickBooleanType DefineImageProperty(Image *image,
191
% const char *property)
193
% A description of each parameter follows:
195
% o image: the image.
197
% o property: the image property.
200
MagickExport MagickBooleanType DefineImageProperty(Image *image,
201
const char *property)
205
value[MaxTextExtent];
210
assert(image != (Image *) NULL);
211
assert(property != (const char *) NULL);
212
(void) CopyMagickString(key,property,MaxTextExtent-1);
213
for (p=key; *p != '\0'; p++)
218
(void) CopyMagickString(value,p+1,MaxTextExtent);
220
return(SetImageProperty(image,key,value));
224
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228
% D e l e t e I m a g e P r o p e r t y %
232
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
234
% DeleteImageProperty() deletes an image property.
236
% The format of the DeleteImageProperty method is:
238
% MagickBooleanType DeleteImageProperty(Image *image,const char *property)
240
% A description of each parameter follows:
242
% o image: the image.
244
% o property: the image property.
247
MagickExport MagickBooleanType DeleteImageProperty(Image *image,
248
const char *property)
250
assert(image != (Image *) NULL);
251
assert(image->signature == MagickSignature);
252
if (image->debug != MagickFalse)
253
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
255
if (image->properties == (void *) NULL)
257
return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
261
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265
% D e s t r o y I m a g e P r o p e r t i e s %
269
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
271
% DestroyImageProperties() releases memory associated with image property
274
% The format of the DestroyDefines method is:
276
% void DestroyImageProperties(Image *image)
278
% A description of each parameter follows:
280
% o image: the image.
283
MagickExport void DestroyImageProperties(Image *image)
285
assert(image != (Image *) NULL);
286
assert(image->signature == MagickSignature);
287
if (image->debug != MagickFalse)
288
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
290
if (image->properties != (void *) NULL)
291
image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
296
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
300
% F o r m a t I m a g e P r o p e r t y %
304
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306
% FormatImageProperty() permits formatted property/value pairs to be saved as
309
% The format of the FormatImageProperty method is:
311
% MagickBooleanType FormatImageProperty(Image *image,const char *property,
312
% const char *format,...)
314
% A description of each parameter follows.
316
% o image: The image.
318
% o property: The attribute property.
320
% o format: A string describing the format to use to write the remaining
325
MagickExport MagickBooleanType FormatImagePropertyList(Image *image,
326
const char *property,const char *format,va_list operands)
329
value[MaxTextExtent];
334
#if defined(MAGICKCORE_HAVE_VSNPRINTF)
335
n=vsnprintf(value,MaxTextExtent,format,operands);
337
n=vsprintf(value,format,operands);
340
value[MaxTextExtent-1]='\0';
341
return(SetImageProperty(image,property,value));
344
MagickExport MagickBooleanType FormatImageProperty(Image *image,
345
const char *property,const char *format,...)
353
va_start(operands,format);
354
status=FormatImagePropertyList(image,property,format,operands);
360
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
364
% G e t I m a g e P r o p e r t y %
368
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
370
% GetImageProperty() gets a value associated with an image property.
372
% The format of the GetImageProperty method is:
374
% const char *GetImageProperty(const Image *image,const char *key)
376
% A description of each parameter follows:
378
% o image: the image.
385
*TracePSClippath(const unsigned char *,size_t,const size_t,
387
*TraceSVGClippath(const unsigned char *,size_t,const size_t,
390
static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
410
profile=GetImageProfile(image,"iptc");
411
if (profile == (StringInfo *) NULL)
412
profile=GetImageProfile(image,"8bim");
413
if (profile == (StringInfo *) NULL)
415
count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
418
attribute=(char *) NULL;
419
for (i=0; i < (ssize_t) GetStringInfoLength(profile); i+=(ssize_t) length)
422
if ((ssize_t) GetStringInfoDatum(profile)[i] != 0x1c)
424
length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
425
length|=GetStringInfoDatum(profile)[i+4];
426
if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
427
((long) GetStringInfoDatum(profile)[i+2] == record))
429
message=(char *) NULL;
431
message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
432
if (message != (char *) NULL)
434
(void) CopyMagickString(message,(char *) GetStringInfoDatum(
435
profile)+i+5,length+1);
436
(void) ConcatenateString(&attribute,message);
437
(void) ConcatenateString(&attribute,";");
438
message=DestroyString(message);
443
if ((attribute == (char *) NULL) || (*attribute == ';'))
445
if (attribute != (char *) NULL)
446
attribute=DestroyString(attribute);
449
attribute[strlen(attribute)-1]='\0';
450
(void) SetImageProperty((Image *) image,key,(const char *) attribute);
451
attribute=DestroyString(attribute);
455
static inline ssize_t MagickMax(const ssize_t x,const ssize_t y)
462
static inline ssize_t MagickMin(const ssize_t x,const ssize_t y)
469
static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
481
static inline size_t ReadPropertyMSBLong(const unsigned char **p,
498
for (i=0; i < 4; i++)
502
buffer[i]=(unsigned char) c;
504
value=(size_t) (buffer[0] << 24);
505
value|=buffer[1] << 16;
506
value|=buffer[2] << 8;
508
return(value & 0xffffffff);
511
static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
527
return((unsigned short) ~0U);
528
for (i=0; i < 2; i++)
532
buffer[i]=(unsigned char) c;
534
value=(unsigned short) (buffer[0] << 8);
536
return((unsigned short) (value & 0xffff));
539
static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
543
format[MaxTextExtent],
572
There are no newlines in path names, so it's safe as terminator.
574
profile=GetImageProfile(image,"8bim");
575
if (profile == (StringInfo *) NULL)
577
count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name,
579
if ((count != 2) && (count != 3) && (count != 4))
582
(void) CopyMagickString(format,"SVG",MaxTextExtent);
587
sub_number=(ssize_t) StringToLong(&name[1]);
588
sub_number=MagickMax(sub_number,1L);
589
resource=(char *) NULL;
591
length=GetStringInfoLength(profile);
592
info=GetStringInfoDatum(profile);
593
while ((length > 0) && (status == MagickFalse))
595
if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
597
if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
599
if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
601
if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
603
id=(ssize_t) ((int) ReadPropertyMSBShort(&info,&length));
604
if (id < (ssize_t) start)
606
if (id > (ssize_t) stop)
608
if (resource != (char *) NULL)
609
resource=DestroyString(resource);
610
count=(ssize_t) ReadPropertyByte(&info,&length);
611
if ((count != 0) && ((size_t) count <= length))
613
resource=(char *) NULL;
614
if (~(1UL*count) >= MaxTextExtent)
615
resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
617
if (resource != (char *) NULL)
619
for (i=0; i < (ssize_t) count; i++)
620
resource[i]=(char) ReadPropertyByte(&info,&length);
621
resource[count]='\0';
624
if ((count & 0x01) == 0)
625
(void) ReadPropertyByte(&info,&length);
626
count=(ssize_t) ((int) ReadPropertyMSBLong(&info,&length));
627
if ((*name != '\0') && (*name != '#'))
628
if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
631
No name match, scroll forward and try next.
634
length-=MagickMin(count,(ssize_t) length);
637
if ((*name == '#') && (sub_number != 1))
640
No numbered match, scroll forward and try next.
644
length-=MagickMin(count,(ssize_t) length);
648
We have the resource of interest.
650
attribute=(char *) NULL;
651
if (~(1UL*count) >= MaxTextExtent)
652
attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
654
if (attribute != (char *) NULL)
656
(void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
657
attribute[count]='\0';
659
length-=MagickMin(count,(ssize_t) length);
660
if ((id <= 1999) || (id >= 2999))
661
(void) SetImageProperty((Image *) image,key,(const char *)
668
if (LocaleCompare(format,"svg") == 0)
669
path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
670
image->columns,image->rows);
672
path=TracePSClippath((unsigned char *) attribute,(size_t) count,
673
image->columns,image->rows);
674
(void) SetImageProperty((Image *) image,key,(const char *) path);
675
path=DestroyString(path);
677
attribute=DestroyString(attribute);
681
if (resource != (char *) NULL)
682
resource=DestroyString(resource);
686
static inline unsigned short ReadPropertyShort(const EndianType endian,
687
const unsigned char *buffer)
692
if (endian == MSBEndian)
694
value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
695
((unsigned char *) buffer)[1]);
696
return((unsigned short) (value & 0xffff));
698
value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
699
return((unsigned short) (value & 0xffff));
702
static inline size_t ReadPropertyLong(const EndianType endian,
703
const unsigned char *buffer)
708
if (endian == MSBEndian)
710
value=(size_t) ((buffer[0] << 24) | (buffer[1] << 16) |
711
(buffer[2] << 8) | buffer[3]);
712
return((size_t) (value & 0xffffffff));
714
value=(size_t) ((buffer[3] << 24) | (buffer[2] << 16) |
715
(buffer[1] << 8 ) | (buffer[0]));
716
return((size_t) (value & 0xffffffff));
719
static MagickBooleanType GetEXIFProperty(const Image *image,
720
const char *property)
722
#define MaxDirectoryStack 16
723
#define EXIF_DELIMITER "\n"
724
#define EXIF_NUM_FORMATS 12
725
#define EXIF_FMT_BYTE 1
726
#define EXIF_FMT_STRING 2
727
#define EXIF_FMT_USHORT 3
728
#define EXIF_FMT_ULONG 4
729
#define EXIF_FMT_URATIONAL 5
730
#define EXIF_FMT_SBYTE 6
731
#define EXIF_FMT_UNDEFINED 7
732
#define EXIF_FMT_SSHORT 8
733
#define EXIF_FMT_SLONG 9
734
#define EXIF_FMT_SRATIONAL 10
735
#define EXIF_FMT_SINGLE 11
736
#define EXIF_FMT_DOUBLE 12
737
#define TAG_EXIF_OFFSET 0x8769
738
#define TAG_GPS_OFFSET 0x8825
739
#define TAG_INTEROP_OFFSET 0xa005
741
#define EXIFMultipleValues(size, format, arg) \
754
for (component=0; component < components; component++) \
756
length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
758
if (length >= MaxTextExtent - 1) \
759
length=MaxTextExtent-1; \
763
buffer[length-2]='\0'; \
764
value=AcquireString(buffer); \
767
#define EXIFMultipleFractions(size, format, arg1, arg2) \
780
for (component=0; component < components; component++) \
782
length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
783
format", ",arg1, arg2); \
784
if (length >= MaxTextExtent - 1) \
785
length=MaxTextExtent-1; \
789
buffer[length-2]='\0'; \
790
value=AcquireString(buffer); \
793
typedef struct _DirectoryInfo
805
typedef struct _TagInfo
817
{ 0x001, "exif:InteroperabilityIndex" },
818
{ 0x002, "exif:InteroperabilityVersion" },
819
{ 0x100, "exif:ImageWidth" },
820
{ 0x101, "exif:ImageLength" },
821
{ 0x102, "exif:BitsPerSample" },
822
{ 0x103, "exif:Compression" },
823
{ 0x106, "exif:PhotometricInterpretation" },
824
{ 0x10a, "exif:FillOrder" },
825
{ 0x10d, "exif:DocumentName" },
826
{ 0x10e, "exif:ImageDescription" },
827
{ 0x10f, "exif:Make" },
828
{ 0x110, "exif:Model" },
829
{ 0x111, "exif:StripOffsets" },
830
{ 0x112, "exif:Orientation" },
831
{ 0x115, "exif:SamplesPerPixel" },
832
{ 0x116, "exif:RowsPerStrip" },
833
{ 0x117, "exif:StripByteCounts" },
834
{ 0x11a, "exif:XResolution" },
835
{ 0x11b, "exif:YResolution" },
836
{ 0x11c, "exif:PlanarConfiguration" },
837
{ 0x11d, "exif:PageName" },
838
{ 0x11e, "exif:XPosition" },
839
{ 0x11f, "exif:YPosition" },
840
{ 0x118, "exif:MinSampleValue" },
841
{ 0x119, "exif:MaxSampleValue" },
842
{ 0x120, "exif:FreeOffsets" },
843
{ 0x121, "exif:FreeByteCounts" },
844
{ 0x122, "exif:GrayResponseUnit" },
845
{ 0x123, "exif:GrayResponseCurve" },
846
{ 0x124, "exif:T4Options" },
847
{ 0x125, "exif:T6Options" },
848
{ 0x128, "exif:ResolutionUnit" },
849
{ 0x12d, "exif:TransferFunction" },
850
{ 0x131, "exif:Software" },
851
{ 0x132, "exif:DateTime" },
852
{ 0x13b, "exif:Artist" },
853
{ 0x13e, "exif:WhitePoint" },
854
{ 0x13f, "exif:PrimaryChromaticities" },
855
{ 0x140, "exif:ColorMap" },
856
{ 0x141, "exif:HalfToneHints" },
857
{ 0x142, "exif:TileWidth" },
858
{ 0x143, "exif:TileLength" },
859
{ 0x144, "exif:TileOffsets" },
860
{ 0x145, "exif:TileByteCounts" },
861
{ 0x14a, "exif:SubIFD" },
862
{ 0x14c, "exif:InkSet" },
863
{ 0x14d, "exif:InkNames" },
864
{ 0x14e, "exif:NumberOfInks" },
865
{ 0x150, "exif:DotRange" },
866
{ 0x151, "exif:TargetPrinter" },
867
{ 0x152, "exif:ExtraSample" },
868
{ 0x153, "exif:SampleFormat" },
869
{ 0x154, "exif:SMinSampleValue" },
870
{ 0x155, "exif:SMaxSampleValue" },
871
{ 0x156, "exif:TransferRange" },
872
{ 0x157, "exif:ClipPath" },
873
{ 0x158, "exif:XClipPathUnits" },
874
{ 0x159, "exif:YClipPathUnits" },
875
{ 0x15a, "exif:Indexed" },
876
{ 0x15b, "exif:JPEGTables" },
877
{ 0x15f, "exif:OPIProxy" },
878
{ 0x200, "exif:JPEGProc" },
879
{ 0x201, "exif:JPEGInterchangeFormat" },
880
{ 0x202, "exif:JPEGInterchangeFormatLength" },
881
{ 0x203, "exif:JPEGRestartInterval" },
882
{ 0x205, "exif:JPEGLosslessPredictors" },
883
{ 0x206, "exif:JPEGPointTransforms" },
884
{ 0x207, "exif:JPEGQTables" },
885
{ 0x208, "exif:JPEGDCTables" },
886
{ 0x209, "exif:JPEGACTables" },
887
{ 0x211, "exif:YCbCrCoefficients" },
888
{ 0x212, "exif:YCbCrSubSampling" },
889
{ 0x213, "exif:YCbCrPositioning" },
890
{ 0x214, "exif:ReferenceBlackWhite" },
891
{ 0x2bc, "exif:ExtensibleMetadataPlatform" },
892
{ 0x301, "exif:Gamma" },
893
{ 0x302, "exif:ICCProfileDescriptor" },
894
{ 0x303, "exif:SRGBRenderingIntent" },
895
{ 0x320, "exif:ImageTitle" },
896
{ 0x5001, "exif:ResolutionXUnit" },
897
{ 0x5002, "exif:ResolutionYUnit" },
898
{ 0x5003, "exif:ResolutionXLengthUnit" },
899
{ 0x5004, "exif:ResolutionYLengthUnit" },
900
{ 0x5005, "exif:PrintFlags" },
901
{ 0x5006, "exif:PrintFlagsVersion" },
902
{ 0x5007, "exif:PrintFlagsCrop" },
903
{ 0x5008, "exif:PrintFlagsBleedWidth" },
904
{ 0x5009, "exif:PrintFlagsBleedWidthScale" },
905
{ 0x500A, "exif:HalftoneLPI" },
906
{ 0x500B, "exif:HalftoneLPIUnit" },
907
{ 0x500C, "exif:HalftoneDegree" },
908
{ 0x500D, "exif:HalftoneShape" },
909
{ 0x500E, "exif:HalftoneMisc" },
910
{ 0x500F, "exif:HalftoneScreen" },
911
{ 0x5010, "exif:JPEGQuality" },
912
{ 0x5011, "exif:GridSize" },
913
{ 0x5012, "exif:ThumbnailFormat" },
914
{ 0x5013, "exif:ThumbnailWidth" },
915
{ 0x5014, "exif:ThumbnailHeight" },
916
{ 0x5015, "exif:ThumbnailColorDepth" },
917
{ 0x5016, "exif:ThumbnailPlanes" },
918
{ 0x5017, "exif:ThumbnailRawBytes" },
919
{ 0x5018, "exif:ThumbnailSize" },
920
{ 0x5019, "exif:ThumbnailCompressedSize" },
921
{ 0x501a, "exif:ColorTransferFunction" },
922
{ 0x501b, "exif:ThumbnailData" },
923
{ 0x5020, "exif:ThumbnailImageWidth" },
924
{ 0x5021, "exif:ThumbnailImageHeight" },
925
{ 0x5022, "exif:ThumbnailBitsPerSample" },
926
{ 0x5023, "exif:ThumbnailCompression" },
927
{ 0x5024, "exif:ThumbnailPhotometricInterp" },
928
{ 0x5025, "exif:ThumbnailImageDescription" },
929
{ 0x5026, "exif:ThumbnailEquipMake" },
930
{ 0x5027, "exif:ThumbnailEquipModel" },
931
{ 0x5028, "exif:ThumbnailStripOffsets" },
932
{ 0x5029, "exif:ThumbnailOrientation" },
933
{ 0x502a, "exif:ThumbnailSamplesPerPixel" },
934
{ 0x502b, "exif:ThumbnailRowsPerStrip" },
935
{ 0x502c, "exif:ThumbnailStripBytesCount" },
936
{ 0x502d, "exif:ThumbnailResolutionX" },
937
{ 0x502e, "exif:ThumbnailResolutionY" },
938
{ 0x502f, "exif:ThumbnailPlanarConfig" },
939
{ 0x5030, "exif:ThumbnailResolutionUnit" },
940
{ 0x5031, "exif:ThumbnailTransferFunction" },
941
{ 0x5032, "exif:ThumbnailSoftwareUsed" },
942
{ 0x5033, "exif:ThumbnailDateTime" },
943
{ 0x5034, "exif:ThumbnailArtist" },
944
{ 0x5035, "exif:ThumbnailWhitePoint" },
945
{ 0x5036, "exif:ThumbnailPrimaryChromaticities" },
946
{ 0x5037, "exif:ThumbnailYCbCrCoefficients" },
947
{ 0x5038, "exif:ThumbnailYCbCrSubsampling" },
948
{ 0x5039, "exif:ThumbnailYCbCrPositioning" },
949
{ 0x503A, "exif:ThumbnailRefBlackWhite" },
950
{ 0x503B, "exif:ThumbnailCopyRight" },
951
{ 0x5090, "exif:LuminanceTable" },
952
{ 0x5091, "exif:ChrominanceTable" },
953
{ 0x5100, "exif:FrameDelay" },
954
{ 0x5101, "exif:LoopCount" },
955
{ 0x5110, "exif:PixelUnit" },
956
{ 0x5111, "exif:PixelPerUnitX" },
957
{ 0x5112, "exif:PixelPerUnitY" },
958
{ 0x5113, "exif:PaletteHistogram" },
959
{ 0x1000, "exif:RelatedImageFileFormat" },
960
{ 0x1001, "exif:RelatedImageLength" },
961
{ 0x1002, "exif:RelatedImageWidth" },
962
{ 0x800d, "exif:ImageID" },
963
{ 0x80e3, "exif:Matteing" },
964
{ 0x80e4, "exif:DataType" },
965
{ 0x80e5, "exif:ImageDepth" },
966
{ 0x80e6, "exif:TileDepth" },
967
{ 0x828d, "exif:CFARepeatPatternDim" },
968
{ 0x828e, "exif:CFAPattern2" },
969
{ 0x828f, "exif:BatteryLevel" },
970
{ 0x8298, "exif:Copyright" },
971
{ 0x829a, "exif:ExposureTime" },
972
{ 0x829d, "exif:FNumber" },
973
{ 0x83bb, "exif:IPTC/NAA" },
974
{ 0x84e3, "exif:IT8RasterPadding" },
975
{ 0x84e5, "exif:IT8ColorTable" },
976
{ 0x8649, "exif:ImageResourceInformation" },
977
{ 0x8769, "exif:ExifOffset" },
978
{ 0x8773, "exif:InterColorProfile" },
979
{ 0x8822, "exif:ExposureProgram" },
980
{ 0x8824, "exif:SpectralSensitivity" },
981
{ 0x8825, "exif:GPSInfo" },
982
{ 0x8827, "exif:ISOSpeedRatings" },
983
{ 0x8828, "exif:OECF" },
984
{ 0x8829, "exif:Interlace" },
985
{ 0x882a, "exif:TimeZoneOffset" },
986
{ 0x882b, "exif:SelfTimerMode" },
987
{ 0x9000, "exif:ExifVersion" },
988
{ 0x9003, "exif:DateTimeOriginal" },
989
{ 0x9004, "exif:DateTimeDigitized" },
990
{ 0x9101, "exif:ComponentsConfiguration" },
991
{ 0x9102, "exif:CompressedBitsPerPixel" },
992
{ 0x9201, "exif:ShutterSpeedValue" },
993
{ 0x9202, "exif:ApertureValue" },
994
{ 0x9203, "exif:BrightnessValue" },
995
{ 0x9204, "exif:ExposureBiasValue" },
996
{ 0x9205, "exif:MaxApertureValue" },
997
{ 0x9206, "exif:SubjectDistance" },
998
{ 0x9207, "exif:MeteringMode" },
999
{ 0x9208, "exif:LightSource" },
1000
{ 0x9209, "exif:Flash" },
1001
{ 0x920a, "exif:FocalLength" },
1002
{ 0x920b, "exif:FlashEnergy" },
1003
{ 0x920c, "exif:SpatialFrequencyResponse" },
1004
{ 0x920d, "exif:Noise" },
1005
{ 0x9211, "exif:ImageNumber" },
1006
{ 0x9212, "exif:SecurityClassification" },
1007
{ 0x9213, "exif:ImageHistory" },
1008
{ 0x9214, "exif:SubjectArea" },
1009
{ 0x9215, "exif:ExposureIndex" },
1010
{ 0x9216, "exif:TIFF-EPStandardID" },
1011
{ 0x927c, "exif:MakerNote" },
1012
{ 0x9C9b, "exif:WinXP-Title" },
1013
{ 0x9C9c, "exif:WinXP-Comments" },
1014
{ 0x9C9d, "exif:WinXP-Author" },
1015
{ 0x9C9e, "exif:WinXP-Keywords" },
1016
{ 0x9C9f, "exif:WinXP-Subject" },
1017
{ 0x9286, "exif:UserComment" },
1018
{ 0x9290, "exif:SubSecTime" },
1019
{ 0x9291, "exif:SubSecTimeOriginal" },
1020
{ 0x9292, "exif:SubSecTimeDigitized" },
1021
{ 0xa000, "exif:FlashPixVersion" },
1022
{ 0xa001, "exif:ColorSpace" },
1023
{ 0xa002, "exif:ExifImageWidth" },
1024
{ 0xa003, "exif:ExifImageLength" },
1025
{ 0xa004, "exif:RelatedSoundFile" },
1026
{ 0xa005, "exif:InteroperabilityOffset" },
1027
{ 0xa20b, "exif:FlashEnergy" },
1028
{ 0xa20c, "exif:SpatialFrequencyResponse" },
1029
{ 0xa20d, "exif:Noise" },
1030
{ 0xa20e, "exif:FocalPlaneXResolution" },
1031
{ 0xa20f, "exif:FocalPlaneYResolution" },
1032
{ 0xa210, "exif:FocalPlaneResolutionUnit" },
1033
{ 0xa214, "exif:SubjectLocation" },
1034
{ 0xa215, "exif:ExposureIndex" },
1035
{ 0xa216, "exif:TIFF/EPStandardID" },
1036
{ 0xa217, "exif:SensingMethod" },
1037
{ 0xa300, "exif:FileSource" },
1038
{ 0xa301, "exif:SceneType" },
1039
{ 0xa302, "exif:CFAPattern" },
1040
{ 0xa401, "exif:CustomRendered" },
1041
{ 0xa402, "exif:ExposureMode" },
1042
{ 0xa403, "exif:WhiteBalance" },
1043
{ 0xa404, "exif:DigitalZoomRatio" },
1044
{ 0xa405, "exif:FocalLengthIn35mmFilm" },
1045
{ 0xa406, "exif:SceneCaptureType" },
1046
{ 0xa407, "exif:GainControl" },
1047
{ 0xa408, "exif:Contrast" },
1048
{ 0xa409, "exif:Saturation" },
1049
{ 0xa40a, "exif:Sharpness" },
1050
{ 0xa40b, "exif:DeviceSettingDescription" },
1051
{ 0xa40c, "exif:SubjectDistanceRange" },
1052
{ 0xa420, "exif:ImageUniqueID" },
1053
{ 0xc4a5, "exif:PrintImageMatching" },
1054
{ 0xa500, "exif:Gamma" },
1055
{ 0xc640, "exif:CR2Slice" },
1056
{ 0x10000, "exif:GPSVersionID" },
1057
{ 0x10001, "exif:GPSLatitudeRef" },
1058
{ 0x10002, "exif:GPSLatitude" },
1059
{ 0x10003, "exif:GPSLongitudeRef" },
1060
{ 0x10004, "exif:GPSLongitude" },
1061
{ 0x10005, "exif:GPSAltitudeRef" },
1062
{ 0x10006, "exif:GPSAltitude" },
1063
{ 0x10007, "exif:GPSTimeStamp" },
1064
{ 0x10008, "exif:GPSSatellites" },
1065
{ 0x10009, "exif:GPSStatus" },
1066
{ 0x1000a, "exif:GPSMeasureMode" },
1067
{ 0x1000b, "exif:GPSDop" },
1068
{ 0x1000c, "exif:GPSSpeedRef" },
1069
{ 0x1000d, "exif:GPSSpeed" },
1070
{ 0x1000e, "exif:GPSTrackRef" },
1071
{ 0x1000f, "exif:GPSTrack" },
1072
{ 0x10010, "exif:GPSImgDirectionRef" },
1073
{ 0x10011, "exif:GPSImgDirection" },
1074
{ 0x10012, "exif:GPSMapDatum" },
1075
{ 0x10013, "exif:GPSDestLatitudeRef" },
1076
{ 0x10014, "exif:GPSDestLatitude" },
1077
{ 0x10015, "exif:GPSDestLongitudeRef" },
1078
{ 0x10016, "exif:GPSDestLongitude" },
1079
{ 0x10017, "exif:GPSDestBearingRef" },
1080
{ 0x10018, "exif:GPSDestBearing" },
1081
{ 0x10019, "exif:GPSDestDistanceRef" },
1082
{ 0x1001a, "exif:GPSDestDistance" },
1083
{ 0x1001b, "exif:GPSProcessingMethod" },
1084
{ 0x1001c, "exif:GPSAreaInformation" },
1085
{ 0x1001d, "exif:GPSDateStamp" },
1086
{ 0x1001e, "exif:GPSDifferential" },
1098
directory_stack[MaxDirectoryStack];
1127
tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1130
If EXIF data exists, then try to parse the request for a tag.
1132
profile=GetImageProfile(image,"exif");
1133
if (profile == (StringInfo *) NULL)
1134
return(MagickFalse);
1135
if ((property == (const char *) NULL) || (*property == '\0'))
1136
return(MagickFalse);
1137
while (isspace((int) ((unsigned char) *property)) != 0)
1141
switch (*(property+5))
1146
Caller has asked for all the tags in the EXIF data.
1149
all=1; /* return the data in description=value format */
1155
all=2; /* return the data in tagid=value format */
1168
Check for a hex based tag specification first.
1170
tag=(*(property+5) == '@') ? 1UL : 0UL;
1174
return(MagickFalse);
1176
Parse tag specification as a hex number.
1181
for (i=(ssize_t) n-1L; i >= 0; i--)
1185
if ((c >= '0') && (c <= '9'))
1188
if ((c >= 'A') && (c <= 'F'))
1191
if ((c >= 'a') && (c <= 'f'))
1194
return(MagickFalse);
1196
} while (*property != '\0');
1202
Try to match the text with a tag name instead.
1206
if (EXIFTag[i].tag == 0)
1208
if (LocaleCompare(EXIFTag[i].description,property) == 0)
1210
tag=(size_t) EXIFTag[i].tag;
1218
return(MagickFalse);
1219
length=GetStringInfoLength(profile);
1220
exif=GetStringInfoDatum(profile);
1223
if (ReadPropertyByte(&exif,&length) != 0x45)
1225
if (ReadPropertyByte(&exif,&length) != 0x78)
1227
if (ReadPropertyByte(&exif,&length) != 0x69)
1229
if (ReadPropertyByte(&exif,&length) != 0x66)
1231
if (ReadPropertyByte(&exif,&length) != 0x00)
1233
if (ReadPropertyByte(&exif,&length) != 0x00)
1238
return(MagickFalse);
1239
id=(ssize_t) ((int) ReadPropertyShort(LSBEndian,exif));
1247
return(MagickFalse);
1248
if (ReadPropertyShort(endian,exif+2) != 0x002a)
1249
return(MagickFalse);
1251
This the offset to the first IFD.
1253
offset=(ssize_t) ((int) ReadPropertyLong(endian,exif+4));
1254
if ((offset < 0) || (size_t) offset >= length)
1255
return(MagickFalse);
1257
Set the pointer to the first IFD and follow it were it leads.
1260
directory=exif+offset;
1264
exif_resources=NewSplayTree((int (*)(const void *,const void *)) NULL,
1265
(void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
1269
If there is anything on the stack then pop it off.
1274
directory=directory_stack[level].directory;
1275
entry=directory_stack[level].entry;
1276
tag_offset=directory_stack[level].offset;
1279
Determine how many entries there are in the current IFD.
1281
number_entries=(size_t) ((int) ReadPropertyShort(endian,directory));
1282
for ( ; entry < number_entries; entry++)
1284
register unsigned char
1295
q=(unsigned char *) (directory+(12*entry)+2);
1296
if (GetValueFromSplayTree(exif_resources,q) == q)
1298
(void) AddValueToSplayTree(exif_resources,q,q);
1299
tag_value=(ssize_t) ((int) ReadPropertyShort(endian,q)+tag_offset);
1300
format=(size_t) ((int) ReadPropertyShort(endian,q+2));
1301
if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1303
components=(ssize_t) ((int) ReadPropertyLong(endian,q+4));
1304
number_bytes=(size_t) components*tag_bytes[format];
1305
if (number_bytes <= 4)
1313
The directory entry contains an offset.
1315
offset=(ssize_t) ((int) ReadPropertyLong(endian,q+8));
1316
if ((offset+number_bytes) < offset)
1317
continue; /* prevent overflow */
1318
if ((size_t) (offset+number_bytes) > length)
1320
p=(unsigned char *) (exif+offset);
1322
if ((all != 0) || (tag == (size_t) tag_value))
1325
buffer[MaxTextExtent],
1331
case EXIF_FMT_UNDEFINED:
1333
EXIFMultipleValues(1,"%.20g",(double)
1334
(*(unsigned char *) p1));
1337
case EXIF_FMT_SBYTE:
1339
EXIFMultipleValues(1,"%.20g",(double) (*(signed char *) p1));
1342
case EXIF_FMT_SSHORT:
1344
EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1));
1347
case EXIF_FMT_USHORT:
1349
EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1));
1352
case EXIF_FMT_ULONG:
1354
EXIFMultipleValues(4,"%.20g",(double)
1355
((int) ReadPropertyLong(endian,p1)));
1358
case EXIF_FMT_SLONG:
1360
EXIFMultipleValues(4,"%.20g",(double)
1361
ReadPropertyLong(endian,p1));
1364
case EXIF_FMT_URATIONAL:
1366
EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1367
((int) ReadPropertyLong(endian,p1)),(double)
1368
((int) ReadPropertyLong(endian,p1+4)));
1371
case EXIF_FMT_SRATIONAL:
1373
EXIFMultipleFractions(8,"%.20g/%.20g",(double)
1374
ReadPropertyLong(endian,p1),(double)
1375
ReadPropertyLong(endian,p1+4));
1378
case EXIF_FMT_SINGLE:
1380
EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1383
case EXIF_FMT_DOUBLE:
1385
EXIFMultipleValues(8,"%f",*(double *) p1);
1389
case EXIF_FMT_STRING:
1391
value=(char *) NULL;
1392
if (~(1UL*number_bytes) >= 1)
1393
value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1395
if (value != (char *) NULL)
1400
for (i=0; i < (ssize_t) number_bytes; i++)
1403
if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1404
value[i]=(char) p[i];
1411
if (value != (char *) NULL)
1419
(void) CopyMagickString(key,property,MaxTextExtent);
1430
description="unknown";
1433
if (EXIFTag[i].tag == 0)
1435
if ((ssize_t) EXIFTag[i].tag == tag_value)
1437
description=EXIFTag[i].description;
1441
(void) FormatMagickString(key,MaxTextExtent,"%s",
1447
if (tag_value < 0x10000)
1448
(void) FormatMagickString(key,MaxTextExtent,"#%04lx",
1449
(unsigned long) tag_value);
1451
if (tag_value < 0x20000)
1452
(void) FormatMagickString(key,MaxTextExtent,"@%04lx",
1453
(unsigned long) (tag_value & 0xffff));
1455
(void) FormatMagickString(key,MaxTextExtent,"unknown");
1459
p=(const char *) NULL;
1460
if (image->properties != (void *) NULL)
1461
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1462
image->properties,key);
1463
if (p == (const char *) NULL)
1464
(void) SetImageProperty((Image *) image,key,value);
1465
value=DestroyString(value);
1469
if ((tag_value == TAG_EXIF_OFFSET) ||
1470
(tag_value == TAG_INTEROP_OFFSET) || (tag_value == TAG_GPS_OFFSET))
1475
offset=(ssize_t) ((int) ReadPropertyLong(endian,p));
1476
if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
1481
tag_offset1=(ssize_t) ((tag_value == TAG_GPS_OFFSET) ? 0x10000 :
1483
directory_stack[level].directory=directory;
1485
directory_stack[level].entry=entry;
1486
directory_stack[level].offset=tag_offset;
1488
directory_stack[level].directory=exif+offset;
1489
directory_stack[level].offset=tag_offset1;
1490
directory_stack[level].entry=0;
1492
if ((directory+2+(12*number_entries)) > (exif+length))
1494
offset=(ssize_t) ((int) ReadPropertyLong(endian,directory+2+(12*
1496
if ((offset != 0) && ((size_t) offset < length) &&
1497
(level < (MaxDirectoryStack-2)))
1499
directory_stack[level].directory=exif+offset;
1500
directory_stack[level].entry=0;
1501
directory_stack[level].offset=tag_offset1;
1508
} while (level > 0);
1509
exif_resources=DestroySplayTree(exif_resources);
1513
static MagickBooleanType GetXMPProperty(const Image *image,
1514
const char *property)
1538
profile=GetImageProfile(image,"xmp");
1539
if (profile == (StringInfo *) NULL)
1540
return(MagickFalse);
1541
if ((property == (const char *) NULL) || (*property == '\0'))
1542
return(MagickFalse);
1543
xmp_profile=StringInfoToString(profile);
1544
if (xmp_profile == (char *) NULL)
1545
return(MagickFalse);
1546
for (p=xmp_profile; *p != '\0'; p++)
1547
if ((*p == '<') && (*(p+1) == 'x'))
1549
exception=AcquireExceptionInfo();
1550
xmp=NewXMLTree((char *) p,exception);
1551
xmp_profile=DestroyString(xmp_profile);
1552
exception=DestroyExceptionInfo(exception);
1553
if (xmp == (XMLTreeInfo *) NULL)
1554
return(MagickFalse);
1556
rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1557
if (rdf != (XMLTreeInfo *) NULL)
1559
if (image->properties == (void *) NULL)
1560
((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1561
RelinquishMagickMemory,RelinquishMagickMemory);
1562
description=GetXMLTreeChild(rdf,"rdf:Description");
1563
while (description != (XMLTreeInfo *) NULL)
1565
node=GetXMLTreeChild(description,(const char *) NULL);
1566
while (node != (XMLTreeInfo *) NULL)
1568
child=GetXMLTreeChild(node,(const char *) NULL);
1569
if (child == (XMLTreeInfo *) NULL)
1570
(void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1571
ConstantString(GetXMLTreeTag(node)),
1572
ConstantString(GetXMLTreeContent(node)));
1573
while (child != (XMLTreeInfo *) NULL)
1575
if (LocaleCompare(GetXMLTreeTag(child),"rdf:Seq") != 0)
1576
(void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1577
ConstantString(GetXMLTreeTag(child)),
1578
ConstantString(GetXMLTreeContent(child)));
1579
child=GetXMLTreeSibling(child);
1581
node=GetXMLTreeSibling(node);
1583
description=GetNextXMLTreeTag(description);
1586
xmp=DestroyXMLTree(xmp);
1590
static char *TracePSClippath(const unsigned char *blob,size_t length,
1591
const size_t magick_unused(columns),
1592
const size_t magick_unused(rows))
1615
path=AcquireString((char *) NULL);
1616
if (path == (char *) NULL)
1617
return((char *) NULL);
1618
message=AcquireString((char *) NULL);
1619
(void) FormatMagickString(message,MaxTextExtent,"/ClipImage\n");
1620
(void) ConcatenateString(&path,message);
1621
(void) FormatMagickString(message,MaxTextExtent,"{\n");
1622
(void) ConcatenateString(&path,message);
1623
(void) FormatMagickString(message,MaxTextExtent," /c {curveto} bind def\n");
1624
(void) ConcatenateString(&path,message);
1625
(void) FormatMagickString(message,MaxTextExtent," /l {lineto} bind def\n");
1626
(void) ConcatenateString(&path,message);
1627
(void) FormatMagickString(message,MaxTextExtent," /m {moveto} bind def\n");
1628
(void) ConcatenateString(&path,message);
1629
(void) FormatMagickString(message,MaxTextExtent,
1630
" /v {currentpoint 6 2 roll curveto} bind def\n");
1631
(void) ConcatenateString(&path,message);
1632
(void) FormatMagickString(message,MaxTextExtent,
1633
" /y {2 copy curveto} bind def\n");
1634
(void) ConcatenateString(&path,message);
1635
(void) FormatMagickString(message,MaxTextExtent,
1636
" /z {closepath} bind def\n");
1637
(void) ConcatenateString(&path,message);
1638
(void) FormatMagickString(message,MaxTextExtent," newpath\n");
1639
(void) ConcatenateString(&path,message);
1641
The clipping path format is defined in "Adobe Photoshop File
1642
Formats Specification" version 6.0 downloadable from adobe.com.
1644
(void) ResetMagickMemory(point,0,sizeof(point));
1645
(void) ResetMagickMemory(first,0,sizeof(first));
1646
(void) ResetMagickMemory(last,0,sizeof(last));
1648
in_subpath=MagickFalse;
1651
selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1657
if (knot_count != 0)
1660
length-=MagickMin(24,(ssize_t) length);
1664
Expected subpath length record.
1666
knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1668
length-=MagickMin(22,(ssize_t) length);
1676
if (knot_count == 0)
1679
Unexpected subpath knot
1682
length-=MagickMin(24,(ssize_t) length);
1688
for (i=0; i < 3; i++)
1694
yy=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1695
xx=(size_t) ((int) ReadPropertyMSBLong(&blob,&length));
1697
if (xx > 2147483647)
1698
x=(ssize_t) xx-4294967295-1;
1700
if (yy > 2147483647)
1701
y=(ssize_t) yy-4294967295-1;
1702
point[i].x=(double) x/4096/4096;
1703
point[i].y=1.0-(double) y/4096/4096;
1705
if (in_subpath == MagickFalse)
1707
(void) FormatMagickString(message,MaxTextExtent," %g %g m\n",
1708
point[1].x,point[1].y);
1709
for (i=0; i < 3; i++)
1718
Handle special cases when Bezier curves are used to describe
1719
corners and straight lines.
1721
if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1722
(point[0].x == point[1].x) && (point[0].y == point[1].y))
1723
(void) FormatMagickString(message,MaxTextExtent,
1724
" %g %g l\n",point[1].x,point[1].y);
1726
if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1727
(void) FormatMagickString(message,MaxTextExtent,
1728
" %g %g %g %g v\n",point[0].x,point[0].y,
1729
point[1].x,point[1].y);
1731
if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1732
(void) FormatMagickString(message,MaxTextExtent,
1733
" %g %g %g %g y\n",last[2].x,last[2].y,
1734
point[1].x,point[1].y);
1736
(void) FormatMagickString(message,MaxTextExtent,
1737
" %g %g %g %g %g %g c\n",last[2].x,
1738
last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
1739
for (i=0; i < 3; i++)
1742
(void) ConcatenateString(&path,message);
1743
in_subpath=MagickTrue;
1746
Close the subpath if there are no more knots.
1748
if (knot_count == 0)
1751
Same special handling as above except we compare to the
1752
first point in the path and close the path.
1754
if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1755
(first[0].x == first[1].x) && (first[0].y == first[1].y))
1756
(void) FormatMagickString(message,MaxTextExtent,
1757
" %g %g l z\n",first[1].x,first[1].y);
1759
if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1760
(void) FormatMagickString(message,MaxTextExtent,
1761
" %g %g %g %g v z\n",first[0].x,first[0].y,
1762
first[1].x,first[1].y);
1764
if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1765
(void) FormatMagickString(message,MaxTextExtent,
1766
" %g %g %g %g y z\n",last[2].x,last[2].y,
1767
first[1].x,first[1].y);
1769
(void) FormatMagickString(message,MaxTextExtent,
1770
" %g %g %g %g %g %g c z\n",last[2].x,
1771
last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1772
(void) ConcatenateString(&path,message);
1773
in_subpath=MagickFalse;
1783
length-=MagickMin(24,(ssize_t) length);
1789
Returns an empty PS path if the path has no knots.
1791
(void) FormatMagickString(message,MaxTextExtent," eoclip\n");
1792
(void) ConcatenateString(&path,message);
1793
(void) FormatMagickString(message,MaxTextExtent,"} bind def");
1794
(void) ConcatenateString(&path,message);
1795
message=DestroyString(message);
1799
static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1800
const size_t columns,const size_t rows)
1823
path=AcquireString((char *) NULL);
1824
if (path == (char *) NULL)
1825
return((char *) NULL);
1826
message=AcquireString((char *) NULL);
1827
(void) FormatMagickString(message,MaxTextExtent,
1828
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
1829
(void) ConcatenateString(&path,message);
1830
(void) FormatMagickString(message,MaxTextExtent,
1831
"<svg width=\"%.20g\" height=\"%.20g\">\n",(double) columns,(double) rows);
1832
(void) ConcatenateString(&path,message);
1833
(void) FormatMagickString(message,MaxTextExtent,"<g>\n");
1834
(void) ConcatenateString(&path,message);
1835
(void) FormatMagickString(message,MaxTextExtent,
1836
"<path style=\"fill:#00000000;stroke:#00000000;");
1837
(void) ConcatenateString(&path,message);
1838
(void) FormatMagickString(message,MaxTextExtent,
1839
"stroke-width:0;stroke-antialiasing:false\" d=\"\n");
1840
(void) ConcatenateString(&path,message);
1841
(void) ResetMagickMemory(point,0,sizeof(point));
1842
(void) ResetMagickMemory(first,0,sizeof(first));
1843
(void) ResetMagickMemory(last,0,sizeof(last));
1845
in_subpath=MagickFalse;
1848
selector=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1854
if (knot_count != 0)
1857
length-=MagickMin(24,(ssize_t) length);
1861
Expected subpath length record.
1863
knot_count=(ssize_t) ((int) ReadPropertyMSBShort(&blob,&length));
1865
length-=MagickMin(22,(ssize_t) length);
1873
if (knot_count == 0)
1876
Unexpected subpath knot.
1879
length-=MagickMin(24,(ssize_t) length);
1885
for (i=0; i < 3; i++)
1891
yy=ReadPropertyMSBLong(&blob,&length);
1892
xx=ReadPropertyMSBLong(&blob,&length);
1894
if (xx > 2147483647)
1895
x=(ssize_t) xx-4294967295-1;
1897
if (yy > 2147483647)
1898
y=(ssize_t) yy-4294967295-1;
1899
point[i].x=(double) x*columns/4096/4096;
1900
point[i].y=(double) y*rows/4096/4096;
1902
if (in_subpath == MagickFalse)
1904
(void) FormatMagickString(message,MaxTextExtent,"M %g,%g\n",
1905
point[1].x,point[1].y);
1906
for (i=0; i < 3; i++)
1914
if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1915
(point[0].x == point[1].x) && (point[0].y == point[1].y))
1916
(void) FormatMagickString(message,MaxTextExtent,"L %g,%g\n",
1917
point[1].x,point[1].y);
1919
(void) FormatMagickString(message,MaxTextExtent,
1920
"C %g,%g %g,%g %g,%g\n",last[2].x,last[2].y,
1921
point[0].x,point[0].y,point[1].x,point[1].y);
1922
for (i=0; i < 3; i++)
1925
(void) ConcatenateString(&path,message);
1926
in_subpath=MagickTrue;
1929
Close the subpath if there are no more knots.
1931
if (knot_count == 0)
1933
if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1934
(first[0].x == first[1].x) && (first[0].y == first[1].y))
1935
(void) FormatMagickString(message,MaxTextExtent,
1936
"L %g,%g Z\n",first[1].x,first[1].y);
1939
(void) FormatMagickString(message,MaxTextExtent,
1940
"C %g,%g %g,%g %g,%g Z\n",last[2].x,
1941
last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
1942
(void) ConcatenateString(&path,message);
1944
in_subpath=MagickFalse;
1954
length-=MagickMin(24,(ssize_t) length);
1960
Return an empty SVG image if the path does not have knots.
1962
(void) FormatMagickString(message,MaxTextExtent,"\"/>\n");
1963
(void) ConcatenateString(&path,message);
1964
(void) FormatMagickString(message,MaxTextExtent,"</g>\n");
1965
(void) ConcatenateString(&path,message);
1966
(void) FormatMagickString(message,MaxTextExtent,"</svg>\n");
1967
(void) ConcatenateString(&path,message);
1968
message=DestroyString(message);
1972
MagickExport const char *GetImageProperty(const Image *image,
1973
const char *property)
1990
assert(image != (Image *) NULL);
1991
assert(image->signature == MagickSignature);
1992
if (image->debug != MagickFalse)
1993
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1994
p=(const char *) NULL;
1995
if (image->properties != (void *) NULL)
1997
if (property == (const char *) NULL)
1999
ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
2000
p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
2004
if (LocaleNCompare("fx:",property,3) != 0)
2006
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2007
image->properties,property);
2008
if (p != (const char *) NULL)
2012
if ((property == (const char *) NULL) ||
2013
(strchr(property,':') == (char *) NULL))
2015
exception=(&((Image *) image)->exception);
2020
if (LocaleNCompare("8bim:",property,5) == 0)
2022
if ((Get8BIMProperty(image,property) != MagickFalse) &&
2023
(image->properties != (void *) NULL))
2025
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2026
image->properties,property);
2035
if (LocaleNCompare("exif:",property,5) == 0)
2037
if ((GetEXIFProperty(image,property) != MagickFalse) &&
2038
(image->properties != (void *) NULL))
2040
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2041
image->properties,property);
2050
if (LocaleNCompare("fx:",property,3) == 0)
2052
fx_info=AcquireFxInfo(image,property+3);
2053
status=FxEvaluateChannelExpression(fx_info,DefaultChannels,0,0,&alpha,
2055
fx_info=DestroyFxInfo(fx_info);
2056
if (status != MagickFalse)
2059
value[MaxTextExtent];
2061
(void) FormatMagickString(value,MaxTextExtent,"%.*g",
2062
GetMagickPrecision(),(double) alpha);
2063
(void) SetImageProperty((Image *) image,property,value);
2065
if (image->properties != (void *) NULL)
2067
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2068
image->properties,property);
2077
if (LocaleNCompare("iptc:",property,5) == 0)
2079
if ((GetIPTCProperty(image,property) != MagickFalse) &&
2080
(image->properties != (void *) NULL))
2082
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2083
image->properties,property);
2092
if (LocaleNCompare("pixel:",property,6) == 0)
2097
GetMagickPixelPacket(image,&pixel);
2098
fx_info=AcquireFxInfo(image,property+6);
2099
status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2101
pixel.red=(MagickRealType) QuantumRange*alpha;
2102
status|=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2104
pixel.green=(MagickRealType) QuantumRange*alpha;
2105
status|=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2107
pixel.blue=(MagickRealType) QuantumRange*alpha;
2108
status|=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2110
pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2111
if (image->colorspace == CMYKColorspace)
2113
status|=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2115
pixel.index=(MagickRealType) QuantumRange*alpha;
2117
fx_info=DestroyFxInfo(fx_info);
2118
if (status != MagickFalse)
2121
name[MaxTextExtent];
2123
(void) QueryMagickColorname(image,&pixel,SVGCompliance,name,
2125
(void) SetImageProperty((Image *) image,property,name);
2126
return(GetImageProperty(image,property));
2134
if (LocaleNCompare("xmp:",property,4) == 0)
2136
if ((GetXMPProperty(image,property) != MagickFalse) &&
2137
(image->properties != (void *) NULL))
2139
p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2140
image->properties,property);
2153
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2157
+ G e t M a g i c k P r o p e r t y %
2161
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2163
% GetMagickProperty() gets a value associated with an image property.
2165
% The format of the GetMagickProperty method is:
2167
% const char *GetMagickProperty(const ImageInfo *image_info,
2168
% Image *image,const char *key)
2170
% A description of each parameter follows:
2172
% o image_info: the image info.
2174
% o image: the image.
2179
MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
2180
Image *image,const char *property)
2183
value[MaxTextExtent],
2184
filename[MaxTextExtent];
2191
if (LocaleNCompare("base",property,4) == 0)
2193
GetPathComponent(image->magick_filename,BasePath,filename);
2194
(void) CopyMagickString(value,filename,MaxTextExtent);
2201
if (LocaleNCompare("channels",property,8) == 0)
2206
(void) FormatMagickString(value,MaxTextExtent,"%s",
2207
CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2208
image->colorspace));
2210
if (image->matte != MagickFalse)
2211
(void) ConcatenateMagickString(value,"a",MaxTextExtent);
2214
if (LocaleNCompare("colorspace",property,10) == 0)
2220
Image storage class and colorspace.
2222
colorspace=image->colorspace;
2223
if (IsGrayImage(image,&image->exception) != MagickFalse)
2224
colorspace=GRAYColorspace;
2225
(void) FormatMagickString(value,MaxTextExtent,"%s",
2226
CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t)
2230
if (LocaleNCompare("copyright",property,9) == 0)
2232
(void) CopyMagickString(value,GetMagickCopyright(),MaxTextExtent);
2239
if (LocaleNCompare("depth",property,5) == 0)
2241
(void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2245
if (LocaleNCompare("directory",property,9) == 0)
2247
GetPathComponent(image->magick_filename,HeadPath,filename);
2248
(void) CopyMagickString(value,filename,MaxTextExtent);
2255
if (LocaleNCompare("extension",property,9) == 0)
2257
GetPathComponent(image->magick_filename,ExtensionPath,filename);
2258
(void) CopyMagickString(value,filename,MaxTextExtent);
2265
if (LocaleNCompare("group",property,5) == 0)
2267
(void) FormatMagickString(value,MaxTextExtent,"0x%lx",
2268
(unsigned long) image_info->group);
2275
if (LocaleNCompare("height",property,6) == 0)
2277
(void) FormatMagickString(value,MaxTextExtent,"%.20g",
2278
image->magick_rows != 0 ? (double) image->magick_rows : 256.0);
2285
if (LocaleNCompare("input",property,5) == 0)
2287
(void) CopyMagickString(value,image->filename,MaxTextExtent);
2294
if (LocaleNCompare("kurtosis",property,8) == 0)
2300
(void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2301
&skewness,&image->exception);
2302
(void) FormatMagickString(value,MaxTextExtent,"%.*g",
2303
GetMagickPrecision(),kurtosis);
2310
if (LocaleNCompare("magick",property,6) == 0)
2312
(void) CopyMagickString(value,image->magick,MaxTextExtent);
2315
if (LocaleNCompare("max",property,3) == 0)
2321
(void) GetImageChannelRange(image,image_info->channel,&minimum,
2322
&maximum,&image->exception);
2323
(void) FormatMagickString(value,MaxTextExtent,"%.*g",
2324
GetMagickPrecision(),maximum);
2327
if (LocaleNCompare("mean",property,4) == 0)
2333
(void) GetImageChannelMean(image,image_info->channel,&mean,
2334
&standard_deviation,&image->exception);
2335
(void) FormatMagickString(value,MaxTextExtent,"%.*g",
2336
GetMagickPrecision(),mean);
2339
if (LocaleNCompare("min",property,3) == 0)
2345
(void) GetImageChannelRange(image,image_info->channel,&minimum,
2346
&maximum,&image->exception);
2347
(void) FormatMagickString(value,MaxTextExtent,"%.*g",
2348
GetMagickPrecision(),minimum);
2355
if (LocaleNCompare("name",property,4) == 0)
2357
(void) CopyMagickString(value,filename,MaxTextExtent);
2364
if (LocaleNCompare("opaque",property,6) == 0)
2369
opaque=IsOpaqueImage(image,&image->exception);
2370
(void) CopyMagickString(value,opaque == MagickFalse ? "false" :
2371
"true",MaxTextExtent);
2374
if (LocaleNCompare("output",property,6) == 0)
2376
(void) CopyMagickString(value,image_info->filename,MaxTextExtent);
2383
if (LocaleNCompare("page",property,4) == 0)
2385
(void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2386
GetImageIndexInList(image)+1);
2393
if (LocaleNCompare("size",property,4) == 0)
2396
format[MaxTextExtent];
2398
(void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
2399
(void) FormatMagickString(value,MaxTextExtent,"%sB",format);
2402
if (LocaleNCompare("scenes",property,6) == 0)
2404
(void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2405
GetImageListLength(image));
2408
if (LocaleNCompare("scene",property,5) == 0)
2410
(void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2412
if (image_info->number_scenes != 0)
2413
(void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2417
if (LocaleNCompare("skewness",property,8) == 0)
2423
(void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2424
&skewness,&image->exception);
2425
(void) FormatMagickString(value,MaxTextExtent,"%.*g",
2426
GetMagickPrecision(),skewness);
2429
if ((LocaleNCompare("standard-deviation",property,18) == 0) ||
2430
(LocaleNCompare("standard_deviation",property,18) == 0))
2436
(void) GetImageChannelMean(image,image_info->channel,&mean,
2437
&standard_deviation,&image->exception);
2438
(void) FormatMagickString(value,MaxTextExtent,"%.*g",
2439
GetMagickPrecision(),standard_deviation);
2446
if (LocaleNCompare("unique",property,6) == 0)
2448
(void) CopyMagickString(filename,image_info->unique,MaxTextExtent);
2449
(void) CopyMagickString(value,filename,MaxTextExtent);
2456
if (LocaleNCompare("version",property,7) == 0)
2458
(void) CopyMagickString(value,GetMagickVersion((size_t *) NULL),
2466
if (LocaleNCompare("width",property,5) == 0)
2468
(void) FormatMagickString(value,MaxTextExtent,"%.20g",(double)
2469
(image->magick_columns != 0 ? image->magick_columns : 256));
2476
if (LocaleNCompare("xresolution",property,11) == 0)
2478
(void) FormatMagickString(value,MaxTextExtent,"%g",
2479
image->x_resolution);
2486
if (LocaleNCompare("yresolution",property,11) == 0)
2488
(void) FormatMagickString(value,MaxTextExtent,"%g",
2489
image->y_resolution);
2496
if (LocaleNCompare("zero",property,4) == 0)
2498
(void) CopyMagickString(filename,image_info->zero,MaxTextExtent);
2499
(void) CopyMagickString(value,filename,MaxTextExtent);
2507
if (image->properties == (void *) NULL)
2508
image->properties=NewSplayTree(CompareSplayTreeString,
2509
RelinquishMagickMemory,RelinquishMagickMemory);
2510
(void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
2511
ConstantString(property),ConstantString(value));
2513
return(GetImageProperty(image,property));
2517
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2521
% G e t N e x t I m a g e P r o p e r t y %
2525
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2527
% GetNextImageProperty() gets the next image property value.
2529
% The format of the GetNextImageProperty method is:
2531
% char *GetNextImageProperty(const Image *image)
2533
% A description of each parameter follows:
2535
% o image: the image.
2538
MagickExport char *GetNextImageProperty(const Image *image)
2540
assert(image != (Image *) NULL);
2541
assert(image->signature == MagickSignature);
2542
if (image->debug != MagickFalse)
2543
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2545
if (image->properties == (void *) NULL)
2546
return((char *) NULL);
2547
return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
2551
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2555
% I n t e r p r e t I m a g e P r o p e r t i e s %
2559
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2561
% InterpretImageProperties() replaces any embedded formatting characters with
2562
% the appropriate image property and returns the interpretted text.
2564
% The format of the InterpretImageProperties method is:
2566
% char *InterpretImageProperties(const ImageInfo *image_info,Image *image,
2567
% const char *embed_text)
2569
% A description of each parameter follows:
2571
% o image_info: the image info.
2573
% o image: the image.
2575
% o embed_text: the address of a character string containing the embedded
2576
% formatting characters.
2579
MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
2580
Image *image,const char *embed_text)
2583
filename[MaxTextExtent],
2603
assert(image != (Image *) NULL);
2604
assert(image->signature == MagickSignature);
2605
if (image->debug != MagickFalse)
2606
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2607
if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))
2608
return((char *) NULL);
2609
text=(char *) embed_text;
2610
if ((*text == '@') && ((*(text+1) == '-') ||
2611
(IsPathAccessible(text+1) != MagickFalse)))
2612
return(FileToString(embed_text+1,~0,&image->exception));
2614
Translate any embedded format characters.
2616
interpret_text=AcquireString(text);
2617
extent=MaxTextExtent;
2619
for (q=interpret_text; *p != '\0'; p++)
2622
if ((size_t) (q-interpret_text+MaxTextExtent) >= extent)
2624
extent+=MaxTextExtent;
2625
interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2626
MaxTextExtent+1,sizeof(*interpret_text));
2627
if (interpret_text == (char *) NULL)
2629
q=interpret_text+strlen(interpret_text);
2632
Process formatting characters in text.
2634
if ((*p == '\\') && (*(p+1) == 'r'))
2640
if ((*p == '\\') && (*(p+1) == 'n'))
2663
format[MaxTextExtent];
2668
(void) FormatMagickString(format,MaxTextExtent,"%.20g",(double)
2670
if (image->extent != (MagickSizeType) ((size_t) image->extent))
2671
(void) FormatMagickSize(image->extent,MagickFalse,format);
2672
q+=ConcatenateMagickString(q,format,extent);
2673
q+=ConcatenateMagickString(q,"B",extent);
2681
value=GetImageProperty(image,"comment");
2682
if (value == (const char *) NULL)
2684
length=strlen(value);
2685
if ((size_t) (q-interpret_text+length+1) >= extent)
2688
interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2689
MaxTextExtent,sizeof(*interpret_text));
2690
if (interpret_text == (char *) NULL)
2692
q=interpret_text+strlen(interpret_text);
2694
(void) CopyMagickString(q,value,extent);
2704
Label segment is the base of the filename.
2706
if (*image->magick_filename == '\0')
2715
GetPathComponent(image->magick_filename,HeadPath,filename);
2716
q+=CopyMagickString(q,filename,extent);
2724
GetPathComponent(image->magick_filename,ExtensionPath,filename);
2725
q+=CopyMagickString(q,filename,extent);
2733
GetPathComponent(image->magick_filename,TailPath,filename);
2734
q+=CopyMagickString(q,filename,extent);
2742
GetPathComponent(image->magick_filename,BasePath,filename);
2743
q+=CopyMagickString(q,filename,extent);
2754
q+=FormatMagickString(q,extent,"%.20gx%.20g%+.20g%+.20g",(double)
2755
image->page.width,(double) image->page.height,(double) image->page.x,
2756
(double) image->page.y);
2764
q+=FormatMagickString(q,extent,"%.20g",(double) (image->rows != 0 ?
2765
image->rows : image->magick_rows));
2773
q+=CopyMagickString(q,image->filename,extent);
2779
Number of unique colors.
2781
q+=FormatMagickString(q,extent,"%.20g",(double) GetNumberColors(image,
2782
(FILE *) NULL,&image->exception));
2790
value=GetImageProperty(image,"label");
2791
if (value == (const char *) NULL)
2793
length=strlen(value);
2794
if ((size_t) (q-interpret_text+length+1) >= extent)
2797
interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2798
MaxTextExtent,sizeof(*interpret_text));
2799
if (interpret_text == (char *) NULL)
2801
q=interpret_text+strlen(interpret_text);
2803
q+=CopyMagickString(q,value,extent);
2811
q+=CopyMagickString(q,image->magick,extent);
2817
Image magick filename.
2819
q+=CopyMagickString(q,image->magick_filename,extent);
2825
Number of images in the list.
2827
q+=FormatMagickString(q,extent,"%.20g",(double)
2828
GetImageListLength(image));
2834
Image output filename.
2836
q+=CopyMagickString(q,image_info->filename,extent);
2842
Image index in list.
2844
q+=FormatMagickString(q,extent,"%.20g",(double)
2845
GetImageIndexInList(image));
2853
q+=FormatMagickString(q,extent,"%.20g",(double)
2854
MAGICKCORE_QUANTUM_DEPTH);
2863
Image storage class and colorspace.
2865
colorspace=image->colorspace;
2866
if (IsGrayImage(image,&image->exception) != MagickFalse)
2867
colorspace=GRAYColorspace;
2868
q+=FormatMagickString(q,extent,"%s%s%s",CommandOptionToMnemonic(
2869
MagickClassOptions,(ssize_t) image->storage_class),
2870
CommandOptionToMnemonic(MagickColorspaceOptions,(ssize_t) colorspace),
2871
image->matte != MagickFalse ? "Matte" : "");
2879
if (image_info->number_scenes == 0)
2880
q+=FormatMagickString(q,extent,"%.20g",(double) image->scene);
2882
q+=FormatMagickString(q,extent,"%.20g",(double) image_info->scene);
2890
(void) CopyMagickString(filename,image_info->unique,extent);
2891
q+=CopyMagickString(q,filename,extent);
2899
q+=FormatMagickString(q,extent,"%.20g",(double) (image->columns != 0 ?
2900
image->columns : image->magick_columns));
2906
Image horizontal resolution.
2908
q+=FormatMagickString(q,extent,"%g %s",image->x_resolution,
2909
CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2916
Image vertical resolution.
2918
q+=FormatMagickString(q,extent,"%g %s",image->y_resolution,
2919
CommandOptionToMnemonic(MagickResolutionOptions,(ssize_t)
2928
q+=FormatMagickString(q,extent,"%.20g",(double) image->depth);
2934
Image alpha channel.
2936
q+=FormatMagickString(q,extent,"%s",CommandOptionToMnemonic(
2937
MagickBooleanOptions,(ssize_t) image->matte));
2943
Image compression method.
2945
q+=FormatMagickString(q,extent,"%s",CommandOptionToMnemonic(
2946
MagickCompressOptions,(ssize_t) image->compression));
2952
Image dispose method.
2954
q+=FormatMagickString(q,extent,"%s",CommandOptionToMnemonic(
2955
MagickDisposeOptions,(ssize_t) image->dispose));
2960
q+=FormatMagickString(q,extent,"%.20gx%.20g",(double)
2961
image->magick_columns,(double) image->magick_rows);
2966
q+=FormatMagickString(q,extent,"%.20g",(double) image->page.height);
2971
q+=FormatMagickString(q,extent,"%+ld%+ld",(long) image->page.x,(long)
2977
q+=FormatMagickString(q,extent,"%.20gx%.20g",(double) image->page.width,
2978
(double) image->page.height);
2983
q+=FormatMagickString(q,extent,"%.20g",(double) image->quality);
2991
if (image_info->number_scenes == 0)
2992
q+=CopyMagickString(q,"2147483647",extent);
2994
q+=FormatMagickString(q,extent,"%.20g",(double) (image_info->scene+
2995
image_info->number_scenes));
3000
q+=FormatMagickString(q,extent,"%.20g",(double) image->delay);
3005
q+=FormatMagickString(q,extent,"%.20g",(double) image->page.width);
3010
q+=FormatMagickString(q,extent,"%+.20g",(double) image->page.x);
3015
q+=FormatMagickString(q,extent,"%+.20g",(double) image->page.y);
3023
(void) CopyMagickString(filename,image_info->zero,extent);
3024
q+=CopyMagickString(q,filename,extent);
3030
pattern[MaxTextExtent];
3042
if (strchr(p,']') == (char *) NULL)
3046
for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
3057
value=GetImageProperty(image,pattern);
3058
if (value != (const char *) NULL)
3060
length=strlen(value);
3061
if ((size_t) (q-interpret_text+length+1) >= extent)
3064
interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3065
extent+MaxTextExtent,sizeof(*interpret_text));
3066
if (interpret_text == (char *) NULL)
3068
q=interpret_text+strlen(interpret_text);
3070
(void) CopyMagickString(q,value,extent);
3075
if (IsGlob(pattern) != MagickFalse)
3078
Iterate over image properties.
3080
ResetImagePropertyIterator(image);
3081
key=GetNextImageProperty(image);
3082
while (key != (const char *) NULL)
3084
if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3086
value=GetImageProperty(image,key);
3087
if (value != (const char *) NULL)
3089
length=strlen(key)+strlen(value)+2;
3090
if ((size_t) (q-interpret_text+length+1) >= extent)
3093
interpret_text=(char *) ResizeQuantumMemory(
3094
interpret_text,extent+MaxTextExtent,
3095
sizeof(*interpret_text));
3096
if (interpret_text == (char *) NULL)
3098
q=interpret_text+strlen(interpret_text);
3100
q+=FormatMagickString(q,extent,"%s=%s\n",key,value);
3103
key=GetNextImageProperty(image);
3106
value=GetMagickProperty(image_info,image,pattern);
3107
if (value != (const char *) NULL)
3109
length=strlen(value);
3110
if ((size_t) (q-interpret_text+length+1) >= extent)
3113
interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3114
extent+MaxTextExtent,sizeof(*interpret_text));
3115
if (interpret_text == (char *) NULL)
3117
q=interpret_text+strlen(interpret_text);
3119
(void) CopyMagickString(q,value,extent);
3123
if (image_info == (ImageInfo *) NULL)
3125
value=GetImageOption(image_info,pattern);
3126
if (value != (char *) NULL)
3128
length=strlen(value);
3129
if ((size_t) (q-interpret_text+length+1) >= extent)
3132
interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3133
extent+MaxTextExtent,sizeof(*interpret_text));
3134
if (interpret_text == (char *) NULL)
3136
q=interpret_text+strlen(interpret_text);
3138
(void) CopyMagickString(q,value,extent);
3152
page=GetImageBoundingBox(image,&image->exception);
3153
q+=FormatMagickString(q,MaxTextExtent,"%.20gx%.20g%+.20g%+.20g",
3154
(double) page.width,(double) page.height,(double) page.x,(double)
3163
(void) SignatureImage(image);
3164
value=GetImageProperty(image,"signature");
3165
if (value == (const char *) NULL)
3167
q+=CopyMagickString(q,value,extent);
3184
if (text != (const char *) embed_text)
3185
text=DestroyString(text);
3186
(void) SubstituteString(&interpret_text,"<","<");
3187
(void) SubstituteString(&interpret_text,">",">");
3188
return(interpret_text);
3192
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3196
% R e m o v e I m a g e P r o p e r t y %
3200
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3202
% RemoveImageProperty() removes a property from the image and returns its
3205
% The format of the RemoveImageProperty method is:
3207
% char *RemoveImageProperty(Image *image,const char *property)
3209
% A description of each parameter follows:
3211
% o image: the image.
3213
% o property: the image property.
3216
MagickExport char *RemoveImageProperty(Image *image,
3217
const char *property)
3222
assert(image != (Image *) NULL);
3223
assert(image->signature == MagickSignature);
3224
if (image->debug != MagickFalse)
3225
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3227
if (image->properties == (void *) NULL)
3228
return((char *) NULL);
3229
value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3235
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3239
% R e s e t I m a g e P r o p e r t y I t e r a t o r %
3243
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3245
% ResetImagePropertyIterator() resets the image properties iterator. Use it
3246
% in conjunction with GetNextImageProperty() to iterate over all the values
3247
% associated with an image property.
3249
% The format of the ResetImagePropertyIterator method is:
3251
% ResetImagePropertyIterator(Image *image)
3253
% A description of each parameter follows:
3255
% o image: the image.
3258
MagickExport void ResetImagePropertyIterator(const Image *image)
3260
assert(image != (Image *) NULL);
3261
assert(image->signature == MagickSignature);
3262
if (image->debug != MagickFalse)
3263
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3265
if (image->properties == (void *) NULL)
3267
ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3271
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3275
% S e t I m a g e P r o p e r t y %
3279
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3281
% SetImageProperty() associates an value with an image property.
3283
% The format of the SetImageProperty method is:
3285
% MagickBooleanType SetImageProperty(Image *image,const char *property,
3286
% const char *value)
3288
% A description of each parameter follows:
3290
% o image: the image.
3292
% o property: the image property.
3294
% o values: the image property values.
3297
MagickExport MagickBooleanType SetImageProperty(Image *image,
3298
const char *property,const char *value)
3309
assert(image != (Image *) NULL);
3310
assert(image->signature == MagickSignature);
3311
if (image->debug != MagickFalse)
3312
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3314
if (image->properties == (void *) NULL)
3315
image->properties=NewSplayTree(CompareSplayTreeString,
3316
RelinquishMagickMemory,RelinquishMagickMemory);
3317
if ((value == (const char *) NULL) || (*value == '\0'))
3318
return(DeleteImageProperty(image,property));
3320
exception=(&image->exception);
3326
if (LocaleCompare(property,"background") == 0)
3328
(void) QueryColorDatabase(value,&image->background_color,exception);
3331
if (LocaleCompare(property,"bias") == 0)
3333
image->bias=SiPrefixToDouble(value,QuantumRange);
3336
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3337
ConstantString(property),ConstantString(value));
3343
if (LocaleCompare(property,"colorspace") == 0)
3348
colorspace=ParseCommandOption(MagickColorspaceOptions,MagickFalse,
3352
(void) SetImageColorspace(image,(ColorspaceType) colorspace);
3355
if (LocaleCompare(property,"compose") == 0)
3360
compose=ParseCommandOption(MagickComposeOptions,MagickFalse,value);
3363
image->compose=(CompositeOperator) compose;
3366
if (LocaleCompare(property,"compress") == 0)
3371
compression=ParseCommandOption(MagickCompressOptions,MagickFalse,
3373
if (compression < 0)
3375
image->compression=(CompressionType) compression;
3378
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3379
ConstantString(property),ConstantString(value));
3385
if (LocaleCompare(property,"delay") == 0)
3390
flags=ParseGeometry(value,&geometry_info);
3391
if ((flags & GreaterValue) != 0)
3393
if (image->delay > (size_t) floor(geometry_info.rho+0.5))
3394
image->delay=(size_t) floor(geometry_info.rho+0.5);
3397
if ((flags & LessValue) != 0)
3399
if (image->delay < (size_t) floor(geometry_info.rho+0.5))
3400
image->ticks_per_second=(ssize_t)
3401
floor(geometry_info.sigma+0.5);
3404
image->delay=(size_t) floor(geometry_info.rho+0.5);
3405
if ((flags & SigmaValue) != 0)
3406
image->ticks_per_second=(ssize_t) floor(geometry_info.sigma+0.5);
3409
if (LocaleCompare(property,"density") == 0)
3414
flags=ParseGeometry(value,&geometry_info);
3415
image->x_resolution=geometry_info.rho;
3416
image->y_resolution=geometry_info.sigma;
3417
if ((flags & SigmaValue) == 0)
3418
image->y_resolution=image->x_resolution;
3420
if (LocaleCompare(property,"depth") == 0)
3422
image->depth=StringToUnsignedLong(value);
3425
if (LocaleCompare(property,"dispose") == 0)
3430
dispose=ParseCommandOption(MagickDisposeOptions,MagickFalse,value);
3433
image->dispose=(DisposeType) dispose;
3436
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3437
ConstantString(property),ConstantString(value));
3443
if (LocaleCompare(property,"gravity") == 0)
3448
gravity=ParseCommandOption(MagickGravityOptions,MagickFalse,value);
3451
image->gravity=(GravityType) gravity;
3454
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3455
ConstantString(property),ConstantString(value));
3461
if (LocaleCompare(property,"intent") == 0)
3466
rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
3468
if (rendering_intent < 0)
3470
image->rendering_intent=(RenderingIntent) rendering_intent;
3473
if (LocaleCompare(property,"interpolate") == 0)
3478
interpolate=ParseCommandOption(MagickInterpolateOptions,MagickFalse,
3480
if (interpolate < 0)
3482
image->interpolate=(InterpolatePixelMethod) interpolate;
3485
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3486
ConstantString(property),ConstantString(value));
3492
if (LocaleCompare(property,"loop") == 0)
3494
image->iterations=StringToUnsignedLong(value);
3497
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3498
ConstantString(property),ConstantString(value));
3504
if (LocaleCompare(property,"page") == 0)
3509
geometry=GetPageGeometry(value);
3510
flags=ParseAbsoluteGeometry(geometry,&image->page);
3511
geometry=DestroyString(geometry);
3514
if (LocaleCompare(property,"profile") == 0)
3522
image_info=AcquireImageInfo();
3523
(void) CopyMagickString(image_info->filename,value,MaxTextExtent);
3524
(void) SetImageInfo(image_info,1,exception);
3525
profile=FileToStringInfo(image_info->filename,~0UL,exception);
3526
if (profile != (StringInfo *) NULL)
3527
status=SetImageProfile(image,image_info->magick,profile);
3528
image_info=DestroyImageInfo(image_info);
3531
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3532
ConstantString(property),ConstantString(value));
3538
if (LocaleCompare(property,"rendering-intent") == 0)
3543
rendering_intent=ParseCommandOption(MagickIntentOptions,MagickFalse,
3545
if (rendering_intent < 0)
3547
image->rendering_intent=(RenderingIntent) rendering_intent;
3550
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3551
ConstantString(property),ConstantString(value));
3557
if (LocaleCompare(property,"tile-offset") == 0)
3562
geometry=GetPageGeometry(value);
3563
flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3564
geometry=DestroyString(geometry);
3567
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3568
ConstantString(property),ConstantString(value));
3574
if (LocaleCompare(property,"units") == 0)
3579
units=ParseCommandOption(MagickResolutionOptions,MagickFalse,value);
3582
image->units=(ResolutionType) units;
3585
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3586
ConstantString(property),ConstantString(value));
3591
status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3592
ConstantString(property),ConstantString(value));