Skip to content

Support upper-case file extensions #2683

@seisman

Description

@seisman

Description of the desired feature

Currently, PyGMT only allows lower-case file extensions like pdf and png, but doesn't support upper-case extensions like PDF or PNG. The Windows OS is case insensitive, so both lower-case and upper-case file extensions should be allowed.

import pygmt
fig = pygmt.Figure()
fig.basemap(region=[0, 10, 0, 10], frame=True)
fig.savefig("map.PNG")
---------------------------------------------------------------------------
GMTInvalidInput                           Traceback (most recent call last)
Cell In[4], line 1
----> 1 fig.savefig("map.PNG")

File pygmt/pygmt/figure.py:315, in Figure.savefig(self, fname, transparent, crop, anti_alias, show, **kwargs)
    310     if ext == "ps":
    311         raise GMTInvalidInput(
    312             "Extension '.ps' is not supported. "
    313             "Please use '.eps' or '.pdf' instead."
    314         )
--> 315     raise GMTInvalidInput(f"Unknown extension '.{ext}'.")
    316 fmt = fmts[ext]
    317 if transparent:

GMTInvalidInput: Unknown extension '.PNG'.

Are you willing to help implement and maintain this feature?

Maybe

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions