blob: 600a50375911c069bc476179552cc2703fd00cc7 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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 %
cristyde984cd2013-12-01 14:49:27 +000016% Cristy %
cristy3ed852e2009-09-05 21:47:34 +000017% July 1992 %
18% %
19% %
Cristy7ce65e72015-12-12 18:03:16 -050020% Copyright 1999-2016 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 Include declarations.
41*/
cristy4c08aed2011-07-01 19:47:50 +000042#include "MagickCore/studio.h"
cristy76ce6e12013-04-05 14:33:38 +000043#include "MagickCore/artifact.h"
cristy4c08aed2011-07-01 19:47:50 +000044#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"
cristy76ce6e12013-04-05 14:33:38 +000058#include "MagickCore/property.h"
cristy4c08aed2011-07-01 19:47:50 +000059#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"
cristy3ed852e2009-09-05 21:47:34 +000064
65/*
66 Forward declarations.
67*/
68static MagickBooleanType
cristy1e178e72011-08-28 19:44:34 +000069 WriteINFOImage(const ImageInfo *,Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000070
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%
cristybb503372010-05-27 20:51:26 +000091% size_t RegisterINFOImage(void)
cristy3ed852e2009-09-05 21:47:34 +000092%
93*/
cristybb503372010-05-27 20:51:26 +000094ModuleExport size_t RegisterINFOImage(void)
cristy3ed852e2009-09-05 21:47:34 +000095{
96 MagickInfo
97 *entry;
98
dirk06b627a2015-04-06 18:59:17 +000099 entry=AcquireMagickInfo("INFO","INFO",
100 "The image format and characteristics");
cristy3ed852e2009-09-05 21:47:34 +0000101 entry->encoder=(EncodeImageHandler *) WriteINFOImage;
dirk08e9a112015-02-22 01:51:41 +0000102 entry->flags^=CoderBlobSupportFlag;
cristy3ed852e2009-09-05 21:47:34 +0000103 (void) RegisterMagickInfo(entry);
104 return(MagickImageCoderSignature);
105}
106
107/*
108%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109% %
110% %
111% %
112% U n r e g i s t e r I N F O I m a g e %
113% %
114% %
115% %
116%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
117%
118% UnregisterINFOImage() removes format registrations made by the
119% INFO module from the list of supported formats.
120%
121% The format of the UnregisterINFOImage method is:
122%
123% UnregisterINFOImage(void)
124%
125*/
126ModuleExport void UnregisterINFOImage(void)
127{
128 (void) UnregisterMagickInfo("INFO");
129}
130
131/*
132%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133% %
134% %
135% %
136% W r i t e I N F O I m a g e %
137% %
138% %
139% %
140%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141%
142% WriteINFOImage writes the pixel values as text numbers.
143%
144% The format of the WriteINFOImage method is:
145%
146% MagickBooleanType WriteINFOImage(const ImageInfo *image_info,
cristy1e178e72011-08-28 19:44:34 +0000147% Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000148%
149% A description of each parameter follows.
150%
151% o image_info: the image info.
152%
153% o image: The image.
154%
cristy1e178e72011-08-28 19:44:34 +0000155% o exception: return any errors or warnings in this structure.
156%
cristy3ed852e2009-09-05 21:47:34 +0000157*/
158static MagickBooleanType WriteINFOImage(const ImageInfo *image_info,
cristy1e178e72011-08-28 19:44:34 +0000159 Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000160{
161 const char
162 *format;
163
164 MagickBooleanType
165 status;
166
167 MagickOffsetType
168 scene;
169
170 /*
171 Open output image file.
172 */
173 assert(image_info != (const ImageInfo *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000174 assert(image_info->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000175 assert(image != (Image *) NULL);
cristye1c94d92015-06-28 12:16:33 +0000176 assert(image->signature == MagickCoreSignature);
cristy3ed852e2009-09-05 21:47:34 +0000177 if (image->debug != MagickFalse)
178 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
cristy1e178e72011-08-28 19:44:34 +0000179 status=OpenBlob(image_info,image,WriteBlobMode,exception);
cristy3ed852e2009-09-05 21:47:34 +0000180 if (status == MagickFalse)
181 return(status);
182 scene=0;
183 do
184 {
cristy092ec8d2013-04-26 13:46:22 +0000185 format=GetImageOption(image_info,"format");
cristy3ed852e2009-09-05 21:47:34 +0000186 if (format == (char *) NULL)
187 {
188 (void) CopyMagickString(image->filename,image->magick_filename,
cristy151b66d2015-04-15 10:50:31 +0000189 MagickPathExtent);
cristy3ed852e2009-09-05 21:47:34 +0000190 image->magick_columns=image->columns;
191 image->magick_rows=image->rows;
192 (void) IdentifyImage(image,GetBlobFileHandle(image),
cristy1e178e72011-08-28 19:44:34 +0000193 image_info->verbose,exception);
cristy3ed852e2009-09-05 21:47:34 +0000194 }
195 else
196 {
197 char
198 *text;
199
cristye67f43f2013-04-29 10:27:50 +0000200 text=InterpretImageProperties((ImageInfo *) image_info,image,format,
201 exception);
cristy3ed852e2009-09-05 21:47:34 +0000202 if (text != (char *) NULL)
203 {
204 (void) WriteBlobString(image,text);
cristy3ed852e2009-09-05 21:47:34 +0000205 text=DestroyString(text);
206 }
207 }
208 if (GetNextImageInList(image) == (Image *) NULL)
209 break;
210 image=SyncNextImageInList(image);
211 status=SetImageProgress(image,SaveImagesTag,scene++,
212 GetImageListLength(image));
213 if (status == MagickFalse)
214 break;
215 } while (image_info->adjoin != MagickFalse);
216 (void) CloseBlob(image);
217 return(MagickTrue);
218}