I'm writing a book in LaTeX. I want to put a page-filling .png figure behind every 'Part_X' frontpage and every 'Chapter_X' frontpage. The page-filling .png picture is different for every Part and Chapter. Here is an example of what it should look like:
Here is some simplified LaTeX code that should put 'testFig_01.png' behind the 'Part_1' frontpage, and 'testFig_02.png' behind the 'Chapter_01' frontpage:
\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage{wallpaper}
% Book's title and subtitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{
\Huge \textbf{FreeRTOS} \\
\huge The internal mechanisms explained}
% Author
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\author {
\textsc{Kristof Mulier}
\thanks{\url{www.sirris.be}}
}
% I want to put the figure 'testFig_01.png' as
% the background of the Part I frontpage.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Source: http://tex.stackexchange.com/questions/94878/page-background-color-for-part
\usepackage{xpatch}
%
\xpatchcmd{\part}{\thispagestyle{plain}}
{\ThisCenterWallPaper{1}{./testFig_01}\thispagestyle{plain}}{}{}
\xpatchcmd{\@endpart}{\vfil\newpage}{\vfil\newpage
\pagecolor{white}}{}{}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% FRONTMATTER %%
%% ------------- %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frontmatter % Turns off chapter numbering
% and uses roman numerals for
% page numbers.
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% MAINMATTER %%
%% ------------ %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\mainmatter % Turns on chapter numbering,
% resets page numbering and
% uses arabic numerals for page numbers.
%%%%%%%%%%%%%%%%
%% CHAPTER_01 %%
%%%%%%%%%%%%%%%%
\part{My first part}
% I want to put 'testFig_02.png' as the
% background of the Chapter 1 frontpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Documentation overview}
\ThisCenterWallPaper{1}{./testFig_02}
\clearpage
\section{Section heading}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \\ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \\ Lorem ipsum list:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% BACKMATTER %%
%% ------------ %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\backmatter % Turns off chapter numbering and
% doesn't fiddle with page numbering.
\chapter{Back}
A word to say goodbye.
\end{document}
Unfortunately, the LaTeX code shown above only puts 'testFig_01' behind the 'Part_1' frontpage, but not 'testFig_02' behind the frontpage of 'Chapter_01'. Strangely, I noticed that commenting out the code for placing 'testFig_01' behind 'Part_01' will allow 'testFig_02' to be drawn behind 'Chapter_01':
% COMMENTED OUT:
% I want to put the figure 'testFig_01.png' as
% the background of the Part I frontpage.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \usepackage{xpatch}
%
% \xpatchcmd{\part}{\thispagestyle{plain}}
% {\ThisCenterWallPaper{1}{./testFig_01}\thispagestyle{plain}}{}{}
% \xpatchcmd{\@endpart}{\vfil\newpage}{\vfil\newpage
% \pagecolor{white}}{}{}
It looks like LaTeX won't allow me to use the \ThisCenterWallPaper{..} command several times to put background images in my document.
What should I do?

\partbackgroundimageand another one\setpartbackgroundimage. Why do you define two new commands? – K.Mulier May 31 '16 at 19:02\partbackgroundimagewould be defined, I have to use\renewcommand\partbackgroundimage{<image>}to change the image on part pages. But I want to avoid\renewcommands in the document body. – esdd Jun 01 '16 at 07:11