For images I found the solution provided in this Q&A (How to crop background from image automatically?) very helpful and easy to use. Now I also want to use this for my from Matlab exported plots in the eps format. How could this be done? The code to crop images automatically looks like this (copied from the link above):
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\section*{Original image}
\fbox{\includegraphics[width=\linewidth]{image.png}}
\section*{Trimmed and clipped image}
\fbox{\includegraphics[width=\linewidth,trim=6.5cm 6cm 6.5cm 4cm,clip]{image.png}}
\section*{Automatic crop}
Note: compile with \verb|--shell-escape|\\
\newcommand\cropped[1]{%
\immediate\write18{convert -trim #1.png #1cropped.png}%
\includegraphics[width=\linewidth]{#1cropped.png}}
\fbox{\cropped{image}}
\end{document}
pdflatex --shell-escape file.tex, is it right? Error... parameter - image.png. – Bobyandbob Apr 22 '17 at 09:23printcommand instead. Something likeprint('-depsc2','filename.eps'). Theprintcommand should automatically crop the file to the contents. – Mike Renfro Apr 22 '17 at 17:02