code: func ScaledDimensions(w, h, mw, mh int) (newWidth int, newHeight int) {
  	if w == 0 || h == 0 || mw == 0 || mh == 0 {
  		imageDebug("ScaledDimensions was given as 0; returning 1x1 as dimensions.")
  		return 1, 1
  	}
  	newWidth, newHeight = mw, mh
  	if float32(h)/float32(mh) > float32(w)/float32(mw) {
  		newWidth = w * mh / h
  	} else {
  		newHeight = h * mw / w
  	}
  	return
  }
docs: // ScaledDimensions returns the newWidth and newHeight obtained
  // when an image of dimensions w x h has to be rescaled under
  // mw x mh, while conserving the proportions.
  // It returns 1,1 if any of the parameter is 0.