benjajaja / ratatui-image

Ratatui widget for rendering image graphics in terminals that support it
https://crates.io/crates/ratatui-image
MIT License
96 stars 14 forks source link

`image` dependency features #13

Closed Riolku closed 7 months ago

Riolku commented 8 months ago

As of right now, ratatui_image uses the default features for image. This is a good default, but it would be nice to be able to disable certain formats. Specifically, I don't care about OpenEXR, but it eats up a lot of my dependency tree.

Any thoughts on an easy way to do this? Realistically, ratatui_image only cares that image exists, not what features are enabled, right? Could we just enable none of them, and have users add image as a dependency with the extra features if they want the formats? Or is that bad UX?

benjajaja commented 8 months ago

I really like this, but I don't know how to do this!

For now I have changed it to image = { version = "0.24.5", default-features = false, features = ["gif", "jpeg", "png", "webp", "pnm", "tga", "tiff", "bmp"] } which seems to reduce the deps a tiny bit, at least.

Riolku commented 8 months ago

Can't you use no features, along with default features off?

Riolku commented 8 months ago

I can test stuff and file a PR in a few hours, if you like.

benjajaja commented 8 months ago

I tried with no features, but then it panics when opening any image :laughing:

So you need to include the formats you want to support. I just don't know how to "delegate" this to the consumer.

Riolku commented 8 months ago

What if ratatui had a feature that was on by default that enabled all the default features of image, but if you turn that feature off, you could control the formats manually? We would need a section in the README about this.

benjajaja commented 8 months ago

I'm all for this, but I really don't know how to let the user of this crate specify the features of a dependency. But it sounds like something common that should have a solution.

Riolku commented 8 months ago

I'll look into it later and let you know how it goes - thanks for looking into it!

deifactor commented 7 months ago

I believe that feature unification means that depending on no features of image will let API users specify features by adding their own image dependency.