]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/blob.c
Fix CLUT interpolation method
[imagemagick] / MagickCore / blob.c
index 33b0ddb5ac1b57474fbe87efe34ad98885c3f3e6..51fc9a920e70b1be5c0cde33738c65f051e5be73 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 1999                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
@@ -41,6 +41,7 @@
   Include declarations.
 */
 #include "MagickCore/studio.h"
+#include "MagickCore/nt-base-private.h"
 #include "MagickCore/blob.h"
 #include "MagickCore/blob-private.h"
 #include "MagickCore/cache.h"
@@ -120,8 +121,20 @@ struct _BlobInfo
   StreamType
     type;
 
-  FILE
-    *file;
+  union _stream_info {
+    FILE
+      *file;
+
+#if defined(MAGICKCORE_ZLIB_DELEGATE)
+    gzFile
+      gzfile;
+#endif
+
+#if defined(MAGICKCORE_BZLIB_DELEGATE)
+    BZFILE
+      *bzfile;
+#endif
+  } stream_info;
 
   struct stat
     properties;
@@ -189,7 +202,7 @@ MagickExport void AttachBlob(BlobInfo *blob_info,const void *blob,
   blob_info->quantum=(size_t) MagickMaxBlobExtent;
   blob_info->offset=0;
   blob_info->type=BlobStream;
-  blob_info->file=(FILE *) NULL;
+  blob_info->stream_info.file=(FILE *) NULL;
   blob_info->data=(unsigned char *) blob;
   blob_info->mapped=MagickFalse;
 }
