Difference between revisions of "Png"

From PyMOLWiki
Jump to navigation Jump to search
(→‎USAGE: updated with additional parameters)
(→‎DPI Setting: updated to account for integrated width, height, and ray arguments)
Line 25: Line 25:
  
 
====DPI Setting====
 
====DPI Setting====
Use the DPI option to have PyMol set the DPI of your image.  If I execute
+
Use the DPI option to have PyMol set the DPI of your image.  Executing the command
<source lang="python">ray 1200,1200</source>
+
<source lang="python">png /tmp/ex.png, width=1200, height=1200, dpi=300, ray=1</source>
then execute
+
will ouput a four-inch square image at 300dpi.  Leaving off the '''dpi''' parameter would yield a 1200x1200 image at your system's default pixel density (e.g. 72 or 96 dpi).  This saves the intermediate step of having to use GIMP/PhotoShop/etc to rescale your photos for publication.
<source lang="python">png /tmp/ex.png, dpi=300</source>
 
I will get a four-inch square image at 300dpi.  Leaving off the '''dpi''' flag would net me a 1200x1200 image at 72dpi.  This saves the intermediate step of having to use GIMP/PhotoShop/etc to rescale your photos for publication.
 
  
 
[[Category:Commands|Png]]
 
[[Category:Commands|Png]]
 
[[Category:Publication_Quality|Png]]
 
[[Category:Publication_Quality|Png]]
 
[[Category:Performance|Png]]
 
[[Category:Performance|Png]]

Revision as of 13:11, 5 June 2014

png writes a png format image file of the current image to disk.

USAGE

png filename[, width[, height[, dpi[, ray[, quiet]]]]]
  • filename = string: file path to be written
  • width = integer or string: width in pixels (integer or string without units), inches (in), or centimeters (cm). If unit suffix is given, `dpi` argument is required as well. If only one of `width` or `height` is given, the aspect ratio of the viewport is preserved. {default: 0 (current)}
  • height = integer or string: height (see width) {default: 0 (current)}
  • dpi = float: dots-per-inch {default -1.0 (unspecified)}
  • ray = 0 or 1: should ray be run first {default: 0 (no)}
  • quiet = 0 or 1: if 1, logged output is suppressed. {default: 0}

PYMOL API

cmd.png(string filename, int width=0, int height=0, float dpi=-1, int ray=0, int quiet=0)

COMMENTS

Blank Screen Shots

If, when you execute the Png command, you get blank images, you may have to Ray trace your image first, before running the Png command. This occurs when there is no device context for the image, such as when running PyMOL in quiet gui-less mode. If the ray tracing is taking too long due to scene complexity or size, then please see the Ray page or search the wiki for information about making movies with PyMOL (there are many ways to speed up rendering).

Transparent Backgrounds

See Ray_opaque_background. This is very useful for presentations, or images that are placed on top of a background of nonuniform color, or if you simply want a transparent background for your images.

DPI Setting

Use the DPI option to have PyMol set the DPI of your image. Executing the command

png /tmp/ex.png, width=1200, height=1200, dpi=300, ray=1

will ouput a four-inch square image at 300dpi. Leaving off the dpi parameter would yield a 1200x1200 image at your system's default pixel density (e.g. 72 or 96 dpi). This saves the intermediate step of having to use GIMP/PhotoShop/etc to rescale your photos for publication.