Fix image size detection