In this section we will see how the m4cm.py script can be used to automate the creation of loose standing EPS, PDF, PNG and JPG pictures. In order to use this script however, some additional programs, over and above those installed in Part I, is required.
- The first is obviously the Python interpreter, or more specifically the Python 3 interpreter. This can be downloaded from the official Python website here, https://www.python.org/downloads/
- The second program required is Ghostscript. The Python script uses it to obtain the bounding box of the dvips generated Postscript (.PS) picture, in order to convert it into an Encapsulated Postscript (.EPS) picture. Ghostcript can be downloaded here, https://www.ghostscript.com/download/gsdnld.html
- The third program required is ImageMagick. The Python script will use it to convert the Encapsulated Postscript (.EPS) picture into a Joint Photographic Experts Group (.JPG) or Portable Network Graphics (.PNG) format if the “-j” or “-n” option respectively is selected with the m4cm script. ImageMagick can be downloaded here, https://imagemagick.org/script/download.php
Some help with the script can be obtained by running the script with either “-h” or “–help”, e.g.
$ m4cm -h
usage: M4CM [-h] [-a [APPEND_CHARS]] [-b L B R T] [-d] [-e] [-g] [-j] [-n]
[-o [OUTPUT_DIR]] [-p] [-q] [-Q] [-r [PNG_RESOLUTION]]
[-t [LATEX_TEMPLATE_FILE]] [-v] [M4CM_FILE [M4CM_FILE …]]
Instead of "M4CM_FILE", it is also possible to use "*.m4cm" to compile all the ".m4cm" files in the current folder
positional arguments: M4CM_FILE M4CM File to be compiled
optional arguments:
-h, --help show this help message and exit
-a [APPEND_CHARS], --append [APPEND_CHARS]
Character/String to append to the end of the output file(s)
-b L B R T, --boundingbox_offset L B R T the BoundingBox Offset: left
offset point value, top offset point value, right offset point value,
bottom offset point values, the default is: 1 1 1 1, i.e. 1pt in each
direction
-d, --delete_eps delete EPS file after converting to PNG or PDF
-e, --eps convert to EPS format [default option]
-g, --ghostscript use GhostScript to convert to PNG format
-j, --jpg convert to JPG format
-n, --png convert to PNG format
-o [OUTPUT_DIR], --output_dir [OUTPUT_DIR] the Output Directory for the
EPS/PDF/PNG/JPG output files
-p, --pdf convert to PDF format
-q, --quiet run quietly, but print progress
-Q, --super_quiet run quietly with no output
-r [PNG_RESOLUTION], --resolution [PNG_RESOLUTION] PNG or JPG resolution
(or density)
-t [LATEX_TEMPLATE_FILE], --template [LATEX_TEMPLATE_FILE]
LaTeX template file to be used [default="default.ltx"]
-v, --version show program's version number and exit
In order to create standalone PDF/JPG/PNG figures for M4 Circuit Macros
