2levelsabove Posted April 14, 2008 Share Posted April 14, 2008 I am using GD 2.0 and Imagemagick. Anyone know how to detect whether uploaded image is color or black and white ? I have asked this question on numerous places but no answers ever. thanks Link to comment https://forums.phpfreaks.com/topic/101091-is-this-even-possible-to-detect-if-uploaded-image-is-bw-or-color/ Share on other sites More sharing options...
papaface Posted April 14, 2008 Share Posted April 14, 2008 http://uk2.php.net/manual/en/function.imagecreatefromgif.php#70280 Should help Link to comment https://forums.phpfreaks.com/topic/101091-is-this-even-possible-to-detect-if-uploaded-image-is-bw-or-color/#findComment-517007 Share on other sites More sharing options...
obsidian Posted April 14, 2008 Share Posted April 14, 2008 Since images don't have a specific heading or flag accessible within PHP as to whether or not they are color or B/W, you could quickly scan the image pixel by pixel and gather all the colors used within the image. You would then be able to parse the list and see if anything besides gray scale was used... Check the imagecolorat() function to see how to read the individual pixel colors. Hope this helps point you to a viable solution. Link to comment https://forums.phpfreaks.com/topic/101091-is-this-even-possible-to-detect-if-uploaded-image-is-bw-or-color/#findComment-517008 Share on other sites More sharing options...
2levelsabove Posted April 14, 2008 Author Share Posted April 14, 2008 Thanks so much. I will take a look at it and post the results here Link to comment https://forums.phpfreaks.com/topic/101091-is-this-even-possible-to-detect-if-uploaded-image-is-bw-or-color/#findComment-517017 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.