public Image scaleToFit(float fitWidth,float fitHeight){
  float horizontalScaling=fitWidth / xObject.getWidth();
  float verticalScaling=fitHeight / xObject.getHeight();
  return scale(Math.min(horizontalScaling,verticalScaling),Math.min(horizontalScaling,verticalScaling));
}

public Image scaleToFit ( float fitWidth , float fitHeight ) { float horizontalScaling = fitWidth / xObject . getWidth ( ) ; float verticalScaling = fitHeight / xObject . getHeight ( ) ; return scale ( Math . min ( horizontalScaling , verticalScaling ) , Math . min ( horizontalScaling , verticalScaling ) ) ; }
scale the image to an absolute size . this method will preserve the width - height ratio of the image .
