Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jcupitt
Copy link
Member

@jcupitt jcupitt commented Dec 6, 2025

_get_gainmap() implied a safe getter, like _get_width(), but this function can modify the image and needs to be treated with care.

Rename as vips_image_prepare_gainmap().

_get_gainmap() implied a safe getter, like _get_width(), but this
function can modify the image and needs to be treated with care.

Rename as vips_image_prepare_gainmap().
@jcupitt
Copy link
Member Author

jcupitt commented Dec 6, 2025

I added a tiny thing (disabled in release mode) to warn if an image you call _prepare_gainmap() on is a shared pointer. The tests seem to run cleanly.

@jcupitt
Copy link
Member Author

jcupitt commented Dec 6, 2025

... we'll need to update the release notes too, of course.

@kleisauke
Copy link
Member

I added a tiny thing (disabled in release mode) to warn if an image you call _prepare_gainmap() on is a shared pointer. The tests seem to run cleanly.

Great idea! I've generalized it in PR #4783 so that any metadata changes on a shared image trigger a warning.

it's better to test all metadata changes
@kleisauke
Copy link
Member

On further thought, what if we remove vips_image_set_image() from vips_image_get_gainmap()? Most callers update the gainmap anyway. This would also allow NetVips to expose the .Gainmap property on Image class rather than MutableImage.

kleisauke added a commit to kleisauke/libvips that referenced this pull request Dec 6, 2025
`_get_gainmap()` now fully transfers ownership of the returned
gainmap image to the caller, who is responsible for managing
its lifecycle and setting the `"gainmap"` metadata.

Supersedes: libvips#4782.
@kleisauke
Copy link
Member

... I just opened PR #4784 as an alternative.

@jcupitt jcupitt merged commit 3bd591d into master Dec 6, 2025
16 checks passed
@jcupitt jcupitt deleted the rename-get_gainmap-to-prepare_gainmap branch December 6, 2025 14:01
@jcupitt
Copy link
Member Author

jcupitt commented Dec 6, 2025

Ah sorry, I didn't realize it was either/or, I should have waited.

jcupitt added a commit that referenced this pull request Dec 6, 2025
jcupitt added a commit that referenced this pull request Dec 6, 2025
@jcupitt jcupitt restored the rename-get_gainmap-to-prepare_gainmap branch December 6, 2025 14:11
jcupitt pushed a commit that referenced this pull request Dec 6, 2025
`_get_gainmap()` now fully transfers ownership of the returned
gainmap image to the caller, who is responsible for managing
its lifecycle and setting the `"gainmap"` metadata.

Supersedes: #4782.
@jcupitt jcupitt deleted the rename-get_gainmap-to-prepare_gainmap branch December 6, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants