Skip to content

improve gflags argument handling #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 24, 2025
Merged

Conversation

jcupitt
Copy link
Member

@jcupitt jcupitt commented Jul 24, 2025

Allow array values for GFlags types.

With this PR, ruby like this works:

$ VIPS_TRACE=1 irb
irb(main):001> require 'vips'
=> true
irb(main):002> x = Vips::Image.black 10, 10
irb(main):003> x.pngsave "x.png", keep: [:icc, :xmp]
vips cache*: cast in=((VipsImage*) 0x63d8ec4851c0) out=((VipsImage*) 0x63d8ecc90770) format=((VipsBandFormat) VIPS_FORMAT_UCHAR) shift=FALSE -
vips cache : copy in=((VipsImage*) 0x63d8ecc90770) out=((VipsImage*) 0x63d8eca264f0) -
vips cache+: cast in=((VipsImage*) 0x63d8eca264f0) out=((VipsImage*) 0x63d8ec583ca0) format=((VipsBandFormat) VIPS_FORMAT_UCHAR) -
vips cache+: colourspace in=((VipsImage*) 0x63d8eca264f0) out=((VipsImage*) 0x63d8ec47f0e0) space=((VipsInterpretation) VIPS_INTERPRETATION_B_W) -
vips cache : pngsave in=((VipsImage*) 0x63d8ec4851c0) filename="x.png" keep=((VipsForeignKeep) VIPS_FOREIGN_KEEP_XMP | VIPS_FOREIGN_KEEP_ICC) -
=> nil

You can see the two flags have bee set correctly in the last line of the trace.

These forms also work:

image.pngsave "x.png", keep: :icc
image.pngsave "x.png", keep: "icc xmp"
image.pngsave "x.png", keep: ["icc", "xmp"]
image.pngsave "x.png", keep: [1 << 3, 1 << 1]

I've not added doc classes for the various flag types, they can come in a follow-up PR.

Something like:

module Vips
  # Savers can be given a set of metadata items to keep.
  #
  # *   `:none` remove all metadata
  # *   `:exif` keep EXIF metadata
  # *   `:xmp` keep XMP metadata
  # *   `:iptc` keep IPTC metadata
  # *   `:icc` keep ICC profiles
  # *   `:other` keep other metadata

  class ForeignKeep < Symbol
  end
end

See #359

@jcupitt jcupitt merged commit baa3123 into master Jul 24, 2025
22 checks passed
@jcupitt jcupitt deleted the improve-gflags-argument-handling branch July 24, 2025 14:58
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.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy