You reset imageCount
when it loops. pygame
doesn't switch to the other image because it's immediately replaced.
Also, you check if the current image exists, then try to move to the next without checking whether that exists.
Instead, try:
def main(imageCount=0): # allow override of start image
while True:
image_name = "IMG_{0}.jpg".format(imageCount)
...
if os.path.exists("IMG_{0}.jpg".format(imageCount+1)):
imageCount += 1