I want pgfplot add a grid with absolute coordinate automatically, for example, below image original pdf is 1.17x1.19in, so I want x is (0,1.17in) and y is (0,1.19in).
Now I hardcode it to Nx/Ny, can we do it by detect the image file automatically, then I no need to change it if image changed.
After update according to reply, it works fine now.
The MWE now is:
\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\begin{document}
\def\imgfilename{tiger}
\def\u{72.26999} % 28.4526 -> pt to cm; 72.26999 -> pt to inch
\newbox\tempfig \newlength\tempwidth \newlength\tempheight
\setbox\tempfig=\hbox{{\includegraphics{\imgfilename}}}
\tempwidth\wd\tempfig \tempheight\ht\tempfig
\pgfmathparse{\tempwidth/\u} \pgfmathsetmacro\Nx{\pgfmathresult}
\pgfmathparse{\tempheight/\u} \pgfmathsetmacro\Ny{\pgfmathresult}
\begin{tikzpicture}
\begin{axis}[
grid=both,minor tick num=2,major grid style={gray!80},
width=10cm,
scale only axis,
enlargelimits=false,
axis on top]
\addplot graphics [xmin=0,xmax=\Nx,ymin=0,ymax=\Ny,
includegraphics={},
] {\imgfilename};
\end{axis}
\draw(current bounding box.north east)node[above left]{$(\Nx\times\Ny\ in)$};
\end{tikzpicture}
\end{document}
The output is:

Original tiger.png is:

