Jump to content


Photo

how to count colors on handle ?


  • Please log in to reply
1 reply to this topic

#1 madrazel

madrazel
  • Members
  • PipPip
  • Member
  • 20 posts

Posted 30 October 2006 - 05:26 PM

$whatever = imagecreatefrompng('somefile.png');

now i want to know how many colors are actually in this file, not how many colors is this format capable to contain, like truecolor etc... not this

in my script i use program to make some png images from command line (a full-length rendering of a html page to png), but this program has very annoying bug that it sometimest returns a blank image, so i want to track somehow these images having only one fill color

how to do this ? many graphical programs have this function ?

#2 Psycho

Psycho
  • Moderators
  • Move along, nothing to see here
  • 11,892 posts
  • LocationCanada

Posted 30 October 2006 - 05:42 PM

The image files themselves don't contain that data explicitly. You would need to find a way to examine each pixel and build the data. I'm not sure about PNG, but with something like jpeg that may not be even possible because of the way the data is stored there is no individual pixel assignments. Even if all of this is possible, it would be a huge resource hog.

I would suggest you use the size (data size not dimensions) as a way of determining if the image is blank or not. That would be very easy to determine.
The quality of the responses received is directly proportional to the quality of the question asked.

I do not always test the code I provide, so there may be some syntax errors. In 99% of all cases I found the solution to your problem here: http://www.php.net




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users