8

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

  • Yes it is possible. Here is an example of using a background image with opacity: Background images for code listings. We'd really have to see a MWE to figure out why what you tried did not work for you. – Peter Grill May 18 '13 at 5:03
  • @PeterGrill It is rather MNWE (minimal non working example). – Przemysław Scherwentke May 18 '13 at 5:46
  • That depends on whether Peter means the document is working, or that the error is working...:) – John Wickerson May 18 '13 at 8:03
7

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.

9

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

  • I have obtained: "! LaTeX Error: Unknown option angle=0' for package background'." 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.