1

I have been struggling for a while trying to insert png figures. I want to use powerdot so I should go through latex->dvi->ps->pdf.

The following did work until my last update

\includegraphics[width=0.3\textwidth,bb=0 0 401 337]{DipoloSmoot.png}

No errors in LaTeX - dvips but in the ps2pdf step

I am using a MikTeX installation on Windows 10:

>>> pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9 64-bit)
(preloaded format=latex 2016.8.6)
>>> dvips.exe -Ppdf "test_powerdot_png.dvi"
This is dvips(k) 5.996 Copyright 2016 Radical Eye Software
(www.radicaleye.com) *' TeX output 2016.08.06:1831' -> test_powerdot_png.ps

>>> "C:\Program Files\gs\gs9.19\bin\gswin64c.exe" -q -dSAFER -dNOPAUSE
-dBATCH -sOutputFile="test_powerdot_png.pdf" -sDEVICE=pdfwrite -c
-setpdfwrite -f "test_powerdot_png.ps"
...
Last OS error: No such file or directory
GPL Ghostscript 9.19: Unrecoverable error, exit code 1

Please forgive my inexperience, I don't know how to upload log and relevant files. Any hint? Thank you in advance

Surfing around I see things similar to mine:

How to configure WinEdt/MikTeX/ps2pdf to use a new version of Ghostscript when converting ps->pdf?
which seems to be solved in the current MikTeX distribution.

However none of the solutions solves the problem.

  • dvips tries to use emtex special for bitmap images. But I think that is not always successful. It is better to convert bitmap images to eps files before the latex: for example, magick DipoloSmoot.png DipoloSmoot.eps

    \includegraphics[width=0.3\textwidth]{DipoloSmoot.eps}

    – Akira Kakuto Aug 07 '16 at 23:39
  • But the message No such file or directory may suggest other problem in your case. – Akira Kakuto Aug 07 '16 at 23:49
  • @AkiraKakuto: good to learn that dvips calls some other piece of tex, thanks. I will investigate in that direction. If the ps from bitmap is produced on the flight and it doesn't work, that may explain the No such file or directory . – Francesco Aug 09 '16 at 12:55
  • I realized looking at the .dvi file that the .png was not converted anymore to .eps. I obtained the previous behaviour by including \DeclareGraphicsRule{.png}{eps}{.bb}{``convert #1 eps:-} after having installed ImageMagick®. – Francesco Aug 12 '16 at 11:58
  • Was the conversion once made by the MikTeK environment? Has the default behaviour changed? – Francesco Aug 12 '16 at 12:03
  • I don't know about MikTeX. Did you add an option -shell-escape (or -enable-write18 ?) ? Anyway, convert DipoloSmoot.png DipoloSmoot.eps before running latex must be OK without touching the \DeclareGraphicsRule. – Akira Kakuto Aug 12 '16 at 14:26
  • If you use the convert command, be sure that there is the image magick binary directory before the c:\windows\system32 in the PATH. The magick command in the recent image magick may be safer than the convert command. – Akira Kakuto Aug 12 '16 at 14:37
  • @AkiraKakuto: indeed converting .png to .eps before works. Also the \DeclareGraphicsRule works, setting the option -R0 in dvips.exe. Thank you for flagging the issue about convert, I checked it uses ImageMagick. With your suggestions this problem has been solved. I am still wondering how and why the behaviour changed but this is irrelevant now! – Francesco Aug 13 '16 at 21:10
  • Still not happy with the conversion, as the size in pixels of the .eps filsize was different from the original .png one, I found necessary to give the option -density 72x72 -units PixelsPerInch to the convert command: \DeclareGraphicsRule{.png}{eps}{.bb}{\convert #1 -density 72x72 -units PixelsPerInch eps:-}. Typo corrected: single backtick beforeconvert`. – Francesco Aug 19 '16 at 20:53

1 Answers1

1

After having installed ImageMagick®:

  • either convert images beforehand, as indicated by Akira KaKuto:

    > convert DipoloSmoot.png DipoloSmoot.eps
    

before running latex.

  • or insert in your tex file:

    \DeclareGraphicsRule{.png}{eps}{.bb}
    {`convert #1 -density 72x72 -units PixelsPerInch eps:-}
    

Depending on which program created the .png file, you may need to use the convert option -density 72x72 -units PixelsPerInch, in both cases.