/src/imagemagick/coders/info.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 | | % % |
4 | | % % |
5 | | % % |
6 | | % IIIII N N FFFFF OOO % |
7 | | % I NN N F O O % |
8 | | % I N N N FFF O O % |
9 | | % I N NN F O O % |
10 | | % IIIII N N F OOO % |
11 | | % % |
12 | | % % |
13 | | % Write Info About the Image. % |
14 | | % % |
15 | | % Software Design % |
16 | | % Cristy % |
17 | | % July 1992 % |
18 | | % % |
19 | | % % |
20 | | % Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization % |
21 | | % 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 | | % https://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 | | Include declarations. |
41 | | */ |
42 | | #include "MagickCore/studio.h" |
43 | | #include "MagickCore/artifact.h" |
44 | | #include "MagickCore/blob.h" |
45 | | #include "MagickCore/blob-private.h" |
46 | | #include "MagickCore/colorspace.h" |
47 | | #include "MagickCore/exception.h" |
48 | | #include "MagickCore/exception-private.h" |
49 | | #include "MagickCore/identify.h" |
50 | | #include "MagickCore/image.h" |
51 | | #include "MagickCore/image-private.h" |
52 | | #include "MagickCore/list.h" |
53 | | #include "MagickCore/magick.h" |
54 | | #include "MagickCore/memory_.h" |
55 | | #include "MagickCore/monitor.h" |
56 | | #include "MagickCore/monitor-private.h" |
57 | | #include "MagickCore/option.h" |
58 | | #include "MagickCore/property.h" |
59 | | #include "MagickCore/quantum-private.h" |
60 | | #include "MagickCore/static.h" |
61 | | #include "MagickCore/string_.h" |
62 | | #include "MagickCore/module.h" |
63 | | #include "MagickCore/utility.h" |
64 | | |
65 | | /* |
66 | | Forward declarations. |
67 | | */ |
68 | | static MagickBooleanType |
69 | | WriteINFOImage(const ImageInfo *,Image *,ExceptionInfo *); |
70 | | |
71 | | /* |
72 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
73 | | % % |
74 | | % % |
75 | | % % |
76 | | % R e g i s t e r I N F O I m a g e % |
77 | | % % |
78 | | % % |
79 | | % % |
80 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
81 | | % |
82 | | % RegisterINFOImage() adds attributes for the INFO image format to |
83 | | % the list of supported formats. The attributes include the image format |
84 | | % tag, a method to read and/or write the format, whether the format |
85 | | % supports the saving of more than one frame to the same file or blob, |
86 | | % whether the format supports native in-memory I/O, and a brief |
87 | | % description of the format. |
88 | | % |
89 | | % The format of the RegisterINFOImage method is: |
90 | | % |
91 | | % size_t RegisterINFOImage(void) |
92 | | % |
93 | | */ |
94 | | ModuleExport size_t RegisterINFOImage(void) |
95 | 8 | { |
96 | 8 | MagickInfo |
97 | 8 | *entry; |
98 | | |
99 | 8 | entry=AcquireMagickInfo("INFO","INFO","The image format and characteristics"); |
100 | 8 | entry->encoder=(EncodeImageHandler *) WriteINFOImage; |
101 | 8 | entry->flags^=CoderBlobSupportFlag; |
102 | 8 | (void) RegisterMagickInfo(entry); |
103 | 8 | return(MagickImageCoderSignature); |
104 | 8 | } |
105 | | |
106 | | /* |
107 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
108 | | % % |
109 | | % % |
110 | | % % |
111 | | % U n r e g i s t e r I N F O I m a g e % |
112 | | % % |
113 | | % % |
114 | | % % |
115 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
116 | | % |
117 | | % UnregisterINFOImage() removes format registrations made by the |
118 | | % INFO module from the list of supported formats. |
119 | | % |
120 | | % The format of the UnregisterINFOImage method is: |
121 | | % |
122 | | % UnregisterINFOImage(void) |
123 | | % |
124 | | */ |
125 | | ModuleExport void UnregisterINFOImage(void) |
126 | 0 | { |
127 | 0 | (void) UnregisterMagickInfo("INFO"); |
128 | 0 | } |
129 | | |
130 | | /* |
131 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
132 | | % % |
133 | | % % |
134 | | % % |
135 | | % W r i t e I N F O I m a g e % |
136 | | % % |
137 | | % % |
138 | | % % |
139 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
140 | | % |
141 | | % WriteINFOImage writes the pixel values as text numbers. |
142 | | % |
143 | | % The format of the WriteINFOImage method is: |
144 | | % |
145 | | % MagickBooleanType WriteINFOImage(const ImageInfo *image_info, |
146 | | % Image *image,ExceptionInfo *exception) |
147 | | % |
148 | | % A description of each parameter follows. |
149 | | % |
150 | | % o image_info: the image info. |
151 | | % |
152 | | % o image: The image. |
153 | | % |
154 | | % o exception: return any errors or warnings in this structure. |
155 | | % |
156 | | */ |
157 | | static MagickBooleanType WriteINFOImage(const ImageInfo *image_info, |
158 | | Image *image,ExceptionInfo *exception) |
159 | 0 | { |
160 | 0 | const char |
161 | 0 | *format; |
162 | |
|
163 | 0 | MagickBooleanType |
164 | 0 | status; |
165 | |
|
166 | 0 | MagickOffsetType |
167 | 0 | scene; |
168 | |
|
169 | 0 | size_t |
170 | 0 | number_scenes; |
171 | | |
172 | | /* |
173 | | Open output image file. |
174 | | */ |
175 | 0 | assert(image_info != (const ImageInfo *) NULL); |
176 | 0 | assert(image_info->signature == MagickCoreSignature); |
177 | 0 | assert(image != (Image *) NULL); |
178 | 0 | assert(image->signature == MagickCoreSignature); |
179 | 0 | if (IsEventLogging() != MagickFalse) |
180 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
181 | 0 | status=OpenBlob(image_info,image,WriteBlobMode,exception); |
182 | 0 | if (status == MagickFalse) |
183 | 0 | return(status); |
184 | 0 | scene=0; |
185 | 0 | number_scenes=GetImageListLength(image); |
186 | 0 | do |
187 | 0 | { |
188 | 0 | format=GetImageOption(image_info,"format"); |
189 | 0 | if (format == (char *) NULL) |
190 | 0 | { |
191 | 0 | (void) CopyMagickString(image->filename,image->magick_filename, |
192 | 0 | MagickPathExtent); |
193 | 0 | image->magick_columns=image->columns; |
194 | 0 | image->magick_rows=image->rows; |
195 | 0 | (void) IdentifyImage(image,GetBlobFileHandle(image), |
196 | 0 | image_info->verbose,exception); |
197 | 0 | } |
198 | 0 | else |
199 | 0 | { |
200 | 0 | char |
201 | 0 | *text; |
202 | |
|
203 | 0 | text=InterpretImageProperties((ImageInfo *) image_info,image,format, |
204 | 0 | exception); |
205 | 0 | if (text != (char *) NULL) |
206 | 0 | { |
207 | 0 | (void) WriteBlobString(image,text); |
208 | 0 | text=DestroyString(text); |
209 | 0 | } |
210 | 0 | } |
211 | 0 | if (GetNextImageInList(image) == (Image *) NULL) |
212 | 0 | break; |
213 | 0 | image=SyncNextImageInList(image); |
214 | 0 | status=SetImageProgress(image,SaveImagesTag,scene++,number_scenes); |
215 | 0 | if (status == MagickFalse) |
216 | 0 | break; |
217 | 0 | } while (image_info->adjoin != MagickFalse); |
218 | 0 | if (CloseBlob(image) == MagickFalse) |
219 | 0 | status=MagickFalse; |
220 | 0 | return(status); |
221 | 0 | } |