# TikZ: Using current length inside scope environment

Following this answer: Drawing on an image with TikZ, I'm using

\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{some_image.jpg}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\end{scope}
\end{tikzpicture}


to draw over an image. This (inside the scope environment) reescales the coordinates of both the x and y axis to match the borders of the image (y = 0 is the lower border and y = 1 the upper border of the image). I want to use these new reescaled lengths in a command like \node[inner sep = 0.5]

The 0.5 will default to 0.5pt, while I may want to use the lengths in which the x or the y axis are given. Is there any simple way in which I can obtain this length and then use it in a node command? I'm looking for something that would look as \node[inner xsep = \xlength, inner ysep = \ylength]

You can use

\path(1,1);\pgfgetlastxy{\xlength}{\ylength}


inside the scope.

Example:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0pt] (image) at (0,0) {\includegraphics[width=0.9\textwidth]{example-image}};
\begin{scope}[x={(image.south east)},y={(image.north west)}]
\path(1,1);\pgfgetlastxy{\xlength}{\ylength}
\node[
inner xsep=.25*\xlength,
inner ysep=.25*\ylength,
draw=green,
line width=4mm,
fill=orange,
opacity=.2
] at (.25,.25){};
\node[
inner xsep=.5*\xlength,
inner ysep=.5*\ylength,
draw=purple,
line width=4mm,
opacity=.2
] at (.5,.5){};
\end{scope}
\end{tikzpicture}
\end{document}


results in

• From the docs: \pgfgetlastxy{\macrox}{\macroy} "Stores the most recent used (x,y) coordinates into two macros" – Nister Dec 6 '16 at 15:12