Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controlling image size #65

Open
Fabian188 opened this issue Oct 28, 2019 · 7 comments
Open

Controlling image size #65

Fabian188 opened this issue Oct 28, 2019 · 7 comments

Comments

@Fabian188
Copy link

I guess this is not a bug but an inability from my side, but after hours trying I still did not succeed the slightest step in controlling the size of images for .epub

Can someone please provide a full example of
a) controlling the size of images relatively to the pagewidth
b) placing two or three images side by side

Thank you very much!

@michal-h21
Copy link
Owner

HI Fabian,

there was recently issue with the Graphics package update that broke the tex4ht image support. It should be fixed in the up-to date TeX Live distribution. When you use the width parameter for the \includegraphics command, it should always include the calculated image dimensions. Without explicit image size, it will be included in the full size. It is best to generate a .xbb file for the image using the command

 ebb -x imagename

This way the dimensions will be generated always.

See this example:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\includegraphics[width=0.4\textwidth]{example-image.jpg}
\includegraphics[]{example-image.jpg}
\end{document}

It will generate this HTML when the example-image.xbb is present:

<!--l. 5--><p class="noindent" ><img 
src="example-image.jpg" alt="PIC"  
width="137" height="103"  /> <img 
src="example-image.jpg" alt="PIC"  
width="401" height="301"  /> </p> 

An example of subfigures that should work:

\documentclass{article}
\usepackage{graphicx}
\usepackage{subfigure}
\begin{document}

\includegraphics[]{example-image.jpg}

\begin{figure}[ht]
\subfigure[]{
\includegraphics[width=0.4\textwidth]{example-image.jpg}
\label{fig:motion/coordprob.a}}
\subfigure[]{
\includegraphics[width=0.4\textwidth]{example-image.jpg}
\label{fig:motion/coordprob.down}}
\subfigure[]{
\includegraphics[width=0.4\textwidth]{example-image.jpg}
\label{fig:motion/coordprob.down}}
\caption{\label{fig:motion/coordprob}(a) Coordinate system with $y$
measured positive upward from the ground. (b) The force diagram
for upward motion. (c) The force diagram for downward
motion.}
\end{figure}
\end{document}

Note that it also depends on the reader how it will display that. It is quite possible that if it has a poor CSS support, it will display the subfigures wrongly.

@Fabian188
Copy link
Author

Thanks a lot, the ebb -x changed a lot!! It works for some cases out of the box, the others need to be investigated.

@michal-h21
Copy link
Owner

@Fabian188 sure, feel free to make a MWE that shows the issues :)

@Fabian188
Copy link
Author

My pdfs (e.g. the ones generated by gnuplot) have a transparent background, I guess this comes from the following command

rungs -q -dNOPAUSE -dBATCH -sDEVICE=pngalpha -r300 -sOutputFile='plots/fan-crop-.png' plots/fan-crop.pdf
Is there a way to make white background instead of alpha? I'm trying to fix it via convert but probably this is easier in the first place. On mac my default epub-reader is Apple's Books which has dark background when the system is running in dark mode.

@michal-h21
Copy link
Owner

The Ghostscript configuration for PDF can be configured using `\Configure{PdfConvert}. This is the default value:

\Configure{PdfConvert}{png}{"rungs -q -dNOPAUSE -dBATCH -dusecropbox -sDEVICE=pngalpha -r300 \ifx\Gin@page\@empty\else -dFirstPage="\Gin@page"  -dLastPage="\Gin@page"\fi\space -sOutputFile="\Gin@base-\[email protected]" "\[email protected]" "}

You can change it according your needs.
You will probably need to use \makeatletter before it in the configuration file, otherwise you can get missing csname errors.

@Fabian188
Copy link
Author

Thanks for the response, I'll follow the way the next edition.

My figures are fine now with the same latex file for pdflatex and for epub. I use the following simple form

\begin{figure}[ht!]
\centering
\includegraphics[width=0.45\textwidth]{pic1.jpg} ,
\includegraphics[width=0.45\textwidth]{pic2.jpg}
\caption{This is a caption}
\end{figure}

However, for mobi, all figures with more than one graphics are smaller than half the page width. For a single graphics mobi looks as epub and I'm fine (just the centering is ignored but that is ok). The result looks like as having halved the width in the multi graphics case.

I use Kindle Previewer 3 on a Mac. I get the same (in Previewer) when converting the epub with Kinde Previewer. When converting the epub to mobi with Calibre, all figures (single and multiple graphics) are not wider than the "Figure x.y:" in the caption.

I know, the ultimage approach is to create new figures out of the single ones, but maybe someone knowns a better workarorund?

Thanks!

@michal-h21
Copy link
Owner

This may be an issue in Kindle, I think it doesn't support full CSS, so it may be hard to achieve what you want. Maybe some info can be found in Kindle publishing guidelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants