The size of the image is retrieved with gimp-image-{width,height} instead of gimp-drawable-{width,height} which fails if the image has a selection.