Page 1 of 1
TIFF format change
Posted: 2018-08-16T10:58:19-07:00
by SecondMet
Hi!
Up to now I was using an older version of Image Magick (5.2.3), to convert BMP files to TIFF format using the commandline tool "mogrify".
I then took the TIFF images plus a metadata file to convert them to GeoTIFF format using the tool geotifcp.
Lately I updated the Image Magick version to 7.0.4. Since then the GeoTIFF conversion tool can no longer process the TIFFs then come out of the mogrify command.
With a TIFF header viewer I found, that the TIFF output of mogrify from version 5.2.3 differs to the one of 7.0.4.
I found a few options to the mogrify command like e.g.:
mogrify -define tiff:rows-per-strip=2 -type Palette -format tiff raw_image.bmp
But still the output makes geotifcp crash. I am not sure why exactly it crashes, but I see from the TIFF header that some items are only available in the TIFF created with version 7.0.4 like: XResolution, YResolution, ResolutionUnit, PageNumber, WhitePoint and PrimaryChormaticities.
I haven't figured out, what exactly leads to the problem, but is there perhaps a way to create TIFF files using a recent version of Image Magick instead of using version 5.2.3?
Cheers,
Carsten
Re: TIFF format change
Posted: 2018-08-16T11:57:13-07:00
by fmw42
Imagemagick 5.2.3 is so ancient it is likely that there have been much changes between that and IM 6 and even more to IM 7. In Imagemagick 7, you must preface mogrify with magick. Also convert is simply replace by magick. See
http://imagemagick.org/script/porting.php#cli
I recommend that you use magick rather than mogrify to process one image at a time. There are also new tiff defines. See
https://www.imagemagick.org/script/comm ... php#define
Most likely the issue is your version of libtiff from your IM 5.x version to your IM 7.x version.
Perhaps you should post an output TIFF from your IM 5 system and the same output from your IM 7 system. You can post to some free hosting service such as dropbox.com that will not alter your uploaded image or zip them. Then put the URLs here. This forum does not allow direct uploads.
Are you getting any error messages from your geotiff tool that might help.
Here are some links to IM 6 commands that might help. IM 7 is similar with the exception of using magick in place of convert and magick mogrify in place of just mogrify.
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
You could inquire of the geotiff tool provider what version of libtiff with which it might be compatible. Or any other requirements or restrictions.
Re: TIFF format change
Posted: 2018-08-16T23:15:55-07:00
by SecondMet
Okay, I will prepare some images and upload them. The GeoTIFF tool unfortunately does not report anything. Simply crashes without any output.
Thanks for the advice so far.
Re: TIFF format change
Posted: 2018-08-17T11:42:50-07:00
by SecondMet
I finally uploaded 2 files. They are not completely identical, basically they are created with the same routines. The main difference here is the headers. At this moment, I don't have access to the image data, otherwise I can (perhaps next Monday) supply images with identical content.
But since my problems is rather the TIFF format not so much the actual image content, I guess this difference should not matter.
https://www.dropbox.com/s/9kjhrc9yov3ni ... t.tif?dl=0
https://www.dropbox.com/s/tqpfhe6pob8xl ... 2.tif?dl=0
Re: TIFF format change
Posted: 2018-08-17T14:20:54-07:00
by fmw42
Please clarify which files are which. Which one is good and which one is bad?
At first Imagemagick could not read your second file with .convert.tif. It objected to the word "convert" in the name with periods.
201801170921_MSG3_GEOTIFFTEST2.tif.convert.tif
So I change it to
201801170921_MSG3_GEOTIFFTEST2_tif_convert.tif
Once I could use identify -verbose on the two files, the main issue is that the first file (without the convert in the name) is Class=Pseudoclass, Type=palette (8-bit color) but not perfectly gray and the second file is Class=Truecolor, Type=Grayscale (8-bit grayscale).
So you have two issues. Once is the class and the other is the type.
If we assume you want to make the second one the same as the first, then add -type palette to your command, but use convert rather than mogrify, since convert is more flexible and allows more features and operators and settings.
Code: Select all
convert input.bmp ... -type palette output.tif
If on IM 7, then
Code: Select all
magick input.bmp ... -type palette output.tif
See if that helps.
Re: TIFF format change
Posted: 2018-08-18T05:27:05-07:00
by SecondMet
The second one is acutally the "good" one. It should contain a tag "Software=" with the version number 5.2.3.: 201808161124_MSG4_GEOTIFFTEST2.tif
I will try to use your recommendations and see if that helps!
Re: TIFF format change
Posted: 2018-08-18T09:55:42-07:00
by fmw42
The image without .tif.convert.tif is the one that has the tag "tiff:software: @(#)ImageMagick 5.2.3 00/09/01 Q:8
cristy@mystic.es.dupont.com" and is of
Class: PseudoClass
Geometry: 3712x3712+0+0
Units: PixelsPerInch
Colorspace: sRGB
Type: Palette
The file with .tif.convert.tif has the tag " Version: ImageMagick 6.9.10-10 Q16 x86_64 2018-08-14
https://www.imagemagick.org" and is of
Class: DirectClass
Geometry: 3712x3712+0+0
Resolution: 29.53x29.53
Print size: 125.703x125.703
Units: PixelsPerCentimeter
Colorspace: Gray
Type: Grayscale
So my suggestion above to add -type palette should make your bmp convert to tiff with Class: PseudoClass and Type: Palette
Re: TIFF format change
Posted: 2018-08-20T00:58:13-07:00
by SecondMet
I tried with:
convert -compress None -type Palette -define tiff:rows-per-strip=2 .\testimage.bmp .\testimage.tif
But the resulting TIFF still cannot be read by the GeoTIFF converter. The only difference in the header after this seems to be the tags for the X and YResolution and the ResolutionUnit and these "PageNumber", "WhitePoint" and "PrimaryChromaticities". But I could find any options to avoid these in the conversion from BMP to TIFF.
Perhaps I'll have to try and read the code of the GeoTIFF conversion tool to see at which point it fails.
Re: TIFF format change
Posted: 2018-08-20T09:35:06-07:00
by fmw42
Proper IM 6 syntax would be to read the input first. Try this:
Code: Select all
convert .\testimage.bmp -compress None -type Palette -define tiff:rows-per-strip=2 .\testimage.tif
Does that work?