2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % FFFFF IIIII TTTTT SSSSS %
13 % Read/Write Flexible Image Transport System Images. %
20 % Copyright 1999-2012 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 "MagickCore/studio.h"
43 #include "MagickCore/attribute.h"
44 #include "MagickCore/blob.h"
45 #include "MagickCore/blob-private.h"
46 #include "MagickCore/cache.h"
47 #include "MagickCore/color-private.h"
48 #include "MagickCore/colorspace.h"
49 #include "MagickCore/colorspace-private.h"
50 #include "MagickCore/constitute.h"
51 #include "MagickCore/exception.h"
52 #include "MagickCore/exception-private.h"
53 #include "MagickCore/image.h"
54 #include "MagickCore/image-private.h"
55 #include "MagickCore/list.h"
56 #include "MagickCore/magick.h"
57 #include "MagickCore/memory_.h"
58 #include "MagickCore/module.h"
59 #include "MagickCore/monitor.h"
60 #include "MagickCore/monitor-private.h"
61 #include "MagickCore/pixel-accessor.h"
62 #include "MagickCore/property.h"
63 #include "MagickCore/quantum-private.h"
64 #include "MagickCore/static.h"
65 #include "MagickCore/statistic.h"
66 #include "MagickCore/string_.h"
67 #include "MagickCore/string-private.h"
68 #include "MagickCore/module.h"
73 #define FITSBlocksize 2880UL
78 static MagickBooleanType
79 WriteFITSImage(const ImageInfo *,Image *,ExceptionInfo *);
82 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
92 % IsFITS() returns MagickTrue if the image format type, identified by the
93 % magick string, is FITS.
95 % The format of the IsFITS method is:
97 % MagickBooleanType IsFITS(const unsigned char *magick,const size_t length)
99 % A description of each parameter follows:
101 % o magick: compare image format pattern against these bytes.
103 % o length: Specifies the length of the magick string.
106 static MagickBooleanType IsFITS(const unsigned char *magick,const size_t length)
110 if (LocaleNCompare((const char *) magick,"IT0",3) == 0)
112 if (LocaleNCompare((const char *) magick,"SIMPLE",6) == 0)
118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122 % R e a d F I T S I m a g e %
126 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 % ReadFITSImage() reads a FITS image file and returns it. It allocates the
129 % memory necessary for the new Image structure and returns a pointer to the
132 % The format of the ReadFITSImage method is:
134 % Image *ReadFITSImage(const ImageInfo *image_info,
135 % ExceptionInfo *exception)
137 % A description of each parameter follows:
139 % o image_info: the image info.
141 % o exception: return any errors or warnings in this structure.
145 static inline double GetFITSPixel(Image *image,int bits_per_pixel)
147 switch (image->depth >> 3)
150 return((double) ReadBlobByte(image));
152 return((double) ((short) ReadBlobShort(image)));
155 if (bits_per_pixel > 0)
156 return((double) ((int) ReadBlobLong(image)));
157 return((double) ReadBlobFloat(image));
161 if (bits_per_pixel > 0)
162 return((double) ((MagickOffsetType) ReadBlobLongLong(image)));
167 return(ReadBlobDouble(image));
170 static void GetFITSPixelExtrema(Image *image,const int bits_per_pixel,
171 double *minima,double *maxima)
182 register MagickOffsetType
185 offset=TellBlob(image);
186 number_pixels=(MagickSizeType) image->columns*image->rows;
187 *minima=GetFITSPixel(image,bits_per_pixel);
189 for (i=1; i < (MagickOffsetType) number_pixels; i++)
191 pixel=GetFITSPixel(image,bits_per_pixel);
197 (void) SeekBlob(image,offset,SEEK_SET);
200 static inline double GetFITSPixelRange(const size_t depth)
202 return((double) ((MagickOffsetType) GetQuantumRange(depth)));
205 static void SetFITSUnsignedPixels(const size_t length,
206 const size_t bits_per_pixel,unsigned char *pixels)
211 for (i=0; i < (ssize_t) length; i++)
214 pixels+=bits_per_pixel >> 3;
218 static Image *ReadFITSImage(const ImageInfo *image_info,
219 ExceptionInfo *exception)
221 typedef struct _FITSInfo
247 property[MaxTextExtent],
284 assert(image_info != (const ImageInfo *) NULL);
285 assert(image_info->signature == MagickSignature);
286 if (image_info->debug != MagickFalse)
287 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
288 image_info->filename);
289 assert(exception != (ExceptionInfo *) NULL);
290 assert(exception->signature == MagickSignature);
291 image=AcquireImage(image_info,exception);
292 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
293 if (status == MagickFalse)
295 image=DestroyImageList(image);
296 return((Image *) NULL);
299 Initialize image header.
301 (void) ResetMagickMemory(&fits_info,0,sizeof(fits_info));
302 fits_info.extend=MagickFalse;
303 fits_info.simple=MagickFalse;
304 fits_info.bits_per_pixel=8;
308 fits_info.number_planes=1;
309 fits_info.min_data=0.0;
310 fits_info.max_data=0.0;
313 fits_info.endian=MSBEndian;
317 for (comment=(char *) NULL; EOFBlob(image) == MagickFalse; )
319 for ( ; EOFBlob(image) == MagickFalse; )
324 count=ReadBlob(image,8,(unsigned char *) keyword);
327 for (i=0; i < 8; i++)
329 if (isspace((int) ((unsigned char) keyword[i])) != 0)
331 keyword[i]=tolower((int) ((unsigned char) keyword[i]));
334 count=ReadBlob(image,72,(unsigned char *) value);
342 while (isspace((int) ((unsigned char) *p)) != 0)
345 if (LocaleCompare(keyword,"end") == 0)
347 if (LocaleCompare(keyword,"extend") == 0)
348 fits_info.extend=(*p == 'T') || (*p == 't') ? MagickTrue : MagickFalse;
349 if (LocaleCompare(keyword,"simple") == 0)
350 fits_info.simple=(*p == 'T') || (*p == 't') ? MagickTrue : MagickFalse;
351 if (LocaleCompare(keyword,"bitpix") == 0)
352 fits_info.bits_per_pixel=StringToLong(p);
353 if (LocaleCompare(keyword,"naxis") == 0)
354 fits_info.number_axes=StringToLong(p);
355 if (LocaleCompare(keyword,"naxis1") == 0)
356 fits_info.columns=StringToLong(p);
357 if (LocaleCompare(keyword,"naxis2") == 0)
358 fits_info.rows=StringToLong(p);
359 if (LocaleCompare(keyword,"naxis3") == 0)
360 fits_info.number_planes=StringToLong(p);
361 if (LocaleCompare(keyword,"datamax") == 0)
362 fits_info.max_data=StringToDouble(p,(char **) NULL);
363 if (LocaleCompare(keyword,"datamin") == 0)
364 fits_info.min_data=StringToDouble(p,(char **) NULL);
365 if (LocaleCompare(keyword,"bzero") == 0)
366 fits_info.zero=StringToDouble(p,(char **) NULL);
367 if (LocaleCompare(keyword,"bscale") == 0)
368 fits_info.scale=StringToDouble(p,(char **) NULL);
369 if (LocaleCompare(keyword,"comment") == 0)
371 if (comment == (char *) NULL)
372 comment=ConstantString(p);
374 (void) ConcatenateString(&comment,p);
376 if (LocaleCompare(keyword,"xendian") == 0)
378 if (LocaleNCompare(p,"big",3) == 0)
379 fits_info.endian=MSBEndian;
381 fits_info.endian=LSBEndian;
383 (void) FormatLocaleString(property,MaxTextExtent,"fits:%s",keyword);
384 (void) SetImageProperty(image,property,p,exception);
387 while (((TellBlob(image) % FITSBlocksize) != 0) && (c != EOF))
388 c=ReadBlobByte(image);
389 if (fits_info.extend == MagickFalse)
391 number_pixels=(MagickSizeType) fits_info.columns*fits_info.rows;
392 if ((fits_info.simple != MagickFalse) && (fits_info.number_axes >= 1) &&
393 (fits_info.number_axes <= 4) && (number_pixels != 0))
397 Verify that required image information is defined.
399 if (comment != (char *) NULL)
401 (void) SetImageProperty(image,"comment",comment,exception);
402 comment=DestroyString(comment);
404 if (EOFBlob(image) != MagickFalse)
405 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
407 number_pixels=(MagickSizeType) fits_info.columns*fits_info.rows;
408 if ((fits_info.simple == MagickFalse) || (fits_info.number_axes < 1) ||
409 (fits_info.number_axes > 4) || (number_pixels == 0))
410 ThrowReaderException(CorruptImageError,"ImageTypeNotSupported");
411 for (scene=0; scene < (ssize_t) fits_info.number_planes; scene++)
413 image->columns=(size_t) fits_info.columns;
414 image->rows=(size_t) fits_info.rows;
415 image->depth=(size_t) (fits_info.bits_per_pixel < 0 ? -1 : 1)*
416 fits_info.bits_per_pixel;
417 image->endian=fits_info.endian;
418 image->scene=(size_t) scene;
419 image->colorspace=GRAYColorspace;
420 if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
421 if (image->scene >= (image_info->scene+image_info->number_scenes-1))
424 Initialize image structure.
426 if ((fits_info.min_data != 0.0) || (fits_info.max_data != 0.0))
428 if ((fits_info.bits_per_pixel != 0) && (fits_info.max_data == 0.0))
429 fits_info.max_data=GetFITSPixelRange((size_t)
430 fits_info.bits_per_pixel);
433 GetFITSPixelExtrema(image,fits_info.bits_per_pixel,&fits_info.min_data,
434 &fits_info.max_data);
436 Convert FITS pixels to pixel packets.
438 scale=(double) QuantumRange/(fits_info.scale*(fits_info.max_data-
439 fits_info.min_data)+fits_info.zero);
440 for (y=(ssize_t) image->rows-1; y >= 0; y--)
442 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
443 if (q == (Quantum *) NULL)
445 for (x=0; x < (ssize_t) image->columns; x++)
447 pixel=GetFITSPixel(image,fits_info.bits_per_pixel);
448 SetPixelGray(image,ClampToQuantum(scale*(fits_info.scale*
449 (pixel-fits_info.min_data)+fits_info.zero)),q);
450 q+=GetPixelChannels(image);
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,exception);
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,
587 % Image *image,ExceptionInfo *exception)
589 % A description of each parameter follows.
591 % o image_info: the image info.
593 % o image: The image.
595 % o exception: return any errors or warnings in this structure.
598 static MagickBooleanType WriteFITSImage(const ImageInfo *image_info,
599 Image *image,ExceptionInfo *exception)
602 header[FITSBlocksize],
611 register const Quantum
626 Open output image file.
628 assert(image_info != (const ImageInfo *) NULL);
629 assert(image_info->signature == MagickSignature);
630 assert(image != (Image *) NULL);
631 assert(image->signature == MagickSignature);
632 if (image->debug != MagickFalse)
633 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
634 assert(exception != (ExceptionInfo *) NULL);
635 assert(exception->signature == MagickSignature);
636 status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
637 if (status == MagickFalse)
639 if (IssRGBColorspace(image->colorspace) == MagickFalse)
640 (void) TransformImageColorspace(image,sRGBColorspace,exception);
642 Allocate image memory.
644 fits_info=(char *) AcquireQuantumMemory(FITSBlocksize,sizeof(*fits_info));
645 if (fits_info == (char *) NULL)
646 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
647 (void) ResetMagickMemory(fits_info,' ',FITSBlocksize*sizeof(*fits_info));
649 Initialize image header.
651 image->depth=GetImageQuantumDepth(image,MagickFalse);
652 quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
653 if (quantum_info == (QuantumInfo *) NULL)
654 ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
656 (void) FormatLocaleString(header,FITSBlocksize,
658 (void) strncpy(fits_info+offset,header,strlen(header));
660 (void) FormatLocaleString(header,FITSBlocksize,"BITPIX = %10ld",
661 (long) (quantum_info->format == FloatingPointQuantumFormat ? -1 : 1)*
663 (void) strncpy(fits_info+offset,header,strlen(header));
665 (void) FormatLocaleString(header,FITSBlocksize,"NAXIS = %10lu",
666 IsImageGray(image,exception) != MagickFalse ? 2UL : 3UL);
667 (void) strncpy(fits_info+offset,header,strlen(header));
669 (void) FormatLocaleString(header,FITSBlocksize,"NAXIS1 = %10lu",
670 (unsigned long) image->columns);
671 (void) strncpy(fits_info+offset,header,strlen(header));
673 (void) FormatLocaleString(header,FITSBlocksize,"NAXIS2 = %10lu",
674 (unsigned long) image->rows);
675 (void) strncpy(fits_info+offset,header,strlen(header));
677 if (IsImageGray(image,exception) == MagickFalse)
679 (void) FormatLocaleString(header,FITSBlocksize,
680 "NAXIS3 = %10lu",3UL);
681 (void) strncpy(fits_info+offset,header,strlen(header));
684 (void) FormatLocaleString(header,FITSBlocksize,"BSCALE = %E",1.0);
685 (void) strncpy(fits_info+offset,header,strlen(header));
687 (void) FormatLocaleString(header,FITSBlocksize,"BZERO = %E",
688 image->depth > 8 ? GetFITSPixelRange(image->depth) : 0.0);
689 (void) strncpy(fits_info+offset,header,strlen(header));
691 (void) FormatLocaleString(header,FITSBlocksize,"DATAMAX = %E",
692 1.0*((MagickOffsetType) GetQuantumRange(image->depth)));
693 (void) strncpy(fits_info+offset,header,strlen(header));
695 (void) FormatLocaleString(header,FITSBlocksize,"DATAMIN = %E",0.0);
696 (void) strncpy(fits_info+offset,header,strlen(header));
698 if (image->endian == LSBEndian)
700 (void) FormatLocaleString(header,FITSBlocksize,"XENDIAN = 'SMALL'");
701 (void) strncpy(fits_info+offset,header,strlen(header));
704 (void) FormatLocaleString(header,FITSBlocksize,"HISTORY %.72s",
705 GetMagickVersion((size_t *) NULL));
706 (void) strncpy(fits_info+offset,header,strlen(header));
708 (void) strncpy(header,"END",FITSBlocksize);
709 (void) strncpy(fits_info+offset,header,strlen(header));
711 (void) WriteBlob(image,FITSBlocksize,(unsigned char *) fits_info);
713 Convert image to fits scale PseudoColor class.
715 pixels=GetQuantumPixels(quantum_info);
716 if (IsImageGray(image,exception) != MagickFalse)
718 length=GetQuantumExtent(image,quantum_info,GrayQuantum);
719 for (y=(ssize_t) image->rows-1; y >= 0; y--)
721 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
722 if (p == (const Quantum *) NULL)
724 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
725 GrayQuantum,pixels,exception);
726 if (image->depth == 16)
727 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
728 if (((image->depth == 32) || (image->depth == 64)) &&
729 (quantum_info->format != FloatingPointQuantumFormat))
730 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
731 count=WriteBlob(image,length,pixels);
732 if (count != (ssize_t) length)
734 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
736 if (status == MagickFalse)
742 length=GetQuantumExtent(image,quantum_info,RedQuantum);
743 for (y=(ssize_t) image->rows-1; y >= 0; y--)
745 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
746 if (p == (const Quantum *) NULL)
748 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
749 RedQuantum,pixels,exception);
750 if (image->depth == 16)
751 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
752 if (((image->depth == 32) || (image->depth == 64)) &&
753 (quantum_info->format != FloatingPointQuantumFormat))
754 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
755 count=WriteBlob(image,length,pixels);
756 if (count != (ssize_t) length)
758 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
760 if (status == MagickFalse)
763 length=GetQuantumExtent(image,quantum_info,GreenQuantum);
764 for (y=(ssize_t) image->rows-1; y >= 0; y--)
766 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
767 if (p == (const Quantum *) NULL)
769 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
770 GreenQuantum,pixels,exception);
771 if (image->depth == 16)
772 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
773 if (((image->depth == 32) || (image->depth == 64)) &&
774 (quantum_info->format != FloatingPointQuantumFormat))
775 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
776 count=WriteBlob(image,length,pixels);
777 if (count != (ssize_t) length)
779 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
781 if (status == MagickFalse)
784 length=GetQuantumExtent(image,quantum_info,BlueQuantum);
785 for (y=(ssize_t) image->rows-1; y >= 0; y--)
787 p=GetVirtualPixels(image,0,y,image->columns,1,exception);
788 if (p == (const Quantum *) NULL)
790 length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
791 BlueQuantum,pixels,exception);
792 if (image->depth == 16)
793 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
794 if (((image->depth == 32) || (image->depth == 64)) &&
795 (quantum_info->format != FloatingPointQuantumFormat))
796 SetFITSUnsignedPixels(image->columns,image->depth,pixels);
797 count=WriteBlob(image,length,pixels);
798 if (count != (ssize_t) length)
800 status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
802 if (status == MagickFalse)
806 quantum_info=DestroyQuantumInfo(quantum_info);
807 length=(size_t) (FITSBlocksize-TellBlob(image) % FITSBlocksize);
810 (void) ResetMagickMemory(fits_info,0,length*sizeof(*fits_info));
811 (void) WriteBlob(image,length,(unsigned char *) fits_info);
813 fits_info=DestroyString(fits_info);
814 (void) CloseBlob(image);