Skip to content

remove_metadata/2 :xmp selector is a silent no-op, maps to wrong header name#198

Merged
kipcole9 merged 2 commits into
elixir-image:mainfrom
hlindset:fix-xmp-removal-via-atom-selector
May 31, 2026
Merged

remove_metadata/2 :xmp selector is a silent no-op, maps to wrong header name#198
kipcole9 merged 2 commits into
elixir-image:mainfrom
hlindset:fix-xmp-removal-via-atom-selector

Conversation

@hlindset

@hlindset hlindset commented May 30, 2026

Copy link
Copy Markdown
Contributor

Removing XMP via the :xmp field selector does nothing because the @metadata_fields map has a typo (xmp-dataa).

Reproduction

{:ok, base} = Vix.Vips.Operation.black(8, 8, bands: 3)
{:ok, img} =
  Vix.Vips.Image.mutate(base, fn m ->
    Vix.Vips.MutableImage.set(m, "xmp-data", :VipsBlob, "FAKE-XMP")
  end)
# attempt to remove XMP data by atom key
{:ok, a} = Image.remove_metadata(img, :xmp)
Vix.Vips.Image.header_field_names(a)
#=> {:ok,
 ["xmp-data", "filename", "yres", "xres", "yoffset", "xoffset",
  "interpretation", "coding", "format", "bands", "height", "width"]}   # XMP still present

Root cause

@metadata_fields %{
  exif: "exif-data",
  xmp: "xmp-dataa",   # <- should be "xmp-data"
  iptc: "iptc-data"
}

I added a test that asserts :exif/:xmp/:iptc removes their respective header, and fixed the typo in the @metadata_fields map.

@kipcole9 kipcole9 merged commit 6d6cef7 into elixir-image:main May 31, 2026
@kipcole9

Copy link
Copy Markdown
Collaborator

Thats sloppy of me, thank you very much for the report and the PR.

@kipcole9

Copy link
Copy Markdown
Collaborator

I've published Image v0.68.0 with the following changelog entry:

Bug Fixes

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.

2 participants