Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to draw a thick red X over an image from a PNG file, as a part of a Tikz picture. How can this be done? The documentation regarding external images in PGF is a bit vague.

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

Place the image in a node and use the node anchors to draw the cross

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz} 

\begin{document}

\begin{tikzpicture}
  \node (img) {\includegraphics{foo.png}};
  \draw[red, line width=1mm] 
    (img.south west) -- (img.north east)
    (img.south east) -- (img.north west);
\end{tikzpicture}

\end{document}
share|improve this answer
    
Thanks! I tried to do the same using \pgfuseimage, but apparently it does not get the bounding box right. –  Little Bobby Tables Apr 17 '11 at 10:44
    
You can modify the extend to which the lines are going beyond the image using either the inner sep or outer sep option for the image \node. For example: inner sep=0pt,outer sep=0pt will make the cross exactly the size of the image. –  Martin Scharrer Apr 17 '11 at 11:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.