Implemented file length detection and automatic PNG dimension calculation.