Hi all,

This is my first message here.

I would like to know how many channels an image has.

The image may be a BMP, JPEG, PNG, or any number of other formats (but these are the most common).
The image might also have an ALPHA channel.
The image might be compressed (like in PNG - you can decide how compressed you want the image to be).

At first I used the "getimagesize" function to retreive the number of channels,
but I realised :
1. It some times returns 0.
2. In images with an ALPHA channel - it doesn't count that channel.

Does anyone here have a solution for me please ?

    stolzyboy wrote:

    have you looked at any of the GD function?

    First of all - thanks for the reply.
    Second of all - Yes, I have lookd at the GD library ...

    I've read dozens of threads looking for an answer,
    but I just can't seem to find one.

    All I want to know is if a certain image has an ALPHA channel or not...

    please someone help me !

      stolzyboy wrote:

      can you use this: http://us2.php.net/manual/en/function.imagecolorsforindex.php

      it'll show you if there is alpha, 0 for none, ?

      Well, I've checked the function - and the problem is - it returns 0 of the ALPHA level in a specific pixel is zero.
      I don't want to go over all the pixels in the image to find out if it has alpha or not.
      If the image does not have an ALPHA channel - all the pixels will return 0.
      Do you understand the problem ?

        yes, i understand the issue, however i see no easy solution, other than looping through all available pixels and checking alpha, if all 0, then image has no alpha channel... i've done no testing and i'm not sure how "heavy" this would be to process, but i'm unsure what other routes you may have, at this point anyway

          stolzyboy wrote:

          yes, i understand the issue, however i see no easy solution, other than looping through all available pixels and checking alpha, if all 0, then image has no alpha channel... i've done no testing and i'm not sure how "heavy" this would be to process, but i'm unsure what other routes you may have, at this point anyway

          Thanks for you kind help.
          I hope someone here would be able to find me a better solution !

            Write a Reply...