Avogadro Molecule Editor: How to render image from command line?

Given a molecular geometry in the .xyz file format, how can I use Avogadro on the command line to render an image of it?


The website states that there is some command line API available, but I can't seem to find any documentation/information about it. Alternatively, are there any other molecular visualization tools that provide a convenient command line interface for image rendering of .xyz files?




There is no way to currently do this using Avogadro, although Python bindings have been "in the works" for a while. The problem is, with volunteer developers, there's not always enough free time to tackle all features.


You can create pseudo-3D images using Open Babel. I developed this for the [Pitt Quantum Repository](http://pqr.pitt.edu/) to give SVG and PNG images in the search interface. It's not perfect, but I like the effect.



```
obabel beta-carotene.xyz -O beta-carotene-2d.svg -xS -xd -xb none

```

[![enter image description here](https://i.stack.imgur.com/aYrGQ.png)](https://i.stack.imgur.com/aYrGQ.png)


The `-xS` indicates this 3D "ball and stick" style, `-xd` prevents the molecule name from being included, and `-xb none` gives transparent background to the SVG (useful for presentations).


 5

If what you want is a simple 2D structure, [OpenBabel can do it for you](https://openbabel.org/docs/dev/FileFormats/PNG_2D_depiction.html).
Say you have a structure named `beta-carotene.xyz`:


[![beta-carotene.xyz](https://i.stack.imgur.com/fDr2c.png)](https://i.stack.imgur.com/fDr2c.png)


The following command issues a 2D depiction of the above:



```
$ obabel beta-carotene.xyz -O beta-carotene-2d.png -xp 600 -x0 molfile

```

[![beta-carotene-2d.png](https://i.stack.imgur.com/Fm0Wa.png)](https://i.stack.imgur.com/Fm0Wa.png)


 3