FITS BZERO incorrect header value

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Gajowy
Posts: 4
Joined: 2018-11-24T06:16:08-07:00
Authentication code: 1152

FITS BZERO incorrect header value

Post by Gajowy »

Hi,
I'm using Imagick library for PHP (ImageMagick 6.9.3-7 Q16 x64 2016-03-27).
I noticed that FITS files saved by the library have a BZERO key value set to 32767.5, while the true value is 32768 (comparing raw bytes and FITS bytes).
According to convention:
true_value = BZERO + BSCALE x array_value
BSCALE is usually 1, so it's even impossible to express true integer value with a offset of 32767.5.
Do you know how to workaround this issue? I could replace header values simply replacing it with 32768, however I have no idea how it would impact further internal image calculations (substarcting, composite etc).

Kind Regards,
Gajowy
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: FITS BZERO incorrect header value

Post by magick »

Try the latest release of ImageMagick, 6.9.10-14. It will likely resolve the problem. If not, let us know and we will investigate further.
Gajowy
Posts: 4
Joined: 2018-11-24T06:16:08-07:00
Authentication code: 1152

Re: FITS BZERO incorrect header value

Post by Gajowy »

It's exactly the same:

SIMPLE = T
BITPIX = 16
NAXIS = 2
NAXIS1 = 1936
NAXIS2 = 1096
BSCALE = 1
BZERO = 32767.5
DATAMAX = 65535
DATAMIN = 0
HISTORY e:\Program Files\ImageMagick-6.9.10-Q16\\index.html
END

Kindly ask for solution.
Regards,
Gajowy
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: FITS BZERO incorrect header value

Post by magick »

Can you post a link to a sample image and the command you use to return a FITS file with a BZERO of 32767.5? Once we can reproduce the problem, we will have a fix within just a few days.
Gajowy
Posts: 4
Joined: 2018-11-24T06:16:08-07:00
Authentication code: 1152

Re: FITS BZERO incorrect header value

Post by Gajowy »

Simplest code below. You can use any input file, eg. the one from Imagick set.

Code: Select all

<?php
$im= new Imagick('rose.png');
$im->setFormat('FITS');
$im->setImageDepth(16);
$im->writeImage('rose.fit');
$im->destroy();
?>
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: FITS BZERO incorrect header value

Post by magick »

Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ https://www.imagemagick.org/download/beta/ by sometime tomorrow.
Gajowy
Posts: 4
Joined: 2018-11-24T06:16:08-07:00
Authentication code: 1152

Re: FITS BZERO incorrect header value

Post by Gajowy »

Thank you in advance!

Gajowy
Post Reply