Frontend: scanner: optimize the maximization of the scan area
(backport of 0411a70f454b24310aa0ee1f45d77922e9caa584)

Signed-off-by: Jerome Flesch <jflesch@gmail.com>