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}


showframeis only for orientation about page layout (that you see, how the figures are fit in text width) and in real use you had to remove them! Use\fbox{...}is up to you, if you liked to have, i will not use it. The image is not more compressed as in @egreg answer (their appearance is copied from there), however the presented image is (cut-off from a screen) is smaller and maybe you have visual impression for this. Also I use default width of text. Put the both solution in the same page and then compare again. – Zarko Apr 25 '16 at 07:43