fix bugs, support image scaling