Package: imdown
imdownimdown (pronounce "I'm down") can be used to collect images from a directory
tree and put them into a markdown file for markdown to compile to another format
usingpandoc(although I typically use pdf's so its targeted at that mainly.)installInstall from PyPI:pip install imdownor from GitHub:pip install git+https://github.com/LeSasse/imdown.gitWrite new filesTry out the exampleYou can try it out on the example provided in this repository. Go to theexampledirectory:git clone https://github.com/LeSasse/imdown.git
cd imdown/exampleCollect all images from thefiguresdirectory and put them into a markdown file:imdown figures -o markdown_files/all_filetypes.mdand see the result inmarkdown_files/all_filetypes.md.
Or filter out a specific filetype only i.e. pdf's:imdown figures -f pdf -o markdown_files/only_pdfs.mdYou can then manually adjust the markdown file and compile viapandoc.
If you do not need to adjust it and just want the pdf, you can also skip the intermediate markdown file
and pipe it straight into pandoc (of course for this you needpandocinstalled!):imdown figures -f pdf | pandoc -o output_pdfs/piped.pdfand see the result inoutput_pdfs/piped.pdf.Adjust the paths written in the markdown outputBy defaultimdownwill write all the paths relative to the directory
in which the markdown file will be written (or from current directory if the
markdown is just printed to stdout). However, you may not always like to build
your final output format from the same directory as the markdown file, so you
can specifiy-b, --build_directory, so that all paths will be written relative
from this directory:imdown figures -b . -o markdown_files/build_directory_specified.mdCheck the result inmarkdown_files/build_directory_specified.mdand you can see that the paths are relative not from the md file but from the
directory you specified (i.e. the current directory). Note that of course the
example in the repository is therefore not able to show the pictures in that
particular md file. Alternatively, you can also simply use the-a, --absoluteflag to write all paths as absolute paths.Ignore paths or filenames based on a stringYou can pass a string to the-i, --ignoreflag. If any of the paths/filenames
of the images include this string, it will be ignored.
For example:imdown figures -i analysis1will result in:![figures/analysis2/fig5.pdf](figures/analysis2/fig5.pdf)

![figures/analysis2/fig4.pdf](figures/analysis2/fig4.pdf)

![figures/analysis2/fig5.png](figures/analysis2/fig5.png)

![figures/analysis3/fig7.pdf](figures/analysis3/fig7.pdf)

![figures/analysis3/fig6.png](figures/analysis3/fig6.png)

![figures/analysis3/fig9.pdf](figures/analysis3/fig9.pdf)

![figures/analysis3/fig8.pdf](figures/analysis3/fig8.pdf)

![figures/analysis3/fig10.pdf](figures/analysis3/fig10.pdf)You can also ignore multiple strings, i.e.imdown figures -f pdf png -i analysis1 analysis2will result in:![figures/analysis3/fig7.pdf](figures/analysis3/fig7.pdf)

![figures/analysis3/fig6.png](figures/analysis3/fig6.png)

![figures/analysis3/fig9.pdf](figures/analysis3/fig9.pdf)

![figures/analysis3/fig8.pdf](figures/analysis3/fig8.pdf)

![figures/analysis3/fig10.pdf](figures/analysis3/fig10.pdf)Walk only to a certain depthYou can specify how many levels the program should walk the directory tree.
If None (default) the program will walk all the way. Specify 0 to only consider
files in the initial directory. For each level deeper add +1.
For example:imdown figures -f pdf png -d 0will output nothing, as there are no files in the initial directory.
However, specifiying one level will be enough to give the same output as the default
in this case, as the program will go one level deeper (but there are no levels beyond
this in the example).imdown figures -f pdf png -d 1Update manually adjusted markdownsNow imagine that you manually adjusted captions or text in one of the markdown files.
But you also added new plots to your directory and want to add them to you markdown or you want to include filetypes
that you did not include previously.For example considermarkdown_files/manually_adjusted.md.
This is the markdown that I created only using pdf plots. I now also want to add all
png's. I have adjusted the captions and added some text and of course I do not want to lose that text when
adding new plots. In order to do this I can provide the adjusted file as a reference file as an
additional argument and add only the new plots. For example I can test it and print the
updated version to stdout:imdown figures -f pdf png -r markdown_files/manually_adjusted.mdwhich should output:![This is a new caption](figures/analysis1/fig2.pdf)

I have also added some text.

![figures/analysis2/fig5.pdf](figures/analysis2/fig5.pdf)

![figures/analysis2/fig4.pdf](figures/analysis2/fig4.pdf)

![figures/analysis3/fig7.pdf](figures/analysis3/fig7.pdf)

![figures/analysis3/fig9.pdf](figures/analysis3/fig9.pdf)

![figures/analysis3/fig8.pdf](figures/analysis3/fig8.pdf)

![figures/analysis3/fig10.pdf](figures/analysis3/fig10.pdf)

![figures/analysis1/fig3.png](figures/analysis1/fig3.png)

![figures/analysis1/fig1.png](figures/analysis1/fig1.png)

![figures/analysis2/fig5.png](figures/analysis2/fig5.png)

![figures/analysis3/fig6.png](figures/analysis3/fig6.png)Note that this outputs all paths as relative to the current directory, since
you are printing to stdout. The advantage is that the old paths aren't just valid
from the reference file, but you can also write it to a new file, in which case
paths will be written relative from that file:imdown figures -f pdf png -o markdown_files/manually_adjusted_and_updated.md -r markdown_files/manually_adjusted.mdfor which you can find the result inmarkdown_files/manually_adjusted_and_updated.md.Of course you can also overwrite the reference file, but do that at your own risk.
Another advantage of this is, that you can take the reference file, update it with the
new plots, and pipe it straight into pandoc again, if you like:imdown figures -f pdf png -r markdown_files/manually_adjusted.md | pandoc -o output_pdfs/piped_from_reference.pdfYou can see the result atoutput_pdfs/piped_from_reference.pdf