GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Figure.image: Add the parameter 'invert' for option -I by seisman · Pull Request #4089 · GenericMappingTools/pygmt

Conversation

@seisman

@seisman seisman commented Sep 15, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Alias -I option to invert and also sort parameters based on #4285.

Upstream docs: https://docs.generic-mapping-tools.org/6.5/image.html#i

Preview: https://pygmt-dev--4089.org.readthedocs.build/en/4089/api/generated/pygmt.Figure.image.html

Related to #4263

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman seisman added this to the 0.17.0 milestone Sep 15, 2025
@seisman seisman added enhancement Improving an existing feature needs review This PR has higher priority and needs review. labels Sep 15, 2025
yvonnefroehlich
yvonnefroehlich reviewed Sep 15, 2025
View reviewed changes
Comment thread pygmt/src/image.py
Comment on lines +73 to +75
invert
Invert 1-bit image before plotting, i.e., black pixels (on) becomes white (off)
and vice versa. Ignored if used with color images.

@yvonnefroehlich yvonnefroehlich Sep 15, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, just trying this and maybe I am missing something here. I thought the remote raster image "vader1.png" is such a 1-bit image (see the last example at https://docs.generic-mapping-tools.org/dev/image.html#examples), but using I=True does not flip the black and white pixels as expected:

import pygmt

fig = pygmt.Figure()
fig.basemap(region=[-5, 5] * 2, projection="X3c/1c", frame=0)

fig.image(imagefile="@vader1.png", position="jLM")
fig.image(imagefile="@vader1.png", position="jMC", bitcolor=["gray+f", "blue+b"])
fig.image(imagefile="@vader1.png", position="jRM", I=True)  # Does not do something
# fig.image(imagefile="@vader1.png", position="jRM", bitcolor=["black+f", "white+b"])

fig.show()
image_invert

Same for

gmt image @vader1.png -I -png image_I_gmt
image_I_gmt

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Sep 15, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, it looks like an upstream bug.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@yvonnefroehlich yvonnefroehlich Sep 15, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it with the gmt dev version, and still no inverted colors. Thus, I wrote an issue report at GenericMappingTools/gmt#8795.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Dec 10, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upstream bug has been fixed.

I've added a note in the docstrings.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@yvonnefroehlich yvonnefroehlich mentioned this pull request Sep 15, 2025
-I of image does not invert the colors of a 1-bit image GenericMappingTools/gmt#8795
Closed
@seisman seisman removed the needs review This PR has higher priority and needs review. label Sep 16, 2025
@seisman
seisman marked this pull request as draft September 16, 2025 14:04
@seisman seisman removed this from the 0.17.0 milestone Sep 17, 2025
@seisman seisman added the upstream Bug or missing feature of upstream core GMT label Sep 17, 2025
@seisman seisman added this to the 0.18.0 milestone Sep 18, 2025
@seisman
seisman force-pushed the image/invert branch from 196f51b to 40b3933 Compare December 10, 2025 03:29
@seisman
Figure.image: Add the alias 'invert' for option -I
22ac054
@seisman
seisman force-pushed the image/invert branch from 40b3933 to 22ac054 Compare December 10, 2025 03:30
@seisman seisman removed the upstream Bug or missing feature of upstream core GMT label Dec 10, 2025
@seisman
seisman marked this pull request as ready for review December 10, 2025 03:53
@seisman seisman added the needs review This PR has higher priority and needs review. label Dec 10, 2025
@seisman seisman changed the title Figure.image: Add the alias 'invert' for option -I Figure.image: Add the parameter 'invert' for option -I Dec 10, 2025
@seisman seisman mentioned this pull request Dec 10, 2025
Figure.image: Plot raster or EPS images #4263
Closed
15 of 18 tasks
@seisman seisman removed the needs review This PR has higher priority and needs review. label Dec 11, 2025
@seisman
seisman marked this pull request as draft December 11, 2025 01:55
@seisman
Merge branch 'main' into image/invert
d10b5bd
@seisman
seisman requested a review from yvonnefroehlich December 17, 2025 03:30
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Dec 17, 2025
@seisman
Merge branch 'main' into image/invert
7060979
@seisman
seisman marked this pull request as ready for review December 17, 2025 03:31
@seisman
Sort common parameters
a398a28
michaelgrund
michaelgrund approved these changes Dec 17, 2025
View reviewed changes
Comment thread pygmt/src/image.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@seisman @michaelgrund
Fix a typo [skip ci]
21665a0
Co-authored-by: Michael Grund <[email protected]>
@seisman
seisman merged commit 216a00c into main Dec 18, 2025
@seisman
seisman deleted the image/invert branch December 18, 2025 00:21
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@michaelgrund michaelgrund michaelgrund approved these changes
@yvonnefroehlich yvonnefroehlich Awaiting requested review from yvonnefroehlich

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement Improving an existing feature

Projects

None yet

Milestone

0.18.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@seisman @michaelgrund @yvonnefroehlich
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.