Update canvasResize.js

further optimize detectSubsampling function