Removing objects while iterating through the same collection is a bad idea.
Please use a separate list for those images whose size is not zero.
Here’s an example where removing an object while iterating over the same list produces incorrect results:
>>> l = [str(i) for i in range(10)]
>>> import random
>>> random.shuffle(l)
>>> l
['6', '2', '4', '8', '9', '3', '7', '0', '1', '5']
>>> for item in l:
... if int(item) % 2 == 0:
... l.remove(item)
...
>>> l
['2', '8', '9', '3', '7', '1', '5']