2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Retrieve An Image Via a File Descriptor. %
21 % Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
22 % dedicated to making software imaging solutions freely available. %
24 % You may not use this file except in compliance with the License. You may %
25 % obtain a copy of the License at %
27 % http://www.imagemagick.org/script/license.php %
29 % Unless required by applicable law or agreed to in writing, software %
30 % distributed under the License is distributed on an "AS IS" BASIS, %
31 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
32 % See the License for the specific language governing permissions and %
33 % limitations under the License. %
35 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "MagickCore/studio.h"
44 #include "MagickCore/blob.h"
45 #include "MagickCore/blob-private.h"
46 #include "MagickCore/constitute.h"
47 #include "MagickCore/exception.h"
48 #include "MagickCore/exception-private.h"
49 #include "MagickCore/image.h"
50 #include "MagickCore/image-private.h"
51 #include "MagickCore/list.h"
52 #include "MagickCore/magick.h"
53 #include "MagickCore/memory_.h"
54 #include "MagickCore/module.h"
55 #include "MagickCore/quantum-private.h"
56 #include "MagickCore/static.h"
57 #include "MagickCore/resource_.h"
58 #include "MagickCore/string_.h"
59 #include "MagickCore/string-private.h"
60 #include "MagickCore/utility.h"
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % R e a d F D I m a g e %
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % ReadFDImage retrieves an image via a file descriptor, decodes the image,
74 % and returns it. It allocates the memory necessary for the new Image
75 % structure and returns a pointer to the new image.
77 % The format of the ReadFDImage method is:
79 % Image *ReadFDImage(const ImageInfo *image_info,ExceptionInfo *exception)
81 % A description of each parameter follows:
83 % o image_info: the image info.
85 % o exception: return any errors or warnings in this structure.
88 static Image *ReadFDImage(const ImageInfo *image_info,ExceptionInfo *exception)
99 assert(image_info != (const ImageInfo *) NULL);
100 assert(image_info->signature == MagickSignature);
101 if (image_info->debug != MagickFalse)
102 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
103 image_info->filename);
104 assert(exception != (ExceptionInfo *) NULL);
105 assert(exception->signature == MagickSignature);
106 read_info=CloneImageInfo(image_info);
107 read_info->file=fdopen(StringToLong(image_info->filename),"rb");
108 if (read_info->file == (FILE *) NULL)
110 ThrowFileException(exception,BlobError,"UnableToOpenBlob",
111 image_info->filename);
112 return((Image *) NULL);
114 *read_info->magick='\0';
115 image=ReadImage(read_info,exception);
116 (void) fclose(read_info->file);
117 read_info=DestroyImageInfo(read_info);
118 if (image == (Image *) NULL)
120 (void) ThrowMagickException(exception,GetMagickModule(),CoderError,
121 "NoDataReturned","`%s'",image_info->filename);
122 return((Image *) NULL);
124 return(GetFirstImageInList(image));
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 % R e g i s t e r F D I m a g e %
136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 % RegisterFDImage() adds attributes for the FD image format to
139 % the list of supported formats. The attributes include the image format
140 % tag, a method to read and/or write the format, whether the format
141 % supports the saving of more than one frame to the same file or blob,
142 % whether the format supports native in-memory I/O, and a brief
143 % description of the format.
145 % The format of the RegisterFDImage method is:
147 % size_t RegisterFDImage(void)
150 ModuleExport size_t RegisterFDImage(void)
155 entry=SetMagickInfo("FD");
156 entry->decoder=(DecodeImageHandler *) ReadFDImage;
157 entry->description=ConstantString("Read image from a file descriptor");
158 entry->module=ConstantString("FD");
159 entry->stealth=MagickTrue;
160 (void) RegisterMagickInfo(entry);
161 return(MagickImageCoderSignature);
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169 % U n r e g i s t e r F D I m a g e %
173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 % UnregisterFDImage() removes format registrations made by the FD module from
176 % the list of supported formats.
178 % The format of the UnregisterFDImage method is:
180 % UnregisterFDImage(void)
183 ModuleExport void UnregisterFDImage(void)
185 (void) UnregisterMagickInfo("FD");