@@ -251,7 +264,7 @@ MagickExport MagickBooleanType BlobToFile(char *filename,const void *blob,
   if (*filename == '\0')
     file=AcquireUniqueFileResource(filename);
   else
-    file=open(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE);
+    file=open_utf8(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE);
   if (file == -1)
     {
       ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename);
@@ -434,7 +447,7 @@ MagickExport BlobInfo *CloneBlobInfo(const BlobInfo *blob_info)
   clone_info->status=blob_info->status;
   clone_info->temporary=blob_info->temporary;
   clone_info->type=blob_info->type;
-  clone_info->file=blob_info->file;
+  clone_info->stream_info.file=blob_info->stream_info.file;
   clone_info->properties=blob_info->properties;
   clone_info->stream=blob_info->stream;
   clone_info->data=blob_info->data;
@@ -499,20 +512,20 @@ MagickExport MagickBooleanType CloseBlob(Image *image)
     case StandardStream:
     case PipeStream:
     {
-      status=ferror(image->blob->file);
+      status=ferror(image->blob->stream_info.file);
       break;
     }
     case ZipStream:
     {
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
-      (void) gzerror(image->blob->file,&status);
+      (void) gzerror(image->blob->stream_info.gzfile,&status);
 #endif
       break;
     }
     case BZipStream:
     {
 #if defined(MAGICKCORE_BZLIB_DELEGATE)
-      (void) BZ2_bzerror((BZFILE *) image->blob->file,&status);
+      (void) BZ2_bzerror(image->blob->stream_info.bzfile,&status);
 #endif
       break;
     }
@@ -530,30 +543,30 @@ MagickExport MagickBooleanType CloseBlob(Image *image)
     {
       if (image->blob->synchronize != MagickFalse)
         {
-          status=fflush(image->blob->file);
-          status=fsync(fileno(image->blob->file));
+          status=fflush(image->blob->stream_info.file);
+          status=fsync(fileno(image->blob->stream_info.file));
         }
-      status=fclose(image->blob->file);
+      status=fclose(image->blob->stream_info.file);
       break;
     }
     case PipeStream:
     {
 #if defined(MAGICKCORE_HAVE_PCLOSE)
-      status=pclose(image->blob->file);
+      status=pclose(image->blob->stream_info.file);
 #endif
       break;
     }
     case ZipStream:
     {
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
-      status=gzclose(image->blob->file);
+      status=gzclose(image->blob->stream_info.gzfile);
 #endif
       break;
     }
     case BZipStream:
     {
 #if defined(MAGICKCORE_BZLIB_DELEGATE)
-      BZ2_bzclose((BZFILE *) image->blob->file);
+      BZ2_bzclose(image->blob->stream_info.bzfile);
 #endif
       break;
     }
@@ -561,11 +574,11 @@ MagickExport MagickBooleanType CloseBlob(Image *image)
       break;
     case BlobStream:
     {
-      if (image->blob->file != (FILE *) NULL)
+      if (image->blob->stream_info.file != (FILE *) NULL)
         {
           if (image->blob->synchronize != MagickFalse)
-            (void) fsync(fileno(image->blob->file));
-          status=fclose(image->blob->file);
+            (void) fsync(fileno(image->blob->stream_info.file));
+          status=fclose(image->blob->stream_info.file);
         }
       break;
     }
@@ -664,7 +677,7 @@ MagickExport unsigned char *DetachBlob(BlobInfo *blob_info)
   blob_info->eof=MagickFalse;
   blob_info->exempt=MagickFalse;
   blob_info->type=UndefinedStream;
-  blob_info->file=(FILE *) NULL;
+  blob_info->stream_info.file=(FILE *) NULL;
   data=blob_info->data;
   blob_info->data=(unsigned char *) NULL;
   blob_info->stream=(StreamHandler) NULL;
@@ -828,7 +841,8 @@ MagickExport int EOFBlob(const Image *image)
     case StandardStream:
     case PipeStream:
     {
-      image->blob->eof=feof(image->blob->file) != 0 ? MagickTrue : MagickFalse;
+      image->blob->eof=feof(image->blob->stream_info.file) != 0 ? MagickTrue :
+        MagickFalse;
       break;
     }
     case ZipStream:
@@ -843,7 +857,7 @@ MagickExport int EOFBlob(const Image *image)
         status;
 
       status=0;
-      (void) BZ2_bzerror((BZFILE *) image->blob->file,&status);
+      (void) BZ2_bzerror(image->blob->stream_info.bzfile,&status);
       image->blob->eof=status == BZ_UNEXPECTED_EOF ? MagickTrue : MagickFalse;
 #endif
       break;
@@ -921,7 +935,7 @@ MagickExport unsigned char *FileToBlob(const char *filename,const size_t extent,
   *length=0;
   file=fileno(stdin);
   if (LocaleCompare(filename,"-") != 0)
-    file=open(filename,O_RDONLY | O_BINARY);
+    file=open_utf8(filename,O_RDONLY | O_BINARY,0);
   if (file == -1)
     {
       ThrowFileException(exception,BlobError,"UnableToOpenFile",filename);
@@ -1088,7 +1102,8 @@ static inline ssize_t WriteBlobStream(Image *image,const size_t length,
   return((ssize_t) length);
 }
 
-MagickExport MagickBooleanType FileToImage(Image *image,const char *filename)
+MagickExport MagickBooleanType FileToImage(Image *image,const char *filename,
+  ExceptionInfo *exception)
 {
   int
     file;
@@ -1110,11 +1125,10 @@ MagickExport MagickBooleanType FileToImage(Image *image,const char *filename)
   assert(image->signature == MagickSignature);
   assert(filename != (const char *) NULL);
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
-  file=open(filename,O_RDONLY | O_BINARY);
+  file=open_utf8(filename,O_RDONLY | O_BINARY,0);
   if (file == -1)
     {
-      ThrowFileException(&image->exception,BlobError,"UnableToOpenBlob",
-        filename);
+      ThrowFileException(exception,BlobError,"UnableToOpenBlob",filename);
       return(MagickFalse);
     }
   quantum=(size_t) MagickMaxBufferExtent;
@@ -1123,8 +1137,8 @@ MagickExport MagickBooleanType FileToImage(Image *image,const char *filename)
   blob=(unsigned char *) AcquireQuantumMemory(quantum,sizeof(*blob));
   if (blob == (unsigned char *) NULL)
     {
-      ThrowFileException(&image->exception,ResourceLimitError,
-        "MemoryAllocationFailed",filename);
+      ThrowFileException(exception,ResourceLimitError,"MemoryAllocationFailed",
+        filename);
       return(MagickFalse);
     }
   for ( ; ; )
@@ -1140,15 +1154,13 @@ MagickExport MagickBooleanType FileToImage(Image *image,const char *filename)
     count=WriteBlobStream(image,length,blob);
     if (count != (ssize_t) length)
       {
-        ThrowFileException(&image->exception,BlobError,"UnableToWriteBlob",
-          filename);
+        ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename);
         break;
       }
   }
   file=close(file);
   if (file == -1)
-    ThrowFileException(&image->exception,BlobError,"UnableToWriteBlob",
-      filename);
+    ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename);
   blob=(unsigned char *) RelinquishMagickMemory(blob);
   return(MagickTrue);
 }
