Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pygmt/src/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def image(
imagefile: PathLike,
projection=None,
box: Box | bool = False,
invert: bool = False,
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
| bool = False,
panel: int | tuple[int, int] | bool = False,
Expand All @@ -35,6 +36,7 @@ def image(

{aliases}
- F = box
- I = invert
- J = projection
- V = verbose
- c = panel
Expand Down Expand Up @@ -68,6 +70,9 @@ def image(
to make those pixels transparent. Can be repeated with different
settings. Alternatively, for color images you can select a single
*color* that should be made transparent instead (**+t**).
invert
Invert 1-bit image before plotting, i.e., black pixels (on) becomes white (off)
and vice versa. Ignored if used with color images.
Comment on lines +73 to +75
Copy link
Member

@yvonnefroehlich yvonnefroehlich Sep 15, 2025

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

Copy link
Member Author

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.

Copy link
Member

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.

monochrome : bool
Convert color image to monochrome grayshades using the (television)
YIQ-transformation.
Expand All @@ -80,6 +85,7 @@ def image(

aliasdict = AliasSystem(
F=Alias(box, name="box"),
I=Alias(invert, name="invert"),
).add_common(
J=projection,
V=verbose,
Expand Down
Loading