I have created a pic with TikZ 3.0 that includes an \includegraphics statement, and a label above a path with the arguments [sloped, above, midway].
The intention of the pic is to reuse it in other parts of my code. At times, I want to rotate the entire pic. However, the graphic and the label are unaffected.
Here is an MWE:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzset{
testpic/.pic={
\node at (3,0) {\includegraphics[width=1cm] {Rock.png}};
\draw (0,0) -- (1,1) node [midway, sloped, above] {test};
}
}
\begin{tikzpicture}
\pic[rotate=90] {testpic};
\end{tikzpicture}
\end{document}
Here is the output:

As you can see, the rock is not rotated by 90 degree. It is intended that it is also rotated, as if I specified \includegraphics[angle=90]. The label above the path is also not rotated.
How can this be fixed?
Asset:

