Measuring For Your Bag
For a Round Container:
1) For circumference of the bag, multiply the width/diameter of the container by 3.14. Divide by 2 to get the flat width. Add two inches for a looser fit.
2) Add 1/2 of the diameter to the height of the container. Add 5 inches to this total for overhang. This is the total length of the bag needed.
3) If tying bag, add 1/2 the diameter to the bag length in #2.
For a square or Rectangular Container: 

1) Add the width and length of the sides. Add 2 inches for a looser fit. This total equals the flat width of the bag needed.
2) Add 1/2 of the shortest side to the height of the container. Add 5 inches to this value for overhang. This equals the length of the bag.
3) If tying the bag, rather than lining a box, and 1/2 length of the shortest side to the bag length in #2.