# HG changeset patch # User Bob Friesenhahn <bfriesen@GraphicsMagick.org> # Date 1338740345 18000 # Node ID 66c5296d01e7ae36e8a53c69e22f3ca0d9e5ae92 # Parent a1f0802c146bd5c01eb281c99b465af765eba8d5 Added new function GetBlobIsOpen(). SetImageAttribute() does not translate comment and label string if blob is open. diff -uNr GraphicsMagick-1.3.12.attribute/magick/attribute.c GraphicsMagick-1.3.12/magick/attribute.c --- GraphicsMagick-1.3.12.attribute/magick/attribute.c 2009-12-16 13:49:52.000000000 -0500 +++ GraphicsMagick-1.3.12/magick/attribute.c 2012-07-26 10:36:33.514056162 -0400 @@ -2441,6 +2441,10 @@ % otherwise False. If the value is NULL, the matching key is deleted % from the list. % +% The 'comment' and 'label' attributes are treated specially in that +% embedded format specifications are translated according to the formatting +% rules of TranslateText(). +% % The format of the SetImageAttribute method is: % % unsigned int SetImageAttribute(Image *image,const char *key, @@ -2503,18 +2507,20 @@ return(MagickFail); attribute->key=AllocateString(key); attribute->length=0; - if ((LocaleNCompare(key,"comment",7) == 0) || - (LocaleNCompare(key,"label",5) == 0)) + if (!GetBlobIsOpen(image) && + ((LocaleNCompare(key,"comment",7) == 0) || + (LocaleNCompare(key,"label",5) == 0))) { /* - Translate format requests in attribute text. + Translate format requests in attribute text when the blob is + not open. This is really gross since it is assumed that the attribute is supplied by the user and the user intends for translation to - occur. However, comment attributes may also come from an - image file and may contain arbitrary text. There does not - seem to be any work-around which preserves the already defined - interface. + occur. However, 'comment' and 'label' attributes may also + come from an image file and may contain arbitrary text. As a + crude-workaround, translations are only performed when the + blob is not open. */ attribute->value=TranslateText((ImageInfo *) NULL,image,value); if (attribute->value != (char *) NULL) diff -uNr GraphicsMagick-1.3.12.attribute/magick/blob.c GraphicsMagick-1.3.12/magick/blob.c --- GraphicsMagick-1.3.12.attribute/magick/blob.c 2010-02-28 15:40:40.000000000 -0500 +++ GraphicsMagick-1.3.12/magick/blob.c 2012-07-26 10:36:33.514056162 -0400 @@ -1343,6 +1343,39 @@ % % % % % % ++ G e t B l o b I s O p e n % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% GetBlobIsOpen() returns MagickTrue if the blob is currently open or +% MagickFalse if it is currently closed. +% +% The format of the GetBlobSize method is: +% +% MagickBool GetBlobIsOpen(const Image *image) +% +% A description of each parameter follows: +% +% o image: The image. +% +% +*/ +MagickExport MagickBool GetBlobIsOpen(const Image *image) +{ + assert(image != (Image *) NULL); + assert(image->signature == MagickSignature); + assert(image->blob != (BlobInfo *) NULL); + + return (image->blob->type != UndefinedStream ? MagickTrue : MagickFalse); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % + G e t B l o b S i z e % % % % % diff -uNr GraphicsMagick-1.3.12.attribute/magick/blob.h GraphicsMagick-1.3.12/magick/blob.h --- GraphicsMagick-1.3.12.attribute/magick/blob.h 2010-03-01 16:15:28.000000000 -0500 +++ GraphicsMagick-1.3.12/magick/blob.h 2012-07-26 10:36:33.514056162 -0400 @@ -194,6 +194,11 @@ extern MagickExport int GetBlobStatus(const Image *image); /* + Test to see if blob is currently open. + */ + extern MagickExport MagickBool GetBlobIsOpen(const Image *image); + + /* Obtain the current size of the file or BLOB. Zero is returned if the size can not be determined. */ diff -uNr GraphicsMagick-1.3.12.attribute/www/api/attribute.html GraphicsMagick-1.3.12/www/api/attribute.html --- GraphicsMagick-1.3.12.attribute/www/api/attribute.html 2010-01-20 18:38:34.000000000 -0500 +++ GraphicsMagick-1.3.12/www/api/attribute.html 2012-07-26 10:36:33.514056162 -0400 @@ -181,6 +181,9 @@ True if the attribute is successfully concatenated or added to the list, otherwise False. If the value is NULL, the matching key is deleted from the list.</p> +<p>The 'comment' and 'label' attributes are treated specially in that +embedded format specifications are translated according to the formatting +rules of TranslateText().</p> <p>The format of the SetImageAttribute method is:</p> <pre class="literal-block"> unsigned int SetImageAttribute( <a class="reference external" href="../api/types.html#image">Image</a> *image, const char *key, const char *value );