Bug 451354 - added automatic size calculation to ImagePainter