protected Rectangle getImageBounds(E img) {
if (img != null) {
PlanarImage source = getPreprocessedImage(img);
boolean nosquarePixel = MathUtil.isDifferent(img.getRescaleX(), img.getRescaleY());
int width = source == null || nosquarePixel
? img.getRescaleWidth(getImageSize(img, TagW.ImageWidth, TagW.get("Columns"))) : source.width();
int height = source == null || nosquarePixel
? img.getRescaleHeight(getImageSize(img, TagW.ImageHeight, TagW.get("Rows"))) : source.height();
return new Rectangle(0, 0, width, height);
}
return new Rectangle(0, 0, 512, 512);
}