# What causes the following gaps?

I have tried to remove any possible white spaces by appending % but the gaps still exist. What causes these gaps?

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=.5]{example-grid-100x100pt}}

\begin{document}
\begin{pspicture}(2\wd\IBox,2\ht\IBox)%
\rput[bl](0,0){\usebox\IBox}%
\rput[bl](\wd\IBox,0){\psscalebox{-1 -1}{\usebox\IBox}}%
\rput[bl](\wd\IBox,\ht\IBox){\psscalebox{1 -1}{\usebox\IBox}}%
\rput[bl](0,\ht\IBox){\psscalebox{-1 1}{\usebox\IBox}}%
\end{pspicture}
\end{document}


-

The bounding box info for the image says 0 0 100 100, so the image is 100bp high. The default resolution for dvips is 600dpi; scaling to 50% makes for 416.66667 pixels, truncated to 416.

The height of the image is computed by TeX to be 50.1875pt, which is the same, but apparently EPS inclusion truncates, while rule positioning rounds. So if I compile

% arara: latex
% arara: dvips
% arara: ps2pdf

\documentclass[border=12pt]{standalone}
\usepackage{graphicx,picture}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=.5]{example-grid-100x100pt}}

\begin{document}
\fboxsep=0pt
\fbox{\usebox{\IBox}}
\the\ht\IBox
\end{document}


% arara: latex
% arara: dvips: { options: "-D 10000" }
% arara: ps2pdf

\documentclass[border=12pt]{standalone}
\usepackage{graphicx,picture}
\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=.5]{example-grid-100x100pt}}

\begin{document}
\fboxsep=0pt
\fbox{\usebox{\IBox}}
\the\ht\IBox
\end{document}


I get a better filling at the top, worse on the side.

If I pass the EPS image through eps2eps so a hires bounding box is computed, I get in example-grid-100x100pt-hires.eps the prolog

%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 100 100
%%HiResBoundingBox: 0.000000 0.000000 99.600000 99.600000


Now the input

% arara: latex
% arara: dvips
% arara: ps2pdf

\documentclass[border=12pt]{standalone}
\usepackage{graphicx,picture}
\newsavebox\IBox
\savebox\IBox{\includegraphics[hiresbb,scale=0.5]{example-grid-100x100pt-hires}}

\begin{document}
\fboxsep=0pt
\fbox{\usebox{\IBox}}
\the\ht\IBox
\end{document}


produces

No gap and the height is computed correctly.

-
Does \includegraphics use hiresbb by default? – kiss my armpit Dec 3 '13 at 20:15
@DonutE.Knot No: if you notice, the "good" example uses the key hiresbb – egreg Dec 3 '13 at 20:16
So, when do we need to use hiresbb? Is it a best practice to always use hiresbb? – kiss my armpit Dec 3 '13 at 20:18
@DonutE.Knot If the EPS file has no HiResBoundingBox information it's useless. – egreg Dec 3 '13 at 20:23
What option did you pass to eps2eps to avoid getting rastered output? – kiss my armpit Dec 4 '13 at 1:45

This doesn't seem to have anything to do with pstricks. This seems to have to do with the image you're importing.

Try the following:

\documentclass[pstricks,border=12pt,12pt]{standalone}

\usepackage{graphicx}
\newsavebox\IBox
\setlength{\fboxrule}{4pt}
\setlength{\fboxsep}{0pt}
\savebox\IBox{\fbox{\includegraphics[scale=5.5]{example-grid-100x100pt}}}

\begin{document}
\begin{pspicture}(2\wd\IBox,2\ht\IBox)%
\rput[bl](0,0){\usebox\IBox}%
%    \rput[bl](\wd\IBox,0){\psscalebox{-1 -1}{\usebox\IBox}}%
%    \rput[bl](\wd\IBox,\ht\IBox){\psscalebox{1 -1}{\usebox\IBox}}%
%    \rput[bl](0,\ht\IBox){\psscalebox{-1 1}{\usebox{\IBox}}}%
\end{pspicture}
\end{document}


From the output, it seems pretty clear that the white space you're getting is from the image itself that you're importing.

-
+1: I am waiting for other responses if any. – kiss my armpit Dec 3 '13 at 5:04