I found this answer which does exactly what I want except the fact that I can't use a caption for my figures:
Forcing subfigures to have same height and take overall X% of linewidth in LaTeX
I want two figures side by side. The problem I usually have is that they are in different sizes and that it takes alot of time to scale them manually to the same height, use the whole text width and still keep the ratio.
I tried to use this command, but it wont work as I get the error "Missing \endgroup inserted".
\resizebox{\textwidth}{!}{%
\begin{figure}[H]
\includegraphics[height=4cm,fbox]{testfigure_1.jpg}%
\caption{My figure 1}
\end{figure}
\begin{figure}[H]
\includegraphics[height=4cm,fbox]{testfigure_2.jpg}%
\caption{My figure 1}
\end{figure}
}
I have realised that I of some reason cannot put an figure enviroment within resizebox. Still I cannot solve this.
I don't know if this matter to your answers but in my code I use this to center all captions for my figures:
\usepackage[justification=centering]{caption}
Best Answer
Slightly adopted @egreg answer in given link (that now you have two figures and not sub-figures):
First compiling is slow due to figure size adjustment and figure size measurements.
Edit: For comparison the size of the figures, I copy @egreg solution from given link into my answer. As expected, the size of figures are the same (this is response to comment, that figures are not the same ...).
I also recommended to use geometry package for determining page layout (no used in above MWE).