Page 1 of 1
Multiple Alpha Channels
Posted: 2008-11-26T14:20:07-07:00
by Quatar
Hey guys, I have some tif files which contain multiple alpha channels.
The results of converting these files is a garbled mess. I've tried several command line options, and can't seem to get a clean converted file.
I am using ImageMagick 6.4.4 Q8 on Windows.
From my investigation on these forums, it seems that ImageMagick doesn't support images with multiple alpha channels. Is that true? Will it be supported in the near future? Or am I just using the wrong options?
Fundamentally, I want to convert a tif file (containing many layers, and two alpha channels) to a 512x512 jpg. If I remove the alpha channel layers of the tif file, leaving only 1 (or 0) the conversion is fine. Is it possible to convert and ignore ALL alpha channels?
Thanks in advance.
Re: Multiple Alpha Channels
Posted: 2008-11-26T17:11:48-07:00
by magick
Currently we look for an alpha channel as a TIFF tag of TIFFTAG_EXTRASAMPLES and look for EXTRASAMPLE_UNASSALPHA or EXTRASAMPLE_ASSOCALPHA. It would be simple enough to scan all the extra channels looking for these tags. Can you post a URL to one or two of your images so we can download and inspect them and see if we can support them.
Re: Multiple Alpha Channels
Posted: 2008-11-27T08:29:29-07:00
by Quatar
I've generated a sample file which express the problem.
There is a 3 meg zip file at the link below:
<link removed>
There are two files in the zip:
small_two_alpha.tif - contains two alpha channels, coverting produces a garbled file.
small_one_alpha.tif - contains a single alpha channel (all I did was remove one from the above file, the rest of the file is identical), and converts properly using ImageMagick.
Any help will be greatly appreciated!
Thanks again.
Re: Multiple Alpha Channels
Posted: 2008-11-27T08:58:19-07:00
by magick
Thanks for the TIF examples. We will have a patch for this problem in the Subversion trunk by sometime tomorrow.
Re: Multiple Alpha Channels
Posted: 2008-11-27T09:09:29-07:00
by Quatar
That would be great! Let me know how it goes.
Re: Multiple Alpha Channels
Posted: 2008-11-27T16:58:43-07:00
by magick
The problem you reported is fixed and will be available tomorrow as ImageMagick 6.4.6-5.
Re: Multiple Alpha Channels
Posted: 2008-11-28T09:28:01-07:00
by Quatar
I'll give it a test, once the version is up for download.
Thank you again.
Re: Multiple Alpha Channels
Posted: 2008-12-01T12:21:08-07:00
by Quatar
I've downloaded 6.4.6-7 and tested, the file I sent you does indeed work! And so do the other samples I have with 2 alpha channels. Thanks!
However, I have other files which have more than 2 alpha channels which still do not work. Is it possible to apply the same fix for 'n' alpha channels, instead of just 2?
Here is a sample which contains 4 alpha channels, and doesn't work, even in the current version.
http://74.54.133.162:3190/fouralphas.zip
Thanks again for all your time and effort!
Re: Multiple Alpha Channels
Posted: 2008-12-01T13:35:26-07:00
by magick
Doh!. Needed to fix the parenthesis in the math expression for the TIFF scanline pad. Look for a fix tomorrow in ImageMagick 6.4.6-8. Thanks for alerting us to the problem.
Re: Multiple Alpha Channels
Posted: 2008-12-02T09:10:55-07:00
by Quatar
I've just downloaded 6.4.6-8 Q8 and unfortunately it seems that the sample I've linked in the above post, with 4 alpha channels, still doesn't work.
Is it possible I didn't get the correct version?
Re: Multiple Alpha Channels
Posted: 2008-12-02T09:48:09-07:00
by magick
Hmmm... 6.4.6-8 works for us with your image. Check coders/tiff.c and ensure SetQuantumPad() looks like this:
- status=SetQuantumPad(image,quantum_info,pad*((bits_per_sample+7) >> 3));
Notice the proper placement of the parenthesis. Also make sure
has 6,4,6,8 associated with the LIB_VERSION_NUMBER tag.
Re: Multiple Alpha Channels
Posted: 2008-12-02T09:55:36-07:00
by Quatar
Haha, yes, LIB_VERSION_NUMBER is 6,4,6,6
And I downloaded: ImageMagick-6.4.6-8-Q8-windows-static.exe
I'll try downloading it again.
Re: Multiple Alpha Channels
Posted: 2008-12-02T10:24:55-07:00
by magick
Stop the presses. The source is 6.4.6-8 but not the Windows binaries. We will update the Windows binaries later today.
Re: Multiple Alpha Channels
Posted: 2008-12-03T10:33:59-07:00
by Quatar
I've downloaded 6.4.6-9 binaries and it works for the four alpha sample! Thanks again for your effort!
I'm compiling the source now, to integrate into my application.