added support for width and height choosing image by best score