Skip to content

Instantly share code, notes, and snippets.

@emleddin
Last active August 16, 2023 14:17
Show Gist options
  • Save emleddin/2c08e5c76f7b10e6aa3904f4fb1151f9 to your computer and use it in GitHub Desktop.
Save emleddin/2c08e5c76f7b10e6aa3904f4fb1151f9 to your computer and use it in GitHub Desktop.
Common Image Needs -- VMD, PowerPoint, and ImageMagick

Higher-Quality Images

TIFFs are great because they retain image layers (which makes them decently editable). PNGs offer lossless compression and allow you to have transparent backgrounds. JPEGs/JPGs are lossy and have their uses, but you're better off avoiding them if you can.

Saving Powerpoint Images with Higher Resolution

PNGs exported from PowerPoint have 72 DPI resolution, which is not ideal for publication. Instead, export the image file as a PDF. Then, use ImageMagick to convert it with 600 DPI resolution (or whatever your goal is).

convert -density 600 in.pdf out.png

Slow Down VMD Gif

You can find out how fast the GIF currently plays with:

identify -verbose in.gif | grep Delay

Generally for VMD, this is 4x100.

You can then change the speed (and make it loop) with:

convert -delay 20x100 in.gif -loop 0 out-slow.gif

Transparency in VMD with POV-Ray

You can use POV-Ray to render images with a transparent background. POV-Ray works best with Diffuse and the AO-type materials (AOChalky, AOShiny, and AOEdgy). Other types, like Transparent need substantially more processing power and time to render.

The default render command, povray +W%w +H%h -I%s -O%s.tga +D +X +A +FT, can be improved up with a few simple additions. Add a 0 onto both the width and height commands for increasing the canvas size, and thus the resolution. The default resolution is the same as the window size at 72 DPI. The addition of +UA to the command adds an alpha channel for the background (making it transparent). Removing the .pov extension from the filename will make the final image output have the correct extension, instead of .pov.tga (etc.).

  • For TGA output: povray +W%w0 +H%h0 -I%s -O%s.tga +X +A +FT +UA
  • For PNG output: povray +W%w0 +H%h0 -I%s -O%s.png +X +A +FN +UA

Transparency in VMD with TachyonLOptiXInternal (GPU-Only)

Tachyon is a gorgeous renderer for VMD, with shorter processing times than POV-Ray. That said, the exact same settings can yield a different image result than POV-Ray! Tachyon is optimized for the AO

You can get transparency for Tachyon images when using an output file format that supports transparency (e.g., TGA or PNG) and a VMD version of 1.9.4 or above. However, the regular Tachyon renderer may not support transparency--it depends on the configuration at install. That's why I like TachyonLOptiXInternal.

Entering set env(VMDOPTIXWRITEALPHA) 1 into the VMD command line will allow background transparency.

Since you can't specify a size (that I've found) for this option, a work-around is to use VMD in text-only mode with a canvas size much larger than your monitor would allow, thus getting the high-DPI result. You can then create the images with a pre-made visualization state file through:

$ vmd -dispdev text -e my-system-vis.vmd -size 4800 4800
> set env(VMDOPTIXWRITEALPHA) 1                                                 
> render TachyonLOptiXInternal my-system-vis.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment