Well, I would count the colors in the image. If there is only one, the image will be blank. I donβt know enough Python or qt to write code for this, but Iβm sure there is a library that can tell you how many colors are in the image (Iβm going to learn how to use ImageMagick for this right after publication).
Update: Here is the Perl (apology) code to do this using Image :: Magic . You should be able to convert it to Python using Python bindings .
Clearly this only works for palette-based images.
#!/usr/bin/perl use strict; use warnings; use Image::Magick; die "Call with image file name\n" unless @ARGV == 1; my ($file) = @ARGV; my $image = Image::Magick->new; my $result = $image->Read( $file ); die "$result" if "$result"; my $colors = $image->Get('colors'); my %unique_colors; for ( my $i = 0; $i < $colors; ++$i ) { $unique_colors{ $image->Get("colormap[$i]") } = undef; } print "'$file' is blank\n" if keys %unique_colors == 1; __END__
source share