I want to draw on an image which I embedded using \includeimage:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics{example-image}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\draw[color=red] (0,0) rectangle (1,1);
\end{scope}
\end{tikzpicture}
\end{document}
Let's say the image has a size of 800x600 pixels. The problem here is that x and y scale between 0 and 1 in width and height. I would like to draw on the image using it's pixels as a coordinate reference, in a way that
\draw[color=red] (0,0) rectangle (1,1);
can be replaced by
\draw[color=red] (0,0) rectangle (800,600);
My problem now is to scale the x and y in the scope. I thought the following statement would work:
\begin{scope}[x={($(image.south east)/800$)},y={($(image.north west)/600$)}]
but it throws the following error:
Package tikz Error: + or - expected.
I looked up chapter 13.5 in the TikZ/PGF manual, but it seems like it is not working with the image.direction statement this way.
How can I scale my scope in the right way?
