make canvas no larger than necessary