used resize_to_fit instead of resize if width and height are specified