code: def conditional_resize(image, ratio, width=None, height=None, upcrop=True,
                         namespace="resized"):
      
      aspect = float(image.width) / float(image.height)
      crop = False
  
      if (aspect > ratio and upcrop) or (aspect <= ratio and not upcrop):
          crop = True
  
      return resize_lazy(image=image, width=width, height=height, crop=crop,
                         namespace=namespace, as_url=True)
docs: Crop the image based on a ratio
  
      If upcrop is true, crops the images that have a higher ratio than the given
      ratio, if false crops the images that have a lower ratio