title: Resize Image without losing quality
body: <p>I'm using the functions below to resize my images width &amp; height but I noticed that it ruins the image quality.</p>
  
  <pre><code>class func imageWithSize(image: UIImage,size: CGSize)-&gt;UIImage{
      if UIScreen.mainScreen().respondsToSelector("scale"){
          UIGraphicsBeginImageContextWithOptions(size,false,UIScreen.mainScreen().scale);
      }
      else
      {
          UIGraphicsBeginImageContext(size);
      }
  
      image.drawInRect(CGRectMake(0, 0, size.width, size.height));
      var newImage = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
  
      return newImage;
  }
  
  class func resizeImageWithAspect(image: UIImage,scaledToMaxWidth width:CGFloat,maxHeight height :CGFloat)-&gt;UIImage
  {
  
  
      let scaleFactor =  width / height;
  
  
      let newSize = CGSizeMake(width, height);
  
      return imageWithSize(image, size: newSize);
  }
  </code></pre>
  
  <p>Is there another way to resize images without ruining the quality? Or how can I fix my functions below so it doesn't ruin the image quality after resizing?</p>