fixed crop_image function