Jump to content

[SOLVED] Find All Black Images


fanfavorite

Recommended Posts

I was wondering if there is a function to be able to locate images that are all black.  I have almost 6000 images in a directory and don't want to have to go through each and every one to delete the ones that are all black.

 

Any ideas would be appreciated. 

 

Thanks,

 

-JC 

Link to comment
https://forums.phpfreaks.com/topic/105031-solved-find-all-black-images/
Share on other sites

theres a few ways to do it conceptually (all using GD):

a) open image, read each pixel, if one is diff to first (or not black) then it isn't all same (or black)

b) if it's not a true colour image then find the size of the palette using imagecolorstotal and if greater than 1 (and not black), then hey presto

c) if a true colour image, read into memory, convert to palette image with imagetruecolortopalette, then as (b).

*) there's probably others but there's enough to get on with...

 

 

Update: First link now works...

I would have thought that any image that was all one colour would be a very small file compared to images with multiple colours.

 

I'd suggest using the glob() function to generate the array and looking at filesizes less than a few kb ought to quickly show the 'black' images.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.