Optimize dpi determination