fix resize image logic