I have an article in TeX, The following image describes what I want to achieve!
I know how TeX works "Normally" on graphics, but really this is what I want.
Thanks.

\documentclass{article}
\usepackage{graphicx,lipsum}
%--------------------------------------------------
\newsavebox\mtbox
\newcommand{\mtgraphics}[1]{%
\sbox\mtbox{\includegraphics{#1}}%
\null%
\dimen255=\dimexpr\pagegoal-\pagetotal-\baselineskip\relax%
\ifdim\dimen255>\ht\mtbox
\usebox\mtbox
\else
\dimen254=\dimen255%
\dimen255=\dimexpr\ht\mtbox-\dimen254\relax%
\includegraphics[trim=0mm 1.\dimen255 0mm 0mm, clip=true]{#1}
\par
\includegraphics[trim=0mm 0mm 0mm \dimen254, clip=true]{#1}
\fi}
%--------------------------------------------------
\begin{document}
\lipsum[1-5]
\mtgraphics{myfoto}
\end{document}
\lipsum command with normal text, the image flies to next page. (I mean how should I change my text to make it behave like \lipsum[1-5]?)
– Qaher
Jan 30 '15 at 12:44
\pagetotal is not accurate at the time you need to look) it is probably the best that can be done for the OPs requirement
– David Carlisle
Jan 30 '15 at 12:53
\includegraphicshappens, and by the time it does decide the page breaks it can not split the image. It's like asking to break the page in the middle of anX– David Carlisle Jan 30 '15 at 09:54\allowdisplaybreaks, but for graphics instead of equations! – Qaher Jan 30 '15 at 10:15\allowdisplaybreaksdoes not allow you to break in the middle of a\sumsign or other unbreakable thing, a display is a series of rows with a natural break point between them, normally amsmath explicitly prevents breaking at that point and\allowdisplaybreaksjust tells it not to do that. An image is completely different, it is like a letter: tex has absolutely no knowledge about its internal structure. – David Carlisle Jan 30 '15 at 10:56\pagetotalas in the posted answer but it does not really have the right information (it has little information about floats for example as they are added to the page later – David Carlisle Jan 30 '15 at 12:50