image icon indicating copy to clipboard operation
image copied to clipboard

Add API to set `ImageReader` format by extension to support hooks

Open RunDevelopment opened this issue 1 month ago • 1 comments

Right now, plugin decoders can only be used when decoding a file. It's impossible to use them to decode arbitrary BufRead+Seek data. This is because hooks are currently only used by ImageReader and the only way to set its internal format to an extension is via ImageReader::open(&Path).

This PR solves this API limitation by adding a new set_format_with_extension method, which sets the internal format to the given extension string.

Bike shedding: I'm not sure about the name. Other options I've considered: set_format_from_extension, set_format_by_extension, set_extension.


Related to #2616

RunDevelopment avatar Nov 25 '25 23:11 RunDevelopment

Another option is to use with_format/set_format and rename the existing methods:

  • with_format -> with_builtin_format
  • set_format -> set_builtin_format

Not entirely sure how I feel about that though, since it would add a bit more churn

fintelia avatar Dec 02 '25 03:12 fintelia