2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % FFFFF IIIII TTTTT SSSSS %
13 % Read/Write Flexible Image Transport System Images. %
20 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
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. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 #include "magick/studio.h"
43 #include "magick/attribute.h"
44 #include "magick/blob.h"
45 #include "magick/blob-private.h"
46 #include "magick/cache.h"
47 #include "magick/color-private.h"
48 #include "magick/colorspace.h"
49 #include "magick/constitute.h"
50 #include "magick/exception.h"
51 #include "magick/exception-private.h"
52 #include "magick/image.h"
53 #include "magick/image-private.h"
54 #include "magick/list.h"
55 #include "magick/magick.h"
56 #include "magick/memory_.h"
57 #include "magick/module.h"
58 #include "magick/monitor.h"
59 #include "magick/monitor-private.h"
60 #include "magick/pixel-private.h"
61 #include "magick/pixel-private.h"
62 #include "magick/property.h"
63 #include "magick/static.h"
64 #include "magick/statistic.h"
65 #include "magick/string_.h"
66 #include "magick/string-private.h"
67 #include "magick/module.h"
72 #define FITSBlocksize 2880UL
77 static MagickBooleanType
78 WriteFITSImage(const ImageInfo *,Image *);
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91 % IsFITS() returns MagickTrue if the image format type, identified by the
92 % magick string, is FITS.
94 % The format of the IsFITS method is:
96 % MagickBooleanType IsFITS(const unsigned char *magick,const size_t length)
98 % A description of each parameter follows:
100 % o magick: compare image format pattern against these bytes.
102 % o length: Specifies the length of the magick string.
105 static MagickBooleanType IsFITS(const unsigned char *magick,const size_t length)
109 if (LocaleNCompare((const char *) magick,"IT0",3) == 0)
111 if (LocaleNCompare((const char *) magick,"SIMPLE",6) == 0)
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
121 % R e a d F I T S I m a g e %
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
127 % ReadFITSImage() reads a FITS image file and returns it. It allocates the
128 % memory necessary for the new Image structure and returns a pointer to the
131 % The format of the ReadFITSImage method is:
133 % Image *ReadFITSImage(const ImageInfo *image_info,
134 % ExceptionInfo *exception)
136 % A description of each parameter follows:
138 % o image_info: the image info.
140 % o exception: return any errors or warnings in this structure.
144 static inline double GetFITSPixel(Image *image,int bits_per_pixel)
146 switch (image->depth >> 3)
149 return((double) ReadBlobByte(image));
151 return((double) ((short) ReadBlobShort(image)));
154 if (bits_per_pixel > 0)
155 return((double) ((int) ReadBlobLong(image)));
156 return((double) ReadBlobFloat(image));
160 if (bits_per_pixel > 0)
161 return((double) ((MagickOffsetType) ReadBlobLongLong(image)));
166 return(ReadBlobDouble(image));
169 static void GetFITSPixelExtrema(Image *image,const int bits_per_pixel,
170 double *minima,double *maxima)
181 register MagickOffsetType
184 offset=TellBlob(image);
185 number_pixels=(MagickSizeType) image->columns*image->rows;
186 *minima=GetFITSPixel(image,bits_per_pixel);
188 for (i=1; i < (MagickOffsetType) number_pixels; i++)
190 pixel=GetFITSPixel(image,bits_per_pixel);
196 (void) SeekBlob(image,offset,SEEK_SET);
199 static inline double GetFITSPixelRange(const size_t depth)
201 return((double) ((MagickOffsetType) GetQuantumRange(depth)));
204 static void SetFITSUnsignedPixels(const size_t length,
205 const size_t bits_per_pixel,unsigned char *pixels)
210 for (i=0; i < (ssize_t) length; i++)
213 pixels+=bits_per_pixel >> 3;
217 static Image *ReadFITSImage(const ImageInfo *image_info,
218 ExceptionInfo *exception)
220 typedef struct _FITSInfo
246 property[MaxTextExtent],
283 assert(image_info != (const ImageInfo *) NULL);
284 assert(image_info->signature == MagickSignature);
285 if (image_info->debug != MagickFalse)
286 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
287 image_info->filename);
288 assert(exception != (ExceptionInfo *) NULL);
289 assert(exception->signature == MagickSignature);
290 image=AcquireImage(image_info);
291 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
292 if (status == MagickFalse)
294 image=DestroyImageList(image);
295 return((Image *) NULL);
298 Initialize image header.
300 (void) ResetMagickMemory(&fits_info,0,sizeof(fits_info));
301 fits_info.extend=MagickFalse;
302 fits_info.simple=MagickFalse;
303 fits_info.bits_per_pixel=8;
307 fits_info.number_planes=1;
308 fits_info.min_data=0.0;
309 fits_info.max_data=0.0;
312 fits_info.endian=MSBEndian;
316 for (comment=(char *) NULL; EOFBlob(image) == MagickFalse; )
318 for ( ; EOFBlob(image) == MagickFalse; )
323 count=ReadBlob(image,8,(unsigned char *) keyword);
326 for (i=0; i < 8; i++)
328 if (isspace((int) ((unsigned char) keyword[i])) != 0)
330 keyword[i]=tolower((int) ((unsigned char) keyword[i]));
333 count=ReadBlob(image,72,(unsigned char *) value);
341 while (isspace((int) ((unsigned char) *p)) != 0)
344 if (LocaleCompare(keyword,"end") == 0)
346 if (LocaleCompare(keyword,"extend") == 0)
347 fits_info.extend=(*p == 'T') || (*p == 't') ? MagickTrue : MagickFalse;
348 if (LocaleCompare(keyword,"simple") == 0)
349 fits_info.simple=(*p == 'T') || (*p == 't') ? MagickTrue : MagickFalse;
350 if (LocaleCompare(keyword,"bitpix") == 0)
351 fits_info.bits_per_pixel=StringToLong(p);
352 if (LocaleCompare(keyword,"naxis") == 0)
353 fits_info.number_axes=StringToLong(p);
354 if (LocaleCompare(keyword,"naxis1") == 0)
355 fits_info.columns=StringToLong(p);
356 if (LocaleCompare(keyword,"naxis2") == 0)
357 fits_info.rows=StringToLong(p);
358 if (LocaleCompare(keyword,"naxis3") == 0)
359 fits_info.number_planes=StringToLong(p);
360 if (LocaleCompare(keyword,"datamax") == 0)
361 fits_info.max_data=InterpretLocaleValue(p,(char **) NULL);
362 if (LocaleCompare(keyword,"datamin") == 0)
363 fits_info.min_data=InterpretLocaleValue(p,(char **) NULL);
364 if (LocaleCompare(keyword,"bzero") == 0)
365 fits_info.zero=InterpretLocaleValue(p,(char **) NULL);
366 if (LocaleCompare(keyword,"bscale") == 0)
367 fits_info.scale=InterpretLocaleValue(p,(char **) NULL);
368 if (LocaleCompare(keyword,"comment") == 0)
370 if (comment == (char *) NULL)
371 comment=ConstantString(p);
373 (void) ConcatenateString(&comment,p);
375 if (LocaleCompare(keyword,"xendian") == 0)
377 if (LocaleNCompare(p,"big",3) == 0)
378 fits_info.endian=MSBEndian;
380 fits_info.endian=LSBEndian;
382 (void) FormatLocaleString(property,MaxTextExtent,"fits:%s",keyword);
383 (void) SetImageProperty(image,property,p);
386 while (((TellBlob(image) % FITSBlocksize) != 0) && (c != EOF))
387 c=ReadBlobByte(image);
388 if (fits_info.extend == MagickFalse)
390 number_pixels=(MagickSizeType) fits_info.columns*fits_info.rows;
391 if ((fits_info.simple != MagickFalse) && (fits_info.number_axes >= 1) &&
392 (fits_info.number_axes <= 4) && (number_pixels != 0))
396 Verify that required image information is defined.
398 if (comment != (char *) NULL)
400 (void) SetImageProperty(image,"comment",comment);
401 comment=DestroyString(comment);
403 if (EOFBlob(image) != MagickFalse)
404 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
406 number_pixels=(MagickSizeType) fits_info.columns*fits_info.rows;
407 if ((fits_info.simple == MagickFalse) || (fits_info.number_axes < 1) ||
408 (fits_info.number_axes > 4) || (number_pixels == 0))
409 ThrowReaderException(CorruptImageError,"ImageTypeNotSupported");
410 for (scene=0; scene < (ssize_t) fits_info.number_planes; scene++)
412 image->columns=(size_t) fits_info.columns;
413 image->rows=(size_t) fits_info.rows;
414 image->depth=(size_t) (fits_info.bits_per_pixel < 0 ? -1 : 1)*
415 fits_info.bits_per_pixel;
416 image->endian=fits_info.endian;
417 image->scene=(size_t) scene;
418 if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
419 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
422 Initialize image structure.
424 if ((fits_info.min_data != 0.0) || (fits_info.max_data != 0.0))
426 if ((fits_info.bits_per_pixel != 0) && (fits_info.max_data == 0.0))
427 fits_info.max_data=GetFITSPixelRange((size_t)
428 fits_info.bits_per_pixel);
431 GetFITSPixelExtrema(image,fits_info.bits_per_pixel,&fits_info.min_data,
432 &fits_info.max_data);
434 Convert FITS pixels to pixel packets.
436 scale=(double) QuantumRange/(fits_info.scale*(fits_info.max_data-
437 fits_info.min_data)+fits_info.zero);
438 for (y=(ssize_t) image->rows-1; y >= 0; y--)
440 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
441 if (q == (PixelPacket *) NULL)
443 for (x=0; x < (ssize_t) image->columns; x++)
445 pixel=GetFITSPixel(image,fits_info.bits_per_pixel);
446 SetRedPixelComponent(q,ClampToQuantum(scale*(fits_info.scale*(pixel-
447 fits_info.min_data)+fits_info.zero)));
448 SetGreenPixelComponent(q,GetRedPixelComponent(q));
449 SetBluePixelComponent(q,GetRedPixelComponent(q));
452 if (SyncAuthenticPixels(image,exception) == MagickFalse)
454 if (image->previous == (Image *) NULL)
456 status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
458 if (status == MagickFalse)
462 if (EOFBlob(image) != MagickFalse)
464 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
469 Proceed to next image.
471 if (image_info->number_scenes != 0)
472 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
474 if (scene < (ssize_t) (fits_info.number_planes-1))
477 Allocate next image structure.
479 AcquireNextImage(image_info,image);
480 if (GetNextImageInList(image) == (Image *) NULL)
482 image=DestroyImageList(image);
483 return((Image *) NULL);
485 image=SyncNextImageInList(image);
486 status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
488 if (status == MagickFalse)
492 (void) CloseBlob(image);
493 return(GetFirstImageInList(image));
497 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
501 % R e g i s t e r F I T S I m a g e %
505 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 % RegisterFITSImage() adds attributes for the FITS image format to
508 % the list of supported formats. The attributes include the image format
509 % tag, a method to read and/or write the format, whether the format
510 % supports the saving of more than one frame to the same file or blob,
511 % whether the format supports native in-memory I/O, and a brief
512 % description of the format.
514 % The format of the RegisterFITSImage method is:
516 % size_t RegisterFITSImage(void)
519 ModuleExport size_t RegisterFITSImage(void)
524 entry=SetMagickInfo("FITS");
525 entry->decoder=(DecodeImageHandler *) ReadFITSImage;
526 entry->encoder=(EncodeImageHandler *) WriteFITSImage;
527 entry->magick=(IsImageFormatHandler *) IsFITS;
528 entry->adjoin=MagickFalse;
529 entry->seekable_stream=MagickTrue;
530 entry->description=ConstantString("Flexible Image Transport System");
531 entry->module=ConstantString("FITS");
532 (void) RegisterMagickInfo(entry);
533 entry=SetMagickInfo("FTS");
534 entry->decoder=(DecodeImageHandler *) ReadFITSImage;
535 entry->encoder=(EncodeImageHandler *) WriteFITSImage;
536 entry->magick=(IsImageFormatHandler *) IsFITS;
537 entry->adjoin=MagickFalse;
538 entry->seekable_stream=MagickTrue;
539 entry->description=ConstantString("Flexible Image Transport System");
540 entry->module=ConstantString("FTS");
541 (void) RegisterMagickInfo(entry);
542 return(MagickImageCoderSignature);
546 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
550 % U n r e g i s t e r F I T S I m a g e %
554 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
556 % UnregisterFITSImage() removes format registrations made by the
557 % FITS module from the list of supported formats.
559 % The format of the UnregisterFITSImage method is:
561 % UnregisterFITSImage(void)
564 ModuleExport void UnregisterFITSImage(void)
566 (void) UnregisterMagickInfo("FITS");
567 (void) UnregisterMagickInfo("FTS");
571 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
575 % W r i t e F I T S I m a g e %
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
581 % WriteFITSImage() writes a Flexible Image Transport System image to a
582 % file as gray scale intensities [0..255].
584 % The format of the WriteFITSImage method is:
586 % MagickBooleanType WriteFITSImage(const ImageInfo *image_info,
589 % A description of each parameter follows.
591 % o image_info: the image info.
593 % o image: The image.
596 static MagickBooleanType WriteFITSImage(const ImageInfo *image_info,
600 header[FITSBlocksize],
609 register const PixelPacket
624 Open output image file.
626 assert(image_info != (const ImageInfo *) NULL);
627 assert(image_info->signature == MagickSignature);
628 assert(image != (Image *) NULL);
629 assert(image->signature == MagickSignature);
630 if (image->debug != MagickFalse)
631 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
632 status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
633 if (status == MagickFalse)
635 if (image->colorspace != RGBColorspace)
636 (void) TransformImageColorspace(image,RGBColorspace);
638 Allocate image memory.
640 fits_info=(char *) AcquireQuantumMemory(FITSBlocksize,sizeof(*fits_info));
641 if (fits_info == (char *) NULL)
642 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
643 (void) ResetMagickMemory(fits_info,' ',FITSBlocksize*sizeof(*fits_info));
645 Initialize image header.
647 image->depth=GetImageQuantumDepth(image,MagickFalse);
648 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
649 if (quantum_info == (QuantumInfo *) NULL)
650 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
652 (void) FormatLocaleString(header,FITSBlocksize,
654 (void) strncpy(fits_info+offset,header,strlen(header));
656 (void) FormatLocaleString(header,FITSBlocksize,"BITPIX = %10ld",
657 (long) (quantum_info->format == FloatingPointQuantumFormat ? -1 : 1)*
659 (void) strncpy(fits_info+offset,header,strlen(header));
661 (void) FormatLocaleString(header,FITSBlocksize,"NAXIS = %10lu",
662 IsGrayImage(image,&image->exception) != MagickFalse ? 2UL : 3UL);
663 (void) strncpy(fits_info+offset,header,strlen(header));
665 (void) FormatLocaleString(header,FITSBlocksize,"NAXIS1 = %10lu",
666 (unsigned long) image->columns);
667 (void) strncpy(fits_info+offset,header,strlen(header));
669 (void) FormatLocaleString(header,FITSBlocksize,"NAXIS2 = %10lu",
670 (unsigned long) image->rows);
671 (void) strncpy(fits_info+offset,header,strlen(header));
673 if (IsGrayImage(image,&image->exception) == MagickFalse)
675 (void) FormatLocaleString(header,FITSBlocksize,
676 "NAXIS3 = %10lu",3UL);
677 (void) strncpy(fits_info+offset,header,strlen(header));
680 (void) FormatLocaleString(header,FITSBlocksize,"BSCALE = %E",1.0);
681 (void) strncpy(fits_info+offset,header,strlen(header));
683 (void) FormatLocaleString(header,FITSBlocksize,"BZERO = %E",
684 image->depth > 8 ? GetFITSPixelRange(image->depth) : 0.0);
685 (void) strncpy(fits_info+offset,header,strlen(header));
687 (void) FormatLocaleString(header,FITSBlocksize,"DATAMAX = %E",
688 1.0*((MagickOffsetType) GetQuantumRange(image->depth)));
689 (void) strncpy(fits_info+offset,header,strlen(header));
691 (void) FormatLocaleString(header,FITSBlocksize,"DATAMIN = %E",0.0);
692 (void) strncpy(fits_info+offset,header,strlen(header));
694 if (image->endian == LSBEndian)
696 (void) FormatLocaleString(header,FITSBlocksize,"XENDIAN = 'SMALL'");
697 (void) strncpy(fits_info+offset,header,strlen(header));
700 (void) FormatLocaleString(header,FITSBlocksize,"HISTORY %.72s",
701 GetMagickVersion((size_t *) NULL));
702 (void) strncpy(fits_info+offset,header,strlen(header));
704 (void) strncpy(header,"END",FITSBlocksize);
705 (void) strncpy(fits_info+offset,header,strlen(header));
707 (void) WriteBlob(image,FITSBlocksize,(unsigned char *) fits_info);
709 Convert image to fits scale PseudoColor class.
711 pixels=GetQuantumPixels(quantum_info);
712 if (IsGrayImage(image,&image->exception) != MagickFalse)
714 length=GetQuantumExtent(image,quantum_info,GrayQuantum);
715 for (y=(ssize_t) image->rows-1; y >= 0; y--)
717 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
718 if (p == (const PixelPacket *) NULL)
720 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
721 GrayQuantum,pixels,&image->exception);
722 if (image->depth == 16)
723 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
724 if (((image->depth == 32) || (image->depth == 64)) &&
725 (quantum_info->format != FloatingPointQuantumFormat))
726 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
727 count=WriteBlob(image,length,pixels);
728 if (count != (ssize_t) length)
730 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
732 if (status == MagickFalse)
738 length=GetQuantumExtent(image,quantum_info,RedQuantum);
739 for (y=(ssize_t) image->rows-1; y >= 0; y--)
741 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
742 if (p == (const PixelPacket *) NULL)
744 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
745 RedQuantum,pixels,&image->exception);
746 if (image->depth == 16)
747 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
748 if (((image->depth == 32) || (image->depth == 64)) &&
749 (quantum_info->format != FloatingPointQuantumFormat))
750 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
751 count=WriteBlob(image,length,pixels);
752 if (count != (ssize_t) length)
754 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
756 if (status == MagickFalse)
759 length=GetQuantumExtent(image,quantum_info,GreenQuantum);
760 for (y=(ssize_t) image->rows-1; y >= 0; y--)
762 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
763 if (p == (const PixelPacket *) NULL)
765 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
766 GreenQuantum,pixels,&image->exception);
767 if (image->depth == 16)
768 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
769 if (((image->depth == 32) || (image->depth == 64)) &&
770 (quantum_info->format != FloatingPointQuantumFormat))
771 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
772 count=WriteBlob(image,length,pixels);
773 if (count != (ssize_t) length)
775 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
777 if (status == MagickFalse)
780 length=GetQuantumExtent(image,quantum_info,BlueQuantum);
781 for (y=(ssize_t) image->rows-1; y >= 0; y--)
783 p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
784 if (p == (const PixelPacket *) NULL)
786 length=ExportQuantumPixels(image,(const CacheView *) NULL,quantum_info,
787 BlueQuantum,pixels,&image->exception);
788 if (image->depth == 16)
789 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
790 if (((image->depth == 32) || (image->depth == 64)) &&
791 (quantum_info->format != FloatingPointQuantumFormat))
792 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
793 count=WriteBlob(image,length,pixels);
794 if (count != (ssize_t) length)
796 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
798 if (status == MagickFalse)
802 quantum_info=DestroyQuantumInfo(quantum_info);
803 length=(size_t) (FITSBlocksize-TellBlob(image) % FITSBlocksize);
806 (void) ResetMagickMemory(fits_info,0,length*sizeof(*fits_info));
807 (void) WriteBlob(image,length,(unsigned char *) fits_info);
809 fits_info=DestroyString(fits_info);
810 (void) CloseBlob(image);