fix bug with keep_aspect_ratio