[Tex/LaTex] how to remove the background for png picture

backgroundspngtikz-pgf

I would like to make the background transparent. In Texmaker, if I right-click on the TikZ picture, I can save it as a png image as follows

enter image description here

If I save this picture, I get the white background. Is there a way to remove it?

\documentclass[border=10pt,tikz]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,fit,arrows.meta, positioning}
\usepackage{graphicx}
\usetikzlibrary{calc}

\begin{document}

\begin{tikzpicture}[auto,node distance=3cm,>={Stealth[width=4mm, length=6mm, fill=red]}]
\coordinate (O) at (5,0);


\draw [very thick,fill=green,fill opacity=.2] 
(-4, 4) circle (2.0cm) node [fill opacity=1]{\textbf{A}};

\end{tikzpicture}

\end{document}

Best Answer

The problem is very likely the use of transparency (option fill opacity). The following examples used opaque colors, the lightgreen is achieved by mixing green with white:

\documentclass[border=10pt,tikz]{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \draw [very thick,fill=green!20!white]
  (-4, 4) circle (2.0cm) node {\textbf{A}};
\end{tikzpicture}

\end{document}

This file can be converted to a PNG file, where the background is transparent:

Result

The PNG image was converted via ghostscript, full command line of the conversion:

$ gs -sDEVICE=pngalpha -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -dUseFastColor=true -dPDFSETTINGS=/prepress -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r216x216 -sOutputFile=test.png -ftest.pdf