@@ -1176,7 +1188,7 @@ MagickExport MagickBooleanType FileToImage(Image *image,const char *filename)
 %    o image: the image.
 %
 */
-MagickExport MagickBooleanType GetBlobError(const Image *image)
+MagickPrivate MagickBooleanType GetBlobError(const Image *image)
 {
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -1211,7 +1223,7 @@ MagickExport FILE *GetBlobFileHandle(const Image *image)
 {
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
-  return(image->blob->file);
+  return(image->blob->stream_info.file);
 }
 \f
 /*
@@ -1236,7 +1248,7 @@ MagickExport FILE *GetBlobFileHandle(const Image *image)
 %    o blob_info: Specifies a pointer to a BlobInfo structure.
 %
 */
-MagickExport void GetBlobInfo(BlobInfo *blob_info)
+MagickPrivate void GetBlobInfo(BlobInfo *blob_info)
 {
   assert(blob_info != (BlobInfo *) NULL);
   (void) ResetMagickMemory(blob_info,0,sizeof(*blob_info));
@@ -1272,7 +1284,7 @@ MagickExport void GetBlobInfo(BlobInfo *blob_info)
 %    o image: the image.
 %
 */
-MagickExport const struct stat *GetBlobProperties(const Image *image)
+MagickPrivate const struct stat *GetBlobProperties(const Image *image)
 {
   assert(image != (Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -1324,7 +1336,7 @@ MagickExport MagickSizeType GetBlobSize(const Image *image)
     }
     case FileStream:
     {
-      if (fstat(fileno(image->blob->file),&image->blob->properties) == 0)
+      if (fstat(fileno(image->blob->stream_info.file),&image->blob->properties) == 0)
         extent=(MagickSizeType) image->blob->properties.st_size;
       break;
     }
@@ -1407,7 +1419,7 @@ MagickExport unsigned char *GetBlobStreamData(const Image *image)
 %    o image: the image.
 %
 */
-MagickExport StreamHandler GetBlobStreamHandler(const Image *image)
+MagickPrivate StreamHandler GetBlobStreamHandler(const Image *image)
 {
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -1617,7 +1629,7 @@ MagickExport MagickBooleanType ImageToFile(Image *image,char *filename,
     if (LocaleCompare(filename,"-") == 0)
       file=fileno(stdout);
     else
-      file=open(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE);
+      file=open_utf8(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE);
   if (file == -1)
     {
       ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename);
@@ -1760,9 +1772,7 @@ MagickExport unsigned char *ImagesToBlob(const ImageInfo *image_info,
           images->blob->exempt=MagickTrue;
           *images->filename='\0';
           status=WriteImages(blob_info,images,images->filename,exception);
-          if ((status == MagickFalse) || (images->blob->length == 0))
-            InheritException(exception,&images->exception);
-          else
+          if ((status != MagickFalse) && (images->blob->length != 0))
             {
               *length=images->blob->length;
               blob=DetachBlob(images->blob);
@@ -1798,9 +1808,7 @@ MagickExport unsigned char *ImagesToBlob(const ImageInfo *image_info,
                 images->magick,unique);
               status=WriteImages(blob_info,images,filename,exception);
               (void) fclose(blob_info->file);
-              if (status == MagickFalse)
-                InheritException(exception,&images->exception);
-              else
+              if (status != MagickFalse)
                 blob=FileToBlob(images->filename,~0UL,length,exception);
             }
           (void) RelinquishUniqueFileResource(unique);
@@ -1926,7 +1934,7 @@ MagickExport MagickBooleanType InjectImageBlob(const ImageInfo *image_info,
   /*
     Inject into image stream.
   */
-  file=open(filename,O_RDONLY | O_BINARY);
+  file=open_utf8(filename,O_RDONLY | O_BINARY,0);
   if (file == -1)
     {
       (void) RelinquishUniqueFileResource(filename);
@@ -1986,7 +1994,7 @@ MagickExport MagickBooleanType InjectImageBlob(const ImageInfo *image_info,
 %    o image: the image.
 %
 */
-MagickExport MagickBooleanType IsBlobExempt(const Image *image)
+MagickPrivate MagickBooleanType IsBlobExempt(const Image *image)
 {
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -2017,7 +2025,7 @@ MagickExport MagickBooleanType IsBlobExempt(const Image *image)
 %    o image: the image.
 %
 */
-MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
+MagickPrivate MagickBooleanType IsBlobSeekable(const Image *image)
 {
   MagickBooleanType
     seekable;
@@ -2026,8 +2034,21 @@ MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
   assert(image->signature == MagickSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
-  seekable=(image->blob->type == FileStream) ||
-    (image->blob->type == BlobStream) ? MagickTrue : MagickFalse;
+  switch (image->blob->type)
+  {
+    case FileStream:
+    case BlobStream:
+    case ZipStream:
+    {
+      seekable=MagickTrue;
+      break;
+    }
+    default:
+    {
+      seekable=MagickFalse;
+      break;
+    }
+  }
   return(seekable);
 }
 \f
@@ -2053,7 +2074,7 @@ MagickExport MagickBooleanType IsBlobSeekable(const Image *image)
 %    o image: the image.
 %
 */
-MagickExport MagickBooleanType IsBlobTemporary(const Image *image)
+MagickPrivate MagickBooleanType IsBlobTemporary(const Image *image)
 {
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -2351,10 +2372,10 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
   if ((LocaleCompare(filename,"-") == 0) ||
       ((*filename == '\0') && (image_info->file == (FILE *) NULL)))
     {
-      image->blob->file=(*type == 'r') ? stdin : stdout;
+      image->blob->stream_info.file=(*type == 'r') ? stdin : stdout;
 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__OS2__)
       if (strchr(type,'b') != (char *) NULL)
-        setmode(_fileno(image->blob->file),_O_BINARY);
+        setmode(_fileno(image->blob->stream_info.file),_O_BINARY);
 #endif
       image->blob->type=StandardStream;
       image->blob->exempt=MagickTrue;
@@ -2367,10 +2388,10 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
 
       *mode=(*type);
       mode[1]='\0';
-      image->blob->file=fdopen(StringToLong(filename+3),mode);
+      image->blob->stream_info.file=fdopen(StringToLong(filename+3),mode);
 #if defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__OS2__)
       if (strchr(type,'b') != (char *) NULL)
-        setmode(_fileno(image->blob->file),_O_BINARY);
+        setmode(_fileno(image->blob->stream_info.file),_O_BINARY);
 #endif
       image->blob->type=StandardStream;
       image->blob->exempt=MagickTrue;
@@ -2391,8 +2412,8 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
 #endif
       *mode=(*type);
       mode[1]='\0';
-      image->blob->file=(FILE *) popen(filename+1,mode);
-      if (image->blob->file == (FILE *) NULL)
+      image->blob->stream_info.file=(FILE *) popen_utf8(filename+1,mode);
+      if (image->blob->stream_info.file == (FILE *) NULL)
         {
           ThrowFileException(exception,BlobError,"UnableToOpenBlob",filename);
           return(MagickFalse);
@@ -2406,8 +2427,8 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
 #if defined(S_ISFIFO)
   if ((status == MagickTrue) && S_ISFIFO(image->blob->properties.st_mode))
     {
-      image->blob->file=(FILE *) OpenMagickStream(filename,type);
-      if (image->blob->file == (FILE *) NULL)
+      image->blob->stream_info.file=(FILE *) fopen_utf8(filename,type);
+      if (image->blob->stream_info.file == (FILE *) NULL)
         {
           ThrowFileException(exception,BlobError,"UnableToOpenBlob",filename);
           return(MagickFalse);
@@ -2428,7 +2449,7 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
             Form filename for multi-part images.
           */
           (void) InterpretImageFilename(image_info,image,image->filename,(int)
-            image->scene,filename);
+            image->scene,filename,exception);
           if ((LocaleCompare(filename,image->filename) == 0) &&
               ((GetPreviousImageInList(image) != (Image *) NULL) ||
                (GetNextImageInList(image) != (Image *) NULL)))
@@ -2452,15 +2473,15 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
     }
   if (image_info->file != (FILE *) NULL)
     {
-      image->blob->file=image_info->file;
+      image->blob->stream_info.file=image_info->file;
       image->blob->type=FileStream;
       image->blob->exempt=MagickTrue;
     }
   else
     if (*type == 'r')
       {
-        image->blob->file=(FILE *) OpenMagickStream(filename,type);
-        if (image->blob->file != (FILE *) NULL)
+        image->blob->stream_info.file=(FILE *) fopen_utf8(filename,type);
+        if (image->blob->stream_info.file != (FILE *) NULL)
           {
             size_t
               count;
@@ -2470,29 +2491,30 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
 
             image->blob->type=FileStream;
 #if defined(MAGICKCORE_HAVE_SETVBUF)
-            (void) setvbuf(image->blob->file,(char *) NULL,(int) _IOFBF,16384);
+            (void) setvbuf(image->blob->stream_info.file,(char *) NULL,
+              (int) _IOFBF,16384);
 #endif
             (void) ResetMagickMemory(magick,0,sizeof(magick));
-            count=fread(magick,1,sizeof(magick),image->blob->file);
-            (void) rewind(image->blob->file);
+            count=fread(magick,1,sizeof(magick),image->blob->stream_info.file);
+            (void) rewind(image->blob->stream_info.file);
             (void) LogMagickEvent(BlobEvent,GetMagickModule(),
                "  read %.20g magic header bytes",(double) count);
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
             if (((int) magick[0] == 0x1F) && ((int) magick[1] == 0x8B) &&
                 ((int) magick[2] == 0x08))
               {
-                (void) fclose(image->blob->file);
-                image->blob->file=(FILE *) gzopen(filename,type);
-                if (image->blob->file != (FILE *) NULL)
+                (void) fclose(image->blob->stream_info.file);
+                image->blob->stream_info.gzfile=gzopen(filename,type);
+                if (image->blob->stream_info.gzfile != (gzFile) NULL)
                   image->blob->type=ZipStream;
                }
 #endif
 #if defined(MAGICKCORE_BZLIB_DELEGATE)
             if (strncmp((char *) magick,"BZh",3) == 0)
               {
-                (void) fclose(image->blob->file);
-                image->blob->file=(FILE *) BZ2_bzopen(filename,type);
-                if (image->blob->file != (FILE *) NULL)
+                (void) fclose(image->blob->stream_info.file);
+                image->blob->stream_info.bzfile=BZ2_bzopen(filename,type);
+                if (image->blob->stream_info.bzfile != (BZFILE *) NULL)
                   image->blob->type=BZipStream;
               }
 #endif
@@ -2522,7 +2544,8 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
                       *blob;
 
                     length=(size_t) properties->st_size;
-                    blob=MapBlob(fileno(image->blob->file),ReadMode,0,length);
+                    blob=MapBlob(fileno(image->blob->stream_info.file),ReadMode,
+                      0,length);
                     if (blob != (void *) NULL)
                       {
                         /*
@@ -2532,8 +2555,8 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
                           image->blob->exempt=MagickFalse;
                         else
                           {
-                            (void) fclose(image->blob->file);
-                            image->blob->file=(FILE *) NULL;
+                            (void) fclose(image->blob->stream_info.file);
+                            image->blob->stream_info.file=(FILE *) NULL;
                           }
                         AttachBlob(image->blob,blob,length);
                         image->blob->mapped=MagickTrue;
@@ -2551,28 +2574,28 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info,
           {
             if (mode == WriteBinaryBlobMode)
               type="wb";
-            image->blob->file=(FILE *) gzopen(filename,type);
-            if (image->blob->file != (FILE *) NULL)
+            image->blob->stream_info.gzfile=gzopen(filename,type);
+            if (image->blob->stream_info.gzfile != (gzFile) NULL)
               image->blob->type=ZipStream;
           }
         else
 #endif
 #if defined(MAGICKCORE_BZLIB_DELEGATE)
-          if (LocaleCompare(extension,".bz2") == 0)
+          if (LocaleCompare(extension,"bz2") == 0)
             {
-              image->blob->file=(FILE *) BZ2_bzopen(filename,type);
-              if (image->blob->file != (FILE *) NULL)
+              image->blob->stream_info.bzfile=BZ2_bzopen(filename,type);
+              if (image->blob->stream_info.bzfile != (BZFILE *) NULL)
                 image->blob->type=BZipStream;
             }
           else
 #endif
             {
-              image->blob->file=(FILE *) OpenMagickStream(filename,type);
-              if (image->blob->file != (FILE *) NULL)
+              image->blob->stream_info.file=(FILE *) fopen_utf8(filename,type);
+              if (image->blob->stream_info.file != (FILE *) NULL)
                 {
                   image->blob->type=FileStream;
 #if defined(MAGICKCORE_HAVE_SETVBUF)
-                  (void) setvbuf(image->blob->file,(char *) NULL,(int) _IOFBF,
+                  (void) setvbuf(image->blob->stream_info.file,(char *) NULL,(int) _IOFBF,
                     16384);
 #endif
                 }
@@ -2736,12 +2759,12 @@ MagickExport ssize_t ReadBlob(Image *image,const size_t length,
       {
         default:
         {
-          count=(ssize_t) fread(q,1,length,image->blob->file);
+          count=(ssize_t) fread(q,1,length,image->blob->stream_info.file);
           break;
         }
         case 2:
         {
-          c=getc(image->blob->file);
+          c=getc(image->blob->stream_info.file);
           if (c == EOF)
             break;
           *q++=(unsigned char) c;
@@ -2749,7 +2772,7 @@ MagickExport ssize_t ReadBlob(Image *image,const size_t length,
         }
         case 1:
         {
-          c=getc(image->blob->file);
+          c=getc(image->blob->stream_info.file);
           if (c == EOF)
             break;
           *q++=(unsigned char) c;
@@ -2767,12 +2790,13 @@ MagickExport ssize_t ReadBlob(Image *image,const size_t length,
       {
         default:
         {
-          count=(ssize_t) gzread(image->blob->file,q,(unsigned int) length);
+          count=(ssize_t) gzread(image->blob->stream_info.gzfile,q,
+            (unsigned int) length);
           break;
         }
         case 2:
         {
-          c=gzgetc(image->blob->file);
+          c=gzgetc(image->blob->stream_info.gzfile);
           if (c == EOF)
             break;
           *q++=(unsigned char) c;
@@ -2780,7 +2804,7 @@ MagickExport ssize_t ReadBlob(Image *image,const size_t length,
         }
         case 1:
         {
-          c=gzgetc(image->blob->file);
+          c=gzgetc(image->blob->stream_info.gzfile);
           if (c == EOF)
             break;
           *q++=(unsigned char) c;
@@ -2795,7 +2819,8 @@ MagickExport ssize_t ReadBlob(Image *image,const size_t length,
     case BZipStream:
     {
 #if defined(MAGICKCORE_BZLIB_DELEGATE)
-      count=(ssize_t) BZ2_bzread((BZFILE *) image->blob->file,q,(int) length);
+      count=(ssize_t) BZ2_bzread(image->blob->stream_info.bzfile,q,
+        (int) length);
 #endif
       break;
     }
@@ -3513,7 +3538,7 @@ MagickExport MagickOffsetType SeekBlob(Image *image,
       break;
     case FileStream:
     {
-      if (fseek(image->blob->file,offset,whence) < 0)
+      if (fseek(image->blob->stream_info.file,offset,whence) < 0)
         return(-1);
       image->blob->offset=TellBlob(image);
       break;
@@ -3523,7 +3548,7 @@ MagickExport MagickOffsetType SeekBlob(Image *image,
     case ZipStream:
     {
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
-      if (gzseek(image->blob->file,(off_t) offset,whence) < 0)
+      if (gzseek(image->blob->stream_info.gzfile,(off_t) offset,whence) < 0)
         return(-1);
 #endif
       image->blob->offset=TellBlob(image);
@@ -3611,7 +3636,7 @@ MagickExport MagickOffsetType SeekBlob(Image *image,
 %    o exempt: Set to true if this blob is exempt from being closed.
 %
 */
-MagickExport void SetBlobExempt(Image *image,const MagickBooleanType exempt)
+MagickPrivate void SetBlobExempt(Image *image,const MagickBooleanType exempt)
 {
   assert(image != (const Image *) NULL);
   assert(image->signature == MagickSignature);
@@ -3646,7 +3671,7 @@ MagickExport void SetBlobExempt(Image *image,const MagickBooleanType exempt)
 %    o extent:  the blob maximum extent.
 %
 */
-MagickExport MagickBooleanType SetBlobExtent(Image *image,
+MagickPrivate MagickBooleanType SetBlobExtent(Image *image,
   const MagickSizeType extent)
 {
   assert(image != (Image *) NULL);
@@ -3674,8 +3699,8 @@ MagickExport MagickBooleanType SetBlobExtent(Image *image,
           offset;
 
         offset=TellBlob(image);
-        status=posix_fallocate(fileno(image->blob->file),(off_t) offset,
-          (off_t) (extent-offset));
+        status=posix_fallocate(fileno(image->blob->stream_info.file),
+          (off_t) offset,(off_t) (extent-offset));
         if (status != 0)
           return(MagickFalse);
       }
@@ -3694,7 +3719,7 @@ MagickExport MagickBooleanType SetBlobExtent(Image *image,
     {
       if (image->blob->mapped != MagickFalse)
         {
-          if (image->blob->file == (FILE *) NULL)
+          if (image->blob->stream_info.file == (FILE *) NULL)
             return(MagickFalse);
           (void) UnmapBlob(image->blob->data,image->blob->length);
 #if !defined(MAGICKCORE_POSIX_FALLOCATE)
@@ -3708,13 +3733,13 @@ MagickExport MagickBooleanType SetBlobExtent(Image *image,
               offset;
 
             offset=TellBlob(image);
-            status=posix_fallocate(fileno(image->blob->file),(off_t) offset,
-              (off_t) (extent-offset));
+            status=posix_fallocate(fileno(image->blob->stream_info.file),
+              (off_t) offset,(off_t) (extent-offset));
             if (status != 0)
               return(MagickFalse);
           }
-          image->blob->data=(unsigned char*) MapBlob(fileno(image->blob->file),
-            WriteMode,0,(size_t) extent);
+          image->blob->data=(unsigned char*) MapBlob(fileno(
+            image->blob->stream_info.file),WriteMode,0,(size_t) extent);
           image->blob->extent=(size_t) extent;
           image->blob->length=(size_t) extent;
           (void) SyncBlob(image);
@@ -3781,20 +3806,20 @@ static int SyncBlob(Image *image)
     case StandardStream:
     case PipeStream:
     {
-      status=fflush(image->blob->file);
+      status=fflush(image->blob->stream_info.file);
       break;
     }
     case ZipStream:
     {
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
-      status=gzflush(image->blob->file,Z_SYNC_FLUSH);
+      status=gzflush(image->blob->stream_info.gzfile,Z_SYNC_FLUSH);
 #endif
       break;
     }
     case BZipStream:
     {
 #if defined(MAGICKCORE_BZLIB_DELEGATE)
-      status=BZ2_bzflush((BZFILE *) image->blob->file);
+      status=BZ2_bzflush(image->blob->stream_info.bzfile);
 #endif
       break;
     }
@@ -3852,7 +3877,7 @@ MagickExport MagickOffsetType TellBlob(const Image *image)
       break;
     case FileStream:
     {
-      offset=ftell(image->blob->file);
+      offset=ftell(image->blob->stream_info.file);
       break;
     }
     case StandardStream:
@@ -3861,7 +3886,7 @@ MagickExport MagickOffsetType TellBlob(const Image *image)
     case ZipStream:
     {
 #if defined(MAGICKCORE_ZLIB_DELEGATE)
-      offset=(MagickOffsetType) gztell(image->blob->file);
+      offset=(MagickOffsetType) gztell(image->blob->stream_info.gzfile);
 #endif
       break;
     }
@@ -3981,19 +4006,19 @@ MagickExport ssize_t WriteBlob(Image *image,const size_t length,
         default:
         {
           count=(ssize_t) fwrite((const char *) data,1,length,
-            image->blob->file);
+            image->blob->stream_info.file);
           break;
         }
         case 2:
         {
-          c=putc((int) *p++,image->blob->file);
+          c=putc((int) *p++,image->blob->stream_info.file);
           if (c == EOF)
             break;
           count++;
         }
         case 1:
         {
-          c=putc((int) *p++,image->blob->file);
+          c=putc((int) *p++,image->blob->stream_info.file);
           if (c == EOF)
             break;
           count++;
@@ -4010,20 +4035,20 @@ MagickExport ssize_t WriteBlob(Image *image,const size_t length,
       {
         default:
         {
-          count=(ssize_t) gzwrite(image->blob->file,(void *) data,
+          count=(ssize_t) gzwrite(image->blob->stream_info.gzfile,(void *) data,
             (unsigned int) length);
           break;
         }
         case 2:
         {
-          c=gzputc(image->blob->file,(int) *p++);
+          c=gzputc(image->blob->stream_info.gzfile,(int) *p++);
           if (c == EOF)
             break;
           count++;
         }
         case 1:
         {
-          c=gzputc(image->blob->file,(int) *p++);
+          c=gzputc(image->blob->stream_info.gzfile,(int) *p++);
           if (c == EOF)
             break;
           count++;
@@ -4037,7 +4062,7 @@ MagickExport ssize_t WriteBlob(Image *image,const size_t length,
     case BZipStream:
     {
 #if defined(MAGICKCORE_BZLIB_DELEGATE)
-      count=(ssize_t) BZ2_bzwrite((BZFILE *) image->blob->file,(void *) data,
+      count=(ssize_t) BZ2_bzwrite(image->blob->stream_info.bzfile,(void *) data,
         (int) length);
 #endif
       break;