Set the size of pgf picture?
Maybe simply \scalebox
:
\documentclass{article}
\usepackage{fontspec} % enagles loading of OpenType fonts
\usepackage{polyglossia} % support for languages
% fonts:
\defaultfontfeatures{Scale=MatchLowercase,Mapping=tex-text} % without this XeLaTeX won't turn "--" into dashes
\setmainfont{DejaVu Sans}
\setsansfont{DejaVu Sans}
\setmonofont{DejaVu Sans Mono}
% pgf:
\usepackage{pgf}
\begin{document}
\scalebox{0.6}{\input{m1.pgf}}
\end{document}
You can first draw a phantom to determine the sizes, compute the scaling factor(s) and draw the image again:
Code
\documentclass[a5paper]{scrreprt}
\usepackage{xifthen}
\usepackage{environ}
\usepackage{tikz}
\pgfmathsetmacro{\maximumpicturewidth}{10}% max width in cm
\pgfmathsetmacro{\maximumpictureheight}{5}% max height in cm
\newcommand{\getxyscale}
{ \path (current bounding box.south west);
\pgfgetlastxy{\xsw}{\ysw}
\path (current bounding box.north east);
\pgfgetlastxy{\xne}{\yne}
\pgfmathsetlengthmacro{\picwidth}{\xne-\xsw}
\pgfmathsetlengthmacro{\picheight}{\yne-\ysw}
\pgfmathsetlengthmacro{\maxpicwidth}{\maximumpicturewidth*28.453}
\pgfmathsetlengthmacro{\maxpicheight}{\maximumpictureheight*28.453}
\pgfmathsetmacro{\xscale}{\maxpicwidth/\picwidth}
\pgfmathsetmacro{\yscale}{\maxpicheight/\picheight}
\xdef\xscalefactor{\xscale}
\xdef\yscalefactor{\yscale}
}
\NewEnviron{autoscaletikz}%
{\noindent\hphantom{\vphantom{\begin{tikzpicture}\BODY\getxyscale\end{tikzpicture}}}%
\noindent\begin{tikzpicture}[xscale=\xscalefactor,yscale=\yscalefactor]\BODY\end{tikzpicture}}
\begin{document}
\begin{autoscaletikz}
\fill[red] (0,0) circle (5 and 1);
\fill[draw=black,left color=blue, right color=orange] (0.5,0) rectangle (4,2);
\draw (2,-1) rectangle (18,1);
\draw (4,-0.5)
\foreach \x in {1,...,12}
{ arc ({mod(\x,4)*90}:{(mod(\x,4)+1)*90}:{\x/10})
} ;
\end{autoscaletikz}
\end{document}
If you want to keep the aspect ratio, simply change the environment:
\NewEnviron{autoscaletikz}%
{\noindent\hphantom{\vphantom{\begin{tikzpicture}\BODY\getxyscale\end{tikzpicture}}}%
\noindent\begin{tikzpicture}[xscale=\xscalefactor,yscale=\xscalefactor]\BODY\end{tikzpicture}}