Skip to main content

Running gimp in batch mode to convert SVG to PNG files

  • strict warning: Non-static method view::load() should not be called statically in /var/www/vhosts/litzastark.com/sites/all/modules/views/views.module on line 906.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /var/www/vhosts/litzastark.com/sites/all/modules/views/handlers/views_handler_argument.inc on line 744.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /var/www/vhosts/litzastark.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 607.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /var/www/vhosts/litzastark.com/sites/all/modules/views/handlers/views_handler_filter.inc on line 607.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /var/www/vhosts/litzastark.com/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 159.
  • strict warning: Non-static method view::load() should not be called statically in /var/www/vhosts/litzastark.com/sites/all/modules/views/views.module on line 906.
  • strict warning: Declaration of views_handler_filter_node_status::operator_form() should be compatible with views_handler_filter::operator_form(&$form, &$form_state) in /var/www/vhosts/litzastark.com/sites/all/modules/views/modules/node/views_handler_filter_node_status.inc on line 13.
  • strict warning: Declaration of views_plugin_style_default::options() should be compatible with views_object::options() in /var/www/vhosts/litzastark.com/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 24.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /var/www/vhosts/litzastark.com/sites/all/modules/views/plugins/views_plugin_row.inc on line 134.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /var/www/vhosts/litzastark.com/sites/all/modules/views/plugins/views_plugin_row.inc on line 134.

Years ago for the NCCP website, I needed to generate charts that would appear as vector graphics (in PDF files) and as raster graphics (in PNG's).

The best solution at the time -- it may not be so any more -- was to write my own library of graph-drawing functions that generated SVG files, then run the GIMP in batch mode to convert those images to PNG files. (I know... I had a lot of time on my hands.)

That was all configured back in 2006/7, and has been running smoothly ever since. Then our server crashed, and I've been stuck trying to recreate the environment from the old server. Just in case (g-d forbid) that should ever happen again, here's what it took to get the SVG-to-raster conversion working again:

  • Installed GIMP (simple, using up2date)
  • At this point I ran into trouble because GIMP has to run once in GUI mode for the current user before it can be run from the command line. A very helpful Rackspace tech did this for me as root and copied the settings directory from /root to /var/www so that it would work when apache was running.
  • I then realized that the command I was using -- svg-to-raster -- was not built in to GIMP, but a custom function. It needed to be downloaded here and configured and run according to those directions.

All in all, it didn't take long to get up and running, but it could have been much more painful!