# How import png image from directory as nodes using nested for loop

Is it possible to generate separate and edited png files from a directory using a (nested) for loop? I have a directory of png files and I want to annotate each one individually and then export them as png files with the annotation. I just simply want to annotate with a number or a letter. This is what I tried so far, but it does not do what I desire.

\documentclass[border=1,convert]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc,positioning}

\begin{document}
\begin{tikzpicture}
\node[inner sep=2pt] (origin) at (0,0) {};
\foreach \x in {2,...,5,A,B,C,D,E}{
\foreach \i in {2,4,6,8,10,12,14,16,18,20}{

\node[inner sep=2pt,right=\i of origin] {\includegraphics[scale=.2] {./\x image.png} node[above] {\x}};
}
}

\end{tikzpicture}
\end{document}

• You've put them all in the same picture. Is that what you want? You need a separate node for the label either a new \node or a label. Writing node in a node will produce a node containing the text node. – cfr Aug 16 '17 at 1:50
• Actually no, I don't want them all in the same picture, but that was the limit of my knowledge. I wanted to see first whether the for loop was working. – Spencer Trinh Aug 16 '17 at 1:51
• So what are you asking? Which step are you on? What do you want from an answer to this question exactly? – cfr Aug 16 '17 at 1:52
• Also, you are including each image many times with different labels, so every image gets every label once. Is that needed? – cfr Aug 16 '17 at 1:54
• I would like to import each png image separately, then annotate it, then export it to a directory with that annotation in png format – Spencer Trinh Aug 16 '17 at 1:55

The following code puts an annotation below each of the three sample images, example-image-a, example-image-b and example-image-c and exports each image-with-annotation to <jobname-n>.png where n takes the values 0, 1 and 2.
\documentclass[border=0pt,tikz,convert]{standalone}

You don't need the count unless you want to use it. I just wanted to put something in the annotations.