Add auto image resize function