def minify_image(data, minify_to=(1200, 1600), preserve_aspect_ratio=True):
 img = _data_to_image(data)
 (owidth, oheight) = img.size
 (nwidth, nheight) = minify_to
 if ((owidth <= nwidth) and (oheight <= nheight)):
  return img
 if preserve_aspect_ratio:
  (scaled, nwidth, nheight) = fit_image(owidth, oheight, nwidth, nheight)
 img.size = (nwidth, nheight)
 return img

def minify_image ( data , minify_to = ( 1200 , 1600 ) , preserve_aspect_ratio = True ) : img = _data_to_image ( data ) ( owidth , oheight ) = img . size ( nwidth , nheight ) = minify_to if ( ( owidth <= nwidth ) and ( oheight <= nheight ) ) : return img if preserve_aspect_ratio : ( scaled , nwidth , nheight ) = fit_image ( owidth , oheight , nwidth , nheight ) img . size = ( nwidth , nheight ) return img
minify image to specified size if image is bigger than specified size and return minified image .