It's more complex than that I'm afraid. The opening is one thing, but volumetric analysis of the package is quite another. You might have a two foot by two foot door but you couldn't fit a lamppost in there cos it was too long for the compartment.
A better example would be a package for that door that was 18 inches square in cross section, but only say 30 inches long. Even if this was short enough to fit inside the compartment, you might be unable to get it inside because of the diagonal nature of its passage through the opening, not to mention that the compartment may have irregular sides.
So I think there'd be a lot of variables to consider to find the max and a better method would be to reverse the calculation and take a series of standard package sizes and empirically build a table of which cargo areas in which aircraft each package was acceptable.
Are you going to consider weight as well?