# Why does \renewcommand not overwrite \includegraphics from tikzscale?

I have the following tex code

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tikz}
\usepackage{tikzscale}
\usepackage{filecontents}
\usepackage{graphicx}

\renewcommand{\includegraphics}[2][]{%
\setlength{\fboxsep}{-\fboxrule}%
\framebox{\rule{0pt}{0.6\linewidth}\rule{\linewidth}{0pt}}%
}

\begin{document}

\begin{filecontents}{tikzpicture.tikz}
\begin{tikzpicture}
\draw (0,0) grid (3,3);
\foreach \c in {(0,0), (1,0), (2,0), (2,1), (1,2)}
\fill \c + (0.5,0.5) circle (0.42);
\end{tikzpicture}
\end{filecontents}

\begin{figure}[ht]
\includegraphics[width=\linewidth]{tikzpicture.tikz}
\end{figure}

\end{document}


The \renewcomand overwrites the \includegraphics and replaces all my pixel images with frameboxes for faster compile time during document writing. However the images with a .tikz extension still get loaded.

As far as I understand it tikzscale overwrites the \includegraphics from graphicx and I overwrite it with my definition. Why does this not work? Is there a way to make it work?

• Thats a nice way of speeding up document creation! Especially when \tikzexternalize doesn´t work. – Paul Paulsen Jun 22 '16 at 7:42

The package tikzscale delays its redefinition of \includegraphics at begin document, so you should do
\AtBeginDocument{%