pngdriver(1grass)
π PNG DISPLAY DRIVER π
okay bestie, meet pngdriver(1grass) β the GRASS User's Manual page that's about to be your new fave. it's a PNG display driver, and it makes PNG, PPM, or BMP images. yes ma'am, three formats, one icon.
β¨ DESCRIPTION β¨
so the PNG driver takes your GRASS display commands and turns them into PNG, PPM, or BMP images β like a little art studio for your raster data π¨. Per default, PNG files are what gets written with this driver. And here's the tea: this driver is used by default if the Cairo driver is not available. so if Cairo's not in the group chat, PNG shows up instead. no cap.
πΈ USAGE πΈ
Environment variables
you can enable the PNG driver by setting the GRASS_RENDER_IMMEDIATE variable, eg.
export GRASS_RENDER_IMMEDIATE=png
Several environment variables affect the operation of the PNG driver, so let's get into it:
GRASS_RENDER_WIDTH=xxxβ the width of the image map (default is640).GRASS_RENDER_HEIGHT=yyyβ the height of the image map (default is480).GRASS_RENDER_BACKGROUNDCOLOR=RRGGBBβ specifies the background color to use in RGB notation (hex orR:G:Bvalues). Named colors are also supported, so yes you CAN just say the color's name π. Default isFFFFFF(white).GRASS_RENDER_TRANSPARENT=[TRUE|FALSE]β sets transparent background on (TRUE) or off (FALSE, default).GRASS_RENDER_TRUECOLOR=[TRUE|FALSE]β sets true-color support. Default isTRUE. it's giving full color, periodt.GRASS_RENDER_FILE=filenameβ the filename to put the resulting image in, default ismap.png. If you setGRASS_RENDER_FILEto a filename which ends in".ppm", a PPM file will be created (with alpha channel stored in a PGM image, if applicable). If you setGRASS_RENDER_FILEto a filename which ends in".bmp", a 32-bpp BMP file will be created β heads up though, these are not readable by some older viewers π.GRASS_RENDER_FILE_COMPRESSION=[0|1|9]β compression level of PNG files (0= none,1= fastest,9= best, default is6).GRASS_RENDER_FILE_READβ ifTRUE, the PNG driver will initialize the image from the contents ofGRASS_RENDER_FILE. it's reading, she's literate π.GRASS_RENDER_FILE_MAPPEDβ ifTRUE, the PNG driver will mapGRASS_RENDER_FILEas its framebuffer, rather than using memory. This only works with BMP files. iykyk.
Example
export GRASS_RENDER_IMMEDIATE=png
export GRASS_RENDER_TRUECOLOR=TRUE
g.region raster=elevation
d.rast elevation
d.vect roadsmajor color=red
This writes a file named map.png in your current directory. slay β¨
π NOTES π
The PNG driver uses the libpng (see the libpng home page) and zlib (see the zlib home page), all which needs to be installed for the PNG driver to work (it's worth it). fr fr, install them.
The resolution of the output images is defined by current region extents. Use g.region -p to get the number of rows and cols and use the environment variables to set the image size. If you would like a larger image, multiply both rows and cols by the same whole number to preserve the aspect ratio β that's the trick bestie, don't mess with the vibe of your aspect ratio π¦.
Further PNG file processing (e.g. quantization to 1 bit for monochrome images) can be done with pnmquant of the netpbm tools. cute little extra glow-up if you need it π
π₯ SEE ALSO π₯
Cairo driver, PS driver, HTML driver, variables
d.rast, d.vect, d.mon, d.erase, d.redraw
π«Ά AUTHORS π«Ά
- Original version: Per Henrik Johansen
<phj (at) norgit.no> - Rewritten by: Glynn Clements, 2003
β SOURCE CODE β
Available at: PNG DISPLAY DRIVER source code (history)
Accessed: Tuesday Sep 08 11:53:11 2026
Main index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual
okay that's the whole page π β brought to you by GRASS 8.5.0 and the pngdriver(1grass) manual, and yes, that's the manual name and the version number, we're doing the footer ourselves because we're thorough like that π. go make some pretty pictures, bestie π
π¦ where this page comes from
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms