Tuesday 6 August 2019

Awk: how to convert PNG files into PDF


Here is a method to convert a bunch of PNG files into another format (here PDF). This method works under linux and uses both awk and convert commands (the conversion is made with the convert command).
The following script generates the commands that are required to perform this task. Here, we redirect the output into a shell file (runme.sh) that can be executed later on.
Some explanations:
sends a list of PNG files to awk (thanks to the pipe sign).
The substr() function (from AWK) replaces the .png extension into .pdf
The convert command does the real work, that is the conversion and accepts many optional arguments that you can play with to be more specific about the output format (size, resolution, …).

0 comments:

Post a Comment