Testing a blank image

Hello!
So in my project I need a way to test whether an image is blank or not. I tried this and it didn’t work.

function setup()
    img = image(50,50)
    if img == image(50,50) then print("BANG") end
end

function draw()
    
end

Is there an easy way to do this, or do I need to check every pixel to make sure it is empty?
Thanks!

What do you consider a blank image. All white, all black or some other color. If you want to check if the image is all the same color, black, white, or what ever, then you would have to check every pixel to be 100% sure. As far as I know, there isn’t a quick way to check for a blank image. What size image are you checking.

I mean blank as in the alpha values of all pixels are 0. I need to check up to 100 images that are each 128x128

You have to check every pixel to be sure

Or you could check (say) every 16th pixel, then that’s only 64 checks per image

As far as I know, to be 100% sure, you’ll need to check each pixel’s alpha value. I tried it on a 128x128 image and it was instantaneous.

OK, that’s good to know. Thanks @Ignatz @dave1707

@Dwins I don’t know where your images are, but you might be able to do something like this. Put the image names in a table and it will print the image name and if it’s blank or not.

function setup()
    tab={"Planet Cute:Character Horn Girl","Planet Cute:Character Pink Girl"}
    for z=1,#tab do
        print(tab[z])
        img=readImage(tab[z])
        checkImage()
    end
end

function checkImage()
    w=img.width
    h=img.height
    n=0
    for x=1,w do
        for y=1,h do
            r,g,b,a=img:get(x,y)
            n=n+a
        end
    end
    if n~=0 then
        print("image isn't blank")
    else
        print("image is blank")
    end
end

Thanks @dave1707 that looks pretty close to what I wrote. I guess since there isn’t a great way to optimize it I’ll just put up with waiting a few seconds