Page 1 of 1

Problems with TIFF formats on Mac OSX.

Posted: 2009-11-08T11:56:55-07:00
by ian313665
I've been discussing some techniques in a different thread and come across some strange results when using TIFF format on Mac OSX.

Code: Select all

Version: ImageMagick 6.5.7-0 2009-11-07 Q16
Tagged Image File Format (LIBTIFF, Version 3.9.1)
Firstly I need to state that I'm not very good at installing and using command-line software. I use MacPorts to simplify the installation process and I don't have the knowledge to investigate this issue any further than stated below.

This command produces a grayscale image:

Code: Select all

convert -colorspace RGB label:'This is a test' cstest.tiff
I apologise in advance if I'm wrong here but I'm sure that the '-colorspace RGB' switch would force the image to be RGB 24/32 bit? The result is grayscale format. Here is the file for reference. (http://www.asura.co.uk/cstest.tiff)

I was obtaining some help in a different thread with this command. I was looping through ASCII characters and using ImageMagick to write out separate files containing each character for some OpenGL font rendering. The aim here is to render an anti-aliased character into the alpha channel and have the RGB fully white.

Code: Select all

convert \( -background black -fill white -pointsize 50 label:A \) \
\( +clone -threshold -1 \) \
-alpha off +swap -compose copy_opacity -composite font.65.tiff
When I use this command, the RGB fill is black instead of white, the format is grayscale and the alpha channel does not have an smooth blend at the font edges. There are also streaky lines in the alpha channel.

If you substitute the '.tiff' for '.tga' then the results are correct for the TGA version.

http://www.asura.co.uk/font.65.tiff (incorrect version using TIFF)
http://www.asura.co.uk/font.65.tga (correct version using TGA)

I hope this helps. Thanks.

Re: Problems with TIFF formats on Mac OSX.

Posted: 2009-11-08T14:39:55-07:00
by fmw42
-colorspace RGB will not help. You have not specified any color for the text, so it will be black and white (binary image).

Use

identify -verbose yourimage.tif

to see that it is colorspace RGB, but a bilevel type with 1-bit per channel grayscale and 1-bit per alpha

The example I provided for you to put the character A in the alpha channel works as you asked to make a white character on a transparent background if you use PNG.

for tiff try this

convert \( -background black -fill white -pointsize 50 label:A -alpha off \) \
\( +clone -threshold -1 \) \
-alpha off +swap -compose copy_opacity -composite -depth 8 font.65.tiff

or as png (without the -depth 8)

convert \( -background black -fill white -pointsize 50 label:A -alpha off \) \
\( +clone -threshold -1 \) \
-alpha off +swap -compose copy_opacity -composite font.65.png

Tiff is strange and has a lot of special arguments and different interpretations. Don't recommend using it.

see http://www.imagemagick.org/Usage/formats/#tiff

If you don't care what the transparent background color is, that is if it can be black rather than white, then this is simpler:

convert -background black -fill white -pointsize 50 label:A -alpha off \
-density 8 -alpha copy font.65.tiff

Re: Problems with TIFF formats on Mac OSX.

Posted: 2009-11-09T19:26:24-07:00
by ian313665
Hi, thanks for the information.

I'm still having trouble rendering a character to a TIFF in RGBA 32bit (8 bits per channel).

It still seems a little strange that trying BMP, TGA, PNG produce the results I expect & TIFF seems to be the odd one out. I read the information about the TIFF format being a little bloated with variations so my apologies if this isn't an actual 'bug'.

Unfortunately, I'm stuck using TIFF format because of various reasons within my processing tools.

Re: Problems with TIFF formats on Mac OSX.

Posted: 2009-11-09T20:02:34-07:00
by fmw42
this should work according to the Examples page on Tiff, but does not. Seems like tiff wants to enforce the bilevel graylevel type for the background white image.

convert \( -background black -fill white -pointsize 50 label:A -alpha off \) \
\( +clone -threshold -1 \) \
-alpha off +swap -compose copy_opacity -composite -depth 8 -type truecolormatte font.65.tiff

even this simple command does not get 8 bit truecolor, only bilevel for a constant white image.

convert -size 10x10 xc:black -depth 8 -type truecolor tmp4.tiff

perhaps a bug?

Re: Problems with TIFF formats on Mac OSX.

Posted: 2009-11-10T04:01:19-07:00
by ian313665
convert \( -background black -fill white -pointsize 50 label:A -alpha off \) \
\( +clone -threshold -1 \) \
-alpha off +swap -compose copy_opacity -composite -depth 8 -type truecolormatte font.65.tiff
I've just tested this on Windows XP and it seems to produce the results I want.

Is the problem on Mac only?