Refactored ImagePanel to remove a duplication of image size calculations.