I found some solutions for full page images (here and here), but what I am trying to achieve is putting an image in a page that already has text (some headings, for example) and the image should fill all the remaining space (from the headings to the footer).
This page contains a proposed solution, but since there is no example, and what ever I tried gave me errors (Undefined control sequence. ...undbild). Here is what I tried:
\newlength{\textundbildtextheight}
\newcommand{\textundbild}[2]{
\settototalheight\textundbildtextheight{\vbox{#1}}
#1
\vfill
\begin{center}
\includegraphics[width=\textwidth,keepaspectratio=true,height=\textheight-\the\textundbildtextheight]{#2}
\end{center}
\vfill
}
\begin{document}
\chapter{Chapter 1}
\section{Section X}
\textundbild{1cm}{IMAGENAME}
...
\end{document}

calcpackage to use\settototalheightand thegraphicxpackage to use\includegraphics. – Phelype Oleinik Apr 05 '19 at 16:58