Rewrite image scaling