image transform with python Pillow library

without border and resize by range ratio.