update image resize logic