Re: [PHP] How to PHP get bit depth of a given PNG image file?

2011-06-16 Thread Mattias Thorslund

On 06/15/2011 10:11 PM, Nam Gi VU wrote:

  Hi everyone,

In PHP code, given an .png image path, I need to detect the bit-depth of
that image. How can I do that?

I've tried to use getImageSize() and read the bits as below sample code but
it always returns '8' for 24-bits/32-bits image.


Reading the manual, it says:


channels will be 3 for RGB pictures and 4 for CMYK pictures.
bits is the number of bits for each color.


So, to get the total bit depth, I think you need to multiply by the 
number of colors, which is in the channels element.


Cheers,

Mattias


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to PHP get bit depth of a given PNG image file?

2011-06-16 Thread Nam Gi VU
Thank you Mattias,

I'll look at `channels` again.

Regards,
Nam



On Thu, Jun 16, 2011 at 1:06 PM, Mattias Thorslund matt...@thorslund.uswrote:

 On 06/15/2011 10:11 PM, Nam Gi VU wrote:

  Hi everyone,

 In PHP code, given an .png image path, I need to detect the bit-depth of
 that image. How can I do that?

 I've tried to use getImageSize() and read the bits as below sample code
 but
 it always returns '8' for 24-bits/32-bits image.


 Reading the manual, it says:

 
 channels will be 3 for RGB pictures and 4 for CMYK pictures.
 bits is the number of bits for each color.
 

 So, to get the total bit depth, I think you need to multiply by the number
 of colors, which is in the channels element.

 Cheers,

 Mattias


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How to PHP get bit depth of a given PNG image file?

2011-06-16 Thread Mattias Thorslund
I think the documentation is a bit unclear about the fact that colors 
and channels are the same thing here. The line about bits should 
probably say bits is the number of bits for each *channel*.


Mattias

On 06/15/2011 11:11 PM, Nam Gi VU wrote:

Thank you Mattias,

I'll look at `channels` again.

Regards,
Nam



On Thu, Jun 16, 2011 at 1:06 PM, Mattias Thorslundmatt...@thorslund.uswrote:


On 06/15/2011 10:11 PM, Nam Gi VU wrote:


  Hi everyone,

In PHP code, given an .png image path, I need to detect the bit-depth of
that image. How can I do that?

I've tried to use getImageSize() and read the bits as below sample code
but
it always returns '8' for 24-bits/32-bits image.


Reading the manual, it says:


channels will be 3 for RGB pictures and 4 for CMYK pictures.
bits is the number of bits for each color.


So, to get the total bit depth, I think you need to multiply by the number
of colors, which is in the channels element.

Cheers,

Mattias


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to PHP get bit depth of a given PNG image file?

2011-06-15 Thread Nam Gi VU
 Hi everyone,

In PHP code, given an .png image path, I need to detect the bit-depth of
that image. How can I do that?

I've tried to use getImageSize() and read the bits as below sample code but
it always returns '8' for 24-bits/32-bits image.

Please help.

class Utils {
//Ham de lay bits cua image

public static function getBits($image) {

$info = getImageSize($image);
return $info['bits'];


}
}

Hope to hear from all of you!
Regards,
Nam.

p.s I also post this issue on stackoverflow.com which is
herehttp://stackoverflow.com/questions/6355692/how-to-php-get-bit-depth-of-a-given-png-image-file
.