fix #3757: NPE while downsampling image