Jump to content

how to count colors on handle ?


madrazel

Recommended Posts

$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 ?
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.