Optimizes the resize operation.