Actually you don't need to determine image size for this specific code and keras will itself find out the input size based on input size of the whole network and previous layers.
But if you wish to know what is the input shape for the layer, after the first convolution layer the input shape will be (IMAGE_WIDTH - 4, IMAGE_HEIGHT - 4, 32) because you have 32 channels and used kernel size of 5. And after the pooling layer the height and width will be divided by two as you mentioned.
And the number of nodes in the dense layer can be determined arbitrarily.