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