TransWikia.com

Conversion problem using standalone and imagemagick

TeX - LaTeX Asked by Mazzy on March 7, 2021

I’m trying to convert a table to png format using Imagemagick

documentclass[12pt,a4paper,border=8pt,convert=true]{standalone}

usepackage{booktabs}
usepackage{caption}
usepackage{siunitx}
sisetup{binary-units = true,
         table-format=7.0}

begin{document}

    minipage{1.08textwidth}
    addtolength{tabcolsep}{-1.0pt}
    begin{tabular}{lS[table-format=6.0]
            S[table-format=6.0]
            S[table-format=6.0]
            SSS}
        toprule
        Device & 2011 & 2012 & 2013 & 2014 & 2015 & 2016 
        midrule
        Non-smarthphones & 22686 & 55813 & 108750 & 196262 & 357797 & 615679 
        Smarthphones & 104759 & 365550 & 933373 & 1915173 & 3257030 & 5221497 
        Laptops e Netbooks & 373831 & 612217 & 917486 & 1340062 & 1963950 & 2617770
        Tablets & 17393 & 63181 & 141153 & 300519 & 554326 & 1083895
        Home gateways & 55064 & 108073 & 180562 & 267545 & 376494 & 514777 
        M2M & 23009 & 47144 & 92150 & 172719 & 302279 & 508022 
        Altri devices & 525 & 1460 & 5429 & 22966 & 84204 & 242681
        bottomrule
    end{tabular}
    captionof*{table}{Traffico mobile globale al mese per dispositivo in si{terabyte}}
    endminipage

end{document}

Here it is the table create using standalone package. I read the documentation and it says to use ImageMagick. The problem is when I compile it doesn’t find the exacutable imgconvert.exe. So I put this exacutable into folder where there is tex file. Now when I compile I got another error:

imgconvert.exe: `%s' (%d) "gswin32c.exe" -q -dQUIET -dSAFER -dBATCH -dNOPAUSE 
-dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=2 
"-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r300x300" 
"-sOutputFile=C:/Users/MAZZAR~1/AppData/Local/Temp/magick-31681PKeFVHE065o" 
"-fC:/Users/MAZZAR~1/AppData/Local/Temp/magick-3168A-Fab6j3iIUc" 
"-fC:/Users/MAZZAR~1/AppData/Local/Temp/magick-3168QXzuvG_UAP07" 
@ error/utility.c/SystemCommand/1890. imgconvert.exe: Postscript delegate failed 
`table.pdf': No such file or directory @ error/pdf.c/ReadPDFImage/678.
imgconvert.exe: no images defined `table.png' @ error/convert.c/ConvertImageCommand/3066.

3 Answers

For some reasons, I too get the same error and was never able to use standalone directly for conversion (I am on windows). It is because the name of the executable is simply convert.exe whereas the standalone searches for imgconvert.exe. :-( I just took a copy of convert.exe and renamed it as imgconvert.exe and put it back in the installation folder of imagemagick. Then your code works fine.

If it is not working for you, then the most possible reason (as is evident from your error report) is the imgconvert.exe is not in the system's path as a result of which it is not found. Try to add it to your system path or reinstall imagemagick (while doing that it will ask you whether you want to add it to the path).

Here is another method to get png files. But for this also convert.exe (here only convert.exe) must be in system's path. Otherwise this won't work!

(Compile with pdflatex):

documentclass{article}
usepackage{filecontents}
begin{filecontents*}{mytable.tex}
  documentclass[12pt,a4paper,border=8pt,convert=true]{standalone}

usepackage{booktabs}
usepackage{caption}
usepackage{siunitx}
sisetup{binary-units = true,
         table-format=7.0}

begin{document}

    minipage{1.08textwidth}
    addtolength{tabcolsep}{-1.0pt}
    begin{tabular}{lS[table-format=6.0]
            S[table-format=6.0]
            S[table-format=6.0]
            SSS}
        toprule
        Device & 2011 & 2012 & 2013 & 2014 & 2015 & 2016 
        midrule
        Non-smarthphones & 22686 & 55813 & 108750 & 196262 & 357797 & 615679 
        Smarthphones & 104759 & 365550 & 933373 & 1915173 & 3257030 & 5221497 
        Laptops e Netbooks & 373831 & 612217 & 917486 & 1340062 & 1963950 & 2617770
        Tablets & 17393 & 63181 & 141153 & 300519 & 554326 & 1083895
        Home gateways & 55064 & 108073 & 180562 & 267545 & 376494 & 514777 
        M2M & 23009 & 47144 & 92150 & 172719 & 302279 & 508022 
        Altri devices & 525 & 1460 & 5429 & 22966 & 84204 & 242681
        bottomrule
    end{tabular}
    captionof*{table}{Traffico mobile globale al mese per dispositivo in si{terabyte}}
    endminipage
end{document}  
end{filecontents*}
% compile with pdflatex
immediatewrite18{pdflatex --shell-escape mytable}
% convert to PNG
makeatletter
immediatewrite18{convert -density 500 -alpha on mytable.pdf [email protected]}
makeatother
%
begin{document}
Check the folder for your verb|mytable-00.png| file.
end{document}

Your code is in between begin{filecontents*} and end{filecontents*}. You must have imagemagick installed and the executable should be in the system path for this to work.

Answered by user11232 on March 7, 2021

First, about the trouble with the executable name:

convert is also the MS tool for FAT to NTFS conversion of hard disk drives, therefore the recommendation is to rename Image Magick's convert.exe to imgconvert.exe. In order not to be blamed for any data loss due to my standalone package (even if this is very unlikely) I put the default executable name to imgconvert. This can be change using the convert={convertexe={convert.exe}} class option. This all is also described in detail in the standalone manual.

I would recommend Windows users to either rename or copy the convert.exe file to imgconvert.exe or change the standalone.cfg file to include:

 standaloneconfig{convert={convertexe={convert.exe},false}}

Now to the error message you get:

I tried this under Windows and found out that it depends on the version of Image Magick. With v6.6.9 I get the same error. Here it doesn't matter if it is called from standalone or manually from the command line. However with v6.8.1 I just downloaded today from here it works without any issues (after selecting the right executable name as mentioned above). It seems there is an issue with PDF using v6.6.9 and maybe other versions after it before v6.8.1.

Therefore the fix for your problem is to update Image Magick. If this doesn't fix your issue, or if you already have v6.8.1 installed, then please post the used version number here. Also try to convert it manually using the command line convert.exe -density 300 file.pdf -quality 90 file.png. If this also throws the same error it isn't an issue with standalone but only with ImageMagick.

Answered by Martin Scharrer on March 7, 2021

The error message tells you that "gswin32c.exe" cannot be found. Install Ghostscript and the problem should be resolved.

Answered by Henning on March 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP