9

Is it possible to use a PNG image as a background, but with selected opacity? It seems to me that standard solutions found here can not change opacity of PNG...

I assume, that in the following one of the flags should be near transparent (taken from Includegraphics: set image opacity):

\documentclass{article}
\usepackage{lipsum}

\usepackage{graphicx}
\usepackage{transparent}
\usepackage{eso-pic}

\begin{document}

\transparent{0.01}\includegraphics[width=0.5\textwidth]{it.png}
\medskip

\transparent{0.99}\includegraphics[width=0.5\textwidth]{it.png}

\end{document}

but the result is:

enter image description here

where it.png is

enter image description here

2 Answers2

8

As a fan of both tikz and background, here's a version showing four different opacities:

Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=5mm,a6paper]{geometry}
\usepackage[angle=0,scale=20,opacity=1,color=black]{background}

\usepackage{lipsum}

\backgroundsetup{%
    contents={%
        \begin{tikzpicture}
            \pgfmathsetmacro{\myopacity}{mod(\thepage-1,4)*0.25+0.25}
            \node[opacity=\myopacity] {\includegraphics[scale=1]{avatar.png}};
        \end{tikzpicture}
    }
}

\begin{document}

\lipsum

\end{document}

Output

enter image description here

Tom Bombadil
  • 40,123
  • I have obtained: "! LaTeX Error: Unknown option angle=0' for packagebackground'." and so on. :-( – Przemysław Scherwentke May 18 '13 at 17:33
  • @PrzemysławScherwentke: Which version do you use? I used the v2.0 natation, which is not compatible with v1.0. There you used \SetBgContents{} \SetBgColor{} \SetBgAngle{} \SetBgOpacity{} \SetBgScale{} \SetBgPosition{} \SetBgAnchor{} \SetBgHshift{} \SetBgVshift{}. Either change to the old syntax or upgrade to v2.0 (if that is the problem). – Tom Bombadil May 18 '13 at 19:23
8

You just have to run pdflatex twice for the transparency to kick in for your original tex source. The package actually prints out a message to say that when you run it the first time.