blob: e6126eeafeb7480af68e6989b3e88793406a396c [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
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 %
11% %
12% %
13% MagickCore Property Methods %
14% %
15% Software Design %
16% John Cristy %
17% March 2000 %
18% %
19% %
cristy16af1cb2009-12-11 21:38:29 +000020% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% http://www.imagemagick.org/script/license.php %
27% %
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. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37%
38*/
39
40/*
41 Include declarations.
42*/
43#include "magick/studio.h"
cristy5a2ca482009-10-14 18:24:56 +000044#include "magick/attribute.h"
cristy3ed852e2009-09-05 21:47:34 +000045#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"
cristyf2e11662009-10-14 01:24:43 +000057#include "magick/histogram.h"
58#include "magick/image.h"
cristy3ed852e2009-09-05 21:47:34 +000059#include "magick/image.h"
60#include "magick/layer.h"
61#include "magick/list.h"
cristy402d9c72010-01-18 17:34:43 +000062#include "magick/magick.h"
cristy3ed852e2009-09-05 21:47:34 +000063#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"
cristyf2f27272009-12-17 14:48:46 +000075#include "magick/string-private.h"
cristy3ed852e2009-09-05 21:47:34 +000076#include "magick/token.h"
77#include "magick/utility.h"
78#include "magick/xml-tree.h"
79
80/*
81%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82% %
83% %
84% %
85% C l o n e I m a g e P r o p e r t i e s %
86% %
87% %
88% %
89%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90%
91% CloneImageProperties() clones one or more image properties.
92%
93% The format of the CloneImageProperties method is:
94%
95% MagickBooleanType CloneImageProperties(Image *image,
96% const Image *clone_image)
97%
98% A description of each parameter follows:
99%
100% o image: the image.
101%
102% o clone_image: the clone image.
103%
104*/
105MagickExport MagickBooleanType CloneImageProperties(Image *image,
106 const Image *clone_image)
107{
108 assert(image != (Image *) NULL);
109 assert(image->signature == MagickSignature);
110 if (image->debug != MagickFalse)
111 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
112 assert(clone_image != (const Image *) NULL);
113 assert(clone_image->signature == MagickSignature);
114 if (clone_image->debug != MagickFalse)
115 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
116 clone_image->filename);
117 (void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
118 (void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
119 MaxTextExtent);
120 image->compression=clone_image->compression;
121 image->quality=clone_image->quality;
122 image->depth=clone_image->depth;
123 image->background_color=clone_image->background_color;
124 image->border_color=clone_image->border_color;
125 image->matte_color=clone_image->matte_color;
126 image->transparent_color=clone_image->transparent_color;
127 image->gamma=clone_image->gamma;
128 image->chromaticity=clone_image->chromaticity;
129 image->rendering_intent=clone_image->rendering_intent;
130 image->black_point_compensation=clone_image->black_point_compensation;
131 image->units=clone_image->units;
132 image->montage=(char *) NULL;
133 image->directory=(char *) NULL;
134 (void) CloneString(&image->geometry,clone_image->geometry);
135 image->offset=clone_image->offset;
136 image->x_resolution=clone_image->x_resolution;
137 image->y_resolution=clone_image->y_resolution;
138 image->page=clone_image->page;
139 image->tile_offset=clone_image->tile_offset;
140 image->extract_info=clone_image->extract_info;
141 image->bias=clone_image->bias;
142 image->filter=clone_image->filter;
143 image->blur=clone_image->blur;
144 image->fuzz=clone_image->fuzz;
145 image->interlace=clone_image->interlace;
146 image->interpolate=clone_image->interpolate;
147 image->endian=clone_image->endian;
148 image->gravity=clone_image->gravity;
149 image->compose=clone_image->compose;
150 image->scene=clone_image->scene;
151 image->orientation=clone_image->orientation;
152 image->dispose=clone_image->dispose;
153 image->delay=clone_image->delay;
154 image->ticks_per_second=clone_image->ticks_per_second;
155 image->iterations=clone_image->iterations;
156 image->total_colors=clone_image->total_colors;
157 image->taint=clone_image->taint;
158 image->progress_monitor=clone_image->progress_monitor;
159 image->client_data=clone_image->client_data;
160 image->start_loop=clone_image->start_loop;
161 image->error=clone_image->error;
162 image->signature=clone_image->signature;
163 if (clone_image->properties != (void *) NULL)
164 {
165 if (image->properties != (void *) NULL)
166 DestroyImageProperties(image);
167 image->properties=CloneSplayTree((SplayTreeInfo *)
168 clone_image->properties,(void *(*)(void *)) ConstantString,
169 (void *(*)(void *)) ConstantString);
170 }
171 return(MagickTrue);
172}
173
174/*
175%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176% %
177% %
178% %
179% D e f i n e I m a g e P r o p e r t y %
180% %
181% %
182% %
183%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184%
185% DefineImageProperty() associates a key/value pair with an image property.
186%
187% The format of the DefineImageProperty method is:
188%
189% MagickBooleanType DefineImageProperty(Image *image,
190% const char *property)
191%
192% A description of each parameter follows:
193%
194% o image: the image.
195%
196% o property: the image property.
197%
198*/
199MagickExport MagickBooleanType DefineImageProperty(Image *image,
200 const char *property)
201{
202 char
203 key[MaxTextExtent],
204 value[MaxTextExtent];
205
206 register char
207 *p;
208
209 assert(image != (Image *) NULL);
210 assert(property != (const char *) NULL);
211 (void) CopyMagickString(key,property,MaxTextExtent-1);
212 for (p=key; *p != '\0'; p++)
213 if (*p == '=')
214 break;
215 *value='\0';
216 if (*p == '=')
217 (void) CopyMagickString(value,p+1,MaxTextExtent);
218 *p='\0';
219 return(SetImageProperty(image,key,value));
220}
221
222/*
223%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
224% %
225% %
226% %
227% D e l e t e I m a g e P r o p e r t y %
228% %
229% %
230% %
231%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
232%
233% DeleteImageProperty() deletes an image property.
234%
235% The format of the DeleteImageProperty method is:
236%
237% MagickBooleanType DeleteImageProperty(Image *image,const char *property)
238%
239% A description of each parameter follows:
240%
241% o image: the image.
242%
243% o property: the image property.
244%
245*/
246MagickExport MagickBooleanType DeleteImageProperty(Image *image,
247 const char *property)
248{
249 assert(image != (Image *) NULL);
250 assert(image->signature == MagickSignature);
251 if (image->debug != MagickFalse)
252 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
253 image->filename);
254 if (image->properties == (void *) NULL)
255 return(MagickFalse);
256 return(DeleteNodeFromSplayTree((SplayTreeInfo *) image->properties,property));
257}
258
259/*
260%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
261% %
262% %
263% %
264% D e s t r o y I m a g e P r o p e r t i e s %
265% %
266% %
267% %
268%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
269%
270% DestroyImageProperties() releases memory associated with image property
271% values.
272%
273% The format of the DestroyDefines method is:
274%
275% void DestroyImageProperties(Image *image)
276%
277% A description of each parameter follows:
278%
279% o image: the image.
280%
281*/
282MagickExport void DestroyImageProperties(Image *image)
283{
284 assert(image != (Image *) NULL);
285 assert(image->signature == MagickSignature);
286 if (image->debug != MagickFalse)
287 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
288 image->filename);
289 if (image->properties != (void *) NULL)
290 image->properties=(void *) DestroySplayTree((SplayTreeInfo *)
291 image->properties);
292}
293
294/*
295%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
296% %
297% %
298% %
299% F o r m a t I m a g e P r o p e r t y %
300% %
301% %
302% %
303%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304%
305% FormatImageProperty() permits formatted property/value pairs to be saved as
306% an image proporty.
307%
308% The format of the FormatImageProperty method is:
309%
310% MagickBooleanType FormatImageProperty(Image *image,const char *property,
311% const char *format,...)
312%
313% A description of each parameter follows.
314%
315% o image: The image.
316%
317% o property: The attribute property.
318%
319% o format: A string describing the format to use to write the remaining
320% arguments.
321%
322*/
323
324MagickExport MagickBooleanType FormatImagePropertyList(Image *image,
325 const char *property,const char *format,va_list operands)
326{
327 char
328 value[MaxTextExtent];
329
330 int
331 n;
332
333#if defined(MAGICKCORE_HAVE_VSNPRINTF)
334 n=vsnprintf(value,MaxTextExtent,format,operands);
335#else
336 n=vsprintf(value,format,operands);
337#endif
338 if (n < 0)
339 value[MaxTextExtent-1]='\0';
340 return(SetImageProperty(image,property,value));
341}
342
343MagickExport MagickBooleanType FormatImageProperty(Image *image,
344 const char *property,const char *format,...)
345{
346 MagickBooleanType
347 status;
348
349 va_list
350 operands;
351
352 va_start(operands,format);
353 status=FormatImagePropertyList(image,property,format,operands);
354 va_end(operands);
355 return(status);
356}
357
358/*
359%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
360% %
361% %
362% %
363% G e t I m a g e P r o p e r t y %
364% %
365% %
366% %
367%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
368%
369% GetImageProperty() gets a value associated with an image property.
370%
371% The format of the GetImageProperty method is:
372%
373% const char *GetImageProperty(const Image *image,const char *key)
374%
375% A description of each parameter follows:
376%
377% o image: the image.
378%
379% o key: the key.
380%
381*/
382
383static char
384 *TracePSClippath(const unsigned char *,size_t,const unsigned long,
385 const unsigned long),
386 *TraceSVGClippath(const unsigned char *,size_t,const unsigned long,
387 const unsigned long);
388
389static MagickBooleanType GetIPTCProperty(const Image *image,const char *key)
390{
391 char
392 *attribute,
393 *message;
394
395 const StringInfo
396 *profile;
397
398 long
399 count,
400 dataset,
401 record;
402
403 register long
404 i;
405
406 size_t
407 length;
408
409 profile=GetImageProfile(image,"iptc");
410 if (profile == (StringInfo *) NULL)
411 profile=GetImageProfile(image,"8bim");
412 if (profile == (StringInfo *) NULL)
413 return(MagickFalse);
414 count=sscanf(key,"IPTC:%ld:%ld",&dataset,&record);
415 if (count != 2)
416 return(MagickFalse);
417 attribute=(char *) NULL;
418 for (i=0; i < (long) GetStringInfoLength(profile); i+=(long) length)
419 {
420 length=1;
421 if ((long) GetStringInfoDatum(profile)[i] != 0x1c)
422 continue;
423 length=(size_t) (GetStringInfoDatum(profile)[i+3] << 8);
424 length|=GetStringInfoDatum(profile)[i+4];
425 if (((long) GetStringInfoDatum(profile)[i+1] == dataset) &&
426 ((long) GetStringInfoDatum(profile)[i+2] == record))
427 {
428 message=(char *) NULL;
429 if (~length >= 1)
430 message=(char *) AcquireQuantumMemory(length+1UL,sizeof(*message));
431 if (message != (char *) NULL)
432 {
433 (void) CopyMagickString(message,(char *) GetStringInfoDatum(
434 profile)+i+5,length+1);
435 (void) ConcatenateString(&attribute,message);
436 (void) ConcatenateString(&attribute,";");
437 message=DestroyString(message);
438 }
439 }
440 i+=5;
441 }
442 if ((attribute == (char *) NULL) || (*attribute == ';'))
443 {
444 if (attribute != (char *) NULL)
445 attribute=DestroyString(attribute);
446 return(MagickFalse);
447 }
448 attribute[strlen(attribute)-1]='\0';
449 (void) SetImageProperty((Image *) image,key,(const char *) attribute);
450 attribute=DestroyString(attribute);
451 return(MagickTrue);
452}
453
454static inline long MagickMax(const long x,const long y)
455{
456 if (x > y)
457 return(x);
458 return(y);
459}
460
461static inline int ReadPropertyByte(const unsigned char **p,size_t *length)
462{
463 int
464 c;
465
466 if (*length < 1)
467 return(EOF);
468 c=(int) (*(*p)++);
469 (*length)--;
470 return(c);
471}
472
473static inline unsigned long ReadPropertyMSBLong(const unsigned char **p,
474 size_t *length)
475{
476 int
477 c;
478
479 register long
480 i;
481
482 unsigned char
483 buffer[4];
484
485 unsigned long
486 value;
487
488 if (*length < 4)
489 return(~0UL);
490 for (i=0; i < 4; i++)
491 {
492 c=(int) (*(*p)++);
493 (*length)--;
494 buffer[i]=(unsigned char) c;
495 }
496 value=(unsigned long) (buffer[0] << 24);
497 value|=buffer[1] << 16;
498 value|=buffer[2] << 8;
499 value|=buffer[3];
500 return(value & 0xffffffff);
501}
502
503static inline unsigned short ReadPropertyMSBShort(const unsigned char **p,
504 size_t *length)
505{
506 int
507 c;
508
509 register long
510 i;
511
512 unsigned char
513 buffer[2];
514
515 unsigned short
516 value;
517
518 if (*length < 2)
519 return((unsigned short) ~0U);
520 for (i=0; i < 2; i++)
521 {
522 c=(int) (*(*p)++);
523 (*length)--;
524 buffer[i]=(unsigned char) c;
525 }
526 value=(unsigned short) (buffer[0] << 8);
527 value|=buffer[1];
528 return((unsigned short) (value & 0xffff));
529}
530
531static MagickBooleanType Get8BIMProperty(const Image *image,const char *key)
532{
533 char
534 *attribute,
535 format[MaxTextExtent],
536 name[MaxTextExtent],
537 *resource;
538
539 const StringInfo
540 *profile;
541
542 const unsigned char
543 *info;
544
545 long
546 id,
547 start,
548 stop,
549 sub_number;
550
551 MagickBooleanType
552 status;
553
554 register long
555 i;
556
557 ssize_t
558 count;
559
560 size_t
561 length;
562
563 /*
564 There's no newlines in path names, so it's safe as terminator.
565 */
566 profile=GetImageProfile(image,"8bim");
567 if (profile == (StringInfo *) NULL)
568 return(MagickFalse);
569 count=(ssize_t) sscanf(key,"8BIM:%ld,%ld:%[^\n]\n%[^\n]",&start,&stop,name,
570 format);
571 if ((count != 2) && (count != 3) && (count != 4))
572 return(MagickFalse);
573 if (count < 4)
574 (void) CopyMagickString(format,"SVG",MaxTextExtent);
575 if (count < 3)
576 *name='\0';
577 sub_number=1;
578 if (*name == '#')
cristyf2f27272009-12-17 14:48:46 +0000579 sub_number=StringToLong(&name[1]);
cristy3ed852e2009-09-05 21:47:34 +0000580 sub_number=MagickMax(sub_number,1L);
581 resource=(char *) NULL;
582 status=MagickFalse;
583 length=GetStringInfoLength(profile);
584 info=GetStringInfoDatum(profile);
585 while ((length > 0) && (status == MagickFalse))
586 {
587 if (ReadPropertyByte(&info,&length) != (unsigned char) '8')
588 continue;
589 if (ReadPropertyByte(&info,&length) != (unsigned char) 'B')
590 continue;
591 if (ReadPropertyByte(&info,&length) != (unsigned char) 'I')
592 continue;
593 if (ReadPropertyByte(&info,&length) != (unsigned char) 'M')
594 continue;
595 id=(long) ReadPropertyMSBShort(&info,&length);
596 if (id < start)
597 continue;
598 if (id > stop)
599 continue;
600 if (resource != (char *) NULL)
601 resource=DestroyString(resource);
602 count=(ssize_t) ReadPropertyByte(&info,&length);
603 if ((count != 0) && ((size_t) count <= length))
604 {
605 resource=(char *) NULL;
606 if (~(1UL*count) >= MaxTextExtent)
607 resource=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
608 sizeof(*resource));
609 if (resource != (char *) NULL)
610 {
611 for (i=0; i < (long) count; i++)
612 resource[i]=(char) ReadPropertyByte(&info,&length);
613 resource[count]='\0';
614 }
615 }
616 if ((count & 0x01) == 0)
617 (void) ReadPropertyByte(&info,&length);
618 count=(ssize_t) ReadPropertyMSBLong(&info,&length);
619 if ((*name != '\0') && (*name != '#'))
620 if ((resource == (char *) NULL) || (LocaleCompare(name,resource) != 0))
621 {
622 /*
623 No name match, scroll forward and try next.
624 */
625 info+=count;
626 length-=count;
627 continue;
628 }
629 if ((*name == '#') && (sub_number != 1))
630 {
631 /*
632 No numbered match, scroll forward and try next.
633 */
634 sub_number--;
635 info+=count;
636 length-=count;
637 continue;
638 }
639 /*
640 We have the resource of interest.
641 */
642 attribute=(char *) NULL;
643 if (~(1UL*count) >= MaxTextExtent)
644 attribute=(char *) AcquireQuantumMemory((size_t) count+MaxTextExtent,
645 sizeof(*attribute));
646 if (attribute != (char *) NULL)
647 {
648 (void) CopyMagickMemory(attribute,(char *) info,(size_t) count);
649 attribute[count]='\0';
650 info+=count;
651 length-=count;
652 if ((id <= 1999) || (id >= 2999))
653 (void) SetImageProperty((Image *) image,key,(const char *)
654 attribute);
655 else
656 {
657 char
658 *path;
659
660 if (LocaleCompare(format,"svg") == 0)
661 path=TraceSVGClippath((unsigned char *) attribute,(size_t) count,
662 image->columns,image->rows);
663 else
664 path=TracePSClippath((unsigned char *) attribute,(size_t) count,
665 image->columns,image->rows);
666 (void) SetImageProperty((Image *) image,key,(const char *) path);
667 path=DestroyString(path);
668 }
669 attribute=DestroyString(attribute);
670 status=MagickTrue;
671 }
672 }
673 if (resource != (char *) NULL)
674 resource=DestroyString(resource);
675 return(status);
676}
677
678static inline unsigned short ReadPropertyShort(const EndianType endian,
679 const unsigned char *buffer)
680{
681 unsigned short
682 value;
683
684 if (endian == MSBEndian)
685 {
686 value=(unsigned short) ((((unsigned char *) buffer)[0] << 8) |
687 ((unsigned char *) buffer)[1]);
688 return((unsigned short) (value & 0xffff));
689 }
690 value=(unsigned short) ((buffer[1] << 8) | buffer[0]);
691 return((unsigned short) (value & 0xffff));
692}
693
694static inline unsigned long ReadPropertyLong(const EndianType endian,
695 const unsigned char *buffer)
696{
697 unsigned long
698 value;
699
700 if (endian == MSBEndian)
701 {
702 value=(unsigned long) ((buffer[0] << 24) | (buffer[1] << 16) |
703 (buffer[2] << 8) | buffer[3]);
704 return((unsigned long) (value & 0xffffffff));
705 }
706 value=(unsigned long) ((buffer[3] << 24) | (buffer[2] << 16) |
707 (buffer[1] << 8 ) | (buffer[0]));
708 return((unsigned long) (value & 0xffffffff));
709}
710
711static MagickBooleanType GetEXIFProperty(const Image *image,
712 const char *property)
713{
714#define MaxDirectoryStack 16
715#define EXIF_DELIMITER "\n"
716#define EXIF_NUM_FORMATS 12
717#define EXIF_FMT_BYTE 1
718#define EXIF_FMT_STRING 2
719#define EXIF_FMT_USHORT 3
720#define EXIF_FMT_ULONG 4
721#define EXIF_FMT_URATIONAL 5
722#define EXIF_FMT_SBYTE 6
723#define EXIF_FMT_UNDEFINED 7
724#define EXIF_FMT_SSHORT 8
725#define EXIF_FMT_SLONG 9
726#define EXIF_FMT_SRATIONAL 10
727#define EXIF_FMT_SINGLE 11
728#define EXIF_FMT_DOUBLE 12
729#define TAG_EXIF_OFFSET 0x8769
730#define TAG_GPS_OFFSET 0x8825
731#define TAG_INTEROP_OFFSET 0xa005
732
733#define EXIFMultipleValues(size, format, arg) \
734{ \
735 long \
736 component; \
737 \
738 size_t \
739 length; \
740 \
741 unsigned char \
742 *p1; \
743 \
744 length=0; \
745 p1=p; \
746 for (component=0; component < components; component++) \
747 { \
748 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
749 format", ",arg); \
750 if (length >= MaxTextExtent - 1) \
751 length=MaxTextExtent-1; \
752 p1+=size; \
753 } \
754 if (length > 1) \
755 buffer[length-2]='\0'; \
756 value=AcquireString(buffer); \
757}
758
759#define EXIFMultipleFractions(size, format, arg1, arg2) \
760{ \
761 long \
762 component; \
763 \
764 size_t \
765 length; \
766 \
767 unsigned char \
768 *p1; \
769 \
770 length=0; \
771 p1=p; \
772 for (component=0; component < components; component++) \
773 { \
774 length+=FormatMagickString(buffer+length,MaxTextExtent-length, \
775 format", ",arg1, arg2); \
776 if (length >= MaxTextExtent - 1) \
777 length=MaxTextExtent-1; \
778 p1+=size; \
779 } \
780 if (length > 1) \
781 buffer[length-2]='\0'; \
782 value=AcquireString(buffer); \
783}
784
785 typedef struct _DirectoryInfo
786 {
787 const unsigned char
788 *directory;
789
790 unsigned long
791 entry,
792 offset;
793 } DirectoryInfo;
794
795 typedef struct _TagInfo
796 {
797 unsigned long
798 tag;
799
800 const char
801 *description;
802 } TagInfo;
803
804 static TagInfo
805 EXIFTag[] =
806 {
807 { 0x001, "exif:InteroperabilityIndex" },
808 { 0x002, "exif:InteroperabilityVersion" },
809 { 0x100, "exif:ImageWidth" },
810 { 0x101, "exif:ImageLength" },
811 { 0x102, "exif:BitsPerSample" },
812 { 0x103, "exif:Compression" },
813 { 0x106, "exif:PhotometricInterpretation" },
814 { 0x10a, "exif:FillOrder" },
815 { 0x10d, "exif:DocumentName" },
816 { 0x10e, "exif:ImageDescription" },
817 { 0x10f, "exif:Make" },
818 { 0x110, "exif:Model" },
819 { 0x111, "exif:StripOffsets" },
820 { 0x112, "exif:Orientation" },
821 { 0x115, "exif:SamplesPerPixel" },
822 { 0x116, "exif:RowsPerStrip" },
823 { 0x117, "exif:StripByteCounts" },
824 { 0x11a, "exif:XResolution" },
825 { 0x11b, "exif:YResolution" },
826 { 0x11c, "exif:PlanarConfiguration" },
827 { 0x11d, "exif:PageName" },
828 { 0x11e, "exif:XPosition" },
829 { 0x11f, "exif:YPosition" },
830 { 0x118, "exif:MinSampleValue" },
831 { 0x119, "exif:MaxSampleValue" },
832 { 0x120, "exif:FreeOffsets" },
833 { 0x121, "exif:FreeByteCounts" },
834 { 0x122, "exif:GrayResponseUnit" },
835 { 0x123, "exif:GrayResponseCurve" },
836 { 0x124, "exif:T4Options" },
837 { 0x125, "exif:T6Options" },
838 { 0x128, "exif:ResolutionUnit" },
839 { 0x12d, "exif:TransferFunction" },
840 { 0x131, "exif:Software" },
841 { 0x132, "exif:DateTime" },
842 { 0x13b, "exif:Artist" },
843 { 0x13e, "exif:WhitePoint" },
844 { 0x13f, "exif:PrimaryChromaticities" },
845 { 0x140, "exif:ColorMap" },
846 { 0x141, "exif:HalfToneHints" },
847 { 0x142, "exif:TileWidth" },
848 { 0x143, "exif:TileLength" },
849 { 0x144, "exif:TileOffsets" },
850 { 0x145, "exif:TileByteCounts" },
851 { 0x14a, "exif:SubIFD" },
852 { 0x14c, "exif:InkSet" },
853 { 0x14d, "exif:InkNames" },
854 { 0x14e, "exif:NumberOfInks" },
855 { 0x150, "exif:DotRange" },
856 { 0x151, "exif:TargetPrinter" },
857 { 0x152, "exif:ExtraSample" },
858 { 0x153, "exif:SampleFormat" },
859 { 0x154, "exif:SMinSampleValue" },
860 { 0x155, "exif:SMaxSampleValue" },
861 { 0x156, "exif:TransferRange" },
862 { 0x157, "exif:ClipPath" },
863 { 0x158, "exif:XClipPathUnits" },
864 { 0x159, "exif:YClipPathUnits" },
865 { 0x15a, "exif:Indexed" },
866 { 0x15b, "exif:JPEGTables" },
867 { 0x15f, "exif:OPIProxy" },
868 { 0x200, "exif:JPEGProc" },
869 { 0x201, "exif:JPEGInterchangeFormat" },
870 { 0x202, "exif:JPEGInterchangeFormatLength" },
871 { 0x203, "exif:JPEGRestartInterval" },
872 { 0x205, "exif:JPEGLosslessPredictors" },
873 { 0x206, "exif:JPEGPointTransforms" },
874 { 0x207, "exif:JPEGQTables" },
875 { 0x208, "exif:JPEGDCTables" },
876 { 0x209, "exif:JPEGACTables" },
877 { 0x211, "exif:YCbCrCoefficients" },
878 { 0x212, "exif:YCbCrSubSampling" },
879 { 0x213, "exif:YCbCrPositioning" },
880 { 0x214, "exif:ReferenceBlackWhite" },
881 { 0x2bc, "exif:ExtensibleMetadataPlatform" },
882 { 0x301, "exif:Gamma" },
883 { 0x302, "exif:ICCProfileDescriptor" },
884 { 0x303, "exif:SRGBRenderingIntent" },
885 { 0x320, "exif:ImageTitle" },
886 { 0x5001, "exif:ResolutionXUnit" },
887 { 0x5002, "exif:ResolutionYUnit" },
888 { 0x5003, "exif:ResolutionXLengthUnit" },
889 { 0x5004, "exif:ResolutionYLengthUnit" },
890 { 0x5005, "exif:PrintFlags" },
891 { 0x5006, "exif:PrintFlagsVersion" },
892 { 0x5007, "exif:PrintFlagsCrop" },
893 { 0x5008, "exif:PrintFlagsBleedWidth" },
894 { 0x5009, "exif:PrintFlagsBleedWidthScale" },
895 { 0x500A, "exif:HalftoneLPI" },
896 { 0x500B, "exif:HalftoneLPIUnit" },
897 { 0x500C, "exif:HalftoneDegree" },
898 { 0x500D, "exif:HalftoneShape" },
899 { 0x500E, "exif:HalftoneMisc" },
900 { 0x500F, "exif:HalftoneScreen" },
901 { 0x5010, "exif:JPEGQuality" },
902 { 0x5011, "exif:GridSize" },
903 { 0x5012, "exif:ThumbnailFormat" },
904 { 0x5013, "exif:ThumbnailWidth" },
905 { 0x5014, "exif:ThumbnailHeight" },
906 { 0x5015, "exif:ThumbnailColorDepth" },
907 { 0x5016, "exif:ThumbnailPlanes" },
908 { 0x5017, "exif:ThumbnailRawBytes" },
909 { 0x5018, "exif:ThumbnailSize" },
910 { 0x5019, "exif:ThumbnailCompressedSize" },
911 { 0x501a, "exif:ColorTransferFunction" },
912 { 0x501b, "exif:ThumbnailData" },
913 { 0x5020, "exif:ThumbnailImageWidth" },
914 { 0x5021, "exif:ThumbnailImageHeight" },
915 { 0x5022, "exif:ThumbnailBitsPerSample" },
916 { 0x5023, "exif:ThumbnailCompression" },
917 { 0x5024, "exif:ThumbnailPhotometricInterp" },
918 { 0x5025, "exif:ThumbnailImageDescription" },
919 { 0x5026, "exif:ThumbnailEquipMake" },
920 { 0x5027, "exif:ThumbnailEquipModel" },
921 { 0x5028, "exif:ThumbnailStripOffsets" },
922 { 0x5029, "exif:ThumbnailOrientation" },
923 { 0x502a, "exif:ThumbnailSamplesPerPixel" },
924 { 0x502b, "exif:ThumbnailRowsPerStrip" },
925 { 0x502c, "exif:ThumbnailStripBytesCount" },
926 { 0x502d, "exif:ThumbnailResolutionX" },
927 { 0x502e, "exif:ThumbnailResolutionY" },
928 { 0x502f, "exif:ThumbnailPlanarConfig" },
929 { 0x5030, "exif:ThumbnailResolutionUnit" },
930 { 0x5031, "exif:ThumbnailTransferFunction" },
931 { 0x5032, "exif:ThumbnailSoftwareUsed" },
932 { 0x5033, "exif:ThumbnailDateTime" },
933 { 0x5034, "exif:ThumbnailArtist" },
934 { 0x5035, "exif:ThumbnailWhitePoint" },
935 { 0x5036, "exif:ThumbnailPrimaryChromaticities" },
936 { 0x5037, "exif:ThumbnailYCbCrCoefficients" },
937 { 0x5038, "exif:ThumbnailYCbCrSubsampling" },
938 { 0x5039, "exif:ThumbnailYCbCrPositioning" },
939 { 0x503A, "exif:ThumbnailRefBlackWhite" },
940 { 0x503B, "exif:ThumbnailCopyRight" },
941 { 0x5090, "exif:LuminanceTable" },
942 { 0x5091, "exif:ChrominanceTable" },
943 { 0x5100, "exif:FrameDelay" },
944 { 0x5101, "exif:LoopCount" },
945 { 0x5110, "exif:PixelUnit" },
946 { 0x5111, "exif:PixelPerUnitX" },
947 { 0x5112, "exif:PixelPerUnitY" },
948 { 0x5113, "exif:PaletteHistogram" },
949 { 0x1000, "exif:RelatedImageFileFormat" },
950 { 0x1001, "exif:RelatedImageLength" },
951 { 0x1002, "exif:RelatedImageWidth" },
952 { 0x800d, "exif:ImageID" },
953 { 0x80e3, "exif:Matteing" },
954 { 0x80e4, "exif:DataType" },
955 { 0x80e5, "exif:ImageDepth" },
956 { 0x80e6, "exif:TileDepth" },
957 { 0x828d, "exif:CFARepeatPatternDim" },
958 { 0x828e, "exif:CFAPattern2" },
959 { 0x828f, "exif:BatteryLevel" },
960 { 0x8298, "exif:Copyright" },
961 { 0x829a, "exif:ExposureTime" },
962 { 0x829d, "exif:FNumber" },
963 { 0x83bb, "exif:IPTC/NAA" },
964 { 0x84e3, "exif:IT8RasterPadding" },
965 { 0x84e5, "exif:IT8ColorTable" },
966 { 0x8649, "exif:ImageResourceInformation" },
967 { 0x8769, "exif:ExifOffset" },
968 { 0x8773, "exif:InterColorProfile" },
969 { 0x8822, "exif:ExposureProgram" },
970 { 0x8824, "exif:SpectralSensitivity" },
971 { 0x8825, "exif:GPSInfo" },
972 { 0x8827, "exif:ISOSpeedRatings" },
973 { 0x8828, "exif:OECF" },
974 { 0x8829, "exif:Interlace" },
975 { 0x882a, "exif:TimeZoneOffset" },
976 { 0x882b, "exif:SelfTimerMode" },
977 { 0x9000, "exif:ExifVersion" },
978 { 0x9003, "exif:DateTimeOriginal" },
979 { 0x9004, "exif:DateTimeDigitized" },
980 { 0x9101, "exif:ComponentsConfiguration" },
981 { 0x9102, "exif:CompressedBitsPerPixel" },
982 { 0x9201, "exif:ShutterSpeedValue" },
983 { 0x9202, "exif:ApertureValue" },
984 { 0x9203, "exif:BrightnessValue" },
985 { 0x9204, "exif:ExposureBiasValue" },
986 { 0x9205, "exif:MaxApertureValue" },
987 { 0x9206, "exif:SubjectDistance" },
988 { 0x9207, "exif:MeteringMode" },
989 { 0x9208, "exif:LightSource" },
990 { 0x9209, "exif:Flash" },
991 { 0x920a, "exif:FocalLength" },
992 { 0x920b, "exif:FlashEnergy" },
993 { 0x920c, "exif:SpatialFrequencyResponse" },
994 { 0x920d, "exif:Noise" },
995 { 0x9211, "exif:ImageNumber" },
996 { 0x9212, "exif:SecurityClassification" },
997 { 0x9213, "exif:ImageHistory" },
998 { 0x9214, "exif:SubjectArea" },
999 { 0x9215, "exif:ExposureIndex" },
1000 { 0x9216, "exif:TIFF-EPStandardID" },
1001 { 0x927c, "exif:MakerNote" },
1002 { 0x9C9b, "exif:WinXP-Title" },
1003 { 0x9C9c, "exif:WinXP-Comments" },
1004 { 0x9C9d, "exif:WinXP-Author" },
1005 { 0x9C9e, "exif:WinXP-Keywords" },
1006 { 0x9C9f, "exif:WinXP-Subject" },
1007 { 0x9286, "exif:UserComment" },
1008 { 0x9290, "exif:SubSecTime" },
1009 { 0x9291, "exif:SubSecTimeOriginal" },
1010 { 0x9292, "exif:SubSecTimeDigitized" },
1011 { 0xa000, "exif:FlashPixVersion" },
1012 { 0xa001, "exif:ColorSpace" },
1013 { 0xa002, "exif:ExifImageWidth" },
1014 { 0xa003, "exif:ExifImageLength" },
1015 { 0xa004, "exif:RelatedSoundFile" },
1016 { 0xa005, "exif:InteroperabilityOffset" },
1017 { 0xa20b, "exif:FlashEnergy" },
1018 { 0xa20c, "exif:SpatialFrequencyResponse" },
1019 { 0xa20d, "exif:Noise" },
1020 { 0xa20e, "exif:FocalPlaneXResolution" },
1021 { 0xa20f, "exif:FocalPlaneYResolution" },
1022 { 0xa210, "exif:FocalPlaneResolutionUnit" },
1023 { 0xa214, "exif:SubjectLocation" },
1024 { 0xa215, "exif:ExposureIndex" },
1025 { 0xa216, "exif:TIFF/EPStandardID" },
1026 { 0xa217, "exif:SensingMethod" },
1027 { 0xa300, "exif:FileSource" },
1028 { 0xa301, "exif:SceneType" },
1029 { 0xa302, "exif:CFAPattern" },
1030 { 0xa401, "exif:CustomRendered" },
1031 { 0xa402, "exif:ExposureMode" },
1032 { 0xa403, "exif:WhiteBalance" },
1033 { 0xa404, "exif:DigitalZoomRatio" },
1034 { 0xa405, "exif:FocalLengthIn35mmFilm" },
1035 { 0xa406, "exif:SceneCaptureType" },
1036 { 0xa407, "exif:GainControl" },
1037 { 0xa408, "exif:Contrast" },
1038 { 0xa409, "exif:Saturation" },
1039 { 0xa40a, "exif:Sharpness" },
1040 { 0xa40b, "exif:DeviceSettingDescription" },
1041 { 0xa40c, "exif:SubjectDistanceRange" },
1042 { 0xa420, "exif:ImageUniqueID" },
1043 { 0xc4a5, "exif:PrintImageMatching" },
cristyb3fea0e2009-11-28 01:46:20 +00001044 { 0xa500, "exif:Gamma" },
1045 { 0xc640, "exif:CR2Slice" },
cristy3ed852e2009-09-05 21:47:34 +00001046 { 0x10000, "exif:GPSVersionID" },
1047 { 0x10001, "exif:GPSLatitudeRef" },
1048 { 0x10002, "exif:GPSLatitude" },
1049 { 0x10003, "exif:GPSLongitudeRef" },
1050 { 0x10004, "exif:GPSLongitude" },
1051 { 0x10005, "exif:GPSAltitudeRef" },
1052 { 0x10006, "exif:GPSAltitude" },
1053 { 0x10007, "exif:GPSTimeStamp" },
1054 { 0x10008, "exif:GPSSatellites" },
1055 { 0x10009, "exif:GPSStatus" },
1056 { 0x1000a, "exif:GPSMeasureMode" },
1057 { 0x1000b, "exif:GPSDop" },
1058 { 0x1000c, "exif:GPSSpeedRef" },
1059 { 0x1000d, "exif:GPSSpeed" },
1060 { 0x1000e, "exif:GPSTrackRef" },
1061 { 0x1000f, "exif:GPSTrack" },
1062 { 0x10010, "exif:GPSImgDirectionRef" },
1063 { 0x10011, "exif:GPSImgDirection" },
1064 { 0x10012, "exif:GPSMapDatum" },
1065 { 0x10013, "exif:GPSDestLatitudeRef" },
1066 { 0x10014, "exif:GPSDestLatitude" },
1067 { 0x10015, "exif:GPSDestLongitudeRef" },
1068 { 0x10016, "exif:GPSDestLongitude" },
1069 { 0x10017, "exif:GPSDestBearingRef" },
1070 { 0x10018, "exif:GPSDestBearing" },
1071 { 0x10019, "exif:GPSDestDistanceRef" },
1072 { 0x1001a, "exif:GPSDestDistance" },
1073 { 0x1001b, "exif:GPSProcessingMethod" },
1074 { 0x1001c, "exif:GPSAreaInformation" },
1075 { 0x1001d, "exif:GPSDateStamp" },
1076 { 0x1001e, "exif:GPSDifferential" },
1077 { 0x0000, NULL}
1078 };
1079
1080 const StringInfo
1081 *profile;
1082
1083 const unsigned char
1084 *directory,
1085 *exif;
1086
1087 DirectoryInfo
1088 directory_stack[MaxDirectoryStack];
1089
1090 EndianType
1091 endian;
1092
1093 long
1094 all,
1095 id,
1096 level,
1097 tag_value;
1098
1099 register long
1100 i;
1101
1102 size_t
1103 length;
1104
1105 ssize_t
1106 offset;
1107
1108 static int
1109 tag_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};
1110
1111 unsigned long
1112 entry,
1113 number_entries,
1114 tag_offset,
1115 tag;
1116
1117 /*
1118 If EXIF data exists, then try to parse the request for a tag.
1119 */
1120 profile=GetImageProfile(image,"exif");
1121 if (profile == (StringInfo *) NULL)
1122 return(MagickFalse);
1123 if ((property == (const char *) NULL) || (*property == '\0'))
1124 return(MagickFalse);
1125 while (isspace((int) ((unsigned char) *property)) != 0)
1126 property++;
1127 all=0;
1128 tag=(~0UL);
1129 switch (*(property+5))
1130 {
1131 case '*':
1132 {
1133 /*
1134 Caller has asked for all the tags in the EXIF data.
1135 */
1136 tag=0;
1137 all=1; /* return the data in description=value format */
1138 break;
1139 }
1140 case '!':
1141 {
1142 tag=0;
1143 all=2; /* return the data in tagid=value format */
1144 break;
1145 }
1146 case '#':
1147 case '@':
1148 {
1149 int
1150 c;
1151
1152 size_t
1153 n;
1154
1155 /*
1156 Check for a hex based tag specification first.
1157 */
1158 tag=(*(property+5) == '@') ? 1UL : 0UL;
1159 property+=6;
1160 n=strlen(property);
1161 if (n != 4)
1162 return(MagickFalse);
1163 /*
1164 Parse tag specification as a hex number.
1165 */
1166 n/=4;
1167 do
1168 {
1169 for (i=(long) n-1L; i >= 0; i--)
1170 {
1171 c=(*property++);
1172 tag<<=4;
1173 if ((c >= '0') && (c <= '9'))
1174 tag|=(c-'0');
1175 else
1176 if ((c >= 'A') && (c <= 'F'))
1177 tag|=(c-('A'-10));
1178 else
1179 if ((c >= 'a') && (c <= 'f'))
1180 tag|=(c-('a'-10));
1181 else
1182 return(MagickFalse);
1183 }
1184 } while (*property != '\0');
1185 break;
1186 }
1187 default:
1188 {
1189 /*
1190 Try to match the text with a tag name instead.
1191 */
1192 for (i=0; ; i++)
1193 {
1194 if (EXIFTag[i].tag == 0)
1195 break;
1196 if (LocaleCompare(EXIFTag[i].description,property) == 0)
1197 {
1198 tag=(unsigned long) EXIFTag[i].tag;
1199 break;
1200 }
1201 }
1202 break;
1203 }
1204 }
1205 if (tag == (~0UL))
1206 return(MagickFalse);
1207 length=GetStringInfoLength(profile);
1208 exif=GetStringInfoDatum(profile);
1209 while (length != 0)
1210 {
1211 if (ReadPropertyByte(&exif,&length) != 0x45)
1212 continue;
1213 if (ReadPropertyByte(&exif,&length) != 0x78)
1214 continue;
1215 if (ReadPropertyByte(&exif,&length) != 0x69)
1216 continue;
1217 if (ReadPropertyByte(&exif,&length) != 0x66)
1218 continue;
1219 if (ReadPropertyByte(&exif,&length) != 0x00)
1220 continue;
1221 if (ReadPropertyByte(&exif,&length) != 0x00)
1222 continue;
1223 break;
1224 }
1225 if (length < 16)
1226 return(MagickFalse);
1227 id=(long) ReadPropertyShort(LSBEndian,exif);
1228 endian=LSBEndian;
1229 if (id == 0x4949)
1230 endian=LSBEndian;
1231 else
1232 if (id == 0x4D4D)
1233 endian=MSBEndian;
1234 else
1235 return(MagickFalse);
1236 if (ReadPropertyShort(endian,exif+2) != 0x002a)
1237 return(MagickFalse);
1238 /*
1239 This the offset to the first IFD.
1240 */
1241 offset=(ssize_t) ReadPropertyLong(endian,exif+4);
1242 if ((size_t) offset >= length)
1243 return(MagickFalse);
1244 /*
1245 Set the pointer to the first IFD and follow it were it leads.
1246 */
1247 directory=exif+offset;
1248 level=0;
1249 entry=0;
1250 tag_offset=0;
1251 do
1252 {
1253 /*
1254 If there is anything on the stack then pop it off.
1255 */
1256 if (level > 0)
1257 {
1258 level--;
1259 directory=directory_stack[level].directory;
1260 entry=directory_stack[level].entry;
1261 tag_offset=directory_stack[level].offset;
1262 }
1263 /*
1264 Determine how many entries there are in the current IFD.
1265 */
1266 number_entries=ReadPropertyShort(endian,directory);
1267 for ( ; entry < number_entries; entry++)
1268 {
1269 long
1270 components;
1271
1272 register unsigned char
1273 *p,
1274 *q;
1275
1276 size_t
1277 number_bytes;
1278
1279 unsigned long
1280 format;
1281
1282 q=(unsigned char *) (directory+2+(12*entry));
1283 tag_value=(long) ReadPropertyShort(endian,q)+tag_offset;
1284 format=(unsigned long) ReadPropertyShort(endian,q+2);
1285 if (format >= (sizeof(tag_bytes)/sizeof(*tag_bytes)))
1286 break;
1287 components=(long) ReadPropertyLong(endian,q+4);
1288 number_bytes=(size_t) components*tag_bytes[format];
1289 if (number_bytes <= 4)
1290 p=q+8;
1291 else
1292 {
1293 ssize_t
1294 offset;
1295
1296 /*
1297 The directory entry contains an offset.
1298 */
1299 offset=(ssize_t) ReadPropertyLong(endian,q+8);
1300 if ((size_t) (offset+number_bytes) > length)
1301 continue;
1302 p=(unsigned char *) (exif+offset);
1303 }
1304 if ((all != 0) || (tag == (unsigned long) tag_value))
1305 {
1306 char
1307 buffer[MaxTextExtent],
1308 *value;
1309
1310 switch (format)
1311 {
1312 case EXIF_FMT_BYTE:
1313 case EXIF_FMT_UNDEFINED:
1314 {
1315 EXIFMultipleValues(1,"%lu",(unsigned long)
1316 (*(unsigned char *) p1));
1317 break;
1318 }
1319 case EXIF_FMT_SBYTE:
1320 {
1321 EXIFMultipleValues(1,"%ld",(long) (*(signed char *) p1));
1322 break;
1323 }
1324 case EXIF_FMT_SSHORT:
1325 {
1326 EXIFMultipleValues(2,"%hd",ReadPropertyShort(endian,p1));
1327 break;
1328 }
1329 case EXIF_FMT_USHORT:
1330 {
1331 EXIFMultipleValues(2,"%hu",ReadPropertyShort(endian,p1));
1332 break;
1333 }
1334 case EXIF_FMT_ULONG:
1335 {
1336 EXIFMultipleValues(4,"%lu",ReadPropertyLong(endian,p1));
1337 break;
1338 }
1339 case EXIF_FMT_SLONG:
1340 {
1341 EXIFMultipleValues(4,"%ld",ReadPropertyLong(endian,p1));
1342 break;
1343 }
1344 case EXIF_FMT_URATIONAL:
1345 {
1346 EXIFMultipleFractions(8,"%ld/%ld",ReadPropertyLong(endian,p1),
1347 ReadPropertyLong(endian,p1+4));
1348 break;
1349 }
1350 case EXIF_FMT_SRATIONAL:
1351 {
1352 EXIFMultipleFractions(8,"%ld/%ld",ReadPropertyLong(endian,p1),
1353 ReadPropertyLong(endian,p1+4));
1354 break;
1355 }
1356 case EXIF_FMT_SINGLE:
1357 {
1358 EXIFMultipleValues(4,"%f",(double) *(float *) p1);
1359 break;
1360 }
1361 case EXIF_FMT_DOUBLE:
1362 {
1363 EXIFMultipleValues(8,"%f",*(double *) p1);
1364 break;
1365 }
1366 default:
1367 case EXIF_FMT_STRING:
1368 {
1369 value=(char *) NULL;
1370 if (~(1UL*number_bytes) >= 1)
1371 value=(char *) AcquireQuantumMemory((size_t) number_bytes+1UL,
1372 sizeof(*value));
1373 if (value != (char *) NULL)
1374 {
1375 register long
1376 i;
1377
1378 for (i=0; i < (long) number_bytes; i++)
1379 {
1380 value[i]='.';
1381 if ((isprint((int) p[i]) != 0) || (p[i] == '\0'))
1382 value[i]=(char) p[i];
1383 }
1384 value[i]='\0';
1385 }
1386 break;
1387 }
1388 }
1389 if (value != (char *) NULL)
1390 {
1391 char
1392 key[MaxTextExtent];
1393
1394 register const char
1395 *p;
1396
1397 (void) CopyMagickString(key,property,MaxTextExtent);
1398 switch (all)
1399 {
1400 case 1:
1401 {
1402 const char
1403 *description;
1404
1405 register long
1406 i;
1407
1408 description="unknown";
1409 for (i=0; ; i++)
1410 {
1411 if (EXIFTag[i].tag == 0)
1412 break;
1413 if ((long) EXIFTag[i].tag == tag_value)
1414 {
1415 description=EXIFTag[i].description;
1416 break;
1417 }
1418 }
1419 (void) FormatMagickString(key,MaxTextExtent,"%s",
1420 description);
1421 break;
1422 }
1423 case 2:
1424 {
1425 if (tag_value < 0x10000)
1426 (void) FormatMagickString(key,MaxTextExtent,"#%04lx",
1427 tag_value);
1428 else
1429 if (tag_value < 0x20000)
1430 (void) FormatMagickString(key,MaxTextExtent,"@%04lx",
1431 tag_value & 0xffff);
1432 else
1433 (void) FormatMagickString(key,MaxTextExtent,"unknown");
1434 break;
1435 }
1436 }
1437 p=(const char *) NULL;
1438 if (image->properties != (void *) NULL)
1439 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1440 image->properties,key);
1441 if (p == (const char *) NULL)
1442 (void) SetImageProperty((Image *) image,key,value);
1443 value=DestroyString(value);
1444 }
1445 }
1446 if ((tag_value == TAG_EXIF_OFFSET) ||
1447 (tag_value == TAG_INTEROP_OFFSET) ||
1448 (tag_value == TAG_GPS_OFFSET))
1449 {
1450 size_t
1451 offset;
1452
1453 offset=(size_t) ReadPropertyLong(endian,p);
1454 if ((offset < length) && (level < (MaxDirectoryStack-2)))
1455 {
1456 unsigned long
1457 tag_offset1;
1458
1459 tag_offset1=(tag_value == TAG_GPS_OFFSET) ? 0x10000UL : 0UL;
1460 directory_stack[level].directory=directory;
1461 entry++;
1462 directory_stack[level].entry=entry;
1463 directory_stack[level].offset=tag_offset;
1464 level++;
1465 directory_stack[level].directory=exif+offset;
1466 directory_stack[level].offset=tag_offset1;
1467 directory_stack[level].entry=0;
1468 level++;
1469 if ((directory+2+(12*number_entries)) > (exif+length))
1470 break;
1471 offset=(size_t) ReadPropertyLong(endian,directory+2+(12*
1472 number_entries));
1473 if ((offset != 0) && (offset < length) &&
1474 (level < (MaxDirectoryStack-2)))
1475 {
1476 directory_stack[level].directory=exif+offset;
1477 directory_stack[level].entry=0;
1478 directory_stack[level].offset=tag_offset1;
1479 level++;
1480 }
1481 }
1482 break;
1483 }
1484 }
1485 } while (level > 0);
1486 return(MagickTrue);
1487}
1488
1489static MagickBooleanType GetXMPProperty(const Image *image,
1490 const char *property)
1491{
1492 char
1493 *xmp_profile;
1494
1495 const StringInfo
1496 *profile;
1497
1498 ExceptionInfo
1499 *exception;
1500
1501 MagickBooleanType
1502 status;
1503
1504 register const char
1505 *p;
1506
1507 XMLTreeInfo
1508 *child,
1509 *description,
1510 *node,
1511 *rdf,
1512 *xmp;
1513
1514 profile=GetImageProfile(image,"xmp");
1515 if (profile == (StringInfo *) NULL)
1516 return(MagickFalse);
1517 if ((property == (const char *) NULL) || (*property == '\0'))
1518 return(MagickFalse);
1519 xmp_profile=StringInfoToString(profile);
1520 if (xmp_profile == (char *) NULL)
1521 return(MagickFalse);
1522 for (p=xmp_profile; *p != '\0'; p++)
1523 if ((*p == '<') && (*(p+1) == 'x'))
1524 break;
1525 exception=AcquireExceptionInfo();
1526 xmp=NewXMLTree((char *) p,exception);
1527 xmp_profile=DestroyString(xmp_profile);
1528 exception=DestroyExceptionInfo(exception);
1529 if (xmp == (XMLTreeInfo *) NULL)
1530 return(MagickFalse);
1531 status=MagickFalse;
1532 rdf=GetXMLTreeChild(xmp,"rdf:RDF");
1533 if (rdf != (XMLTreeInfo *) NULL)
1534 {
1535 if (image->properties == (void *) NULL)
1536 ((Image *) image)->properties=NewSplayTree(CompareSplayTreeString,
1537 RelinquishMagickMemory,RelinquishMagickMemory);
1538 description=GetXMLTreeChild(rdf,"rdf:Description");
1539 while (description != (XMLTreeInfo *) NULL)
1540 {
1541 node=GetXMLTreeChild(description,(const char *) NULL);
1542 while (node != (XMLTreeInfo *) NULL)
1543 {
1544 child=GetXMLTreeChild(node,(const char *) NULL);
1545 if (child == (XMLTreeInfo *) NULL)
1546 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1547 ConstantString(GetXMLTreeTag(node)),
1548 ConstantString(GetXMLTreeContent(node)));
1549 while (child != (XMLTreeInfo *) NULL)
1550 {
1551 if (LocaleCompare(GetXMLTreeTag(child),"rdf:Seq") != 0)
1552 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
1553 ConstantString(GetXMLTreeTag(child)),
1554 ConstantString(GetXMLTreeContent(child)));
1555 child=GetXMLTreeSibling(child);
1556 }
1557 node=GetXMLTreeSibling(node);
1558 }
1559 description=GetNextXMLTreeTag(description);
1560 }
1561 }
1562 xmp=DestroyXMLTree(xmp);
1563 return(status);
1564}
1565
1566static char *TracePSClippath(const unsigned char *blob,size_t length,
1567 const unsigned long magick_unused(columns),
1568 const unsigned long magick_unused(rows))
1569{
1570 char
1571 *path,
1572 *message;
1573
1574 long
1575 knot_count,
1576 selector,
1577 y;
1578
1579 MagickBooleanType
1580 in_subpath;
1581
1582 PointInfo
1583 first[3],
1584 last[3],
1585 point[3];
1586
1587 register long
1588 i,
1589 x;
1590
1591 path=AcquireString((char *) NULL);
1592 if (path == (char *) NULL)
1593 return((char *) NULL);
1594 message=AcquireString((char *) NULL);
1595 (void) FormatMagickString(message,MaxTextExtent,"/ClipImage\n");
1596 (void) ConcatenateString(&path,message);
1597 (void) FormatMagickString(message,MaxTextExtent,"{\n");
1598 (void) ConcatenateString(&path,message);
1599 (void) FormatMagickString(message,MaxTextExtent," /c {curveto} bind def\n");
1600 (void) ConcatenateString(&path,message);
1601 (void) FormatMagickString(message,MaxTextExtent," /l {lineto} bind def\n");
1602 (void) ConcatenateString(&path,message);
1603 (void) FormatMagickString(message,MaxTextExtent," /m {moveto} bind def\n");
1604 (void) ConcatenateString(&path,message);
1605 (void) FormatMagickString(message,MaxTextExtent,
1606 " /v {currentpoint 6 2 roll curveto} bind def\n");
1607 (void) ConcatenateString(&path,message);
1608 (void) FormatMagickString(message,MaxTextExtent,
1609 " /y {2 copy curveto} bind def\n");
1610 (void) ConcatenateString(&path,message);
1611 (void) FormatMagickString(message,MaxTextExtent,
1612 " /z {closepath} bind def\n");
1613 (void) ConcatenateString(&path,message);
1614 (void) FormatMagickString(message,MaxTextExtent," newpath\n");
1615 (void) ConcatenateString(&path,message);
1616 /*
1617 The clipping path format is defined in "Adobe Photoshop File
1618 Formats Specification" version 6.0 downloadable from adobe.com.
1619 */
1620 (void) ResetMagickMemory(point,0,sizeof(point));
1621 (void) ResetMagickMemory(first,0,sizeof(first));
1622 (void) ResetMagickMemory(last,0,sizeof(last));
1623 knot_count=0;
1624 in_subpath=MagickFalse;
1625 while (length > 0)
1626 {
1627 selector=(long) ReadPropertyMSBShort(&blob,&length);
1628 switch (selector)
1629 {
1630 case 0:
1631 case 3:
1632 {
1633 if (knot_count != 0)
1634 {
1635 blob+=24;
1636 length-=24;
1637 break;
1638 }
1639 /*
1640 Expected subpath length record.
1641 */
1642 knot_count=(long) ReadPropertyMSBShort(&blob,&length);
1643 blob+=22;
1644 length-=22;
1645 break;
1646 }
1647 case 1:
1648 case 2:
1649 case 4:
1650 case 5:
1651 {
1652 if (knot_count == 0)
1653 {
1654 /*
1655 Unexpected subpath knot
1656 */
1657 blob+=24;
1658 length-=24;
1659 break;
1660 }
1661 /*
1662 Add sub-path knot
1663 */
1664 for (i=0; i < 3; i++)
1665 {
cristy97433202009-10-27 02:05:08 +00001666 unsigned long
1667 xx,
1668 yy;
1669
1670 yy=ReadPropertyMSBLong(&blob,&length);
1671 xx=ReadPropertyMSBLong(&blob,&length);
1672 x=(long) xx;
1673 if (xx > 2147483647)
1674 x=xx-4294967295-1;
1675 y=(long) yy;
1676 if (yy > 2147483647)
1677 y=yy-4294967295-1;
cristy3ed852e2009-09-05 21:47:34 +00001678 point[i].x=(double) x/4096/4096;
1679 point[i].y=1.0-(double) y/4096/4096;
1680 }
1681 if (in_subpath == MagickFalse)
1682 {
cristye7f51092010-01-17 00:39:37 +00001683 (void) FormatMagickString(message,MaxTextExtent," %g %g m\n",
cristy3ed852e2009-09-05 21:47:34 +00001684 point[1].x,point[1].y);
1685 for (i=0; i < 3; i++)
1686 {
1687 first[i]=point[i];
1688 last[i]=point[i];
1689 }
1690 }
1691 else
1692 {
1693 /*
1694 Handle special cases when Bezier curves are used to describe
1695 corners and straight lines.
1696 */
1697 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1698 (point[0].x == point[1].x) && (point[0].y == point[1].y))
cristy8cd5b312010-01-07 01:10:24 +00001699 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001700 " %g %g l\n",point[1].x,point[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001701 else
1702 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1703 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001704 " %g %g %g %g v\n",point[0].x,point[0].y,
cristy8cd5b312010-01-07 01:10:24 +00001705 point[1].x,point[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001706 else
1707 if ((point[0].x == point[1].x) && (point[0].y == point[1].y))
1708 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001709 " %g %g %g %g y\n",last[2].x,last[2].y,
cristy8cd5b312010-01-07 01:10:24 +00001710 point[1].x,point[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001711 else
1712 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001713 " %g %g %g %g %g %g c\n",last[2].x,
cristy8cd5b312010-01-07 01:10:24 +00001714 last[2].y,point[0].x,point[0].y,point[1].x,point[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001715 for (i=0; i < 3; i++)
1716 last[i]=point[i];
1717 }
1718 (void) ConcatenateString(&path,message);
1719 in_subpath=MagickTrue;
1720 knot_count--;
1721 /*
1722 Close the subpath if there are no more knots.
1723 */
1724 if (knot_count == 0)
1725 {
1726 /*
1727 Same special handling as above except we compare to the
1728 first point in the path and close the path.
1729 */
1730 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1731 (first[0].x == first[1].x) && (first[0].y == first[1].y))
cristy8cd5b312010-01-07 01:10:24 +00001732 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001733 " %g %g l z\n",first[1].x,first[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001734 else
1735 if ((last[1].x == last[2].x) && (last[1].y == last[2].y))
1736 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001737 " %g %g %g %g v z\n",first[0].x,first[0].y,
cristy8cd5b312010-01-07 01:10:24 +00001738 first[1].x,first[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001739 else
1740 if ((first[0].x == first[1].x) && (first[0].y == first[1].y))
1741 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001742 " %g %g %g %g y z\n",last[2].x,last[2].y,
cristy8cd5b312010-01-07 01:10:24 +00001743 first[1].x,first[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001744 else
1745 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001746 " %g %g %g %g %g %g c z\n",last[2].x,
cristy8cd5b312010-01-07 01:10:24 +00001747 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001748 (void) ConcatenateString(&path,message);
1749 in_subpath=MagickFalse;
1750 }
1751 break;
1752 }
1753 case 6:
1754 case 7:
1755 case 8:
1756 default:
1757 {
1758 blob+=24;
1759 length-=24;
1760 break;
1761 }
1762 }
1763 }
1764 /*
1765 Returns an empty PS path if the path has no knots.
1766 */
1767 (void) FormatMagickString(message,MaxTextExtent," eoclip\n");
1768 (void) ConcatenateString(&path,message);
1769 (void) FormatMagickString(message,MaxTextExtent,"} bind def");
1770 (void) ConcatenateString(&path,message);
1771 message=DestroyString(message);
1772 return(path);
1773}
1774
1775static char *TraceSVGClippath(const unsigned char *blob,size_t length,
1776 const unsigned long columns,const unsigned long rows)
1777{
1778 char
1779 *path,
1780 *message;
1781
1782 long
1783 knot_count,
1784 selector,
1785 x,
1786 y;
1787
1788 MagickBooleanType
1789 in_subpath;
1790
1791 PointInfo
1792 first[3],
1793 last[3],
1794 point[3];
1795
1796 register long
1797 i;
1798
1799 path=AcquireString((char *) NULL);
1800 if (path == (char *) NULL)
1801 return((char *) NULL);
1802 message=AcquireString((char *) NULL);
1803 (void) FormatMagickString(message,MaxTextExtent,
1804 "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n");
1805 (void) ConcatenateString(&path,message);
1806 (void) FormatMagickString(message,MaxTextExtent,
1807 "<svg width=\"%lu\" height=\"%lu\">\n",columns,rows);
1808 (void) ConcatenateString(&path,message);
1809 (void) FormatMagickString(message,MaxTextExtent,"<g>\n");
1810 (void) ConcatenateString(&path,message);
1811 (void) FormatMagickString(message,MaxTextExtent,
1812 "<path style=\"fill:#00000000;stroke:#00000000;");
1813 (void) ConcatenateString(&path,message);
1814 (void) FormatMagickString(message,MaxTextExtent,
1815 "stroke-width:0;stroke-antialiasing:false\" d=\"\n");
1816 (void) ConcatenateString(&path,message);
1817 (void) ResetMagickMemory(point,0,sizeof(point));
1818 (void) ResetMagickMemory(first,0,sizeof(first));
1819 (void) ResetMagickMemory(last,0,sizeof(last));
1820 knot_count=0;
1821 in_subpath=MagickFalse;
1822 while (length != 0)
1823 {
1824 selector=(long) ReadPropertyMSBShort(&blob,&length);
1825 switch (selector)
1826 {
1827 case 0:
1828 case 3:
1829 {
1830 if (knot_count != 0)
1831 {
1832 blob+=24;
1833 length-=24;
1834 break;
1835 }
1836 /*
1837 Expected subpath length record.
1838 */
1839 knot_count=(long) ReadPropertyMSBShort(&blob,&length);
1840 blob+=22;
1841 length-=22;
1842 break;
1843 }
1844 case 1:
1845 case 2:
1846 case 4:
1847 case 5:
1848 {
1849 if (knot_count == 0)
1850 {
1851 /*
1852 Unexpected subpath knot.
1853 */
1854 blob+=24;
1855 length-=24;
cristy97433202009-10-27 02:05:08 +00001856 break;
1857 }
1858 /*
1859 Add sub-path knot
1860 */
1861 for (i=0; i < 3; i++)
1862 {
1863 unsigned long
1864 xx,
1865 yy;
1866
1867 yy=ReadPropertyMSBLong(&blob,&length);
1868 xx=ReadPropertyMSBLong(&blob,&length);
1869 x=(long) xx;
1870 if (xx > 2147483647)
1871 x=xx-4294967295-1;
1872 y=(long) yy;
1873 if (yy > 2147483647)
1874 y=yy-4294967295-1;
1875 point[i].x=(double) x*columns/4096/4096;
1876 point[i].y=(double) y*rows/4096/4096;
1877 }
1878 if (in_subpath == MagickFalse)
1879 {
cristye7f51092010-01-17 00:39:37 +00001880 (void) FormatMagickString(message,MaxTextExtent,"M %g,%g\n",
cristy97433202009-10-27 02:05:08 +00001881 point[1].x,point[1].y);
1882 for (i=0; i < 3; i++)
1883 {
1884 first[i]=point[i];
1885 last[i]=point[i];
1886 }
cristy3ed852e2009-09-05 21:47:34 +00001887 }
1888 else
1889 {
cristy97433202009-10-27 02:05:08 +00001890 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1891 (point[0].x == point[1].x) && (point[0].y == point[1].y))
cristye7f51092010-01-17 00:39:37 +00001892 (void) FormatMagickString(message,MaxTextExtent,"L %g,%g\n",
cristy97433202009-10-27 02:05:08 +00001893 point[1].x,point[1].y);
1894 else
1895 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001896 "C %g,%g %g,%g %g,%g\n",last[2].x,last[2].y,
cristy97433202009-10-27 02:05:08 +00001897 point[0].x,point[0].y,point[1].x,point[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001898 for (i=0; i < 3; i++)
cristy97433202009-10-27 02:05:08 +00001899 last[i]=point[i];
1900 }
1901 (void) ConcatenateString(&path,message);
1902 in_subpath=MagickTrue;
1903 knot_count--;
1904 /*
1905 Close the subpath if there are no more knots.
1906 */
1907 if (knot_count == 0)
1908 {
1909 if ((last[1].x == last[2].x) && (last[1].y == last[2].y) &&
1910 (first[0].x == first[1].x) && (first[0].y == first[1].y))
cristy8cd5b312010-01-07 01:10:24 +00001911 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001912 "L %g,%g Z\n",first[1].x,first[1].y);
cristy3ed852e2009-09-05 21:47:34 +00001913 else
1914 {
cristy97433202009-10-27 02:05:08 +00001915 (void) FormatMagickString(message,MaxTextExtent,
cristye7f51092010-01-17 00:39:37 +00001916 "C %g,%g %g,%g %g,%g Z\n",last[2].x,
cristy8cd5b312010-01-07 01:10:24 +00001917 last[2].y,first[0].x,first[0].y,first[1].x,first[1].y);
cristy97433202009-10-27 02:05:08 +00001918 (void) ConcatenateString(&path,message);
cristy3ed852e2009-09-05 21:47:34 +00001919 }
cristy97433202009-10-27 02:05:08 +00001920 in_subpath=MagickFalse;
cristy3ed852e2009-09-05 21:47:34 +00001921 }
cristy97433202009-10-27 02:05:08 +00001922 break;
cristy3ed852e2009-09-05 21:47:34 +00001923 }
1924 case 6:
1925 case 7:
1926 case 8:
1927 default:
1928 {
1929 blob+=24;
1930 length-=24;
1931 break;
1932 }
1933 }
1934 }
1935 /*
1936 Return an empty SVG image if the path does not have knots.
1937 */
1938 (void) FormatMagickString(message,MaxTextExtent,"\"/>\n");
1939 (void) ConcatenateString(&path,message);
1940 (void) FormatMagickString(message,MaxTextExtent,"</g>\n");
1941 (void) ConcatenateString(&path,message);
1942 (void) FormatMagickString(message,MaxTextExtent,"</svg>\n");
1943 (void) ConcatenateString(&path,message);
1944 message=DestroyString(message);
1945 return(path);
1946}
1947
1948MagickExport const char *GetImageProperty(const Image *image,
1949 const char *property)
1950{
1951 ExceptionInfo
1952 *exception;
1953
1954 FxInfo
1955 *fx_info;
1956
1957 MagickRealType
1958 alpha;
1959
1960 MagickStatusType
1961 status;
1962
1963 register const char
1964 *p;
1965
1966 assert(image != (Image *) NULL);
1967 assert(image->signature == MagickSignature);
1968 if (image->debug != MagickFalse)
1969 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1970 p=(const char *) NULL;
1971 if (property == (const char *) NULL)
1972 {
1973 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
1974 p=(const char *) GetNextValueInSplayTree((SplayTreeInfo *)
1975 image->properties);
1976 return(p);
1977 }
1978 if ((image->properties != (void *) NULL) &&
1979 (LocaleNCompare("fx:",property,3) != 0))
1980 {
1981 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1982 image->properties,property);
1983 if (p != (const char *) NULL)
1984 return(p);
1985 }
1986 if (strchr(property,':') == (char *) NULL)
1987 return(p);
1988 exception=(&((Image *) image)->exception);
1989 switch (*property)
1990 {
1991 case '8':
1992 {
1993 if (LocaleNCompare("8bim:",property,5) == 0)
1994 {
1995 if (Get8BIMProperty(image,property) != MagickFalse)
1996 {
1997 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
1998 image->properties,property);
1999 return(p);
2000 }
2001 }
2002 break;
2003 }
2004 case 'E':
2005 case 'e':
2006 {
2007 if (LocaleNCompare("exif:",property,5) == 0)
2008 {
2009 if (GetEXIFProperty(image,property) != MagickFalse)
2010 {
2011 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2012 image->properties,property);
2013 return(p);
2014 }
2015 }
2016 break;
2017 }
2018 case 'F':
2019 case 'f':
2020 {
2021 if (LocaleNCompare("fx:",property,3) == 0)
2022 {
2023 fx_info=AcquireFxInfo(image,property+3);
2024 status=FxEvaluateExpression(fx_info,&alpha,exception);
2025 fx_info=DestroyFxInfo(fx_info);
2026 if (status != MagickFalse)
2027 {
2028 char
2029 value[MaxTextExtent];
2030
cristye7f51092010-01-17 00:39:37 +00002031 (void) FormatMagickString(value,MaxTextExtent,"%g",(double)
cristy3ed852e2009-09-05 21:47:34 +00002032 alpha);
2033 (void) SetImageProperty((Image *) image,property,value);
2034 }
2035 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2036 image->properties,property);
2037 return(p);
2038 }
2039 break;
2040 }
2041 case 'I':
2042 case 'i':
2043 {
2044 if (LocaleNCompare("iptc:",property,5) == 0)
2045 {
2046 if (GetIPTCProperty(image,property) != MagickFalse)
2047 {
2048 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2049 image->properties,property);
2050 return(p);
2051 }
2052 }
2053 break;
2054 }
2055 case 'P':
2056 case 'p':
2057 {
2058 if (LocaleNCompare("pixel:",property,6) == 0)
2059 {
2060 MagickPixelPacket
2061 pixel;
2062
2063 GetMagickPixelPacket(image,&pixel);
2064 fx_info=AcquireFxInfo(image,property+6);
2065 status=FxEvaluateChannelExpression(fx_info,RedChannel,0,0,&alpha,
2066 exception);
2067 pixel.red=(MagickRealType) QuantumRange*alpha;
2068 status|=FxEvaluateChannelExpression(fx_info,GreenChannel,0,0,&alpha,
2069 exception);
2070 pixel.green=(MagickRealType) QuantumRange*alpha;
2071 status|=FxEvaluateChannelExpression(fx_info,BlueChannel,0,0,&alpha,
2072 exception);
2073 pixel.blue=(MagickRealType) QuantumRange*alpha;
2074 status|=FxEvaluateChannelExpression(fx_info,OpacityChannel,0,0,&alpha,
2075 exception);
2076 pixel.opacity=(MagickRealType) QuantumRange*(1.0-alpha);
2077 if (image->colorspace == CMYKColorspace)
2078 {
2079 status|=FxEvaluateChannelExpression(fx_info,BlackChannel,0,0,
2080 &alpha,exception);
2081 pixel.index=(MagickRealType) QuantumRange*alpha;
2082 }
2083 fx_info=DestroyFxInfo(fx_info);
2084 if (status != MagickFalse)
2085 {
2086 char
2087 name[MaxTextExtent];
2088
2089 (void) QueryMagickColorname(image,&pixel,SVGCompliance,name,
2090 exception);
2091 (void) SetImageProperty((Image *) image,property,name);
2092 return(GetImageProperty(image,property));
2093 }
2094 }
2095 break;
2096 }
2097 case 'X':
2098 case 'x':
2099 {
2100 if (LocaleNCompare("xmp:",property,4) == 0)
2101 {
2102 if (GetXMPProperty(image,property) != MagickFalse)
2103 {
2104 p=(const char *) GetValueFromSplayTree((SplayTreeInfo *)
2105 image->properties,property);
2106 return(p);
2107 }
2108 }
2109 break;
2110 }
2111 }
2112 return(p);
2113}
2114
2115/*
2116%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2117% %
2118% %
2119% %
2120+ G e t M a g i c k P r o p e r t y %
2121% %
2122% %
2123% %
2124%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2125%
2126% GetMagickProperty() gets a value associated with an image property.
2127%
2128% The format of the GetMagickProperty method is:
2129%
2130% const char *GetMagickProperty(const ImageInfo *image_info,
2131% Image *image,const char *key)
2132%
2133% A description of each parameter follows:
2134%
2135% o image_info: the image info.
2136%
2137% o image: the image.
2138%
2139% o key: the key.
2140%
2141*/
2142MagickExport const char *GetMagickProperty(const ImageInfo *image_info,
2143 Image *image,const char *property)
2144{
2145 char
2146 value[MaxTextExtent],
2147 filename[MaxTextExtent];
2148
2149 *value='\0';
2150 switch (*(property))
2151 {
2152 case 'b':
2153 {
2154 if (LocaleNCompare("base",property,4) == 0)
2155 {
2156 GetPathComponent(image->magick_filename,BasePath,filename);
2157 (void) CopyMagickString(value,filename,MaxTextExtent);
2158 break;
2159 }
2160 break;
2161 }
2162 case 'c':
2163 {
2164 if (LocaleNCompare("channels",property,8) == 0)
2165 {
2166 /*
2167 Image channels.
2168 */
2169 (void) FormatMagickString(value,MaxTextExtent,"%s",
2170 MagickOptionToMnemonic(MagickColorspaceOptions,(long)
2171 image->colorspace));
2172 LocaleLower(value);
2173 if (image->matte != MagickFalse)
2174 (void) ConcatenateMagickString(value,"a",MaxTextExtent);
2175 break;
2176 }
2177 if (LocaleNCompare("colorspace",property,10) == 0)
2178 {
2179 ColorspaceType
2180 colorspace;
2181
2182 /*
2183 Image storage class and colorspace.
2184 */
2185 colorspace=image->colorspace;
2186 if (IsGrayImage(image,&image->exception) != MagickFalse)
2187 colorspace=GRAYColorspace;
2188 (void) FormatMagickString(value,MaxTextExtent,"%s",
2189 MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace));
2190 break;
2191 }
2192 break;
2193 }
2194 case 'd':
2195 {
2196 if (LocaleNCompare("depth",property,5) == 0)
2197 {
2198 (void) FormatMagickString(value,MaxTextExtent,"%lu",image->depth);
2199 break;
2200 }
2201 if (LocaleNCompare("directory",property,9) == 0)
2202 {
2203 GetPathComponent(image->magick_filename,HeadPath,filename);
2204 (void) CopyMagickString(value,filename,MaxTextExtent);
2205 break;
2206 }
2207 break;
2208 }
2209 case 'e':
2210 {
2211 if (LocaleNCompare("extension",property,9) == 0)
2212 {
2213 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2214 (void) CopyMagickString(value,filename,MaxTextExtent);
2215 break;
2216 }
2217 break;
2218 }
2219 case 'g':
2220 {
2221 if (LocaleNCompare("group",property,5) == 0)
2222 {
2223 (void) FormatMagickString(value,MaxTextExtent,"0x%lx",
2224 image_info->group);
2225 break;
2226 }
2227 break;
2228 }
2229 case 'h':
2230 {
2231 if (LocaleNCompare("height",property,6) == 0)
2232 {
2233 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2234 image->magick_rows != 0 ? image->magick_rows : 256UL);
2235 break;
2236 }
2237 break;
2238 }
2239 case 'i':
2240 {
2241 if (LocaleNCompare("input",property,5) == 0)
2242 {
2243 (void) CopyMagickString(value,image->filename,MaxTextExtent);
2244 break;
2245 }
2246 break;
2247 }
2248 case 'k':
2249 {
2250 if (LocaleNCompare("kurtosis",property,8) == 0)
2251 {
2252 double
2253 kurtosis,
2254 skewness;
2255
2256 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2257 &skewness,&image->exception);
cristy0596f852010-01-17 20:21:09 +00002258 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2259 GetMagickPrecision(),kurtosis);
cristy3ed852e2009-09-05 21:47:34 +00002260 break;
2261 }
2262 break;
2263 }
2264 case 'm':
2265 {
2266 if (LocaleNCompare("magick",property,6) == 0)
2267 {
2268 (void) CopyMagickString(value,image->magick,MaxTextExtent);
2269 break;
2270 }
2271 if (LocaleNCompare("max",property,3) == 0)
2272 {
2273 double
2274 maximum,
2275 minimum;
2276
2277 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2278 &maximum,&image->exception);
cristye7f51092010-01-17 00:39:37 +00002279 (void) FormatMagickString(value,MaxTextExtent,"%g",maximum);
cristy3ed852e2009-09-05 21:47:34 +00002280 break;
2281 }
2282 if (LocaleNCompare("mean",property,4) == 0)
2283 {
2284 double
2285 mean,
2286 standard_deviation;
2287
2288 (void) GetImageChannelMean(image,image_info->channel,&mean,
2289 &standard_deviation,&image->exception);
cristy0596f852010-01-17 20:21:09 +00002290 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2291 GetMagickPrecision(),mean);
cristy3ed852e2009-09-05 21:47:34 +00002292 break;
2293 }
2294 if (LocaleNCompare("min",property,3) == 0)
2295 {
2296 double
2297 maximum,
2298 minimum;
2299
2300 (void) GetImageChannelRange(image,image_info->channel,&minimum,
2301 &maximum,&image->exception);
cristye7f51092010-01-17 00:39:37 +00002302 (void) FormatMagickString(value,MaxTextExtent,"%g",minimum);
cristy3ed852e2009-09-05 21:47:34 +00002303 break;
2304 }
2305 break;
2306 }
2307 case 'n':
2308 {
2309 if (LocaleNCompare("name",property,4) == 0)
2310 {
2311 (void) CopyMagickString(value,filename,MaxTextExtent);
2312 break;
2313 }
2314 break;
2315 }
2316 case 'o':
2317 {
2318 if (LocaleNCompare("output",property,6) == 0)
2319 {
2320 (void) CopyMagickString(value,image_info->filename,MaxTextExtent);
2321 break;
2322 }
2323 break;
2324 }
2325 case 'p':
2326 {
2327 if (LocaleNCompare("page",property,4) == 0)
2328 {
2329 register const Image
2330 *p;
2331
2332 unsigned long
2333 page;
2334
2335 p=image;
2336 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2337 p=GetPreviousImageInList(p);
2338 (void) FormatMagickString(value,MaxTextExtent,"%lu",page);
2339 break;
2340 }
2341 break;
2342 }
2343 case 's':
2344 {
2345 if (LocaleNCompare("size",property,4) == 0)
2346 {
2347 char
2348 format[MaxTextExtent];
2349
cristyb9080c92009-12-01 20:13:26 +00002350 (void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
cristy2ce15c92010-03-12 14:03:41 +00002351 (void) FormatMagickString(value,MaxTextExtent,"%sB",format);
cristy3ed852e2009-09-05 21:47:34 +00002352 break;
2353 }
2354 if (LocaleNCompare("scenes",property,6) == 0)
2355 {
2356 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2357 (unsigned long) GetImageListLength(image));
2358 break;
2359 }
2360 if (LocaleNCompare("scene",property,5) == 0)
2361 {
2362 (void) FormatMagickString(value,MaxTextExtent,"%lu",image->scene);
2363 if (image_info->number_scenes != 0)
2364 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2365 image_info->scene);
2366 break;
2367 }
2368 if (LocaleNCompare("skewness",property,8) == 0)
2369 {
2370 double
2371 kurtosis,
2372 skewness;
2373
2374 (void) GetImageChannelKurtosis(image,image_info->channel,&kurtosis,
2375 &skewness,&image->exception);
cristy0596f852010-01-17 20:21:09 +00002376 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2377 GetMagickPrecision(),skewness);
cristy3ed852e2009-09-05 21:47:34 +00002378 break;
2379 }
2380 if ((LocaleNCompare("standard-deviation",property,18) == 0) ||
2381 (LocaleNCompare("standard_deviation",property,18) == 0))
2382 {
2383 double
2384 mean,
2385 standard_deviation;
2386
2387 (void) GetImageChannelMean(image,image_info->channel,&mean,
2388 &standard_deviation,&image->exception);
cristy0596f852010-01-17 20:21:09 +00002389 (void) FormatMagickString(value,MaxTextExtent,"%.*g",
2390 GetMagickPrecision(),standard_deviation);
cristy3ed852e2009-09-05 21:47:34 +00002391 break;
2392 }
2393 break;
2394 }
2395 case 'u':
2396 {
2397 if (LocaleNCompare("unique",property,6) == 0)
2398 {
2399 (void) CopyMagickString(filename,image_info->unique,MaxTextExtent);
2400 (void) CopyMagickString(value,filename,MaxTextExtent);
2401 break;
2402 }
2403 break;
2404 }
2405 case 'w':
2406 {
2407 if (LocaleNCompare("width",property,5) == 0)
2408 {
2409 (void) FormatMagickString(value,MaxTextExtent,"%lu",
2410 image->magick_columns != 0 ? image->magick_columns : 256UL);
2411 break;
2412 }
2413 break;
2414 }
2415 case 'x':
2416 {
2417 if (LocaleNCompare("xresolution",property,11) == 0)
2418 {
cristye7f51092010-01-17 00:39:37 +00002419 (void) FormatMagickString(value,MaxTextExtent,"%g",
cristy3ed852e2009-09-05 21:47:34 +00002420 image->x_resolution);
2421 break;
2422 }
2423 break;
2424 }
2425 case 'y':
2426 {
2427 if (LocaleNCompare("yresolution",property,11) == 0)
2428 {
cristye7f51092010-01-17 00:39:37 +00002429 (void) FormatMagickString(value,MaxTextExtent,"%g",
cristy3ed852e2009-09-05 21:47:34 +00002430 image->y_resolution);
2431 break;
2432 }
2433 break;
2434 }
2435 case 'z':
2436 {
2437 if (LocaleNCompare("zero",property,4) == 0)
2438 {
2439 (void) CopyMagickString(filename,image_info->zero,MaxTextExtent);
2440 (void) CopyMagickString(value,filename,MaxTextExtent);
2441 break;
2442 }
2443 break;
2444 }
2445 }
2446 if (*value != '\0')
2447 {
2448 if (image->properties == (void *) NULL)
2449 image->properties=NewSplayTree(CompareSplayTreeString,
2450 RelinquishMagickMemory,RelinquishMagickMemory);
2451 (void) AddValueToSplayTree((SplayTreeInfo *) image->properties,
2452 ConstantString(property),ConstantString(value));
2453 }
2454 return(GetImageProperty(image,property));
2455}
2456
2457/*
2458%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2459% %
2460% %
2461% %
2462% G e t N e x t I m a g e P r o p e r t y %
2463% %
2464% %
2465% %
2466%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2467%
2468% GetNextImageProperty() gets the next image property value.
2469%
2470% The format of the GetNextImageProperty method is:
2471%
2472% char *GetNextImageProperty(const Image *image)
2473%
2474% A description of each parameter follows:
2475%
2476% o image: the image.
2477%
2478*/
2479MagickExport char *GetNextImageProperty(const Image *image)
2480{
2481 assert(image != (Image *) NULL);
2482 assert(image->signature == MagickSignature);
2483 if (image->debug != MagickFalse)
2484 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2485 image->filename);
2486 if (image->properties == (void *) NULL)
2487 return((char *) NULL);
2488 return((char *) GetNextKeyInSplayTree((SplayTreeInfo *) image->properties));
2489}
2490
2491/*
2492%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2493% %
2494% %
2495% %
2496% I n t e r p r e t I m a g e P r o p e r t i e s %
2497% %
2498% %
2499% %
2500%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2501%
2502% InterpretImageProperties() replaces any embedded formatting characters with
2503% the appropriate image property and returns the interpretted text.
2504%
2505% The format of the InterpretImageProperties method is:
2506%
2507% char *InterpretImageProperties(const ImageInfo *image_info,Image *image,
2508% const char *embed_text)
2509%
2510% A description of each parameter follows:
2511%
2512% o image_info: the image info.
2513%
2514% o image: the image.
2515%
2516% o embed_text: the address of a character string containing the embedded
2517% formatting characters.
2518%
2519*/
2520MagickExport char *InterpretImageProperties(const ImageInfo *image_info,
2521 Image *image,const char *embed_text)
2522{
2523 char
2524 filename[MaxTextExtent],
2525 *interpret_text,
2526 *text;
2527
2528 const char
2529 *value;
2530
2531 ImageInfo
2532 *text_info;
2533
2534 register char
2535 *q;
2536
2537 register const char
2538 *p;
2539
2540 register long
2541 i;
2542
2543 size_t
2544 extent,
2545 length;
2546
2547 assert(image != (Image *) NULL);
2548 assert(image->signature == MagickSignature);
2549 if (image->debug != MagickFalse)
2550 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2551 if ((embed_text == (const char *) NULL) || (*embed_text == '\0'))
2552 return((char *) NULL);
2553 text=(char *) embed_text;
2554 if ((*text == '@') && ((*(text+1) == '-') ||
2555 (IsPathAccessible(text+1) != MagickFalse)))
2556 return(FileToString(embed_text+1,~0,&image->exception));
2557 /*
2558 Translate any embedded format characters.
2559 */
2560 text_info=CloneImageInfo(image_info);
2561 interpret_text=AcquireString(text);
2562 extent=MaxTextExtent;
2563 p=text;
2564 for (q=interpret_text; *p != '\0'; p++)
2565 {
2566 *q='\0';
2567 if ((size_t) (q-interpret_text+MaxTextExtent) >= extent)
2568 {
2569 extent+=MaxTextExtent;
2570 interpret_text=(char *) ResizeQuantumMemory(interpret_text,extent+
2571 MaxTextExtent+1,sizeof(*interpret_text));
2572 if (interpret_text == (char *) NULL)
2573 break;
2574 q=interpret_text+strlen(interpret_text);
2575 }
2576 /*
2577 Process formatting characters in text.
2578 */
2579 if ((*p == '\\') && (*(p+1) == 'r'))
2580 {
2581 *q++='\r';
2582 p++;
2583 continue;
2584 }
2585 if ((*p == '\\') && (*(p+1) == 'n'))
2586 {
2587 *q++='\n';
2588 p++;
2589 continue;
2590 }
2591 if (*p == '\\')
2592 {
2593 p++;
2594 *q++=(*p);
2595 continue;
2596 }
2597 if (*p != '%')
2598 {
2599 *q++=(*p);
2600 continue;
2601 }
2602 p++;
2603 switch (*p)
2604 {
2605 case 'b':
2606 {
2607 char
2608 format[MaxTextExtent];
2609
cristy3ed852e2009-09-05 21:47:34 +00002610 /*
2611 File size.
2612 */
cristy3ed852e2009-09-05 21:47:34 +00002613 (void) FormatMagickString(format,MaxTextExtent,"%lu",(unsigned long)
cristy81b8ce52010-02-05 01:53:17 +00002614 image->extent);
2615 if (image->extent != (MagickSizeType) ((size_t) image->extent))
2616 (void) FormatMagickSize(image->extent,MagickFalse,format);
cristy3ed852e2009-09-05 21:47:34 +00002617 q+=ConcatenateMagickString(q,format,extent);
cristy2ce15c92010-03-12 14:03:41 +00002618 q+=ConcatenateMagickString(q,"B",extent);
cristy3ed852e2009-09-05 21:47:34 +00002619 break;
2620 }
2621 case 'c':
2622 {
2623 /*
2624 Image comment.
2625 */
2626 value=GetImageProperty(image,"comment");
2627 if (value == (const char *) NULL)
2628 break;
2629 length=strlen(value);
2630 if ((size_t) (q-interpret_text+length+1) >= extent)
2631 {
2632 extent+=length;
2633 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
2634 extent+MaxTextExtent,sizeof(*interpret_text));
2635 if (interpret_text == (char *) NULL)
2636 break;
2637 q=interpret_text+strlen(interpret_text);
2638 }
2639 (void) CopyMagickString(q,value,extent);
2640 q+=length;
2641 break;
2642 }
2643 case 'd':
2644 case 'e':
2645 case 'f':
2646 case 't':
2647 {
2648 /*
2649 Label segment is the base of the filename.
2650 */
2651 if (*image->magick_filename == '\0')
2652 break;
2653 switch (*p)
2654 {
2655 case 'd':
2656 {
2657 /*
2658 Directory.
2659 */
2660 GetPathComponent(image->magick_filename,HeadPath,filename);
2661 q+=CopyMagickString(q,filename,extent);
2662 break;
2663 }
2664 case 'e':
2665 {
2666 /*
2667 Filename extension.
2668 */
2669 GetPathComponent(image->magick_filename,ExtensionPath,filename);
2670 q+=CopyMagickString(q,filename,extent);
2671 break;
2672 }
2673 case 'f':
2674 {
2675 /*
2676 Filename.
2677 */
2678 GetPathComponent(image->magick_filename,TailPath,filename);
2679 q+=CopyMagickString(q,filename,extent);
2680 break;
2681 }
2682 case 't':
2683 {
2684 /*
2685 Base filename.
2686 */
2687 GetPathComponent(image->magick_filename,BasePath,filename);
2688 q+=CopyMagickString(q,filename,extent);
2689 break;
2690 }
2691 }
2692 break;
2693 }
2694 case 'g':
2695 {
2696 /*
2697 Image geometry.
2698 */
2699 q+=FormatMagickString(q,extent,"%lux%lu%+ld%+ld",image->page.width,
2700 image->page.height,image->page.x,image->page.y);
2701 break;
2702 }
2703 case 'h':
2704 {
2705 /*
2706 Image height.
2707 */
2708 q+=FormatMagickString(q,extent,"%lu",image->rows != 0 ? image->rows :
2709 image->magick_rows);
2710 break;
2711 }
2712 case 'i':
2713 {
2714 /*
2715 Image filename.
2716 */
2717 q+=CopyMagickString(q,image->filename,extent);
2718 break;
2719 }
2720 case 'k':
2721 {
2722 /*
2723 Number of unique colors.
2724 */
2725 q+=FormatMagickString(q,extent,"%lu",GetNumberColors(image,
2726 (FILE *) NULL,&image->exception));
2727 break;
2728 }
2729 case 'l':
2730 {
2731 /*
2732 Image label.
2733 */
2734 value=GetImageProperty(image,"label");
2735 if (value == (const char *) NULL)
2736 break;
2737 length=strlen(value);
2738 if ((size_t) (q-interpret_text+length+1) >= extent)
2739 {
2740 extent+=length;
2741 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
2742 extent+MaxTextExtent,sizeof(*interpret_text));
2743 if (interpret_text == (char *) NULL)
2744 break;
2745 q=interpret_text+strlen(interpret_text);
2746 }
2747 q+=CopyMagickString(q,value,extent);
2748 break;
2749 }
2750 case 'm':
2751 {
2752 /*
2753 Image format.
2754 */
2755 q+=CopyMagickString(q,image->magick,extent);
2756 break;
2757 }
2758 case 'M':
2759 {
2760 /*
2761 Image magick filename.
2762 */
2763 q+=CopyMagickString(q,image->magick_filename,extent);
2764 break;
2765 }
2766 case 'n':
2767 {
2768 /*
2769 Number of images in the list.
2770 */
2771 q+=FormatMagickString(q,extent,"%lu",(unsigned long)
2772 GetImageListLength(image));
2773 break;
2774 }
2775 case 'o':
2776 {
2777 /*
2778 Image output filename.
2779 */
2780 q+=CopyMagickString(q,text_info->filename,extent);
2781 break;
2782 }
2783 case 'p':
2784 {
2785 register const Image
2786 *p;
2787
2788 unsigned long
2789 page;
2790
2791 /*
2792 Image page number.
2793 */
2794 p=image;
2795 for (page=1; GetPreviousImageInList(p) != (Image *) NULL; page++)
2796 p=GetPreviousImageInList(p);
2797 q+=FormatMagickString(q,extent,"%lu",page);
2798 break;
2799 }
2800 case 'q':
2801 {
2802 /*
2803 Image depth.
2804 */
2805 q+=FormatMagickString(q,extent,"%lu",image->depth);
2806 break;
2807 }
2808 case 'r':
2809 {
2810 ColorspaceType
2811 colorspace;
2812
2813 /*
2814 Image storage class and colorspace.
2815 */
2816 colorspace=image->colorspace;
2817 if (IsGrayImage(image,&image->exception) != MagickFalse)
2818 colorspace=GRAYColorspace;
2819 q+=FormatMagickString(q,extent,"%s%s%s",MagickOptionToMnemonic(
2820 MagickClassOptions,(long) image->storage_class),
2821 MagickOptionToMnemonic(MagickColorspaceOptions,(long) colorspace),
2822 image->matte != MagickFalse ? "Matte" : "");
2823 break;
2824 }
2825 case 's':
2826 {
2827 /*
2828 Image scene number.
2829 */
2830 if (text_info->number_scenes == 0)
2831 q+=FormatMagickString(q,extent,"%lu",image->scene);
2832 else
2833 q+=FormatMagickString(q,extent,"%lu",text_info->scene);
2834 break;
2835 }
2836 case 'u':
2837 {
2838 /*
2839 Unique filename.
2840 */
2841 (void) CopyMagickString(filename,text_info->unique,extent);
2842 q+=CopyMagickString(q,filename,extent);
2843 break;
2844 }
2845 case 'w':
2846 {
2847 /*
2848 Image width.
2849 */
2850 q+=FormatMagickString(q,extent,"%lu",image->columns != 0 ?
2851 image->columns : image->magick_columns);
2852 break;
2853 }
2854 case 'x':
2855 {
2856 /*
2857 Image horizontal resolution.
2858 */
cristye7f51092010-01-17 00:39:37 +00002859 q+=FormatMagickString(q,extent,"%g %s",image->x_resolution,
cristy3ed852e2009-09-05 21:47:34 +00002860 MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
2861 break;
2862 }
2863 case 'y':
2864 {
2865 /*
2866 Image vertical resolution.
2867 */
cristye7f51092010-01-17 00:39:37 +00002868 q+=FormatMagickString(q,extent,"%g %s",image->y_resolution,
cristy3ed852e2009-09-05 21:47:34 +00002869 MagickOptionToMnemonic(MagickResolutionOptions,(long) image->units));
2870 break;
2871 }
2872 case 'z':
2873 {
2874 /*
2875 Image depth.
2876 */
2877 q+=FormatMagickString(q,extent,"%lu",image->depth);
2878 break;
2879 }
2880 case 'A':
2881 {
2882 /*
2883 Image alpha channel.
2884 */
2885 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2886 MagickBooleanOptions,(long) image->matte));
2887 break;
2888 }
2889 case 'C':
2890 {
2891 /*
2892 Image compression method.
2893 */
2894 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2895 MagickCompressOptions,(long) image->compression));
2896 break;
2897 }
2898 case 'D':
2899 {
2900 /*
2901 Image dispose method.
2902 */
2903 q+=FormatMagickString(q,extent,"%s",MagickOptionToMnemonic(
2904 MagickDisposeOptions,(long) image->dispose));
2905 break;
2906 }
2907 case 'G':
2908 {
2909 q+=FormatMagickString(q,extent,"%lux%lu",image->magick_columns,
2910 image->magick_rows);
2911 break;
2912 }
2913 case 'H':
2914 {
2915 q+=FormatMagickString(q,extent,"%ld",image->page.height);
2916 break;
2917 }
2918 case 'O':
2919 {
2920 q+=FormatMagickString(q,extent,"%+ld%+ld",image->page.x,image->page.y);
2921 break;
2922 }
2923 case 'P':
2924 {
2925 q+=FormatMagickString(q,extent,"%lux%lu",image->page.width,
2926 image->page.height);
2927 break;
2928 }
2929 case 'Q':
2930 {
2931 q+=FormatMagickString(q,extent,"%lu",image->quality);
2932 break;
2933 }
2934 case 'S':
2935 {
2936 /*
2937 Image scenes.
2938 */
2939 if (text_info->number_scenes == 0)
2940 q+=CopyMagickString(q,"2147483647",extent);
2941 else
2942 q+=FormatMagickString(q,extent,"%lu",text_info->scene+
2943 text_info->number_scenes);
2944 break;
2945 }
2946 case 'T':
2947 {
2948 q+=FormatMagickString(q,extent,"%lu",image->delay);
2949 break;
2950 }
2951 case 'W':
2952 {
2953 q+=FormatMagickString(q,extent,"%ld",image->page.width);
2954 break;
2955 }
2956 case 'X':
2957 {
2958 q+=FormatMagickString(q,extent,"%+ld",image->page.x);
2959 break;
2960 }
2961 case 'Y':
2962 {
2963 q+=FormatMagickString(q,extent,"%+ld",image->page.y);
2964 break;
2965 }
2966 case 'Z':
2967 {
2968 /*
2969 Unique filename.
2970 */
2971 (void) CopyMagickString(filename,text_info->zero,extent);
2972 q+=CopyMagickString(q,filename,extent);
2973 break;
2974 }
2975 case '[':
2976 {
2977 char
2978 pattern[MaxTextExtent];
2979
2980 const char
2981 *key,
2982 *value;
2983
2984 long
2985 depth;
2986
2987 /*
2988 Image value.
2989 */
2990 if (strchr(p,']') == (char *) NULL)
2991 break;
2992 depth=1;
2993 p++;
2994 for (i=0; (i < (MaxTextExtent-1L)) && (*p != '\0'); i++)
2995 {
2996 if (*p == '[')
2997 depth++;
2998 if (*p == ']')
2999 depth--;
3000 if (depth <= 0)
3001 break;
3002 pattern[i]=(*p++);
3003 }
3004 pattern[i]='\0';
3005 value=GetImageProperty(image,pattern);
3006 if (value != (const char *) NULL)
3007 {
3008 length=strlen(value);
3009 if ((size_t) (q-interpret_text+length+1) >= extent)
3010 {
3011 extent+=length;
3012 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3013 extent+MaxTextExtent,sizeof(*interpret_text));
3014 if (interpret_text == (char *) NULL)
3015 break;
3016 q=interpret_text+strlen(interpret_text);
3017 }
3018 (void) CopyMagickString(q,value,extent);
3019 q+=length;
3020 break;
3021 }
3022 else
3023 if (IsGlob(pattern) != MagickFalse)
3024 {
3025 /*
3026 Iterate over image properties.
3027 */
3028 ResetImagePropertyIterator(image);
3029 key=GetNextImageProperty(image);
3030 while (key != (const char *) NULL)
3031 {
3032 if (GlobExpression(key,pattern,MagickTrue) != MagickFalse)
3033 {
3034 value=GetImageProperty(image,key);
3035 if (value != (const char *) NULL)
3036 {
3037 length=strlen(key)+strlen(value)+2;
3038 if ((size_t) (q-interpret_text+length+1) >= extent)
3039 {
3040 extent+=length;
3041 interpret_text=(char *) ResizeQuantumMemory(
3042 interpret_text,extent+MaxTextExtent,
3043 sizeof(*interpret_text));
3044 if (interpret_text == (char *) NULL)
3045 break;
3046 q=interpret_text+strlen(interpret_text);
3047 }
3048 q+=FormatMagickString(q,extent,"%s=%s\n",key,value);
3049 }
3050 }
3051 key=GetNextImageProperty(image);
3052 }
3053 }
3054 value=GetMagickProperty(text_info,image,pattern);
3055 if (value != (const char *) NULL)
3056 {
3057 length=strlen(value);
3058 if ((size_t) (q-interpret_text+length+1) >= extent)
3059 {
3060 extent+=length;
3061 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3062 extent+MaxTextExtent,sizeof(*interpret_text));
3063 if (interpret_text == (char *) NULL)
3064 break;
3065 q=interpret_text+strlen(interpret_text);
3066 }
3067 (void) CopyMagickString(q,value,extent);
3068 q+=length;
3069 }
3070 if (image_info == (ImageInfo *) NULL)
3071 break;
3072 value=GetImageOption(image_info,pattern);
3073 if (value != (char *) NULL)
3074 {
3075 length=strlen(value);
3076 if ((size_t) (q-interpret_text+length+1) >= extent)
3077 {
3078 extent+=length;
3079 interpret_text=(char *) ResizeQuantumMemory(interpret_text,
3080 extent+MaxTextExtent,sizeof(*interpret_text));
3081 if (interpret_text == (char *) NULL)
3082 break;
3083 q=interpret_text+strlen(interpret_text);
3084 }
3085 (void) CopyMagickString(q,value,extent);
3086 q+=length;
3087 }
3088 break;
3089 }
3090 case '@':
3091 {
3092 RectangleInfo
3093 page;
3094
3095 /*
3096 Image bounding box.
3097 */
3098 page=GetImageBoundingBox(image,&image->exception);
3099 q+=FormatMagickString(q,MaxTextExtent,"%lux%lu%+ld%+ld",page.width,
3100 page.height,page.x,page.y);
3101 break;
3102 }
3103 case '#':
3104 {
3105 /*
3106 Image signature.
3107 */
3108 (void) SignatureImage(image);
3109 value=GetImageProperty(image,"signature");
3110 if (value == (const char *) NULL)
3111 break;
3112 q+=CopyMagickString(q,value,extent);
3113 break;
3114 }
3115 case '%':
3116 {
3117 *q++=(*p);
3118 break;
3119 }
3120 default:
3121 {
3122 *q++='%';
3123 *q++=(*p);
3124 break;
3125 }
3126 }
3127 }
3128 *q='\0';
3129 text_info=DestroyImageInfo(text_info);
3130 if (text != (const char *) embed_text)
3131 text=DestroyString(text);
3132 (void) SubstituteString(&interpret_text,"&lt;","<");
3133 (void) SubstituteString(&interpret_text,"&gt;",">");
3134 return(interpret_text);
3135}
3136
3137/*
3138%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3139% %
3140% %
3141% %
3142% R e m o v e I m a g e P r o p e r t y %
3143% %
3144% %
3145% %
3146%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3147%
3148% RemoveImageProperty() removes a property from the image and returns its
3149% value.
3150%
3151% The format of the RemoveImageProperty method is:
3152%
3153% char *RemoveImageProperty(Image *image,const char *property)
3154%
3155% A description of each parameter follows:
3156%
3157% o image: the image.
3158%
3159% o property: the image property.
3160%
3161*/
3162MagickExport char *RemoveImageProperty(Image *image,
3163 const char *property)
3164{
3165 char
3166 *value;
3167
3168 assert(image != (Image *) NULL);
3169 assert(image->signature == MagickSignature);
3170 if (image->debug != MagickFalse)
3171 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3172 image->filename);
3173 if (image->properties == (void *) NULL)
3174 return((char *) NULL);
3175 value=(char *) RemoveNodeFromSplayTree((SplayTreeInfo *) image->properties,
3176 property);
3177 return(value);
3178}
3179
3180/*
3181%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3182% %
3183% %
3184% %
3185% 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 %
3186% %
3187% %
3188% %
3189%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3190%
3191% ResetImagePropertyIterator() resets the image properties iterator. Use it
3192% in conjunction with GetNextImageProperty() to iterate over all the values
3193% associated with an image property.
3194%
3195% The format of the ResetImagePropertyIterator method is:
3196%
3197% ResetImagePropertyIterator(Image *image)
3198%
3199% A description of each parameter follows:
3200%
3201% o image: the image.
3202%
3203*/
3204MagickExport void ResetImagePropertyIterator(const Image *image)
3205{
3206 assert(image != (Image *) NULL);
3207 assert(image->signature == MagickSignature);
3208 if (image->debug != MagickFalse)
3209 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3210 image->filename);
3211 if (image->properties == (void *) NULL)
3212 return;
3213 ResetSplayTreeIterator((SplayTreeInfo *) image->properties);
3214}
3215
3216/*
3217%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3218% %
3219% %
3220% %
3221% S e t I m a g e P r o p e r t y %
3222% %
3223% %
3224% %
3225%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3226%
3227% SetImageProperty() associates an value with an image property.
3228%
3229% The format of the SetImageProperty method is:
3230%
3231% MagickBooleanType SetImageProperty(Image *image,const char *property,
3232% const char *value)
3233%
3234% A description of each parameter follows:
3235%
3236% o image: the image.
3237%
3238% o property: the image property.
3239%
3240% o values: the image property values.
3241%
3242*/
3243MagickExport MagickBooleanType SetImageProperty(Image *image,
3244 const char *property,const char *value)
3245{
3246 MagickBooleanType
3247 status;
3248
3249 MagickStatusType
3250 flags;
3251
3252 assert(image != (Image *) NULL);
3253 assert(image->signature == MagickSignature);
3254 if (image->debug != MagickFalse)
3255 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
3256 image->filename);
3257 if (image->properties == (void *) NULL)
3258 image->properties=NewSplayTree(CompareSplayTreeString,
3259 RelinquishMagickMemory,RelinquishMagickMemory);
3260 if ((value == (const char *) NULL) || (*value == '\0'))
3261 return(DeleteImageProperty(image,property));
3262 status=MagickTrue;
3263 switch (*property)
3264 {
3265 case 'B':
3266 case 'b':
3267 {
3268 if (LocaleCompare(property,"bias") == 0)
3269 {
cristyf2f27272009-12-17 14:48:46 +00003270 image->bias=SiPrefixToDouble(value,QuantumRange);
cristy3ed852e2009-09-05 21:47:34 +00003271 break;
3272 }
3273 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3274 ConstantString(property),ConstantString(value));
3275 break;
3276 }
3277 case 'C':
3278 case 'c':
3279 {
3280 if (LocaleCompare(property,"colorspace") == 0)
3281 {
3282 long
3283 colorspace;
3284
3285 colorspace=ParseMagickOption(MagickColorspaceOptions,MagickFalse,
3286 value);
3287 if (colorspace < 0)
3288 break;
3289 (void) SetImageColorspace(image,(ColorspaceType) colorspace);
3290 break;
3291 }
3292 if (LocaleCompare(property,"compose") == 0)
3293 {
3294 long
3295 compose;
3296
3297 compose=ParseMagickOption(MagickComposeOptions,MagickFalse,value);
3298 if (compose < 0)
3299 break;
3300 image->compose=(CompositeOperator) compose;
3301 break;
3302 }
3303 if (LocaleCompare(property,"compress") == 0)
3304 {
3305 long
3306 compression;
3307
3308 compression=ParseMagickOption(MagickCompressOptions,MagickFalse,
3309 value);
3310 if (compression < 0)
3311 break;
3312 image->compression=(CompressionType) compression;
3313 break;
3314 }
3315 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3316 ConstantString(property),ConstantString(value));
3317 break;
3318 }
3319 case 'D':
3320 case 'd':
3321 {
3322 if (LocaleCompare(property,"delay") == 0)
3323 {
3324 GeometryInfo
3325 geometry_info;
3326
3327 flags=ParseGeometry(value,&geometry_info);
3328 if ((flags & GreaterValue) != 0)
3329 {
cristy06609ee2010-03-17 20:21:27 +00003330 if (image->delay > (unsigned long) floor(geometry_info.rho+0.5))
3331 image->delay=(unsigned long) floor(geometry_info.rho+0.5);
cristy3ed852e2009-09-05 21:47:34 +00003332 }
3333 else
3334 if ((flags & LessValue) != 0)
3335 {
cristy06609ee2010-03-17 20:21:27 +00003336 if (image->delay < (unsigned long) floor(geometry_info.rho+0.5))
3337 image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
cristy3ed852e2009-09-05 21:47:34 +00003338 }
3339 else
cristy06609ee2010-03-17 20:21:27 +00003340 image->delay=(unsigned long) floor(geometry_info.rho+0.5);
cristy3ed852e2009-09-05 21:47:34 +00003341 if ((flags & SigmaValue) != 0)
cristy06609ee2010-03-17 20:21:27 +00003342 image->ticks_per_second=(long) floor(geometry_info.sigma+0.5);
cristy3ed852e2009-09-05 21:47:34 +00003343 break;
3344 }
3345 if (LocaleCompare(property,"depth") == 0)
3346 {
cristye27293e2009-12-18 02:53:20 +00003347 image->depth=StringToUnsignedLong(value);
cristy3ed852e2009-09-05 21:47:34 +00003348 break;
3349 }
3350 if (LocaleCompare(property,"dispose") == 0)
3351 {
3352 long
3353 dispose;
3354
3355 dispose=ParseMagickOption(MagickDisposeOptions,MagickFalse,value);
3356 if (dispose < 0)
3357 break;
3358 image->dispose=(DisposeType) dispose;
3359 break;
3360 }
3361 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3362 ConstantString(property),ConstantString(value));
3363 break;
3364 }
3365 case 'G':
3366 case 'g':
3367 {
3368 if (LocaleCompare(property,"gravity") == 0)
3369 {
3370 long
3371 gravity;
3372
3373 gravity=ParseMagickOption(MagickGravityOptions,MagickFalse,value);
3374 if (gravity < 0)
3375 break;
3376 image->gravity=(GravityType) gravity;
3377 break;
3378 }
3379 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3380 ConstantString(property),ConstantString(value));
3381 break;
3382 }
3383 case 'I':
3384 case 'i':
3385 {
3386 if (LocaleCompare(property,"intent") == 0)
3387 {
3388 long
3389 rendering_intent;
3390
3391 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3392 value);
3393 if (rendering_intent < 0)
3394 break;
3395 image->rendering_intent=(RenderingIntent) rendering_intent;
3396 break;
3397 }
3398 if (LocaleCompare(property,"interpolate") == 0)
3399 {
3400 long
3401 interpolate;
3402
3403 interpolate=ParseMagickOption(MagickInterpolateOptions,MagickFalse,
3404 value);
3405 if (interpolate < 0)
3406 break;
3407 image->interpolate=(InterpolatePixelMethod) interpolate;
3408 break;
3409 }
3410 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3411 ConstantString(property),ConstantString(value));
3412 break;
3413 }
3414 case 'L':
3415 case 'l':
3416 {
3417 if (LocaleCompare(property,"loop") == 0)
3418 {
cristye27293e2009-12-18 02:53:20 +00003419 image->iterations=StringToUnsignedLong(value);
cristy3ed852e2009-09-05 21:47:34 +00003420 break;
3421 }
3422 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3423 ConstantString(property),ConstantString(value));
3424 break;
3425 }
3426 case 'P':
3427 case 'p':
3428 {
3429 if (LocaleCompare(property,"page") == 0)
3430 {
3431 char
3432 *geometry;
3433
3434 geometry=GetPageGeometry(value);
3435 flags=ParseAbsoluteGeometry(geometry,&image->page);
3436 geometry=DestroyString(geometry);
3437 break;
3438 }
cristy071dd7b2010-04-09 13:04:54 +00003439 if (LocaleCompare(property,"profile") == 0)
3440 {
3441 ImageInfo
3442 *image_info;
3443
3444 StringInfo
3445 *profile;
3446
3447 image_info=AcquireImageInfo();
3448 (void) CopyMagickString(image_info->filename,value,MaxTextExtent);
3449 (void) SetImageInfo(image_info,1,&image->exception);
3450 profile=FileToStringInfo(image_info->filename,~0UL,&image->exception);
3451 if (profile != (StringInfo *) NULL)
3452 status=SetImageProfile(image,image_info->magick,profile);
3453 image_info=DestroyImageInfo(image_info);
3454 break;
3455 }
cristy3ed852e2009-09-05 21:47:34 +00003456 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3457 ConstantString(property),ConstantString(value));
3458 break;
3459 }
3460 case 'R':
3461 case 'r':
3462 {
3463 if (LocaleCompare(property,"rendering-intent") == 0)
3464 {
3465 long
3466 rendering_intent;
3467
3468 rendering_intent=ParseMagickOption(MagickIntentOptions,MagickFalse,
3469 value);
3470 if (rendering_intent < 0)
3471 break;
3472 image->rendering_intent=(RenderingIntent) rendering_intent;
3473 break;
3474 }
3475 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3476 ConstantString(property),ConstantString(value));
3477 break;
3478 }
3479 case 'T':
3480 case 't':
3481 {
3482 if (LocaleCompare(property,"tile-offset") == 0)
3483 {
3484 char
3485 *geometry;
3486
3487 geometry=GetPageGeometry(value);
3488 flags=ParseAbsoluteGeometry(geometry,&image->tile_offset);
3489 geometry=DestroyString(geometry);
3490 break;
3491 }
3492 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3493 ConstantString(property),ConstantString(value));
3494 break;
3495 }
3496 default:
3497 {
3498 status=AddValueToSplayTree((SplayTreeInfo *) image->properties,
3499 ConstantString(property),ConstantString(value));
3500 break;
3501 }
3502 }
3503 return(status);
3504}