Skip to content

psconvert: gs options passed via -C doesn't override internally hardcoded options  #8982

@uliw

Description

@uliw

Edit by @seisman: The issue was initially reported to the PyGMT repository, but it turns out to be an GMT issue, so I transferred it here.

To reproduce the issue in the GMT CLI, try the following:

gmt psbasemap -R0/10/0/10 -JX10c -Baf > map.ps
gmt psconvert map.ps -C-dMaxBitmap=2000000 -S

The output is

gs -q -dNOPAUSE -dBATCH -dNOSAFER -dSCANCONVERTERTYPE=2 -dMaxBitmap=2000000 -dMaxBitmap=2147483647 -dUseFastColor=true -dGraphicsAlphaBits=2 -dTextAlphaBits=4 -sDEVICE=jpeg -dJPEGQ=90 -g2480x3509 -r300 -sOutputFile='map.jpg' './psconvert_3324091d.eps'

Description of the problem

Specifying ghostcript options in the figure command like this:

fig.savefig("foo.pd",
            gs_option="-dMaxBitmap=2000000,
            ) 

will pass the option to the ghopstcript process. However it will do so in front of the default values, so that the custom options are nullified.

Minimal Complete Verifiable Example

I only noticed because the psconvert step fails with an error. If this can be traced without creating a ginormous plot file, the above commands should be sufficient.

Full error message

pygmt.exceptions.GMTCLibError: Module 'psconvert' failed with status code 79:
psconvert [ERROR]: System call [gs -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=20000000000, -dMaxBitmap=2147483647 -dUseFastColor=true '/home/uliw/.gmt/sessions/gmt_session.25132/gmt_1.ps-' 2> '/home/uliw/.gmt/sessions/gmt_session.25132/psconvert_25132c.bb'] returned error 256.

System information

PyGMT information:
  version: v0.18.0
System information:
  python: 3.14.3 | packaged by conda-forge | (main, Feb  9 2026, 21:56:02) [GCC 14.3.0]
  executable: /home/uliw/miniforge3/envs/p314/bin/python
  machine: Linux-6.19.2-1-default-x86_64-with-glibc2.42
Dependency information:
  numpy: 2.4.3
  pandas: 3.0.2
  xarray: 2026.2.0
  packaging: 26.0
  contextily: None
  geopandas: 1.1.3
  IPython: None
  pyarrow: None
  rioxarray: None
  gdal: 3.12.3
  ghostscript: 10.07.0
GMT library information:
  version: 6.6.0
  padding: 2
  share dir: /home/uliw/miniforge3/envs/p314/share/gmt
  plugin dir: /home/uliw/miniforge3/envs/p314/lib/gmt/plugins
  library path: /home/uliw/miniforge3/envs/p314/lib/libgmt.so
  cores: 32
  grid layout: rows
  image layout: 
  binary version: 6.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions