Skip to content

psimage: Add -A to report the image width and/or height (#9256) - #9262

Open
Esteban82 wants to merge 1 commit into
masterfrom
feature-9256
Open

Esteban82 wants to merge 1 commit into
masterfrom
feature-9256

Conversation

@Esteban82

Copy link
Copy Markdown
Member

Add -A[w][h] to image/psimage to report the dimensions set by -D (keeping the aspect ratio when only a width is given) in PROJ_LENGTH_UNIT and exit without plotting, similar to mapproject -W. The values are written as a data record (key >DA, as in psbasemap -A) so external APIs can capture them, and, as with basemap -A, gmt image -A works outside a modern session.

I used -A because -W is already taken by the deprecated psimage -W<width>. If anyone prefers a different letter, it is a one-line change.

Tested with:

gmt image @USGS.png -D+w3i -Ah                          # 3.08224719101 (cm)
gmt image @USGS.png -D+w3i -A --PROJ_LENGTH_UNIT=inch   # 3	1.21348314607
gmt image @USGS.png -D+r300 -Aw                         # 1.50706666667

Fixes #9256

Implemented with Claude Code (Sonnet 5.5 for the code, reviewed with Opus 5.5).

-A[w][h] reports the dimensions set by -D (keeping the aspect ratio when only
a width is given) in PROJ_LENGTH_UNIT and exits without plotting, similar to
mapproject -W. The values are written as a data record (key >DA, as in
psbasemap -A) so external APIs can capture them. As with basemap -A, the
modern name image is accepted outside a session when -A is given.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Esteban82
Esteban82 requested review from joa-quim and seisman October 13, 2026 17:51
@Esteban82 Esteban82 added enhancement Improving an existing feature add-changelog Add PR to the changelog labels Oct 13, 2026
@Esteban82

Copy link
Copy Markdown
Member Author

@ESaltPi could you test it?

@joa-quim

Copy link
Copy Markdown
Member

Sorry, but I think this is a too trivial thing that doesn't deserve the adding one more option, document it etc...

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A method to find image height similar to mapproject -Wh

2 participants