# Some issues with post-processing of included graphics #939

Closed
opened this issue Feb 3, 2018 · 5 comments
Labels
Milestone

### asmaier commented Feb 3, 2018

 The output of the following example document including two graphics (the EPS can be freely downloaded from https://www.freepik.com/index.php?goto=74&idfoto=762099) shows some problems with the post-processing of images in LaTeXML: \documentclass[12pt,a4paper,twoside]{book} \usepackage{graphicx} \begin{document} \begin{figure}[t] \centering \includegraphics[width=0.8\linewidth]{Sheet-of-paper-with-grid/04.eps} \includegraphics[trim=0 0 400 400, width=0.8\linewidth, clip]{Sheet-of-paper-with-grid/04.eps} \end{figure}  Using pdflatex the output looks like Using LaTeXML like $latexml testgraphics.tex --dest=testgraphics.xml$ latexmlpost --format=html5 --javascript='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=MML_CHTML' --dest=testgraphics.html testgraphics.xml  the output looks like I see three issues here: Obviously the colors don't fit. This might be due to issues with transparency in the EPS file. The width=0.8\linewidth parameter seems to be ignored or handled differently. With pdflatex this causes the image to take 80% of the width of the text. So the second image ends up below the first image. This doesn't happen with LaTeXML. When I add a third image it will also show up at the side and not below the other images. The parameters for trim seem to be interpreted differently by LaTeXML. The size of the image is 800x800 points, so trim=0 0 400 400 should crop the lower left quadrant of the image. But the area cropped by latexmlpost is smaller than that. Maybe latexmlpost doesn't use points as default units as pdflatex does? For the test I had installed the latest version of LaTeXML on Mac OS 10.12.6 via brew install https://raw.githubusercontent.com/matteosecli/homebrew-core/patch-1/Formula/latexml.rb --HEAD  My versions of the software were $latexml --VERSION latexml (LaTeXML version 0.8.2; revision f48d643)$ convert -version Version: ImageMagick 7.0.7-22 Q16 x86_64 2018-02-01 
added the label Feb 3, 2018
added this to the LaTeXML-0.8.4 milestone Feb 4, 2018
added the label Feb 4, 2018

### brucemiller commented Feb 4, 2018

 Issue (1) seems due to transparency; I now check if the image already has a transparent color set. The result is better, perhaps, but still kind of iffy (perhaps for other reasons?) Issue(2) is a bit tricky; \linewidth is understood, but it isn't setting the image size to 80% (tricky to preserve the relative size). And the flow (linewrap) isn't handled quite the same way as LaTeX would, with fixed width page at run time. I'm going to defer on this for now. Issue(3) the trim (& clip) needed to be handled in points relative to the image's own resolution, even though we're magnifying the image slightly. So, this is all (mostly) fixed. Thanks for the report!
closed this Feb 4, 2018

### asmaier commented Feb 6, 2018 • edited

 Thank you for solving the issue (3) about trim. Now it works as expected. But issue (1) doesn't seem to be fixed. In my tests I still don't see the correct colors. However using imagemagick on the commandline I saw, that the problem might be due to the CMYK colorspace of the EPS file. To convert that file one has to use -colorspace sRGB instead of -colorspace RGB to get the correct colors. For issue(2) I found some kind of a workaround. To make sure the second image will show up below the first image in the HTML produced by latexmlpost one has have one \figure environment for each \includegraphics like \documentclass[12pt,a4paper,twoside]{book} \usepackage{graphicx} \begin{document} \begin{figure}[t] \centering \includegraphics[width=0.8\linewidth]{Sheet-of-paper-with-grid/04.eps} \end{figure} \begin{figure}[t] \centering \includegraphics[trim=0 0 400 400, width=0.8\linewidth, clip]{Sheet-of-paper-with-grid/04.eps} \end{figure} 

### brucemiller commented Feb 6, 2018

 Yeah, as I said the "fix" for (1) doen't quite do it. In fact, I just discovered it seems to be mangling the colors of some of my images. Thanks for the clue; it may be that the colorspace is the issue.
reopened this Feb 6, 2018

### brucemiller commented Feb 7, 2018

 OK, I think (hope!) this is fixed now. Thanks again;
closed this Feb 7, 2018

### asmaier commented Feb 8, 2018

 I can confirm issue (1) is fixed now. Thank you very much.
modified the milestones: LaTeXML-0.8.4, LaTeXML-0.8.3 Feb 25, 2018