Multiple Alpha Channels

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Quatar

Multiple Alpha Channels

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multiple Alpha Channels

Post 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.
Quatar

Re: Multiple Alpha Channels

Post 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.
Last edited by Quatar on 2008-12-01T13:44:14-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multiple Alpha Channels

Post by magick »

Thanks for the TIF examples. We will have a patch for this problem in the Subversion trunk by sometime tomorrow.
Quatar

Re: Multiple Alpha Channels

Post by Quatar »

That would be great! Let me know how it goes.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multiple Alpha Channels

Post by magick »

The problem you reported is fixed and will be available tomorrow as ImageMagick 6.4.6-5.
Quatar

Re: Multiple Alpha Channels

Post by Quatar »

I'll give it a test, once the version is up for download.

Thank you again.
Quatar

Re: Multiple Alpha Channels

Post 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!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multiple Alpha Channels

Post 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.
Quatar

Re: Multiple Alpha Channels

Post 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?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multiple Alpha Channels

Post 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
  • convert -list configure
has 6,4,6,8 associated with the LIB_VERSION_NUMBER tag.
Quatar

Re: Multiple Alpha Channels

Post 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.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Multiple Alpha Channels

Post 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.
Quatar

Re: Multiple Alpha Channels

Post 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.
Post Reply