[Bugfix] Move file reading error checking closer to actual file read command

Previously, if (height > 0 && width > 0) was true, the
cv::resize() function would be called before cv_img_origin was
confirmed valid; if the image file/filename was not valid, this
caused an opencv assert error like this:

terminate called after throwing an instance of 'cv::Exception'
  what():  /tmp/A3p0_4200_32550/batserve/A3p0/glnxa64/OpenCV/modules/imgproc/src/imgwarp.cpp:1725: error: (-215)
  ssize.area() > 0 in function resize